@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,11 +1,1215 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
|
|
1
|
+
// ../kos-codegen-core/src/lib/codegen-filesystem.ts
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
var TrackingFileSystem = class {
|
|
5
|
+
inner;
|
|
6
|
+
_writtenPaths = [];
|
|
7
|
+
constructor(inner) {
|
|
8
|
+
this.inner = inner;
|
|
9
|
+
}
|
|
10
|
+
get root() {
|
|
11
|
+
return this.inner.root;
|
|
12
|
+
}
|
|
13
|
+
get writtenPaths() {
|
|
14
|
+
return [...this._writtenPaths];
|
|
15
|
+
}
|
|
16
|
+
read(filePath) {
|
|
17
|
+
return this.inner.read(filePath);
|
|
18
|
+
}
|
|
19
|
+
write(filePath, content) {
|
|
20
|
+
this.inner.write(filePath, content);
|
|
21
|
+
this._writtenPaths.push(
|
|
22
|
+
path.isAbsolute(filePath) ? filePath : path.join(this.inner.root, filePath)
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
exists(filePath) {
|
|
26
|
+
return this.inner.exists(filePath);
|
|
27
|
+
}
|
|
28
|
+
delete(filePath) {
|
|
29
|
+
this.inner.delete(filePath);
|
|
30
|
+
}
|
|
31
|
+
listFiles(dirPath) {
|
|
32
|
+
return this.inner.listFiles(dirPath);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var DirectFileSystem = class {
|
|
36
|
+
root;
|
|
37
|
+
constructor(workspaceRoot) {
|
|
38
|
+
this.root = path.resolve(workspaceRoot);
|
|
39
|
+
}
|
|
40
|
+
read(filePath) {
|
|
41
|
+
const abs = this.resolve(filePath);
|
|
42
|
+
try {
|
|
43
|
+
return fs.readFileSync(abs, "utf-8");
|
|
44
|
+
} catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
write(filePath, content) {
|
|
49
|
+
const abs = this.resolve(filePath);
|
|
50
|
+
fs.mkdirSync(path.dirname(abs), { recursive: true });
|
|
51
|
+
fs.writeFileSync(abs, content, "utf-8");
|
|
52
|
+
}
|
|
53
|
+
exists(filePath) {
|
|
54
|
+
return fs.existsSync(this.resolve(filePath));
|
|
55
|
+
}
|
|
56
|
+
delete(filePath) {
|
|
57
|
+
const abs = this.resolve(filePath);
|
|
58
|
+
try {
|
|
59
|
+
fs.unlinkSync(abs);
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
listFiles(dirPath) {
|
|
64
|
+
const abs = this.resolve(dirPath);
|
|
65
|
+
if (!fs.existsSync(abs)) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
return this.walkDir(abs).map((file) => path.relative(this.root, file));
|
|
69
|
+
}
|
|
70
|
+
resolve(filePath) {
|
|
71
|
+
if (path.isAbsolute(filePath)) {
|
|
72
|
+
return filePath;
|
|
73
|
+
}
|
|
74
|
+
return path.join(this.root, filePath);
|
|
75
|
+
}
|
|
76
|
+
walkDir(dir) {
|
|
77
|
+
const results = [];
|
|
78
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
79
|
+
for (const entry of entries) {
|
|
80
|
+
const full = path.join(dir, entry.name);
|
|
81
|
+
if (entry.isDirectory()) {
|
|
82
|
+
results.push(...this.walkDir(full));
|
|
83
|
+
} else {
|
|
84
|
+
results.push(full);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return results;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// ../kos-codegen-core/src/lib/generate-files.ts
|
|
92
|
+
import * as fs2 from "fs";
|
|
93
|
+
import * as path2 from "path";
|
|
94
|
+
import * as ejs from "ejs";
|
|
95
|
+
|
|
96
|
+
// ../kos-codegen-core/src/lib/logger.ts
|
|
97
|
+
var noopLogger = {
|
|
98
|
+
debug: () => {
|
|
99
|
+
},
|
|
100
|
+
info: () => {
|
|
101
|
+
},
|
|
102
|
+
warn: () => {
|
|
103
|
+
},
|
|
104
|
+
error: () => {
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
var activeLogger = noopLogger;
|
|
108
|
+
function getCodegenLogger() {
|
|
109
|
+
return activeLogger;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// ../kos-codegen-core/src/lib/generate-files.ts
|
|
113
|
+
function generateFilesFromTemplates(codegenFs, srcFolder, destFolder, substitutions) {
|
|
114
|
+
const logger = getCodegenLogger();
|
|
115
|
+
const templateFiles = walkTemplateDir(srcFolder);
|
|
116
|
+
for (const templateFile of templateFiles) {
|
|
117
|
+
const relPath = path2.relative(srcFolder, templateFile);
|
|
118
|
+
let destRelPath = interpolateFilename(relPath, substitutions);
|
|
119
|
+
if (destRelPath.endsWith(".template")) {
|
|
120
|
+
destRelPath = destRelPath.slice(0, -".template".length);
|
|
121
|
+
}
|
|
122
|
+
const destPath = path2.join(destFolder, destRelPath);
|
|
123
|
+
const rawContent = fs2.readFileSync(templateFile, "utf-8");
|
|
124
|
+
const rendered = ejs.render(rawContent, substitutions, {
|
|
125
|
+
filename: templateFile
|
|
126
|
+
// for EJS error messages and includes
|
|
127
|
+
});
|
|
128
|
+
logger.debug(`Generating ${destPath}`);
|
|
129
|
+
codegenFs.write(destPath, rendered);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function interpolateFilename(filePath, substitutions) {
|
|
133
|
+
return filePath.replace(/__([^_]+)__/g, (match, key) => {
|
|
134
|
+
if (key in substitutions) {
|
|
135
|
+
return String(substitutions[key]);
|
|
136
|
+
}
|
|
137
|
+
return match;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function walkTemplateDir(dir) {
|
|
141
|
+
const results = [];
|
|
142
|
+
const entries = fs2.readdirSync(dir, { withFileTypes: true });
|
|
143
|
+
for (const entry of entries) {
|
|
144
|
+
const full = path2.join(dir, entry.name);
|
|
145
|
+
if (entry.isDirectory()) {
|
|
146
|
+
results.push(...walkTemplateDir(full));
|
|
147
|
+
} else {
|
|
148
|
+
results.push(full);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return results;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ../kos-codegen-core/src/lib/project-discovery.ts
|
|
155
|
+
import * as fs3 from "fs";
|
|
156
|
+
import * as path3 from "path";
|
|
157
|
+
import fg from "fast-glob";
|
|
158
|
+
function discoverProjects(workspaceRoot) {
|
|
159
|
+
const logger = getCodegenLogger();
|
|
160
|
+
const projects = /* @__PURE__ */ new Map();
|
|
161
|
+
const projectJsonPaths = fg.sync("**/project.json", {
|
|
162
|
+
cwd: workspaceRoot,
|
|
163
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/.git/**"],
|
|
164
|
+
absolute: false
|
|
165
|
+
});
|
|
166
|
+
for (const relPath of projectJsonPaths) {
|
|
167
|
+
const absPath = path3.join(workspaceRoot, relPath);
|
|
168
|
+
try {
|
|
169
|
+
const raw = fs3.readFileSync(absPath, "utf-8");
|
|
170
|
+
const json = JSON.parse(raw);
|
|
171
|
+
const projectRoot = path3.dirname(relPath);
|
|
172
|
+
const name = json.name ?? path3.basename(projectRoot);
|
|
173
|
+
const config = {
|
|
174
|
+
name,
|
|
175
|
+
root: projectRoot,
|
|
176
|
+
sourceRoot: json.sourceRoot ?? path3.join(projectRoot, "src"),
|
|
177
|
+
projectType: json.projectType,
|
|
178
|
+
targets: json.targets,
|
|
179
|
+
tags: json.tags
|
|
180
|
+
};
|
|
181
|
+
projects.set(name, config);
|
|
182
|
+
logger.debug(`Discovered project: ${name} at ${projectRoot}`);
|
|
183
|
+
} catch (err) {
|
|
184
|
+
logger.warn(`Failed to parse ${absPath}: ${err}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
logger.info(`Discovered ${projects.size} projects`);
|
|
188
|
+
return projects;
|
|
189
|
+
}
|
|
190
|
+
function findProjectByName(workspaceRoot, projectName, projects) {
|
|
191
|
+
const map = projects ?? discoverProjects(workspaceRoot);
|
|
192
|
+
return map.get(projectName);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// ../kos-codegen-core/src/lib/json-utils.ts
|
|
196
|
+
function readJson(codegenFs, filePath) {
|
|
197
|
+
const content = codegenFs.read(filePath);
|
|
198
|
+
if (content === null) {
|
|
199
|
+
throw new Error(`File not found: ${filePath}`);
|
|
200
|
+
}
|
|
201
|
+
return JSON.parse(content);
|
|
202
|
+
}
|
|
203
|
+
function writeJson(codegenFs, filePath, value) {
|
|
204
|
+
codegenFs.write(filePath, JSON.stringify(value, null, 2) + "\n");
|
|
205
|
+
}
|
|
206
|
+
function updateJson(codegenFs, filePath, updater) {
|
|
207
|
+
const current = readJson(codegenFs, filePath);
|
|
208
|
+
const updated = updater(current);
|
|
209
|
+
writeJson(codegenFs, filePath, updated);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ../kos-codegen-core/src/lib/format-files.ts
|
|
213
|
+
import * as fs4 from "fs";
|
|
214
|
+
import * as path4 from "path";
|
|
215
|
+
import prettier from "prettier";
|
|
216
|
+
var FORMATTABLE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
217
|
+
".ts",
|
|
218
|
+
".tsx",
|
|
219
|
+
".js",
|
|
220
|
+
".jsx",
|
|
221
|
+
".json",
|
|
222
|
+
".css",
|
|
223
|
+
".scss",
|
|
224
|
+
".md",
|
|
225
|
+
".yaml",
|
|
226
|
+
".yml",
|
|
227
|
+
".html"
|
|
228
|
+
]);
|
|
229
|
+
async function formatFiles(workspaceRoot, filePaths) {
|
|
230
|
+
const logger = getCodegenLogger();
|
|
231
|
+
for (const filePath of filePaths) {
|
|
232
|
+
const ext = path4.extname(filePath);
|
|
233
|
+
if (!FORMATTABLE_EXTENSIONS.has(ext)) {
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
const content = fs4.readFileSync(filePath, "utf-8");
|
|
238
|
+
const options = await prettier.resolveConfig(filePath, {
|
|
239
|
+
editorconfig: true
|
|
240
|
+
});
|
|
241
|
+
const formatted = await prettier.format(content, {
|
|
242
|
+
...options,
|
|
243
|
+
filepath: filePath
|
|
244
|
+
});
|
|
245
|
+
fs4.writeFileSync(filePath, formatted, "utf-8");
|
|
246
|
+
logger.debug(`Formatted ${path4.relative(workspaceRoot, filePath)}`);
|
|
247
|
+
} catch (err) {
|
|
248
|
+
logger.warn(`Failed to format ${filePath}: ${err}`);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// ../kos-codegen-core/src/lib/name-utils.ts
|
|
254
|
+
function dashCase(input) {
|
|
255
|
+
return input.replace(/\s+/g, "-").replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
256
|
+
}
|
|
257
|
+
function camelCase(input) {
|
|
258
|
+
if (input.length === 0)
|
|
259
|
+
return "";
|
|
260
|
+
const words = input.split(/-|\s+/);
|
|
261
|
+
if (words.length > 0 && words[0].length > 0) {
|
|
262
|
+
words[0] = words[0].charAt(0).toLowerCase() + words[0].slice(1);
|
|
263
|
+
}
|
|
264
|
+
for (let i = 1; i < words.length; i++) {
|
|
265
|
+
words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1);
|
|
266
|
+
}
|
|
267
|
+
return words.join("");
|
|
268
|
+
}
|
|
269
|
+
function pascalCase(input) {
|
|
270
|
+
if (input.length === 0)
|
|
271
|
+
return "";
|
|
272
|
+
const cc = camelCase(input);
|
|
273
|
+
return cc[0].toUpperCase() + cc.slice(1);
|
|
274
|
+
}
|
|
275
|
+
function properCase(input) {
|
|
276
|
+
const words = input.toLowerCase().replaceAll("-", " ").split(" ").filter(Boolean);
|
|
277
|
+
for (let i = 0; i < words.length; i++) {
|
|
278
|
+
words[i] = words[i][0].toUpperCase() + words[i].slice(1);
|
|
279
|
+
}
|
|
280
|
+
return words.join("");
|
|
281
|
+
}
|
|
282
|
+
function constantCase(input) {
|
|
283
|
+
if (input.length === 0)
|
|
284
|
+
return "";
|
|
285
|
+
return input.toUpperCase().split(/[\s-]+/).filter(Boolean).join("_");
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// ../kos-codegen-core/src/lib/normalize-values.ts
|
|
289
|
+
var normalizeValue = (optionsName, value) => ({
|
|
290
|
+
[`${camelCase(optionsName)}CamelCase`]: camelCase(value),
|
|
291
|
+
[`${camelCase(optionsName)}ConstantCase`]: constantCase(value),
|
|
292
|
+
[`${camelCase(optionsName)}DashCase`]: dashCase(value),
|
|
293
|
+
[`${camelCase(optionsName)}PascalCase`]: pascalCase(value),
|
|
294
|
+
[`${camelCase(optionsName)}ProperCase`]: properCase(value),
|
|
295
|
+
[`${camelCase(optionsName)}LowerCase`]: value.toLowerCase(),
|
|
296
|
+
[`${optionsName}`]: value
|
|
297
|
+
});
|
|
298
|
+
var normalizeAllValues = (options) => {
|
|
299
|
+
let normalizedValues = {};
|
|
300
|
+
for (const key in options) {
|
|
301
|
+
if (Object.prototype.hasOwnProperty.call(options, key)) {
|
|
302
|
+
const element = options[key];
|
|
303
|
+
const newOptions = typeof element !== "string" || element === "" ? { [key]: element } : normalizeValue(key, element);
|
|
304
|
+
normalizedValues = {
|
|
305
|
+
...normalizedValues,
|
|
306
|
+
...newOptions
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return normalizedValues;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
// ../kos-codegen-core/src/lib/kos-config.ts
|
|
314
|
+
import * as path5 from "path";
|
|
315
|
+
function getKosProjectConfiguration(codegenFs, projectName, projects) {
|
|
316
|
+
const project = findProjectByName(codegenFs.root, projectName, projects);
|
|
317
|
+
if (!project)
|
|
318
|
+
return void 0;
|
|
319
|
+
const configPath = path5.join(project.root, ".kos.json");
|
|
320
|
+
if (!codegenFs.exists(configPath)) {
|
|
321
|
+
const defaultConfig = {
|
|
322
|
+
name: `${dashCase(projectName)}-model`,
|
|
323
|
+
type: "kos.model",
|
|
324
|
+
version: "0.1.0",
|
|
325
|
+
models: {},
|
|
326
|
+
generator: { defaults: { model: { folder: "" } } }
|
|
327
|
+
};
|
|
328
|
+
codegenFs.write(configPath, JSON.stringify(defaultConfig, null, 2));
|
|
329
|
+
}
|
|
330
|
+
const content = codegenFs.read(configPath);
|
|
331
|
+
return content ? JSON.parse(content) : void 0;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// ../kos-codegen-core/src/lib/template-resolver.ts
|
|
335
|
+
import * as path6 from "path";
|
|
336
|
+
import * as fs5 from "fs";
|
|
337
|
+
function findPackageRoot() {
|
|
338
|
+
if (process.env.KOS_TEMPLATE_BASE_DIR) {
|
|
339
|
+
return process.env.KOS_TEMPLATE_BASE_DIR;
|
|
340
|
+
}
|
|
341
|
+
let dir = __dirname;
|
|
342
|
+
while (dir !== path6.dirname(dir)) {
|
|
343
|
+
const pkgPath = path6.join(dir, "package.json");
|
|
344
|
+
if (fs5.existsSync(pkgPath)) {
|
|
345
|
+
try {
|
|
346
|
+
const pkg = JSON.parse(fs5.readFileSync(pkgPath, "utf-8"));
|
|
347
|
+
if (pkg.name === "@kosdev-code/kos-codegen-core") {
|
|
348
|
+
return dir;
|
|
349
|
+
}
|
|
350
|
+
} catch {
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
dir = path6.dirname(dir);
|
|
354
|
+
}
|
|
355
|
+
return path6.resolve(__dirname, "..", "..");
|
|
356
|
+
}
|
|
357
|
+
function getTemplateDir(generatorName) {
|
|
358
|
+
return path6.join(findPackageRoot(), "templates", generatorName);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// ../kos-codegen-core/src/lib/generators/normalize-options.ts
|
|
362
|
+
import * as path7 from "path";
|
|
363
|
+
function normalizeOptions(codegenFs, options, projects) {
|
|
364
|
+
const toNormalize = {
|
|
365
|
+
name: options.name
|
|
366
|
+
};
|
|
367
|
+
if (options.modelName) {
|
|
368
|
+
toNormalize.modelName = options.modelName;
|
|
369
|
+
}
|
|
370
|
+
if (options.companionModel) {
|
|
371
|
+
toNormalize.companionModel = options.companionModel;
|
|
372
|
+
}
|
|
373
|
+
const normalizedValues = normalizeAllValues(toNormalize);
|
|
374
|
+
const modelProject = options.modelProject;
|
|
375
|
+
const registrationProject = options.registrationProject || "";
|
|
376
|
+
const useModelProject = modelProject !== "__NONE__";
|
|
377
|
+
let importPath = "";
|
|
378
|
+
if (useModelProject) {
|
|
379
|
+
const modelProjectConfig = findProjectByName(
|
|
380
|
+
codegenFs.root,
|
|
381
|
+
modelProject,
|
|
382
|
+
projects
|
|
383
|
+
);
|
|
384
|
+
if (modelProjectConfig) {
|
|
385
|
+
const pkgJsonPath = path7.join(modelProjectConfig.root, "package.json");
|
|
386
|
+
try {
|
|
387
|
+
const pkgJson = readJson(codegenFs, pkgJsonPath);
|
|
388
|
+
importPath = pkgJson.name || "";
|
|
389
|
+
} catch {
|
|
390
|
+
importPath = "";
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
const booleanDefaults = {
|
|
395
|
+
companion: false,
|
|
396
|
+
skipRegistration: false
|
|
397
|
+
};
|
|
398
|
+
return {
|
|
399
|
+
...booleanDefaults,
|
|
400
|
+
...options,
|
|
401
|
+
...normalizedValues,
|
|
402
|
+
modelProject,
|
|
403
|
+
importPath,
|
|
404
|
+
registrationProject,
|
|
405
|
+
template: ""
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// ../kos-codegen-core/src/lib/generators/update-model-index.ts
|
|
410
|
+
import * as ts from "typescript";
|
|
411
|
+
|
|
412
|
+
// ../kos-codegen-core/src/lib/generators/component/generate-component.ts
|
|
413
|
+
import * as path10 from "path";
|
|
414
|
+
|
|
415
|
+
// ../kos-codegen-core/src/lib/generators/component/types.ts
|
|
416
|
+
var PLUGIN_TYPES = {
|
|
417
|
+
CUI: "cui",
|
|
418
|
+
UTILITY: "utility",
|
|
419
|
+
TROUBLE_ACTION: "troubleAction",
|
|
420
|
+
SETUP: "setup",
|
|
421
|
+
SETTING: "setting",
|
|
422
|
+
NAV: "nav",
|
|
423
|
+
CONTROL_POUR: "controlPour",
|
|
424
|
+
CUSTOM: "custom"
|
|
425
|
+
};
|
|
426
|
+
var CONTRIBUTION_TYPE_MAP = {
|
|
427
|
+
[PLUGIN_TYPES.SETUP]: "setup",
|
|
428
|
+
[PLUGIN_TYPES.CUI]: "cui",
|
|
429
|
+
[PLUGIN_TYPES.UTILITY]: "utility",
|
|
430
|
+
[PLUGIN_TYPES.SETTING]: "setting",
|
|
431
|
+
[PLUGIN_TYPES.NAV]: "nav",
|
|
432
|
+
[PLUGIN_TYPES.TROUBLE_ACTION]: "trouble-action",
|
|
433
|
+
[PLUGIN_TYPES.CONTROL_POUR]: "control-pour",
|
|
434
|
+
[PLUGIN_TYPES.CUSTOM]: "custom"
|
|
435
|
+
};
|
|
436
|
+
var LOCALIZED_PLUGIN_TYPES = /* @__PURE__ */ new Set([
|
|
437
|
+
PLUGIN_TYPES.CUI,
|
|
438
|
+
PLUGIN_TYPES.UTILITY,
|
|
439
|
+
PLUGIN_TYPES.SETUP,
|
|
440
|
+
PLUGIN_TYPES.SETTING,
|
|
441
|
+
PLUGIN_TYPES.NAV,
|
|
442
|
+
PLUGIN_TYPES.CONTROL_POUR,
|
|
443
|
+
PLUGIN_TYPES.TROUBLE_ACTION,
|
|
444
|
+
PLUGIN_TYPES.CUSTOM
|
|
445
|
+
]);
|
|
446
|
+
|
|
447
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/base.ts
|
|
448
|
+
var BasePluginHandler = class {
|
|
449
|
+
getContributionKey() {
|
|
450
|
+
return this.contributionKey;
|
|
451
|
+
}
|
|
452
|
+
requiresLocalization() {
|
|
453
|
+
return this.requiresI18n;
|
|
454
|
+
}
|
|
455
|
+
getTemplatePath() {
|
|
456
|
+
return this.contributionKey;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Helper to create experience configuration
|
|
460
|
+
*/
|
|
461
|
+
createExperience(options, experienceId) {
|
|
462
|
+
const compPath = this.getComponentPath(options);
|
|
463
|
+
return {
|
|
464
|
+
id: experienceId,
|
|
465
|
+
component: options.namePascalCase,
|
|
466
|
+
location: `./src/${compPath}`
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Helper to get component path
|
|
471
|
+
*/
|
|
472
|
+
getComponentPath(options) {
|
|
473
|
+
return `${options.appDirectory}/${this.contributionKey}/${options.nameDashCase}/${options.nameDashCase}.tsx`;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Helper to create config prefix
|
|
477
|
+
*/
|
|
478
|
+
getConfigPrefix(options) {
|
|
479
|
+
return `${options.appProject}.${options.nameCamelCase}`;
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/control-pour-handler.ts
|
|
484
|
+
var ControlPourPluginHandler = class extends BasePluginHandler {
|
|
485
|
+
pluginType = PLUGIN_TYPES.CONTROL_POUR;
|
|
486
|
+
contributionKey = "control-pour";
|
|
487
|
+
requiresI18n = true;
|
|
488
|
+
createConfiguration(options) {
|
|
489
|
+
const configPrefix = this.getConfigPrefix(options);
|
|
490
|
+
const experienceId = `${configPrefix}.controlPour.experience`;
|
|
491
|
+
const contribution = {
|
|
492
|
+
id: `${configPrefix}.controlPour`,
|
|
493
|
+
title: `${configPrefix}.controlPour.title`,
|
|
494
|
+
namespace: options.appProject,
|
|
495
|
+
experienceId
|
|
496
|
+
};
|
|
497
|
+
const experience = this.createExperience(options, experienceId);
|
|
498
|
+
return {
|
|
499
|
+
contributions: {
|
|
500
|
+
controlPour: [contribution]
|
|
501
|
+
},
|
|
502
|
+
experiences: {
|
|
503
|
+
[experienceId]: experience
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/cui-handler.ts
|
|
510
|
+
var CuiPluginHandler = class extends BasePluginHandler {
|
|
511
|
+
pluginType = PLUGIN_TYPES.CUI;
|
|
512
|
+
contributionKey = "cui";
|
|
513
|
+
requiresI18n = true;
|
|
514
|
+
createConfiguration(options) {
|
|
515
|
+
const configPrefix = this.getConfigPrefix(options);
|
|
516
|
+
const experienceId = `${configPrefix}.cui.experience`;
|
|
517
|
+
const contribution = {
|
|
518
|
+
id: configPrefix,
|
|
519
|
+
title: `${configPrefix}.cui.title`,
|
|
520
|
+
namespace: options.appProject,
|
|
521
|
+
experienceId
|
|
522
|
+
};
|
|
523
|
+
const experience = this.createExperience(options, experienceId);
|
|
524
|
+
return {
|
|
525
|
+
contributions: {
|
|
526
|
+
cui: [contribution]
|
|
527
|
+
},
|
|
528
|
+
experiences: {
|
|
529
|
+
[experienceId]: experience
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/custom-handler.ts
|
|
536
|
+
var CustomPluginHandler = class extends BasePluginHandler {
|
|
537
|
+
pluginType = PLUGIN_TYPES.CUSTOM;
|
|
538
|
+
contributionKey = "custom";
|
|
539
|
+
requiresI18n = true;
|
|
540
|
+
createConfiguration(options) {
|
|
541
|
+
const configPrefix = this.getConfigPrefix(options);
|
|
542
|
+
const experienceId = `${configPrefix}.${options.contributionKey || "custom"}.experience`;
|
|
543
|
+
const userContributionKey = options.contributionKey || "custom";
|
|
544
|
+
const contribution = {
|
|
545
|
+
id: configPrefix,
|
|
546
|
+
title: `${configPrefix}.${userContributionKey}.title`,
|
|
547
|
+
namespace: options.appProject,
|
|
548
|
+
experienceId
|
|
549
|
+
// TODO: Add additional fields as required by the plugin-explorer specification
|
|
550
|
+
// Refer to the plugin-explorer documentation for your specific contribution type
|
|
551
|
+
};
|
|
552
|
+
const experience = this.createExperience(options, experienceId);
|
|
553
|
+
return {
|
|
554
|
+
contributions: {
|
|
555
|
+
[userContributionKey]: [contribution]
|
|
556
|
+
},
|
|
557
|
+
experiences: {
|
|
558
|
+
[experienceId]: experience
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
getTemplatePath() {
|
|
563
|
+
return this.contributionKey || "custom";
|
|
564
|
+
}
|
|
565
|
+
getComponentPath(options) {
|
|
566
|
+
const pathKey = options.contributionKey || "custom";
|
|
567
|
+
return `${options.appDirectory}/${pathKey}/${options.nameDashCase}/${options.nameDashCase}.tsx`;
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/default-handler.ts
|
|
572
|
+
var DefaultComponentHandler = class extends BasePluginHandler {
|
|
573
|
+
pluginType = "component";
|
|
574
|
+
contributionKey = "components";
|
|
575
|
+
requiresI18n = false;
|
|
576
|
+
createConfiguration(options) {
|
|
577
|
+
const compPath = this.getComponentPath(options);
|
|
578
|
+
const viewConfig = {
|
|
579
|
+
id: `${options.appProject}.${options.nameCamelCase}`,
|
|
580
|
+
title: "ddk.ncui.config.title",
|
|
581
|
+
namespace: options.appProject,
|
|
582
|
+
component: options.namePascalCase,
|
|
583
|
+
location: `./src/${compPath}`
|
|
584
|
+
};
|
|
585
|
+
return {
|
|
586
|
+
contributions: {},
|
|
587
|
+
experiences: {},
|
|
588
|
+
views: {
|
|
589
|
+
[this.getTabViewKey()]: [viewConfig]
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
getTabViewKey() {
|
|
594
|
+
return "ddk.ncui.settings.tabView";
|
|
595
|
+
}
|
|
596
|
+
getTemplatePath() {
|
|
597
|
+
return "files";
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/nav-handler.ts
|
|
602
|
+
var NavPluginHandler = class extends BasePluginHandler {
|
|
603
|
+
pluginType = PLUGIN_TYPES.NAV;
|
|
604
|
+
contributionKey = "nav";
|
|
605
|
+
requiresI18n = true;
|
|
606
|
+
createConfiguration(options) {
|
|
607
|
+
const configPrefix = this.getConfigPrefix(options);
|
|
608
|
+
const experienceId = `${configPrefix}.nav.experience`;
|
|
609
|
+
const contribution = {
|
|
610
|
+
id: `${configPrefix}.nav`,
|
|
611
|
+
title: `${configPrefix}.nav.title`,
|
|
612
|
+
namespace: options.appProject,
|
|
613
|
+
navDescriptor: options.nameLowerCase,
|
|
614
|
+
experienceId
|
|
615
|
+
};
|
|
616
|
+
const experience = this.createExperience(options, experienceId);
|
|
617
|
+
return {
|
|
618
|
+
contributions: {
|
|
619
|
+
navViews: [contribution]
|
|
620
|
+
},
|
|
621
|
+
experiences: {
|
|
622
|
+
[experienceId]: experience
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/setting-handler.ts
|
|
629
|
+
var SettingPluginHandler = class extends BasePluginHandler {
|
|
630
|
+
pluginType = PLUGIN_TYPES.SETTING;
|
|
631
|
+
contributionKey = "setting";
|
|
632
|
+
requiresI18n = true;
|
|
633
|
+
createConfiguration(options) {
|
|
634
|
+
const configPrefix = this.getConfigPrefix(options);
|
|
635
|
+
const experienceId = `${configPrefix}.settings.experience`;
|
|
636
|
+
const contribution = {
|
|
637
|
+
id: `${configPrefix}.setting`,
|
|
638
|
+
title: `${configPrefix}.setting.title`,
|
|
639
|
+
namespace: options.appProject,
|
|
640
|
+
settingsGroup: options.group || "general",
|
|
641
|
+
experienceId
|
|
642
|
+
};
|
|
643
|
+
const experience = this.createExperience(options, experienceId);
|
|
644
|
+
return {
|
|
645
|
+
contributions: {
|
|
646
|
+
settings: [contribution]
|
|
647
|
+
},
|
|
648
|
+
experiences: {
|
|
649
|
+
[experienceId]: experience
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/setup-handler.ts
|
|
656
|
+
var SetupPluginHandler = class extends BasePluginHandler {
|
|
657
|
+
pluginType = PLUGIN_TYPES.SETUP;
|
|
658
|
+
contributionKey = "setup";
|
|
659
|
+
requiresI18n = true;
|
|
660
|
+
createConfiguration(options) {
|
|
661
|
+
const configPrefix = this.getConfigPrefix(options);
|
|
662
|
+
const experienceId = `${configPrefix}.setup.experience`;
|
|
663
|
+
const contribution = {
|
|
664
|
+
id: `${configPrefix}.setup`,
|
|
665
|
+
title: `${configPrefix}.setup.title`,
|
|
666
|
+
namespace: options.appProject,
|
|
667
|
+
setupDescriptor: options.nameCamelCase,
|
|
668
|
+
experienceId
|
|
669
|
+
};
|
|
670
|
+
const experience = this.createExperience(options, experienceId);
|
|
671
|
+
return {
|
|
672
|
+
contributions: {
|
|
673
|
+
setupStep: [contribution]
|
|
674
|
+
},
|
|
675
|
+
experiences: {
|
|
676
|
+
[experienceId]: experience
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/trouble-action-handler.ts
|
|
683
|
+
var TroubleActionPluginHandler = class extends BasePluginHandler {
|
|
684
|
+
pluginType = PLUGIN_TYPES.TROUBLE_ACTION;
|
|
685
|
+
contributionKey = "trouble-action";
|
|
686
|
+
requiresI18n = true;
|
|
687
|
+
createConfiguration(options) {
|
|
688
|
+
const configPrefix = this.getConfigPrefix(options);
|
|
689
|
+
const experienceId = `${configPrefix}.troubleAction.experience`;
|
|
690
|
+
const contribution = {
|
|
691
|
+
id: `${configPrefix}.troubleAction`,
|
|
692
|
+
title: `${configPrefix}.troubleAction.title`,
|
|
693
|
+
namespace: options.appProject,
|
|
694
|
+
troubleType: options.nameCamelCase,
|
|
695
|
+
experienceId
|
|
696
|
+
};
|
|
697
|
+
const experience = this.createExperience(options, experienceId);
|
|
698
|
+
return {
|
|
699
|
+
contributions: {
|
|
700
|
+
troubleActions: [contribution]
|
|
701
|
+
},
|
|
702
|
+
experiences: {
|
|
703
|
+
[experienceId]: experience
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/utility-handler.ts
|
|
710
|
+
var UtilityPluginHandler = class extends BasePluginHandler {
|
|
711
|
+
pluginType = PLUGIN_TYPES.UTILITY;
|
|
712
|
+
contributionKey = "utility";
|
|
713
|
+
requiresI18n = true;
|
|
714
|
+
createConfiguration(options) {
|
|
715
|
+
const configPrefix = this.getConfigPrefix(options);
|
|
716
|
+
const experienceId = `${configPrefix}.util.experience`;
|
|
717
|
+
const contribution = {
|
|
718
|
+
id: `${configPrefix}.util`,
|
|
719
|
+
title: `${configPrefix}.utility.title`,
|
|
720
|
+
namespace: options.appProject,
|
|
721
|
+
utilDescriptor: options.nameCamelCase,
|
|
722
|
+
experienceId
|
|
723
|
+
};
|
|
724
|
+
const experience = this.createExperience(options, experienceId);
|
|
725
|
+
return {
|
|
726
|
+
contributions: {
|
|
727
|
+
utilities: [contribution]
|
|
728
|
+
},
|
|
729
|
+
experiences: {
|
|
730
|
+
[experienceId]: experience
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
// ../kos-codegen-core/src/lib/generators/component/plugin-handlers/factory.ts
|
|
737
|
+
var PluginHandlerFactory = class {
|
|
738
|
+
static handlers = /* @__PURE__ */ new Map([
|
|
739
|
+
[PLUGIN_TYPES.CUI, CuiPluginHandler],
|
|
740
|
+
[PLUGIN_TYPES.UTILITY, UtilityPluginHandler],
|
|
741
|
+
[PLUGIN_TYPES.SETTING, SettingPluginHandler],
|
|
742
|
+
[PLUGIN_TYPES.SETUP, SetupPluginHandler],
|
|
743
|
+
[PLUGIN_TYPES.NAV, NavPluginHandler],
|
|
744
|
+
[PLUGIN_TYPES.CONTROL_POUR, ControlPourPluginHandler],
|
|
745
|
+
[PLUGIN_TYPES.TROUBLE_ACTION, TroubleActionPluginHandler],
|
|
746
|
+
[PLUGIN_TYPES.CUSTOM, CustomPluginHandler]
|
|
747
|
+
]);
|
|
748
|
+
static createHandler(pluginType) {
|
|
749
|
+
if (!pluginType) {
|
|
750
|
+
return new DefaultComponentHandler();
|
|
751
|
+
}
|
|
752
|
+
const HandlerClass = this.handlers.get(pluginType);
|
|
753
|
+
if (!HandlerClass) {
|
|
754
|
+
console.warn(
|
|
755
|
+
`No handler found for plugin type: ${pluginType}. Using default handler.`
|
|
756
|
+
);
|
|
757
|
+
return new DefaultComponentHandler();
|
|
758
|
+
}
|
|
759
|
+
return new HandlerClass();
|
|
760
|
+
}
|
|
761
|
+
static isValidPluginType(type) {
|
|
762
|
+
return this.handlers.has(type);
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
// ../kos-codegen-core/src/lib/generators/component/utils/file-generator.ts
|
|
767
|
+
import * as path8 from "path";
|
|
768
|
+
function generateComponentFiles(codegenFs, templateBaseDir, templateSubPath, targetPath, options) {
|
|
769
|
+
generateFilesFromTemplates(
|
|
770
|
+
codegenFs,
|
|
771
|
+
path8.join(templateBaseDir, templateSubPath),
|
|
772
|
+
targetPath,
|
|
773
|
+
options
|
|
774
|
+
);
|
|
775
|
+
if (options.useEmotionCss) {
|
|
776
|
+
deleteCssFile(codegenFs, targetPath, options);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
function deleteCssFile(codegenFs, targetPath, options) {
|
|
780
|
+
const cssPath = path8.join(targetPath, `${options.nameDashCase}.css`);
|
|
781
|
+
if (codegenFs.exists(cssPath)) {
|
|
782
|
+
codegenFs.delete(cssPath);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
// ../kos-codegen-core/src/lib/generators/component/utils/kos-config-builder.ts
|
|
787
|
+
var KosConfigBuilder = class _KosConfigBuilder {
|
|
788
|
+
contributions = {};
|
|
789
|
+
experiences = {};
|
|
790
|
+
views = {};
|
|
791
|
+
/**
|
|
792
|
+
* Adds plugin configuration to the builder
|
|
793
|
+
*/
|
|
794
|
+
addPluginConfiguration(config) {
|
|
795
|
+
Object.entries(config.contributions).forEach(([key, value]) => {
|
|
796
|
+
this.contributions[key] = [...this.contributions[key] || [], ...value];
|
|
797
|
+
});
|
|
798
|
+
Object.assign(this.experiences, config.experiences);
|
|
799
|
+
if (config.views) {
|
|
800
|
+
Object.entries(config.views).forEach(([key, value]) => {
|
|
801
|
+
this.views[key] = [...this.views[key] || [], ...value];
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
return this;
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Applies the built configuration to the .kos.json file
|
|
808
|
+
*/
|
|
809
|
+
applyToFile(codegenFs, kosConfigPath) {
|
|
810
|
+
updateJson(codegenFs, kosConfigPath, (json) => {
|
|
811
|
+
const structure = this.initializeStructure(json);
|
|
812
|
+
Object.entries(this.contributions).forEach(([key, value]) => {
|
|
813
|
+
structure.contributes[key] = [
|
|
814
|
+
...structure.contributes[key] || [],
|
|
815
|
+
...value
|
|
816
|
+
];
|
|
817
|
+
});
|
|
818
|
+
structure.contributes.experiences = {
|
|
819
|
+
...structure.contributes.experiences,
|
|
820
|
+
...this.experiences
|
|
821
|
+
};
|
|
822
|
+
if (Object.keys(this.views).length > 0) {
|
|
823
|
+
structure.contributes.views = structure.contributes.views || {};
|
|
824
|
+
Object.entries(this.views).forEach(([key, value]) => {
|
|
825
|
+
structure.contributes.views[key] = [
|
|
826
|
+
...structure.contributes.views[key] || [],
|
|
827
|
+
...value
|
|
828
|
+
];
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
return json;
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Initializes the deep JSON structure
|
|
836
|
+
*/
|
|
837
|
+
initializeStructure(json) {
|
|
838
|
+
json.kos ??= {};
|
|
839
|
+
json.kos.ui ??= {};
|
|
840
|
+
json.kos.ui.plugin ??= {};
|
|
841
|
+
json.kos.ui.plugin.contributes ??= {};
|
|
842
|
+
return json.kos.ui.plugin;
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Creates a new builder instance
|
|
846
|
+
*/
|
|
847
|
+
static create() {
|
|
848
|
+
return new _KosConfigBuilder();
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
// ../kos-codegen-core/src/lib/generators/component/utils/localization.ts
|
|
853
|
+
import * as path9 from "path";
|
|
854
|
+
function updateLocalization(codegenFs, projectRoot, options, pluginType) {
|
|
855
|
+
const localePath = path9.join(
|
|
856
|
+
projectRoot,
|
|
857
|
+
"assets",
|
|
858
|
+
"locales",
|
|
859
|
+
"en",
|
|
860
|
+
`${options.appProject}.json`
|
|
861
|
+
);
|
|
862
|
+
if (!codegenFs.exists(localePath)) {
|
|
863
|
+
console.warn(`Locale file not found: ${localePath}`);
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
updateJson(codegenFs, localePath, (json) => {
|
|
867
|
+
json[options.appProject] = json[options.appProject] || {};
|
|
868
|
+
json[options.appProject][options.nameCamelCase] = json[options.appProject][options.nameCamelCase] || {};
|
|
869
|
+
json[options.appProject][options.nameCamelCase][pluginType] = {
|
|
870
|
+
...json[options.appProject][options.nameCamelCase][pluginType],
|
|
871
|
+
title: options.nameCamelCase
|
|
872
|
+
};
|
|
873
|
+
return json;
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
// ../kos-codegen-core/src/lib/generators/component/utils/validation.ts
|
|
878
|
+
var ValidationError = class extends Error {
|
|
879
|
+
constructor(message) {
|
|
880
|
+
super(message);
|
|
881
|
+
this.name = "ValidationError";
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
function validateOptions(codegenFs, options, projects) {
|
|
885
|
+
if (!options.name) {
|
|
886
|
+
throw new ValidationError("Component name is required");
|
|
887
|
+
}
|
|
888
|
+
if (!options.appProject) {
|
|
889
|
+
throw new ValidationError("App project is required");
|
|
890
|
+
}
|
|
891
|
+
const project = findProjectByName(codegenFs.root, options.appProject, projects);
|
|
892
|
+
if (!project) {
|
|
893
|
+
throw new ValidationError(
|
|
894
|
+
`Project "${options.appProject}" not found in workspace`
|
|
895
|
+
);
|
|
896
|
+
}
|
|
897
|
+
if (options.pluginType && !PluginHandlerFactory.isValidPluginType(options.pluginType)) {
|
|
898
|
+
console.warn(
|
|
899
|
+
`Unknown plugin type "${options.pluginType}". Component will be generated with default configuration.`
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
if (options.pluginType === "setting" && !options.group) {
|
|
903
|
+
throw new ValidationError(
|
|
904
|
+
"Settings group is required for setting plugin type"
|
|
905
|
+
);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
// ../kos-codegen-core/src/lib/generators/component/generate-component.ts
|
|
910
|
+
function generateComponent(codegenFs, templateDir, options, projects) {
|
|
911
|
+
validateOptions(codegenFs, options, projects);
|
|
912
|
+
const normalized = prepareOptions(codegenFs, options, projects);
|
|
913
|
+
const projectConfig = findProjectByName(
|
|
914
|
+
codegenFs.root,
|
|
915
|
+
normalized.appProject,
|
|
916
|
+
projects
|
|
917
|
+
);
|
|
918
|
+
if (!projectConfig) {
|
|
919
|
+
throw new Error(
|
|
920
|
+
`Project "${normalized.appProject}" not found in workspace`
|
|
921
|
+
);
|
|
922
|
+
}
|
|
923
|
+
const projectRoot = projectConfig.sourceRoot;
|
|
924
|
+
if (!projectRoot) {
|
|
925
|
+
throw new Error(
|
|
926
|
+
`No source root found for project ${normalized.appProject}`
|
|
927
|
+
);
|
|
928
|
+
}
|
|
929
|
+
generateFiles(codegenFs, templateDir, projectRoot, normalized);
|
|
930
|
+
if (options.pluginType) {
|
|
931
|
+
updatePluginConfiguration(codegenFs, projectConfig, normalized);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
function prepareOptions(codegenFs, options, projects) {
|
|
935
|
+
const normalized = normalizeOptions(
|
|
936
|
+
codegenFs,
|
|
937
|
+
{
|
|
938
|
+
...options,
|
|
939
|
+
modelProject: "__NONE__"
|
|
940
|
+
},
|
|
941
|
+
projects
|
|
942
|
+
);
|
|
943
|
+
const kosConfig = getKosProjectConfiguration(
|
|
944
|
+
codegenFs,
|
|
945
|
+
options.appProject,
|
|
946
|
+
projects
|
|
947
|
+
);
|
|
948
|
+
const componentLocation = kosConfig?.generator?.defaults?.component?.folder || "";
|
|
949
|
+
normalized.appDirectory = options.appDirectory || componentLocation;
|
|
950
|
+
normalized.type = CONTRIBUTION_TYPE_MAP[options.pluginType || ""] || options.type;
|
|
951
|
+
if (options.contributionKey) {
|
|
952
|
+
normalized.contributionKey = options.contributionKey;
|
|
953
|
+
}
|
|
954
|
+
return normalized;
|
|
955
|
+
}
|
|
956
|
+
function generateFiles(codegenFs, templateDir, projectRoot, options) {
|
|
957
|
+
const handler = PluginHandlerFactory.createHandler(options.pluginType);
|
|
958
|
+
const templatePath = handler.getTemplatePath();
|
|
959
|
+
const targetPath = path10.join(
|
|
960
|
+
projectRoot,
|
|
961
|
+
options.appDirectory,
|
|
962
|
+
options.type,
|
|
963
|
+
options.nameDashCase
|
|
964
|
+
);
|
|
965
|
+
generateComponentFiles(
|
|
966
|
+
codegenFs,
|
|
967
|
+
templateDir,
|
|
968
|
+
templatePath,
|
|
969
|
+
targetPath,
|
|
970
|
+
options
|
|
971
|
+
);
|
|
972
|
+
}
|
|
973
|
+
function updatePluginConfiguration(codegenFs, projectConfig, options) {
|
|
974
|
+
const kosConfigPath = path10.join(projectConfig.root, ".kos.json");
|
|
975
|
+
if (!codegenFs.exists(kosConfigPath)) {
|
|
976
|
+
console.warn(`No .kos.json found at ${kosConfigPath}`);
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
const handler = PluginHandlerFactory.createHandler(options.pluginType);
|
|
980
|
+
const pluginConfig = handler.createConfiguration(options);
|
|
981
|
+
const builder = KosConfigBuilder.create();
|
|
982
|
+
builder.addPluginConfiguration(pluginConfig);
|
|
983
|
+
builder.applyToFile(codegenFs, kosConfigPath);
|
|
984
|
+
if (handler.requiresLocalization() && projectConfig.sourceRoot) {
|
|
985
|
+
updateLocalization(
|
|
986
|
+
codegenFs,
|
|
987
|
+
projectConfig.sourceRoot,
|
|
988
|
+
options,
|
|
989
|
+
handler.getContributionKey()
|
|
990
|
+
);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
// src/lib/utils/nx-context.mjs
|
|
995
|
+
import { existsSync as existsSync4, readFileSync as readFileSync6, readdirSync as readdirSync3, statSync } from "fs";
|
|
996
|
+
import path12 from "path";
|
|
997
|
+
import { fileURLToPath } from "url";
|
|
998
|
+
|
|
999
|
+
// src/lib/utils/cache.mjs
|
|
1000
|
+
import fs6 from "fs";
|
|
1001
|
+
import path11 from "path";
|
|
1002
|
+
var CACHE_PATH = path11.resolve(".nx/cli-cache.json");
|
|
1003
|
+
var CACHE_TTL = 600 * 1e3;
|
|
1004
|
+
var ARGS = process.argv;
|
|
1005
|
+
var DISABLE_CACHE = process.env.DISABLE_CACHE === "true" || process.env.REFRESH === "true";
|
|
1006
|
+
var _cache = {};
|
|
1007
|
+
var _loaded = false;
|
|
1008
|
+
function ensureCacheDir() {
|
|
1009
|
+
const dir = path11.dirname(CACHE_PATH);
|
|
1010
|
+
if (!fs6.existsSync(dir))
|
|
1011
|
+
fs6.mkdirSync(dir, { recursive: true });
|
|
1012
|
+
}
|
|
1013
|
+
function loadCacheFromDisk() {
|
|
1014
|
+
if (_loaded)
|
|
1015
|
+
return;
|
|
1016
|
+
_loaded = true;
|
|
1017
|
+
try {
|
|
1018
|
+
if (fs6.existsSync(CACHE_PATH)) {
|
|
1019
|
+
const data = fs6.readFileSync(CACHE_PATH, "utf-8");
|
|
1020
|
+
_cache = JSON.parse(data);
|
|
1021
|
+
}
|
|
1022
|
+
} catch (err) {
|
|
1023
|
+
console.warn("Failed to load CLI cache:", err);
|
|
1024
|
+
_cache = {};
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
function saveCacheToDisk() {
|
|
1028
|
+
try {
|
|
1029
|
+
ensureCacheDir();
|
|
1030
|
+
fs6.writeFileSync(CACHE_PATH, JSON.stringify(_cache, null, 2));
|
|
1031
|
+
} catch (err) {
|
|
1032
|
+
console.warn("Failed to save CLI cache:", err);
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
function isFresh(entry, ttl = CACHE_TTL) {
|
|
1036
|
+
if (!entry || !entry.timestamp)
|
|
1037
|
+
return false;
|
|
1038
|
+
return Date.now() - entry.timestamp < ttl;
|
|
1039
|
+
}
|
|
1040
|
+
function getCached(key, ttl = CACHE_TTL) {
|
|
1041
|
+
if (DISABLE_CACHE)
|
|
1042
|
+
return null;
|
|
1043
|
+
loadCacheFromDisk();
|
|
1044
|
+
const entry = _cache[key];
|
|
1045
|
+
if (isFresh(entry, ttl))
|
|
1046
|
+
return entry.data;
|
|
1047
|
+
return null;
|
|
1048
|
+
}
|
|
1049
|
+
function setCached(key, data) {
|
|
1050
|
+
loadCacheFromDisk();
|
|
1051
|
+
_cache[key] = {
|
|
1052
|
+
data,
|
|
1053
|
+
timestamp: Date.now()
|
|
1054
|
+
};
|
|
1055
|
+
saveCacheToDisk();
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// src/lib/utils/nx-context.mjs
|
|
1059
|
+
var __dirname2 = path12.dirname(fileURLToPath(import.meta.url));
|
|
1060
|
+
function findKosJsonFiles(dir = process.cwd(), files = []) {
|
|
1061
|
+
try {
|
|
1062
|
+
const entries = readdirSync3(dir);
|
|
1063
|
+
for (const entry of entries) {
|
|
1064
|
+
if (entry === "node_modules" || entry === ".git" || entry === ".nx" || entry === "dist" || entry === "coverage" || entry === ".vscode" || entry === ".idea" || entry.startsWith(".") && entry !== ".kos.json") {
|
|
1065
|
+
continue;
|
|
1066
|
+
}
|
|
1067
|
+
const fullPath = path12.join(dir, entry);
|
|
1068
|
+
try {
|
|
1069
|
+
const stat = statSync(fullPath);
|
|
1070
|
+
if (stat.isFile() && entry === ".kos.json") {
|
|
1071
|
+
files.push(fullPath);
|
|
1072
|
+
} else if (stat.isDirectory()) {
|
|
1073
|
+
if (entry !== "tmp" && entry !== "temp" && entry !== "build") {
|
|
1074
|
+
findKosJsonFiles(fullPath, files);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
} catch (error) {
|
|
1078
|
+
continue;
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
} catch (error) {
|
|
1082
|
+
}
|
|
1083
|
+
return files;
|
|
1084
|
+
}
|
|
1085
|
+
async function getAllProjects() {
|
|
1086
|
+
const cached = getCached("allProjects");
|
|
1087
|
+
if (cached)
|
|
1088
|
+
return cached;
|
|
1089
|
+
const projectMap = discoverProjects(process.cwd());
|
|
1090
|
+
const projects = Array.from(projectMap.keys());
|
|
1091
|
+
setCached("allProjects", projects);
|
|
1092
|
+
return projects;
|
|
1093
|
+
}
|
|
1094
|
+
async function getPluginProjects() {
|
|
1095
|
+
const cached = getCached("pluginProjects");
|
|
1096
|
+
if (cached)
|
|
1097
|
+
return cached;
|
|
1098
|
+
const all = await getAllProjects();
|
|
1099
|
+
const filtered = all.filter(
|
|
1100
|
+
(p) => p.includes("plugin") || p.includes("extension")
|
|
1101
|
+
);
|
|
1102
|
+
setCached("pluginProjects", filtered);
|
|
1103
|
+
return filtered;
|
|
1104
|
+
}
|
|
1105
|
+
async function getAllKosProjects() {
|
|
1106
|
+
const cached = getCached("allKosProjects");
|
|
1107
|
+
if (cached)
|
|
1108
|
+
return cached;
|
|
1109
|
+
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
1110
|
+
console.warn(`[kos-cli] Discovering KOS projects by scanning .kos.json files...`);
|
|
1111
|
+
}
|
|
1112
|
+
const projectDirs = ["apps", "libs", "packages"];
|
|
1113
|
+
const kosJsonFiles = [];
|
|
1114
|
+
const workspaceRoot = process.cwd();
|
|
1115
|
+
for (const dir of projectDirs) {
|
|
1116
|
+
const dirPath = path12.join(workspaceRoot, dir);
|
|
1117
|
+
if (existsSync4(dirPath)) {
|
|
1118
|
+
findKosJsonFiles(dirPath, kosJsonFiles);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
const rootKosJson = path12.join(workspaceRoot, ".kos.json");
|
|
1122
|
+
if (existsSync4(rootKosJson)) {
|
|
1123
|
+
kosJsonFiles.push(rootKosJson);
|
|
1124
|
+
}
|
|
1125
|
+
if (kosJsonFiles.length === 0) {
|
|
1126
|
+
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
1127
|
+
console.warn(`[kos-cli] No .kos.json files found in common directories, performing full workspace scan...`);
|
|
1128
|
+
}
|
|
1129
|
+
findKosJsonFiles(workspaceRoot, kosJsonFiles);
|
|
1130
|
+
}
|
|
1131
|
+
const kosProjects = [];
|
|
1132
|
+
for (const kosJsonPath of kosJsonFiles) {
|
|
1133
|
+
try {
|
|
1134
|
+
const kosConfig = JSON.parse(readFileSync6(kosJsonPath, "utf-8"));
|
|
1135
|
+
const projectDir = path12.dirname(kosJsonPath);
|
|
1136
|
+
let projectName = null;
|
|
1137
|
+
const projectJsonPath = path12.join(projectDir, "project.json");
|
|
1138
|
+
if (existsSync4(projectJsonPath)) {
|
|
1139
|
+
try {
|
|
1140
|
+
const projectJson = JSON.parse(readFileSync6(projectJsonPath, "utf-8"));
|
|
1141
|
+
projectName = projectJson.name;
|
|
1142
|
+
} catch (error) {
|
|
1143
|
+
projectName = path12.basename(projectDir);
|
|
1144
|
+
}
|
|
1145
|
+
} else {
|
|
1146
|
+
projectName = path12.basename(projectDir);
|
|
1147
|
+
}
|
|
1148
|
+
if (kosConfig.type === "root") {
|
|
1149
|
+
continue;
|
|
1150
|
+
}
|
|
1151
|
+
kosProjects.push({
|
|
1152
|
+
name: projectName,
|
|
1153
|
+
path: projectDir,
|
|
1154
|
+
kosJsonPath,
|
|
1155
|
+
config: kosConfig,
|
|
1156
|
+
projectType: kosConfig.generator?.projectType
|
|
1157
|
+
});
|
|
1158
|
+
} catch (error) {
|
|
1159
|
+
console.warn(`[kos-cli] Error reading ${kosJsonPath}: ${error.message}`);
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
setCached("allKosProjects", kosProjects);
|
|
1163
|
+
return kosProjects;
|
|
1164
|
+
}
|
|
1165
|
+
async function getProjectsByType(targetType) {
|
|
1166
|
+
const cacheKey = `projectsByType:${targetType}`;
|
|
1167
|
+
const cached = getCached(cacheKey);
|
|
1168
|
+
if (cached)
|
|
1169
|
+
return cached;
|
|
1170
|
+
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
1171
|
+
console.warn(`[kos-cli] Filtering projects for ${targetType} projectType...`);
|
|
1172
|
+
}
|
|
1173
|
+
const allKosProjects = await getAllKosProjects();
|
|
1174
|
+
const filteredProjects = [];
|
|
1175
|
+
for (const kosProject of allKosProjects) {
|
|
1176
|
+
const projectType = kosProject.projectType;
|
|
1177
|
+
const hasTargetType = Array.isArray(projectType) ? projectType.includes(targetType) : projectType === targetType;
|
|
1178
|
+
if (hasTargetType) {
|
|
1179
|
+
filteredProjects.push(kosProject.name);
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
setCached(cacheKey, filteredProjects);
|
|
1183
|
+
return filteredProjects;
|
|
1184
|
+
}
|
|
1185
|
+
async function getPluginProjectsWithFallback() {
|
|
1186
|
+
const pluginProjectsByType = await getProjectsByType("plugin");
|
|
1187
|
+
if (pluginProjectsByType.length > 0) {
|
|
1188
|
+
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
1189
|
+
console.warn(`[kos-cli] Found ${pluginProjectsByType.length} plugin projects by type`);
|
|
1190
|
+
}
|
|
1191
|
+
return pluginProjectsByType;
|
|
1192
|
+
}
|
|
1193
|
+
const pluginProjectsByName = await getPluginProjects();
|
|
1194
|
+
if (pluginProjectsByName.length > 0) {
|
|
1195
|
+
if (process.env.KOS_CLI_QUIET !== "true") {
|
|
1196
|
+
console.warn(`[kos-cli] Found ${pluginProjectsByName.length} plugin projects by name`);
|
|
1197
|
+
}
|
|
1198
|
+
return pluginProjectsByName;
|
|
1199
|
+
}
|
|
1200
|
+
console.warn(`[kos-cli] No plugin projects found, showing all projects`);
|
|
1201
|
+
return await getAllProjects();
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
// src/lib/utils/validators.mjs
|
|
1205
|
+
function required(value) {
|
|
1206
|
+
return value && value.trim() !== "" ? true : "This field is required.";
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
// src/lib/generators/plugin/index.mjs
|
|
1210
|
+
var metadata = [
|
|
1211
|
+
{
|
|
1212
|
+
key: "pluginComponent",
|
|
9
1213
|
name: "KOS UI Plugin Component",
|
|
10
1214
|
namedArguments: {
|
|
11
1215
|
name: "componentName",
|
|
@@ -15,8 +1219,8 @@ export const metadata = [
|
|
|
15
1219
|
extensionPoint: "extensionPoint"
|
|
16
1220
|
}
|
|
17
1221
|
},
|
|
18
|
-
{
|
|
19
|
-
key: "plugin:cui",
|
|
1222
|
+
{
|
|
1223
|
+
key: "plugin:cui",
|
|
20
1224
|
name: "KOS UI Plugin CUI Configuration",
|
|
21
1225
|
namedArguments: {
|
|
22
1226
|
name: "componentName",
|
|
@@ -25,8 +1229,8 @@ export const metadata = [
|
|
|
25
1229
|
componentProject: "componentProject"
|
|
26
1230
|
}
|
|
27
1231
|
},
|
|
28
|
-
{
|
|
29
|
-
key: "plugin:setup",
|
|
1232
|
+
{
|
|
1233
|
+
key: "plugin:setup",
|
|
30
1234
|
name: "KOS UI Plugin Setup Step",
|
|
31
1235
|
namedArguments: {
|
|
32
1236
|
name: "componentName",
|
|
@@ -35,8 +1239,8 @@ export const metadata = [
|
|
|
35
1239
|
componentProject: "componentProject"
|
|
36
1240
|
}
|
|
37
1241
|
},
|
|
38
|
-
{
|
|
39
|
-
key: "plugin:utility",
|
|
1242
|
+
{
|
|
1243
|
+
key: "plugin:utility",
|
|
40
1244
|
name: "KOS UI Plugin Utility",
|
|
41
1245
|
namedArguments: {
|
|
42
1246
|
name: "componentName",
|
|
@@ -45,8 +1249,8 @@ export const metadata = [
|
|
|
45
1249
|
componentProject: "componentProject"
|
|
46
1250
|
}
|
|
47
1251
|
},
|
|
48
|
-
{
|
|
49
|
-
key: "plugin:setting",
|
|
1252
|
+
{
|
|
1253
|
+
key: "plugin:setting",
|
|
50
1254
|
name: "KOS UI Plugin Setting",
|
|
51
1255
|
namedArguments: {
|
|
52
1256
|
name: "componentName",
|
|
@@ -56,8 +1260,8 @@ export const metadata = [
|
|
|
56
1260
|
group: "group"
|
|
57
1261
|
}
|
|
58
1262
|
},
|
|
59
|
-
{
|
|
60
|
-
key: "plugin:nav",
|
|
1263
|
+
{
|
|
1264
|
+
key: "plugin:nav",
|
|
61
1265
|
name: "KOS UI Plugin Navigation View",
|
|
62
1266
|
namedArguments: {
|
|
63
1267
|
name: "componentName",
|
|
@@ -86,28 +1290,31 @@ export const metadata = [
|
|
|
86
1290
|
componentProject: "componentProject",
|
|
87
1291
|
contributionKey: "contributionKey"
|
|
88
1292
|
}
|
|
89
|
-
}
|
|
1293
|
+
}
|
|
90
1294
|
];
|
|
91
|
-
|
|
92
|
-
export default async function (plop) {
|
|
1295
|
+
async function plugin_default(plop) {
|
|
93
1296
|
const pluginProjects = await getPluginProjectsWithFallback();
|
|
94
|
-
|
|
95
|
-
|
|
1297
|
+
plop.setActionType("createPluginComponent", async function(answers) {
|
|
1298
|
+
const cwd = process.cwd();
|
|
1299
|
+
const codegenFs = new TrackingFileSystem(new DirectFileSystem(cwd));
|
|
96
1300
|
const pluginType = answers.extensionPoint;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
1301
|
+
const options = {
|
|
1302
|
+
name: answers.componentName,
|
|
1303
|
+
appProject: answers.componentProject,
|
|
1304
|
+
type: "components",
|
|
1305
|
+
pluginType,
|
|
1306
|
+
useEmotionCss: false,
|
|
1307
|
+
appDirectory: "",
|
|
1308
|
+
modelDirectory: ""
|
|
1309
|
+
};
|
|
1310
|
+
if (answers.group) {
|
|
1311
|
+
options.group = answers.group;
|
|
103
1312
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
await execute(command);
|
|
107
|
-
} catch (error) {
|
|
108
|
-
throw new Error(error);
|
|
1313
|
+
if (pluginType === "custom" && answers.contributionKey) {
|
|
1314
|
+
options.contributionKey = answers.contributionKey;
|
|
109
1315
|
}
|
|
110
|
-
|
|
1316
|
+
generateComponent(codegenFs, getTemplateDir("kos-component"), options);
|
|
1317
|
+
await formatFiles(codegenFs.root, codegenFs.writtenPaths);
|
|
111
1318
|
return `Component ${answers.componentName} created in ${answers.componentProject}`;
|
|
112
1319
|
});
|
|
113
1320
|
const pluginPrompts = [
|
|
@@ -115,16 +1322,15 @@ export default async function (plop) {
|
|
|
115
1322
|
type: "input",
|
|
116
1323
|
name: "componentName",
|
|
117
1324
|
message: "Enter the name of the component",
|
|
118
|
-
validate: required
|
|
1325
|
+
validate: required
|
|
119
1326
|
},
|
|
120
1327
|
{
|
|
121
1328
|
type: "list",
|
|
122
1329
|
name: "componentProject",
|
|
123
1330
|
message: "Which project should the component be created in?",
|
|
124
|
-
choices: pluginProjects
|
|
125
|
-
}
|
|
1331
|
+
choices: pluginProjects
|
|
1332
|
+
}
|
|
126
1333
|
];
|
|
127
|
-
|
|
128
1334
|
const pluginTypes = [
|
|
129
1335
|
{ key: "plugin:cui", name: "cui" },
|
|
130
1336
|
{ key: "plugin:setup", name: "setup" },
|
|
@@ -132,10 +1338,8 @@ export default async function (plop) {
|
|
|
132
1338
|
{ key: "plugin:setting", name: "setting" },
|
|
133
1339
|
{ key: "plugin:nav", name: "nav" },
|
|
134
1340
|
{ key: "plugin:cp", name: "controlPour" },
|
|
135
|
-
{ key: "plugin:custom", name: "custom" }
|
|
1341
|
+
{ key: "plugin:custom", name: "custom" }
|
|
136
1342
|
];
|
|
137
|
-
|
|
138
|
-
// Generic plugin component
|
|
139
1343
|
plop.setGenerator("pluginComponent", {
|
|
140
1344
|
description: "Create a new KOS Plugin Component",
|
|
141
1345
|
prompts: [
|
|
@@ -144,52 +1348,49 @@ export default async function (plop) {
|
|
|
144
1348
|
type: "list",
|
|
145
1349
|
name: "extensionPoint",
|
|
146
1350
|
message: "What type of extension point is the plugin supporting?",
|
|
147
|
-
choices: pluginTypes.map((pt) => pt.name)
|
|
148
|
-
}
|
|
1351
|
+
choices: pluginTypes.map((pt) => pt.name)
|
|
1352
|
+
}
|
|
149
1353
|
],
|
|
150
|
-
actions: [{ type: "createPluginComponent" }]
|
|
1354
|
+
actions: [{ type: "createPluginComponent" }]
|
|
151
1355
|
});
|
|
152
|
-
|
|
153
|
-
// Specific plugin type aliases
|
|
154
1356
|
for (const { key, name } of pluginTypes) {
|
|
155
1357
|
const prompts = [
|
|
156
1358
|
...pluginPrompts,
|
|
157
|
-
...
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
validate: required,
|
|
173
|
-
},
|
|
174
|
-
]
|
|
175
|
-
: []),
|
|
1359
|
+
...name === "setting" ? [
|
|
1360
|
+
{
|
|
1361
|
+
type: "input",
|
|
1362
|
+
name: "group",
|
|
1363
|
+
message: "Which settings group should the setting be located?"
|
|
1364
|
+
}
|
|
1365
|
+
] : [],
|
|
1366
|
+
...name === "custom" ? [
|
|
1367
|
+
{
|
|
1368
|
+
type: "input",
|
|
1369
|
+
name: "contributionKey",
|
|
1370
|
+
message: "What contribution key should be used in .kos.json? (e.g., 'menus', 'panels', 'commands', etc.)",
|
|
1371
|
+
validate: required
|
|
1372
|
+
}
|
|
1373
|
+
] : [],
|
|
176
1374
|
{
|
|
177
1375
|
type: "input",
|
|
178
1376
|
name: "extensionPoint",
|
|
179
1377
|
message: "Hidden extensionPoint",
|
|
180
1378
|
default: name,
|
|
181
|
-
when: false
|
|
182
|
-
|
|
1379
|
+
when: false
|
|
1380
|
+
// hide from CLI
|
|
1381
|
+
}
|
|
183
1382
|
];
|
|
184
|
-
|
|
185
1383
|
plop.setGenerator(key, {
|
|
186
|
-
description: `Create a new KOS ${
|
|
187
|
-
name[0].toUpperCase() + name.slice(1)
|
|
188
|
-
} Plugin Component`,
|
|
1384
|
+
description: `Create a new KOS ${name[0].toUpperCase() + name.slice(1)} Plugin Component`,
|
|
189
1385
|
prompts,
|
|
190
1386
|
actions: [
|
|
191
|
-
{ type: "createPluginComponent", data: { extensionPoint: name } }
|
|
192
|
-
]
|
|
1387
|
+
{ type: "createPluginComponent", data: { extensionPoint: name } }
|
|
1388
|
+
]
|
|
193
1389
|
});
|
|
194
1390
|
}
|
|
195
1391
|
}
|
|
1392
|
+
export {
|
|
1393
|
+
plugin_default as default,
|
|
1394
|
+
metadata
|
|
1395
|
+
};
|
|
1396
|
+
//# sourceMappingURL=index.mjs.map
|