@kosdev-code/kos-ui-cli 0.1.0-dev.5053
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/package.json +30 -0
- package/src/index.d.ts +2 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +1 -0
- package/src/index.js.map +1 -0
- package/src/lib/cli.mjs +803 -0
- package/src/lib/generators/cache/index.mjs +18 -0
- package/src/lib/generators/component/index.mjs +55 -0
- package/src/lib/generators/env/index.mjs +42 -0
- package/src/lib/generators/i18n/namespace.mjs +61 -0
- package/src/lib/generators/kab/index.mjs +82 -0
- package/src/lib/generators/metadata.json +341 -0
- package/src/lib/generators/model/add-future.mjs +96 -0
- package/src/lib/generators/model/companion.mjs +117 -0
- package/src/lib/generators/model/container.mjs +96 -0
- package/src/lib/generators/model/context.mjs +77 -0
- package/src/lib/generators/model/hook.mjs +77 -0
- package/src/lib/generators/model/model.mjs +79 -0
- package/src/lib/generators/plugin/index.mjs +195 -0
- package/src/lib/generators/project/app.mjs +39 -0
- package/src/lib/generators/project/content.mjs +41 -0
- package/src/lib/generators/project/i18n.mjs +38 -0
- package/src/lib/generators/project/plugin.mjs +38 -0
- package/src/lib/generators/project/splash.mjs +39 -0
- package/src/lib/generators/project/theme.mjs +38 -0
- package/src/lib/generators/serve/index.mjs +74 -0
- package/src/lib/generators/version/index.mjs +182 -0
- package/src/lib/generators/workspace/index.mjs +40 -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 +67 -0
- package/src/lib/routing-plopfile.mjs +53 -0
- package/src/lib/scripts/generate-metadata.mjs +39 -0
- package/src/lib/utils/action-factory.mjs +9 -0
- package/src/lib/utils/cache.mjs +128 -0
- package/src/lib/utils/command-builder.mjs +94 -0
- package/src/lib/utils/exec.mjs +18 -0
- package/src/lib/utils/generator-loader.mjs +65 -0
- package/src/lib/utils/index.mjs +1 -0
- package/src/lib/utils/java-home.mjs +55 -0
- package/src/lib/utils/logger.mjs +0 -0
- package/src/lib/utils/nx-context.mjs +395 -0
- package/src/lib/utils/prompts.mjs +75 -0
- package/src/lib/utils/studio-home.mjs +12 -0
- package/src/lib/utils/utils.mjs +126 -0
- package/src/lib/utils/validators.mjs +10 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { clearCache } from "../../utils/cache.mjs";
|
|
2
|
+
|
|
3
|
+
export const metadata = {
|
|
4
|
+
name: "cache:clear",
|
|
5
|
+
description: "Clear the generator context cache",
|
|
6
|
+
invalidateCache: false,
|
|
7
|
+
requiresModels: false,
|
|
8
|
+
};
|
|
9
|
+
export default function registerCacheGenerators(plop) {
|
|
10
|
+
plop.setGenerator("cache:clear", {
|
|
11
|
+
description: "Clear the generator context cache",
|
|
12
|
+
prompts: [],
|
|
13
|
+
actions: () => {
|
|
14
|
+
clearCache();
|
|
15
|
+
return ["[ok] CLI cache cleared successfully."];
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// generators/component/index.mjs
|
|
2
|
+
import { actionFactory } from "../../utils/action-factory.mjs";
|
|
3
|
+
import { execute } from "../../utils/exec.mjs";
|
|
4
|
+
import { getComponentCompatibleProjectsWithFallback } from "../../utils/nx-context.mjs";
|
|
5
|
+
import { required } from "../../utils/validators.mjs";
|
|
6
|
+
|
|
7
|
+
export const metadata = {
|
|
8
|
+
key: "component",
|
|
9
|
+
name: "KOS React Component",
|
|
10
|
+
namedArguments: {
|
|
11
|
+
name: "componentName",
|
|
12
|
+
componentName: "componentName",
|
|
13
|
+
project: "componentProject",
|
|
14
|
+
componentProject: "componentProject"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default async function (plop) {
|
|
19
|
+
const componentProjects = await getComponentCompatibleProjectsWithFallback();
|
|
20
|
+
|
|
21
|
+
plop.setActionType("createComponent", async function (answers) {
|
|
22
|
+
const command = `npx nx generate @kosdev-code/kos-nx-plugin:kos-component \
|
|
23
|
+
--name=${answers.componentName} \
|
|
24
|
+
--appProject=${answers.componentProject} \
|
|
25
|
+
--type=components \
|
|
26
|
+
--no-interactive`;
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
await execute(command);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
throw new Error(error);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return `Component ${answers.componentName} created in ${answers.componentProject}`;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
plop.setGenerator("component", {
|
|
38
|
+
description: "Create a new KOS Component",
|
|
39
|
+
prompts: [
|
|
40
|
+
{
|
|
41
|
+
type: "input",
|
|
42
|
+
name: "componentName",
|
|
43
|
+
message: "Enter the name of the component",
|
|
44
|
+
validate: required,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: "list",
|
|
48
|
+
name: "componentProject",
|
|
49
|
+
message: "Which project should the component be created in?",
|
|
50
|
+
choices: componentProjects,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
actions: actionFactory("createComponent", metadata),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// generators/env/index.mjs
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import directoryPrompt from "inquirer-directory";
|
|
4
|
+
import { findJavaExecutable } from "../../utils/java-home.mjs";
|
|
5
|
+
import { detectWorkspace } from "../../utils/nx-context.mjs";
|
|
6
|
+
import { findStudioHome } from "../../utils/studio-home.mjs";
|
|
7
|
+
|
|
8
|
+
export const metadata = {
|
|
9
|
+
key: "env",
|
|
10
|
+
name: "Discover and Set Studio Environment Variables",
|
|
11
|
+
namedArguments: { interactive: "interactive" },
|
|
12
|
+
};
|
|
13
|
+
export default async function (plop) {
|
|
14
|
+
plop.setPrompt("directory", directoryPrompt);
|
|
15
|
+
|
|
16
|
+
plop.setActionType("findEnv", async function () {
|
|
17
|
+
console.log("[kos-cli] Discovering Studio Environment Variables...");
|
|
18
|
+
const isWorkspace = await detectWorkspace();
|
|
19
|
+
|
|
20
|
+
if (!isWorkspace) {
|
|
21
|
+
console.warn(
|
|
22
|
+
"[kos-cli] Not inside an Nx workspace. Skipping env generator."
|
|
23
|
+
);
|
|
24
|
+
return "Skipped: Not a workspace";
|
|
25
|
+
}
|
|
26
|
+
const studioHome = findStudioHome();
|
|
27
|
+
const javaHome = findJavaExecutable();
|
|
28
|
+
|
|
29
|
+
fs.writeFileSync(
|
|
30
|
+
".env.local",
|
|
31
|
+
`# Path to the Java binary\nJAVA_CMD='${javaHome}'\n\n# Path to the kos installation\nKOS_INSTALL_PATH='${studioHome}'\n`
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return `\nStudio Home: ${studioHome}\nJava Home: ${javaHome}`;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
plop.setGenerator("env", {
|
|
38
|
+
description: "Discover Studio Environment Variables",
|
|
39
|
+
prompts: [],
|
|
40
|
+
actions: () => [{ type: "findEnv" }],
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// generators/i18n/namespace.mjs
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { actionFactory } from "../../utils/action-factory.mjs";
|
|
5
|
+
import { getI18nProjectsWithFallback, getProjectDetails } from "../../utils/nx-context.mjs";
|
|
6
|
+
import { required } from "../../utils/validators.mjs";
|
|
7
|
+
|
|
8
|
+
export const metadata = {
|
|
9
|
+
key: "i18n:namespace",
|
|
10
|
+
name: "KOS i18n Project Namespace",
|
|
11
|
+
namedArguments: {
|
|
12
|
+
name: "name",
|
|
13
|
+
locale: "locale",
|
|
14
|
+
project: "project",
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default async function (plop) {
|
|
19
|
+
const i18nProjects = await getI18nProjectsWithFallback();
|
|
20
|
+
|
|
21
|
+
plop.setActionType("addNamespace", async function (answers) {
|
|
22
|
+
const i18nProject = await getProjectDetails(answers.project);
|
|
23
|
+
const srcRoot = i18nProject.sourceRoot;
|
|
24
|
+
const locale = answers.locale;
|
|
25
|
+
const namespaceDir = path.join(srcRoot, "assets", "locales", locale);
|
|
26
|
+
const namespacePath = path.join(namespaceDir, `${answers.name}.json`);
|
|
27
|
+
|
|
28
|
+
fs.mkdirSync(namespaceDir, { recursive: true });
|
|
29
|
+
fs.writeFileSync(
|
|
30
|
+
namespacePath,
|
|
31
|
+
JSON.stringify({ name: answers.name }, null, 2)
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return `Namespace ${answers.name}.json created for locale ${locale} in ${answers.project}`;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
plop.setGenerator("i18n:namespace", {
|
|
38
|
+
description: "Create a new KOS UI i18n namespace",
|
|
39
|
+
prompts: [
|
|
40
|
+
{
|
|
41
|
+
type: "input",
|
|
42
|
+
name: "name",
|
|
43
|
+
message: "What is the name of the i18n namespace?",
|
|
44
|
+
validate: required,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: "input",
|
|
48
|
+
name: "locale",
|
|
49
|
+
message: "What is the locale of the i18n namespace?",
|
|
50
|
+
validate: required,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: "list",
|
|
54
|
+
name: "project",
|
|
55
|
+
message: "Which project should the namespace be created in?",
|
|
56
|
+
choices: i18nProjects,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
actions: actionFactory("addNamespace", metadata),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// generators/kab/index.mjs
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
import inquirer from "inquirer";
|
|
4
|
+
import { detectWorkspace } from "../../utils/nx-context.mjs";
|
|
5
|
+
|
|
6
|
+
export const metadata = {
|
|
7
|
+
key: "kab",
|
|
8
|
+
name: "Run Kab Target",
|
|
9
|
+
namedArguments: {
|
|
10
|
+
project: "project",
|
|
11
|
+
interactive: "interactive"
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
async function getProjectsWithTarget(target) {
|
|
16
|
+
try {
|
|
17
|
+
const output = execSync(`npx nx show projects --with-target ${target} --json`, {
|
|
18
|
+
encoding: "utf-8",
|
|
19
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
20
|
+
});
|
|
21
|
+
return JSON.parse(output);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default async function (plop) {
|
|
28
|
+
const projects = await getProjectsWithTarget("kab");
|
|
29
|
+
|
|
30
|
+
if (projects.length === 0) {
|
|
31
|
+
console.warn("[kos-cli] No projects found with kab target");
|
|
32
|
+
// Still register the generator but it will fail gracefully
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
plop.setActionType("runKab", async function (answers) {
|
|
36
|
+
const isWorkspace = await detectWorkspace();
|
|
37
|
+
|
|
38
|
+
if (!isWorkspace) {
|
|
39
|
+
console.warn(
|
|
40
|
+
"[kos-cli] Not inside an Nx workspace. Cannot run kab target."
|
|
41
|
+
);
|
|
42
|
+
return "Skipped: Not a workspace";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const { project } = answers;
|
|
46
|
+
|
|
47
|
+
if (project === "all") {
|
|
48
|
+
console.log("[kos-cli] Running kab on all projects with kab target...");
|
|
49
|
+
try {
|
|
50
|
+
execSync("npx nx run-many --target=kab", {
|
|
51
|
+
stdio: "inherit",
|
|
52
|
+
});
|
|
53
|
+
return "Successfully ran kab on all projects";
|
|
54
|
+
} catch (error) {
|
|
55
|
+
throw new Error(`Failed to run kab on all projects: ${error.message}`);
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
console.log(`[kos-cli] Running kab on ${project}...`);
|
|
59
|
+
try {
|
|
60
|
+
execSync(`npx nx run ${project}:kab`, {
|
|
61
|
+
stdio: "inherit",
|
|
62
|
+
});
|
|
63
|
+
return `Successfully ran kab on ${project}`;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
throw new Error(`Failed to run kab on ${project}: ${error.message}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
plop.setGenerator("kab", {
|
|
71
|
+
description: "Run the kab target on a project",
|
|
72
|
+
prompts: [
|
|
73
|
+
{
|
|
74
|
+
type: "list",
|
|
75
|
+
name: "project",
|
|
76
|
+
message: "Select a project to run kab:",
|
|
77
|
+
choices: [...projects, new inquirer.Separator(), { name: "Run on all projects", value: "all" }],
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
actions: () => [{ type: "runKab" }],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"category": "cache",
|
|
4
|
+
"file": "index.mjs",
|
|
5
|
+
"metadata": {
|
|
6
|
+
"name": "cache:clear",
|
|
7
|
+
"description": "Clear the generator context cache",
|
|
8
|
+
"invalidateCache": false,
|
|
9
|
+
"requiresModels": false
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"category": "component",
|
|
14
|
+
"file": "index.mjs",
|
|
15
|
+
"metadata": {
|
|
16
|
+
"key": "component",
|
|
17
|
+
"name": "KOS React Component",
|
|
18
|
+
"namedArguments": {
|
|
19
|
+
"name": "componentName",
|
|
20
|
+
"componentName": "componentName",
|
|
21
|
+
"project": "componentProject",
|
|
22
|
+
"componentProject": "componentProject"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"category": "env",
|
|
28
|
+
"file": "index.mjs",
|
|
29
|
+
"metadata": {
|
|
30
|
+
"key": "env",
|
|
31
|
+
"name": "Discover and Set Studio Environment Variables"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"category": "i18n",
|
|
36
|
+
"file": "namespace.mjs",
|
|
37
|
+
"metadata": {
|
|
38
|
+
"key": "i18n: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
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"category": "model",
|
|
67
|
+
"file": "companion.mjs",
|
|
68
|
+
"metadata": {
|
|
69
|
+
"key": "model:companion",
|
|
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
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"category": "model",
|
|
89
|
+
"file": "container.mjs",
|
|
90
|
+
"metadata": {
|
|
91
|
+
"key": "container",
|
|
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
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"category": "model",
|
|
107
|
+
"file": "context.mjs",
|
|
108
|
+
"metadata": {
|
|
109
|
+
"key": "context",
|
|
110
|
+
"name": "KOS Model React Context",
|
|
111
|
+
"namedArguments": {
|
|
112
|
+
"modelName": "modelName",
|
|
113
|
+
"componentProject": "componentProject",
|
|
114
|
+
"project": "componentProject"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"category": "model",
|
|
120
|
+
"file": "hook.mjs",
|
|
121
|
+
"metadata": {
|
|
122
|
+
"key": "hook",
|
|
123
|
+
"name": "KOS Model React Hook",
|
|
124
|
+
"namedArguments": {
|
|
125
|
+
"modelName": "modelName",
|
|
126
|
+
"componentProject": "componentProject",
|
|
127
|
+
"project": "componentProject"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"category": "model",
|
|
133
|
+
"file": "model.mjs",
|
|
134
|
+
"metadata": {
|
|
135
|
+
"key": "model",
|
|
136
|
+
"name": "KOS Model",
|
|
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
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"category": "plugin",
|
|
155
|
+
"file": "index.mjs",
|
|
156
|
+
"metadata": [
|
|
157
|
+
{
|
|
158
|
+
"key": "pluginComponent",
|
|
159
|
+
"name": "KOS UI Plugin Component",
|
|
160
|
+
"namedArguments": {
|
|
161
|
+
"name": "componentName",
|
|
162
|
+
"componentName": "componentName",
|
|
163
|
+
"project": "componentProject",
|
|
164
|
+
"componentProject": "componentProject",
|
|
165
|
+
"extensionPoint": "extensionPoint"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"key": "plugin:cui",
|
|
170
|
+
"name": "KOS UI Plugin CUI Configuration",
|
|
171
|
+
"namedArguments": {
|
|
172
|
+
"name": "componentName",
|
|
173
|
+
"componentName": "componentName",
|
|
174
|
+
"project": "componentProject",
|
|
175
|
+
"componentProject": "componentProject"
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"key": "plugin:setup",
|
|
180
|
+
"name": "KOS UI Plugin Setup Step",
|
|
181
|
+
"namedArguments": {
|
|
182
|
+
"name": "componentName",
|
|
183
|
+
"componentName": "componentName",
|
|
184
|
+
"project": "componentProject",
|
|
185
|
+
"componentProject": "componentProject"
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"key": "plugin:utility",
|
|
190
|
+
"name": "KOS UI Plugin Utility",
|
|
191
|
+
"namedArguments": {
|
|
192
|
+
"name": "componentName",
|
|
193
|
+
"componentName": "componentName",
|
|
194
|
+
"project": "componentProject",
|
|
195
|
+
"componentProject": "componentProject"
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"key": "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
|
+
}
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"key": "plugin:nav",
|
|
211
|
+
"name": "KOS UI Plugin Navigation View",
|
|
212
|
+
"namedArguments": {
|
|
213
|
+
"name": "componentName",
|
|
214
|
+
"componentName": "componentName",
|
|
215
|
+
"project": "componentProject",
|
|
216
|
+
"componentProject": "componentProject"
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"key": "plugin:cp",
|
|
221
|
+
"name": "KOS UI Plugin Control Pour",
|
|
222
|
+
"namedArguments": {
|
|
223
|
+
"name": "componentName",
|
|
224
|
+
"componentName": "componentName",
|
|
225
|
+
"project": "componentProject",
|
|
226
|
+
"componentProject": "componentProject"
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
]
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"category": "project",
|
|
233
|
+
"file": "app.mjs",
|
|
234
|
+
"metadata": {
|
|
235
|
+
"key": "project",
|
|
236
|
+
"name": "KOS UI App Project",
|
|
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
|
+
}
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"category": "project",
|
|
257
|
+
"file": "i18n.mjs",
|
|
258
|
+
"metadata": {
|
|
259
|
+
"key": "i18n",
|
|
260
|
+
"name": "KOS Localization Project",
|
|
261
|
+
"invalidateCache": true,
|
|
262
|
+
"namedArguments": {
|
|
263
|
+
"name": "name"
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"category": "project",
|
|
269
|
+
"file": "plugin.mjs",
|
|
270
|
+
"metadata": {
|
|
271
|
+
"key": "plugin",
|
|
272
|
+
"name": "KOS Plugin Project",
|
|
273
|
+
"invalidateCache": true,
|
|
274
|
+
"namedArguments": {
|
|
275
|
+
"name": "name"
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"category": "project",
|
|
281
|
+
"file": "splash.mjs",
|
|
282
|
+
"metadata": {
|
|
283
|
+
"key": "project:splash",
|
|
284
|
+
"name": "KOS Splash Screen Project",
|
|
285
|
+
"invalidateCache": true,
|
|
286
|
+
"namedArguments": {
|
|
287
|
+
"name": "name"
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
"category": "project",
|
|
293
|
+
"file": "theme.mjs",
|
|
294
|
+
"metadata": {
|
|
295
|
+
"key": "theme",
|
|
296
|
+
"name": "KOS Theme Project",
|
|
297
|
+
"invalidateCache": true,
|
|
298
|
+
"namedArguments": {
|
|
299
|
+
"name": "name"
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"category": "workspace",
|
|
305
|
+
"file": "index.mjs",
|
|
306
|
+
"metadata": {
|
|
307
|
+
"key": "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
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
]
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// generators/model/add-future.mjs
|
|
2
|
+
import { actionFactory } from "../../utils/action-factory.mjs";
|
|
3
|
+
import { execute } from "../../utils/exec.mjs";
|
|
4
|
+
import { getAllModels } from "../../utils/nx-context.mjs";
|
|
5
|
+
import { DEFAULT_PROMPTS } from "../../utils/prompts.mjs";
|
|
6
|
+
|
|
7
|
+
export const metadata = {
|
|
8
|
+
key: "add-future",
|
|
9
|
+
name: "Add Future Support to Model",
|
|
10
|
+
invalidateCache: true,
|
|
11
|
+
namedArguments: {
|
|
12
|
+
modelName: "modelName",
|
|
13
|
+
project: "modelProject",
|
|
14
|
+
modelProject: "modelProject",
|
|
15
|
+
futureType: "futureType",
|
|
16
|
+
updateServices: "updateServices",
|
|
17
|
+
dryRun: "dryRun",
|
|
18
|
+
interactive: "interactive",
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default async function (plop) {
|
|
23
|
+
// Check if we're in interactive mode by looking at process args
|
|
24
|
+
const isInteractive = process.argv.includes('-i') || process.argv.includes('--interactive');
|
|
25
|
+
|
|
26
|
+
// For interactive mode, use lazy loading. For non-interactive, load immediately.
|
|
27
|
+
let modelChoices;
|
|
28
|
+
if (isInteractive) {
|
|
29
|
+
modelChoices = async () => {
|
|
30
|
+
const allModels = await getAllModels();
|
|
31
|
+
return allModels.map((m) => ({
|
|
32
|
+
name: `${m.model} (${m.project})`,
|
|
33
|
+
value: m.model,
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
} else {
|
|
37
|
+
const allModels = await getAllModels();
|
|
38
|
+
modelChoices = allModels.map((m) => ({
|
|
39
|
+
name: `${m.model} (${m.project})`,
|
|
40
|
+
value: m.model,
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
plop.setActionType("addFutureToModel", async function (answers) {
|
|
45
|
+
const allModels = await getAllModels();
|
|
46
|
+
const modelProject = allModels.find(
|
|
47
|
+
(m) => m.model === answers.modelName
|
|
48
|
+
)?.project;
|
|
49
|
+
|
|
50
|
+
const command = `npx nx generate @kosdev-code/kos-nx-plugin:kos-add-future-to-model \\
|
|
51
|
+
--modelName=${answers.modelName} \\
|
|
52
|
+
--modelProject=${modelProject} \\
|
|
53
|
+
--futureType=${answers.futureType} \\
|
|
54
|
+
--updateServices=${!!answers.updateServices} \\
|
|
55
|
+
--no-interactive ${answers.dryRun ? "--dryRun" : ""} --verbose`;
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
await execute(command);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
throw new Error(error);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return `Future support (${answers.futureType}) added to model ${answers.modelName} in ${modelProject}`;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
plop.setGenerator("add-future", {
|
|
67
|
+
description: "Add Future support to an existing KOS Model",
|
|
68
|
+
prompts: [
|
|
69
|
+
...DEFAULT_PROMPTS,
|
|
70
|
+
{
|
|
71
|
+
type: "list",
|
|
72
|
+
name: "modelName",
|
|
73
|
+
message: "Which model do you want to add Future support to?",
|
|
74
|
+
choices: modelChoices,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: "list",
|
|
78
|
+
name: "futureType",
|
|
79
|
+
message: "What type of Future support?",
|
|
80
|
+
choices: [
|
|
81
|
+
{ name: "Minimal (external access only)", value: "minimal" },
|
|
82
|
+
{ name: "Complete (internal + external access)", value: "complete" },
|
|
83
|
+
],
|
|
84
|
+
default: "minimal",
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
type: "confirm",
|
|
88
|
+
name: "updateServices",
|
|
89
|
+
message: "Update/create services file with Future operations?",
|
|
90
|
+
default: true,
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
|
|
94
|
+
actions: actionFactory("addFutureToModel", metadata),
|
|
95
|
+
});
|
|
96
|
+
}
|