@topogram/cli 0.3.37 → 0.3.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli.js +38 -4
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -134,6 +134,8 @@ const PACKAGE_UPDATE_CLI_CHECK_SCRIPTS = [
|
|
|
134
134
|
"pack:check",
|
|
135
135
|
"verify"
|
|
136
136
|
];
|
|
137
|
+
const PACKAGE_UPDATE_CLI_INFO_SCRIPTS = ["cli:surface", "doctor", "catalog:show", "catalog:template-show"];
|
|
138
|
+
const PACKAGE_UPDATE_CLI_VERIFICATION_SCRIPTS = ["verify", "pack:check", "check"];
|
|
137
139
|
const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
138
140
|
const ENGINE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
139
141
|
const TEMPLATES_ROOT = path.join(ENGINE_ROOT, "templates");
|
|
@@ -680,6 +682,7 @@ function printPackageHelp() {
|
|
|
680
682
|
console.log(" - npm install updates package.json and package-lock.json.");
|
|
681
683
|
console.log(" - Available consumer verification scripts run after install.");
|
|
682
684
|
console.log(` - Recognized scripts: ${PACKAGE_UPDATE_CLI_CHECK_SCRIPTS.join(", ")}.`);
|
|
685
|
+
console.log(" - Verification scripts are selected by strength: verify, then pack:check, then check.");
|
|
683
686
|
console.log("");
|
|
684
687
|
console.log("Examples:");
|
|
685
688
|
console.log(" topogram package update-cli 0.3.5");
|
|
@@ -1651,11 +1654,10 @@ function buildPackageUpdateCliPayload(requested, options = {}) {
|
|
|
1651
1654
|
const versionConvention = writeTopogramCliVersionConventionIfPresent(cwd, version);
|
|
1652
1655
|
const packageJson = readPackageJsonForUpdate(cwd);
|
|
1653
1656
|
const scripts = packageJson.scripts && typeof packageJson.scripts === "object" ? packageJson.scripts : {};
|
|
1654
|
-
const candidateScripts = PACKAGE_UPDATE_CLI_CHECK_SCRIPTS;
|
|
1655
1657
|
const scriptsRun = [];
|
|
1656
1658
|
const skippedScripts = [];
|
|
1657
1659
|
if (dependencyUpdatedBy !== "npm-install") {
|
|
1658
|
-
skippedScripts.push(...
|
|
1660
|
+
skippedScripts.push(...PACKAGE_UPDATE_CLI_CHECK_SCRIPTS);
|
|
1659
1661
|
diagnostics.push({
|
|
1660
1662
|
code: "package_update_cli_checks_skipped_after_file_update",
|
|
1661
1663
|
severity: "warning",
|
|
@@ -1664,11 +1666,23 @@ function buildPackageUpdateCliPayload(requested, options = {}) {
|
|
|
1664
1666
|
suggestedFix: "Run npm install or npm ci, then rerun consumer verification."
|
|
1665
1667
|
});
|
|
1666
1668
|
} else {
|
|
1667
|
-
|
|
1669
|
+
const scriptsToRun = packageUpdateCliScriptsToRun(scripts);
|
|
1670
|
+
for (const scriptName of PACKAGE_UPDATE_CLI_INFO_SCRIPTS) {
|
|
1668
1671
|
if (!Object.prototype.hasOwnProperty.call(scripts, scriptName)) {
|
|
1669
1672
|
skippedScripts.push(scriptName);
|
|
1670
|
-
continue;
|
|
1671
1673
|
}
|
|
1674
|
+
}
|
|
1675
|
+
for (const scriptName of PACKAGE_UPDATE_CLI_VERIFICATION_SCRIPTS) {
|
|
1676
|
+
if (!Object.prototype.hasOwnProperty.call(scripts, scriptName)) {
|
|
1677
|
+
skippedScripts.push(scriptName);
|
|
1678
|
+
} else if (!scriptsToRun.includes(scriptName)) {
|
|
1679
|
+
const coveringScript = scriptsToRun.find((candidate) =>
|
|
1680
|
+
PACKAGE_UPDATE_CLI_VERIFICATION_SCRIPTS.includes(candidate)
|
|
1681
|
+
);
|
|
1682
|
+
skippedScripts.push(`${scriptName} (covered by ${coveringScript})`);
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
for (const scriptName of scriptsToRun) {
|
|
1672
1686
|
const result = runNpmForPackageUpdate(["run", scriptName], cwd);
|
|
1673
1687
|
if (result.status !== 0) {
|
|
1674
1688
|
throw new Error(formatPackageUpdateNpmError(`npm run ${scriptName}`, "check", result));
|
|
@@ -1695,6 +1709,26 @@ function buildPackageUpdateCliPayload(requested, options = {}) {
|
|
|
1695
1709
|
};
|
|
1696
1710
|
}
|
|
1697
1711
|
|
|
1712
|
+
/**
|
|
1713
|
+
* @param {Record<string, any>} scripts
|
|
1714
|
+
* @returns {string[]}
|
|
1715
|
+
*/
|
|
1716
|
+
function packageUpdateCliScriptsToRun(scripts) {
|
|
1717
|
+
const selected = [];
|
|
1718
|
+
for (const scriptName of PACKAGE_UPDATE_CLI_INFO_SCRIPTS) {
|
|
1719
|
+
if (Object.prototype.hasOwnProperty.call(scripts, scriptName)) {
|
|
1720
|
+
selected.push(scriptName);
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
const verificationScript = PACKAGE_UPDATE_CLI_VERIFICATION_SCRIPTS.find((scriptName) =>
|
|
1724
|
+
Object.prototype.hasOwnProperty.call(scripts, scriptName)
|
|
1725
|
+
);
|
|
1726
|
+
if (verificationScript) {
|
|
1727
|
+
selected.push(verificationScript);
|
|
1728
|
+
}
|
|
1729
|
+
return selected;
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1698
1732
|
/**
|
|
1699
1733
|
* @param {ReturnType<typeof buildPackageUpdateCliPayload>} payload
|
|
1700
1734
|
* @returns {void}
|