@revoengine/cli 1.0.10 → 1.0.12

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.
Files changed (104) hide show
  1. package/README.md +314 -239
  2. package/dist/src/cli.js +126 -9
  3. package/dist/src/client.d.ts +373 -6
  4. package/dist/src/client.js +1005 -53
  5. package/dist/src/commands/auth.js +4 -2
  6. package/dist/src/commands/component.d.ts +67 -0
  7. package/dist/src/commands/component.js +555 -164
  8. package/dist/src/commands/database-tables.d.ts +2 -0
  9. package/dist/src/commands/database-tables.js +169 -0
  10. package/dist/src/commands/database-views.d.ts +2 -0
  11. package/dist/src/commands/database-views.js +126 -0
  12. package/dist/src/commands/endpoints.js +124 -0
  13. package/dist/src/commands/env.js +44 -24
  14. package/dist/src/commands/events.d.ts +2 -0
  15. package/dist/src/commands/events.js +144 -0
  16. package/dist/src/commands/groups.d.ts +2 -0
  17. package/dist/src/commands/groups.js +160 -0
  18. package/dist/src/commands/index.d.ts +9 -0
  19. package/dist/src/commands/index.js +9 -0
  20. package/dist/src/commands/job-templates.d.ts +2 -0
  21. package/dist/src/commands/job-templates.js +107 -0
  22. package/dist/src/commands/metadata.js +75 -10
  23. package/dist/src/commands/migrate.d.ts +6 -0
  24. package/dist/src/commands/migrate.js +658 -0
  25. package/dist/src/commands/project.js +10 -3
  26. package/dist/src/commands/role-groups.d.ts +2 -0
  27. package/dist/src/commands/role-groups.js +141 -0
  28. package/dist/src/commands/schedules.d.ts +2 -0
  29. package/dist/src/commands/schedules.js +140 -0
  30. package/dist/src/commands/terminal-browser.d.ts +16 -0
  31. package/dist/src/commands/terminal-browser.js +92 -0
  32. package/dist/src/commands/terminal-image.d.ts +7 -0
  33. package/dist/src/commands/terminal-image.js +40 -0
  34. package/dist/src/commands/terminal-patch-worker.d.ts +1 -0
  35. package/dist/src/commands/terminal-patch-worker.js +24 -0
  36. package/dist/src/commands/terminal-patch.d.ts +2 -0
  37. package/dist/src/commands/terminal-patch.js +156 -0
  38. package/dist/src/commands/terminal-sandbox.d.ts +8 -0
  39. package/dist/src/commands/terminal-sandbox.js +87 -0
  40. package/dist/src/commands/terminal-service.d.ts +38 -0
  41. package/dist/src/commands/terminal-service.js +210 -0
  42. package/dist/src/commands/terminal.d.ts +49 -0
  43. package/dist/src/commands/terminal.js +826 -0
  44. package/dist/src/component-lock.d.ts +111 -3
  45. package/dist/src/component-lock.js +363 -15
  46. package/dist/src/config.d.ts +10 -2
  47. package/dist/src/config.js +49 -14
  48. package/dist/src/database-table-artifacts.d.ts +7 -0
  49. package/dist/src/database-table-artifacts.js +8 -0
  50. package/dist/src/diff-details.d.ts +8 -0
  51. package/dist/src/diff-details.js +152 -0
  52. package/dist/src/env-sync.d.ts +0 -3
  53. package/dist/src/env-sync.js +11 -25
  54. package/dist/src/http-trace.d.ts +94 -0
  55. package/dist/src/http-trace.js +226 -0
  56. package/dist/src/metadata-backfill.d.ts +18 -7
  57. package/dist/src/metadata-backfill.js +1002 -27
  58. package/dist/src/migration.d.ts +141 -0
  59. package/dist/src/migration.js +1632 -0
  60. package/dist/src/project.d.ts +2 -0
  61. package/dist/src/project.js +4 -17
  62. package/dist/src/prompt.js +10 -18
  63. package/dist/src/resource-inventory.d.ts +28 -0
  64. package/dist/src/resource-inventory.js +85 -0
  65. package/dist/src/resource-metadata.d.ts +1 -0
  66. package/dist/src/resource-metadata.js +3 -0
  67. package/dist/src/resource-syncs/database-table-sync.d.ts +127 -0
  68. package/dist/src/resource-syncs/database-table-sync.js +2374 -0
  69. package/dist/src/resource-syncs/database-view-sync.d.ts +146 -0
  70. package/dist/src/resource-syncs/database-view-sync.js +1405 -0
  71. package/dist/src/resource-syncs/endpoint-sync.d.ts +123 -0
  72. package/dist/src/resource-syncs/endpoint-sync.js +1563 -0
  73. package/dist/src/resource-syncs/event-sync.d.ts +126 -0
  74. package/dist/src/resource-syncs/event-sync.js +1046 -0
  75. package/dist/src/resource-syncs/group-sync.d.ts +93 -0
  76. package/dist/src/resource-syncs/group-sync.js +928 -0
  77. package/dist/src/resource-syncs/job-template-sync.d.ts +106 -0
  78. package/dist/src/resource-syncs/job-template-sync.js +843 -0
  79. package/dist/src/resource-syncs/role-group-sync.d.ts +90 -0
  80. package/dist/src/resource-syncs/role-group-sync.js +635 -0
  81. package/dist/src/resource-syncs/schedule-sync.d.ts +140 -0
  82. package/dist/src/resource-syncs/schedule-sync.js +1396 -0
  83. package/dist/src/resource-syncs/util.d.ts +22 -0
  84. package/dist/src/resource-syncs/util.js +118 -0
  85. package/dist/src/resource-target.d.ts +11 -0
  86. package/dist/src/resource-target.js +48 -0
  87. package/dist/src/runtime-view.d.ts +1 -0
  88. package/dist/src/runtime-view.js +6 -1
  89. package/dist/src/sync-output.d.ts +66 -0
  90. package/dist/src/sync-output.js +268 -0
  91. package/dist/src/tracked-resources.d.ts +1 -1
  92. package/dist/src/tracked-resources.js +28 -2
  93. package/dist/src/types.d.ts +227 -0
  94. package/dist/src/ui.d.ts +3 -0
  95. package/dist/src/ui.js +76 -18
  96. package/dist/src/utils.d.ts +4 -0
  97. package/dist/src/utils.js +81 -0
  98. package/dist/src/workspace-component.d.ts +2 -0
  99. package/dist/src/workspace-component.js +34 -0
  100. package/dist/src/workspace-diff.d.ts +25 -0
  101. package/dist/src/workspace-diff.js +75 -0
  102. package/dist/src/workspace-resource.d.ts +2 -0
  103. package/dist/src/workspace-resource.js +52 -0
  104. package/package.json +12 -4
@@ -0,0 +1,144 @@
1
+ import { readProjectStableKeyName } from "../project.js";
2
+ import { resolveResourceTarget } from "../resource-target.js";
3
+ import { activateVerifiedEvents, buildEventsPlan, pullEventsToWorkspace, pushEvents } from "../resource-syncs/event-sync.js";
4
+ import { isInteractiveTerminal, promptConfirm } from "../prompt.js";
5
+ import { planDependencyHints, printSyncNotice, printSyncPlan, printSyncStatus, printSyncSummary } from "../sync-output.js";
6
+ import { readBoolFlag } from "../utils.js";
7
+ export async function handleEventsCommand(context) {
8
+ const subcommand = context.args._[1] || '';
9
+ if (!['pull', 'plan', 'push'].includes(subcommand)) {
10
+ throw new Error('Unknown events command. Usage: revo events <pull|plan|push> --all [--env <name>]');
11
+ }
12
+ if (!readBoolFlag(context.args, ['all', 'a'])) {
13
+ throw new Error('Event sync currently requires --all.');
14
+ }
15
+ const { client, envName, displayName } = await resolveResourceTarget(context, { resource: 'Event' });
16
+ const activate = readBoolFlag(context.args, ['activate']);
17
+ if (activate && subcommand !== 'push') {
18
+ throw new Error('--activate is available only with events push.');
19
+ }
20
+ if (subcommand === 'plan') {
21
+ const plan = await buildEventsPlan({
22
+ client,
23
+ cwd: context.cwd,
24
+ envName,
25
+ stableKeyName: readProjectStableKeyName(context.cwd),
26
+ });
27
+ if (readBoolFlag(context.args, ['json'])) {
28
+ context.print(plan);
29
+ }
30
+ else {
31
+ printSyncPlan(context.println, {
32
+ title: 'Event',
33
+ environment: displayName,
34
+ counts: plan.counts,
35
+ showHints: readBoolFlag(context.args, ['hints']),
36
+ items: plan.items.map((item) => ({
37
+ ...item,
38
+ hints: item.dependency
39
+ ? planDependencyHints({ ...item.dependency, resource: 'job-template' })
40
+ : undefined,
41
+ })),
42
+ warnings: [...plan.warnings, ...plan.exclusions],
43
+ blockers: plan.blockers,
44
+ });
45
+ }
46
+ if (readBoolFlag(context.args, ['strict'])) {
47
+ const drift = plan.items.filter((item) => !['clean', 'orphan', 'skipped'].includes(item.status));
48
+ if (plan.blockers.length > 0 || drift.length > 0) {
49
+ throw new Error(`Event strict plan is not converged: ${drift.length} drift item(s), ${plan.blockers.length} blocker(s).`);
50
+ }
51
+ }
52
+ return;
53
+ }
54
+ if (subcommand === 'push') {
55
+ if (!readBoolFlag(context.args, ['yes', 'y'])) {
56
+ if (activate && !isInteractiveTerminal()) {
57
+ throw new Error('Event activation in non-interactive mode requires --yes --activate.');
58
+ }
59
+ if (!isInteractiveTerminal() || !await promptConfirm(`Push Events to "${displayName}"?`, false)) {
60
+ throw new Error('Event push requires confirmation. Re-run with --yes or use an interactive terminal.');
61
+ }
62
+ }
63
+ const startedAt = Date.now();
64
+ const pushed = await pushEvents({
65
+ client,
66
+ cwd: context.cwd,
67
+ envName,
68
+ stableKeyName: readProjectStableKeyName(context.cwd),
69
+ force: readBoolFlag(context.args, ['force', 'f']),
70
+ });
71
+ const results = [...pushed.results];
72
+ let activation;
73
+ if (activate) {
74
+ const candidateCount = pushed.verifiedActivationCandidates.length;
75
+ const configurationFailures = pushed.results.filter((item) => item.status === 'failed');
76
+ if (configurationFailures.length > 0) {
77
+ activation = { candidateCount, results: [], skipped: 'configuration phase has failures' };
78
+ }
79
+ else {
80
+ const confirmed = !isInteractiveTerminal() || await promptConfirm(`Align activation for ${candidateCount} verified Event(s) on "${displayName}"?`, false);
81
+ if (confirmed) {
82
+ const activationResults = await activateVerifiedEvents({ client, candidates: pushed.verifiedActivationCandidates });
83
+ results.push(...activationResults);
84
+ activation = { candidateCount, results: activationResults };
85
+ }
86
+ else {
87
+ activation = { candidateCount, results: [], skipped: 'activation not confirmed' };
88
+ }
89
+ }
90
+ }
91
+ if (readBoolFlag(context.args, ['json'])) {
92
+ context.print({ plan: pushed.plan, results, ...(activation ? { activation } : {}) });
93
+ }
94
+ else {
95
+ for (const item of results) {
96
+ const label = item.action === 'activate'
97
+ ? 'Activated'
98
+ : item.action === 'disable'
99
+ ? 'Deactivated'
100
+ : item.status === 'deployed'
101
+ ? 'Deployed'
102
+ : item.status === 'failed'
103
+ ? 'Failed'
104
+ : 'Skipped';
105
+ printSyncStatus(context.println, {
106
+ status: label,
107
+ direction: 'push',
108
+ targetPath: item.targetPath,
109
+ reason: item.error || item.reason,
110
+ });
111
+ }
112
+ if (activation?.skipped) {
113
+ printSyncNotice(context.println, `${activation.candidateCount} verified Event activation candidate(s): ${activation.skipped}`);
114
+ }
115
+ printSyncSummary(context.println, 'Deployed', results, Date.now() - startedAt);
116
+ }
117
+ const failed = results.filter((item) => item.status === 'failed');
118
+ if (failed.length > 0) {
119
+ throw new Error(`Event push finished with ${failed.length} failure(s).`);
120
+ }
121
+ return;
122
+ }
123
+ const startedAt = Date.now();
124
+ const result = await pullEventsToWorkspace({
125
+ client,
126
+ cwd: context.cwd,
127
+ envName,
128
+ stableKeyName: readProjectStableKeyName(context.cwd),
129
+ force: readBoolFlag(context.args, ['force', 'f']),
130
+ });
131
+ if (readBoolFlag(context.args, ['json'])) {
132
+ context.print(result);
133
+ return;
134
+ }
135
+ const output = [];
136
+ for (const pulled of result.pulled) {
137
+ printSyncStatus(context.println, { status: 'Pulled', direction: 'pull', targetPath: pulled.targetPath });
138
+ output.push({ status: 'pulled', targetPath: pulled.targetPath });
139
+ }
140
+ for (const warning of result.warnings) {
141
+ printSyncNotice(context.println, `${warning.stableKey}: ${warning.reason}`);
142
+ }
143
+ printSyncSummary(context.println, 'Pulled', output, Date.now() - startedAt);
144
+ }
@@ -0,0 +1,2 @@
1
+ import type { CommandContext } from '../types.ts';
2
+ export declare function handleGroupsCommand(context: CommandContext): Promise<void>;
@@ -0,0 +1,160 @@
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 { isInteractiveTerminal, promptConfirm } from "../prompt.js";
6
+ import { buildGroupsPlan, pullGroupsToWorkspace, pushGroups } from "../resource-syncs/group-sync.js";
7
+ import { printSyncNotice, 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
+ return;
18
+ }
19
+ const warning = `Ignoring experimental ${legacyPaths.map((candidate) => path.relative(projectRoot, candidate)).join(', ')}; groups use workspace/Groups and .revoengine/revo.lock.json.`;
20
+ if (readBoolFlag(context.args, ['json'])) {
21
+ (context.warn || context.error)(warning);
22
+ }
23
+ else {
24
+ context.println(warning);
25
+ }
26
+ }
27
+ async function handlePull(context) {
28
+ if (!readBoolFlag(context.args, ['all', 'a'])) {
29
+ throw new Error('Group pull currently requires --all.');
30
+ }
31
+ const { client, envName } = await resolveResourceTarget(context, { resource: 'Group', allowDefaultProfile: true });
32
+ const startedAt = Date.now();
33
+ const result = await pullGroupsToWorkspace({
34
+ client,
35
+ cwd: context.cwd,
36
+ envName,
37
+ stableKeyName: readProjectStableKeyName(context.cwd),
38
+ force: readBoolFlag(context.args, ['force', 'f']),
39
+ });
40
+ if (readBoolFlag(context.args, ['json'])) {
41
+ context.print(result);
42
+ return;
43
+ }
44
+ const outputResults = [];
45
+ for (const pulled of result.pulled) {
46
+ printSyncStatus(context.println, { status: 'Pulled', direction: 'pull', targetPath: pulled.targetPath });
47
+ outputResults.push({ status: 'pulled', targetPath: pulled.targetPath });
48
+ }
49
+ for (const skipped of result.skipped) {
50
+ printSyncStatus(context.println, {
51
+ status: 'Skipped',
52
+ direction: 'pull',
53
+ targetPath: skipped.targetPath,
54
+ reason: skipped.reason,
55
+ });
56
+ outputResults.push({ status: 'skipped', targetPath: skipped.targetPath, reason: skipped.reason });
57
+ }
58
+ for (const notice of result.notices) {
59
+ printSyncNotice(context.println, `${notice.stableKey}: ${notice.reason}`);
60
+ }
61
+ printSyncSummary(context.println, 'Pulled', outputResults, Date.now() - startedAt);
62
+ }
63
+ async function handlePlan(context) {
64
+ if (!readBoolFlag(context.args, ['all', 'a'])) {
65
+ throw new Error('Group plan currently requires --all.');
66
+ }
67
+ if (readBoolFlag(context.args, ['prune'])) {
68
+ throw new Error('Group prune is disabled until a reviewed deletion contract is introduced.');
69
+ }
70
+ const { client, envName, displayName } = await resolveResourceTarget(context, { resource: 'Group', allowDefaultProfile: true });
71
+ const plan = await buildGroupsPlan({
72
+ client,
73
+ cwd: context.cwd,
74
+ envName,
75
+ stableKeyName: readProjectStableKeyName(context.cwd),
76
+ });
77
+ if (readBoolFlag(context.args, ['json'])) {
78
+ context.print(plan);
79
+ }
80
+ else {
81
+ printSyncPlan(context.println, {
82
+ title: 'Group',
83
+ environment: displayName,
84
+ counts: plan.counts,
85
+ showHints: readBoolFlag(context.args, ['hints']),
86
+ items: plan.items.map((item) => ({
87
+ ...item,
88
+ hints: item.ownerStableKey
89
+ ? [{ label: 'owner', values: item.ownerStableKey }]
90
+ : [],
91
+ })),
92
+ warnings: plan.warnings,
93
+ blockers: plan.blockers,
94
+ });
95
+ }
96
+ if (readBoolFlag(context.args, ['strict'])) {
97
+ const drift = plan.items.filter((item) => !['clean', 'orphan', 'skipped'].includes(item.status));
98
+ if (plan.blockers.length > 0 || drift.length > 0) {
99
+ throw new Error(`Group plan is not clean: ${drift.length} drift item(s), ${plan.blockers.length} blocker(s).`);
100
+ }
101
+ }
102
+ }
103
+ async function handlePush(context) {
104
+ if (!readBoolFlag(context.args, ['all', 'a'])) {
105
+ throw new Error('Group push currently requires --all.');
106
+ }
107
+ if (readBoolFlag(context.args, ['prune'])) {
108
+ throw new Error('Group prune is disabled until a reviewed deletion contract is introduced.');
109
+ }
110
+ const { client, envName, displayName } = await resolveResourceTarget(context, { resource: 'Group', allowDefaultProfile: true });
111
+ if (!readBoolFlag(context.args, ['yes', 'y'])) {
112
+ if (!isInteractiveTerminal() || !await promptConfirm(`Push Groups to "${displayName}"?`, false)) {
113
+ throw new Error('Group push requires confirmation. Re-run with --yes or use an interactive terminal.');
114
+ }
115
+ }
116
+ const startedAt = Date.now();
117
+ const result = await pushGroups({
118
+ client,
119
+ cwd: context.cwd,
120
+ envName,
121
+ stableKeyName: readProjectStableKeyName(context.cwd),
122
+ force: readBoolFlag(context.args, ['force', 'f']),
123
+ });
124
+ if (readBoolFlag(context.args, ['json'])) {
125
+ context.print(result);
126
+ }
127
+ else {
128
+ for (const item of result.results) {
129
+ const label = item.status === 'deployed' ? 'Deployed' : item.status === 'failed' ? 'Failed' : 'Skipped';
130
+ printSyncStatus(context.println, {
131
+ status: label,
132
+ direction: 'push',
133
+ targetPath: item.targetPath,
134
+ reason: item.error || item.reason,
135
+ });
136
+ }
137
+ printSyncSummary(context.println, 'Deployed', result.results, Date.now() - startedAt);
138
+ }
139
+ const failed = result.results.filter((item) => item.status === 'failed');
140
+ if (failed.length > 0) {
141
+ throw new Error(`Group push finished with ${failed.length} failure(s).`);
142
+ }
143
+ }
144
+ export async function handleGroupsCommand(context) {
145
+ warnAboutExperimentalState(context);
146
+ const subcommand = context.args._[1] || '';
147
+ if (subcommand === 'pull') {
148
+ await handlePull(context);
149
+ return;
150
+ }
151
+ if (subcommand === 'plan') {
152
+ await handlePlan(context);
153
+ return;
154
+ }
155
+ if (subcommand === 'push') {
156
+ await handlePush(context);
157
+ return;
158
+ }
159
+ throw new Error('Unknown groups command. Usage: revo groups <pull|plan|push> --all [--env <name>]');
160
+ }
@@ -1,9 +1,18 @@
1
1
  export * from './auth.ts';
2
2
  export * from './component.ts';
3
+ export * from './database-tables.ts';
4
+ export * from './database-views.ts';
3
5
  export * from './endpoints.ts';
4
6
  export * from './env.ts';
7
+ export * from './events.ts';
8
+ export * from './groups.ts';
5
9
  export * from './info.ts';
10
+ export * from './job-templates.ts';
6
11
  export * from './metadata.ts';
12
+ export * from './migrate.ts';
7
13
  export * from './project.ts';
8
14
  export * from './request.ts';
15
+ export * from './role-groups.ts';
9
16
  export * from './search.ts';
17
+ export * from './terminal.ts';
18
+ export * from './schedules.ts';
@@ -1,9 +1,18 @@
1
1
  export * from "./auth.js";
2
2
  export * from "./component.js";
3
+ export * from "./database-tables.js";
4
+ export * from "./database-views.js";
3
5
  export * from "./endpoints.js";
4
6
  export * from "./env.js";
7
+ export * from "./events.js";
8
+ export * from "./groups.js";
5
9
  export * from "./info.js";
10
+ export * from "./job-templates.js";
6
11
  export * from "./metadata.js";
12
+ export * from "./migrate.js";
7
13
  export * from "./project.js";
8
14
  export * from "./request.js";
15
+ export * from "./role-groups.js";
9
16
  export * from "./search.js";
17
+ export * from "./terminal.js";
18
+ export * from "./schedules.js";
@@ -0,0 +1,2 @@
1
+ import type { CommandContext } from '../types.ts';
2
+ export declare function handleJobTemplatesCommand(context: CommandContext): Promise<void>;
@@ -0,0 +1,107 @@
1
+ import { buildJobTemplatesPlan, pullJobTemplatesToWorkspace, pushJobTemplates } from "../resource-syncs/job-template-sync.js";
2
+ import { isInteractiveTerminal, promptConfirm } from "../prompt.js";
3
+ import { readProjectStableKeyName } from "../project.js";
4
+ import { resolveResourceTarget } from "../resource-target.js";
5
+ import { printSyncNotice, printSyncPlan, printSyncStatus, printSyncSummary } from "../sync-output.js";
6
+ import { readBoolFlag } from "../utils.js";
7
+ export async function handleJobTemplatesCommand(context) {
8
+ const subcommand = context.args._[1] || '';
9
+ if (!['pull', 'plan', 'push'].includes(subcommand))
10
+ throw new Error('Unknown job-templates command. Usage: revo job-templates <pull|plan|push> --all [--env <name>]');
11
+ if (!readBoolFlag(context.args, ['all', 'a']))
12
+ throw new Error('Job-template sync currently requires --all.');
13
+ const { client, envName, displayName } = await resolveResourceTarget(context, { resource: 'Job-template' });
14
+ if (subcommand === 'push') {
15
+ if (!readBoolFlag(context.args, ['yes', 'y'])) {
16
+ if (!isInteractiveTerminal() || !await promptConfirm(`Push job templates to "${displayName}"?`, false)) {
17
+ throw new Error('Job-template push requires confirmation. Re-run with --yes or use an interactive terminal.');
18
+ }
19
+ }
20
+ const startedAt = Date.now();
21
+ const result = await pushJobTemplates({
22
+ client,
23
+ cwd: context.cwd,
24
+ envName,
25
+ stableKeyName: readProjectStableKeyName(context.cwd),
26
+ force: readBoolFlag(context.args, ['force', 'f']),
27
+ });
28
+ if (readBoolFlag(context.args, ['json'])) {
29
+ context.print(result);
30
+ }
31
+ else {
32
+ for (const item of result.results) {
33
+ const label = item.status === 'deployed' ? 'Deployed' : item.status === 'failed' ? 'Failed' : 'Skipped';
34
+ printSyncStatus(context.println, {
35
+ status: label,
36
+ direction: 'push',
37
+ targetPath: item.targetPath,
38
+ reason: item.error || item.reason,
39
+ });
40
+ }
41
+ printSyncSummary(context.println, 'Deployed', result.results, Date.now() - startedAt);
42
+ }
43
+ const failed = result.results.filter((item) => item.status === 'failed');
44
+ if (failed.length > 0)
45
+ throw new Error(`Job-template push finished with ${failed.length} failure(s).`);
46
+ return;
47
+ }
48
+ if (subcommand === 'plan') {
49
+ const plan = await buildJobTemplatesPlan({
50
+ client,
51
+ cwd: context.cwd,
52
+ envName,
53
+ stableKeyName: readProjectStableKeyName(context.cwd),
54
+ });
55
+ if (readBoolFlag(context.args, ['json'])) {
56
+ context.print(plan);
57
+ }
58
+ else {
59
+ printSyncPlan(context.println, {
60
+ title: 'Job-template',
61
+ environment: displayName,
62
+ counts: plan.counts,
63
+ showHints: readBoolFlag(context.args, ['hints']),
64
+ items: plan.items.map((item) => ({
65
+ ...item,
66
+ hints: [
67
+ ...(item.componentStableKey ? [{ label: 'component', values: item.componentStableKey }] : []),
68
+ ...(item.dependencyReadiness ? [{ label: 'dependency', values: item.dependencyReadiness }] : []),
69
+ ],
70
+ })),
71
+ warnings: plan.warnings,
72
+ blockers: plan.blockers,
73
+ });
74
+ }
75
+ if (readBoolFlag(context.args, ['strict'])) {
76
+ const drift = plan.items.filter((item) => !['clean', 'orphan', 'skipped'].includes(item.status));
77
+ if (plan.blockers.length > 0 || drift.length > 0) {
78
+ throw new Error(`Job-template strict plan is not converged: ${drift.length} drift item(s), ${plan.blockers.length} blocker(s).`);
79
+ }
80
+ }
81
+ return;
82
+ }
83
+ const startedAt = Date.now();
84
+ const result = await pullJobTemplatesToWorkspace({
85
+ client,
86
+ cwd: context.cwd,
87
+ envName,
88
+ stableKeyName: readProjectStableKeyName(context.cwd),
89
+ force: readBoolFlag(context.args, ['force', 'f']),
90
+ });
91
+ if (readBoolFlag(context.args, ['json'])) {
92
+ context.print(result);
93
+ return;
94
+ }
95
+ const output = [];
96
+ for (const pulled of result.pulled) {
97
+ printSyncStatus(context.println, { status: 'Pulled', direction: 'pull', targetPath: pulled.targetPath });
98
+ output.push({ status: 'pulled', targetPath: pulled.targetPath });
99
+ }
100
+ for (const skipped of result.skipped) {
101
+ printSyncStatus(context.println, { status: 'Skipped', direction: 'pull', targetPath: skipped.targetPath, reason: skipped.reason });
102
+ output.push({ status: 'skipped', targetPath: skipped.targetPath, reason: skipped.reason });
103
+ }
104
+ for (const warning of result.warnings)
105
+ printSyncNotice(context.println, `${warning.stableKey}: ${warning.reason}`);
106
+ printSyncSummary(context.println, 'Pulled', output, Date.now() - startedAt);
107
+ }
@@ -1,5 +1,5 @@
1
1
  import { RevoClient } from "../client.js";
2
- import { DEFAULT_ENV_NAME, resolveRuntimeConfig } from "../config.js";
2
+ import { DEFAULT_ENV_NAME } from "../config.js";
3
3
  import { applyMetadataBackfillPlan, buildMetadataBackfillPlan, } from "../metadata-backfill.js";
4
4
  import { isInteractiveTerminal, promptConfirm } from "../prompt.js";
5
5
  import { readProjectStableKeyName, readProjectTrackedResources } from "../project.js";
@@ -35,7 +35,7 @@ function readTrackedResources(context) {
35
35
  : readProjectTrackedResources(context.cwd);
36
36
  }
37
37
  function buildEnvClient(envName) {
38
- return new RevoClient(resolveRuntimeConfig({ envName }));
38
+ return new RevoClient({ envName });
39
39
  }
40
40
  async function buildPlan(context) {
41
41
  const envName = readEnvName(context);
@@ -46,18 +46,79 @@ async function buildPlan(context) {
46
46
  stableKeyName: readStableKeyName(context),
47
47
  trackedResources: readTrackedResources(context),
48
48
  force: readBoolFlag(context.args, ['force']),
49
+ skipPartitions: readBoolFlag(context.args, ['skip-partitions', 'skipPartitions']),
49
50
  });
50
51
  }
51
52
  function printPlanText(context, plan) {
52
53
  const { println } = context;
53
54
  println(`Metadata backfill ${paint(plan.env, ANSI.bold + ANSI.cyan)} (${plan.stableKeyName})`);
54
- for (const item of plan.items) {
55
- if (item.action === 'skip') {
56
- continue;
55
+ if (plan.skipPartitions) {
56
+ println('Scope: root database schemas only (partitions skipped).');
57
+ }
58
+ const sortedItems = [...plan.items].sort((left, right) => [
59
+ left.resourceType,
60
+ left.category || '',
61
+ left.name,
62
+ left.resourceId,
63
+ left.metadataField,
64
+ left.columnName || '',
65
+ ].join('\0').localeCompare([
66
+ right.resourceType,
67
+ right.category || '',
68
+ right.name,
69
+ right.resourceId,
70
+ right.metadataField,
71
+ right.columnName || '',
72
+ ].join('\0')));
73
+ const assignedItems = sortedItems.filter((item) => item.action === 'skip' && item.stableKey);
74
+ const excludedItems = sortedItems.filter((item) => item.action === 'skip' && !item.stableKey);
75
+ const updateItems = sortedItems.filter((item) => item.action === 'update');
76
+ const blockedItems = sortedItems.filter((item) => item.action === 'blocked');
77
+ const printItems = (items) => {
78
+ for (const item of items) {
79
+ const reservedMetadataNotice = item.resourceType === 'group'
80
+ && item.reason.includes('backend-reserved metadata keys excluded')
81
+ ? ` (${item.reason})`
82
+ : '';
83
+ const resourceLabel = item.resourceKind === 'database-partition'
84
+ ? `${item.resourceType} partition ${item.name}${item.parentName ? ` (parent: ${item.parentName})` : ''}`
85
+ : item.resourceKind === 'database-column'
86
+ ? `${item.resourceType} column ${item.name}`
87
+ : `${item.resourceType} ${item.name}`;
88
+ if (item.action === 'skip') {
89
+ if (item.stableKey) {
90
+ println(`${paint('= assigned', ANSI.dim + ANSI.yellow)} ${resourceLabel} -> ${item.metadataField}.${item.stableKeyName}=${item.stableKey}${reservedMetadataNotice}`);
91
+ }
92
+ else {
93
+ println(`${paint('- excluded', ANSI.dim + ANSI.yellow)} ${resourceLabel} (${item.reason})`);
94
+ }
95
+ continue;
96
+ }
97
+ if (item.action === 'blocked') {
98
+ println(`${paint('! blocked', ANSI.bold + ANSI.red)} ${resourceLabel} -> ${item.metadataField}.${item.stableKeyName}=${item.stableKey} (${item.reason})`);
99
+ continue;
100
+ }
101
+ println(`${paint('+ update', ANSI.bold + ANSI.green)} ${resourceLabel} -> ${item.metadataField}.${item.stableKeyName}=${item.stableKey}${reservedMetadataNotice}`);
57
102
  }
58
- println(`${paint('+ update', ANSI.bold + ANSI.green)} ${item.resourceType} ${item.name} -> ${item.metadataField}.${item.stableKeyName}=${item.stableKey}`);
103
+ };
104
+ println(`Assigned Stable Keys (${assignedItems.length})`);
105
+ printItems(assignedItems);
106
+ println(`Stable Keys to update (${updateItems.length})`);
107
+ printItems(updateItems);
108
+ if (excludedItems.length > 0) {
109
+ println(`Excluded resources (${excludedItems.length})`);
110
+ printItems(excludedItems);
111
+ }
112
+ if (blockedItems.length > 0) {
113
+ println(`Blocked Stable Keys (${blockedItems.length})`);
114
+ printItems(blockedItems);
115
+ }
116
+ println(`Plan: ${updateItems.length} to update, ${assignedItems.length} assigned, ${excludedItems.length} excluded, ${blockedItems.length} blocked.`);
117
+ }
118
+ function assertNoPlanBlockers(plan) {
119
+ if (plan.blockers.length > 0) {
120
+ throw new Error(`Metadata plan has ${plan.blockers.length} blocking validation error(s).`);
59
121
  }
60
- println(`Plan: ${plan.counts.update} to update, ${plan.counts.skip} already populated.`);
61
122
  }
62
123
  function printResult(context, result) {
63
124
  const { println } = context;
@@ -88,15 +149,18 @@ async function handleMetadataPlan(context) {
88
149
  const plan = await buildPlan(context);
89
150
  if (readBoolFlag(context.args, ['json'])) {
90
151
  context.print(plan);
91
- return;
92
152
  }
93
- printPlanText(context, plan);
153
+ else {
154
+ printPlanText(context, plan);
155
+ }
156
+ assertNoPlanBlockers(plan);
94
157
  }
95
158
  async function handleMetadataApply(context) {
96
159
  const plan = await buildPlan(context);
97
160
  if (!readBoolFlag(context.args, ['json'])) {
98
161
  printPlanText(context, plan);
99
162
  }
163
+ assertNoPlanBlockers(plan);
100
164
  if (!await confirmApply(context, plan)) {
101
165
  if (readBoolFlag(context.args, ['json'])) {
102
166
  context.print({ plan, results: [] });
@@ -107,6 +171,7 @@ async function handleMetadataApply(context) {
107
171
  return;
108
172
  }
109
173
  const client = buildEnvClient(plan.env);
174
+ await client.validateSession();
110
175
  const results = await applyMetadataBackfillPlan({ client, plan });
111
176
  if (readBoolFlag(context.args, ['json'])) {
112
177
  context.print({ plan, results });
@@ -133,5 +198,5 @@ export async function handleMetadataCommand(context) {
133
198
  await handleMetadataApply(context);
134
199
  return;
135
200
  }
136
- throw new Error('Unknown metadata command. Usage: revo metadata <plan|apply> --env <name>');
201
+ throw new Error('Unknown metadata command. Usage: revo metadata <plan|apply> --project <name>');
137
202
  }
@@ -0,0 +1,6 @@
1
+ import type { CommandContext } from '../types.ts';
2
+ export declare function handleDiffCommand(context: CommandContext): Promise<void>;
3
+ export declare function handlePlanCommand(context: CommandContext): Promise<void>;
4
+ export declare function handlePullCommand(context: CommandContext): Promise<void>;
5
+ export declare function handleDeployCommand(context: CommandContext): Promise<void>;
6
+ export declare function handleMigrateCommand(context: CommandContext): Promise<void>;