Skip to content

Commit 899ab89

Browse files
Brooooooklynclaude
andauthored
chore: remove dead code, slop, over tests and comment noise before open source (#400)
## Problem Before open source, a review of the SDK, framework and CLI packages (`packages/*`) found 737 cleanup issues of four kinds: ``` over tests 322 tests of repo tooling, tests for tests, duplicate tests slop 241 needless defensive code, copies of helpers, pass-through wrappers, test-only seams over comments 113 bug-fix history, essays, stale line references, comments that repeat the code dead code 61 unused exports, branches, params, files ``` This PR removes them. It does not fix bugs or change behavior. The real bugs from the same review go in separate PRs. ## What this PR changes ``` packages/* 620 files +22.9k −63.1k (net −40k lines) ├─ tests +15.3k −43.7k └─ source +7.6k −19.5k 737 issues ──► 555 fixed 117 partly fixed (the safe part only) 56 skipped (public API, behavior change, or needs a new public export) 9 left for an owner decision ``` Larger items: ``` provision.ts 4,975 → 3,224 lines. A 440-line Proxy-safe redaction for a path that production never used is now a small helper. client.ts 2,479 → 1,918 lines. About 55 endpoints share one private request helper. installer phases 11 get/set accessor pairs → one run-state object config readers duplicate Wrangler config readers and record guards → shared internal ones tooling tests 10 SDK test files that tested repo scripts or test config → removed. vp run check now typechecks root test/ and .github/scripts instead. ``` ## Decisions | Topic | Decision | | --- | --- | | Behavior | No reachable change. Return values, thrown errors and messages, CLI output, exit codes, files written and network calls stay the same. | | Path patterns | `@void/edge` matches header, revalidate and routing patterns with a small parser instead of a RegExp built from the pattern. Results stay the same for every pattern the old code could run. Patterns too large for V8 now match instead of failing, and catastrophic backtracking is gone. | | User-visible text | Kept as it is on main, even where the wording is out of date (for example `void.json`, "Wrangler"). Wording changes need their own PRs. | | Public API | Every published export and documented feature stays. The generated Pages client entry still exports `router`. | | Deleted tests | Each one either tested tooling or config, or another test still asserts the same behavior. Unique assertions moved into the kept test. | | Shared helpers | Only internal modules. No new public exports, and no `packages/*` import from `platform/`. | ## Rollout ``` main ── #399 (Cloudflare e2e fixes) ── this PR (cleanup) ``` Stacked on #399, because both PRs touch the same installer and deploy files. Merge #399 first. ## Known limits - In one middle commit the typecheck fails until a later commit (`test(cli): pass explicit access ...`). This matters only for bisect, because the PR is squash-merged. - Independent review rounds found 35 places where the cleanup changed behavior or lost unique coverage. All 35 are restored here. - The removed tooling tests leave three scripts without tests: `.github/scripts/production-baseline.ts`, `.github/scripts/schema-compat-tests.ts` (CI only) and `packages/platform/scripts/source-revision.mjs` (build time, display only). ## Testing | Check | Result | | --- | --- | | `vp run build:all` + `node test/check-playground-build-artifacts.mjs` | pass | | `vp run check` (31 typecheck tasks) | pass | | `vp lint`, `vp fmt --check .` | pass (2,477 files formatted) | | `vp test run` (full suite) | 685 files, 12,942 tests pass (1 file, 30 tests skipped) | | `vp run test --base <previous head>` (latest restores) | 13 files, 497 tests pass | | Restored tests | Each one fails when its code is broken on purpose | 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0123r5HnanmW2VUrZ7VWDufH --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent ad7e6ca commit 899ab89

627 files changed

Lines changed: 23515 additions & 63189 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/scripts/postgres-concurrency-tests.ts‎

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { spawnSync } from 'node:child_process';
22
import { readFileSync } from 'node:fs';
33
// eslint-disable-next-line no-restricted-imports -- Native filesystem paths are never embedded in source.
44
import { join } from 'node:path';
5-
import { fileURLToPath, pathToFileURL } from 'node:url';
5+
import { fileURLToPath } from 'node:url';
66
import { parseSync } from 'vite';
77
import { isRecord } from '../../packages/deploy-core/src/is-record.ts';
88
import { compatibilityTestFiles } from './schema-compat-tests.ts';
@@ -38,7 +38,7 @@ function usesPostgresEnvironment(node: unknown): boolean {
3838
}
3939

4040
/** Select real PostgreSQL cases without repeating the whole in-memory API suite. */
41-
export function postgresConcurrencyTestFiles(root: string): Array<string> {
41+
function postgresConcurrencyTestFiles(root: string): Array<string> {
4242
const files = compatibilityTestFiles(root).filter((file) => {
4343
const parsed = parseSync(file, readFileSync(join(root, file), 'utf8'));
4444
if (parsed.errors.length > 0) {
@@ -52,16 +52,14 @@ export function postgresConcurrencyTestFiles(root: string): Array<string> {
5252
return files;
5353
}
5454

55-
if (process.argv[1] && pathToFileURL(process.argv[1]).href === import.meta.url) {
56-
const files = postgresConcurrencyTestFiles(process.cwd());
57-
// Reuse the bounded runner's independent database clones and cleanup for every file.
58-
const result = spawnSync(
59-
process.execPath,
60-
[fileURLToPath(new URL('./schema-compat-tests.ts', import.meta.url)), ...files],
61-
{ stdio: 'inherit' },
62-
);
63-
if (result.error) {
64-
throw result.error;
65-
}
66-
process.exitCode = result.status ?? 1;
55+
const files = postgresConcurrencyTestFiles(process.cwd());
56+
// Reuse the bounded runner's independent database clones and cleanup for every file.
57+
const result = spawnSync(
58+
process.execPath,
59+
[fileURLToPath(new URL('./schema-compat-tests.ts', import.meta.url)), ...files],
60+
{ stdio: 'inherit' },
61+
);
62+
if (result.error) {
63+
throw result.error;
6764
}
65+
process.exitCode = result.status ?? 1;

‎.github/scripts/production-baseline.ts‎

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { appendFileSync } from 'node:fs';
2-
import { pathToFileURL } from 'node:url';
32

4-
export async function productionBaseline(options: {
3+
async function productionBaseline(options: {
54
configuredSha?: string;
65
repository: string;
76
token?: string;
8-
environment?: string;
9-
request?: typeof fetch;
7+
environment: string;
108
}): Promise<string> {
119
if (options.configuredSha) {
1210
if (options.configuredSha.length !== 40 || !/^[0-9a-f]{40}$/i.test(options.configuredSha)) {
@@ -21,11 +19,10 @@ export async function productionBaseline(options: {
2119
'Provide a GitHub repository and read token, or set VOID_PLATFORM_PRODUCTION_REF to the deployed SHA.',
2220
);
2321
}
24-
const request = options.request ?? fetch;
2522
const signal = AbortSignal.timeout(60_000);
26-
const environment = options.environment ?? 'Prod';
23+
const { environment } = options;
2724
const get = async (path: string): Promise<unknown> => {
28-
const response = await request(`https://api.github.com/repos/${options.repository}/${path}`, {
25+
const response = await fetch(`https://api.github.com/repos/${options.repository}/${path}`, {
2926
headers: {
3027
Accept: 'application/vnd.github+json',
3128
Authorization: `Bearer ${options.token}`,
@@ -70,15 +67,13 @@ export async function productionBaseline(options: {
7067
);
7168
}
7269

73-
if (process.argv[1] && pathToFileURL(process.argv[1]).href === import.meta.url) {
74-
const sha = await productionBaseline({
75-
configuredSha: process.env.PRODUCTION_REF,
76-
repository: process.env.GITHUB_REPOSITORY ?? '',
77-
token: process.env.GITHUB_TOKEN,
78-
environment: process.env.PRODUCTION_ENVIRONMENT || 'Prod',
79-
});
80-
if (process.env.GITHUB_OUTPUT) {
81-
appendFileSync(process.env.GITHUB_OUTPUT, `sha=${sha}\n`);
82-
}
83-
console.log(`Previous production runtime: ${sha}`);
70+
const sha = await productionBaseline({
71+
configuredSha: process.env.PRODUCTION_REF,
72+
repository: process.env.GITHUB_REPOSITORY ?? '',
73+
token: process.env.GITHUB_TOKEN,
74+
environment: process.env.PRODUCTION_ENVIRONMENT || 'Prod',
75+
});
76+
if (process.env.GITHUB_OUTPUT) {
77+
appendFileSync(process.env.GITHUB_OUTPUT, `sha=${sha}\n`);
8478
}
79+
console.log(`Previous production runtime: ${sha}`);

‎.github/scripts/schema-compat-tests.ts‎

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { createRequire } from 'node:module';
77
import { join, relative, resolve } from 'node:path';
88
import { pathToFileURL } from 'node:url';
99

10-
export const legacyZoneFixture = ` const second = await createTestProject(env.db, user.id, 'concurrent-zone-second');
10+
const legacyZoneFixture = ` const second = await createTestProject(env.db, user.id, 'concurrent-zone-second');
1111
stubCustomerCf({ zones });`;
12-
export const correctedZoneFixture = ` const second = await createTestProject(env.db, user.id, 'concurrent-zone-second');
12+
const correctedZoneFixture = ` const second = await createTestProject(env.db, user.id, 'concurrent-zone-second');
1313
const mx: Record<string, Array<string>> = {
1414
'concurrent-one.example.com': [],
1515
'concurrent-two.example.com': [],
@@ -32,13 +32,13 @@ export const correctedZoneFixture = ` const second = await createTestProjec
3232
},
3333
});`;
3434

35-
export const legacyZoneProvision = ` await runEmailOperation(env.db, bindings(), accepted.value.operationId);`;
36-
export const correctedZoneProvision = ` provisionedDomain = (await env.db.select().from(emailDomainRoutes))[0]!.domain;
35+
const legacyZoneProvision = ` await runEmailOperation(env.db, bindings(), accepted.value.operationId);`;
36+
const correctedZoneProvision = ` provisionedDomain = (await env.db.select().from(emailDomainRoutes))[0]!.domain;
3737
await runEmailOperation(env.db, bindings(), accepted.value.operationId);`;
3838

39-
export const legacyDeployBodyFixture = ` expect(res.status).not.toBe(413);
39+
const legacyDeployBodyFixture = ` expect(res.status).not.toBe(413);
4040
});`;
41-
export const correctedDeployBodyFixture = ` expect(res.status).not.toBe(413);
41+
const correctedDeployBodyFixture = ` expect(res.status).not.toBe(413);
4242
// Finish the deployment's database work before the next fixture resets its tables.
4343
await res.text();
4444
});`;
@@ -63,7 +63,7 @@ function correctKnownFixture(
6363
}
6464

6565
/** Correct only the known deployed test fixture; runtime code and every assertion stay intact. */
66-
export function correctLegacyEmailFixture(source: string): string {
66+
function correctLegacyEmailFixture(source: string): string {
6767
return correctKnownFixture(
6868
source,
6969
'bf3ec4cd84c85a9e2cd01c7906ca6952dce5d7b957dc38487d6cfe99e9257eed',
@@ -74,7 +74,7 @@ export function correctLegacyEmailFixture(source: string): string {
7474
);
7575
}
7676

77-
export function correctLegacyDeployFixture(source: string): string {
77+
function correctLegacyDeployFixture(source: string): string {
7878
return correctKnownFixture(
7979
source,
8080
'a62cdbc79573bba09da2212c441ebdcec74569d5ec4193d494f54fad98722f33',
@@ -83,7 +83,7 @@ export function correctLegacyDeployFixture(source: string): string {
8383
}
8484

8585
/** Only the disposable CI database may be used as a template. */
86-
export function compatibilityTemplate(value: string): URL {
86+
function compatibilityTemplate(value: string): URL {
8787
let url: URL;
8888
try {
8989
url = new URL(value);
@@ -120,18 +120,14 @@ export function compatibilityTestFiles(root: string): Array<string> {
120120
}
121121

122122
/** Keep the deployed runtime/tests intact, with one upgraded database snapshot per file. */
123-
export async function runIsolatedCompatibilityTests(options: {
123+
async function runIsolatedCompatibilityTests(options: {
124124
templateUrl: string;
125125
files: ReadonlyArray<string>;
126126
query: (statement: string) => Promise<unknown>;
127127
runTest: (file: string, databaseUrl: string) => Promise<number>;
128-
concurrency?: number;
129128
}): Promise<Array<string>> {
130129
const template = compatibilityTemplate(options.templateUrl);
131-
const concurrency = options.concurrency ?? 2;
132-
if (!Number.isInteger(concurrency) || concurrency < 1 || concurrency > 4) {
133-
throw new Error('Compatibility concurrency must be between 1 and 4.');
134-
}
130+
const concurrency = 2;
135131
if (!options.files.length || new Set(options.files).size !== options.files.length) {
136132
throw new Error('Compatibility tests must contain unique test files.');
137133
}

‎.github/scripts/schema-fixture.mjs‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ const PROJECT_MODE_MIGRATION = {
99
timestamp: 1790841384175,
1010
};
1111

12-
export function isProjectModeMigrationApplied(rows) {
12+
function isProjectModeMigrationApplied(rows) {
1313
return (
1414
rows.length === 1 &&
1515
rows[0].hash === PROJECT_MODE_MIGRATION.hash &&
1616
String(rows[0].created_at) === String(PROJECT_MODE_MIGRATION.timestamp)
1717
);
1818
}
1919

20-
export function assertSchemaFixturePreserved(original, rows, projectModeMigrationApplied = false) {
20+
function assertSchemaFixturePreserved(original, rows, projectModeMigrationApplied = false) {
2121
for (const [table, row] of Object.entries(original)) {
2222
for (const [key, value] of Object.entries(row)) {
2323
// 0054 deliberately normalizes the obsolete Worker mode to the public
@@ -40,11 +40,11 @@ export function assertSchemaFixturePreserved(original, rows, projectModeMigratio
4040
}
4141
}
4242

43-
export async function runSchemaFixture(command, env = process.env) {
43+
async function runSchemaFixture(command) {
4444
const snapshot =
45-
env.COMPAT_FIXTURE_PATH ??
46-
(env.RUNNER_TEMP ? `${env.RUNNER_TEMP}/void-schema-fixture.json` : undefined);
47-
if (!snapshot || !env.COMPAT_DATABASE_URL) {
45+
process.env.COMPAT_FIXTURE_PATH ??
46+
(process.env.RUNNER_TEMP ? `${process.env.RUNNER_TEMP}/void-schema-fixture.json` : undefined);
47+
if (!snapshot || !process.env.COMPAT_DATABASE_URL) {
4848
throw new Error('A disposable compatibility database and fixture path are required.');
4949
}
5050
if (command !== 'seed' && command !== 'verify') {
@@ -55,7 +55,7 @@ export async function runSchemaFixture(command, env = process.env) {
5555
const { Pool } = createRequire(
5656
pathToFileURL(`${process.cwd()}/platform/packages/api/package.json`),
5757
)('pg');
58-
const pool = new Pool({ connectionString: env.COMPAT_DATABASE_URL });
58+
const pool = new Pool({ connectionString: process.env.COMPAT_DATABASE_URL });
5959
try {
6060
if (command === 'seed') {
6161
await pool.query(
@@ -104,6 +104,4 @@ export async function runSchemaFixture(command, env = process.env) {
104104
}
105105
}
106106

107-
if (process.argv[1] && pathToFileURL(process.argv[1]).href === import.meta.url) {
108-
await runSchemaFixture(process.argv[2]);
109-
}
107+
await runSchemaFixture(process.argv[2]);

‎TESTING.md‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ The runner adds coverage that imports cannot describe:
5151
`--list` does not refresh builds, so built-export coverage can expand when the command executes.
5252
Affected selection is conservative, not a proof that all behavior is covered: computed imports,
5353
filesystem reads, generated artifacts, and external services can introduce additional dependencies.
54-
Explicitly run a known consumer when changing one of those boundaries, and add a selector regression
55-
when introducing a new fixture layout. Changes to packaging still need the packed checks below;
56-
changes to metaframework output still need `build:all` and the artifact check.
54+
Explicitly run a known consumer when changing one of those boundaries. Changes to packaging still
55+
need the packed checks below; changes to metaframework output still need `build:all` and the
56+
artifact check.
5757

5858
For a leaf-module edit with known import-based consumers, Vitest's native related command is useful:
5959

@@ -143,16 +143,14 @@ repeat those production builds. `vpr test:all` runs the same artifact check loca
143143

144144
Integration sharding uses [measured duration estimates](test/integration-timings.ts), rather than
145145
filename hashes. [The sequencer](test/sequencer.ts) packs the longest files first and starts costly
146-
fixtures early. Estimates affect scheduling only: new files receive a fallback estimate, and
147-
membership tests ensure every discovered file appears exactly once. Refresh the estimates when
148-
the suite's costs change materially. Seeded file shuffling remains available for isolation checks.
146+
fixtures early. Estimates affect scheduling only: new files receive a fallback estimate. Refresh
147+
the estimates when the suite's costs change materially. Seeded file shuffling remains available
148+
for isolation checks.
149149

150150
The four adapter suites share their client and island test definitions in `test/`. Each runs the
151151
full browser behavior contract against its production preview build, plus a dev-mode navigation,
152152
island hydration/interaction smoke check, SSR/protocol assertions, and HMR checks. This keeps both
153-
runtime modes covered without repeating the full browser matrix. Before integrations start,
154-
their sources are snapshotted so another test cloning a fixture cannot capture an in-flight HMR
155-
edit. Dependencies stay linked to the installed workspace, and snapshots are removed afterward.
153+
runtime modes covered without repeating the full browser matrix.
156154

157155
Use production functions in unit tests. A copy of a hook's implementation inside a test cannot
158156
catch regressions in the real hook. Shared form-value equality has one direct suite, and actual
@@ -247,8 +245,7 @@ VOID_TEST_BROWSER=webkit vp test run packages/react/test/integration packages/vu
247245
Use `waitForIslandsHydrated` from `test/browser-helpers.ts` before asserting island state or
248246
interacting with islands. Pass the expected minimum count when checking a multi-island fixture.
249247
Each island imports and hydrates independently, so a selector matching one hydrated island does
250-
not establish that its siblings are ready. The helper rejects empty or partially hydrated pages;
251-
`packages/void/test/integration/browser-helpers.test.ts` covers these cases.
248+
not establish that its siblings are ready. The helper rejects empty or partially hydrated pages.
252249

253250
For SPA navigation, wait for a client readiness signal before setting the document marker and
254251
clicking. The Nuxt and SvelteKit playgrounds expose `h1[data-hydrated="true"]` after client startup.

‎packages/create-void/src/pm.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { join } from 'pathslash';
44

55
export type PM = 'npm' | 'pnpm' | 'yarn' | 'bun';
66

7-
export const VOID_PNPM_ALLOWED_BUILDS = ['esbuild', 'sharp', 'workerd'] as const;
7+
const VOID_PNPM_ALLOWED_BUILDS = ['esbuild', 'sharp', 'workerd'] as const;
88

99
/** Write the explicit build-script policy required by a new pnpm project. */
1010
export function writePnpmBuildPolicy(root: string, pm: PM): void {

‎packages/create-void/test/unit/pm.test.ts‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
22
import { tmpdir } from 'node:os';
33
import { join } from 'node:path';
44
import { afterEach, describe, expect, it } from 'vite-plus/test';
5-
import { VOID_PNPM_ALLOWED_BUILDS, writePnpmBuildPolicy } from '../../src/pm.ts';
5+
import { writePnpmBuildPolicy } from '../../src/pm.ts';
66

77
const temporaryDirectories: Array<string> = [];
88

@@ -20,7 +20,7 @@ describe('create-void package manager bootstrap', () => {
2020
writePnpmBuildPolicy(root, 'pnpm');
2121

2222
expect(readFileSync(join(root, 'pnpm-workspace.yaml'), 'utf-8')).toBe(
23-
`allowBuilds:\n better-sqlite3: false\n${VOID_PNPM_ALLOWED_BUILDS.map((name) => ` ${name}: true`).join('\n')}\n`,
23+
'allowBuilds:\n better-sqlite3: false\n esbuild: true\n sharp: true\n workerd: true\n',
2424
);
2525
});
2626

@@ -34,20 +34,4 @@ describe('create-void package manager bootstrap', () => {
3434
expect(existsSync(join(root, 'pnpm-workspace.yaml'))).toBe(false);
3535
}
3636
});
37-
38-
it('stays aligned with the policy written by void init', () => {
39-
const initSource = readFileSync(
40-
join(import.meta.dirname, '../../../void/src/cli/init.ts'),
41-
'utf-8',
42-
);
43-
const declaration = initSource.match(
44-
/const PNPM_ALLOWED_BUILDS = \[([\s\S]*?)\] as const;/,
45-
)?.[1];
46-
if (!declaration) {
47-
throw new Error('Could not find the void init pnpm build policy.');
48-
}
49-
const initAllowedBuilds = [...declaration.matchAll(/'([^']+)'/g)].map((match) => match[1]);
50-
51-
expect(VOID_PNPM_ALLOWED_BUILDS).toEqual(initAllowedBuilds);
52-
});
5337
});

‎packages/deploy-cloudflare/src/config.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { existsSync, readFileSync } from 'node:fs';
2-
import { parse as parseJsoncConfig, type ParseError } from 'jsonc-parser';
2+
import { applyEdits, modify, parse as parseJsoncConfig, type ParseError } from 'jsonc-parser';
33

44
/** Parse a root Wrangler JSON/JSONC config without accepting a partial parse. */
55
export function parseRootWranglerConfig(configPath: string): Record<string, unknown> {
@@ -21,6 +21,14 @@ export function parseRootWranglerConfig(configPath: string): Record<string, unkn
2121
return parsed as Record<string, unknown>;
2222
}
2323

24+
/** Set one value in JSONC text, keeping comments and formatting elsewhere. */
25+
export function setJsoncValue(text: string, path: Array<string>, value: unknown): string {
26+
return applyEdits(
27+
text,
28+
modify(text, path, value, { formattingOptions: { insertSpaces: true, tabSize: 2, eol: '\n' } }),
29+
);
30+
}
31+
2432
export function readWranglerTopLevelString(
2533
config: Record<string, unknown>,
2634
field: string,

‎packages/deploy-cloudflare/src/framework.ts‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2-
import { applyEdits, modify, parse } from 'jsonc-parser';
2+
import { parse } from 'jsonc-parser';
33
import { dirname, join, relative } from 'pathslash';
4+
import { setJsoncValue } from './config.ts';
45

56
export type CloudflareFrameworkDeployConfig = Readonly<{
67
configPath: string;
@@ -33,12 +34,7 @@ export function writeCloudflareFrameworkDeployConfig(
3334
: '{}\n';
3435
let content = initial;
3536
const upsert = (path: Array<string>, value: unknown): void => {
36-
content = applyEdits(
37-
content,
38-
modify(content, path, value, {
39-
formattingOptions: { insertSpaces: true, tabSize: 2, eol: '\n' },
40-
}),
41-
);
37+
content = setJsoncValue(content, path, value);
4238
};
4339

4440
upsert(['name'], options.name);

‎packages/deploy-cloudflare/src/static.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
22
import type { AssetConfig, HeaderRule, RedirectRule } from '@void/deploy-core';
33
import {
4-
applyEdits,
54
createScanner,
6-
modify,
75
parse,
86
parseTree,
97
type Node,
108
type ParseError,
119
SyntaxKind,
1210
} from 'jsonc-parser';
1311
import { dirname, join, relative, resolve } from 'pathslash';
12+
import { setJsoncValue } from './config.ts';
1413

1514
export type CloudflareStaticDeployConfig = Readonly<{
1615
configPath: string;
@@ -100,10 +99,7 @@ export function writeCloudflareStaticDeployConfig(options: CloudflareStaticDeplo
10099
const originalComments = extractCommentTokens(source);
101100
let content = source;
102101
const upsert = (path: Array<string>, value: unknown): void => {
103-
const edits = modify(content, path, value, {
104-
formattingOptions: { insertSpaces: true, tabSize: 2, eol: '\n' },
105-
});
106-
content = applyEdits(content, edits);
102+
content = setJsoncValue(content, path, value);
107103
};
108104

109105
upsert(['name'], options.name);

0 commit comments

Comments
 (0)