@topogram/cli 0.3.36 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +69 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topogram/cli",
3
- "version": "0.3.36",
3
+ "version": "0.3.38",
4
4
  "description": "Topogram CLI for checking Topogram workspaces and generating app bundles.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/src/cli.js CHANGED
@@ -108,7 +108,34 @@ const CLI_PACKAGE_NAME = "@topogram/cli";
108
108
  const NPMJS_REGISTRY = "https://registry.npmjs.org";
109
109
  const TEMPLATE_FILES_MANIFEST = ".topogram-template-files.json";
110
110
  const TEMPLATE_POLICY_FILE = "topogram.template-policy.json";
111
- const KNOWN_CLI_CONSUMER_REPOS = ["topogram-starters", "topogram-template-todo", "topogram-demo-todo"];
111
+ const FIRST_PARTY_GENERATOR_REPOS = [
112
+ "topogram-generator-express-api",
113
+ "topogram-generator-hono-api",
114
+ "topogram-generator-postgres-db",
115
+ "topogram-generator-react-web",
116
+ "topogram-generator-sqlite-db",
117
+ "topogram-generator-sveltekit-web",
118
+ "topogram-generator-swiftui-native",
119
+ "topogram-generator-vanilla-web"
120
+ ];
121
+ const KNOWN_CLI_CONSUMER_REPOS = [
122
+ ...FIRST_PARTY_GENERATOR_REPOS,
123
+ "topogram-starters",
124
+ "topogram-template-todo",
125
+ "topogram-demo-todo",
126
+ "topogram-hello"
127
+ ];
128
+ const PACKAGE_UPDATE_CLI_CHECK_SCRIPTS = [
129
+ "cli:surface",
130
+ "doctor",
131
+ "catalog:show",
132
+ "catalog:template-show",
133
+ "check",
134
+ "pack:check",
135
+ "verify"
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"];
112
139
  const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
113
140
  const ENGINE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
114
141
  const TEMPLATES_ROOT = path.join(ENGINE_ROOT, "templates");
@@ -654,6 +681,8 @@ function printPackageHelp() {
654
681
  console.log(" - npmjs package inspection confirms the requested public CLI version.");
655
682
  console.log(" - npm install updates package.json and package-lock.json.");
656
683
  console.log(" - Available consumer verification scripts run after install.");
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.");
657
686
  console.log("");
658
687
  console.log("Examples:");
659
688
  console.log(" topogram package update-cli 0.3.5");
@@ -667,7 +696,7 @@ function printPackageHelp() {
667
696
  function printReleaseHelp() {
668
697
  console.log("Usage: topogram release status [--json] [--strict]");
669
698
  console.log("");
670
- console.log("Checks the local CLI version, latest published package version, release tag, and known consumer pins.");
699
+ console.log("Checks the local CLI version, latest published package version, release tag, and first-party consumer pins.");
671
700
  console.log("");
672
701
  console.log("Examples:");
673
702
  console.log(" topogram release status");
@@ -1625,11 +1654,10 @@ function buildPackageUpdateCliPayload(requested, options = {}) {
1625
1654
  const versionConvention = writeTopogramCliVersionConventionIfPresent(cwd, version);
1626
1655
  const packageJson = readPackageJsonForUpdate(cwd);
1627
1656
  const scripts = packageJson.scripts && typeof packageJson.scripts === "object" ? packageJson.scripts : {};
1628
- const candidateScripts = ["cli:surface", "doctor", "catalog:show", "catalog:template-show", "check"];
1629
1657
  const scriptsRun = [];
1630
1658
  const skippedScripts = [];
1631
1659
  if (dependencyUpdatedBy !== "npm-install") {
1632
- skippedScripts.push(...candidateScripts);
1660
+ skippedScripts.push(...PACKAGE_UPDATE_CLI_CHECK_SCRIPTS);
1633
1661
  diagnostics.push({
1634
1662
  code: "package_update_cli_checks_skipped_after_file_update",
1635
1663
  severity: "warning",
@@ -1638,11 +1666,23 @@ function buildPackageUpdateCliPayload(requested, options = {}) {
1638
1666
  suggestedFix: "Run npm install or npm ci, then rerun consumer verification."
1639
1667
  });
1640
1668
  } else {
1641
- for (const scriptName of candidateScripts) {
1669
+ const scriptsToRun = packageUpdateCliScriptsToRun(scripts);
1670
+ for (const scriptName of PACKAGE_UPDATE_CLI_INFO_SCRIPTS) {
1642
1671
  if (!Object.prototype.hasOwnProperty.call(scripts, scriptName)) {
1643
1672
  skippedScripts.push(scriptName);
1644
- continue;
1645
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) {
1646
1686
  const result = runNpmForPackageUpdate(["run", scriptName], cwd);
1647
1687
  if (result.status !== 0) {
1648
1688
  throw new Error(formatPackageUpdateNpmError(`npm run ${scriptName}`, "check", result));
@@ -1669,6 +1709,26 @@ function buildPackageUpdateCliPayload(requested, options = {}) {
1669
1709
  };
1670
1710
  }
1671
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
+
1672
1732
  /**
1673
1733
  * @param {ReturnType<typeof buildPackageUpdateCliPayload>} payload
1674
1734
  * @returns {void}
@@ -1700,7 +1760,7 @@ function printPackageUpdateCli(payload) {
1700
1760
  console.log(" git diff package.json package-lock.json");
1701
1761
  console.log(` git commit -am "Update Topogram CLI to ${payload.requestedVersion}"`);
1702
1762
  console.log(" git push");
1703
- console.log(" confirm Demo Verification passes");
1763
+ console.log(" confirm the repo verification workflow passes");
1704
1764
  }
1705
1765
 
1706
1766
  /**
@@ -1804,9 +1864,9 @@ function releaseStatusStrictDiagnostics(release) {
1804
1864
  diagnostics.push({
1805
1865
  code: "release_consumer_pins_not_current",
1806
1866
  severity: "error",
1807
- message: `Known consumers are not all pinned to ${CLI_PACKAGE_NAME}@${release.localVersion}.`,
1867
+ message: `First-party consumers are not all pinned to ${CLI_PACKAGE_NAME}@${release.localVersion}.`,
1808
1868
  path: "topogram-cli.version",
1809
- suggestedFix: "Roll known consumer repositories to the current CLI version before treating this release as complete."
1869
+ suggestedFix: "Roll first-party consumer repositories to the current CLI version before treating this release as complete."
1810
1870
  });
1811
1871
  }
1812
1872
  return diagnostics;