@revoengine/cli 1.0.17 → 1.0.19
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 +19 -7
- package/dist/src/client.d.ts +25 -4
- package/dist/src/client.js +1 -1
- package/dist/src/commands/component.js +25 -0
- package/dist/src/commands/migrate.js +47 -173
- package/dist/src/migration-actions.d.ts +44 -0
- package/dist/src/migration-actions.js +211 -0
- package/dist/src/migration.d.ts +11 -10
- package/dist/src/migration.js +94 -217
- package/dist/src/project.js +1 -1
- package/dist/src/resource-syncs/endpoint-sync.d.ts +2 -0
- package/dist/src/resource-syncs/endpoint-sync.js +7 -0
- package/dist/src/resource-syncs/job-template-sync.d.ts +1 -0
- package/dist/src/resource-syncs/job-template-sync.js +31 -0
- package/dist/src/resource-syncs/service-account-sync.js +38 -3
- package/dist/src/types.d.ts +17 -0
- package/dist/src/ui.js +1 -1
- package/dist/src/workspace-prune.d.ts +2 -0
- package/dist/src/workspace-prune.js +85 -9
- package/package.json +2 -2
package/dist/src/migration.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { projectRepositoryItems, migrationItemOperation, BLOCKING_SCHEMA_STATUSES, schemaItemAction, viewItemIsBlocked, viewItemAction, componentItemAction, jobTemplateItemAction, endpointItemAction, scheduleItemAction, eventItemAction, groupItemAction, roleGroupItemAction, serviceAccountItemAction, } from "./migration-actions.js";
|
|
1
2
|
import fs from 'node:fs';
|
|
2
3
|
import { applyWorkspacePrune, buildWorkspacePrunePlan, samePrunePlan } from "./workspace-prune.js";
|
|
3
4
|
import { planIdentityMigration } from "./resource-syncs/identity-migration.js";
|
|
@@ -6,6 +7,7 @@ import os from 'node:os';
|
|
|
6
7
|
import path from 'node:path';
|
|
7
8
|
import { RevoClient } from "./client.js";
|
|
8
9
|
import { REVO_LOCK_FILE, readComponentLock } from "./component-lock.js";
|
|
10
|
+
import { normalizeStableKeyValue } from "./resource-metadata.js";
|
|
9
11
|
import { withHttpTraceContext } from "./http-trace.js";
|
|
10
12
|
import { buildComponentPlan, pullAllComponents, pushAllComponents, } from "./commands/component.js";
|
|
11
13
|
import { resolveRuntimeConfig } from "./config.js";
|
|
@@ -30,13 +32,6 @@ const RESOURCE_ORDER = [
|
|
|
30
32
|
'group',
|
|
31
33
|
'role-group',
|
|
32
34
|
];
|
|
33
|
-
const BLOCKING_SCHEMA_STATUSES = new Set([
|
|
34
|
-
'collision',
|
|
35
|
-
'manual-schema-migration-required',
|
|
36
|
-
'access-policy-required',
|
|
37
|
-
'previously-deleted-partition',
|
|
38
|
-
'replacement-requires-two-phases',
|
|
39
|
-
]);
|
|
40
35
|
function selectedResources(input) {
|
|
41
36
|
const requested = new Set(input.resources?.length ? input.resources : RESOURCE_ORDER);
|
|
42
37
|
return RESOURCE_ORDER.filter((resource) => requested.has(resource));
|
|
@@ -69,186 +64,6 @@ function viewMigrationPolicy(input, deferPreview = false) {
|
|
|
69
64
|
function emptyOperations() {
|
|
70
65
|
return { noop: 0, create: 0, update: 0, adopt: 0, excluded: 0, blocked: 0 };
|
|
71
66
|
}
|
|
72
|
-
function schemaItemAction(item) {
|
|
73
|
-
if (BLOCKING_SCHEMA_STATUSES.has(item.status)) {
|
|
74
|
-
return 'blocked';
|
|
75
|
-
}
|
|
76
|
-
if (item.status === 'create') {
|
|
77
|
-
return 'create';
|
|
78
|
-
}
|
|
79
|
-
if (item.status === 'safe-update' || item.status === 'remote-changed' || item.status === 'conflict') {
|
|
80
|
-
return 'update';
|
|
81
|
-
}
|
|
82
|
-
if (item.status === 'missing-lock') {
|
|
83
|
-
return item.desiredHash === item.currentHash ? 'adopt' : 'update';
|
|
84
|
-
}
|
|
85
|
-
if (item.status === 'reconciled') {
|
|
86
|
-
return 'adopt';
|
|
87
|
-
}
|
|
88
|
-
if (item.status === 'orphan-root'
|
|
89
|
-
|| item.status === 'orphan-partition'
|
|
90
|
-
|| item.status === 'delete-partition'
|
|
91
|
-
|| item.status === 'unmanaged') {
|
|
92
|
-
return 'excluded';
|
|
93
|
-
}
|
|
94
|
-
return 'noop';
|
|
95
|
-
}
|
|
96
|
-
function viewItemIsBlocked(item) {
|
|
97
|
-
return item.status === 'collision'
|
|
98
|
-
|| item.status === 'validation-failed'
|
|
99
|
-
|| (item.status === 'conflict' && Boolean(item.reason));
|
|
100
|
-
}
|
|
101
|
-
function viewItemAction(item) {
|
|
102
|
-
if (viewItemIsBlocked(item)) {
|
|
103
|
-
return 'blocked';
|
|
104
|
-
}
|
|
105
|
-
if (item.status === 'create') {
|
|
106
|
-
return 'create';
|
|
107
|
-
}
|
|
108
|
-
if (item.status === 'safe-update' || item.status === 'remote-changed' || item.status === 'conflict') {
|
|
109
|
-
return 'update';
|
|
110
|
-
}
|
|
111
|
-
if (item.status === 'missing-lock') {
|
|
112
|
-
return item.desiredHash === item.currentHash ? 'adopt' : 'update';
|
|
113
|
-
}
|
|
114
|
-
if (item.status === 'orphan' || item.status === 'skipped') {
|
|
115
|
-
return 'excluded';
|
|
116
|
-
}
|
|
117
|
-
return 'noop';
|
|
118
|
-
}
|
|
119
|
-
function componentItemAction(item) {
|
|
120
|
-
if (item.blocked === true || item.status === 'blocked') {
|
|
121
|
-
return 'blocked';
|
|
122
|
-
}
|
|
123
|
-
if (item.status === 'clean'
|
|
124
|
-
&& item.lockHash === null
|
|
125
|
-
&& item.localHash !== null
|
|
126
|
-
&& item.localHash === item.remoteHash) {
|
|
127
|
-
return 'adopt';
|
|
128
|
-
}
|
|
129
|
-
if (item.status === 'create') {
|
|
130
|
-
return 'create';
|
|
131
|
-
}
|
|
132
|
-
if (item.status === 'local-changed'
|
|
133
|
-
|| item.status === 'remote-changed'
|
|
134
|
-
|| item.status === 'conflict'
|
|
135
|
-
|| item.status === 'missing-lock') {
|
|
136
|
-
return 'update';
|
|
137
|
-
}
|
|
138
|
-
if (item.status === 'safe-update') {
|
|
139
|
-
return 'excluded';
|
|
140
|
-
}
|
|
141
|
-
return 'noop';
|
|
142
|
-
}
|
|
143
|
-
function jobTemplateItemAction(item) {
|
|
144
|
-
if (item.status === 'collision' || (item.status === 'conflict' && !item.desiredHash)) {
|
|
145
|
-
return 'blocked';
|
|
146
|
-
}
|
|
147
|
-
if (item.status === 'create') {
|
|
148
|
-
return 'create';
|
|
149
|
-
}
|
|
150
|
-
if (item.status === 'safe-update' || item.status === 'remote-changed' || item.status === 'conflict') {
|
|
151
|
-
return 'update';
|
|
152
|
-
}
|
|
153
|
-
if (item.status === 'missing-lock') {
|
|
154
|
-
return item.desiredHash === item.currentHash ? 'adopt' : 'update';
|
|
155
|
-
}
|
|
156
|
-
if (item.status === 'orphan' || item.status === 'skipped') {
|
|
157
|
-
return 'excluded';
|
|
158
|
-
}
|
|
159
|
-
return 'noop';
|
|
160
|
-
}
|
|
161
|
-
function endpointItemAction(item) {
|
|
162
|
-
if (item.status === 'restore-blocked' || item.status === 'collision') {
|
|
163
|
-
return 'blocked';
|
|
164
|
-
}
|
|
165
|
-
if (item.status === 'create') {
|
|
166
|
-
return 'create';
|
|
167
|
-
}
|
|
168
|
-
if (item.status === 'restore' || item.status === 'safe-update' || item.status === 'remote-changed' || item.status === 'conflict') {
|
|
169
|
-
return 'update';
|
|
170
|
-
}
|
|
171
|
-
if (item.status === 'missing-lock') {
|
|
172
|
-
return item.desiredHash === item.currentHash ? 'adopt' : 'update';
|
|
173
|
-
}
|
|
174
|
-
if (item.status === 'orphan' || item.status === 'skipped') {
|
|
175
|
-
return 'excluded';
|
|
176
|
-
}
|
|
177
|
-
return 'noop';
|
|
178
|
-
}
|
|
179
|
-
function scheduleItemAction(item) {
|
|
180
|
-
if (item.blocked === true || item.status === 'collision') {
|
|
181
|
-
return 'blocked';
|
|
182
|
-
}
|
|
183
|
-
if (item.status === 'create') {
|
|
184
|
-
return 'create';
|
|
185
|
-
}
|
|
186
|
-
if (item.status === 'safe-update' || item.status === 'remote-changed' || item.status === 'conflict') {
|
|
187
|
-
return 'update';
|
|
188
|
-
}
|
|
189
|
-
if (item.status === 'missing-lock') {
|
|
190
|
-
return item.desiredHash === item.currentHash ? 'adopt' : 'update';
|
|
191
|
-
}
|
|
192
|
-
if (item.status === 'orphan' || item.status === 'skipped') {
|
|
193
|
-
return 'excluded';
|
|
194
|
-
}
|
|
195
|
-
return 'noop';
|
|
196
|
-
}
|
|
197
|
-
function eventItemAction(item) {
|
|
198
|
-
if (item.blocked === true || item.status === 'collision') {
|
|
199
|
-
return 'blocked';
|
|
200
|
-
}
|
|
201
|
-
if (item.status === 'create') {
|
|
202
|
-
return 'create';
|
|
203
|
-
}
|
|
204
|
-
if (item.status === 'safe-update' || item.status === 'remote-changed' || item.status === 'conflict') {
|
|
205
|
-
return 'update';
|
|
206
|
-
}
|
|
207
|
-
if (item.status === 'missing-lock') {
|
|
208
|
-
return item.desiredHash === item.currentHash ? 'adopt' : 'update';
|
|
209
|
-
}
|
|
210
|
-
if (item.status === 'orphan' || item.status === 'skipped' || item.status === 'activation-drift') {
|
|
211
|
-
return 'excluded';
|
|
212
|
-
}
|
|
213
|
-
return 'noop';
|
|
214
|
-
}
|
|
215
|
-
function groupItemAction(item) {
|
|
216
|
-
if (item.status === 'collision'
|
|
217
|
-
|| ((item.status === 'conflict' || item.status === 'missing-lock') && !item.currentHash)) {
|
|
218
|
-
return 'blocked';
|
|
219
|
-
}
|
|
220
|
-
if (item.status === 'create') {
|
|
221
|
-
return 'create';
|
|
222
|
-
}
|
|
223
|
-
if (item.status === 'safe-update' || item.status === 'remote-changed' || item.status === 'conflict') {
|
|
224
|
-
return 'update';
|
|
225
|
-
}
|
|
226
|
-
if (item.status === 'missing-lock') {
|
|
227
|
-
return item.desiredHash === item.currentHash ? 'adopt' : 'update';
|
|
228
|
-
}
|
|
229
|
-
if (item.status === 'manual-owner' || item.status === 'orphan' || item.status === 'skipped') {
|
|
230
|
-
return 'excluded';
|
|
231
|
-
}
|
|
232
|
-
return 'noop';
|
|
233
|
-
}
|
|
234
|
-
function roleGroupItemAction(item) {
|
|
235
|
-
if (item.status === 'collision' || (item.status === 'conflict' && !item.currentHash)) {
|
|
236
|
-
return 'blocked';
|
|
237
|
-
}
|
|
238
|
-
if (item.status === 'create') {
|
|
239
|
-
return 'create';
|
|
240
|
-
}
|
|
241
|
-
if (item.status === 'safe-update' || item.status === 'remote-changed' || item.status === 'conflict') {
|
|
242
|
-
return 'update';
|
|
243
|
-
}
|
|
244
|
-
if (item.status === 'missing-lock') {
|
|
245
|
-
return item.desiredHash === item.currentHash ? 'adopt' : 'update';
|
|
246
|
-
}
|
|
247
|
-
if (item.status === 'orphan' || item.status === 'skipped') {
|
|
248
|
-
return 'excluded';
|
|
249
|
-
}
|
|
250
|
-
return 'noop';
|
|
251
|
-
}
|
|
252
67
|
function phaseVerdict(blockers, warnings) {
|
|
253
68
|
if (blockers.length > 0) {
|
|
254
69
|
return 'blocked';
|
|
@@ -258,7 +73,7 @@ function phaseVerdict(blockers, warnings) {
|
|
|
258
73
|
function summarizeSchemaPhase(plan) {
|
|
259
74
|
const operations = emptyOperations();
|
|
260
75
|
for (const item of plan.items) {
|
|
261
|
-
operations[schemaItemAction(item)] += 1;
|
|
76
|
+
operations[migrationItemOperation(item, schemaItemAction(item))] += 1;
|
|
262
77
|
}
|
|
263
78
|
const itemBlockers = plan.items
|
|
264
79
|
.filter((item) => BLOCKING_SCHEMA_STATUSES.has(item.status) && Boolean(item.desiredHash))
|
|
@@ -282,7 +97,7 @@ function summarizeSchemaPhase(plan) {
|
|
|
282
97
|
function summarizeViewPhase(plan) {
|
|
283
98
|
const operations = emptyOperations();
|
|
284
99
|
for (const item of plan.items) {
|
|
285
|
-
operations[viewItemAction(item)] += 1;
|
|
100
|
+
operations[migrationItemOperation(item, viewItemAction(item))] += 1;
|
|
286
101
|
}
|
|
287
102
|
const itemBlockers = plan.items.flatMap((item) => {
|
|
288
103
|
const identity = item.stableKey || item.name;
|
|
@@ -318,7 +133,7 @@ function summarizeViewPhase(plan) {
|
|
|
318
133
|
function summarizeComponentPhase(plan) {
|
|
319
134
|
const operations = emptyOperations();
|
|
320
135
|
for (const item of plan.items) {
|
|
321
|
-
operations[componentItemAction(item)] += 1;
|
|
136
|
+
operations[migrationItemOperation(item, componentItemAction(item))] += 1;
|
|
322
137
|
}
|
|
323
138
|
const warnings = [...new Set([
|
|
324
139
|
...(plan.unmanaged.local > 0
|
|
@@ -334,7 +149,7 @@ function summarizeComponentPhase(plan) {
|
|
|
334
149
|
.filter((item) => item.status === 'remote-changed' || item.status === 'conflict')
|
|
335
150
|
.map((item) => `Component "${item.stableKey || item.componentName}" has target drift; source-wins migration will overwrite its portable definition.`),
|
|
336
151
|
...plan.items
|
|
337
|
-
.filter((item) => item.status === 'missing-lock')
|
|
152
|
+
.filter((item) => item.status === 'missing-lock' && migrationItemOperation(item, componentItemAction(item)) !== 'noop')
|
|
338
153
|
.map((item) => `Component "${item.stableKey || item.componentName}" has no target lock baseline; source-wins migration will align and verify it.`),
|
|
339
154
|
])];
|
|
340
155
|
const blockers = [...new Set(plan.blockers)];
|
|
@@ -352,7 +167,7 @@ function summarizeComponentPhase(plan) {
|
|
|
352
167
|
function summarizeJobTemplatePhase(plan) {
|
|
353
168
|
const operations = emptyOperations();
|
|
354
169
|
for (const item of plan.items) {
|
|
355
|
-
operations[jobTemplateItemAction(item)] += 1;
|
|
170
|
+
operations[migrationItemOperation(item, jobTemplateItemAction(item))] += 1;
|
|
356
171
|
}
|
|
357
172
|
const warnings = [...new Set([
|
|
358
173
|
...plan.warnings,
|
|
@@ -361,7 +176,7 @@ function summarizeJobTemplatePhase(plan) {
|
|
|
361
176
|
.filter((item) => item.status === 'remote-changed' || (item.status === 'conflict' && Boolean(item.desiredHash)))
|
|
362
177
|
.map((item) => `Job Template "${item.stableKey || item.name}" has target drift; source-wins migration will overwrite its portable definition.`),
|
|
363
178
|
...plan.items
|
|
364
|
-
.filter((item) => item.status === 'missing-lock')
|
|
179
|
+
.filter((item) => item.status === 'missing-lock' && migrationItemOperation(item, jobTemplateItemAction(item)) !== 'noop')
|
|
365
180
|
.map((item) => `Job Template "${item.stableKey || item.name}" has no target lock baseline; source-wins migration will align or adopt it.`),
|
|
366
181
|
])];
|
|
367
182
|
const blockers = [...new Set(plan.blockers)];
|
|
@@ -379,7 +194,7 @@ function summarizeJobTemplatePhase(plan) {
|
|
|
379
194
|
function summarizeEndpointPhase(plan) {
|
|
380
195
|
const operations = emptyOperations();
|
|
381
196
|
for (const item of plan.items) {
|
|
382
|
-
operations[endpointItemAction(item)] += 1;
|
|
197
|
+
operations[migrationItemOperation(item, endpointItemAction(item))] += 1;
|
|
383
198
|
}
|
|
384
199
|
const warnings = [...new Set([
|
|
385
200
|
...plan.warnings,
|
|
@@ -388,7 +203,7 @@ function summarizeEndpointPhase(plan) {
|
|
|
388
203
|
.filter((item) => item.status === 'remote-changed' || item.status === 'conflict')
|
|
389
204
|
.map((item) => `Endpoint "${item.stableKey || item.name}" has target drift; source-wins migration will overwrite its portable definition.`),
|
|
390
205
|
...plan.items
|
|
391
|
-
.filter((item) => item.status === 'missing-lock')
|
|
206
|
+
.filter((item) => item.status === 'missing-lock' && migrationItemOperation(item, endpointItemAction(item)) !== 'noop')
|
|
392
207
|
.map((item) => `Endpoint "${item.stableKey || item.name}" has no target lock baseline; source-wins migration will align or adopt it.`),
|
|
393
208
|
])];
|
|
394
209
|
const blockers = [...new Set(plan.blockers)];
|
|
@@ -406,7 +221,7 @@ function summarizeEndpointPhase(plan) {
|
|
|
406
221
|
function summarizeSchedulePhase(plan) {
|
|
407
222
|
const operations = emptyOperations();
|
|
408
223
|
for (const item of plan.items) {
|
|
409
|
-
operations[scheduleItemAction(item)] += 1;
|
|
224
|
+
operations[migrationItemOperation(item, scheduleItemAction(item))] += 1;
|
|
410
225
|
}
|
|
411
226
|
const warnings = [...new Set([
|
|
412
227
|
...plan.warnings,
|
|
@@ -415,7 +230,7 @@ function summarizeSchedulePhase(plan) {
|
|
|
415
230
|
.filter((item) => item.status === 'remote-changed' || (item.status === 'conflict' && item.blocked !== true))
|
|
416
231
|
.map((item) => `Schedule "${item.stableKey || item.name}" has target drift; source-wins migration will overwrite its portable definition.`),
|
|
417
232
|
...plan.items
|
|
418
|
-
.filter((item) => item.status === 'missing-lock')
|
|
233
|
+
.filter((item) => item.status === 'missing-lock' && migrationItemOperation(item, scheduleItemAction(item)) !== 'noop')
|
|
419
234
|
.map((item) => `Schedule "${item.stableKey || item.name}" has no target lock baseline; source-wins migration will align or adopt it.`),
|
|
420
235
|
])];
|
|
421
236
|
const blockers = [...new Set(plan.blockers)];
|
|
@@ -433,7 +248,7 @@ function summarizeSchedulePhase(plan) {
|
|
|
433
248
|
function summarizeEventPhase(plan) {
|
|
434
249
|
const operations = emptyOperations();
|
|
435
250
|
for (const item of plan.items) {
|
|
436
|
-
operations[eventItemAction(item)] += 1;
|
|
251
|
+
operations[migrationItemOperation(item, eventItemAction(item))] += 1;
|
|
437
252
|
}
|
|
438
253
|
const warnings = [...new Set([
|
|
439
254
|
...plan.warnings,
|
|
@@ -442,7 +257,7 @@ function summarizeEventPhase(plan) {
|
|
|
442
257
|
.filter((item) => item.status === 'remote-changed' || (item.status === 'conflict' && item.blocked !== true))
|
|
443
258
|
.map((item) => `Event "${item.stableKey || item.name}" has target drift; source-wins migration will overwrite its portable definition.`),
|
|
444
259
|
...plan.items
|
|
445
|
-
.filter((item) => item.status === 'missing-lock')
|
|
260
|
+
.filter((item) => item.status === 'missing-lock' && migrationItemOperation(item, eventItemAction(item)) !== 'noop')
|
|
446
261
|
.map((item) => `Event "${item.stableKey || item.name}" has no target lock baseline; source-wins migration will align or adopt it.`),
|
|
447
262
|
...plan.items
|
|
448
263
|
.filter((item) => item.status === 'activation-drift')
|
|
@@ -463,7 +278,7 @@ function summarizeEventPhase(plan) {
|
|
|
463
278
|
function summarizeGroupPhase(plan) {
|
|
464
279
|
const operations = emptyOperations();
|
|
465
280
|
for (const item of plan.items) {
|
|
466
|
-
operations[groupItemAction(item)] += 1;
|
|
281
|
+
operations[migrationItemOperation(item, groupItemAction(item))] += 1;
|
|
467
282
|
}
|
|
468
283
|
const warnings = [...new Set([
|
|
469
284
|
...plan.warnings,
|
|
@@ -475,7 +290,7 @@ function summarizeGroupPhase(plan) {
|
|
|
475
290
|
.filter((item) => item.status === 'remote-changed' || (item.status === 'conflict' && Boolean(item.currentHash)))
|
|
476
291
|
.map((item) => `Group "${item.stableKey || item.name}" has target drift; source-wins migration will overwrite its portable definition.`),
|
|
477
292
|
...plan.items
|
|
478
|
-
.filter((item) => item.status === 'missing-lock' && Boolean(item.currentHash))
|
|
293
|
+
.filter((item) => item.status === 'missing-lock' && Boolean(item.currentHash) && migrationItemOperation(item, groupItemAction(item)) !== 'noop')
|
|
479
294
|
.map((item) => `Group "${item.stableKey || item.name}" has no target lock baseline; source-wins migration will align or adopt it.`),
|
|
480
295
|
])];
|
|
481
296
|
const blockers = [...new Set(plan.blockers)];
|
|
@@ -490,16 +305,10 @@ function summarizeGroupPhase(plan) {
|
|
|
490
305
|
blockers,
|
|
491
306
|
};
|
|
492
307
|
}
|
|
493
|
-
function serviceAccountItemAction(item) {
|
|
494
|
-
if (item.status === 'manual-owner') {
|
|
495
|
-
return 'excluded';
|
|
496
|
-
}
|
|
497
|
-
return roleGroupItemAction({ ...item, status: item.status });
|
|
498
|
-
}
|
|
499
308
|
function summarizeServiceAccountPhase(plan) {
|
|
500
309
|
const operations = emptyOperations();
|
|
501
310
|
for (const item of plan.items) {
|
|
502
|
-
operations[serviceAccountItemAction(item)] += 1;
|
|
311
|
+
operations[migrationItemOperation(item, serviceAccountItemAction(item))] += 1;
|
|
503
312
|
}
|
|
504
313
|
const warnings = [...plan.exclusions,
|
|
505
314
|
...plan.items.filter((item) => item.status === 'manual-owner').map((item) => `Service account "${item.stableKey}": ${item.reason}.`),
|
|
@@ -511,7 +320,7 @@ function summarizeServiceAccountPhase(plan) {
|
|
|
511
320
|
function summarizeRoleGroupPhase(plan) {
|
|
512
321
|
const operations = emptyOperations();
|
|
513
322
|
for (const item of plan.items) {
|
|
514
|
-
operations[roleGroupItemAction(item)] += 1;
|
|
323
|
+
operations[migrationItemOperation(item, roleGroupItemAction(item))] += 1;
|
|
515
324
|
}
|
|
516
325
|
const warnings = [...new Set([
|
|
517
326
|
...plan.exclusions.map((exclusion) => `Excluded: ${exclusion}.`),
|
|
@@ -522,7 +331,7 @@ function summarizeRoleGroupPhase(plan) {
|
|
|
522
331
|
.filter((item) => item.status === 'remote-changed' || (item.status === 'conflict' && Boolean(item.currentHash)))
|
|
523
332
|
.map((item) => `Role Group "${item.stableKey || item.name}" has target drift; the final source-wins phase will overwrite its portable definition and role assignments.`),
|
|
524
333
|
...plan.items
|
|
525
|
-
.filter((item) => item.status === 'missing-lock')
|
|
334
|
+
.filter((item) => item.status === 'missing-lock' && migrationItemOperation(item, roleGroupItemAction(item)) !== 'noop')
|
|
526
335
|
.map((item) => `Role Group "${item.stableKey || item.name}" has no target lock baseline; the final phase will align or adopt it.`),
|
|
527
336
|
])];
|
|
528
337
|
const blockers = [...new Set(plan.blockers)];
|
|
@@ -622,6 +431,7 @@ function applyWorkspaceDeploymentPolicy(input, phase, plans) {
|
|
|
622
431
|
for (const item of plans.databaseSchemas.items.filter((candidate) => candidate.status === 'delete-partition')) {
|
|
623
432
|
const operation = {
|
|
624
433
|
from: 'excluded',
|
|
434
|
+
item,
|
|
625
435
|
message: `Database partition "${item.stableKey || item.name}" was previously managed and removed from the repository; deletion requires --force.`,
|
|
626
436
|
};
|
|
627
437
|
gates.push(operation);
|
|
@@ -635,6 +445,7 @@ function applyWorkspaceDeploymentPolicy(input, phase, plans) {
|
|
|
635
445
|
if ((action === 'create' || action === 'update') && (item.databaseViewStableKey || targetTypeTransition)) {
|
|
636
446
|
gates.push({
|
|
637
447
|
from: action,
|
|
448
|
+
item,
|
|
638
449
|
message: targetTypeTransition
|
|
639
450
|
? `Schedule "${item.stableKey || item.name}" target type transition requires --force for repository deployment.`
|
|
640
451
|
: `Materialized View Schedule "${item.stableKey || item.name}" requires --force for repository deployment.`,
|
|
@@ -648,6 +459,7 @@ function applyWorkspaceDeploymentPolicy(input, phase, plans) {
|
|
|
648
459
|
if (action === 'create' || action === 'update') {
|
|
649
460
|
gates.push({
|
|
650
461
|
from: action,
|
|
462
|
+
item,
|
|
651
463
|
message: `Group "${item.stableKey || item.name}" can change environment access and requires --force for repository deployment.`,
|
|
652
464
|
});
|
|
653
465
|
}
|
|
@@ -659,6 +471,7 @@ function applyWorkspaceDeploymentPolicy(input, phase, plans) {
|
|
|
659
471
|
if (action === 'create' || action === 'update') {
|
|
660
472
|
gates.push({
|
|
661
473
|
from: action,
|
|
474
|
+
item,
|
|
662
475
|
message: `Service Account "${item.stableKey || item.name}" can change environment access and requires --force for repository deployment.`,
|
|
663
476
|
});
|
|
664
477
|
}
|
|
@@ -670,6 +483,7 @@ function applyWorkspaceDeploymentPolicy(input, phase, plans) {
|
|
|
670
483
|
if (action === 'create' || action === 'update') {
|
|
671
484
|
gates.push({
|
|
672
485
|
from: action,
|
|
486
|
+
item,
|
|
673
487
|
message: `Role Group "${item.stableKey || item.name}" can change environment authorization and requires --force for repository deployment.`,
|
|
674
488
|
});
|
|
675
489
|
}
|
|
@@ -680,6 +494,9 @@ function applyWorkspaceDeploymentPolicy(input, phase, plans) {
|
|
|
680
494
|
for (const operation of forceOperations) {
|
|
681
495
|
operations[operation.from] = Math.max(0, (operations[operation.from] || 0) - 1);
|
|
682
496
|
operations.update += 1;
|
|
497
|
+
if (operation.item.operation !== undefined) {
|
|
498
|
+
operation.item.operation = 'update';
|
|
499
|
+
}
|
|
683
500
|
}
|
|
684
501
|
return {
|
|
685
502
|
...phase,
|
|
@@ -693,6 +510,9 @@ function applyWorkspaceDeploymentPolicy(input, phase, plans) {
|
|
|
693
510
|
for (const gate of gates) {
|
|
694
511
|
operations[gate.from] = Math.max(0, (operations[gate.from] || 0) - 1);
|
|
695
512
|
operations.blocked += 1;
|
|
513
|
+
if (gate.item.operation !== undefined) {
|
|
514
|
+
gate.item.operation = 'blocked';
|
|
515
|
+
}
|
|
696
516
|
}
|
|
697
517
|
const blockers = [...new Set([...phase.blockers, ...gates.map((gate) => gate.message)])];
|
|
698
518
|
return {
|
|
@@ -705,6 +525,44 @@ function applyWorkspaceDeploymentPolicy(input, phase, plans) {
|
|
|
705
525
|
};
|
|
706
526
|
}
|
|
707
527
|
function combinePlan(input) {
|
|
528
|
+
if (input.migrationInput.sourceMode === 'workspace') {
|
|
529
|
+
const lock = readComponentLock(requireProject(input.migrationInput).projectRoot);
|
|
530
|
+
const environment = targetKey(input.migrationInput);
|
|
531
|
+
const baselineByKey = (entries, normalize = (key) => key) => {
|
|
532
|
+
const baselines = new Map(Object.values(entries).map((entry) => [normalize(entry.stableKey), entry.environments[environment]?.remoteHash]));
|
|
533
|
+
return (item) => item.stableKey ? baselines.get(normalize(item.stableKey)) : undefined;
|
|
534
|
+
};
|
|
535
|
+
if (input.databaseSchemas) {
|
|
536
|
+
input.databaseSchemas = { ...input.databaseSchemas, items: projectRepositoryItems(input.databaseSchemas.items, schemaItemAction, (item) => item.stableKey ? lock.databaseSchemas[item.stableKey]?.environments[environment]?.remoteHash : undefined) };
|
|
537
|
+
}
|
|
538
|
+
if (input.databaseViews) {
|
|
539
|
+
input.databaseViews = { ...input.databaseViews, items: projectRepositoryItems(input.databaseViews.items, viewItemAction, (item) => item.stableKey ? lock.databaseViews[item.stableKey]?.environments[environment]?.remoteHash : undefined) };
|
|
540
|
+
}
|
|
541
|
+
if (input.components) {
|
|
542
|
+
input.components = { ...input.components, items: projectRepositoryItems(input.components.items, componentItemAction, (item) => item.lockHash) };
|
|
543
|
+
}
|
|
544
|
+
if (input.serviceAccounts) {
|
|
545
|
+
input.serviceAccounts = { ...input.serviceAccounts, items: projectRepositoryItems(input.serviceAccounts.items, serviceAccountItemAction, baselineByKey(lock.serviceAccounts)) };
|
|
546
|
+
}
|
|
547
|
+
if (input.jobTemplates) {
|
|
548
|
+
input.jobTemplates = { ...input.jobTemplates, items: projectRepositoryItems(input.jobTemplates.items, jobTemplateItemAction, baselineByKey(lock.jobTemplates)) };
|
|
549
|
+
}
|
|
550
|
+
if (input.endpoints) {
|
|
551
|
+
input.endpoints = { ...input.endpoints, items: projectRepositoryItems(input.endpoints.items, endpointItemAction, (item) => item.stableKey ? lock.endpoints[item.stableKey]?.environments[environment]?.remoteHash : undefined) };
|
|
552
|
+
}
|
|
553
|
+
if (input.schedules) {
|
|
554
|
+
input.schedules = { ...input.schedules, items: projectRepositoryItems(input.schedules.items, scheduleItemAction, (item) => item.stableKey ? lock.schedules[item.stableKey]?.environments[environment]?.remoteHash : undefined) };
|
|
555
|
+
}
|
|
556
|
+
if (input.events) {
|
|
557
|
+
input.events = { ...input.events, items: projectRepositoryItems(input.events.items, eventItemAction, (item) => item.stableKey ? lock.events[item.stableKey]?.environments[environment]?.remoteHash : undefined) };
|
|
558
|
+
}
|
|
559
|
+
if (input.groups) {
|
|
560
|
+
input.groups = { ...input.groups, items: projectRepositoryItems(input.groups.items, groupItemAction, baselineByKey(lock.groups)) };
|
|
561
|
+
}
|
|
562
|
+
if (input.roleGroups) {
|
|
563
|
+
input.roleGroups = { ...input.roleGroups, items: projectRepositoryItems(input.roleGroups.items, roleGroupItemAction, baselineByKey(lock.roleGroups, normalizeStableKeyValue)) };
|
|
564
|
+
}
|
|
565
|
+
}
|
|
708
566
|
const phases = [
|
|
709
567
|
...(input.databaseSchemas ? [summarizeSchemaPhase(input.databaseSchemas)] : []),
|
|
710
568
|
...(input.databaseViews ? [summarizeViewPhase(input.databaseViews)] : []),
|
|
@@ -1178,6 +1036,9 @@ async function planWorkspace(input) {
|
|
|
1178
1036
|
}), undefined, input.detailedDiff === true))
|
|
1179
1037
|
: undefined;
|
|
1180
1038
|
const identities = await planIdentityMigration({ client, cwd: input.cwd, stableKeyName, resources });
|
|
1039
|
+
if (input.prune && input.sourceMode !== 'workspace')
|
|
1040
|
+
throw new Error('Prune requires repository plan/deploy; named migration remains upsert-only.');
|
|
1041
|
+
const prune = input.prune ? await buildWorkspacePrunePlan({ cwd: input.cwd, client, resources }) : undefined;
|
|
1181
1042
|
const serviceAccounts = resources.includes('service-account')
|
|
1182
1043
|
? await runMigrationStage('target plan', 'service-account', environmentLabel, () => buildServiceAccountsPlan({ client, cwd: input.cwd, envName: environmentKey, stableKeyName,
|
|
1183
1044
|
projectedIdentities: identities?.projection })) : undefined;
|
|
@@ -1191,6 +1052,7 @@ async function planWorkspace(input) {
|
|
|
1191
1052
|
envName: environmentKey,
|
|
1192
1053
|
stableKeyName,
|
|
1193
1054
|
projectedServiceAccounts: identities?.projection.serviceAccounts,
|
|
1055
|
+
pruneBeforeUpsertIds: prune?.items.filter((item) => item.resource === 'job-template' && item.beforeUpserts).map((item) => item.targetId),
|
|
1194
1056
|
...(input.projectDependencies === true && components
|
|
1195
1057
|
? { projectedComponents: projectedComponentDependencies(components) }
|
|
1196
1058
|
: {}),
|
|
@@ -1202,6 +1064,7 @@ async function planWorkspace(input) {
|
|
|
1202
1064
|
cwd: input.cwd,
|
|
1203
1065
|
envName: environmentKey,
|
|
1204
1066
|
stableKeyName,
|
|
1067
|
+
includeDependencyBlockers: input.sourceMode === 'workspace',
|
|
1205
1068
|
...(input.projectDependencies === true && components
|
|
1206
1069
|
? { projectedComponents: projectedComponentDependencies(components) }
|
|
1207
1070
|
: {}),
|
|
@@ -1270,10 +1133,8 @@ async function planWorkspace(input) {
|
|
|
1270
1133
|
if (identities) {
|
|
1271
1134
|
combined.identityOrder = identities.ordered.map(({ resource, stableKey }) => ({ resource, stableKey }));
|
|
1272
1135
|
}
|
|
1273
|
-
if (
|
|
1274
|
-
|
|
1275
|
-
throw new Error('Prune requires repository plan/deploy; named migration remains upsert-only.');
|
|
1276
|
-
combined.prune = await buildWorkspacePrunePlan({ cwd: input.cwd, client, resources });
|
|
1136
|
+
if (prune) {
|
|
1137
|
+
combined.prune = prune;
|
|
1277
1138
|
combined.pruneTargetKey = environmentKey;
|
|
1278
1139
|
combined.policy.mode = 'reconcile';
|
|
1279
1140
|
combined.operations.delete = combined.prune.items.length;
|
|
@@ -1282,7 +1143,13 @@ async function planWorkspace(input) {
|
|
|
1282
1143
|
const removed = Math.min(phase.operations.excluded, combined.prune.items.filter((item) => item.resource === phase.resource).length);
|
|
1283
1144
|
phase.operations.excluded -= removed;
|
|
1284
1145
|
combined.operations.excluded -= removed;
|
|
1146
|
+
phase.warnings = phase.warnings.filter((warning) => !/target-only/i.test(warning)
|
|
1147
|
+
|| !prune.items.some((item) => item.resource === phase.resource && warning.includes(`"${item.stableKey}"`)));
|
|
1285
1148
|
}
|
|
1149
|
+
combined.warnings = combined.warnings.filter((warning) => !/target-only/i.test(warning)
|
|
1150
|
+
|| !prune.items.some((item) => warning.includes(`"${item.stableKey}"`)));
|
|
1151
|
+
if (combined.jobTemplates)
|
|
1152
|
+
combined.jobTemplates.exclusions = combined.jobTemplates.exclusions.filter((exclusion) => !exclusion.includes('target-only orphans'));
|
|
1286
1153
|
combined.blockers = [...new Set([...combined.blockers, ...combined.prune.blockers])];
|
|
1287
1154
|
combined.readyToMigrate = combined.blockers.length === 0;
|
|
1288
1155
|
combined.needsChanges ||= combined.prune.items.length > 0;
|
|
@@ -1371,6 +1238,15 @@ export async function runMigration(input) {
|
|
|
1371
1238
|
const environmentKey = targetKey(input);
|
|
1372
1239
|
const phaseResults = {};
|
|
1373
1240
|
const results = [];
|
|
1241
|
+
let remainingPrune = initialPlan.prune;
|
|
1242
|
+
if (remainingPrune?.items.some((item) => item.beforeUpserts)) {
|
|
1243
|
+
const pruned = await applyWorkspacePrune({ cwd: input.cwd, client: targetClient,
|
|
1244
|
+
resources, envName: environmentKey, plan: remainingPrune, beforeUpsertsOnly: true });
|
|
1245
|
+
results.push(...pruned);
|
|
1246
|
+
if (!resultsAreComplete(pruned))
|
|
1247
|
+
return { ...base, verdict: 'failed', results, phaseResults };
|
|
1248
|
+
remainingPrune = { ...remainingPrune, items: remainingPrune.items.filter((item) => !item.beforeUpserts) };
|
|
1249
|
+
}
|
|
1374
1250
|
if (resources.includes('database-table')) {
|
|
1375
1251
|
const pushed = await pushDatabaseSchemas({
|
|
1376
1252
|
client: targetClient,
|
|
@@ -1558,6 +1434,7 @@ export async function runMigration(input) {
|
|
|
1558
1434
|
cwd: input.cwd,
|
|
1559
1435
|
envName: environmentKey,
|
|
1560
1436
|
stableKeyName,
|
|
1437
|
+
includeDependencyBlockers: input.sourceMode === 'workspace',
|
|
1561
1438
|
});
|
|
1562
1439
|
const liveEndpointPhase = summarizeEndpointPhase(liveEndpointPlan);
|
|
1563
1440
|
if (!liveEndpointPhase.readyToMigrate) {
|
|
@@ -1729,14 +1606,14 @@ export async function runMigration(input) {
|
|
|
1729
1606
|
return { ...base, verdict: 'failed', results, phaseResults, verification };
|
|
1730
1607
|
}
|
|
1731
1608
|
}
|
|
1732
|
-
if (
|
|
1609
|
+
if (remainingPrune) {
|
|
1733
1610
|
const fresh = await buildWorkspacePrunePlan({ cwd: input.cwd, client: targetClient, resources });
|
|
1734
|
-
if (!samePrunePlan(
|
|
1611
|
+
if (!samePrunePlan(remainingPrune, fresh)) {
|
|
1735
1612
|
results.push({ status: 'failed', targetPath: 'workspace prune', reason: 'Deletion plan changed during upserts; review a fresh plan.' });
|
|
1736
1613
|
return { ...base, verdict: 'failed', results, phaseResults };
|
|
1737
1614
|
}
|
|
1738
1615
|
const pruneResults = await applyWorkspacePrune({ cwd: input.cwd, client: targetClient,
|
|
1739
|
-
resources, envName: environmentKey, plan:
|
|
1616
|
+
resources, envName: environmentKey, plan: remainingPrune });
|
|
1740
1617
|
results.push(...pruneResults);
|
|
1741
1618
|
}
|
|
1742
1619
|
const verification = await planWorkspace({
|
package/dist/src/project.js
CHANGED
|
@@ -526,7 +526,7 @@ export function ensureProjectDebugScaffolding(rootDir) {
|
|
|
526
526
|
[path.join(rootDir, REVO_DEBUG_CONFIG_FILE), `${JSON.stringify({
|
|
527
527
|
timeout: 10,
|
|
528
528
|
memory: 128,
|
|
529
|
-
|
|
529
|
+
readOnly: true,
|
|
530
530
|
}, null, 2)}\n`],
|
|
531
531
|
[path.join(rootDir, REVO_PLAYGROUND_JS_FILE), ''],
|
|
532
532
|
[path.join(rootDir, REVO_PLAYGROUND_TS_FILE), ''],
|
|
@@ -58,6 +58,7 @@ export type EndpointPlanItem = {
|
|
|
58
58
|
values: string;
|
|
59
59
|
}>;
|
|
60
60
|
dependencies?: EndpointDependencyEdge[];
|
|
61
|
+
dependencyBlockers?: string[];
|
|
61
62
|
routeDependencies?: string[];
|
|
62
63
|
targetRevisionHash?: string;
|
|
63
64
|
};
|
|
@@ -109,6 +110,7 @@ export declare function buildEndpointsPlan(input: {
|
|
|
109
110
|
envName: string;
|
|
110
111
|
stableKeyName: string;
|
|
111
112
|
projectedComponents?: ProjectedEndpointComponentDependency[];
|
|
113
|
+
includeDependencyBlockers?: boolean;
|
|
112
114
|
}): Promise<EndpointPlan>;
|
|
113
115
|
export declare function pushEndpoints(input: {
|
|
114
116
|
client: RevoClient;
|
|
@@ -930,6 +930,10 @@ export async function buildEndpointsPlan(input) {
|
|
|
930
930
|
projectedComponents: projectedComponentsByKey,
|
|
931
931
|
});
|
|
932
932
|
warnings.push(...dependency.warnings);
|
|
933
|
+
// Repository operation classification needs item-level gates without changing legacy family statuses.
|
|
934
|
+
const dependencyBlockers = input.includeDependencyBlockers && dependency.blockers.length > 0
|
|
935
|
+
? { dependencyBlockers: [...dependency.blockers] }
|
|
936
|
+
: {};
|
|
933
937
|
const desiredHash = hashPortableEndpoint(desired);
|
|
934
938
|
if (ambiguousTargetKeys.has(stableKey) || targetIssueKeys.has(stableKey)) {
|
|
935
939
|
continue;
|
|
@@ -951,6 +955,7 @@ export async function buildEndpointsPlan(input) {
|
|
|
951
955
|
const restoreBlocked = dependency.blockers.length > 0 || restoreSafety.length > 0;
|
|
952
956
|
items.push({
|
|
953
957
|
status: restoreBlocked ? 'restore-blocked' : 'restore',
|
|
958
|
+
...dependencyBlockers,
|
|
954
959
|
stableKey,
|
|
955
960
|
name: desired.name,
|
|
956
961
|
desiredHash,
|
|
@@ -979,6 +984,7 @@ export async function buildEndpointsPlan(input) {
|
|
|
979
984
|
if (targets.length === 0) {
|
|
980
985
|
items.push({
|
|
981
986
|
status: 'create',
|
|
987
|
+
...dependencyBlockers,
|
|
982
988
|
stableKey,
|
|
983
989
|
name: desired.name,
|
|
984
990
|
desiredHash,
|
|
@@ -995,6 +1001,7 @@ export async function buildEndpointsPlan(input) {
|
|
|
995
1001
|
const current = targets[0];
|
|
996
1002
|
const baselineHash = lock.endpoints[stableKey]?.environments[input.envName]?.remoteHash;
|
|
997
1003
|
const common = {
|
|
1004
|
+
...dependencyBlockers,
|
|
998
1005
|
stableKey,
|
|
999
1006
|
name: desired.name,
|
|
1000
1007
|
desiredHash,
|
|
@@ -89,6 +89,7 @@ export declare function buildJobTemplatesPlan(input: {
|
|
|
89
89
|
stableKeyName: string;
|
|
90
90
|
projectedComponents?: ProjectedComponentDependency[];
|
|
91
91
|
projectedServiceAccounts?: string[];
|
|
92
|
+
pruneBeforeUpsertIds?: readonly string[];
|
|
92
93
|
}): Promise<JobTemplatesPlan>;
|
|
93
94
|
export declare function pullJobTemplatesToWorkspace(input: {
|
|
94
95
|
client: RevoClient;
|