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
package/dist/bin.js
CHANGED
|
@@ -1,47 +1,164 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { runServiceCommand } from './services-command.js';
|
|
3
|
+
import { shipCloudflareApplication, shipSelectedVercelApplication, shipSelectedStack, } from './ship.js';
|
|
4
|
+
import { integrationStatus, recoverIntegrationResource } from './providers/recovery.js';
|
|
5
|
+
import { INTEGRATION_PROVIDERS } from './providers/config.js';
|
|
6
|
+
import { recoverDeliveryLock } from './project-state.js';
|
|
7
|
+
import { readLifecycleOperation } from './lifecycle.js';
|
|
8
|
+
import { buildMobileApplication } from './mobile-delivery.js';
|
|
9
|
+
import { authenticateProviders } from './provider-auth.js';
|
|
2
10
|
import { runAdd, runRegistry } from './registry/commands.js';
|
|
3
|
-
import { registerManagedApplication, stageManagedVersion, saveManagedVersion, deployManagedVersion, managedApplicationStatus, } from './managed-hosting.js';
|
|
4
11
|
import { setupRepository } from './repository.js';
|
|
5
12
|
import path from 'node:path';
|
|
6
|
-
import {
|
|
7
|
-
import { registerVercelApplication, connectVercelApplication,
|
|
8
|
-
import { registerApplication, connectApplication,
|
|
13
|
+
import { hasProjectSection, readProjectSection } from './project-config.js';
|
|
14
|
+
import { registerVercelApplication, connectVercelApplication, vercelApplicationStatus, verifyVercelApplication, rollbackVercelApplication, adoptVercelApplication, recoverVercelApplication, writeVercelOverview, } from './vercel.js';
|
|
15
|
+
import { registerApplication, connectApplication, applicationStatus, verifyApplication, rollbackApplication, recoverApplication, } from './delivery.js';
|
|
9
16
|
import { planProvisioning, provisionApplication } from './provision.js';
|
|
10
17
|
import { writeManagementOverview } from './management.js';
|
|
11
18
|
import { inspectProviderReadiness } from './provider-readiness.js';
|
|
12
19
|
import { inspectProject } from './readiness.js';
|
|
20
|
+
import { inspectApplication } from './project-inspector.js';
|
|
13
21
|
import { argv } from 'node:process';
|
|
14
22
|
import { STANDARD_USAGE, parseStandardOptions, scaffoldStandardProject } from './standard.js';
|
|
15
23
|
import { GENERATOR_VERSION } from './version.js';
|
|
16
24
|
import { PostCommitError } from './transaction.js';
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
import { CliArgumentError, globalArguments, inlineArguments, validateCommand, } from './cli-arguments.js';
|
|
26
|
+
import { printResult } from './cli-output.js';
|
|
27
|
+
import { commandHelp } from './registry/usage.js';
|
|
28
|
+
let [command, ...args] = argv.slice(2);
|
|
29
|
+
let json = argv.includes('--json');
|
|
30
|
+
let output = { json };
|
|
31
|
+
function argumentError(message) {
|
|
32
|
+
return new CliArgumentError(message, `Run anhedral ${command && commandHelp(command) ? command + ' ' : ''}--help.`);
|
|
33
|
+
}
|
|
19
34
|
async function main() {
|
|
20
|
-
|
|
21
|
-
|
|
35
|
+
const global = globalArguments(argv.slice(2));
|
|
36
|
+
[command, ...args] = global.args;
|
|
37
|
+
json = global.json;
|
|
38
|
+
if (json)
|
|
39
|
+
args.push('--json');
|
|
40
|
+
args = inlineArguments(command, args);
|
|
41
|
+
output = { json, quiet: global.quiet };
|
|
42
|
+
if ([undefined, '--help', '-h', 'help'].includes(command) ||
|
|
43
|
+
args.includes('--help') ||
|
|
44
|
+
args.includes('-h')) {
|
|
45
|
+
const target = command === 'help'
|
|
46
|
+
? args.filter((arg) => arg !== '--json')[0]
|
|
47
|
+
: ['--help', '-h'].includes(command)
|
|
48
|
+
? undefined
|
|
49
|
+
: command;
|
|
50
|
+
const help = target ? commandHelp(target) : STANDARD_USAGE;
|
|
51
|
+
if (!help)
|
|
52
|
+
throw new CliArgumentError('Unknown help topic.', 'Run anhedral --help.');
|
|
53
|
+
console.log(json ? JSON.stringify({ usage: help }) : help);
|
|
22
54
|
return;
|
|
23
55
|
}
|
|
56
|
+
validateCommand(command, args);
|
|
24
57
|
if (['--version', '-v'].includes(command)) {
|
|
25
58
|
console.log(json ? JSON.stringify({ version: GENERATOR_VERSION }) : GENERATOR_VERSION);
|
|
26
59
|
return;
|
|
27
60
|
}
|
|
28
|
-
if (
|
|
29
|
-
|
|
61
|
+
if (global.cwd) {
|
|
62
|
+
try {
|
|
63
|
+
process.chdir(global.cwd);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
throw new CliArgumentError('Working directory is unavailable.', 'Choose an existing directory with --cwd <directory>.');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (global.quiet || json)
|
|
70
|
+
process.env.ANHEDRAL_QUIET = '1';
|
|
71
|
+
if (global.verbose && !json && !global.quiet)
|
|
72
|
+
process.env.ANHEDRAL_VERBOSE = '1';
|
|
73
|
+
if (command === 'services') {
|
|
74
|
+
printResult(command, await runServiceCommand(process.cwd(), args), output);
|
|
30
75
|
return;
|
|
31
76
|
}
|
|
32
|
-
if (command === '
|
|
33
|
-
|
|
77
|
+
if (command === 'inspect') {
|
|
78
|
+
const directories = args.filter((arg) => arg !== '--json');
|
|
79
|
+
if (directories.length > 1 || directories.some((arg) => arg.startsWith('-')))
|
|
80
|
+
throw argumentError('Specify at most one project directory.');
|
|
81
|
+
printResult(command, inspectApplication(path.resolve(directories[0] ?? process.cwd())), output);
|
|
34
82
|
return;
|
|
35
83
|
}
|
|
36
|
-
if (command === '
|
|
37
|
-
|
|
84
|
+
if (command === 'integrations') {
|
|
85
|
+
const [action, ...input] = args.filter((arg) => arg !== '--json');
|
|
86
|
+
const directories = [];
|
|
87
|
+
const options = {};
|
|
88
|
+
for (let index = 0; index < input.length; index++) {
|
|
89
|
+
const flag = input[index];
|
|
90
|
+
if (['--provider', '--operation', '--resource'].includes(flag))
|
|
91
|
+
options[flag] = input[++index];
|
|
92
|
+
else if (flag.startsWith('-'))
|
|
93
|
+
throw argumentError('Unknown integration option.');
|
|
94
|
+
else
|
|
95
|
+
directories.push(flag);
|
|
96
|
+
}
|
|
97
|
+
if (directories.length > 1)
|
|
98
|
+
throw argumentError('Specify one application directory.');
|
|
99
|
+
const root = path.resolve(directories[0] ?? process.cwd());
|
|
100
|
+
if (action === 'status') {
|
|
101
|
+
if (Object.keys(options).length)
|
|
102
|
+
throw argumentError('Integration status accepts no recovery options.');
|
|
103
|
+
printResult(command, integrationStatus(root), output);
|
|
104
|
+
}
|
|
105
|
+
else if (action === 'recover') {
|
|
106
|
+
if (!INTEGRATION_PROVIDERS.includes(options['--provider']) ||
|
|
107
|
+
!options['--operation'] ||
|
|
108
|
+
!options['--resource'])
|
|
109
|
+
throw argumentError('Recovery requires --provider, --operation and --resource.');
|
|
110
|
+
printResult(command, await recoverIntegrationResource(root, {
|
|
111
|
+
provider: options['--provider'],
|
|
112
|
+
operation: options['--operation'],
|
|
113
|
+
resourceId: options['--resource'],
|
|
114
|
+
}), output);
|
|
115
|
+
}
|
|
116
|
+
else
|
|
117
|
+
throw argumentError('Use integrations status or integrations recover.');
|
|
38
118
|
return;
|
|
39
119
|
}
|
|
40
|
-
if (command === '
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
120
|
+
if (command === 'auth') {
|
|
121
|
+
let provider;
|
|
122
|
+
const directories = [];
|
|
123
|
+
for (let index = 0; index < args.length; index++) {
|
|
124
|
+
const flag = args[index];
|
|
125
|
+
if (['--json', '--status', '--non-interactive'].includes(flag))
|
|
126
|
+
continue;
|
|
127
|
+
if (flag === '--provider') {
|
|
128
|
+
const value = args[++index];
|
|
129
|
+
if (provider || !value || value.startsWith('-'))
|
|
130
|
+
throw argumentError('Specify one auth provider.');
|
|
131
|
+
provider = value;
|
|
132
|
+
}
|
|
133
|
+
else if (flag.startsWith('-'))
|
|
134
|
+
throw argumentError('Unknown auth option.');
|
|
135
|
+
else
|
|
136
|
+
directories.push(flag);
|
|
44
137
|
}
|
|
138
|
+
if (directories.length > 1)
|
|
139
|
+
throw argumentError('Specify one application directory.');
|
|
140
|
+
const result = await authenticateProviders(path.resolve(directories[0] ?? process.cwd()), {
|
|
141
|
+
provider,
|
|
142
|
+
status: args.includes('--status'),
|
|
143
|
+
interactive: !json &&
|
|
144
|
+
!output.quiet &&
|
|
145
|
+
!args.includes('--non-interactive') &&
|
|
146
|
+
Boolean(process.stdin.isTTY),
|
|
147
|
+
});
|
|
148
|
+
printResult('auth', result, output);
|
|
149
|
+
if (!result.authenticated)
|
|
150
|
+
process.exitCode = 1;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (command === 'add') {
|
|
154
|
+
await runAdd(args, output);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (command === 'registry') {
|
|
158
|
+
await runRegistry(args, json, output);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (command === 'repository') {
|
|
45
162
|
let owner;
|
|
46
163
|
let name;
|
|
47
164
|
let visibility = 'private';
|
|
@@ -58,36 +175,36 @@ async function main() {
|
|
|
58
175
|
if (flag === '--owner' || flag === '--name' || flag === '--visibility') {
|
|
59
176
|
const value = args[++index];
|
|
60
177
|
if (!value || value.startsWith('-'))
|
|
61
|
-
throw
|
|
178
|
+
throw argumentError('Missing repository option value.');
|
|
62
179
|
if (flag === '--owner') {
|
|
63
180
|
if (owner)
|
|
64
|
-
throw
|
|
181
|
+
throw argumentError('Specify one GitHub owner.');
|
|
65
182
|
owner = value;
|
|
66
183
|
}
|
|
67
184
|
else if (flag === '--name') {
|
|
68
185
|
if (name)
|
|
69
|
-
throw
|
|
186
|
+
throw argumentError('Specify one repository name.');
|
|
70
187
|
name = value;
|
|
71
188
|
}
|
|
72
189
|
else {
|
|
73
190
|
if (!['private', 'public'].includes(value))
|
|
74
|
-
throw
|
|
191
|
+
throw argumentError('Visibility must be private or public.');
|
|
75
192
|
visibility = value;
|
|
76
193
|
}
|
|
77
194
|
continue;
|
|
78
195
|
}
|
|
79
196
|
if (flag.startsWith('-'))
|
|
80
|
-
throw
|
|
197
|
+
throw argumentError('Unknown repository option.');
|
|
81
198
|
directories.push(flag);
|
|
82
199
|
}
|
|
83
200
|
if (directories.length > 1)
|
|
84
|
-
throw
|
|
85
|
-
|
|
201
|
+
throw argumentError('Specify one application directory.');
|
|
202
|
+
printResult('repository', await setupRepository(path.resolve(directories[0] ?? process.cwd()), {
|
|
86
203
|
owner,
|
|
87
204
|
name,
|
|
88
205
|
visibility,
|
|
89
206
|
create,
|
|
90
|
-
}),
|
|
207
|
+
}), output);
|
|
91
208
|
return;
|
|
92
209
|
}
|
|
93
210
|
if ([
|
|
@@ -109,87 +226,14 @@ async function main() {
|
|
|
109
226
|
await runDoctor(args);
|
|
110
227
|
return;
|
|
111
228
|
}
|
|
112
|
-
if (command !== '
|
|
113
|
-
throw
|
|
114
|
-
}
|
|
115
|
-
if (args.some((arg) => ['--help', '-h'].includes(arg))) {
|
|
116
|
-
console.log(json ? JSON.stringify({ usage: STANDARD_USAGE }) : STANDARD_USAGE);
|
|
117
|
-
return;
|
|
229
|
+
if (command !== 'init') {
|
|
230
|
+
throw argumentError(`Unknown command: ${command}. Use init, auth, ship, add, registry, inspect, doctor, repository, register, connect, provision, status, manage, verify, rollback, adopt, recover, --help, or --version.`);
|
|
118
231
|
}
|
|
119
|
-
const options = readOptions(
|
|
232
|
+
const options = readOptions(args);
|
|
120
233
|
if (options)
|
|
121
|
-
await scaffoldStandardProject(options);
|
|
122
|
-
}
|
|
123
|
-
async function runCloud(args) {
|
|
124
|
-
const [action, ...flags] = args;
|
|
125
|
-
if (!action || flags.includes('--help') || action === '--help') {
|
|
126
|
-
console.log('anhedral cloud register|stage|save|deploy|status [directory] [--artifact directory] [--version stage-id] [--audience private|public] [--json]');
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
let artifact;
|
|
130
|
-
let version;
|
|
131
|
-
let audience = 'private';
|
|
132
|
-
const directories = [];
|
|
133
|
-
for (let index = 0; index < flags.length; index++) {
|
|
134
|
-
const flag = flags[index];
|
|
135
|
-
if (flag === '--json')
|
|
136
|
-
continue;
|
|
137
|
-
if ((flag === '--artifact' && action === 'stage') ||
|
|
138
|
-
(flag === '--version' && ['save', 'deploy'].includes(action)) ||
|
|
139
|
-
(flag === '--audience' && action === 'register')) {
|
|
140
|
-
const value = flags[++index];
|
|
141
|
-
if (!value || value.startsWith('-'))
|
|
142
|
-
throw new Error('Missing cloud option value.');
|
|
143
|
-
if (flag === '--artifact') {
|
|
144
|
-
if (artifact)
|
|
145
|
-
throw new Error('Specify one artifact.');
|
|
146
|
-
artifact = value;
|
|
147
|
-
}
|
|
148
|
-
else if (flag === '--version') {
|
|
149
|
-
if (version)
|
|
150
|
-
throw new Error('Specify one version.');
|
|
151
|
-
version = value;
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
if (value !== 'private' && value !== 'public')
|
|
155
|
-
throw new Error('Audience must be private or public.');
|
|
156
|
-
audience = value;
|
|
157
|
-
}
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
if (flag.startsWith('-'))
|
|
161
|
-
throw new Error('Unknown cloud option.');
|
|
162
|
-
directories.push(flag);
|
|
163
|
-
}
|
|
164
|
-
if (directories.length > 1)
|
|
165
|
-
throw new Error('Specify one application directory.');
|
|
166
|
-
const root = path.resolve(directories[0] ?? process.cwd());
|
|
167
|
-
let result;
|
|
168
|
-
if (action === 'register')
|
|
169
|
-
result = registerManagedApplication(root, audience);
|
|
170
|
-
else if (action === 'stage') {
|
|
171
|
-
if (!artifact)
|
|
172
|
-
throw new Error('Stage requires --artifact <complete-build-directory>.');
|
|
173
|
-
result = await stageManagedVersion(root, path.resolve(artifact));
|
|
174
|
-
}
|
|
175
|
-
else if (action === 'save' || action === 'deploy') {
|
|
176
|
-
if (!version)
|
|
177
|
-
throw new Error('Save/deploy requires --version <stage-id>.');
|
|
178
|
-
result = await (action === 'save'
|
|
179
|
-
? saveManagedVersion(root, version)
|
|
180
|
-
: deployManagedVersion(root, version));
|
|
181
|
-
}
|
|
182
|
-
else if (action === 'status')
|
|
183
|
-
result = await managedApplicationStatus(root);
|
|
184
|
-
else
|
|
185
|
-
throw new Error('Unknown cloud action.');
|
|
186
|
-
console.log(JSON.stringify(result, null, 2));
|
|
234
|
+
await scaffoldStandardProject(options, undefined, output);
|
|
187
235
|
}
|
|
188
236
|
async function runDelivery(command, args) {
|
|
189
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
190
|
-
console.log(STANDARD_USAGE);
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
237
|
const positional = [];
|
|
194
238
|
let account;
|
|
195
239
|
let audience;
|
|
@@ -200,27 +244,47 @@ async function runDelivery(command, args) {
|
|
|
200
244
|
let use;
|
|
201
245
|
let create = false;
|
|
202
246
|
let git = false;
|
|
247
|
+
let platform;
|
|
248
|
+
let profile;
|
|
203
249
|
for (let index = 0; index < args.length; index++) {
|
|
204
250
|
const arg = args[index];
|
|
251
|
+
if (command === 'ship' && (arg === '--platform' || arg === '--profile')) {
|
|
252
|
+
const value = args[++index];
|
|
253
|
+
if (!value || value.startsWith('-'))
|
|
254
|
+
throw argumentError('Missing mobile build option.');
|
|
255
|
+
if (arg === '--platform') {
|
|
256
|
+
if (platform || !['ios', 'android'].includes(value))
|
|
257
|
+
throw argumentError('Select one mobile platform.');
|
|
258
|
+
platform = value;
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
if (profile)
|
|
262
|
+
throw argumentError('Select one build profile.');
|
|
263
|
+
profile = value;
|
|
264
|
+
}
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
if (command === 'recover' && arg === '--lock')
|
|
268
|
+
continue;
|
|
205
269
|
if (arg === '--provider') {
|
|
206
270
|
const value = args[++index];
|
|
207
271
|
if (!['vercel', 'cloudflare'].includes(value) || provider)
|
|
208
|
-
throw
|
|
272
|
+
throw argumentError('Specify one provider: vercel or cloudflare.');
|
|
209
273
|
provider = value;
|
|
210
274
|
continue;
|
|
211
275
|
}
|
|
212
276
|
if (command === 'connect' && arg === '--scope') {
|
|
213
277
|
if (scope)
|
|
214
|
-
throw
|
|
278
|
+
throw argumentError('Specify one Vercel scope.');
|
|
215
279
|
scope = args[++index];
|
|
216
280
|
if (!scope || scope.startsWith('-'))
|
|
217
|
-
throw
|
|
281
|
+
throw argumentError('Missing Vercel scope.');
|
|
218
282
|
continue;
|
|
219
283
|
}
|
|
220
284
|
if (command === 'connect' && arg === '--use') {
|
|
221
285
|
const value = args[++index];
|
|
222
286
|
if (!['personal', 'commercial'].includes(value) || use)
|
|
223
|
-
throw
|
|
287
|
+
throw argumentError('Specify --use personal or commercial.');
|
|
224
288
|
use = value;
|
|
225
289
|
continue;
|
|
226
290
|
}
|
|
@@ -235,7 +299,7 @@ async function runDelivery(command, args) {
|
|
|
235
299
|
if (command === 'rollback' && arg === '--release') {
|
|
236
300
|
releaseId = args[++index];
|
|
237
301
|
if (!releaseId || releaseId.startsWith('-'))
|
|
238
|
-
throw
|
|
302
|
+
throw argumentError('Missing release ID.');
|
|
239
303
|
continue;
|
|
240
304
|
}
|
|
241
305
|
if (command === 'rollback' && arg === '--data-compatible')
|
|
@@ -248,10 +312,10 @@ async function runDelivery(command, args) {
|
|
|
248
312
|
continue;
|
|
249
313
|
if (command === 'connect' && arg === '--account') {
|
|
250
314
|
if (account)
|
|
251
|
-
throw
|
|
315
|
+
throw argumentError('Specify one account.');
|
|
252
316
|
account = args[++index];
|
|
253
317
|
if (!account || account.startsWith('-'))
|
|
254
|
-
throw
|
|
318
|
+
throw argumentError('Missing account ID.');
|
|
255
319
|
continue;
|
|
256
320
|
}
|
|
257
321
|
if (command === 'connect' &&
|
|
@@ -264,39 +328,68 @@ async function runDelivery(command, args) {
|
|
|
264
328
|
if (command === 'connect' && arg === '--allow-email') {
|
|
265
329
|
const email = args[++index];
|
|
266
330
|
if (!email || email.startsWith('-'))
|
|
267
|
-
throw
|
|
331
|
+
throw argumentError('Missing allowed email address.');
|
|
268
332
|
emails.push(email);
|
|
269
333
|
continue;
|
|
270
334
|
}
|
|
271
335
|
if (arg.startsWith('-'))
|
|
272
|
-
throw
|
|
336
|
+
throw argumentError(`Unknown ${command} option: ${arg}`);
|
|
273
337
|
positional.push(arg);
|
|
274
338
|
}
|
|
275
339
|
if (positional.length > 1)
|
|
276
|
-
throw
|
|
340
|
+
throw argumentError('Specify at most one application directory.');
|
|
277
341
|
const root = path.resolve(positional[0] ?? process.cwd());
|
|
278
342
|
let result;
|
|
343
|
+
if (command === 'recover' && args.includes('--lock')) {
|
|
344
|
+
if (provider || args.includes('--refresh'))
|
|
345
|
+
throw argumentError('Local lock recovery cannot be combined with provider recovery or --refresh.');
|
|
346
|
+
printResult(command, recoverDeliveryLock(root), output);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
if (platform || profile) {
|
|
350
|
+
if (!platform || !profile || provider)
|
|
351
|
+
throw argumentError('Mobile shipping requires --platform and --profile, without --provider.');
|
|
352
|
+
result = await buildMobileApplication(root, {
|
|
353
|
+
platform,
|
|
354
|
+
profile,
|
|
355
|
+
dryRun: args.includes('--dry-run'),
|
|
356
|
+
});
|
|
357
|
+
printResult(command, result, output);
|
|
358
|
+
if (result &&
|
|
359
|
+
typeof result === 'object' &&
|
|
360
|
+
'state' in result &&
|
|
361
|
+
['configuration-required', 'provider-configuration-required'].includes(String(result.state)))
|
|
362
|
+
process.exitCode = 1;
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
279
365
|
const web = provider === 'vercel' ||
|
|
280
366
|
(provider !== 'cloudflare' &&
|
|
281
|
-
(
|
|
367
|
+
(hasProjectSection(root, 'vercel') ||
|
|
282
368
|
(command === 'register' &&
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
369
|
+
hasProjectSection(root, 'setup') &&
|
|
370
|
+
readProjectSection(root, 'setup').hosting === 'vercel')));
|
|
371
|
+
if (command === 'ship' && !provider) {
|
|
372
|
+
result = await shipSelectedStack(root, args.includes('--dry-run'));
|
|
373
|
+
printResult(command, result, output);
|
|
374
|
+
if (result &&
|
|
375
|
+
typeof result === 'object' &&
|
|
376
|
+
'state' in result &&
|
|
377
|
+
['configuration-required', 'provider-configuration-required', 'partial'].includes(String(result.state)))
|
|
378
|
+
process.exitCode = 1;
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
286
381
|
if (web) {
|
|
287
382
|
if (account || emails.length)
|
|
288
|
-
throw
|
|
383
|
+
throw argumentError('Cloudflare account/member flags require --provider cloudflare.');
|
|
289
384
|
if (command === 'register')
|
|
290
385
|
result = registerVercelApplication(root);
|
|
291
386
|
else if (command === 'connect') {
|
|
292
387
|
if (!audience || !use)
|
|
293
|
-
throw
|
|
388
|
+
throw argumentError('Vercel connect requires --audience public|private and --use personal|commercial.');
|
|
294
389
|
result = await connectVercelApplication(root, { scope, audience, use, create, git });
|
|
295
390
|
}
|
|
296
391
|
else if (command === 'ship')
|
|
297
|
-
result = args.includes('--dry-run')
|
|
298
|
-
? planVercelDelivery(root)
|
|
299
|
-
: await shipVercelApplication(root);
|
|
392
|
+
result = await shipSelectedVercelApplication(root, args.includes('--dry-run'));
|
|
300
393
|
else if (command === 'adopt')
|
|
301
394
|
result = await adoptVercelApplication(root);
|
|
302
395
|
else if (command === 'recover')
|
|
@@ -305,7 +398,7 @@ async function runDelivery(command, args) {
|
|
|
305
398
|
result = await verifyVercelApplication(root);
|
|
306
399
|
else if (command === 'rollback') {
|
|
307
400
|
if (!releaseId)
|
|
308
|
-
throw
|
|
401
|
+
throw argumentError('Rollback requires --release <recorded-id>.');
|
|
309
402
|
result = await rollbackVercelApplication(root, releaseId, args.includes('--data-compatible'));
|
|
310
403
|
}
|
|
311
404
|
else if (command === 'status')
|
|
@@ -315,12 +408,19 @@ async function runDelivery(command, args) {
|
|
|
315
408
|
result = { file: writeVercelOverview(root, snapshot), evidence: snapshot.evidence };
|
|
316
409
|
}
|
|
317
410
|
else
|
|
318
|
-
throw
|
|
319
|
-
|
|
411
|
+
throw argumentError('Vercel project creation is handled by connect --create; Cloudflare resource provisioning requires --provider cloudflare.');
|
|
412
|
+
if (command === 'status')
|
|
413
|
+
result = { ...result, operation: readLifecycleOperation(root) };
|
|
414
|
+
printResult(command, result, output);
|
|
415
|
+
if (result &&
|
|
416
|
+
typeof result === 'object' &&
|
|
417
|
+
'state' in result &&
|
|
418
|
+
result.state === 'provider-configuration-required')
|
|
419
|
+
process.exitCode = 1;
|
|
320
420
|
return;
|
|
321
421
|
}
|
|
322
422
|
if (scope || use || create || git)
|
|
323
|
-
throw
|
|
423
|
+
throw argumentError('Vercel connect options require a Vercel web manifest or --provider vercel.');
|
|
324
424
|
if (command === 'register')
|
|
325
425
|
result = registerApplication(root);
|
|
326
426
|
else if (command === 'connect') {
|
|
@@ -329,16 +429,16 @@ async function runDelivery(command, args) {
|
|
|
329
429
|
else if (command === 'provision')
|
|
330
430
|
result = args.includes('--dry-run') ? planProvisioning(root) : await provisionApplication(root);
|
|
331
431
|
else if (command === 'ship')
|
|
332
|
-
result = args.includes('--dry-run')
|
|
432
|
+
result = await shipCloudflareApplication(root, args.includes('--dry-run'));
|
|
333
433
|
else if (command === 'adopt')
|
|
334
|
-
throw
|
|
434
|
+
throw argumentError('Git deployment adoption requires --provider vercel.');
|
|
335
435
|
else if (command === 'recover')
|
|
336
436
|
result = await recoverApplication(root);
|
|
337
437
|
else if (command === 'verify')
|
|
338
438
|
result = await verifyApplication(root);
|
|
339
439
|
else if (command === 'rollback') {
|
|
340
440
|
if (!releaseId)
|
|
341
|
-
throw
|
|
441
|
+
throw argumentError('Rollback requires --release <recorded-id>.');
|
|
342
442
|
result = await rollbackApplication(root, releaseId, args.includes('--data-compatible'));
|
|
343
443
|
}
|
|
344
444
|
else if (command === 'manage') {
|
|
@@ -347,29 +447,42 @@ async function runDelivery(command, args) {
|
|
|
347
447
|
}
|
|
348
448
|
else
|
|
349
449
|
result = await applicationStatus(root, args.includes('--refresh'));
|
|
350
|
-
|
|
450
|
+
if (command === 'status')
|
|
451
|
+
result = { ...result, operation: readLifecycleOperation(root) };
|
|
452
|
+
printResult(command, result, output);
|
|
453
|
+
if (result &&
|
|
454
|
+
typeof result === 'object' &&
|
|
455
|
+
'state' in result &&
|
|
456
|
+
['configuration-required', 'provider-configuration-required'].includes(String(result.state)))
|
|
457
|
+
process.exitCode = 1;
|
|
351
458
|
}
|
|
352
459
|
async function runDoctor(args) {
|
|
353
460
|
const positional = args.filter((arg) => arg !== '--json' && arg !== '--providers');
|
|
354
461
|
if (positional.length > 1 || positional.some((arg) => arg.startsWith('-')))
|
|
355
|
-
throw
|
|
462
|
+
throw argumentError('Usage: anhedral doctor [directory] [--providers] [--json]');
|
|
356
463
|
const root = path.resolve(positional[0] ?? process.cwd());
|
|
357
464
|
const report = args.includes('--providers')
|
|
358
465
|
? await inspectProviderReadiness(root)
|
|
359
466
|
: inspectProject(root);
|
|
360
|
-
|
|
467
|
+
printResult('doctor', report, output);
|
|
361
468
|
if (!report.localReady ||
|
|
362
469
|
('prerequisitesReady' in report &&
|
|
363
470
|
(!report.prerequisitesReady || report.providerVerification !== 'verified-existing-context')))
|
|
364
471
|
process.exitCode = 1;
|
|
365
472
|
}
|
|
366
|
-
function readOptions(
|
|
473
|
+
function readOptions(args) {
|
|
367
474
|
try {
|
|
368
|
-
return parseStandardOptions(
|
|
475
|
+
return parseStandardOptions(args);
|
|
369
476
|
}
|
|
370
477
|
catch (error) {
|
|
371
478
|
const message = error instanceof Error ? error.message : String(error);
|
|
372
|
-
console.error(json
|
|
479
|
+
console.error(json
|
|
480
|
+
? JSON.stringify({
|
|
481
|
+
error: message,
|
|
482
|
+
code: 'INVALID_ARGUMENT',
|
|
483
|
+
nextAction: `Run anhedral ${command} --help.`,
|
|
484
|
+
})
|
|
485
|
+
: `Error: ${message}\nNext: Run anhedral ${command} --help.`);
|
|
373
486
|
process.exitCode = 1;
|
|
374
487
|
return;
|
|
375
488
|
}
|
|
@@ -379,33 +492,41 @@ try {
|
|
|
379
492
|
}
|
|
380
493
|
catch (error) {
|
|
381
494
|
const message = error instanceof Error ? error.message : String(error);
|
|
382
|
-
const code = error instanceof
|
|
383
|
-
?
|
|
384
|
-
:
|
|
385
|
-
'
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
495
|
+
const code = error instanceof CliArgumentError
|
|
496
|
+
? error.code
|
|
497
|
+
: error instanceof PostCommitError
|
|
498
|
+
? 'POST_COMMIT_FAILED'
|
|
499
|
+
: [
|
|
500
|
+
'repository',
|
|
501
|
+
'register',
|
|
502
|
+
'connect',
|
|
503
|
+
'provision',
|
|
504
|
+
'ship',
|
|
505
|
+
'status',
|
|
506
|
+
'manage',
|
|
507
|
+
'verify',
|
|
508
|
+
'rollback',
|
|
509
|
+
'adopt',
|
|
510
|
+
'recover',
|
|
511
|
+
'integrations',
|
|
512
|
+
].includes(command ?? '')
|
|
513
|
+
? 'DELIVERY_FAILED'
|
|
514
|
+
: command === 'auth'
|
|
515
|
+
? 'AUTH_FAILED'
|
|
516
|
+
: command === 'doctor'
|
|
517
|
+
? 'INVALID_ARGUMENT'
|
|
518
|
+
: command === 'init'
|
|
519
|
+
? 'GENERATION_FAILED'
|
|
520
|
+
: command === 'add'
|
|
521
|
+
? 'ADDITION_FAILED'
|
|
522
|
+
: command === 'registry'
|
|
523
|
+
? 'REGISTRY_FAILED'
|
|
524
|
+
: 'UNKNOWN_COMMAND';
|
|
525
|
+
const nextAction = error instanceof CliArgumentError
|
|
526
|
+
? error.nextAction
|
|
527
|
+
: `Run anhedral ${command && commandHelp(command) ? command + ' ' : ''}--help.`;
|
|
528
|
+
console.error(json
|
|
529
|
+
? JSON.stringify({ error: message, code, nextAction })
|
|
530
|
+
: `Error: ${message}\nNext: ${nextAction}`);
|
|
410
531
|
process.exitCode = 1;
|
|
411
532
|
}
|