@kidd-cli/cli 0.1.0 → 0.1.1

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 CHANGED
@@ -1,11 +1,11 @@
1
- # kidd-cli
1
+ # @kidd-cli/cli
2
2
 
3
3
  DX companion CLI for the kidd framework.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- pnpm add -g kidd-cli
8
+ pnpm add -g @kidd-cli/cli
9
9
  ```
10
10
 
11
11
  ## Usage
@@ -1,5 +1,5 @@
1
1
  import { n as renderTemplate, t as writeFiles } from "../../write-DDGnajpV.mjs";
2
- import { t as detectProject } from "../../detect-DDE1hlQ8.mjs";
2
+ import { t as detectProject } from "../../detect-CSSt9GdX.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";
@@ -1,5 +1,5 @@
1
1
  import { n as renderTemplate, t as writeFiles } from "../../write-DDGnajpV.mjs";
2
- import { t as detectProject } from "../../detect-DDE1hlQ8.mjs";
2
+ import { t as detectProject } from "../../detect-CSSt9GdX.mjs";
3
3
  import { command } from "@kidd-cli/core";
4
4
  import { join } from "node:path";
5
5
  import { z } from "zod";
@@ -193,7 +193,7 @@ async function checkKiddDependency(context) {
193
193
  status: "pass"
194
194
  });
195
195
  return checkResult({
196
- hint: "Run \"pnpm add kidd\" or use --fix to add it (fixable with --fix)",
196
+ hint: "Run \"pnpm add @kidd-cli/core\" or use --fix to add it (fixable with --fix)",
197
197
  message: "Not found in dependencies or devDependencies",
198
198
  name: "@kidd-cli/core dependency",
199
199
  status: "fail"
@@ -1,7 +1,10 @@
1
1
  import { n as renderTemplate, t as writeFiles } from "../write-DDGnajpV.mjs";
2
+ import { createRequire } from "node:module";
2
3
  import { command } from "@kidd-cli/core";
3
- import { join } from "node:path";
4
+ import { dirname, join } from "node:path";
5
+ import { readManifest } from "@kidd-cli/utils/manifest";
4
6
  import { z } from "zod";
7
+ import { attempt } from "@kidd-cli/utils/fp";
5
8
 
6
9
  //#region src/commands/init.ts
7
10
  const KEBAB_CASE_CHARS_RE = /^[a-z][\da-z-]*$/;
@@ -23,9 +26,13 @@ const initCommand = command({
23
26
  const packageManager = await resolvePackageManager(ctx);
24
27
  const includeExample = await resolveIncludeExample(ctx);
25
28
  ctx.spinner.start("Scaffolding project...");
29
+ const coreVersion = await resolveDependencyVersion("@kidd-cli/core");
30
+ const cliVersion = await resolveSelfVersion();
26
31
  const [renderError, rendered] = await renderTemplate({
27
32
  templateDir: join(import.meta.dirname, "..", "lib", "templates", "project"),
28
33
  variables: {
34
+ cliVersion,
35
+ coreVersion,
29
36
  description: projectDescription,
30
37
  name: projectName,
31
38
  packageManager
@@ -162,6 +169,41 @@ function selectFiles(includeExample, rendered) {
162
169
  function excludeHelloCommand(file) {
163
170
  return !file.relativePath.includes("commands/hello.ts");
164
171
  }
172
+ const DEFAULT_VERSION = "0.0.0";
173
+ /**
174
+ * Resolve the version of the running CLI package.
175
+ *
176
+ * Reads the CLI's own `package.json` by navigating up from the current
177
+ * command file directory. Returns `'0.0.0'` when the manifest cannot be
178
+ * read or is missing a version field.
179
+ *
180
+ * @returns The CLI package version string, or `'0.0.0'` on failure.
181
+ * @private
182
+ */
183
+ async function resolveSelfVersion() {
184
+ const [error, manifest] = await readManifest(join(import.meta.dirname, "..", ".."));
185
+ if (error || !manifest.version) return DEFAULT_VERSION;
186
+ return manifest.version;
187
+ }
188
+ /**
189
+ * Resolve the installed version of a dependency package.
190
+ *
191
+ * Uses `createRequire` to locate the package entry point, derives the
192
+ * package root from the resolved path, and reads its `package.json`.
193
+ * Returns `'0.0.0'` when resolution fails for any reason.
194
+ *
195
+ * @param packageName - The npm package name to resolve (e.g. `'@kidd-cli/core'`).
196
+ * @returns The package version string, or `'0.0.0'` on failure.
197
+ * @private
198
+ */
199
+ async function resolveDependencyVersion(packageName) {
200
+ const require = createRequire(import.meta.url);
201
+ const [resolveError, entryPath] = attempt(() => require.resolve(packageName));
202
+ if (resolveError || entryPath === null) return DEFAULT_VERSION;
203
+ const [manifestError, manifest] = await readManifest(join(dirname(entryPath), ".."));
204
+ if (manifestError || !manifest.version) return DEFAULT_VERSION;
205
+ return manifest.version;
206
+ }
165
207
 
166
208
  //#endregion
167
209
  export { initCommand as default };
@@ -6,7 +6,7 @@ import { attemptAsync, ok, toErrorMessage } from "@kidd-cli/utils/fp";
6
6
  /**
7
7
  * Detect whether the given directory contains a kidd-based CLI project.
8
8
  *
9
- * Looks for a `package.json` with `kidd` listed in `dependencies` or
9
+ * Looks for a `package.json` with `@kidd-cli/core` listed in `dependencies` or
10
10
  * `devDependencies`, and checks for a `src/commands/` directory.
11
11
  *
12
12
  * @param cwd - The directory to inspect.
@@ -0,0 +1,6 @@
1
+ import { defineConfig } from '@kidd-cli/core'
2
+
3
+ export default defineConfig({
4
+ entry: './src/index.ts',
5
+ commands: './src/commands',
6
+ })
@@ -12,17 +12,17 @@
12
12
  ],
13
13
  "type": "module",
14
14
  "scripts": {
15
- "build": "tsdown",
15
+ "build": "kidd build",
16
16
  "typecheck": "tsc --noEmit",
17
17
  "test": "vitest run",
18
18
  "test:watch": "vitest"
19
19
  },
20
20
  "dependencies": {
21
- "@kidd-cli/core": "^0.0.0",
21
+ "@kidd-cli/core": "^{{ coreVersion }}",
22
22
  "zod": "^3.24.0"
23
23
  },
24
24
  "devDependencies": {
25
- "tsdown": "^0.21.0",
25
+ "@kidd-cli/cli": "^{{ cliVersion }}",
26
26
  "typescript": "^5.7.0",
27
27
  "vitest": "^4.0.0"
28
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kidd-cli/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "DX companion CLI for the kidd framework",
5
5
  "keywords": [
6
6
  "cli",
@@ -9,6 +9,11 @@
9
9
  "scaffolding"
10
10
  ],
11
11
  "license": "MIT",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/joggrdocs/kidd.git",
15
+ "directory": "packages/cli"
16
+ },
12
17
  "bin": {
13
18
  "kidd": "./dist/index.mjs"
14
19
  },
@@ -21,10 +26,10 @@
21
26
  "liquidjs": "^10.24.0",
22
27
  "picocolors": "^1.1.1",
23
28
  "zod": "^4.3.6",
24
- "@kidd-cli/bundler": "0.1.0",
25
- "@kidd-cli/core": "0.1.0",
26
- "@kidd-cli/utils": "0.1.0",
27
- "@kidd-cli/config": "0.1.0"
29
+ "@kidd-cli/bundler": "0.1.1",
30
+ "@kidd-cli/config": "0.1.1",
31
+ "@kidd-cli/core": "0.1.1",
32
+ "@kidd-cli/utils": "0.1.1"
28
33
  },
29
34
  "devDependencies": {
30
35
  "@types/fs-extra": "^11.0.4",
@@ -1,9 +0,0 @@
1
- import { defineConfig } from 'tsdown'
2
-
3
- export default defineConfig({
4
- clean: true,
5
- dts: true,
6
- entry: ['src/index.ts'],
7
- format: 'esm',
8
- outDir: 'dist',
9
- })