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 @@
1#!/usr/bin/env node1#!/usr/bin/env node
2 2
3import { createRequire } from "node:module";3import * as NodeModule from "node:module";
4 4
5import { fromYaml } from "@t3tools/shared/schemaYaml";5import { fromYaml } from "@t3tools/shared/schemaYaml";
6import { HostProcessPlatform } from "@t3tools/shared/hostProcess";6import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
@@ -482,7 +482,7 @@ const stageClerkPasskeyNativeBinaries = Effect.fn("stageClerkPasskeyNativeBinari · 475 unmodified lines
482 path.join(stageAppDir, "node_modules", "@clerk", "electron-passkeys", "index.js"),482 path.join(stageAppDir, "node_modules", "@clerk", "electron-passkeys", "index.js"),
483 );483 );
484 const packageDir = path.dirname(packageEntryPath);484 const packageDir = path.dirname(packageEntryPath);
485 const packageRequire = createRequire(packageEntryPath);485 const packageRequire = NodeModule.createRequire(packageEntryPath);
486 486
487 for (const artifact of resolveClerkPasskeyNativeArtifacts(platform, arch)) {487 for (const artifact of resolveClerkPasskeyNativeArtifacts(platform, arch)) {
488 const sourcePath = yield* Effect.try({488 const sourcePath = yield* Effect.try({
scripts/lib/public-config.test.ts+9−9
@@ -1,7 +1,7 @@
1// @effect-diagnostics nodeBuiltinImport:off - Tests exercise root env file precedence directly.1// @effect-diagnostics nodeBuiltinImport:off - Tests exercise root env file precedence directly.
2import { mkdtempSync, rmSync, writeFileSync } from "node:fs";2import * as NodeFS from "node:fs";
3import { tmpdir } from "node:os";3import * as NodeOS from "node:os";
4import { join } from "node:path";4import * as NodePath from "node:path";
5import { afterEach, describe, expect, it } from "vite-plus/test";5import { afterEach, describe, expect, it } from "vite-plus/test";
6 6
7import { loadRepoEnv, resolvePublicConfig } from "./public-config.ts";7import { loadRepoEnv, resolvePublicConfig } from "./public-config.ts";
@@ -10,7 +10,7 @@ const temporaryDirectories: string[] = []; · 2 unmodified lines
10 10
11afterEach(() => {11afterEach(() => {
12 for (const directory of temporaryDirectories.splice(0)) {12 for (const directory of temporaryDirectories.splice(0)) {
13 rmSync(directory, { recursive: true, force: true });13 NodeFS.rmSync(directory, { recursive: true, force: true });
14 }14 }
15});15});
16 16
@@ -43,12 +43,12 @@ describe("loadRepoEnv", () => { · 26 unmodified lines
43 43
44 it("applies process, root local, and root precedence in that order", () => {44 it("applies process, root local, and root precedence in that order", () => {
45 const repoRoot = makeTemporaryDirectory();45 const repoRoot = makeTemporaryDirectory();
46 writeFileSync(46 NodeFS.writeFileSync(
47 join(repoRoot, ".env"),47 NodePath.join(repoRoot, ".env"),
48 "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",48 "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",
49 );49 );
50 writeFileSync(50 NodeFS.writeFileSync(
51 join(repoRoot, ".env.local"),51 NodePath.join(repoRoot, ".env.local"),
52 "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",52 "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",
53 );53 );
54 54
@@ -148,7 +148,7 @@ describe("loadRepoEnv", () => { · 93 unmodified lines
148});148});
149 149
150function makeTemporaryDirectory() {150function makeTemporaryDirectory() {
151 const directory = mkdtempSync(join(tmpdir(), "t3code-public-config-"));151 const directory = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3code-public-config-"));
152 temporaryDirectories.push(directory);152 temporaryDirectories.push(directory);
153 return directory;153 return directory;
154}154}
scripts/release-smoke.ts+62−64
@@ -1,21 +1,13 @@
1// @effect-diagnostics nodeBuiltinImport:off1// @effect-diagnostics nodeBuiltinImport:off
2import { execFileSync } from "node:child_process";2import * as NodeChildProcess from "node:child_process";
3import {3import * as NodeFS from "node:fs";
4 cpSync,4import * as NodeOS from "node:os";
5 existsSync,5import * as NodePath from "node:path";
6 mkdirSync,6import * as NodeURL from "node:url";
7 mkdtempSync,
8 readFileSync,
9 rmSync,
10 writeFileSync,
11} from "node:fs";
12import { tmpdir } from "node:os";
13import { dirname, join, resolve } from "node:path";
14import { fileURLToPath } from "node:url";
15import * as Console from "effect/Console";7import * as Console from "effect/Console";
16import * as Effect from "effect/Effect";8import * as Effect from "effect/Effect";
17 9
18const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");10const repoRoot = NodePath.resolve(NodePath.dirname(NodeURL.fileURLToPath(import.meta.url)), "..");
19 11
20const workspaceFiles = [12const workspaceFiles = [
21 "package.json",13 "package.json",
@@ -44,26 +36,26 @@ const workspaceFiles = [ · 22 unmodified lines
44 36
45function copyWorkspaceManifestFixture(targetRoot: string): void {37function copyWorkspaceManifestFixture(targetRoot: string): void {
46 for (const relativePath of workspaceFiles) {38 for (const relativePath of workspaceFiles) {
47 const sourcePath = resolve(repoRoot, relativePath);39 const sourcePath = NodePath.resolve(repoRoot, relativePath);
48 const destinationPath = resolve(targetRoot, relativePath);40 const destinationPath = NodePath.resolve(targetRoot, relativePath);
49 mkdirSync(dirname(destinationPath), { recursive: true });41 NodeFS.mkdirSync(NodePath.dirname(destinationPath), { recursive: true });
50 cpSync(sourcePath, destinationPath);42 NodeFS.cpSync(sourcePath, destinationPath);
51 }43 }
52 44
53 const patchesDirectory = resolve(repoRoot, "patches");45 const patchesDirectory = NodePath.resolve(repoRoot, "patches");
54 if (existsSync(patchesDirectory)) {46 if (NodeFS.existsSync(patchesDirectory)) {
55 cpSync(patchesDirectory, resolve(targetRoot, "patches"), { recursive: true });47 NodeFS.cpSync(patchesDirectory, NodePath.resolve(targetRoot, "patches"), { recursive: true });
56 }48 }
57}49}
58 50
59function writeMacManifestFixtures(targetRoot: string): { arm64Path: string; x64Path: string } {51function writeMacManifestFixtures(targetRoot: string): { arm64Path: string; x64Path: string } {
60 const assetDirectory = resolve(targetRoot, "release-assets");52 const assetDirectory = NodePath.resolve(targetRoot, "release-assets");
61 mkdirSync(assetDirectory, { recursive: true });53 NodeFS.mkdirSync(assetDirectory, { recursive: true });
62 54
63 const arm64Path = resolve(assetDirectory, "latest-mac.yml");55 const arm64Path = NodePath.resolve(assetDirectory, "latest-mac.yml");
64 const x64Path = resolve(assetDirectory, "latest-mac-x64.yml");56 const x64Path = NodePath.resolve(assetDirectory, "latest-mac-x64.yml");
65 57
66 writeFileSync(58 NodeFS.writeFileSync(
67 arm64Path,59 arm64Path,
68 `version: 9.9.9-smoke.060 `version: 9.9.9-smoke.0
69files:61files:
@@ -79,7 +71,7 @@ releaseDate: '2026-03-08T10:32:14.587Z' · 9 unmodified lines
79`,71`,
80 );72 );
81 73
82 writeFileSync(74 NodeFS.writeFileSync(
83 x64Path,75 x64Path,
84 `version: 9.9.9-smoke.076 `version: 9.9.9-smoke.0
85files:77files:
@@ -102,13 +94,13 @@ function writeWindowsManifestFixtures( · 16 unmodified lines
102 targetRoot: string,94 targetRoot: string,
103 channel: string,95 channel: string,
104): { arm64Path: string; x64Path: string } {96): { arm64Path: string; x64Path: string } {
105 const assetDirectory = resolve(targetRoot, "release-assets");97 const assetDirectory = NodePath.resolve(targetRoot, "release-assets");
106 mkdirSync(assetDirectory, { recursive: true });98 NodeFS.mkdirSync(assetDirectory, { recursive: true });
107 99
108 const arm64Path = resolve(assetDirectory, `${channel}-win-arm64.yml`);100 const arm64Path = NodePath.resolve(assetDirectory, `${channel}-win-arm64.yml`);
109 const x64Path = resolve(assetDirectory, `${channel}-win-x64.yml`);101 const x64Path = NodePath.resolve(assetDirectory, `${channel}-win-x64.yml`);
110 102
111 writeFileSync(103 NodeFS.writeFileSync(
112 arm64Path,104 arm64Path,
113 `version: 9.9.9-smoke.0105 `version: 9.9.9-smoke.0
114files:106files:
@@ -124,7 +116,7 @@ releaseDate: '2026-03-08T10:32:14.587Z' · 9 unmodified lines
124`,116`,
125 );117 );
126 118
127 writeFileSync(119 NodeFS.writeFileSync(
128 x64Path,120 x64Path,
129 `version: 9.9.9-smoke.0121 `version: 9.9.9-smoke.0
130files:122files:
@@ -147,11 +139,11 @@ function writeWindowsBuilderDebugFixtures(targetRoot: string): { · 16 unmodified lines
147 arm64Path: string;139 arm64Path: string;
148 x64Path: string;140 x64Path: string;
149} {141} {
150 const assetDirectory = resolve(targetRoot, "release-assets");142 const assetDirectory = NodePath.resolve(targetRoot, "release-assets");
151 mkdirSync(assetDirectory, { recursive: true });143 NodeFS.mkdirSync(assetDirectory, { recursive: true });
152 144
153 const arm64Path = resolve(assetDirectory, "builder-debug-win-arm64.yml");145 const arm64Path = NodePath.resolve(assetDirectory, "builder-debug-win-arm64.yml");
154 const x64Path = resolve(assetDirectory, "builder-debug-win-x64.yml");146 const x64Path = NodePath.resolve(assetDirectory, "builder-debug-win-x64.yml");
155 const debugFixture = `arm64:147 const debugFixture = `arm64:
156 firstOrDefaultFilePatterns:148 firstOrDefaultFilePatterns:
157 - '**/*'149 - '**/*'
@@ -160,8 +152,8 @@ nsis: · 2 unmodified lines
160 !include "example.nsh"152 !include "example.nsh"
161`;153`;
162 154
163 writeFileSync(arm64Path, debugFixture);155 NodeFS.writeFileSync(arm64Path, debugFixture);
164 writeFileSync(x64Path, debugFixture);156 NodeFS.writeFileSync(x64Path, debugFixture);
165 157
166 return { arm64Path, x64Path };158 return { arm64Path, x64Path };
167}159}
@@ -172,13 +164,13 @@ function assertContains(haystack: string, needle: string, message: string): void · 4 unmodified lines
172}164}
173 165
174function assertExists(path: string, message: string): void {166function assertExists(path: string, message: string): void {
175 if (!existsSync(path)) {167 if (!NodeFS.existsSync(path)) {
176 throw new Error(message);168 throw new Error(message);
177 }169 }
178}170}
179 171
180function assertPackageVersion(path: string, version: string): void {172function 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 {
182 readonly version?: unknown;174 readonly version?: unknown;
183 };175 };
184 176
@@ -188,20 +180,20 @@ function assertPackageVersion(path: string, version: string): void { · 3 unmodified lines
188}180}
189 181
190function assertMissing(path: string, message: string): void {182function assertMissing(path: string, message: string): void {
191 if (existsSync(path)) {183 if (NodeFS.existsSync(path)) {
192 throw new Error(message);184 throw new Error(message);
193 }185 }
194}186}
195 187
196const tempRoot = mkdtempSync(join(tmpdir(), "t3-release-smoke-"));188const tempRoot = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-release-smoke-"));
197 189
198try {190try {
199 copyWorkspaceManifestFixture(tempRoot);191 copyWorkspaceManifestFixture(tempRoot);
200 192
201 execFileSync(193 NodeChildProcess.execFileSync(
202 process.execPath,194 process.execPath,
203 [195 [
204 resolve(repoRoot, "scripts/update-release-package-versions.ts"),196 NodePath.resolve(repoRoot, "scripts/update-release-package-versions.ts"),
205 "9.9.9-smoke.0",197 "9.9.9-smoke.0",
206 "--root",198 "--root",
207 tempRoot,199 tempRoot,
@@ -212,14 +204,14 @@ try { · 4 unmodified lines
212 },204 },
213 );205 );
214 206
215 rmSync(resolve(tempRoot, "pnpm-lock.yaml"), { force: true });207 NodeFS.rmSync(NodePath.resolve(tempRoot, "pnpm-lock.yaml"), { force: true });
216 208
217 execFileSync("vp", ["install", "--lockfile-only", "--ignore-scripts"], {209 NodeChildProcess.execFileSync("vp", ["install", "--lockfile-only", "--ignore-scripts"], {
218 cwd: tempRoot,210 cwd: tempRoot,
219 stdio: "inherit",211 stdio: "inherit",
220 });212 });
221 213
222 const lockfile = readFileSync(resolve(tempRoot, "pnpm-lock.yaml"), "utf8");214 const lockfile = NodeFS.readFileSync(NodePath.resolve(tempRoot, "pnpm-lock.yaml"), "utf8");
223 assertContains(lockfile, "lockfileVersion:", "Expected pnpm-lock.yaml to be regenerated.");215 assertContains(lockfile, "lockfileVersion:", "Expected pnpm-lock.yaml to be regenerated.");
224 216
225 for (const relativePath of [217 for (const relativePath of [
@@ -228,13 +220,13 @@ try { · 2 unmodified lines
228 "apps/web/package.json",220 "apps/web/package.json",
229 "packages/contracts/package.json",221 "packages/contracts/package.json",
230 ]) {222 ]) {
231 assertPackageVersion(resolve(tempRoot, relativePath), "9.9.9-smoke.0");223 assertPackageVersion(NodePath.resolve(tempRoot, relativePath), "9.9.9-smoke.0");
232 }224 }
233 225
234 const nightlyReleaseMetadata = execFileSync(226 const nightlyReleaseMetadata = NodeChildProcess.execFileSync(
235 process.execPath,227 process.execPath,
236 [228 [
237 resolve(repoRoot, "scripts/resolve-nightly-release.ts"),229 NodePath.resolve(repoRoot, "scripts/resolve-nightly-release.ts"),
238 "--date",230 "--date",
239 "20260413",231 "20260413",
240 "--run-number",232 "--run-number",
@@ -266,10 +258,10 @@ try { · 25 unmodified lines
266 );258 );
267 259
268 const { arm64Path, x64Path } = writeMacManifestFixtures(tempRoot);260 const { arm64Path, x64Path } = writeMacManifestFixtures(tempRoot);
269 execFileSync(261 NodeChildProcess.execFileSync(
270 process.execPath,262 process.execPath,
271 [263 [
272 resolve(repoRoot, "scripts/merge-update-manifests.ts"),264 NodePath.resolve(repoRoot, "scripts/merge-update-manifests.ts"),
273 "--platform",265 "--platform",
274 "mac",266 "mac",
275 arm64Path,267 arm64Path,
@@ -281,7 +273,7 @@ try { · 5 unmodified lines
281 },273 },
282 );274 );
283 275
284 const mergedManifest = readFileSync(arm64Path, "utf8");276 const mergedManifest = NodeFS.readFileSync(arm64Path, "utf8");
285 assertContains(277 assertContains(
286 mergedManifest,278 mergedManifest,
287 "T3-Code-9.9.9-smoke.0-arm64.zip",279 "T3-Code-9.9.9-smoke.0-arm64.zip",
@@ -297,21 +289,21 @@ try { · 9 unmodified lines
297 tempRoot,289 tempRoot,
298 "latest",290 "latest",
299 );291 );
300 const mergedWindowsManifestPath = resolve(tempRoot, "release-assets/latest.yml");292 const mergedWindowsManifestPath = NodePath.resolve(tempRoot, "release-assets/latest.yml");
301 const { arm64Path: nightlyWinArm64Path, x64Path: nightlyWinX64Path } =293 const { arm64Path: nightlyWinArm64Path, x64Path: nightlyWinX64Path } =
302 writeWindowsManifestFixtures(tempRoot, "nightly");294 writeWindowsManifestFixtures(tempRoot, "nightly");
303 const mergedNightlyWindowsManifestPath = resolve(tempRoot, "release-assets/nightly.yml");295 const mergedNightlyWindowsManifestPath = NodePath.resolve(tempRoot, "release-assets/nightly.yml");
304 const { arm64Path: previewWinArm64Path, x64Path: previewWinX64Path } =296 const { arm64Path: previewWinArm64Path, x64Path: previewWinX64Path } =
305 writeWindowsManifestFixtures(tempRoot, "preview");297 writeWindowsManifestFixtures(tempRoot, "preview");
306 const mergedPreviewWindowsManifestPath = resolve(tempRoot, "release-assets/preview.yml");298 const mergedPreviewWindowsManifestPath = NodePath.resolve(tempRoot, "release-assets/preview.yml");
307 const { arm64Path: winDebugArm64Path, x64Path: winDebugX64Path } =299 const { arm64Path: winDebugArm64Path, x64Path: winDebugX64Path } =
308 writeWindowsBuilderDebugFixtures(tempRoot);300 writeWindowsBuilderDebugFixtures(tempRoot);
309 execFileSync(301 NodeChildProcess.execFileSync(
310 "bash",302 "bash",
311 [303 [
312 "-lc",304 "-lc",
313 `305 `
314 release_assets_dir=${JSON.stringify(resolve(tempRoot, "release-assets"))}306 release_assets_dir=${JSON.stringify(NodePath.resolve(tempRoot, "release-assets"))}
315 shopt -s nullglob307 shopt -s nullglob
316 found_windows_manifest=false308 found_windows_manifest=false
317 for x64_manifest in "$release_assets_dir"/*-win-x64.yml; do309 for x64_manifest in "$release_assets_dir"/*-win-x64.yml; do
@@ -327,7 +319,7 @@ try { · 9 unmodified lines
327 fi319 fi
328 320
329 found_windows_manifest=true321 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 \
331 "$arm64_manifest" \323 "$arm64_manifest" \
332 "$x64_manifest" \324 "$x64_manifest" \
333 "$output_manifest"325 "$output_manifest"
@@ -346,7 +338,7 @@ try { · 12 unmodified lines
346 },338 },
347 );339 );
348 340
349 const mergedWindowsManifest = readFileSync(mergedWindowsManifestPath, "utf8");341 const mergedWindowsManifest = NodeFS.readFileSync(mergedWindowsManifestPath, "utf8");
350 assertContains(342 assertContains(
351 mergedWindowsManifest,343 mergedWindowsManifest,
352 "T3-Code-9.9.9-smoke.0-arm64.exe",344 "T3-Code-9.9.9-smoke.0-arm64.exe",
@@ -357,7 +349,10 @@ try { · 4 unmodified lines
357 "T3-Code-9.9.9-smoke.0-x64.exe",349 "T3-Code-9.9.9-smoke.0-x64.exe",
358 "Merged Windows manifest is missing the x64 asset.",350 "Merged Windows manifest is missing the x64 asset.",
359 );351 );
360 const mergedNightlyWindowsManifest = readFileSync(mergedNightlyWindowsManifestPath, "utf8");352 const mergedNightlyWindowsManifest = NodeFS.readFileSync(
353 mergedNightlyWindowsManifestPath,
354 "utf8",
355 );
361 assertContains(356 assertContains(
362 mergedNightlyWindowsManifest,357 mergedNightlyWindowsManifest,
363 "T3-Code-9.9.9-smoke.0-arm64.exe",358 "T3-Code-9.9.9-smoke.0-arm64.exe",
@@ -368,7 +363,10 @@ try { · 4 unmodified lines
368 "T3-Code-9.9.9-smoke.0-x64.exe",363 "T3-Code-9.9.9-smoke.0-x64.exe",
369 "Merged nightly Windows manifest is missing the x64 asset.",364 "Merged nightly Windows manifest is missing the x64 asset.",
370 );365 );
371 const mergedPreviewWindowsManifest = readFileSync(mergedPreviewWindowsManifestPath, "utf8");366 const mergedPreviewWindowsManifest = NodeFS.readFileSync(
367 mergedPreviewWindowsManifestPath,
368 "utf8",
369 );
372 assertContains(370 assertContains(
373 mergedPreviewWindowsManifest,371 mergedPreviewWindowsManifest,
374 "T3-Code-9.9.9-smoke.0-arm64.exe",372 "T3-Code-9.9.9-smoke.0-arm64.exe",
@@ -411,5 +409,5 @@ try { · 36 unmodified lines
411 409
412 Effect.runSync(Console.log("Release smoke checks passed."));410 Effect.runSync(Console.log("Release smoke checks passed."));
413} finally {411} finally {
414 rmSync(tempRoot, { recursive: true, force: true });412 NodeFS.rmSync(tempRoot, { recursive: true, force: true });
415}413}