@revoengine/cli 1.0.15 → 1.0.17
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 +70 -12
- package/dist/src/cli.js +6 -2
- package/dist/src/client.d.ts +29 -3
- package/dist/src/client.js +92 -2
- package/dist/src/commands/component.js +2 -4
- package/dist/src/commands/index.d.ts +1 -0
- package/dist/src/commands/index.js +1 -0
- package/dist/src/commands/migrate.js +83 -20
- package/dist/src/commands/service-accounts.d.ts +2 -0
- package/dist/src/commands/service-accounts.js +149 -0
- package/dist/src/commands/terminal-browser.d.ts +29 -2
- package/dist/src/commands/terminal-browser.js +144 -35
- package/dist/src/commands/terminal-file.d.ts +21 -0
- package/dist/src/commands/terminal-file.js +160 -0
- package/dist/src/commands/terminal-operational-log.js +2 -2
- package/dist/src/commands/terminal-policy.d.ts +5 -2
- package/dist/src/commands/terminal-policy.js +10 -4
- package/dist/src/commands/terminal-reconnect-grace.js +1 -1
- package/dist/src/commands/terminal-sandbox.js +7 -0
- package/dist/src/commands/terminal-secure-browser.d.ts +1 -0
- package/dist/src/commands/terminal-secure-browser.js +2 -1
- package/dist/src/commands/terminal-service.js +4 -4
- package/dist/src/commands/terminal.d.ts +12 -0
- package/dist/src/commands/terminal.js +134 -45
- package/dist/src/component-lock.d.ts +4 -0
- package/dist/src/component-lock.js +21 -2
- package/dist/src/metadata-backfill.js +50 -1
- package/dist/src/migration.d.ts +20 -5
- package/dist/src/migration.js +200 -75
- package/dist/src/resource-inventory.d.ts +3 -2
- package/dist/src/resource-inventory.js +6 -1
- package/dist/src/resource-syncs/account-principal.d.ts +22 -0
- package/dist/src/resource-syncs/account-principal.js +86 -0
- package/dist/src/resource-syncs/group-sync.d.ts +10 -0
- package/dist/src/resource-syncs/group-sync.js +92 -20
- package/dist/src/resource-syncs/identity-migration.d.ts +19 -0
- package/dist/src/resource-syncs/identity-migration.js +108 -0
- package/dist/src/resource-syncs/job-template-sync.d.ts +4 -0
- package/dist/src/resource-syncs/job-template-sync.js +55 -12
- package/dist/src/resource-syncs/service-account-sync.d.ts +98 -0
- package/dist/src/resource-syncs/service-account-sync.js +620 -0
- package/dist/src/sync-output.js +10 -5
- package/dist/src/tracked-resources.d.ts +1 -1
- package/dist/src/tracked-resources.js +5 -1
- package/dist/src/types.d.ts +12 -0
- package/dist/src/ui.js +6 -3
- package/dist/src/workspace-diff.d.ts +1 -0
- package/dist/src/workspace-diff.js +4 -1
- package/dist/src/workspace-prune.d.ts +40 -0
- package/dist/src/workspace-prune.js +363 -0
- package/package.json +2 -2
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { normalizeStableKeyValue } from "../resource-metadata.js";
|
|
4
|
+
import { samePrunePlan } from "../workspace-prune.js";
|
|
1
5
|
import { DEFAULT_ENV_NAME } from "../config.js";
|
|
2
6
|
import { buildMigrationPlan, pullResourcesToWorkspace, runMigration, } from "../migration.js";
|
|
3
7
|
import { isInteractiveTerminal, promptConfirm } from "../prompt.js";
|
|
@@ -30,6 +34,8 @@ const RESOURCE_ALIASES = {
|
|
|
30
34
|
events: 'event',
|
|
31
35
|
group: 'group',
|
|
32
36
|
groups: 'group',
|
|
37
|
+
'service-account': 'service-account',
|
|
38
|
+
'service-accounts': 'service-account',
|
|
33
39
|
'role-group': 'role-group',
|
|
34
40
|
'role-groups': 'role-group',
|
|
35
41
|
rolegroup: 'role-group',
|
|
@@ -39,6 +45,7 @@ const MIGRATION_RESOURCE_ORDER = [
|
|
|
39
45
|
'database-table',
|
|
40
46
|
'database-view',
|
|
41
47
|
'component',
|
|
48
|
+
'service-account',
|
|
42
49
|
'job-template',
|
|
43
50
|
'endpoint',
|
|
44
51
|
'schedule',
|
|
@@ -60,7 +67,7 @@ function readMigrationResources(context, commandLabel = 'Migration') {
|
|
|
60
67
|
for (const value of values) {
|
|
61
68
|
const resource = RESOURCE_ALIASES[value];
|
|
62
69
|
if (!resource) {
|
|
63
|
-
throw new Error(`${commandLabel} currently supports: database-table, database-view, component, job-template, endpoint, schedule, event, group, role-group, or all.`);
|
|
70
|
+
throw new Error(`${commandLabel} currently supports: database-table, database-view, component, job-template, endpoint, schedule, event, group, role-group, service-account, or all.`);
|
|
64
71
|
}
|
|
65
72
|
if (!resources.includes(resource)) {
|
|
66
73
|
resources.push(resource);
|
|
@@ -97,13 +104,17 @@ function readMigrationInput(context) {
|
|
|
97
104
|
allowDestructive: readBoolFlag(context.args, ['force', 'f']),
|
|
98
105
|
};
|
|
99
106
|
}
|
|
107
|
+
function retainedPlanItems(plan, resource, items) {
|
|
108
|
+
const removed = new Set(plan.prune?.items.filter((item) => item.resource === resource).map((item) => normalizeStableKeyValue(item.stableKey)));
|
|
109
|
+
return items.filter((item) => !item.stableKey || !removed.has(normalizeStableKeyValue(item.stableKey)));
|
|
110
|
+
}
|
|
100
111
|
function printMigrationPlan(context, plan) {
|
|
101
112
|
const phaseLabel = plan.from === 'workspace' ? 'Deployment plan' : 'Migration';
|
|
102
113
|
context.println(`${phaseLabel} ${plan.from} -> ${plan.to}`);
|
|
103
114
|
context.println(`Resources: ${plan.resources.join(' -> ')}.`);
|
|
104
115
|
context.println(`Ready to ${plan.from === 'workspace' ? 'deploy' : 'migrate'}: ${plan.readyToMigrate ? 'yes' : 'no'}.`);
|
|
105
116
|
context.println(`Changes required: ${plan.needsChanges ? 'yes' : 'no'}; verdict: ${plan.verdict}.`);
|
|
106
|
-
context.println(`Summary: create ${plan.operations.create}, update ${plan.operations.update}, adopt ${plan.operations.adopt}, unchanged ${plan.operations.noop}, excluded ${plan.operations.excluded}, blocked ${plan.operations.blocked}.`);
|
|
117
|
+
context.println(`Summary: create ${plan.operations.create}, update ${plan.operations.update}${plan.prune ? `, delete ${plan.operations.delete || 0}` : ''}, adopt ${plan.operations.adopt}, unchanged ${plan.operations.noop}, excluded ${plan.operations.excluded}, blocked ${plan.operations.blocked}.`);
|
|
107
118
|
context.println(`Diagnostics: ${plan.warnings.length} warning(s), ${plan.blockers.length} blocker(s).`);
|
|
108
119
|
if (plan.sourcePull.mode === 'repository') {
|
|
109
120
|
context.println('Source snapshot: repository workspace (no remote source pull).');
|
|
@@ -114,6 +125,9 @@ function printMigrationPlan(context, plan) {
|
|
|
114
125
|
: 'configured workspace';
|
|
115
126
|
context.println(`Source snapshot: ${plan.sourcePull.pulled} pulled, ${plan.sourcePull.pruned} pruned, ${plan.sourcePull.skipped} skipped in ${pullLocation}.`);
|
|
116
127
|
}
|
|
128
|
+
if (plan.identityOrder?.length) {
|
|
129
|
+
context.println(`Identity order before consumers: ${plan.identityOrder.map((node) => `${node.resource}:${node.stableKey}`).join(' -> ')}.`);
|
|
130
|
+
}
|
|
117
131
|
for (const phase of plan.phases) {
|
|
118
132
|
const pull = plan.sourcePull.byResource[phase.resource];
|
|
119
133
|
if (pull) {
|
|
@@ -125,7 +139,7 @@ function printMigrationPlan(context, plan) {
|
|
|
125
139
|
environment: plan.to,
|
|
126
140
|
counts: phase.operations,
|
|
127
141
|
showHints: readBoolFlag(context.args, ['hints']),
|
|
128
|
-
items: plan.databaseSchemas.items.map((item) => ({
|
|
142
|
+
items: retainedPlanItems(plan, 'database-table', plan.databaseSchemas.items).map((item) => ({
|
|
129
143
|
status: schemaItemActionLabel(item),
|
|
130
144
|
target: item.stableKey || item.name,
|
|
131
145
|
reason: item.reason,
|
|
@@ -143,7 +157,7 @@ function printMigrationPlan(context, plan) {
|
|
|
143
157
|
environment: plan.to,
|
|
144
158
|
counts: phase.operations,
|
|
145
159
|
showHints: readBoolFlag(context.args, ['hints']),
|
|
146
|
-
items: plan.databaseViews.items.map((item) => ({
|
|
160
|
+
items: retainedPlanItems(plan, 'database-view', plan.databaseViews.items).map((item) => ({
|
|
147
161
|
status: viewItemActionLabel(item),
|
|
148
162
|
target: item.stableKey || item.name,
|
|
149
163
|
reason: item.reason,
|
|
@@ -167,7 +181,7 @@ function printMigrationPlan(context, plan) {
|
|
|
167
181
|
environment: plan.to,
|
|
168
182
|
counts: phase.operations,
|
|
169
183
|
showHints: readBoolFlag(context.args, ['hints']),
|
|
170
|
-
items: plan.components.items.map((item) => ({
|
|
184
|
+
items: retainedPlanItems(plan, 'component', plan.components.items).map((item) => ({
|
|
171
185
|
status: componentItemActionLabel(item),
|
|
172
186
|
target: item.stableKey || item.path,
|
|
173
187
|
reason: item.reason,
|
|
@@ -184,13 +198,17 @@ function printMigrationPlan(context, plan) {
|
|
|
184
198
|
blockers: phase.blockers,
|
|
185
199
|
});
|
|
186
200
|
}
|
|
201
|
+
if (phase.resource === 'service-account' && plan.serviceAccounts) {
|
|
202
|
+
printSyncPlan(context.println, { title: `${phaseLabel} phase ${phase.order} / Service Account`, environment: plan.to,
|
|
203
|
+
counts: phase.operations, items: retainedPlanItems(plan, 'service-account', plan.serviceAccounts.items), warnings: phase.warnings, blockers: phase.blockers });
|
|
204
|
+
}
|
|
187
205
|
if (phase.resource === 'job-template' && plan.jobTemplates) {
|
|
188
206
|
printSyncPlan(context.println, {
|
|
189
207
|
title: `${phaseLabel} phase ${phase.order} / Job Template`,
|
|
190
208
|
environment: plan.to,
|
|
191
209
|
counts: phase.operations,
|
|
192
210
|
showHints: readBoolFlag(context.args, ['hints']),
|
|
193
|
-
items: plan.jobTemplates.items.map((item) => ({
|
|
211
|
+
items: retainedPlanItems(plan, 'job-template', plan.jobTemplates.items).map((item) => ({
|
|
194
212
|
status: jobTemplateItemActionLabel(item),
|
|
195
213
|
target: item.stableKey || item.name,
|
|
196
214
|
reason: item.reason,
|
|
@@ -211,7 +229,7 @@ function printMigrationPlan(context, plan) {
|
|
|
211
229
|
environment: plan.to,
|
|
212
230
|
counts: phase.operations,
|
|
213
231
|
showHints: readBoolFlag(context.args, ['hints']),
|
|
214
|
-
items: plan.endpoints.items.map((item) => ({
|
|
232
|
+
items: retainedPlanItems(plan, 'endpoint', plan.endpoints.items).map((item) => ({
|
|
215
233
|
status: endpointItemActionLabel(item),
|
|
216
234
|
target: item.stableKey || item.name,
|
|
217
235
|
reason: item.reason,
|
|
@@ -238,7 +256,7 @@ function printMigrationPlan(context, plan) {
|
|
|
238
256
|
environment: plan.to,
|
|
239
257
|
counts: phase.operations,
|
|
240
258
|
showHints: readBoolFlag(context.args, ['hints']),
|
|
241
|
-
items: plan.schedules.items.map((item) => ({
|
|
259
|
+
items: retainedPlanItems(plan, 'schedule', plan.schedules.items).map((item) => ({
|
|
242
260
|
status: scheduleItemActionLabel(item),
|
|
243
261
|
target: item.stableKey || item.name,
|
|
244
262
|
reason: item.reason,
|
|
@@ -256,7 +274,7 @@ function printMigrationPlan(context, plan) {
|
|
|
256
274
|
environment: plan.to,
|
|
257
275
|
counts: phase.operations,
|
|
258
276
|
showHints: readBoolFlag(context.args, ['hints']),
|
|
259
|
-
items: plan.events.items.map((item) => ({
|
|
277
|
+
items: retainedPlanItems(plan, 'event', plan.events.items).map((item) => ({
|
|
260
278
|
status: eventItemActionLabel(item),
|
|
261
279
|
target: item.stableKey || item.name,
|
|
262
280
|
reason: item.reason,
|
|
@@ -276,7 +294,7 @@ function printMigrationPlan(context, plan) {
|
|
|
276
294
|
environment: plan.to,
|
|
277
295
|
counts: phase.operations,
|
|
278
296
|
showHints: readBoolFlag(context.args, ['hints']),
|
|
279
|
-
items: plan.groups.items.map((item) => ({
|
|
297
|
+
items: retainedPlanItems(plan, 'group', plan.groups.items).map((item) => ({
|
|
280
298
|
status: groupItemActionLabel(item),
|
|
281
299
|
target: item.stableKey || item.name,
|
|
282
300
|
reason: item.reason,
|
|
@@ -296,7 +314,7 @@ function printMigrationPlan(context, plan) {
|
|
|
296
314
|
environment: plan.to,
|
|
297
315
|
counts: phase.operations,
|
|
298
316
|
showHints: readBoolFlag(context.args, ['hints']),
|
|
299
|
-
items: plan.roleGroups.items.map((item) => ({
|
|
317
|
+
items: retainedPlanItems(plan, 'role-group', plan.roleGroups.items).map((item) => ({
|
|
300
318
|
status: roleGroupItemActionLabel(item),
|
|
301
319
|
target: item.stableKey || item.name,
|
|
302
320
|
reason: item.reason,
|
|
@@ -309,6 +327,15 @@ function printMigrationPlan(context, plan) {
|
|
|
309
327
|
});
|
|
310
328
|
}
|
|
311
329
|
}
|
|
330
|
+
if (plan.prune) {
|
|
331
|
+
printSyncPlan(context.println, {
|
|
332
|
+
title: 'Deletion after verified upserts', environment: plan.to,
|
|
333
|
+
counts: { delete: plan.prune.items.length },
|
|
334
|
+
items: plan.prune.items.map((item) => ({ status: 'delete', target: `${item.resource}:${item.stableKey}`,
|
|
335
|
+
details: [{ label: 'target', values: item.targetId }, { label: 'name', values: item.name }] })),
|
|
336
|
+
blockers: plan.prune.blockers,
|
|
337
|
+
});
|
|
338
|
+
}
|
|
312
339
|
}
|
|
313
340
|
function schemaItemActionLabel(item) {
|
|
314
341
|
if (item.status === 'missing-lock') {
|
|
@@ -474,7 +501,8 @@ async function readWorkspaceDeploymentInput(context) {
|
|
|
474
501
|
to: context.client.baseUrl,
|
|
475
502
|
resources,
|
|
476
503
|
withStats: readBoolFlag(context.args, ['with-stats']),
|
|
477
|
-
allowDestructive: readBoolFlag(context.args, ['force', 'f']),
|
|
504
|
+
allowDestructive: readBoolFlag(context.args, ['force', 'f']) || readBoolFlag(context.args, ['prune']),
|
|
505
|
+
prune: readBoolFlag(context.args, ['prune']),
|
|
478
506
|
sourceMode: 'workspace',
|
|
479
507
|
targetClient: context.client,
|
|
480
508
|
targetKey: `instance:${authenticatedInstance}`,
|
|
@@ -497,6 +525,12 @@ async function handleMigrationRead(context, input, command) {
|
|
|
497
525
|
}
|
|
498
526
|
return;
|
|
499
527
|
}
|
|
528
|
+
const outputFile = readFlag(context.args, ['out']);
|
|
529
|
+
if (outputFile) {
|
|
530
|
+
if (command !== 'plan')
|
|
531
|
+
throw new Error('--out is supported by plan only.');
|
|
532
|
+
fs.writeFileSync(path.resolve(context.cwd, outputFile), `${JSON.stringify(plan, null, 2)}\n`, { mode: 0o600 });
|
|
533
|
+
}
|
|
500
534
|
if (readBoolFlag(context.args, ['json'])) {
|
|
501
535
|
context.print({ ...plan, command });
|
|
502
536
|
}
|
|
@@ -509,13 +543,15 @@ async function handleMigrationRead(context, input, command) {
|
|
|
509
543
|
}
|
|
510
544
|
if (command === 'plan' && input.sourceMode === 'workspace'
|
|
511
545
|
&& readBoolFlag(context.args, ['strict']) && plan.needsChanges) {
|
|
512
|
-
throw new Error(`Deployment strict plan has pending changes: ${plan.operations.create} create, ${plan.operations.update} update.`);
|
|
546
|
+
throw new Error(`Deployment strict plan has pending changes: ${plan.operations.create} create, ${plan.operations.update} update${plan.prune ? `, ${plan.operations.delete || 0} delete` : ''}.`);
|
|
513
547
|
}
|
|
514
548
|
if (command === 'verify' && plan.needsChanges) {
|
|
515
549
|
throw new Error('Migration verification failed: target still requires changes.');
|
|
516
550
|
}
|
|
517
551
|
}
|
|
518
552
|
export async function handleDiffCommand(context) {
|
|
553
|
+
if (readBoolFlag(context.args, ['prune']))
|
|
554
|
+
throw new Error('Review deletions with revo plan --prune; diff compares content only.');
|
|
519
555
|
if (readBoolFlag(context.args, ['force', 'f'])) {
|
|
520
556
|
throw new Error('Repository diff only compares content. Use revo plan --force to review force-gated deployment operations.');
|
|
521
557
|
}
|
|
@@ -608,15 +644,16 @@ async function confirmDeploy(context) {
|
|
|
608
644
|
if (readBoolFlag(context.args, ['yes', 'y'])) {
|
|
609
645
|
return;
|
|
610
646
|
}
|
|
611
|
-
if (!isInteractiveTerminal() || !await promptConfirm(`
|
|
647
|
+
if (!isInteractiveTerminal() || !await promptConfirm(`Apply the displayed deployment plan to "${context.client.baseUrl}"${readBoolFlag(context.args, ['prune']) ? ', including all listed deletions' : ''}?`, false)) {
|
|
612
648
|
throw new Error('Deployment requires confirmation. Re-run with --yes or use an interactive terminal.');
|
|
613
649
|
}
|
|
614
650
|
}
|
|
615
|
-
function printRunResult(context, result) {
|
|
616
|
-
|
|
651
|
+
function printRunResult(context, result, showPlan = true) {
|
|
652
|
+
if (showPlan)
|
|
653
|
+
printMigrationPlan(context, result.plan);
|
|
617
654
|
for (const item of result.results) {
|
|
618
655
|
printSyncStatus(context.println, {
|
|
619
|
-
status: item.status === 'deployed' ? 'Deployed' : item.status === 'write-unverified' ? 'Unverified' : item.status === 'failed' ? 'Failed' : 'Skipped',
|
|
656
|
+
status: item.status === 'deployed' ? 'Deployed' : item.status === 'pruned' ? 'Pruned' : item.status === 'write-unverified' ? 'Unverified' : item.status === 'failed' ? 'Failed' : 'Skipped',
|
|
620
657
|
direction: 'push',
|
|
621
658
|
targetPath: item.targetPath,
|
|
622
659
|
reason: ('error' in item ? item.error : undefined) || item.reason,
|
|
@@ -625,14 +662,38 @@ function printRunResult(context, result) {
|
|
|
625
662
|
context.println(`Final verdict: ${result.verdict}.`);
|
|
626
663
|
}
|
|
627
664
|
export async function handleDeployCommand(context) {
|
|
665
|
+
if (readBoolFlag(context.args, ['changed']) || readFlag(context.args, ['base']) || readValues(context.args, ['resources', 'resource']).length > 0) {
|
|
666
|
+
throw new Error('Repository deployment evaluates all tracked resources; select resources in .revoengine/revo.json.');
|
|
667
|
+
}
|
|
668
|
+
const input = { ...await readWorkspaceDeploymentInput(context), detailedDiff: true };
|
|
669
|
+
const preview = await buildMigrationPlan(input);
|
|
670
|
+
const reviewedFile = readFlag(context.args, ['reviewed-plan']);
|
|
671
|
+
if (reviewedFile) {
|
|
672
|
+
if (!input.prune)
|
|
673
|
+
throw new Error('--reviewed-plan requires --prune.');
|
|
674
|
+
const reviewed = JSON.parse(fs.readFileSync(path.resolve(context.cwd, reviewedFile), 'utf8'));
|
|
675
|
+
if (!reviewed.readyToMigrate || reviewed.schemaVersion !== 2 || reviewed.command !== 'plan'
|
|
676
|
+
|| !reviewed.prune || !preview.prune || reviewed.pruneTargetKey !== preview.pruneTargetKey
|
|
677
|
+
|| JSON.stringify(reviewed.resources) !== JSON.stringify(preview.resources)
|
|
678
|
+
|| !samePrunePlan(reviewed.prune, preview.prune)) {
|
|
679
|
+
throw new Error('Reviewed deletion plan does not match this instance, resource scope or live target; run plan again.');
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
// Interactive confirmation must always expose the plan, including JSON mode.
|
|
683
|
+
if (!readBoolFlag(context.args, ['json']))
|
|
684
|
+
printMigrationPlan(context, preview);
|
|
685
|
+
else if (!readBoolFlag(context.args, ['yes', 'y']))
|
|
686
|
+
printMigrationPlan({ ...context, println: context.error }, preview);
|
|
687
|
+
if (!preview.readyToMigrate)
|
|
688
|
+
throw new Error(`Deployment plan is blocked by ${preview.blockers.length} issue(s).`);
|
|
628
689
|
await confirmDeploy(context);
|
|
629
690
|
const startedAt = Date.now();
|
|
630
|
-
const result = await runMigration({ ...
|
|
691
|
+
const result = await runMigration({ ...input, reviewedPrune: preview.prune });
|
|
631
692
|
if (readBoolFlag(context.args, ['json'])) {
|
|
632
693
|
context.print({ ...result, command: 'deploy' });
|
|
633
694
|
}
|
|
634
695
|
else {
|
|
635
|
-
printRunResult(context, result);
|
|
696
|
+
printRunResult(context, result, false);
|
|
636
697
|
printSyncSummary(context.println, 'Deployed', result.results, Date.now() - startedAt);
|
|
637
698
|
}
|
|
638
699
|
if (result.verdict !== 'succeeded') {
|
|
@@ -640,11 +701,13 @@ export async function handleDeployCommand(context) {
|
|
|
640
701
|
}
|
|
641
702
|
}
|
|
642
703
|
export async function handleMigrateCommand(context) {
|
|
704
|
+
if (readBoolFlag(context.args, ['prune']))
|
|
705
|
+
throw new Error('Prune requires repository plan/deploy; named migration remains upsert-only.');
|
|
643
706
|
const requestedSubcommand = context.args._[1] || 'plan';
|
|
644
707
|
const dryRun = readBoolFlag(context.args, ['dry-run']);
|
|
645
708
|
const subcommand = dryRun ? 'plan' : requestedSubcommand;
|
|
646
709
|
if (requestedSubcommand !== 'plan' && requestedSubcommand !== 'run' && requestedSubcommand !== 'verify') {
|
|
647
|
-
throw new Error('Unknown migrate command. Usage: revo migrate <plan|run|verify> --from <env> --to <env> [--resources database-table,database-view,component,job-template,endpoint,schedule,event,group,role-group] [--skip-groups] [--dry-run]');
|
|
710
|
+
throw new Error('Unknown migrate command. Usage: revo migrate <plan|run|verify> --from <env> --to <env> [--resources database-table,database-view,component,job-template,endpoint,schedule,event,group,role-group,service-account] [--skip-groups] [--dry-run]');
|
|
648
711
|
}
|
|
649
712
|
const input = readMigrationInput(context);
|
|
650
713
|
const json = readBoolFlag(context.args, ['json']);
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { resolveProjectRoot, readProjectStableKeyName } from "../project.js";
|
|
4
|
+
import { resolveResourceTarget } from "../resource-target.js";
|
|
5
|
+
import { buildServiceAccountsPlan, pullServiceAccountsToWorkspace, pushServiceAccounts } from "../resource-syncs/service-account-sync.js";
|
|
6
|
+
import { isInteractiveTerminal, promptConfirm } from "../prompt.js";
|
|
7
|
+
import { printSyncPlan, printSyncStatus, printSyncSummary } from "../sync-output.js";
|
|
8
|
+
import { readBoolFlag } from "../utils.js";
|
|
9
|
+
function warnAboutExperimentalState(context) {
|
|
10
|
+
const projectRoot = resolveProjectRoot(context.cwd) || path.resolve(context.cwd);
|
|
11
|
+
const legacyPaths = [
|
|
12
|
+
path.join(projectRoot, '.revoengine', 'resources'),
|
|
13
|
+
path.join(projectRoot, '.revoengine', 'resources.lock.json'),
|
|
14
|
+
path.join(projectRoot, '.revoengine', 'plans'),
|
|
15
|
+
].filter((candidate) => fs.existsSync(candidate));
|
|
16
|
+
if (legacyPaths.length > 0) {
|
|
17
|
+
const warning = `Ignoring experimental ${legacyPaths.map((candidate) => path.relative(projectRoot, candidate)).join(', ')}; service-accounts use workspace/ServiceAccounts and .revoengine/revo.lock.json.`;
|
|
18
|
+
if (readBoolFlag(context.args, ['json'])) {
|
|
19
|
+
(context.warn || context.error)(warning);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
context.println(warning);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function handlePull(context) {
|
|
27
|
+
if (!readBoolFlag(context.args, ['all', 'a'])) {
|
|
28
|
+
throw new Error('Service-account pull currently requires --all.');
|
|
29
|
+
}
|
|
30
|
+
const { client, envName } = await resolveResourceTarget(context, { resource: 'Service-account', allowDefaultProfile: true });
|
|
31
|
+
const startedAt = Date.now();
|
|
32
|
+
const result = await pullServiceAccountsToWorkspace({
|
|
33
|
+
client,
|
|
34
|
+
cwd: context.cwd,
|
|
35
|
+
envName,
|
|
36
|
+
stableKeyName: readProjectStableKeyName(context.cwd),
|
|
37
|
+
force: readBoolFlag(context.args, ['force', 'f']),
|
|
38
|
+
});
|
|
39
|
+
if (readBoolFlag(context.args, ['json'])) {
|
|
40
|
+
context.print(result);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const outputResults = [];
|
|
44
|
+
for (const pulled of result.pulled) {
|
|
45
|
+
printSyncStatus(context.println, { status: 'Pulled', direction: 'pull', targetPath: pulled.targetPath });
|
|
46
|
+
outputResults.push({ status: 'pulled', targetPath: pulled.targetPath });
|
|
47
|
+
}
|
|
48
|
+
for (const skipped of result.skipped) {
|
|
49
|
+
printSyncStatus(context.println, { status: 'Skipped', direction: 'pull', targetPath: skipped.targetPath, reason: skipped.reason });
|
|
50
|
+
outputResults.push({ status: 'skipped', targetPath: skipped.targetPath, reason: skipped.reason });
|
|
51
|
+
}
|
|
52
|
+
printSyncSummary(context.println, 'Pulled', outputResults, Date.now() - startedAt);
|
|
53
|
+
}
|
|
54
|
+
async function handlePlan(context) {
|
|
55
|
+
if (!readBoolFlag(context.args, ['all', 'a'])) {
|
|
56
|
+
throw new Error('Service-account plan currently requires --all.');
|
|
57
|
+
}
|
|
58
|
+
if (readBoolFlag(context.args, ['prune'])) {
|
|
59
|
+
throw new Error('Service-account prune is disabled until the backend soft-delete contract is confirmed.');
|
|
60
|
+
}
|
|
61
|
+
const { client, envName, displayName } = await resolveResourceTarget(context, { resource: 'Service-account', allowDefaultProfile: true });
|
|
62
|
+
const plan = await buildServiceAccountsPlan({
|
|
63
|
+
client,
|
|
64
|
+
cwd: context.cwd,
|
|
65
|
+
envName,
|
|
66
|
+
stableKeyName: readProjectStableKeyName(context.cwd),
|
|
67
|
+
});
|
|
68
|
+
if (readBoolFlag(context.args, ['json'])) {
|
|
69
|
+
context.print(plan);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
printSyncPlan(context.println, {
|
|
73
|
+
title: 'Service-account',
|
|
74
|
+
environment: displayName,
|
|
75
|
+
counts: plan.counts,
|
|
76
|
+
showHints: readBoolFlag(context.args, ['hints']),
|
|
77
|
+
items: plan.items.map((item) => ({
|
|
78
|
+
...item,
|
|
79
|
+
details: [],
|
|
80
|
+
})),
|
|
81
|
+
blockers: plan.blockers,
|
|
82
|
+
warnings: plan.exclusions,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (readBoolFlag(context.args, ['strict'])) {
|
|
86
|
+
const drift = plan.items.filter((item) => !['clean', 'orphan', 'skipped'].includes(item.status));
|
|
87
|
+
if (plan.blockers.length > 0 || drift.length > 0) {
|
|
88
|
+
throw new Error(`Service-account plan is not clean: ${drift.length} drift item(s), ${plan.blockers.length} blocker(s).`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async function handlePush(context) {
|
|
93
|
+
if (!readBoolFlag(context.args, ['all', 'a'])) {
|
|
94
|
+
throw new Error('Service-account push currently requires --all.');
|
|
95
|
+
}
|
|
96
|
+
if (readBoolFlag(context.args, ['prune'])) {
|
|
97
|
+
throw new Error('Service-account prune is disabled until the backend soft-delete contract is confirmed.');
|
|
98
|
+
}
|
|
99
|
+
const { client, envName, displayName } = await resolveResourceTarget(context, { resource: 'Service-account', allowDefaultProfile: true });
|
|
100
|
+
if (!readBoolFlag(context.args, ['yes', 'y'])) {
|
|
101
|
+
if (!isInteractiveTerminal() || !await promptConfirm(`Push service-accounts to "${displayName}"?`, false)) {
|
|
102
|
+
throw new Error('Service-account push requires confirmation. Re-run with --yes or use an interactive terminal.');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const startedAt = Date.now();
|
|
106
|
+
const result = await pushServiceAccounts({
|
|
107
|
+
client,
|
|
108
|
+
cwd: context.cwd,
|
|
109
|
+
envName,
|
|
110
|
+
stableKeyName: readProjectStableKeyName(context.cwd),
|
|
111
|
+
force: readBoolFlag(context.args, ['force', 'f']),
|
|
112
|
+
});
|
|
113
|
+
if (readBoolFlag(context.args, ['json'])) {
|
|
114
|
+
context.print(result);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
for (const item of result.results) {
|
|
118
|
+
const label = item.status === 'deployed' ? 'Deployed' : item.status === 'failed' ? 'Failed' : 'Skipped';
|
|
119
|
+
printSyncStatus(context.println, {
|
|
120
|
+
status: label,
|
|
121
|
+
direction: 'push',
|
|
122
|
+
targetPath: item.targetPath,
|
|
123
|
+
reason: item.error || item.reason,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
printSyncSummary(context.println, 'Deployed', result.results, Date.now() - startedAt);
|
|
127
|
+
}
|
|
128
|
+
const failed = result.results.filter((item) => item.status === 'failed');
|
|
129
|
+
if (failed.length > 0) {
|
|
130
|
+
throw new Error(`Service-account push finished with ${failed.length} failure(s).`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export async function handleServiceAccountsCommand(context) {
|
|
134
|
+
warnAboutExperimentalState(context);
|
|
135
|
+
const subcommand = context.args._[1] || '';
|
|
136
|
+
if (subcommand === 'pull') {
|
|
137
|
+
await handlePull(context);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (subcommand === 'plan') {
|
|
141
|
+
await handlePlan(context);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (subcommand === 'push') {
|
|
145
|
+
await handlePush(context);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
throw new Error('Unknown service-accounts command. Usage: revo service-accounts <pull|plan|push> --all [--env <name>]');
|
|
149
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type BrowserAction = 'navigate' | 'dom' | 'click' | 'fill' | 'check' | 'select' | 'press' | 'scroll' | 'wait_for' | 'screenshot';
|
|
1
|
+
export type BrowserAction = 'navigate' | 'dom' | 'click' | 'fill' | 'check' | 'select' | 'press' | 'scroll' | 'wait_for' | 'screenshot' | 'tabs' | 'new_tab' | 'select_tab' | 'close_tab' | 'close';
|
|
2
2
|
export type BrowserCapture = 'viewport' | 'full_page' | 'element' | 'crop';
|
|
3
3
|
export type BrowserClip = {
|
|
4
4
|
x: number;
|
|
@@ -10,7 +10,9 @@ export type BrowserActionInput = {
|
|
|
10
10
|
url: string;
|
|
11
11
|
action: BrowserAction;
|
|
12
12
|
workspace: string;
|
|
13
|
+
agentTerminalWorkspaceId?: string;
|
|
13
14
|
browserSessionId: string;
|
|
15
|
+
tabId?: string;
|
|
14
16
|
selector?: string | null;
|
|
15
17
|
width?: number;
|
|
16
18
|
height?: number;
|
|
@@ -20,29 +22,54 @@ export type BrowserActionInput = {
|
|
|
20
22
|
deltaY?: number;
|
|
21
23
|
state?: 'visible' | 'hidden';
|
|
22
24
|
waitTimeoutMs?: number;
|
|
25
|
+
actionTimeoutMs?: number;
|
|
23
26
|
capture?: BrowserCapture;
|
|
24
27
|
clip?: BrowserClip;
|
|
25
28
|
localOnly?: boolean;
|
|
26
29
|
networkAccessExpiresAt?: number | null;
|
|
27
30
|
networkAccessOnce?: boolean;
|
|
31
|
+
networkAccessForThread?: boolean;
|
|
32
|
+
actorUserId?: string;
|
|
33
|
+
threadId?: string;
|
|
34
|
+
policyGrantRevision?: number;
|
|
28
35
|
signal?: AbortSignal;
|
|
29
36
|
onActionAttempt?: () => void;
|
|
30
37
|
};
|
|
38
|
+
export type BrowserTab = {
|
|
39
|
+
id: string;
|
|
40
|
+
title: string;
|
|
41
|
+
url: string;
|
|
42
|
+
active: boolean;
|
|
43
|
+
};
|
|
31
44
|
export type BrowserActionResult = {
|
|
32
45
|
dom: string;
|
|
33
46
|
pageUrl: string;
|
|
34
47
|
screenshotPath?: string;
|
|
48
|
+
browserSessionId: string;
|
|
49
|
+
activeTabId: string | null;
|
|
50
|
+
tabs: BrowserTab[];
|
|
51
|
+
sessionCreated: boolean;
|
|
35
52
|
};
|
|
36
53
|
export declare function browserUrl(value: string): string;
|
|
37
54
|
export declare function localBrowserUrl(value: string): string;
|
|
38
55
|
export declare function validateBrowserActionInput(input: BrowserActionInput): void;
|
|
39
56
|
export declare function closeBrowserSessions(): Promise<void>;
|
|
40
|
-
export declare function reconcileBrowserSessions(networkMode: 'restricted' | 'sandbox' | 'external'): Promise<number>;
|
|
57
|
+
export declare function reconcileBrowserSessions(networkMode: 'restricted' | 'sandbox' | 'external', policyGrantRevision?: number): Promise<number>;
|
|
58
|
+
export declare function threadBrowserScopes(): Array<{
|
|
59
|
+
browserSessionId: string;
|
|
60
|
+
actorUserId: string;
|
|
61
|
+
threadId: string;
|
|
62
|
+
policyGrantRevision: number;
|
|
63
|
+
networkAccess: 'local' | 'full';
|
|
64
|
+
}>;
|
|
65
|
+
export declare function closeThreadBrowserSession(browserSessionId: string): Promise<void>;
|
|
66
|
+
export declare function browserSessionIds(): string[];
|
|
41
67
|
export declare function hasBrowserSessions(): boolean;
|
|
42
68
|
export declare function writePrivateScreenshot(file: string, bytes: Buffer): void;
|
|
43
69
|
export declare function runBrowserAction(input: BrowserActionInput): Promise<BrowserActionResult>;
|
|
44
70
|
export declare function fillBrowserSecret(input: {
|
|
45
71
|
browserSessionId: string;
|
|
72
|
+
browserTabId?: string;
|
|
46
73
|
origin: string;
|
|
47
74
|
selector: string;
|
|
48
75
|
value: string;
|