api-sdk-generator 0.2.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 +39 -0
- package/dist/chunk-EJ36UYRY.js +123 -0
- package/dist/chunk-EJ36UYRY.js.map +1 -0
- package/dist/cli.cjs +256 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +123 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +159 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +35 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 minkinad
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# api-sdk-generator
|
|
2
|
+
|
|
3
|
+
Generate TypeScript fetch SDKs from OpenAPI JSON or YAML schemas.
|
|
4
|
+
Requires Node.js 20 or later.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npx api-sdk-generator generate --file ./openapi.yaml --output ./generated
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install --save-dev api-sdk-generator
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Options:
|
|
15
|
+
|
|
16
|
+
- `--file <path>` or `--url <url>`: exactly one schema source.
|
|
17
|
+
- `--output <path>`: generated SDK directory (required).
|
|
18
|
+
- `--name <name>`: SDK name override.
|
|
19
|
+
- `--base-url <url>`: API server override.
|
|
20
|
+
- `--dry-run`: validate and preview without writing.
|
|
21
|
+
- `--check`: verify generated files; exit code 2 means missing or outdated files.
|
|
22
|
+
- `--clean`: remove the output directory before generation.
|
|
23
|
+
- `--verbose`: diagnostic logs.
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { createClient } from './generated/index.js';
|
|
27
|
+
|
|
28
|
+
const client = createClient({
|
|
29
|
+
baseUrl: 'https://api.example.com',
|
|
30
|
+
headers: { Authorization: 'Bearer token' },
|
|
31
|
+
});
|
|
32
|
+
await client.getUserById({ id: '123' });
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
See [documentation](https://minkinad.github.io/api-sdk-generator/) and
|
|
36
|
+
[source](https://github.com/minkinad/api-sdk-generator) for supported features and limitations.
|
|
37
|
+
For programmatic generation, install `@minkinad/api-sdk-generator-core`.
|
|
38
|
+
|
|
39
|
+
MIT licensed.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { generateSdk } from "@minkinad/api-sdk-generator-core";
|
|
5
|
+
|
|
6
|
+
// src/errors.ts
|
|
7
|
+
var CliUsageError = class extends Error {
|
|
8
|
+
exitCode;
|
|
9
|
+
constructor(message, exitCode = 1) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "CliUsageError";
|
|
12
|
+
this.exitCode = exitCode;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// src/logger.ts
|
|
17
|
+
import pc from "picocolors";
|
|
18
|
+
function createCliLogger(verbose = false) {
|
|
19
|
+
return {
|
|
20
|
+
debug(message) {
|
|
21
|
+
if (verbose) {
|
|
22
|
+
console.info(pc.dim(`[debug] ${message}`));
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
error(message) {
|
|
26
|
+
console.error(pc.red(`[error] ${message}`));
|
|
27
|
+
},
|
|
28
|
+
info(message) {
|
|
29
|
+
console.info(pc.cyan(`[api-sdk-generator] ${message}`));
|
|
30
|
+
},
|
|
31
|
+
warn(message) {
|
|
32
|
+
console.warn(pc.yellow(`[warn] ${message}`));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/options.ts
|
|
38
|
+
import path from "path";
|
|
39
|
+
function normalizeGenerateCommandOptions(options) {
|
|
40
|
+
const workingDirectory = process.env.INIT_CWD ?? process.cwd();
|
|
41
|
+
if (options.check && options.dryRun) {
|
|
42
|
+
throw new CliUsageError("Use either --check or --dry-run, not both.");
|
|
43
|
+
}
|
|
44
|
+
if (!options.output) {
|
|
45
|
+
throw new CliUsageError("The --output option is required.");
|
|
46
|
+
}
|
|
47
|
+
const hasFile = typeof options.file === "string" && options.file.length > 0;
|
|
48
|
+
const hasUrl = typeof options.url === "string" && options.url.length > 0;
|
|
49
|
+
if (hasFile === hasUrl) {
|
|
50
|
+
throw new CliUsageError("Provide exactly one input source: either --file or --url.");
|
|
51
|
+
}
|
|
52
|
+
if (options.url) {
|
|
53
|
+
try {
|
|
54
|
+
if (!["http:", "https:"].includes(new URL(options.url).protocol)) throw new Error();
|
|
55
|
+
} catch {
|
|
56
|
+
throw new CliUsageError(`Invalid --url value: "${options.url}".`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (options.baseUrl) {
|
|
60
|
+
try {
|
|
61
|
+
if (!["http:", "https:"].includes(new URL(options.baseUrl).protocol)) throw new Error();
|
|
62
|
+
} catch {
|
|
63
|
+
throw new CliUsageError(`Invalid --base-url value: "${options.baseUrl}".`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
baseUrl: options.baseUrl,
|
|
68
|
+
clean: options.clean ?? false,
|
|
69
|
+
check: options.check ?? false,
|
|
70
|
+
dryRun: options.dryRun ?? false,
|
|
71
|
+
input: {
|
|
72
|
+
file: options.file ? path.resolve(workingDirectory, options.file) : void 0,
|
|
73
|
+
url: options.url
|
|
74
|
+
},
|
|
75
|
+
outputDir: path.resolve(workingDirectory, options.output),
|
|
76
|
+
sdkName: options.name,
|
|
77
|
+
verbose: options.verbose ?? false
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/index.ts
|
|
82
|
+
async function runGenerateCommand(input) {
|
|
83
|
+
const options = normalizeGenerateCommandOptions(input);
|
|
84
|
+
await executeGenerateCommand(options);
|
|
85
|
+
}
|
|
86
|
+
async function executeGenerateCommand(options) {
|
|
87
|
+
const logger = createCliLogger(options.verbose);
|
|
88
|
+
logger.info("Starting SDK generation");
|
|
89
|
+
const result = await generateSdk({
|
|
90
|
+
baseUrl: options.baseUrl,
|
|
91
|
+
clean: options.clean,
|
|
92
|
+
check: options.check,
|
|
93
|
+
dryRun: options.dryRun,
|
|
94
|
+
input: options.input,
|
|
95
|
+
logger,
|
|
96
|
+
outputDir: options.outputDir,
|
|
97
|
+
sdkName: options.sdkName
|
|
98
|
+
});
|
|
99
|
+
if (options.check) {
|
|
100
|
+
if (result.changedFiles.length > 0) {
|
|
101
|
+
throw new CliUsageError(`Generated SDK is out of date: ${result.changedFiles.join(", ")}`, 2);
|
|
102
|
+
}
|
|
103
|
+
logger.info("Generated SDK is up to date");
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (options.dryRun) {
|
|
107
|
+
logger.info(
|
|
108
|
+
`Would generate ${result.files.length} files for ${result.operations} operations: ${result.files.map((file) => file.path).join(", ")}`
|
|
109
|
+
);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
logger.info(
|
|
113
|
+
`Generated ${result.files.length} files for ${result.operations} operations in ${result.outputDir}`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export {
|
|
118
|
+
CliUsageError,
|
|
119
|
+
normalizeGenerateCommandOptions,
|
|
120
|
+
runGenerateCommand,
|
|
121
|
+
executeGenerateCommand
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=chunk-EJ36UYRY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/logger.ts","../src/options.ts"],"sourcesContent":["import { generateSdk } from '@minkinad/api-sdk-generator-core';\n\nimport { CliUsageError } from './errors.js';\nimport { createCliLogger } from './logger.js';\nimport {\n normalizeGenerateCommandOptions,\n type GenerateCommandOptionsInput,\n type NormalizedGenerateCommandOptions,\n} from './options.js';\n\nexport type { GenerateCommandOptionsInput, NormalizedGenerateCommandOptions } from './options.js';\nexport { CliUsageError } from './errors.js';\nexport { normalizeGenerateCommandOptions } from './options.js';\n\nexport async function runGenerateCommand(input: GenerateCommandOptionsInput): Promise<void> {\n const options = normalizeGenerateCommandOptions(input);\n await executeGenerateCommand(options);\n}\n\nexport async function executeGenerateCommand(\n options: NormalizedGenerateCommandOptions,\n): Promise<void> {\n const logger = createCliLogger(options.verbose);\n logger.info('Starting SDK generation');\n\n const result = await generateSdk({\n baseUrl: options.baseUrl,\n clean: options.clean,\n check: options.check,\n dryRun: options.dryRun,\n input: options.input,\n logger,\n outputDir: options.outputDir,\n sdkName: options.sdkName,\n });\n\n if (options.check) {\n if (result.changedFiles.length > 0) {\n throw new CliUsageError(`Generated SDK is out of date: ${result.changedFiles.join(', ')}`, 2);\n }\n logger.info('Generated SDK is up to date');\n return;\n }\n if (options.dryRun) {\n logger.info(\n `Would generate ${result.files.length} files for ${result.operations} operations: ${result.files.map((file) => file.path).join(', ')}`,\n );\n return;\n }\n logger.info(\n `Generated ${result.files.length} files for ${result.operations} operations in ${result.outputDir}`,\n );\n}\n","export class CliUsageError extends Error {\n public readonly exitCode: number;\n\n public constructor(message: string, exitCode = 1) {\n super(message);\n this.name = 'CliUsageError';\n this.exitCode = exitCode;\n }\n}\n","import type { Logger } from '@minkinad/api-sdk-generator-core';\nimport pc from 'picocolors';\n\nexport function createCliLogger(verbose = false): Logger {\n return {\n debug(message: string): void {\n if (verbose) {\n console.info(pc.dim(`[debug] ${message}`));\n }\n },\n error(message: string): void {\n console.error(pc.red(`[error] ${message}`));\n },\n info(message: string): void {\n console.info(pc.cyan(`[api-sdk-generator] ${message}`));\n },\n warn(message: string): void {\n console.warn(pc.yellow(`[warn] ${message}`));\n },\n };\n}\n","import path from 'node:path';\n\nimport { CliUsageError } from './errors.js';\n\nexport interface GenerateCommandOptionsInput {\n baseUrl?: string;\n clean?: boolean;\n check?: boolean;\n dryRun?: boolean;\n file?: string;\n name?: string;\n output?: string;\n url?: string;\n verbose?: boolean;\n}\n\nexport interface NormalizedGenerateCommandOptions {\n baseUrl?: string;\n clean: boolean;\n check: boolean;\n dryRun: boolean;\n input: {\n file?: string;\n url?: string;\n };\n outputDir: string;\n sdkName?: string;\n verbose: boolean;\n}\n\nexport function normalizeGenerateCommandOptions(\n options: GenerateCommandOptionsInput,\n): NormalizedGenerateCommandOptions {\n const workingDirectory = process.env.INIT_CWD ?? process.cwd();\n\n if (options.check && options.dryRun) {\n throw new CliUsageError('Use either --check or --dry-run, not both.');\n }\n\n if (!options.output) {\n throw new CliUsageError('The --output option is required.');\n }\n\n const hasFile = typeof options.file === 'string' && options.file.length > 0;\n const hasUrl = typeof options.url === 'string' && options.url.length > 0;\n\n if (hasFile === hasUrl) {\n throw new CliUsageError('Provide exactly one input source: either --file or --url.');\n }\n\n if (options.url) {\n try {\n if (!['http:', 'https:'].includes(new URL(options.url).protocol)) throw new Error();\n } catch {\n throw new CliUsageError(`Invalid --url value: \"${options.url}\".`);\n }\n }\n\n if (options.baseUrl) {\n try {\n if (!['http:', 'https:'].includes(new URL(options.baseUrl).protocol)) throw new Error();\n } catch {\n throw new CliUsageError(`Invalid --base-url value: \"${options.baseUrl}\".`);\n }\n }\n\n return {\n baseUrl: options.baseUrl,\n clean: options.clean ?? false,\n check: options.check ?? false,\n dryRun: options.dryRun ?? false,\n input: {\n file: options.file ? path.resolve(workingDirectory, options.file) : undefined,\n url: options.url,\n },\n outputDir: path.resolve(workingDirectory, options.output),\n sdkName: options.name,\n verbose: options.verbose ?? false,\n };\n}\n"],"mappings":";;;AAAA,SAAS,mBAAmB;;;ACArB,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvB;AAAA,EAET,YAAY,SAAiB,WAAW,GAAG;AAChD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EAClB;AACF;;;ACPA,OAAO,QAAQ;AAER,SAAS,gBAAgB,UAAU,OAAe;AACvD,SAAO;AAAA,IACL,MAAM,SAAuB;AAC3B,UAAI,SAAS;AACX,gBAAQ,KAAK,GAAG,IAAI,WAAW,OAAO,EAAE,CAAC;AAAA,MAC3C;AAAA,IACF;AAAA,IACA,MAAM,SAAuB;AAC3B,cAAQ,MAAM,GAAG,IAAI,WAAW,OAAO,EAAE,CAAC;AAAA,IAC5C;AAAA,IACA,KAAK,SAAuB;AAC1B,cAAQ,KAAK,GAAG,KAAK,uBAAuB,OAAO,EAAE,CAAC;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
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/cli.ts
|
|
27
|
+
var import_api_sdk_generator_core2 = require("@minkinad/api-sdk-generator-core");
|
|
28
|
+
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
29
|
+
|
|
30
|
+
// src/errors.ts
|
|
31
|
+
var CliUsageError = class extends Error {
|
|
32
|
+
exitCode;
|
|
33
|
+
constructor(message, exitCode = 1) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.name = "CliUsageError";
|
|
36
|
+
this.exitCode = exitCode;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/program.ts
|
|
41
|
+
var import_commander = require("commander");
|
|
42
|
+
|
|
43
|
+
// package.json
|
|
44
|
+
var package_default = {
|
|
45
|
+
name: "api-sdk-generator",
|
|
46
|
+
version: "0.2.0",
|
|
47
|
+
description: "CLI for generating TypeScript SDK clients from OpenAPI 3.x schemas.",
|
|
48
|
+
type: "module",
|
|
49
|
+
bin: {
|
|
50
|
+
"api-sdk-generator": "dist/cli.cjs"
|
|
51
|
+
},
|
|
52
|
+
main: "./dist/index.cjs",
|
|
53
|
+
module: "./dist/index.js",
|
|
54
|
+
types: "./dist/index.d.ts",
|
|
55
|
+
exports: {
|
|
56
|
+
".": {
|
|
57
|
+
import: {
|
|
58
|
+
types: "./dist/index.d.ts",
|
|
59
|
+
default: "./dist/index.js"
|
|
60
|
+
},
|
|
61
|
+
require: {
|
|
62
|
+
types: "./dist/index.d.cts",
|
|
63
|
+
default: "./dist/index.cjs"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
files: [
|
|
68
|
+
"dist",
|
|
69
|
+
"README.md",
|
|
70
|
+
"LICENSE"
|
|
71
|
+
],
|
|
72
|
+
sideEffects: false,
|
|
73
|
+
engines: {
|
|
74
|
+
node: ">=20"
|
|
75
|
+
},
|
|
76
|
+
publishConfig: {
|
|
77
|
+
access: "public",
|
|
78
|
+
registry: "https://registry.npmjs.org/"
|
|
79
|
+
},
|
|
80
|
+
scripts: {
|
|
81
|
+
build: "tsup",
|
|
82
|
+
generate: "node ./dist/cli.cjs generate",
|
|
83
|
+
test: "vitest run --coverage",
|
|
84
|
+
"test:watch": "vitest",
|
|
85
|
+
lint: "eslint src test",
|
|
86
|
+
typecheck: "tsc --project tsconfig.json --noEmit",
|
|
87
|
+
clean: "rm -rf dist coverage",
|
|
88
|
+
prepack: "pnpm run build"
|
|
89
|
+
},
|
|
90
|
+
dependencies: {
|
|
91
|
+
"@minkinad/api-sdk-generator-core": "workspace:*",
|
|
92
|
+
commander: "^13.1.0",
|
|
93
|
+
picocolors: "^1.1.1"
|
|
94
|
+
},
|
|
95
|
+
license: "MIT",
|
|
96
|
+
author: "minkinad",
|
|
97
|
+
homepage: "https://minkinad.github.io/api-sdk-generator/",
|
|
98
|
+
bugs: {
|
|
99
|
+
url: "https://github.com/minkinad/api-sdk-generator/issues"
|
|
100
|
+
},
|
|
101
|
+
repository: {
|
|
102
|
+
type: "git",
|
|
103
|
+
url: "git+https://github.com/minkinad/api-sdk-generator.git",
|
|
104
|
+
directory: "packages/cli"
|
|
105
|
+
},
|
|
106
|
+
keywords: [
|
|
107
|
+
"openapi",
|
|
108
|
+
"sdk",
|
|
109
|
+
"typescript",
|
|
110
|
+
"codegen",
|
|
111
|
+
"fetch"
|
|
112
|
+
]
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// src/index.ts
|
|
116
|
+
var import_api_sdk_generator_core = require("@minkinad/api-sdk-generator-core");
|
|
117
|
+
|
|
118
|
+
// src/logger.ts
|
|
119
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
120
|
+
function createCliLogger(verbose = false) {
|
|
121
|
+
return {
|
|
122
|
+
debug(message) {
|
|
123
|
+
if (verbose) {
|
|
124
|
+
console.info(import_picocolors.default.dim(`[debug] ${message}`));
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
error(message) {
|
|
128
|
+
console.error(import_picocolors.default.red(`[error] ${message}`));
|
|
129
|
+
},
|
|
130
|
+
info(message) {
|
|
131
|
+
console.info(import_picocolors.default.cyan(`[api-sdk-generator] ${message}`));
|
|
132
|
+
},
|
|
133
|
+
warn(message) {
|
|
134
|
+
console.warn(import_picocolors.default.yellow(`[warn] ${message}`));
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/options.ts
|
|
140
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
141
|
+
function normalizeGenerateCommandOptions(options) {
|
|
142
|
+
const workingDirectory = process.env.INIT_CWD ?? process.cwd();
|
|
143
|
+
if (options.check && options.dryRun) {
|
|
144
|
+
throw new CliUsageError("Use either --check or --dry-run, not both.");
|
|
145
|
+
}
|
|
146
|
+
if (!options.output) {
|
|
147
|
+
throw new CliUsageError("The --output option is required.");
|
|
148
|
+
}
|
|
149
|
+
const hasFile = typeof options.file === "string" && options.file.length > 0;
|
|
150
|
+
const hasUrl = typeof options.url === "string" && options.url.length > 0;
|
|
151
|
+
if (hasFile === hasUrl) {
|
|
152
|
+
throw new CliUsageError("Provide exactly one input source: either --file or --url.");
|
|
153
|
+
}
|
|
154
|
+
if (options.url) {
|
|
155
|
+
try {
|
|
156
|
+
if (!["http:", "https:"].includes(new URL(options.url).protocol)) throw new Error();
|
|
157
|
+
} catch {
|
|
158
|
+
throw new CliUsageError(`Invalid --url value: "${options.url}".`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (options.baseUrl) {
|
|
162
|
+
try {
|
|
163
|
+
if (!["http:", "https:"].includes(new URL(options.baseUrl).protocol)) throw new Error();
|
|
164
|
+
} catch {
|
|
165
|
+
throw new CliUsageError(`Invalid --base-url value: "${options.baseUrl}".`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
baseUrl: options.baseUrl,
|
|
170
|
+
clean: options.clean ?? false,
|
|
171
|
+
check: options.check ?? false,
|
|
172
|
+
dryRun: options.dryRun ?? false,
|
|
173
|
+
input: {
|
|
174
|
+
file: options.file ? import_node_path.default.resolve(workingDirectory, options.file) : void 0,
|
|
175
|
+
url: options.url
|
|
176
|
+
},
|
|
177
|
+
outputDir: import_node_path.default.resolve(workingDirectory, options.output),
|
|
178
|
+
sdkName: options.name,
|
|
179
|
+
verbose: options.verbose ?? false
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// src/index.ts
|
|
184
|
+
async function runGenerateCommand(input) {
|
|
185
|
+
const options = normalizeGenerateCommandOptions(input);
|
|
186
|
+
await executeGenerateCommand(options);
|
|
187
|
+
}
|
|
188
|
+
async function executeGenerateCommand(options) {
|
|
189
|
+
const logger = createCliLogger(options.verbose);
|
|
190
|
+
logger.info("Starting SDK generation");
|
|
191
|
+
const result = await (0, import_api_sdk_generator_core.generateSdk)({
|
|
192
|
+
baseUrl: options.baseUrl,
|
|
193
|
+
clean: options.clean,
|
|
194
|
+
check: options.check,
|
|
195
|
+
dryRun: options.dryRun,
|
|
196
|
+
input: options.input,
|
|
197
|
+
logger,
|
|
198
|
+
outputDir: options.outputDir,
|
|
199
|
+
sdkName: options.sdkName
|
|
200
|
+
});
|
|
201
|
+
if (options.check) {
|
|
202
|
+
if (result.changedFiles.length > 0) {
|
|
203
|
+
throw new CliUsageError(`Generated SDK is out of date: ${result.changedFiles.join(", ")}`, 2);
|
|
204
|
+
}
|
|
205
|
+
logger.info("Generated SDK is up to date");
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (options.dryRun) {
|
|
209
|
+
logger.info(
|
|
210
|
+
`Would generate ${result.files.length} files for ${result.operations} operations: ${result.files.map((file) => file.path).join(", ")}`
|
|
211
|
+
);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
logger.info(
|
|
215
|
+
`Generated ${result.files.length} files for ${result.operations} operations in ${result.outputDir}`
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// src/program.ts
|
|
220
|
+
function createCliProgram() {
|
|
221
|
+
const program = new import_commander.Command();
|
|
222
|
+
program.name("api-sdk-generator").description("Generate a TypeScript fetch SDK from an OpenAPI 3.x schema.").showHelpAfterError().version(package_default.version);
|
|
223
|
+
program.command("generate").description("Generate SDK files from an OpenAPI schema URL or local file").option("--url <url>", "OpenAPI schema URL").option("--file <path>", "Local path to an OpenAPI schema JSON or YAML file").requiredOption("--output <path>", "Output directory for the generated SDK").option("--name <sdkName>", "Override the generated SDK name").option("--base-url <baseUrl>", "Override the generated client base URL").option("--clean", "Delete the output directory before writing files").option("--dry-run", "Validate and preview generation without writing files").option(
|
|
224
|
+
"--check",
|
|
225
|
+
"Check for outdated generated files without writing (exit code 2 on changes)"
|
|
226
|
+
).option("--verbose", "Enable verbose logs").action(runGenerateCommand);
|
|
227
|
+
return program;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// src/cli.ts
|
|
231
|
+
async function main() {
|
|
232
|
+
const program = createCliProgram();
|
|
233
|
+
try {
|
|
234
|
+
await program.parseAsync(process.argv);
|
|
235
|
+
} catch (error) {
|
|
236
|
+
if (error instanceof CliUsageError) {
|
|
237
|
+
console.error(import_picocolors2.default.red(error.message));
|
|
238
|
+
process.exitCode = error.exitCode;
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (error instanceof import_api_sdk_generator_core2.ApiSdkGeneratorError) {
|
|
242
|
+
console.error(import_picocolors2.default.red(`${error.code}: ${error.message}`));
|
|
243
|
+
process.exitCode = 1;
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (error instanceof Error) {
|
|
247
|
+
console.error(import_picocolors2.default.red(error.message));
|
|
248
|
+
process.exitCode = 1;
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
console.error(import_picocolors2.default.red("Unknown error during CLI execution."));
|
|
252
|
+
process.exitCode = 1;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
void main();
|
|
256
|
+
//# sourceMappingURL=cli.cjs.map
|
package/dist/cli.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/errors.ts","../src/program.ts","../package.json","../src/index.ts","../src/logger.ts","../src/options.ts"],"sourcesContent":["import { ApiSdkGeneratorError } from '@minkinad/api-sdk-generator-core';\nimport pc from 'picocolors';\n\nimport { CliUsageError } from './errors.js';\nimport { createCliProgram } from './program.js';\n\nasync function main(): Promise<void> {\n const program = createCliProgram();\n\n try {\n await program.parseAsync(process.argv);\n } catch (error) {\n if (error instanceof CliUsageError) {\n console.error(pc.red(error.message));\n process.exitCode = error.exitCode;\n return;\n }\n\n if (error instanceof ApiSdkGeneratorError) {\n console.error(pc.red(`${error.code}: ${error.message}`));\n process.exitCode = 1;\n return;\n }\n\n if (error instanceof Error) {\n console.error(pc.red(error.message));\n process.exitCode = 1;\n return;\n }\n\n console.error(pc.red('Unknown error during CLI execution.'));\n process.exitCode = 1;\n }\n}\n\nvoid main();\n","export class CliUsageError extends Error {\n public readonly exitCode: number;\n\n public constructor(message: string, exitCode = 1) {\n super(message);\n this.name = 'CliUsageError';\n this.exitCode = exitCode;\n }\n}\n","import { Command } from 'commander';\n\nimport packageMetadata from '../package.json' with { type: 'json' };\nimport { runGenerateCommand } from './index.js';\n\nexport function createCliProgram(): Command {\n const program = new Command();\n\n program\n .name('api-sdk-generator')\n .description('Generate a TypeScript fetch SDK from an OpenAPI 3.x schema.')\n .showHelpAfterError()\n .version(packageMetadata.version);\n\n program\n .command('generate')\n .description('Generate SDK files from an OpenAPI schema URL or local file')\n .option('--url <url>', 'OpenAPI schema URL')\n .option('--file <path>', 'Local path to an OpenAPI schema JSON or YAML file')\n .requiredOption('--output <path>', 'Output directory for the generated SDK')\n .option('--name <sdkName>', 'Override the generated SDK name')\n .option('--base-url <baseUrl>', 'Override the generated client base URL')\n .option('--clean', 'Delete the output directory before writing files')\n .option('--dry-run', 'Validate and preview generation without writing files')\n .option(\n '--check',\n 'Check for outdated generated files without writing (exit code 2 on changes)',\n )\n .option('--verbose', 'Enable verbose logs')\n .action(runGenerateCommand);\n\n return program;\n}\n","{\n \"name\": \"api-sdk-generator\",\n \"version\": \"0.2.0\",\n \"description\": \"CLI for generating TypeScript SDK clients from OpenAPI 3.x schemas.\",\n \"type\": \"module\",\n \"bin\": {\n \"api-sdk-generator\": \"dist/cli.cjs\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n }\n },\n \"files\": [\n \"dist\",\n \"README.md\",\n \"LICENSE\"\n ],\n \"sideEffects\": false,\n \"engines\": {\n \"node\": \">=20\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"generate\": \"node ./dist/cli.cjs generate\",\n \"test\": \"vitest run --coverage\",\n \"test:watch\": \"vitest\",\n \"lint\": \"eslint src test\",\n \"typecheck\": \"tsc --project tsconfig.json --noEmit\",\n \"clean\": \"rm -rf dist coverage\",\n \"prepack\": \"pnpm run build\"\n },\n \"dependencies\": {\n \"@minkinad/api-sdk-generator-core\": \"workspace:*\",\n \"commander\": \"^13.1.0\",\n \"picocolors\": \"^1.1.1\"\n },\n \"license\": \"MIT\",\n \"author\": \"minkinad\",\n \"homepage\": \"https://minkinad.github.io/api-sdk-generator/\",\n \"bugs\": {\n \"url\": \"https://github.com/minkinad/api-sdk-generator/issues\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/minkinad/api-sdk-generator.git\",\n \"directory\": \"packages/cli\"\n },\n \"keywords\": [\n \"openapi\",\n \"sdk\",\n \"typescript\",\n \"codegen\",\n \"fetch\"\n ]\n}\n","import { generateSdk } from '@minkinad/api-sdk-generator-core';\n\nimport { CliUsageError } from './errors.js';\nimport { createCliLogger } from './logger.js';\nimport {\n normalizeGenerateCommandOptions,\n type GenerateCommandOptionsInput,\n type NormalizedGenerateCommandOptions,\n} from './options.js';\n\nexport type { GenerateCommandOptionsInput, NormalizedGenerateCommandOptions } from './options.js';\nexport { CliUsageError } from './errors.js';\nexport { normalizeGenerateCommandOptions } from './options.js';\n\nexport async function runGenerateCommand(input: GenerateCommandOptionsInput): Promise<void> {\n const options = normalizeGenerateCommandOptions(input);\n await executeGenerateCommand(options);\n}\n\nexport async function executeGenerateCommand(\n options: NormalizedGenerateCommandOptions,\n): Promise<void> {\n const logger = createCliLogger(options.verbose);\n logger.info('Starting SDK generation');\n\n const result = await generateSdk({\n baseUrl: options.baseUrl,\n clean: options.clean,\n check: options.check,\n dryRun: options.dryRun,\n input: options.input,\n logger,\n outputDir: options.outputDir,\n sdkName: options.sdkName,\n });\n\n if (options.check) {\n if (result.changedFiles.length > 0) {\n throw new CliUsageError(`Generated SDK is out of date: ${result.changedFiles.join(', ')}`, 2);\n }\n logger.info('Generated SDK is up to date');\n return;\n }\n if (options.dryRun) {\n logger.info(\n `Would generate ${result.files.length} files for ${result.operations} operations: ${result.files.map((file) => file.path).join(', ')}`,\n );\n return;\n }\n logger.info(\n `Generated ${result.files.length} files for ${result.operations} operations in ${result.outputDir}`,\n );\n}\n","import type { Logger } from '@minkinad/api-sdk-generator-core';\nimport pc from 'picocolors';\n\nexport function createCliLogger(verbose = false): Logger {\n return {\n debug(message: string): void {\n if (verbose) {\n console.info(pc.dim(`[debug] ${message}`));\n }\n },\n error(message: string): void {\n console.error(pc.red(`[error] ${message}`));\n },\n info(message: string): void {\n console.info(pc.cyan(`[api-sdk-generator] ${message}`));\n },\n warn(message: string): void {\n console.warn(pc.yellow(`[warn] ${message}`));\n },\n };\n}\n","import path from 'node:path';\n\nimport { CliUsageError } from './errors.js';\n\nexport interface GenerateCommandOptionsInput {\n baseUrl?: string;\n clean?: boolean;\n check?: boolean;\n dryRun?: boolean;\n file?: string;\n name?: string;\n output?: string;\n url?: string;\n verbose?: boolean;\n}\n\nexport interface NormalizedGenerateCommandOptions {\n baseUrl?: string;\n clean: boolean;\n check: boolean;\n dryRun: boolean;\n input: {\n file?: string;\n url?: string;\n };\n outputDir: string;\n sdkName?: string;\n verbose: boolean;\n}\n\nexport function normalizeGenerateCommandOptions(\n options: GenerateCommandOptionsInput,\n): NormalizedGenerateCommandOptions {\n const workingDirectory = process.env.INIT_CWD ?? process.cwd();\n\n if (options.check && options.dryRun) {\n throw new CliUsageError('Use either --check or --dry-run, not both.');\n }\n\n if (!options.output) {\n throw new CliUsageError('The --output option is required.');\n }\n\n const hasFile = typeof options.file === 'string' && options.file.length > 0;\n const hasUrl = typeof options.url === 'string' && options.url.length > 0;\n\n if (hasFile === hasUrl) {\n throw new CliUsageError('Provide exactly one input source: either --file or --url.');\n }\n\n if (options.url) {\n try {\n if (!['http:', 'https:'].includes(new URL(options.url).protocol)) throw new Error();\n } catch {\n throw new CliUsageError(`Invalid --url value: \"${options.url}\".`);\n }\n }\n\n if (options.baseUrl) {\n try {\n if (!['http:', 'https:'].includes(new URL(options.baseUrl).protocol)) throw new Error();\n } catch {\n throw new CliUsageError(`Invalid --base-url value: \"${options.baseUrl}\".`);\n }\n }\n\n return {\n baseUrl: options.baseUrl,\n clean: options.clean ?? false,\n check: options.check ?? false,\n dryRun: options.dryRun ?? false,\n input: {\n file: options.file ? path.resolve(workingDirectory, options.file) : undefined,\n url: options.url,\n },\n outputDir: path.resolve(workingDirectory, options.output),\n sdkName: options.name,\n verbose: options.verbose ?? false,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,iCAAqC;AACrC,IAAAC,qBAAe;;;ACDR,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvB;AAAA,EAET,YAAY,SAAiB,WAAW,GAAG;AAChD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EAClB;AACF;;;ACRA,uBAAwB;;;ACAxB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,KAAO;AAAA,IACL,qBAAqB;AAAA,EACvB;AAAA,EACA,MAAQ;AAAA,EACR,QAAU;AAAA,EACV,OAAS;AAAA,EACT,SAAW;AAAA,IACT,KAAK;AAAA,MACH,QAAU;AAAA,QACR,OAAS;AAAA,QACT,SAAW;AAAA,MACb;AAAA,MACA,SAAW;AAAA,QACT,OAAS;AAAA,QACT,SAAW;AAAA,MACb;AAAA,IACF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AAO,eAAe,oBAAoB,EAC1C,OAAO,iBAAiB,mDAAmD,EAC3E,eAAe,mBAAmB,wCAAwC,EAC1E,OAAO,oBAAoB,iCAAiC,EAC5D,OAAO,wBAAwB,wCAAwC,EACvE,OAAO,WAAW,kDAAkD,EACpE,OAAO,aAAa,uDAAuD,EAC3E;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,aAAa,qBAAqB,EACzC,OAAO,kBAAkB;AAE5B,SAAO;AACT;;;AF1BA,eAAe,OAAsB;AACnC,QAAM,UAAU,iBAAiB;AAEjC,MAAI;AACF,UAAM,QAAQ,WAAW,QAAQ,IAAI;AAAA,EACvC,SAAS,OAAO;AACd,QAAI,iBAAiB,eAAe;AAClC,cAAQ,MAAM,mBAAAC,QAAG,IAAI,MAAM,OAAO,CAAC;AACnC,cAAQ,WAAW,MAAM;AACzB;AAAA,IACF;AAEA,QAAI,iBAAiB,qDAAsB;AACzC,cAAQ,MAAM,mBAAAA,QAAG,IAAI,GAAG,MAAM,IAAI,KAAK,MAAM,OAAO,EAAE,CAAC;AACvD,cAAQ,WAAW;AACnB;AAAA,IACF;AAEA,QAAI,iBAAiB,OAAO;AAC1B,cAAQ,MAAM,mBAAAA,QAAG,IAAI,MAAM,OAAO,CAAC;AACnC,cAAQ,WAAW;AACnB;AAAA,IACF;AAEA,YAAQ,MAAM,mBAAAA,QAAG,IAAI,qCAAqC,CAAC;AAC3D,YAAQ,WAAW;AAAA,EACrB;AACF;AAEA,KAAK,KAAK;","names":["import_api_sdk_generator_core","import_picocolors","pc","path","pc"]}
|
package/dist/cli.d.cts
ADDED
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
CliUsageError,
|
|
4
|
+
runGenerateCommand
|
|
5
|
+
} from "./chunk-EJ36UYRY.js";
|
|
6
|
+
|
|
7
|
+
// src/cli.ts
|
|
8
|
+
import { ApiSdkGeneratorError } from "@minkinad/api-sdk-generator-core";
|
|
9
|
+
import pc from "picocolors";
|
|
10
|
+
|
|
11
|
+
// src/program.ts
|
|
12
|
+
import { Command } from "commander";
|
|
13
|
+
|
|
14
|
+
// package.json
|
|
15
|
+
var package_default = {
|
|
16
|
+
name: "api-sdk-generator",
|
|
17
|
+
version: "0.2.0",
|
|
18
|
+
description: "CLI for generating TypeScript SDK clients from OpenAPI 3.x schemas.",
|
|
19
|
+
type: "module",
|
|
20
|
+
bin: {
|
|
21
|
+
"api-sdk-generator": "dist/cli.cjs"
|
|
22
|
+
},
|
|
23
|
+
main: "./dist/index.cjs",
|
|
24
|
+
module: "./dist/index.js",
|
|
25
|
+
types: "./dist/index.d.ts",
|
|
26
|
+
exports: {
|
|
27
|
+
".": {
|
|
28
|
+
import: {
|
|
29
|
+
types: "./dist/index.d.ts",
|
|
30
|
+
default: "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
require: {
|
|
33
|
+
types: "./dist/index.d.cts",
|
|
34
|
+
default: "./dist/index.cjs"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
files: [
|
|
39
|
+
"dist",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
],
|
|
43
|
+
sideEffects: false,
|
|
44
|
+
engines: {
|
|
45
|
+
node: ">=20"
|
|
46
|
+
},
|
|
47
|
+
publishConfig: {
|
|
48
|
+
access: "public",
|
|
49
|
+
registry: "https://registry.npmjs.org/"
|
|
50
|
+
},
|
|
51
|
+
scripts: {
|
|
52
|
+
build: "tsup",
|
|
53
|
+
generate: "node ./dist/cli.cjs generate",
|
|
54
|
+
test: "vitest run --coverage",
|
|
55
|
+
"test:watch": "vitest",
|
|
56
|
+
lint: "eslint src test",
|
|
57
|
+
typecheck: "tsc --project tsconfig.json --noEmit",
|
|
58
|
+
clean: "rm -rf dist coverage",
|
|
59
|
+
prepack: "pnpm run build"
|
|
60
|
+
},
|
|
61
|
+
dependencies: {
|
|
62
|
+
"@minkinad/api-sdk-generator-core": "workspace:*",
|
|
63
|
+
commander: "^13.1.0",
|
|
64
|
+
picocolors: "^1.1.1"
|
|
65
|
+
},
|
|
66
|
+
license: "MIT",
|
|
67
|
+
author: "minkinad",
|
|
68
|
+
homepage: "https://minkinad.github.io/api-sdk-generator/",
|
|
69
|
+
bugs: {
|
|
70
|
+
url: "https://github.com/minkinad/api-sdk-generator/issues"
|
|
71
|
+
},
|
|
72
|
+
repository: {
|
|
73
|
+
type: "git",
|
|
74
|
+
url: "git+https://github.com/minkinad/api-sdk-generator.git",
|
|
75
|
+
directory: "packages/cli"
|
|
76
|
+
},
|
|
77
|
+
keywords: [
|
|
78
|
+
"openapi",
|
|
79
|
+
"sdk",
|
|
80
|
+
"typescript",
|
|
81
|
+
"codegen",
|
|
82
|
+
"fetch"
|
|
83
|
+
]
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// src/program.ts
|
|
87
|
+
function createCliProgram() {
|
|
88
|
+
const program = new Command();
|
|
89
|
+
program.name("api-sdk-generator").description("Generate a TypeScript fetch SDK from an OpenAPI 3.x schema.").showHelpAfterError().version(package_default.version);
|
|
90
|
+
program.command("generate").description("Generate SDK files from an OpenAPI schema URL or local file").option("--url <url>", "OpenAPI schema URL").option("--file <path>", "Local path to an OpenAPI schema JSON or YAML file").requiredOption("--output <path>", "Output directory for the generated SDK").option("--name <sdkName>", "Override the generated SDK name").option("--base-url <baseUrl>", "Override the generated client base URL").option("--clean", "Delete the output directory before writing files").option("--dry-run", "Validate and preview generation without writing files").option(
|
|
91
|
+
"--check",
|
|
92
|
+
"Check for outdated generated files without writing (exit code 2 on changes)"
|
|
93
|
+
).option("--verbose", "Enable verbose logs").action(runGenerateCommand);
|
|
94
|
+
return program;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/cli.ts
|
|
98
|
+
async function main() {
|
|
99
|
+
const program = createCliProgram();
|
|
100
|
+
try {
|
|
101
|
+
await program.parseAsync(process.argv);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if (error instanceof CliUsageError) {
|
|
104
|
+
console.error(pc.red(error.message));
|
|
105
|
+
process.exitCode = error.exitCode;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (error instanceof ApiSdkGeneratorError) {
|
|
109
|
+
console.error(pc.red(`${error.code}: ${error.message}`));
|
|
110
|
+
process.exitCode = 1;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (error instanceof Error) {
|
|
114
|
+
console.error(pc.red(error.message));
|
|
115
|
+
process.exitCode = 1;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
console.error(pc.red("Unknown error during CLI execution."));
|
|
119
|
+
process.exitCode = 1;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
void main();
|
|
123
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/program.ts","../package.json"],"sourcesContent":["import { ApiSdkGeneratorError } from '@minkinad/api-sdk-generator-core';\nimport pc from 'picocolors';\n\nimport { CliUsageError } from './errors.js';\nimport { createCliProgram } from './program.js';\n\nasync function main(): Promise<void> {\n const program = createCliProgram();\n\n try {\n await program.parseAsync(process.argv);\n } catch (error) {\n if (error instanceof CliUsageError) {\n console.error(pc.red(error.message));\n process.exitCode = error.exitCode;\n return;\n }\n\n if (error instanceof ApiSdkGeneratorError) {\n console.error(pc.red(`${error.code}: ${error.message}`));\n process.exitCode = 1;\n return;\n }\n\n if (error instanceof Error) {\n console.error(pc.red(error.message));\n process.exitCode = 1;\n return;\n }\n\n console.error(pc.red('Unknown error during CLI execution.'));\n process.exitCode = 1;\n }\n}\n\nvoid main();\n","import { Command } from 'commander';\n\nimport packageMetadata from '../package.json' with { type: 'json' };\nimport { runGenerateCommand } from './index.js';\n\nexport function createCliProgram(): Command {\n const program = new Command();\n\n program\n .name('api-sdk-generator')\n .description('Generate a TypeScript fetch SDK from an OpenAPI 3.x schema.')\n .showHelpAfterError()\n .version(packageMetadata.version);\n\n program\n .command('generate')\n .description('Generate SDK files from an OpenAPI schema URL or local file')\n .option('--url <url>', 'OpenAPI schema URL')\n .option('--file <path>', 'Local path to an OpenAPI schema JSON or YAML file')\n .requiredOption('--output <path>', 'Output directory for the generated SDK')\n .option('--name <sdkName>', 'Override the generated SDK name')\n .option('--base-url <baseUrl>', 'Override the generated client base URL')\n .option('--clean', 'Delete the output directory before writing files')\n .option('--dry-run', 'Validate and preview generation without writing files')\n .option(\n '--check',\n 'Check for outdated generated files without writing (exit code 2 on changes)',\n )\n .option('--verbose', 'Enable verbose logs')\n .action(runGenerateCommand);\n\n return program;\n}\n","{\n \"name\": \"api-sdk-generator\",\n \"version\": \"0.2.0\",\n \"description\": \"CLI for generating TypeScript SDK clients from OpenAPI 3.x schemas.\",\n \"type\": \"module\",\n \"bin\": {\n \"api-sdk-generator\": \"dist/cli.cjs\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n }\n },\n \"files\": [\n \"dist\",\n \"README.md\",\n \"LICENSE\"\n ],\n \"sideEffects\": false,\n \"engines\": {\n \"node\": \">=20\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"generate\": \"node ./dist/cli.cjs generate\",\n \"test\": \"vitest run --coverage\",\n \"test:watch\": \"vitest\",\n \"lint\": \"eslint src test\",\n \"typecheck\": \"tsc --project tsconfig.json --noEmit\",\n \"clean\": \"rm -rf dist coverage\",\n \"prepack\": \"pnpm run build\"\n },\n \"dependencies\": {\n \"@minkinad/api-sdk-generator-core\": \"workspace:*\",\n \"commander\": \"^13.1.0\",\n \"picocolors\": \"^1.1.1\"\n },\n \"license\": \"MIT\",\n \"author\": \"minkinad\",\n \"homepage\": \"https://minkinad.github.io/api-sdk-generator/\",\n \"bugs\": {\n \"url\": \"https://github.com/minkinad/api-sdk-generator/issues\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/minkinad/api-sdk-generator.git\",\n \"directory\": \"packages/cli\"\n },\n \"keywords\": [\n \"openapi\",\n \"sdk\",\n \"typescript\",\n \"codegen\",\n \"fetch\"\n ]\n}\n"],"mappings":";;;;;;;AAAA,SAAS,4BAA4B;AACrC,OAAO,QAAQ;;;ACDf,SAAS,eAAe;;;ACAxB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,KAAO;AAAA,IACL,qBAAqB;AAAA,EACvB;AAAA,EACA,MAAQ;AAAA,EACR,QAAU;AAAA,EACV,OAAS;AAAA,EACT,SAAW;AAAA,IACT,KAAK;AAAA,MACH,QAAU;AAAA,QACR,OAAS;AAAA,QACT,SAAW;AAAA,MACb;AAAA,MACA,SAAW;AAAA,QACT,OAAS;AAAA,QACT,SAAW;AAAA,MACb;AAAA,IACF;AAAA,EACF;AAAA,EACA,OAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,aAAe;AAAA,EACf,SAAW;AAAA,IACT,MAAQ;AAAA,EACV;AAAA,EACA,eAAiB;AAAA,IACf,QAAU;AAAA,IACV,UAAY;AAAA,EACd;AAAA,EACA,SAAW;AAAA,IACT,OAAS;AAAA,IACT,UAAY;AAAA,IACZ,MAAQ;AAAA,IACR,cAAc;AAAA,IACd,MAAQ;AAAA,IACR,WAAa;AAAA,IACb,OAAS;AAAA,IACT,SAAW;AAAA,EACb;AAAA,EACA,cAAgB;AAAA,IACd,oCAAoC;AAAA,IACpC,WAAa;AAAA,IACb,Y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AAC;AACnC,cAAQ,WAAW;AACnB;AAAA,IACF;AAEA,YAAQ,MAAM,GAAG,IAAI,qCAAqC,CAAC;AAC3D,YAAQ,WAAW;AAAA,EACrB;AACF;AAEA,KAAK,KAAK;","names":[]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/index.ts
|
|
32
|
+
var index_exports = {};
|
|
33
|
+
__export(index_exports, {
|
|
34
|
+
CliUsageError: () => CliUsageError,
|
|
35
|
+
executeGenerateCommand: () => executeGenerateCommand,
|
|
36
|
+
normalizeGenerateCommandOptions: () => normalizeGenerateCommandOptions,
|
|
37
|
+
runGenerateCommand: () => runGenerateCommand
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(index_exports);
|
|
40
|
+
var import_api_sdk_generator_core = require("@minkinad/api-sdk-generator-core");
|
|
41
|
+
|
|
42
|
+
// src/errors.ts
|
|
43
|
+
var CliUsageError = class extends Error {
|
|
44
|
+
exitCode;
|
|
45
|
+
constructor(message, exitCode = 1) {
|
|
46
|
+
super(message);
|
|
47
|
+
this.name = "CliUsageError";
|
|
48
|
+
this.exitCode = exitCode;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// src/logger.ts
|
|
53
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
54
|
+
function createCliLogger(verbose = false) {
|
|
55
|
+
return {
|
|
56
|
+
debug(message) {
|
|
57
|
+
if (verbose) {
|
|
58
|
+
console.info(import_picocolors.default.dim(`[debug] ${message}`));
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
error(message) {
|
|
62
|
+
console.error(import_picocolors.default.red(`[error] ${message}`));
|
|
63
|
+
},
|
|
64
|
+
info(message) {
|
|
65
|
+
console.info(import_picocolors.default.cyan(`[api-sdk-generator] ${message}`));
|
|
66
|
+
},
|
|
67
|
+
warn(message) {
|
|
68
|
+
console.warn(import_picocolors.default.yellow(`[warn] ${message}`));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/options.ts
|
|
74
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
75
|
+
function normalizeGenerateCommandOptions(options) {
|
|
76
|
+
const workingDirectory = process.env.INIT_CWD ?? process.cwd();
|
|
77
|
+
if (options.check && options.dryRun) {
|
|
78
|
+
throw new CliUsageError("Use either --check or --dry-run, not both.");
|
|
79
|
+
}
|
|
80
|
+
if (!options.output) {
|
|
81
|
+
throw new CliUsageError("The --output option is required.");
|
|
82
|
+
}
|
|
83
|
+
const hasFile = typeof options.file === "string" && options.file.length > 0;
|
|
84
|
+
const hasUrl = typeof options.url === "string" && options.url.length > 0;
|
|
85
|
+
if (hasFile === hasUrl) {
|
|
86
|
+
throw new CliUsageError("Provide exactly one input source: either --file or --url.");
|
|
87
|
+
}
|
|
88
|
+
if (options.url) {
|
|
89
|
+
try {
|
|
90
|
+
if (!["http:", "https:"].includes(new URL(options.url).protocol)) throw new Error();
|
|
91
|
+
} catch {
|
|
92
|
+
throw new CliUsageError(`Invalid --url value: "${options.url}".`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (options.baseUrl) {
|
|
96
|
+
try {
|
|
97
|
+
if (!["http:", "https:"].includes(new URL(options.baseUrl).protocol)) throw new Error();
|
|
98
|
+
} catch {
|
|
99
|
+
throw new CliUsageError(`Invalid --base-url value: "${options.baseUrl}".`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
baseUrl: options.baseUrl,
|
|
104
|
+
clean: options.clean ?? false,
|
|
105
|
+
check: options.check ?? false,
|
|
106
|
+
dryRun: options.dryRun ?? false,
|
|
107
|
+
input: {
|
|
108
|
+
file: options.file ? import_node_path.default.resolve(workingDirectory, options.file) : void 0,
|
|
109
|
+
url: options.url
|
|
110
|
+
},
|
|
111
|
+
outputDir: import_node_path.default.resolve(workingDirectory, options.output),
|
|
112
|
+
sdkName: options.name,
|
|
113
|
+
verbose: options.verbose ?? false
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/index.ts
|
|
118
|
+
async function runGenerateCommand(input) {
|
|
119
|
+
const options = normalizeGenerateCommandOptions(input);
|
|
120
|
+
await executeGenerateCommand(options);
|
|
121
|
+
}
|
|
122
|
+
async function executeGenerateCommand(options) {
|
|
123
|
+
const logger = createCliLogger(options.verbose);
|
|
124
|
+
logger.info("Starting SDK generation");
|
|
125
|
+
const result = await (0, import_api_sdk_generator_core.generateSdk)({
|
|
126
|
+
baseUrl: options.baseUrl,
|
|
127
|
+
clean: options.clean,
|
|
128
|
+
check: options.check,
|
|
129
|
+
dryRun: options.dryRun,
|
|
130
|
+
input: options.input,
|
|
131
|
+
logger,
|
|
132
|
+
outputDir: options.outputDir,
|
|
133
|
+
sdkName: options.sdkName
|
|
134
|
+
});
|
|
135
|
+
if (options.check) {
|
|
136
|
+
if (result.changedFiles.length > 0) {
|
|
137
|
+
throw new CliUsageError(`Generated SDK is out of date: ${result.changedFiles.join(", ")}`, 2);
|
|
138
|
+
}
|
|
139
|
+
logger.info("Generated SDK is up to date");
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (options.dryRun) {
|
|
143
|
+
logger.info(
|
|
144
|
+
`Would generate ${result.files.length} files for ${result.operations} operations: ${result.files.map((file) => file.path).join(", ")}`
|
|
145
|
+
);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
logger.info(
|
|
149
|
+
`Generated ${result.files.length} files for ${result.operations} operations in ${result.outputDir}`
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
153
|
+
0 && (module.exports = {
|
|
154
|
+
CliUsageError,
|
|
155
|
+
executeGenerateCommand,
|
|
156
|
+
normalizeGenerateCommandOptions,
|
|
157
|
+
runGenerateCommand
|
|
158
|
+
});
|
|
159
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/logger.ts","../src/options.ts"],"sourcesContent":["import { generateSdk } from '@minkinad/api-sdk-generator-core';\n\nimport { CliUsageError } from './errors.js';\nimport { createCliLogger } from './logger.js';\nimport {\n normalizeGenerateCommandOptions,\n type GenerateCommandOptionsInput,\n type NormalizedGenerateCommandOptions,\n} from './options.js';\n\nexport type { GenerateCommandOptionsInput, NormalizedGenerateCommandOptions } from './options.js';\nexport { CliUsageError } from './errors.js';\nexport { normalizeGenerateCommandOptions } from './options.js';\n\nexport async function runGenerateCommand(input: GenerateCommandOptionsInput): Promise<void> {\n const options = normalizeGenerateCommandOptions(input);\n await executeGenerateCommand(options);\n}\n\nexport async function executeGenerateCommand(\n options: NormalizedGenerateCommandOptions,\n): Promise<void> {\n const logger = createCliLogger(options.verbose);\n logger.info('Starting SDK generation');\n\n const result = await generateSdk({\n baseUrl: options.baseUrl,\n clean: options.clean,\n check: options.check,\n dryRun: options.dryRun,\n input: options.input,\n logger,\n outputDir: options.outputDir,\n sdkName: options.sdkName,\n });\n\n if (options.check) {\n if (result.changedFiles.length > 0) {\n throw new CliUsageError(`Generated SDK is out of date: ${result.changedFiles.join(', ')}`, 2);\n }\n logger.info('Generated SDK is up to date');\n return;\n }\n if (options.dryRun) {\n logger.info(\n `Would generate ${result.files.length} files for ${result.operations} operations: ${result.files.map((file) => file.path).join(', ')}`,\n );\n return;\n }\n logger.info(\n `Generated ${result.files.length} files for ${result.operations} operations in ${result.outputDir}`,\n );\n}\n","export class CliUsageError extends Error {\n public readonly exitCode: number;\n\n public constructor(message: string, exitCode = 1) {\n super(message);\n this.name = 'CliUsageError';\n this.exitCode = exitCode;\n }\n}\n","import type { Logger } from '@minkinad/api-sdk-generator-core';\nimport pc from 'picocolors';\n\nexport function createCliLogger(verbose = false): Logger {\n return {\n debug(message: string): void {\n if (verbose) {\n console.info(pc.dim(`[debug] ${message}`));\n }\n },\n error(message: string): void {\n console.error(pc.red(`[error] ${message}`));\n },\n info(message: string): void {\n console.info(pc.cyan(`[api-sdk-generator] ${message}`));\n },\n warn(message: string): void {\n console.warn(pc.yellow(`[warn] ${message}`));\n },\n };\n}\n","import path from 'node:path';\n\nimport { CliUsageError } from './errors.js';\n\nexport interface GenerateCommandOptionsInput {\n baseUrl?: string;\n clean?: boolean;\n check?: boolean;\n dryRun?: boolean;\n file?: string;\n name?: string;\n output?: string;\n url?: string;\n verbose?: boolean;\n}\n\nexport interface NormalizedGenerateCommandOptions {\n baseUrl?: string;\n clean: boolean;\n check: boolean;\n dryRun: boolean;\n input: {\n file?: string;\n url?: string;\n };\n outputDir: string;\n sdkName?: string;\n verbose: boolean;\n}\n\nexport function normalizeGenerateCommandOptions(\n options: GenerateCommandOptionsInput,\n): NormalizedGenerateCommandOptions {\n const workingDirectory = process.env.INIT_CWD ?? process.cwd();\n\n if (options.check && options.dryRun) {\n throw new CliUsageError('Use either --check or --dry-run, not both.');\n }\n\n if (!options.output) {\n throw new CliUsageError('The --output option is required.');\n }\n\n const hasFile = typeof options.file === 'string' && options.file.length > 0;\n const hasUrl = typeof options.url === 'string' && options.url.length > 0;\n\n if (hasFile === hasUrl) {\n throw new CliUsageError('Provide exactly one input source: either --file or --url.');\n }\n\n if (options.url) {\n try {\n if (!['http:', 'https:'].includes(new URL(options.url).protocol)) throw new Error();\n } catch {\n throw new CliUsageError(`Invalid --url value: \"${options.url}\".`);\n }\n }\n\n if (options.baseUrl) {\n try {\n if (!['http:', 'https:'].includes(new URL(options.baseUrl).protocol)) throw new Error();\n } catch {\n throw new CliUsageError(`Invalid --base-url value: \"${options.baseUrl}\".`);\n }\n }\n\n return {\n baseUrl: options.baseUrl,\n clean: options.clean ?? false,\n check: options.check ?? false,\n dryRun: options.dryRun ?? false,\n input: {\n file: options.file ? path.resolve(workingDirectory, options.file) : undefined,\n url: options.url,\n },\n outputDir: path.resolve(workingDirectory, options.output),\n sdkName: options.name,\n verbose: options.verbose ?? false,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAA4B;;;ACArB,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvB;AAAA,EAET,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iC,OAAO,aAAa,KAAK,IAAI,CAAC,IAAI,CAAC;AAAA,IAC9F;AACA,WAAO,KAAK,6BAA6B;AACzC;AAAA,EACF;AACA,MAAI,QAAQ,QAAQ;AAClB,WAAO;AAAA,MACL,kBAAkB,OAAO,MAAM,MAAM,cAAc,OAAO,UAAU,gBAAgB,OAAO,MAAM,IAAI,CAAC,SAAS,KAAK,IAAI,EAAE,KAAK,IAAI,CAAC;AAAA,IACtI;AACA;AAAA,EACF;AACA,SAAO;AAAA,IACL,aAAa,OAAO,MAAM,MAAM,cAAc,OAAO,UAAU,kBAAkB,OAAO,SAAS;AAAA,EACnG;AACF;","names":["pc","path"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
interface GenerateCommandOptionsInput {
|
|
2
|
+
baseUrl?: string;
|
|
3
|
+
clean?: boolean;
|
|
4
|
+
check?: boolean;
|
|
5
|
+
dryRun?: boolean;
|
|
6
|
+
file?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
output?: string;
|
|
9
|
+
url?: string;
|
|
10
|
+
verbose?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface NormalizedGenerateCommandOptions {
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
clean: boolean;
|
|
15
|
+
check: boolean;
|
|
16
|
+
dryRun: boolean;
|
|
17
|
+
input: {
|
|
18
|
+
file?: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
};
|
|
21
|
+
outputDir: string;
|
|
22
|
+
sdkName?: string;
|
|
23
|
+
verbose: boolean;
|
|
24
|
+
}
|
|
25
|
+
declare function normalizeGenerateCommandOptions(options: GenerateCommandOptionsInput): NormalizedGenerateCommandOptions;
|
|
26
|
+
|
|
27
|
+
declare class CliUsageError extends Error {
|
|
28
|
+
readonly exitCode: number;
|
|
29
|
+
constructor(message: string, exitCode?: number);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare function runGenerateCommand(input: GenerateCommandOptionsInput): Promise<void>;
|
|
33
|
+
declare function executeGenerateCommand(options: NormalizedGenerateCommandOptions): Promise<void>;
|
|
34
|
+
|
|
35
|
+
export { CliUsageError, type GenerateCommandOptionsInput, type NormalizedGenerateCommandOptions, executeGenerateCommand, normalizeGenerateCommandOptions, runGenerateCommand };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
interface GenerateCommandOptionsInput {
|
|
2
|
+
baseUrl?: string;
|
|
3
|
+
clean?: boolean;
|
|
4
|
+
check?: boolean;
|
|
5
|
+
dryRun?: boolean;
|
|
6
|
+
file?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
output?: string;
|
|
9
|
+
url?: string;
|
|
10
|
+
verbose?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface NormalizedGenerateCommandOptions {
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
clean: boolean;
|
|
15
|
+
check: boolean;
|
|
16
|
+
dryRun: boolean;
|
|
17
|
+
input: {
|
|
18
|
+
file?: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
};
|
|
21
|
+
outputDir: string;
|
|
22
|
+
sdkName?: string;
|
|
23
|
+
verbose: boolean;
|
|
24
|
+
}
|
|
25
|
+
declare function normalizeGenerateCommandOptions(options: GenerateCommandOptionsInput): NormalizedGenerateCommandOptions;
|
|
26
|
+
|
|
27
|
+
declare class CliUsageError extends Error {
|
|
28
|
+
readonly exitCode: number;
|
|
29
|
+
constructor(message: string, exitCode?: number);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare function runGenerateCommand(input: GenerateCommandOptionsInput): Promise<void>;
|
|
33
|
+
declare function executeGenerateCommand(options: NormalizedGenerateCommandOptions): Promise<void>;
|
|
34
|
+
|
|
35
|
+
export { CliUsageError, type GenerateCommandOptionsInput, type NormalizedGenerateCommandOptions, executeGenerateCommand, normalizeGenerateCommandOptions, runGenerateCommand };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
CliUsageError,
|
|
4
|
+
executeGenerateCommand,
|
|
5
|
+
normalizeGenerateCommandOptions,
|
|
6
|
+
runGenerateCommand
|
|
7
|
+
} from "./chunk-EJ36UYRY.js";
|
|
8
|
+
export {
|
|
9
|
+
CliUsageError,
|
|
10
|
+
executeGenerateCommand,
|
|
11
|
+
normalizeGenerateCommandOptions,
|
|
12
|
+
runGenerateCommand
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "api-sdk-generator",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "CLI for generating TypeScript SDK clients from OpenAPI 3.x schemas.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"api-sdk-generator": "dist/cli.cjs"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.cjs",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.cts",
|
|
20
|
+
"default": "./dist/index.cjs"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=20"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public",
|
|
35
|
+
"registry": "https://registry.npmjs.org/"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"commander": "^13.1.0",
|
|
39
|
+
"picocolors": "^1.1.1",
|
|
40
|
+
"@minkinad/api-sdk-generator-core": "0.2.0"
|
|
41
|
+
},
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"author": "minkinad",
|
|
44
|
+
"homepage": "https://minkinad.github.io/api-sdk-generator/",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/minkinad/api-sdk-generator/issues"
|
|
47
|
+
},
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/minkinad/api-sdk-generator.git",
|
|
51
|
+
"directory": "packages/cli"
|
|
52
|
+
},
|
|
53
|
+
"keywords": [
|
|
54
|
+
"openapi",
|
|
55
|
+
"sdk",
|
|
56
|
+
"typescript",
|
|
57
|
+
"codegen",
|
|
58
|
+
"fetch"
|
|
59
|
+
],
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "tsup",
|
|
62
|
+
"generate": "node ./dist/cli.cjs generate",
|
|
63
|
+
"test": "vitest run --coverage",
|
|
64
|
+
"test:watch": "vitest",
|
|
65
|
+
"lint": "eslint src test",
|
|
66
|
+
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
67
|
+
"clean": "rm -rf dist coverage"
|
|
68
|
+
}
|
|
69
|
+
}
|