@kosdev-code/kos-ui-cli 2.0.39 → 2.0.41
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 +2 -2
- package/src/lib/cli.mjs +18 -7
- package/src/lib/generators/metadata.json +197 -20
- package/src/lib/generators/project/content.mjs +41 -0
- package/src/lib/generators/workspace/index.mjs +6 -0
- package/src/lib/generators/workspace/list-models.mjs +64 -0
- package/src/lib/generators/workspace/list-projects.mjs +167 -0
- package/src/lib/plopfile.mjs +2 -0
- package/src/lib/utils/nx-context.mjs +30 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kosdev-code/kos-ui-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.41",
|
|
4
4
|
"bin": {
|
|
5
5
|
"kosui": "./src/lib/cli.mjs"
|
|
6
6
|
},
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"main": "./src/index.js",
|
|
21
21
|
"kos": {
|
|
22
22
|
"build": {
|
|
23
|
-
"gitHash": "
|
|
23
|
+
"gitHash": "82f501e94dcc050e3ec05bb9fd68f2671112823d"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
package/src/lib/cli.mjs
CHANGED
|
@@ -11,16 +11,24 @@ const originalArgs = process.argv.slice(2);
|
|
|
11
11
|
const parsedArgs = minimist(originalArgs);
|
|
12
12
|
const command = parsedArgs._[0] || "help";
|
|
13
13
|
|
|
14
|
-
const customFlags = ["--no-cache", "--refresh"];
|
|
14
|
+
const customFlags = ["--no-cache", "--refresh", "--quiet"];
|
|
15
15
|
const hasNoCache = originalArgs.includes("--no-cache");
|
|
16
16
|
const hasRefresh = originalArgs.includes("--refresh");
|
|
17
|
+
const hasQuiet = originalArgs.includes("--quiet");
|
|
17
18
|
|
|
18
19
|
if (hasNoCache || hasRefresh) {
|
|
19
20
|
process.env.DISABLE_CACHE = "true";
|
|
20
|
-
|
|
21
|
+
if (!hasQuiet) {
|
|
22
|
+
console.log("[kos-cli] Cache disabled or refresh forced. Clearing cache...");
|
|
23
|
+
}
|
|
21
24
|
clearCache();
|
|
22
25
|
}
|
|
23
26
|
|
|
27
|
+
if (hasQuiet) {
|
|
28
|
+
process.env.DISABLE_CLI_BANNER = "true";
|
|
29
|
+
process.env.KOS_CLI_QUIET = "true";
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
25
33
|
const configPath = path.join(__dirname, "plopfile.mjs");
|
|
26
34
|
|
|
@@ -47,6 +55,7 @@ async function launch() {
|
|
|
47
55
|
console.log("\nGlobal Options:");
|
|
48
56
|
console.log(" --no-cache Disable cache");
|
|
49
57
|
console.log(" --refresh Clear cache and refresh");
|
|
58
|
+
console.log(" --quiet Suppress banner and debug output");
|
|
50
59
|
console.log(
|
|
51
60
|
" --interactive, -i Force interactive mode (ignore provided arguments)"
|
|
52
61
|
);
|
|
@@ -395,7 +404,7 @@ async function launch() {
|
|
|
395
404
|
|
|
396
405
|
const meta = await getGeneratorMetadata(command);
|
|
397
406
|
|
|
398
|
-
if (showBanner) {
|
|
407
|
+
if (showBanner && !hasQuiet) {
|
|
399
408
|
console.log(`--- Running KOS Generator: ${meta?.name || command} ---`);
|
|
400
409
|
}
|
|
401
410
|
|
|
@@ -753,10 +762,12 @@ async function launch() {
|
|
|
753
762
|
|
|
754
763
|
const results = await generator.runActions(answers);
|
|
755
764
|
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
765
|
+
if (!hasQuiet) {
|
|
766
|
+
console.log("[kos-cli] Generator completed successfully!");
|
|
767
|
+
results.changes.forEach((result) => {
|
|
768
|
+
console.log(result.path || result.message);
|
|
769
|
+
});
|
|
770
|
+
}
|
|
760
771
|
|
|
761
772
|
results.failures.forEach((fail) => {
|
|
762
773
|
console.error(fail.error || fail.message);
|
|
@@ -14,7 +14,13 @@
|
|
|
14
14
|
"file": "index.mjs",
|
|
15
15
|
"metadata": {
|
|
16
16
|
"key": "component",
|
|
17
|
-
"name": "KOS React Component"
|
|
17
|
+
"name": "KOS React Component",
|
|
18
|
+
"namedArguments": {
|
|
19
|
+
"name": "componentName",
|
|
20
|
+
"componentName": "componentName",
|
|
21
|
+
"project": "componentProject",
|
|
22
|
+
"componentProject": "componentProject"
|
|
23
|
+
}
|
|
18
24
|
}
|
|
19
25
|
},
|
|
20
26
|
{
|
|
@@ -30,7 +36,30 @@
|
|
|
30
36
|
"file": "namespace.mjs",
|
|
31
37
|
"metadata": {
|
|
32
38
|
"key": "i18n:namespace",
|
|
33
|
-
"name": "KOS i18n Project Namespace"
|
|
39
|
+
"name": "KOS i18n Project Namespace",
|
|
40
|
+
"namedArguments": {
|
|
41
|
+
"name": "name",
|
|
42
|
+
"locale": "locale",
|
|
43
|
+
"project": "project"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"category": "model",
|
|
49
|
+
"file": "add-future.mjs",
|
|
50
|
+
"metadata": {
|
|
51
|
+
"key": "add-future",
|
|
52
|
+
"name": "Add Future Support to Model",
|
|
53
|
+
"invalidateCache": true,
|
|
54
|
+
"namedArguments": {
|
|
55
|
+
"modelName": "modelName",
|
|
56
|
+
"project": "modelProject",
|
|
57
|
+
"modelProject": "modelProject",
|
|
58
|
+
"futureType": "futureType",
|
|
59
|
+
"updateServices": "updateServices",
|
|
60
|
+
"dryRun": "dryRun",
|
|
61
|
+
"interactive": "interactive"
|
|
62
|
+
}
|
|
34
63
|
}
|
|
35
64
|
},
|
|
36
65
|
{
|
|
@@ -38,7 +67,21 @@
|
|
|
38
67
|
"file": "companion.mjs",
|
|
39
68
|
"metadata": {
|
|
40
69
|
"key": "model:companion",
|
|
41
|
-
"name": "KOS Companion Model"
|
|
70
|
+
"name": "KOS Companion Model",
|
|
71
|
+
"namedArguments": {
|
|
72
|
+
"name": "modelName",
|
|
73
|
+
"modelName": "modelName",
|
|
74
|
+
"project": "modelProject",
|
|
75
|
+
"modelProject": "modelProject",
|
|
76
|
+
"companionParent": "companionParent",
|
|
77
|
+
"companionPattern": "companionPattern",
|
|
78
|
+
"container": "container",
|
|
79
|
+
"parentAware": "parentAware",
|
|
80
|
+
"singleton": "singleton",
|
|
81
|
+
"dataServices": "dataServices",
|
|
82
|
+
"dryRun": "dryRun",
|
|
83
|
+
"interactive": "interactive"
|
|
84
|
+
}
|
|
42
85
|
}
|
|
43
86
|
},
|
|
44
87
|
{
|
|
@@ -46,7 +89,17 @@
|
|
|
46
89
|
"file": "container.mjs",
|
|
47
90
|
"metadata": {
|
|
48
91
|
"key": "container",
|
|
49
|
-
"name": "KOS Container Model"
|
|
92
|
+
"name": "KOS Container Model",
|
|
93
|
+
"namedArguments": {
|
|
94
|
+
"modelName": "modelName",
|
|
95
|
+
"registrationProject": "registrationProject",
|
|
96
|
+
"container": "container",
|
|
97
|
+
"parentAware": "parentAware",
|
|
98
|
+
"singleton": "singleton",
|
|
99
|
+
"dataServices": "dataServices",
|
|
100
|
+
"dryRun": "dryRun",
|
|
101
|
+
"interactive": "interactive"
|
|
102
|
+
}
|
|
50
103
|
}
|
|
51
104
|
},
|
|
52
105
|
{
|
|
@@ -54,7 +107,12 @@
|
|
|
54
107
|
"file": "context.mjs",
|
|
55
108
|
"metadata": {
|
|
56
109
|
"key": "context",
|
|
57
|
-
"name": "KOS Model React Context"
|
|
110
|
+
"name": "KOS Model React Context",
|
|
111
|
+
"namedArguments": {
|
|
112
|
+
"modelName": "modelName",
|
|
113
|
+
"componentProject": "componentProject",
|
|
114
|
+
"project": "componentProject"
|
|
115
|
+
}
|
|
58
116
|
}
|
|
59
117
|
},
|
|
60
118
|
{
|
|
@@ -62,7 +120,12 @@
|
|
|
62
120
|
"file": "hook.mjs",
|
|
63
121
|
"metadata": {
|
|
64
122
|
"key": "hook",
|
|
65
|
-
"name": "KOS Model React Hook"
|
|
123
|
+
"name": "KOS Model React Hook",
|
|
124
|
+
"namedArguments": {
|
|
125
|
+
"modelName": "modelName",
|
|
126
|
+
"componentProject": "componentProject",
|
|
127
|
+
"project": "componentProject"
|
|
128
|
+
}
|
|
66
129
|
}
|
|
67
130
|
},
|
|
68
131
|
{
|
|
@@ -71,7 +134,20 @@
|
|
|
71
134
|
"metadata": {
|
|
72
135
|
"key": "model",
|
|
73
136
|
"name": "KOS Model",
|
|
74
|
-
"invalidateCache": true
|
|
137
|
+
"invalidateCache": true,
|
|
138
|
+
"namedArguments": {
|
|
139
|
+
"name": "modelName",
|
|
140
|
+
"modelName": "modelName",
|
|
141
|
+
"project": "modelProject",
|
|
142
|
+
"modelProject": "modelProject",
|
|
143
|
+
"container": "container",
|
|
144
|
+
"parentAware": "parentAware",
|
|
145
|
+
"singleton": "singleton",
|
|
146
|
+
"dataServices": "dataServices",
|
|
147
|
+
"futureAware": "futureAware",
|
|
148
|
+
"dryRun": "dryRun",
|
|
149
|
+
"interactive": "interactive"
|
|
150
|
+
}
|
|
75
151
|
}
|
|
76
152
|
},
|
|
77
153
|
{
|
|
@@ -80,31 +156,75 @@
|
|
|
80
156
|
"metadata": [
|
|
81
157
|
{
|
|
82
158
|
"key": "pluginComponent",
|
|
83
|
-
"name": "KOS UI Plugin Component"
|
|
159
|
+
"name": "KOS UI Plugin Component",
|
|
160
|
+
"namedArguments": {
|
|
161
|
+
"name": "componentName",
|
|
162
|
+
"componentName": "componentName",
|
|
163
|
+
"project": "componentProject",
|
|
164
|
+
"componentProject": "componentProject",
|
|
165
|
+
"extensionPoint": "extensionPoint"
|
|
166
|
+
}
|
|
84
167
|
},
|
|
85
168
|
{
|
|
86
169
|
"key": "plugin:cui",
|
|
87
|
-
"name": "KOS UI Plugin CUI Configuration"
|
|
170
|
+
"name": "KOS UI Plugin CUI Configuration",
|
|
171
|
+
"namedArguments": {
|
|
172
|
+
"name": "componentName",
|
|
173
|
+
"componentName": "componentName",
|
|
174
|
+
"project": "componentProject",
|
|
175
|
+
"componentProject": "componentProject"
|
|
176
|
+
}
|
|
88
177
|
},
|
|
89
178
|
{
|
|
90
179
|
"key": "plugin:setup",
|
|
91
|
-
"name": "KOS UI Plugin Setup Step"
|
|
180
|
+
"name": "KOS UI Plugin Setup Step",
|
|
181
|
+
"namedArguments": {
|
|
182
|
+
"name": "componentName",
|
|
183
|
+
"componentName": "componentName",
|
|
184
|
+
"project": "componentProject",
|
|
185
|
+
"componentProject": "componentProject"
|
|
186
|
+
}
|
|
92
187
|
},
|
|
93
188
|
{
|
|
94
189
|
"key": "plugin:utility",
|
|
95
|
-
"name": "KOS UI Plugin Utility"
|
|
190
|
+
"name": "KOS UI Plugin Utility",
|
|
191
|
+
"namedArguments": {
|
|
192
|
+
"name": "componentName",
|
|
193
|
+
"componentName": "componentName",
|
|
194
|
+
"project": "componentProject",
|
|
195
|
+
"componentProject": "componentProject"
|
|
196
|
+
}
|
|
96
197
|
},
|
|
97
198
|
{
|
|
98
199
|
"key": "plugin:setting",
|
|
99
|
-
"name": "KOS UI Plugin Setting"
|
|
200
|
+
"name": "KOS UI Plugin Setting",
|
|
201
|
+
"namedArguments": {
|
|
202
|
+
"name": "componentName",
|
|
203
|
+
"componentName": "componentName",
|
|
204
|
+
"project": "componentProject",
|
|
205
|
+
"componentProject": "componentProject",
|
|
206
|
+
"group": "group"
|
|
207
|
+
}
|
|
100
208
|
},
|
|
101
209
|
{
|
|
102
210
|
"key": "plugin:nav",
|
|
103
|
-
"name": "KOS UI Plugin Navigation View"
|
|
211
|
+
"name": "KOS UI Plugin Navigation View",
|
|
212
|
+
"namedArguments": {
|
|
213
|
+
"name": "componentName",
|
|
214
|
+
"componentName": "componentName",
|
|
215
|
+
"project": "componentProject",
|
|
216
|
+
"componentProject": "componentProject"
|
|
217
|
+
}
|
|
104
218
|
},
|
|
105
219
|
{
|
|
106
220
|
"key": "plugin:cp",
|
|
107
|
-
"name": "KOS UI Plugin Control Pour"
|
|
221
|
+
"name": "KOS UI Plugin Control Pour",
|
|
222
|
+
"namedArguments": {
|
|
223
|
+
"name": "componentName",
|
|
224
|
+
"componentName": "componentName",
|
|
225
|
+
"project": "componentProject",
|
|
226
|
+
"componentProject": "componentProject"
|
|
227
|
+
}
|
|
108
228
|
}
|
|
109
229
|
]
|
|
110
230
|
},
|
|
@@ -114,7 +234,22 @@
|
|
|
114
234
|
"metadata": {
|
|
115
235
|
"key": "project",
|
|
116
236
|
"name": "KOS UI App Project",
|
|
117
|
-
"invalidateCache": true
|
|
237
|
+
"invalidateCache": true,
|
|
238
|
+
"namedArguments": {
|
|
239
|
+
"name": "name"
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"category": "project",
|
|
245
|
+
"file": "content.mjs",
|
|
246
|
+
"metadata": {
|
|
247
|
+
"key": "content",
|
|
248
|
+
"name": "KOS Content Project",
|
|
249
|
+
"invalidateCache": true,
|
|
250
|
+
"namedArguments": {
|
|
251
|
+
"name": "name"
|
|
252
|
+
}
|
|
118
253
|
}
|
|
119
254
|
},
|
|
120
255
|
{
|
|
@@ -123,7 +258,10 @@
|
|
|
123
258
|
"metadata": {
|
|
124
259
|
"key": "i18n",
|
|
125
260
|
"name": "KOS Localization Project",
|
|
126
|
-
"invalidateCache": true
|
|
261
|
+
"invalidateCache": true,
|
|
262
|
+
"namedArguments": {
|
|
263
|
+
"name": "name"
|
|
264
|
+
}
|
|
127
265
|
}
|
|
128
266
|
},
|
|
129
267
|
{
|
|
@@ -132,7 +270,10 @@
|
|
|
132
270
|
"metadata": {
|
|
133
271
|
"key": "plugin",
|
|
134
272
|
"name": "KOS Plugin Project",
|
|
135
|
-
"invalidateCache": true
|
|
273
|
+
"invalidateCache": true,
|
|
274
|
+
"namedArguments": {
|
|
275
|
+
"name": "name"
|
|
276
|
+
}
|
|
136
277
|
}
|
|
137
278
|
},
|
|
138
279
|
{
|
|
@@ -141,7 +282,10 @@
|
|
|
141
282
|
"metadata": {
|
|
142
283
|
"key": "project:splash",
|
|
143
284
|
"name": "KOS Splash Screen Project",
|
|
144
|
-
"invalidateCache": true
|
|
285
|
+
"invalidateCache": true,
|
|
286
|
+
"namedArguments": {
|
|
287
|
+
"name": "name"
|
|
288
|
+
}
|
|
145
289
|
}
|
|
146
290
|
},
|
|
147
291
|
{
|
|
@@ -150,7 +294,10 @@
|
|
|
150
294
|
"metadata": {
|
|
151
295
|
"key": "theme",
|
|
152
296
|
"name": "KOS Theme Project",
|
|
153
|
-
"invalidateCache": true
|
|
297
|
+
"invalidateCache": true,
|
|
298
|
+
"namedArguments": {
|
|
299
|
+
"name": "name"
|
|
300
|
+
}
|
|
154
301
|
}
|
|
155
302
|
},
|
|
156
303
|
{
|
|
@@ -158,7 +305,37 @@
|
|
|
158
305
|
"file": "index.mjs",
|
|
159
306
|
"metadata": {
|
|
160
307
|
"key": "workspace",
|
|
161
|
-
"name": "Create a new KOS UI Workspace"
|
|
308
|
+
"name": "Create a new KOS UI Workspace",
|
|
309
|
+
"namedArguments": {
|
|
310
|
+
"name": "workspaceName",
|
|
311
|
+
"workspaceName": "workspaceName"
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
"category": "workspace",
|
|
317
|
+
"file": "list-models.mjs",
|
|
318
|
+
"metadata": {
|
|
319
|
+
"key": "workspace:list-models",
|
|
320
|
+
"name": "List all available models in the workspace",
|
|
321
|
+
"description": "List all available models in the workspace",
|
|
322
|
+
"namedArguments": {
|
|
323
|
+
"format": "outputFormat"
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
"category": "workspace",
|
|
329
|
+
"file": "list-projects.mjs",
|
|
330
|
+
"metadata": {
|
|
331
|
+
"key": "workspace:list-projects",
|
|
332
|
+
"name": "List all available projects in the workspace",
|
|
333
|
+
"description": "List all available projects in the workspace with optional type filtering",
|
|
334
|
+
"namedArguments": {
|
|
335
|
+
"type": "projectType",
|
|
336
|
+
"format": "outputFormat",
|
|
337
|
+
"fallback": "includeFallback"
|
|
338
|
+
}
|
|
162
339
|
}
|
|
163
340
|
}
|
|
164
341
|
]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// generators/project/content.mjs
|
|
2
|
+
import { actionFactory } from "../../utils/action-factory.mjs";
|
|
3
|
+
import { execute } from "../../utils/exec.mjs";
|
|
4
|
+
import { required } from "../../utils/validators.mjs";
|
|
5
|
+
|
|
6
|
+
export const metadata = {
|
|
7
|
+
key: "content",
|
|
8
|
+
name: "KOS Content Project",
|
|
9
|
+
invalidateCache: true,
|
|
10
|
+
namedArguments: { name: "name" },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default async function (plop) {
|
|
14
|
+
plop.setActionType("createContentProject", async function (answers) {
|
|
15
|
+
const command = `npx nx generate @kosdev-code/kos-nx-plugin:kos-content-project \
|
|
16
|
+
--name=${answers.name} \
|
|
17
|
+
--no-interactive`;
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
await execute(command);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
throw new Error(error);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return `Content project ${answers.name} created.`;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
plop.setGenerator("content", {
|
|
29
|
+
description:
|
|
30
|
+
"Create a new KOS Content project for KAB (Kos Asset Bundle) generation",
|
|
31
|
+
prompts: [
|
|
32
|
+
{
|
|
33
|
+
type: "input",
|
|
34
|
+
name: "name",
|
|
35
|
+
message: "What is the name of the content project?",
|
|
36
|
+
validate: required,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
actions: actionFactory("createContentProject", metadata),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// generators/workspace/index.mjs
|
|
2
2
|
import { createWorkspace } from "create-nx-workspace";
|
|
3
3
|
import { required } from "../../utils/validators.mjs";
|
|
4
|
+
import registerListModels from "./list-models.mjs";
|
|
5
|
+
import registerListProjects from "./list-projects.mjs";
|
|
4
6
|
|
|
5
7
|
export const metadata = {
|
|
6
8
|
key: "workspace",
|
|
@@ -31,4 +33,8 @@ export default async function (plop) {
|
|
|
31
33
|
],
|
|
32
34
|
actions: () => [{ type: "createWorkspace" }],
|
|
33
35
|
});
|
|
36
|
+
|
|
37
|
+
// Register additional workspace generators
|
|
38
|
+
await registerListModels(plop);
|
|
39
|
+
await registerListProjects(plop);
|
|
34
40
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { getAllModels } from "../../utils/nx-context.mjs";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generator for listing all models in a workspace
|
|
5
|
+
*/
|
|
6
|
+
export default async function register(plop) {
|
|
7
|
+
plop.setGenerator("workspace:list-models", {
|
|
8
|
+
description: "List all available models in the workspace",
|
|
9
|
+
prompts: [
|
|
10
|
+
{
|
|
11
|
+
type: "list",
|
|
12
|
+
name: "outputFormat",
|
|
13
|
+
message: "Output format",
|
|
14
|
+
choices: ["json", "table", "simple"],
|
|
15
|
+
default: "json",
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
actions: function (answers) {
|
|
19
|
+
return [
|
|
20
|
+
async function listModels() {
|
|
21
|
+
const models = await getAllModels();
|
|
22
|
+
|
|
23
|
+
formatModelOutput(models, answers.outputFormat);
|
|
24
|
+
|
|
25
|
+
return `[ok] Found ${models.length} models in workspace`;
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
function formatModelOutput(models, format) {
|
|
34
|
+
switch (format) {
|
|
35
|
+
case "json":
|
|
36
|
+
console.log(JSON.stringify(models, null, 2));
|
|
37
|
+
break;
|
|
38
|
+
|
|
39
|
+
case "table":
|
|
40
|
+
console.table(
|
|
41
|
+
models.map((m) => ({
|
|
42
|
+
Model: m.model,
|
|
43
|
+
Project: m.project,
|
|
44
|
+
}))
|
|
45
|
+
);
|
|
46
|
+
break;
|
|
47
|
+
|
|
48
|
+
case "simple":
|
|
49
|
+
for (const model of models) {
|
|
50
|
+
console.log(`${model.project}/${model.model}`);
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Export metadata for CLI integration
|
|
57
|
+
export const metadata = {
|
|
58
|
+
key: "workspace:list-models",
|
|
59
|
+
name: "List all available models in the workspace",
|
|
60
|
+
description: "List all available models in the workspace",
|
|
61
|
+
namedArguments: {
|
|
62
|
+
format: "outputFormat",
|
|
63
|
+
},
|
|
64
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAllProjects,
|
|
3
|
+
getLibraryProjects,
|
|
4
|
+
getModelProjects,
|
|
5
|
+
getModelComponentProjects,
|
|
6
|
+
getUIProjects,
|
|
7
|
+
getI18nProjects,
|
|
8
|
+
getPluginProjects,
|
|
9
|
+
getModelProjectsWithFallback,
|
|
10
|
+
getModelComponentProjectsWithFallback,
|
|
11
|
+
getI18nProjectsWithFallback,
|
|
12
|
+
getPluginProjectsWithFallback,
|
|
13
|
+
} from "../../utils/nx-context.mjs";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Generator for listing all projects in a workspace
|
|
17
|
+
*/
|
|
18
|
+
export default async function register(plop) {
|
|
19
|
+
plop.setGenerator("workspace:list-projects", {
|
|
20
|
+
description: "List all available projects in the workspace",
|
|
21
|
+
prompts: [
|
|
22
|
+
{
|
|
23
|
+
type: "list",
|
|
24
|
+
name: "projectType",
|
|
25
|
+
message: "Project type to filter by",
|
|
26
|
+
choices: [
|
|
27
|
+
{ name: "All projects", value: "all" },
|
|
28
|
+
{ name: "Model projects", value: "model" },
|
|
29
|
+
{ name: "Model component projects", value: "model-component" },
|
|
30
|
+
{ name: "UI projects", value: "ui" },
|
|
31
|
+
{ name: "I18n projects", value: "i18n" },
|
|
32
|
+
{ name: "Plugin projects", value: "plugin" },
|
|
33
|
+
{ name: "Library projects", value: "library" },
|
|
34
|
+
],
|
|
35
|
+
default: "all",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: "list",
|
|
39
|
+
name: "outputFormat",
|
|
40
|
+
message: "Output format",
|
|
41
|
+
choices: ["json", "table", "simple"],
|
|
42
|
+
default: "json",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: "confirm",
|
|
46
|
+
name: "includeFallback",
|
|
47
|
+
message: "Include fallback projects if no projects of specified type found?",
|
|
48
|
+
default: true,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
actions: function (answers) {
|
|
52
|
+
return [
|
|
53
|
+
async function listProjects() {
|
|
54
|
+
const includeFallback = answers.projectType === "all" ? false : (answers.includeFallback ?? true);
|
|
55
|
+
const projects = await getProjectsByType(
|
|
56
|
+
answers.projectType,
|
|
57
|
+
includeFallback
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
formatProjectOutput(projects, answers.outputFormat, answers.projectType);
|
|
61
|
+
|
|
62
|
+
return `[ok] Found ${projects.length} ${answers.projectType} projects`;
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Zone 1: High-level orchestration
|
|
70
|
+
async function getProjectsByType(projectType, includeFallback) {
|
|
71
|
+
switch (projectType) {
|
|
72
|
+
case "all":
|
|
73
|
+
return await getAllProjects();
|
|
74
|
+
case "model":
|
|
75
|
+
return includeFallback
|
|
76
|
+
? await getModelProjectsWithFallback()
|
|
77
|
+
: await getModelProjects();
|
|
78
|
+
case "model-component":
|
|
79
|
+
return includeFallback
|
|
80
|
+
? await getModelComponentProjectsWithFallback()
|
|
81
|
+
: await getModelComponentProjects();
|
|
82
|
+
case "ui":
|
|
83
|
+
return await getUIProjects();
|
|
84
|
+
case "i18n":
|
|
85
|
+
return includeFallback
|
|
86
|
+
? await getI18nProjectsWithFallback()
|
|
87
|
+
: await getI18nProjects();
|
|
88
|
+
case "plugin":
|
|
89
|
+
return includeFallback
|
|
90
|
+
? await getPluginProjectsWithFallback()
|
|
91
|
+
: await getPluginProjects();
|
|
92
|
+
case "library":
|
|
93
|
+
return await getLibraryProjects();
|
|
94
|
+
default:
|
|
95
|
+
throw new Error(`Unknown project type: ${projectType}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Zone 3: Output formatting
|
|
100
|
+
function formatProjectOutput(projects, format, projectType) {
|
|
101
|
+
const enrichedProjects = enrichProjectData(projects, projectType);
|
|
102
|
+
|
|
103
|
+
switch (format) {
|
|
104
|
+
case "json":
|
|
105
|
+
console.log(JSON.stringify(enrichedProjects, null, 2));
|
|
106
|
+
break;
|
|
107
|
+
|
|
108
|
+
case "table":
|
|
109
|
+
console.table(
|
|
110
|
+
enrichedProjects.map((p) => ({
|
|
111
|
+
Name: p.name,
|
|
112
|
+
Type: p.type || "unknown",
|
|
113
|
+
}))
|
|
114
|
+
);
|
|
115
|
+
break;
|
|
116
|
+
|
|
117
|
+
case "simple":
|
|
118
|
+
for (const project of enrichedProjects) {
|
|
119
|
+
console.log(project.name);
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function enrichProjectData(projects, requestedType) {
|
|
126
|
+
return projects.map((projectName) => ({
|
|
127
|
+
name: projectName,
|
|
128
|
+
type: requestedType === "all" ? inferProjectType(projectName) : requestedType,
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function inferProjectType(projectName) {
|
|
133
|
+
const name = projectName.toLowerCase();
|
|
134
|
+
|
|
135
|
+
if (name.includes("model") && !name.includes("component")) {
|
|
136
|
+
return "model";
|
|
137
|
+
}
|
|
138
|
+
if (name.includes("model") && name.includes("component")) {
|
|
139
|
+
return "model-component";
|
|
140
|
+
}
|
|
141
|
+
if (name.includes("ui") || name.includes("app")) {
|
|
142
|
+
return "ui";
|
|
143
|
+
}
|
|
144
|
+
if (name.includes("i18n") || name.includes("localization")) {
|
|
145
|
+
return "i18n";
|
|
146
|
+
}
|
|
147
|
+
if (name.includes("plugin") || name.includes("extension")) {
|
|
148
|
+
return "plugin";
|
|
149
|
+
}
|
|
150
|
+
if (name.includes("lib")) {
|
|
151
|
+
return "library";
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return "unknown";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Export metadata for CLI integration
|
|
158
|
+
export const metadata = {
|
|
159
|
+
key: "workspace:list-projects",
|
|
160
|
+
name: "List all available projects in the workspace",
|
|
161
|
+
description: "List all available projects in the workspace with optional type filtering",
|
|
162
|
+
namedArguments: {
|
|
163
|
+
type: "projectType",
|
|
164
|
+
format: "outputFormat",
|
|
165
|
+
fallback: "includeFallback",
|
|
166
|
+
},
|
|
167
|
+
};
|
package/src/lib/plopfile.mjs
CHANGED
|
@@ -16,6 +16,7 @@ import registerCacheGenerators from "./generators/cache/index.mjs";
|
|
|
16
16
|
import registerEnv from "./generators/env/index.mjs";
|
|
17
17
|
import registerI18nNamespace from "./generators/i18n/namespace.mjs";
|
|
18
18
|
import registerUiProject from "./generators/project/app.mjs";
|
|
19
|
+
import registerContentProject from "./generators/project/content.mjs";
|
|
19
20
|
import registerI18n from "./generators/project/i18n.mjs";
|
|
20
21
|
import registerPluginProject from "./generators/project/plugin.mjs";
|
|
21
22
|
import registerSplashProject from "./generators/project/splash.mjs";
|
|
@@ -49,6 +50,7 @@ export default async function (plop) {
|
|
|
49
50
|
await registerComponent(plop);
|
|
50
51
|
await registerPluginComponent(plop);
|
|
51
52
|
await registerTheme(plop);
|
|
53
|
+
await registerContentProject(plop);
|
|
52
54
|
await registerUiProject(plop);
|
|
53
55
|
await registerPluginProject(plop);
|
|
54
56
|
await registerSplashProject(plop);
|
|
@@ -104,7 +104,9 @@ export async function getAllKosProjects() {
|
|
|
104
104
|
const cached = getCached("allKosProjects");
|
|
105
105
|
if (cached) return cached;
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
108
|
+
console.warn(`[kos-cli] Discovering KOS projects by scanning .kos.json files...`);
|
|
109
|
+
}
|
|
108
110
|
|
|
109
111
|
// In an NX workspace, focus on common project directories first
|
|
110
112
|
const projectDirs = ['apps', 'libs', 'packages'];
|
|
@@ -127,7 +129,9 @@ export async function getAllKosProjects() {
|
|
|
127
129
|
|
|
128
130
|
// If we didn't find any in the common directories, fall back to full scan
|
|
129
131
|
if (kosJsonFiles.length === 0) {
|
|
130
|
-
|
|
132
|
+
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
133
|
+
console.warn(`[kos-cli] No .kos.json files found in common directories, performing full workspace scan...`);
|
|
134
|
+
}
|
|
131
135
|
findKosJsonFiles(workspaceRoot, kosJsonFiles);
|
|
132
136
|
}
|
|
133
137
|
|
|
@@ -181,7 +185,9 @@ export async function getProjectsByType(targetType) {
|
|
|
181
185
|
const cached = getCached(cacheKey);
|
|
182
186
|
if (cached) return cached;
|
|
183
187
|
|
|
184
|
-
|
|
188
|
+
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
189
|
+
console.warn(`[kos-cli] Filtering projects for ${targetType} projectType...`);
|
|
190
|
+
}
|
|
185
191
|
const allKosProjects = await getAllKosProjects();
|
|
186
192
|
const filteredProjects = [];
|
|
187
193
|
|
|
@@ -223,10 +229,14 @@ export async function getProjectsByTypeWithFallback(targetType, fallbackFunction
|
|
|
223
229
|
const filteredProjects = await getProjectsByType(targetType);
|
|
224
230
|
|
|
225
231
|
if (filteredProjects.length > 0) {
|
|
226
|
-
|
|
232
|
+
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
233
|
+
console.warn(`[kos-cli] Found ${filteredProjects.length} ${targetType} projects`);
|
|
234
|
+
}
|
|
227
235
|
return filteredProjects;
|
|
228
236
|
} else {
|
|
229
|
-
|
|
237
|
+
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
238
|
+
console.warn(`[kos-cli] No ${targetType} projects found, showing fallback projects`);
|
|
239
|
+
}
|
|
230
240
|
return await fallbackFunction();
|
|
231
241
|
}
|
|
232
242
|
}
|
|
@@ -275,10 +285,14 @@ export async function getComponentCompatibleProjectsWithFallback() {
|
|
|
275
285
|
const componentProjects = await getComponentCompatibleProjects();
|
|
276
286
|
|
|
277
287
|
if (componentProjects.length > 0) {
|
|
278
|
-
|
|
288
|
+
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
289
|
+
console.warn(`[kos-cli] Found ${componentProjects.length} component-compatible projects`);
|
|
290
|
+
}
|
|
279
291
|
return componentProjects;
|
|
280
292
|
} else {
|
|
281
|
-
|
|
293
|
+
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
294
|
+
console.warn(`[kos-cli] No component-compatible projects found, showing all projects`);
|
|
295
|
+
}
|
|
282
296
|
return await getAllProjects();
|
|
283
297
|
}
|
|
284
298
|
}
|
|
@@ -291,14 +305,18 @@ export async function getPluginProjectsWithFallback() {
|
|
|
291
305
|
// First try type-based filtering
|
|
292
306
|
const pluginProjectsByType = await getProjectsByType("plugin");
|
|
293
307
|
if (pluginProjectsByType.length > 0) {
|
|
294
|
-
|
|
308
|
+
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
309
|
+
console.warn(`[kos-cli] Found ${pluginProjectsByType.length} plugin projects by type`);
|
|
310
|
+
}
|
|
295
311
|
return pluginProjectsByType;
|
|
296
312
|
}
|
|
297
313
|
|
|
298
314
|
// Fall back to existing name-based filtering
|
|
299
315
|
const pluginProjectsByName = await getPluginProjects();
|
|
300
316
|
if (pluginProjectsByName.length > 0) {
|
|
301
|
-
|
|
317
|
+
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
318
|
+
console.warn(`[kos-cli] Found ${pluginProjectsByName.length} plugin projects by name`);
|
|
319
|
+
}
|
|
302
320
|
return pluginProjectsByName;
|
|
303
321
|
}
|
|
304
322
|
|
|
@@ -311,7 +329,9 @@ export async function getAllModels() {
|
|
|
311
329
|
const cached = getCached("allModels");
|
|
312
330
|
if (cached) return cached;
|
|
313
331
|
|
|
314
|
-
|
|
332
|
+
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
333
|
+
console.warn(`[kos-cli] Scanning for models in KOS projects...`);
|
|
334
|
+
}
|
|
315
335
|
const allKosProjects = await getAllKosProjects();
|
|
316
336
|
const models = [];
|
|
317
337
|
|