@saltify/milky-generator 0.1.1 → 0.2.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.
Files changed (3) hide show
  1. package/README.md +54 -0
  2. package/dist/cli.mjs +20 -6
  3. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # @saltify/milky-generator
2
+
3
+ Milky 代码生成 CLI,用于基于 Milky IR 生成不同目标格式的规范文件。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install -g @saltify/milky-generator
9
+ ```
10
+
11
+ 安装后可直接使用命令:
12
+
13
+ ```bash
14
+ milkygen
15
+ ```
16
+
17
+ ## 命令
18
+
19
+ ### 查看可用 generator
20
+
21
+ ```
22
+ milkygen list
23
+ ```
24
+
25
+ ### 生成内容
26
+
27
+ ```
28
+ milkygen generate <generator> [--output <file>] [--version <version>]
29
+ ```
30
+
31
+ 示例:
32
+
33
+ ```bash
34
+ milkygen generate openapi
35
+ milkygen generate json-schema -o ./dist/schema.json
36
+ milkygen generate typescript/zod -version latest --output ./generated/schema.ts
37
+ milkygen generate rust/serde --version 1.2.1
38
+ ```
39
+
40
+ 参数说明:
41
+
42
+ - `--output`, `-o`: 输出文件路径;若未提供,输出到标准输出。
43
+ - `--version`, `-v`: 指定使用的 Milky IR 版本,支持以下值:
44
+ - `latest`: 默认值,使用 npm `latest` 标签对应版本的协议定义。
45
+ - 具体版本号: **只能使用 `1.2.1` 及以上版本**,因为协议定义在 `1.2.1` 版本中才正式发布。
46
+ - `local`: 使用当前包依赖中的本地协议定义。不建议使用,因为可能与发布版本不一致。
47
+
48
+ ### 查看 CLI 版本
49
+
50
+ ```
51
+ milkygen version
52
+ ```
53
+
54
+ 注意这里的 version 是指 milkygen CLI 的版本,而不是 Milky IR 协议的版本。Milky IR 协议版本需要通过 `--version` 参数指定,具体说明见上文。
package/dist/cli.mjs CHANGED
@@ -885,7 +885,7 @@ const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (i
885
885
  });
886
886
  //#endregion
887
887
  //#region ../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.js
888
- const version$1 = {
888
+ const version$2 = {
889
889
  major: 4,
890
890
  minor: 3,
891
891
  patch: 6
@@ -897,7 +897,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
897
897
  inst ?? (inst = {});
898
898
  inst._zod.def = def;
899
899
  inst._zod.bag = inst._zod.bag || {};
900
- inst._zod.version = version$1;
900
+ inst._zod.version = version$2;
901
901
  const checks = [...inst._zod.def.checks ?? []];
902
902
  if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
903
903
  for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
@@ -25679,12 +25679,12 @@ const apiCategories = [
25679
25679
  ];
25680
25680
  //#endregion
25681
25681
  //#region ../protocol/package.json
25682
- var version = "1.2.1-rc.2";
25682
+ var version$1 = "1.2.1-rc.2";
25683
25683
  //#endregion
25684
25684
  //#region ../protocol/src/index.ts
25685
25685
  const ir = {
25686
- milkyVersion: version.split(".").slice(0, 2).join("."),
25687
- milkyPackageVersion: version,
25686
+ milkyVersion: version$1.split(".").slice(0, 2).join("."),
25687
+ milkyPackageVersion: version$1,
25688
25688
  commonStructs,
25689
25689
  apiCategories
25690
25690
  };
@@ -29284,7 +29284,7 @@ var require_rest = /* @__PURE__ */ __commonJSMin(((exports) => {
29284
29284
  }
29285
29285
  }));
29286
29286
  //#endregion
29287
- //#region src/cli.ts
29287
+ //#region package.json
29288
29288
  var import_cjs = (/* @__PURE__ */ __commonJSMin(((exports) => {
29289
29289
  /**
29290
29290
  * The index module: the entrance to the world of cmd-ts 😎
@@ -29447,6 +29447,10 @@ var import_cjs = (/* @__PURE__ */ __commonJSMin(((exports) => {
29447
29447
  }
29448
29448
  });
29449
29449
  })))();
29450
+ var version = "0.2.0";
29451
+ var description = "Milky codegen CLI";
29452
+ //#endregion
29453
+ //#region src/cli.ts
29450
29454
  const generators = [
29451
29455
  {
29452
29456
  canonicalName: "dart/json-serializable",
@@ -29496,9 +29500,11 @@ function serializeOutput(output) {
29496
29500
  }
29497
29501
  (0, import_cjs.run)((0, import_cjs.subcommands)({
29498
29502
  name: "milkygen",
29503
+ description,
29499
29504
  cmds: {
29500
29505
  generate: (0, import_cjs.command)({
29501
29506
  name: "generate",
29507
+ description: "Generate a spec from Milky IR.",
29502
29508
  args: {
29503
29509
  generator: (0, import_cjs.positional)({
29504
29510
  type: import_cjs.string,
@@ -29551,6 +29557,14 @@ function serializeOutput(output) {
29551
29557
  console.log(` - ${gen.canonicalName}`);
29552
29558
  });
29553
29559
  }
29560
+ }),
29561
+ version: (0, import_cjs.command)({
29562
+ name: "version",
29563
+ description: "Print the version of milkygen.",
29564
+ args: {},
29565
+ handler: () => {
29566
+ console.log(version);
29567
+ }
29554
29568
  })
29555
29569
  }
29556
29570
  }), process.argv.slice(2));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@saltify/milky-generator",
3
3
  "type": "module",
4
- "version": "0.1.1",
4
+ "version": "0.2.0",
5
5
  "description": "Milky codegen CLI",
6
6
  "bin": {
7
7
  "milkygen": "dist/cli.mjs"