@kosdev-code/kos-ddk-cli 0.0.0-stage → 0.1.0-dev.105

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.
Files changed (124) hide show
  1. package/README.md +181 -2
  2. package/agent-plugin/.claude-plugin/marketplace.json +13 -0
  3. package/agent-plugin/kos-ddk-tools/.claude-plugin/plugin.json +8 -0
  4. package/agent-plugin/kos-ddk-tools/.mcp.json +11 -0
  5. package/agent-plugin/kos-ddk-tools/agents/kos-ddk-plugin-planner.md +45 -0
  6. package/agent-plugin/kos-ddk-tools/agents/kos-ddk-plugin-reviewer.md +43 -0
  7. package/agent-plugin/kos-ddk-tools/catalog/contributions.json +921 -0
  8. package/agent-plugin/kos-ddk-tools/mcp.json +12 -0
  9. package/agent-plugin/kos-ddk-tools/plugin.json +7 -0
  10. package/agent-plugin/kos-ddk-tools/reference/reference.json +21141 -0
  11. package/agent-plugin/kos-ddk-tools/servers/kos-ddk.mjs +48656 -0
  12. package/agent-plugin/kos-ddk-tools/skills/build-ddk-plugin/SKILL.md +110 -0
  13. package/agent-plugin/kos-ddk-tools/skills/ddk-config-page/SKILL.md +130 -0
  14. package/agent-plugin/kos-ddk-tools/skills/ddk-content-component/SKILL.md +59 -0
  15. package/agent-plugin/kos-ddk-tools/skills/ddk-storybook/SKILL.md +45 -0
  16. package/agent-plugin/kos-ddk-tools/templates/cui/__nameDashCase__.stories.tsx__template__ +32 -0
  17. package/agent-plugin/kos-ddk-tools/templates/cui/__nameDashCase__.tsx__template__ +35 -0
  18. package/agent-plugin/kos-ddk-tools/templates/cui/index.ts__template__ +1 -0
  19. package/agent-plugin/kos-ddk-tools/templates/dashboard-detail/detail/__nameDashCase__.stories.tsx__template__ +34 -0
  20. package/agent-plugin/kos-ddk-tools/templates/dashboard-detail/detail/__nameDashCase__.tsx__template__ +52 -0
  21. package/agent-plugin/kos-ddk-tools/templates/dashboard-detail/detail/index.ts__template__ +1 -0
  22. package/agent-plugin/kos-ddk-tools/templates/dashboard-region/__nameDashCase__.stories.tsx__template__ +38 -0
  23. package/agent-plugin/kos-ddk-tools/templates/dashboard-region/__nameDashCase__.tsx__template__ +28 -0
  24. package/agent-plugin/kos-ddk-tools/templates/dashboard-region/index.ts__template__ +1 -0
  25. package/agent-plugin/kos-ddk-tools/templates/dashboard-summary/summary/__nameDashCase__.stories.tsx__template__ +34 -0
  26. package/agent-plugin/kos-ddk-tools/templates/dashboard-summary/summary/__nameDashCase__.tsx__template__ +41 -0
  27. package/agent-plugin/kos-ddk-tools/templates/dashboard-summary/summary/index.ts__template__ +1 -0
  28. package/agent-plugin/kos-ddk-tools/templates/macro-summary/__nameDashCase__.stories.tsx__template__ +34 -0
  29. package/agent-plugin/kos-ddk-tools/templates/macro-summary/__nameDashCase__.tsx__template__ +24 -0
  30. package/agent-plugin/kos-ddk-tools/templates/macro-summary/index.ts__template__ +1 -0
  31. package/agent-plugin/kos-ddk-tools/templates/nav/__nameDashCase__.stories.tsx__template__ +32 -0
  32. package/agent-plugin/kos-ddk-tools/templates/nav/__nameDashCase__.tsx__template__ +27 -0
  33. package/agent-plugin/kos-ddk-tools/templates/nav/index.ts__template__ +1 -0
  34. package/agent-plugin/kos-ddk-tools/templates/plugin-project/.storybook/preview.tsx.template +113 -0
  35. package/agent-plugin/kos-ddk-tools/templates/plugin-project/.storybook/registration.ts.template +6 -0
  36. package/agent-plugin/kos-ddk-tools/templates/pump-detail/__nameDashCase__.stories.tsx__template__ +34 -0
  37. package/agent-plugin/kos-ddk-tools/templates/pump-detail/__nameDashCase__.tsx__template__ +38 -0
  38. package/agent-plugin/kos-ddk-tools/templates/pump-detail/index.ts__template__ +1 -0
  39. package/agent-plugin/kos-ddk-tools/templates/pump-summary/__nameDashCase__.stories.tsx__template__ +34 -0
  40. package/agent-plugin/kos-ddk-tools/templates/pump-summary/__nameDashCase__.tsx__template__ +25 -0
  41. package/agent-plugin/kos-ddk-tools/templates/pump-summary/index.ts__template__ +1 -0
  42. package/agent-plugin/kos-ddk-tools/templates/setup/__nameDashCase__.stories.tsx__template__ +32 -0
  43. package/agent-plugin/kos-ddk-tools/templates/setup/__nameDashCase__.tsx__template__ +33 -0
  44. package/agent-plugin/kos-ddk-tools/templates/setup/index.ts__template__ +1 -0
  45. package/agent-plugin/kos-ddk-tools/templates/theme-project/theme/assets/component.css.template +2 -0
  46. package/agent-plugin/kos-ddk-tools/templates/theme-project/theme/assets/generic.css.template +2 -0
  47. package/agent-plugin/kos-ddk-tools/templates/theme-project/theme/assets/semantic.css.template +2 -0
  48. package/agent-plugin/kos-ddk-tools/templates/theme-project/theme/assets/theme-overlay.css.template +7 -0
  49. package/agent-plugin/kos-ddk-tools/templates/trouble-action/__nameDashCase__.stories.tsx__template__ +31 -0
  50. package/agent-plugin/kos-ddk-tools/templates/trouble-action/__nameDashCase__.tsx__template__ +57 -0
  51. package/agent-plugin/kos-ddk-tools/templates/trouble-action/index.ts__template__ +1 -0
  52. package/agent-plugin/kos-ddk-tools/templates/utility/__nameDashCase__.stories.tsx__template__ +60 -0
  53. package/agent-plugin/kos-ddk-tools/templates/utility/__nameDashCase__.tsx__template__ +88 -0
  54. package/agent-plugin/kos-ddk-tools/templates/utility/index.ts__template__ +1 -0
  55. package/catalog/contributions.json +921 -0
  56. package/guides/config-property-cards.md +77 -0
  57. package/guides/ddk-dev.md +59 -0
  58. package/guides/getting-started.md +126 -0
  59. package/guides/storybook.md +127 -0
  60. package/package.json +33 -3
  61. package/reference/reference.json +21141 -0
  62. package/src/build-paths.mjs +20 -0
  63. package/src/codegen/contribution.mjs +530 -0
  64. package/src/codegen/descriptor.mjs +422 -0
  65. package/src/codegen/json-preserve.mjs +137 -0
  66. package/src/codegen/ncui-descriptor.mjs +167 -0
  67. package/src/codegen/overrides.mjs +263 -0
  68. package/src/codegen/project.mjs +271 -0
  69. package/src/extension.mjs +32 -0
  70. package/src/generators/agent-install.mjs +80 -0
  71. package/src/generators/catalog.mjs +81 -0
  72. package/src/generators/contributions.mjs +164 -0
  73. package/src/generators/dashboard.mjs +282 -0
  74. package/src/generators/descriptor-entries.mjs +53 -0
  75. package/src/generators/descriptor-project.mjs +84 -0
  76. package/src/generators/dev.mjs +231 -0
  77. package/src/generators/override-prompts.mjs +27 -0
  78. package/src/generators/plugin-project.mjs +71 -0
  79. package/src/generators/theme-project.mjs +53 -0
  80. package/src/handlers.mjs +335 -0
  81. package/src/mcp/pkg-info.mjs +7 -0
  82. package/src/mcp/plugin-inspect.mjs +328 -0
  83. package/src/mcp/reference.mjs +315 -0
  84. package/src/mcp/server.mjs +12 -0
  85. package/src/mcp/tools.mjs +619 -0
  86. package/templates/cui/__nameDashCase__.stories.tsx__template__ +32 -0
  87. package/templates/cui/__nameDashCase__.tsx__template__ +35 -0
  88. package/templates/cui/index.ts__template__ +1 -0
  89. package/templates/dashboard-detail/detail/__nameDashCase__.stories.tsx__template__ +34 -0
  90. package/templates/dashboard-detail/detail/__nameDashCase__.tsx__template__ +52 -0
  91. package/templates/dashboard-detail/detail/index.ts__template__ +1 -0
  92. package/templates/dashboard-region/__nameDashCase__.stories.tsx__template__ +38 -0
  93. package/templates/dashboard-region/__nameDashCase__.tsx__template__ +28 -0
  94. package/templates/dashboard-region/index.ts__template__ +1 -0
  95. package/templates/dashboard-summary/summary/__nameDashCase__.stories.tsx__template__ +34 -0
  96. package/templates/dashboard-summary/summary/__nameDashCase__.tsx__template__ +41 -0
  97. package/templates/dashboard-summary/summary/index.ts__template__ +1 -0
  98. package/templates/macro-summary/__nameDashCase__.stories.tsx__template__ +34 -0
  99. package/templates/macro-summary/__nameDashCase__.tsx__template__ +24 -0
  100. package/templates/macro-summary/index.ts__template__ +1 -0
  101. package/templates/nav/__nameDashCase__.stories.tsx__template__ +32 -0
  102. package/templates/nav/__nameDashCase__.tsx__template__ +27 -0
  103. package/templates/nav/index.ts__template__ +1 -0
  104. package/templates/plugin-project/.storybook/preview.tsx.template +113 -0
  105. package/templates/plugin-project/.storybook/registration.ts.template +6 -0
  106. package/templates/pump-detail/__nameDashCase__.stories.tsx__template__ +34 -0
  107. package/templates/pump-detail/__nameDashCase__.tsx__template__ +38 -0
  108. package/templates/pump-detail/index.ts__template__ +1 -0
  109. package/templates/pump-summary/__nameDashCase__.stories.tsx__template__ +34 -0
  110. package/templates/pump-summary/__nameDashCase__.tsx__template__ +25 -0
  111. package/templates/pump-summary/index.ts__template__ +1 -0
  112. package/templates/setup/__nameDashCase__.stories.tsx__template__ +32 -0
  113. package/templates/setup/__nameDashCase__.tsx__template__ +33 -0
  114. package/templates/setup/index.ts__template__ +1 -0
  115. package/templates/theme-project/theme/assets/component.css.template +2 -0
  116. package/templates/theme-project/theme/assets/generic.css.template +2 -0
  117. package/templates/theme-project/theme/assets/semantic.css.template +2 -0
  118. package/templates/theme-project/theme/assets/theme-overlay.css.template +7 -0
  119. package/templates/trouble-action/__nameDashCase__.stories.tsx__template__ +31 -0
  120. package/templates/trouble-action/__nameDashCase__.tsx__template__ +57 -0
  121. package/templates/trouble-action/index.ts__template__ +1 -0
  122. package/templates/utility/__nameDashCase__.stories.tsx__template__ +60 -0
  123. package/templates/utility/__nameDashCase__.tsx__template__ +88 -0
  124. package/templates/utility/index.ts__template__ +1 -0
@@ -0,0 +1,84 @@
1
+ // ddk:descriptor-project: an NCUI descriptor project. kos-nx-plugin's generic content
2
+ // project as a ddk.ncui.descriptor KAB, with the NCUI descriptor for a layout and the
3
+ // dispenser's options.
4
+ import { createDdkProject, dryRunReport } from "../codegen/project.mjs";
5
+ import { NCUI_LAYOUTS, NCUI_OPTIONS } from "../codegen/ncui-descriptor.mjs";
6
+
7
+ const installNote = (toInstall) =>
8
+ toInstall?.length
9
+ ? `Run npm install: the project added ${toInstall.join(", ")}.`
10
+ : "";
11
+
12
+ const flag = (value) => value === true || value === "true";
13
+
14
+ export const metadata = {
15
+ key: "ddk:descriptor-project",
16
+ name: "DDK NCUI Descriptor Project",
17
+ description:
18
+ "Create an NCUI descriptor project (a ddk.ncui.descriptor KAB): --layout standard or compact; --carb, --ice and --beveragePourTest add those (off by default)",
19
+ invalidateCache: true,
20
+ namedArguments: {
21
+ name: "name",
22
+ layout: "layout",
23
+ ...Object.fromEntries(Object.keys(NCUI_OPTIONS).map((o) => [o, o])),
24
+ dryRun: "dryRun",
25
+ interactive: "interactive",
26
+ },
27
+ };
28
+
29
+ export async function register(plop, { host }) {
30
+ plop.setActionType("ddk:createDescriptorProject", (answers) => {
31
+ const ncui = {
32
+ layout: answers.layout || "standard",
33
+ ...Object.fromEntries(
34
+ Object.keys(NCUI_OPTIONS).map((o) => [o, flag(answers[o])])
35
+ ),
36
+ };
37
+ const dryRun = !!answers.dryRun;
38
+ const result = createDdkProject("descriptor", {
39
+ workspaceRoot: process.cwd(),
40
+ name: answers.name,
41
+ ncui,
42
+ dryRun,
43
+ stdio: dryRun ? "pipe" : "inherit",
44
+ });
45
+ if (dryRun) return dryRunReport(result);
46
+ const { root, toInstall } = result;
47
+ const on = Object.keys(NCUI_OPTIONS).filter((o) => ncui[o]);
48
+ return [
49
+ `DDK NCUI descriptor project ${answers.name} created at ${root}: ${
50
+ ncui.layout
51
+ } layout${on.length ? `, with ${on.join(", ")}` : ""}.`,
52
+ `Installed beside the DDK app, its KAB replaces the system app's NCUI descriptor. List a new utility, setup step or navigation in it with --descriptorProject ${answers.name} on ddk:utility, ddk:setup and ddk:nav.`,
53
+ installNote(toInstall),
54
+ ]
55
+ .filter(Boolean)
56
+ .join("\n");
57
+ });
58
+
59
+ plop.setGenerator("ddk:descriptor-project", {
60
+ description: metadata.description,
61
+ prompts: [
62
+ {
63
+ type: "input",
64
+ name: "name",
65
+ message: "What is the name of the descriptor project?",
66
+ validate: host.required,
67
+ },
68
+ {
69
+ type: "list",
70
+ name: "layout",
71
+ message: "Which layout?",
72
+ choices: NCUI_LAYOUTS,
73
+ default: "standard",
74
+ },
75
+ ...Object.entries(NCUI_OPTIONS).map(([name, what]) => ({
76
+ type: "confirm",
77
+ name,
78
+ message: `Include ${what}?`,
79
+ default: false,
80
+ })),
81
+ ],
82
+ actions: host.actionFactory("ddk:createDescriptorProject", metadata),
83
+ });
84
+ }
@@ -0,0 +1,231 @@
1
+ // ddk:dev: serves the workspace's DDK plugin projects for a device to load with
2
+ // ?pluginDevServers=, using kosui's plugin dev server runner.
3
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+
7
+ const DDK_PLUGIN_TYPE = "ddk.ncui.plugin";
8
+ const SKIP_DIRS = new Set(["node_modules", "dist", "tmp", ".git", ".nx"]);
9
+ const LOG_DIR = process.env.DEV_LOG_DIR || "/tmp/kos-dev-logs";
10
+
11
+ export const metadata = {
12
+ key: "ddk:dev",
13
+ name: "DDK Plugin Dev Servers",
14
+ description:
15
+ "Serve DDK plugin projects for a running DDK to load with ?pluginDevServers=",
16
+ invalidateCache: false,
17
+ namedArguments: {
18
+ plugins: "plugins",
19
+ scenario: "scenario",
20
+ device: "device",
21
+ interactive: "interactive",
22
+ },
23
+ };
24
+
25
+ const readJson = (file) => JSON.parse(readFileSync(file, "utf-8"));
26
+
27
+ export function findWorkspaceRoot(start = process.cwd()) {
28
+ let dir = start;
29
+ while (dir !== path.dirname(dir)) {
30
+ if (existsSync(path.join(dir, "nx.json"))) return dir;
31
+ dir = path.dirname(dir);
32
+ }
33
+ throw new Error("ddk:dev must run inside an Nx workspace");
34
+ }
35
+
36
+ function findKosJsonFiles(dir, found) {
37
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
38
+ if (entry.isDirectory() && !SKIP_DIRS.has(entry.name)) {
39
+ findKosJsonFiles(path.join(dir, entry.name), found);
40
+ } else if (entry.name === ".kos.json" && dir !== found.root) {
41
+ found.files.push(path.join(dir, entry.name));
42
+ }
43
+ }
44
+ return found.files;
45
+ }
46
+
47
+ /**
48
+ * DDK plugin projects (`.kos.json` type ddk.ncui.plugin) with the port of their `serve`
49
+ * target and the alias the root `.kos.json` gives them, if any.
50
+ */
51
+ export function findDdkPlugins(root) {
52
+ const rootKos = existsSync(path.join(root, ".kos.json"))
53
+ ? readJson(path.join(root, ".kos.json"))
54
+ : {};
55
+ const aliases = new Map(
56
+ (rootKos.development?.hosts ?? [])
57
+ .flatMap((host) => host.plugins ?? [])
58
+ .map((plugin) => [plugin.project, plugin.alias])
59
+ );
60
+ return findKosJsonFiles(root, { root, files: [] })
61
+ .filter((file) => readJson(file).type === DDK_PLUGIN_TYPE)
62
+ .map((file) => {
63
+ const projectJson = path.join(path.dirname(file), "project.json");
64
+ const project = existsSync(projectJson) ? readJson(projectJson) : {};
65
+ const name = project.name ?? path.basename(path.dirname(file));
66
+ return {
67
+ project: name,
68
+ dir: path.relative(root, path.dirname(file)).split(path.sep).join("/"),
69
+ alias: aliases.get(name),
70
+ port: project.targets?.serve?.options?.port,
71
+ };
72
+ })
73
+ .sort((a, b) => a.project.localeCompare(b.project));
74
+ }
75
+
76
+ /**
77
+ * The plugins to start: `scenario` names a list under `.kos.json`
78
+ * development.ddkScenarios, `plugins` is a comma-separated list; entries match a
79
+ * project name or alias. Neither selects every DDK plugin.
80
+ */
81
+ export function selectPlugins(all, { plugins, scenario, scenarios = {} }) {
82
+ let names;
83
+ if (scenario) {
84
+ names = scenarios[scenario];
85
+ if (!names) {
86
+ const known = Object.keys(scenarios);
87
+ throw new Error(
88
+ `Unknown scenario "${scenario}". ${
89
+ known.length
90
+ ? `Scenarios: ${known.join(", ")}.`
91
+ : "Define scenarios under development.ddkScenarios in .kos.json."
92
+ }`
93
+ );
94
+ }
95
+ } else if (plugins) {
96
+ names = plugins
97
+ .split(",")
98
+ .map((name) => name.trim())
99
+ .filter(Boolean);
100
+ } else {
101
+ return all;
102
+ }
103
+ return names.map((name) => {
104
+ const match = all.find(
105
+ (plugin) => plugin.project === name || plugin.alias === name
106
+ );
107
+ if (!match) {
108
+ throw new Error(
109
+ `"${name}" is not a DDK plugin project. DDK plugins: ${
110
+ all.map((plugin) => plugin.project).join(", ") || "none"
111
+ }.`
112
+ );
113
+ }
114
+ return match;
115
+ });
116
+ }
117
+
118
+ function devMachineAddress(device) {
119
+ if (!device || /\/\/(localhost|127\.0\.0\.1)(:|\/|$)/.test(device)) {
120
+ return "localhost";
121
+ }
122
+ const external = Object.values(os.networkInterfaces())
123
+ .flat()
124
+ .find((net) => net?.family === "IPv4" && !net.internal);
125
+ return external?.address ?? "localhost";
126
+ }
127
+
128
+ /** Where a device or simulator serves the DDK NCUI. */
129
+ export const NCUI_PATH = "/app/kosdev.ddk/ncui/index.html";
130
+
131
+ /** The URL that loads `plugins` into the DDK served by `device`. */
132
+ export function deviceUrl(device, plugins) {
133
+ const address = devMachineAddress(device);
134
+ const servers = plugins
135
+ .map((plugin) => `http://${address}:${plugin.port}`)
136
+ .join(",");
137
+ const base = device ? device.replace(/\/+$/, "") : "<device-url>";
138
+ const pathname = new URL(base, "http://x").pathname;
139
+ // An origin gets the NCUI page; a page URL such as .../ncui/index.html takes the
140
+ // query directly.
141
+ const page = !device
142
+ ? "/"
143
+ : pathname === "/"
144
+ ? NCUI_PATH
145
+ : /\/[^/]+\.[a-z]+$/i.test(pathname)
146
+ ? ""
147
+ : "/";
148
+ return `${base}${page}?pluginDevServers=${servers}`;
149
+ }
150
+
151
+ export async function register(plop, { host }) {
152
+ plop.setActionType("ddk:runDev", async (answers) => {
153
+ const root = findWorkspaceRoot();
154
+ const rootKos = existsSync(path.join(root, ".kos.json"))
155
+ ? readJson(path.join(root, ".kos.json"))
156
+ : {};
157
+ const selected = selectPlugins(findDdkPlugins(root), {
158
+ plugins: answers.plugins,
159
+ scenario: answers.scenario,
160
+ scenarios: rootKos.development?.ddkScenarios,
161
+ });
162
+ if (selected.length === 0) {
163
+ throw new Error("No DDK plugin projects found in this workspace.");
164
+ }
165
+ const unserved = selected.filter((plugin) => !plugin.port);
166
+ if (unserved.length > 0) {
167
+ throw new Error(
168
+ `No serve port for ${unserved
169
+ .map((plugin) => plugin.project)
170
+ .join(", ")}: give its serve target an options.port.`
171
+ );
172
+ }
173
+
174
+ if (typeof host.startPluginDevServers !== "function") {
175
+ throw new Error(
176
+ "ddk:dev needs a newer @kosdev-code/kos-ui-cli; update it with: kosui cli:update"
177
+ );
178
+ }
179
+
180
+ const ready = await host.startPluginDevServers(selected, {
181
+ logDir: LOG_DIR,
182
+ });
183
+ if (!ready) {
184
+ throw new Error(`Some plugin servers failed to start; logs: ${LOG_DIR}`);
185
+ }
186
+ console.log(
187
+ [
188
+ "",
189
+ "DDK plugin dev servers:",
190
+ ...selected.map(
191
+ (plugin) => ` ${plugin.project}: http://localhost:${plugin.port}`
192
+ ),
193
+ "",
194
+ "Load them into a running DDK with:",
195
+ ` ${deviceUrl(answers.device, selected)}`,
196
+ "",
197
+ "Press Ctrl+C to stop.",
198
+ ].join("\n")
199
+ );
200
+ await new Promise(() => {});
201
+ });
202
+
203
+ plop.setGenerator("ddk:dev", {
204
+ description: metadata.description,
205
+ prompts: [
206
+ ...host.DEFAULT_PROMPTS,
207
+ {
208
+ type: "input",
209
+ name: "scenario",
210
+ message:
211
+ "Scenario from .kos.json development.ddkScenarios (blank: none)?",
212
+ default: "",
213
+ },
214
+ {
215
+ type: "input",
216
+ name: "plugins",
217
+ message: "Plugins to start, comma-separated (blank: all DDK plugins)?",
218
+ default: "",
219
+ when: (answers) => !answers.scenario,
220
+ },
221
+ {
222
+ type: "input",
223
+ name: "device",
224
+ message:
225
+ "Device URL, e.g. http://192.168.1.50:8081 (blank: print a template)?",
226
+ default: "",
227
+ },
228
+ ],
229
+ actions: host.actionFactory("ddk:runDev", metadata),
230
+ });
231
+ }
@@ -0,0 +1,27 @@
1
+ // The --override and --rank prompts every rankable ddk:<point> command shares.
2
+ import { listOverridableContributions } from "../codegen/overrides.mjs";
3
+
4
+ export function overridePrompts(point) {
5
+ return [
6
+ {
7
+ type: "list",
8
+ name: "override",
9
+ message: "Override a standard contribution?",
10
+ choices: () => [
11
+ { name: "No, add a new one", value: "" },
12
+ ...listOverridableContributions(point).map((entry) => ({
13
+ name: `${entry.id} (${Object.values(entry.keys).join(", ")})`,
14
+ value: entry.id,
15
+ })),
16
+ ],
17
+ default: "",
18
+ },
19
+ {
20
+ type: "input",
21
+ name: "rank",
22
+ message:
23
+ "Rank (lower wins; blank: unranked, or one that beats the overridden contribution)?",
24
+ default: "",
25
+ },
26
+ ];
27
+ }
@@ -0,0 +1,71 @@
1
+ // ddk:plugin-project: a DDK plugin project. kos-nx-plugin's generic plugin project with
2
+ // the DDK KAB type, Storybook preview, registration, contribution keys and packages.
3
+ import { createDdkProject, dryRunReport } from "../codegen/project.mjs";
4
+
5
+ const installNote = (toInstall) =>
6
+ toInstall?.length
7
+ ? `Run npm install: the project added ${toInstall.join(", ")}.`
8
+ : "";
9
+
10
+ export const metadata = {
11
+ key: "ddk:plugin-project",
12
+ name: "DDK Plugin Project",
13
+ description:
14
+ "Create a new DDK plugin project; --directory sets the parent folder, --host the host it registers with",
15
+ invalidateCache: true,
16
+ namedArguments: {
17
+ name: "name",
18
+ directory: "directory",
19
+ host: "host",
20
+ dryRun: "dryRun",
21
+ interactive: "interactive",
22
+ },
23
+ };
24
+
25
+ export async function register(plop, { host }) {
26
+ plop.setActionType("ddk:createPluginProject", (answers) => {
27
+ const dryRun = !!answers.dryRun;
28
+ const result = createDdkProject("plugin", {
29
+ workspaceRoot: process.cwd(),
30
+ name: answers.name,
31
+ directory: answers.directory || undefined,
32
+ host: answers.host || undefined,
33
+ dryRun,
34
+ stdio: dryRun ? "pipe" : "inherit",
35
+ });
36
+ if (dryRun) return dryRunReport(result);
37
+ const { toInstall } = result;
38
+ return [
39
+ `DDK plugin project ${answers.name} created.`,
40
+ installNote(toInstall),
41
+ ]
42
+ .filter(Boolean)
43
+ .join("\n");
44
+ });
45
+
46
+ plop.setGenerator("ddk:plugin-project", {
47
+ description: metadata.description,
48
+ prompts: [
49
+ {
50
+ type: "input",
51
+ name: "name",
52
+ message: "What is the name of the plugin project?",
53
+ validate: host.required,
54
+ },
55
+ {
56
+ type: "input",
57
+ name: "directory",
58
+ message: "Folder to create it in (blank: plugins)?",
59
+ default: "",
60
+ },
61
+ {
62
+ type: "input",
63
+ name: "host",
64
+ message:
65
+ "Host to register with (blank: the kosdev.ddk host, else none)?",
66
+ default: "",
67
+ },
68
+ ],
69
+ actions: host.actionFactory("ddk:createPluginProject", metadata),
70
+ });
71
+ }
@@ -0,0 +1,53 @@
1
+ // ddk:theme-project: a DDK theme project. kos-nx-plugin's generic theme project with the
2
+ // DDK KAB type and the theme-overlay.css the DDK apps load over their base tokens.
3
+ import { createDdkProject, dryRunReport } from "../codegen/project.mjs";
4
+
5
+ const installNote = (toInstall) =>
6
+ toInstall?.length
7
+ ? `Run npm install: the project added ${toInstall.join(", ")}.`
8
+ : "";
9
+
10
+ export const metadata = {
11
+ key: "ddk:theme-project",
12
+ name: "DDK Theme Project",
13
+ description: "Create a new DDK theme project",
14
+ invalidateCache: true,
15
+ namedArguments: {
16
+ name: "name",
17
+ dryRun: "dryRun",
18
+ interactive: "interactive",
19
+ },
20
+ };
21
+
22
+ export async function register(plop, { host }) {
23
+ plop.setActionType("ddk:createThemeProject", (answers) => {
24
+ const dryRun = !!answers.dryRun;
25
+ const result = createDdkProject("theme", {
26
+ workspaceRoot: process.cwd(),
27
+ name: answers.name,
28
+ dryRun,
29
+ stdio: dryRun ? "pipe" : "inherit",
30
+ });
31
+ if (dryRun) return dryRunReport(result);
32
+ const { toInstall } = result;
33
+ return [
34
+ `DDK theme project ${answers.name} created.`,
35
+ installNote(toInstall),
36
+ ]
37
+ .filter(Boolean)
38
+ .join("\n");
39
+ });
40
+
41
+ plop.setGenerator("ddk:theme-project", {
42
+ description: metadata.description,
43
+ prompts: [
44
+ {
45
+ type: "input",
46
+ name: "name",
47
+ message: "What is the name of the theme project?",
48
+ validate: host.required,
49
+ },
50
+ ],
51
+ actions: host.actionFactory("ddk:createThemeProject", metadata),
52
+ });
53
+ }