@geekmidas/cli 0.0.19 → 0.0.21
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/{build-DqTE4qtW.mjs → build-BbzztcKf.mjs} +15 -5
- package/dist/{build-HWB991oI.cjs → build-C9pAFzAM.cjs} +15 -5
- package/dist/build.cjs +1 -1
- package/dist/build.mjs +1 -1
- package/dist/index.cjs +10 -6
- package/dist/index.mjs +10 -6
- package/package.json +5 -3
- package/src/build.ts +15 -3
- package/src/index.ts +9 -2
- package/src/types.ts +1 -0
|
@@ -39,13 +39,13 @@ async function buildCommand(options) {
|
|
|
39
39
|
await mkdir(outputDir, { recursive: true });
|
|
40
40
|
logger.log(`\nGenerating handlers for provider: ${provider}`);
|
|
41
41
|
if (provider === "server") {
|
|
42
|
-
const serverFile = await generateServerFile(outputDir, allEndpoints, envParserPath, envParserImportPattern, loggerPath, loggerImportPattern);
|
|
42
|
+
const serverFile = await generateServerFile(outputDir, allEndpoints, envParserPath, envParserImportPattern, loggerPath, loggerImportPattern, options.enableOpenApi || false);
|
|
43
43
|
routes.push({
|
|
44
44
|
path: "*",
|
|
45
45
|
method: "ALL",
|
|
46
46
|
handler: relative(process.cwd(), serverFile)
|
|
47
47
|
});
|
|
48
|
-
logger.log(`Generated server app with ${allEndpoints.length} endpoints`);
|
|
48
|
+
logger.log(`Generated server app with ${allEndpoints.length} endpoints${options.enableOpenApi ? " (OpenAPI enabled)" : ""}`);
|
|
49
49
|
} else for (const { file, exportName, routeInfo } of allEndpoints) {
|
|
50
50
|
const handlerFile = await generateHandlerFile(outputDir, file, exportName, provider, routeInfo, envParserPath, envParserImportPattern);
|
|
51
51
|
routes.push({
|
|
@@ -61,7 +61,7 @@ async function buildCommand(options) {
|
|
|
61
61
|
logger.log(`Routes manifest: ${relative(process.cwd(), manifestPath)}`);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
async function generateServerFile(outputDir, endpoints, envParserPath, envParserImportPattern, loggerPath, loggerImportPattern) {
|
|
64
|
+
async function generateServerFile(outputDir, endpoints, envParserPath, envParserImportPattern, loggerPath, loggerImportPattern, enableOpenApi) {
|
|
65
65
|
const serverFileName = "app.ts";
|
|
66
66
|
const serverPath = join(outputDir, serverFileName);
|
|
67
67
|
const importsByFile = /* @__PURE__ */ new Map();
|
|
@@ -83,7 +83,7 @@ import ${envParserImportPattern} from '${relativeEnvParserPath}';
|
|
|
83
83
|
import ${loggerImportPattern} from '${relativeLoggerPath}';
|
|
84
84
|
${imports}
|
|
85
85
|
|
|
86
|
-
export function createApp(app?: Hono): Hono {
|
|
86
|
+
export function createApp(app?: Hono, enableOpenApi: boolean = ${enableOpenApi}): Hono {
|
|
87
87
|
const honoApp = app || new Hono();
|
|
88
88
|
|
|
89
89
|
const endpoints: Endpoint<any, any, any, any, any, any>[] = [
|
|
@@ -95,7 +95,17 @@ export function createApp(app?: Hono): Hono {
|
|
|
95
95
|
envParser
|
|
96
96
|
);
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
// Configure OpenAPI options based on enableOpenApi flag
|
|
99
|
+
const openApiOptions = enableOpenApi ? {
|
|
100
|
+
docsPath: '/docs',
|
|
101
|
+
openApiOptions: {
|
|
102
|
+
title: 'API Documentation',
|
|
103
|
+
version: '1.0.0',
|
|
104
|
+
description: 'Generated API documentation'
|
|
105
|
+
}
|
|
106
|
+
} : { docsPath: false };
|
|
107
|
+
|
|
108
|
+
HonoEndpoint.addRoutes(endpoints, serviceDiscovery, honoApp, openApiOptions);
|
|
99
109
|
|
|
100
110
|
return honoApp;
|
|
101
111
|
}
|
|
@@ -40,13 +40,13 @@ async function buildCommand(options) {
|
|
|
40
40
|
await (0, node_fs_promises.mkdir)(outputDir, { recursive: true });
|
|
41
41
|
logger.log(`\nGenerating handlers for provider: ${provider}`);
|
|
42
42
|
if (provider === "server") {
|
|
43
|
-
const serverFile = await generateServerFile(outputDir, allEndpoints, envParserPath, envParserImportPattern, loggerPath, loggerImportPattern);
|
|
43
|
+
const serverFile = await generateServerFile(outputDir, allEndpoints, envParserPath, envParserImportPattern, loggerPath, loggerImportPattern, options.enableOpenApi || false);
|
|
44
44
|
routes.push({
|
|
45
45
|
path: "*",
|
|
46
46
|
method: "ALL",
|
|
47
47
|
handler: (0, path.relative)(process.cwd(), serverFile)
|
|
48
48
|
});
|
|
49
|
-
logger.log(`Generated server app with ${allEndpoints.length} endpoints`);
|
|
49
|
+
logger.log(`Generated server app with ${allEndpoints.length} endpoints${options.enableOpenApi ? " (OpenAPI enabled)" : ""}`);
|
|
50
50
|
} else for (const { file, exportName, routeInfo } of allEndpoints) {
|
|
51
51
|
const handlerFile = await generateHandlerFile(outputDir, file, exportName, provider, routeInfo, envParserPath, envParserImportPattern);
|
|
52
52
|
routes.push({
|
|
@@ -62,7 +62,7 @@ async function buildCommand(options) {
|
|
|
62
62
|
logger.log(`Routes manifest: ${(0, path.relative)(process.cwd(), manifestPath)}`);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
async function generateServerFile(outputDir, endpoints, envParserPath, envParserImportPattern, loggerPath, loggerImportPattern) {
|
|
65
|
+
async function generateServerFile(outputDir, endpoints, envParserPath, envParserImportPattern, loggerPath, loggerImportPattern, enableOpenApi) {
|
|
66
66
|
const serverFileName = "app.ts";
|
|
67
67
|
const serverPath = (0, path.join)(outputDir, serverFileName);
|
|
68
68
|
const importsByFile = /* @__PURE__ */ new Map();
|
|
@@ -84,7 +84,7 @@ import ${envParserImportPattern} from '${relativeEnvParserPath}';
|
|
|
84
84
|
import ${loggerImportPattern} from '${relativeLoggerPath}';
|
|
85
85
|
${imports}
|
|
86
86
|
|
|
87
|
-
export function createApp(app?: Hono): Hono {
|
|
87
|
+
export function createApp(app?: Hono, enableOpenApi: boolean = ${enableOpenApi}): Hono {
|
|
88
88
|
const honoApp = app || new Hono();
|
|
89
89
|
|
|
90
90
|
const endpoints: Endpoint<any, any, any, any, any, any>[] = [
|
|
@@ -96,7 +96,17 @@ export function createApp(app?: Hono): Hono {
|
|
|
96
96
|
envParser
|
|
97
97
|
);
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
// Configure OpenAPI options based on enableOpenApi flag
|
|
100
|
+
const openApiOptions = enableOpenApi ? {
|
|
101
|
+
docsPath: '/docs',
|
|
102
|
+
openApiOptions: {
|
|
103
|
+
title: 'API Documentation',
|
|
104
|
+
version: '1.0.0',
|
|
105
|
+
description: 'Generated API documentation'
|
|
106
|
+
}
|
|
107
|
+
} : { docsPath: false };
|
|
108
|
+
|
|
109
|
+
HonoEndpoint.addRoutes(endpoints, serviceDiscovery, honoApp, openApiOptions);
|
|
100
110
|
|
|
101
111
|
return honoApp;
|
|
102
112
|
}
|
package/dist/build.cjs
CHANGED
package/dist/build.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
3
3
|
require('./config-BNqUMsvc.cjs');
|
|
4
4
|
require('./loadEndpoints-BBIavB9h.cjs');
|
|
5
|
-
const require_build = require('./build-
|
|
5
|
+
const require_build = require('./build-C9pAFzAM.cjs');
|
|
6
6
|
const require_openapi_react_query = require('./openapi-react-query-C1JLYUOs.cjs');
|
|
7
7
|
const require_openapi = require('./openapi-D4QQJUPY.cjs');
|
|
8
8
|
const commander = require_chunk.__toESM(require("commander"));
|
|
9
9
|
|
|
10
10
|
//#region package.json
|
|
11
11
|
var name = "@geekmidas/cli";
|
|
12
|
-
var version = "0.0.
|
|
12
|
+
var version = "0.0.21";
|
|
13
13
|
var private$1 = false;
|
|
14
14
|
var type = "module";
|
|
15
15
|
var bin = { "gkm": "./dist/index.cjs" };
|
|
@@ -22,9 +22,9 @@ var dependencies = {
|
|
|
22
22
|
"lodash.get": "~4.4.2",
|
|
23
23
|
"lodash.set": "~4.3.2",
|
|
24
24
|
"zod": "~3.25.67",
|
|
25
|
-
"fast-glob": "~3.3.3"
|
|
26
|
-
"@geekmidas/api": "workspace:*"
|
|
25
|
+
"fast-glob": "~3.3.3"
|
|
27
26
|
};
|
|
27
|
+
var peerDependencies = { "@geekmidas/api": "^0.0.41" };
|
|
28
28
|
var devDependencies = {
|
|
29
29
|
"@types/lodash.get": "~4.4.9",
|
|
30
30
|
"@types/lodash.set": "~4.3.9"
|
|
@@ -37,6 +37,7 @@ var package_default = {
|
|
|
37
37
|
bin,
|
|
38
38
|
publishConfig,
|
|
39
39
|
dependencies,
|
|
40
|
+
peerDependencies,
|
|
40
41
|
devDependencies
|
|
41
42
|
};
|
|
42
43
|
|
|
@@ -44,12 +45,15 @@ var package_default = {
|
|
|
44
45
|
//#region src/index.ts
|
|
45
46
|
const program = new commander.Command();
|
|
46
47
|
program.name("gkm").description("GeekMidas backend framework CLI").version(package_default.version).option("--cwd <path>", "Change working directory");
|
|
47
|
-
program.command("build").description("Build API handlers from endpoints").option("--providers <providers>", "Target providers for generated handlers (comma-separated)", "aws-apigatewayv1").action(async (options) => {
|
|
48
|
+
program.command("build").description("Build API handlers from endpoints").option("--providers <providers>", "Target providers for generated handlers (comma-separated)", "aws-apigatewayv1").option("--enable-openapi", "Enable OpenAPI documentation generation for server builds").action(async (options) => {
|
|
48
49
|
try {
|
|
49
50
|
const globalOptions = program.opts();
|
|
50
51
|
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
|
51
52
|
const providerList = [...new Set(options.providers.split(",").map((p) => p.trim()))];
|
|
52
|
-
await require_build.buildCommand({
|
|
53
|
+
await require_build.buildCommand({
|
|
54
|
+
providers: providerList,
|
|
55
|
+
enableOpenApi: options.enableOpenapi || false
|
|
56
|
+
});
|
|
53
57
|
} catch (error) {
|
|
54
58
|
console.error("Build failed:", error.message);
|
|
55
59
|
process.exit(1);
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
2
|
import "./config-BciAdY6_.mjs";
|
|
3
3
|
import "./loadEndpoints-DAZ53Og2.mjs";
|
|
4
|
-
import { buildCommand } from "./build-
|
|
4
|
+
import { buildCommand } from "./build-BbzztcKf.mjs";
|
|
5
5
|
import { generateReactQueryCommand } from "./openapi-react-query-DpT3XHFC.mjs";
|
|
6
6
|
import { openapiCommand } from "./openapi-CksVdkh2.mjs";
|
|
7
7
|
import { Command } from "commander";
|
|
8
8
|
|
|
9
9
|
//#region package.json
|
|
10
10
|
var name = "@geekmidas/cli";
|
|
11
|
-
var version = "0.0.
|
|
11
|
+
var version = "0.0.21";
|
|
12
12
|
var private$1 = false;
|
|
13
13
|
var type = "module";
|
|
14
14
|
var bin = { "gkm": "./dist/index.cjs" };
|
|
@@ -21,9 +21,9 @@ var dependencies = {
|
|
|
21
21
|
"lodash.get": "~4.4.2",
|
|
22
22
|
"lodash.set": "~4.3.2",
|
|
23
23
|
"zod": "~3.25.67",
|
|
24
|
-
"fast-glob": "~3.3.3"
|
|
25
|
-
"@geekmidas/api": "workspace:*"
|
|
24
|
+
"fast-glob": "~3.3.3"
|
|
26
25
|
};
|
|
26
|
+
var peerDependencies = { "@geekmidas/api": "^0.0.41" };
|
|
27
27
|
var devDependencies = {
|
|
28
28
|
"@types/lodash.get": "~4.4.9",
|
|
29
29
|
"@types/lodash.set": "~4.3.9"
|
|
@@ -36,6 +36,7 @@ var package_default = {
|
|
|
36
36
|
bin,
|
|
37
37
|
publishConfig,
|
|
38
38
|
dependencies,
|
|
39
|
+
peerDependencies,
|
|
39
40
|
devDependencies
|
|
40
41
|
};
|
|
41
42
|
|
|
@@ -43,12 +44,15 @@ var package_default = {
|
|
|
43
44
|
//#region src/index.ts
|
|
44
45
|
const program = new Command();
|
|
45
46
|
program.name("gkm").description("GeekMidas backend framework CLI").version(package_default.version).option("--cwd <path>", "Change working directory");
|
|
46
|
-
program.command("build").description("Build API handlers from endpoints").option("--providers <providers>", "Target providers for generated handlers (comma-separated)", "aws-apigatewayv1").action(async (options) => {
|
|
47
|
+
program.command("build").description("Build API handlers from endpoints").option("--providers <providers>", "Target providers for generated handlers (comma-separated)", "aws-apigatewayv1").option("--enable-openapi", "Enable OpenAPI documentation generation for server builds").action(async (options) => {
|
|
47
48
|
try {
|
|
48
49
|
const globalOptions = program.opts();
|
|
49
50
|
if (globalOptions.cwd) process.chdir(globalOptions.cwd);
|
|
50
51
|
const providerList = [...new Set(options.providers.split(",").map((p) => p.trim()))];
|
|
51
|
-
await buildCommand({
|
|
52
|
+
await buildCommand({
|
|
53
|
+
providers: providerList,
|
|
54
|
+
enableOpenApi: options.enableOpenapi || false
|
|
55
|
+
});
|
|
52
56
|
} catch (error) {
|
|
53
57
|
console.error("Build failed:", error.message);
|
|
54
58
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekmidas/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
"lodash.get": "~4.4.2",
|
|
16
16
|
"lodash.set": "~4.3.2",
|
|
17
17
|
"zod": "~3.25.67",
|
|
18
|
-
"fast-glob": "~3.3.3"
|
|
19
|
-
|
|
18
|
+
"fast-glob": "~3.3.3"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@geekmidas/api": "^0.0.41"
|
|
20
22
|
},
|
|
21
23
|
"devDependencies": {
|
|
22
24
|
"@types/lodash.get": "~4.4.9",
|
package/src/build.ts
CHANGED
|
@@ -80,6 +80,7 @@ export async function buildCommand(options: BuildOptions): Promise<void> {
|
|
|
80
80
|
envParserImportPattern,
|
|
81
81
|
loggerPath,
|
|
82
82
|
loggerImportPattern,
|
|
83
|
+
options.enableOpenApi || false,
|
|
83
84
|
);
|
|
84
85
|
|
|
85
86
|
routes.push({
|
|
@@ -88,7 +89,7 @@ export async function buildCommand(options: BuildOptions): Promise<void> {
|
|
|
88
89
|
handler: relative(process.cwd(), serverFile),
|
|
89
90
|
});
|
|
90
91
|
|
|
91
|
-
logger.log(`Generated server app with ${allEndpoints.length} endpoints`);
|
|
92
|
+
logger.log(`Generated server app with ${allEndpoints.length} endpoints${options.enableOpenApi ? ' (OpenAPI enabled)' : ''}`);
|
|
92
93
|
} else {
|
|
93
94
|
// Generate individual handler files for AWS providers
|
|
94
95
|
for (const { file, exportName, routeInfo } of allEndpoints) {
|
|
@@ -140,6 +141,7 @@ async function generateServerFile(
|
|
|
140
141
|
envParserImportPattern: string,
|
|
141
142
|
loggerPath: string,
|
|
142
143
|
loggerImportPattern: string,
|
|
144
|
+
enableOpenApi: boolean,
|
|
143
145
|
): Promise<string> {
|
|
144
146
|
const serverFileName = 'app.ts';
|
|
145
147
|
const serverPath = join(outputDir, serverFileName);
|
|
@@ -178,7 +180,7 @@ import ${envParserImportPattern} from '${relativeEnvParserPath}';
|
|
|
178
180
|
import ${loggerImportPattern} from '${relativeLoggerPath}';
|
|
179
181
|
${imports}
|
|
180
182
|
|
|
181
|
-
export function createApp(app?: Hono): Hono {
|
|
183
|
+
export function createApp(app?: Hono, enableOpenApi: boolean = ${enableOpenApi}): Hono {
|
|
182
184
|
const honoApp = app || new Hono();
|
|
183
185
|
|
|
184
186
|
const endpoints: Endpoint<any, any, any, any, any, any>[] = [
|
|
@@ -190,7 +192,17 @@ export function createApp(app?: Hono): Hono {
|
|
|
190
192
|
envParser
|
|
191
193
|
);
|
|
192
194
|
|
|
193
|
-
|
|
195
|
+
// Configure OpenAPI options based on enableOpenApi flag
|
|
196
|
+
const openApiOptions = enableOpenApi ? {
|
|
197
|
+
docsPath: '/docs',
|
|
198
|
+
openApiOptions: {
|
|
199
|
+
title: 'API Documentation',
|
|
200
|
+
version: '1.0.0',
|
|
201
|
+
description: 'Generated API documentation'
|
|
202
|
+
}
|
|
203
|
+
} : { docsPath: false };
|
|
204
|
+
|
|
205
|
+
HonoEndpoint.addRoutes(endpoints, serviceDiscovery, honoApp, openApiOptions);
|
|
194
206
|
|
|
195
207
|
return honoApp;
|
|
196
208
|
}
|
package/src/index.ts
CHANGED
|
@@ -23,7 +23,11 @@ program
|
|
|
23
23
|
'Target providers for generated handlers (comma-separated)',
|
|
24
24
|
'aws-apigatewayv1',
|
|
25
25
|
)
|
|
26
|
-
.
|
|
26
|
+
.option(
|
|
27
|
+
'--enable-openapi',
|
|
28
|
+
'Enable OpenAPI documentation generation for server builds',
|
|
29
|
+
)
|
|
30
|
+
.action(async (options: { providers: string; enableOpenapi?: boolean }) => {
|
|
27
31
|
try {
|
|
28
32
|
const globalOptions = program.opts();
|
|
29
33
|
if (globalOptions.cwd) {
|
|
@@ -32,7 +36,10 @@ program
|
|
|
32
36
|
const providerList = [
|
|
33
37
|
...new Set(options.providers.split(',').map((p) => p.trim())),
|
|
34
38
|
] as Provider[];
|
|
35
|
-
await buildCommand({
|
|
39
|
+
await buildCommand({
|
|
40
|
+
providers: providerList,
|
|
41
|
+
enableOpenApi: options.enableOpenapi || false
|
|
42
|
+
});
|
|
36
43
|
} catch (error) {
|
|
37
44
|
console.error('Build failed:', (error as Error).message);
|
|
38
45
|
process.exit(1);
|