@xrystal/core 3.55.8 → 3.55.9
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/project-info.mjs +13 -0
- package/x/bin/commands/projects.mjs +56 -11
- package/x/bin/commands/watch.mjs +2 -2
- package/x/bin/helpers/.generated/.generated-from +1 -1
- package/x/bin/helpers/.generated/tmp-schema.mjs +21 -9
- package/x/bin/helpers/.generated/{xrystal-home-registry.mjs → user-home-registry.mjs} +150 -43
- package/x/bin/helpers/.generated/workspace.mjs +162 -34
- package/x/bin/helpers/cli-i18n.mjs +14 -0
- package/x/bin/helpers/create-target.mjs +5 -1
- package/x/bin/helpers/project-artifacts.mjs +2 -2
- package/x/bin/helpers/project-context.mjs +11 -4
- package/x/bin/helpers/registry-display.mjs +30 -0
- package/x/bin/helpers/workspace-resolve.mjs +7 -0
- package/x/bin/helpers/workspace-tmp.mjs +9 -3
- package/x/bin/helpers/xrystal-config.mjs +4 -4
- package/x/bin/helpers/xrystal-registry.mjs +4 -4
- package/x/bin/helpers/xrystal-watch-daemon.mjs +3 -3
- package/x/bin/helpers/xrystal-watch-service.mjs +2 -2
- package/x/bin/helpers/xrystal-watch-spawn.mjs +3 -3
- 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/tmp-schema.d.ts +2 -0
- package/x/dist/utils/helpers/tmp/tmp-schema.js +21 -9
- package/x/dist/utils/helpers/{xrystal-home → user-home}/registry.d.ts +11 -10
- package/x/dist/utils/helpers/{xrystal-home → user-home}/registry.js +11 -10
- package/x/dist/utils/helpers/workspace/index.d.ts +33 -1
- package/x/dist/utils/helpers/workspace/index.js +169 -33
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import { resolveProjectContext } from '../helpers/project-context.mjs'
|
|
|
7
7
|
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
8
8
|
import { ensureTmpSchemaVersion } from '../helpers/tmp-schema-version.mjs'
|
|
9
9
|
import { ProjectScopeKindEnum } from '../helpers/cli-enums.mjs'
|
|
10
|
+
import { formatSlotMismatch } from '../helpers/workspace-resolve.mjs'
|
|
10
11
|
|
|
11
12
|
function line(label, value) {
|
|
12
13
|
console.log(` ${label.padEnd(20)}${value}`)
|
|
@@ -73,6 +74,18 @@ export function registerProjectInfoCommand(cli, { cliName = CLI_PRIMARY_NAME } =
|
|
|
73
74
|
console.log(chalk.bold.cyan('\n Workspace link'))
|
|
74
75
|
line('name', `${ctx.selfEntry.name} [${ctx.selfEntry.type}]`)
|
|
75
76
|
line('slot', ctx.selfEntry.slot)
|
|
77
|
+
} else if (ctx.selfMismatch) {
|
|
78
|
+
console.log(chalk.bold.red('\n Slot mismatch (this project)'))
|
|
79
|
+
console.log(` ${chalk.red('✗')} ${formatSlotMismatch(ctx.selfMismatch)}`)
|
|
80
|
+
console.log(chalk.gray(` tmp: ${ctx.selfMismatch.tmp}`))
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (ctx.slotMismatches?.length > 0) {
|
|
84
|
+
console.log(chalk.bold.red(`\n Slot mismatches (${ctx.slotMismatches.length})`))
|
|
85
|
+
for (const mismatch of ctx.slotMismatches) {
|
|
86
|
+
console.log(` ${chalk.red('✗')} ${formatSlotMismatch(mismatch)}`)
|
|
87
|
+
console.log(chalk.gray(` ${mismatch.projectPath}`))
|
|
88
|
+
}
|
|
76
89
|
}
|
|
77
90
|
|
|
78
91
|
if (ctx.workspaceEntries.length > 0 && ctx.kind === ProjectScopeKindEnum.WORKSPACE_ROOT) {
|
|
@@ -2,30 +2,75 @@ import chalk from 'chalk'
|
|
|
2
2
|
|
|
3
3
|
import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
|
|
4
4
|
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
5
|
+
import { t } from '../helpers/cli-i18n.mjs'
|
|
5
6
|
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
6
|
-
import {
|
|
7
|
+
import { groupProjectsBySlot, REGISTRY_SLOT_ORDER } from '../helpers/registry-display.mjs'
|
|
8
|
+
import { formatSlotMismatch, scanWorkspaceProjects } from '../helpers/workspace-resolve.mjs'
|
|
9
|
+
import { readRegistry, resolveUserHome, syncRegistryFromPath } from '../helpers/xrystal-registry.mjs'
|
|
10
|
+
|
|
11
|
+
function printProjectLine(project, { indent = ' ' } = {}) {
|
|
12
|
+
const cluster = project.cluster ? chalk.yellow(` cluster=${project.cluster}`) : ''
|
|
13
|
+
console.log(`${indent}• ${project.name} [${project.type}] → ${project.path}${cluster}`)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function printWorkspaceSlotMismatches(workspacePath) {
|
|
17
|
+
const { mismatches } = scanWorkspaceProjects(workspacePath)
|
|
18
|
+
if (mismatches.length === 0) return
|
|
19
|
+
|
|
20
|
+
console.log(chalk.red.bold(` ${t('registry.slotMismatches')}`))
|
|
21
|
+
for (const slot of REGISTRY_SLOT_ORDER) {
|
|
22
|
+
const items = mismatches.filter((m) => m.slot === slot)
|
|
23
|
+
if (items.length === 0) continue
|
|
24
|
+
console.log(chalk.red(` ${slot}`))
|
|
25
|
+
for (const mismatch of items) {
|
|
26
|
+
console.log(chalk.red(` ✗ ${formatSlotMismatch(mismatch)}`))
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function printWorkspaceProjects(projects) {
|
|
32
|
+
if (projects.length === 0) {
|
|
33
|
+
console.log(chalk.gray(` ${t('registry.noProjects')}`))
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const { groups, other } = groupProjectsBySlot(projects)
|
|
38
|
+
|
|
39
|
+
for (const slot of REGISTRY_SLOT_ORDER) {
|
|
40
|
+
const items = groups[slot]
|
|
41
|
+
console.log(chalk.bold(` ${slot}`))
|
|
42
|
+
if (items.length === 0) {
|
|
43
|
+
console.log(chalk.gray(` ${t('registry.slotEmpty')}`))
|
|
44
|
+
continue
|
|
45
|
+
}
|
|
46
|
+
for (const project of items) {
|
|
47
|
+
printProjectLine(project)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (other.length > 0) {
|
|
52
|
+
console.log(chalk.bold(` ${t('registry.other')}`))
|
|
53
|
+
for (const project of other) {
|
|
54
|
+
printProjectLine(project)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
7
58
|
|
|
8
59
|
function printProjectsRegistry() {
|
|
9
60
|
const registry = readRegistry()
|
|
10
|
-
console.log(chalk.gray(` home: ${
|
|
61
|
+
console.log(chalk.gray(` home: ${resolveUserHome()}`))
|
|
11
62
|
console.log(chalk.gray(` workspaces: ${registry.workspaces.length}`))
|
|
12
63
|
|
|
13
64
|
if (registry.workspaces.length === 0) {
|
|
14
|
-
console.log(chalk.yellow(
|
|
65
|
+
console.log(chalk.yellow(`\n ${t('registry.noWorkspaces')}\n`))
|
|
15
66
|
return
|
|
16
67
|
}
|
|
17
68
|
|
|
18
69
|
for (const ws of registry.workspaces) {
|
|
19
70
|
console.log(chalk.cyan(`\n${ws.name}`))
|
|
20
71
|
console.log(chalk.gray(` path: ${ws.path}`))
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
continue
|
|
24
|
-
}
|
|
25
|
-
for (const project of ws.projects) {
|
|
26
|
-
const cluster = project.cluster ? chalk.yellow(` cluster=${project.cluster}`) : ''
|
|
27
|
-
console.log(` • ${project.name} [${project.type}] → ${project.path}${cluster}`)
|
|
28
|
-
}
|
|
72
|
+
printWorkspaceProjects(ws.projects)
|
|
73
|
+
printWorkspaceSlotMismatches(ws.path)
|
|
29
74
|
}
|
|
30
75
|
console.log('')
|
|
31
76
|
}
|
package/x/bin/commands/watch.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
|
|
|
4
4
|
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
5
5
|
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
6
6
|
import { collectWatchTargets } from '../helpers/xrystal-watch-daemon.mjs'
|
|
7
|
-
import { readRegistry,
|
|
7
|
+
import { readRegistry, resolveUserHome } from '../helpers/xrystal-registry.mjs'
|
|
8
8
|
import {
|
|
9
9
|
ensureWatchDaemon,
|
|
10
10
|
startWatchDaemon,
|
|
@@ -67,7 +67,7 @@ export function registerWatchCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
67
67
|
printCommandHeader({ cliName, command: 'watch status', version })
|
|
68
68
|
|
|
69
69
|
const status = watchDaemonStatus()
|
|
70
|
-
console.log(chalk.gray(` home: ${
|
|
70
|
+
console.log(chalk.gray(` home: ${resolveUserHome()}`))
|
|
71
71
|
console.log(status.running
|
|
72
72
|
? chalk.green(` running pid ${status.pid}`)
|
|
73
73
|
: chalk.yellow(' not running'))
|
|
@@ -279,6 +279,13 @@ function readTmpGlobalPathsBlock(configs) {
|
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
281
|
}
|
|
282
|
+
function buildTmpRelPath(rootFolder, tmpFileName) {
|
|
283
|
+
const root = stripDotSlash(rootFolder);
|
|
284
|
+
const tmp = stripDotSlash(tmpFileName) || "tmp.yml";
|
|
285
|
+
if (!root || root === ".")
|
|
286
|
+
return tmp;
|
|
287
|
+
return `${root}/${tmp}`.replace(/\/+/g, "/");
|
|
288
|
+
}
|
|
282
289
|
function resolveMergedPaths(configs) {
|
|
283
290
|
const paths = readTmpGlobalPathsBlock(configs);
|
|
284
291
|
const root = stripDotSlash(normalizeRootFolder2(paths.root));
|
|
@@ -289,7 +296,7 @@ function resolveMergedPaths(configs) {
|
|
|
289
296
|
root,
|
|
290
297
|
source,
|
|
291
298
|
special,
|
|
292
|
-
tmpRelPath:
|
|
299
|
+
tmpRelPath: buildTmpRelPath(root, tmpName)
|
|
293
300
|
};
|
|
294
301
|
}
|
|
295
302
|
function readWorkspaceGlobalBlock(global) {
|
|
@@ -400,12 +407,14 @@ function resolveTmpRuntimeConfigs(tmp) {
|
|
|
400
407
|
const global = readTmpGlobalBlock(configs);
|
|
401
408
|
const depends = readTmpDependsBlock(configs);
|
|
402
409
|
if (global.type === "workspace" /* WORKSPACE */) {
|
|
410
|
+
const root = stripDotSlash(normalizeRootFolder2(global.paths.root ?? ".")) || ".";
|
|
411
|
+
const tmpName = stripDotSlash(global.paths.tmp ?? "tmp.yml") || "tmp.yml";
|
|
403
412
|
return {
|
|
404
413
|
global: { ...global, build: {} },
|
|
405
414
|
depends: buildNormalizedDepends(depends),
|
|
406
415
|
deploymentName: resolveTmpDeploymentName(tmp),
|
|
407
|
-
rootFolderPath:
|
|
408
|
-
tmpRelPath:
|
|
416
|
+
rootFolderPath: root,
|
|
417
|
+
tmpRelPath: buildTmpRelPath(root, tmpName)
|
|
409
418
|
};
|
|
410
419
|
}
|
|
411
420
|
const merged = resolveMergedPaths(configs);
|
|
@@ -428,17 +437,19 @@ function normalizeTmpDocument(tmp) {
|
|
|
428
437
|
};
|
|
429
438
|
}
|
|
430
439
|
function resolveProjectRootFromTmpPath(tmpFilePath, configs) {
|
|
431
|
-
const
|
|
440
|
+
const runtime = resolveTmpRuntimeConfigs(isRecord2(configs?.global) ? { configs } : { configs: configs ?? {} });
|
|
432
441
|
const abs = tmpFilePath.replace(/\\/g, "/");
|
|
433
|
-
const rel =
|
|
434
|
-
if (abs.endsWith(`/${rel}`)) {
|
|
435
|
-
|
|
442
|
+
const rel = runtime.tmpRelPath;
|
|
443
|
+
if (abs === rel || abs.endsWith(`/${rel}`)) {
|
|
444
|
+
const root = abs === rel ? "" : abs.slice(0, -(rel.length + 1));
|
|
445
|
+
return root || ".";
|
|
436
446
|
}
|
|
437
447
|
throw new Error(`${defaults_default.packageName}: tmp path ${tmpFilePath} does not match configs.global.paths (${rel})`);
|
|
438
448
|
}
|
|
439
449
|
function resolveTmpAbsPath(projectRoot, configs) {
|
|
440
|
-
const
|
|
441
|
-
|
|
450
|
+
const runtime = resolveTmpRuntimeConfigs(isRecord2(configs?.global) ? { configs } : { configs: configs ?? {} });
|
|
451
|
+
const base = projectRoot.replace(/\\/g, "/").replace(/\/$/, "");
|
|
452
|
+
return `${base}/${runtime.tmpRelPath}`;
|
|
442
453
|
}
|
|
443
454
|
export {
|
|
444
455
|
resolveTmpRuntimeConfigs,
|
|
@@ -459,6 +470,7 @@ export {
|
|
|
459
470
|
normalizeGlobalType,
|
|
460
471
|
normalizeBundler,
|
|
461
472
|
buildTmpVarContext,
|
|
473
|
+
buildTmpRelPath,
|
|
462
474
|
assertNoLegacyTmpKeys,
|
|
463
475
|
applyTmpGlobalVars
|
|
464
476
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// source/utils/helpers/
|
|
1
|
+
// source/utils/helpers/user-home/registry.ts
|
|
2
2
|
import fs3 from "node:fs";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path5 from "node:path";
|
|
@@ -278,11 +278,31 @@ function parseFolderStructure(text) {
|
|
|
278
278
|
["mobile" /* MOBILE */]: readSlot("mobile" /* MOBILE */)
|
|
279
279
|
};
|
|
280
280
|
}
|
|
281
|
+
function allowedGlobalTypesForSlot(slot) {
|
|
282
|
+
if (slot === "api" /* API */)
|
|
283
|
+
return ["api-service" /* API_SERVICE */];
|
|
284
|
+
if (slot === "web" /* WEB */ || slot === "mobile" /* MOBILE */) {
|
|
285
|
+
return ["frontend" /* FRONTEND */];
|
|
286
|
+
}
|
|
287
|
+
return [];
|
|
288
|
+
}
|
|
281
289
|
function workspaceDiscoverySlots(fsMap) {
|
|
282
290
|
return [
|
|
283
|
-
{
|
|
284
|
-
|
|
285
|
-
|
|
291
|
+
{
|
|
292
|
+
slot: "api" /* API */,
|
|
293
|
+
folder: fsMap["api" /* API */],
|
|
294
|
+
allowedTypes: allowedGlobalTypesForSlot("api" /* API */)
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
slot: "web" /* WEB */,
|
|
298
|
+
folder: fsMap["web" /* WEB */],
|
|
299
|
+
allowedTypes: allowedGlobalTypesForSlot("web" /* WEB */)
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
slot: "mobile" /* MOBILE */,
|
|
303
|
+
folder: fsMap["mobile" /* MOBILE */],
|
|
304
|
+
allowedTypes: allowedGlobalTypesForSlot("mobile" /* MOBILE */)
|
|
305
|
+
}
|
|
286
306
|
];
|
|
287
307
|
}
|
|
288
308
|
function entryName(meta) {
|
|
@@ -303,13 +323,38 @@ function entryType(meta, slot) {
|
|
|
303
323
|
return null;
|
|
304
324
|
}
|
|
305
325
|
function findWorkspaceRoot(startDir = process.cwd()) {
|
|
306
|
-
|
|
326
|
+
return findWorkspaceAnchor(startDir)?.root ?? null;
|
|
327
|
+
}
|
|
328
|
+
function resolveWorkspaceOuterTmp(workspaceRoot) {
|
|
329
|
+
const root = path4.resolve(workspaceRoot);
|
|
330
|
+
const anchor = findWorkspaceAnchor(root);
|
|
331
|
+
if (!anchor)
|
|
332
|
+
return null;
|
|
333
|
+
if (path4.resolve(anchor.root) !== root)
|
|
334
|
+
return null;
|
|
335
|
+
return anchor.tmpPath;
|
|
336
|
+
}
|
|
337
|
+
function findWorkspaceAnchor(startDir = process.cwd()) {
|
|
338
|
+
const start = path4.resolve(startDir);
|
|
339
|
+
let cur = start;
|
|
307
340
|
for (;; ) {
|
|
308
|
-
const candidate
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
341
|
+
for (const candidate of listShallowTmpCandidates(cur)) {
|
|
342
|
+
let meta;
|
|
343
|
+
try {
|
|
344
|
+
meta = readTmpFile(candidate);
|
|
345
|
+
} catch {
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
if (meta.globalType !== "workspace" /* WORKSPACE */)
|
|
349
|
+
continue;
|
|
350
|
+
try {
|
|
351
|
+
const root = path4.resolve(resolveRepoRootFromTmpMeta(candidate, meta));
|
|
352
|
+
if (start === root || start.startsWith(`${root}${path4.sep}`)) {
|
|
353
|
+
return { root, tmpPath: path4.resolve(candidate), meta };
|
|
354
|
+
}
|
|
355
|
+
} catch {
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
313
358
|
}
|
|
314
359
|
const parent = path4.dirname(cur);
|
|
315
360
|
if (parent === cur)
|
|
@@ -318,6 +363,29 @@ function findWorkspaceRoot(startDir = process.cwd()) {
|
|
|
318
363
|
}
|
|
319
364
|
return null;
|
|
320
365
|
}
|
|
366
|
+
function listShallowTmpCandidates(dir) {
|
|
367
|
+
const out = [];
|
|
368
|
+
const direct = path4.join(dir, TMP_FILE);
|
|
369
|
+
if (fs2.existsSync(direct))
|
|
370
|
+
out.push(direct);
|
|
371
|
+
let entries;
|
|
372
|
+
try {
|
|
373
|
+
entries = fs2.readdirSync(dir, { withFileTypes: true });
|
|
374
|
+
} catch {
|
|
375
|
+
return out;
|
|
376
|
+
}
|
|
377
|
+
for (const entry of entries) {
|
|
378
|
+
const full = path4.join(dir, entry.name);
|
|
379
|
+
if (!isTraversableDir(entry, full))
|
|
380
|
+
continue;
|
|
381
|
+
if (SKIP_DIRS.has(entry.name) || entry.name.startsWith("."))
|
|
382
|
+
continue;
|
|
383
|
+
const nested = path4.join(full, TMP_FILE);
|
|
384
|
+
if (fs2.existsSync(nested))
|
|
385
|
+
out.push(nested);
|
|
386
|
+
}
|
|
387
|
+
return out;
|
|
388
|
+
}
|
|
321
389
|
function isTraversableDir(entry, fullPath) {
|
|
322
390
|
if (entry.isDirectory())
|
|
323
391
|
return true;
|
|
@@ -358,39 +426,70 @@ function walkTmpUnder(rootDir) {
|
|
|
358
426
|
return found;
|
|
359
427
|
}
|
|
360
428
|
function stripDotSlash(value) {
|
|
361
|
-
return value.replace(/^\.\//, "");
|
|
362
|
-
}
|
|
363
|
-
function
|
|
364
|
-
const
|
|
365
|
-
const rootFolder = stripDotSlash(meta.pathsRoot
|
|
366
|
-
const tmpName = stripDotSlash(meta.pathsTmp
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
429
|
+
return value.replace(/^\.\//, "").replace(/\/$/, "");
|
|
430
|
+
}
|
|
431
|
+
function buildRepoTmpRelPath(meta) {
|
|
432
|
+
const isWorkspace = meta.globalType === "workspace" /* WORKSPACE */;
|
|
433
|
+
const rootFolder = stripDotSlash(meta.pathsRoot?.trim() || (isWorkspace ? "." : packageDefaults.packageRootFolder));
|
|
434
|
+
const tmpName = stripDotSlash(meta.pathsTmp?.trim() || TMP_FILE) || TMP_FILE;
|
|
435
|
+
if (!rootFolder || rootFolder === ".")
|
|
436
|
+
return tmpName;
|
|
437
|
+
return `${rootFolder}/${tmpName}`.replace(/\/+/g, "/");
|
|
438
|
+
}
|
|
439
|
+
function resolveRepoRootFromTmpMeta(tmpPath, meta) {
|
|
440
|
+
const abs = path4.resolve(tmpPath).replace(/\\/g, "/");
|
|
441
|
+
const rel = buildRepoTmpRelPath(meta);
|
|
442
|
+
if (abs === rel || abs.endsWith(`/${rel}`)) {
|
|
443
|
+
const root = abs === rel ? "" : abs.slice(0, -(rel.length + 1));
|
|
444
|
+
return root || path4.dirname(abs);
|
|
370
445
|
}
|
|
371
446
|
throw new Error(`tmp path mismatch: expected */${rel}, got ${abs}`);
|
|
372
447
|
}
|
|
373
|
-
function
|
|
374
|
-
const
|
|
448
|
+
function scanWorkspaceProjects(workspaceRoot) {
|
|
449
|
+
const outerTmp = resolveWorkspaceOuterTmp(workspaceRoot);
|
|
450
|
+
const wsMeta = readTmpFile(outerTmp ?? path4.join(workspaceRoot, TMP_FILE));
|
|
375
451
|
const fsMap = wsMeta.folderStructure;
|
|
376
452
|
const entries = [];
|
|
453
|
+
const mismatches = [];
|
|
377
454
|
const seen = new Set;
|
|
378
|
-
|
|
455
|
+
const seenMismatch = new Set;
|
|
456
|
+
const outerResolved = outerTmp ? path4.resolve(outerTmp) : null;
|
|
457
|
+
for (const { slot, folder: folderRel, allowedTypes } of workspaceDiscoverySlots(fsMap)) {
|
|
379
458
|
const folder = path4.join(workspaceRoot, folderRel);
|
|
380
459
|
for (const tmpPath of walkTmpUnder(folder)) {
|
|
381
|
-
if (path4.resolve(tmpPath) ===
|
|
460
|
+
if (outerResolved && path4.resolve(tmpPath) === outerResolved)
|
|
382
461
|
continue;
|
|
383
462
|
const meta = readTmpFile(tmpPath);
|
|
384
463
|
const kind = entryType(meta, slot);
|
|
385
464
|
if (kind === "workspace" /* WORKSPACE */)
|
|
386
465
|
continue;
|
|
387
|
-
if (frontendOnly && kind !== "frontend" /* FRONTEND */)
|
|
388
|
-
continue;
|
|
389
|
-
if (kind !== "api-service" /* API_SERVICE */ && kind !== "frontend" /* FRONTEND */)
|
|
390
|
-
continue;
|
|
391
466
|
const name = entryName(meta);
|
|
467
|
+
const explicitType = (meta.globalType ?? "").trim() || null;
|
|
468
|
+
const projectPath = (() => {
|
|
469
|
+
try {
|
|
470
|
+
return resolveRepoRootFromTmpMeta(tmpPath, meta);
|
|
471
|
+
} catch {
|
|
472
|
+
return path4.dirname(tmpPath);
|
|
473
|
+
}
|
|
474
|
+
})();
|
|
392
475
|
if (!name)
|
|
393
476
|
continue;
|
|
477
|
+
if (kind == null || !allowedTypes.includes(kind)) {
|
|
478
|
+
const mismatchKey = `${slot}:${tmpPath}`;
|
|
479
|
+
if (!seenMismatch.has(mismatchKey)) {
|
|
480
|
+
seenMismatch.add(mismatchKey);
|
|
481
|
+
mismatches.push({
|
|
482
|
+
slot,
|
|
483
|
+
slotFolder: folderRel,
|
|
484
|
+
projectName: name,
|
|
485
|
+
globalType: explicitType,
|
|
486
|
+
expectedTypes: allowedTypes,
|
|
487
|
+
tmp: tmpPath,
|
|
488
|
+
projectPath
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
394
493
|
const key = `${kind}:${name}`;
|
|
395
494
|
if (seen.has(key))
|
|
396
495
|
continue;
|
|
@@ -398,29 +497,37 @@ function findEntries(workspaceRoot) {
|
|
|
398
497
|
entries.push({
|
|
399
498
|
name,
|
|
400
499
|
type: kind,
|
|
401
|
-
path:
|
|
500
|
+
path: projectPath,
|
|
402
501
|
tmp: tmpPath,
|
|
403
502
|
slot,
|
|
404
503
|
cluster: meta.clusterDeployment ?? meta.projectName
|
|
405
504
|
});
|
|
406
505
|
}
|
|
407
506
|
}
|
|
408
|
-
|
|
507
|
+
const sortEntries = (a, b) => a.type === b.type ? a.name.localeCompare(b.name) : a.type.localeCompare(b.type);
|
|
508
|
+
mismatches.sort((a, b) => a.slot.localeCompare(b.slot) || a.projectName.localeCompare(b.projectName) || a.tmp.localeCompare(b.tmp));
|
|
509
|
+
return {
|
|
510
|
+
entries: entries.sort(sortEntries),
|
|
511
|
+
mismatches
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
function findEntries(workspaceRoot) {
|
|
515
|
+
return scanWorkspaceProjects(workspaceRoot).entries;
|
|
409
516
|
}
|
|
410
517
|
|
|
411
|
-
// source/utils/helpers/
|
|
412
|
-
var
|
|
413
|
-
function
|
|
414
|
-
const override = process.env.XRYSTAL_HOME?.trim();
|
|
518
|
+
// source/utils/helpers/user-home/registry.ts
|
|
519
|
+
var USER_HOME_DIR = ".xrystal";
|
|
520
|
+
function resolveUserHome() {
|
|
521
|
+
const override = process.env.XRY_HOME?.trim() || process.env.XRYSTAL_HOME?.trim();
|
|
415
522
|
if (override)
|
|
416
523
|
return path5.resolve(override);
|
|
417
|
-
return path5.join(os.homedir(),
|
|
524
|
+
return path5.join(os.homedir(), USER_HOME_DIR);
|
|
418
525
|
}
|
|
419
526
|
function registryFilePath() {
|
|
420
|
-
return path5.join(
|
|
527
|
+
return path5.join(resolveUserHome(), "registry.json");
|
|
421
528
|
}
|
|
422
|
-
function
|
|
423
|
-
const home =
|
|
529
|
+
function ensureUserHome() {
|
|
530
|
+
const home = resolveUserHome();
|
|
424
531
|
fs3.mkdirSync(path5.join(home, "workspaces"), { recursive: true });
|
|
425
532
|
return home;
|
|
426
533
|
}
|
|
@@ -453,7 +560,7 @@ function scanWorkspace(workspacePath, workspaceName) {
|
|
|
453
560
|
};
|
|
454
561
|
}
|
|
455
562
|
function readRegistry() {
|
|
456
|
-
|
|
563
|
+
ensureUserHome();
|
|
457
564
|
const file = registryFilePath();
|
|
458
565
|
if (!fs3.existsSync(file)) {
|
|
459
566
|
return { version: 1, updatedAt: new Date().toISOString(), workspaces: [] };
|
|
@@ -461,12 +568,12 @@ function readRegistry() {
|
|
|
461
568
|
return JSON.parse(fs3.readFileSync(file, "utf8"));
|
|
462
569
|
}
|
|
463
570
|
function writeRegistry(registry) {
|
|
464
|
-
|
|
571
|
+
ensureUserHome();
|
|
465
572
|
registry.updatedAt = new Date().toISOString();
|
|
466
573
|
fs3.writeFileSync(registryFilePath(), `${JSON.stringify(registry, null, 2)}
|
|
467
574
|
`);
|
|
468
575
|
for (const ws of registry.workspaces) {
|
|
469
|
-
const wsDir = path5.join(
|
|
576
|
+
const wsDir = path5.join(resolveUserHome(), "workspaces", ws.name);
|
|
470
577
|
fs3.mkdirSync(wsDir, { recursive: true });
|
|
471
578
|
fs3.writeFileSync(path5.join(wsDir, "workspace.json"), `${JSON.stringify(ws, null, 2)}
|
|
472
579
|
`);
|
|
@@ -533,12 +640,12 @@ export {
|
|
|
533
640
|
upsertWorkspace,
|
|
534
641
|
syncRegistryFromPath,
|
|
535
642
|
scanWorkspace,
|
|
536
|
-
|
|
643
|
+
resolveUserHome,
|
|
537
644
|
registryFilePath,
|
|
538
645
|
readRegistry,
|
|
539
646
|
listRegistryProjects,
|
|
540
647
|
healRegistryAtPath,
|
|
541
648
|
entryToRegistryProject,
|
|
542
|
-
|
|
543
|
-
|
|
649
|
+
ensureUserHome,
|
|
650
|
+
USER_HOME_DIR
|
|
544
651
|
};
|