@kosdev-code/kos-ui-cli 2.1.38 → 3.0.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/package.json +5 -6
- package/src/lib/cli.mjs +34 -10
- package/src/lib/generators/component/index.mjs +1230 -27
- package/src/lib/generators/component/index.mjs.map +7 -0
- package/src/lib/generators/model/add-future.mjs +1449 -43
- package/src/lib/generators/model/add-future.mjs.map +7 -0
- package/src/lib/generators/model/companion.mjs +1465 -56
- package/src/lib/generators/model/companion.mjs.map +7 -0
- package/src/lib/generators/model/container.mjs +1234 -45
- package/src/lib/generators/model/container.mjs.map +7 -0
- package/src/lib/generators/model/context.mjs +1102 -35
- package/src/lib/generators/model/context.mjs.map +7 -0
- package/src/lib/generators/model/hook.mjs +1097 -33
- package/src/lib/generators/model/hook.mjs.map +7 -0
- package/src/lib/generators/model/model.mjs +1411 -39
- package/src/lib/generators/model/model.mjs.map +7 -0
- package/src/lib/generators/plugin/index.mjs +1275 -74
- package/src/lib/generators/plugin/index.mjs.map +7 -0
- package/src/lib/generators/project/splash.mjs +691 -21
- package/src/lib/generators/project/splash.mjs.map +7 -0
- package/src/lib/utils/dev-config.mjs +7 -12
- package/src/lib/utils/nx-context.mjs +584 -170
- package/src/lib/utils/nx-context.mjs.map +7 -0
- package/README.md +0 -484
- package/src/index.d.ts +0 -2
- package/src/index.d.ts.map +0 -1
- package/src/index.js +0 -1
- package/src/index.js.map +0 -1
|
@@ -1,97 +1,548 @@
|
|
|
1
|
-
// utils/nx-context.mjs
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import path from "path";
|
|
1
|
+
// src/lib/utils/nx-context.mjs
|
|
2
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, readdirSync, statSync } from "fs";
|
|
3
|
+
import path3 from "path";
|
|
5
4
|
import { fileURLToPath } from "url";
|
|
6
|
-
import { getCached, setCached } from "./cache.mjs";
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
// src/lib/utils/cache.mjs
|
|
7
|
+
import fs from "fs";
|
|
8
|
+
import path from "path";
|
|
9
|
+
var CACHE_PATH = path.resolve(".nx/cli-cache.json");
|
|
10
|
+
var CACHE_TTL = 600 * 1e3;
|
|
11
|
+
var ARGS = process.argv;
|
|
12
|
+
var DISABLE_CACHE = process.env.DISABLE_CACHE === "true" || process.env.REFRESH === "true";
|
|
13
|
+
var _cache = {};
|
|
14
|
+
var _loaded = false;
|
|
15
|
+
function ensureCacheDir() {
|
|
16
|
+
const dir = path.dirname(CACHE_PATH);
|
|
17
|
+
if (!fs.existsSync(dir))
|
|
18
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
function loadCacheFromDisk() {
|
|
21
|
+
if (_loaded)
|
|
22
|
+
return;
|
|
23
|
+
_loaded = true;
|
|
24
|
+
try {
|
|
25
|
+
if (fs.existsSync(CACHE_PATH)) {
|
|
26
|
+
const data = fs.readFileSync(CACHE_PATH, "utf-8");
|
|
27
|
+
_cache = JSON.parse(data);
|
|
28
|
+
}
|
|
29
|
+
} catch (err) {
|
|
30
|
+
console.warn("Failed to load CLI cache:", err);
|
|
31
|
+
_cache = {};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function saveCacheToDisk() {
|
|
35
|
+
try {
|
|
36
|
+
ensureCacheDir();
|
|
37
|
+
fs.writeFileSync(CACHE_PATH, JSON.stringify(_cache, null, 2));
|
|
38
|
+
} catch (err) {
|
|
39
|
+
console.warn("Failed to save CLI cache:", err);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function isFresh(entry, ttl = CACHE_TTL) {
|
|
43
|
+
if (!entry || !entry.timestamp)
|
|
44
|
+
return false;
|
|
45
|
+
return Date.now() - entry.timestamp < ttl;
|
|
46
|
+
}
|
|
47
|
+
function getCached(key, ttl = CACHE_TTL) {
|
|
48
|
+
if (DISABLE_CACHE)
|
|
49
|
+
return null;
|
|
50
|
+
loadCacheFromDisk();
|
|
51
|
+
const entry = _cache[key];
|
|
52
|
+
if (isFresh(entry, ttl))
|
|
53
|
+
return entry.data;
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
function setCached(key, data) {
|
|
57
|
+
loadCacheFromDisk();
|
|
58
|
+
_cache[key] = {
|
|
59
|
+
data,
|
|
60
|
+
timestamp: Date.now()
|
|
61
|
+
};
|
|
62
|
+
saveCacheToDisk();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ../kos-codegen-core/src/lib/generate-files.ts
|
|
66
|
+
import * as ejs from "ejs";
|
|
67
|
+
|
|
68
|
+
// ../kos-codegen-core/src/lib/logger.ts
|
|
69
|
+
var noopLogger = {
|
|
70
|
+
debug: () => {
|
|
71
|
+
},
|
|
72
|
+
info: () => {
|
|
73
|
+
},
|
|
74
|
+
warn: () => {
|
|
75
|
+
},
|
|
76
|
+
error: () => {
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
var activeLogger = noopLogger;
|
|
80
|
+
function getCodegenLogger() {
|
|
81
|
+
return activeLogger;
|
|
82
|
+
}
|
|
9
83
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
84
|
+
// ../kos-codegen-core/src/lib/project-discovery.ts
|
|
85
|
+
import * as fs2 from "fs";
|
|
86
|
+
import * as path2 from "path";
|
|
87
|
+
import fg from "fast-glob";
|
|
88
|
+
function discoverProjects(workspaceRoot) {
|
|
89
|
+
const logger = getCodegenLogger();
|
|
90
|
+
const projects = /* @__PURE__ */ new Map();
|
|
91
|
+
const projectJsonPaths = fg.sync("**/project.json", {
|
|
92
|
+
cwd: workspaceRoot,
|
|
93
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/.git/**"],
|
|
94
|
+
absolute: false
|
|
95
|
+
});
|
|
96
|
+
for (const relPath of projectJsonPaths) {
|
|
97
|
+
const absPath = path2.join(workspaceRoot, relPath);
|
|
98
|
+
try {
|
|
99
|
+
const raw = fs2.readFileSync(absPath, "utf-8");
|
|
100
|
+
const json = JSON.parse(raw);
|
|
101
|
+
const projectRoot = path2.dirname(relPath);
|
|
102
|
+
const name = json.name ?? path2.basename(projectRoot);
|
|
103
|
+
const config = {
|
|
104
|
+
name,
|
|
105
|
+
root: projectRoot,
|
|
106
|
+
sourceRoot: json.sourceRoot ?? path2.join(projectRoot, "src"),
|
|
107
|
+
projectType: json.projectType,
|
|
108
|
+
targets: json.targets,
|
|
109
|
+
tags: json.tags
|
|
110
|
+
};
|
|
111
|
+
projects.set(name, config);
|
|
112
|
+
logger.debug(`Discovered project: ${name} at ${projectRoot}`);
|
|
113
|
+
} catch (err) {
|
|
114
|
+
logger.warn(`Failed to parse ${absPath}: ${err}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
logger.info(`Discovered ${projects.size} projects`);
|
|
118
|
+
return projects;
|
|
119
|
+
}
|
|
120
|
+
function findProjectByName(workspaceRoot, projectName, projects) {
|
|
121
|
+
const map = projects ?? discoverProjects(workspaceRoot);
|
|
122
|
+
return map.get(projectName);
|
|
13
123
|
}
|
|
14
124
|
|
|
125
|
+
// ../kos-codegen-core/src/lib/format-files.ts
|
|
126
|
+
import prettier from "prettier";
|
|
127
|
+
|
|
128
|
+
// ../kos-codegen-core/src/lib/generators/update-model-index.ts
|
|
129
|
+
import * as ts from "typescript";
|
|
130
|
+
|
|
131
|
+
// ../kos-codegen-core/src/lib/generators/component/types.ts
|
|
132
|
+
var PLUGIN_TYPES = {
|
|
133
|
+
CUI: "cui",
|
|
134
|
+
UTILITY: "utility",
|
|
135
|
+
TROUBLE_ACTION: "troubleAction",
|
|
136
|
+
SETUP: "setup",
|
|
137
|
+
SETTING: "setting",
|
|
138
|
+
NAV: "nav",
|
|
139
|
+
CONTROL_POUR: "controlPour",
|
|
140
|
+
CUSTOM: "custom"
|
|
141
|
+
};
|
|
142
|
+
var CONTRIBUTION_TYPE_MAP = {
|
|
143
|
+
[PLUGIN_TYPES.SETUP]: "setup",
|
|
144
|
+
[PLUGIN_TYPES.CUI]: "cui",
|
|
145
|
+
[PLUGIN_TYPES.UTILITY]: "utility",
|
|
146
|
+
[PLUGIN_TYPES.SETTING]: "setting",
|
|
147
|
+
[PLUGIN_TYPES.NAV]: "nav",
|
|
148
|
+
[PLUGIN_TYPES.TROUBLE_ACTION]: "trouble-action",
|
|
149
|
+
[PLUGIN_TYPES.CONTROL_POUR]: "control-pour",
|
|
150
|
+
[PLUGIN_TYPES.CUSTOM]: "custom"
|
|
151
|
+
};
|
|
152
|
+
var LOCALIZED_PLUGIN_TYPES = /* @__PURE__ */ new Set([
|
|
153
|
+
PLUGIN_TYPES.CUI,
|
|
154
|
+
PLUGIN_TYPES.UTILITY,
|
|
155
|
+
PLUGIN_TYPES.SETUP,
|
|
156
|
+
PLUGIN_TYPES.SETTING,
|
|
157
|
+
PLUGIN_TYPES.NAV,
|
|
158
|
+
PLUGIN_TYPES.CONTROL_POUR,
|
|
159
|
+
PLUGIN_TYPES.TROUBLE_ACTION,
|
|
160
|
+
PLUGIN_TYPES.CUSTOM
|
|
161
|
+
]);
|
|
162
|
+
|
|
163
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/base.ts
|
|
164
|
+
var BasePluginHandler = class {
|
|
165
|
+
getContributionKey() {
|
|
166
|
+
return this.contributionKey;
|
|
167
|
+
}
|
|
168
|
+
requiresLocalization() {
|
|
169
|
+
return this.requiresI18n;
|
|
170
|
+
}
|
|
171
|
+
getTemplatePath() {
|
|
172
|
+
return this.contributionKey;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Helper to create experience configuration
|
|
176
|
+
*/
|
|
177
|
+
createExperience(options, experienceId) {
|
|
178
|
+
const compPath = this.getComponentPath(options);
|
|
179
|
+
return {
|
|
180
|
+
id: experienceId,
|
|
181
|
+
component: options.namePascalCase,
|
|
182
|
+
location: `./src/${compPath}`
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Helper to get component path
|
|
187
|
+
*/
|
|
188
|
+
getComponentPath(options) {
|
|
189
|
+
return `${options.appDirectory}/${this.contributionKey}/${options.nameDashCase}/${options.nameDashCase}.tsx`;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Helper to create config prefix
|
|
193
|
+
*/
|
|
194
|
+
getConfigPrefix(options) {
|
|
195
|
+
return `${options.appProject}.${options.nameCamelCase}`;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/control-pour-handler.ts
|
|
200
|
+
var ControlPourPluginHandler = class extends BasePluginHandler {
|
|
201
|
+
pluginType = PLUGIN_TYPES.CONTROL_POUR;
|
|
202
|
+
contributionKey = "control-pour";
|
|
203
|
+
requiresI18n = true;
|
|
204
|
+
createConfiguration(options) {
|
|
205
|
+
const configPrefix = this.getConfigPrefix(options);
|
|
206
|
+
const experienceId = `${configPrefix}.controlPour.experience`;
|
|
207
|
+
const contribution = {
|
|
208
|
+
id: `${configPrefix}.controlPour`,
|
|
209
|
+
title: `${configPrefix}.controlPour.title`,
|
|
210
|
+
namespace: options.appProject,
|
|
211
|
+
experienceId
|
|
212
|
+
};
|
|
213
|
+
const experience = this.createExperience(options, experienceId);
|
|
214
|
+
return {
|
|
215
|
+
contributions: {
|
|
216
|
+
controlPour: [contribution]
|
|
217
|
+
},
|
|
218
|
+
experiences: {
|
|
219
|
+
[experienceId]: experience
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/cui-handler.ts
|
|
226
|
+
var CuiPluginHandler = class extends BasePluginHandler {
|
|
227
|
+
pluginType = PLUGIN_TYPES.CUI;
|
|
228
|
+
contributionKey = "cui";
|
|
229
|
+
requiresI18n = true;
|
|
230
|
+
createConfiguration(options) {
|
|
231
|
+
const configPrefix = this.getConfigPrefix(options);
|
|
232
|
+
const experienceId = `${configPrefix}.cui.experience`;
|
|
233
|
+
const contribution = {
|
|
234
|
+
id: configPrefix,
|
|
235
|
+
title: `${configPrefix}.cui.title`,
|
|
236
|
+
namespace: options.appProject,
|
|
237
|
+
experienceId
|
|
238
|
+
};
|
|
239
|
+
const experience = this.createExperience(options, experienceId);
|
|
240
|
+
return {
|
|
241
|
+
contributions: {
|
|
242
|
+
cui: [contribution]
|
|
243
|
+
},
|
|
244
|
+
experiences: {
|
|
245
|
+
[experienceId]: experience
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/custom-handler.ts
|
|
252
|
+
var CustomPluginHandler = class extends BasePluginHandler {
|
|
253
|
+
pluginType = PLUGIN_TYPES.CUSTOM;
|
|
254
|
+
contributionKey = "custom";
|
|
255
|
+
requiresI18n = true;
|
|
256
|
+
createConfiguration(options) {
|
|
257
|
+
const configPrefix = this.getConfigPrefix(options);
|
|
258
|
+
const experienceId = `${configPrefix}.${options.contributionKey || "custom"}.experience`;
|
|
259
|
+
const userContributionKey = options.contributionKey || "custom";
|
|
260
|
+
const contribution = {
|
|
261
|
+
id: configPrefix,
|
|
262
|
+
title: `${configPrefix}.${userContributionKey}.title`,
|
|
263
|
+
namespace: options.appProject,
|
|
264
|
+
experienceId
|
|
265
|
+
// TODO: Add additional fields as required by the plugin-explorer specification
|
|
266
|
+
// Refer to the plugin-explorer documentation for your specific contribution type
|
|
267
|
+
};
|
|
268
|
+
const experience = this.createExperience(options, experienceId);
|
|
269
|
+
return {
|
|
270
|
+
contributions: {
|
|
271
|
+
[userContributionKey]: [contribution]
|
|
272
|
+
},
|
|
273
|
+
experiences: {
|
|
274
|
+
[experienceId]: experience
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
getTemplatePath() {
|
|
279
|
+
return this.contributionKey || "custom";
|
|
280
|
+
}
|
|
281
|
+
getComponentPath(options) {
|
|
282
|
+
const pathKey = options.contributionKey || "custom";
|
|
283
|
+
return `${options.appDirectory}/${pathKey}/${options.nameDashCase}/${options.nameDashCase}.tsx`;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/default-handler.ts
|
|
288
|
+
var DefaultComponentHandler = class extends BasePluginHandler {
|
|
289
|
+
pluginType = "component";
|
|
290
|
+
contributionKey = "components";
|
|
291
|
+
requiresI18n = false;
|
|
292
|
+
createConfiguration(options) {
|
|
293
|
+
const compPath = this.getComponentPath(options);
|
|
294
|
+
const viewConfig = {
|
|
295
|
+
id: `${options.appProject}.${options.nameCamelCase}`,
|
|
296
|
+
title: "ddk.ncui.config.title",
|
|
297
|
+
namespace: options.appProject,
|
|
298
|
+
component: options.namePascalCase,
|
|
299
|
+
location: `./src/${compPath}`
|
|
300
|
+
};
|
|
301
|
+
return {
|
|
302
|
+
contributions: {},
|
|
303
|
+
experiences: {},
|
|
304
|
+
views: {
|
|
305
|
+
[this.getTabViewKey()]: [viewConfig]
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
getTabViewKey() {
|
|
310
|
+
return "ddk.ncui.settings.tabView";
|
|
311
|
+
}
|
|
312
|
+
getTemplatePath() {
|
|
313
|
+
return "files";
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/nav-handler.ts
|
|
318
|
+
var NavPluginHandler = class extends BasePluginHandler {
|
|
319
|
+
pluginType = PLUGIN_TYPES.NAV;
|
|
320
|
+
contributionKey = "nav";
|
|
321
|
+
requiresI18n = true;
|
|
322
|
+
createConfiguration(options) {
|
|
323
|
+
const configPrefix = this.getConfigPrefix(options);
|
|
324
|
+
const experienceId = `${configPrefix}.nav.experience`;
|
|
325
|
+
const contribution = {
|
|
326
|
+
id: `${configPrefix}.nav`,
|
|
327
|
+
title: `${configPrefix}.nav.title`,
|
|
328
|
+
namespace: options.appProject,
|
|
329
|
+
navDescriptor: options.nameLowerCase,
|
|
330
|
+
experienceId
|
|
331
|
+
};
|
|
332
|
+
const experience = this.createExperience(options, experienceId);
|
|
333
|
+
return {
|
|
334
|
+
contributions: {
|
|
335
|
+
navViews: [contribution]
|
|
336
|
+
},
|
|
337
|
+
experiences: {
|
|
338
|
+
[experienceId]: experience
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/setting-handler.ts
|
|
345
|
+
var SettingPluginHandler = class extends BasePluginHandler {
|
|
346
|
+
pluginType = PLUGIN_TYPES.SETTING;
|
|
347
|
+
contributionKey = "setting";
|
|
348
|
+
requiresI18n = true;
|
|
349
|
+
createConfiguration(options) {
|
|
350
|
+
const configPrefix = this.getConfigPrefix(options);
|
|
351
|
+
const experienceId = `${configPrefix}.settings.experience`;
|
|
352
|
+
const contribution = {
|
|
353
|
+
id: `${configPrefix}.setting`,
|
|
354
|
+
title: `${configPrefix}.setting.title`,
|
|
355
|
+
namespace: options.appProject,
|
|
356
|
+
settingsGroup: options.group || "general",
|
|
357
|
+
experienceId
|
|
358
|
+
};
|
|
359
|
+
const experience = this.createExperience(options, experienceId);
|
|
360
|
+
return {
|
|
361
|
+
contributions: {
|
|
362
|
+
settings: [contribution]
|
|
363
|
+
},
|
|
364
|
+
experiences: {
|
|
365
|
+
[experienceId]: experience
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/setup-handler.ts
|
|
372
|
+
var SetupPluginHandler = class extends BasePluginHandler {
|
|
373
|
+
pluginType = PLUGIN_TYPES.SETUP;
|
|
374
|
+
contributionKey = "setup";
|
|
375
|
+
requiresI18n = true;
|
|
376
|
+
createConfiguration(options) {
|
|
377
|
+
const configPrefix = this.getConfigPrefix(options);
|
|
378
|
+
const experienceId = `${configPrefix}.setup.experience`;
|
|
379
|
+
const contribution = {
|
|
380
|
+
id: `${configPrefix}.setup`,
|
|
381
|
+
title: `${configPrefix}.setup.title`,
|
|
382
|
+
namespace: options.appProject,
|
|
383
|
+
setupDescriptor: options.nameCamelCase,
|
|
384
|
+
experienceId
|
|
385
|
+
};
|
|
386
|
+
const experience = this.createExperience(options, experienceId);
|
|
387
|
+
return {
|
|
388
|
+
contributions: {
|
|
389
|
+
setupStep: [contribution]
|
|
390
|
+
},
|
|
391
|
+
experiences: {
|
|
392
|
+
[experienceId]: experience
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/trouble-action-handler.ts
|
|
399
|
+
var TroubleActionPluginHandler = class extends BasePluginHandler {
|
|
400
|
+
pluginType = PLUGIN_TYPES.TROUBLE_ACTION;
|
|
401
|
+
contributionKey = "trouble-action";
|
|
402
|
+
requiresI18n = true;
|
|
403
|
+
createConfiguration(options) {
|
|
404
|
+
const configPrefix = this.getConfigPrefix(options);
|
|
405
|
+
const experienceId = `${configPrefix}.troubleAction.experience`;
|
|
406
|
+
const contribution = {
|
|
407
|
+
id: `${configPrefix}.troubleAction`,
|
|
408
|
+
title: `${configPrefix}.troubleAction.title`,
|
|
409
|
+
namespace: options.appProject,
|
|
410
|
+
troubleType: options.nameCamelCase,
|
|
411
|
+
experienceId
|
|
412
|
+
};
|
|
413
|
+
const experience = this.createExperience(options, experienceId);
|
|
414
|
+
return {
|
|
415
|
+
contributions: {
|
|
416
|
+
troubleActions: [contribution]
|
|
417
|
+
},
|
|
418
|
+
experiences: {
|
|
419
|
+
[experienceId]: experience
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/utility-handler.ts
|
|
426
|
+
var UtilityPluginHandler = class extends BasePluginHandler {
|
|
427
|
+
pluginType = PLUGIN_TYPES.UTILITY;
|
|
428
|
+
contributionKey = "utility";
|
|
429
|
+
requiresI18n = true;
|
|
430
|
+
createConfiguration(options) {
|
|
431
|
+
const configPrefix = this.getConfigPrefix(options);
|
|
432
|
+
const experienceId = `${configPrefix}.util.experience`;
|
|
433
|
+
const contribution = {
|
|
434
|
+
id: `${configPrefix}.util`,
|
|
435
|
+
title: `${configPrefix}.utility.title`,
|
|
436
|
+
namespace: options.appProject,
|
|
437
|
+
utilDescriptor: options.nameCamelCase,
|
|
438
|
+
experienceId
|
|
439
|
+
};
|
|
440
|
+
const experience = this.createExperience(options, experienceId);
|
|
441
|
+
return {
|
|
442
|
+
contributions: {
|
|
443
|
+
utilities: [contribution]
|
|
444
|
+
},
|
|
445
|
+
experiences: {
|
|
446
|
+
[experienceId]: experience
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/factory.ts
|
|
453
|
+
var PluginHandlerFactory = class {
|
|
454
|
+
static handlers = /* @__PURE__ */ new Map([
|
|
455
|
+
[PLUGIN_TYPES.CUI, CuiPluginHandler],
|
|
456
|
+
[PLUGIN_TYPES.UTILITY, UtilityPluginHandler],
|
|
457
|
+
[PLUGIN_TYPES.SETTING, SettingPluginHandler],
|
|
458
|
+
[PLUGIN_TYPES.SETUP, SetupPluginHandler],
|
|
459
|
+
[PLUGIN_TYPES.NAV, NavPluginHandler],
|
|
460
|
+
[PLUGIN_TYPES.CONTROL_POUR, ControlPourPluginHandler],
|
|
461
|
+
[PLUGIN_TYPES.TROUBLE_ACTION, TroubleActionPluginHandler],
|
|
462
|
+
[PLUGIN_TYPES.CUSTOM, CustomPluginHandler]
|
|
463
|
+
]);
|
|
464
|
+
static createHandler(pluginType) {
|
|
465
|
+
if (!pluginType) {
|
|
466
|
+
return new DefaultComponentHandler();
|
|
467
|
+
}
|
|
468
|
+
const HandlerClass = this.handlers.get(pluginType);
|
|
469
|
+
if (!HandlerClass) {
|
|
470
|
+
console.warn(
|
|
471
|
+
`No handler found for plugin type: ${pluginType}. Using default handler.`
|
|
472
|
+
);
|
|
473
|
+
return new DefaultComponentHandler();
|
|
474
|
+
}
|
|
475
|
+
return new HandlerClass();
|
|
476
|
+
}
|
|
477
|
+
static isValidPluginType(type) {
|
|
478
|
+
return this.handlers.has(type);
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
// src/lib/utils/nx-context.mjs
|
|
483
|
+
var __dirname2 = path3.dirname(fileURLToPath(import.meta.url));
|
|
15
484
|
function findKosJsonFiles(dir = process.cwd(), files = []) {
|
|
16
485
|
try {
|
|
17
486
|
const entries = readdirSync(dir);
|
|
18
|
-
|
|
19
487
|
for (const entry of entries) {
|
|
20
|
-
|
|
21
|
-
// BUT don't skip .kos.json files themselves!
|
|
22
|
-
if (entry === 'node_modules' || entry === '.git' || entry === '.nx' ||
|
|
23
|
-
entry === 'dist' || entry === 'coverage' || entry === '.vscode' ||
|
|
24
|
-
entry === '.idea' || (entry.startsWith('.') && entry !== '.kos.json')) {
|
|
488
|
+
if (entry === "node_modules" || entry === ".git" || entry === ".nx" || entry === "dist" || entry === "coverage" || entry === ".vscode" || entry === ".idea" || entry.startsWith(".") && entry !== ".kos.json") {
|
|
25
489
|
continue;
|
|
26
490
|
}
|
|
27
|
-
|
|
28
|
-
const fullPath = path.join(dir, entry);
|
|
29
|
-
|
|
491
|
+
const fullPath = path3.join(dir, entry);
|
|
30
492
|
try {
|
|
31
493
|
const stat = statSync(fullPath);
|
|
32
|
-
|
|
33
|
-
if (stat.isFile() && entry === '.kos.json') {
|
|
494
|
+
if (stat.isFile() && entry === ".kos.json") {
|
|
34
495
|
files.push(fullPath);
|
|
35
496
|
} else if (stat.isDirectory()) {
|
|
36
|
-
|
|
37
|
-
// Skip common build/temp directories
|
|
38
|
-
if (entry !== 'tmp' && entry !== 'temp' && entry !== 'build') {
|
|
497
|
+
if (entry !== "tmp" && entry !== "temp" && entry !== "build") {
|
|
39
498
|
findKosJsonFiles(fullPath, files);
|
|
40
499
|
}
|
|
41
500
|
}
|
|
42
501
|
} catch (error) {
|
|
43
|
-
// Skip files/directories we can't access
|
|
44
502
|
continue;
|
|
45
503
|
}
|
|
46
504
|
}
|
|
47
505
|
} catch (error) {
|
|
48
|
-
// Skip directories we can't read
|
|
49
506
|
}
|
|
50
|
-
|
|
51
507
|
return files;
|
|
52
508
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (_workspaceDetected !== undefined) return _workspaceDetected;
|
|
58
|
-
|
|
509
|
+
var _workspaceDetected;
|
|
510
|
+
async function detectWorkspace(startDir = process.cwd()) {
|
|
511
|
+
if (_workspaceDetected !== void 0)
|
|
512
|
+
return _workspaceDetected;
|
|
59
513
|
let dir = startDir;
|
|
60
|
-
while (dir !==
|
|
61
|
-
if (
|
|
514
|
+
while (dir !== path3.dirname(dir)) {
|
|
515
|
+
if (existsSync2(path3.join(dir, "nx.json"))) {
|
|
62
516
|
_workspaceDetected = true;
|
|
63
517
|
return true;
|
|
64
518
|
}
|
|
65
|
-
dir =
|
|
519
|
+
dir = path3.dirname(dir);
|
|
66
520
|
}
|
|
67
|
-
|
|
68
521
|
_workspaceDetected = false;
|
|
69
522
|
return false;
|
|
70
523
|
}
|
|
71
|
-
|
|
524
|
+
async function getAllProjects() {
|
|
72
525
|
const cached = getCached("allProjects");
|
|
73
|
-
if (cached)
|
|
74
|
-
|
|
75
|
-
const
|
|
526
|
+
if (cached)
|
|
527
|
+
return cached;
|
|
528
|
+
const projectMap = discoverProjects(process.cwd());
|
|
529
|
+
const projects = Array.from(projectMap.keys());
|
|
76
530
|
setCached("allProjects", projects);
|
|
77
531
|
return projects;
|
|
78
532
|
}
|
|
79
|
-
|
|
80
|
-
export async function getLibraryProjects() {
|
|
533
|
+
async function getLibraryProjects() {
|
|
81
534
|
const cached = getCached("libraryProjects");
|
|
82
|
-
if (cached)
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
);
|
|
535
|
+
if (cached)
|
|
536
|
+
return cached;
|
|
537
|
+
const projectMap = discoverProjects(process.cwd());
|
|
538
|
+
const projects = Array.from(projectMap.values()).filter((p) => p.projectType === "library").map((p) => p.name);
|
|
87
539
|
setCached("libraryProjects", projects);
|
|
88
540
|
return projects;
|
|
89
541
|
}
|
|
90
|
-
|
|
91
|
-
export async function getPluginProjects() {
|
|
542
|
+
async function getPluginProjects() {
|
|
92
543
|
const cached = getCached("pluginProjects");
|
|
93
|
-
if (cached)
|
|
94
|
-
|
|
544
|
+
if (cached)
|
|
545
|
+
return cached;
|
|
95
546
|
const all = await getAllProjects();
|
|
96
547
|
const filtered = all.filter(
|
|
97
548
|
(p) => p.includes("plugin") || p.includes("extension")
|
|
@@ -99,71 +550,52 @@ export async function getPluginProjects() {
|
|
|
99
550
|
setCached("pluginProjects", filtered);
|
|
100
551
|
return filtered;
|
|
101
552
|
}
|
|
102
|
-
|
|
103
|
-
export async function getAllKosProjects() {
|
|
553
|
+
async function getAllKosProjects() {
|
|
104
554
|
const cached = getCached("allKosProjects");
|
|
105
|
-
if (cached)
|
|
106
|
-
|
|
555
|
+
if (cached)
|
|
556
|
+
return cached;
|
|
107
557
|
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
108
558
|
console.warn(`[kos-cli] Discovering KOS projects by scanning .kos.json files...`);
|
|
109
559
|
}
|
|
110
|
-
|
|
111
|
-
// In an NX workspace, focus on common project directories first
|
|
112
|
-
const projectDirs = ['apps', 'libs', 'packages'];
|
|
560
|
+
const projectDirs = ["apps", "libs", "packages"];
|
|
113
561
|
const kosJsonFiles = [];
|
|
114
562
|
const workspaceRoot = process.cwd();
|
|
115
|
-
|
|
116
|
-
// First scan common project directories
|
|
117
563
|
for (const dir of projectDirs) {
|
|
118
|
-
const dirPath =
|
|
119
|
-
if (
|
|
564
|
+
const dirPath = path3.join(workspaceRoot, dir);
|
|
565
|
+
if (existsSync2(dirPath)) {
|
|
120
566
|
findKosJsonFiles(dirPath, kosJsonFiles);
|
|
121
567
|
}
|
|
122
568
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const rootKosJson = path.join(workspaceRoot, '.kos.json');
|
|
126
|
-
if (existsSync(rootKosJson)) {
|
|
569
|
+
const rootKosJson = path3.join(workspaceRoot, ".kos.json");
|
|
570
|
+
if (existsSync2(rootKosJson)) {
|
|
127
571
|
kosJsonFiles.push(rootKosJson);
|
|
128
572
|
}
|
|
129
|
-
|
|
130
|
-
// If we didn't find any in the common directories, fall back to full scan
|
|
131
573
|
if (kosJsonFiles.length === 0) {
|
|
132
574
|
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
133
575
|
console.warn(`[kos-cli] No .kos.json files found in common directories, performing full workspace scan...`);
|
|
134
576
|
}
|
|
135
577
|
findKosJsonFiles(workspaceRoot, kosJsonFiles);
|
|
136
578
|
}
|
|
137
|
-
|
|
138
579
|
const kosProjects = [];
|
|
139
|
-
|
|
140
580
|
for (const kosJsonPath of kosJsonFiles) {
|
|
141
581
|
try {
|
|
142
|
-
const kosConfig = JSON.parse(
|
|
143
|
-
const projectDir =
|
|
144
|
-
|
|
145
|
-
// Try to determine the project name by looking for project.json
|
|
582
|
+
const kosConfig = JSON.parse(readFileSync2(kosJsonPath, "utf-8"));
|
|
583
|
+
const projectDir = path3.dirname(kosJsonPath);
|
|
146
584
|
let projectName = null;
|
|
147
|
-
const projectJsonPath =
|
|
148
|
-
|
|
149
|
-
if (existsSync(projectJsonPath)) {
|
|
585
|
+
const projectJsonPath = path3.join(projectDir, "project.json");
|
|
586
|
+
if (existsSync2(projectJsonPath)) {
|
|
150
587
|
try {
|
|
151
|
-
const projectJson = JSON.parse(
|
|
588
|
+
const projectJson = JSON.parse(readFileSync2(projectJsonPath, "utf-8"));
|
|
152
589
|
projectName = projectJson.name;
|
|
153
590
|
} catch (error) {
|
|
154
|
-
|
|
155
|
-
projectName = path.basename(projectDir);
|
|
591
|
+
projectName = path3.basename(projectDir);
|
|
156
592
|
}
|
|
157
593
|
} else {
|
|
158
|
-
|
|
159
|
-
projectName = path.basename(projectDir);
|
|
594
|
+
projectName = path3.basename(projectDir);
|
|
160
595
|
}
|
|
161
|
-
|
|
162
|
-
// Skip root-type configurations as they are not projects
|
|
163
|
-
if (kosConfig.type === 'root') {
|
|
596
|
+
if (kosConfig.type === "root") {
|
|
164
597
|
continue;
|
|
165
598
|
}
|
|
166
|
-
|
|
167
599
|
kosProjects.push({
|
|
168
600
|
name: projectName,
|
|
169
601
|
path: projectDir,
|
|
@@ -175,59 +607,43 @@ export async function getAllKosProjects() {
|
|
|
175
607
|
console.warn(`[kos-cli] Error reading ${kosJsonPath}: ${error.message}`);
|
|
176
608
|
}
|
|
177
609
|
}
|
|
178
|
-
|
|
179
610
|
setCached("allKosProjects", kosProjects);
|
|
180
611
|
return kosProjects;
|
|
181
612
|
}
|
|
182
|
-
|
|
183
|
-
export async function getProjectsByType(targetType) {
|
|
613
|
+
async function getProjectsByType(targetType) {
|
|
184
614
|
const cacheKey = `projectsByType:${targetType}`;
|
|
185
615
|
const cached = getCached(cacheKey);
|
|
186
|
-
if (cached)
|
|
187
|
-
|
|
616
|
+
if (cached)
|
|
617
|
+
return cached;
|
|
188
618
|
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
189
619
|
console.warn(`[kos-cli] Filtering projects for ${targetType} projectType...`);
|
|
190
620
|
}
|
|
191
621
|
const allKosProjects = await getAllKosProjects();
|
|
192
622
|
const filteredProjects = [];
|
|
193
|
-
|
|
194
623
|
for (const kosProject of allKosProjects) {
|
|
195
624
|
const projectType = kosProject.projectType;
|
|
196
|
-
|
|
197
|
-
// Handle both string and array formats for projectType
|
|
198
|
-
const hasTargetType = Array.isArray(projectType)
|
|
199
|
-
? projectType.includes(targetType)
|
|
200
|
-
: projectType === targetType;
|
|
201
|
-
|
|
625
|
+
const hasTargetType = Array.isArray(projectType) ? projectType.includes(targetType) : projectType === targetType;
|
|
202
626
|
if (hasTargetType) {
|
|
203
627
|
filteredProjects.push(kosProject.name);
|
|
204
628
|
}
|
|
205
629
|
}
|
|
206
|
-
|
|
207
630
|
setCached(cacheKey, filteredProjects);
|
|
208
631
|
return filteredProjects;
|
|
209
632
|
}
|
|
210
|
-
|
|
211
|
-
export async function getModelProjects() {
|
|
633
|
+
async function getModelProjects() {
|
|
212
634
|
return await getProjectsByType("model");
|
|
213
635
|
}
|
|
214
|
-
|
|
215
|
-
export async function getUIProjects() {
|
|
636
|
+
async function getUIProjects() {
|
|
216
637
|
return await getProjectsByType("ui");
|
|
217
638
|
}
|
|
218
|
-
|
|
219
|
-
export async function getModelComponentProjects() {
|
|
639
|
+
async function getModelComponentProjects() {
|
|
220
640
|
return await getProjectsByType("model-component");
|
|
221
641
|
}
|
|
222
|
-
|
|
223
|
-
export async function getI18nProjects() {
|
|
642
|
+
async function getI18nProjects() {
|
|
224
643
|
return await getProjectsByType("i18n");
|
|
225
644
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
export async function getProjectsByTypeWithFallback(targetType, fallbackFunction = getLibraryProjects) {
|
|
645
|
+
async function getProjectsByTypeWithFallback(targetType, fallbackFunction = getLibraryProjects) {
|
|
229
646
|
const filteredProjects = await getProjectsByType(targetType);
|
|
230
|
-
|
|
231
647
|
if (filteredProjects.length > 0) {
|
|
232
648
|
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
233
649
|
console.warn(`[kos-cli] Found ${filteredProjects.length} ${targetType} projects`);
|
|
@@ -240,50 +656,37 @@ export async function getProjectsByTypeWithFallback(targetType, fallbackFunction
|
|
|
240
656
|
return await fallbackFunction();
|
|
241
657
|
}
|
|
242
658
|
}
|
|
243
|
-
|
|
244
|
-
export async function getModelProjectsWithFallback() {
|
|
659
|
+
async function getModelProjectsWithFallback() {
|
|
245
660
|
return await getProjectsByTypeWithFallback("model", getLibraryProjects);
|
|
246
661
|
}
|
|
247
|
-
|
|
248
|
-
export async function getModelComponentProjectsWithFallback() {
|
|
662
|
+
async function getModelComponentProjectsWithFallback() {
|
|
249
663
|
return await getProjectsByTypeWithFallback("model-component", getAllProjects);
|
|
250
664
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const cacheKey = `projectsByMultipleTypes:${targetTypes.join(',')}`;
|
|
665
|
+
async function getProjectsByMultipleTypes(targetTypes) {
|
|
666
|
+
const cacheKey = `projectsByMultipleTypes:${targetTypes.join(",")}`;
|
|
254
667
|
const cached = getCached(cacheKey);
|
|
255
|
-
if (cached)
|
|
256
|
-
|
|
257
|
-
console.warn(`[kos-cli] Filtering projects for projectTypes: ${targetTypes.join(
|
|
668
|
+
if (cached)
|
|
669
|
+
return cached;
|
|
670
|
+
console.warn(`[kos-cli] Filtering projects for projectTypes: ${targetTypes.join(", ")}...`);
|
|
258
671
|
const allKosProjects = await getAllKosProjects();
|
|
259
672
|
const filteredProjects = [];
|
|
260
|
-
|
|
261
673
|
for (const kosProject of allKosProjects) {
|
|
262
674
|
const projectType = kosProject.projectType;
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const hasAnyTargetType = targetTypes.some(targetType => {
|
|
266
|
-
return Array.isArray(projectType)
|
|
267
|
-
? projectType.includes(targetType)
|
|
268
|
-
: projectType === targetType;
|
|
675
|
+
const hasAnyTargetType = targetTypes.some((targetType) => {
|
|
676
|
+
return Array.isArray(projectType) ? projectType.includes(targetType) : projectType === targetType;
|
|
269
677
|
});
|
|
270
|
-
|
|
271
678
|
if (hasAnyTargetType) {
|
|
272
679
|
filteredProjects.push(kosProject.name);
|
|
273
680
|
}
|
|
274
681
|
}
|
|
275
|
-
|
|
276
682
|
setCached(cacheKey, filteredProjects);
|
|
277
683
|
return filteredProjects;
|
|
278
684
|
}
|
|
279
|
-
|
|
280
|
-
export async function getComponentCompatibleProjects() {
|
|
685
|
+
async function getComponentCompatibleProjects() {
|
|
281
686
|
return await getProjectsByMultipleTypes(["ui", "splash", "model-component"]);
|
|
282
687
|
}
|
|
283
|
-
|
|
284
|
-
export async function getComponentCompatibleProjectsWithFallback() {
|
|
688
|
+
async function getComponentCompatibleProjectsWithFallback() {
|
|
285
689
|
const componentProjects = await getComponentCompatibleProjects();
|
|
286
|
-
|
|
287
690
|
if (componentProjects.length > 0) {
|
|
288
691
|
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
289
692
|
console.warn(`[kos-cli] Found ${componentProjects.length} component-compatible projects`);
|
|
@@ -296,13 +699,10 @@ export async function getComponentCompatibleProjectsWithFallback() {
|
|
|
296
699
|
return await getAllProjects();
|
|
297
700
|
}
|
|
298
701
|
}
|
|
299
|
-
|
|
300
|
-
export async function getI18nProjectsWithFallback() {
|
|
702
|
+
async function getI18nProjectsWithFallback() {
|
|
301
703
|
return await getProjectsByTypeWithFallback("i18n", getAllProjects);
|
|
302
704
|
}
|
|
303
|
-
|
|
304
|
-
export async function getPluginProjectsWithFallback() {
|
|
305
|
-
// First try type-based filtering
|
|
705
|
+
async function getPluginProjectsWithFallback() {
|
|
306
706
|
const pluginProjectsByType = await getProjectsByType("plugin");
|
|
307
707
|
if (pluginProjectsByType.length > 0) {
|
|
308
708
|
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
@@ -310,8 +710,6 @@ export async function getPluginProjectsWithFallback() {
|
|
|
310
710
|
}
|
|
311
711
|
return pluginProjectsByType;
|
|
312
712
|
}
|
|
313
|
-
|
|
314
|
-
// Fall back to existing name-based filtering
|
|
315
713
|
const pluginProjectsByName = await getPluginProjects();
|
|
316
714
|
if (pluginProjectsByName.length > 0) {
|
|
317
715
|
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
@@ -319,31 +717,25 @@ export async function getPluginProjectsWithFallback() {
|
|
|
319
717
|
}
|
|
320
718
|
return pluginProjectsByName;
|
|
321
719
|
}
|
|
322
|
-
|
|
323
|
-
// Final fallback to all projects
|
|
324
720
|
console.warn(`[kos-cli] No plugin projects found, showing all projects`);
|
|
325
721
|
return await getAllProjects();
|
|
326
722
|
}
|
|
327
|
-
|
|
328
|
-
export async function getAllModels() {
|
|
723
|
+
async function getAllModels() {
|
|
329
724
|
const cached = getCached("allModels");
|
|
330
|
-
if (cached)
|
|
331
|
-
|
|
725
|
+
if (cached)
|
|
726
|
+
return cached;
|
|
332
727
|
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
333
728
|
console.warn(`[kos-cli] Scanning for models in KOS projects...`);
|
|
334
729
|
}
|
|
335
730
|
const allKosProjects = await getAllKosProjects();
|
|
336
731
|
const models = [];
|
|
337
|
-
|
|
338
732
|
for (const kosProject of allKosProjects) {
|
|
339
733
|
if (kosProject.config.models) {
|
|
340
734
|
Object.keys(kosProject.config.models).forEach((model) => {
|
|
341
|
-
models.push({ model
|
|
735
|
+
models.push({ model, project: kosProject.name });
|
|
342
736
|
});
|
|
343
737
|
}
|
|
344
738
|
}
|
|
345
|
-
|
|
346
|
-
// Sort models by project name first, then by model name
|
|
347
739
|
models.sort((a, b) => {
|
|
348
740
|
if (a.project === b.project) {
|
|
349
741
|
return a.model.localeCompare(b.model);
|
|
@@ -351,22 +743,19 @@ export async function getAllModels() {
|
|
|
351
743
|
return a.project.localeCompare(b.project);
|
|
352
744
|
}
|
|
353
745
|
});
|
|
354
|
-
|
|
355
746
|
setCached("allModels", models);
|
|
356
747
|
return models;
|
|
357
748
|
}
|
|
358
|
-
|
|
359
|
-
export async function getWorkspaceDefaults() {
|
|
749
|
+
async function getWorkspaceDefaults() {
|
|
360
750
|
const cached = getCached("workspaceDefaults");
|
|
361
|
-
if (cached)
|
|
362
|
-
|
|
751
|
+
if (cached)
|
|
752
|
+
return cached;
|
|
363
753
|
const workspaceRoot = process.cwd();
|
|
364
|
-
const rootKosJsonPath =
|
|
365
|
-
|
|
366
|
-
if (existsSync(rootKosJsonPath)) {
|
|
754
|
+
const rootKosJsonPath = path3.join(workspaceRoot, ".kos.json");
|
|
755
|
+
if (existsSync2(rootKosJsonPath)) {
|
|
367
756
|
try {
|
|
368
|
-
const rootConfig = JSON.parse(
|
|
369
|
-
if (rootConfig.type ===
|
|
757
|
+
const rootConfig = JSON.parse(readFileSync2(rootKosJsonPath, "utf-8"));
|
|
758
|
+
if (rootConfig.type === "root" && rootConfig.generator?.defaults) {
|
|
370
759
|
setCached("workspaceDefaults", rootConfig.generator.defaults);
|
|
371
760
|
return rootConfig.generator.defaults;
|
|
372
761
|
}
|
|
@@ -374,22 +763,47 @@ export async function getWorkspaceDefaults() {
|
|
|
374
763
|
console.warn(`[kos-cli] Error reading workspace defaults: ${error.message}`);
|
|
375
764
|
}
|
|
376
765
|
}
|
|
377
|
-
|
|
378
766
|
setCached("workspaceDefaults", {});
|
|
379
767
|
return {};
|
|
380
768
|
}
|
|
381
|
-
|
|
382
|
-
export async function getDefaultProjectForType(projectType) {
|
|
769
|
+
async function getDefaultProjectForType(projectType) {
|
|
383
770
|
const defaults = await getWorkspaceDefaults();
|
|
384
771
|
return defaults[projectType] || null;
|
|
385
772
|
}
|
|
386
|
-
|
|
387
|
-
export async function getProjectDetails(projectName) {
|
|
773
|
+
async function getProjectDetails(projectName) {
|
|
388
774
|
const cacheKey = `projectDetails:${projectName}`;
|
|
389
775
|
const cached = getCached(cacheKey);
|
|
390
|
-
if (cached)
|
|
391
|
-
|
|
392
|
-
const details =
|
|
776
|
+
if (cached)
|
|
777
|
+
return cached;
|
|
778
|
+
const details = findProjectByName(process.cwd(), projectName);
|
|
779
|
+
if (!details) {
|
|
780
|
+
throw new Error(`Project "${projectName}" not found in workspace`);
|
|
781
|
+
}
|
|
393
782
|
setCached(cacheKey, details);
|
|
394
783
|
return details;
|
|
395
784
|
}
|
|
785
|
+
export {
|
|
786
|
+
detectWorkspace,
|
|
787
|
+
getAllKosProjects,
|
|
788
|
+
getAllModels,
|
|
789
|
+
getAllProjects,
|
|
790
|
+
getComponentCompatibleProjects,
|
|
791
|
+
getComponentCompatibleProjectsWithFallback,
|
|
792
|
+
getDefaultProjectForType,
|
|
793
|
+
getI18nProjects,
|
|
794
|
+
getI18nProjectsWithFallback,
|
|
795
|
+
getLibraryProjects,
|
|
796
|
+
getModelComponentProjects,
|
|
797
|
+
getModelComponentProjectsWithFallback,
|
|
798
|
+
getModelProjects,
|
|
799
|
+
getModelProjectsWithFallback,
|
|
800
|
+
getPluginProjects,
|
|
801
|
+
getPluginProjectsWithFallback,
|
|
802
|
+
getProjectDetails,
|
|
803
|
+
getProjectsByMultipleTypes,
|
|
804
|
+
getProjectsByType,
|
|
805
|
+
getProjectsByTypeWithFallback,
|
|
806
|
+
getUIProjects,
|
|
807
|
+
getWorkspaceDefaults
|
|
808
|
+
};
|
|
809
|
+
//# sourceMappingURL=nx-context.mjs.map
|