@topogram/cli 0.3.88 → 0.3.89

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topogram/cli",
3
- "version": "0.3.88",
3
+ "version": "0.3.89",
4
4
  "description": "Topogram CLI for checking Topogram workspaces and generating app bundles.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -2,6 +2,7 @@
2
2
 
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
5
6
 
6
7
  import {
7
8
  catalogEntryPackageSpec,
@@ -23,7 +24,7 @@ import {
23
24
  import { shellCommandArg } from "./catalog/shared.js";
24
25
  import { stableStringify } from "../../format.js";
25
26
 
26
- const ENGINE_ROOT = path.resolve(decodeURIComponent(new URL("../../../", import.meta.url).pathname));
27
+ const ENGINE_ROOT = path.resolve(fileURLToPath(new URL("../../../", import.meta.url)));
27
28
  const TEMPLATES_ROOT = path.join(ENGINE_ROOT, "templates");
28
29
 
29
30
  /**
@@ -1,5 +1,8 @@
1
1
  // @ts-check
2
2
 
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+
3
6
  export const CLI_PACKAGE_NAME = "@topogram/cli";
4
7
  export const NPMJS_REGISTRY = "https://registry.npmjs.org";
5
8
 
@@ -14,4 +17,4 @@ export const PACKAGE_UPDATE_CLI_CHECK_SCRIPTS = [
14
17
  ];
15
18
  export const PACKAGE_UPDATE_CLI_INFO_SCRIPTS = ["cli:surface", "doctor", "catalog:show", "catalog:template-show"];
16
19
  export const PACKAGE_UPDATE_CLI_VERIFICATION_SCRIPTS = ["verify", "pack:check", "check"];
17
- export const ENGINE_ROOT = decodeURIComponent(new URL("../../../../", import.meta.url).pathname);
20
+ export const ENGINE_ROOT = path.resolve(fileURLToPath(new URL("../../../../", import.meta.url)));
@@ -3,6 +3,7 @@
3
3
  import childProcess from "node:child_process";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
6
7
 
7
8
  import {
8
9
  latestWorkflowRun,
@@ -15,7 +16,7 @@ import {
15
16
  releaseConsumerWorkflowName
16
17
  } from "../../topogram-config.js";
17
18
 
18
- const REPO_ROOT = decodeURIComponent(new URL("../../../../", import.meta.url).pathname);
19
+ const REPO_ROOT = path.resolve(fileURLToPath(new URL("../../../../", import.meta.url)));
19
20
 
20
21
  /**
21
22
  * @typedef {Record<string, any>} AnyRecord
@@ -1,8 +1,9 @@
1
1
  // @ts-check
2
2
 
3
3
  import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
4
5
 
5
6
  export const TEMPLATE_FILES_MANIFEST = ".topogram-template-files.json";
6
7
  export const TEMPLATE_POLICY_FILE = "topogram.template-policy.json";
7
- export const ENGINE_ROOT = decodeURIComponent(new URL("../../../../", import.meta.url).pathname);
8
+ export const ENGINE_ROOT = path.resolve(fileURLToPath(new URL("../../../../", import.meta.url)));
8
9
  export const TEMPLATES_ROOT = path.join(ENGINE_ROOT, "templates");
@@ -3,13 +3,27 @@
3
3
  import fs from "node:fs";
4
4
  import os from "node:os";
5
5
  import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
6
7
 
7
8
  import { outputOwnershipForPath } from "../project-config.js";
8
9
  import { DEFAULT_TOPO_FOLDER_NAME } from "../workspace-paths.js";
9
10
 
10
11
  export const GENERATED_OUTPUT_SENTINEL = ".topogram-generated.json";
11
12
 
12
- const REPO_ROOT = path.resolve(decodeURIComponent(new URL("../../../", import.meta.url).pathname));
13
+ /**
14
+ * Resolve the repository root from a CLI module URL without using URL
15
+ * pathname decoding. `fileURLToPath` preserves platform semantics for
16
+ * encoded paths and Windows drive roots, which output replacement guards
17
+ * depend on before deleting or writing generated files.
18
+ *
19
+ * @param {string|URL} moduleUrl
20
+ * @returns {string}
21
+ */
22
+ export function repoRootFromCliModuleUrl(moduleUrl) {
23
+ return path.resolve(fileURLToPath(new URL("../../../", moduleUrl)));
24
+ }
25
+
26
+ const REPO_ROOT = repoRootFromCliModuleUrl(import.meta.url);
13
27
 
14
28
  /**
15
29
  * @param {string} parent
@@ -1,5 +1,6 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
3
4
  import { resolveWorkspaceContext } from "../../../workspace-paths.js";
4
5
 
5
6
  import { parseDocFile } from "../../../workspace-docs.js";
@@ -10,7 +11,7 @@ import {
10
11
  import { seamIdHint, stableSortedStrings, titleCaseWords } from "./primitives.js";
11
12
  import { buildMaintainedWriteScope, recommendedVerificationTargets } from "./metrics.js";
12
13
 
13
- const bundledRepoRoot = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..", "..", "..", "..");
14
+ const bundledRepoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "..");
14
15
 
15
16
  /**
16
17
  * @param {import("./types.d.ts").ContextGraph} graph
@@ -129,8 +129,9 @@ if (stamp) {
129
129
  function renderBuildScript() {
130
130
  return `import fs from "node:fs";
131
131
  import path from "node:path";
132
+ import { fileURLToPath } from "node:url";
132
133
 
133
- const root = path.resolve(new URL("..", import.meta.url).pathname);
134
+ const root = path.resolve(fileURLToPath(new URL("..", import.meta.url)));
134
135
  const dist = path.join(root, "dist");
135
136
  fs.rmSync(dist, { recursive: true, force: true });
136
137
  fs.mkdirSync(dist, { recursive: true });
@@ -146,8 +147,9 @@ console.log("Built vanilla web app to dist/.");
146
147
  function renderCheckScript() {
147
148
  return `import fs from "node:fs";
148
149
  import path from "node:path";
150
+ import { fileURLToPath } from "node:url";
149
151
 
150
- const root = path.resolve(new URL("..", import.meta.url).pathname);
152
+ const root = path.resolve(fileURLToPath(new URL("..", import.meta.url)));
151
153
  const htmlFiles = fs.readdirSync(root).filter((entry) => entry.endsWith(".html"));
152
154
  if (htmlFiles.length < 1) {
153
155
  throw new Error("Expected at least one HTML page.");
@@ -227,8 +229,9 @@ function renderDevScript() {
227
229
  return `import http from "node:http";
228
230
  import fs from "node:fs";
229
231
  import path from "node:path";
232
+ import { fileURLToPath } from "node:url";
230
233
 
231
- const root = path.resolve(new URL("..", import.meta.url).pathname);
234
+ const root = path.resolve(fileURLToPath(new URL("..", import.meta.url)));
232
235
  const port = Number(process.env.PORT || process.env.WEB_PORT || 5173);
233
236
  const types = new Map([
234
237
  [".html", "text/html; charset=utf-8"],