@forinda/kickjs 0.1.0 → 0.1.4
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 +197 -23
- package/dist/cli.js +765 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +133 -3
- package/dist/index.js +829 -100
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/cli.ts","../package.json","../src/cli/tasks/init-project.ts","../src/cli/utils/fs.ts","../src/cli/commands/init.ts","../src/cli/tasks/generate-controller.ts","../src/cli/tasks/generate-domain.ts","../src/cli/commands/generate-controller.ts","../src/cli/config.ts","../src/utils/errors.ts","../src/cli/utils/shell.ts","../src/cli/commands/custom.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from 'commander';\nimport pkg from '../../package.json';\nimport { registerInitCommand } from './commands/init';\nimport { registerGeneratorCommands } from './commands/generate-controller';\nimport { loadKickConfig } from './config';\nimport { registerCustomCommands } from './commands/custom';\n\nasync function main() {\n const program = new Command();\n program.name('kick').description('Kick project CLI').version(pkg.version ?? '0.0.0');\n\n const config = await loadKickConfig(process.cwd());\n\n registerInitCommand(program, { structure: config?.structure });\n registerGeneratorCommands(program, {\n controllerRoot: config?.generators?.controllerRoot,\n structure: config?.structure\n });\n registerCustomCommands(program, config);\n\n program.showHelpAfterError();\n\n try {\n await program.parseAsync(process.argv);\n } catch (error) {\n console.error(error instanceof Error ? error.message : error);\n process.exitCode = 1;\n }\n}\n\nmain().catch((error) => {\n console.error(error instanceof Error ? error.message : error);\n process.exitCode = 1;\n});\n","{\n \"name\": \"@forinda/kickjs\",\n \"version\": \"0.1.4\",\n \"description\": \"Express + TypeScript + Inversify starter with reactive state, request telemetry, and Spring Boot-style decorators.\",\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"require\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"bin\": {\n \"kick\": \"dist/cli.js\"\n },\n \"scripts\": {\n \"clean\": \"rm -rf dist\",\n \"dev\": \"ts-node-dev --respawn --transpile-only src/main.ts\",\n \"check\": \"tsc --noEmit\",\n \"build\": \"tsup\",\n \"start\": \"node dist/index.js\",\n \"prepublishOnly\": \"npm run build && npm run check && npm test\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"prepare\": \"husky\"\n },\n \"keywords\": [\n \"express\",\n \"typescript\",\n \"inversify\",\n \"decorators\",\n \"starter\"\n ],\n \"author\": \"\",\n \"license\": \"MIT\",\n \"engines\": {\n \"node\": \">=18.17\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"dependencies\": {\n \"commander\": \"^11.1.0\",\n \"express\": \"^5.1.0\",\n \"inversify\": \"^7.10.0\",\n \"reflect-metadata\": \"^0.2.2\"\n },\n \"devDependencies\": {\n \"@swc/core\": \"^1.7.28\",\n \"@types/express\": \"^5.0.3\",\n \"@types/node\": \"^24.5.2\",\n \"@vitest/coverage-v8\": \"^3.2.4\",\n \"husky\": \"^9.1.7\",\n \"joi\": \"^18.0.1\",\n \"node-mocks-http\": \"^1.17.2\",\n \"ts-node\": \"^10.9.2\",\n \"ts-node-dev\": \"^2.0.0\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.9.2\",\n \"vitest\": \"^3.2.4\",\n \"zod\": \"^4.1.9\"\n }\n}\n","import path from 'node:path';\nimport { fileExists, ensureDirectory, writeFileSafe, writeJsonFile, readJsonFile } from '../utils/fs';\nimport type { KickStructureConfig } from '../types';\n\nexport interface InitProjectOptions {\n targetDirectory: string;\n force?: boolean;\n packageName?: string;\n structure?: KickStructureConfig;\n}\n\nexport interface InitProjectResult {\n createdFiles: string[];\n skippedFiles: string[];\n}\n\nexport async function initProject(options: InitProjectOptions): Promise<InitProjectResult> {\n const targetDir = path.resolve(process.cwd(), options.targetDirectory || '.');\n const force = options.force ?? false;\n const structure = normalizeStructure(options.structure);\n const createdFiles: string[] = [];\n const skippedFiles: string[] = [];\n\n await ensureDirectory(targetDir);\n\n const packageJsonPath = path.join(targetDir, 'package.json');\n const packageJson = (await readJsonFile<Record<string, unknown>>(packageJsonPath)) ?? {};\n if (Object.keys(packageJson).length === 0) {\n const name = options.packageName ??\n (path.basename(targetDir).replace(/[^a-zA-Z0-9-_]/g, '-') || 'kick-app');\n await writeJsonFile(\n packageJsonPath,\n {\n name,\n version: '0.1.0',\n private: true,\n type: 'commonjs',\n scripts: {\n dev: 'tsx watch src/main.ts',\n build: 'tsup',\n start: 'node dist/main.js',\n test: 'vitest'\n },\n dependencies: {\n '@forinda/kickjs': 'latest'\n },\n devDependencies: {\n typescript: '^5.4.0',\n tsx: '^4.7.0',\n tsup: '^8.0.0',\n vitest: '^3.0.0'\n }\n },\n { force: true }\n );\n createdFiles.push('package.json');\n } else {\n skippedFiles.push('package.json');\n }\n\n const tsconfigPath = path.join(targetDir, 'tsconfig.json');\n const tsconfigExists = await fileExists(tsconfigPath);\n if (!tsconfigExists || force) {\n await writeJsonFile(\n tsconfigPath,\n {\n compilerOptions: {\n target: 'es2021',\n module: 'commonjs',\n moduleResolution: 'node',\n lib: ['es2021'],\n rootDir: 'src',\n outDir: 'dist',\n strict: true,\n esModuleInterop: true,\n skipLibCheck: true,\n resolveJsonModule: true,\n experimentalDecorators: true,\n emitDecoratorMetadata: true\n },\n include: ['src']\n },\n { force: true }\n );\n createdFiles.push('tsconfig.json');\n } else {\n skippedFiles.push('tsconfig.json');\n }\n\n const mainFilePath = path.join(targetDir, 'src', 'main.ts');\n const mainCreated = await writeFileSafe(\n mainFilePath,\n `import 'reflect-metadata';\\nimport { bootstrap, configureApp } from '@forinda/kickjs';\\n\\nconfigureApp({ prefix: '/api' });\\n\\nasync function main() {\\n const { shutdown } = await bootstrap({ port: process.env.PORT ?? 3000 });\\n process.on('SIGINT', shutdown);\\n process.on('SIGTERM', shutdown);\\n}\\n\\nmain().catch((error) => {\\n console.error('Failed to bootstrap Kick app', error);\\n process.exitCode = 1;\\n});\\n`,\n { force }\n );\n mainCreated ? createdFiles.push('src/main.ts') : skippedFiles.push('src/main.ts');\n\n const domainBase = path.join(targetDir, structure.domainRoot, structure.defaultDomain);\n for (const folder of structure.domainFolders) {\n const folderPath = path.join(domainBase, folder);\n const exists = await fileExists(folderPath);\n await ensureDirectory(folderPath);\n const relativePath = path.relative(targetDir, folderPath);\n if (exists) {\n skippedFiles.push(relativePath);\n } else {\n createdFiles.push(relativePath);\n }\n }\n\n const controllerFolder = structure.domainFolders.includes('controllers')\n ? 'controllers'\n : structure.domainFolders[0];\n const controllerPath = path.join(domainBase, controllerFolder, 'hello.get.controller.ts');\n const controllerCreated = await writeFileSafe(\n controllerPath,\n `import type { Request, Response } from 'express';\\nimport { GetController } from '@forinda/kickjs';\\n\\nexport default class HelloGetController extends GetController {\\n handle(_req: Request, res: Response) {\\n return this.ok(res, { message: 'Hello from Kick!' });\\n }\\n}\\n`,\n { force }\n );\n const relativeControllerPath = path.relative(targetDir, controllerPath);\n controllerCreated ? createdFiles.push(relativeControllerPath) : skippedFiles.push(relativeControllerPath);\n\n const appConfigDir = path.join(targetDir, 'src', 'config');\n await ensureDirectory(appConfigDir);\n const appConfigPath = path.join(appConfigDir, 'kick.config.ts');\n const appConfigCreated = await writeFileSafe(\n appConfigPath,\n buildAppConfigFile(structure),\n { force }\n );\n const relativeAppConfig = path.relative(targetDir, appConfigPath);\n appConfigCreated ? createdFiles.push(relativeAppConfig) : skippedFiles.push(relativeAppConfig);\n\n const configPath = path.join(targetDir, 'kick.config.ts');\n const configCreated = await writeFileSafe(\n configPath,\n buildConfigFile(structure),\n { force }\n );\n configCreated ? createdFiles.push('kick.config.ts') : skippedFiles.push('kick.config.ts');\n\n return { createdFiles, skippedFiles };\n}\n\nfunction normalizeStructure(structure?: KickStructureConfig): Required<KickStructureConfig> {\n return {\n domainRoot: structure?.domainRoot ?? 'src/domains',\n domainFolders:\n structure?.domainFolders && structure.domainFolders.length > 0\n ? [...structure.domainFolders]\n : ['controllers', 'services', 'domain'],\n defaultDomain: structure?.defaultDomain ?? 'app'\n };\n}\n\nfunction buildConfigFile(structure: Required<KickStructureConfig>) {\n const controllerRoot = `${structure.domainRoot}/${structure.defaultDomain}/controllers`;\n const structureSnippet = JSON.stringify(structure, null, 2)\n .split('\\n')\n .map((line, index) => (index === 0 ? line : ` ${line}`))\n .join('\\n');\n\n return `import type { KickConfig } from '@forinda/kickjs';\\n\\nconst config: KickConfig = {\\n structure: ${structureSnippet},\\n generators: {\\n controllerRoot: '${controllerRoot}'\\n },\\n commands: [\\n {\\n name: 'dev',\\n description: 'Run the Kick dev server',\\n steps: 'npm run dev'\\n }\\n ]\\n};\\n\\nexport default config;\\n`;\n}\n\nfunction buildAppConfigFile(structure: Required<KickStructureConfig>) {\n const controllerRoot = `${structure.domainRoot}/${structure.defaultDomain}/controllers`;\n const roots = [controllerRoot, 'src/http'].map((root) => `'${root}'`).join(', ');\n\n return `import { createKickConfig } from '@forinda/kickjs';\\n\\nexport default createKickConfig({\\n defaults: {\\n prefix: '/api',\\n api: {\\n discovery: {\\n roots: [${roots}]\\n }\\n }\\n },\\n env: {\\n KICK_PREFIX: 'prefix',\\n KICK_HEALTH: 'healthEndpoint',\\n KICK_LOG_LEVEL: { path: 'logging.level' }\\n }\\n});\\n`;\n}\n","import { promises as fs } from 'node:fs';\nimport path from 'node:path';\n\nexport async function ensureDirectory(target: string) {\n await fs.mkdir(target, { recursive: true });\n}\n\nexport async function writeFileSafe(filePath: string, content: string, options: { force?: boolean } = {}) {\n const { force = false } = options;\n try {\n if (!force) {\n await fs.access(filePath);\n return false;\n }\n } catch (error) {\n // File does not exist, safe to write\n }\n\n await ensureDirectory(path.dirname(filePath));\n await fs.writeFile(filePath, content, 'utf8');\n return true;\n}\n\nexport async function fileExists(filePath: string) {\n try {\n await fs.access(filePath);\n return true;\n } catch (error) {\n return false;\n }\n}\n\nexport async function readJsonFile<T>(filePath: string): Promise<T | undefined> {\n try {\n const raw = await fs.readFile(filePath, 'utf8');\n return JSON.parse(raw) as T;\n } catch (error) {\n return undefined;\n }\n}\n\nexport async function writeJsonFile(filePath: string, data: unknown, options: { force?: boolean } = {}) {\n await writeFileSafe(filePath, `${JSON.stringify(data, null, 2)}\\n`, options);\n}\n","import type { Command } from 'commander';\nimport { initProject } from '../tasks/init-project';\nimport type { KickStructureConfig } from '../types';\n\nexport function registerInitCommand(program: Command, defaults: { structure?: KickStructureConfig } = {}) {\n program\n .command('init [directory]')\n .description('Scaffold a new Kick project in the target directory')\n .option('-f, --force', 'Overwrite existing files when scaffolding', false)\n .option('-n, --name <packageName>', 'Package name to use in package.json')\n .action(async (directory: string | undefined, options: { force?: boolean; name?: string }) => {\n const targetDirectory = directory ?? '.';\n const result = await initProject({\n targetDirectory,\n force: options.force,\n packageName: options.name,\n structure: defaults.structure\n });\n\n if (result.createdFiles.length > 0) {\n console.log(`Created files:\\n - ${result.createdFiles.join('\\n - ')}`);\n }\n if (result.skippedFiles.length > 0) {\n console.log(`Skipped existing files:\\n - ${result.skippedFiles.join('\\n - ')}`);\n }\n\n console.log('Project scaffold complete. Run \"npm install\" to install dependencies.');\n });\n}\n","import path from 'node:path';\nimport { writeFileSafe } from '../utils/fs';\n\nconst SUPPORTED_METHODS = ['get', 'post', 'put', 'patch', 'delete'] as const;\n\nexport type SupportedMethod = (typeof SUPPORTED_METHODS)[number];\n\nexport interface GenerateControllerOptions {\n name: string;\n method?: SupportedMethod | string;\n root?: string;\n force?: boolean;\n tags?: string[];\n}\n\nexport interface GenerateControllerResult {\n filePath: string;\n created: boolean;\n}\n\nexport async function generateController(options: GenerateControllerOptions): Promise<GenerateControllerResult> {\n const method = normalizeMethod(options.method);\n const root = options.root ?? 'src/http';\n const rootPath = path.isAbsolute(root) ? root : path.join(process.cwd(), root);\n const normalizedName = options.name.replace(/\\\\/g, '/');\n const segments = normalizedName.split('/').filter(Boolean);\n const fileSegment = segments.pop() ?? 'index';\n\n const relativeDir = segments.join('/');\n const fileName = `${fileSegment}.${method}.controller.ts`;\n const targetFile = path.join(rootPath, relativeDir, fileName);\n\n const className = buildClassName([...segments, fileSegment], method);\n const methodController = `${capitalize(method)}Controller`;\n\n const template = buildTemplate({ className, methodController, method, tags: options.tags });\n\n const created = await writeFileSafe(targetFile, template, { force: options.force });\n\n return { filePath: targetFile, created };\n}\n\nfunction normalizeMethod(raw?: string): SupportedMethod {\n const method = (raw ?? 'get').toLowerCase();\n if (!SUPPORTED_METHODS.includes(method as SupportedMethod)) {\n throw new Error(`Unsupported method \"${raw}\". Supported methods: ${SUPPORTED_METHODS.join(', ')}`);\n }\n return method as SupportedMethod;\n}\n\nfunction buildTemplate(params: {\n className: string;\n methodController: string;\n method: SupportedMethod;\n tags?: string[];\n}) {\n const tagsBlock = params.tags && params.tags.length > 0 ? ` static tags = ${JSON.stringify(params.tags)};\\n\\n` : '';\n\n const requestType = params.method === 'get' || params.method === 'delete' ? 'Request' : 'Request';\n\n return `import type { Request, Response } from 'express';\\nimport { ${params.methodController} } from '@forinda/kickjs';\\n\\nexport default class ${params.className} extends ${params.methodController} {\\n${tagsBlock} handle(_req: ${requestType}, res: Response) {\\n return this.ok(res, { message: '${humanize(params.method)} ${params.className}' });\\n }\\n}\\n`;\n}\n\nfunction humanize(method: string) {\n return method.toUpperCase();\n}\n\nfunction buildClassName(segments: string[], method: string) {\n const normalizedSegments = segments\n .map((segment) => segment.replace(/\\.\\.\\./g, 'Rest'))\n .map((segment) => segment.replace(/\\[(.+?)]/g, '$1'))\n .flatMap((segment) => segment.split(/[^a-zA-Z0-9]+/g))\n .filter(Boolean)\n .map(capitalize);\n\n if (normalizedSegments.length === 0) {\n normalizedSegments.push('Root');\n }\n\n normalizedSegments.push(capitalize(method), 'Controller');\n return normalizedSegments.join('');\n}\n\nfunction capitalize(value: string) {\n return value.charAt(0).toUpperCase() + value.slice(1);\n}\n","import path from 'node:path';\nimport { ensureDirectory, writeFileSafe, fileExists } from '../utils/fs';\nimport type { KickStructureConfig } from '../types';\n\nexport interface GenerateDomainOptions {\n name: string;\n structure?: KickStructureConfig;\n force?: boolean;\n withController?: boolean;\n}\n\nexport interface GenerateDomainResult {\n root: string;\n createdFolders: string[];\n existingFolders: string[];\n controllerPath?: string;\n controllerCreated?: boolean;\n}\n\nexport async function generateDomain(options: GenerateDomainOptions): Promise<GenerateDomainResult> {\n const structure = options.structure ?? {\n domainRoot: 'src/domains',\n domainFolders: ['controllers', 'services', 'domain'],\n defaultDomain: 'app'\n };\n\n const domainRoot = structure.domainRoot ?? 'src/domains';\n const domainRootBase = path.isAbsolute(domainRoot) ? domainRoot : path.join(process.cwd(), domainRoot);\n const folders = structure.domainFolders && structure.domainFolders.length > 0 ? structure.domainFolders : ['controllers'];\n const targetRoot = path.join(domainRootBase, options.name);\n\n const createdFolders: string[] = [];\n const existingFolders: string[] = [];\n\n for (const folder of folders) {\n const folderPath = path.join(targetRoot, folder);\n const alreadyExists = await fileExists(folderPath);\n await ensureDirectory(folderPath);\n if (alreadyExists) {\n existingFolders.push(path.relative(process.cwd(), folderPath));\n } else {\n createdFolders.push(path.relative(process.cwd(), folderPath));\n }\n }\n\n let controllerPath: string | undefined;\n let controllerCreated: boolean | undefined;\n\n if (options.withController !== false && folders.includes('controllers')) {\n controllerPath = path.join(targetRoot, 'controllers', 'index.get.controller.ts');\n controllerCreated = await writeFileSafe(\n controllerPath,\n `import type { Request, Response } from 'express';\\nimport { GetController } from '@forinda/kickjs';\\n\\nexport default class ${capitalize(options.name)}IndexGetController extends GetController {\\n handle(_req: Request, res: Response) {\\n return this.ok(res, { domain: '${options.name}', message: 'Hello from ${options.name}' });\\n }\\n}\\n`,\n { force: options.force }\n );\n if (controllerCreated) {\n createdFolders.push(path.relative(process.cwd(), controllerPath));\n } else if (controllerPath) {\n existingFolders.push(path.relative(process.cwd(), controllerPath));\n }\n }\n\n return {\n root: targetRoot,\n createdFolders,\n existingFolders,\n controllerPath,\n controllerCreated\n };\n}\n\nfunction capitalize(value: string) {\n if (!value) {\n return 'Domain';\n }\n return value.charAt(0).toUpperCase() + value.slice(1);\n}\n","import type { Command } from 'commander';\nimport { generateController } from '../tasks/generate-controller';\nimport type { KickStructureConfig } from '../types';\nimport { generateDomain } from '../tasks/generate-domain';\n\nexport function registerGeneratorCommands(\n program: Command,\n defaults: { controllerRoot?: string; structure?: KickStructureConfig } = {}\n) {\n const generate = program.command('generate').description('Generate Kick resources');\n\n generate\n .command('domain <name>')\n .description('Scaffold a domain folder with optional default files')\n .option('-f, --force', 'Overwrite existing generated files', false)\n .option('--no-controller', 'Do not create a default controller')\n .action(async (name: string, options: { force?: boolean; controller?: boolean }) => {\n const result = await generateDomain({\n name,\n structure: defaults.structure,\n force: options.force,\n withController: options.controller\n });\n\n console.log(`Domain root: ${result.root}`);\n if (result.createdFolders.length > 0) {\n console.log(`Created:\\n - ${result.createdFolders.join('\\n - ')}`);\n }\n if (result.existingFolders.length > 0) {\n console.log(`Existing:\\n - ${result.existingFolders.join('\\n - ')}`);\n }\n });\n\n generate\n .command('controller <name>')\n .description('Generate a file-system discovered controller')\n .option('-m, --method <verb>', 'HTTP verb to use (get, post, put, patch, delete)', 'get')\n .option('-r, --root <path>', 'Root directory for generated controllers', defaults.controllerRoot ?? 'src/http')\n .option('-f, --force', 'Overwrite the controller if it already exists', false)\n .option('--tags <tags>', 'Comma separated tags to assign to the controller')\n .action(async (name: string, options: { method?: string; root?: string; force?: boolean; tags?: string }) => {\n const tags = options.tags\n ? options.tags\n .split(',')\n .map((tag) => tag.trim())\n .filter(Boolean)\n : undefined;\n\n const defaultRoot = computeDefaultControllerRoot(defaults, name);\n const result = await generateController({\n name,\n method: options.method,\n root: options.root ?? defaultRoot,\n force: options.force,\n tags\n });\n\n if (result.created) {\n console.log(`Created controller at ${result.filePath}`);\n } else {\n console.log(`Controller already exists at ${result.filePath}`);\n }\n });\n}\n\nfunction computeDefaultControllerRoot(\n defaults: { controllerRoot?: string; structure?: KickStructureConfig },\n name: string\n) {\n if (defaults.controllerRoot) {\n return defaults.controllerRoot;\n }\n\n const structure = defaults.structure;\n if (!structure) {\n return 'src/http';\n }\n\n const domainRoot = structure.domainRoot ?? 'src/domains';\n const defaultDomain = structure.defaultDomain ?? 'app';\n\n if (name.includes('/')) {\n const [maybeDomain] = name.split('/');\n return `${domainRoot}/${maybeDomain}/controllers`;\n }\n\n return `${domainRoot}/${defaultDomain}/controllers`;\n}\n","import { existsSync, promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { KickConfig, KickStructureConfig } from './types';\nimport { createError } from '../utils/errors';\n\nconst CONFIG_FILE_CANDIDATES = [\n 'kick.config.ts',\n 'kick.config.js',\n 'kick.config.mjs',\n 'kick.config.cjs',\n 'kick.config.json'\n];\n\nlet tsNodeRegistered = false;\n\nexport async function loadKickConfig(cwd = process.cwd()): Promise<KickConfig | undefined> {\n for (const file of CONFIG_FILE_CANDIDATES) {\n const absolute = path.join(cwd, file);\n if (!existsSync(absolute)) {\n continue;\n }\n\n if (file.endsWith('.json')) {\n const raw = await fs.readFile(absolute, 'utf8');\n return normalizeConfig(JSON.parse(raw));\n }\n\n if (file.endsWith('.ts')) {\n ensureTsNode();\n }\n\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const loaded = require(absolute);\n const config = loaded?.default ?? loaded;\n return normalizeConfig(config);\n }\n\n return undefined;\n}\n\nfunction ensureTsNode() {\n if (tsNodeRegistered) {\n return;\n }\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n require('ts-node/register');\n tsNodeRegistered = true;\n } catch (error) {\n throw createError('TS_NODE_REQUIRED', 'Custom CLI config requires ts-node for TypeScript configuration files.');\n }\n}\n\nfunction normalizeConfig(raw: unknown): KickConfig {\n if (!raw || typeof raw !== 'object') {\n throw createError('INVALID_CLI_CONFIG', 'kick.config must export an object');\n }\n\n const config = raw as KickConfig;\n const normalized: KickConfig = {};\n\n if (Array.isArray(config.commands)) {\n normalized.commands = config.commands.map((command) => {\n if (!command || typeof command !== 'object') {\n throw createError('INVALID_CLI_COMMAND', 'Command entries must be objects');\n }\n if (!command.name) {\n throw createError('INVALID_CLI_COMMAND', 'Command entries must include a name');\n }\n\n return {\n name: command.name,\n description: command.description,\n steps: Array.isArray(command.steps)\n ? [...command.steps]\n : command.steps\n ? [command.steps]\n : []\n };\n });\n }\n\n if (config.generators) {\n normalized.generators = {\n controllerRoot: config.generators.controllerRoot ?? undefined\n };\n }\n\n if (config.structure) {\n normalized.structure = normalizeStructureConfig(config.structure);\n }\n\n return normalized;\n}\n\nexport type { KickConfig } from './types';\n\nfunction normalizeStructureConfig(raw: KickStructureConfig): KickStructureConfig {\n return {\n domainRoot: raw.domainRoot ?? 'src/domains',\n domainFolders: Array.isArray(raw.domainFolders) && raw.domainFolders.length > 0 ? [...raw.domainFolders] : ['controllers', 'services', 'domain'],\n defaultDomain: raw.defaultDomain ?? 'app'\n };\n}\n","export interface AppErrorOptions {\n status?: number;\n cause?: unknown;\n details?: Record<string, unknown>;\n}\n\nexport class AppError extends Error {\n readonly code: string;\n readonly status?: number;\n readonly details?: Record<string, unknown>;\n\n constructor(code: string, message: string, options: AppErrorOptions = {}) {\n super(message);\n this.code = code;\n this.status = options.status;\n this.details = options.details;\n\n if (options.cause) {\n // @ts-expect-error cause is standard on Error but not typed in older TS libs\n this.cause = options.cause;\n }\n\n this.name = 'AppError';\n }\n}\n\nexport function createError(code: string, message: string, options: AppErrorOptions = {}) {\n return new AppError(code, message, options);\n}\n\nexport function isAppError(error: unknown): error is AppError {\n return error instanceof AppError;\n}\n","import { spawn } from 'node:child_process';\n\nexport function runShellCommand(command: string, options: { cwd?: string } = {}) {\n return new Promise<void>((resolve, reject) => {\n const child = spawn(command, {\n cwd: options.cwd,\n stdio: 'inherit',\n shell: true\n });\n\n child.on('exit', (code) => {\n if (code === 0) {\n resolve();\n } else {\n reject(new Error(`Command failed with exit code ${code}: ${command}`));\n }\n });\n\n child.on('error', (error) => {\n reject(error);\n });\n });\n}\n","import type { Command } from 'commander';\nimport { KickConfig } from '../config';\nimport { runShellCommand } from '../utils/shell';\n\nexport function registerCustomCommands(program: Command, config?: KickConfig) {\n if (!config?.commands) {\n return;\n }\n\n config.commands.forEach((command) => {\n const cmd = program\n .command(command.name)\n .description(command.description ?? 'Custom command defined in kick.config');\n\n cmd.action(async () => {\n if (!command.steps || command.steps.length === 0) {\n console.warn(`No steps defined for command \"${command.name}\".`);\n return;\n }\n\n for (const step of command.steps) {\n await runShellCommand(step);\n }\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uBAAwB;;;ACDxB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,OAAS;AAAA,EACT,SAAW;AAAA,IACT,KAAK;AAAA,MACH,SAAW;AAAA,MACX,OAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,OAAS;AAAA,IACP;AAAA,EACF;AAAA,EACA,KAAO;AAAA,IACL,MAAQ;AAAA,EACV;AAAA,EACA,SAAW;AAAA,IACT,OAAS;AAAA,IACT,KAAO;AAAA,IACP,OAAS;AAAA,IACT,OAAS;AAAA,IACT,OAAS;AAAA,IACT,gBAAkB;AAAA,IAClB,MAAQ;AAAA,IACR,cAAc;AAAA,IACd,SAAW;AAAA,EACb;AAAA,EACA,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,QAAU;AAAA,EACV,SAAW;AAAA,EACX,SAAW;AAAA,IACT,MAAQ;AAAA,EACV;AAAA,EACA,eAAiB;AAAA,IACf,QAAU;AAAA,EACZ;AAAA,EACA,cAAgB;AAAA,IACd,WAAa;AAAA,IACb,SAAW;AAAA,IACX,WAAa;AAAA,IACb,oBAAoB;AAAA,EACtB;AAAA,EACA,iBAAmB;AAAA,IACjB,aAAa;AAAA,IACb,kBAA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AAA;AACF;AArBgBd;;;AXIhB,eAAegB,OAAAA;AACb,QAAMC,UAAU,IAAIC,yBAAAA;AACpBD,UAAQE,KAAK,MAAA,EAAQC,YAAY,kBAAA,EAAoBC,QAAQC,gBAAID,WAAW,OAAA;AAE5E,QAAME,SAAS,MAAMC,eAAeC,QAAQC,IAAG,CAAA;AAE/CC,sBAAoBV,SAAS;IAAEW,WAAWL,QAAQK;EAAU,CAAA;AAC5DC,4BAA0BZ,SAAS;IACjCa,gBAAgBP,QAAQQ,YAAYD;IACpCF,WAAWL,QAAQK;EACrB,CAAA;AACAI,yBAAuBf,SAASM,MAAAA;AAEhCN,UAAQgB,mBAAkB;AAE1B,MAAI;AACF,UAAMhB,QAAQiB,WAAWT,QAAQU,IAAI;EACvC,SAASC,OAAO;AACdC,YAAQD,MAAMA,iBAAiBE,QAAQF,MAAMG,UAAUH,KAAAA;AACvDX,YAAQe,WAAW;EACrB;AACF;AArBexB;AAuBfA,KAAAA,EAAOyB,MAAM,CAACL,UAAAA;AACZC,UAAQD,MAAMA,iBAAiBE,QAAQF,MAAMG,UAAUH,KAAAA;AACvDX,UAAQe,WAAW;AACrB,CAAA;","names":["import_node_path","ensureDirectory","target","fs","mkdir","recursive","writeFileSafe","filePath","content","options","force","access","error","path","dirname","writeFile","fileExists","readJsonFile","raw","readFile","JSON","parse","undefined","writeJsonFile","data","stringify","initProject","options","targetDir","path","resolve","process","cwd","targetDirectory","force","structure","normalizeStructure","createdFiles","skippedFiles","ensureDirectory","packageJsonPath","join","packageJson","readJsonFile","Object","keys","length","name","packageName","basename","replace","writeJsonFile","version","private","type","scripts","dev","build","start","test","dependencies","devDependencies","typescript","tsx","tsup","vitest","push","tsconfigPath","tsconfigExists","fileExists","compilerOptions","target","module","moduleResolution","lib","rootDir","outDir","strict","esModuleInterop","skipLibCheck","resolveJsonModule","experimentalDecorators","emitDecoratorMetadata","include","mainFilePath","mainCreated","writeFileSafe","domainBase","domainRoot","defaultDomain","folder","domainFolders","folderPath","exists","relativePath","relative","controllerFolder","includes","controllerPath","controllerCreated","relativeControllerPath","appConfigDir","appConfigPath","appConfigCreated","buildAppConfigFile","relativeAppConfig","configPath","configCreated","buildConfigFile","controllerRoot","structureSnippet","JSON","stringify","split","map","line","index","roots","root","registerInitCommand","program","defaults","command","description","option","action","directory","options","targetDirectory","result","initProject","force","packageName","name","structure","createdFiles","length","console","log","join","skippedFiles","import_node_path","SUPPORTED_METHODS","generateController","options","method","normalizeMethod","root","rootPath","path","isAbsolute","join","process","cwd","normalizedName","name","replace","segments","split","filter","Boolean","fileSegment","pop","relativeDir","fileName","targetFile","className","buildClassName","methodController","capitalize","template","buildTemplate","tags","created","writeFileSafe","force","filePath","raw","toLowerCase","includes","Error","params","tagsBlock","length","JSON","stringify","requestType","humanize","toUpperCase","normalizedSegments","map","segment","flatMap","push","value","charAt","slice","import_node_path","generateDomain","options","structure","domainRoot","domainFolders","defaultDomain","domainRootBase","path","isAbsolute","join","process","cwd","folders","length","targetRoot","name","createdFolders","existingFolders","folder","folderPath","alreadyExists","fileExists","ensureDirectory","push","relative","controllerPath","controllerCreated","withController","includes","writeFileSafe","capitalize","force","root","value","charAt","toUpperCase","slice","registerGeneratorCommands","program","defaults","generate","command","description","option","action","name","options","result","generateDomain","structure","force","withController","controller","console","log","root","createdFolders","length","join","existingFolders","controllerRoot","tags","split","map","tag","trim","filter","Boolean","undefined","defaultRoot","computeDefaultControllerRoot","generateController","method","created","filePath","domainRoot","defaultDomain","includes","maybeDomain","import_node_fs","import_node_path","AppError","Error","code","status","details","message","options","cause","name","createError","CONFIG_FILE_CANDIDATES","tsNodeRegistered","loadKickConfig","cwd","process","file","absolute","path","join","existsSync","endsWith","raw","fs","readFile","normalizeConfig","JSON","parse","ensureTsNode","loaded","require","config","default","undefined","error","createError","normalized","Array","isArray","commands","map","command","name","description","steps","generators","controllerRoot","structure","normalizeStructureConfig","domainRoot","domainFolders","length","defaultDomain","runShellCommand","command","options","Promise","resolve","reject","child","spawn","cwd","stdio","shell","on","code","Error","error","registerCustomCommands","program","config","commands","forEach","command","cmd","name","description","action","steps","length","console","warn","step","runShellCommand","main","program","Command","name","description","version","pkg","config","loadKickConfig","process","cwd","registerInitCommand","structure","registerGeneratorCommands","controllerRoot","generators","registerCustomCommands","showHelpAfterError","parseAsync","argv","error","console","Error","message","exitCode","catch"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { RequestHandler, Request, Response, NextFunction, Application } from 'ex
|
|
|
2
2
|
import { Server } from 'http';
|
|
3
3
|
import { Container, ServiceIdentifier } from 'inversify';
|
|
4
4
|
|
|
5
|
+
type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
5
6
|
interface ControllerOptions {
|
|
6
7
|
path?: string;
|
|
7
8
|
autoRegister?: boolean;
|
|
@@ -135,18 +136,65 @@ interface TelemetryConfig {
|
|
|
135
136
|
trackReactiveHistory?: boolean;
|
|
136
137
|
requestHistoryLimit?: number;
|
|
137
138
|
}
|
|
139
|
+
interface ControllerDiscoveryConfig {
|
|
140
|
+
enabled?: boolean;
|
|
141
|
+
roots?: string[];
|
|
142
|
+
suffix?: string;
|
|
143
|
+
extensions?: string[];
|
|
144
|
+
baseRoute?: string;
|
|
145
|
+
segmentSeparator?: string;
|
|
146
|
+
enforceStructure?: boolean;
|
|
147
|
+
registerGlobally?: boolean;
|
|
148
|
+
ignore?: string[];
|
|
149
|
+
tagsFromDirectories?: boolean;
|
|
150
|
+
allowStaticRoutes?: boolean;
|
|
151
|
+
}
|
|
152
|
+
interface ApiConfig {
|
|
153
|
+
discovery?: ControllerDiscoveryConfig;
|
|
154
|
+
}
|
|
138
155
|
interface AppConfig {
|
|
139
156
|
prefix?: string;
|
|
140
157
|
healthEndpoint?: string | false;
|
|
141
158
|
logging?: LoggerConfig;
|
|
142
159
|
telemetry?: TelemetryConfig;
|
|
160
|
+
api?: ApiConfig;
|
|
161
|
+
}
|
|
162
|
+
type AppConfigPath = 'prefix' | 'healthEndpoint' | 'logging.level' | 'telemetry.trackReactiveHistory' | 'telemetry.requestHistoryLimit' | 'api.discovery.enabled' | 'api.discovery.roots' | 'api.discovery.baseRoute';
|
|
163
|
+
interface ResolvedControllerDiscoveryConfig {
|
|
164
|
+
enabled: boolean;
|
|
165
|
+
roots: string[];
|
|
166
|
+
suffix: string;
|
|
167
|
+
extensions: string[];
|
|
168
|
+
baseRoute: string;
|
|
169
|
+
segmentSeparator: string;
|
|
170
|
+
enforceStructure: boolean;
|
|
171
|
+
registerGlobally: boolean;
|
|
172
|
+
ignore: string[];
|
|
173
|
+
tagsFromDirectories: boolean;
|
|
174
|
+
allowStaticRoutes: boolean;
|
|
175
|
+
}
|
|
176
|
+
interface ResolvedApiConfig {
|
|
177
|
+
discovery: ResolvedControllerDiscoveryConfig;
|
|
143
178
|
}
|
|
144
179
|
interface ResolvedAppConfig {
|
|
145
180
|
prefix: string;
|
|
146
181
|
healthEndpoint: string | false;
|
|
147
182
|
logging: Required<LoggerConfig>;
|
|
148
183
|
telemetry: Required<TelemetryConfig>;
|
|
184
|
+
api: ResolvedApiConfig;
|
|
185
|
+
}
|
|
186
|
+
interface EnvBindingOptions<T = unknown> {
|
|
187
|
+
path: AppConfigPath;
|
|
188
|
+
transform?: (value: string, env: NodeJS.ProcessEnv) => T;
|
|
189
|
+
}
|
|
190
|
+
type EnvBinding = AppConfigPath | EnvBindingOptions | ((value: string, env: NodeJS.ProcessEnv) => AppConfig);
|
|
191
|
+
interface CreateKickConfigOptions {
|
|
192
|
+
defaults?: AppConfig;
|
|
193
|
+
env?: Record<string, EnvBinding>;
|
|
194
|
+
overrides?: AppConfig | ((config: AppConfig) => AppConfig);
|
|
195
|
+
envFiles?: string[] | false;
|
|
149
196
|
}
|
|
197
|
+
declare function createKickConfig(options?: CreateKickConfigOptions): AppConfig;
|
|
150
198
|
declare function configureApp(config: AppConfig): void;
|
|
151
199
|
declare function getAppConfig(): ResolvedAppConfig;
|
|
152
200
|
declare function resolveConfig(overrides?: AppConfig): ResolvedAppConfig;
|
|
@@ -173,8 +221,8 @@ declare class RequestTracker {
|
|
|
173
221
|
}
|
|
174
222
|
|
|
175
223
|
declare abstract class BaseController {
|
|
176
|
-
private
|
|
177
|
-
|
|
224
|
+
private injectedTracker?;
|
|
225
|
+
private runtimeTracker?;
|
|
178
226
|
protected abstract controllerId(): string;
|
|
179
227
|
protected ok<T>(res: Response, payload: T): Response<any, Record<string, any>>;
|
|
180
228
|
protected created<T>(res: Response, payload: T): Response<any, Record<string, any>>;
|
|
@@ -188,7 +236,62 @@ declare abstract class BaseController {
|
|
|
188
236
|
protected mergeRequestMetadata(res: Response, patch: Record<string, unknown>): void;
|
|
189
237
|
protected getRequestState(res: Response): RequestState | undefined;
|
|
190
238
|
protected fail(code: string, message: string, options?: AppErrorOptions): never;
|
|
239
|
+
attachRequestTracker(tracker: RequestTracker): void;
|
|
240
|
+
private ensureTracker;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Base class for controllers that target a specific HTTP verb. Each discovered controller
|
|
245
|
+
* should extend one of the verb specific classes so that single responsibility is enforced.
|
|
246
|
+
*/
|
|
247
|
+
declare abstract class HttpVerbController<Req extends Request = Request, Res extends Response = Response, Result = unknown> extends BaseController {
|
|
248
|
+
/**
|
|
249
|
+
* Return the HTTP method associated with this controller. Static so discovery can consume it
|
|
250
|
+
* without instantiating the controller (which would require container dependencies).
|
|
251
|
+
*/
|
|
252
|
+
static method(): HttpMethod;
|
|
253
|
+
/** HTTP method instance mirror for convenience in handlers/tests. */
|
|
254
|
+
readonly httpMethod: HttpMethod;
|
|
255
|
+
/**
|
|
256
|
+
* Optional static override for the route path. When provided, discovery will use this value
|
|
257
|
+
* instead of deriving the path from the file-system location.
|
|
258
|
+
*/
|
|
259
|
+
static route?: string;
|
|
260
|
+
/**
|
|
261
|
+
* Optional static tags collection. These map to the controller metadata and can be used by
|
|
262
|
+
* diagnostics tooling.
|
|
263
|
+
*/
|
|
264
|
+
static tags?: string[];
|
|
265
|
+
protected controllerId(): string;
|
|
266
|
+
/**
|
|
267
|
+
* Handle the request for the configured HTTP verb.
|
|
268
|
+
*/
|
|
269
|
+
abstract handle(req: Req, res: Res, next: NextFunction): Result | Promise<Result>;
|
|
270
|
+
}
|
|
271
|
+
declare abstract class GetController<Req extends Request = Request, Res extends Response = Response, Result = unknown> extends HttpVerbController<Req, Res, Result> {
|
|
272
|
+
static method(): HttpMethod;
|
|
273
|
+
}
|
|
274
|
+
declare abstract class PostController<Req extends Request = Request, Res extends Response = Response, Result = unknown> extends HttpVerbController<Req, Res, Result> {
|
|
275
|
+
static method(): HttpMethod;
|
|
276
|
+
}
|
|
277
|
+
declare abstract class PutController<Req extends Request = Request, Res extends Response = Response, Result = unknown> extends HttpVerbController<Req, Res, Result> {
|
|
278
|
+
static method(): HttpMethod;
|
|
191
279
|
}
|
|
280
|
+
declare abstract class PatchController<Req extends Request = Request, Res extends Response = Response, Result = unknown> extends HttpVerbController<Req, Res, Result> {
|
|
281
|
+
static method(): HttpMethod;
|
|
282
|
+
}
|
|
283
|
+
declare abstract class DeleteController<Req extends Request = Request, Res extends Response = Response, Result = unknown> extends HttpVerbController<Req, Res, Result> {
|
|
284
|
+
static method(): HttpMethod;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
interface DiscoveredController {
|
|
288
|
+
controller: ControllerConstructor;
|
|
289
|
+
filePath: string;
|
|
290
|
+
route: string;
|
|
291
|
+
method: HttpMethod;
|
|
292
|
+
tags: string[];
|
|
293
|
+
}
|
|
294
|
+
declare function discoverControllersFromFilesystem(config: ResolvedControllerDiscoveryConfig): DiscoveredController[];
|
|
192
295
|
|
|
193
296
|
interface StoreSnapshot {
|
|
194
297
|
id: string;
|
|
@@ -220,6 +323,9 @@ interface CreateAppResult {
|
|
|
220
323
|
requestTracker: RequestTracker;
|
|
221
324
|
diagnostics: AppDiagnostics;
|
|
222
325
|
config: ResolvedAppConfig;
|
|
326
|
+
discovery: {
|
|
327
|
+
controllers: DiscoveredController[];
|
|
328
|
+
};
|
|
223
329
|
}
|
|
224
330
|
interface BootstrapOptions extends CreateAppOptions {
|
|
225
331
|
port?: number | string;
|
|
@@ -231,11 +337,35 @@ interface BootstrapContext {
|
|
|
231
337
|
requestTracker: RequestTracker;
|
|
232
338
|
diagnostics: AppDiagnostics;
|
|
233
339
|
config: ResolvedAppConfig;
|
|
340
|
+
discovery: {
|
|
341
|
+
controllers: DiscoveredController[];
|
|
342
|
+
};
|
|
234
343
|
shutdown(): void;
|
|
235
344
|
}
|
|
236
345
|
declare function createApp(options?: CreateAppOptions): CreateAppResult;
|
|
237
346
|
declare function bootstrap(options?: BootstrapOptions): Promise<BootstrapContext>;
|
|
238
347
|
|
|
348
|
+
type CommandStep = string;
|
|
349
|
+
interface KickCommandDefinition {
|
|
350
|
+
name: string;
|
|
351
|
+
description?: string;
|
|
352
|
+
steps?: CommandStep | CommandStep[];
|
|
353
|
+
}
|
|
354
|
+
interface KickGeneratorsConfig {
|
|
355
|
+
controllerRoot?: string;
|
|
356
|
+
}
|
|
357
|
+
interface KickCliConfig {
|
|
358
|
+
commands?: KickCommandDefinition[];
|
|
359
|
+
generators?: KickGeneratorsConfig;
|
|
360
|
+
structure?: KickStructureConfig;
|
|
361
|
+
}
|
|
362
|
+
interface KickStructureConfig {
|
|
363
|
+
domainRoot?: string;
|
|
364
|
+
domainFolders?: string[];
|
|
365
|
+
defaultDomain?: string;
|
|
366
|
+
}
|
|
367
|
+
type KickConfig = KickCliConfig;
|
|
368
|
+
|
|
239
369
|
type BindingIdentifier<T = unknown> = ServiceIdentifier<T>;
|
|
240
370
|
declare function Injectable(): ClassDecorator;
|
|
241
371
|
declare function Inject<T = unknown>(identifier: BindingIdentifier<T>): MethodDecorator & ParameterDecorator & PropertyDecorator;
|
|
@@ -245,4 +375,4 @@ declare function Named(name: string | number | symbol): MethodDecorator & Parame
|
|
|
245
375
|
declare function Tagged(metadataKey: string | number | symbol, metadataValue: unknown): MethodDecorator & ParameterDecorator & PropertyDecorator;
|
|
246
376
|
declare function Unmanaged(): MethodDecorator & ParameterDecorator & PropertyDecorator;
|
|
247
377
|
|
|
248
|
-
export { type AppConfig, AppDiagnostics, AppError, type AppErrorOptions, type AppState, BaseController, type BindingIdentifier, type BootstrapContext, type BootstrapOptions, Controller, type ControllerConstructor, type CreateAppOptions, type CreateAppResult, Delete, Get, Inject, Injectable, MultiInject, Named, Optional, Patch, Post, Put, type RequestLogEntry, type RequestState, RequestTracker, type ResolvedAppConfig, type RouteOptions, type RouteValidation, TYPES, Tagged, Unmanaged, bootstrap, configureApp, createApp, createError, getAppConfig, isAppError, listRegisteredControllers, registerController, resetAppConfig, resetControllerRegistry, resolveConfig };
|
|
378
|
+
export { type ApiConfig, type AppConfig, type AppConfigPath, AppDiagnostics, AppError, type AppErrorOptions, type AppState, BaseController, type BindingIdentifier, type BootstrapContext, type BootstrapOptions, Controller, type ControllerConstructor, type ControllerDiscoveryConfig, type CreateAppOptions, type CreateAppResult, type CreateKickConfigOptions, Delete, DeleteController, type DiscoveredController, type EnvBinding, type EnvBindingOptions, Get, GetController, HttpVerbController, Inject, Injectable, type KickCliConfig, type KickCommandDefinition, type KickConfig, type KickStructureConfig, MultiInject, Named, Optional, Patch, PatchController, Post, PostController, Put, PutController, type RequestLogEntry, type RequestState, RequestTracker, type ResolvedApiConfig, type ResolvedAppConfig, type ResolvedControllerDiscoveryConfig, type RouteOptions, type RouteValidation, TYPES, Tagged, Unmanaged, bootstrap, configureApp, createApp, createError, createKickConfig, discoverControllersFromFilesystem, getAppConfig, isAppError, listRegisteredControllers, registerController, resetAppConfig, resetControllerRegistry, resolveConfig };
|