@revoengine/cli 1.0.33 → 1.0.35
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/CHANGELOG.md +34 -0
- package/README.md +89 -6
- package/dist/src/argument-contract.d.ts +17 -0
- package/dist/src/argument-contract.js +359 -0
- package/dist/src/automation-contract.generated.d.ts +2 -2
- package/dist/src/automation-contract.generated.js +2 -2
- package/dist/src/cli.js +15 -13
- package/dist/src/client.d.ts +2 -0
- package/dist/src/client.js +38 -1
- package/dist/src/commands/agents.js +5 -1
- package/dist/src/commands/auth.js +2 -0
- package/dist/src/commands/component.js +34 -17
- package/dist/src/commands/database-tables.js +5 -1
- package/dist/src/commands/database-views.js +5 -1
- package/dist/src/commands/endpoints.js +5 -1
- package/dist/src/commands/env.js +5 -1
- package/dist/src/commands/events.js +5 -1
- package/dist/src/commands/groups.js +5 -1
- package/dist/src/commands/info.js +2 -0
- package/dist/src/commands/job-templates.js +5 -1
- package/dist/src/commands/metadata.js +2 -0
- package/dist/src/commands/migrate.d.ts +2 -2
- package/dist/src/commands/migrate.js +31 -7
- package/dist/src/commands/project.js +19 -14
- package/dist/src/commands/request.js +2 -0
- package/dist/src/commands/role-groups.js +5 -1
- package/dist/src/commands/schedules.js +5 -1
- package/dist/src/commands/search.js +2 -0
- package/dist/src/commands/service-accounts.js +5 -1
- package/dist/src/commands/studio.js +2 -0
- package/dist/src/commands/terminal-file-descriptor.d.ts +9 -0
- package/dist/src/commands/terminal-file-descriptor.js +39 -0
- package/dist/src/commands/terminal-file.js +41 -6
- package/dist/src/commands/terminal-image.js +3 -31
- package/dist/src/commands/terminal-process-group.d.ts +25 -0
- package/dist/src/commands/terminal-process-group.js +144 -0
- package/dist/src/commands/terminal.js +123 -40
- package/dist/src/commands/tests.js +2 -0
- package/dist/src/component-lock.d.ts +15 -1
- package/dist/src/component-lock.js +96 -10
- package/dist/src/env-sync.js +12 -6
- package/dist/src/migration.d.ts +7 -0
- package/dist/src/migration.js +39 -21
- package/dist/src/planning-snapshot.d.ts +3 -0
- package/dist/src/planning-snapshot.js +60 -2
- package/dist/src/project.d.ts +1 -0
- package/dist/src/project.js +7 -8
- package/dist/src/resource-syncs/agent-sync.js +76 -24
- package/dist/src/resource-syncs/database-table-sync.js +33 -22
- package/dist/src/resource-syncs/database-view-sync.js +41 -28
- package/dist/src/resource-syncs/endpoint-sync.js +90 -18
- package/dist/src/resource-syncs/event-sync.js +33 -14
- package/dist/src/resource-syncs/group-sync.js +21 -11
- package/dist/src/resource-syncs/job-template-sync.js +98 -37
- package/dist/src/resource-syncs/role-group-sync.js +22 -11
- package/dist/src/resource-syncs/schedule-sync.js +26 -11
- package/dist/src/resource-syncs/service-account-sync.js +22 -11
- package/dist/src/reviewed-plan.js +3 -0
- package/dist/src/runtime-view.js +2 -18
- package/dist/src/sync-omit-command.d.ts +6 -0
- package/dist/src/sync-omit-command.js +49 -0
- package/dist/src/sync-omit-write-fence.d.ts +10 -0
- package/dist/src/sync-omit-write-fence.js +134 -0
- package/dist/src/sync-omit.d.ts +59 -0
- package/dist/src/sync-omit.js +469 -0
- package/dist/src/ui.js +10 -5
- package/dist/src/update-notifier.d.ts +1 -1
- package/dist/src/update-notifier.js +2 -1
- package/dist/src/utils.js +46 -17
- package/dist/src/workspace-prune.js +11 -3
- package/dist/src/workspace-write-lock.d.ts +7 -0
- package/dist/src/workspace-write-lock.js +144 -0
- package/package.json +4 -2
|
@@ -3,10 +3,19 @@ import fs from 'node:fs';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { REVO_PROJECT_DIR } from "./project.js";
|
|
5
5
|
import { COMPONENT_IDENTITY_BY_ID, normalizeComponentIdentityConfig, readComponentIdentityValue, sameComponentIdentityConfig, sanitizeUserMetadata, } from "./resource-metadata.js";
|
|
6
|
-
import {
|
|
6
|
+
import { writeJsonFile } from "./utils.js";
|
|
7
7
|
import { requestContracts, validateRequestContract } from "./request-contract.js";
|
|
8
8
|
import { componentSourceConfigurationErrors } from "./component-source-validation.js";
|
|
9
|
+
import { hashSyncDefinition, preserveOmittedProperties, syncBaselineData } from "./sync-omit.js";
|
|
10
|
+
import { withWorkspaceWriteLockAtRoot } from "./workspace-write-lock.js";
|
|
9
11
|
export const REVO_LOCK_FILE = path.join(REVO_PROJECT_DIR, 'revo.lock.json');
|
|
12
|
+
const lockRevision = Symbol('revo-lock-revision');
|
|
13
|
+
function revisionHash(contents) { return crypto.createHash('sha256').update(contents).digest('hex'); }
|
|
14
|
+
function markLockRevision(lock, filePath, hash) {
|
|
15
|
+
// Enumerable symbols survive object spreads while JSON serialization ignores them.
|
|
16
|
+
Object.defineProperty(lock, lockRevision, { value: { path: path.resolve(filePath), hash }, enumerable: true, configurable: true });
|
|
17
|
+
return lock;
|
|
18
|
+
}
|
|
10
19
|
const VOLATILE_COMPONENT_FIELDS = new Set([
|
|
11
20
|
'version',
|
|
12
21
|
'revision',
|
|
@@ -102,7 +111,7 @@ export function normalizeComponentSource(component) {
|
|
|
102
111
|
};
|
|
103
112
|
}
|
|
104
113
|
export function hashComponentSource(component) {
|
|
105
|
-
return
|
|
114
|
+
return hashSyncDefinition('component', normalizeComponentSource(component));
|
|
106
115
|
}
|
|
107
116
|
// componentId is instance-local, so comparing components across two RevoEngine
|
|
108
117
|
// environments must project it away; element componentElementIds are already
|
|
@@ -112,7 +121,7 @@ export function normalizePortableComponentSource(component) {
|
|
|
112
121
|
return portable;
|
|
113
122
|
}
|
|
114
123
|
export function hashPortableComponentSource(component) {
|
|
115
|
-
return
|
|
124
|
+
return hashSyncDefinition('component', normalizePortableComponentSource(component));
|
|
116
125
|
}
|
|
117
126
|
export const PORTABLE_COMPONENT_CONFIG_FIELDS = [
|
|
118
127
|
'name',
|
|
@@ -134,7 +143,7 @@ export function componentTypeTransitionReason(desired, current) {
|
|
|
134
143
|
: `The target API cannot change Component type from ${currentType} to ${desiredType}; resolve this transition manually before syncing.`;
|
|
135
144
|
}
|
|
136
145
|
export function diffPortableComponentSource(source, target) {
|
|
137
|
-
const sourcePortable = normalizePortableComponentSource(source);
|
|
146
|
+
const sourcePortable = normalizePortableComponentSource(preserveOmittedProperties('component', source, target));
|
|
138
147
|
const targetPortable = normalizePortableComponentSource(target);
|
|
139
148
|
const configurationFields = PORTABLE_COMPONENT_CONFIG_FIELDS.filter((field) => hashStable(sourcePortable[field] ?? null) !== hashStable(targetPortable[field] ?? null));
|
|
140
149
|
const elementsChanged = hashStable(sourcePortable.elements) !== hashStable(targetPortable.elements);
|
|
@@ -154,7 +163,7 @@ export function buildPortableComponentUpdatePayload(source, target, changedField
|
|
|
154
163
|
const configurationErrors = componentSourceConfigurationErrors(source);
|
|
155
164
|
if (configurationErrors.length)
|
|
156
165
|
throw new Error(configurationErrors.join('; '));
|
|
157
|
-
const sourcePortable = normalizePortableComponentSource(source);
|
|
166
|
+
const sourcePortable = normalizePortableComponentSource(preserveOmittedProperties('component', source, target));
|
|
158
167
|
const activationError = componentActivationValidationError(source);
|
|
159
168
|
if (activationError)
|
|
160
169
|
throw new Error(activationError);
|
|
@@ -202,7 +211,7 @@ export function getLockPath(projectRoot) {
|
|
|
202
211
|
export function readComponentLock(projectRoot) {
|
|
203
212
|
const lockPath = getLockPath(projectRoot);
|
|
204
213
|
if (!fs.existsSync(lockPath)) {
|
|
205
|
-
return {
|
|
214
|
+
return markLockRevision({
|
|
206
215
|
schemaVersion: 2,
|
|
207
216
|
componentIdentity: COMPONENT_IDENTITY_BY_ID,
|
|
208
217
|
components: {},
|
|
@@ -217,9 +226,11 @@ export function readComponentLock(projectRoot) {
|
|
|
217
226
|
endpoints: {},
|
|
218
227
|
databaseSchemas: {},
|
|
219
228
|
databaseViews: {},
|
|
220
|
-
};
|
|
229
|
+
}, lockPath, null);
|
|
221
230
|
}
|
|
222
|
-
const
|
|
231
|
+
const contents = fs.readFileSync(lockPath, 'utf8');
|
|
232
|
+
const revision = revisionHash(contents);
|
|
233
|
+
const raw = (contents.trim() ? JSON.parse(contents) : {});
|
|
223
234
|
const componentIdentity = normalizeComponentIdentityConfig(raw.componentIdentity, COMPONENT_IDENTITY_BY_ID);
|
|
224
235
|
const diagnostics = normalizeDiagnostics(raw.diagnostics);
|
|
225
236
|
const components = Object.fromEntries(Object.entries(raw.components && typeof raw.components === 'object' ? raw.components : {})
|
|
@@ -248,12 +259,13 @@ export function readComponentLock(projectRoot) {
|
|
|
248
259
|
remoteVersion: typeof baseline.remoteVersion === 'number' ? baseline.remoteVersion : null,
|
|
249
260
|
remoteHash: String(baseline.remoteHash),
|
|
250
261
|
syncedAt: String(baseline.syncedAt),
|
|
262
|
+
...(baseline.omitBaseline ? { omitBaseline: baseline.omitBaseline } : {}),
|
|
251
263
|
}])),
|
|
252
264
|
}
|
|
253
265
|
: {}),
|
|
254
266
|
}];
|
|
255
267
|
}));
|
|
256
|
-
return {
|
|
268
|
+
return markLockRevision({
|
|
257
269
|
schemaVersion: 2,
|
|
258
270
|
...(raw.workspaceDigests ? { workspaceDigests: raw.workspaceDigests } : {}),
|
|
259
271
|
...(diagnostics ? { diagnostics } : {}),
|
|
@@ -269,6 +281,7 @@ export function readComponentLock(projectRoot) {
|
|
|
269
281
|
stableKey: String(entry.stableKey),
|
|
270
282
|
path: String(entry.path),
|
|
271
283
|
sourceHash: String(entry.sourceHash),
|
|
284
|
+
...(entry.sourceBaseline ? { sourceBaseline: entry.sourceBaseline } : {}),
|
|
272
285
|
...((isRecord(entry.owner) && (entry.owner.type === 'group' || entry.owner.type === 'service-account') && typeof entry.owner.stableKey === 'string')
|
|
273
286
|
? { owner: { type: entry.owner.type, stableKey: entry.owner.stableKey } }
|
|
274
287
|
: (isRecord(entry.owner) && entry.owner.type === 'system')
|
|
@@ -283,6 +296,7 @@ export function readComponentLock(projectRoot) {
|
|
|
283
296
|
.map(([envName, baseline]) => [envName, {
|
|
284
297
|
remoteHash: String(baseline.remoteHash),
|
|
285
298
|
syncedAt: String(baseline.syncedAt),
|
|
299
|
+
...(baseline.omitBaseline ? { omitBaseline: baseline.omitBaseline } : {}),
|
|
286
300
|
}])),
|
|
287
301
|
}])),
|
|
288
302
|
agents: Object.fromEntries(Object.entries(raw.agents && typeof raw.agents === 'object' ? raw.agents : {})
|
|
@@ -295,11 +309,13 @@ export function readComponentLock(projectRoot) {
|
|
|
295
309
|
stableKey: String(entry.stableKey),
|
|
296
310
|
path: String(entry.path),
|
|
297
311
|
sourceHash: String(entry.sourceHash),
|
|
312
|
+
...(entry.sourceBaseline ? { sourceBaseline: entry.sourceBaseline } : {}),
|
|
298
313
|
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
299
314
|
.filter(([, baseline]) => typeof baseline.remoteHash === 'string' && typeof baseline.syncedAt === 'string')
|
|
300
315
|
.map(([envName, baseline]) => [envName, {
|
|
301
316
|
remoteHash: String(baseline.remoteHash),
|
|
302
317
|
syncedAt: String(baseline.syncedAt),
|
|
318
|
+
...(baseline.omitBaseline ? { omitBaseline: baseline.omitBaseline } : {}),
|
|
303
319
|
}])),
|
|
304
320
|
}])),
|
|
305
321
|
agentPlugins: Object.fromEntries(Object.entries(raw.agentPlugins && typeof raw.agentPlugins === 'object' ? raw.agentPlugins : {})
|
|
@@ -312,11 +328,13 @@ export function readComponentLock(projectRoot) {
|
|
|
312
328
|
stableKey: String(entry.stableKey),
|
|
313
329
|
path: String(entry.path),
|
|
314
330
|
sourceHash: String(entry.sourceHash),
|
|
331
|
+
...(entry.sourceBaseline ? { sourceBaseline: entry.sourceBaseline } : {}),
|
|
315
332
|
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
316
333
|
.filter(([, baseline]) => typeof baseline.remoteHash === 'string' && typeof baseline.syncedAt === 'string')
|
|
317
334
|
.map(([envName, baseline]) => [envName, {
|
|
318
335
|
remoteHash: String(baseline.remoteHash),
|
|
319
336
|
syncedAt: String(baseline.syncedAt),
|
|
337
|
+
...(baseline.omitBaseline ? { omitBaseline: baseline.omitBaseline } : {}),
|
|
320
338
|
}])),
|
|
321
339
|
}])),
|
|
322
340
|
serviceAccounts: Object.fromEntries(Object.entries(raw.serviceAccounts && typeof raw.serviceAccounts === 'object' ? raw.serviceAccounts : {})
|
|
@@ -329,11 +347,13 @@ export function readComponentLock(projectRoot) {
|
|
|
329
347
|
stableKey: String(entry.stableKey),
|
|
330
348
|
path: String(entry.path),
|
|
331
349
|
sourceHash: String(entry.sourceHash),
|
|
350
|
+
...(entry.sourceBaseline ? { sourceBaseline: entry.sourceBaseline } : {}),
|
|
332
351
|
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
333
352
|
.filter(([, baseline]) => typeof baseline.remoteHash === 'string' && typeof baseline.syncedAt === 'string')
|
|
334
353
|
.map(([envName, baseline]) => [envName, {
|
|
335
354
|
remoteHash: String(baseline.remoteHash),
|
|
336
355
|
syncedAt: String(baseline.syncedAt),
|
|
356
|
+
...(baseline.omitBaseline ? { omitBaseline: baseline.omitBaseline } : {}),
|
|
337
357
|
}])),
|
|
338
358
|
}])),
|
|
339
359
|
roleGroups: Object.fromEntries(Object.entries(raw.roleGroups && typeof raw.roleGroups === 'object' ? raw.roleGroups : {})
|
|
@@ -346,11 +366,13 @@ export function readComponentLock(projectRoot) {
|
|
|
346
366
|
stableKey: String(entry.stableKey),
|
|
347
367
|
path: String(entry.path),
|
|
348
368
|
sourceHash: String(entry.sourceHash),
|
|
369
|
+
...(entry.sourceBaseline ? { sourceBaseline: entry.sourceBaseline } : {}),
|
|
349
370
|
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
350
371
|
.filter(([, baseline]) => typeof baseline.remoteHash === 'string' && typeof baseline.syncedAt === 'string')
|
|
351
372
|
.map(([envName, baseline]) => [envName, {
|
|
352
373
|
remoteHash: String(baseline.remoteHash),
|
|
353
374
|
syncedAt: String(baseline.syncedAt),
|
|
375
|
+
...(baseline.omitBaseline ? { omitBaseline: baseline.omitBaseline } : {}),
|
|
354
376
|
}])),
|
|
355
377
|
}])),
|
|
356
378
|
jobTemplates: Object.fromEntries(Object.entries(raw.jobTemplates && typeof raw.jobTemplates === 'object' ? raw.jobTemplates : {})
|
|
@@ -363,6 +385,7 @@ export function readComponentLock(projectRoot) {
|
|
|
363
385
|
stableKey: String(entry.stableKey),
|
|
364
386
|
path: String(entry.path),
|
|
365
387
|
sourceHash: String(entry.sourceHash),
|
|
388
|
+
...(entry.sourceBaseline ? { sourceBaseline: entry.sourceBaseline } : {}),
|
|
366
389
|
...((isRecord(entry.migration) && (entry.migration.componentBinding === 'pinned-unsupported'
|
|
367
390
|
|| entry.migration.executionPrincipal === 'excluded')) ? {
|
|
368
391
|
migration: {
|
|
@@ -375,6 +398,7 @@ export function readComponentLock(projectRoot) {
|
|
|
375
398
|
.map(([envName, baseline]) => [envName, {
|
|
376
399
|
remoteHash: String(baseline.remoteHash),
|
|
377
400
|
syncedAt: String(baseline.syncedAt),
|
|
401
|
+
...(baseline.omitBaseline ? { omitBaseline: baseline.omitBaseline } : {}),
|
|
378
402
|
}])),
|
|
379
403
|
}])),
|
|
380
404
|
schedules: Object.fromEntries(Object.entries(raw.schedules && typeof raw.schedules === 'object' ? raw.schedules : {})
|
|
@@ -387,11 +411,13 @@ export function readComponentLock(projectRoot) {
|
|
|
387
411
|
stableKey: String(entry.stableKey),
|
|
388
412
|
path: String(entry.path),
|
|
389
413
|
sourceHash: String(entry.sourceHash),
|
|
414
|
+
...(entry.sourceBaseline ? { sourceBaseline: entry.sourceBaseline } : {}),
|
|
390
415
|
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
391
416
|
.filter(([, baseline]) => typeof baseline.remoteHash === 'string' && typeof baseline.syncedAt === 'string')
|
|
392
417
|
.map(([envName, baseline]) => [envName, {
|
|
393
418
|
remoteHash: String(baseline.remoteHash),
|
|
394
419
|
syncedAt: String(baseline.syncedAt),
|
|
420
|
+
...(baseline.omitBaseline ? { omitBaseline: baseline.omitBaseline } : {}),
|
|
395
421
|
}])),
|
|
396
422
|
}])),
|
|
397
423
|
events: Object.fromEntries(Object.entries(raw.events && typeof raw.events === 'object' ? raw.events : {})
|
|
@@ -404,11 +430,13 @@ export function readComponentLock(projectRoot) {
|
|
|
404
430
|
stableKey: String(entry.stableKey),
|
|
405
431
|
path: String(entry.path),
|
|
406
432
|
sourceHash: String(entry.sourceHash),
|
|
433
|
+
...(entry.sourceBaseline ? { sourceBaseline: entry.sourceBaseline } : {}),
|
|
407
434
|
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
408
435
|
.filter(([, baseline]) => typeof baseline.remoteHash === 'string' && typeof baseline.syncedAt === 'string')
|
|
409
436
|
.map(([envName, baseline]) => [envName, {
|
|
410
437
|
remoteHash: String(baseline.remoteHash),
|
|
411
438
|
syncedAt: String(baseline.syncedAt),
|
|
439
|
+
...(baseline.omitBaseline ? { omitBaseline: baseline.omitBaseline } : {}),
|
|
412
440
|
}])),
|
|
413
441
|
}])),
|
|
414
442
|
endpoints: Object.fromEntries(Object.entries(raw.endpoints && typeof raw.endpoints === 'object' ? raw.endpoints : {})
|
|
@@ -421,11 +449,13 @@ export function readComponentLock(projectRoot) {
|
|
|
421
449
|
stableKey: String(entry.stableKey),
|
|
422
450
|
path: String(entry.path),
|
|
423
451
|
sourceHash: String(entry.sourceHash),
|
|
452
|
+
...(entry.sourceBaseline ? { sourceBaseline: entry.sourceBaseline } : {}),
|
|
424
453
|
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
425
454
|
.filter(([, baseline]) => typeof baseline.remoteHash === 'string' && typeof baseline.syncedAt === 'string')
|
|
426
455
|
.map(([envName, baseline]) => [envName, {
|
|
427
456
|
remoteHash: String(baseline.remoteHash),
|
|
428
457
|
syncedAt: String(baseline.syncedAt),
|
|
458
|
+
...(baseline.omitBaseline ? { omitBaseline: baseline.omitBaseline } : {}),
|
|
429
459
|
}])),
|
|
430
460
|
}])),
|
|
431
461
|
databaseSchemas: Object.fromEntries(Object.entries(raw.databaseSchemas && typeof raw.databaseSchemas === 'object' ? raw.databaseSchemas : {})
|
|
@@ -438,6 +468,7 @@ export function readComponentLock(projectRoot) {
|
|
|
438
468
|
stableKey: String(entry.stableKey),
|
|
439
469
|
path: String(entry.path),
|
|
440
470
|
sourceHash: String(entry.sourceHash),
|
|
471
|
+
...(entry.sourceBaseline ? { sourceBaseline: entry.sourceBaseline } : {}),
|
|
441
472
|
...(typeof entry.sourceRestricted === 'boolean' ? { sourceRestricted: entry.sourceRestricted } : {}),
|
|
442
473
|
...(typeof entry.parentStableKey === 'string' ? { parentStableKey: entry.parentStableKey } : {}),
|
|
443
474
|
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
@@ -450,6 +481,7 @@ export function readComponentLock(projectRoot) {
|
|
|
450
481
|
parentStableKey: baseline.tombstone.parentStableKey,
|
|
451
482
|
} }
|
|
452
483
|
: {}),
|
|
484
|
+
...(baseline.omitBaseline ? { omitBaseline: baseline.omitBaseline } : {}),
|
|
453
485
|
}])),
|
|
454
486
|
}])),
|
|
455
487
|
databaseViews: Object.fromEntries(Object.entries(raw.databaseViews && typeof raw.databaseViews === 'object' ? raw.databaseViews : {})
|
|
@@ -462,17 +494,68 @@ export function readComponentLock(projectRoot) {
|
|
|
462
494
|
stableKey: String(entry.stableKey),
|
|
463
495
|
path: String(entry.path),
|
|
464
496
|
sourceHash: String(entry.sourceHash),
|
|
497
|
+
...(entry.sourceBaseline ? { sourceBaseline: entry.sourceBaseline } : {}),
|
|
465
498
|
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
466
499
|
.filter(([, baseline]) => typeof baseline.remoteHash === 'string' && typeof baseline.syncedAt === 'string')
|
|
467
500
|
.map(([envName, baseline]) => [envName, {
|
|
468
501
|
remoteHash: String(baseline.remoteHash),
|
|
469
502
|
syncedAt: String(baseline.syncedAt),
|
|
470
503
|
...(typeof baseline.dependencyHash === 'string' ? { dependencyHash: baseline.dependencyHash } : {}),
|
|
504
|
+
...(baseline.omitBaseline ? { omitBaseline: baseline.omitBaseline } : {}),
|
|
471
505
|
}])),
|
|
472
506
|
}])),
|
|
473
|
-
};
|
|
507
|
+
}, lockPath, revision);
|
|
474
508
|
}
|
|
475
509
|
export function writeComponentLock(projectRoot, lock) {
|
|
510
|
+
return withWorkspaceWriteLockAtRoot(projectRoot, () => writeComponentLockWithRevision(projectRoot, lock));
|
|
511
|
+
}
|
|
512
|
+
function writeComponentLockWithRevision(projectRoot, lock) {
|
|
513
|
+
const lockPath = getLockPath(projectRoot);
|
|
514
|
+
const previousContents = fs.existsSync(lockPath) ? fs.readFileSync(lockPath, 'utf8') : null;
|
|
515
|
+
const expected = lock[lockRevision];
|
|
516
|
+
const currentRevision = previousContents === null ? null : revisionHash(previousContents);
|
|
517
|
+
if (expected && (expected.path !== path.resolve(lockPath) || expected.hash !== currentRevision)
|
|
518
|
+
|| !expected && currentRevision !== null) {
|
|
519
|
+
throw new Error('Workspace lock changed after it was read. Read a fresh revo.lock.json and retry; no baseline was overwritten.');
|
|
520
|
+
}
|
|
521
|
+
const previous = (previousContents?.trim() ? JSON.parse(previousContents) : {});
|
|
522
|
+
// Keep field digests beside each verified baseline, never input/secret values.
|
|
523
|
+
const fields = [
|
|
524
|
+
['component', 'components'], ['database-table', 'databaseSchemas'], ['database-view', 'databaseViews'],
|
|
525
|
+
['job-template', 'jobTemplates'], ['endpoint', 'endpoints'], ['schedule', 'schedules'], ['event', 'events'],
|
|
526
|
+
['group', 'groups'], ['role-group', 'roleGroups'], ['service-account', 'serviceAccounts'],
|
|
527
|
+
['agent', 'agents'], ['agent-plugin', 'agentPlugins'],
|
|
528
|
+
];
|
|
529
|
+
for (const [family, field] of fields) {
|
|
530
|
+
const entries = lock[field] || {};
|
|
531
|
+
for (const [entryKey, entry] of Object.entries(entries)) {
|
|
532
|
+
const prior = previous[field]?.[entryKey];
|
|
533
|
+
if (entry.sourceHash) {
|
|
534
|
+
const captured = syncBaselineData(family, entry.sourceHash);
|
|
535
|
+
if (captured?.rawHash === entry.sourceHash && captured.paths.length === 0)
|
|
536
|
+
entry.sourceBaseline = captured;
|
|
537
|
+
}
|
|
538
|
+
if (entry.remoteHash && (!prior || entry.remoteHash !== prior.remoteHash || entry.pulledAt !== prior.pulledAt)) {
|
|
539
|
+
const captured = syncBaselineData(family, entry.remoteHash);
|
|
540
|
+
if (captured)
|
|
541
|
+
entry.omitBaseline = captured;
|
|
542
|
+
}
|
|
543
|
+
for (const [environment, baseline] of Object.entries(entry.environments || {})) {
|
|
544
|
+
const old = prior?.environments?.[environment];
|
|
545
|
+
if (old && baseline.remoteHash === old.remoteHash && JSON.stringify(baseline) === JSON.stringify(old))
|
|
546
|
+
continue;
|
|
547
|
+
const captured = syncBaselineData(family, baseline.remoteHash);
|
|
548
|
+
if (captured)
|
|
549
|
+
baseline.omitBaseline = captured;
|
|
550
|
+
}
|
|
551
|
+
if (entry.sourceBaseline) {
|
|
552
|
+
// Readers and writers use the same position for this optional proof, so
|
|
553
|
+
// a no-op roundtrip cannot move it to the end of every resource entry.
|
|
554
|
+
entries[entryKey] = Object.fromEntries(Object.entries(entry).filter(([key]) => key !== 'sourceBaseline')
|
|
555
|
+
.flatMap(([key, value]) => key === 'sourceHash' ? [[key, value], ['sourceBaseline', entry.sourceBaseline]] : [[key, value]]));
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
476
559
|
const sortedComponents = Object.fromEntries(Object.entries(lock.components).sort(([left], [right]) => left.localeCompare(right)));
|
|
477
560
|
const sortedRoleGroups = Object.fromEntries(Object.entries(lock.roleGroups).sort(([left], [right]) => left.localeCompare(right)));
|
|
478
561
|
const sortedGroups = Object.fromEntries(Object.entries(lock.groups || {}).sort(([left], [right]) => left.localeCompare(right)));
|
|
@@ -500,6 +583,7 @@ export function writeComponentLock(projectRoot, lock) {
|
|
|
500
583
|
...(Object.keys(sortedDatabaseSchemas).length > 0 ? { databaseSchemas: sortedDatabaseSchemas } : {}),
|
|
501
584
|
...(Object.keys(sortedDatabaseViews).length > 0 ? { databaseViews: sortedDatabaseViews } : {}),
|
|
502
585
|
});
|
|
586
|
+
markLockRevision(lock, lockPath, revisionHash(fs.readFileSync(lockPath, 'utf8')));
|
|
503
587
|
}
|
|
504
588
|
export function componentLockKey(identity, component) {
|
|
505
589
|
return readComponentIdentityValue(component, identity);
|
|
@@ -528,6 +612,7 @@ export function getComponentLockEntry(lock, identity, component, environmentName
|
|
|
528
612
|
remoteComponentId: baseline.remoteComponentId,
|
|
529
613
|
remoteVersion: baseline.remoteVersion,
|
|
530
614
|
remoteHash: baseline.remoteHash,
|
|
615
|
+
omitBaseline: baseline.omitBaseline,
|
|
531
616
|
pulledAt: baseline.syncedAt,
|
|
532
617
|
};
|
|
533
618
|
}
|
|
@@ -548,6 +633,7 @@ export function getComponentLockEntries(lock, identity, environmentName) {
|
|
|
548
633
|
remoteComponentId: baseline.remoteComponentId,
|
|
549
634
|
remoteVersion: baseline.remoteVersion,
|
|
550
635
|
remoteHash: baseline.remoteHash,
|
|
636
|
+
omitBaseline: baseline.omitBaseline,
|
|
551
637
|
pulledAt: baseline.syncedAt,
|
|
552
638
|
}]];
|
|
553
639
|
}));
|
package/dist/src/env-sync.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { preserveOmittedProperties, assertOmittedPropertiesPreserved, withoutSyncOmit } from "./sync-omit.js";
|
|
1
2
|
import { verifyComponentRuntime } from "./component-contract.js";
|
|
2
3
|
import { changeComponentActivation } from "./component-lifecycle.js";
|
|
3
4
|
import { componentElementValidationErrors } from "./component-element-validation.js";
|
|
@@ -267,10 +268,14 @@ function buildCreatePayload(component) {
|
|
|
267
268
|
elements: buildPortableElementPayload(component),
|
|
268
269
|
};
|
|
269
270
|
}
|
|
270
|
-
async function verifyAppliedComponent(targetClient, componentId, expectedHash) {
|
|
271
|
+
async function verifyAppliedComponent(targetClient, componentId, expectedHash, previous, fullSource) {
|
|
271
272
|
const component = unwrapComponent(await targetClient.getComponent(componentId));
|
|
273
|
+
if (fullSource && !withoutSyncOmit(() => hashPortableComponentSource(component) === hashPortableComponentSource(fullSource)))
|
|
274
|
+
return false;
|
|
272
275
|
if (hashPortableComponentSource(component) !== expectedHash)
|
|
273
276
|
return false;
|
|
277
|
+
if (previous)
|
|
278
|
+
assertOmittedPropertiesPreserved('component', normalizePortableComponentSource(previous), normalizePortableComponentSource(component));
|
|
274
279
|
await verifyComponentRuntime(targetClient, component, 120_000);
|
|
275
280
|
return true;
|
|
276
281
|
}
|
|
@@ -318,7 +323,7 @@ async function applyPlanItem(targetClient, item, source, target, stableKeyName =
|
|
|
318
323
|
// elements guards against create endpoints that ignore inline elements.
|
|
319
324
|
if (sourceEntry.component.elements?.length)
|
|
320
325
|
await targetClient.saveComponentElements(newComponentId, buildPortableElementPayload(sourceEntry.component));
|
|
321
|
-
const verified = await verifyAppliedComponent(targetClient, newComponentId, sourceEntry.portableHash);
|
|
326
|
+
const verified = await verifyAppliedComponent(targetClient, newComponentId, sourceEntry.portableHash, undefined, sourceEntry.component);
|
|
322
327
|
return { stableKey: item.stableKey, action: item.action, status: 'applied', verified };
|
|
323
328
|
}
|
|
324
329
|
if (item.action === 'update') {
|
|
@@ -340,14 +345,15 @@ async function applyPlanItem(targetClient, item, source, target, stableKeyName =
|
|
|
340
345
|
if (transition)
|
|
341
346
|
throw new Error(transition);
|
|
342
347
|
let expectedVersion = Number.isSafeInteger(targetEntry.component.version) ? targetEntry.component.version : null;
|
|
343
|
-
const
|
|
348
|
+
const effectivePortable = preserveOmittedProperties('component', sourceEntry.portable, targetEntry.portable);
|
|
349
|
+
const activationChanged = effectivePortable.active !== targetEntry.portable.active;
|
|
344
350
|
const updateFields = (item.changedFields || []).filter(field => field !== 'active' && field !== 'type');
|
|
345
351
|
const updatePayload = updateFields.length || activationChanged
|
|
346
352
|
? buildPortableComponentUpdatePayload(sourceEntry.component, targetEntry.component, updateFields) : undefined;
|
|
347
353
|
const hasElementChanges = Boolean(item.addedElementKeys?.length || item.removedElementKeys?.length || item.changedElementKeys?.length);
|
|
348
354
|
const targetElementsByKey = new Map((targetEntry.component.elements || []).map(element => [element.key, element]));
|
|
349
355
|
const elementPayload = hasElementChanges ? buildPortableElementPayload(sourceEntry.component, targetElementsByKey) : undefined;
|
|
350
|
-
if (activationChanged && !
|
|
356
|
+
if (activationChanged && !effectivePortable.active) {
|
|
351
357
|
expectedVersion = await changeComponentActivation(targetClient, targetEntry.componentId, false, expectedVersion);
|
|
352
358
|
}
|
|
353
359
|
if (updateFields.length > 0) {
|
|
@@ -360,14 +366,14 @@ async function applyPlanItem(targetClient, item, source, target, stableKeyName =
|
|
|
360
366
|
if (result.status !== 304 && expectedVersion !== null)
|
|
361
367
|
expectedVersion += 1;
|
|
362
368
|
}
|
|
363
|
-
if (activationChanged &&
|
|
369
|
+
if (activationChanged && effectivePortable.active) {
|
|
364
370
|
const beforeActivation = unwrapComponent(await targetClient.getComponent(targetEntry.componentId));
|
|
365
371
|
if (hashPortableComponentSource(beforeActivation) !== hashPortableComponentSource({ ...sourceEntry.component, active: false })) {
|
|
366
372
|
throw new Error('component source did not verify before activation');
|
|
367
373
|
}
|
|
368
374
|
await changeComponentActivation(targetClient, targetEntry.componentId, true, expectedVersion);
|
|
369
375
|
}
|
|
370
|
-
const verified = await verifyAppliedComponent(targetClient, targetEntry.componentId, sourceEntry.portableHash);
|
|
376
|
+
const verified = await verifyAppliedComponent(targetClient, targetEntry.componentId, sourceEntry.portableHash, targetEntry.component);
|
|
371
377
|
return { stableKey: item.stableKey, action: item.action, status: 'applied', verified };
|
|
372
378
|
}
|
|
373
379
|
if (item.action === 'delete') {
|
package/dist/src/migration.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type SyncOmitTargetVersions } from './sync-omit-write-fence.ts';
|
|
2
|
+
import { type SyncOmitPolicy } from './sync-omit.ts';
|
|
1
3
|
import { type AgentSyncPlan, type AgentSyncPull, type AgentSyncResult } from './resource-syncs/agent-sync.ts';
|
|
2
4
|
import { type MigrationResourcePlan } from './migration-actions.ts';
|
|
3
5
|
import { type WorkspacePrunePlan } from './workspace-prune.ts';
|
|
@@ -42,6 +44,9 @@ export type MigrationSourcePullSummary = {
|
|
|
42
44
|
export type MigrationPlan = {
|
|
43
45
|
schemaVersion: 2;
|
|
44
46
|
reviewedPlanVersion?: 1;
|
|
47
|
+
omitTargetRevisionHash?: string;
|
|
48
|
+
omitSourceRevisionHash?: string;
|
|
49
|
+
omitTargetVersions?: SyncOmitTargetVersions;
|
|
45
50
|
command: 'plan';
|
|
46
51
|
from: string;
|
|
47
52
|
to: string;
|
|
@@ -51,6 +56,7 @@ export type MigrationPlan = {
|
|
|
51
56
|
policy: DatabaseSchemaMigrationPolicy & {
|
|
52
57
|
mode: 'upsert' | 'reconcile';
|
|
53
58
|
activateAutomations?: boolean;
|
|
59
|
+
omit?: SyncOmitPolicy;
|
|
54
60
|
};
|
|
55
61
|
needsChanges: boolean;
|
|
56
62
|
readyToMigrate: boolean;
|
|
@@ -86,6 +92,7 @@ export type MigrationRun = {
|
|
|
86
92
|
policy: DatabaseSchemaMigrationPolicy & {
|
|
87
93
|
mode: 'upsert' | 'reconcile';
|
|
88
94
|
activateAutomations?: boolean;
|
|
95
|
+
omit?: SyncOmitPolicy;
|
|
89
96
|
};
|
|
90
97
|
verdict: 'succeeded' | 'blocked' | 'failed';
|
|
91
98
|
sourcePull: {
|
package/dist/src/migration.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import { fenceSyncOmitWrites } from "./sync-omit-write-fence.js";
|
|
2
|
+
import { currentSyncOmitPolicy, syncBaselineHash, withoutSyncOmit } from "./sync-omit.js";
|
|
1
3
|
import { AGENT_LAYOUT, buildAgentsPlan, pullAgentsToWorkspace, pushAgents } from "./resource-syncs/agent-sync.js";
|
|
2
4
|
import { projectRepositoryItems, migrationItemOperation, BLOCKING_SCHEMA_STATUSES, schemaItemAction, viewItemIsBlocked, viewItemAction, componentItemAction, jobTemplateItemAction, endpointItemAction, scheduleItemAction, eventItemAction, groupItemAction, roleGroupItemAction, serviceAccountItemAction, } from "./migration-actions.js";
|
|
3
5
|
import fs from 'node:fs';
|
|
4
6
|
import { sameReviewedPlan } from "./reviewed-plan.js";
|
|
5
|
-
import { applyWorkspacePrune, buildWorkspacePrunePlan, samePrunePlan } from "./workspace-prune.js";
|
|
7
|
+
import { applyWorkspacePrune, buildWorkspacePrunePlan, samePrunePlan, readPruneManifests } from "./workspace-prune.js";
|
|
6
8
|
import { planIdentityMigration } from "./resource-syncs/identity-migration.js";
|
|
7
9
|
import { SERVICE_ACCOUNTS_DIRECTORY, buildServiceAccountsPlan, pullServiceAccountsToWorkspace, pushServiceAccounts } from "./resource-syncs/service-account-sync.js";
|
|
8
10
|
import os from 'node:os';
|
|
9
11
|
import path from 'node:path';
|
|
10
12
|
import { RevoClient } from "./client.js";
|
|
11
|
-
import { planningSnapshot } from "./planning-snapshot.js";
|
|
12
|
-
import { REVO_LOCK_FILE, readComponentLock } from "./component-lock.js";
|
|
13
|
+
import { planningSnapshot, planningSnapshotReviewHash, planningSnapshotVersions } from "./planning-snapshot.js";
|
|
14
|
+
import { REVO_LOCK_FILE, readComponentLock, hashStable } from "./component-lock.js";
|
|
13
15
|
import { normalizeStableKeyValue } from "./resource-metadata.js";
|
|
14
16
|
import { withHttpTraceContext } from "./http-trace.js";
|
|
15
17
|
import { buildComponentPlan, pullAllComponents, pushAllComponents, } from "./commands/component.js";
|
|
@@ -570,43 +572,43 @@ function combinePlan(input) {
|
|
|
570
572
|
if (input.migrationInput.sourceMode === 'workspace') {
|
|
571
573
|
const lock = readComponentLock(requireProject(input.migrationInput).projectRoot);
|
|
572
574
|
const environment = targetKey(input.migrationInput);
|
|
573
|
-
const baselineByKey = (entries, normalize = (key) => key) => {
|
|
574
|
-
const baselines = new Map(Object.values(entries).map((entry) => [normalize(entry.stableKey), entry.environments[environment]
|
|
575
|
+
const baselineByKey = (family, entries, normalize = (key) => key) => {
|
|
576
|
+
const baselines = new Map(Object.values(entries).map((entry) => [normalize(entry.stableKey), syncBaselineHash(family, entry.environments[environment])]));
|
|
575
577
|
return (item) => item.stableKey ? baselines.get(normalize(item.stableKey)) : undefined;
|
|
576
578
|
};
|
|
577
579
|
if (input.databaseSchemas) {
|
|
578
|
-
input.databaseSchemas = { ...input.databaseSchemas, items: projectRepositoryItems(input.databaseSchemas.items, schemaItemAction, (item) => item.stableKey ? lock.databaseSchemas[item.stableKey]?.environments[environment]
|
|
580
|
+
input.databaseSchemas = { ...input.databaseSchemas, items: projectRepositoryItems(input.databaseSchemas.items, schemaItemAction, (item) => item.stableKey ? syncBaselineHash('database-table', lock.databaseSchemas[item.stableKey]?.environments[environment]) : undefined) };
|
|
579
581
|
}
|
|
580
582
|
if (input.databaseViews) {
|
|
581
|
-
input.databaseViews = { ...input.databaseViews, items: projectRepositoryItems(input.databaseViews.items, viewItemAction, (item) => item.stableKey ? lock.databaseViews[item.stableKey]?.environments[environment]
|
|
583
|
+
input.databaseViews = { ...input.databaseViews, items: projectRepositoryItems(input.databaseViews.items, viewItemAction, (item) => item.stableKey ? syncBaselineHash('database-view', lock.databaseViews[item.stableKey]?.environments[environment]) : undefined) };
|
|
582
584
|
}
|
|
583
585
|
if (input.components) {
|
|
584
586
|
input.components = { ...input.components, items: projectRepositoryItems(input.components.items, componentItemAction, (item) => item.lockHash) };
|
|
585
587
|
}
|
|
586
588
|
for (const field of ['agentPlugins', 'agents']) {
|
|
587
589
|
if (input[field])
|
|
588
|
-
input[field] = { ...input[field], items: projectRepositoryItems(input[field].items, agentItemAction, baselineByKey(lock[field])) };
|
|
590
|
+
input[field] = { ...input[field], items: projectRepositoryItems(input[field].items, agentItemAction, baselineByKey(field === 'agents' ? 'agent' : 'agent-plugin', lock[field])) };
|
|
589
591
|
}
|
|
590
592
|
if (input.serviceAccounts) {
|
|
591
|
-
input.serviceAccounts = { ...input.serviceAccounts, items: projectRepositoryItems(input.serviceAccounts.items, serviceAccountItemAction, baselineByKey(lock.serviceAccounts)) };
|
|
593
|
+
input.serviceAccounts = { ...input.serviceAccounts, items: projectRepositoryItems(input.serviceAccounts.items, serviceAccountItemAction, baselineByKey('service-account', lock.serviceAccounts)) };
|
|
592
594
|
}
|
|
593
595
|
if (input.jobTemplates) {
|
|
594
|
-
input.jobTemplates = { ...input.jobTemplates, items: projectRepositoryItems(input.jobTemplates.items, jobTemplateItemAction, baselineByKey(lock.jobTemplates)) };
|
|
596
|
+
input.jobTemplates = { ...input.jobTemplates, items: projectRepositoryItems(input.jobTemplates.items, jobTemplateItemAction, baselineByKey('job-template', lock.jobTemplates)) };
|
|
595
597
|
}
|
|
596
598
|
if (input.endpoints) {
|
|
597
|
-
input.endpoints = { ...input.endpoints, items: projectRepositoryItems(input.endpoints.items, endpointItemAction, (item) => item.stableKey ? lock.endpoints[item.stableKey]?.environments[environment]
|
|
599
|
+
input.endpoints = { ...input.endpoints, items: projectRepositoryItems(input.endpoints.items, endpointItemAction, (item) => item.stableKey ? syncBaselineHash('endpoint', lock.endpoints[item.stableKey]?.environments[environment]) : undefined) };
|
|
598
600
|
}
|
|
599
601
|
if (input.schedules) {
|
|
600
|
-
input.schedules = { ...input.schedules, items: projectRepositoryItems(input.schedules.items, item => input.migrationInput.activateAutomations && item.status === 'activation-drift' && !item.blocked ? 'update' : scheduleItemAction(item), (item) => item.stableKey ? lock.schedules[item.stableKey]?.environments[environment]
|
|
602
|
+
input.schedules = { ...input.schedules, items: projectRepositoryItems(input.schedules.items, item => input.migrationInput.activateAutomations && item.status === 'activation-drift' && !item.blocked ? 'update' : scheduleItemAction(item), (item) => item.stableKey ? syncBaselineHash('schedule', lock.schedules[item.stableKey]?.environments[environment]) : undefined) };
|
|
601
603
|
}
|
|
602
604
|
if (input.events) {
|
|
603
|
-
input.events = { ...input.events, items: projectRepositoryItems(input.events.items, item => input.migrationInput.activateAutomations && item.status === 'activation-drift' && !item.blocked ? 'update' : eventItemAction(item), (item) => item.stableKey ? lock.events[item.stableKey]?.environments[environment]
|
|
605
|
+
input.events = { ...input.events, items: projectRepositoryItems(input.events.items, item => input.migrationInput.activateAutomations && item.status === 'activation-drift' && !item.blocked ? 'update' : eventItemAction(item), (item) => item.stableKey ? syncBaselineHash('event', lock.events[item.stableKey]?.environments[environment]) : undefined) };
|
|
604
606
|
}
|
|
605
607
|
if (input.groups) {
|
|
606
|
-
input.groups = { ...input.groups, items: projectRepositoryItems(input.groups.items, groupItemAction, baselineByKey(lock.groups)) };
|
|
608
|
+
input.groups = { ...input.groups, items: projectRepositoryItems(input.groups.items, groupItemAction, baselineByKey('group', lock.groups)) };
|
|
607
609
|
}
|
|
608
610
|
if (input.roleGroups) {
|
|
609
|
-
input.roleGroups = { ...input.roleGroups, items: projectRepositoryItems(input.roleGroups.items, roleGroupItemAction, baselineByKey(lock.roleGroups, normalizeStableKeyValue)) };
|
|
611
|
+
input.roleGroups = { ...input.roleGroups, items: projectRepositoryItems(input.roleGroups.items, roleGroupItemAction, baselineByKey('role-group', lock.roleGroups, normalizeStableKeyValue)) };
|
|
610
612
|
}
|
|
611
613
|
}
|
|
612
614
|
const phases = [
|
|
@@ -713,7 +715,7 @@ function combinePlan(input) {
|
|
|
713
715
|
from: input.migrationInput.from,
|
|
714
716
|
to: input.migrationInput.to,
|
|
715
717
|
resources: selectedResources(input.migrationInput),
|
|
716
|
-
policy: { ...migrationPolicy(input.migrationInput), mode: 'upsert', ...(input.migrationInput.activateAutomations ? { activateAutomations: true } : {}) },
|
|
718
|
+
policy: { ...migrationPolicy(input.migrationInput), mode: 'upsert', ...(currentSyncOmitPolicy().rules.length ? { omit: currentSyncOmitPolicy() } : {}), ...(input.migrationInput.activateAutomations ? { activateAutomations: true } : {}) },
|
|
717
719
|
needsChanges: phases.some((phase) => phase.needsChanges),
|
|
718
720
|
readyToMigrate: blockers.length === 0,
|
|
719
721
|
verdict: phaseVerdict(blockers, warnings),
|
|
@@ -830,7 +832,8 @@ function migrationComponentIdentity(cwd) {
|
|
|
830
832
|
}
|
|
831
833
|
function componentCommandContext(input) {
|
|
832
834
|
return {
|
|
833
|
-
args: { _: ['component', input.operation], all: true,
|
|
835
|
+
args: { _: ['component', input.operation], all: true,
|
|
836
|
+
...(input.operation !== 'plan' ? { force: true, yes: true } : {}) },
|
|
834
837
|
client: input.client,
|
|
835
838
|
componentEnvironment: input.envName,
|
|
836
839
|
componentIdentity: migrationComponentIdentity(input.cwd),
|
|
@@ -963,7 +966,7 @@ export async function pullResourcesToWorkspace(input) {
|
|
|
963
966
|
};
|
|
964
967
|
}
|
|
965
968
|
async function pullSelectedResources(input) {
|
|
966
|
-
return (await pullResourcesToWorkspace({
|
|
969
|
+
return (await withoutSyncOmit(() => pullResourcesToWorkspace({
|
|
967
970
|
cwd: input.cwd,
|
|
968
971
|
client: createEnvironmentClient(input.from),
|
|
969
972
|
sourceKey: input.from,
|
|
@@ -971,7 +974,7 @@ async function pullSelectedResources(input) {
|
|
|
971
974
|
resources: selectedResources(input),
|
|
972
975
|
force: true,
|
|
973
976
|
pruneOrphans: true,
|
|
974
|
-
})).results;
|
|
977
|
+
}))).results;
|
|
975
978
|
}
|
|
976
979
|
function projectedComponentDependencies(plan) {
|
|
977
980
|
return plan.items.flatMap((item) => {
|
|
@@ -1053,6 +1056,10 @@ function projectedDatabaseRecords(pull) {
|
|
|
1053
1056
|
partition: manifest.partition,
|
|
1054
1057
|
}));
|
|
1055
1058
|
}
|
|
1059
|
+
function sourceOmitReviewHash(cwd, resources) {
|
|
1060
|
+
const manifests = readPruneManifests(cwd, resources);
|
|
1061
|
+
return hashStable(resources.map(resource => [resource, [...(manifests[resource]?.entries() || [])].sort(([left], [right]) => left.localeCompare(right))]));
|
|
1062
|
+
}
|
|
1056
1063
|
async function planWorkspace(input) {
|
|
1057
1064
|
const planStage = (stage, resource, environment, operation) => runMigrationStage(stage, resource, environment, operation, input.onProgress);
|
|
1058
1065
|
const resources = selectedResources(input);
|
|
@@ -1200,6 +1207,11 @@ async function planWorkspace(input) {
|
|
|
1200
1207
|
agents,
|
|
1201
1208
|
});
|
|
1202
1209
|
combined.reviewedPlanVersion = 1;
|
|
1210
|
+
if (currentSyncOmitPolicy().rules.length) {
|
|
1211
|
+
combined.omitTargetRevisionHash = planningSnapshotReviewHash(client);
|
|
1212
|
+
combined.omitSourceRevisionHash = sourceOmitReviewHash(input.cwd, resources);
|
|
1213
|
+
combined.omitTargetVersions = planningSnapshotVersions(client);
|
|
1214
|
+
}
|
|
1203
1215
|
if (identities) {
|
|
1204
1216
|
combined.identityOrder = identities.ordered.map(({ resource, stableKey }) => ({ resource, stableKey }));
|
|
1205
1217
|
}
|
|
@@ -1302,14 +1314,20 @@ export async function runMigration(input) {
|
|
|
1302
1314
|
from: input.from,
|
|
1303
1315
|
to: input.to,
|
|
1304
1316
|
resources,
|
|
1305
|
-
policy: { ...migrationPolicy(input), mode: 'upsert', ...(input.activateAutomations ? { activateAutomations: true } : {}) },
|
|
1317
|
+
policy: { ...migrationPolicy(input), mode: 'upsert', ...(currentSyncOmitPolicy().rules.length ? { omit: currentSyncOmitPolicy() } : {}), ...(input.activateAutomations ? { activateAutomations: true } : {}) },
|
|
1306
1318
|
sourcePull: pulls,
|
|
1307
1319
|
plan: initialPlan,
|
|
1308
1320
|
};
|
|
1309
1321
|
if (!initialPlan.readyToMigrate) {
|
|
1310
1322
|
return { ...base, verdict: 'blocked', results: [], phaseResults: {} };
|
|
1311
1323
|
}
|
|
1312
|
-
const
|
|
1324
|
+
const rawTargetClient = resolveTargetClient(input);
|
|
1325
|
+
const targetClient = currentSyncOmitPolicy().rules.length
|
|
1326
|
+
? fenceSyncOmitWrites(rawTargetClient, initialPlan.omitTargetVersions || {}, () => {
|
|
1327
|
+
if (sourceOmitReviewHash(input.cwd, resources) !== initialPlan.omitSourceRevisionHash) {
|
|
1328
|
+
throw new Error('Workspace source changed after the deployment plan was reviewed; run plan again before writing.');
|
|
1329
|
+
}
|
|
1330
|
+
}) : rawTargetClient;
|
|
1313
1331
|
const deployStage = (resource, operation) => runMigrationStage('target deploy', resource, targetLabel(input), operation, input.onProgress);
|
|
1314
1332
|
const environmentKey = targetKey(input);
|
|
1315
1333
|
const phaseResults = {};
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { RevoClient } from './client.ts';
|
|
2
|
+
import { type SyncOmitTargetVersions } from './sync-omit-write-fence.ts';
|
|
3
|
+
export declare function planningSnapshotVersions(client: RevoClient): SyncOmitTargetVersions;
|
|
4
|
+
export declare function planningSnapshotReviewHash(client: RevoClient): string;
|
|
2
5
|
export declare function planningSnapshot(client: RevoClient): RevoClient;
|