-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #218 from ZenVoich/cli/global-cache-install-resolve
install/resolve via global cache
- Loading branch information
Showing
11 changed files
with
133 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import {copyCache, getDepCacheName} from '../../cache.js'; | ||
import {getDependencyType, getRootDir} from '../../mops.js'; | ||
import {resolvePackages} from '../../resolve-packages.js'; | ||
|
||
export async function syncLocalCache({verbose = false} = {}) : Promise<Record<string, string>> { | ||
let resolvedPackages = await resolvePackages(); | ||
let rootDir = getRootDir(); | ||
|
||
verbose && console.log('Syncing local cache...'); | ||
|
||
let installedDeps : Record<string, string> = {}; | ||
|
||
await Promise.all(Object.entries(resolvedPackages).map(([name, value]) => { | ||
let depType = getDependencyType(value); | ||
|
||
if (depType === 'mops' || depType === 'github') { | ||
let cacheName = getDepCacheName(name, value); | ||
let dest = path.join(rootDir, '.mops', cacheName); | ||
|
||
if (!fs.existsSync(dest)) { | ||
if (depType === 'mops') { | ||
installedDeps[name] = value; | ||
} | ||
return copyCache(cacheName, path.join(rootDir, '.mops', cacheName)); | ||
} | ||
} | ||
|
||
return Promise.resolve(); | ||
})); | ||
|
||
return installedDeps; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import {getDependencyType} from './mops.js'; | ||
import {mainActor} from './api/actors.js'; | ||
import {resolvePackages} from './resolve-packages.js'; | ||
|
||
export async function notifyInstalls(names : string[]) { | ||
let resolvedPackages = await resolvePackages(); | ||
let packages : [string, string][] = names.map(name => [name, resolvedPackages[name] as string]); | ||
export async function notifyInstalls(installedDeps : Record<string, string>) { | ||
let packages = Object.entries(installedDeps).filter(([_, version]) => getDependencyType(version) === 'mops'); | ||
if (packages.length) { | ||
let actor = await mainActor(); | ||
await actor.notifyInstalls(packages.filter(([_, version]) => getDependencyType(version) === 'mops')); | ||
|
||
try { | ||
await actor.notifyInstalls(packages); | ||
} | ||
catch (err) { | ||
// verbose && console.error('Failed to notify installs:', err); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.