@kidd-cli/cli 0.1.3 → 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.
@@ -1,10 +1,9 @@
1
- import { n as isKebabCase, r as renderTemplate, t as writeFiles } from "../../write-dfZMTbtn.mjs";
2
- import { t as detectProject } from "../../detect-t9mL3oTg.mjs";
1
+ import { n as isKebabCase, r as renderTemplate, t as writeFiles } from "../../write-CdoqLFeH.mjs";
2
+ import { t as detectProject } from "../../detect-DcO0_CWy.mjs";
3
3
  import { command } from "@kidd-cli/core";
4
4
  import { join } from "node:path";
5
5
  import { loadConfig } from "@kidd-cli/config/loader";
6
6
  import { z } from "zod";
7
-
8
7
  //#region src/commands/add/command.ts
9
8
  const addCommandCommand = command({
10
9
  args: z.object({
@@ -117,6 +116,5 @@ function resolveCommandsDir(configResult, rootDir) {
117
116
  if (configResult) return join(rootDir, configResult.config.commands ?? DEFAULT_COMMANDS);
118
117
  return join(rootDir, DEFAULT_COMMANDS);
119
118
  }
120
-
121
119
  //#endregion
122
- export { addCommandCommand as default };
120
+ export { addCommandCommand as default };
@@ -1,7 +1,5 @@
1
1
  import { command } from "@kidd-cli/core";
2
-
3
2
  //#region src/commands/add/index.ts
4
3
  const addCommand = command({ description: "Add a command or middleware to your project" });
5
-
6
4
  //#endregion
7
- export { addCommand as default };
5
+ export { addCommand as default };
@@ -1,9 +1,8 @@
1
- import { n as isKebabCase, r as renderTemplate, t as writeFiles } from "../../write-dfZMTbtn.mjs";
2
- import { t as detectProject } from "../../detect-t9mL3oTg.mjs";
1
+ import { n as isKebabCase, r as renderTemplate, t as writeFiles } from "../../write-CdoqLFeH.mjs";
2
+ import { t as detectProject } from "../../detect-DcO0_CWy.mjs";
3
3
  import { command } from "@kidd-cli/core";
4
4
  import { join } from "node:path";
5
5
  import { z } from "zod";
6
-
7
6
  //#region src/commands/add/middleware.ts
8
7
  const addMiddlewareCommand = command({
9
8
  args: z.object({
@@ -82,6 +81,5 @@ async function resolveDescription(ctx) {
82
81
  placeholder: "What does this middleware do?"
83
82
  });
84
83
  }
85
-
86
84
  //#endregion
87
- export { addMiddlewareCommand as default };
85
+ export { addMiddlewareCommand as default };
@@ -1,10 +1,9 @@
1
- import { t as extractConfig } from "../config-helpers-QvhfBI9b.mjs";
1
+ import { t as extractConfig } from "../config-helpers-wZhBJJXJ.mjs";
2
2
  import { command } from "@kidd-cli/core";
3
3
  import { relative } from "node:path";
4
4
  import { build, compile, resolveTargetLabel } from "@kidd-cli/bundler";
5
5
  import { loadConfig } from "@kidd-cli/config/loader";
6
6
  import { z } from "zod";
7
-
8
7
  //#region src/commands/build.ts
9
8
  /**
10
9
  * Build a kidd CLI project for production using tsdown.
@@ -42,7 +41,8 @@ const buildCommand = command({
42
41
  ctx.logger.note(formatBuildNote({
43
42
  cwd,
44
43
  entryFile: buildOutput.entryFile,
45
- outDir: buildOutput.outDir
44
+ outDir: buildOutput.outDir,
45
+ version: buildOutput.version
46
46
  }), "Bundle");
47
47
  return;
48
48
  }
@@ -64,7 +64,8 @@ const buildCommand = command({
64
64
  ctx.logger.note(formatBuildNote({
65
65
  cwd,
66
66
  entryFile: buildOutput.entryFile,
67
- outDir: buildOutput.outDir
67
+ outDir: buildOutput.outDir,
68
+ version: buildOutput.version
68
69
  }), "Bundle");
69
70
  ctx.logger.note(formatBinariesNote({
70
71
  binaries: compileOutput.binaries,
@@ -134,7 +135,22 @@ function resolveExistingCompile(value) {
134
135
  * @returns A formatted string with entry and output directory.
135
136
  */
136
137
  function formatBuildNote(params) {
137
- return [`entry ${relative(params.cwd, params.entryFile)}`, `output ${relative(params.cwd, params.outDir)}`].join("\n");
138
+ return [
139
+ `entry ${relative(params.cwd, params.entryFile)}`,
140
+ `output ${relative(params.cwd, params.outDir)}`,
141
+ ...formatVersionLine(params.version)
142
+ ].join("\n");
143
+ }
144
+ /**
145
+ * Format a version line for the build note, if a version is available.
146
+ *
147
+ * @private
148
+ * @param version - The version string, or undefined.
149
+ * @returns A single-element array with the formatted line, or an empty array.
150
+ */
151
+ function formatVersionLine(version) {
152
+ if (!version) return [];
153
+ return [`version ${version}`];
138
154
  }
139
155
  /**
140
156
  * Format compiled binaries into an aligned, multi-line string for display.
@@ -147,6 +163,5 @@ function formatBinariesNote(params) {
147
163
  const maxLen = Math.max(...params.binaries.map((b) => b.label.length));
148
164
  return params.binaries.map((binary) => `${binary.label.padEnd(maxLen)} ${relative(params.cwd, binary.path)}`).join("\n");
149
165
  }
150
-
151
166
  //#endregion
152
- export { buildCommand as default };
167
+ export { buildCommand as default };
@@ -1,9 +1,8 @@
1
- import { t as extractConfig } from "../config-helpers-QvhfBI9b.mjs";
1
+ import { t as extractConfig } from "../config-helpers-wZhBJJXJ.mjs";
2
2
  import { autoload, command } from "@kidd-cli/core";
3
3
  import { join } from "node:path";
4
4
  import { loadConfig } from "@kidd-cli/config/loader";
5
5
  import { existsSync } from "node:fs";
6
-
7
6
  //#region src/commands/commands.ts
8
7
  /**
9
8
  * Display the command tree for a kidd CLI project.
@@ -44,21 +43,79 @@ async function resolveSubcommands(commands) {
44
43
  /**
45
44
  * Recursively build a sorted tree of entries from a CommandMap.
46
45
  *
46
+ * Commands listed in the order array appear first in the specified order;
47
+ * omitted commands fall back to alphabetical sort.
48
+ *
47
49
  * @private
48
50
  * @param commandMap - The map of command names to Command objects.
51
+ * @param order - Optional array of command names defining display order.
49
52
  * @returns A sorted array of TreeEntry nodes.
50
53
  */
51
- async function buildTree(commandMap) {
52
- const entries = Object.entries(commandMap).toSorted(([a], [b]) => a.localeCompare(b));
54
+ async function buildTree(commandMap, order) {
55
+ const entries = sortEntries({
56
+ entries: Object.entries(commandMap),
57
+ order
58
+ });
53
59
  return Promise.all(entries.map(async ([name, cmd]) => {
54
60
  return {
55
- children: await buildTree(await resolveSubcommands(cmd.commands)),
61
+ children: await buildTree(await resolveSubcommands(cmd.commands), cmd.order),
56
62
  description: cmd.description ?? "",
57
63
  name
58
64
  };
59
65
  }));
60
66
  }
61
67
  /**
68
+ * Sort command entries with ordered names first (in specified order),
69
+ * remaining names alphabetically.
70
+ *
71
+ * Validates the order array against available command names and logs a
72
+ * warning for unknown or duplicate entries rather than failing silently.
73
+ *
74
+ * @private
75
+ * @param params - The command entries and optional order array.
76
+ * @returns Sorted array of entries.
77
+ */
78
+ function sortEntries(params) {
79
+ const { entries, order } = params;
80
+ if (!order || order.length === 0) return entries.toSorted(([a], [b]) => a.localeCompare(b));
81
+ const validOrder = validateOrder({
82
+ commandNames: entries.map(([name]) => name),
83
+ order
84
+ });
85
+ const entryMap = new Map(entries);
86
+ const orderedSet = new Set(validOrder);
87
+ const ordered = validOrder.filter((name) => entryMap.has(name)).map((name) => [name, entryMap.get(name)]);
88
+ const remaining = entries.filter(([name]) => !orderedSet.has(name)).toSorted(([a], [b]) => a.localeCompare(b));
89
+ return [...ordered, ...remaining];
90
+ }
91
+ /**
92
+ * Validate the order array by filtering out unknown and duplicate names.
93
+ *
94
+ * Logs warnings for invalid entries so developers see the mismatch
95
+ * during `kidd commands` introspection, matching the runtime behaviour.
96
+ *
97
+ * @private
98
+ * @param params - The order array and available command names.
99
+ * @returns A deduplicated array of valid order names.
100
+ */
101
+ function validateOrder(params) {
102
+ const { commandNames, order } = params;
103
+ const nameSet = new Set(commandNames);
104
+ const seen = /* @__PURE__ */ new Set();
105
+ return order.filter((name) => {
106
+ if (seen.has(name)) {
107
+ console.warn(`Warning: duplicate command name "${name}" in order array`);
108
+ return false;
109
+ }
110
+ seen.add(name);
111
+ if (!nameSet.has(name)) {
112
+ console.warn(`Warning: unknown command "${name}" in order array`);
113
+ return false;
114
+ }
115
+ return true;
116
+ });
117
+ }
118
+ /**
62
119
  * Render a tree of entries into an ASCII tree string.
63
120
  *
64
121
  * @private
@@ -118,6 +175,5 @@ function formatLabel(name, description) {
118
175
  if (description) return `${name} — ${description}`;
119
176
  return name;
120
177
  }
121
-
122
178
  //#endregion
123
- export { commandsCommand as default };
179
+ export { commandsCommand as default };
@@ -1,8 +1,7 @@
1
- import { t as extractConfig } from "../config-helpers-QvhfBI9b.mjs";
1
+ import { t as extractConfig } from "../config-helpers-wZhBJJXJ.mjs";
2
2
  import { command } from "@kidd-cli/core";
3
3
  import { watch } from "@kidd-cli/bundler";
4
4
  import { loadConfig } from "@kidd-cli/config/loader";
5
-
6
5
  //#region src/commands/dev.ts
7
6
  /**
8
7
  * Start a kidd CLI project in development mode with file watching.
@@ -52,6 +51,5 @@ function createOnSuccess(ctx) {
52
51
  ctx.logger.success("Rebuilt successfully");
53
52
  };
54
53
  }
55
-
56
54
  //#endregion
57
- export { devCommand as default };
55
+ export { devCommand as default };
@@ -3,12 +3,11 @@ import { dirname, join, relative } from "node:path";
3
3
  import { readManifest } from "@kidd-cli/utils/manifest";
4
4
  import { loadConfig } from "@kidd-cli/config/loader";
5
5
  import { z } from "zod";
6
+ import { attemptAsync, err, match, ok } from "@kidd-cli/utils/fp";
6
7
  import pc from "picocolors";
7
8
  import { mkdir, readFile, writeFile } from "node:fs/promises";
8
- import { attemptAsync, err, ok } from "@kidd-cli/utils/fp";
9
9
  import { fileExists } from "@kidd-cli/utils/fs";
10
10
  import { jsonParse, jsonStringify } from "@kidd-cli/utils/json";
11
-
12
11
  //#region src/lib/checks.ts
13
12
  /**
14
13
  * Default entry point for the CLI source.
@@ -493,7 +492,6 @@ async function updatePackageJson(cwd, transform) {
493
492
  if (writeError) return err(`Failed to write package.json: ${writeError.message}`);
494
493
  return ok();
495
494
  }
496
-
497
495
  //#endregion
498
496
  //#region src/commands/doctor.ts
499
497
  /**
@@ -636,10 +634,7 @@ function formatResultLine(result, fixResults) {
636
634
  * @returns A colored string representation of the status.
637
635
  */
638
636
  function formatDisplayStatus(status) {
639
- if (status === "pass") return pc.green("pass");
640
- if (status === "warn") return pc.yellow("warn");
641
- if (status === "fix") return pc.blue("fix ");
642
- return pc.red("fail");
637
+ return match(status).with("pass", () => pc.green("pass")).with("warn", () => pc.yellow("warn")).with("fix", () => pc.blue("fix ")).with("fail", () => pc.red("fail")).exhaustive();
643
638
  }
644
639
  /**
645
640
  * Format the summary line with counts.
@@ -664,6 +659,5 @@ function pluralizeCheck(count) {
664
659
  if (count === 1) return "check";
665
660
  return "checks";
666
661
  }
667
-
668
662
  //#endregion
669
- export { doctorCommand as default };
663
+ export { doctorCommand as default };
@@ -1,11 +1,28 @@
1
- import { n as isKebabCase, r as renderTemplate, t as writeFiles } from "../write-dfZMTbtn.mjs";
1
+ import { n as isKebabCase, r as renderTemplate, t as writeFiles } from "../write-CdoqLFeH.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { command } from "@kidd-cli/core";
4
4
  import { dirname, join } from "node:path";
5
5
  import { readManifest } from "@kidd-cli/utils/manifest";
6
6
  import { z } from "zod";
7
7
  import { attempt } from "@kidd-cli/utils/fp";
8
-
8
+ //#region src/generated/template-versions.ts
9
+ /**
10
+ * Zod version from the workspace catalog.
11
+ */
12
+ const ZOD_VERSION = "^4.3.6";
13
+ /**
14
+ * TypeScript version from the workspace catalog.
15
+ */
16
+ const TYPESCRIPT_VERSION = "^5.9.3";
17
+ /**
18
+ * Vitest version from the workspace catalog.
19
+ */
20
+ const VITEST_VERSION = "^4.0.18";
21
+ /**
22
+ * Tsdown version from the workspace catalog.
23
+ */
24
+ const TSDOWN_VERSION = "^0.21.1";
25
+ //#endregion
9
26
  //#region src/commands/init.ts
10
27
  const initCommand = command({
11
28
  args: z.object({
@@ -34,7 +51,11 @@ const initCommand = command({
34
51
  coreVersion,
35
52
  description: projectDescription,
36
53
  name: projectName,
37
- packageManager
54
+ packageManager,
55
+ tsdownVersion: TSDOWN_VERSION,
56
+ typescriptVersion: TYPESCRIPT_VERSION,
57
+ vitestVersion: VITEST_VERSION,
58
+ zodVersion: ZOD_VERSION
38
59
  }
39
60
  });
40
61
  if (renderError) {
@@ -190,6 +211,5 @@ async function resolveDependencyVersion(packageName) {
190
211
  if (manifestError || !manifest.version) return DEFAULT_VERSION;
191
212
  return manifest.version;
192
213
  }
193
-
194
214
  //#endregion
195
- export { initCommand as default };
215
+ export { initCommand as default };
@@ -9,6 +9,5 @@ function extractConfig(result) {
9
9
  if (result) return result.config;
10
10
  return {};
11
11
  }
12
-
13
12
  //#endregion
14
- export { extractConfig as t };
13
+ export { extractConfig as t };
@@ -1,8 +1,7 @@
1
1
  import { join } from "node:path";
2
- import { readFile } from "node:fs/promises";
3
2
  import { attemptAsync, ok, toErrorMessage } from "@kidd-cli/utils/fp";
3
+ import { readFile } from "node:fs/promises";
4
4
  import { fileExists } from "@kidd-cli/utils/fs";
5
-
6
5
  //#region src/lib/detect.ts
7
6
  /**
8
7
  * Detect whether the given directory contains a kidd-based CLI project.
@@ -58,6 +57,5 @@ async function readPackageJson(filePath) {
58
57
  }, null];
59
58
  }
60
59
  }
61
-
62
60
  //#endregion
63
- export { detectProject as t };
61
+ export { detectProject as t };
package/dist/index.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  import { cli } from "@kidd-cli/core";
2
2
  import { join } from "node:path";
3
3
  import { readManifest } from "@kidd-cli/utils/manifest";
4
-
5
4
  //#region src/manifest.ts
6
5
  /**
7
6
  * Read and validate the CLI package manifest.
@@ -26,16 +25,15 @@ async function loadCLIManifest(baseDir) {
26
25
  version: manifest.version
27
26
  };
28
27
  }
29
-
30
28
  //#endregion
31
29
  //#region src/index.ts
32
30
  const manifest = await loadCLIManifest(import.meta.dirname);
33
31
  await cli({
34
32
  commands: `${import.meta.dirname}/commands`,
35
33
  description: manifest.description,
34
+ help: { header: `${manifest.name} v${manifest.version}` },
36
35
  name: manifest.name,
37
36
  version: manifest.version
38
37
  });
39
-
40
38
  //#endregion
41
- export { };
39
+ export {};
@@ -5,7 +5,7 @@
5
5
  "keywords": [],
6
6
  "license": "MIT",
7
7
  "bin": {
8
- "{{ name }}": "./dist/index.js"
8
+ "{{ name }}": "./dist/index.mjs"
9
9
  },
10
10
  "files": [
11
11
  "dist"
@@ -19,11 +19,12 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@kidd-cli/core": "^{{ coreVersion }}",
22
- "zod": "^3.24.0"
22
+ "zod": "{{ zodVersion }}"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@kidd-cli/cli": "^{{ cliVersion }}",
26
- "typescript": "^5.7.0",
27
- "vitest": "^4.0.0"
26
+ "tsdown": "{{ tsdownVersion }}",
27
+ "typescript": "{{ typescriptVersion }}",
28
+ "vitest": "{{ vitestVersion }}"
28
29
  }
29
30
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "ES2022",
3
+ "target": "ES2024",
4
4
  "module": "ESNext",
5
5
  "moduleResolution": "bundler",
6
6
  "strict": true,
@@ -1,9 +1,8 @@
1
1
  import { dirname, join, relative } from "node:path";
2
- import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
3
2
  import { ok, toErrorMessage } from "@kidd-cli/utils/fp";
3
+ import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
4
4
  import { fileExists } from "@kidd-cli/utils/fs";
5
5
  import { Liquid } from "liquidjs";
6
-
7
6
  //#region src/lib/render.ts
8
7
  /**
9
8
  * Render all `.liquid` templates in a directory using LiquidJS.
@@ -92,7 +91,6 @@ function isGenerateError(value) {
92
91
  if (typeof value !== "object" || value === null) return false;
93
92
  return "type" in value && "message" in value;
94
93
  }
95
-
96
94
  //#endregion
97
95
  //#region src/lib/validate.ts
98
96
  const KEBAB_CASE_CHARS_RE = /^[a-z][\da-z-]*$/;
@@ -108,7 +106,6 @@ function isKebabCase(value) {
108
106
  if (value.includes("--")) return false;
109
107
  return true;
110
108
  }
111
-
112
109
  //#endregion
113
110
  //#region src/lib/write.ts
114
111
  /**
@@ -162,6 +159,5 @@ async function writeSingleFile(file, outputDir, overwrite) {
162
159
  }, null];
163
160
  }
164
161
  }
165
-
166
162
  //#endregion
167
- export { isKebabCase as n, renderTemplate as r, writeFiles as t };
163
+ export { isKebabCase as n, renderTemplate as r, writeFiles as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kidd-cli/cli",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "DX companion CLI for the kidd framework",
5
5
  "keywords": [
6
6
  "cli",
@@ -22,20 +22,21 @@
22
22
  ],
23
23
  "type": "module",
24
24
  "dependencies": {
25
- "fs-extra": "^11.3.3",
25
+ "fs-extra": "^11.3.4",
26
26
  "liquidjs": "^10.25.0",
27
27
  "picocolors": "^1.1.1",
28
28
  "zod": "^4.3.6",
29
- "@kidd-cli/bundler": "0.1.2",
30
- "@kidd-cli/config": "0.1.2",
31
- "@kidd-cli/core": "0.2.0",
32
- "@kidd-cli/utils": "0.1.2"
29
+ "@kidd-cli/bundler": "0.2.0",
30
+ "@kidd-cli/config": "0.1.4",
31
+ "@kidd-cli/core": "0.4.0",
32
+ "@kidd-cli/utils": "0.1.4"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/fs-extra": "^11.0.4",
36
- "tsdown": "0.21.0-beta.2",
36
+ "tsdown": "0.21.1",
37
37
  "typescript": "^5.9.3",
38
- "vitest": "^4.0.18"
38
+ "vitest": "^4.0.18",
39
+ "yaml": "^2.8.0"
39
40
  },
40
41
  "scripts": {
41
42
  "build": "tsdown && mkdir -p dist/lib && cp -r src/lib/templates dist/lib/templates",