@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
|
@@ -273,13 +273,38 @@ function parseFolderStructure(text) {
|
|
|
273
273
|
["mobile" /* MOBILE */]: readSlot("mobile" /* MOBILE */)
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
|
+
function allowedGlobalTypesForSlot(slot) {
|
|
277
|
+
if (slot === "api" /* API */)
|
|
278
|
+
return ["api-service" /* API_SERVICE */];
|
|
279
|
+
if (slot === "web" /* WEB */ || slot === "mobile" /* MOBILE */) {
|
|
280
|
+
return ["frontend" /* FRONTEND */];
|
|
281
|
+
}
|
|
282
|
+
return [];
|
|
283
|
+
}
|
|
276
284
|
function workspaceDiscoverySlots(fsMap) {
|
|
277
285
|
return [
|
|
278
|
-
{
|
|
279
|
-
|
|
280
|
-
|
|
286
|
+
{
|
|
287
|
+
slot: "api" /* API */,
|
|
288
|
+
folder: fsMap["api" /* API */],
|
|
289
|
+
allowedTypes: allowedGlobalTypesForSlot("api" /* API */)
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
slot: "web" /* WEB */,
|
|
293
|
+
folder: fsMap["web" /* WEB */],
|
|
294
|
+
allowedTypes: allowedGlobalTypesForSlot("web" /* WEB */)
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
slot: "mobile" /* MOBILE */,
|
|
298
|
+
folder: fsMap["mobile" /* MOBILE */],
|
|
299
|
+
allowedTypes: allowedGlobalTypesForSlot("mobile" /* MOBILE */)
|
|
300
|
+
}
|
|
281
301
|
];
|
|
282
302
|
}
|
|
303
|
+
function formatSlotMismatch(mismatch) {
|
|
304
|
+
const expected = mismatch.expectedTypes.join(" | ");
|
|
305
|
+
const got = mismatch.globalType?.trim() || "(missing global.type)";
|
|
306
|
+
return `${mismatch.projectName}: ${got} in ${mismatch.slot}/ slot — expected ${expected}`;
|
|
307
|
+
}
|
|
283
308
|
function entryName(meta) {
|
|
284
309
|
const project = (meta.projectName ?? "").trim();
|
|
285
310
|
return project || null;
|
|
@@ -298,13 +323,38 @@ function entryType(meta, slot) {
|
|
|
298
323
|
return null;
|
|
299
324
|
}
|
|
300
325
|
function findWorkspaceRoot(startDir = process.cwd()) {
|
|
301
|
-
|
|
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;
|
|
302
340
|
for (;; ) {
|
|
303
|
-
const candidate
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
+
}
|
|
308
358
|
}
|
|
309
359
|
const parent = path4.dirname(cur);
|
|
310
360
|
if (parent === cur)
|
|
@@ -313,6 +363,29 @@ function findWorkspaceRoot(startDir = process.cwd()) {
|
|
|
313
363
|
}
|
|
314
364
|
return null;
|
|
315
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
|
+
}
|
|
316
389
|
function isTraversableDir(entry, fullPath) {
|
|
317
390
|
if (entry.isDirectory())
|
|
318
391
|
return true;
|
|
@@ -353,39 +426,70 @@ function walkTmpUnder(rootDir) {
|
|
|
353
426
|
return found;
|
|
354
427
|
}
|
|
355
428
|
function stripDotSlash(value) {
|
|
356
|
-
return value.replace(/^\.\//, "");
|
|
357
|
-
}
|
|
358
|
-
function
|
|
359
|
-
const
|
|
360
|
-
const rootFolder = stripDotSlash(meta.pathsRoot
|
|
361
|
-
const tmpName = stripDotSlash(meta.pathsTmp
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
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);
|
|
365
445
|
}
|
|
366
446
|
throw new Error(`tmp path mismatch: expected */${rel}, got ${abs}`);
|
|
367
447
|
}
|
|
368
|
-
function
|
|
369
|
-
const
|
|
448
|
+
function scanWorkspaceProjects(workspaceRoot) {
|
|
449
|
+
const outerTmp = resolveWorkspaceOuterTmp(workspaceRoot);
|
|
450
|
+
const wsMeta = readTmpFile(outerTmp ?? path4.join(workspaceRoot, TMP_FILE));
|
|
370
451
|
const fsMap = wsMeta.folderStructure;
|
|
371
452
|
const entries = [];
|
|
453
|
+
const mismatches = [];
|
|
372
454
|
const seen = new Set;
|
|
373
|
-
|
|
455
|
+
const seenMismatch = new Set;
|
|
456
|
+
const outerResolved = outerTmp ? path4.resolve(outerTmp) : null;
|
|
457
|
+
for (const { slot, folder: folderRel, allowedTypes } of workspaceDiscoverySlots(fsMap)) {
|
|
374
458
|
const folder = path4.join(workspaceRoot, folderRel);
|
|
375
459
|
for (const tmpPath of walkTmpUnder(folder)) {
|
|
376
|
-
if (path4.resolve(tmpPath) ===
|
|
460
|
+
if (outerResolved && path4.resolve(tmpPath) === outerResolved)
|
|
377
461
|
continue;
|
|
378
462
|
const meta = readTmpFile(tmpPath);
|
|
379
463
|
const kind = entryType(meta, slot);
|
|
380
464
|
if (kind === "workspace" /* WORKSPACE */)
|
|
381
465
|
continue;
|
|
382
|
-
if (frontendOnly && kind !== "frontend" /* FRONTEND */)
|
|
383
|
-
continue;
|
|
384
|
-
if (kind !== "api-service" /* API_SERVICE */ && kind !== "frontend" /* FRONTEND */)
|
|
385
|
-
continue;
|
|
386
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
|
+
})();
|
|
387
475
|
if (!name)
|
|
388
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
|
+
}
|
|
389
493
|
const key = `${kind}:${name}`;
|
|
390
494
|
if (seen.has(key))
|
|
391
495
|
continue;
|
|
@@ -393,14 +497,22 @@ function findEntries(workspaceRoot) {
|
|
|
393
497
|
entries.push({
|
|
394
498
|
name,
|
|
395
499
|
type: kind,
|
|
396
|
-
path:
|
|
500
|
+
path: projectPath,
|
|
397
501
|
tmp: tmpPath,
|
|
398
502
|
slot,
|
|
399
503
|
cluster: meta.clusterDeployment ?? meta.projectName
|
|
400
504
|
});
|
|
401
505
|
}
|
|
402
506
|
}
|
|
403
|
-
|
|
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;
|
|
404
516
|
}
|
|
405
517
|
function findApiServices(workspaceRoot) {
|
|
406
518
|
return findEntries(workspaceRoot).filter((e) => e.type === "api-service" /* API_SERVICE */);
|
|
@@ -410,17 +522,23 @@ function resolveEntryPath(workspaceRoot, name) {
|
|
|
410
522
|
return hit?.path ?? null;
|
|
411
523
|
}
|
|
412
524
|
function workspaceProjectName(workspaceRoot) {
|
|
413
|
-
const
|
|
525
|
+
const tmpPath = resolveWorkspaceOuterTmp(workspaceRoot);
|
|
526
|
+
if (!tmpPath)
|
|
527
|
+
return path4.basename(workspaceRoot);
|
|
528
|
+
const meta = readTmpFile(tmpPath);
|
|
414
529
|
return meta.projectName?.trim() || path4.basename(workspaceRoot);
|
|
415
530
|
}
|
|
416
531
|
function readWorkspaceGlobalTmp(workspaceRoot) {
|
|
417
|
-
const
|
|
532
|
+
const tmpPath = resolveWorkspaceOuterTmp(workspaceRoot);
|
|
533
|
+
if (!tmpPath)
|
|
534
|
+
return {};
|
|
535
|
+
const text = fs2.readFileSync(tmpPath, "utf8");
|
|
418
536
|
const match = text.match(/options:\s*\n(?:[ \t]+[^\n]+\n)*?[ \t]+fileWatchIntervalMs:\s*(\d+)/m) ?? text.match(/fileWatchIntervalMs:\s*(\d+)/);
|
|
419
537
|
return match ? { fileWatchIntervalMs: Number(match[1]) } : {};
|
|
420
538
|
}
|
|
421
539
|
function ensureWorkspaceSlotDirs(workspaceRoot) {
|
|
422
|
-
const tmpPath =
|
|
423
|
-
if (!
|
|
540
|
+
const tmpPath = resolveWorkspaceOuterTmp(workspaceRoot);
|
|
541
|
+
if (!tmpPath)
|
|
424
542
|
return [];
|
|
425
543
|
const meta = readTmpFile(tmpPath);
|
|
426
544
|
const created = [];
|
|
@@ -434,8 +552,8 @@ function ensureWorkspaceSlotDirs(workspaceRoot) {
|
|
|
434
552
|
return created;
|
|
435
553
|
}
|
|
436
554
|
function healWorkspaceOuterTmpOptions(workspaceRoot) {
|
|
437
|
-
const tmpPath =
|
|
438
|
-
if (!
|
|
555
|
+
const tmpPath = resolveWorkspaceOuterTmp(workspaceRoot);
|
|
556
|
+
if (!tmpPath)
|
|
439
557
|
return false;
|
|
440
558
|
const text = fs2.readFileSync(tmpPath, "utf8");
|
|
441
559
|
if (/fileWatchIntervalMs:\s*\d+/m.test(text))
|
|
@@ -458,6 +576,9 @@ function workspaceTmpTemplate(projectName) {
|
|
|
458
576
|
configs:
|
|
459
577
|
global:
|
|
460
578
|
type: workspace
|
|
579
|
+
paths:
|
|
580
|
+
root: .
|
|
581
|
+
tmp: tmp.yml
|
|
461
582
|
options:
|
|
462
583
|
fileWatchIntervalMs: 500
|
|
463
584
|
folder-structure:
|
|
@@ -475,6 +596,9 @@ export {
|
|
|
475
596
|
workspaceTmpTemplate,
|
|
476
597
|
workspaceProjectName,
|
|
477
598
|
workspaceDiscoverySlots,
|
|
599
|
+
scanWorkspaceProjects,
|
|
600
|
+
resolveWorkspaceOuterTmp,
|
|
601
|
+
resolveRepoRootFromTmpMeta,
|
|
478
602
|
resolveEntryPath,
|
|
479
603
|
readWorkspaceGlobalTmp,
|
|
480
604
|
readWorkspaceCoreTmp,
|
|
@@ -482,12 +606,16 @@ export {
|
|
|
482
606
|
parseFolderStructure,
|
|
483
607
|
normalizeGlobalType,
|
|
484
608
|
healWorkspaceOuterTmpOptions,
|
|
609
|
+
formatSlotMismatch,
|
|
485
610
|
findWorkspaceRoot,
|
|
611
|
+
findWorkspaceAnchor,
|
|
486
612
|
findEntries,
|
|
487
613
|
findApiServices,
|
|
488
614
|
entryType,
|
|
489
615
|
entryName,
|
|
490
616
|
ensureWorkspaceSlotDirs,
|
|
617
|
+
buildRepoTmpRelPath,
|
|
618
|
+
allowedGlobalTypesForSlot,
|
|
491
619
|
TMP_FILE,
|
|
492
620
|
SKIP_DIRS,
|
|
493
621
|
DEFAULT_FOLDER_STRUCTURE
|
|
@@ -67,6 +67,13 @@ const MESSAGES = {
|
|
|
67
67
|
{ ctx: 'Global registry only', cmd: 'workspaces sync', effect: 'rescan ~/.xrystal from cwd' },
|
|
68
68
|
],
|
|
69
69
|
syncScopeHint: 'shows which row applies to your cwd',
|
|
70
|
+
registry: {
|
|
71
|
+
noWorkspaces: 'no workspaces registered — run xry create demo --workspace then xry workspaces sync',
|
|
72
|
+
noProjects: 'projects: (none linked yet)',
|
|
73
|
+
slotEmpty: '(empty)',
|
|
74
|
+
slotMismatches: 'slot mismatches (wrong global.type for folder slot)',
|
|
75
|
+
other: 'other',
|
|
76
|
+
},
|
|
70
77
|
},
|
|
71
78
|
[CliLangEnum.TR]: {
|
|
72
79
|
langTip: 'Dil: xry config lang tr (~/.xrystal/config.json)',
|
|
@@ -129,6 +136,13 @@ const MESSAGES = {
|
|
|
129
136
|
{ ctx: 'Sadece global registry', cmd: 'workspaces sync', effect: '~/.xrystal yeniden tara' },
|
|
130
137
|
],
|
|
131
138
|
syncScopeHint: 'hangi satırın cwd\'ne uyduğunu gösterir',
|
|
139
|
+
registry: {
|
|
140
|
+
noWorkspaces: 'kayıtlı workspace yok — xry create demo --workspace sonra xry workspaces sync',
|
|
141
|
+
noProjects: 'projeler: (henüz link yok)',
|
|
142
|
+
slotEmpty: '(boş)',
|
|
143
|
+
slotMismatches: 'slot uyumsuzlukları (global.type bu klasör slotuna uymuyor)',
|
|
144
|
+
other: 'diğer',
|
|
145
|
+
},
|
|
132
146
|
},
|
|
133
147
|
}
|
|
134
148
|
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
DEFAULT_FOLDER_STRUCTURE,
|
|
6
6
|
findWorkspaceRoot,
|
|
7
7
|
readTmpFile,
|
|
8
|
+
resolveWorkspaceOuterTmp,
|
|
8
9
|
} from './workspace-resolve.mjs'
|
|
9
10
|
import { WorkspaceSlotEnum } from './cli-enums.mjs'
|
|
10
11
|
|
|
@@ -51,7 +52,10 @@ export function resolveCreateTarget(projectName, targetDir, { slot = WorkspaceSl
|
|
|
51
52
|
|
|
52
53
|
if (workspaceRoot) {
|
|
53
54
|
const wsRoot = resolveReal(workspaceRoot)
|
|
54
|
-
const wsTmp =
|
|
55
|
+
const wsTmp = resolveWorkspaceOuterTmp(wsRoot)
|
|
56
|
+
if (!wsTmp) {
|
|
57
|
+
throw new Error(`Workspace outer tmp.yml not found under ${wsRoot}`)
|
|
58
|
+
}
|
|
55
59
|
const fsMap = readTmpFile(wsTmp).folderStructure
|
|
56
60
|
const slotFolder = fsMap[slot] ?? DEFAULT_FOLDER_STRUCTURE[slot]
|
|
57
61
|
const slotRoot = path.join(wsRoot, slotFolder)
|
|
@@ -20,8 +20,8 @@ function cliGeneratedModules() {
|
|
|
20
20
|
outfile: path.join(CLI_GENERATED_DIR, 'tmp-schema.mjs'),
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
|
-
source: `${main}/utils/helpers/
|
|
24
|
-
outfile: path.join(CLI_GENERATED_DIR, '
|
|
23
|
+
source: `${main}/utils/helpers/user-home/registry.ts`,
|
|
24
|
+
outfile: path.join(CLI_GENERATED_DIR, 'user-home-registry.mjs'),
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
source: `${main}/utils/helpers/workspace/index.ts`,
|
|
@@ -4,7 +4,7 @@ import yaml from 'yaml'
|
|
|
4
4
|
|
|
5
5
|
import { packageDefaults } from './package-defaults.mjs'
|
|
6
6
|
import { isCorePackageRoot } from './tmp-layout.mjs'
|
|
7
|
-
import {
|
|
7
|
+
import { findWorkspaceRoot, resolveWorkspaceOuterTmp, scanWorkspaceProjects, workspaceProjectName } from './workspace-resolve.mjs'
|
|
8
8
|
import { getInstalledCoreVersion, readCliPackageJson, readProjectPackageJson, resolveProjectRoot } from './project-root.mjs'
|
|
9
9
|
import { readTmpSchemaVersion, TMP_SCHEMA_VERSION } from './tmp-schema-version.mjs'
|
|
10
10
|
import { GlobalTypeEnum, ProjectScopeKindEnum } from './cli-enums.mjs'
|
|
@@ -30,8 +30,7 @@ function readTmpMeta(tmpFilePath) {
|
|
|
30
30
|
function findOuterWorkspaceTmp(startDir) {
|
|
31
31
|
const wsRoot = findWorkspaceRoot(startDir)
|
|
32
32
|
if (!wsRoot) return null
|
|
33
|
-
|
|
34
|
-
return fs.existsSync(outer) ? outer : null
|
|
33
|
+
return resolveWorkspaceOuterTmp(wsRoot)
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
export function resolveProjectContext(startDir = process.cwd()) {
|
|
@@ -110,10 +109,16 @@ export function resolveProjectContext(startDir = process.cwd()) {
|
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
const
|
|
112
|
+
const workspaceScan = workspaceRoot ? scanWorkspaceProjects(workspaceRoot) : { entries: [], mismatches: [] }
|
|
113
|
+
const workspaceEntries = workspaceScan.entries
|
|
114
|
+
const slotMismatches = workspaceScan.mismatches
|
|
114
115
|
const selfEntry = workspaceEntries.find((e) => path.resolve(e.path) === path.resolve(projectRoot))
|
|
116
|
+
const selfMismatch = slotMismatches.find((m) => path.resolve(m.projectPath) === path.resolve(projectRoot))
|
|
115
117
|
|
|
116
118
|
const hints = []
|
|
119
|
+
if (slotMismatches.length > 0) {
|
|
120
|
+
hints.push('Fix slot/type mismatches — api slot → api-service · web/mobile → frontend')
|
|
121
|
+
}
|
|
117
122
|
if (kind === ProjectScopeKindEnum.WORKSPACE_ROOT) {
|
|
118
123
|
hints.push('Outer tmp: ./tmp.yml · inner tmp: each api|web|mobile project (admin → web/)')
|
|
119
124
|
hints.push('xry sync — all linked projects + ~/.xrystal registry')
|
|
@@ -142,6 +147,8 @@ export function resolveProjectContext(startDir = process.cwd()) {
|
|
|
142
147
|
innerTmp: innerMeta,
|
|
143
148
|
tmp: innerMeta ?? outerMeta,
|
|
144
149
|
selfEntry: selfEntry ?? null,
|
|
150
|
+
selfMismatch: selfMismatch ?? null,
|
|
151
|
+
slotMismatches,
|
|
145
152
|
package: pkg,
|
|
146
153
|
core: {
|
|
147
154
|
cli: cliVersion,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { WorkspaceSlotEnum } from './cli-enums.mjs'
|
|
2
|
+
|
|
3
|
+
export const REGISTRY_SLOT_ORDER = [
|
|
4
|
+
WorkspaceSlotEnum.API,
|
|
5
|
+
WorkspaceSlotEnum.WEB,
|
|
6
|
+
WorkspaceSlotEnum.MOBILE,
|
|
7
|
+
]
|
|
8
|
+
|
|
9
|
+
/** @param {Array<{ slot?: string }>} projects */
|
|
10
|
+
export function groupProjectsBySlot(projects) {
|
|
11
|
+
const groups = Object.fromEntries(REGISTRY_SLOT_ORDER.map((slot) => [slot, []]))
|
|
12
|
+
/** @type {typeof projects} */
|
|
13
|
+
const other = []
|
|
14
|
+
|
|
15
|
+
for (const project of projects) {
|
|
16
|
+
const slot = project.slot
|
|
17
|
+
if (slot && groups[slot]) {
|
|
18
|
+
groups[slot].push(project)
|
|
19
|
+
continue
|
|
20
|
+
}
|
|
21
|
+
other.push(project)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
for (const slot of REGISTRY_SLOT_ORDER) {
|
|
25
|
+
groups[slot].sort((a, b) => a.name.localeCompare(b.name))
|
|
26
|
+
}
|
|
27
|
+
other.sort((a, b) => a.name.localeCompare(b.name))
|
|
28
|
+
|
|
29
|
+
return { groups, other }
|
|
30
|
+
}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
export {
|
|
2
2
|
DEFAULT_FOLDER_STRUCTURE,
|
|
3
|
+
allowedGlobalTypesForSlot,
|
|
4
|
+
buildRepoTmpRelPath,
|
|
3
5
|
ensureWorkspaceSlotDirs,
|
|
4
6
|
findApiServices,
|
|
5
7
|
findEntries,
|
|
8
|
+
findWorkspaceAnchor,
|
|
6
9
|
findWorkspaceRoot,
|
|
10
|
+
formatSlotMismatch,
|
|
7
11
|
healWorkspaceOuterTmpOptions,
|
|
8
12
|
normalizeGlobalType,
|
|
9
13
|
parseFolderStructure,
|
|
10
14
|
readTmpFile,
|
|
11
15
|
readWorkspaceCoreTmp,
|
|
12
16
|
resolveEntryPath,
|
|
17
|
+
resolveRepoRootFromTmpMeta,
|
|
18
|
+
resolveWorkspaceOuterTmp,
|
|
19
|
+
scanWorkspaceProjects,
|
|
13
20
|
workspaceProjectName,
|
|
14
21
|
workspaceTmpTemplate,
|
|
15
22
|
} from './.generated/workspace.mjs'
|
|
@@ -2,15 +2,21 @@ import fs from 'node:fs'
|
|
|
2
2
|
import path from 'node:path'
|
|
3
3
|
|
|
4
4
|
import { ensureTmpSchemaVersion } from './tmp-schema-version.mjs'
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
resolveWorkspaceOuterTmp,
|
|
7
|
+
workspaceProjectName,
|
|
8
|
+
workspaceTmpTemplate,
|
|
9
|
+
} from './workspace-resolve.mjs'
|
|
6
10
|
import { runWorkspaceSelfHeal } from './workspace-heal.mjs'
|
|
7
11
|
|
|
8
12
|
export function ensureOuterWorkspaceTmp(workspaceRoot, { projectName } = {}) {
|
|
9
13
|
const resolved = path.resolve(workspaceRoot)
|
|
10
|
-
const
|
|
14
|
+
const existing = resolveWorkspaceOuterTmp(resolved)
|
|
15
|
+
let tmpPath = existing
|
|
11
16
|
let created = false
|
|
12
17
|
|
|
13
|
-
if (!
|
|
18
|
+
if (!tmpPath) {
|
|
19
|
+
tmpPath = path.join(resolved, 'tmp.yml')
|
|
14
20
|
const name = projectName ?? workspaceProjectName(resolved)
|
|
15
21
|
fs.writeFileSync(tmpPath, workspaceTmpTemplate(name))
|
|
16
22
|
created = true
|
|
@@ -2,16 +2,16 @@ import fs from 'node:fs'
|
|
|
2
2
|
import path from 'node:path'
|
|
3
3
|
|
|
4
4
|
import { CliLangEnum, normalizeCliLang } from './cli-lang.mjs'
|
|
5
|
-
import {
|
|
5
|
+
import { ensureUserHome, resolveUserHome } from './xrystal-registry.mjs'
|
|
6
6
|
|
|
7
7
|
const CONFIG_VERSION = 1
|
|
8
8
|
|
|
9
9
|
export function configFilePath() {
|
|
10
|
-
return `${
|
|
10
|
+
return `${resolveUserHome()}/config.json`
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function readXrystalConfig() {
|
|
14
|
-
|
|
14
|
+
ensureUserHome()
|
|
15
15
|
const file = configFilePath()
|
|
16
16
|
if (!fs.existsSync(file)) {
|
|
17
17
|
return { version: CONFIG_VERSION, cli: {} }
|
|
@@ -29,7 +29,7 @@ export function readXrystalConfig() {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export function writeXrystalConfig(next) {
|
|
32
|
-
|
|
32
|
+
ensureUserHome()
|
|
33
33
|
const current = readXrystalConfig()
|
|
34
34
|
const merged = {
|
|
35
35
|
version: CONFIG_VERSION,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export {
|
|
2
|
-
|
|
2
|
+
ensureUserHome,
|
|
3
3
|
entryToRegistryProject,
|
|
4
4
|
healRegistryAtPath,
|
|
5
5
|
listRegistryProjects,
|
|
6
6
|
readRegistry,
|
|
7
7
|
registryFilePath,
|
|
8
|
-
|
|
8
|
+
resolveUserHome,
|
|
9
9
|
scanWorkspace,
|
|
10
10
|
syncRegistryFromPath,
|
|
11
11
|
upsertWorkspace,
|
|
12
12
|
writeRegistry,
|
|
13
|
-
|
|
14
|
-
} from './.generated/
|
|
13
|
+
USER_HOME_DIR,
|
|
14
|
+
} from './.generated/user-home-registry.mjs'
|
|
@@ -3,7 +3,7 @@ import path from 'node:path'
|
|
|
3
3
|
|
|
4
4
|
import { packageDefaults } from './package-defaults.mjs'
|
|
5
5
|
import { findEntries, readWorkspaceCoreTmp } from './workspace-resolve.mjs'
|
|
6
|
-
import { readRegistry, registryFilePath,
|
|
6
|
+
import { readRegistry, registryFilePath, resolveUserHome } from './xrystal-registry.mjs'
|
|
7
7
|
import { runWorkspaceSelfHeal } from './workspace-heal.mjs'
|
|
8
8
|
import { watchPidPath } from './xrystal-watch-spawn.mjs'
|
|
9
9
|
|
|
@@ -57,7 +57,7 @@ export function collectWatchTargets(registry = readRegistry()) {
|
|
|
57
57
|
|
|
58
58
|
function appendWatchLog(line) {
|
|
59
59
|
try {
|
|
60
|
-
fs.appendFileSync(path.join(
|
|
60
|
+
fs.appendFileSync(path.join(resolveUserHome(), 'watch.log'), `${new Date().toISOString()} ${line}\n`)
|
|
61
61
|
} catch {
|
|
62
62
|
// ignore log failures
|
|
63
63
|
}
|
|
@@ -65,7 +65,7 @@ function appendWatchLog(line) {
|
|
|
65
65
|
|
|
66
66
|
export function runWatchDaemonMain() {
|
|
67
67
|
const pidFile = watchPidPath()
|
|
68
|
-
fs.mkdirSync(
|
|
68
|
+
fs.mkdirSync(resolveUserHome(), { recursive: true })
|
|
69
69
|
fs.writeFileSync(pidFile, `${process.pid}\n`)
|
|
70
70
|
|
|
71
71
|
const active = new Map()
|
|
@@ -3,7 +3,7 @@ import fs from 'node:fs'
|
|
|
3
3
|
import os from 'node:os'
|
|
4
4
|
import path from 'node:path'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { resolveUserHome } from './xrystal-registry.mjs'
|
|
7
7
|
import { watchDaemonScriptPath, watchLogPath } from './xrystal-watch-spawn.mjs'
|
|
8
8
|
|
|
9
9
|
const LAUNCHD_LABEL = 'com.xrystal.watch'
|
|
@@ -111,7 +111,7 @@ export function watchServiceStatus() {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
export function installWatchService() {
|
|
114
|
-
fs.mkdirSync(
|
|
114
|
+
fs.mkdirSync(resolveUserHome(), { recursive: true })
|
|
115
115
|
|
|
116
116
|
const platform = detectWatchServicePlatform()
|
|
117
117
|
if (platform === 'launchd') {
|
|
@@ -3,7 +3,7 @@ import fs from 'node:fs'
|
|
|
3
3
|
import path from 'node:path'
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { resolveUserHome } from './xrystal-registry.mjs'
|
|
7
7
|
|
|
8
8
|
const HELPERS_DIR = path.dirname(fileURLToPath(import.meta.url))
|
|
9
9
|
|
|
@@ -12,11 +12,11 @@ export function watchDaemonScriptPath() {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export function watchPidPath() {
|
|
15
|
-
return path.join(
|
|
15
|
+
return path.join(resolveUserHome(), 'watch.pid')
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export function watchLogPath() {
|
|
19
|
-
return path.join(
|
|
19
|
+
return path.join(resolveUserHome(), 'watch.log')
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export function watchDaemonStatus() {
|
|
@@ -3,7 +3,7 @@ export { getTmpLoader, getTmpLoaderPath, getTmpSnapshot, onTmpReload, resetTmpLo
|
|
|
3
3
|
export { bindLoaderTmpSync, type ITmpSyncLoader, } from '../../../utils/helpers/tmp/loader-tmp-sync';
|
|
4
4
|
export { resolveTmpWatchIntervalMs } from '../../../utils/helpers/tmp/tmp-watch';
|
|
5
5
|
export { resolveLoaderBootPlan, isInfraLoaderEnabled, LoaderBootProfileEnum, InfraLoaderEnum, type LoaderBootPlan, } from '../../../utils/helpers/tmp/loader-boot-plan';
|
|
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';
|
|
6
|
+
export { normalizeTmpDocument, buildTmpRelPath, 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';
|
|
9
9
|
export { healToolchainIfLayoutNeedsSync, layoutFingerprint, layoutOptionsFromRuntimeConfigs, resetToolchainHealState, writeTsconfigFromLayout, auditTsconfigAgainstLayout, type ToolchainHealResult, type ToolchainLayoutOptions, } from '../../../utils/helpers/tmp/toolchain-heal';
|
|
@@ -3,7 +3,7 @@ export { getTmpLoader, getTmpLoaderPath, getTmpSnapshot, onTmpReload, resetTmpLo
|
|
|
3
3
|
export { bindLoaderTmpSync, } from '../../../utils/helpers/tmp/loader-tmp-sync.js';
|
|
4
4
|
export { resolveTmpWatchIntervalMs } from '../../../utils/helpers/tmp/tmp-watch.js';
|
|
5
5
|
export { resolveLoaderBootPlan, isInfraLoaderEnabled, LoaderBootProfileEnum, InfraLoaderEnum, } from '../../../utils/helpers/tmp/loader-boot-plan.js';
|
|
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';
|
|
6
|
+
export { normalizeTmpDocument, buildTmpRelPath, 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';
|
|
9
9
|
export { healToolchainIfLayoutNeedsSync, layoutFingerprint, layoutOptionsFromRuntimeConfigs, resetToolchainHealState, writeTsconfigFromLayout, auditTsconfigAgainstLayout, } from '../../../utils/helpers/tmp/toolchain-heal.js';
|
|
@@ -52,6 +52,8 @@ export declare function resolveEffectiveBundler(bundler: BundlerEnum, _runtime:
|
|
|
52
52
|
export declare function normalizeRootFolder(value?: string): string;
|
|
53
53
|
export declare function normalizeSourceFolder(value?: string): string;
|
|
54
54
|
export declare function readTmpGlobalPathsBlock(configs?: Record<string, unknown>): TmpGlobalPathsBlock;
|
|
55
|
+
/** Join paths.root + paths.tmp → relative path from project/workspace root (dynamic). */
|
|
56
|
+
export declare function buildTmpRelPath(rootFolder: string, tmpFileName: string): string;
|
|
55
57
|
export declare function resolveMergedPaths(configs?: Record<string, unknown>): TmpMergedPaths;
|
|
56
58
|
export declare function readTmpGlobalBlock(configs?: Record<string, unknown>): TmpGlobalBlock;
|
|
57
59
|
/** Reject removed tmp.yml keys (depends.build, cluster, etc.). */
|