@xrystal/core 3.51.5 → 3.52.0
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 +35 -1
- package/package.json +1 -1
- package/x/bin/commands/create.mjs +44 -0
- package/x/bin/commands/projects.mjs +53 -0
- package/x/bin/commands/sync.mjs +49 -1
- package/x/bin/commands/tmp.mjs +1 -1
- package/x/bin/helpers/.generated/.generated-from +2 -0
- package/x/bin/helpers/.generated/seed-from-tmp.mjs +25 -31
- package/x/bin/helpers/.generated/tmp-schema.mjs +156 -96
- package/x/bin/helpers/.generated/workspace.mjs +402 -0
- package/x/bin/helpers/.generated/xrystal-home-registry.mjs +310 -0
- package/x/bin/helpers/build-config.mjs +3 -2
- package/x/bin/helpers/cli-help.mjs +3 -1
- package/x/bin/helpers/project-artifacts.mjs +9 -0
- package/x/bin/helpers/tmp-config.mjs +13 -12
- package/x/bin/helpers/tmp-layout.mjs +28 -52
- package/x/bin/helpers/tmp-schema.mjs +9 -3
- package/x/bin/helpers/workspace-resolve.mjs +11 -0
- package/x/bin/helpers/workspace-scaffold.mjs +23 -0
- package/x/bin/helpers/xrystal-registry.mjs +13 -0
- package/x/bin/main-cli.js +2 -0
- package/x/dist/index.js +5 -1
- package/x/dist/loader/clients/index.js +22 -1
- package/x/dist/loader/configs/index.js +97 -1
- package/x/dist/loader/controller/index.js +267 -1
- package/x/dist/loader/dto/index.js +92 -1
- package/x/dist/loader/events/index.js +39 -1
- package/x/dist/loader/index.js +13 -1
- package/x/dist/loader/kafka/index.js +142 -1
- package/x/dist/loader/kafka/resolve-ssl.js +23 -1
- package/x/dist/loader/localizations/index.js +46 -1
- package/x/dist/loader/logger/index.js +229 -2
- package/x/dist/loader/mongo/index.js +52 -1
- package/x/dist/loader/mongo/resolve-connect.js +16 -1
- package/x/dist/loader/redis/index.js +57 -1
- package/x/dist/loader/redis/resolve-socket.js +31 -1
- package/x/dist/loader/registry/index.js +1 -1
- package/x/dist/loader/service/index.js +7 -1
- package/x/dist/loader/system/index.js +26 -1
- package/x/dist/project/index.js +51 -1
- package/x/dist/utils/constants/defaults.json +3 -1
- package/x/dist/utils/constants/index.d.ts +1 -0
- package/x/dist/utils/constants/index.js +42 -1
- package/x/dist/utils/constants/package-root.js +6 -1
- package/x/dist/utils/helpers/configs/index.js +1 -1
- package/x/dist/utils/helpers/context/controller-store.js +12 -1
- package/x/dist/utils/helpers/context/index.js +24 -1
- package/x/dist/utils/helpers/core/handlebars-resolve.js +15 -1
- package/x/dist/utils/helpers/core/index.js +46 -1
- package/x/dist/utils/helpers/core/paths.js +78 -1
- package/x/dist/utils/helpers/core/tmp-layout.d.ts +4 -4
- package/x/dist/utils/helpers/core/tmp-layout.js +229 -1
- package/x/dist/utils/helpers/date/index.js +48 -1
- package/x/dist/utils/helpers/dispatch/index.js +53 -1
- package/x/dist/utils/helpers/dto/index.js +10 -1
- package/x/dist/utils/helpers/filters/index.js +44 -1
- package/x/dist/utils/helpers/framework/index.js +18 -1
- package/x/dist/utils/helpers/handlers/adapters.js +41 -1
- package/x/dist/utils/helpers/handlers/execute.js +82 -1
- package/x/dist/utils/helpers/handlers/index.js +31 -1
- package/x/dist/utils/helpers/hash/crypto.js +22 -1
- package/x/dist/utils/helpers/id/index.js +24 -1
- package/x/dist/utils/helpers/index.d.ts +1 -0
- package/x/dist/utils/helpers/index.js +28 -1
- package/x/dist/utils/helpers/ip/index.js +21 -1
- package/x/dist/utils/helpers/is/index.js +35 -1
- package/x/dist/utils/helpers/kafka-loader-options/index.js +14 -1
- package/x/dist/utils/helpers/locales/index.js +82 -1
- package/x/dist/utils/helpers/logger-layer/index.js +33 -1
- package/x/dist/utils/helpers/math/index.js +14 -1
- package/x/dist/utils/helpers/middleware/index.js +36 -1
- package/x/dist/utils/helpers/node-env/index.js +20 -1
- package/x/dist/utils/helpers/objects/index.js +55 -1
- package/x/dist/utils/helpers/path/index.js +5 -1
- package/x/dist/utils/helpers/path/resolve-alias-path.d.ts +1 -1
- package/x/dist/utils/helpers/path/resolve-alias-path.js +62 -1
- package/x/dist/utils/helpers/protocol/index.d.ts +1 -1
- package/x/dist/utils/helpers/protocol/index.js +100 -1
- package/x/dist/utils/helpers/protocol/options.js +13 -1
- package/x/dist/utils/helpers/regex/checkSpecialRegexControl.js +3 -1
- package/x/dist/utils/helpers/registry/index.d.ts +6 -0
- package/x/dist/utils/helpers/registry/index.js +103 -1
- package/x/dist/utils/helpers/runtime/dto-access.js +5 -1
- package/x/dist/utils/helpers/runtime/dto-types.js +1 -1
- package/x/dist/utils/helpers/runtime/index.js +2 -1
- package/x/dist/utils/helpers/runtime/shutdown.js +36 -1
- package/x/dist/utils/helpers/state/index.js +185 -1
- package/x/dist/utils/helpers/state/props-from-tmp.js +46 -1
- package/x/dist/utils/helpers/state/request-key-guard.js +43 -1
- package/x/dist/utils/helpers/state/scopes.js +69 -1
- package/x/dist/utils/helpers/string/index.js +9 -1
- package/x/dist/utils/helpers/timer/index.js +5 -1
- package/x/dist/utils/helpers/tmp/index.d.ts +2 -2
- package/x/dist/utils/helpers/tmp/index.js +8 -1
- package/x/dist/utils/helpers/tmp/loader-tmp-sync.js +14 -1
- package/x/dist/utils/helpers/tmp/path-normalize.js +27 -1
- package/x/dist/utils/helpers/tmp/runtime-tmp.js +42 -1
- package/x/dist/utils/helpers/tmp/seed-from-tmp.d.ts +2 -2
- package/x/dist/utils/helpers/tmp/seed-from-tmp.js +62 -1
- package/x/dist/utils/helpers/tmp/tmp-interpolate.js +22 -1
- package/x/dist/utils/helpers/tmp/tmp-loader.js +56 -1
- package/x/dist/utils/helpers/tmp/tmp-schema.d.ts +35 -23
- package/x/dist/utils/helpers/tmp/tmp-schema.js +211 -1
- package/x/dist/utils/helpers/tmp/tmp-watch.js +23 -1
- package/x/dist/utils/helpers/tmp/toolchain-heal.js +157 -2
- package/x/dist/utils/helpers/validates/index.js +20 -1
- package/x/dist/utils/helpers/workspace/index.d.ts +42 -0
- package/x/dist/utils/helpers/workspace/index.js +222 -0
- package/x/dist/utils/helpers/xrystal-home/registry.d.ts +32 -0
- package/x/dist/utils/helpers/xrystal-home/registry.js +92 -0
- package/x/dist/utils/index.js +3 -1
- package/x/dist/utils/models/classes/class.clients.js +142 -1
- package/x/dist/utils/models/classes/class.interfaces.js +10 -1
- package/x/dist/utils/models/classes/class.service-locator.js +16 -1
- package/x/dist/utils/models/classes/class.tmp-file-loader.js +61 -1
- package/x/dist/utils/models/classes/class.x.js +181 -1
- package/x/dist/utils/models/enums/index.d.ts +9 -1
- package/x/dist/utils/models/enums/index.js +169 -1
- package/x/dist/utils/models/index.js +9 -1
- package/x/dist/utils/models/types/index.js +2 -1
- package/x/tmp.yml +7 -50
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
// source/utils/helpers/workspace/index.ts
|
|
2
|
+
import fs2 from "node:fs";
|
|
3
|
+
import path2 from "node:path";
|
|
4
|
+
|
|
5
|
+
// source/utils/models/enums/index.ts
|
|
6
|
+
var GlobalTypeEnum;
|
|
7
|
+
((GlobalTypeEnum2) => {
|
|
8
|
+
GlobalTypeEnum2["WORKSPACE"] = "workspace";
|
|
9
|
+
GlobalTypeEnum2["API_SERVICE"] = "api-service";
|
|
10
|
+
GlobalTypeEnum2["FRONTEND"] = "frontend";
|
|
11
|
+
})(GlobalTypeEnum ||= {});
|
|
12
|
+
// source/utils/constants/defaults.json
|
|
13
|
+
var defaults_default = {
|
|
14
|
+
packageName: "@xrystal/core",
|
|
15
|
+
packageRootFolder: "x",
|
|
16
|
+
cliName: "xry",
|
|
17
|
+
cliBinNames: [
|
|
18
|
+
"xry"
|
|
19
|
+
],
|
|
20
|
+
cliBinFile: "main-cli.js",
|
|
21
|
+
tmpBaseName: "tmp",
|
|
22
|
+
tmpExtension: ".yml",
|
|
23
|
+
apiServiceTemplateRel: "x/templates/api-service/tmp.yml",
|
|
24
|
+
templateRepoUri: "https://github.com/xdloper/api-gpt-svc",
|
|
25
|
+
publicFolderName: "public",
|
|
26
|
+
kafkaLogsTopic: "log",
|
|
27
|
+
pathAliasKey: "@/*",
|
|
28
|
+
eslintRestrictedImportDepth: 2,
|
|
29
|
+
brand: {
|
|
30
|
+
primary: "xrystal",
|
|
31
|
+
secondary: "core",
|
|
32
|
+
tagline: "microservice runtime library",
|
|
33
|
+
capabilities: "loaders · tmp.yml · dto · i18n · multi-protocol · scaffold"
|
|
34
|
+
},
|
|
35
|
+
runtimes: {
|
|
36
|
+
bun: {
|
|
37
|
+
label: "Bun",
|
|
38
|
+
packageManager: "bun",
|
|
39
|
+
installCommand: "bun install",
|
|
40
|
+
scriptRunner: "bun run",
|
|
41
|
+
binRunner: "bun",
|
|
42
|
+
testRunner: "bun test",
|
|
43
|
+
tscBin: "bunx tsc",
|
|
44
|
+
esbuildBin: "bunx esbuild",
|
|
45
|
+
devInvoker: null
|
|
46
|
+
},
|
|
47
|
+
node: {
|
|
48
|
+
label: "Node.js",
|
|
49
|
+
packageManager: "npm",
|
|
50
|
+
installCommand: "npm install",
|
|
51
|
+
scriptRunner: "npm run",
|
|
52
|
+
binRunner: "node",
|
|
53
|
+
testRunner: "node --test",
|
|
54
|
+
tscBin: "npx tsc",
|
|
55
|
+
esbuildBin: "npx esbuild",
|
|
56
|
+
devInvoker: "npx"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
bundlers: [
|
|
60
|
+
"auto",
|
|
61
|
+
"bun",
|
|
62
|
+
"tsc",
|
|
63
|
+
"esbuild"
|
|
64
|
+
],
|
|
65
|
+
tmpWatchDefaults: {
|
|
66
|
+
intervalMs: 500,
|
|
67
|
+
minIntervalMs: 100,
|
|
68
|
+
maxIntervalMs: 1e4
|
|
69
|
+
},
|
|
70
|
+
buildDefaults: {
|
|
71
|
+
bundler: "auto",
|
|
72
|
+
tsconfig: "tsconfig.json",
|
|
73
|
+
typecheck: false,
|
|
74
|
+
tscLenient: true,
|
|
75
|
+
declarations: false,
|
|
76
|
+
sourcemap: false,
|
|
77
|
+
minify: false
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// source/utils/helpers/tmp/seed-from-tmp.ts
|
|
82
|
+
import fs from "node:fs";
|
|
83
|
+
import path from "node:path";
|
|
84
|
+
import { fileURLToPath } from "node:url";
|
|
85
|
+
import yaml from "yaml";
|
|
86
|
+
|
|
87
|
+
// source/utils/helpers/tmp/path-normalize.ts
|
|
88
|
+
function normalizeRootFolder(value, fallback) {
|
|
89
|
+
if (typeof value !== "string" || !value.trim())
|
|
90
|
+
return fallback;
|
|
91
|
+
return value.trim().replace(/^\.\/+/, "");
|
|
92
|
+
}
|
|
93
|
+
function normalizeSourceFolder(value, fallback) {
|
|
94
|
+
if (typeof value !== "string" || !value.trim())
|
|
95
|
+
return fallback;
|
|
96
|
+
const trimmed = value.trim();
|
|
97
|
+
if (trimmed.startsWith("./") || trimmed.startsWith("../"))
|
|
98
|
+
return trimmed;
|
|
99
|
+
return `./${trimmed}`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// source/utils/helpers/tmp/seed-from-tmp.ts
|
|
103
|
+
var here = path.dirname(fileURLToPath(import.meta.url));
|
|
104
|
+
var templateRel = defaults_default.apiServiceTemplateRel ?? "x/templates/api-service/tmp.yml";
|
|
105
|
+
function requireString(value, label) {
|
|
106
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
107
|
+
throw new Error(`${defaults_default.packageName}: bundled template missing ${label}`);
|
|
108
|
+
}
|
|
109
|
+
return value.trim();
|
|
110
|
+
}
|
|
111
|
+
function readLayoutFromSpecial(special) {
|
|
112
|
+
const block = special && typeof special === "object" && !Array.isArray(special) ? special : {};
|
|
113
|
+
return {
|
|
114
|
+
tests: requireString(block.tests, "configs.global.paths.special.tests"),
|
|
115
|
+
environments: requireString(block.environments, "configs.global.paths.special.environments"),
|
|
116
|
+
dist: requireString(block.dist, "configs.global.paths.special.dist")
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function findApiTemplate() {
|
|
120
|
+
const starts = [here, process.cwd()].map((value) => path.resolve(value));
|
|
121
|
+
for (const start of starts) {
|
|
122
|
+
let dir = start;
|
|
123
|
+
for (;; ) {
|
|
124
|
+
const candidate = path.join(dir, templateRel);
|
|
125
|
+
if (fs.existsSync(candidate))
|
|
126
|
+
return candidate;
|
|
127
|
+
const parent = path.dirname(dir);
|
|
128
|
+
if (parent === dir)
|
|
129
|
+
break;
|
|
130
|
+
dir = parent;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
throw new Error(`${defaults_default.packageName}: api-service template not found (${templateRel})`);
|
|
134
|
+
}
|
|
135
|
+
function loadSeedFromBundledTmp(tmpFilePath) {
|
|
136
|
+
const file = tmpFilePath ?? findApiTemplate();
|
|
137
|
+
const doc = yaml.parse(fs.readFileSync(file, "utf8"));
|
|
138
|
+
const configs = doc?.configs && typeof doc.configs === "object" ? doc.configs : {};
|
|
139
|
+
const global = configs.global && typeof configs.global === "object" ? configs.global : {};
|
|
140
|
+
const paths = global.paths && typeof global.paths === "object" ? global.paths : {};
|
|
141
|
+
const special = paths.special;
|
|
142
|
+
const root = requireString(paths.root, "configs.global.paths.root");
|
|
143
|
+
const rootNorm = normalizeRootFolder(root, defaults_default.packageRootFolder).replace(/^\.\//, "");
|
|
144
|
+
const tmpName = typeof paths.tmp === "string" && paths.tmp.trim() ? paths.tmp.trim().replace(/^\.\//, "") : "tmp.yml";
|
|
145
|
+
const sourceRaw = requireString(paths.source, "configs.global.paths.source");
|
|
146
|
+
return {
|
|
147
|
+
rootFolder: rootNorm,
|
|
148
|
+
sourceFolder: normalizeSourceFolder(sourceRaw, sourceRaw),
|
|
149
|
+
framework: requireString(global.framework, "configs.global.framework"),
|
|
150
|
+
layout: readLayoutFromSpecial(special),
|
|
151
|
+
tmpRelPath: `${rootNorm}/${tmpName}`.replace(/\/+/g, "/")
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
var seedFromTmp = loadSeedFromBundledTmp();
|
|
155
|
+
|
|
156
|
+
// source/utils/helpers/tmp/tmp-interpolate.ts
|
|
157
|
+
import Handlebars from "handlebars";
|
|
158
|
+
|
|
159
|
+
// source/utils/helpers/tmp/tmp-schema.ts
|
|
160
|
+
function normalizeGlobalType(value) {
|
|
161
|
+
if (value === undefined || value === null || value === "")
|
|
162
|
+
return;
|
|
163
|
+
const raw = typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
164
|
+
if (raw === "workspace" /* WORKSPACE */)
|
|
165
|
+
return "workspace" /* WORKSPACE */;
|
|
166
|
+
if (raw === "api-service" /* API_SERVICE */)
|
|
167
|
+
return "api-service" /* API_SERVICE */;
|
|
168
|
+
if (raw === "frontend" /* FRONTEND */)
|
|
169
|
+
return "frontend" /* FRONTEND */;
|
|
170
|
+
throw new Error(`${defaults_default.packageName}: configs.global.type must be one of ${Object.values(GlobalTypeEnum).join("|")} (got "${String(value)}")`);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// source/utils/helpers/workspace/index.ts
|
|
174
|
+
var TMP_FILE = "tmp.yml";
|
|
175
|
+
var SKIP_DIRS = new Set(["node_modules", ".git", "dist", ".turbo", "coverage"]);
|
|
176
|
+
var DEFAULT_FOLDER_STRUCTURE = {
|
|
177
|
+
api: "api",
|
|
178
|
+
admin: "admin",
|
|
179
|
+
web: "web"
|
|
180
|
+
};
|
|
181
|
+
function parseScalar(raw) {
|
|
182
|
+
const trimmed = raw.trim();
|
|
183
|
+
if (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'")) {
|
|
184
|
+
return trimmed.slice(1, -1);
|
|
185
|
+
}
|
|
186
|
+
return trimmed;
|
|
187
|
+
}
|
|
188
|
+
function readTmpFile(filePath) {
|
|
189
|
+
const text = fs2.readFileSync(filePath, "utf8");
|
|
190
|
+
const out = { path: filePath, folderStructure: { ...DEFAULT_FOLDER_STRUCTURE } };
|
|
191
|
+
const projectMatch = text.match(/^project:\s*\n(?:[ \t]+[^\n]+\n)*?[ \t]+name:\s*(.+?)\s*(?:#.*)?$/m) ?? text.match(/^project:\s*\n[ \t]+name:\s*(.+?)\s*(?:#.*)?$/m);
|
|
192
|
+
if (projectMatch)
|
|
193
|
+
out.projectName = parseScalar(projectMatch[1]);
|
|
194
|
+
const typeMatch = text.match(/global:\s*\n(?:[ \t]+[^\n]+\n)*?[ \t]+type:\s*(.+?)\s*(?:#.*)?$/m);
|
|
195
|
+
if (typeMatch)
|
|
196
|
+
out.globalType = parseScalar(typeMatch[1]);
|
|
197
|
+
const kubeMatch = text.match(/^kubeconfig:\s*(.+?)\s*(?:#.*)?$/m);
|
|
198
|
+
if (kubeMatch)
|
|
199
|
+
out.kubeconfig = parseScalar(kubeMatch[1]).replace(/^~/, process.env.HOME ?? "");
|
|
200
|
+
const rootBlock = text.match(/paths:\s*\n(?:[ \t]+[^\n]+\n)*?[ \t]+root:\s*(.+?)\s*(?:#.*)?$/m);
|
|
201
|
+
if (rootBlock)
|
|
202
|
+
out.pathsRoot = parseScalar(rootBlock[1]);
|
|
203
|
+
const tmpBlock = text.match(/paths:\s*\n(?:[ \t]+[^\n]+\n)*?[ \t]+tmp:\s*(.+?)\s*(?:#.*)?$/m);
|
|
204
|
+
if (tmpBlock)
|
|
205
|
+
out.pathsTmp = parseScalar(tmpBlock[1]);
|
|
206
|
+
if (out.projectName)
|
|
207
|
+
out.clusterDeployment = out.projectName;
|
|
208
|
+
out.folderStructure = parseFolderStructure(text);
|
|
209
|
+
return out;
|
|
210
|
+
}
|
|
211
|
+
function parseFolderStructure(text) {
|
|
212
|
+
const fsBlock = text.match(/folder-structure:\s*\n((?:[ \t]+[^\n]+\n?)*)/)?.[1] ?? "";
|
|
213
|
+
const readSlot = (key) => {
|
|
214
|
+
const scalar = fsBlock.match(new RegExp(`^[ ]+${key}:s*(.+?)(?:s+#.*)?$`, "m"));
|
|
215
|
+
if (scalar)
|
|
216
|
+
return parseScalar(scalar[1]);
|
|
217
|
+
return DEFAULT_FOLDER_STRUCTURE[key];
|
|
218
|
+
};
|
|
219
|
+
return {
|
|
220
|
+
api: readSlot("api"),
|
|
221
|
+
admin: readSlot("admin"),
|
|
222
|
+
web: readSlot("web")
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function entryName(meta) {
|
|
226
|
+
const project = (meta.projectName ?? "").trim();
|
|
227
|
+
return project || null;
|
|
228
|
+
}
|
|
229
|
+
function entryType(meta, slot) {
|
|
230
|
+
const explicit = (meta.globalType ?? "").trim();
|
|
231
|
+
if (explicit) {
|
|
232
|
+
try {
|
|
233
|
+
return normalizeGlobalType(explicit) ?? null;
|
|
234
|
+
} catch {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (slot === "api")
|
|
239
|
+
return "api-service" /* API_SERVICE */;
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
function findWorkspaceRoot(startDir = process.cwd()) {
|
|
243
|
+
let cur = path2.resolve(startDir);
|
|
244
|
+
for (;; ) {
|
|
245
|
+
const candidate = path2.join(cur, TMP_FILE);
|
|
246
|
+
if (fs2.existsSync(candidate)) {
|
|
247
|
+
const meta = readTmpFile(candidate);
|
|
248
|
+
if (meta.globalType === "workspace" /* WORKSPACE */)
|
|
249
|
+
return cur;
|
|
250
|
+
}
|
|
251
|
+
const parent = path2.dirname(cur);
|
|
252
|
+
if (parent === cur)
|
|
253
|
+
break;
|
|
254
|
+
cur = parent;
|
|
255
|
+
}
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
function isTraversableDir(entry, fullPath) {
|
|
259
|
+
if (entry.isDirectory())
|
|
260
|
+
return true;
|
|
261
|
+
if (entry.isSymbolicLink()) {
|
|
262
|
+
try {
|
|
263
|
+
return fs2.statSync(fullPath).isDirectory();
|
|
264
|
+
} catch {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
function walkTmpUnder(rootDir) {
|
|
271
|
+
const found = [];
|
|
272
|
+
if (!fs2.existsSync(rootDir))
|
|
273
|
+
return found;
|
|
274
|
+
const stack = [rootDir];
|
|
275
|
+
while (stack.length) {
|
|
276
|
+
const dir = stack.pop();
|
|
277
|
+
let entries;
|
|
278
|
+
try {
|
|
279
|
+
entries = fs2.readdirSync(dir, { withFileTypes: true });
|
|
280
|
+
} catch {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
for (const entry of entries) {
|
|
284
|
+
const full = path2.join(dir, entry.name);
|
|
285
|
+
if (isTraversableDir(entry, full)) {
|
|
286
|
+
if (SKIP_DIRS.has(entry.name) || entry.name.startsWith("."))
|
|
287
|
+
continue;
|
|
288
|
+
stack.push(full);
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (entry.isFile() && entry.name === TMP_FILE)
|
|
292
|
+
found.push(full);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return found;
|
|
296
|
+
}
|
|
297
|
+
function stripDotSlash(value) {
|
|
298
|
+
return value.replace(/^\.\//, "");
|
|
299
|
+
}
|
|
300
|
+
function repoRootFromTmp(tmpPath, meta) {
|
|
301
|
+
const abs = tmpPath.replace(/\\/g, "/");
|
|
302
|
+
const rootFolder = stripDotSlash(meta.pathsRoot ?? "./x");
|
|
303
|
+
const tmpName = stripDotSlash(meta.pathsTmp ?? "tmp.yml");
|
|
304
|
+
const rel = `${rootFolder}/${tmpName}`.replace(/\/+/g, "/");
|
|
305
|
+
if (abs.endsWith(`/${rel}`)) {
|
|
306
|
+
return abs.slice(0, -(rel.length + 1));
|
|
307
|
+
}
|
|
308
|
+
throw new Error(`tmp path mismatch: expected */${rel}, got ${abs}`);
|
|
309
|
+
}
|
|
310
|
+
function findEntries(workspaceRoot) {
|
|
311
|
+
const wsMeta = readTmpFile(path2.join(workspaceRoot, TMP_FILE));
|
|
312
|
+
const fsMap = wsMeta.folderStructure;
|
|
313
|
+
const entries = [];
|
|
314
|
+
const seen = new Set;
|
|
315
|
+
const slots = ["api", "admin", "web"];
|
|
316
|
+
for (const slot of slots) {
|
|
317
|
+
const folder = path2.join(workspaceRoot, fsMap[slot]);
|
|
318
|
+
for (const tmpPath of walkTmpUnder(folder)) {
|
|
319
|
+
if (path2.resolve(tmpPath) === path2.join(workspaceRoot, TMP_FILE))
|
|
320
|
+
continue;
|
|
321
|
+
const meta = readTmpFile(tmpPath);
|
|
322
|
+
const kind = entryType(meta, slot);
|
|
323
|
+
if (kind === "workspace" /* WORKSPACE */)
|
|
324
|
+
continue;
|
|
325
|
+
if (slot !== "api" && kind !== "frontend" /* FRONTEND */)
|
|
326
|
+
continue;
|
|
327
|
+
if (kind !== "api-service" /* API_SERVICE */ && kind !== "frontend" /* FRONTEND */)
|
|
328
|
+
continue;
|
|
329
|
+
const name = entryName(meta);
|
|
330
|
+
if (!name)
|
|
331
|
+
continue;
|
|
332
|
+
const key = `${kind}:${name}`;
|
|
333
|
+
if (seen.has(key))
|
|
334
|
+
continue;
|
|
335
|
+
seen.add(key);
|
|
336
|
+
entries.push({
|
|
337
|
+
name,
|
|
338
|
+
type: kind,
|
|
339
|
+
path: repoRootFromTmp(tmpPath, meta),
|
|
340
|
+
tmp: tmpPath,
|
|
341
|
+
slot,
|
|
342
|
+
cluster: meta.clusterDeployment ?? meta.projectName
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return entries.sort((a, b) => a.type === b.type ? a.name.localeCompare(b.name) : a.type.localeCompare(b.type));
|
|
347
|
+
}
|
|
348
|
+
function findApiServices(workspaceRoot) {
|
|
349
|
+
return findEntries(workspaceRoot).filter((e) => e.type === "api-service" /* API_SERVICE */);
|
|
350
|
+
}
|
|
351
|
+
function resolveEntryPath(workspaceRoot, name) {
|
|
352
|
+
const hit = findEntries(workspaceRoot).find((e) => e.name === name);
|
|
353
|
+
return hit?.path ?? null;
|
|
354
|
+
}
|
|
355
|
+
function workspaceProjectName(workspaceRoot) {
|
|
356
|
+
const meta = readTmpFile(path2.join(workspaceRoot, TMP_FILE));
|
|
357
|
+
return meta.projectName?.trim() || path2.basename(workspaceRoot);
|
|
358
|
+
}
|
|
359
|
+
function readWorkspaceGlobalTmp(workspaceRoot) {
|
|
360
|
+
const text = fs2.readFileSync(path2.join(workspaceRoot, TMP_FILE), "utf8");
|
|
361
|
+
const match = text.match(/options:\s*\n(?:[ \t]+[^\n]+\n)*?[ \t]+fileWatchIntervalMs:\s*(\d+)/m) ?? text.match(/fileWatchIntervalMs:\s*(\d+)/);
|
|
362
|
+
return match ? { fileWatchIntervalMs: Number(match[1]) } : {};
|
|
363
|
+
}
|
|
364
|
+
var readWorkspaceCoreTmp = readWorkspaceGlobalTmp;
|
|
365
|
+
function workspaceTmpTemplate(projectName) {
|
|
366
|
+
return `project:
|
|
367
|
+
name: ${projectName}
|
|
368
|
+
|
|
369
|
+
configs:
|
|
370
|
+
global:
|
|
371
|
+
type: workspace
|
|
372
|
+
runtime: bun
|
|
373
|
+
framework: bun
|
|
374
|
+
paths:
|
|
375
|
+
root: .
|
|
376
|
+
tmp: tmp.yml
|
|
377
|
+
options:
|
|
378
|
+
fileWatchIntervalMs: 500
|
|
379
|
+
folder-structure:
|
|
380
|
+
api: api
|
|
381
|
+
admin: admin
|
|
382
|
+
web: web
|
|
383
|
+
`;
|
|
384
|
+
}
|
|
385
|
+
export {
|
|
386
|
+
workspaceTmpTemplate,
|
|
387
|
+
workspaceProjectName,
|
|
388
|
+
resolveEntryPath,
|
|
389
|
+
readWorkspaceGlobalTmp,
|
|
390
|
+
readWorkspaceCoreTmp,
|
|
391
|
+
readTmpFile,
|
|
392
|
+
parseFolderStructure,
|
|
393
|
+
normalizeGlobalType,
|
|
394
|
+
findWorkspaceRoot,
|
|
395
|
+
findEntries,
|
|
396
|
+
findApiServices,
|
|
397
|
+
entryType,
|
|
398
|
+
entryName,
|
|
399
|
+
TMP_FILE,
|
|
400
|
+
SKIP_DIRS,
|
|
401
|
+
DEFAULT_FOLDER_STRUCTURE
|
|
402
|
+
};
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
// source/utils/helpers/xrystal-home/registry.ts
|
|
2
|
+
import fs2 from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path2 from "node:path";
|
|
5
|
+
|
|
6
|
+
// source/utils/helpers/workspace/index.ts
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
|
|
10
|
+
// source/utils/models/enums/index.ts
|
|
11
|
+
var GlobalTypeEnum;
|
|
12
|
+
((GlobalTypeEnum2) => {
|
|
13
|
+
GlobalTypeEnum2["WORKSPACE"] = "workspace";
|
|
14
|
+
GlobalTypeEnum2["API_SERVICE"] = "api-service";
|
|
15
|
+
GlobalTypeEnum2["FRONTEND"] = "frontend";
|
|
16
|
+
})(GlobalTypeEnum ||= {});
|
|
17
|
+
|
|
18
|
+
// source/utils/helpers/workspace/index.ts
|
|
19
|
+
var TMP_FILE = "tmp.yml";
|
|
20
|
+
var SKIP_DIRS = new Set(["node_modules", ".git", "dist", ".turbo", "coverage"]);
|
|
21
|
+
var DEFAULT_FOLDER_STRUCTURE = {
|
|
22
|
+
api: "api",
|
|
23
|
+
admin: "admin",
|
|
24
|
+
web: "web"
|
|
25
|
+
};
|
|
26
|
+
function parseScalar(raw) {
|
|
27
|
+
const trimmed = raw.trim();
|
|
28
|
+
if (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'")) {
|
|
29
|
+
return trimmed.slice(1, -1);
|
|
30
|
+
}
|
|
31
|
+
return trimmed;
|
|
32
|
+
}
|
|
33
|
+
function readTmpFile(filePath) {
|
|
34
|
+
const text = fs.readFileSync(filePath, "utf8");
|
|
35
|
+
const out = { path: filePath, folderStructure: { ...DEFAULT_FOLDER_STRUCTURE } };
|
|
36
|
+
const projectMatch = text.match(/^project:\s*\n(?:[ \t]+[^\n]+\n)*?[ \t]+name:\s*(.+?)\s*(?:#.*)?$/m) ?? text.match(/^project:\s*\n[ \t]+name:\s*(.+?)\s*(?:#.*)?$/m);
|
|
37
|
+
if (projectMatch)
|
|
38
|
+
out.projectName = parseScalar(projectMatch[1]);
|
|
39
|
+
const typeMatch = text.match(/global:\s*\n(?:[ \t]+[^\n]+\n)*?[ \t]+type:\s*(.+?)\s*(?:#.*)?$/m);
|
|
40
|
+
if (typeMatch)
|
|
41
|
+
out.globalType = parseScalar(typeMatch[1]);
|
|
42
|
+
const kubeMatch = text.match(/^kubeconfig:\s*(.+?)\s*(?:#.*)?$/m);
|
|
43
|
+
if (kubeMatch)
|
|
44
|
+
out.kubeconfig = parseScalar(kubeMatch[1]).replace(/^~/, process.env.HOME ?? "");
|
|
45
|
+
const rootBlock = text.match(/paths:\s*\n(?:[ \t]+[^\n]+\n)*?[ \t]+root:\s*(.+?)\s*(?:#.*)?$/m);
|
|
46
|
+
if (rootBlock)
|
|
47
|
+
out.pathsRoot = parseScalar(rootBlock[1]);
|
|
48
|
+
const tmpBlock = text.match(/paths:\s*\n(?:[ \t]+[^\n]+\n)*?[ \t]+tmp:\s*(.+?)\s*(?:#.*)?$/m);
|
|
49
|
+
if (tmpBlock)
|
|
50
|
+
out.pathsTmp = parseScalar(tmpBlock[1]);
|
|
51
|
+
const clusterBlock = text.match(/cluster:\s*\n(?:[ \t]+[^\n]+\n)*?[ \t]+deployment:\s*(.+?)\s*(?:#.*)?$/m);
|
|
52
|
+
if (clusterBlock)
|
|
53
|
+
out.clusterDeployment = parseScalar(clusterBlock[1]);
|
|
54
|
+
else if (out.projectName)
|
|
55
|
+
out.clusterDeployment = out.projectName;
|
|
56
|
+
out.folderStructure = parseFolderStructure(text);
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
function parseFolderStructure(text) {
|
|
60
|
+
const fsBlock = text.match(/folder-structure:\s*\n((?:[ \t]+[^\n]+\n?)*)/)?.[1] ?? "";
|
|
61
|
+
const readSlot = (key) => {
|
|
62
|
+
const scalar = fsBlock.match(new RegExp(`^[ ]+${key}:s*(.+?)(?:s+#.*)?$`, "m"));
|
|
63
|
+
if (scalar)
|
|
64
|
+
return parseScalar(scalar[1]);
|
|
65
|
+
return DEFAULT_FOLDER_STRUCTURE[key];
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
api: readSlot("api"),
|
|
69
|
+
admin: readSlot("admin"),
|
|
70
|
+
web: readSlot("web")
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function normalizeGlobalType(value) {
|
|
74
|
+
const raw = typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
75
|
+
if (raw === "workspace" /* WORKSPACE */)
|
|
76
|
+
return "workspace" /* WORKSPACE */;
|
|
77
|
+
if (raw === "api-service" /* API_SERVICE */)
|
|
78
|
+
return "api-service" /* API_SERVICE */;
|
|
79
|
+
if (raw === "frontend" /* FRONTEND */)
|
|
80
|
+
return "frontend" /* FRONTEND */;
|
|
81
|
+
throw new Error(`@xrystal/core: configs.global.type must be one of ${Object.values(GlobalTypeEnum).join("|")} (got "${String(value)}")`);
|
|
82
|
+
}
|
|
83
|
+
function entryName(meta) {
|
|
84
|
+
const project = (meta.projectName ?? "").trim();
|
|
85
|
+
return project || null;
|
|
86
|
+
}
|
|
87
|
+
function entryType(meta, slot) {
|
|
88
|
+
const explicit = (meta.globalType ?? "").trim();
|
|
89
|
+
if (explicit) {
|
|
90
|
+
try {
|
|
91
|
+
return normalizeGlobalType(explicit);
|
|
92
|
+
} catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (slot === "api")
|
|
97
|
+
return "api-service" /* API_SERVICE */;
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
function findWorkspaceRoot(startDir = process.cwd()) {
|
|
101
|
+
let cur = path.resolve(startDir);
|
|
102
|
+
for (;; ) {
|
|
103
|
+
const candidate = path.join(cur, TMP_FILE);
|
|
104
|
+
if (fs.existsSync(candidate)) {
|
|
105
|
+
const meta = readTmpFile(candidate);
|
|
106
|
+
if (meta.globalType === "workspace" /* WORKSPACE */)
|
|
107
|
+
return cur;
|
|
108
|
+
}
|
|
109
|
+
const parent = path.dirname(cur);
|
|
110
|
+
if (parent === cur)
|
|
111
|
+
break;
|
|
112
|
+
cur = parent;
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
function isTraversableDir(entry, fullPath) {
|
|
117
|
+
if (entry.isDirectory())
|
|
118
|
+
return true;
|
|
119
|
+
if (entry.isSymbolicLink()) {
|
|
120
|
+
try {
|
|
121
|
+
return fs.statSync(fullPath).isDirectory();
|
|
122
|
+
} catch {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
function walkTmpUnder(rootDir) {
|
|
129
|
+
const found = [];
|
|
130
|
+
if (!fs.existsSync(rootDir))
|
|
131
|
+
return found;
|
|
132
|
+
const stack = [rootDir];
|
|
133
|
+
while (stack.length) {
|
|
134
|
+
const dir = stack.pop();
|
|
135
|
+
let entries;
|
|
136
|
+
try {
|
|
137
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
138
|
+
} catch {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
for (const entry of entries) {
|
|
142
|
+
const full = path.join(dir, entry.name);
|
|
143
|
+
if (isTraversableDir(entry, full)) {
|
|
144
|
+
if (SKIP_DIRS.has(entry.name) || entry.name.startsWith("."))
|
|
145
|
+
continue;
|
|
146
|
+
stack.push(full);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (entry.isFile() && entry.name === TMP_FILE)
|
|
150
|
+
found.push(full);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return found;
|
|
154
|
+
}
|
|
155
|
+
function stripDotSlash(value) {
|
|
156
|
+
return value.replace(/^\.\//, "");
|
|
157
|
+
}
|
|
158
|
+
function repoRootFromTmp(tmpPath, meta) {
|
|
159
|
+
const abs = tmpPath.replace(/\\/g, "/");
|
|
160
|
+
const rootFolder = stripDotSlash(meta.pathsRoot ?? "./x");
|
|
161
|
+
const tmpName = stripDotSlash(meta.pathsTmp ?? "tmp.yml");
|
|
162
|
+
const rel = `${rootFolder}/${tmpName}`.replace(/\/+/g, "/");
|
|
163
|
+
if (abs.endsWith(`/${rel}`)) {
|
|
164
|
+
return abs.slice(0, -(rel.length + 1));
|
|
165
|
+
}
|
|
166
|
+
throw new Error(`tmp path mismatch: expected */${rel}, got ${abs}`);
|
|
167
|
+
}
|
|
168
|
+
function findEntries(workspaceRoot) {
|
|
169
|
+
const wsMeta = readTmpFile(path.join(workspaceRoot, TMP_FILE));
|
|
170
|
+
const fsMap = wsMeta.folderStructure;
|
|
171
|
+
const entries = [];
|
|
172
|
+
const seen = new Set;
|
|
173
|
+
const slots = ["api", "admin", "web"];
|
|
174
|
+
for (const slot of slots) {
|
|
175
|
+
const folder = path.join(workspaceRoot, fsMap[slot]);
|
|
176
|
+
for (const tmpPath of walkTmpUnder(folder)) {
|
|
177
|
+
if (path.resolve(tmpPath) === path.join(workspaceRoot, TMP_FILE))
|
|
178
|
+
continue;
|
|
179
|
+
const meta = readTmpFile(tmpPath);
|
|
180
|
+
const kind = entryType(meta, slot);
|
|
181
|
+
if (kind === "workspace" /* WORKSPACE */)
|
|
182
|
+
continue;
|
|
183
|
+
if (slot !== "api" && kind !== "frontend" /* FRONTEND */)
|
|
184
|
+
continue;
|
|
185
|
+
if (kind !== "api-service" /* API_SERVICE */ && kind !== "frontend" /* FRONTEND */)
|
|
186
|
+
continue;
|
|
187
|
+
const name = entryName(meta);
|
|
188
|
+
if (!name)
|
|
189
|
+
continue;
|
|
190
|
+
const key = `${kind}:${name}`;
|
|
191
|
+
if (seen.has(key))
|
|
192
|
+
continue;
|
|
193
|
+
seen.add(key);
|
|
194
|
+
entries.push({
|
|
195
|
+
name,
|
|
196
|
+
type: kind,
|
|
197
|
+
path: repoRootFromTmp(tmpPath, meta),
|
|
198
|
+
tmp: tmpPath,
|
|
199
|
+
slot,
|
|
200
|
+
cluster: meta.clusterDeployment ?? meta.projectName
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return entries.sort((a, b) => a.type === b.type ? a.name.localeCompare(b.name) : a.type.localeCompare(b.type));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// source/utils/helpers/xrystal-home/registry.ts
|
|
208
|
+
var XRYSTAL_HOME_DIR = ".xrystal";
|
|
209
|
+
function resolveXrystalHome() {
|
|
210
|
+
return path2.join(os.homedir(), XRYSTAL_HOME_DIR);
|
|
211
|
+
}
|
|
212
|
+
function registryFilePath() {
|
|
213
|
+
return path2.join(resolveXrystalHome(), "registry.json");
|
|
214
|
+
}
|
|
215
|
+
function ensureXrystalHome() {
|
|
216
|
+
const home = resolveXrystalHome();
|
|
217
|
+
fs2.mkdirSync(path2.join(home, "workspaces"), { recursive: true });
|
|
218
|
+
return home;
|
|
219
|
+
}
|
|
220
|
+
function entryToRegistryProject(entry) {
|
|
221
|
+
return {
|
|
222
|
+
name: entry.name,
|
|
223
|
+
type: entry.type,
|
|
224
|
+
path: entry.path,
|
|
225
|
+
slot: entry.slot,
|
|
226
|
+
cluster: entry.cluster ?? entry.name
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function normalizeRegistryPath(input) {
|
|
230
|
+
const resolved = path2.resolve(input);
|
|
231
|
+
try {
|
|
232
|
+
return fs2.realpathSync.native(resolved);
|
|
233
|
+
} catch {
|
|
234
|
+
return resolved;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function scanWorkspace(workspacePath, workspaceName) {
|
|
238
|
+
const root = normalizeRegistryPath(workspacePath);
|
|
239
|
+
const entries = findEntries(root);
|
|
240
|
+
const name = workspaceName ?? path2.basename(root);
|
|
241
|
+
return {
|
|
242
|
+
name,
|
|
243
|
+
path: root,
|
|
244
|
+
projects: entries.map(entryToRegistryProject),
|
|
245
|
+
updatedAt: new Date().toISOString()
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function readRegistry() {
|
|
249
|
+
ensureXrystalHome();
|
|
250
|
+
const file = registryFilePath();
|
|
251
|
+
if (!fs2.existsSync(file)) {
|
|
252
|
+
return { version: 1, updatedAt: new Date().toISOString(), workspaces: [] };
|
|
253
|
+
}
|
|
254
|
+
return JSON.parse(fs2.readFileSync(file, "utf8"));
|
|
255
|
+
}
|
|
256
|
+
function writeRegistry(registry) {
|
|
257
|
+
ensureXrystalHome();
|
|
258
|
+
registry.updatedAt = new Date().toISOString();
|
|
259
|
+
fs2.writeFileSync(registryFilePath(), `${JSON.stringify(registry, null, 2)}
|
|
260
|
+
`);
|
|
261
|
+
for (const ws of registry.workspaces) {
|
|
262
|
+
const wsDir = path2.join(resolveXrystalHome(), "workspaces", ws.name);
|
|
263
|
+
fs2.mkdirSync(wsDir, { recursive: true });
|
|
264
|
+
fs2.writeFileSync(path2.join(wsDir, "workspace.json"), `${JSON.stringify(ws, null, 2)}
|
|
265
|
+
`);
|
|
266
|
+
for (const project of ws.projects) {
|
|
267
|
+
fs2.writeFileSync(path2.join(wsDir, `${project.name}.json`), `${JSON.stringify(project, null, 2)}
|
|
268
|
+
`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function upsertWorkspace(registry, workspace) {
|
|
273
|
+
const workspacePath = normalizeRegistryPath(workspace.path);
|
|
274
|
+
const normalized = { ...workspace, path: workspacePath };
|
|
275
|
+
const next = registry.workspaces.filter((item) => normalizeRegistryPath(item.path) !== workspacePath);
|
|
276
|
+
next.push(normalized);
|
|
277
|
+
return { ...registry, workspaces: next.sort((a, b) => a.name.localeCompare(b.name)) };
|
|
278
|
+
}
|
|
279
|
+
function syncRegistryFromPath(startDir = process.cwd()) {
|
|
280
|
+
const workspaceRoot = findWorkspaceRoot(startDir);
|
|
281
|
+
if (!workspaceRoot) {
|
|
282
|
+
throw new Error("No workspace tmp.yml found — run xry create demo --workspace first");
|
|
283
|
+
}
|
|
284
|
+
const scanned = scanWorkspace(workspaceRoot);
|
|
285
|
+
const registry = upsertWorkspace(readRegistry(), scanned);
|
|
286
|
+
writeRegistry(registry);
|
|
287
|
+
return registry;
|
|
288
|
+
}
|
|
289
|
+
function listRegistryProjects(registry = readRegistry()) {
|
|
290
|
+
const rows = [];
|
|
291
|
+
for (const ws of registry.workspaces) {
|
|
292
|
+
for (const project of ws.projects) {
|
|
293
|
+
rows.push({ ...project, workspace: ws.name });
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return rows.sort((a, b) => a.workspace.localeCompare(b.workspace) || a.name.localeCompare(b.name));
|
|
297
|
+
}
|
|
298
|
+
export {
|
|
299
|
+
writeRegistry,
|
|
300
|
+
upsertWorkspace,
|
|
301
|
+
syncRegistryFromPath,
|
|
302
|
+
scanWorkspace,
|
|
303
|
+
resolveXrystalHome,
|
|
304
|
+
registryFilePath,
|
|
305
|
+
readRegistry,
|
|
306
|
+
listRegistryProjects,
|
|
307
|
+
entryToRegistryProject,
|
|
308
|
+
ensureXrystalHome,
|
|
309
|
+
XRYSTAL_HOME_DIR
|
|
310
|
+
};
|