@revoengine/cli 1.0.17 → 1.0.18
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 +14 -4
- 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/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/workspace-prune.d.ts +2 -0
- package/dist/src/workspace-prune.js +59 -6
- package/package.json +2 -2
|
@@ -9,6 +9,7 @@ export type WorkspacePruneItem = {
|
|
|
9
9
|
name: string;
|
|
10
10
|
version: number | null;
|
|
11
11
|
targetHash: string;
|
|
12
|
+
beforeUpserts?: true;
|
|
12
13
|
};
|
|
13
14
|
export type WorkspacePrunePlan = {
|
|
14
15
|
items: WorkspacePruneItem[];
|
|
@@ -36,5 +37,6 @@ export declare function applyWorkspacePrune(input: {
|
|
|
36
37
|
resources: readonly TrackableResourceType[];
|
|
37
38
|
envName: string;
|
|
38
39
|
plan: WorkspacePrunePlan;
|
|
40
|
+
beforeUpsertsOnly?: boolean;
|
|
39
41
|
}): Promise<WorkspaceSyncResult[]>;
|
|
40
42
|
export {};
|
|
@@ -191,11 +191,15 @@ export function planWorkspacePrune(input) {
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
const dependencies = new Map();
|
|
194
|
+
const consumers = new Map();
|
|
194
195
|
for (const [idKey, target] of byId) {
|
|
195
196
|
for (const reference of remoteReferences(target.resource, target.record, input.inventory['database-table'] || [])) {
|
|
196
197
|
const referenced = key(reference.resource, reference.identity);
|
|
197
198
|
if (!candidates.has(referenced))
|
|
198
199
|
continue;
|
|
200
|
+
const usages = consumers.get(referenced) || new Set();
|
|
201
|
+
usages.add(idKey);
|
|
202
|
+
consumers.set(referenced, usages);
|
|
199
203
|
if (candidates.has(idKey)) {
|
|
200
204
|
const dependents = dependencies.get(referenced) || new Set();
|
|
201
205
|
dependents.add(idKey);
|
|
@@ -214,6 +218,46 @@ export function planWorkspacePrune(input) {
|
|
|
214
218
|
}
|
|
215
219
|
}
|
|
216
220
|
}
|
|
221
|
+
// Names are unique independently of Stable Key. Release only reviewed name
|
|
222
|
+
// conflicts and their obsolete consumers before upserts; retained consumers
|
|
223
|
+
// cannot detach during this phase, even if their desired manifest moves later.
|
|
224
|
+
const beforeUpserts = new Set();
|
|
225
|
+
const templatesByName = new Map();
|
|
226
|
+
for (const [idKey, target] of byId) {
|
|
227
|
+
if (target.resource !== 'job-template' || typeof target.record.name !== 'string')
|
|
228
|
+
continue;
|
|
229
|
+
const matches = templatesByName.get(target.record.name) || [];
|
|
230
|
+
matches.push(idKey);
|
|
231
|
+
templatesByName.set(target.record.name, matches);
|
|
232
|
+
}
|
|
233
|
+
for (const manifest of input.local['job-template']?.values() || []) {
|
|
234
|
+
if (typeof manifest.name !== 'string')
|
|
235
|
+
continue;
|
|
236
|
+
for (const idKey of templatesByName.get(manifest.name) || []) {
|
|
237
|
+
const target = byId.get(idKey);
|
|
238
|
+
if (target.stableKey === manifest.stableKey)
|
|
239
|
+
continue;
|
|
240
|
+
if (candidates.has(idKey))
|
|
241
|
+
beforeUpserts.add(idKey);
|
|
242
|
+
else
|
|
243
|
+
blockers.push(`Job-template name "${manifest.name}" is already used by retained or unmanaged target "${resourceIdOf(target.record)}".`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const pending = [...beforeUpserts];
|
|
247
|
+
for (const idKey of pending) {
|
|
248
|
+
for (const consumer of consumers.get(idKey) || []) {
|
|
249
|
+
if (!candidates.has(consumer)) {
|
|
250
|
+
const target = byId.get(consumer);
|
|
251
|
+
blockers.push(`Cannot delete ${candidates.get(idKey).resource} "${candidates.get(idKey).stableKey}" before upserts: retained ${target.resource} "${target.stableKey || resourceIdOf(target.record)}" still references it.`);
|
|
252
|
+
}
|
|
253
|
+
else if (!beforeUpserts.has(consumer)) {
|
|
254
|
+
beforeUpserts.add(consumer);
|
|
255
|
+
pending.push(consumer);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
for (const idKey of beforeUpserts)
|
|
260
|
+
candidates.get(idKey).beforeUpserts = true;
|
|
217
261
|
const items = [];
|
|
218
262
|
const remaining = new Map(candidates);
|
|
219
263
|
while (remaining.size) {
|
|
@@ -321,17 +365,25 @@ export async function applyWorkspacePrune(input) {
|
|
|
321
365
|
if (input.plan.blockers.length)
|
|
322
366
|
throw new Error('Workspace prune plan is blocked.');
|
|
323
367
|
const results = [];
|
|
324
|
-
|
|
368
|
+
const deleted = new Set();
|
|
369
|
+
for (const item of input.plan.items.filter((item) => !input.beforeUpsertsOnly || item.beforeUpserts)) {
|
|
325
370
|
let accepted = false;
|
|
326
371
|
try {
|
|
327
372
|
if (readPruneManifests(input.cwd, input.resources)[item.resource]?.has(normalizeStableKeyValue(item.stableKey))) {
|
|
328
373
|
throw new Error('local manifest reappeared after planning');
|
|
329
374
|
}
|
|
330
|
-
//
|
|
331
|
-
//
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
375
|
+
// Early template replacement needs its event/schedule graph, including
|
|
376
|
+
// unmanaged and out-of-scope consumers. Avoid reloading unrelated tables,
|
|
377
|
+
// identities and components for every early delete. Cascades still fence
|
|
378
|
+
// the complete remaining plan.
|
|
379
|
+
if (input.beforeUpsertsOnly || item.resource === 'database-table' || item.resource === 'database-view') {
|
|
380
|
+
const resources = input.beforeUpsertsOnly
|
|
381
|
+
? input.resources.filter((resource) => resource === 'job-template' || resource === 'event' || resource === 'schedule')
|
|
382
|
+
: input.resources;
|
|
383
|
+
const fresh = await buildWorkspacePrunePlan({ ...input, resources });
|
|
384
|
+
const remaining = input.plan.items.filter((candidate) => resources.includes(candidate.resource)
|
|
385
|
+
&& !deleted.has(key(candidate.resource, candidate.targetId)));
|
|
386
|
+
if (!samePrunePlan({ ...input.plan, items: remaining }, fresh)) {
|
|
335
387
|
throw new Error('remaining deletion dependencies changed after planning');
|
|
336
388
|
}
|
|
337
389
|
}
|
|
@@ -350,6 +402,7 @@ export async function applyWorkspacePrune(input) {
|
|
|
350
402
|
throw new Error('delete did not remove the resource from the active catalog');
|
|
351
403
|
}
|
|
352
404
|
clearPruneBaseline(input.cwd, input.envName, item);
|
|
405
|
+
deleted.add(key(item.resource, item.targetId));
|
|
353
406
|
results.push({ status: 'pruned', targetPath: `${item.resource}:${item.stableKey}` });
|
|
354
407
|
}
|
|
355
408
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revoengine/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "CLI package for the RevoEngine Platform API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "npm run clean && tsc -p tsconfig.build.json",
|
|
13
13
|
"clean": "node --input-type=module -e \"import fs from 'node:fs'; fs.rmSync('dist', { recursive: true, force: true });\"",
|
|
14
|
-
"check": "node --input-type=module -e \"await import('./src/config.ts'); await import('./src/legacy.ts'); await import('./src/http-trace.ts'); await import('./src/request-queue.ts'); await import('./src/client.ts'); await import('./src/component-lock.ts'); await import('./src/diff-details.ts'); await import('./src/resource-metadata.ts'); await import('./src/tracked-resources.ts'); await import('./src/resource-inventory.ts'); await import('./src/metadata-backfill.ts'); await import('./src/workspace-component.ts'); await import('./src/workspace-resource.ts'); await import('./src/database-table-artifacts.ts'); await import('./src/project.ts'); await import('./src/prompt.ts'); await import('./src/runtime-view.ts'); await import('./src/spinner.ts'); await import('./src/types.ts'); await import('./src/utils.ts'); await import('./src/resource-syncs/util.ts'); await import('./src/resource-syncs/database-table-sync.ts'); await import('./src/resource-syncs/database-view-sync.ts'); await import('./src/resource-syncs/endpoint-sync.ts'); await import('./src/resource-syncs/group-sync.ts'); await import('./src/resource-syncs/role-group-sync.ts'); await import('./src/resource-syncs/job-template-sync.ts'); await import('./src/resource-syncs/schedule-sync.ts'); await import('./src/resource-syncs/event-sync.ts'); await import('./src/resource-syncs/account-principal.ts'); await import('./src/resource-syncs/identity-migration.ts'); await import('./src/resource-syncs/service-account-sync.ts'); await import('./src/commands/service-accounts.ts'); await import('./src/migration.ts'); await import('./src/workspace-diff.ts'); await import('./src/workspace-prune.ts'); await import('./src/sync-output.ts'); await import('./src/ui.ts'); await import('./src/update-notifier.ts'); await import('./src/env-sync.ts'); await import('./src/commands/auth.ts'); await import('./src/commands/component.ts'); await import('./src/commands/database-tables.ts'); await import('./src/commands/database-views.ts'); await import('./src/commands/endpoints.ts'); await import('./src/commands/env.ts'); await import('./src/commands/events.ts'); await import('./src/commands/groups.ts'); await import('./src/commands/info.ts'); await import('./src/commands/job-templates.ts'); await import('./src/commands/metadata.ts'); await import('./src/commands/migrate.ts'); await import('./src/commands/request.ts'); await import('./src/commands/role-groups.ts'); await import('./src/commands/search.ts'); await import('./src/commands/schedules.ts'); await import('./src/commands/terminal-service.ts'); await import('./src/commands/terminal-browser.ts'); await import('./src/commands/terminal-image.ts'); await import('./src/commands/terminal-sandbox.ts'); await import('./src/commands/terminal-patch.ts'); await import('./src/commands/terminal-patch-worker.ts'); await import('./src/commands/terminal.ts'); await import('./src/cli.ts'); await import('./src/index.ts'); await import('./bin/revo.ts'); await import('./scripts/dev.ts')\"",
|
|
14
|
+
"check": "node --input-type=module -e \"await import('./src/config.ts'); await import('./src/legacy.ts'); await import('./src/http-trace.ts'); await import('./src/request-queue.ts'); await import('./src/client.ts'); await import('./src/component-lock.ts'); await import('./src/diff-details.ts'); await import('./src/resource-metadata.ts'); await import('./src/tracked-resources.ts'); await import('./src/resource-inventory.ts'); await import('./src/metadata-backfill.ts'); await import('./src/workspace-component.ts'); await import('./src/workspace-resource.ts'); await import('./src/database-table-artifacts.ts'); await import('./src/project.ts'); await import('./src/prompt.ts'); await import('./src/runtime-view.ts'); await import('./src/spinner.ts'); await import('./src/types.ts'); await import('./src/utils.ts'); await import('./src/resource-syncs/util.ts'); await import('./src/resource-syncs/database-table-sync.ts'); await import('./src/resource-syncs/database-view-sync.ts'); await import('./src/resource-syncs/endpoint-sync.ts'); await import('./src/resource-syncs/group-sync.ts'); await import('./src/resource-syncs/role-group-sync.ts'); await import('./src/resource-syncs/job-template-sync.ts'); await import('./src/resource-syncs/schedule-sync.ts'); await import('./src/resource-syncs/event-sync.ts'); await import('./src/resource-syncs/account-principal.ts'); await import('./src/resource-syncs/identity-migration.ts'); await import('./src/resource-syncs/service-account-sync.ts'); await import('./src/commands/service-accounts.ts'); await import('./src/migration-actions.ts'); await import('./src/migration.ts'); await import('./src/workspace-diff.ts'); await import('./src/workspace-prune.ts'); await import('./src/sync-output.ts'); await import('./src/ui.ts'); await import('./src/update-notifier.ts'); await import('./src/env-sync.ts'); await import('./src/commands/auth.ts'); await import('./src/commands/component.ts'); await import('./src/commands/database-tables.ts'); await import('./src/commands/database-views.ts'); await import('./src/commands/endpoints.ts'); await import('./src/commands/env.ts'); await import('./src/commands/events.ts'); await import('./src/commands/groups.ts'); await import('./src/commands/info.ts'); await import('./src/commands/job-templates.ts'); await import('./src/commands/metadata.ts'); await import('./src/commands/migrate.ts'); await import('./src/commands/request.ts'); await import('./src/commands/role-groups.ts'); await import('./src/commands/search.ts'); await import('./src/commands/schedules.ts'); await import('./src/commands/terminal-service.ts'); await import('./src/commands/terminal-browser.ts'); await import('./src/commands/terminal-image.ts'); await import('./src/commands/terminal-sandbox.ts'); await import('./src/commands/terminal-patch.ts'); await import('./src/commands/terminal-patch-worker.ts'); await import('./src/commands/terminal.ts'); await import('./src/cli.ts'); await import('./src/index.ts'); await import('./bin/revo.ts'); await import('./scripts/dev.ts')\"",
|
|
15
15
|
"dev": "node ./scripts/dev.ts",
|
|
16
16
|
"prepack": "npm run build",
|
|
17
17
|
"test": "node --test ./test/*.test.ts",
|