anhedral 0.17.0 → 0.19.0
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 +33 -68
- package/assets/contracts/LICENSE +201 -0
- package/assets/contracts/LICENSE.environment +201 -0
- package/assets/contracts/LICENSE.operations +201 -0
- package/assets/contracts/deployment-provenance.json +15 -0
- package/assets/contracts/environment-provenance.json +11 -0
- package/assets/contracts/operations-provenance.json +12 -0
- package/assets/launch/application.server.ts.txt +13 -0
- package/assets/launch/auth-client.ts.txt +4 -0
- package/assets/launch/home.tsx.txt +20 -0
- package/assets/launch/minimal-application.server.ts.txt +5 -0
- package/assets/launch/minimal-server.ts.txt +7 -0
- package/assets/launch/oj/OJ.LICENSE +21 -0
- package/assets/launch/oj/run.mjs +82 -0
- package/assets/launch/oj/runtime.json +21 -0
- package/assets/launch/request-context.ts.txt +3 -0
- package/assets/launch/root.tsx.txt +26 -0
- package/assets/launch/router.tsx.txt +21 -0
- package/assets/launch/server.ts.txt +15 -0
- package/assets/launch/sign-in.tsx.txt +53 -0
- package/assets/launch/styles.css.txt +19 -0
- package/assets/security/credential-patterns.d.mts +3 -0
- package/assets/security/credential-patterns.mjs +59 -0
- package/assets/stack/api-index.ts.txt +6 -1
- package/assets/stack/stripe.ts.txt +30 -13
- package/assets/ui/catalog.json +36 -324
- package/dist/{platforms/web.d.ts → api-proxy.d.ts} +1 -3
- package/dist/api-proxy.js +48 -0
- package/dist/bin.js +55 -36
- package/dist/capability-catalog.d.ts +36 -57
- package/dist/capability-catalog.js +65 -67
- package/dist/capability-command.d.ts +3 -3
- package/dist/capability-command.js +146 -59
- package/dist/capability-editor.js +6 -5
- package/dist/capability-recipes.js +9 -296
- package/dist/cli-arguments.d.ts +2 -0
- package/dist/cli-arguments.js +101 -50
- package/dist/cli-commands.d.ts +1 -1
- package/dist/cli-commands.js +31 -5
- package/dist/cli-errors.d.ts +18 -0
- package/dist/cli-errors.js +63 -0
- package/dist/cli-output.d.ts +22 -0
- package/dist/cli-output.js +42 -7
- package/dist/command-runner.js +88 -0
- package/dist/command-schema.d.ts +16 -0
- package/dist/command-schema.js +496 -21
- package/dist/command-types.d.ts +1 -0
- package/dist/command-types.js +1 -0
- package/dist/completion.d.ts +2 -0
- package/dist/completion.js +201 -0
- package/dist/composition.d.ts +25 -0
- package/dist/composition.js +28 -0
- package/dist/contracts/cli-transport.d.ts +316 -0
- package/dist/contracts/cli-transport.js +236 -0
- package/dist/contracts/deployment.d.ts +233 -0
- package/dist/contracts/deployment.js +198 -0
- package/dist/contracts/environment-file.d.ts +7 -0
- package/dist/contracts/environment-file.js +112 -0
- package/dist/contracts/environment-transport.d.ts +79 -0
- package/dist/contracts/environment-transport.js +110 -0
- package/dist/contracts/production-transport.d.ts +71 -0
- package/dist/contracts/production-transport.js +56 -0
- package/dist/contracts/runtime-logs-transport.d.ts +127 -0
- package/dist/contracts/runtime-logs-transport.js +50 -0
- package/dist/contracts/source-bundle.d.ts +11 -0
- package/dist/contracts/source-bundle.js +197 -0
- package/dist/contracts/source-profile.d.ts +4 -0
- package/dist/contracts/source-profile.js +5 -0
- package/dist/contracts/staging-transport.d.ts +79 -0
- package/dist/contracts/staging-transport.js +43 -0
- package/dist/dependencies.d.ts +9 -27
- package/dist/dependencies.js +19 -66
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/launch.d.ts +27 -0
- package/dist/launch.js +262 -0
- package/dist/platform-command.d.ts +9 -0
- package/dist/platform-command.js +787 -0
- package/dist/platform-environment.d.ts +18 -0
- package/dist/platform-environment.js +257 -0
- package/dist/platform-operations.d.ts +26 -0
- package/dist/platform-operations.js +155 -0
- package/dist/platform-production.d.ts +16 -0
- package/dist/platform-production.js +135 -0
- package/dist/platform-source.d.ts +8 -0
- package/dist/platform-source.js +111 -0
- package/dist/platform-state.d.ts +15 -0
- package/dist/platform-state.js +229 -0
- package/dist/platforms/tanstack.d.ts +10 -0
- package/dist/platforms/tanstack.js +248 -0
- package/dist/registry/usage.d.ts +4 -1
- package/dist/registry/usage.js +59 -4
- package/dist/scaffold/bootstrap.d.ts +3 -3
- package/dist/scaffold/styling.d.ts +3 -2
- package/dist/transaction.js +28 -3
- package/dist/ui-catalog.d.ts +3 -5
- package/dist/ui-catalog.js +8 -24
- package/dist/ui-command.d.ts +3 -1
- package/dist/ui-command.js +74 -72
- package/dist/ui-project.d.ts +4 -2
- package/dist/ui-project.js +40 -38
- package/dist/util.js +40 -61
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/capabilities.md +23 -89
- package/docs/software-factory.md +208 -9
- package/docs/stack-standard.md +7 -17
- package/docs/ui.md +9 -22
- package/package.json +26 -22
- package/assets/stack/ai-schema.ts.txt +0 -5
- package/assets/stack/ai.ts.txt +0 -30
- package/assets/stack/desktop.rs.txt +0 -21
- package/assets/stack/events-schema.ts.txt +0 -12
- package/assets/stack/events.ts.txt +0 -59
- package/assets/stack/mobile-auth.ts.txt +0 -25
- package/assets/stack/mobile-billing.tsx.txt +0 -63
- package/assets/stack/mobile-session.tsx.txt +0 -83
- package/assets/stack/native-button.tsx.txt +0 -108
- package/assets/stack/native-global.css.txt +0 -4
- package/assets/stack/native-lib-utils.ts.txt +0 -5
- package/assets/stack/native-metro.config.js.txt +0 -6
- package/assets/stack/native-nativewind-env.d.ts.txt +0 -1
- package/assets/stack/native-tailwind.config.js.txt +0 -73
- package/assets/stack/native-text.tsx.txt +0 -89
- package/assets/stack/purchases.ts.txt +0 -65
- package/assets/stack/revenuecat.ts.txt +0 -88
- package/assets/stack/rtc-schema.ts.txt +0 -10
- package/assets/stack/rtc.ts.txt +0 -122
- package/assets/stack/web-sign-in.tsx.txt +0 -51
- package/dist/capabilities.d.ts +0 -11
- package/dist/capabilities.js +0 -14
- package/dist/dependency-order.d.ts +0 -2
- package/dist/dependency-order.js +0 -24
- package/dist/platforms/lint.d.ts +0 -1
- package/dist/platforms/lint.js +0 -5
- package/dist/platforms/web.js +0 -251
- package/dist/project-config.d.ts +0 -3
- package/dist/project-config.js +0 -16
- package/dist/registry/context.d.ts +0 -3
- package/dist/registry/context.js +0 -20
- package/dist/registry/options.d.ts +0 -2
- package/dist/registry/options.js +0 -44
- package/dist/registry/resolve.d.ts +0 -11
- package/dist/registry/resolve.js +0 -46
- package/dist/registry/types.d.ts +0 -60
- package/dist/scaffold/api.d.ts +0 -2
- package/dist/scaffold/api.js +0 -38
- package/dist/scaffold/backend.d.ts +0 -2
- package/dist/scaffold/backend.js +0 -36
- package/dist/scaffold/compose.d.ts +0 -4
- package/dist/scaffold/compose.js +0 -30
- package/dist/scaffold/database.d.ts +0 -2
- package/dist/scaffold/database.js +0 -41
- package/dist/scaffold/documentation.d.ts +0 -2
- package/dist/scaffold/documentation.js +0 -71
- package/dist/scaffold/environment.d.ts +0 -4
- package/dist/scaffold/environment.js +0 -22
- package/dist/scaffold/stack-documentation.d.ts +0 -2
- package/dist/scaffold/stack-documentation.js +0 -6
- package/dist/scaffold/storage.d.ts +0 -2
- package/dist/scaffold/storage.js +0 -21
- package/dist/scaffold/workspace.d.ts +0 -3
- package/dist/scaffold/workspace.js +0 -131
- package/dist/stack-registry.d.ts +0 -35
- package/dist/stack-registry.js +0 -189
- package/dist/standard.d.ts +0 -8
- package/dist/standard.js +0 -94
- package/dist/workspace-graph.d.ts +0 -7
- package/dist/workspace-graph.js +0 -74
- package/docs/anhedral-stack.md +0 -12
- package/docs/assets/anhedral-stack-light.png +0 -0
- package/docs/assets/anhedral-stack.png +0 -0
- package/docs/native-ui.md +0 -47
- /package/dist/{registry/types.js → command-runner.d.ts} +0 -0
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { existsSync, realpathSync, statSync, chmodSync } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { commandArguments, commandArgumentError } from './cli-arguments.js';
|
|
4
|
-
import {
|
|
4
|
+
import { createReporter } from './cli-output.js';
|
|
5
|
+
import { ANHEDRAL_STACK, PUBLIC_STACK_ADDITIONS, CAPABILITIES, CAPABILITY_IDS, capabilityOrder, } from './capability-catalog.js';
|
|
5
6
|
import { CapabilityEditor } from './capability-editor.js';
|
|
6
7
|
import { addCapabilityRecipe, composeCapabilities } from './capability-recipes.js';
|
|
7
|
-
import {
|
|
8
|
+
import { normalizeOjFoundation } from './platforms/tanstack.js';
|
|
9
|
+
import { GENERATOR_VERSION } from './version.js';
|
|
10
|
+
import { PostCommitError, runStagedTransaction, recoverInterruptedTransaction, } from './transaction.js';
|
|
8
11
|
import { put } from './scaffold/files.js';
|
|
9
12
|
import { execFile } from './util.js';
|
|
10
13
|
import { capabilityReferences } from './capability-references.js';
|
|
11
14
|
import { configureDependencyPatches } from './dependency-patches.js';
|
|
12
|
-
|
|
15
|
+
import { composeSourceProvenance } from './composition.js';
|
|
16
|
+
function projectRoot(cwd, allowRecovery = false) {
|
|
13
17
|
let root = realpathSync(cwd);
|
|
14
18
|
for (;;) {
|
|
15
|
-
if (existsSync(path.join(root, 'anhedral.json'))
|
|
19
|
+
if (existsSync(path.join(root, 'anhedral.json')) ||
|
|
20
|
+
(allowRecovery && existsSync(path.join(root, '.anhedral-journal.json'))))
|
|
16
21
|
return root;
|
|
17
22
|
if (existsSync(path.join(root, '.git')))
|
|
18
23
|
break;
|
|
@@ -40,77 +45,147 @@ function readState(e) {
|
|
|
40
45
|
throw Error(`Invalid capability state: ${id} requires ${parent}.`);
|
|
41
46
|
return { installed, managedFiles: state.managedFiles };
|
|
42
47
|
}
|
|
48
|
+
const publicGroups = {
|
|
49
|
+
backend: ['hono', 'database-auth'],
|
|
50
|
+
r2: ['r2'],
|
|
51
|
+
stripe: ['stripe'],
|
|
52
|
+
};
|
|
53
|
+
function publicScopeError(command = 'add') {
|
|
54
|
+
return commandArgumentError(command, 'The CLI edits only the Anhedral Stack: TanStack Start with OJ and shadcn.');
|
|
55
|
+
}
|
|
56
|
+
/** Identify the source before any recovery or source mutation. One missing manifest can be an interrupted add. */
|
|
57
|
+
function assertPublicWorkspace(root, allowRecovery = false, command = 'add') {
|
|
58
|
+
const editor = new CapabilityEditor(root, {});
|
|
59
|
+
const recovering = allowRecovery && existsSync(path.join(root, '.anhedral-journal.json'));
|
|
60
|
+
const hasWeb = existsSync(path.join(root, 'apps/web/package.json'));
|
|
61
|
+
const hasConfiguration = existsSync(path.join(root, 'anhedral.json'));
|
|
62
|
+
if (!hasWeb && !hasConfiguration)
|
|
63
|
+
throw publicScopeError(command);
|
|
64
|
+
if (hasWeb) {
|
|
65
|
+
const dependencies = editor.json('apps/web/package.json').dependencies;
|
|
66
|
+
if (!dependencies?.['@tanstack/react-start'] || dependencies.next)
|
|
67
|
+
throw publicScopeError(command);
|
|
68
|
+
}
|
|
69
|
+
else if (!recovering)
|
|
70
|
+
throw publicScopeError(command);
|
|
71
|
+
if (hasConfiguration) {
|
|
72
|
+
const configuration = editor.json('anhedral.json');
|
|
73
|
+
const composition = configuration.composition;
|
|
74
|
+
if (Array.isArray(configuration.capabilities?.installed) &&
|
|
75
|
+
configuration.capabilities.installed.some((id) => !['hono', 'database-auth', 'r2', 'stripe'].includes(id)))
|
|
76
|
+
throw publicScopeError(command);
|
|
77
|
+
if (configuration.setup?.stack !== 'anhedral-stack' ||
|
|
78
|
+
composition?.contractVersion !== 2 ||
|
|
79
|
+
composition?.foundation !== 'tanstack-start')
|
|
80
|
+
throw publicScopeError(command);
|
|
81
|
+
}
|
|
82
|
+
else if (!recovering)
|
|
83
|
+
throw publicScopeError(command);
|
|
84
|
+
}
|
|
85
|
+
function publicStackState(root, state) {
|
|
86
|
+
if (state.installed.some((id) => !['hono', 'database-auth', 'r2', 'stripe'].includes(id)))
|
|
87
|
+
throw publicScopeError('stack');
|
|
88
|
+
const additions = PUBLIC_STACK_ADDITIONS.map((id) => {
|
|
89
|
+
const item = ANHEDRAL_STACK.additions[id];
|
|
90
|
+
const group = publicGroups[id];
|
|
91
|
+
const present = group.filter((capability) => state.installed.includes(capability));
|
|
92
|
+
const installed = present.length === group.length;
|
|
93
|
+
const missingFiles = present.length
|
|
94
|
+
? item.targets.filter((file) => !existsSync(path.join(root, file)))
|
|
95
|
+
: [];
|
|
96
|
+
const missingPrerequisites = item.requires.filter((required) => !publicGroups[required].every((capability) => state.installed.includes(capability)));
|
|
97
|
+
return {
|
|
98
|
+
id,
|
|
99
|
+
name: item.name,
|
|
100
|
+
sourceState: present.length
|
|
101
|
+
? installed && !missingFiles.length && !missingPrerequisites.length
|
|
102
|
+
? 'installed'
|
|
103
|
+
: 'incomplete'
|
|
104
|
+
: missingPrerequisites.length
|
|
105
|
+
? 'locked'
|
|
106
|
+
: 'available',
|
|
107
|
+
missingPrerequisites,
|
|
108
|
+
missingFiles,
|
|
109
|
+
activation: 'not verified',
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
const missingFiles = ANHEDRAL_STACK.foundation.targets.filter((file) => !existsSync(path.join(root, file)));
|
|
113
|
+
const foundationReady = !missingFiles.length;
|
|
114
|
+
return {
|
|
115
|
+
root,
|
|
116
|
+
stack: {
|
|
117
|
+
id: ANHEDRAL_STACK.id,
|
|
118
|
+
name: ANHEDRAL_STACK.name,
|
|
119
|
+
foundation: { ...ANHEDRAL_STACK.foundation, missingFiles },
|
|
120
|
+
},
|
|
121
|
+
foundationReady,
|
|
122
|
+
sourceReady: foundationReady && additions.every((item) => item.sourceState !== 'incomplete'),
|
|
123
|
+
additions,
|
|
124
|
+
runtimeAcceptance: 'not evaluated',
|
|
125
|
+
resourcesProvisionedByCli: false,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
43
128
|
export async function runCapabilityCommand(command, args, output, run = execFile) {
|
|
44
129
|
const parsed = commandArguments(command, args);
|
|
130
|
+
if (command === 'add') {
|
|
131
|
+
const unsupported = parsed.positional.filter((id) => !PUBLIC_STACK_ADDITIONS.includes(id));
|
|
132
|
+
if (unsupported.length)
|
|
133
|
+
throw commandArgumentError('add', 'Choose backend, r2 or stripe for the Anhedral Stack.');
|
|
134
|
+
}
|
|
45
135
|
let result;
|
|
46
136
|
if (command === 'stack') {
|
|
47
137
|
const [action, ...extra] = parsed.positional;
|
|
48
138
|
if (extra.length || !['list', 'status', 'doctor'].includes(action))
|
|
49
139
|
throw commandArgumentError('stack', 'Use stack list, status or doctor.');
|
|
50
140
|
if (action === 'list')
|
|
51
|
-
result = {
|
|
52
|
-
capabilities: CAPABILITY_IDS.map((id) => ({ id, ...CAPABILITIES[id] })),
|
|
53
|
-
provisioning: 'Separate from source installation',
|
|
54
|
-
};
|
|
141
|
+
result = { stack: ANHEDRAL_STACK, resourcesProvisionedByCli: false };
|
|
55
142
|
else {
|
|
56
143
|
const root = projectRoot(process.cwd());
|
|
144
|
+
assertPublicWorkspace(root, false, 'stack');
|
|
57
145
|
const e = new CapabilityEditor(root, {});
|
|
58
146
|
const state = readState(e);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const installed = state.installed.includes(id);
|
|
62
|
-
const missingFiles = installed
|
|
63
|
-
? CAPABILITIES[id].targets.filter((target) => !existsSync(path.join(root, target)))
|
|
64
|
-
: [];
|
|
65
|
-
return {
|
|
66
|
-
id,
|
|
67
|
-
name: CAPABILITIES[id].name,
|
|
68
|
-
sourceState: installed
|
|
69
|
-
? missingFiles.length
|
|
70
|
-
? 'incomplete'
|
|
71
|
-
: 'installed'
|
|
72
|
-
: missing.length
|
|
73
|
-
? 'locked'
|
|
74
|
-
: 'available',
|
|
75
|
-
missingPrerequisites: missing,
|
|
76
|
-
missingFiles,
|
|
77
|
-
configuration: installed ? CAPABILITIES[id].configuration : [],
|
|
78
|
-
activation: 'not verified',
|
|
79
|
-
};
|
|
80
|
-
});
|
|
81
|
-
const foundationReady = existsSync(path.join(root, 'apps/web/package.json')) &&
|
|
82
|
-
!!e.json('apps/web/package.json').dependencies?.next;
|
|
83
|
-
const sourceReady = foundationReady && capabilities.every((c) => c.sourceState !== 'incomplete');
|
|
84
|
-
result = {
|
|
85
|
-
root,
|
|
86
|
-
foundationReady,
|
|
87
|
-
sourceReady,
|
|
88
|
-
capabilities,
|
|
89
|
-
runtimeAcceptance: 'not evaluated',
|
|
90
|
-
resourcesProvisionedByCli: false,
|
|
91
|
-
};
|
|
92
|
-
if (action === 'doctor' && !sourceReady)
|
|
147
|
+
result = publicStackState(root, state);
|
|
148
|
+
if (action === 'doctor' && !result.sourceReady)
|
|
93
149
|
process.exitCode = 1;
|
|
94
150
|
}
|
|
95
151
|
}
|
|
96
152
|
else {
|
|
97
153
|
if (!parsed.positional.length || parsed.positional.length > CAPABILITY_IDS.length)
|
|
98
154
|
throw commandArgumentError('add', 'Choose one or more capabilities from anhedral stack list.');
|
|
99
|
-
const root = projectRoot(process.cwd());
|
|
155
|
+
const root = projectRoot(process.cwd(), !parsed.has('--dry-run'));
|
|
156
|
+
assertPublicWorkspace(root, !parsed.has('--dry-run'));
|
|
157
|
+
if (!parsed.has('--dry-run') && existsSync(path.join(root, '.anhedral-journal.json')))
|
|
158
|
+
recoverInterruptedTransaction(root);
|
|
100
159
|
const e = new CapabilityEditor(root, {});
|
|
101
160
|
const state = readState(e);
|
|
161
|
+
{
|
|
162
|
+
assertPublicWorkspace(root);
|
|
163
|
+
if (state.installed.some((id) => !['hono', 'database-auth', 'r2', 'stripe'].includes(id)))
|
|
164
|
+
throw publicScopeError();
|
|
165
|
+
}
|
|
102
166
|
Object.assign(e.managed, state.managedFiles);
|
|
103
167
|
const manifest = e.json('package.json');
|
|
104
168
|
if (typeof manifest.name !== 'string' || !manifest.name)
|
|
105
169
|
throw Error('The workspace needs a package name.');
|
|
106
|
-
if (!e.json('apps/web/package.json').dependencies?.next)
|
|
107
|
-
throw Error('A Next.js foundation is required.');
|
|
108
170
|
for (const id of state.installed)
|
|
109
171
|
for (const target of CAPABILITIES[id].targets)
|
|
110
172
|
if (!existsSync(path.join(root, target)))
|
|
111
173
|
throw Error(`Installed capability is incomplete: ${id} (${target}). Reconcile its source first.`);
|
|
112
|
-
|
|
174
|
+
if (!parsed.has('--with-dependencies') &&
|
|
175
|
+
!parsed.positional.includes('backend') &&
|
|
176
|
+
!(state.installed.includes('hono') && state.installed.includes('database-auth')) &&
|
|
177
|
+
parsed.positional.some((id) => id === 'r2' || id === 'stripe'))
|
|
178
|
+
throw commandArgumentError('add', 'Private storage and payments require backend. Run anhedral add backend first, or explicitly use --with-dependencies.');
|
|
179
|
+
const requested = [
|
|
180
|
+
...new Set(parsed.positional.flatMap((id) => (id === 'backend' ? ['hono', 'database-auth'] : [id]))),
|
|
181
|
+
];
|
|
182
|
+
const additions = capabilityOrder(requested, state.installed, parsed.has('--with-dependencies'));
|
|
113
183
|
const installed = [...state.installed, ...additions];
|
|
184
|
+
const beforeConfiguration = e.json('anhedral.json');
|
|
185
|
+
const metadataChanged = beforeConfiguration.setup?.cliVersion !== GENERATOR_VERSION ||
|
|
186
|
+
beforeConfiguration.composition?.generatorVersion !== GENERATOR_VERSION;
|
|
187
|
+
const foundationChanged = normalizeOjFoundation(e, state.installed, metadataChanged);
|
|
188
|
+
const composition = composeSourceProvenance(e.json('anhedral.json').composition, installed, additions);
|
|
114
189
|
for (const id of additions)
|
|
115
190
|
addCapabilityRecipe(e, id, manifest.name);
|
|
116
191
|
if (additions.length) {
|
|
@@ -118,6 +193,10 @@ export async function runCapabilityCommand(command, args, output, run = execFile
|
|
|
118
193
|
if (e.read(file) === null)
|
|
119
194
|
e.create(file, source);
|
|
120
195
|
composeCapabilities(e, installed);
|
|
196
|
+
}
|
|
197
|
+
if (additions.length || foundationChanged || metadataChanged) {
|
|
198
|
+
e.set('anhedral.json', ['setup', 'cliVersion'], GENERATOR_VERSION);
|
|
199
|
+
e.set('anhedral.json', ['composition'], composition);
|
|
121
200
|
e.set('anhedral.json', ['capabilities'], {
|
|
122
201
|
schemaVersion: 1,
|
|
123
202
|
installed,
|
|
@@ -128,11 +207,18 @@ export async function runCapabilityCommand(command, args, output, run = execFile
|
|
|
128
207
|
const files = [...e.writes.keys()];
|
|
129
208
|
const plan = {
|
|
130
209
|
root,
|
|
131
|
-
added: additions,
|
|
132
|
-
alreadyInstalled: parsed.positional.filter((id) =>
|
|
133
|
-
|
|
210
|
+
added: PUBLIC_STACK_ADDITIONS.filter((id) => publicGroups[id].some((capability) => additions.includes(capability))),
|
|
211
|
+
alreadyInstalled: parsed.positional.filter((id) => id === 'backend'
|
|
212
|
+
? state.installed.includes('hono') && state.installed.includes('database-auth')
|
|
213
|
+
: state.installed.includes(id)),
|
|
214
|
+
installed: PUBLIC_STACK_ADDITIONS.filter((id) => publicGroups[id].every((capability) => installed.includes(capability))),
|
|
134
215
|
files,
|
|
135
|
-
configuration:
|
|
216
|
+
configuration: PUBLIC_STACK_ADDITIONS.filter((id) => publicGroups[id].some((capability) => additions.includes(capability))).map((id) => ({
|
|
217
|
+
id,
|
|
218
|
+
requirements: [
|
|
219
|
+
...new Set(publicGroups[id].flatMap((capability) => [...CAPABILITIES[capability].configuration])),
|
|
220
|
+
],
|
|
221
|
+
})),
|
|
136
222
|
dryRun: parsed.has('--dry-run'),
|
|
137
223
|
resourcesProvisionedByCli: false,
|
|
138
224
|
activation: 'not verified',
|
|
@@ -175,14 +261,15 @@ export async function runCapabilityCommand(command, args, output, run = execFile
|
|
|
175
261
|
dependenciesInstalled: !parsed.has('--dry-run') && !parsed.has('--skip-install'),
|
|
176
262
|
};
|
|
177
263
|
}
|
|
178
|
-
|
|
179
|
-
console.log(JSON.stringify(result, null, 2));
|
|
180
|
-
else if (!output.quiet) {
|
|
264
|
+
const format = () => {
|
|
181
265
|
if (command === 'add')
|
|
182
|
-
|
|
183
|
-
else
|
|
184
|
-
|
|
185
|
-
.map((
|
|
186
|
-
.
|
|
187
|
-
|
|
266
|
+
return `${parsed.has('--dry-run') ? 'Plan' : 'Source additions'}: ${result.added.join(', ') || 'already installed'}\n${result.files.map((file) => ' ' + file).join('\n')}\nReview capability configuration and migrations before deployment. No resources were provisioned.`;
|
|
267
|
+
else {
|
|
268
|
+
const rows = parsed.positional[0] === 'list'
|
|
269
|
+
? PUBLIC_STACK_ADDITIONS.map((id) => `${id}\t${ANHEDRAL_STACK.additions[id].name}`)
|
|
270
|
+
: result.additions.map((item) => `${item.id}\t${item.sourceState}`);
|
|
271
|
+
return `${ANHEDRAL_STACK.name}\n${ANHEDRAL_STACK.foundation.name}\n${rows.join('\n')}\nSource state is not live provider activation.`;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
createReporter(output, format).result(result);
|
|
188
275
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { readBoundedFile, MAX_PROJECT_JSON_BYTES } from './bounded-file.js';
|
|
1
2
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import { existsSync, lstatSync
|
|
3
|
+
import { existsSync, lstatSync } from 'node:fs';
|
|
3
4
|
import path from 'node:path';
|
|
4
5
|
import { parse, modify, applyEdits } from 'jsonc-parser';
|
|
5
6
|
export const fingerprint = (source) => createHash('sha256').update(source).digest('hex');
|
|
@@ -38,9 +39,7 @@ export class CapabilityEditor {
|
|
|
38
39
|
if (this.writes.has(relative))
|
|
39
40
|
return this.writes.get(relative);
|
|
40
41
|
if (!this.before.has(relative)) {
|
|
41
|
-
const value = existsSync(file) ?
|
|
42
|
-
if (value && value.length > 2 * 1024 * 1024)
|
|
43
|
-
throw Error(`Configuration exceeds its bound: ${relative}`);
|
|
42
|
+
const value = existsSync(file) ? readBoundedFile(file, MAX_PROJECT_JSON_BYTES) : null;
|
|
44
43
|
this.before.set(relative, value?.toString('utf8') ?? null);
|
|
45
44
|
}
|
|
46
45
|
return this.before.get(relative);
|
|
@@ -89,7 +88,9 @@ export class CapabilityEditor {
|
|
|
89
88
|
verify() {
|
|
90
89
|
for (const [relative, before] of this.before) {
|
|
91
90
|
const file = this.file(relative);
|
|
92
|
-
const current = existsSync(file)
|
|
91
|
+
const current = existsSync(file)
|
|
92
|
+
? readBoundedFile(file, MAX_PROJECT_JSON_BYTES).toString('utf8')
|
|
93
|
+
: null;
|
|
93
94
|
if (before !== current)
|
|
94
95
|
throw Error(`Source changed during addition: ${relative}. Retry after reviewing it.`);
|
|
95
96
|
}
|