History

[codex] Enforce canonical Node namespace imports (#3238)

Julius Marminge committed 4 months ago

Commit 2fa37ec1 parent db2750271 files · +1205 −952Browse files

Showing the changes to scripts (3 of 71 files). Show all

Unified · Split

3 files
  1. scripts/build-desktop-artifact.ts +2 −2
  2. scripts/lib/public-config.test.ts +9 −9
  3. scripts/release-smoke.ts +62 −64
scripts/build-desktop-artifact.ts+2−2
@@ -1,6 +1,6 @@
11 #!/usr/bin/env node
22
3−import { createRequire } from "node:module";
3+import * as NodeModule from "node:module";
44
55 import { fromYaml } from "@t3tools/shared/schemaYaml";
66 import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
@@ -482,7 +482,7 @@ const stageClerkPasskeyNativeBinaries = Effect.fn("stageClerkPasskeyNativeBinari · 475 unmodified lines
482482 path.join(stageAppDir, "node_modules", "@clerk", "electron-passkeys", "index.js"),
483483 );
484484 const packageDir = path.dirname(packageEntryPath);
485− const packageRequire = createRequire(packageEntryPath);
485+ const packageRequire = NodeModule.createRequire(packageEntryPath);
486486
487487 for (const artifact of resolveClerkPasskeyNativeArtifacts(platform, arch)) {
488488 const sourcePath = yield* Effect.try({
scripts/lib/public-config.test.ts+9−9
@@ -1,7 +1,7 @@
11 // @effect-diagnostics nodeBuiltinImport:off - Tests exercise root env file precedence directly.
2−import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
3−import { tmpdir } from "node:os";
4−import { join } from "node:path";
2+import * as NodeFS from "node:fs";
3+import * as NodeOS from "node:os";
4+import * as NodePath from "node:path";
55 import { afterEach, describe, expect, it } from "vite-plus/test";
66
77 import { loadRepoEnv, resolvePublicConfig } from "./public-config.ts";
@@ -10,7 +10,7 @@ const temporaryDirectories: string[] = []; · 2 unmodified lines
1010
1111 afterEach(() => {
1212 for (const directory of temporaryDirectories.splice(0)) {
13− rmSync(directory, { recursive: true, force: true });
13+ NodeFS.rmSync(directory, { recursive: true, force: true });
1414 }
1515 });
1616
@@ -43,12 +43,12 @@ describe("loadRepoEnv", () => { · 26 unmodified lines
4343
4444 it("applies process, root local, and root precedence in that order", () => {
4545 const repoRoot = makeTemporaryDirectory();
46− writeFileSync(
47− join(repoRoot, ".env"),
46+ NodeFS.writeFileSync(
47+ NodePath.join(repoRoot, ".env"),
4848 "T3CODE_CLERK_PUBLISHABLE_KEY=pk_root\nT3CODE_CLERK_JWT_TEMPLATE=template_root\nT3CODE_CLERK_CLI_OAUTH_CLIENT_ID=oauth_root\nT3CODE_RELAY_URL=https://root.example.test\n",
4949 );
50− writeFileSync(
51− join(repoRoot, ".env.local"),
50+ NodeFS.writeFileSync(
51+ NodePath.join(repoRoot, ".env.local"),
5252 "T3CODE_CLERK_PUBLISHABLE_KEY=pk_local\nT3CODE_CLERK_JWT_TEMPLATE=template_local\nT3CODE_CLERK_CLI_OAUTH_CLIENT_ID=oauth_local\nT3CODE_RELAY_URL=https://local.example.test\n",
5353 );
5454
@@ -148,7 +148,7 @@ describe("loadRepoEnv", () => { · 93 unmodified lines
148148 });
149149
150150 function makeTemporaryDirectory() {
151− const directory = mkdtempSync(join(tmpdir(), "t3code-public-config-"));
151+ const directory = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3code-public-config-"));
152152 temporaryDirectories.push(directory);
153153 return directory;
154154 }
scripts/release-smoke.ts+62−64
@@ -1,21 +1,13 @@
11 // @effect-diagnostics nodeBuiltinImport:off
2−import { execFileSync } from "node:child_process";
3−import {
4− cpSync,
5− existsSync,
6− mkdirSync,
7− mkdtempSync,
8− readFileSync,
9− rmSync,
10− writeFileSync,
11−} from "node:fs";
12−import { tmpdir } from "node:os";
13−import { dirname, join, resolve } from "node:path";
14−import { fileURLToPath } from "node:url";
2+import * as NodeChildProcess from "node:child_process";
3+import * as NodeFS from "node:fs";
4+import * as NodeOS from "node:os";
5+import * as NodePath from "node:path";
6+import * as NodeURL from "node:url";
157 import * as Console from "effect/Console";
168 import * as Effect from "effect/Effect";
179
18−const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
10+const repoRoot = NodePath.resolve(NodePath.dirname(NodeURL.fileURLToPath(import.meta.url)), "..");
1911
2012 const workspaceFiles = [
2113 "package.json",
@@ -44,26 +36,26 @@ const workspaceFiles = [ · 22 unmodified lines
4436
4537 function copyWorkspaceManifestFixture(targetRoot: string): void {
4638 for (const relativePath of workspaceFiles) {
47− const sourcePath = resolve(repoRoot, relativePath);
48− const destinationPath = resolve(targetRoot, relativePath);
49− mkdirSync(dirname(destinationPath), { recursive: true });
50− cpSync(sourcePath, destinationPath);
39+ const sourcePath = NodePath.resolve(repoRoot, relativePath);
40+ const destinationPath = NodePath.resolve(targetRoot, relativePath);
41+ NodeFS.mkdirSync(NodePath.dirname(destinationPath), { recursive: true });
42+ NodeFS.cpSync(sourcePath, destinationPath);
5143 }
5244
53− const patchesDirectory = resolve(repoRoot, "patches");
54− if (existsSync(patchesDirectory)) {
55− cpSync(patchesDirectory, resolve(targetRoot, "patches"), { recursive: true });
45+ const patchesDirectory = NodePath.resolve(repoRoot, "patches");
46+ if (NodeFS.existsSync(patchesDirectory)) {
47+ NodeFS.cpSync(patchesDirectory, NodePath.resolve(targetRoot, "patches"), { recursive: true });
5648 }
5749 }
5850
5951 function writeMacManifestFixtures(targetRoot: string): { arm64Path: string; x64Path: string } {
60− const assetDirectory = resolve(targetRoot, "release-assets");
61− mkdirSync(assetDirectory, { recursive: true });
52+ const assetDirectory = NodePath.resolve(targetRoot, "release-assets");
53+ NodeFS.mkdirSync(assetDirectory, { recursive: true });
6254
63− const arm64Path = resolve(assetDirectory, "latest-mac.yml");
64− const x64Path = resolve(assetDirectory, "latest-mac-x64.yml");
55+ const arm64Path = NodePath.resolve(assetDirectory, "latest-mac.yml");
56+ const x64Path = NodePath.resolve(assetDirectory, "latest-mac-x64.yml");
6557
66− writeFileSync(
58+ NodeFS.writeFileSync(
6759 arm64Path,
6860 `version: 9.9.9-smoke.0
6961 files:
@@ -79,7 +71,7 @@ releaseDate: '2026-03-08T10:32:14.587Z' · 9 unmodified lines
7971 `,
8072 );
8173
82− writeFileSync(
74+ NodeFS.writeFileSync(
8375 x64Path,
8476 `version: 9.9.9-smoke.0
8577 files:
@@ -102,13 +94,13 @@ function writeWindowsManifestFixtures( · 16 unmodified lines
10294 targetRoot: string,
10395 channel: string,
10496 ): { arm64Path: string; x64Path: string } {
105− const assetDirectory = resolve(targetRoot, "release-assets");
106− mkdirSync(assetDirectory, { recursive: true });
97+ const assetDirectory = NodePath.resolve(targetRoot, "release-assets");
98+ NodeFS.mkdirSync(assetDirectory, { recursive: true });
10799
108− const arm64Path = resolve(assetDirectory, `${channel}-win-arm64.yml`);
109− const x64Path = resolve(assetDirectory, `${channel}-win-x64.yml`);
100+ const arm64Path = NodePath.resolve(assetDirectory, `${channel}-win-arm64.yml`);
101+ const x64Path = NodePath.resolve(assetDirectory, `${channel}-win-x64.yml`);
110102
111− writeFileSync(
103+ NodeFS.writeFileSync(
112104 arm64Path,
113105 `version: 9.9.9-smoke.0
114106 files:
@@ -124,7 +116,7 @@ releaseDate: '2026-03-08T10:32:14.587Z' · 9 unmodified lines
124116 `,
125117 );
126118
127− writeFileSync(
119+ NodeFS.writeFileSync(
128120 x64Path,
129121 `version: 9.9.9-smoke.0
130122 files:
@@ -147,11 +139,11 @@ function writeWindowsBuilderDebugFixtures(targetRoot: string): { · 16 unmodified lines
147139 arm64Path: string;
148140 x64Path: string;
149141 } {
150− const assetDirectory = resolve(targetRoot, "release-assets");
151− mkdirSync(assetDirectory, { recursive: true });
142+ const assetDirectory = NodePath.resolve(targetRoot, "release-assets");
143+ NodeFS.mkdirSync(assetDirectory, { recursive: true });
152144
153− const arm64Path = resolve(assetDirectory, "builder-debug-win-arm64.yml");
154− const x64Path = resolve(assetDirectory, "builder-debug-win-x64.yml");
145+ const arm64Path = NodePath.resolve(assetDirectory, "builder-debug-win-arm64.yml");
146+ const x64Path = NodePath.resolve(assetDirectory, "builder-debug-win-x64.yml");
155147 const debugFixture = `arm64:
156148 firstOrDefaultFilePatterns:
157149 - '**/*'
@@ -160,8 +152,8 @@ nsis: · 2 unmodified lines
160152 !include "example.nsh"
161153 `;
162154
163− writeFileSync(arm64Path, debugFixture);
164− writeFileSync(x64Path, debugFixture);
155+ NodeFS.writeFileSync(arm64Path, debugFixture);
156+ NodeFS.writeFileSync(x64Path, debugFixture);
165157
166158 return { arm64Path, x64Path };
167159 }
@@ -172,13 +164,13 @@ function assertContains(haystack: string, needle: string, message: string): void · 4 unmodified lines
172164 }
173165
174166 function assertExists(path: string, message: string): void {
175− if (!existsSync(path)) {
167+ if (!NodeFS.existsSync(path)) {
176168 throw new Error(message);
177169 }
178170 }
179171
180172 function assertPackageVersion(path: string, version: string): void {
181− const packageJson = JSON.parse(readFileSync(path, "utf8")) as {
173+ const packageJson = JSON.parse(NodeFS.readFileSync(path, "utf8")) as {
182174 readonly version?: unknown;
183175 };
184176
@@ -188,20 +180,20 @@ function assertPackageVersion(path: string, version: string): void { · 3 unmodified lines
188180 }
189181
190182 function assertMissing(path: string, message: string): void {
191− if (existsSync(path)) {
183+ if (NodeFS.existsSync(path)) {
192184 throw new Error(message);
193185 }
194186 }
195187
196−const tempRoot = mkdtempSync(join(tmpdir(), "t3-release-smoke-"));
188+const tempRoot = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-release-smoke-"));
197189
198190 try {
199191 copyWorkspaceManifestFixture(tempRoot);
200192
201− execFileSync(
193+ NodeChildProcess.execFileSync(
202194 process.execPath,
203195 [
204− resolve(repoRoot, "scripts/update-release-package-versions.ts"),
196+ NodePath.resolve(repoRoot, "scripts/update-release-package-versions.ts"),
205197 "9.9.9-smoke.0",
206198 "--root",
207199 tempRoot,
@@ -212,14 +204,14 @@ try { · 4 unmodified lines
212204 },
213205 );
214206
215− rmSync(resolve(tempRoot, "pnpm-lock.yaml"), { force: true });
207+ NodeFS.rmSync(NodePath.resolve(tempRoot, "pnpm-lock.yaml"), { force: true });
216208
217− execFileSync("vp", ["install", "--lockfile-only", "--ignore-scripts"], {
209+ NodeChildProcess.execFileSync("vp", ["install", "--lockfile-only", "--ignore-scripts"], {
218210 cwd: tempRoot,
219211 stdio: "inherit",
220212 });
221213
222− const lockfile = readFileSync(resolve(tempRoot, "pnpm-lock.yaml"), "utf8");
214+ const lockfile = NodeFS.readFileSync(NodePath.resolve(tempRoot, "pnpm-lock.yaml"), "utf8");
223215 assertContains(lockfile, "lockfileVersion:", "Expected pnpm-lock.yaml to be regenerated.");
224216
225217 for (const relativePath of [
@@ -228,13 +220,13 @@ try { · 2 unmodified lines
228220 "apps/web/package.json",
229221 "packages/contracts/package.json",
230222 ]) {
231− assertPackageVersion(resolve(tempRoot, relativePath), "9.9.9-smoke.0");
223+ assertPackageVersion(NodePath.resolve(tempRoot, relativePath), "9.9.9-smoke.0");
232224 }
233225
234− const nightlyReleaseMetadata = execFileSync(
226+ const nightlyReleaseMetadata = NodeChildProcess.execFileSync(
235227 process.execPath,
236228 [
237− resolve(repoRoot, "scripts/resolve-nightly-release.ts"),
229+ NodePath.resolve(repoRoot, "scripts/resolve-nightly-release.ts"),
238230 "--date",
239231 "20260413",
240232 "--run-number",
@@ -266,10 +258,10 @@ try { · 25 unmodified lines
266258 );
267259
268260 const { arm64Path, x64Path } = writeMacManifestFixtures(tempRoot);
269− execFileSync(
261+ NodeChildProcess.execFileSync(
270262 process.execPath,
271263 [
272− resolve(repoRoot, "scripts/merge-update-manifests.ts"),
264+ NodePath.resolve(repoRoot, "scripts/merge-update-manifests.ts"),
273265 "--platform",
274266 "mac",
275267 arm64Path,
@@ -281,7 +273,7 @@ try { · 5 unmodified lines
281273 },
282274 );
283275
284− const mergedManifest = readFileSync(arm64Path, "utf8");
276+ const mergedManifest = NodeFS.readFileSync(arm64Path, "utf8");
285277 assertContains(
286278 mergedManifest,
287279 "T3-Code-9.9.9-smoke.0-arm64.zip",
@@ -297,21 +289,21 @@ try { · 9 unmodified lines
297289 tempRoot,
298290 "latest",
299291 );
300− const mergedWindowsManifestPath = resolve(tempRoot, "release-assets/latest.yml");
292+ const mergedWindowsManifestPath = NodePath.resolve(tempRoot, "release-assets/latest.yml");
301293 const { arm64Path: nightlyWinArm64Path, x64Path: nightlyWinX64Path } =
302294 writeWindowsManifestFixtures(tempRoot, "nightly");
303− const mergedNightlyWindowsManifestPath = resolve(tempRoot, "release-assets/nightly.yml");
295+ const mergedNightlyWindowsManifestPath = NodePath.resolve(tempRoot, "release-assets/nightly.yml");
304296 const { arm64Path: previewWinArm64Path, x64Path: previewWinX64Path } =
305297 writeWindowsManifestFixtures(tempRoot, "preview");
306− const mergedPreviewWindowsManifestPath = resolve(tempRoot, "release-assets/preview.yml");
298+ const mergedPreviewWindowsManifestPath = NodePath.resolve(tempRoot, "release-assets/preview.yml");
307299 const { arm64Path: winDebugArm64Path, x64Path: winDebugX64Path } =
308300 writeWindowsBuilderDebugFixtures(tempRoot);
309− execFileSync(
301+ NodeChildProcess.execFileSync(
310302 "bash",
311303 [
312304 "-lc",
313305 `
314− release_assets_dir=${JSON.stringify(resolve(tempRoot, "release-assets"))}
306+ release_assets_dir=${JSON.stringify(NodePath.resolve(tempRoot, "release-assets"))}
315307 shopt -s nullglob
316308 found_windows_manifest=false
317309 for x64_manifest in "$release_assets_dir"/*-win-x64.yml; do
@@ -327,7 +319,7 @@ try { · 9 unmodified lines
327319 fi
328320
329321 found_windows_manifest=true
330− ${JSON.stringify(process.execPath)} ${JSON.stringify(resolve(repoRoot, "scripts/merge-update-manifests.ts"))} --platform win \
322+ ${JSON.stringify(process.execPath)} ${JSON.stringify(NodePath.resolve(repoRoot, "scripts/merge-update-manifests.ts"))} --platform win \
331323 "$arm64_manifest" \
332324 "$x64_manifest" \
333325 "$output_manifest"
@@ -346,7 +338,7 @@ try { · 12 unmodified lines
346338 },
347339 );
348340
349− const mergedWindowsManifest = readFileSync(mergedWindowsManifestPath, "utf8");
341+ const mergedWindowsManifest = NodeFS.readFileSync(mergedWindowsManifestPath, "utf8");
350342 assertContains(
351343 mergedWindowsManifest,
352344 "T3-Code-9.9.9-smoke.0-arm64.exe",
@@ -357,7 +349,10 @@ try { · 4 unmodified lines
357349 "T3-Code-9.9.9-smoke.0-x64.exe",
358350 "Merged Windows manifest is missing the x64 asset.",
359351 );
360− const mergedNightlyWindowsManifest = readFileSync(mergedNightlyWindowsManifestPath, "utf8");
352+ const mergedNightlyWindowsManifest = NodeFS.readFileSync(
353+ mergedNightlyWindowsManifestPath,
354+ "utf8",
355+ );
361356 assertContains(
362357 mergedNightlyWindowsManifest,
363358 "T3-Code-9.9.9-smoke.0-arm64.exe",
@@ -368,7 +363,10 @@ try { · 4 unmodified lines
368363 "T3-Code-9.9.9-smoke.0-x64.exe",
369364 "Merged nightly Windows manifest is missing the x64 asset.",
370365 );
371− const mergedPreviewWindowsManifest = readFileSync(mergedPreviewWindowsManifestPath, "utf8");
366+ const mergedPreviewWindowsManifest = NodeFS.readFileSync(
367+ mergedPreviewWindowsManifestPath,
368+ "utf8",
369+ );
372370 assertContains(
373371 mergedPreviewWindowsManifest,
374372 "T3-Code-9.9.9-smoke.0-arm64.exe",
@@ -411,5 +409,5 @@ try { · 36 unmodified lines
411409
412410 Effect.runSync(Console.log("Release smoke checks passed."));
413411 } finally {
414− rmSync(tempRoot, { recursive: true, force: true });
412+ NodeFS.rmSync(tempRoot, { recursive: true, force: true });
415413 }