@kidd-cli/core 0.1.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 (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +214 -0
  3. package/dist/config-BvGapuFJ.js +282 -0
  4. package/dist/config-BvGapuFJ.js.map +1 -0
  5. package/dist/create-store-BQUX0tAn.js +197 -0
  6. package/dist/create-store-BQUX0tAn.js.map +1 -0
  7. package/dist/index.d.ts +73 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +1034 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/lib/config.d.ts +64 -0
  12. package/dist/lib/config.d.ts.map +1 -0
  13. package/dist/lib/config.js +4 -0
  14. package/dist/lib/logger.d.ts +2 -0
  15. package/dist/lib/logger.js +55 -0
  16. package/dist/lib/logger.js.map +1 -0
  17. package/dist/lib/output.d.ts +62 -0
  18. package/dist/lib/output.d.ts.map +1 -0
  19. package/dist/lib/output.js +276 -0
  20. package/dist/lib/output.js.map +1 -0
  21. package/dist/lib/project.d.ts +59 -0
  22. package/dist/lib/project.d.ts.map +1 -0
  23. package/dist/lib/project.js +3 -0
  24. package/dist/lib/prompts.d.ts +24 -0
  25. package/dist/lib/prompts.d.ts.map +1 -0
  26. package/dist/lib/prompts.js +3 -0
  27. package/dist/lib/store.d.ts +56 -0
  28. package/dist/lib/store.d.ts.map +1 -0
  29. package/dist/lib/store.js +4 -0
  30. package/dist/logger-BkQQej8h.d.ts +76 -0
  31. package/dist/logger-BkQQej8h.d.ts.map +1 -0
  32. package/dist/middleware/auth.d.ts +22 -0
  33. package/dist/middleware/auth.d.ts.map +1 -0
  34. package/dist/middleware/auth.js +759 -0
  35. package/dist/middleware/auth.js.map +1 -0
  36. package/dist/middleware/http.d.ts +87 -0
  37. package/dist/middleware/http.d.ts.map +1 -0
  38. package/dist/middleware/http.js +255 -0
  39. package/dist/middleware/http.js.map +1 -0
  40. package/dist/middleware-D3psyhYo.js +54 -0
  41. package/dist/middleware-D3psyhYo.js.map +1 -0
  42. package/dist/project-NPtYX2ZX.js +181 -0
  43. package/dist/project-NPtYX2ZX.js.map +1 -0
  44. package/dist/prompts-lLfUSgd6.js +63 -0
  45. package/dist/prompts-lLfUSgd6.js.map +1 -0
  46. package/dist/types-CqKJhsYk.d.ts +135 -0
  47. package/dist/types-CqKJhsYk.d.ts.map +1 -0
  48. package/dist/types-Cz9h927W.d.ts +23 -0
  49. package/dist/types-Cz9h927W.d.ts.map +1 -0
  50. package/dist/types-DFtYg5uZ.d.ts +26 -0
  51. package/dist/types-DFtYg5uZ.d.ts.map +1 -0
  52. package/dist/types-kjpRau0U.d.ts +382 -0
  53. package/dist/types-kjpRau0U.d.ts.map +1 -0
  54. package/package.json +94 -0
@@ -0,0 +1,197 @@
1
+ import { n as resolveLocalPath, t as resolveGlobalPath } from "./project-NPtYX2ZX.js";
2
+ import { join } from "node:path";
3
+ import { attempt, err, match, ok } from "@kidd-cli/utils/fp";
4
+ import { jsonParse, jsonStringify } from "@kidd-cli/utils/json";
5
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
+
7
+ //#region src/lib/store/create-store.ts
8
+ /**
9
+ * Create a file-backed {@link FileStore} that resolves JSON files from project-local
10
+ * or global home directories.
11
+ *
12
+ * @param options - Store configuration.
13
+ * @returns A FileStore instance.
14
+ */
15
+ function createStore(options) {
16
+ const { dirName, defaults } = options;
17
+ /**
18
+ * Resolve the local project directory for the store.
19
+ *
20
+ * @private
21
+ * @param startDir - Optional directory to start searching from.
22
+ * @returns The local directory path, or null if no project root is found.
23
+ */
24
+ function getLocalDir(startDir) {
25
+ return resolveLocalPath({
26
+ dirName,
27
+ startDir
28
+ });
29
+ }
30
+ /**
31
+ * Resolve the global home directory for the store.
32
+ *
33
+ * @private
34
+ * @returns The global directory path.
35
+ */
36
+ function getGlobalDir() {
37
+ return resolveGlobalPath({ dirName });
38
+ }
39
+ /**
40
+ * Read the raw string content from a file path.
41
+ *
42
+ * @private
43
+ * @param filePath - The file path to read.
44
+ * @returns The file content, or null if the file does not exist or cannot be read.
45
+ */
46
+ function loadFromPath(filePath) {
47
+ if (!existsSync(filePath)) return null;
48
+ const [error, content] = attempt(() => readFileSync(filePath, "utf8"));
49
+ if (error) return null;
50
+ return content;
51
+ }
52
+ /**
53
+ * Resolve a file from local or global directories based on the source strategy.
54
+ *
55
+ * @private
56
+ * @param resolveOptions - Resolution options.
57
+ * @returns The resolved result, or null if not found.
58
+ */
59
+ function resolveFromSource(resolveOptions) {
60
+ return match(resolveOptions.source).with("local", () => {
61
+ if (!resolveOptions.localDir) return null;
62
+ return resolveOptions.handler(join(resolveOptions.localDir, resolveOptions.filename));
63
+ }).with("global", () => resolveOptions.handler(join(resolveOptions.globalDir, resolveOptions.filename))).with("resolve", () => {
64
+ if (resolveOptions.localDir) {
65
+ const localResult = resolveOptions.handler(join(resolveOptions.localDir, resolveOptions.filename));
66
+ if (localResult !== null) return localResult;
67
+ }
68
+ return resolveOptions.handler(join(resolveOptions.globalDir, resolveOptions.filename));
69
+ }).exhaustive();
70
+ }
71
+ /**
72
+ * Load the raw string content of a store file.
73
+ *
74
+ * @private
75
+ * @param filename - The filename to load.
76
+ * @param loadOptions - Options controlling source resolution.
77
+ * @returns The raw file content, or null if not found.
78
+ */
79
+ function loadRaw(filename, loadOptions = {}) {
80
+ const { source: loadSource = "resolve", startDir } = loadOptions;
81
+ const localDir = getLocalDir(startDir);
82
+ return resolveFromSource({
83
+ filename,
84
+ globalDir: getGlobalDir(),
85
+ handler: loadFromPath,
86
+ localDir,
87
+ source: loadSource
88
+ });
89
+ }
90
+ /**
91
+ * Load and parse a store file as JSON, merging with defaults if available.
92
+ *
93
+ * @private
94
+ * @param filename - The filename to load.
95
+ * @param loadOptions - Options controlling source resolution.
96
+ * @returns The parsed data, defaults, or null.
97
+ */
98
+ function load(filename, loadOptions = {}) {
99
+ const raw = loadRaw(filename, loadOptions);
100
+ if (raw === null) return defaults ?? null;
101
+ const [parseError, parsed] = jsonParse(raw);
102
+ if (parseError) return defaults ?? null;
103
+ if (defaults) return {
104
+ ...defaults,
105
+ ...parsed
106
+ };
107
+ return parsed;
108
+ }
109
+ /**
110
+ * Check if a file exists at the given path and return the path if so.
111
+ *
112
+ * @private
113
+ * @param filePath - The file path to check.
114
+ * @returns The file path if it exists, or null.
115
+ */
116
+ function checkFileExists(filePath) {
117
+ if (existsSync(filePath)) return filePath;
118
+ return null;
119
+ }
120
+ /**
121
+ * Resolve the file path for a store file without reading its content.
122
+ *
123
+ * @private
124
+ * @param filename - The filename to resolve.
125
+ * @param loadOptions - Options controlling source resolution.
126
+ * @returns The resolved file path, or null if not found.
127
+ */
128
+ function getFilePath(filename, loadOptions = {}) {
129
+ const { source: fileSource = "resolve", startDir } = loadOptions;
130
+ const localDir = getLocalDir(startDir);
131
+ return resolveFromSource({
132
+ filename,
133
+ globalDir: getGlobalDir(),
134
+ handler: checkFileExists,
135
+ localDir,
136
+ source: fileSource
137
+ });
138
+ }
139
+ /**
140
+ * Serialize data to JSON and write it to a store file.
141
+ *
142
+ * Creates the target directory if it does not exist. Defaults to
143
+ * the global home directory when no source is specified.
144
+ *
145
+ * @private
146
+ * @param filename - The filename to write.
147
+ * @param data - The data to serialize.
148
+ * @param saveOptions - Options controlling the write target.
149
+ * @returns A Result with the written file path on success.
150
+ */
151
+ function save(filename, data, saveOptions = {}) {
152
+ const { source: saveSource = "global", startDir } = saveOptions;
153
+ const dir = resolveSaveDir({
154
+ globalDir: getGlobalDir(),
155
+ localDir: getLocalDir(startDir),
156
+ source: saveSource
157
+ });
158
+ if (dir === null) return err(/* @__PURE__ */ new Error(`Cannot save to "${saveSource}" — no local project directory found`));
159
+ const [stringifyError, json] = jsonStringify(data, { pretty: true });
160
+ if (stringifyError) return err(stringifyError);
161
+ const filePath = join(dir, filename);
162
+ const [writeError] = attempt(() => {
163
+ mkdirSync(dir, {
164
+ mode: 448,
165
+ recursive: true
166
+ });
167
+ writeFileSync(filePath, json, {
168
+ encoding: "utf8",
169
+ mode: 384
170
+ });
171
+ });
172
+ if (writeError) return err(writeError);
173
+ return ok(filePath);
174
+ }
175
+ return {
176
+ getFilePath,
177
+ getGlobalDir,
178
+ getLocalDir,
179
+ load,
180
+ loadRaw,
181
+ save
182
+ };
183
+ }
184
+ /**
185
+ * Resolve the target directory for a save operation.
186
+ *
187
+ * @private
188
+ * @param options - Resolution options.
189
+ * @returns The directory path, or null when `local` is requested but unavailable.
190
+ */
191
+ function resolveSaveDir(options) {
192
+ return match(options.source).with("local", () => options.localDir).with("global", () => options.globalDir).exhaustive();
193
+ }
194
+
195
+ //#endregion
196
+ export { createStore as t };
197
+ //# sourceMappingURL=create-store-BQUX0tAn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-store-BQUX0tAn.js","names":[],"sources":["../src/lib/store/create-store.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport { attempt, err, match, ok } from '@kidd-cli/utils/fp'\nimport type { Result } from '@kidd-cli/utils/fp'\nimport { jsonParse, jsonStringify } from '@kidd-cli/utils/json'\n\nimport { resolveGlobalPath, resolveLocalPath } from '@/lib/project/index.js'\nimport type { PathSource } from '@/lib/project/types.js'\n\nimport type { FileStore, LoadOptions, SaveOptions, StoreOptions } from './types.js'\n\n/**\n * Create a file-backed {@link FileStore} that resolves JSON files from project-local\n * or global home directories.\n *\n * @param options - Store configuration.\n * @returns A FileStore instance.\n */\nexport function createStore<TData = unknown>(options: StoreOptions<TData>): FileStore<TData> {\n const { dirName, defaults } = options\n\n /**\n * Resolve the local project directory for the store.\n *\n * @private\n * @param startDir - Optional directory to start searching from.\n * @returns The local directory path, or null if no project root is found.\n */\n function getLocalDir(startDir?: string): string | null {\n return resolveLocalPath({ dirName, startDir })\n }\n\n /**\n * Resolve the global home directory for the store.\n *\n * @private\n * @returns The global directory path.\n */\n function getGlobalDir(): string {\n return resolveGlobalPath({ dirName })\n }\n\n /**\n * Read the raw string content from a file path.\n *\n * @private\n * @param filePath - The file path to read.\n * @returns The file content, or null if the file does not exist or cannot be read.\n */\n function loadFromPath(filePath: string): string | null {\n if (!existsSync(filePath)) {\n return null\n }\n const [error, content] = attempt(() => readFileSync(filePath, 'utf8'))\n if (error) {\n return null\n }\n return content\n }\n\n /**\n * Resolve a file from local or global directories based on the source strategy.\n *\n * @private\n * @param resolveOptions - Resolution options.\n * @returns The resolved result, or null if not found.\n */\n function resolveFromSource<T>(resolveOptions: {\n source: PathSource\n localDir: string | null\n globalDir: string\n filename: string\n handler: (filePath: string) => T | null\n }): T | null {\n return match(resolveOptions.source)\n .with('local', (): T | null => {\n if (!resolveOptions.localDir) {\n return null\n }\n return resolveOptions.handler(join(resolveOptions.localDir, resolveOptions.filename))\n })\n .with('global', () =>\n resolveOptions.handler(join(resolveOptions.globalDir, resolveOptions.filename))\n )\n .with('resolve', (): T | null => {\n if (resolveOptions.localDir) {\n const localResult = resolveOptions.handler(\n join(resolveOptions.localDir, resolveOptions.filename)\n )\n if (localResult !== null) {\n return localResult\n }\n }\n return resolveOptions.handler(join(resolveOptions.globalDir, resolveOptions.filename))\n })\n .exhaustive()\n }\n\n /**\n * Load the raw string content of a store file.\n *\n * @private\n * @param filename - The filename to load.\n * @param loadOptions - Options controlling source resolution.\n * @returns The raw file content, or null if not found.\n */\n function loadRaw(filename: string, loadOptions: LoadOptions = {}): string | null {\n const { source: loadSource = 'resolve', startDir } = loadOptions\n const localDir = getLocalDir(startDir)\n const globalDir = getGlobalDir()\n\n return resolveFromSource<string>({\n filename,\n globalDir,\n handler: loadFromPath,\n localDir,\n source: loadSource,\n })\n }\n\n /**\n * Load and parse a store file as JSON, merging with defaults if available.\n *\n * @private\n * @param filename - The filename to load.\n * @param loadOptions - Options controlling source resolution.\n * @returns The parsed data, defaults, or null.\n */\n function load(filename: string, loadOptions: LoadOptions = {}): TData | null {\n const raw = loadRaw(filename, loadOptions)\n\n if (raw === null) {\n return defaults ?? null\n }\n\n const [parseError, parsed] = jsonParse(raw)\n if (parseError) {\n return defaults ?? null\n }\n\n if (defaults) {\n return { ...defaults, ...(parsed as Partial<TData>) }\n }\n return parsed as TData\n }\n\n /**\n * Check if a file exists at the given path and return the path if so.\n *\n * @private\n * @param filePath - The file path to check.\n * @returns The file path if it exists, or null.\n */\n function checkFileExists(filePath: string): string | null {\n if (existsSync(filePath)) {\n return filePath\n }\n return null\n }\n\n /**\n * Resolve the file path for a store file without reading its content.\n *\n * @private\n * @param filename - The filename to resolve.\n * @param loadOptions - Options controlling source resolution.\n * @returns The resolved file path, or null if not found.\n */\n function getFilePath(filename: string, loadOptions: LoadOptions = {}): string | null {\n const { source: fileSource = 'resolve', startDir } = loadOptions\n const localDir = getLocalDir(startDir)\n const globalDir = getGlobalDir()\n\n return resolveFromSource<string>({\n filename,\n globalDir,\n handler: checkFileExists,\n localDir,\n source: fileSource,\n })\n }\n\n /**\n * Serialize data to JSON and write it to a store file.\n *\n * Creates the target directory if it does not exist. Defaults to\n * the global home directory when no source is specified.\n *\n * @private\n * @param filename - The filename to write.\n * @param data - The data to serialize.\n * @param saveOptions - Options controlling the write target.\n * @returns A Result with the written file path on success.\n */\n function save(filename: string, data: unknown, saveOptions: SaveOptions = {}): Result<string> {\n const { source: saveSource = 'global', startDir } = saveOptions\n\n const dir = resolveSaveDir({ globalDir: getGlobalDir(), localDir: getLocalDir(startDir), source: saveSource })\n\n if (dir === null) {\n return err(new Error(`Cannot save to \"${saveSource}\" — no local project directory found`))\n }\n\n const [stringifyError, json] = jsonStringify(data, { pretty: true })\n\n if (stringifyError) {\n return err(stringifyError)\n }\n\n const filePath = join(dir, filename)\n\n const [writeError] = attempt(() => {\n mkdirSync(dir, { mode: 0o700, recursive: true })\n writeFileSync(filePath, json, { encoding: 'utf8', mode: 0o600 })\n })\n\n if (writeError) {\n return err(writeError)\n }\n\n return ok(filePath)\n }\n\n return {\n getFilePath,\n getGlobalDir,\n getLocalDir,\n load,\n loadRaw,\n save,\n }\n}\n\n// ---------------------------------------------------------------------------\n// Private helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve the target directory for a save operation.\n *\n * @private\n * @param options - Resolution options.\n * @returns The directory path, or null when `local` is requested but unavailable.\n */\nfunction resolveSaveDir(options: {\n readonly localDir: string | null\n readonly globalDir: string\n readonly source: 'local' | 'global'\n}): string | null {\n return match(options.source)\n .with('local', (): string | null => options.localDir)\n .with('global', () => options.globalDir)\n .exhaustive()\n}\n"],"mappings":"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"}
@@ -0,0 +1,73 @@
1
+ import { a as CommandDef, c as MiddlewareFn, i as Command, l as Context, n as AutoloadOptions, o as CommandMap, r as CliOptions, s as Middleware, t as ArgsDef } from "./types-kjpRau0U.js";
2
+ import { defineConfig } from "@kidd-cli/config";
3
+ import { z } from "zod";
4
+
5
+ //#region src/cli.d.ts
6
+ /**
7
+ * Bootstrap and run the CLI application.
8
+ *
9
+ * Parses argv, resolves the matched command, loads config, runs the
10
+ * middleware chain, and invokes the command handler.
11
+ *
12
+ * @param options - CLI configuration including name, version, commands, and middleware.
13
+ */
14
+ declare function cli<TSchema extends z.ZodType = z.ZodType>(options: CliOptions<TSchema>): Promise<void>;
15
+ //#endregion
16
+ //#region src/command.d.ts
17
+ /**
18
+ * Define a CLI command with typed args, config, and handler.
19
+ *
20
+ * @param def - Command definition including description, args schema, and handler.
21
+ * @returns A resolved Command object for registration in the command map.
22
+ */
23
+ declare function command<TArgsDef extends ArgsDef = ArgsDef, TConfig extends Record<string, unknown> = Record<string, unknown>>(def: CommandDef<TArgsDef, TConfig>): Command<TArgsDef, TConfig>;
24
+ //#endregion
25
+ //#region src/autoloader.d.ts
26
+ /**
27
+ * Scan a directory for command files and produce a CommandMap.
28
+ *
29
+ * @param options - Autoload configuration (directory override, etc.).
30
+ * @returns A promise resolving to a CommandMap built from the directory tree.
31
+ */
32
+ declare function autoload(options?: AutoloadOptions): Promise<CommandMap>;
33
+ //#endregion
34
+ //#region src/context/decorate.d.ts
35
+ /**
36
+ * Add a typed, immutable property to a context instance.
37
+ *
38
+ * Middleware authors use this to extend ctx with custom properties.
39
+ * Pair with module augmentation on Context for type safety:
40
+ *
41
+ * ```ts
42
+ * declare module '@kidd-cli/core' {
43
+ * interface Context {
44
+ * readonly github: HttpClient
45
+ * }
46
+ * }
47
+ * ```
48
+ *
49
+ * **Note:** This function mutates the context object via
50
+ * `Object.defineProperty`. The added property is non-writable and
51
+ * non-configurable, making it effectively frozen after assignment.
52
+ * Mutation is intentional here — the context is assembled incrementally
53
+ * across middleware, and copying the entire object on each decoration
54
+ * would break the single-reference threading model used by the runner.
55
+ *
56
+ * @param ctx - The context instance to decorate (mutated in place).
57
+ * @param key - The property name.
58
+ * @param value - The property value (frozen after assignment).
59
+ * @returns The same ctx reference, now carrying the new property.
60
+ */
61
+ declare function decorateContext<TKey extends string, TValue>(ctx: Context, key: TKey, value: TValue): Context;
62
+ //#endregion
63
+ //#region src/middleware.d.ts
64
+ /**
65
+ * Create a typed middleware that runs before command handlers.
66
+ *
67
+ * @param handler - The middleware function receiving ctx and next.
68
+ * @returns A Middleware object for use in the cli() middleware stack.
69
+ */
70
+ declare function middleware<TConfig extends Record<string, unknown> = Record<string, unknown>>(handler: MiddlewareFn<TConfig>): Middleware<TConfig>;
71
+ //#endregion
72
+ export { type Command, type Context, autoload, cli, command, decorateContext, defineConfig, middleware };
73
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/cli.ts","../src/command.ts","../src/autoloader.ts","../src/context/decorate.ts","../src/middleware.ts"],"mappings":";;;;;;;;;AAyBA;;;;iBAAsB,GAAA,iBAAoB,CAAA,CAAE,OAAA,GAAU,CAAA,CAAE,OAAA,CAAA,CACtD,OAAA,EAAS,UAAA,CAAW,OAAA,IACnB,OAAA;;;;;;;;AAFH;iBCfgB,OAAA,kBACG,OAAA,GAAU,OAAA,kBACX,MAAA,oBAA0B,MAAA,kBAAA,CAC1C,GAAA,EAAK,UAAA,CAAW,QAAA,EAAU,OAAA,IAAW,OAAA,CAAY,QAAA,EAAU,OAAA;;;;;;;;ADY7D;iBEPsB,QAAA,CAAS,OAAA,GAAU,eAAA,GAAkB,OAAA,CAAQ,UAAA;;;;;;;;AFOnE;;;;;;;;;;;;;;;;;;;;;iBGGgB,eAAA,6BAAA,CACd,GAAA,EAAK,OAAA,EACL,GAAA,EAAK,IAAA,EACL,KAAA,EAAO,MAAA,GACN,OAAA;;;;;;;;AHPH;iBIfgB,UAAA,iBAA2B,MAAA,oBAA0B,MAAA,kBAAA,CACnE,OAAA,EAAS,YAAA,CAAa,OAAA,IACrB,UAAA,CAAW,OAAA"}