@xrystal/core 3.53.0 → 3.53.2
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/package.json +1 -1
- package/x/bin/commands/create.mjs +6 -1
- package/x/bin/commands/project-info.mjs +2 -1
- package/x/bin/commands/sync.mjs +16 -8
- package/x/bin/commands/tmp.mjs +5 -4
- package/x/bin/helpers/.generated/workspace.mjs +110 -28
- package/x/bin/helpers/.generated/xrystal-home-registry.mjs +119 -37
- package/x/bin/helpers/cli-context-guard.mjs +2 -1
- package/x/bin/helpers/cli-enums.mjs +33 -0
- package/x/bin/helpers/create-target.mjs +3 -2
- package/x/bin/helpers/project-context.mjs +18 -10
- package/x/bin/helpers/tmp-config.mjs +6 -5
- package/x/bin/helpers/workspace-heal.mjs +30 -0
- package/x/bin/helpers/workspace-resolve.mjs +2 -0
- package/x/bin/helpers/workspace-scaffold.mjs +4 -3
- package/x/bin/helpers/workspace-tmp.mjs +2 -0
- package/x/bin/helpers/xrystal-registry.mjs +1 -0
- package/x/dist/loader/mongo/index.js +2 -1
- package/x/dist/loader/redis/index.js +2 -1
- package/x/dist/project/index.js +5 -4
- package/x/dist/utils/helpers/loader-options/index.d.ts +5 -1
- package/x/dist/utils/helpers/loader-options/index.js +15 -0
- package/x/dist/utils/helpers/tmp/index.d.ts +1 -1
- package/x/dist/utils/helpers/tmp/index.js +1 -1
- package/x/dist/utils/helpers/tmp/loader-boot-plan.d.ts +7 -6
- package/x/dist/utils/helpers/tmp/loader-boot-plan.js +27 -16
- package/x/dist/utils/helpers/workspace/index.d.ts +7 -7
- package/x/dist/utils/helpers/workspace/index.js +47 -12
- package/x/dist/utils/helpers/xrystal-home/registry.d.ts +7 -0
- package/x/dist/utils/helpers/xrystal-home/registry.js +32 -3
- package/x/dist/utils/models/enums/index.d.ts +26 -0
- package/x/dist/utils/models/enums/index.js +30 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { InfraLoaderEnum } from '../../../utils/models/enums/index.js';
|
|
1
2
|
function readOptionsBlock(loaders, key) {
|
|
2
3
|
const block = loaders?.[key];
|
|
3
4
|
if (typeof block !== 'object' || block === null)
|
|
@@ -7,10 +8,24 @@ function readOptionsBlock(loaders, key) {
|
|
|
7
8
|
return {};
|
|
8
9
|
return options;
|
|
9
10
|
}
|
|
11
|
+
export function createInfraLoaderFlags(overrides = {}) {
|
|
12
|
+
return {
|
|
13
|
+
[InfraLoaderEnum.KAFKA]: overrides[InfraLoaderEnum.KAFKA] ?? false,
|
|
14
|
+
[InfraLoaderEnum.REDIS]: overrides[InfraLoaderEnum.REDIS] ?? false,
|
|
15
|
+
[InfraLoaderEnum.MONGO]: overrides[InfraLoaderEnum.MONGO] ?? false,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
10
18
|
export function readInfraLoaderEnabled(loaders, key, defaultEnabled) {
|
|
11
19
|
const options = readOptionsBlock(loaders, key);
|
|
12
20
|
if ('enabled' in options)
|
|
13
21
|
return options.enabled !== false;
|
|
14
22
|
return defaultEnabled;
|
|
15
23
|
}
|
|
24
|
+
export function readInfraLoaderFlags(loaders, defaults) {
|
|
25
|
+
return {
|
|
26
|
+
[InfraLoaderEnum.KAFKA]: readInfraLoaderEnabled(loaders, InfraLoaderEnum.KAFKA, defaults[InfraLoaderEnum.KAFKA]),
|
|
27
|
+
[InfraLoaderEnum.REDIS]: readInfraLoaderEnabled(loaders, InfraLoaderEnum.REDIS, defaults[InfraLoaderEnum.REDIS]),
|
|
28
|
+
[InfraLoaderEnum.MONGO]: readInfraLoaderEnabled(loaders, InfraLoaderEnum.MONGO, defaults[InfraLoaderEnum.MONGO]),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
16
31
|
export { readKafkaLoaderOptions } from '../../../utils/helpers/kafka-loader-options/index.js';
|
|
@@ -2,7 +2,7 @@ export { setRuntimeTmpConfigs, getRuntimeTmpConfigs, onRuntimeTmpChange, notifyR
|
|
|
2
2
|
export { getTmpLoader, getTmpLoaderPath, getTmpSnapshot, onTmpReload, resetTmpLoaderForTests, stopTmpLoader, } from '../../../utils/helpers/tmp/tmp-loader';
|
|
3
3
|
export { bindLoaderTmpSync, type ITmpSyncLoader, } from '../../../utils/helpers/tmp/loader-tmp-sync';
|
|
4
4
|
export { resolveTmpWatchIntervalMs } from '../../../utils/helpers/tmp/tmp-watch';
|
|
5
|
-
export { resolveLoaderBootPlan,
|
|
5
|
+
export { resolveLoaderBootPlan, isInfraLoaderEnabled, LoaderBootProfileEnum, InfraLoaderEnum, type LoaderBootPlan, } from '../../../utils/helpers/tmp/loader-boot-plan';
|
|
6
6
|
export { normalizeTmpDocument, normalizeRootFolder, normalizeSourceFolder, normalizeRuntime, normalizeBundler, resolveEffectiveBundler, readTmpDependsBlock, readTmpBuildBlock, readTmpGlobalBlock, assertNoLegacyTmpKeys, resolveTmpDeploymentName, readTmpGlobalPathsBlock, applyTmpGlobalVars, resolveMergedPaths, resolveTmpRuntimeConfigs, resolveProjectRootFromTmpPath, resolveTmpAbsPath, normalizeGlobalType, } from '../../../utils/helpers/tmp/tmp-schema';
|
|
7
7
|
export { loadSeedFromBundledTmp, seedFromTmp, type SeedFromTmp, } from '../../../utils/helpers/tmp/seed-from-tmp';
|
|
8
8
|
export { normalizeLayoutPaths, type LayoutPaths, } from '../../../utils/helpers/tmp/path-normalize';
|
|
@@ -2,7 +2,7 @@ export { setRuntimeTmpConfigs, getRuntimeTmpConfigs, onRuntimeTmpChange, notifyR
|
|
|
2
2
|
export { getTmpLoader, getTmpLoaderPath, getTmpSnapshot, onTmpReload, resetTmpLoaderForTests, stopTmpLoader, } from '../../../utils/helpers/tmp/tmp-loader.js';
|
|
3
3
|
export { bindLoaderTmpSync, } from '../../../utils/helpers/tmp/loader-tmp-sync.js';
|
|
4
4
|
export { resolveTmpWatchIntervalMs } from '../../../utils/helpers/tmp/tmp-watch.js';
|
|
5
|
-
export { resolveLoaderBootPlan, } from '../../../utils/helpers/tmp/loader-boot-plan.js';
|
|
5
|
+
export { resolveLoaderBootPlan, isInfraLoaderEnabled, LoaderBootProfileEnum, InfraLoaderEnum, } from '../../../utils/helpers/tmp/loader-boot-plan.js';
|
|
6
6
|
export { normalizeTmpDocument, normalizeRootFolder, normalizeSourceFolder, normalizeRuntime, normalizeBundler, resolveEffectiveBundler, readTmpDependsBlock, readTmpBuildBlock, readTmpGlobalBlock, assertNoLegacyTmpKeys, resolveTmpDeploymentName, readTmpGlobalPathsBlock, applyTmpGlobalVars, resolveMergedPaths, resolveTmpRuntimeConfigs, resolveProjectRootFromTmpPath, resolveTmpAbsPath, normalizeGlobalType, } from '../../../utils/helpers/tmp/tmp-schema.js';
|
|
7
7
|
export { loadSeedFromBundledTmp, seedFromTmp, } from '../../../utils/helpers/tmp/seed-from-tmp.js';
|
|
8
8
|
export { normalizeLayoutPaths, } from '../../../utils/helpers/tmp/path-normalize.js';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { GlobalTypeEnum, InfraLoaderEnum, LoaderBootProfileEnum } from '../../../utils/models/enums';
|
|
2
|
+
import { type InfraLoaderFlags } from '../../../utils/helpers/loader-options';
|
|
1
3
|
import type { TmpRuntimeConfigs } from '../../../utils/helpers/tmp/tmp-schema';
|
|
2
|
-
export
|
|
4
|
+
export { LoaderBootProfileEnum, InfraLoaderEnum } from '../../../utils/models/enums';
|
|
3
5
|
export type LoaderBootPlan = {
|
|
4
|
-
profile:
|
|
5
|
-
projectType:
|
|
6
|
-
|
|
7
|
-
redis: boolean;
|
|
8
|
-
mongo: boolean;
|
|
6
|
+
profile: LoaderBootProfileEnum;
|
|
7
|
+
projectType: GlobalTypeEnum | undefined;
|
|
8
|
+
infra: InfraLoaderFlags;
|
|
9
9
|
};
|
|
10
10
|
export declare function resolveLoaderBootPlan(configs?: TmpRuntimeConfigs | null): LoaderBootPlan;
|
|
11
|
+
export declare function isInfraLoaderEnabled(plan: LoaderBootPlan, loader: InfraLoaderEnum): boolean;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import { GlobalTypeEnum } from '../../../utils/models/enums/index.js';
|
|
2
|
-
import {
|
|
1
|
+
import { GlobalTypeEnum, InfraLoaderEnum, LoaderBootProfileEnum } from '../../../utils/models/enums/index.js';
|
|
2
|
+
import { createInfraLoaderFlags, readInfraLoaderFlags, } from '../../../utils/helpers/loader-options/index.js';
|
|
3
|
+
export { LoaderBootProfileEnum, InfraLoaderEnum } from '../../../utils/models/enums/index.js';
|
|
4
|
+
const FRONTEND_INFRA_DEFAULTS = createInfraLoaderFlags();
|
|
5
|
+
const API_SERVICE_INFRA_DEFAULTS = createInfraLoaderFlags({
|
|
6
|
+
[InfraLoaderEnum.KAFKA]: true,
|
|
7
|
+
[InfraLoaderEnum.REDIS]: true,
|
|
8
|
+
[InfraLoaderEnum.MONGO]: true,
|
|
9
|
+
});
|
|
10
|
+
const WORKSPACE_INFRA_DEFAULTS = createInfraLoaderFlags();
|
|
3
11
|
function loadersBlock(configs) {
|
|
4
12
|
const loaders = configs?.depends?.loaders;
|
|
5
13
|
return typeof loaders === 'object' && loaders !== null ? loaders : undefined;
|
|
@@ -9,28 +17,31 @@ export function resolveLoaderBootPlan(configs) {
|
|
|
9
17
|
const loaders = loadersBlock(configs);
|
|
10
18
|
if (type === GlobalTypeEnum.FRONTEND) {
|
|
11
19
|
return {
|
|
12
|
-
profile:
|
|
20
|
+
profile: LoaderBootProfileEnum.FRONTEND,
|
|
13
21
|
projectType: type,
|
|
14
|
-
|
|
15
|
-
redis: readInfraLoaderEnabled(loaders, 'redis', false),
|
|
16
|
-
mongo: readInfraLoaderEnabled(loaders, 'mongo', false),
|
|
22
|
+
infra: readInfraLoaderFlags(loaders, FRONTEND_INFRA_DEFAULTS),
|
|
17
23
|
};
|
|
18
24
|
}
|
|
19
25
|
if (type === GlobalTypeEnum.WORKSPACE) {
|
|
20
26
|
return {
|
|
21
|
-
profile:
|
|
27
|
+
profile: LoaderBootProfileEnum.WORKSPACE,
|
|
22
28
|
projectType: type,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
infra: { ...WORKSPACE_INFRA_DEFAULTS },
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (type === GlobalTypeEnum.API_SERVICE) {
|
|
33
|
+
return {
|
|
34
|
+
profile: LoaderBootProfileEnum.API_SERVICE,
|
|
35
|
+
projectType: type,
|
|
36
|
+
infra: readInfraLoaderFlags(loaders, API_SERVICE_INFRA_DEFAULTS),
|
|
26
37
|
};
|
|
27
38
|
}
|
|
28
|
-
const kafkaOpts = readKafkaLoaderOptions(loaders);
|
|
29
39
|
return {
|
|
30
|
-
profile:
|
|
31
|
-
projectType: type
|
|
32
|
-
|
|
33
|
-
redis: readInfraLoaderEnabled(loaders, 'redis', true),
|
|
34
|
-
mongo: readInfraLoaderEnabled(loaders, 'mongo', true),
|
|
40
|
+
profile: LoaderBootProfileEnum.MINIMAL,
|
|
41
|
+
projectType: type,
|
|
42
|
+
infra: readInfraLoaderFlags(loaders, API_SERVICE_INFRA_DEFAULTS),
|
|
35
43
|
};
|
|
36
44
|
}
|
|
45
|
+
export function isInfraLoaderEnabled(plan, loader) {
|
|
46
|
+
return plan.infra[loader];
|
|
47
|
+
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { GlobalTypeEnum } from '../../../utils/models/enums';
|
|
1
|
+
import { GlobalTypeEnum, WorkspaceSlotEnum } from '../../../utils/models/enums';
|
|
2
2
|
export declare const TMP_FILE = "tmp.yml";
|
|
3
3
|
export declare const SKIP_DIRS: Set<string>;
|
|
4
|
-
export type FolderStructure =
|
|
5
|
-
api: string;
|
|
6
|
-
web: string;
|
|
7
|
-
mobile: string;
|
|
8
|
-
};
|
|
4
|
+
export type FolderStructure = Record<WorkspaceSlotEnum, string>;
|
|
9
5
|
export declare const DEFAULT_FOLDER_STRUCTURE: FolderStructure;
|
|
10
6
|
export type TmpMeta = {
|
|
11
7
|
path: string;
|
|
@@ -17,7 +13,7 @@ export type TmpMeta = {
|
|
|
17
13
|
pathsRoot?: string;
|
|
18
14
|
folderStructure: FolderStructure;
|
|
19
15
|
};
|
|
20
|
-
export type WorkspaceSlot =
|
|
16
|
+
export type WorkspaceSlot = WorkspaceSlotEnum;
|
|
21
17
|
export type WorkspaceEntry = {
|
|
22
18
|
name: string;
|
|
23
19
|
type: GlobalTypeEnum.API_SERVICE | GlobalTypeEnum.FRONTEND;
|
|
@@ -45,5 +41,9 @@ export declare function workspaceProjectName(workspaceRoot: string): string;
|
|
|
45
41
|
export declare function readWorkspaceGlobalTmp(workspaceRoot: string): {
|
|
46
42
|
fileWatchIntervalMs?: number;
|
|
47
43
|
};
|
|
44
|
+
/** Ensure api/web/mobile (or custom folder-structure paths) exist on disk. */
|
|
45
|
+
export declare function ensureWorkspaceSlotDirs(workspaceRoot: string): string[];
|
|
46
|
+
/** Patch outer workspace tmp when global.options.fileWatchIntervalMs is missing. */
|
|
47
|
+
export declare function healWorkspaceOuterTmpOptions(workspaceRoot: string): boolean;
|
|
48
48
|
/** @deprecated */ export declare const readWorkspaceCoreTmp: typeof readWorkspaceGlobalTmp;
|
|
49
49
|
export declare function workspaceTmpTemplate(projectName: string): string;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { GlobalTypeEnum } from '../../../utils/models/enums/index.js';
|
|
3
|
+
import { GlobalTypeEnum, WorkspaceSlotEnum } from '../../../utils/models/enums/index.js';
|
|
4
|
+
import { packageDefaults } from '../../../utils/constants/index.js';
|
|
4
5
|
import { normalizeGlobalType } from '../../../utils/helpers/tmp/tmp-schema.js';
|
|
5
6
|
export const TMP_FILE = 'tmp.yml';
|
|
6
7
|
export const SKIP_DIRS = new Set(['node_modules', '.git', 'dist', '.turbo', 'coverage']);
|
|
7
8
|
export const DEFAULT_FOLDER_STRUCTURE = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
[WorkspaceSlotEnum.API]: 'api',
|
|
10
|
+
[WorkspaceSlotEnum.WEB]: 'web',
|
|
11
|
+
[WorkspaceSlotEnum.MOBILE]: 'mobile',
|
|
11
12
|
};
|
|
12
13
|
function parseScalar(raw) {
|
|
13
14
|
const trimmed = raw.trim();
|
|
@@ -47,22 +48,22 @@ export function parseFolderStructure(text) {
|
|
|
47
48
|
throw new Error('configs.folder-structure.admin removed — put admin panels under web/ (e.g. web/admin-ui)');
|
|
48
49
|
}
|
|
49
50
|
const readSlot = (key) => {
|
|
50
|
-
const scalar = fsBlock.match(new RegExp(`^[
|
|
51
|
+
const scalar = fsBlock.match(new RegExp(`^[ \\t]+${key}:\\s*(.+?)(?:\\s+#.*)?$`, 'm'));
|
|
51
52
|
if (scalar)
|
|
52
53
|
return parseScalar(scalar[1]);
|
|
53
54
|
return DEFAULT_FOLDER_STRUCTURE[key];
|
|
54
55
|
};
|
|
55
56
|
return {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
[WorkspaceSlotEnum.API]: readSlot(WorkspaceSlotEnum.API),
|
|
58
|
+
[WorkspaceSlotEnum.WEB]: readSlot(WorkspaceSlotEnum.WEB),
|
|
59
|
+
[WorkspaceSlotEnum.MOBILE]: readSlot(WorkspaceSlotEnum.MOBILE),
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
62
|
export function workspaceDiscoverySlots(fsMap) {
|
|
62
63
|
return [
|
|
63
|
-
{ slot:
|
|
64
|
-
{ slot:
|
|
65
|
-
{ slot:
|
|
64
|
+
{ slot: WorkspaceSlotEnum.API, folder: fsMap[WorkspaceSlotEnum.API], frontendOnly: false },
|
|
65
|
+
{ slot: WorkspaceSlotEnum.WEB, folder: fsMap[WorkspaceSlotEnum.WEB], frontendOnly: true },
|
|
66
|
+
{ slot: WorkspaceSlotEnum.MOBILE, folder: fsMap[WorkspaceSlotEnum.MOBILE], frontendOnly: true },
|
|
66
67
|
];
|
|
67
68
|
}
|
|
68
69
|
export { normalizeGlobalType } from '../../../utils/helpers/tmp/tmp-schema.js';
|
|
@@ -80,7 +81,7 @@ export function entryType(meta, slot) {
|
|
|
80
81
|
return null;
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
|
-
if (slot ===
|
|
84
|
+
if (slot === WorkspaceSlotEnum.API)
|
|
84
85
|
return GlobalTypeEnum.API_SERVICE;
|
|
85
86
|
return null;
|
|
86
87
|
}
|
|
@@ -208,6 +209,38 @@ export function readWorkspaceGlobalTmp(workspaceRoot) {
|
|
|
208
209
|
?? text.match(/fileWatchIntervalMs:\s*(\d+)/);
|
|
209
210
|
return match ? { fileWatchIntervalMs: Number(match[1]) } : {};
|
|
210
211
|
}
|
|
212
|
+
/** Ensure api/web/mobile (or custom folder-structure paths) exist on disk. */
|
|
213
|
+
export function ensureWorkspaceSlotDirs(workspaceRoot) {
|
|
214
|
+
const tmpPath = path.join(workspaceRoot, TMP_FILE);
|
|
215
|
+
if (!fs.existsSync(tmpPath))
|
|
216
|
+
return [];
|
|
217
|
+
const meta = readTmpFile(tmpPath);
|
|
218
|
+
const created = [];
|
|
219
|
+
for (const folder of Object.values(meta.folderStructure)) {
|
|
220
|
+
const dir = path.join(workspaceRoot, folder);
|
|
221
|
+
if (!fs.existsSync(dir)) {
|
|
222
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
223
|
+
created.push(folder);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return created;
|
|
227
|
+
}
|
|
228
|
+
/** Patch outer workspace tmp when global.options.fileWatchIntervalMs is missing. */
|
|
229
|
+
export function healWorkspaceOuterTmpOptions(workspaceRoot) {
|
|
230
|
+
const tmpPath = path.join(workspaceRoot, TMP_FILE);
|
|
231
|
+
if (!fs.existsSync(tmpPath))
|
|
232
|
+
return false;
|
|
233
|
+
const text = fs.readFileSync(tmpPath, 'utf8');
|
|
234
|
+
if (/fileWatchIntervalMs:\s*\d+/m.test(text))
|
|
235
|
+
return false;
|
|
236
|
+
const defaultMs = packageDefaults.tmpWatchDefaults.intervalMs;
|
|
237
|
+
const insertBlock = ` options:\n fileWatchIntervalMs: ${defaultMs}\n`;
|
|
238
|
+
const patched = text.replace(/(configs:\s*\n\s+global:\s*\n\s+type:\s*workspace\s*\n)/m, `$1${insertBlock}`);
|
|
239
|
+
if (patched === text)
|
|
240
|
+
return false;
|
|
241
|
+
fs.writeFileSync(tmpPath, patched);
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
211
244
|
/** @deprecated */ export const readWorkspaceCoreTmp = readWorkspaceGlobalTmp;
|
|
212
245
|
export function workspaceTmpTemplate(projectName) {
|
|
213
246
|
return `project:
|
|
@@ -216,6 +249,8 @@ export function workspaceTmpTemplate(projectName) {
|
|
|
216
249
|
configs:
|
|
217
250
|
global:
|
|
218
251
|
type: workspace
|
|
252
|
+
options:
|
|
253
|
+
fileWatchIntervalMs: 500
|
|
219
254
|
folder-structure:
|
|
220
255
|
api: api
|
|
221
256
|
web: web
|
|
@@ -27,6 +27,13 @@ export declare function readRegistry(): XrystalRegistry;
|
|
|
27
27
|
export declare function writeRegistry(registry: XrystalRegistry): void;
|
|
28
28
|
export declare function upsertWorkspace(registry: XrystalRegistry, workspace: RegistryWorkspace): XrystalRegistry;
|
|
29
29
|
export declare function syncRegistryFromPath(startDir?: string): XrystalRegistry;
|
|
30
|
+
/** Rescan workspace, prune dead registry rows, write when drift detected. */
|
|
31
|
+
export declare function healRegistryAtPath(workspaceRoot: string, { force }?: {
|
|
32
|
+
force?: boolean;
|
|
33
|
+
}): {
|
|
34
|
+
changed: boolean;
|
|
35
|
+
registry: XrystalRegistry;
|
|
36
|
+
};
|
|
30
37
|
export declare function listRegistryProjects(registry?: XrystalRegistry): Array<RegistryProject & {
|
|
31
38
|
workspace: string;
|
|
32
39
|
}>;
|
|
@@ -76,11 +76,40 @@ export function syncRegistryFromPath(startDir = process.cwd()) {
|
|
|
76
76
|
if (!workspaceRoot) {
|
|
77
77
|
throw new Error('No workspace tmp.yml found — run xry create demo --workspace first');
|
|
78
78
|
}
|
|
79
|
-
const
|
|
80
|
-
const registry = upsertWorkspace(readRegistry(), scanned);
|
|
81
|
-
writeRegistry(registry);
|
|
79
|
+
const { registry } = healRegistryAtPath(workspaceRoot, { force: true });
|
|
82
80
|
return registry;
|
|
83
81
|
}
|
|
82
|
+
function projectsFingerprint(projects) {
|
|
83
|
+
return JSON.stringify([...projects].sort((a, b) => a.path.localeCompare(b.path) || a.name.localeCompare(b.name)));
|
|
84
|
+
}
|
|
85
|
+
/** Rescan workspace, prune dead registry rows, write when drift detected. */
|
|
86
|
+
export function healRegistryAtPath(workspaceRoot, { force = false } = {}) {
|
|
87
|
+
const root = normalizeRegistryPath(workspaceRoot);
|
|
88
|
+
let registry = readRegistry();
|
|
89
|
+
const beforeLen = registry.workspaces.length;
|
|
90
|
+
registry = {
|
|
91
|
+
...registry,
|
|
92
|
+
workspaces: registry.workspaces.filter((ws) => {
|
|
93
|
+
try {
|
|
94
|
+
return fs.existsSync(normalizeRegistryPath(ws.path));
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}),
|
|
100
|
+
};
|
|
101
|
+
const pruned = registry.workspaces.length !== beforeLen;
|
|
102
|
+
const scanned = scanWorkspace(root);
|
|
103
|
+
const existing = registry.workspaces.find((ws) => normalizeRegistryPath(ws.path) === root);
|
|
104
|
+
const projectsChanged = !existing
|
|
105
|
+
|| projectsFingerprint(existing.projects) !== projectsFingerprint(scanned.projects);
|
|
106
|
+
if (force || pruned || projectsChanged) {
|
|
107
|
+
registry = upsertWorkspace(registry, scanned);
|
|
108
|
+
writeRegistry(registry);
|
|
109
|
+
return { changed: true, registry };
|
|
110
|
+
}
|
|
111
|
+
return { changed: false, registry };
|
|
112
|
+
}
|
|
84
113
|
export function listRegistryProjects(registry = readRegistry()) {
|
|
85
114
|
const rows = [];
|
|
86
115
|
for (const ws of registry.workspaces) {
|
|
@@ -26,6 +26,32 @@ export declare enum GlobalTypeEnum {
|
|
|
26
26
|
API_SERVICE = "api-service",
|
|
27
27
|
FRONTEND = "frontend"
|
|
28
28
|
}
|
|
29
|
+
/** Runtime loader boot profile derived from tmp global.type (+ minimal fallback). */
|
|
30
|
+
export declare enum LoaderBootProfileEnum {
|
|
31
|
+
API_SERVICE = "api-service",
|
|
32
|
+
FRONTEND = "frontend",
|
|
33
|
+
WORKSPACE = "workspace",
|
|
34
|
+
MINIMAL = "minimal"
|
|
35
|
+
}
|
|
36
|
+
/** Infra loaders gated by tmp depends.loaders.<key>.options.enabled */
|
|
37
|
+
export declare enum InfraLoaderEnum {
|
|
38
|
+
KAFKA = "kafka",
|
|
39
|
+
REDIS = "redis",
|
|
40
|
+
MONGO = "mongo"
|
|
41
|
+
}
|
|
42
|
+
/** CLI / tooling project scope (xry project). */
|
|
43
|
+
export declare enum ProjectScopeKindEnum {
|
|
44
|
+
CORE_LIBRARY = "core-library",
|
|
45
|
+
WORKSPACE_ROOT = "workspace-root",
|
|
46
|
+
WORKSPACE_SERVICE = "workspace-service",
|
|
47
|
+
STANDALONE_SERVICE = "standalone-service"
|
|
48
|
+
}
|
|
49
|
+
/** Workspace folder-structure slots (outer tmp.yml). */
|
|
50
|
+
export declare enum WorkspaceSlotEnum {
|
|
51
|
+
API = "api",
|
|
52
|
+
WEB = "web",
|
|
53
|
+
MOBILE = "mobile"
|
|
54
|
+
}
|
|
29
55
|
export declare enum RuntimeEnum {
|
|
30
56
|
BUN = "bun",
|
|
31
57
|
NODE = "node"
|
|
@@ -30,6 +30,36 @@ export var GlobalTypeEnum;
|
|
|
30
30
|
GlobalTypeEnum["API_SERVICE"] = "api-service";
|
|
31
31
|
GlobalTypeEnum["FRONTEND"] = "frontend";
|
|
32
32
|
})(GlobalTypeEnum || (GlobalTypeEnum = {}));
|
|
33
|
+
/** Runtime loader boot profile derived from tmp global.type (+ minimal fallback). */
|
|
34
|
+
export var LoaderBootProfileEnum;
|
|
35
|
+
(function (LoaderBootProfileEnum) {
|
|
36
|
+
LoaderBootProfileEnum["API_SERVICE"] = "api-service";
|
|
37
|
+
LoaderBootProfileEnum["FRONTEND"] = "frontend";
|
|
38
|
+
LoaderBootProfileEnum["WORKSPACE"] = "workspace";
|
|
39
|
+
LoaderBootProfileEnum["MINIMAL"] = "minimal";
|
|
40
|
+
})(LoaderBootProfileEnum || (LoaderBootProfileEnum = {}));
|
|
41
|
+
/** Infra loaders gated by tmp depends.loaders.<key>.options.enabled */
|
|
42
|
+
export var InfraLoaderEnum;
|
|
43
|
+
(function (InfraLoaderEnum) {
|
|
44
|
+
InfraLoaderEnum["KAFKA"] = "kafka";
|
|
45
|
+
InfraLoaderEnum["REDIS"] = "redis";
|
|
46
|
+
InfraLoaderEnum["MONGO"] = "mongo";
|
|
47
|
+
})(InfraLoaderEnum || (InfraLoaderEnum = {}));
|
|
48
|
+
/** CLI / tooling project scope (xry project). */
|
|
49
|
+
export var ProjectScopeKindEnum;
|
|
50
|
+
(function (ProjectScopeKindEnum) {
|
|
51
|
+
ProjectScopeKindEnum["CORE_LIBRARY"] = "core-library";
|
|
52
|
+
ProjectScopeKindEnum["WORKSPACE_ROOT"] = "workspace-root";
|
|
53
|
+
ProjectScopeKindEnum["WORKSPACE_SERVICE"] = "workspace-service";
|
|
54
|
+
ProjectScopeKindEnum["STANDALONE_SERVICE"] = "standalone-service";
|
|
55
|
+
})(ProjectScopeKindEnum || (ProjectScopeKindEnum = {}));
|
|
56
|
+
/** Workspace folder-structure slots (outer tmp.yml). */
|
|
57
|
+
export var WorkspaceSlotEnum;
|
|
58
|
+
(function (WorkspaceSlotEnum) {
|
|
59
|
+
WorkspaceSlotEnum["API"] = "api";
|
|
60
|
+
WorkspaceSlotEnum["WEB"] = "web";
|
|
61
|
+
WorkspaceSlotEnum["MOBILE"] = "mobile";
|
|
62
|
+
})(WorkspaceSlotEnum || (WorkspaceSlotEnum = {}));
|
|
33
63
|
export var RuntimeEnum;
|
|
34
64
|
(function (RuntimeEnum) {
|
|
35
65
|
RuntimeEnum["BUN"] = "bun";
|