Attempt to patch more bugs
This commit is contained in:
parent
d36970b9de
commit
8455d259c0
|
@ -74,8 +74,7 @@ EOF`);
|
||||||
install -d "\${pkg}/opt/riju/langs"
|
install -d "\${pkg}/opt/riju/langs"
|
||||||
cat <<"EOF" > "\${pkg}/opt/riju/langs/${id}.json"
|
cat <<"EOF" > "\${pkg}/opt/riju/langs/${id}.json"
|
||||||
${JSON.stringify(langConfig, null, 2)}
|
${JSON.stringify(langConfig, null, 2)}
|
||||||
EOF
|
EOF`);
|
||||||
`);
|
|
||||||
return parts.join("\n\n");
|
return parts.join("\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,32 +149,14 @@ function printTable(data, headers) {
|
||||||
async function main() {
|
async function main() {
|
||||||
const program = new Command();
|
const program = new Command();
|
||||||
program.option("--publish", "deploy newly built artifacts");
|
program.option("--publish", "deploy newly built artifacts");
|
||||||
program.option("--all", "show also unchanged artifacts");
|
program.option("--show-all", "show also unchanged artifacts");
|
||||||
program.option(
|
program.option(
|
||||||
"--omit-unneeded-downloads",
|
"--omit-unneeded-downloads",
|
||||||
"don't download artifacts unless needed for dependent builds"
|
"don't download artifacts unless needed for dependent builds"
|
||||||
);
|
);
|
||||||
program.parse(process.argv);
|
program.parse(process.argv);
|
||||||
let plan = await computePlan();
|
let plan = await computePlan();
|
||||||
const filteredPlan = plan.filter(
|
let tableData = plan.map(
|
||||||
({ desired, local, remote }) => desired !== local || desired !== remote
|
|
||||||
);
|
|
||||||
console.log();
|
|
||||||
if (filteredPlan.length === 0) {
|
|
||||||
console.log(`*** NO CHANGES REQUIRED TO ${plan.length} ARTIFACTS ***`);
|
|
||||||
} else {
|
|
||||||
console.log(
|
|
||||||
`*** CHANGES REQUIRED TO ${filteredPlan.length} of ${plan.length} ARTIFACTS ***`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
console.log();
|
|
||||||
if (!program.all) {
|
|
||||||
plan = filteredPlan;
|
|
||||||
}
|
|
||||||
if (plan.length === 0) {
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
const tableData = plan.map(
|
|
||||||
({
|
({
|
||||||
id,
|
id,
|
||||||
deps,
|
deps,
|
||||||
|
@ -187,22 +169,25 @@ async function main() {
|
||||||
build,
|
build,
|
||||||
upload,
|
upload,
|
||||||
}) => {
|
}) => {
|
||||||
let action, details, func, couldPrune;
|
let action, details, func, couldPrune, noop;
|
||||||
if (remote === desired && local === desired) {
|
if (remote === desired && local === desired) {
|
||||||
action = "(no action)";
|
action = "(no action)";
|
||||||
details = desired;
|
details = desired;
|
||||||
func = () => {};
|
func = () => {};
|
||||||
couldPrune = true;
|
couldPrune = true;
|
||||||
|
noop = true;
|
||||||
} else if (remote === desired && local !== desired) {
|
} else if (remote === desired && local !== desired) {
|
||||||
action = "download remote";
|
action = "download remote";
|
||||||
details = `${local} => ${desired}`;
|
details = `${local} => ${desired}`;
|
||||||
func = download;
|
func = download;
|
||||||
couldPrune = true;
|
couldPrune = true;
|
||||||
|
noop = false;
|
||||||
} else if (local === desired && remote !== desired) {
|
} else if (local === desired && remote !== desired) {
|
||||||
action = "publish local";
|
action = "publish local";
|
||||||
details = `${remote} => ${desired}`;
|
details = `${remote} => ${desired}`;
|
||||||
func = upload;
|
func = upload;
|
||||||
couldPrune = false;
|
couldPrune = false;
|
||||||
|
noop = false;
|
||||||
} else {
|
} else {
|
||||||
action = "rebuild and publish";
|
action = "rebuild and publish";
|
||||||
if (local === remote) {
|
if (local === remote) {
|
||||||
|
@ -215,33 +200,62 @@ async function main() {
|
||||||
await upload();
|
await upload();
|
||||||
};
|
};
|
||||||
couldPrune = false;
|
couldPrune = false;
|
||||||
|
noop = false;
|
||||||
}
|
}
|
||||||
return { id, deps, couldPrune, artifact, name, action, details, func };
|
return {
|
||||||
|
id,
|
||||||
|
deps,
|
||||||
|
couldPrune,
|
||||||
|
artifact,
|
||||||
|
name,
|
||||||
|
action,
|
||||||
|
details,
|
||||||
|
func,
|
||||||
|
noop,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if (program.omitUnneededDownloads) {
|
if (program.omitUnneededDownloads) {
|
||||||
// Recall that JavaScript object keys are sorted by insertion
|
for (const datum of [...tableData].reverse()) {
|
||||||
// order.
|
if (
|
||||||
const index = Object.fromEntries(
|
datum.couldPrune &&
|
||||||
tableData.map((datum) => [datum.id, datum]).reverse()
|
_.every(
|
||||||
);
|
tableData,
|
||||||
for (const [id, datum] of Object.entries(index)) {
|
(otherDatum) =>
|
||||||
// See if we can prune this step.
|
otherDatum.pruned || !otherDatum.deps.includes(datum.id)
|
||||||
if (datum.couldPrune && _.every(datum.deps, index[dep].pruned)) {
|
)
|
||||||
|
) {
|
||||||
datum.pruned = true;
|
datum.pruned = true;
|
||||||
if (!datum.details.startsWith("(")) {
|
if (!datum.noop) {
|
||||||
datum.details += " [skipping]";
|
datum.action += " [skipping]";
|
||||||
|
datum.noop = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printTable(tableData, [
|
|
||||||
{ key: "artifact", title: "Type" },
|
|
||||||
{ key: "name", title: "Name" },
|
|
||||||
{ key: "action", title: "Action" },
|
|
||||||
{ key: "details", title: "Details" },
|
|
||||||
]);
|
|
||||||
console.log();
|
console.log();
|
||||||
|
const filteredTableData = tableData.filter(({ noop }) => !noop);
|
||||||
|
if (filteredTableData.length === 0) {
|
||||||
|
console.log(`*** NO ACTION REQUIRED FOR ${plan.length} ARTIFACTS ***`);
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
`*** ACTION REQUIRED FOR ${filteredTableData.length} of ${plan.length} ARTIFACTS ***`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
console.log();
|
||||||
|
if (!program.showAll) {
|
||||||
|
tableData = filteredTableData;
|
||||||
|
}
|
||||||
|
if (tableData.length > 0) {
|
||||||
|
printTable(tableData, [
|
||||||
|
{ key: "artifact", title: "Type" },
|
||||||
|
{ key: "name", title: "Name" },
|
||||||
|
{ key: "action", title: "Action" },
|
||||||
|
{ key: "details", title: "Details" },
|
||||||
|
]);
|
||||||
|
console.log();
|
||||||
|
}
|
||||||
|
tableData = filteredTableData;
|
||||||
if (program.publish) {
|
if (program.publish) {
|
||||||
for (const { func } of tableData) {
|
for (const { func } of tableData) {
|
||||||
await func();
|
await func();
|
||||||
|
|
|
@ -12,7 +12,7 @@ fi
|
||||||
|
|
||||||
make pull-base scripts
|
make pull-base scripts
|
||||||
|
|
||||||
node tools/plan-publish.js --publish --omit-unneeded-downloads
|
node tools/plan-publish.js --publish --show-all --omit-unneeded-downloads
|
||||||
|
|
||||||
sha="$(git describe --match=always-omit-tag --always --abbrev=40 --dirty)"
|
sha="$(git describe --match=always-omit-tag --always --abbrev=40 --dirty)"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue