zitejs 0.10.0-start.2 → 0.10.0-start.21
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/dist/cjs/auth/actions.d.ts +28 -0
- package/dist/cjs/auth/actions.js +93 -0
- package/dist/cjs/auth/client.d.ts +357 -0
- package/dist/cjs/auth/client.js +66 -0
- package/dist/cjs/auth/index.d.ts +2 -249
- package/dist/cjs/auth/index.js +11 -108
- package/dist/cjs/auth/index.test.js +48 -0
- package/dist/cjs/auth/previewClaim.d.ts +7 -0
- package/dist/cjs/auth/previewClaim.js +16 -0
- package/dist/cjs/auth/profileUpdates.d.ts +9 -0
- package/dist/cjs/auth/profileUpdates.js +11 -0
- package/dist/cjs/backend/index.d.ts +121 -3
- package/dist/cjs/backend/index.test.js +58 -0
- package/dist/cjs/bundle/index.d.ts +8 -0
- package/dist/cjs/bundle/index.js +9 -8
- package/dist/cjs/check/index.d.ts +45 -1
- package/dist/cjs/check/index.js +198 -109
- package/dist/cjs/check/start/problem.d.ts +11 -0
- package/dist/cjs/check/start/problem.js +5 -0
- package/dist/cjs/check/start/routeTree.d.ts +9 -0
- package/dist/cjs/check/start/routeTree.js +111 -0
- package/dist/cjs/check/start/sourceRules.d.ts +8 -0
- package/dist/cjs/check/start/sourceRules.js +1159 -0
- package/dist/cjs/check/start/tsgo.d.ts +2 -0
- package/dist/cjs/check/start/tsgo.js +35 -0
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/client/index.d.ts +24 -0
- package/dist/cjs/dev/index.js +14 -4
- package/dist/cjs/integrations/rules.d.ts +13 -0
- package/dist/cjs/integrations/rules.js +31 -0
- package/dist/cjs/integrations/rules.test.js +1 -0
- package/dist/cjs/internal/appMode.d.ts +3 -0
- package/dist/cjs/internal/appMode.js +15 -0
- package/dist/cjs/runtime/index.d.ts +64 -25
- package/dist/cjs/runtime/sendEmailParamsTypes.test-d.d.ts +1 -0
- package/dist/cjs/runtime/sendEmailParamsTypes.test-d.js +33 -0
- package/dist/cjs/start/entries.d.ts +10 -4
- package/dist/cjs/start/entries.js +23 -6
- package/dist/cjs/steps/index.d.ts +78 -0
- package/dist/cjs/steps/index.js +507 -0
- package/dist/cjs/steps/index.test.d.ts +1 -0
- package/dist/cjs/steps/index.test.js +635 -0
- package/dist/cjs/sync/index.js +2 -1
- package/dist/cjs/sync/lib.d.ts +10 -3
- package/dist/cjs/sync/lib.js +44 -25
- package/dist/cjs/sync/lib.test.js +116 -36
- package/dist/cjs/types/fields.d.ts +8 -1
- package/dist/cjs/types/fields.js +7 -1
- package/dist/cjs/types/tables.d.ts +16 -0
- package/dist/cjs/upload/index.js +12 -2
- package/dist/cjs/upload/index.test.js +39 -0
- package/dist/cjs/vite/index.js +8 -3
- package/dist/cjs/vite/index.test.js +10 -2
- package/dist/esm/auth/actions.d.ts +28 -0
- package/dist/esm/auth/actions.js +55 -0
- package/dist/esm/auth/client.d.ts +357 -0
- package/dist/esm/auth/client.js +62 -0
- package/dist/esm/auth/index.d.ts +2 -249
- package/dist/esm/auth/index.js +2 -103
- package/dist/esm/auth/index.test.js +48 -0
- package/dist/esm/auth/previewClaim.d.ts +7 -0
- package/dist/esm/auth/previewClaim.js +12 -0
- package/dist/esm/auth/profileUpdates.d.ts +9 -0
- package/dist/esm/auth/profileUpdates.js +6 -0
- package/dist/esm/backend/index.d.ts +121 -3
- package/dist/esm/backend/index.test.js +58 -0
- package/dist/esm/bundle/index.d.ts +8 -0
- package/dist/esm/bundle/index.js +8 -8
- package/dist/esm/check/index.d.ts +45 -1
- package/dist/esm/check/index.js +198 -113
- package/dist/esm/check/start/problem.d.ts +11 -0
- package/dist/esm/check/start/problem.js +1 -0
- package/dist/esm/check/start/routeTree.d.ts +9 -0
- package/dist/esm/check/start/routeTree.js +70 -0
- package/dist/esm/check/start/sourceRules.d.ts +8 -0
- package/dist/esm/check/start/sourceRules.js +1156 -0
- package/dist/esm/check/start/tsgo.d.ts +2 -0
- package/dist/esm/check/start/tsgo.js +29 -0
- package/dist/esm/cli.js +1 -1
- package/dist/esm/client/index.d.ts +24 -0
- package/dist/esm/dev/index.js +16 -6
- package/dist/esm/integrations/rules.d.ts +13 -0
- package/dist/esm/integrations/rules.js +31 -0
- package/dist/esm/integrations/rules.test.js +1 -0
- package/dist/esm/internal/appMode.d.ts +3 -0
- package/dist/esm/internal/appMode.js +10 -0
- package/dist/esm/runtime/index.d.ts +64 -25
- package/dist/esm/runtime/sendEmailParamsTypes.test-d.d.ts +1 -0
- package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +31 -0
- package/dist/esm/start/aiUsage.d.ts +23 -0
- package/dist/esm/start/aiUsage.js +146 -0
- package/dist/esm/start/airtable/arrayFields.d.ts +10 -0
- package/dist/esm/start/airtable/arrayFields.js +30 -0
- package/dist/esm/start/airtable/dispatch.d.ts +54 -0
- package/dist/esm/start/airtable/dispatch.js +483 -0
- package/dist/esm/start/airtable/formulas.d.ts +70 -0
- package/dist/esm/start/airtable/formulas.js +260 -0
- package/dist/esm/start/airtable/index.d.ts +8 -0
- package/dist/esm/start/airtable/index.js +54 -0
- package/dist/esm/start/authHooks.d.ts +7 -0
- package/dist/esm/start/authHooks.js +10 -0
- package/dist/esm/start/authHooksModule.d.ts +1 -0
- package/dist/esm/start/authHooksModule.js +3 -0
- package/dist/esm/start/clientErrorMessage.test.d.ts +1 -0
- package/dist/esm/start/clientErrorMessage.test.js +105 -0
- package/dist/esm/start/credentials.d.ts +2 -0
- package/dist/esm/start/credentials.js +2 -0
- package/dist/esm/start/data/baseRunner.d.ts +92 -0
- package/dist/esm/start/data/baseRunner.js +83 -0
- package/dist/esm/start/data/dispatch.d.ts +16 -0
- package/dist/esm/start/data/dispatch.js +198 -0
- package/dist/esm/start/data/index.d.ts +15 -0
- package/dist/esm/start/data/index.js +58 -0
- package/dist/esm/start/data/sqlNameMappings.d.ts +58 -0
- package/dist/esm/start/data/sqlNameMappings.js +92 -0
- package/dist/esm/start/data/transformations.d.ts +97 -0
- package/dist/esm/start/data/transformations.js +262 -0
- package/dist/esm/start/data/types.d.ts +91 -0
- package/dist/esm/start/data/types.js +14 -0
- package/dist/esm/start/describe.d.ts +42 -5
- package/dist/esm/start/describe.js +77 -23
- package/dist/esm/start/entries.d.ts +10 -4
- package/dist/esm/start/entries.js +21 -5
- package/dist/esm/start/errors.d.ts +63 -0
- package/dist/esm/start/errors.js +146 -0
- package/dist/esm/start/errors.test.d.ts +1 -0
- package/dist/esm/start/errors.test.js +23 -0
- package/dist/esm/start/factories.test-d.d.ts +2 -0
- package/dist/esm/start/factories.test-d.js +20 -0
- package/dist/esm/start/host.d.ts +2 -2
- package/dist/esm/start/index.d.ts +32 -27
- package/dist/esm/start/index.js +79 -47
- package/dist/esm/start/instance.d.ts +4 -4
- package/dist/esm/start/instance.js +54 -11
- package/dist/esm/start/outbound.d.ts +11 -0
- package/dist/esm/start/outbound.js +400 -0
- package/dist/esm/start/previewClaim.d.ts +7 -0
- package/dist/esm/start/previewClaim.js +23 -0
- package/dist/esm/start/problems.js +1 -1
- package/dist/esm/start/quiet.d.ts +2 -0
- package/dist/esm/start/quiet.js +27 -0
- package/dist/esm/start/redactSecrets.d.ts +15 -0
- package/dist/esm/start/redactSecrets.js +154 -0
- package/dist/esm/start/redactSecrets.test.d.ts +1 -0
- package/dist/esm/start/redactSecrets.test.js +151 -0
- package/dist/esm/start/registration.d.ts +13 -0
- package/dist/esm/start/registration.js +21 -0
- package/dist/esm/start/registrationHash.d.ts +22 -0
- package/dist/esm/start/registrationHash.js +470 -0
- package/dist/esm/start/router.d.ts +25 -4
- package/dist/esm/start/router.js +169 -11
- package/dist/esm/start/runLog.d.ts +7 -4
- package/dist/esm/start/runLog.js +64 -6
- package/dist/esm/start/scope.d.ts +4 -4
- package/dist/esm/start/server.d.ts +40 -36
- package/dist/esm/start/server.js +322 -49
- package/dist/esm/start/steps.d.ts +28 -0
- package/dist/esm/start/steps.js +97 -0
- package/dist/esm/start/types.d.ts +179 -6
- package/dist/esm/start/version.d.ts +1 -0
- package/dist/esm/start/version.js +2 -0
- package/dist/esm/start/vite.js +91 -14
- package/dist/esm/start/worker.d.ts +6 -0
- package/dist/esm/start/worker.js +12 -0
- package/dist/esm/start/workflow.d.ts +46 -12
- package/dist/esm/start/workflow.js +10 -3
- package/dist/esm/start/workflow.test-d.js +50 -8
- package/dist/esm/start/workflowModules.js +1 -1
- package/dist/esm/start/workflowRun.d.ts +26 -8
- package/dist/esm/start/workflowRun.js +39 -8
- package/dist/esm/steps/index.d.ts +78 -0
- package/dist/esm/steps/index.js +502 -0
- package/dist/esm/steps/index.test.d.ts +1 -0
- package/dist/esm/steps/index.test.js +633 -0
- package/dist/esm/sync/index.js +2 -1
- package/dist/esm/sync/lib.d.ts +10 -3
- package/dist/esm/sync/lib.js +44 -25
- package/dist/esm/sync/lib.test.js +116 -36
- package/dist/esm/types/fields.d.ts +8 -1
- package/dist/esm/types/fields.js +6 -0
- package/dist/esm/types/tables.d.ts +16 -0
- package/dist/esm/upload/index.js +12 -2
- package/dist/esm/upload/index.test.js +39 -0
- package/dist/esm/vite/index.js +8 -3
- package/dist/esm/vite/index.test.js +10 -2
- package/package.json +37 -16
- package/dist/cjs/start/problems.d.ts +0 -19
- package/dist/cjs/start/problems.js +0 -11
|
@@ -8,6 +8,8 @@ const requestContext = { user: { id: "u1", email: "a@b.c", roles: [] } };
|
|
|
8
8
|
// Direct execute() calls need the step surface the runtime always provides.
|
|
9
9
|
const stepStub = {
|
|
10
10
|
run: async (_name, fn) => await fn(),
|
|
11
|
+
sleep: async () => { },
|
|
12
|
+
sleepUntil: async () => { },
|
|
11
13
|
};
|
|
12
14
|
(0, vitest_1.afterEach)(() => {
|
|
13
15
|
vitest_1.vi.unstubAllGlobals();
|
|
@@ -207,6 +209,62 @@ const stepStub = {
|
|
|
207
209
|
return params.trigger;
|
|
208
210
|
},
|
|
209
211
|
});
|
|
212
|
+
(0, index_js_1.createEndpoint)({
|
|
213
|
+
trigger: { table: "orders", on: ["updated"], fields: ["status"] },
|
|
214
|
+
execute: async ({ input, trigger }) => {
|
|
215
|
+
// @ts-expect-error a database change has no cursor API
|
|
216
|
+
trigger?.advance("x");
|
|
217
|
+
const status = input.record?.status;
|
|
218
|
+
return { status, changed: input.changedFields, at: input.event };
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
(0, index_js_1.createEndpoint)({
|
|
222
|
+
// @ts-expect-error a database trigger names its table, not a connection
|
|
223
|
+
trigger: { table: "orders", on: ["created"], integration: "x" },
|
|
224
|
+
execute: async () => 1,
|
|
225
|
+
});
|
|
226
|
+
(0, index_js_1.createEndpoint)({
|
|
227
|
+
trigger: { form: "Intake form", on: ["submitted"] },
|
|
228
|
+
execute: async ({ input, trigger }) => {
|
|
229
|
+
// @ts-expect-error a form submission has no cursor API
|
|
230
|
+
trigger?.advance("x");
|
|
231
|
+
return {
|
|
232
|
+
email: input.answers.Email,
|
|
233
|
+
workEmail: input.answersById["wWorkEmail"],
|
|
234
|
+
id: input.submissionId,
|
|
235
|
+
};
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
(0, index_js_1.createEndpoint)({
|
|
239
|
+
// @ts-expect-error a form trigger watches submissions only
|
|
240
|
+
trigger: { form: "Intake form", on: ["updated"] },
|
|
241
|
+
execute: async () => 1,
|
|
242
|
+
});
|
|
243
|
+
(0, index_js_1.createEndpoint)({
|
|
244
|
+
// @ts-expect-error only created, updated and deleted
|
|
245
|
+
trigger: { table: "orders", on: ["archived"] },
|
|
246
|
+
execute: async () => 1,
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
(0, vitest_1.it)("hands a database trigger its change without parsing it against the input schema", async () => {
|
|
250
|
+
const endpoint = (0, index_js_1.createEndpoint)({
|
|
251
|
+
inputSchema: zod_1.z.object({ orderId: zod_1.z.string() }),
|
|
252
|
+
trigger: { table: "orders", on: ["created"] },
|
|
253
|
+
execute: async ({ input }) => input.recordId,
|
|
254
|
+
});
|
|
255
|
+
await (0, vitest_1.expect)(endpoint.execute({
|
|
256
|
+
step: stepStub,
|
|
257
|
+
input: {
|
|
258
|
+
event: "created",
|
|
259
|
+
table: "orders",
|
|
260
|
+
recordId: "rec_1",
|
|
261
|
+
record: { id: "rec_1" },
|
|
262
|
+
previous: null,
|
|
263
|
+
changedFields: [],
|
|
264
|
+
},
|
|
265
|
+
context: { user: null },
|
|
266
|
+
trigger: { headers: {}, deliveryId: "db:e1:rec_1" },
|
|
267
|
+
})).resolves.toBe("rec_1");
|
|
210
268
|
});
|
|
211
269
|
(0, vitest_1.it)("types a trigger's registration exports and checks what subscribe returns", async () => {
|
|
212
270
|
const subscribe = (async (input) => ({
|
|
@@ -20,10 +20,18 @@
|
|
|
20
20
|
* "@babel/parser": "^7.26.0"
|
|
21
21
|
*/
|
|
22
22
|
import * as esbuild from 'esbuild';
|
|
23
|
+
import { type SourceRoot } from '../sourceRoots.js';
|
|
23
24
|
export declare const UNSUPPORTED_IN_WORKERD: Set<string>;
|
|
24
25
|
export declare const BASE_BUILD_OPTIONS: esbuild.BuildOptions;
|
|
25
26
|
export declare function createAliasPlugin(opts: {
|
|
26
27
|
baseDir?: string;
|
|
27
28
|
sdkPath?: string;
|
|
28
29
|
}): esbuild.Plugin;
|
|
30
|
+
export interface EndpointBundleResult {
|
|
31
|
+
bundledEndpoints: Record<string, string>;
|
|
32
|
+
endpointErrors?: Record<string, string>;
|
|
33
|
+
bundledAuthHooks?: string;
|
|
34
|
+
authHooksError?: string;
|
|
35
|
+
}
|
|
36
|
+
export declare function bundleEndpoints(baseDir: string, root: SourceRoot, endpointNames: string[], logLevel: esbuild.LogLevel): Promise<EndpointBundleResult>;
|
|
29
37
|
export declare function runBundle(): Promise<void>;
|
package/dist/cjs/bundle/index.js
CHANGED
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.BASE_BUILD_OPTIONS = exports.UNSUPPORTED_IN_WORKERD = void 0;
|
|
37
37
|
exports.createAliasPlugin = createAliasPlugin;
|
|
38
|
+
exports.bundleEndpoints = bundleEndpoints;
|
|
38
39
|
exports.runBundle = runBundle;
|
|
39
40
|
/**
|
|
40
41
|
* `npx zitejs bundle` — Bundle endpoint files for cloudflare-lambda deployment.
|
|
@@ -404,7 +405,7 @@ import endpoint from '${entryImport}';
|
|
|
404
405
|
globalThis.__endpoint = endpoint;
|
|
405
406
|
`;
|
|
406
407
|
}
|
|
407
|
-
async function
|
|
408
|
+
async function bundleEndpoints(baseDir, root, endpointNames, logLevel) {
|
|
408
409
|
const bundledEndpoints = {};
|
|
409
410
|
const endpointErrors = {};
|
|
410
411
|
const aliasPlugin = createAliasPlugin({ baseDir });
|
|
@@ -441,7 +442,7 @@ async function bundleEndpointsImpl(baseDir, root, endpointNames) {
|
|
|
441
442
|
resolveDir: `${baseDir}/src`,
|
|
442
443
|
loader: 'ts',
|
|
443
444
|
},
|
|
444
|
-
logLevel
|
|
445
|
+
logLevel,
|
|
445
446
|
plugins: [aliasPlugin],
|
|
446
447
|
});
|
|
447
448
|
if (result.warnings && result.warnings.length > 0) {
|
|
@@ -511,7 +512,7 @@ globalThis.__endpoint = endpoint;
|
|
|
511
512
|
resolveDir: `${baseDir}/src`,
|
|
512
513
|
loader: 'ts',
|
|
513
514
|
},
|
|
514
|
-
logLevel
|
|
515
|
+
logLevel,
|
|
515
516
|
plugins: [aliasPlugin],
|
|
516
517
|
});
|
|
517
518
|
if (result.outputFiles && result.outputFiles.length > 0) {
|
|
@@ -538,14 +539,12 @@ globalThis.__endpoint = endpoint;
|
|
|
538
539
|
}
|
|
539
540
|
}
|
|
540
541
|
}
|
|
541
|
-
|
|
542
|
+
return {
|
|
542
543
|
bundledEndpoints,
|
|
543
544
|
endpointErrors: Object.keys(endpointErrors).length > 0 ? endpointErrors : undefined,
|
|
544
545
|
bundledAuthHooks,
|
|
545
546
|
authHooksError,
|
|
546
|
-
}
|
|
547
|
-
fs.writeFileSync('/tmp/zitejs-bundle-result.json', output);
|
|
548
|
-
console.log(output);
|
|
547
|
+
};
|
|
549
548
|
}
|
|
550
549
|
async function bundleOneOffScriptImpl(scriptPath, sdkPath) {
|
|
551
550
|
const rawScript = fs.readFileSync(scriptPath, 'utf-8');
|
|
@@ -663,5 +662,7 @@ async function runBundle() {
|
|
|
663
662
|
endpointNames = (0, sourceRoots_js_1.listEndpointNames)(root, baseDir);
|
|
664
663
|
}
|
|
665
664
|
// Even with no endpoints, zite.auth.ts may still need bundling.
|
|
666
|
-
|
|
665
|
+
const output = JSON.stringify(await bundleEndpoints(baseDir, root, endpointNames, 'warning'));
|
|
666
|
+
fs.writeFileSync('/tmp/zitejs-bundle-result.json', output);
|
|
667
|
+
console.log(output);
|
|
667
668
|
}
|
|
@@ -1 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
import { type Problem } from './start/problem.js';
|
|
2
|
+
/**
|
|
3
|
+
* A step's result. `unchecked` is why it couldn't answer at all (killed, out of
|
|
4
|
+
* memory, a tool missing): nothing for the app to fix, so it carries no output.
|
|
5
|
+
*/
|
|
6
|
+
type StepResult = {
|
|
7
|
+
ok: boolean;
|
|
8
|
+
output?: string;
|
|
9
|
+
unchecked?: string;
|
|
10
|
+
};
|
|
11
|
+
type Step = {
|
|
12
|
+
name: string;
|
|
13
|
+
} & StepResult;
|
|
14
|
+
/** One app's check, as `--json` reports it. */
|
|
15
|
+
export type AppCheck = {
|
|
16
|
+
path: string;
|
|
17
|
+
runtime: 'classic' | 'start';
|
|
18
|
+
/** False when something in it needs fixing. */
|
|
19
|
+
ok: boolean;
|
|
20
|
+
/** Set when a step couldn't run to an answer, so the app wasn't fully checked. */
|
|
21
|
+
unchecked?: true;
|
|
22
|
+
steps: Step[];
|
|
23
|
+
problems: Problem[];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* While `--json` checks, stdout carries only the report: app code that logs as
|
|
27
|
+
* it's described in-process goes to stderr instead.
|
|
28
|
+
*/
|
|
29
|
+
export declare const withStdoutOnStderr: <T>(run: () => Promise<T>) => Promise<T>;
|
|
30
|
+
/** Prints as it goes, or with `--json` stays quiet and reports everything at the end. */
|
|
31
|
+
export declare class Reporter {
|
|
32
|
+
private readonly json;
|
|
33
|
+
readonly apps: AppCheck[];
|
|
34
|
+
constructor(json: boolean);
|
|
35
|
+
app(path: string, runtime: AppCheck['runtime'], heading: boolean): AppCheck;
|
|
36
|
+
step(app: AppCheck, name: string, result: StepResult): boolean;
|
|
37
|
+
problems(app: AppCheck, problems: Problem[]): void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Runs a tool to its answer, or says why it gave none: a kill (a signal, or an
|
|
41
|
+
* exit of 128 and up with nothing printed) is a sandbox limit, not the app's.
|
|
42
|
+
*/
|
|
43
|
+
export declare function runTool(file: string, args: string[], cwd: string): StepResult;
|
|
44
|
+
export declare function runCheck(args?: string[]): Promise<void>;
|
|
45
|
+
export {};
|
package/dist/cjs/check/index.js
CHANGED
|
@@ -33,11 +33,16 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Reporter = exports.withStdoutOnStderr = void 0;
|
|
37
|
+
exports.runTool = runTool;
|
|
36
38
|
exports.runCheck = runCheck;
|
|
37
39
|
const child_process_1 = require("child_process");
|
|
40
|
+
const esbuild = __importStar(require("esbuild"));
|
|
38
41
|
const fs_1 = require("fs");
|
|
39
42
|
const path_1 = require("path");
|
|
43
|
+
const index_js_1 = require("../bundle/index.js");
|
|
40
44
|
const sourceRoots_js_1 = require("../sourceRoots.js");
|
|
45
|
+
const problem_js_1 = require("./start/problem.js");
|
|
41
46
|
/**
|
|
42
47
|
* An argument array, not a command string, so no shell is involved.
|
|
43
48
|
*
|
|
@@ -61,28 +66,9 @@ function run(file, args, cwd) {
|
|
|
61
66
|
return { ok: false, output: (e.stderr ?? '') + (e.stdout ?? '') };
|
|
62
67
|
}
|
|
63
68
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* still exits 0, so a non-empty `endpointErrors` is the only signal there is.
|
|
67
|
-
*/
|
|
68
|
-
function bundleFailures(output) {
|
|
69
|
-
const line = output
|
|
70
|
-
.trim()
|
|
71
|
-
.split('\n')
|
|
72
|
-
.reverse()
|
|
73
|
-
.find(l => l.startsWith('{'));
|
|
74
|
-
if (!line)
|
|
75
|
-
return ['bundle produced no result'];
|
|
76
|
-
let result;
|
|
77
|
-
try {
|
|
78
|
-
result = JSON.parse(line);
|
|
79
|
-
}
|
|
80
|
-
catch {
|
|
81
|
-
return [`could not parse bundle output: ${line.slice(0, 200)}`];
|
|
82
|
-
}
|
|
69
|
+
async function bundleFailures(root, appPath, endpointNames) {
|
|
70
|
+
const result = await (0, index_js_1.bundleEndpoints)((0, path_1.resolve)(appPath), root, endpointNames, 'silent').finally(() => esbuild.stop());
|
|
83
71
|
const failures = [];
|
|
84
|
-
if (result.error)
|
|
85
|
-
failures.push(result.error);
|
|
86
72
|
for (const [name, err] of Object.entries(result.endpointErrors ?? {})) {
|
|
87
73
|
failures.push(`${name}: ${err}`);
|
|
88
74
|
}
|
|
@@ -93,41 +79,185 @@ function bundleFailures(output) {
|
|
|
93
79
|
}
|
|
94
80
|
const indent = (output) => output.trim().split('\n').map(l => ` ${l}`).join('\n');
|
|
95
81
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* refuses, read the same way.
|
|
82
|
+
* While `--json` checks, stdout carries only the report: app code that logs as
|
|
83
|
+
* it's described in-process goes to stderr instead.
|
|
99
84
|
*/
|
|
100
|
-
async
|
|
101
|
-
process.stdout.write
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
85
|
+
const withStdoutOnStderr = async (run) => {
|
|
86
|
+
const write = process.stdout.write;
|
|
87
|
+
process.stdout.write = process.stderr.write.bind(process.stderr);
|
|
88
|
+
try {
|
|
89
|
+
return await run();
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
process.stdout.write = write;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
exports.withStdoutOnStderr = withStdoutOnStderr;
|
|
96
|
+
/** Prints as it goes, or with `--json` stays quiet and reports everything at the end. */
|
|
97
|
+
class Reporter {
|
|
98
|
+
json;
|
|
99
|
+
apps = [];
|
|
100
|
+
constructor(json) {
|
|
101
|
+
this.json = json;
|
|
102
|
+
}
|
|
103
|
+
app(path, runtime, heading) {
|
|
104
|
+
const app = { path, runtime, ok: true, steps: [], problems: [] };
|
|
105
|
+
this.apps.push(app);
|
|
106
|
+
if (heading && !this.json)
|
|
107
|
+
console.log(`\n── ${path} ──`);
|
|
108
|
+
return app;
|
|
109
|
+
}
|
|
110
|
+
step(app, name, result) {
|
|
111
|
+
if (result.unchecked) {
|
|
112
|
+
app.steps.push({ name, ok: false, unchecked: result.unchecked });
|
|
113
|
+
app.unchecked = true;
|
|
114
|
+
if (!this.json)
|
|
115
|
+
console.log(` ${name} ... unchecked: ${result.unchecked}`);
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
const output = result.output?.trim();
|
|
119
|
+
app.steps.push({ name, ok: result.ok, ...(output && !result.ok && { output }) });
|
|
120
|
+
if (!result.ok)
|
|
121
|
+
app.ok = false;
|
|
122
|
+
if (!this.json) {
|
|
123
|
+
console.log(` ${name} ... ${result.ok ? '✓' : '✗'}`);
|
|
124
|
+
if (!result.ok && output)
|
|
125
|
+
console.log(indent(output));
|
|
126
|
+
}
|
|
127
|
+
return result.ok;
|
|
128
|
+
}
|
|
129
|
+
problems(app, problems) {
|
|
130
|
+
app.problems.push(...problems);
|
|
131
|
+
if (problems.some(p => p.severity === 'error'))
|
|
132
|
+
app.ok = false;
|
|
133
|
+
if (!this.json && problems.length)
|
|
134
|
+
console.log(problems.map(p => ` ${(0, problem_js_1.formatProblem)(p)}`).join('\n'));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.Reporter = Reporter;
|
|
138
|
+
const SKIPPED_DIRS = new Set(['node_modules', 'dist', '.output', '.tanstack', '.wrangler']);
|
|
139
|
+
/** The app's own source, by app-relative path. */
|
|
140
|
+
function readAppSources(appPath) {
|
|
141
|
+
const sources = {};
|
|
142
|
+
const visit = (dir) => {
|
|
143
|
+
for (const entry of (0, fs_1.readdirSync)(dir, { withFileTypes: true })) {
|
|
144
|
+
if (SKIPPED_DIRS.has(entry.name))
|
|
145
|
+
continue;
|
|
146
|
+
const full = (0, path_1.join)(dir, entry.name);
|
|
147
|
+
if (entry.isDirectory())
|
|
148
|
+
visit(full);
|
|
149
|
+
else if (/\.[cm]?[jt]sx?$/.test(entry.name))
|
|
150
|
+
sources[(0, path_1.relative)(appPath, full)] = (0, fs_1.readFileSync)(full, 'utf-8');
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const src = (0, path_1.join)(appPath, 'src');
|
|
154
|
+
if ((0, fs_1.existsSync)(src))
|
|
155
|
+
visit(src);
|
|
156
|
+
return sources;
|
|
157
|
+
}
|
|
158
|
+
const isInternalApp = (appPath) => {
|
|
159
|
+
try {
|
|
160
|
+
return JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(appPath, 'zite.config.json'), 'utf-8'))?.accessMode === 'internal';
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
106
163
|
return false;
|
|
107
164
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* tsgo's Node launcher rethrows its compiler's kill: an exit of 1 with Node's
|
|
168
|
+
* `Error: Command failed: …/tsgo …` dump, `signal: 'SIGKILL'` included. Matched
|
|
169
|
+
* at line start, since `--pretty` quotes source lines that could hold either.
|
|
170
|
+
*/
|
|
171
|
+
const launcherKill = (output) => /^Error: Command failed: \S*tsgo\b/m.test(output) ? output.match(/\bsignal: '(SIG[A-Z]+)'/)?.[1] : undefined;
|
|
172
|
+
/**
|
|
173
|
+
* Runs a tool to its answer, or says why it gave none: a kill (a signal, or an
|
|
174
|
+
* exit of 128 and up with nothing printed) is a sandbox limit, not the app's.
|
|
175
|
+
*/
|
|
176
|
+
function runTool(file, args, cwd) {
|
|
177
|
+
const result = (0, child_process_1.spawnSync)(file, args, { cwd, encoding: 'utf-8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: 64 * 1024 * 1024 });
|
|
178
|
+
const output = (result.stderr ?? '') + (result.stdout ?? '');
|
|
179
|
+
if (result.error)
|
|
180
|
+
return { ok: false, unchecked: `couldn't run: ${result.error.message}` };
|
|
181
|
+
const signal = result.signal ?? (result.status !== 0 ? launcherKill(output) : undefined);
|
|
182
|
+
if (signal)
|
|
183
|
+
return { ok: false, unchecked: `killed by ${signal}` };
|
|
184
|
+
if (result.status !== null && result.status >= 128 && !output.trim()) {
|
|
185
|
+
return { ok: false, unchecked: `exited ${result.status} with no output` };
|
|
186
|
+
}
|
|
187
|
+
return { ok: result.status === 0, output };
|
|
188
|
+
}
|
|
189
|
+
const isMissingModule = (err) => err?.code === 'MODULE_NOT_FOUND';
|
|
190
|
+
/**
|
|
191
|
+
* A Start app, in about a second: its route tree regenerated as `vite build`
|
|
192
|
+
* writes it, a tsgo typecheck, which reads that tree, then the source rules.
|
|
193
|
+
* Neither a build nor describe: the platform's build is where access is decided
|
|
194
|
+
* and enforced, and these only say early what it would refuse.
|
|
195
|
+
*/
|
|
196
|
+
async function checkStartApp(reporter, app, appPath) {
|
|
197
|
+
const { regenerateRouteTree } = await Promise.resolve().then(() => __importStar(require('./start/routeTree.js')));
|
|
198
|
+
let routeTree = { ok: true };
|
|
115
199
|
try {
|
|
116
|
-
|
|
117
|
-
const { descriptionProblems } = await Promise.resolve().then(() => __importStar(require('../start/problems.js')));
|
|
118
|
-
const problems = descriptionProblems((await describeBuiltApp(appPath)));
|
|
119
|
-
console.log(problems.length ? '✗' : '✓');
|
|
120
|
-
if (problems.length)
|
|
121
|
-
console.log(problems.map(p => ` ${p}`).join('\n'));
|
|
122
|
-
return tsc.ok && problems.length === 0;
|
|
200
|
+
await regenerateRouteTree(appPath);
|
|
123
201
|
}
|
|
124
202
|
catch (err) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
203
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
204
|
+
routeTree = isMissingModule(err)
|
|
205
|
+
? { ok: false, unchecked: `the app's TanStack Start isn't installed: ${message}` }
|
|
206
|
+
: { ok: false, output: message };
|
|
207
|
+
}
|
|
208
|
+
if (reporter.step(app, 'route tree', routeTree)) {
|
|
209
|
+
const { findTsgo } = await Promise.resolve().then(() => __importStar(require('./start/tsgo.js')));
|
|
210
|
+
const tsgo = findTsgo(appPath);
|
|
211
|
+
reporter.step(app, 'tsgo --noEmit', !(0, fs_1.existsSync)((0, path_1.join)(appPath, 'tsconfig.app.json'))
|
|
212
|
+
? { ok: false, output: `no ${(0, path_1.join)(appPath, 'tsconfig.app.json')}` }
|
|
213
|
+
: !tsgo
|
|
214
|
+
? { ok: false, unchecked: "tsgo isn't installed (npm install -g @typescript/native-preview)" }
|
|
215
|
+
: // --pretty for `file:line:col - error` lines, the shape the platform re-roots. Two checkers, not
|
|
216
|
+
// four, hold half the type graph: a large app fits the sandbox's memory.
|
|
217
|
+
runTool(process.execPath, [tsgo, '--noEmit', '--pretty', '-p', 'tsconfig.app.json', '--checkers', '2'], appPath));
|
|
218
|
+
}
|
|
219
|
+
const { sourceProblems } = await Promise.resolve().then(() => __importStar(require('./start/sourceRules.js')));
|
|
220
|
+
const root = (0, sourceRoots_js_1.sourceRootOf)(appPath);
|
|
221
|
+
let hints;
|
|
222
|
+
try {
|
|
223
|
+
hints = sourceProblems(readAppSources(appPath), {
|
|
224
|
+
internal: isInternalApp(appPath),
|
|
225
|
+
kind: root && { apps: 'app', automations: 'automation' }[root],
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
catch (err) {
|
|
229
|
+
// A rule's own bug is nothing for the app to fix, and mustn't cost the report the steps before it.
|
|
230
|
+
reporter.step(app, 'source', { ok: false, unchecked: `source rules failed: ${err instanceof Error ? err.message : String(err)}` });
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
reporter.step(app, 'source', { ok: !hints.some(p => p.severity === 'error') });
|
|
234
|
+
reporter.problems(app, hints);
|
|
235
|
+
}
|
|
236
|
+
async function checkClassicApp(reporter, app, root, appPath) {
|
|
237
|
+
// Only tsconfig.app.json compiles anything. The app's tsconfig.json is a
|
|
238
|
+
// solution-style config — `"files": []` plus a reference — so
|
|
239
|
+
// `tsc --noEmit -p tsconfig.json` type-checks zero files and exits 0. It
|
|
240
|
+
// used to be the fallback, which meant an app missing tsconfig.app.json
|
|
241
|
+
// reported a passing typecheck it never ran.
|
|
242
|
+
const tsconfigAppPath = (0, path_1.join)(appPath, 'tsconfig.app.json');
|
|
243
|
+
reporter.step(app, 'tsc --noEmit', (0, fs_1.existsSync)(tsconfigAppPath)
|
|
244
|
+
? run('npx', ['tsc', '--noEmit', '-p', tsconfigAppPath], '.')
|
|
245
|
+
: { ok: false, output: `no ${tsconfigAppPath}` });
|
|
246
|
+
// Endpoints never reach vite — they are bundled separately for the lambda,
|
|
247
|
+
// against a different resolver. tsc and vite both pass on an endpoint whose
|
|
248
|
+
// `zitejs/*` alias has no generated file behind it; only the bundler knows.
|
|
249
|
+
const endpointNames = (0, sourceRoots_js_1.listEndpointNames)(root, appPath);
|
|
250
|
+
if (endpointNames.length > 0) {
|
|
251
|
+
const failures = await bundleFailures(root, appPath, endpointNames);
|
|
252
|
+
reporter.step(app, 'bundle endpoints', { ok: failures.length === 0, output: failures.join('\n') });
|
|
253
|
+
}
|
|
254
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(appPath, 'vite.config.ts'))) {
|
|
255
|
+
reporter.step(app, 'vite build', run('npx', ['vite', 'build'], appPath));
|
|
128
256
|
}
|
|
129
257
|
}
|
|
130
|
-
async function runCheck() {
|
|
258
|
+
async function runCheck(args = process.argv.slice(3)) {
|
|
259
|
+
const json = args.includes('--json');
|
|
260
|
+
const reporter = new Reporter(json);
|
|
131
261
|
const { isStartAppDir } = await Promise.resolve().then(() => __importStar(require('../start/entries.js')));
|
|
132
262
|
// Run inside a Start app, its own zitejs checks just that app: the workspace
|
|
133
263
|
// root's is a classic release that doesn't know Start.
|
|
@@ -137,72 +267,31 @@ async function runCheck() {
|
|
|
137
267
|
console.error('No apps or automations found under apps/ or automations/.');
|
|
138
268
|
process.exit(1);
|
|
139
269
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
// Only tsconfig.app.json compiles anything. The app's tsconfig.json is a
|
|
149
|
-
// solution-style config — `"files": []` plus a reference — so
|
|
150
|
-
// `tsc --noEmit -p tsconfig.json` type-checks zero files and exits 0. It
|
|
151
|
-
// used to be the fallback, which meant an app missing tsconfig.app.json
|
|
152
|
-
// reported a passing typecheck it never ran.
|
|
153
|
-
const tsconfigAppPath = (0, path_1.join)(appPath, 'tsconfig.app.json');
|
|
154
|
-
if (!(0, fs_1.existsSync)(tsconfigAppPath)) {
|
|
155
|
-
console.log(` tsc --noEmit ... ✗ (no ${tsconfigAppPath})`);
|
|
156
|
-
allPassed = false;
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
process.stdout.write(' tsc --noEmit ... ');
|
|
160
|
-
const tsc = run('npx', ['tsc', '--noEmit', '-p', tsconfigAppPath], '.');
|
|
161
|
-
if (tsc.ok) {
|
|
162
|
-
console.log('✓');
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
console.log('✗');
|
|
166
|
-
console.log(tsc.output.trim().split('\n').map(l => ` ${l}`).join('\n'));
|
|
167
|
-
allPassed = false;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
// Endpoints never reach vite — they are bundled separately for the lambda,
|
|
171
|
-
// against a different resolver. tsc and vite both pass on an endpoint whose
|
|
172
|
-
// `zitejs/*` alias has no generated file behind it; only the bundler knows.
|
|
173
|
-
if ((0, sourceRoots_js_1.listEndpointNames)(root, appPath).length > 0) {
|
|
174
|
-
process.stdout.write(' bundle endpoints ... ');
|
|
175
|
-
const bundle = run('npx', ['zitejs', 'bundle', '--app', app], '.');
|
|
176
|
-
const failures = bundle.ok ? bundleFailures(bundle.output) : [bundle.output];
|
|
177
|
-
if (failures.length === 0) {
|
|
178
|
-
console.log('✓');
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
console.log('✗');
|
|
182
|
-
console.log(failures.map(l => ` ${l}`).join('\n'));
|
|
183
|
-
allPassed = false;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
const viteConfig = (0, path_1.join)(appPath, 'vite.config.ts');
|
|
187
|
-
if ((0, fs_1.existsSync)(viteConfig)) {
|
|
188
|
-
process.stdout.write(' vite build ... ');
|
|
189
|
-
const vite = run('npx', ['vite', 'build'], appPath);
|
|
190
|
-
if (vite.ok) {
|
|
191
|
-
console.log('✓');
|
|
270
|
+
const checkAll = async () => {
|
|
271
|
+
if (inStartApp)
|
|
272
|
+
await checkStartApp(reporter, reporter.app('.', 'start', false), '.');
|
|
273
|
+
for (const { root, path: appPath } of appDirs) {
|
|
274
|
+
if (isStartAppDir(appPath)) {
|
|
275
|
+
await checkStartApp(reporter, reporter.app(appPath, 'start', true), appPath);
|
|
192
276
|
}
|
|
193
277
|
else {
|
|
194
|
-
|
|
195
|
-
console.log(vite.output.trim().split('\n').map(l => ` ${l}`).join('\n'));
|
|
196
|
-
allPassed = false;
|
|
278
|
+
await checkClassicApp(reporter, reporter.app(appPath, 'classic', true), root, appPath);
|
|
197
279
|
}
|
|
198
280
|
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
281
|
+
};
|
|
282
|
+
await (json ? (0, exports.withStdoutOnStderr)(checkAll) : checkAll());
|
|
283
|
+
const failed = reporter.apps.some(app => !app.ok);
|
|
284
|
+
const unchecked = reporter.apps.some(app => app.unchecked);
|
|
285
|
+
if (json) {
|
|
286
|
+
process.stdout.write(`${JSON.stringify({ ok: !failed && !unchecked, ...(unchecked && { unchecked: true }), apps: reporter.apps })}\n`);
|
|
203
287
|
}
|
|
204
288
|
else {
|
|
205
|
-
console.log('
|
|
206
|
-
|
|
289
|
+
console.log('');
|
|
290
|
+
console.log(failed ? 'Some apps failed.' : unchecked ? 'Some apps were not fully checked.' : 'All apps pass.');
|
|
207
291
|
}
|
|
292
|
+
// 3: nothing to fix, but not everything ran.
|
|
293
|
+
if (failed)
|
|
294
|
+
process.exit(1);
|
|
295
|
+
if (unchecked)
|
|
296
|
+
process.exit(3);
|
|
208
297
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Severity = "error" | "warning";
|
|
2
|
+
/** One finding of `zitejs check`, named by its rule. Errors fail the check; warnings only report. */
|
|
3
|
+
export type Problem = {
|
|
4
|
+
rule: string;
|
|
5
|
+
severity: Severity;
|
|
6
|
+
/** App-relative. */
|
|
7
|
+
file?: string;
|
|
8
|
+
line?: number;
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const formatProblem: ({ rule, severity, file, line, message }: Problem) => string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatProblem = void 0;
|
|
4
|
+
const formatProblem = ({ rule, severity, file, line, message }) => `${severity} ${rule}${file ? ` ${file}${line ? `:${line}` : ""}` : ""}: ${message}`;
|
|
5
|
+
exports.formatProblem = formatProblem;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const ENTRY_EXTENSIONS: string[];
|
|
2
|
+
/** Start's footer (start-plugin-core route-tree-footer), which types the router and start instance for `@tanstack/react-start`. */
|
|
3
|
+
export declare const startRouteTreeFooter: (generatedRouteTree: string, routerFile: string, startFile: string | undefined) => string[];
|
|
4
|
+
/**
|
|
5
|
+
* Regenerates the route tree with the router generator the app's own
|
|
6
|
+
* `@tanstack/react-start` builds with, configured as zitejs's Start plugin
|
|
7
|
+
* configures it, so the file is the one `vite build` writes, byte for byte.
|
|
8
|
+
*/
|
|
9
|
+
export declare function regenerateRouteTree(appDir: string): Promise<void>;
|