@kosdev-code/kos-ddk-cli 0.1.0-dev.61 → 0.1.0-dev.63

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosdev-code/kos-ddk-cli",
3
- "version": "0.1.0-dev.61",
3
+ "version": "0.1.0-dev.63",
4
4
  "description": "DDK commands for kosui: plugin projects and DDK extension-point contributions.",
5
5
  "type": "module",
6
6
  "kosui": {
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "kos": {
29
29
  "build": {
30
- "gitHash": "edc581166b672e67c4ae900dff675c78908691b1"
30
+ "gitHash": "bc5245dbcb317a31a44c3441ff772db881239b65"
31
31
  }
32
32
  },
33
33
  "publishConfig": {
@@ -43,6 +43,32 @@ function descriptorProject(codegenFs, name) {
43
43
  return project;
44
44
  }
45
45
 
46
+ /**
47
+ * The KosMock setup module that serves a descriptor project without deploying it:
48
+ * `fixtures/setups/<name>.mjs`, relative to the workspace root, for
49
+ * `kosui fixtures serve`. Regenerated whenever the descriptor project changes.
50
+ */
51
+ export function descriptorMockSetup(kosJson) {
52
+ const { name, kondra } = kosJson;
53
+ return {
54
+ path: path.join("fixtures", "setups", `${name}.mjs`),
55
+ content: `// Generated from the descriptor project ${name}; regenerated whenever a ddk
56
+ // command lists an entry there, so put other mocking in a setup of its own.
57
+ // Serves ${name} as the installed NCUI descriptor without deploying it: run
58
+ // \`kosui fixtures serve\` and open the DDK app with
59
+ // ?kosMock=on&kosFixtureServer&kosSetup=${name}
60
+ const descriptor = ${JSON.stringify({ kondra }, null, 2)};
61
+
62
+ export default (kosMock) => {
63
+ if (!kosMock.ddk) {
64
+ throw new Error("kosMock.ddk is missing: it needs a DDK and kos-ui-sdk that provide it");
65
+ }
66
+ return kosMock.ddk.useDescriptor(descriptor);
67
+ };
68
+ `,
69
+ };
70
+ }
71
+
46
72
  const parseRoles = (roles) =>
47
73
  (Array.isArray(roles) ? roles : String(roles ?? "").split(","))
48
74
  .map((role) => role.trim())
@@ -117,6 +143,8 @@ export function addDescriptorEntry(
117
143
  }
118
144
 
119
145
  codegenFs.write(kosJsonPath, JSON.stringify(kosJson, null, 2) + "\n");
146
+ const setup = descriptorMockSetup(kosJson);
147
+ codegenFs.write(setup.path, setup.content);
120
148
  return note;
121
149
  }
122
150
 
@@ -5,7 +5,7 @@ import fs from "node:fs";
5
5
  import path from "node:path";
6
6
  import { findProjectByName } from "@kosdev-code/kos-codegen-core";
7
7
  import { TEMPLATES_DIR } from "../handlers.mjs";
8
- import { DESCRIPTOR_KAB_TYPE } from "./descriptor.mjs";
8
+ import { DESCRIPTOR_KAB_TYPE, descriptorMockSetup } from "./descriptor.mjs";
9
9
  import { buildNcuiDescriptor } from "./ncui-descriptor.mjs";
10
10
 
11
11
  export const DDK_VERSION = "~3.1.0";
@@ -87,12 +87,16 @@ function overlayTheme(_workspaceRoot, projectRoot) {
87
87
  });
88
88
  }
89
89
 
90
- function overlayDescriptor(_workspaceRoot, projectRoot, { ncui } = {}) {
90
+ function overlayDescriptor(workspaceRoot, projectRoot, { ncui } = {}) {
91
91
  const kosJsonPath = path.join(projectRoot, ".kos.json");
92
92
  const kosJson = readJson(kosJsonPath);
93
93
  kosJson.type = DESCRIPTOR_KAB_TYPE;
94
94
  kosJson.kondra = buildNcuiDescriptor(ncui);
95
95
  writeJson(kosJsonPath, kosJson);
96
+ const setup = descriptorMockSetup(kosJson);
97
+ const setupPath = path.join(workspaceRoot, setup.path);
98
+ fs.mkdirSync(path.dirname(setupPath), { recursive: true });
99
+ fs.writeFileSync(setupPath, setup.content);
96
100
  }
97
101
 
98
102
  const PROJECT_KINDS = {
@@ -223,6 +227,8 @@ export function createDdkProject(
223
227
  `.kos.json: type ${DESCRIPTOR_KAB_TYPE}, kondra.ncui for the ${
224
228
  ncui.layout ?? "standard"
225
229
  } layout`,
230
+ descriptorMockSetup({ name }).path +
231
+ ": KosMock setup serving the descriptor",
226
232
  ]
227
233
  : templateFiles(kind),
228
234
  };