@revoengine/cli 1.0.2 → 1.0.3

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.
@@ -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
- return path.join(cwd, 'Components');
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 === '') {
@@ -3,6 +3,7 @@ export declare const REVO_PROJECT_DIR = ".revoengine";
3
3
  export declare const REVO_TYPES_DIR: string;
4
4
  export declare const REVO_TYPES_FILE: string;
5
5
  export declare const REVO_METADATA_FILE: string;
6
+ export declare const REVO_VSCODE_CONFIG_FILE: string;
6
7
  export declare const REVO_TYPES_GITIGNORE_ENTRY = ".revoengine/types/";
7
8
  export declare const REVO_DEBUG_JS_FILE: string;
8
9
  export declare const REVO_DEBUG_TS_FILE: string;
@@ -31,6 +32,7 @@ export type RevoProjectMetadata = {
31
32
  libVersion: string;
32
33
  hash: string;
33
34
  lastSyncAt: string;
35
+ workspace?: string;
34
36
  };
35
37
  export type ProjectSyncInput = {
36
38
  endpoint: string;
@@ -71,6 +73,7 @@ export declare function buildProjectMetadata(input: {
71
73
  export declare function findProjectMetadataFile(startDir?: string): string;
72
74
  export declare function readProjectMetadata(startDir?: string): RevoProjectMetadata | null;
73
75
  export declare function resolveProjectRoot(startDir?: string): string;
76
+ export declare function resolveProjectWorkspace(startDir?: string): string;
74
77
  export declare function buildProjectSyncState(input: {
75
78
  fallbackEndpoint: string;
76
79
  bundle: EditorTypesBundle;
@@ -5,6 +5,7 @@ export const REVO_PROJECT_DIR = '.revoengine';
5
5
  export const REVO_TYPES_DIR = path.join(REVO_PROJECT_DIR, 'types');
6
6
  export const REVO_TYPES_FILE = path.join(REVO_TYPES_DIR, 'revo.editor.d.ts');
7
7
  export const REVO_METADATA_FILE = path.join(REVO_PROJECT_DIR, 'revo.json');
8
+ export const REVO_VSCODE_CONFIG_FILE = path.join(REVO_PROJECT_DIR, 'vscode.json');
8
9
  export const REVO_TYPES_GITIGNORE_ENTRY = '.revoengine/types/';
9
10
  export const REVO_DEBUG_JS_FILE = path.join(REVO_PROJECT_DIR, 'debug_code.js');
10
11
  export const REVO_DEBUG_TS_FILE = path.join(REVO_PROJECT_DIR, 'debug_code.ts');
@@ -335,6 +336,38 @@ export function resolveProjectRoot(startDir = process.cwd()) {
335
336
  const metadataFile = findProjectMetadataFile(startDir);
336
337
  return metadataFile ? path.dirname(path.dirname(metadataFile)) : '';
337
338
  }
339
+ function readWorkspaceDirectoryFromProjectConfig(projectRoot, metadata) {
340
+ const vscodeConfigPath = path.join(projectRoot, REVO_VSCODE_CONFIG_FILE);
341
+ if (fs.existsSync(vscodeConfigPath)) {
342
+ const config = parseConfigFile(vscodeConfigPath);
343
+ const workspaceDirectory = readString(config.workspaceDirectory);
344
+ if (workspaceDirectory) {
345
+ return workspaceDirectory;
346
+ }
347
+ }
348
+ return readString(metadata.workspace) || '';
349
+ }
350
+ function resolveProjectWorkspaceRoot(projectRoot, workspaceDirectory) {
351
+ const resolved = path.resolve(projectRoot, workspaceDirectory || '.');
352
+ const relative = path.relative(projectRoot, resolved);
353
+ if (relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative))) {
354
+ return resolved;
355
+ }
356
+ throw new Error('Project workspace directory must stay inside the Revo project root.');
357
+ }
358
+ export function resolveProjectWorkspace(startDir = process.cwd()) {
359
+ const metadataFile = findProjectMetadataFile(startDir);
360
+ if (!metadataFile) {
361
+ return '';
362
+ }
363
+ const projectRoot = path.dirname(path.dirname(metadataFile));
364
+ const raw = readJsonFile(metadataFile);
365
+ if (!isRecord(raw)) {
366
+ return projectRoot;
367
+ }
368
+ const workspaceDirectory = readWorkspaceDirectoryFromProjectConfig(projectRoot, raw);
369
+ return resolveProjectWorkspaceRoot(projectRoot, workspaceDirectory);
370
+ }
338
371
  export function buildProjectSyncState(input) {
339
372
  const metadata = buildProjectMetadata({
340
373
  baseUrl: input.fallbackEndpoint,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revoengine/cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "CLI package for the RevoEngine Platform API",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",