-
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.
- Loading branch information
Showing
12 changed files
with
143 additions
and
115 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 was deleted.
Oops, something went wrong.
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,32 @@ | ||
import path from 'node:path'; | ||
import {installFromGithub} from '../../vessel.js'; | ||
import {installMopsDep} from './install-mops-dep.js'; | ||
import {Dependency} from '../../types.js'; | ||
import {installLocalDep} from './install-local-dep.js'; | ||
|
||
type InstallDepOptions = { | ||
verbose ?: boolean; | ||
silent ?: boolean; | ||
threads ?: number; | ||
}; | ||
|
||
// install dependency | ||
// returns false if failed | ||
export async function installDep(dep : Dependency, {verbose, silent, threads} : InstallDepOptions = {}, parentPkgPath ?: string) : Promise<Record<string, string> | false> { | ||
if (dep.repo) { | ||
await installFromGithub(dep.name, dep.repo, {silent, verbose}); | ||
return {}; | ||
} | ||
else if (dep.path) { | ||
let depPath = dep.path; | ||
if (parentPkgPath) { | ||
depPath = path.resolve(parentPkgPath, dep.path); | ||
} | ||
return installLocalDep(dep.name, depPath, {silent, verbose}); | ||
} | ||
else if (dep.version) { | ||
return installMopsDep(dep.name, dep.version, {silent, verbose, threads}); | ||
} | ||
|
||
return {}; | ||
} |
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,31 @@ | ||
import {Dependency} from '../../types.js'; | ||
import {installDep} from './install-dep.js'; | ||
|
||
type InstallDepsOptions = { | ||
verbose ?: boolean; | ||
silent ?: boolean; | ||
threads ?: number; | ||
}; | ||
|
||
// install all dependencies | ||
// returns actual installed dependencies | ||
// returns false if failed | ||
export async function installDeps(deps : Dependency[], {verbose, silent, threads} : InstallDepsOptions = {}, parentPkgPath ?: string) : Promise<Record<string, string> | false> { | ||
let installedDeps = {}; | ||
let ok = true; | ||
for (const dep of deps) { | ||
let res = await installDep(dep, {verbose, silent, threads}, parentPkgPath); | ||
if (res) { | ||
installedDeps = {...installedDeps, ...res}; | ||
} | ||
else { | ||
ok = false; | ||
} | ||
} | ||
|
||
if (!ok) { | ||
return false; | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import process from 'node:process'; | ||
import path from 'node:path'; | ||
import {createLogUpdate} from 'log-update'; | ||
import {getRootDir, readConfig} from '../../mops.js'; | ||
import {installDeps} from './install-deps.js'; | ||
|
||
type InstallLocalDepOptions = { | ||
verbose ?: boolean; | ||
silent ?: boolean; | ||
}; | ||
|
||
// skip install and just find non-local dependencies to install | ||
// pkgPath should be relative to the current root dir or absolute | ||
export async function installLocalDep(pkg : string, pkgPath = '', {verbose, silent} : InstallLocalDepOptions = {}) : Promise<Record<string, string> | false> { | ||
if (!silent) { | ||
let logUpdate = createLogUpdate(process.stdout, {showCursor: true}); | ||
logUpdate(`Local dependency ${pkg} = "${pkgPath}"`); | ||
|
||
if (verbose) { | ||
silent || logUpdate.done(); | ||
} | ||
else { | ||
logUpdate.clear(); | ||
} | ||
} | ||
|
||
// install dependencies | ||
let dir = path.resolve(getRootDir(), pkgPath); | ||
let config = readConfig(path.join(dir, 'mops.toml')); | ||
return installDeps(Object.values(config.dependencies || {}), {silent, verbose}, pkgPath); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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