@geekmidas/cli 0.8.0 → 0.10.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/dist/{config-Bq72aj8e.mjs → config-BrkUalUh.mjs} +4 -2
- package/dist/config-BrkUalUh.mjs.map +1 -0
- package/dist/{config-CFls09Ey.cjs → config-C9aXOHBe.cjs} +4 -2
- package/dist/config-C9aXOHBe.cjs.map +1 -0
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +1 -0
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.mts +1 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +1 -1
- package/dist/index.cjs +27 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +27 -15
- package/dist/index.mjs.map +1 -1
- package/dist/{openapi-CHhTPief.cjs → openapi-BeHLKcwP.cjs} +13 -13
- package/dist/{openapi-CHhTPief.cjs.map → openapi-BeHLKcwP.cjs.map} +1 -1
- package/dist/{openapi--vOy9mo4.mjs → openapi-CZLI4QTr.mjs} +13 -13
- package/dist/{openapi--vOy9mo4.mjs.map → openapi-CZLI4QTr.mjs.map} +1 -1
- package/dist/openapi-react-query.d.cts.map +1 -0
- package/dist/openapi-react-query.d.mts.map +1 -0
- package/dist/openapi.cjs +2 -2
- package/dist/openapi.d.cts.map +1 -0
- package/dist/openapi.d.mts.map +1 -0
- package/dist/openapi.mjs +2 -2
- package/dist/types-DXgiA1sF.d.mts.map +1 -0
- package/dist/types-b-vwGpqc.d.cts.map +1 -0
- package/package.json +7 -7
- package/src/__tests__/test-helpers.ts +3 -2
- package/src/config.ts +3 -1
- package/src/dev/index.ts +35 -11
- package/src/generators/OpenApiTsGenerator.ts +11 -11
- package/src/index.ts +11 -18
- package/tsconfig.json +9 -0
- package/dist/config-Bq72aj8e.mjs.map +0 -1
- package/dist/config-CFls09Ey.cjs.map +0 -1
package/src/index.ts
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import pkg from '../package.json' assert { type: 'json' };
|
|
5
|
-
import { buildCommand } from './build/index
|
|
6
|
-
import { devCommand } from './dev/index
|
|
7
|
-
import { type InitOptions, initCommand } from './init/index
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import type { LegacyProvider, MainProvider } from './types
|
|
5
|
+
import { buildCommand } from './build/index';
|
|
6
|
+
import { devCommand } from './dev/index';
|
|
7
|
+
import { type InitOptions, initCommand } from './init/index';
|
|
8
|
+
import { openapiCommand } from './openapi';
|
|
9
|
+
import { generateReactQueryCommand } from './openapi-react-query';
|
|
10
|
+
import type { LegacyProvider, MainProvider } from './types';
|
|
11
11
|
|
|
12
12
|
const program = new Command();
|
|
13
13
|
|
|
@@ -111,7 +111,7 @@ program
|
|
|
111
111
|
program
|
|
112
112
|
.command('dev')
|
|
113
113
|
.description('Start development server with automatic reload')
|
|
114
|
-
.option('--port <port>', 'Port to run the development server on'
|
|
114
|
+
.option('-p, --port <port>', 'Port to run the development server on')
|
|
115
115
|
.option(
|
|
116
116
|
'--enable-openapi',
|
|
117
117
|
'Enable OpenAPI documentation for development server',
|
|
@@ -126,6 +126,7 @@ program
|
|
|
126
126
|
|
|
127
127
|
await devCommand({
|
|
128
128
|
port: options.port ? Number.parseInt(options.port) : 3000,
|
|
129
|
+
portExplicit: !!options.port,
|
|
129
130
|
enableOpenApi: options.enableOpenapi ?? true,
|
|
130
131
|
});
|
|
131
132
|
} catch (error) {
|
|
@@ -169,22 +170,14 @@ program
|
|
|
169
170
|
|
|
170
171
|
program
|
|
171
172
|
.command('openapi')
|
|
172
|
-
.description(
|
|
173
|
-
|
|
174
|
-
)
|
|
175
|
-
.option(
|
|
176
|
-
'--output <path>',
|
|
177
|
-
'Output file path for the OpenAPI spec',
|
|
178
|
-
'openapi.ts',
|
|
179
|
-
)
|
|
180
|
-
.option('--json', 'Generate JSON instead of TypeScript (legacy)', false)
|
|
181
|
-
.action(async (options: { output?: string; json?: boolean }) => {
|
|
173
|
+
.description('Generate OpenAPI specification from endpoints')
|
|
174
|
+
.action(async () => {
|
|
182
175
|
try {
|
|
183
176
|
const globalOptions = program.opts();
|
|
184
177
|
if (globalOptions.cwd) {
|
|
185
178
|
process.chdir(globalOptions.cwd);
|
|
186
179
|
}
|
|
187
|
-
await openapiCommand(
|
|
180
|
+
await openapiCommand({});
|
|
188
181
|
} catch (error) {
|
|
189
182
|
console.error('OpenAPI generation failed:', (error as Error).message);
|
|
190
183
|
process.exit(1);
|
package/tsconfig.json
ADDED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-Bq72aj8e.mjs","names":["config: GkmConfig","configString: string","defaultAlias: string","cwd: string"],"sources":["../src/config.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'path';\nimport type { GkmConfig } from './types.ts';\n\nexport type { GkmConfig } from './types.ts';\n/**\n * Define GKM configuration with full TypeScript support.\n * This is an identity function that provides type safety and autocomplete.\n *\n * @example\n * ```ts\n * // gkm.config.ts\n * import { defineConfig } from '@geekmidas/cli/config';\n *\n * export default defineConfig({\n * routes: './src/endpoints/**\\/*.ts',\n * envParser: './src/config/env',\n * logger: './src/config/logger',\n * telescope: true,\n * });\n * ```\n */\nexport function defineConfig(config: GkmConfig): GkmConfig {\n return config;\n}\n\nexport interface ParsedModuleConfig {\n path: string;\n importPattern: string;\n}\n\n/**\n * Parse a module config string into path and import pattern.\n *\n * @param configString - Config string in format \"./path/to/module\" or \"./path/to/module#exportName\"\n * @param defaultAlias - The default alias name to use if no export name specified\n * @returns Object with path and import pattern\n *\n * @example\n * parseModuleConfig('./src/config/env', 'envParser')\n * // { path: './src/config/env', importPattern: 'envParser' }\n *\n * parseModuleConfig('./src/config/env#envParser', 'envParser')\n * // { path: './src/config/env', importPattern: '{ envParser }' }\n *\n * parseModuleConfig('./src/config/env#myEnv', 'envParser')\n * // { path: './src/config/env', importPattern: '{ myEnv as envParser }' }\n */\nexport function parseModuleConfig(\n configString: string,\n defaultAlias: string,\n): ParsedModuleConfig {\n const [path, exportName] = configString.split('#');\n const importPattern = !exportName\n ? defaultAlias\n : exportName === defaultAlias\n ? `{ ${defaultAlias} }`\n : `{ ${exportName} as ${defaultAlias} }`;\n\n return { path, importPattern };\n}\n\nexport async function loadConfig(\n cwd: string = process.cwd(),\n): Promise<GkmConfig> {\n const files = ['gkm.config.json', 'gkm.config.ts', 'gkm.config.js'];\n let configPath = '';\n\n for (const file of files) {\n const path = join(cwd, file);\n if (existsSync(path)) {\n configPath = path;\n break;\n }\n }\n\n if (!configPath) {\n throw new Error(\n 'Configuration file not found. Please create gkm.config.json, gkm.config.ts, or gkm.config.js in the project root.',\n );\n }\n\n try {\n const config = await import(configPath);\n return config.default;\n } catch (error) {\n throw new Error(\n `Failed to load gkm.config.json: ${(error as Error).message}`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,aAAaA,QAA8B;AACzD,QAAO;AACR;;;;;;;;;;;;;;;;;;AAwBD,SAAgB,kBACdC,cACAC,cACoB;CACpB,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,MAAM,IAAI;CAClD,MAAM,iBAAiB,aACnB,eACA,eAAe,gBACZ,IAAI,aAAa,OACjB,IAAI,WAAW,MAAM,aAAa;AAEzC,QAAO;EAAE;EAAM;CAAe;AAC/B;AAED,eAAsB,WACpBC,MAAc,QAAQ,KAAK,EACP;CACpB,MAAM,QAAQ;EAAC;EAAmB;EAAiB;CAAgB;CACnE,IAAI,aAAa;AAEjB,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,OAAO,KAAK,KAAK,KAAK;AAC5B,MAAI,WAAW,KAAK,EAAE;AACpB,gBAAa;AACb;EACD;CACF;AAED,MAAK,WACH,OAAM,IAAI,MACR;AAIJ,KAAI;EACF,MAAM,SAAS,MAAM,OAAO;AAC5B,SAAO,OAAO;CACf,SAAQ,OAAO;AACd,QAAM,IAAI,OACP,kCAAmC,MAAgB,QAAQ;CAE/D;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-CFls09Ey.cjs","names":["config: GkmConfig","configString: string","defaultAlias: string","path","cwd: string"],"sources":["../src/config.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'path';\nimport type { GkmConfig } from './types.ts';\n\nexport type { GkmConfig } from './types.ts';\n/**\n * Define GKM configuration with full TypeScript support.\n * This is an identity function that provides type safety and autocomplete.\n *\n * @example\n * ```ts\n * // gkm.config.ts\n * import { defineConfig } from '@geekmidas/cli/config';\n *\n * export default defineConfig({\n * routes: './src/endpoints/**\\/*.ts',\n * envParser: './src/config/env',\n * logger: './src/config/logger',\n * telescope: true,\n * });\n * ```\n */\nexport function defineConfig(config: GkmConfig): GkmConfig {\n return config;\n}\n\nexport interface ParsedModuleConfig {\n path: string;\n importPattern: string;\n}\n\n/**\n * Parse a module config string into path and import pattern.\n *\n * @param configString - Config string in format \"./path/to/module\" or \"./path/to/module#exportName\"\n * @param defaultAlias - The default alias name to use if no export name specified\n * @returns Object with path and import pattern\n *\n * @example\n * parseModuleConfig('./src/config/env', 'envParser')\n * // { path: './src/config/env', importPattern: 'envParser' }\n *\n * parseModuleConfig('./src/config/env#envParser', 'envParser')\n * // { path: './src/config/env', importPattern: '{ envParser }' }\n *\n * parseModuleConfig('./src/config/env#myEnv', 'envParser')\n * // { path: './src/config/env', importPattern: '{ myEnv as envParser }' }\n */\nexport function parseModuleConfig(\n configString: string,\n defaultAlias: string,\n): ParsedModuleConfig {\n const [path, exportName] = configString.split('#');\n const importPattern = !exportName\n ? defaultAlias\n : exportName === defaultAlias\n ? `{ ${defaultAlias} }`\n : `{ ${exportName} as ${defaultAlias} }`;\n\n return { path, importPattern };\n}\n\nexport async function loadConfig(\n cwd: string = process.cwd(),\n): Promise<GkmConfig> {\n const files = ['gkm.config.json', 'gkm.config.ts', 'gkm.config.js'];\n let configPath = '';\n\n for (const file of files) {\n const path = join(cwd, file);\n if (existsSync(path)) {\n configPath = path;\n break;\n }\n }\n\n if (!configPath) {\n throw new Error(\n 'Configuration file not found. Please create gkm.config.json, gkm.config.ts, or gkm.config.js in the project root.',\n );\n }\n\n try {\n const config = await import(configPath);\n return config.default;\n } catch (error) {\n throw new Error(\n `Failed to load gkm.config.json: ${(error as Error).message}`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,aAAaA,QAA8B;AACzD,QAAO;AACR;;;;;;;;;;;;;;;;;;AAwBD,SAAgB,kBACdC,cACAC,cACoB;CACpB,MAAM,CAACC,QAAM,WAAW,GAAG,aAAa,MAAM,IAAI;CAClD,MAAM,iBAAiB,aACnB,eACA,eAAe,gBACZ,IAAI,aAAa,OACjB,IAAI,WAAW,MAAM,aAAa;AAEzC,QAAO;EAAE;EAAM;CAAe;AAC/B;AAED,eAAsB,WACpBC,MAAc,QAAQ,KAAK,EACP;CACpB,MAAM,QAAQ;EAAC;EAAmB;EAAiB;CAAgB;CACnE,IAAI,aAAa;AAEjB,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAMD,SAAO,eAAK,KAAK,KAAK;AAC5B,MAAI,mBAAWA,OAAK,EAAE;AACpB,gBAAaA;AACb;EACD;CACF;AAED,MAAK,WACH,OAAM,IAAI,MACR;AAIJ,KAAI;EACF,MAAM,SAAS,MAAM,OAAO;AAC5B,SAAO,OAAO;CACf,SAAQ,OAAO;AACd,QAAM,IAAI,OACP,kCAAmC,MAAgB,QAAQ;CAE/D;AACF"}
|