@revoengine/cli 1.0.33 → 1.0.34
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 +25 -0
- package/README.md +83 -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 +22 -0
- 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 +3 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function workspaceWriteLockPath(cwd: string, options?: {
|
|
2
|
+
explicitRoot?: boolean;
|
|
3
|
+
}): string;
|
|
4
|
+
/** Locks writers for one project, including nested sync orchestration. Readers remain lock-free. */
|
|
5
|
+
export declare function withWorkspaceWriteLock<T>(cwd: string, operation: () => T): T;
|
|
6
|
+
/** Project initialization locks its actual target, even before its metadata exists. */
|
|
7
|
+
export declare function withWorkspaceWriteLockAtRoot<T>(root: string, operation: () => T): T;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { resolveProjectRoot } from "./project.js";
|
|
6
|
+
const held = new AsyncLocalStorage();
|
|
7
|
+
const ownerPattern = /^owner-([1-9][0-9]*)-[a-f0-9-]{36}$/;
|
|
8
|
+
export function workspaceWriteLockPath(cwd, options = {}) {
|
|
9
|
+
const root = fs.realpathSync(options.explicitRoot ? path.resolve(cwd) : resolveProjectRoot(cwd) || path.resolve(cwd));
|
|
10
|
+
return path.join(root, '.revoengine', 'workspace-write.lock');
|
|
11
|
+
}
|
|
12
|
+
function busy() {
|
|
13
|
+
return new Error('Another command is writing this RevoEngine workspace. Wait for it to finish, then retry. An incomplete lock requires checking that its command has stopped before manual removal.');
|
|
14
|
+
}
|
|
15
|
+
function sameDirectory(owner) {
|
|
16
|
+
try {
|
|
17
|
+
const stat = fs.lstatSync(owner.directory);
|
|
18
|
+
return !stat.isSymbolicLink() && stat.isDirectory() && stat.dev === owner.dev && stat.ino === owner.ino;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function acquire(directory) {
|
|
25
|
+
fs.mkdirSync(path.dirname(directory), { recursive: true, mode: 0o700 });
|
|
26
|
+
if (fs.lstatSync(path.dirname(directory)).isSymbolicLink())
|
|
27
|
+
throw new Error('Workspace state directory must not be a symbolic link.');
|
|
28
|
+
const baseline = path.join(path.dirname(directory), 'revo.lock.json');
|
|
29
|
+
try {
|
|
30
|
+
if (fs.lstatSync(baseline).isSymbolicLink())
|
|
31
|
+
throw new Error('Workspace baseline must not be a symbolic link.');
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error.code !== 'ENOENT')
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
38
|
+
try {
|
|
39
|
+
fs.mkdirSync(directory, { mode: 0o700 });
|
|
40
|
+
const stat = fs.lstatSync(directory);
|
|
41
|
+
const owner = { directory, entry: `owner-${process.pid}-${randomUUID()}`, dev: stat.dev, ino: stat.ino, released: false };
|
|
42
|
+
// The exclusive owner filename is also the reclamation token. A crash
|
|
43
|
+
// before this entry exists leaves an unknown lock, which fails closed.
|
|
44
|
+
fs.writeFileSync(path.join(directory, owner.entry), '', { flag: 'wx', mode: 0o600 });
|
|
45
|
+
return owner;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (error.code !== 'EEXIST')
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
let stat;
|
|
52
|
+
try {
|
|
53
|
+
stat = fs.lstatSync(directory);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (error.code === 'ENOENT')
|
|
57
|
+
continue;
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
if (stat.isSymbolicLink() || !stat.isDirectory())
|
|
61
|
+
throw busy();
|
|
62
|
+
let entries;
|
|
63
|
+
try {
|
|
64
|
+
entries = fs.readdirSync(directory);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error.code === 'ENOENT')
|
|
68
|
+
continue;
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
const match = entries.length === 1 ? ownerPattern.exec(entries[0]) : null;
|
|
72
|
+
if (!match)
|
|
73
|
+
throw busy();
|
|
74
|
+
const pid = Number(match[1]);
|
|
75
|
+
try {
|
|
76
|
+
process.kill(pid, 0);
|
|
77
|
+
throw busy();
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
// EPERM and a reused/live PID are never proof that an owner is dead.
|
|
81
|
+
if (error.code !== 'ESRCH')
|
|
82
|
+
throw busy();
|
|
83
|
+
}
|
|
84
|
+
const observed = { directory, entry: entries[0], dev: stat.dev, ino: stat.ino, released: false };
|
|
85
|
+
if (!sameDirectory(observed))
|
|
86
|
+
continue;
|
|
87
|
+
try {
|
|
88
|
+
// Only the winner deleting this exact dead owner's token may rmdir.
|
|
89
|
+
// A competing reclaimer must not remove a replacement owner's directory.
|
|
90
|
+
fs.unlinkSync(path.join(directory, observed.entry));
|
|
91
|
+
fs.rmdirSync(directory);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (!['ENOENT', 'ENOTEMPTY', 'EEXIST'].includes(error.code || ''))
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
throw busy();
|
|
99
|
+
}
|
|
100
|
+
function release(owner) {
|
|
101
|
+
owner.released = true;
|
|
102
|
+
if (!sameDirectory(owner))
|
|
103
|
+
return;
|
|
104
|
+
try {
|
|
105
|
+
fs.unlinkSync(path.join(owner.directory, owner.entry));
|
|
106
|
+
fs.rmdirSync(owner.directory);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
if (!['ENOENT', 'ENOTEMPTY', 'EEXIST'].includes(error.code || ''))
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** Locks writers for one project, including nested sync orchestration. Readers remain lock-free. */
|
|
114
|
+
export function withWorkspaceWriteLock(cwd, operation) {
|
|
115
|
+
return withLockDirectory(workspaceWriteLockPath(cwd), operation);
|
|
116
|
+
}
|
|
117
|
+
/** Project initialization locks its actual target, even before its metadata exists. */
|
|
118
|
+
export function withWorkspaceWriteLockAtRoot(root, operation) {
|
|
119
|
+
fs.mkdirSync(root, { recursive: true });
|
|
120
|
+
return withLockDirectory(workspaceWriteLockPath(root, { explicitRoot: true }), operation);
|
|
121
|
+
}
|
|
122
|
+
function withLockDirectory(directory, operation) {
|
|
123
|
+
const inherited = held.getStore();
|
|
124
|
+
const existing = inherited?.get(directory);
|
|
125
|
+
if (existing) {
|
|
126
|
+
if (existing.released || !sameDirectory(existing) || !fs.existsSync(path.join(directory, existing.entry)))
|
|
127
|
+
throw busy();
|
|
128
|
+
return operation();
|
|
129
|
+
}
|
|
130
|
+
const owner = acquire(directory);
|
|
131
|
+
try {
|
|
132
|
+
const result = held.run(new Map([...(inherited || []), [directory, owner]]), operation);
|
|
133
|
+
if (result && typeof result.then === 'function') {
|
|
134
|
+
return Promise.resolve(result).finally(() => release(owner));
|
|
135
|
+
}
|
|
136
|
+
release(owner);
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
if (!owner.released)
|
|
141
|
+
release(owner);
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revoengine/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.34",
|
|
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/component-lifecycle.ts'); await import('./src/component-element-validation.ts'); await import('./src/component-source-validation.ts'); await import('./src/request-contract.ts'); await import('./src/component-contract.ts'); await import('./src/component-manifests.ts'); await import('./src/planning-snapshot.ts'); await import('./src/workspace-digests.ts'); await import('./src/database-indexes.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/agent-sync.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/commands/agents.ts'); await import('./src/migration-actions.ts'); await import('./src/reviewed-plan.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/studio.ts'); await import('./src/commands/tests.ts'); await import('./src/native-tests.ts'); await import('./src/test-workspace.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-browser-profile-import.protocol.ts'); await import('./src/commands/terminal-browser-profile-import.ts'); await import('./src/commands/terminal-browser-profile-import-runner.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/commands/terminal-process-group.ts'); await import('./src/commands/terminal-file-descriptor.ts'); await import('./src/workspace-write-lock.ts'); await import('./src/argument-contract.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/component-lifecycle.ts'); await import('./src/component-element-validation.ts'); await import('./src/component-source-validation.ts'); await import('./src/request-contract.ts'); await import('./src/sync-omit.ts'); await import('./src/sync-omit-command.ts'); await import('./src/sync-omit-write-fence.ts'); await import('./src/component-contract.ts'); await import('./src/component-manifests.ts'); await import('./src/planning-snapshot.ts'); await import('./src/workspace-digests.ts'); await import('./src/database-indexes.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/agent-sync.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/commands/agents.ts'); await import('./src/migration-actions.ts'); await import('./src/reviewed-plan.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/studio.ts'); await import('./src/commands/tests.ts'); await import('./src/native-tests.ts'); await import('./src/test-workspace.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-browser-profile-import.protocol.ts'); await import('./src/commands/terminal-browser-profile-import.ts'); await import('./src/commands/terminal-browser-profile-import-runner.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",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"files": [
|
|
23
23
|
"dist/",
|
|
24
24
|
"README.md",
|
|
25
|
+
"CHANGELOG.md",
|
|
25
26
|
"tsconfig.json",
|
|
26
27
|
"tsconfig.build.json"
|
|
27
28
|
],
|