Add --local-only mode to depgraph
This commit is contained in:
parent
0c611c1fba
commit
4404657909
|
@ -344,6 +344,7 @@ async function executeDepGraph({
|
||||||
manual,
|
manual,
|
||||||
holdManual,
|
holdManual,
|
||||||
all,
|
all,
|
||||||
|
localOnly,
|
||||||
publish,
|
publish,
|
||||||
yes,
|
yes,
|
||||||
targets,
|
targets,
|
||||||
|
@ -362,10 +363,16 @@ async function executeDepGraph({
|
||||||
const transitiveTargets = getTransitiveDependencies({ artifacts, targets });
|
const transitiveTargets = getTransitiveDependencies({ artifacts, targets });
|
||||||
const requiredInfo = new Set();
|
const requiredInfo = new Set();
|
||||||
for (const target of transitiveTargets) {
|
for (const target of transitiveTargets) {
|
||||||
for (const name of Object.values(
|
for (const [method, name] of Object.entries(
|
||||||
artifacts[target].informationalDependencies || {}
|
artifacts[target].informationalDependencies || {}
|
||||||
)) {
|
)) {
|
||||||
requiredInfo.add(name);
|
if (
|
||||||
|
!(
|
||||||
|
localOnly &&
|
||||||
|
["getPublishedHash", "retrieveFromRegistry"].includes(method)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
requiredInfo.add(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const info = {};
|
const info = {};
|
||||||
|
@ -391,7 +398,9 @@ async function executeDepGraph({
|
||||||
promises.desired[target] = Promise.resolve(null);
|
promises.desired[target] = Promise.resolve(null);
|
||||||
} else {
|
} else {
|
||||||
promises.local[target] = artifacts[target].getLocalHash(info);
|
promises.local[target] = artifacts[target].getLocalHash(info);
|
||||||
promises.published[target] = artifacts[target].getPublishedHash(info);
|
promises.published[target] = localOnly
|
||||||
|
? Promise.resolve(null)
|
||||||
|
: artifacts[target].getPublishedHash(info);
|
||||||
promises.desired[target] = (async () => {
|
promises.desired[target] = (async () => {
|
||||||
const dependencyHashes = {};
|
const dependencyHashes = {};
|
||||||
for (const dependency of artifacts[target].dependencies) {
|
for (const dependency of artifacts[target].dependencies) {
|
||||||
|
@ -424,9 +433,6 @@ async function executeDepGraph({
|
||||||
}
|
}
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
transitiveTargets.map(async (target) => {
|
transitiveTargets.map(async (target) => {
|
||||||
const { getLocalHash, getPublishedHash, getDesiredHash } = artifacts[
|
|
||||||
target
|
|
||||||
];
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
promises.local[target].then((hash) => {
|
promises.local[target].then((hash) => {
|
||||||
hashes.local[target] = hash;
|
hashes.local[target] = hash;
|
||||||
|
@ -600,16 +606,28 @@ async function executeDepGraph({
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const program = new Command();
|
const program = new Command("dep");
|
||||||
program.usage("<target>...");
|
program.usage("<target>...");
|
||||||
program.option("--list", "list available artifacts; ignore other arguments");
|
program.option("--list", "list available artifacts; ignore other arguments");
|
||||||
program.option("--manual", "operate explicitly on manual artifacts");
|
program.option("--manual", "operate explicitly on manual artifacts");
|
||||||
program.option("--hold-manual", "prefer local versions of manual artifacts");
|
program.option("--hold-manual", "prefer local versions of manual artifacts");
|
||||||
program.option("--all", "do not skip unneeded intermediate artifacts");
|
program.option("--all", "do not skip unneeded intermediate artifacts");
|
||||||
|
program.option(
|
||||||
|
"--local-only",
|
||||||
|
"do not fetch artifacts from remote registries"
|
||||||
|
);
|
||||||
program.option("--publish", "publish artifacts to remote registries");
|
program.option("--publish", "publish artifacts to remote registries");
|
||||||
program.option("--yes", "execute plan without confirmation");
|
program.option("--yes", "execute plan without confirmation");
|
||||||
program.parse(process.argv);
|
program.parse(process.argv);
|
||||||
const { list, manual, holdManual, all, publish, yes } = program.opts();
|
const {
|
||||||
|
list,
|
||||||
|
manual,
|
||||||
|
holdManual,
|
||||||
|
all,
|
||||||
|
localOnly,
|
||||||
|
publish,
|
||||||
|
yes,
|
||||||
|
} = program.opts();
|
||||||
const depgraph = await getDepGraph();
|
const depgraph = await getDepGraph();
|
||||||
if (list) {
|
if (list) {
|
||||||
for (const { name } of depgraph.artifacts) {
|
for (const { name } of depgraph.artifacts) {
|
||||||
|
@ -627,6 +645,7 @@ async function main() {
|
||||||
manual,
|
manual,
|
||||||
holdManual,
|
holdManual,
|
||||||
all,
|
all,
|
||||||
|
localOnly,
|
||||||
publish,
|
publish,
|
||||||
yes,
|
yes,
|
||||||
targets: program.args,
|
targets: program.args,
|
||||||
|
|
Loading…
Reference in New Issue