anhedral 0.10.1 → 0.11.1
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/README.md +79 -124
- package/assets/patches/LICENSE.braces +21 -0
- package/assets/patches/LICENSE.node-forge +50 -0
- package/assets/patches/audit-deps.mjs +167 -0
- package/assets/patches/braces@3.0.3.patch +127 -0
- package/assets/patches/node-forge@1.4.0.patch +41 -0
- package/dist/auth-schema.js +3 -3
- package/dist/bin.js +284 -163
- package/dist/capabilities.d.ts +4 -4
- package/dist/capabilities.js +6 -2
- package/dist/capability-contract.d.ts +47 -0
- package/dist/capability-contract.js +153 -0
- package/dist/catalog-model.d.ts +24 -0
- package/dist/catalog-model.js +1 -0
- package/dist/catalog-registration.d.ts +16 -0
- package/dist/catalog-registration.js +22 -0
- package/dist/catalog-snapshot.d.ts +5 -0
- package/dist/catalog-snapshot.js +97 -0
- package/dist/cli-arguments.d.ts +16 -0
- package/dist/cli-arguments.js +115 -0
- package/dist/cli-output.d.ts +8 -0
- package/dist/cli-output.js +236 -0
- package/dist/cloudflare.d.ts +14 -3
- package/dist/cloudflare.js +196 -36
- package/dist/command-schema.d.ts +21 -0
- package/dist/command-schema.js +418 -0
- package/dist/delivery.d.ts +12 -5
- package/dist/delivery.js +173 -39
- package/dist/dependencies.d.ts +24 -0
- package/dist/dependencies.js +48 -0
- package/dist/dependency-patches.d.ts +7 -0
- package/dist/dependency-patches.js +125 -0
- package/dist/index.d.ts +26 -1
- package/dist/index.js +17 -1
- package/dist/inspector-model.d.ts +123 -0
- package/dist/inspector-model.js +1 -0
- package/dist/integration-service-readers.d.ts +13 -0
- package/dist/integration-service-readers.js +173 -0
- package/dist/lifecycle-model.d.ts +15 -0
- package/dist/lifecycle-model.js +20 -0
- package/dist/lifecycle.d.ts +11 -0
- package/dist/lifecycle.js +91 -0
- package/dist/mobile-delivery.d.ts +100 -0
- package/dist/mobile-delivery.js +319 -0
- package/dist/neon-service-data.d.ts +8 -0
- package/dist/neon-service-data.js +117 -0
- package/dist/platforms/mobile.js +8 -5
- package/dist/pnpm-policy.d.ts +2 -2
- package/dist/pnpm-policy.js +19 -45
- package/dist/project-catalog.d.ts +41 -0
- package/dist/project-catalog.js +288 -0
- package/dist/project-config.d.ts +14 -0
- package/dist/project-config.js +89 -0
- package/dist/project-inspector.d.ts +4 -0
- package/dist/project-inspector.js +702 -0
- package/dist/project-lifecycle.d.ts +25 -0
- package/dist/project-lifecycle.js +57 -0
- package/dist/project-state.d.ts +22 -1
- package/dist/project-state.js +361 -27
- package/dist/provider-auth.d.ts +41 -0
- package/dist/provider-auth.js +209 -0
- package/dist/provider-readiness.js +27 -10
- package/dist/providers/adapters.d.ts +17 -0
- package/dist/providers/adapters.js +272 -0
- package/dist/providers/api.d.ts +29 -0
- package/dist/providers/api.js +253 -0
- package/dist/providers/config.d.ts +15 -0
- package/dist/providers/config.js +182 -0
- package/dist/providers/definitions.d.ts +318 -0
- package/dist/providers/definitions.js +127 -0
- package/dist/providers/provision.d.ts +24 -0
- package/dist/providers/provision.js +76 -0
- package/dist/providers/receipts.d.ts +20 -0
- package/dist/providers/receipts.js +66 -0
- package/dist/providers/recovery-verification.d.ts +7 -0
- package/dist/providers/recovery-verification.js +112 -0
- package/dist/providers/recovery.d.ts +30 -0
- package/dist/providers/recovery.js +34 -0
- package/dist/providers/runtime.d.ts +10 -0
- package/dist/providers/runtime.js +254 -0
- package/dist/providers/schema.d.ts +28 -0
- package/dist/providers/schema.js +49 -0
- package/dist/providers/state.d.ts +55 -0
- package/dist/providers/state.js +289 -0
- package/dist/provision.d.ts +10 -1
- package/dist/provision.js +91 -4
- package/dist/r2-service-data.d.ts +2 -0
- package/dist/r2-service-data.js +136 -0
- package/dist/readiness.js +9 -13
- package/dist/registry/add.d.ts +6 -0
- package/dist/registry/add.js +93 -22
- package/dist/registry/commands.d.ts +3 -2
- package/dist/registry/commands.js +52 -15
- package/dist/registry/options.d.ts +1 -1
- package/dist/registry/options.js +5 -4
- package/dist/registry/preview.d.ts +11 -0
- package/dist/registry/preview.js +91 -0
- package/dist/registry/receipt.d.ts +1 -0
- package/dist/registry/receipt.js +19 -4
- package/dist/registry/resolve.js +5 -1
- package/dist/registry/usage.d.ts +10 -0
- package/dist/registry/usage.js +18 -37
- package/dist/render.d.ts +2 -0
- package/dist/render.js +6 -0
- package/dist/runtime-policy.d.ts +4 -0
- package/dist/runtime-policy.js +21 -0
- package/dist/scaffold/auth.js +3 -19
- package/dist/scaffold/bootstrap.js +2 -2
- package/dist/scaffold/compose.js +9 -3
- package/dist/scaffold/database.js +107 -25
- package/dist/scaffold/documentation.js +18 -13
- package/dist/scaffold/lint.d.ts +4 -0
- package/dist/scaffold/lint.js +56 -0
- package/dist/scaffold/neon-realtime.d.ts +2 -0
- package/dist/scaffold/neon-realtime.js +97 -0
- package/dist/scaffold/stack-documentation.js +1 -1
- package/dist/scaffold/void.d.ts +4 -0
- package/dist/scaffold/void.js +256 -0
- package/dist/scaffold/web.js +7 -1
- package/dist/scaffold/workspace.js +127 -25
- package/dist/service-deletion.d.ts +29 -0
- package/dist/service-deletion.js +195 -0
- package/dist/service-descriptor.d.ts +10 -0
- package/dist/service-descriptor.js +78 -0
- package/dist/service-model.d.ts +49 -0
- package/dist/service-model.js +8 -0
- package/dist/service-operations.d.ts +29 -0
- package/dist/service-operations.js +78 -0
- package/dist/service-readers.d.ts +8 -0
- package/dist/service-readers.js +247 -0
- package/dist/services-command.d.ts +39 -0
- package/dist/services-command.js +100 -0
- package/dist/ship.d.ts +348 -0
- package/dist/ship.js +237 -0
- package/dist/stack-registry.d.ts +4 -2
- package/dist/stack-registry.js +48 -12
- package/dist/standard.d.ts +2 -1
- package/dist/standard.js +33 -14
- package/dist/transaction.d.ts +2 -0
- package/dist/transaction.js +10 -0
- package/dist/util.js +17 -2
- package/dist/vercel.d.ts +5 -3
- package/dist/vercel.js +96 -14
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/vinext.d.ts +1 -0
- package/dist/vinext.js +13 -1
- package/dist/void-execution.d.ts +10 -0
- package/dist/void-execution.js +94 -0
- package/dist/void-migrations.d.ts +6 -0
- package/dist/void-migrations.js +110 -0
- package/dist/void-state.d.ts +16 -0
- package/dist/void-state.js +65 -0
- package/dist/void.d.ts +3 -0
- package/dist/void.js +5 -0
- package/docs/cli-design.md +67 -0
- package/docs/delivery-workflow.md +32 -17
- package/docs/plugin-ui.md +102 -0
- package/docs/provider-configuration.md +116 -0
- package/docs/stack-standard.md +175 -0
- package/docs/void-verification.md +185 -0
- package/package.json +29 -23
- package/assets/anhedral-cli-init-technical.svg +0 -322
- package/assets/anhedral-cli-init.svg +0 -322
- package/assets/anhedral-mark.svg +0 -4
- package/assets/anhedral.svg +0 -4
- package/assets/favicon.ico +0 -0
- package/assets/security/LICENSES.txt +0 -63
- package/assets/security/audit-deps.mjs +0 -300
- package/assets/security/braces-regression.mjs +0 -102
- package/assets/security/braces@3.0.3.patch +0 -285
- package/assets/security/decode-uri-component@0.2.2.patch +0 -149
- package/assets/security/decoder-regression.mjs +0 -37
- package/assets/security/forge-regression.mjs +0 -46
- package/assets/security/manifest.json +0 -53
- package/assets/security/node-forge@1.4.0.patch +0 -26
- package/dist/managed-hosting.d.ts +0 -49
- package/dist/managed-hosting.js +0 -373
- package/dist/security-backports.d.ts +0 -3
- package/dist/security-backports.js +0 -26
- package/docs/application-stack-standard.md +0 -104
- package/docs/managed-hosting-architecture.md +0 -87
- package/docs/sponsorships.md +0 -25
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readProjectSection, writeProjectSection, hasProjectSection } from '../project-config.js';
|
|
2
|
+
import { STACK_DEPENDENCIES, WORKSPACE_NODE_ENGINE, SECURITY_OVERRIDE_DEPENDENCIES, GLOB_10_OVERRIDE_VERSION, GLOB_11_OVERRIDE_VERSION, BRACE_EXPANSION_1_OVERRIDE_VERSION, BRACE_EXPANSION_2_OVERRIDE_VERSION, BRACE_EXPANSION_5_OVERRIDE_VERSION, } from '../dependencies.js';
|
|
3
|
+
import { writeDependencyAudit } from '../dependency-patches.js';
|
|
4
|
+
import { usesVoidSelection } from '../runtime-policy.js';
|
|
5
|
+
import { VOID_NODE_ENGINE } from '../void.js';
|
|
2
6
|
import { setPnpmPolicy } from '../pnpm-policy.js';
|
|
3
|
-
import { writeSecurityBackports } from '../security-backports.js';
|
|
4
7
|
import { BOOTSTRAP_COMMAND } from '../registry/bootstrap.js';
|
|
5
8
|
import { appendGitignore } from '../util.js';
|
|
6
9
|
import { PACKAGE_MANAGER } from '../dependencies.js';
|
|
@@ -9,38 +12,70 @@ import { json, put, readJson, patchPackage, } from './files.js';
|
|
|
9
12
|
import { writeSetupDocumentation, workerBuildSuffix } from './documentation.js';
|
|
10
13
|
import { writeStackDocumentation } from './stack-documentation.js';
|
|
11
14
|
import { writeEnvironmentExample } from './environment.js';
|
|
15
|
+
import { providerConfigurationTemplate } from '../providers/config.js';
|
|
16
|
+
import { existsSync, readdirSync, rmSync } from 'node:fs';
|
|
17
|
+
import path from 'node:path';
|
|
12
18
|
function securityOverrides(options) {
|
|
13
19
|
const has = (value) => options.products.includes(value);
|
|
14
20
|
return {
|
|
15
|
-
...(has('wxt')
|
|
16
|
-
|
|
21
|
+
...(has('wxt')
|
|
22
|
+
? {
|
|
23
|
+
'@wxt-dev/module-react>@vitejs/plugin-react': SECURITY_OVERRIDE_DEPENDENCIES['@vitejs/plugin-react'],
|
|
24
|
+
}
|
|
25
|
+
: {}),
|
|
26
|
+
...(has('next') || has('vinext')
|
|
27
|
+
? { 'sharp@<0.35.5': SECURITY_OVERRIDE_DEPENDENCIES.sharp }
|
|
28
|
+
: {}),
|
|
17
29
|
...(options.products.some((product) => ['vinext', 'next', 'expo', 'electron', 'wxt', 'neon', 'd1'].includes(product))
|
|
18
|
-
? { 'source-map-js@<1.2.2': '
|
|
30
|
+
? { 'source-map-js@<1.2.2': SECURITY_OVERRIDE_DEPENDENCIES['source-map-js'] }
|
|
19
31
|
: {}),
|
|
20
32
|
...(has('next') && options.hosting === 'cloudflare'
|
|
21
|
-
? {
|
|
33
|
+
? {
|
|
34
|
+
'glob@>=10.2.0 <10.5.0': GLOB_10_OVERRIDE_VERSION,
|
|
35
|
+
'glob@>=11.0.0 <11.1.0': GLOB_11_OVERRIDE_VERSION,
|
|
36
|
+
}
|
|
22
37
|
: {}),
|
|
23
38
|
...(has('wxt')
|
|
24
|
-
? {
|
|
39
|
+
? {
|
|
40
|
+
'shell-quote@<1.12.0': SECURITY_OVERRIDE_DEPENDENCIES['shell-quote'],
|
|
41
|
+
'tmp@<0.2.7': SECURITY_OVERRIDE_DEPENDENCIES.tmp,
|
|
42
|
+
'adm-zip@<0.6.1': SECURITY_OVERRIDE_DEPENDENCIES['adm-zip'],
|
|
43
|
+
}
|
|
25
44
|
: {}),
|
|
26
|
-
'baseline-browser-mapping@<2.11.0': '
|
|
27
|
-
'browserslist@<4.28.7':
|
|
45
|
+
'baseline-browser-mapping@<2.11.0': SECURITY_OVERRIDE_DEPENDENCIES['baseline-browser-mapping'],
|
|
46
|
+
'browserslist@<4.28.7': SECURITY_OVERRIDE_DEPENDENCIES.browserslist,
|
|
28
47
|
...(((has('next') || has('vinext')) && options.hosting === 'cloudflare') ||
|
|
29
48
|
has('hono') ||
|
|
30
49
|
has('electron') ||
|
|
31
50
|
has('wxt')
|
|
32
|
-
? { 'esbuild@<0.25.0':
|
|
51
|
+
? { 'esbuild@<0.25.0': SECURITY_OVERRIDE_DEPENDENCIES.esbuild }
|
|
33
52
|
: {}),
|
|
34
|
-
'brace-expansion@<2':
|
|
35
|
-
'brace-expansion@>=2 <3':
|
|
36
|
-
'brace-expansion@>=
|
|
37
|
-
'brace-expansion@>=4 <5.0.12': '5.0.12',
|
|
53
|
+
'brace-expansion@<2': BRACE_EXPANSION_1_OVERRIDE_VERSION,
|
|
54
|
+
'brace-expansion@>=2 <3': BRACE_EXPANSION_2_OVERRIDE_VERSION,
|
|
55
|
+
'brace-expansion@>=4 <5.0.12': BRACE_EXPANSION_5_OVERRIDE_VERSION,
|
|
38
56
|
};
|
|
39
57
|
}
|
|
40
58
|
function writeTurboConfiguration(root, registry) {
|
|
41
|
-
const turbo =
|
|
59
|
+
const turbo = existsSync(path.join(root, 'turbo.json'))
|
|
60
|
+
? readJson(root, 'turbo.json')
|
|
61
|
+
: { tasks: {} };
|
|
62
|
+
turbo.$schema = 'https://turbo.build/schema.json';
|
|
63
|
+
turbo.globalDependencies = [
|
|
64
|
+
...new Set([
|
|
65
|
+
...(turbo.globalDependencies ?? []),
|
|
66
|
+
'**/.env',
|
|
67
|
+
'**/.env.*',
|
|
68
|
+
'**/.dev.vars',
|
|
69
|
+
'**/.dev.vars.*',
|
|
70
|
+
]),
|
|
71
|
+
];
|
|
42
72
|
turbo.globalEnv = [
|
|
43
|
-
...new Set([
|
|
73
|
+
...new Set([
|
|
74
|
+
...(turbo.globalEnv ?? []),
|
|
75
|
+
'VOID_CLOUDFLARE_DEPLOY_BUILD',
|
|
76
|
+
'npm_execpath',
|
|
77
|
+
...registry.items.flatMap((item) => item.environment),
|
|
78
|
+
]),
|
|
44
79
|
].sort();
|
|
45
80
|
turbo.tasks = {
|
|
46
81
|
...turbo.tasks,
|
|
@@ -48,10 +83,22 @@ function writeTurboConfiguration(root, registry) {
|
|
|
48
83
|
lint: { ...turbo.tasks.lint, dependsOn: ['^lint'] },
|
|
49
84
|
typecheck: { ...turbo.tasks.typecheck, dependsOn: ['^typecheck'] },
|
|
50
85
|
test: { dependsOn: ['^build'], outputs: ['coverage/**'] },
|
|
86
|
+
'db:generate': { cache: false },
|
|
87
|
+
'db:migrate': {
|
|
88
|
+
cache: false,
|
|
89
|
+
passThroughEnv: ['CLOUDFLARE_API_TOKEN', 'CLOUDFLARE_ACCOUNT_ID'],
|
|
90
|
+
},
|
|
51
91
|
build: {
|
|
52
92
|
...turbo.tasks.build,
|
|
53
93
|
dependsOn: [...new Set(['^build', ...(turbo.tasks.build?.dependsOn ?? [])])],
|
|
54
|
-
outputs: [
|
|
94
|
+
outputs: [
|
|
95
|
+
'.next/**',
|
|
96
|
+
'!.next/cache/**',
|
|
97
|
+
'!.next/dev/**',
|
|
98
|
+
'.open-next/**',
|
|
99
|
+
'dist/**',
|
|
100
|
+
'.output/**',
|
|
101
|
+
],
|
|
55
102
|
},
|
|
56
103
|
};
|
|
57
104
|
json(root, 'turbo.json', turbo);
|
|
@@ -63,7 +110,11 @@ export function writeStandardRoot(root, options, registry, updating = false) {
|
|
|
63
110
|
name: options.name,
|
|
64
111
|
private: true,
|
|
65
112
|
packageManager: PACKAGE_MANAGER,
|
|
66
|
-
engines: {
|
|
113
|
+
engines: {
|
|
114
|
+
node: usesVoidSelection(options.products, options.hosting)
|
|
115
|
+
? VOID_NODE_ENGINE
|
|
116
|
+
: WORKSPACE_NODE_ENGINE,
|
|
117
|
+
},
|
|
67
118
|
scripts: {
|
|
68
119
|
dev: 'turbo dev',
|
|
69
120
|
build: 'turbo build',
|
|
@@ -73,18 +124,25 @@ export function writeStandardRoot(root, options, registry, updating = false) {
|
|
|
73
124
|
lint: 'turbo lint',
|
|
74
125
|
typecheck: 'turbo typecheck',
|
|
75
126
|
test: 'turbo test',
|
|
127
|
+
...(has('neon') || has('d1')
|
|
128
|
+
? {
|
|
129
|
+
'db:generate': 'turbo run db:generate --filter=@workspace/db',
|
|
130
|
+
'db:migrate': 'turbo run db:migrate --filter=@workspace/db',
|
|
131
|
+
}
|
|
132
|
+
: {}),
|
|
76
133
|
audit: 'node scripts/audit.mjs',
|
|
77
134
|
'audit:full': 'fallow --fail-on-issues',
|
|
78
|
-
'audit:deps': 'node scripts/
|
|
135
|
+
'audit:deps': 'node scripts/audit-deps.mjs',
|
|
79
136
|
check: `pnpm lint && pnpm typecheck && pnpm run audit && pnpm audit:deps && pnpm test && pnpm build${workerBuildSuffix(options)}`,
|
|
80
137
|
},
|
|
81
|
-
devDependencies: { fallow: STACK_DEPENDENCIES['fallow'] },
|
|
138
|
+
devDependencies: { turbo: STACK_DEPENDENCIES['turbo'], fallow: STACK_DEPENDENCIES['fallow'] },
|
|
82
139
|
// Upstream starter lockfiles can retain vulnerable transitive versions. Keep fixes within compatible majors.
|
|
83
140
|
pnpm: {
|
|
84
141
|
...existing.pnpm,
|
|
85
142
|
overrides: { ...existing.pnpm?.overrides, ...securityOverrides(options) },
|
|
86
143
|
},
|
|
87
144
|
});
|
|
145
|
+
writeDependencyAudit(root, updating);
|
|
88
146
|
put(root, 'scripts/audit.mjs', `import { spawnSync } from 'node:child_process';
|
|
89
147
|
const base = process.env.AUDIT_BASE;
|
|
90
148
|
const hasBase = base || ['origin/main', 'main'].find((ref) => spawnSync('git', ['rev-parse', '--verify', ref], { stdio: 'ignore' }).status === 0);
|
|
@@ -96,7 +154,15 @@ if (result.error) throw result.error;
|
|
|
96
154
|
process.exitCode = result.status ?? 1;
|
|
97
155
|
`);
|
|
98
156
|
json(root, '.fallowrc.json', {
|
|
99
|
-
|
|
157
|
+
// Void loads these contracts outside the JavaScript import graph. Declare
|
|
158
|
+
// them as roots so their application dependencies remain fully audited.
|
|
159
|
+
entry: [
|
|
160
|
+
'apps/*/void.config.ts',
|
|
161
|
+
'apps/*/env.ts',
|
|
162
|
+
'apps/*/src/void-entry.ts',
|
|
163
|
+
'apps/*/crons/**/*.{ts,mts,js,mjs}',
|
|
164
|
+
...(has('electron') ? ['apps/desktop/src/main/preload.cts'] : []),
|
|
165
|
+
],
|
|
100
166
|
// Expo web export and NativeWind load these runtime dependencies dynamically.
|
|
101
167
|
...(has('expo')
|
|
102
168
|
? {
|
|
@@ -109,9 +175,16 @@ process.exitCode = result.status ?? 1;
|
|
|
109
175
|
}
|
|
110
176
|
: {}),
|
|
111
177
|
ignorePatterns: [
|
|
178
|
+
// Maintained bundled tooling is regression-tested in the CLI repository;
|
|
179
|
+
// app audits cover customer code without re-auditing vendored CLI helpers.
|
|
180
|
+
'scripts/audit.mjs',
|
|
181
|
+
'scripts/audit-deps.mjs',
|
|
182
|
+
'scripts/void-migrations.mjs',
|
|
183
|
+
'scripts/prepare-void-migrations.mjs',
|
|
112
184
|
'**/next-env.d.ts',
|
|
113
185
|
'**/.next/**',
|
|
114
186
|
'**/.open-next/**',
|
|
187
|
+
'**/.vinext/**',
|
|
115
188
|
'**/.wrangler/**',
|
|
116
189
|
'**/dist/**',
|
|
117
190
|
'**/worker-configuration.d.ts',
|
|
@@ -120,6 +193,8 @@ process.exitCode = result.status ?? 1;
|
|
|
120
193
|
});
|
|
121
194
|
writeTurboConfiguration(root, registry);
|
|
122
195
|
setPnpmPolicy(root, {
|
|
196
|
+
...(!updating ? { packages: ['apps/*', 'packages/*'] } : {}),
|
|
197
|
+
sharedWorkspaceLockfile: true,
|
|
123
198
|
allowBuilds: undefined,
|
|
124
199
|
onlyBuiltDependencies: [
|
|
125
200
|
'esbuild',
|
|
@@ -129,11 +204,30 @@ process.exitCode = result.status ?? 1;
|
|
|
129
204
|
...(has('electron') ? ['electron'] : []),
|
|
130
205
|
],
|
|
131
206
|
});
|
|
132
|
-
|
|
207
|
+
// Upstream app/package lockfiles would create competing dependency authorities.
|
|
208
|
+
if (!updating) {
|
|
209
|
+
for (const parent of ['apps', 'packages']) {
|
|
210
|
+
const directory = path.join(root, parent);
|
|
211
|
+
if (!existsSync(directory))
|
|
212
|
+
continue;
|
|
213
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
214
|
+
if (!entry.isDirectory())
|
|
215
|
+
continue;
|
|
216
|
+
for (const lock of ['pnpm-lock.yaml', 'package-lock.json', 'yarn.lock'])
|
|
217
|
+
rmSync(path.join(directory, entry.name, lock), { force: true });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
for (const lock of ['package-lock.json', 'yarn.lock'])
|
|
221
|
+
rmSync(path.join(root, lock), { force: true });
|
|
222
|
+
}
|
|
133
223
|
appendGitignore(root, [
|
|
134
224
|
'node_modules/',
|
|
135
225
|
'.open-next/',
|
|
226
|
+
'.vinext/',
|
|
136
227
|
'.wrangler/',
|
|
228
|
+
'.void/',
|
|
229
|
+
'.void-wrangler.jsonc',
|
|
230
|
+
'/apps/*/db/migrations/',
|
|
137
231
|
'.dev.vars',
|
|
138
232
|
'.dev.vars.*',
|
|
139
233
|
'!.dev.vars.example',
|
|
@@ -146,13 +240,13 @@ process.exitCode = result.status ?? 1;
|
|
|
146
240
|
]);
|
|
147
241
|
writeEnvironmentExample(root, registry);
|
|
148
242
|
writeStackDocumentation(root, registry);
|
|
149
|
-
|
|
243
|
+
writeProjectSection(root, 'standard', {
|
|
150
244
|
schemaVersion: 1,
|
|
151
245
|
standard: 'anhedral-application-stack',
|
|
152
246
|
products: options.products,
|
|
153
247
|
hosting: has('next') || has('vinext') ? options.hosting : null,
|
|
154
248
|
bootstrap: updating
|
|
155
|
-
?
|
|
249
|
+
? readProjectSection(root, 'standard').bootstrap
|
|
156
250
|
: {
|
|
157
251
|
command: BOOTSTRAP_COMMAND.join(' '),
|
|
158
252
|
upstreamPackageManager: existing.packageManager,
|
|
@@ -160,7 +254,15 @@ process.exitCode = result.status ?? 1;
|
|
|
160
254
|
status: 'starter',
|
|
161
255
|
resourcesProvisioned: false,
|
|
162
256
|
});
|
|
163
|
-
|
|
257
|
+
writeProjectSection(root, 'setup', createSetupPlan({ ...options, dryRun: false }, registry));
|
|
258
|
+
const providers = providerConfigurationTemplate(options.products, options.name);
|
|
259
|
+
const prior = updating && hasProjectSection(root, 'providers')
|
|
260
|
+
? readProjectSection(root, 'providers')
|
|
261
|
+
: undefined;
|
|
262
|
+
writeProjectSection(root, 'providers', {
|
|
263
|
+
...providers,
|
|
264
|
+
providers: { ...providers.providers, ...prior?.providers },
|
|
265
|
+
});
|
|
164
266
|
if (!updating)
|
|
165
267
|
writeSetupDocumentation(root, options);
|
|
166
268
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CloudflareRequest } from './cloudflare.js';
|
|
2
|
+
export interface DeletionPlan {
|
|
3
|
+
token: string;
|
|
4
|
+
name: string;
|
|
5
|
+
accountId: string;
|
|
6
|
+
resourceId: string;
|
|
7
|
+
kind: string;
|
|
8
|
+
applications: string[];
|
|
9
|
+
expiresAt: string;
|
|
10
|
+
impact: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class ServiceDeletionStore {
|
|
13
|
+
readonly directory: string;
|
|
14
|
+
constructor(directory: string);
|
|
15
|
+
plan(root: string, key: string, request: CloudflareRequest): Promise<DeletionPlan>;
|
|
16
|
+
execute(root: string, key: string, token: string, typedName: string, request: CloudflareRequest): Promise<{
|
|
17
|
+
state: "deleted";
|
|
18
|
+
resourceId: string;
|
|
19
|
+
message: string;
|
|
20
|
+
} | {
|
|
21
|
+
state: "uncertain";
|
|
22
|
+
resourceId: string;
|
|
23
|
+
message: string;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
export declare function assertNoDeletedServices(root: string, resources: {
|
|
27
|
+
kind: string;
|
|
28
|
+
name: string;
|
|
29
|
+
}[]): void;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
2
|
+
import { existsSync, mkdirSync, realpathSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { readBoundedFile } from './bounded-file.js';
|
|
6
|
+
import { atomicJson, readApplication, withApplicationLock } from './project-state.js';
|
|
7
|
+
import { inspectApplication } from './project-inspector.js';
|
|
8
|
+
import { resolveService } from './service-descriptor.js';
|
|
9
|
+
import { observeService, record, serviceEndpoint } from './service-readers.js';
|
|
10
|
+
const digest = (value) => createHash('sha256').update(value).digest('hex');
|
|
11
|
+
const actionSchema = z
|
|
12
|
+
.object({
|
|
13
|
+
schemaVersion: z.literal(1),
|
|
14
|
+
root: z.string(),
|
|
15
|
+
serviceKey: z.string().max(1024),
|
|
16
|
+
fingerprint: z.string().regex(/^[a-f0-9]{64}$/),
|
|
17
|
+
name: z.string().max(256),
|
|
18
|
+
expiresAt: z.number(),
|
|
19
|
+
state: z.enum(['prepared', 'pending', 'deleted', 'uncertain', 'rejected']),
|
|
20
|
+
})
|
|
21
|
+
.strict();
|
|
22
|
+
function fingerprint(root, service) {
|
|
23
|
+
const inspection = inspectApplication(root);
|
|
24
|
+
return digest(JSON.stringify({
|
|
25
|
+
service,
|
|
26
|
+
project: readApplication(root),
|
|
27
|
+
configuration: inspection.configuration,
|
|
28
|
+
receipts: inspection.cloudflareResources,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
async function assertDeletionScope(root, service, request) {
|
|
32
|
+
if (!['d1', 'kv'].includes(service.kind) ||
|
|
33
|
+
service.ownership !== 'created' ||
|
|
34
|
+
!service.name ||
|
|
35
|
+
service.applications.length > 1)
|
|
36
|
+
throw new Error('Deletion requires a supported, recorded project-created resource with at most one owning application. Reused, shared, or unverified resources cannot be deleted here.');
|
|
37
|
+
const observation = await observeService(service, request);
|
|
38
|
+
if (observation.state !== 'available' || observation.name !== service.name)
|
|
39
|
+
throw new Error('The exact resource identity must be confirmed before deletion.');
|
|
40
|
+
const scripts = await request('GET', '/workers/scripts?per_page=100');
|
|
41
|
+
if (!Array.isArray(scripts.result) ||
|
|
42
|
+
scripts.result.length >= 100 ||
|
|
43
|
+
(scripts.result_info?.total_pages ?? 1) > 1)
|
|
44
|
+
throw new Error('Worker dependency listing is incomplete; deletion is blocked.');
|
|
45
|
+
const project = readApplication(root);
|
|
46
|
+
const allowed = new Set(project.targets
|
|
47
|
+
.filter((target) => service.applications.includes(target.directory))
|
|
48
|
+
.map((target) => target.workerName));
|
|
49
|
+
for (const raw of scripts.result) {
|
|
50
|
+
const script = record(raw);
|
|
51
|
+
if (typeof script.id !== 'string' || !/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,62}$/.test(script.id))
|
|
52
|
+
throw new Error('Worker dependency identity is unavailable.');
|
|
53
|
+
const settings = record((await request('GET', `/workers/scripts/${script.id}/settings`)).result);
|
|
54
|
+
if (!Array.isArray(settings.bindings) || settings.bindings.length > 500)
|
|
55
|
+
throw new Error('Worker dependencies could not be verified.');
|
|
56
|
+
for (const rawBinding of settings.bindings) {
|
|
57
|
+
const binding = record(rawBinding);
|
|
58
|
+
if ((binding.type === 'd1' && typeof binding.id !== 'string') ||
|
|
59
|
+
(binding.type === 'kv_namespace' && typeof binding.namespace_id !== 'string'))
|
|
60
|
+
throw new Error('Worker dependency identities are incomplete.');
|
|
61
|
+
const uses = service.kind === 'd1'
|
|
62
|
+
? binding.type === 'd1' && binding.id === service.id
|
|
63
|
+
: binding.type === 'kv_namespace' && binding.namespace_id === service.id;
|
|
64
|
+
if (uses && !allowed.has(script.id))
|
|
65
|
+
throw new Error('Another Worker uses this resource. Shared resources cannot be deleted here.');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export class ServiceDeletionStore {
|
|
70
|
+
directory;
|
|
71
|
+
constructor(directory) {
|
|
72
|
+
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
73
|
+
this.directory = realpathSync(directory);
|
|
74
|
+
}
|
|
75
|
+
async plan(root, key, request) {
|
|
76
|
+
root = realpathSync(root);
|
|
77
|
+
const service = resolveService(root, key);
|
|
78
|
+
const before = fingerprint(root, service);
|
|
79
|
+
await assertDeletionScope(root, service, request);
|
|
80
|
+
if (before !== fingerprint(root, resolveService(root, key)))
|
|
81
|
+
throw new Error('Source changed during deletion planning.');
|
|
82
|
+
const token = randomBytes(32).toString('base64url');
|
|
83
|
+
const expiresAt = Date.now() + 5 * 60_000;
|
|
84
|
+
writeFileSync(path.join(this.directory, `${digest(token)}.json`), JSON.stringify({
|
|
85
|
+
schemaVersion: 1,
|
|
86
|
+
root,
|
|
87
|
+
serviceKey: key,
|
|
88
|
+
fingerprint: before,
|
|
89
|
+
name: service.name,
|
|
90
|
+
expiresAt,
|
|
91
|
+
state: 'prepared',
|
|
92
|
+
}), { mode: 0o600, flag: 'wx' });
|
|
93
|
+
return {
|
|
94
|
+
token,
|
|
95
|
+
name: service.name,
|
|
96
|
+
accountId: service.accountId,
|
|
97
|
+
resourceId: service.id,
|
|
98
|
+
kind: service.kind,
|
|
99
|
+
applications: service.applications,
|
|
100
|
+
expiresAt: new Date(expiresAt).toISOString(),
|
|
101
|
+
impact: 'Permanently removes this resource and its stored data. Existing source bindings remain and must be reviewed before shipping.',
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
async execute(root, key, token, typedName, request) {
|
|
105
|
+
if (!/^[a-zA-Z0-9_-]{43}$/.test(token))
|
|
106
|
+
throw new Error('Invalid deletion confirmation.');
|
|
107
|
+
const file = path.join(this.directory, `${digest(token)}.json`);
|
|
108
|
+
return withApplicationLock(root, async () => {
|
|
109
|
+
const saved = actionSchema.parse(JSON.parse(readBoundedFile(file, 16384).toString('utf8')));
|
|
110
|
+
root = realpathSync(root);
|
|
111
|
+
if (saved.root !== root ||
|
|
112
|
+
saved.serviceKey !== key ||
|
|
113
|
+
saved.name !== typedName ||
|
|
114
|
+
saved.expiresAt < Date.now() ||
|
|
115
|
+
saved.state !== 'prepared')
|
|
116
|
+
throw new Error('Deletion confirmation is expired, already used, or does not match this resource.');
|
|
117
|
+
const service = resolveService(root, key);
|
|
118
|
+
if (saved.fingerprint !== fingerprint(root, service))
|
|
119
|
+
throw new Error('Service identity or dependencies changed. Review a new deletion plan.');
|
|
120
|
+
await assertDeletionScope(root, service, request);
|
|
121
|
+
if (saved.fingerprint !== fingerprint(root, resolveService(root, key)))
|
|
122
|
+
throw new Error('Source changed before deletion.');
|
|
123
|
+
saved.state = 'pending';
|
|
124
|
+
atomicJson(file, saved);
|
|
125
|
+
const journal = path.join(root, '.anhedral/service-deletions.json');
|
|
126
|
+
const writeReceipt = (state) => {
|
|
127
|
+
let entries = [];
|
|
128
|
+
if (existsSync(journal)) {
|
|
129
|
+
const previous = record(JSON.parse(readBoundedFile(journal, 256 * 1024).toString('utf8')));
|
|
130
|
+
if (previous.projectId !== service.projectId ||
|
|
131
|
+
previous.accountId !== service.accountId ||
|
|
132
|
+
!Array.isArray(previous.entries) ||
|
|
133
|
+
previous.entries.length >= 500)
|
|
134
|
+
throw new Error('Deletion journal is invalid or full.');
|
|
135
|
+
entries = previous.entries.filter((entry) => record(entry).resourceId !== service.id);
|
|
136
|
+
}
|
|
137
|
+
atomicJson(journal, {
|
|
138
|
+
schemaVersion: 1,
|
|
139
|
+
projectId: service.projectId,
|
|
140
|
+
accountId: service.accountId,
|
|
141
|
+
entries: [
|
|
142
|
+
...entries,
|
|
143
|
+
{
|
|
144
|
+
resourceId: service.id,
|
|
145
|
+
kind: service.kind,
|
|
146
|
+
name: service.name,
|
|
147
|
+
state,
|
|
148
|
+
recordedAt: new Date().toISOString(),
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
writeReceipt('pending');
|
|
154
|
+
try {
|
|
155
|
+
await request('DELETE', serviceEndpoint(service));
|
|
156
|
+
if ((await observeService(service, request)).state !== 'not-found')
|
|
157
|
+
throw new Error('Deletion could not be confirmed.');
|
|
158
|
+
saved.state = 'deleted';
|
|
159
|
+
atomicJson(file, saved);
|
|
160
|
+
writeReceipt('deleted');
|
|
161
|
+
return {
|
|
162
|
+
state: 'deleted',
|
|
163
|
+
resourceId: service.id,
|
|
164
|
+
message: 'Provider confirmed deletion. Review the remaining source bindings before shipping.',
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
saved.state = 'uncertain';
|
|
169
|
+
atomicJson(file, saved);
|
|
170
|
+
writeReceipt('uncertain');
|
|
171
|
+
return {
|
|
172
|
+
state: 'uncertain',
|
|
173
|
+
resourceId: service.id,
|
|
174
|
+
message: 'Deletion outcome is uncertain. Refresh provider status; no automatic deletion retry is performed.',
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
export function assertNoDeletedServices(root, resources) {
|
|
181
|
+
const file = path.join(root, '.anhedral/service-deletions.json');
|
|
182
|
+
if (!existsSync(file))
|
|
183
|
+
return;
|
|
184
|
+
const saved = record(JSON.parse(readBoundedFile(file, 256 * 1024).toString('utf8')));
|
|
185
|
+
const project = readApplication(root);
|
|
186
|
+
if (saved.projectId !== project.id ||
|
|
187
|
+
saved.accountId !== project.accountId ||
|
|
188
|
+
!Array.isArray(saved.entries))
|
|
189
|
+
throw new Error('Deletion history cannot be verified before provisioning.');
|
|
190
|
+
for (const raw of saved.entries) {
|
|
191
|
+
const entry = record(raw);
|
|
192
|
+
if (resources.some((resource) => resource.kind === entry.kind && resource.name === entry.name))
|
|
193
|
+
throw new Error('A selected resource has a recorded deletion attempt. Review source bindings and remote state before provisioning; deleted services are not recreated automatically.');
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ServiceDescriptor, ServiceKind } from './service-model.js';
|
|
2
|
+
import type { ProjectInspection } from './inspector-model.js';
|
|
3
|
+
export declare function unboundResourceSelectors(inspection: ProjectInspection): string[];
|
|
4
|
+
export declare function resolveService(root: string, key: string): ServiceDescriptor;
|
|
5
|
+
export declare function serviceCapabilities(kind: ServiceKind): {
|
|
6
|
+
status: boolean;
|
|
7
|
+
metrics: boolean;
|
|
8
|
+
data: boolean;
|
|
9
|
+
delete: boolean;
|
|
10
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { inspectApplication } from './project-inspector.js';
|
|
2
|
+
import { readApplication } from './project-state.js';
|
|
3
|
+
const kinds = {
|
|
4
|
+
D1: 'd1',
|
|
5
|
+
KV: 'kv',
|
|
6
|
+
R2: 'r2',
|
|
7
|
+
'Queue producer': 'queue',
|
|
8
|
+
'Queue consumer': 'queue',
|
|
9
|
+
};
|
|
10
|
+
export function unboundResourceSelectors(inspection) {
|
|
11
|
+
return inspection.cloudflareResources.data
|
|
12
|
+
.filter((resource) => !inspection.configuration.data.bindings.some((binding) => kinds[binding.kind] === resource.kind &&
|
|
13
|
+
(binding.resourceId === resource.id ||
|
|
14
|
+
(['r2', 'queue'].includes(resource.kind) && binding.resourceId === resource.name))))
|
|
15
|
+
.map((resource) => `receipt:${resource.kind}:${resource.id}`);
|
|
16
|
+
}
|
|
17
|
+
export function resolveService(root, key) {
|
|
18
|
+
const inspection = inspectApplication(root);
|
|
19
|
+
const project = readApplication(root);
|
|
20
|
+
if (!project.accountId ||
|
|
21
|
+
inspection.targets.state !== 'available' ||
|
|
22
|
+
inspection.configuration.state !== 'available')
|
|
23
|
+
throw new Error('Validated service configuration and a connected account are required.');
|
|
24
|
+
const target = inspection.targets.data.find((item) => key === `target:${item.provider}:${item.id}` && item.provider === 'cloudflare' && !item.error);
|
|
25
|
+
if (target) {
|
|
26
|
+
const configured = project.targets.find((item) => item.directory === target.application);
|
|
27
|
+
if (!configured)
|
|
28
|
+
throw new Error('Service target identity changed.');
|
|
29
|
+
return {
|
|
30
|
+
key,
|
|
31
|
+
kind: 'worker',
|
|
32
|
+
id: configured.workerName,
|
|
33
|
+
name: configured.workerName,
|
|
34
|
+
accountId: project.accountId,
|
|
35
|
+
projectId: project.id,
|
|
36
|
+
applications: [target.application],
|
|
37
|
+
ownership: 'unknown',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const binding = inspection.configuration.data.bindings.find((item) => key === `binding:${item.application}:${item.kind}:${item.name}`);
|
|
41
|
+
const record = inspection.cloudflareResources.data.find((item) => key === `receipt:${item.kind}:${item.id}`);
|
|
42
|
+
const kind = binding ? kinds[binding.kind] : record?.kind;
|
|
43
|
+
const id = binding?.resourceId ?? record?.id;
|
|
44
|
+
if (!kind ||
|
|
45
|
+
!['d1', 'kv', 'r2', 'queue'].includes(kind) ||
|
|
46
|
+
!id ||
|
|
47
|
+
!/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,254}$/.test(id))
|
|
48
|
+
throw new Error('This service has no supported provider resource identity.');
|
|
49
|
+
const receipt = record ??
|
|
50
|
+
inspection.cloudflareResources.data.find((item) => item.kind === kind &&
|
|
51
|
+
(item.id === id || (['r2', 'queue'].includes(kind) && item.name === id)));
|
|
52
|
+
const references = inspection.configuration.data.bindings.filter((item) => kinds[item.kind] === kind &&
|
|
53
|
+
(item.resourceId === id ||
|
|
54
|
+
(receipt && [receipt.name, receipt.id].includes(item.resourceId ?? ''))));
|
|
55
|
+
return {
|
|
56
|
+
key,
|
|
57
|
+
kind,
|
|
58
|
+
id: receipt?.id ?? id,
|
|
59
|
+
name: receipt?.name ?? (kind === 'r2' ? id : null),
|
|
60
|
+
accountId: project.accountId,
|
|
61
|
+
projectId: project.id,
|
|
62
|
+
applications: [...new Set(references.map((item) => item.application))].sort(),
|
|
63
|
+
ownership: inspection.cloudflareResources.state === 'available' &&
|
|
64
|
+
(receipt?.createdByProject === true || receipt?.reused === false)
|
|
65
|
+
? 'created'
|
|
66
|
+
: receipt?.reused === true
|
|
67
|
+
? 'reused'
|
|
68
|
+
: 'unknown',
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export function serviceCapabilities(kind) {
|
|
72
|
+
return {
|
|
73
|
+
status: true,
|
|
74
|
+
metrics: kind === 'd1' || kind === 'worker',
|
|
75
|
+
data: kind === 'd1' || kind === 'kv' || kind === 'r2',
|
|
76
|
+
delete: kind === 'd1' || kind === 'kv',
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export declare const SERVICE_TOOL_ACTIONS: {
|
|
2
|
+
readonly refresh_service: "status";
|
|
3
|
+
readonly get_service_metrics: "metrics";
|
|
4
|
+
readonly list_service_tables: "tables";
|
|
5
|
+
readonly browse_service_data: "data";
|
|
6
|
+
readonly plan_service_deletion: "delete-plan";
|
|
7
|
+
readonly delete_service: "delete";
|
|
8
|
+
};
|
|
9
|
+
export type ServiceAction = (typeof SERVICE_TOOL_ACTIONS)[keyof typeof SERVICE_TOOL_ACTIONS];
|
|
10
|
+
export type ServiceKind = 'worker' | 'd1' | 'kv' | 'r2' | 'queue';
|
|
11
|
+
export interface ServiceDescriptor {
|
|
12
|
+
key: string;
|
|
13
|
+
kind: ServiceKind;
|
|
14
|
+
id: string;
|
|
15
|
+
name: string | null;
|
|
16
|
+
accountId: string;
|
|
17
|
+
projectId: string;
|
|
18
|
+
applications: string[];
|
|
19
|
+
ownership: 'created' | 'reused' | 'unknown';
|
|
20
|
+
}
|
|
21
|
+
export interface ServiceObservation {
|
|
22
|
+
state: 'available' | 'not-found' | 'permission-required' | 'unavailable';
|
|
23
|
+
fetchedAt: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
storageBytes?: number;
|
|
26
|
+
message: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ServiceMetrics {
|
|
29
|
+
fetchedAt: string;
|
|
30
|
+
start: string;
|
|
31
|
+
end: string;
|
|
32
|
+
timezone: 'UTC';
|
|
33
|
+
source: string;
|
|
34
|
+
sampled: boolean;
|
|
35
|
+
points: {
|
|
36
|
+
time: string;
|
|
37
|
+
values: Record<string, number>;
|
|
38
|
+
}[];
|
|
39
|
+
units: Record<string, string>;
|
|
40
|
+
}
|
|
41
|
+
export interface ServiceData {
|
|
42
|
+
fetchedAt: string;
|
|
43
|
+
columns: string[];
|
|
44
|
+
rows: (string | number | boolean | null)[][];
|
|
45
|
+
offset: number;
|
|
46
|
+
hasMore: boolean;
|
|
47
|
+
masked: boolean;
|
|
48
|
+
nextCursor?: string;
|
|
49
|
+
}
|