@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.
- package/LICENSE +21 -0
- package/README.md +214 -0
- package/dist/config-BvGapuFJ.js +282 -0
- package/dist/config-BvGapuFJ.js.map +1 -0
- package/dist/create-store-BQUX0tAn.js +197 -0
- package/dist/create-store-BQUX0tAn.js.map +1 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1034 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/config.d.ts +64 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +4 -0
- package/dist/lib/logger.d.ts +2 -0
- package/dist/lib/logger.js +55 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/output.d.ts +62 -0
- package/dist/lib/output.d.ts.map +1 -0
- package/dist/lib/output.js +276 -0
- package/dist/lib/output.js.map +1 -0
- package/dist/lib/project.d.ts +59 -0
- package/dist/lib/project.d.ts.map +1 -0
- package/dist/lib/project.js +3 -0
- package/dist/lib/prompts.d.ts +24 -0
- package/dist/lib/prompts.d.ts.map +1 -0
- package/dist/lib/prompts.js +3 -0
- package/dist/lib/store.d.ts +56 -0
- package/dist/lib/store.d.ts.map +1 -0
- package/dist/lib/store.js +4 -0
- package/dist/logger-BkQQej8h.d.ts +76 -0
- package/dist/logger-BkQQej8h.d.ts.map +1 -0
- package/dist/middleware/auth.d.ts +22 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/auth.js +759 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/http.d.ts +87 -0
- package/dist/middleware/http.d.ts.map +1 -0
- package/dist/middleware/http.js +255 -0
- package/dist/middleware/http.js.map +1 -0
- package/dist/middleware-D3psyhYo.js +54 -0
- package/dist/middleware-D3psyhYo.js.map +1 -0
- package/dist/project-NPtYX2ZX.js +181 -0
- package/dist/project-NPtYX2ZX.js.map +1 -0
- package/dist/prompts-lLfUSgd6.js +63 -0
- package/dist/prompts-lLfUSgd6.js.map +1 -0
- package/dist/types-CqKJhsYk.d.ts +135 -0
- package/dist/types-CqKJhsYk.d.ts.map +1 -0
- package/dist/types-Cz9h927W.d.ts +23 -0
- package/dist/types-Cz9h927W.d.ts.map +1 -0
- package/dist/types-DFtYg5uZ.d.ts +26 -0
- package/dist/types-DFtYg5uZ.d.ts.map +1 -0
- package/dist/types-kjpRau0U.d.ts +382 -0
- package/dist/types-kjpRau0U.d.ts.map +1 -0
- package/package.json +94 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","names":[],"sources":["../../src/context/redact.ts","../../src/lib/output/renderer.ts","../../src/lib/output/format.ts","../../src/lib/output/create-output.ts","../../src/lib/output/defaults.ts"],"sourcesContent":["import pinoRedact from '@pinojs/redact'\n\nconst CENSOR = '[REDACTED]'\n\n/**\n * Keys that are always redacted regardless of their depth in the object tree.\n */\nconst SENSITIVE_KEYS: ReadonlySet<string> = new Set([\n 'password',\n 'secret',\n 'token',\n 'apiKey',\n 'api_key',\n 'apiSecret',\n 'api_secret',\n 'authorization',\n 'auth',\n 'credentials',\n 'private_key',\n 'privateKey',\n])\n\n/**\n * Specific nested paths where the key name alone is not sensitive\n * but the location makes it sensitive. Handled by `@pinojs/redact`.\n */\nconst SPECIFIC_PATHS: readonly string[] = [\n 'headers.Authorization',\n 'env.GITHUB_TOKEN',\n 'env.LINEAR_API_KEY',\n]\n\nconst redactPaths = pinoRedact({\n censor: resolveCensor,\n paths: [...SPECIFIC_PATHS],\n serialize: false,\n})\n\n// ---------------------------------------------------------------------------\n// Private helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Censor function for `@pinojs/redact` that preserves null/undefined values.\n *\n * @private\n * @param value - The original value at a redacted path.\n * @returns The censor string or the original null/undefined.\n */\nfunction resolveCensor(value: unknown): unknown {\n if (value === null || value === undefined) {\n return value\n }\n return CENSOR\n}\n\n/**\n * Deep-clone an object and replace values at sensitive key paths with `[REDACTED]`.\n *\n * Uses `@pinojs/redact` for specific fixed paths and a recursive walk for\n * any-depth key-name matching against {@link SENSITIVE_KEYS}.\n *\n * @param obj - The object to redact.\n * @returns A deep clone with sensitive values replaced.\n */\nexport function redactObject<TObj extends object>(obj: TObj): TObj {\n const pathRedacted = redactPaths(obj)\n return redactSensitiveKeys(pathRedacted as Record<string, unknown>) as TObj\n}\n\n/**\n * Recursively walk an object and redact values whose key is in {@link SENSITIVE_KEYS}.\n * Returns a new object — does not mutate the input.\n *\n * @private\n * @param target - The record to walk.\n * @returns A new record with sensitive values replaced.\n */\nfunction redactSensitiveKeys(target: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(target)\n .filter(([key]) => key !== 'restore')\n .map(([key, value]) => redactEntry(key, value))\n )\n}\n\n/**\n * Process a single key-value entry for sensitive-key redaction.\n *\n * @private\n * @param key - The property key.\n * @param value - The property value.\n * @returns A [key, value] tuple with the value potentially redacted.\n */\nfunction redactEntry(key: string, value: unknown): [string, unknown] {\n if (SENSITIVE_KEYS.has(key) && value !== undefined && value !== null) {\n return [key, CENSOR]\n }\n\n if (Array.isArray(value)) {\n return [key, value.map(redactArrayItem)]\n }\n\n if (value && typeof value === 'object') {\n return [key, redactSensitiveKeys(value as Record<string, unknown>)]\n }\n\n return [key, value]\n}\n\n/**\n * Redact sensitive keys within an array item if it is an object.\n *\n * @private\n * @param item - The array element.\n * @returns The element with sensitive keys redacted, or the original primitive.\n */\nfunction redactArrayItem(item: unknown): unknown {\n if (item && typeof item === 'object') {\n return redactSensitiveKeys(item as Record<string, unknown>)\n }\n return item\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { attempt, err, ok } from '@kidd-cli/utils/fp'\nimport type { Result } from '@kidd-cli/utils/fp'\nimport { Liquid } from 'liquidjs'\n\nimport type {\n CreateRendererOptions,\n LoadTemplateOptions,\n Renderer,\n RenderTemplateOptions,\n ToMarkdownParams,\n} from './types.js'\n\n/**\n * Resolve an unknown error to a string message.\n *\n * @param error - The error to resolve.\n * @returns A string error message.\n */\nexport function resolveRenderError(error: unknown): string {\n if (error instanceof Error) {\n return error.message\n }\n return 'Unknown error'\n}\n\n/**\n * Create a Liquid template {@link Renderer}.\n *\n * @param options - Renderer configuration.\n * @returns A Renderer instance.\n */\nexport function createRenderer(options: CreateRendererOptions): Renderer {\n const { templates: templatesDir, filters = {}, context } = options\n const liquid = new Liquid()\n const templateCache = new Map<string, string>()\n\n for (const [name, fn] of Object.entries(filters)) {\n liquid.registerFilter(name, fn)\n }\n\n return {\n render(params: ToMarkdownParams): Result<string, Error> {\n const [templateError, template] = loadTemplateFromDisk({\n cache: templateCache,\n templatesDir,\n type: params.type,\n })\n if (templateError) {\n return [templateError, null]\n }\n\n const extraContext = resolveExtraContext(context, params)\n return renderTemplate({ extraContext, liquid, params, template })\n },\n }\n}\n\n// ---------------------------------------------------------------------------\n// Private\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve the full filesystem path to a Liquid template file.\n *\n * @private\n */\nfunction resolveTemplatePath(templatesDir: string, type: string): string {\n const segments = type.split(':')\n return `${path.join(templatesDir, ...segments)}.liquid`\n}\n\n/**\n * Load a Liquid template from disk, using a cache to avoid redundant reads.\n *\n * @private\n */\nfunction loadTemplateFromDisk(options: LoadTemplateOptions): Result<string, Error> {\n const { templatesDir, type, cache } = options\n const cached = cache.get(type)\n if (cached !== undefined) {\n return ok(cached)\n }\n\n const templatePath = resolveTemplatePath(templatesDir, type)\n const [error, content] = attempt(() => fs.readFileSync(templatePath, 'utf8'))\n\n if (error || content === null) {\n return err(new Error(`Template not found for type '${type}': ${templatePath}`))\n }\n\n cache.set(type, content)\n return ok(content)\n}\n\n/**\n * Resolve additional template context from the user-provided context function.\n *\n * @private\n */\nfunction resolveExtraContext(\n context: ((params: ToMarkdownParams) => Record<string, unknown>) | undefined,\n params: ToMarkdownParams\n): Record<string, unknown> {\n if (context) {\n return context(params)\n }\n return {}\n}\n\n/**\n * Render a Liquid template with the given parameters and context.\n *\n * @private\n */\nfunction renderTemplate(options: RenderTemplateOptions): Result<string, Error> {\n const { liquid, template, params, extraContext } = options\n const [error, result] = attempt(() =>\n liquid.parseAndRenderSync(template, {\n ...(params.data as object),\n ...extraContext,\n })\n )\n\n if (error || result === undefined) {\n const errorMessage = resolveRenderError(error)\n return err(new Error(`Failed to render template for ${params.type}: ${errorMessage}`))\n }\n\n return ok(result)\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { attempt, err, ok } from '@kidd-cli/utils/fp'\nimport type { Result } from '@kidd-cli/utils/fp'\nimport { jsonStringify } from '@kidd-cli/utils/json'\n\nimport { redactObject } from '@/context/redact.js'\n\nimport { resolveRenderError } from './renderer.js'\nimport type { JsonOutputOptions, WriteParams } from './types.js'\n\n/**\n * Serialize data to a JSON string.\n *\n * @param data - The data to serialize.\n * @param opts - JSON output options.\n * @returns The JSON string.\n */\nexport function formatJson(data: unknown, opts: JsonOutputOptions = {}): string {\n const { pretty = true, redact = false } = opts\n const processed = resolveProcessed(data, redact)\n const [, json] = jsonStringify(processed, { pretty })\n return json || ''\n}\n\n/**\n * Write content to a file on disk, creating parent directories as needed.\n *\n * @param params - Write parameters (path and content).\n * @returns A Result indicating success or failure.\n */\nexport function writeToFile(params: WriteParams): Result<void, Error> {\n const [error] = attempt(() => {\n fs.mkdirSync(path.dirname(params.path), { recursive: true })\n fs.writeFileSync(params.path, params.content, 'utf8')\n })\n\n if (error) {\n const errorMessage = resolveRenderError(error)\n return err(new Error(`Failed to write file ${params.path}: ${errorMessage}`))\n }\n\n return ok()\n}\n\n// ---------------------------------------------------------------------------\n// Private\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve the processed data, optionally redacting sensitive fields.\n *\n * @private\n */\nfunction resolveProcessed(data: unknown, redact: boolean): unknown {\n if (redact && data && typeof data === 'object') {\n return redactObject(data as object)\n }\n return data\n}\n","import { err } from '@kidd-cli/utils/fp'\nimport type { Result } from '@kidd-cli/utils/fp'\n\nimport { createCliLogger } from '@/lib/logger.js'\n\nimport { formatJson, writeToFile } from './format.js'\nimport { createRenderer } from './renderer.js'\nimport type {\n CliOutput,\n CreateOutputOptions,\n JsonOutputOptions,\n Renderer,\n ToMarkdownParams,\n} from './types.js'\n\n/**\n * Create a new {@link CliOutput} instance for structured CLI output.\n *\n * @param options - Output configuration.\n * @returns A CliOutput instance.\n */\nexport function createOutput(options: CreateOutputOptions = {}): CliOutput {\n const logger = createCliLogger({ output: options.output ?? process.stdout })\n const renderer = resolveRenderer(options)\n\n function toMarkdown(params: ToMarkdownParams): Result<string, Error> {\n if (!renderer) {\n return err(\n new Error('Templates directory not configured. Pass `templates` to createOutput().')\n )\n }\n return renderer.render(params)\n }\n\n return {\n json(data: unknown, jsonOptions: JsonOutputOptions = {}): void {\n logger.print(formatJson(data, jsonOptions))\n },\n print(content: string): void {\n logger.print(content)\n },\n toJson: formatJson,\n toMarkdown,\n write: writeToFile,\n }\n}\n\n// ---------------------------------------------------------------------------\n// Private\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve a Renderer from the output options, if templates are configured.\n *\n * @private\n */\nfunction resolveRenderer(options: CreateOutputOptions): Renderer | undefined {\n if (options.templates) {\n return createRenderer({\n context: options.context,\n filters: options.filters,\n templates: options.templates,\n })\n }\n return undefined\n}\n","import { createOutput } from './create-output.js'\nimport type { CliOutput } from './types.js'\n\n/**\n * Default output instance writing to stdout.\n */\nexport const output: CliOutput = createOutput()\n"],"mappings":";;;;;;;;;AAEA,MAAM,SAAS;;;;AAKf,MAAM,iBAAsC,IAAI,IAAI;CAClD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAYF,MAAM,cAAc,WAAW;CAC7B,QAAQ;CACR,OAAO,CAAC,GARgC;EACxC;EACA;EACA;EACD,CAI2B;CAC1B,WAAW;CACZ,CAAC;;;;;;;;AAaF,SAAS,cAAc,OAAyB;AAC9C,KAAI,UAAU,QAAQ,UAAU,OAC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|
+
/**
|
|
5
|
+
* Resolve a directory path relative to the project root.
|
|
6
|
+
*
|
|
7
|
+
* @param options - Options containing the directory name and optional start directory.
|
|
8
|
+
* @returns The resolved local path, or null if no project root is found.
|
|
9
|
+
*/
|
|
10
|
+
declare function resolveLocalPath(options: {
|
|
11
|
+
readonly dirName: string;
|
|
12
|
+
readonly startDir?: string;
|
|
13
|
+
}): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve a directory path relative to the user's home directory.
|
|
16
|
+
*
|
|
17
|
+
* @param options - Options containing the directory name.
|
|
18
|
+
* @returns The resolved global path.
|
|
19
|
+
*/
|
|
20
|
+
declare function resolveGlobalPath(options: {
|
|
21
|
+
readonly dirName: string;
|
|
22
|
+
}): string;
|
|
23
|
+
/**
|
|
24
|
+
* Resolve a directory path using the specified source strategy.
|
|
25
|
+
*
|
|
26
|
+
* When source is 'local', resolves relative to the project root.
|
|
27
|
+
* When source is 'global', resolves relative to the home directory.
|
|
28
|
+
* When source is 'resolve' (default), tries local first, falling back to global.
|
|
29
|
+
*
|
|
30
|
+
* @param options - Resolution options with dirName, source, and startDir.
|
|
31
|
+
* @returns The resolved path, or null if local resolution fails with source='local'.
|
|
32
|
+
*/
|
|
33
|
+
declare function resolvePath(options: ResolvePathOptions): string | null;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/lib/project/root.d.ts
|
|
36
|
+
/**
|
|
37
|
+
* Walk up the directory tree to find the nearest git project root.
|
|
38
|
+
*
|
|
39
|
+
* @param startDir - Directory to start searching from (defaults to cwd).
|
|
40
|
+
* @returns The project root info, or null if no git root is found.
|
|
41
|
+
*/
|
|
42
|
+
declare function findProjectRoot(startDir?: string): ProjectRoot | null;
|
|
43
|
+
/**
|
|
44
|
+
* Check whether the current directory is inside a git submodule.
|
|
45
|
+
*
|
|
46
|
+
* @param startDir - Directory to start searching from.
|
|
47
|
+
* @returns True if the directory is inside a submodule.
|
|
48
|
+
*/
|
|
49
|
+
declare function isInSubmodule(startDir?: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve the parent repository root when inside a git submodule.
|
|
52
|
+
*
|
|
53
|
+
* @param startDir - Directory to start searching from.
|
|
54
|
+
* @returns The parent repository root path, or null.
|
|
55
|
+
*/
|
|
56
|
+
declare function getParentRepoRoot(startDir?: string): string | null;
|
|
57
|
+
//#endregion
|
|
58
|
+
export { type PathSource, type ProjectRoot, type ResolvePathOptions, findProjectRoot, getParentRepoRoot, isInSubmodule, resolveGlobalPath, resolveLocalPath, resolvePath };
|
|
59
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","names":[],"sources":["../../src/lib/project/paths.ts","../../src/lib/project/root.ts"],"mappings":";;;;;AAcA;;;;iBAAgB,gBAAA,CAAiB,OAAA;EAAA,SACtB,OAAA;EAAA,SACA,QAAA;AAAA;;AAeX;;;;;iBAAgB,iBAAA,CAAkB,OAAA;EAAA,SAAoB,OAAA;AAAA;;;;;;AChBtD;;;;;iBD8BgB,WAAA,CAAY,OAAA,EAAS,kBAAA;;;;;AA/BrC;;;;iBCCgB,eAAA,CAAgB,QAAA,YAAmC,WAAA;;;;;ADgBnE;;iBCsBgB,aAAA,CAAc,QAAA;;;ADR9B;;;;iBCsBgB,iBAAA,CAAkB,QAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as getParentRepoRoot, i as findProjectRoot, n as resolveLocalPath, o as isInSubmodule, r as resolvePath, t as resolveGlobalPath } from "../project-NPtYX2ZX.js";
|
|
2
|
+
|
|
3
|
+
export { findProjectRoot, getParentRepoRoot, isInSubmodule, resolveGlobalPath, resolveLocalPath, resolvePath };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { n as Spinner, t as PromptUtils } from "../types-DFtYg5uZ.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/prompts/create-prompts.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Create a new {@link Spinner} instance backed by @clack/prompts.
|
|
6
|
+
*/
|
|
7
|
+
declare function createSpinner(): Spinner;
|
|
8
|
+
/**
|
|
9
|
+
* Create a new {@link PromptUtils} instance backed by @clack/prompts.
|
|
10
|
+
*/
|
|
11
|
+
declare function createPromptUtils(): PromptUtils;
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/lib/prompts/defaults.d.ts
|
|
14
|
+
/**
|
|
15
|
+
* Default spinner instance.
|
|
16
|
+
*/
|
|
17
|
+
declare const spinner: Spinner;
|
|
18
|
+
/**
|
|
19
|
+
* Default prompt utilities instance.
|
|
20
|
+
*/
|
|
21
|
+
declare const prompts: PromptUtils;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { type PromptUtils, type Spinner, createPromptUtils, createSpinner, prompts, spinner };
|
|
24
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","names":[],"sources":["../../src/lib/prompts/create-prompts.ts","../../src/lib/prompts/defaults.ts"],"mappings":";;;;;AAOA;iBAAgB,aAAA,CAAA,GAAiB,OAAA;;;;iBAqBjB,iBAAA,CAAA,GAAqB,WAAA;;;;;AArBrC;cCDa,OAAA,EAAS,OAAA;;;;cAKT,OAAA,EAAS,WAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { t as PathSource } from "../types-Cz9h927W.js";
|
|
2
|
+
import { Result } from "@kidd-cli/utils/fp";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/store/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Write-target for {@link FileStore.save}.
|
|
7
|
+
*
|
|
8
|
+
* Only `'local'` and `'global'` are valid — writes must target an
|
|
9
|
+
* explicit directory (no automatic resolution).
|
|
10
|
+
*/
|
|
11
|
+
type SaveSource = "local" | "global";
|
|
12
|
+
/**
|
|
13
|
+
* Options for creating a file-backed store.
|
|
14
|
+
*/
|
|
15
|
+
interface StoreOptions<TData> {
|
|
16
|
+
dirName: string;
|
|
17
|
+
defaults?: TData;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Options for loading a file from the store.
|
|
21
|
+
*/
|
|
22
|
+
interface LoadOptions {
|
|
23
|
+
source?: PathSource;
|
|
24
|
+
startDir?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Options for saving a file to the store.
|
|
28
|
+
*/
|
|
29
|
+
interface SaveOptions {
|
|
30
|
+
source?: SaveSource;
|
|
31
|
+
startDir?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* File-backed JSON store with local/global resolution.
|
|
35
|
+
*/
|
|
36
|
+
interface FileStore<TData> {
|
|
37
|
+
getLocalDir(startDir?: string): string | null;
|
|
38
|
+
getGlobalDir(): string;
|
|
39
|
+
load(filename: string, options?: LoadOptions): TData | null;
|
|
40
|
+
loadRaw(filename: string, options?: LoadOptions): string | null;
|
|
41
|
+
getFilePath(filename: string, options?: LoadOptions): string | null;
|
|
42
|
+
save(filename: string, data: unknown, options?: SaveOptions): Result<string>;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/lib/store/create-store.d.ts
|
|
46
|
+
/**
|
|
47
|
+
* Create a file-backed {@link FileStore} that resolves JSON files from project-local
|
|
48
|
+
* or global home directories.
|
|
49
|
+
*
|
|
50
|
+
* @param options - Store configuration.
|
|
51
|
+
* @returns A FileStore instance.
|
|
52
|
+
*/
|
|
53
|
+
declare function createStore<TData = unknown>(options: StoreOptions<TData>): FileStore<TData>;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { type FileStore, type LoadOptions, type SaveOptions, type SaveSource, type StoreOptions, createStore };
|
|
56
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","names":[],"sources":["../../src/lib/store/types.ts","../../src/lib/store/create-store.ts"],"mappings":";;;;;;AASA;;;;KAAY,UAAA;AAKZ;;;AAAA,UAAiB,YAAA;EACf,OAAA;EACA,QAAA,GAAW,KAAA;AAAA;;;;UAMI,WAAA;EACf,MAAA,GAAS,UAAA;EACT,QAAA;AAAA;;;;UAMe,WAAA;EACf,MAAA,GAAS,UAAA;EACT,QAAA;AAAA;;;;UAMe,SAAA;EACf,WAAA,CAAY,QAAA;EACZ,YAAA;EACA,IAAA,CAAK,QAAA,UAAkB,OAAA,GAAU,WAAA,GAAc,KAAA;EAC/C,OAAA,CAAQ,QAAA,UAAkB,OAAA,GAAU,WAAA;EACpC,WAAA,CAAY,QAAA,UAAkB,OAAA,GAAU,WAAA;EACxC,IAAA,CAAK,QAAA,UAAkB,IAAA,WAAe,OAAA,GAAU,WAAA,GAAc,MAAA;AAAA;;;;;;AAnChE;;;;iBCUgB,WAAA,iBAAA,CAA6B,OAAA,EAAS,YAAA,CAAa,KAAA,IAAS,SAAA,CAAU,KAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//#region src/lib/logger.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Options for creating a logger instance.
|
|
4
|
+
*/
|
|
5
|
+
interface CliLoggerOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Writable stream for raw output methods like {@link CliLogger.print} and {@link CliLogger.newline}.
|
|
8
|
+
* Defaults to `process.stderr`.
|
|
9
|
+
*/
|
|
10
|
+
readonly output?: NodeJS.WriteStream;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Structured logger backed by @clack/prompts for terminal UI output.
|
|
14
|
+
*/
|
|
15
|
+
interface CliLogger {
|
|
16
|
+
/**
|
|
17
|
+
* Log an informational message.
|
|
18
|
+
*/
|
|
19
|
+
info(message: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Log a success message.
|
|
22
|
+
*/
|
|
23
|
+
success(message: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Log an error message.
|
|
26
|
+
*/
|
|
27
|
+
error(message: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Log a warning message.
|
|
30
|
+
*/
|
|
31
|
+
warn(message: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Log a step indicator message.
|
|
34
|
+
*/
|
|
35
|
+
step(message: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Log a message with an optional custom symbol prefix.
|
|
38
|
+
*/
|
|
39
|
+
message(message: string, opts?: {
|
|
40
|
+
symbol?: string;
|
|
41
|
+
}): void;
|
|
42
|
+
/**
|
|
43
|
+
* Print an intro banner with an optional title.
|
|
44
|
+
*/
|
|
45
|
+
intro(title?: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Print an outro banner with an optional closing message.
|
|
48
|
+
*/
|
|
49
|
+
outro(message?: string): void;
|
|
50
|
+
/**
|
|
51
|
+
* Display a boxed note with an optional title.
|
|
52
|
+
*/
|
|
53
|
+
note(message?: string, title?: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Write a blank line to the output stream.
|
|
56
|
+
*/
|
|
57
|
+
newline(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Write raw text followed by a newline to the output stream.
|
|
60
|
+
*/
|
|
61
|
+
print(text: string): void;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Create a new {@link CliLogger} instance.
|
|
65
|
+
*
|
|
66
|
+
* @param options - Logger configuration.
|
|
67
|
+
* @returns A CliLogger wired to the given output stream.
|
|
68
|
+
*/
|
|
69
|
+
declare function createCliLogger(options?: CliLoggerOptions): CliLogger;
|
|
70
|
+
/**
|
|
71
|
+
* Default logger instance writing to stderr.
|
|
72
|
+
*/
|
|
73
|
+
declare const cliLogger: CliLogger;
|
|
74
|
+
//#endregion
|
|
75
|
+
export { createCliLogger as i, CliLoggerOptions as n, cliLogger as r, CliLogger as t };
|
|
76
|
+
//# sourceMappingURL=logger-BkQQej8h.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-BkQQej8h.d.ts","names":[],"sources":["../src/lib/logger.ts"],"mappings":";;AAKA;;UAAiB,gBAAA;EAKU;;;;EAAA,SAAhB,MAAA,GAAS,MAAA,CAAO,WAAA;AAAA;AAM3B;;;AAAA,UAAiB,SAAA;;;;EAIf,IAAA,CAAK,OAAA;;;;EAIL,OAAA,CAAQ,OAAA;;;;EAIR,KAAA,CAAM,OAAA;;;;EAIN,IAAA,CAAK,OAAA;;;;EAIL,IAAA,CAAK,OAAA;;;;EAIL,OAAA,CAAQ,OAAA,UAAiB,IAAA;IAAS,MAAA;EAAA;EA6BpC;;;EAzBE,KAAA,CAAM,KAAA;;;;EAIN,KAAA,CAAM,OAAA;EAqByD;AA2CjE;;EA5DE,IAAA,CAAK,OAAA,WAAkB,KAAA;EA4DD;;;EAxDtB,OAAA;;;;EAIA,KAAA,CAAM,IAAA;AAAA;;;;;;;iBASQ,eAAA,CAAgB,OAAA,GAAS,gBAAA,GAAwB,SAAA;;;;cA2CpD,SAAA,EAAW,SAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { s as Middleware } from "../types-kjpRau0U.js";
|
|
2
|
+
import { a as ResolverConfig, i as LoginError, n as AuthCredential, r as AuthOptions, t as AuthContext } from "../types-CqKJhsYk.js";
|
|
3
|
+
|
|
4
|
+
//#region src/middleware/auth/auth.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Create an auth middleware that decorates `ctx.auth`.
|
|
7
|
+
*
|
|
8
|
+
* No credential data is stored on the context. `ctx.auth.credential()`
|
|
9
|
+
* resolves passively from two sources on every call:
|
|
10
|
+
* 1. File — `~/.cli-name/auth.json`
|
|
11
|
+
* 2. Env — `CLI_NAME_TOKEN`
|
|
12
|
+
*
|
|
13
|
+
* Interactive resolvers (OAuth, prompt, custom) only run when the
|
|
14
|
+
* command handler explicitly calls `ctx.auth.authenticate()`.
|
|
15
|
+
*
|
|
16
|
+
* @param options - Auth middleware configuration.
|
|
17
|
+
* @returns A Middleware that decorates ctx.auth.
|
|
18
|
+
*/
|
|
19
|
+
declare function auth(options: AuthOptions): Middleware;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { type AuthContext, type AuthCredential, type AuthOptions, type LoginError, type ResolverConfig, auth };
|
|
22
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","names":[],"sources":["../../src/middleware/auth/auth.ts"],"mappings":";;;;;;;AAiCA;;;;;;;;;;;iBAAgB,IAAA,CAAK,OAAA,EAAS,WAAA,GAAc,UAAA"}
|