@revoengine/cli 1.0.2 → 1.0.4
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 +2 -1
- package/dist/src/commands/component.js +3 -2
- package/dist/src/commands/project.js +2 -5
- package/dist/src/project.d.ts +2 -0
- package/dist/src/project.js +24 -0
- package/dist/src/ui.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,9 +54,10 @@ Initialize a project for ambient low-code editor globals:
|
|
|
54
54
|
```bash
|
|
55
55
|
revo project
|
|
56
56
|
revo project init ./app
|
|
57
|
+
revo project update ./app
|
|
57
58
|
```
|
|
58
59
|
|
|
59
|
-
This writes `.revoengine/types/revo.editor.d.ts`, `.revoengine/revo.json`, patches `tsconfig.json` or `jsconfig.json`, and updates `.gitignore` so the generated type bundle stays local by default.
|
|
60
|
+
This writes or refreshes `.revoengine/types/revo.editor.d.ts`, `.revoengine/revo.json`, patches `tsconfig.json` or `jsconfig.json`, and updates `.gitignore` so the generated type bundle stays local by default. Pass a path such as `./backend` when the RevoEngine workspace is nested.
|
|
60
61
|
|
|
61
62
|
## Common commands
|
|
62
63
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { ApiError, PermissionDeniedError } from "../client.js";
|
|
4
|
-
import { buildSandboxDebugUrl, extractSandboxEndpoint } from "../project.js";
|
|
4
|
+
import { buildSandboxDebugUrl, extractSandboxEndpoint, resolveProjectWorkspace } from "../project.js";
|
|
5
5
|
import { isInteractiveTerminal, promptConfirm } from "../prompt.js";
|
|
6
6
|
import { deepClone, readBoolFlag, readFlag, readValues, sanitizeSegment, writeJsonFile } from "../utils.js";
|
|
7
7
|
const NULL_CATEGORY_FOLDER = '__no_category__';
|
|
@@ -192,7 +192,8 @@ function normalizeComponentType(component) {
|
|
|
192
192
|
return 'CODE_JS';
|
|
193
193
|
}
|
|
194
194
|
function getWorkspaceRoot(cwd) {
|
|
195
|
-
|
|
195
|
+
const projectWorkspace = resolveProjectWorkspace(cwd);
|
|
196
|
+
return path.join(projectWorkspace || cwd, 'Components');
|
|
196
197
|
}
|
|
197
198
|
function getCategoryFolder(component) {
|
|
198
199
|
if (component.category == null || component.category === '') {
|
|
@@ -30,14 +30,11 @@ async function resolveProjectSyncInput(context) {
|
|
|
30
30
|
export async function handleProjectCommand(context) {
|
|
31
31
|
const { args, client, cwd, println } = context;
|
|
32
32
|
const invocation = resolveProjectInvocation(args);
|
|
33
|
-
if (invocation.action === 'update') {
|
|
34
|
-
throw new Error('`revo project update` is not implemented yet.');
|
|
35
|
-
}
|
|
36
33
|
if (invocation.extraArgs.length > 0) {
|
|
37
|
-
throw new Error(
|
|
34
|
+
throw new Error(`Project ${invocation.action} accepts at most one path argument.`);
|
|
38
35
|
}
|
|
39
36
|
const targetDir = resolveProjectTarget(cwd, invocation.targetArg);
|
|
40
37
|
const syncInput = await resolveProjectSyncInput(context);
|
|
41
38
|
const result = syncProjectFiles(targetDir, syncInput);
|
|
42
|
-
printSyncSummary(println, targetDir, result, 'Initialized Revo project in');
|
|
39
|
+
printSyncSummary(println, targetDir, result, invocation.action === 'update' ? 'Updated Revo project in' : 'Initialized Revo project in');
|
|
43
40
|
}
|
package/dist/src/project.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export type RevoProjectMetadata = {
|
|
|
31
31
|
libVersion: string;
|
|
32
32
|
hash: string;
|
|
33
33
|
lastSyncAt: string;
|
|
34
|
+
workspace?: string;
|
|
34
35
|
};
|
|
35
36
|
export type ProjectSyncInput = {
|
|
36
37
|
endpoint: string;
|
|
@@ -71,6 +72,7 @@ export declare function buildProjectMetadata(input: {
|
|
|
71
72
|
export declare function findProjectMetadataFile(startDir?: string): string;
|
|
72
73
|
export declare function readProjectMetadata(startDir?: string): RevoProjectMetadata | null;
|
|
73
74
|
export declare function resolveProjectRoot(startDir?: string): string;
|
|
75
|
+
export declare function resolveProjectWorkspace(startDir?: string): string;
|
|
74
76
|
export declare function buildProjectSyncState(input: {
|
|
75
77
|
fallbackEndpoint: string;
|
|
76
78
|
bundle: EditorTypesBundle;
|
package/dist/src/project.js
CHANGED
|
@@ -335,6 +335,30 @@ export function resolveProjectRoot(startDir = process.cwd()) {
|
|
|
335
335
|
const metadataFile = findProjectMetadataFile(startDir);
|
|
336
336
|
return metadataFile ? path.dirname(path.dirname(metadataFile)) : '';
|
|
337
337
|
}
|
|
338
|
+
function readWorkspaceDirectoryFromProjectConfig(projectRoot, metadata) {
|
|
339
|
+
return readString(metadata.workspace) || '';
|
|
340
|
+
}
|
|
341
|
+
function resolveProjectWorkspaceRoot(projectRoot, workspaceDirectory) {
|
|
342
|
+
const resolved = path.resolve(projectRoot, workspaceDirectory || '.');
|
|
343
|
+
const relative = path.relative(projectRoot, resolved);
|
|
344
|
+
if (relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative))) {
|
|
345
|
+
return resolved;
|
|
346
|
+
}
|
|
347
|
+
throw new Error('Project workspace directory must stay inside the Revo project root.');
|
|
348
|
+
}
|
|
349
|
+
export function resolveProjectWorkspace(startDir = process.cwd()) {
|
|
350
|
+
const metadataFile = findProjectMetadataFile(startDir);
|
|
351
|
+
if (!metadataFile) {
|
|
352
|
+
return '';
|
|
353
|
+
}
|
|
354
|
+
const projectRoot = path.dirname(path.dirname(metadataFile));
|
|
355
|
+
const raw = readJsonFile(metadataFile);
|
|
356
|
+
if (!isRecord(raw)) {
|
|
357
|
+
return projectRoot;
|
|
358
|
+
}
|
|
359
|
+
const workspaceDirectory = readWorkspaceDirectoryFromProjectConfig(projectRoot, raw);
|
|
360
|
+
return resolveProjectWorkspaceRoot(projectRoot, workspaceDirectory);
|
|
361
|
+
}
|
|
338
362
|
export function buildProjectSyncState(input) {
|
|
339
363
|
const metadata = buildProjectMetadata({
|
|
340
364
|
baseUrl: input.fallbackEndpoint,
|
package/dist/src/ui.js
CHANGED
|
@@ -104,6 +104,7 @@ function renderCommandCatalog() {
|
|
|
104
104
|
commandRow('revo auth status', 'Show the current authentication status'),
|
|
105
105
|
commandRow('revo auth logout', 'Remove stored credentials'),
|
|
106
106
|
commandRow('revo project [path]', 'Initialize ambient editor types for JS and TS'),
|
|
107
|
+
commandRow('revo project update [path]', 'Refresh editor types and project metadata'),
|
|
107
108
|
commandRow('revo endpoints', 'List available API endpoints'),
|
|
108
109
|
'',
|
|
109
110
|
paintHeader('Components'),
|