@bleedingdev/modern-js-app-tools 3.5.0-ultramodern.30 → 3.5.0-ultramodern.32
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/plugins/backend-federation/codegen.js +208 -0
- package/dist/cjs/plugins/backend-federation/config.js +217 -0
- package/dist/cjs/plugins/backend-federation/emit.js +139 -0
- package/dist/cjs/plugins/backendFederationBuild.js +4 -298
- package/dist/cjs/plugins/deploy/platforms/cloudflare/artifacts.js +127 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/constants.js +137 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/delivery-unit.js +118 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/i18n-worker.js +135 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/index.js +126 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/security-policies.js +223 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/types.js +18 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/utils.js +66 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/worker-manifest.js +178 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/wrangler-config.js +189 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/identity.js +83 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js +184 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/issues.js +54 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/manifest.js +83 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.js +158 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.js +137 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier.js +23 -363
- package/dist/cjs/plugins/deploy/platforms/cloudflare.js +2 -745
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +22 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +32 -0
- package/dist/esm/plugins/backend-federation/codegen.mjs +157 -0
- package/dist/esm/plugins/backend-federation/config.mjs +141 -0
- package/dist/esm/plugins/backend-federation/emit.mjs +88 -0
- package/dist/esm/plugins/backendFederationBuild.mjs +1 -296
- package/dist/esm/plugins/deploy/platforms/cloudflare/artifacts.mjs +64 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/constants.mjs +33 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +67 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +97 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/index.mjs +78 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/security-policies.mjs +167 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/types.mjs +0 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/utils.mjs +12 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +118 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +135 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +45 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +129 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +10 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +45 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +97 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +68 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier.mjs +1 -347
- package/dist/esm/plugins/deploy/platforms/cloudflare.mjs +1 -735
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +22 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +32 -0
- package/dist/esm-node/plugins/backend-federation/codegen.mjs +158 -0
- package/dist/esm-node/plugins/backend-federation/config.mjs +142 -0
- package/dist/esm-node/plugins/backend-federation/emit.mjs +89 -0
- package/dist/esm-node/plugins/backendFederationBuild.mjs +1 -296
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/artifacts.mjs +65 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/constants.mjs +34 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +68 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +98 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/index.mjs +79 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/security-policies.mjs +168 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/types.mjs +1 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/utils.mjs +13 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +119 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +136 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +46 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +130 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +11 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +46 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +98 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +69 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier.mjs +1 -347
- package/dist/esm-node/plugins/deploy/platforms/cloudflare.mjs +1 -735
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +22 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +32 -0
- package/dist/types/plugins/backend-federation/codegen.d.ts +82 -0
- package/dist/types/plugins/backend-federation/config.d.ts +103 -0
- package/dist/types/plugins/backend-federation/emit.d.ts +13 -0
- package/dist/types/plugins/backendFederationBuild.d.ts +2 -11
- package/dist/types/plugins/deploy/platforms/cloudflare/artifacts.d.ts +15 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/constants.d.ts +23 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/delivery-unit.d.ts +23 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/i18n-worker.d.ts +21 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/index.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/security-policies.d.ts +88 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/types.d.ts +5 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/utils.d.ts +6 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/worker-manifest.d.ts +100 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/wrangler-config.d.ts +39 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/identity.d.ts +4 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/index.d.ts +18 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/issues.d.ts +14 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/manifest.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.d.ts +13 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.d.ts +16 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier.d.ts +1 -32
- package/dist/types/plugins/deploy/platforms/cloudflare.d.ts +1 -2
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.d.mts +1 -0
- package/package.json +11 -11
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -879
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -879
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -879
- /package/dist/types/plugins/deploy/platforms/templates/{cloudflare-entry.d.mts → cloudflare-entry.006-fetch-handler.d.mts} +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { CLOUDFLARE_ASSETS_BINDING, CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY, CLOUDFLARE_RUNTIME_TYPE, CLOUDFLARE_WORKER_ENTRY } from "../cloudflare-output-contract.mjs";
|
|
3
|
+
import { addIssue, assertEqual } from "./issues.mjs";
|
|
4
|
+
const verifyManifestShape = (issues, manifest, manifestPath)=>{
|
|
5
|
+
assertEqual(issues, manifest.runtime?.type, CLOUDFLARE_RUNTIME_TYPE, {
|
|
6
|
+
code: 'invalid-manifest',
|
|
7
|
+
message: 'Cloudflare output manifest runtime.type must be cloudflare-module-worker.',
|
|
8
|
+
path: manifestPath
|
|
9
|
+
});
|
|
10
|
+
assertEqual(issues, manifest.runtime?.entry, CLOUDFLARE_WORKER_ENTRY, {
|
|
11
|
+
code: 'invalid-manifest',
|
|
12
|
+
message: `Cloudflare output manifest runtime.entry must be ${CLOUDFLARE_WORKER_ENTRY}.`,
|
|
13
|
+
path: manifestPath
|
|
14
|
+
});
|
|
15
|
+
assertEqual(issues, manifest.runtime?.fetchExport, true, {
|
|
16
|
+
code: 'invalid-manifest',
|
|
17
|
+
message: 'Cloudflare output manifest runtime.fetchExport must be true.',
|
|
18
|
+
path: manifestPath
|
|
19
|
+
});
|
|
20
|
+
assertEqual(issues, manifest.runtime?.nodeListen, false, {
|
|
21
|
+
code: 'invalid-manifest',
|
|
22
|
+
message: 'Cloudflare output manifest runtime.nodeListen must be false.',
|
|
23
|
+
path: manifestPath
|
|
24
|
+
});
|
|
25
|
+
assertEqual(issues, manifest.assets?.binding, CLOUDFLARE_ASSETS_BINDING, {
|
|
26
|
+
code: 'invalid-manifest',
|
|
27
|
+
message: 'Cloudflare output manifest assets.binding must be ASSETS.',
|
|
28
|
+
path: manifestPath
|
|
29
|
+
});
|
|
30
|
+
assertEqual(issues, manifest.assets?.directory, `./${CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY}`, {
|
|
31
|
+
code: 'invalid-manifest',
|
|
32
|
+
message: 'Cloudflare output manifest assets.directory must be ./public.',
|
|
33
|
+
path: manifestPath
|
|
34
|
+
});
|
|
35
|
+
assertEqual(issues, manifest.assets?.runWorkerFirst, true, {
|
|
36
|
+
code: 'invalid-manifest',
|
|
37
|
+
message: 'Cloudflare output manifest assets.runWorkerFirst must be true.',
|
|
38
|
+
path: manifestPath
|
|
39
|
+
});
|
|
40
|
+
if (!Array.isArray(manifest.routeSpec?.routes)) addIssue(issues, {
|
|
41
|
+
code: 'invalid-manifest',
|
|
42
|
+
message: 'Cloudflare output manifest routeSpec.routes must be array.',
|
|
43
|
+
path: manifestPath
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
export { verifyManifestShape };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import promises from "node:fs/promises";
|
|
3
|
+
import node_path from "node:path";
|
|
4
|
+
import { addIssue } from "./issues.mjs";
|
|
5
|
+
const SOURCE_SCAN_FILE_PATTERN = /\.(?:[cm]?[jt]s|json)$/u;
|
|
6
|
+
const SOURCE_SCAN_IGNORED_DIRECTORY_NAMES = new Set([
|
|
7
|
+
'.codex',
|
|
8
|
+
'.fastcontext',
|
|
9
|
+
'.git',
|
|
10
|
+
'.mf',
|
|
11
|
+
'.modernjs',
|
|
12
|
+
'.output',
|
|
13
|
+
'coverage',
|
|
14
|
+
'dist',
|
|
15
|
+
'dist-cloudflare',
|
|
16
|
+
'node_modules',
|
|
17
|
+
'repos',
|
|
18
|
+
'topology'
|
|
19
|
+
]);
|
|
20
|
+
const FORBIDDEN_MUTATION_PATTERNS = [
|
|
21
|
+
{
|
|
22
|
+
code: 'forbidden-mutation-pattern',
|
|
23
|
+
message: "Generated Cloudflare server worker output must not be rewritten by app scripts.",
|
|
24
|
+
pattern: /\.output\/server\/index\.mjs/u
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
code: 'forbidden-mutation-pattern',
|
|
28
|
+
message: "Generated Cloudflare server worker output must not be rewritten by app scripts.",
|
|
29
|
+
pattern: /path\.(?:join|resolve)\(\s*['"`]\.output['"`]\s*,\s*['"`]server['"`]\s*,\s*['"`]index\.mjs['"`]\s*\)/u
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
code: 'forbidden-mutation-pattern',
|
|
33
|
+
message: "Generated Cloudflare BFF worker bundles must not be rewritten by app scripts.",
|
|
34
|
+
pattern: /\.output\/worker\/[^'"`]*\.(?:mjs|cjs|js)/u
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
code: 'forbidden-mutation-pattern',
|
|
38
|
+
message: "Generated Cloudflare BFF worker bundles must not be rewritten by app scripts.",
|
|
39
|
+
pattern: /path\.(?:join|resolve)\(\s*['"`]\.output['"`]\s*,\s*['"`]worker['"`]\s*,\s*['"`][^'"`]+\.(?:mjs|cjs|js)['"`]\s*\)/u
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
code: 'forbidden-mutation-pattern',
|
|
43
|
+
message: "Drizzle entityKind worker bundle markers must be fixed in the framework toolchain, not post-build scripts.",
|
|
44
|
+
pattern: /replaceAll\(\s*['"`];entityKind(?:,entityKind)?;/u
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
code: 'forbidden-mutation-pattern',
|
|
48
|
+
message: "Effect BFF Cloudflare dispatch must not depend on duck-typed runtime helper probing in app scripts.",
|
|
49
|
+
pattern: /(?:typeof\s+[^;\n]*dispatchEffectBffRequest|['"`]dispatchEffectBffRequest['"`]\s+in\s+|\.dispatchEffectBffRequest\b)/u
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
code: 'forbidden-mutation-pattern',
|
|
53
|
+
message: "Effect BFF Cloudflare dispatch must not branch on handler.length in app scripts.",
|
|
54
|
+
pattern: /\bhandler\s*\.\s*length\b/u
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
const pathExists = async (filePath)=>{
|
|
58
|
+
try {
|
|
59
|
+
await promises.access(filePath);
|
|
60
|
+
return true;
|
|
61
|
+
} catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const walkFiles = async (root)=>{
|
|
66
|
+
if (!await pathExists(root)) return [];
|
|
67
|
+
const entries = await promises.readdir(root, {
|
|
68
|
+
withFileTypes: true
|
|
69
|
+
});
|
|
70
|
+
const files = [];
|
|
71
|
+
for (const entry of entries){
|
|
72
|
+
if (SOURCE_SCAN_IGNORED_DIRECTORY_NAMES.has(entry.name)) continue;
|
|
73
|
+
const entryPath = node_path.join(root, entry.name);
|
|
74
|
+
if (entry.isDirectory()) {
|
|
75
|
+
files.push(...await walkFiles(entryPath));
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (SOURCE_SCAN_FILE_PATTERN.test(entry.name)) files.push(entryPath);
|
|
79
|
+
}
|
|
80
|
+
return files;
|
|
81
|
+
};
|
|
82
|
+
const verifyCloudflareOutputMutationPolicy = async (options)=>{
|
|
83
|
+
const issues = [];
|
|
84
|
+
const files = (await Promise.all(options.scanRoots.map((scanRoot)=>walkFiles(node_path.resolve(scanRoot))))).flat();
|
|
85
|
+
for (const file of files){
|
|
86
|
+
const source = await promises.readFile(file, 'utf-8');
|
|
87
|
+
for (const forbidden of FORBIDDEN_MUTATION_PATTERNS)if (forbidden.pattern.test(source)) addIssue(issues, {
|
|
88
|
+
code: forbidden.code,
|
|
89
|
+
message: forbidden.message,
|
|
90
|
+
path: file
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
ok: 0 === issues.length,
|
|
95
|
+
issues
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
export { FORBIDDEN_MUTATION_PATTERNS, SOURCE_SCAN_FILE_PATTERN, SOURCE_SCAN_IGNORED_DIRECTORY_NAMES, verifyCloudflareOutputMutationPolicy, walkFiles };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import node_path from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { CLOUDFLARE_WORKER_BUNDLE_DIRECTORY } from "../cloudflare-output-contract.mjs";
|
|
5
|
+
import { addIssue } from "./issues.mjs";
|
|
6
|
+
const getReferencedRouteWorkers = (manifest)=>Array.isArray(manifest?.routeSpec?.routes) ? manifest.routeSpec.routes.map((route)=>'string' == typeof route?.worker && route.worker.length > 0 ? route.worker : void 0).filter((worker)=>'string' == typeof worker) : [];
|
|
7
|
+
const getEffectBffWorker = (manifest)=>manifest?.bff?.runtimeFramework === 'effect' && 'string' == typeof manifest.bff.worker ? manifest.bff.worker : void 0;
|
|
8
|
+
const getWorkerBundleReferences = (manifest)=>{
|
|
9
|
+
const effectBffWorker = getEffectBffWorker(manifest);
|
|
10
|
+
return [
|
|
11
|
+
...effectBffWorker ? [
|
|
12
|
+
{
|
|
13
|
+
kind: 'effect-bff',
|
|
14
|
+
reference: effectBffWorker
|
|
15
|
+
}
|
|
16
|
+
] : [],
|
|
17
|
+
...getReferencedRouteWorkers(manifest).map((reference)=>({
|
|
18
|
+
kind: 'route',
|
|
19
|
+
reference
|
|
20
|
+
}))
|
|
21
|
+
];
|
|
22
|
+
};
|
|
23
|
+
const resolveWorkerBundleReference = (issues, outputDirectory, reference, manifestPath)=>{
|
|
24
|
+
const workerRoot = node_path.resolve(outputDirectory, CLOUDFLARE_WORKER_BUNDLE_DIRECTORY);
|
|
25
|
+
const workerPath = node_path.resolve(outputDirectory, reference.reference);
|
|
26
|
+
const relativeToWorkerRoot = node_path.relative(workerRoot, workerPath);
|
|
27
|
+
if (node_path.isAbsolute(reference.reference) || relativeToWorkerRoot.startsWith('..') || node_path.isAbsolute(relativeToWorkerRoot)) {
|
|
28
|
+
addIssue(issues, {
|
|
29
|
+
code: 'invalid-manifest',
|
|
30
|
+
message: 'Cloudflare output manifest worker bundle references must stay under worker/.',
|
|
31
|
+
path: manifestPath
|
|
32
|
+
});
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
...reference,
|
|
37
|
+
path: workerPath
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const missingWorkerBundleMessage = (reference)=>'effect-bff' === reference.kind ? 'Cloudflare Effect BFF manifest points to a missing worker bundle.' : 'Cloudflare route worker manifest points to a missing worker bundle.';
|
|
41
|
+
const FORBIDDEN_WORKER_BUNDLE_REFERENCE_PATTERNS = [
|
|
42
|
+
/\.\.\/server\//u,
|
|
43
|
+
/\.output\/server\//u,
|
|
44
|
+
/server\/index\.mjs/u
|
|
45
|
+
];
|
|
46
|
+
const verifyWorkerBundleReferences = (issues, worker, source)=>{
|
|
47
|
+
if (FORBIDDEN_WORKER_BUNDLE_REFERENCE_PATTERNS.some((pattern)=>pattern.test(source))) addIssue(issues, {
|
|
48
|
+
code: 'invalid-worker-bundle',
|
|
49
|
+
message: 'Cloudflare worker bundles must not reference framework-owned server output paths.',
|
|
50
|
+
path: worker.path
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const verifyWorkerImport = async (issues, entryPath)=>{
|
|
54
|
+
try {
|
|
55
|
+
const worker = (await import(`${pathToFileURL(entryPath).href}?t=${Date.now()}`)).default;
|
|
56
|
+
if (!worker || 'function' != typeof worker.fetch) addIssue(issues, {
|
|
57
|
+
code: 'worker-import-failed',
|
|
58
|
+
message: 'Cloudflare server entry must default-export a Worker with fetch.',
|
|
59
|
+
path: entryPath
|
|
60
|
+
});
|
|
61
|
+
} catch (error) {
|
|
62
|
+
addIssue(issues, {
|
|
63
|
+
code: 'worker-import-failed',
|
|
64
|
+
message: `Cloudflare server entry could not be imported: ${error instanceof Error ? error.message : String(error)}`,
|
|
65
|
+
path: entryPath
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
export { FORBIDDEN_WORKER_BUNDLE_REFERENCE_PATTERNS, getEffectBffWorker, getReferencedRouteWorkers, getWorkerBundleReferences, missingWorkerBundleMessage, resolveWorkerBundleReference, verifyWorkerBundleReferences, verifyWorkerImport };
|
|
@@ -1,348 +1,2 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
|
|
3
|
-
import node_path from "node:path";
|
|
4
|
-
import { pathToFileURL } from "node:url";
|
|
5
|
-
import { CLOUDFLARE_ASSETS_BINDING, CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY, CLOUDFLARE_RUNTIME_TYPE, CLOUDFLARE_WORKER_BUNDLE_DIRECTORY, CLOUDFLARE_WORKER_ENTRY } from "./cloudflare-output-contract.mjs";
|
|
6
|
-
import { createCloudflareOutputPlan } from "./cloudflare-output-plan.mjs";
|
|
7
|
-
const SOURCE_SCAN_FILE_PATTERN = /\.(?:[cm]?[jt]s|json)$/u;
|
|
8
|
-
const SOURCE_SCAN_IGNORED_DIRECTORY_NAMES = new Set([
|
|
9
|
-
'.codex',
|
|
10
|
-
'.fastcontext',
|
|
11
|
-
'.git',
|
|
12
|
-
'.mf',
|
|
13
|
-
'.modernjs',
|
|
14
|
-
'.output',
|
|
15
|
-
'coverage',
|
|
16
|
-
'dist',
|
|
17
|
-
'dist-cloudflare',
|
|
18
|
-
'node_modules',
|
|
19
|
-
'repos',
|
|
20
|
-
'topology'
|
|
21
|
-
]);
|
|
22
|
-
const FORBIDDEN_MUTATION_PATTERNS = [
|
|
23
|
-
{
|
|
24
|
-
code: 'forbidden-mutation-pattern',
|
|
25
|
-
message: "Generated Cloudflare server worker output must not be rewritten by app scripts.",
|
|
26
|
-
pattern: /\.output\/server\/index\.mjs/u
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
code: 'forbidden-mutation-pattern',
|
|
30
|
-
message: "Generated Cloudflare server worker output must not be rewritten by app scripts.",
|
|
31
|
-
pattern: /path\.join\(\s*['"`]\.output['"`]\s*,\s*['"`]server['"`]\s*,\s*['"`]index\.mjs['"`]\s*\)/u
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
code: 'forbidden-mutation-pattern',
|
|
35
|
-
message: "Generated Cloudflare BFF worker bundles must not be rewritten by app scripts.",
|
|
36
|
-
pattern: /\.output\/worker\/[^'"`]*\.(?:mjs|cjs|js)/u
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
code: 'forbidden-mutation-pattern',
|
|
40
|
-
message: "Generated Cloudflare BFF worker bundles must not be rewritten by app scripts.",
|
|
41
|
-
pattern: /path\.join\(\s*['"`]\.output['"`]\s*,\s*['"`]worker['"`]\s*,\s*['"`][^'"`]+\.(?:mjs|cjs|js)['"`]\s*\)/u
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
code: 'forbidden-mutation-pattern',
|
|
45
|
-
message: "Drizzle entityKind worker bundle markers must be fixed in the framework toolchain, not post-build scripts.",
|
|
46
|
-
pattern: /replaceAll\(\s*['"`];entityKind(?:,entityKind)?;/u
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
code: 'forbidden-mutation-pattern',
|
|
50
|
-
message: "Effect BFF Cloudflare dispatch must not depend on duck-typed runtime helper probing in app scripts.",
|
|
51
|
-
pattern: /(?:typeof\s+[^;\n]*dispatchEffectBffRequest|['"`]dispatchEffectBffRequest['"`]\s+in\s+|\.dispatchEffectBffRequest\b)/u
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
code: 'forbidden-mutation-pattern',
|
|
55
|
-
message: "Effect BFF Cloudflare dispatch must not branch on handler.length in app scripts.",
|
|
56
|
-
pattern: /\bhandler\s*\.\s*length\b/u
|
|
57
|
-
}
|
|
58
|
-
];
|
|
59
|
-
const pathExists = async (filePath)=>{
|
|
60
|
-
try {
|
|
61
|
-
await promises.access(filePath);
|
|
62
|
-
return true;
|
|
63
|
-
} catch {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
const readJson = async (filePath)=>JSON.parse(await promises.readFile(filePath, 'utf-8'));
|
|
68
|
-
const addIssue = (issues, issue)=>{
|
|
69
|
-
issues.push(issue);
|
|
70
|
-
};
|
|
71
|
-
const assertEqual = (issues, actual, expected, issue)=>{
|
|
72
|
-
if (actual !== expected) addIssue(issues, issue);
|
|
73
|
-
};
|
|
74
|
-
const assertFlag = (issues, flags, flag, issue)=>{
|
|
75
|
-
if (!Array.isArray(flags) || !flags.includes(flag)) addIssue(issues, issue);
|
|
76
|
-
};
|
|
77
|
-
const getReferencedRouteWorkers = (manifest)=>Array.isArray(manifest?.routeSpec?.routes) ? manifest.routeSpec.routes.map((route)=>'string' == typeof route?.worker && route.worker.length > 0 ? route.worker : void 0).filter((worker)=>'string' == typeof worker) : [];
|
|
78
|
-
const getEffectBffWorker = (manifest)=>manifest?.bff?.runtimeFramework === 'effect' && 'string' == typeof manifest.bff.worker ? manifest.bff.worker : void 0;
|
|
79
|
-
const getWorkerBundleReferences = (manifest)=>{
|
|
80
|
-
const effectBffWorker = getEffectBffWorker(manifest);
|
|
81
|
-
return [
|
|
82
|
-
...effectBffWorker ? [
|
|
83
|
-
{
|
|
84
|
-
kind: 'effect-bff',
|
|
85
|
-
reference: effectBffWorker
|
|
86
|
-
}
|
|
87
|
-
] : [],
|
|
88
|
-
...getReferencedRouteWorkers(manifest).map((reference)=>({
|
|
89
|
-
kind: 'route',
|
|
90
|
-
reference
|
|
91
|
-
}))
|
|
92
|
-
];
|
|
93
|
-
};
|
|
94
|
-
const resolveWorkerBundleReference = (issues, outputDirectory, reference, manifestPath)=>{
|
|
95
|
-
const workerRoot = node_path.resolve(outputDirectory, CLOUDFLARE_WORKER_BUNDLE_DIRECTORY);
|
|
96
|
-
const workerPath = node_path.resolve(outputDirectory, reference.reference);
|
|
97
|
-
const relativeToWorkerRoot = node_path.relative(workerRoot, workerPath);
|
|
98
|
-
if (node_path.isAbsolute(reference.reference) || relativeToWorkerRoot.startsWith('..') || node_path.isAbsolute(relativeToWorkerRoot)) {
|
|
99
|
-
addIssue(issues, {
|
|
100
|
-
code: 'invalid-manifest',
|
|
101
|
-
message: 'Cloudflare output manifest worker bundle references must stay under worker/.',
|
|
102
|
-
path: manifestPath
|
|
103
|
-
});
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
...reference,
|
|
108
|
-
path: workerPath
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
const missingWorkerBundleMessage = (reference)=>'effect-bff' === reference.kind ? 'Cloudflare Effect BFF manifest points to a missing worker bundle.' : 'Cloudflare route worker manifest points to a missing worker bundle.';
|
|
112
|
-
const DELIVERY_UNIT_IDENTITY_FIELDS = [
|
|
113
|
-
'unitId',
|
|
114
|
-
'buildMarker',
|
|
115
|
-
'sourceRevision'
|
|
116
|
-
];
|
|
117
|
-
const verifyDeliveryUnitIdentity = (issues, manifest, manifestPath, declared)=>{
|
|
118
|
-
const stamped = manifest?.deliveryUnit;
|
|
119
|
-
const hasStamp = Boolean(stamped) && 'object' == typeof stamped;
|
|
120
|
-
if (declared) {
|
|
121
|
-
if (!hasStamp) return void addIssue(issues, {
|
|
122
|
-
code: 'missing-delivery-unit',
|
|
123
|
-
message: `Cloudflare worker manifest is missing the delivery-unit identity declared by the workspace topology (expected unitId ${declared.unitId}, buildMarker ${declared.buildMarker}).`,
|
|
124
|
-
path: manifestPath
|
|
125
|
-
});
|
|
126
|
-
for (const field of DELIVERY_UNIT_IDENTITY_FIELDS)assertEqual(issues, stamped[field], declared[field], {
|
|
127
|
-
code: 'delivery-unit-drift',
|
|
128
|
-
message: `Cloudflare worker manifest deliveryUnit.${field} must match the topology delivery-unit record (expected ${declared[field]}, received ${stamped[field] ?? 'undefined'}).`,
|
|
129
|
-
path: manifestPath
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
if (hasStamp && stamped.surfaces && 'object' == typeof stamped.surfaces) for (const surface of [
|
|
133
|
-
'ui',
|
|
134
|
-
'api'
|
|
135
|
-
]){
|
|
136
|
-
const marker = stamped.surfaces[surface];
|
|
137
|
-
if (!marker || 'object' != typeof marker) {
|
|
138
|
-
addIssue(issues, {
|
|
139
|
-
code: 'missing-delivery-unit',
|
|
140
|
-
message: `Cloudflare worker manifest is missing the ${surface} delivery-unit surface marker.`,
|
|
141
|
-
path: manifestPath
|
|
142
|
-
});
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
for (const field of DELIVERY_UNIT_IDENTITY_FIELDS)assertEqual(issues, marker[field], stamped[field], {
|
|
146
|
-
code: 'delivery-unit-drift',
|
|
147
|
-
message: `Cloudflare worker manifest ${surface} surface deliveryUnit.${field} must derive from one delivery-unit record (expected ${stamped[field] ?? 'undefined'}, received ${marker[field] ?? 'undefined'}).`,
|
|
148
|
-
path: manifestPath
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
const verifyManifestShape = (issues, manifest, manifestPath)=>{
|
|
153
|
-
assertEqual(issues, manifest.runtime?.type, CLOUDFLARE_RUNTIME_TYPE, {
|
|
154
|
-
code: 'invalid-manifest',
|
|
155
|
-
message: 'Cloudflare output manifest runtime.type must be cloudflare-module-worker.',
|
|
156
|
-
path: manifestPath
|
|
157
|
-
});
|
|
158
|
-
assertEqual(issues, manifest.runtime?.entry, CLOUDFLARE_WORKER_ENTRY, {
|
|
159
|
-
code: 'invalid-manifest',
|
|
160
|
-
message: `Cloudflare output manifest runtime.entry must be ${CLOUDFLARE_WORKER_ENTRY}.`,
|
|
161
|
-
path: manifestPath
|
|
162
|
-
});
|
|
163
|
-
assertEqual(issues, manifest.runtime?.fetchExport, true, {
|
|
164
|
-
code: 'invalid-manifest',
|
|
165
|
-
message: 'Cloudflare output manifest runtime.fetchExport must be true.',
|
|
166
|
-
path: manifestPath
|
|
167
|
-
});
|
|
168
|
-
assertEqual(issues, manifest.runtime?.nodeListen, false, {
|
|
169
|
-
code: 'invalid-manifest',
|
|
170
|
-
message: 'Cloudflare output manifest runtime.nodeListen must be false.',
|
|
171
|
-
path: manifestPath
|
|
172
|
-
});
|
|
173
|
-
assertEqual(issues, manifest.assets?.binding, CLOUDFLARE_ASSETS_BINDING, {
|
|
174
|
-
code: 'invalid-manifest',
|
|
175
|
-
message: 'Cloudflare output manifest assets.binding must be ASSETS.',
|
|
176
|
-
path: manifestPath
|
|
177
|
-
});
|
|
178
|
-
assertEqual(issues, manifest.assets?.directory, `./${CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY}`, {
|
|
179
|
-
code: 'invalid-manifest',
|
|
180
|
-
message: 'Cloudflare output manifest assets.directory must be ./public.',
|
|
181
|
-
path: manifestPath
|
|
182
|
-
});
|
|
183
|
-
assertEqual(issues, manifest.assets?.runWorkerFirst, true, {
|
|
184
|
-
code: 'invalid-manifest',
|
|
185
|
-
message: 'Cloudflare output manifest assets.runWorkerFirst must be true.',
|
|
186
|
-
path: manifestPath
|
|
187
|
-
});
|
|
188
|
-
};
|
|
189
|
-
const walkFiles = async (root)=>{
|
|
190
|
-
if (!await pathExists(root)) return [];
|
|
191
|
-
const entries = await promises.readdir(root, {
|
|
192
|
-
withFileTypes: true
|
|
193
|
-
});
|
|
194
|
-
const files = [];
|
|
195
|
-
for (const entry of entries){
|
|
196
|
-
if (SOURCE_SCAN_IGNORED_DIRECTORY_NAMES.has(entry.name)) continue;
|
|
197
|
-
const entryPath = node_path.join(root, entry.name);
|
|
198
|
-
if (entry.isDirectory()) {
|
|
199
|
-
files.push(...await walkFiles(entryPath));
|
|
200
|
-
continue;
|
|
201
|
-
}
|
|
202
|
-
if (SOURCE_SCAN_FILE_PATTERN.test(entry.name)) files.push(entryPath);
|
|
203
|
-
}
|
|
204
|
-
return files;
|
|
205
|
-
};
|
|
206
|
-
const verifyCloudflareOutputMutationPolicy = async (options)=>{
|
|
207
|
-
const issues = [];
|
|
208
|
-
const files = (await Promise.all(options.scanRoots.map((scanRoot)=>walkFiles(node_path.resolve(scanRoot))))).flat();
|
|
209
|
-
for (const file of files){
|
|
210
|
-
const source = await promises.readFile(file, 'utf-8');
|
|
211
|
-
for (const forbidden of FORBIDDEN_MUTATION_PATTERNS)if (forbidden.pattern.test(source)) addIssue(issues, {
|
|
212
|
-
code: forbidden.code,
|
|
213
|
-
message: forbidden.message,
|
|
214
|
-
path: file
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
return {
|
|
218
|
-
ok: 0 === issues.length,
|
|
219
|
-
issues
|
|
220
|
-
};
|
|
221
|
-
};
|
|
222
|
-
const verifyWorkerImport = async (issues, entryPath)=>{
|
|
223
|
-
try {
|
|
224
|
-
const worker = (await import(`${pathToFileURL(entryPath).href}?t=${Date.now()}`)).default;
|
|
225
|
-
if (!worker || 'function' != typeof worker.fetch) addIssue(issues, {
|
|
226
|
-
code: 'worker-import-failed',
|
|
227
|
-
message: 'Cloudflare server entry must default-export a Worker with fetch.',
|
|
228
|
-
path: entryPath
|
|
229
|
-
});
|
|
230
|
-
} catch (error) {
|
|
231
|
-
addIssue(issues, {
|
|
232
|
-
code: 'worker-import-failed',
|
|
233
|
-
message: `Cloudflare server entry could not be imported: ${error instanceof Error ? error.message : String(error)}`,
|
|
234
|
-
path: entryPath
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
const verifyCloudflareOutput = async (options)=>{
|
|
239
|
-
const outputDirectory = node_path.resolve(options.outputDirectory);
|
|
240
|
-
const issues = [];
|
|
241
|
-
const outputPlan = createCloudflareOutputPlan(outputDirectory);
|
|
242
|
-
for (const relativePath of outputPlan.requiredFiles){
|
|
243
|
-
const filePath = node_path.join(outputDirectory, relativePath);
|
|
244
|
-
if (!await pathExists(filePath)) addIssue(issues, {
|
|
245
|
-
code: 'missing-file',
|
|
246
|
-
message: `Cloudflare output is missing ${relativePath}.`,
|
|
247
|
-
path: filePath
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
const manifestPath = outputPlan.paths.workerManifest;
|
|
251
|
-
const wranglerPath = outputPlan.paths.wranglerConfig;
|
|
252
|
-
const packagePath = outputPlan.paths.outputPackage;
|
|
253
|
-
const workerPackagePath = outputPlan.paths.workerPackage;
|
|
254
|
-
const manifest = await pathExists(manifestPath) ? await readJson(manifestPath) : void 0;
|
|
255
|
-
const wrangler = await pathExists(wranglerPath) ? await readJson(wranglerPath) : void 0;
|
|
256
|
-
const outputPackage = await pathExists(packagePath) ? await readJson(packagePath) : void 0;
|
|
257
|
-
const workerPackage = await pathExists(workerPackagePath) ? await readJson(workerPackagePath) : void 0;
|
|
258
|
-
if (manifest) {
|
|
259
|
-
verifyManifestShape(issues, manifest, manifestPath);
|
|
260
|
-
verifyDeliveryUnitIdentity(issues, manifest, manifestPath, options.deliveryUnit);
|
|
261
|
-
const workerReferences = getWorkerBundleReferences(manifest);
|
|
262
|
-
if (workerReferences.length > 0 && !await pathExists(workerPackagePath)) addIssue(issues, {
|
|
263
|
-
code: 'missing-file',
|
|
264
|
-
message: 'Cloudflare output is missing worker/package.json for referenced worker bundles.',
|
|
265
|
-
path: workerPackagePath
|
|
266
|
-
});
|
|
267
|
-
if (manifest.bff?.runtimeFramework === 'effect' && !getEffectBffWorker(manifest)) addIssue(issues, {
|
|
268
|
-
code: 'missing-worker-bundle',
|
|
269
|
-
message: 'Cloudflare Effect BFF manifest points to a missing worker bundle.'
|
|
270
|
-
});
|
|
271
|
-
for (const workerReference of workerReferences){
|
|
272
|
-
const resolvedWorker = resolveWorkerBundleReference(issues, outputDirectory, workerReference, manifestPath);
|
|
273
|
-
if (!resolvedWorker) continue;
|
|
274
|
-
const workerExists = await pathExists(resolvedWorker.path);
|
|
275
|
-
if (!workerExists) addIssue(issues, {
|
|
276
|
-
code: 'missing-worker-bundle',
|
|
277
|
-
message: missingWorkerBundleMessage(workerReference),
|
|
278
|
-
path: resolvedWorker.path
|
|
279
|
-
});
|
|
280
|
-
if (workerExists && 'effect-bff' === resolvedWorker.kind) {
|
|
281
|
-
const workerSource = await promises.readFile(resolvedWorker.path, 'utf-8');
|
|
282
|
-
if (workerSource.includes(';entityKind;') || workerSource.includes(';entityKind,entityKind;')) addIssue(issues, {
|
|
283
|
-
code: 'invalid-worker-bundle',
|
|
284
|
-
message: 'Cloudflare Effect BFF worker bundle contains invalid Drizzle entityKind marker references.',
|
|
285
|
-
path: resolvedWorker.path
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
if (wrangler) {
|
|
291
|
-
assertEqual(issues, wrangler.main, outputPlan.wrangler.main, {
|
|
292
|
-
code: 'invalid-wrangler',
|
|
293
|
-
message: `wrangler.json main must be ${outputPlan.wrangler.main}.`,
|
|
294
|
-
path: wranglerPath
|
|
295
|
-
});
|
|
296
|
-
assertEqual(issues, wrangler.assets?.binding, outputPlan.wrangler.assets.binding, {
|
|
297
|
-
code: 'invalid-wrangler',
|
|
298
|
-
message: 'wrangler.json assets.binding must be ASSETS.',
|
|
299
|
-
path: wranglerPath
|
|
300
|
-
});
|
|
301
|
-
assertEqual(issues, wrangler.assets?.directory, outputPlan.wrangler.assets.directory, {
|
|
302
|
-
code: 'invalid-wrangler',
|
|
303
|
-
message: 'wrangler.json assets.directory must be ./public.',
|
|
304
|
-
path: wranglerPath
|
|
305
|
-
});
|
|
306
|
-
assertEqual(issues, wrangler.assets?.run_worker_first, outputPlan.wrangler.assets.run_worker_first, {
|
|
307
|
-
code: 'invalid-wrangler',
|
|
308
|
-
message: 'wrangler.json assets.run_worker_first must be true.',
|
|
309
|
-
path: wranglerPath
|
|
310
|
-
});
|
|
311
|
-
for (const flag of outputPlan.wrangler.requiredCompatibilityFlags)assertFlag(issues, wrangler.compatibility_flags, flag, {
|
|
312
|
-
code: 'invalid-wrangler',
|
|
313
|
-
message: `wrangler.json compatibility_flags must include ${flag}.`,
|
|
314
|
-
path: wranglerPath
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
if (outputPackage) assertEqual(issues, outputPackage.type, outputPlan.packages.output.type, {
|
|
318
|
-
code: 'invalid-package',
|
|
319
|
-
message: '.output/package.json must declare type module.',
|
|
320
|
-
path: packagePath
|
|
321
|
-
});
|
|
322
|
-
if (workerPackage) assertEqual(issues, workerPackage.type, outputPlan.packages.worker.type, {
|
|
323
|
-
code: 'invalid-package',
|
|
324
|
-
message: '.output/worker/package.json must declare type commonjs.',
|
|
325
|
-
path: workerPackagePath
|
|
326
|
-
});
|
|
327
|
-
for (const leakedPath of outputPlan.publicLeakDirectories){
|
|
328
|
-
const publicPath = node_path.join(outputPlan.paths.publicAssets, leakedPath);
|
|
329
|
-
if (await pathExists(publicPath)) addIssue(issues, {
|
|
330
|
-
code: 'public-output-leak',
|
|
331
|
-
message: `Framework-owned ${leakedPath} output leaked into public assets.`,
|
|
332
|
-
path: publicPath
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
if (false !== options.importWorker && await pathExists(outputPlan.paths.workerEntry)) await verifyWorkerImport(issues, outputPlan.paths.workerEntry);
|
|
336
|
-
return {
|
|
337
|
-
ok: 0 === issues.length,
|
|
338
|
-
issues
|
|
339
|
-
};
|
|
340
|
-
};
|
|
341
|
-
const assertCloudflareOutput = async (options)=>{
|
|
342
|
-
const result = await verifyCloudflareOutput(options);
|
|
343
|
-
if (!result.ok) throw new Error([
|
|
344
|
-
'Cloudflare output verification failed:',
|
|
345
|
-
...result.issues.map((issue)=>`- ${issue.code}: ${issue.message}${issue.path ? ` (${issue.path})` : ''}`)
|
|
346
|
-
].join('\n'));
|
|
347
|
-
};
|
|
348
|
-
export { assertCloudflareOutput, verifyCloudflareOutput, verifyCloudflareOutputMutationPolicy };
|
|
2
|
+
export * from "./cloudflare-output-verifier/index.mjs";
|