dorval 0.1.7 → 0.2.2
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/bin/dorval.cjs +178 -0
- package/dist/bin/dorval.cjs.map +1 -0
- package/dist/bin/dorval.d.cts +1 -0
- package/dist/bin/dorval.d.ts +1 -0
- package/dist/bin/dorval.js +39 -62
- package/dist/bin/dorval.js.map +1 -1
- package/dist/index.cjs +183 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +34 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +34 -74
- package/dist/index.js.map +1 -1
- package/package.json +17 -8
|
@@ -0,0 +1,178 @@
|
|
|
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 __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/bin/dorval.ts
|
|
27
|
+
var import_commander = require("commander");
|
|
28
|
+
var import_chalk3 = __toESM(require("chalk"), 1);
|
|
29
|
+
|
|
30
|
+
// src/commands/generate.ts
|
|
31
|
+
var import_chalk = __toESM(require("chalk"), 1);
|
|
32
|
+
var import_core = require("@dorval/core");
|
|
33
|
+
|
|
34
|
+
// src/config.ts
|
|
35
|
+
var import_cosmiconfig = require("cosmiconfig");
|
|
36
|
+
function getExplorer() {
|
|
37
|
+
return (0, import_cosmiconfig.cosmiconfigSync)("orval", {
|
|
38
|
+
searchPlaces: [
|
|
39
|
+
"orval.config.ts",
|
|
40
|
+
"orval.config.js",
|
|
41
|
+
"orval.config.cjs",
|
|
42
|
+
".orvalrc",
|
|
43
|
+
".orvalrc.json",
|
|
44
|
+
".orvalrc.yaml",
|
|
45
|
+
".orvalrc.yml",
|
|
46
|
+
"package.json"
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async function loadConfig(configPath) {
|
|
51
|
+
const explorer = getExplorer();
|
|
52
|
+
const result = configPath ? explorer.load(configPath) : explorer.search();
|
|
53
|
+
if (!result) {
|
|
54
|
+
throw new Error("No configuration file found");
|
|
55
|
+
}
|
|
56
|
+
const config = result.config.default || result.config;
|
|
57
|
+
if (typeof config === "object" && !config.input) {
|
|
58
|
+
const firstKey = Object.keys(config)[0];
|
|
59
|
+
return config[firstKey];
|
|
60
|
+
}
|
|
61
|
+
return config;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// src/commands/generate.ts
|
|
65
|
+
async function generateCommand(options) {
|
|
66
|
+
const ora = await import("ora").then((m) => m.default || m);
|
|
67
|
+
const spinner = ora("Loading configuration...").start();
|
|
68
|
+
try {
|
|
69
|
+
let config;
|
|
70
|
+
if (options.input && options.output) {
|
|
71
|
+
config = {
|
|
72
|
+
input: options.input,
|
|
73
|
+
output: {
|
|
74
|
+
target: options.output,
|
|
75
|
+
client: options.client || "dio",
|
|
76
|
+
mode: "split",
|
|
77
|
+
override: {
|
|
78
|
+
generator: {
|
|
79
|
+
freezed: true,
|
|
80
|
+
jsonSerializable: true,
|
|
81
|
+
nullSafety: true
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
} else if (options.config) {
|
|
87
|
+
config = await loadConfig(options.config);
|
|
88
|
+
} else {
|
|
89
|
+
try {
|
|
90
|
+
config = await loadConfig();
|
|
91
|
+
} catch {
|
|
92
|
+
throw new Error("Either provide a config file or use -i and -o options");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
spinner.text = "Parsing OpenAPI specification...";
|
|
96
|
+
const files = await (0, import_core.generateDartCode)(config);
|
|
97
|
+
spinner.succeed(import_chalk.default.green(`\u2705 Generated ${files.length} files`));
|
|
98
|
+
console.log(import_chalk.default.cyan("\nGenerated files:"));
|
|
99
|
+
files.forEach((file) => {
|
|
100
|
+
console.log(import_chalk.default.gray(` - ${file.path}`));
|
|
101
|
+
});
|
|
102
|
+
if (config.hooks?.afterAllFilesWrite) {
|
|
103
|
+
spinner.start("Running post-generation hooks...");
|
|
104
|
+
spinner.succeed("Hooks completed");
|
|
105
|
+
}
|
|
106
|
+
console.log(import_chalk.default.green("\n\u2728 Generation completed successfully!"));
|
|
107
|
+
} catch (error) {
|
|
108
|
+
spinner.fail(import_chalk.default.red("Generation failed"));
|
|
109
|
+
console.error(import_chalk.default.red(`
|
|
110
|
+
Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/commands/watch.ts
|
|
116
|
+
var import_chalk2 = __toESM(require("chalk"), 1);
|
|
117
|
+
var fs = __toESM(require("fs"), 1);
|
|
118
|
+
var path = __toESM(require("path"), 1);
|
|
119
|
+
var import_core2 = require("@dorval/core");
|
|
120
|
+
async function watchCommand(options) {
|
|
121
|
+
const ora = await import("ora").then((m) => m.default || m);
|
|
122
|
+
const spinner = ora("Starting watch mode...").start();
|
|
123
|
+
try {
|
|
124
|
+
const config = await loadConfig(options.config);
|
|
125
|
+
if (typeof config.input !== "string") {
|
|
126
|
+
throw new Error("Watch mode requires a file path input");
|
|
127
|
+
}
|
|
128
|
+
const inputPath = path.resolve(config.input);
|
|
129
|
+
spinner.succeed(import_chalk2.default.green(`Watching ${inputPath} for changes...`));
|
|
130
|
+
await (0, import_core2.generateDartCode)(config);
|
|
131
|
+
console.log(import_chalk2.default.cyan("\u2705 Initial generation completed"));
|
|
132
|
+
fs.watchFile(inputPath, async () => {
|
|
133
|
+
console.log(import_chalk2.default.yellow("\n\u{1F4DD} File changed, regenerating..."));
|
|
134
|
+
try {
|
|
135
|
+
await (0, import_core2.generateDartCode)(config);
|
|
136
|
+
console.log(import_chalk2.default.green("\u2705 Regeneration completed"));
|
|
137
|
+
} catch (error) {
|
|
138
|
+
console.error(import_chalk2.default.red(`\u274C Regeneration failed: ${error instanceof Error ? error.message : String(error)}`));
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
process.stdin.resume();
|
|
142
|
+
process.on("SIGINT", () => {
|
|
143
|
+
console.log(import_chalk2.default.yellow("\n\u{1F44B} Stopping watch mode..."));
|
|
144
|
+
fs.unwatchFile(inputPath);
|
|
145
|
+
process.exit(0);
|
|
146
|
+
});
|
|
147
|
+
} catch (error) {
|
|
148
|
+
spinner.fail(import_chalk2.default.red("Watch mode failed"));
|
|
149
|
+
console.error(import_chalk2.default.red(`
|
|
150
|
+
Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// package.json
|
|
156
|
+
var version = "0.1.7";
|
|
157
|
+
|
|
158
|
+
// src/bin/dorval.ts
|
|
159
|
+
import_commander.program.name("dorval").description("Generate Dart API clients from OpenAPI specifications").version(version);
|
|
160
|
+
import_commander.program.command("generate").alias("gen").description("Generate Dart code from OpenAPI spec").option("-c, --config <path>", "Path to config file").option("-i, --input <path>", "OpenAPI spec file or URL").option("-o, --output <path>", "Output directory").option("--client <type>", "Client type (dio, http, chopper)", "dio").option("--watch", "Watch for changes").action(generateCommand);
|
|
161
|
+
import_commander.program.command("watch").description("Watch OpenAPI spec for changes and regenerate").option("-c, --config <path>", "Path to config file").action(watchCommand);
|
|
162
|
+
import_commander.program.action(() => {
|
|
163
|
+
console.log(import_chalk3.default.cyan(`
|
|
164
|
+
\u{1F3AF} Dorval v${version}
|
|
165
|
+
Generate type-safe Dart API clients from OpenAPI specifications.
|
|
166
|
+
|
|
167
|
+
Usage:
|
|
168
|
+
dorval generate [options]
|
|
169
|
+
dorval watch [options]
|
|
170
|
+
|
|
171
|
+
Run 'dorval --help' for more information.
|
|
172
|
+
`));
|
|
173
|
+
});
|
|
174
|
+
import_commander.program.parse(process.argv);
|
|
175
|
+
if (!process.argv.slice(2).length) {
|
|
176
|
+
import_commander.program.outputHelp();
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=dorval.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/bin/dorval.ts","../../src/commands/generate.ts","../../src/config.ts","../../src/commands/watch.ts","../../package.json"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Dorval CLI entry point\n */\n\nimport { program } from 'commander';\nimport chalk from 'chalk';\nimport { generateCommand } from '../commands/generate.js';\nimport { watchCommand } from '../commands/watch.js';\nimport { version } from '../../package.json';\n\nprogram\n .name('dorval')\n .description('Generate Dart API clients from OpenAPI specifications')\n .version(version);\n\n// Generate command\nprogram\n .command('generate')\n .alias('gen')\n .description('Generate Dart code from OpenAPI spec')\n .option('-c, --config <path>', 'Path to config file')\n .option('-i, --input <path>', 'OpenAPI spec file or URL')\n .option('-o, --output <path>', 'Output directory')\n .option('--client <type>', 'Client type (dio, http, chopper)', 'dio')\n .option('--watch', 'Watch for changes')\n .action(generateCommand);\n\n// Watch command\nprogram\n .command('watch')\n .description('Watch OpenAPI spec for changes and regenerate')\n .option('-c, --config <path>', 'Path to config file')\n .action(watchCommand);\n\n// Default action\nprogram\n .action(() => {\n console.log(chalk.cyan(`\n🎯 Dorval v${version}\nGenerate type-safe Dart API clients from OpenAPI specifications.\n\nUsage:\n dorval generate [options]\n dorval watch [options]\n\nRun 'dorval --help' for more information.\n `));\n });\n\n// Parse command line arguments\nprogram.parse(process.argv);\n\n// Show help if no arguments\nif (!process.argv.slice(2).length) {\n program.outputHelp();\n}","/**\n * Generate command implementation\n */\n\nimport chalk from 'chalk';\nimport { generateDartCode, DartGeneratorOptions } from '@dorval/core';\nimport { loadConfig } from '../config.js';\n\ninterface GenerateOptions {\n config?: string;\n input?: string;\n output?: string;\n client?: 'dio' | 'http' | 'chopper';\n watch?: boolean;\n}\n\nexport async function generateCommand(options: GenerateOptions) {\n // Dynamic import for ora to support both CJS and ESM\n const ora = await import('ora').then(m => m.default || m);\n const spinner = ora('Loading configuration...').start();\n \n try {\n // Load configuration\n let config: DartGeneratorOptions;\n \n if (options.input && options.output) {\n // Use command line options\n config = {\n input: options.input,\n output: {\n target: options.output,\n client: options.client || 'dio',\n mode: 'split',\n override: {\n generator: {\n freezed: true,\n jsonSerializable: true,\n nullSafety: true\n }\n }\n }\n };\n } else if (options.config) {\n config = await loadConfig(options.config);\n } else {\n // Try to load from default locations\n try {\n config = await loadConfig();\n } catch {\n throw new Error('Either provide a config file or use -i and -o options');\n }\n }\n \n spinner.text = 'Parsing OpenAPI specification...';\n \n // Generate code\n const files = await generateDartCode(config);\n \n spinner.succeed(chalk.green(`✅ Generated ${files.length} files`));\n \n // List generated files\n console.log(chalk.cyan('\\nGenerated files:'));\n files.forEach(file => {\n console.log(chalk.gray(` - ${file.path}`));\n });\n \n // Run post-generation hooks\n if (config.hooks?.afterAllFilesWrite) {\n spinner.start('Running post-generation hooks...');\n // TODO: Implement hook execution\n spinner.succeed('Hooks completed');\n }\n \n console.log(chalk.green('\\n✨ Generation completed successfully!'));\n \n } catch (error) {\n spinner.fail(chalk.red('Generation failed'));\n console.error(chalk.red(`\\nError: ${error instanceof Error ? error.message : String(error)}`));\n process.exit(1);\n }\n}","/**\n * Configuration loader\n */\n\nimport { cosmiconfigSync } from 'cosmiconfig';\nimport { DartGeneratorOptions } from '@dorval/core';\n\n// Create explorer lazily to avoid initialization issues\nfunction getExplorer() {\n return cosmiconfigSync('orval', {\n searchPlaces: [\n 'orval.config.ts',\n 'orval.config.js',\n 'orval.config.cjs',\n '.orvalrc',\n '.orvalrc.json',\n '.orvalrc.yaml',\n '.orvalrc.yml',\n 'package.json'\n ]\n });\n}\n\nexport async function loadConfig(configPath?: string): Promise<DartGeneratorOptions> {\n const explorer = getExplorer();\n const result = configPath\n ? explorer.load(configPath)\n : explorer.search();\n \n if (!result) {\n throw new Error('No configuration file found');\n }\n \n // Handle default export or direct config\n const config = result.config.default || result.config;\n \n // If config has multiple specs, use the first one\n if (typeof config === 'object' && !config.input) {\n const firstKey = Object.keys(config)[0];\n return config[firstKey];\n }\n \n return config;\n}","/**\n * Watch command implementation\n */\n\nimport chalk from 'chalk';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { generateDartCode } from '@dorval/core';\nimport { loadConfig } from '../config.js';\n\ninterface WatchOptions {\n config?: string;\n}\n\nexport async function watchCommand(options: WatchOptions) {\n // Dynamic import for ora to support both CJS and ESM\n const ora = await import('ora').then(m => m.default || m);\n const spinner = ora('Starting watch mode...').start();\n \n try {\n // Load configuration\n const config = await loadConfig(options.config);\n \n if (typeof config.input !== 'string') {\n throw new Error('Watch mode requires a file path input');\n }\n \n const inputPath = path.resolve(config.input);\n \n spinner.succeed(chalk.green(`Watching ${inputPath} for changes...`));\n \n // Initial generation\n await generateDartCode(config);\n console.log(chalk.cyan('✅ Initial generation completed'));\n \n // Watch for changes\n fs.watchFile(inputPath, async () => {\n console.log(chalk.yellow('\\n📝 File changed, regenerating...'));\n \n try {\n await generateDartCode(config);\n console.log(chalk.green('✅ Regeneration completed'));\n } catch (error) {\n console.error(chalk.red(`❌ Regeneration failed: ${error instanceof Error ? error.message : String(error)}`));\n }\n });\n \n // Keep process alive\n process.stdin.resume();\n \n // Handle exit\n process.on('SIGINT', () => {\n console.log(chalk.yellow('\\n👋 Stopping watch mode...'));\n fs.unwatchFile(inputPath);\n process.exit(0);\n });\n \n } catch (error) {\n spinner.fail(chalk.red('Watch mode failed'));\n console.error(chalk.red(`\\nError: ${error instanceof Error ? error.message : String(error)}`));\n process.exit(1);\n }\n}","{\n \"name\": \"dorval\",\n \"version\": \"0.1.7\",\n \"description\": \"CLI tool for generating Dart/Flutter API clients from OpenAPI specifications\",\n \"keywords\": [\n \"cli\",\n \"dart\",\n \"flutter\",\n \"openapi\",\n \"swagger\",\n \"codegen\",\n \"code-generator\",\n \"api-client\",\n \"dio\",\n \"freezed\",\n \"rest-api\",\n \"orval\",\n \"dorval\",\n \"openapi3\",\n \"generator-cli\"\n ],\n \"homepage\": \"https://github.com/qwlong/dorval#readme\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/qwlong/dorval.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/qwlong/dorval/issues\"\n },\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"bin\": {\n \"dorval\": \"./dist/bin/dorval.js\"\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup ./src/index.ts ./src/bin/dorval.ts --clean --sourcemap --watch src --dts\",\n \"lint\": \"eslint 'src/**/*.ts'\",\n \"test\": \"vitest run\"\n },\n \"dependencies\": {\n \"@dorval/core\": \"0.1.7\",\n \"chalk\": \"^4.1.2\",\n \"commander\": \"^11.0.0\",\n \"cosmiconfig\": \"^8.2.0\",\n \"ora\": \"^8.1.1\",\n \"typescript\": \"^5.2.2\"\n },\n \"devDependencies\": {\n \"@types/fs-extra\": \"^11.0.4\",\n \"@types/node\": \"^20.13.0\",\n \"globals\": \"^16.3.0\",\n \"tsup\": \"^8.5.0\",\n \"vitest\": \"^0.6.3\"\n },\n \"engines\": {\n \"node\": \">=18\"\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,uBAAwB;AACxB,IAAAA,gBAAkB;;;ACHlB,mBAAkB;AAClB,kBAAuD;;;ACDvD,yBAAgC;AAIhC,SAAS,cAAc;AACrB,aAAO,oCAAgB,SAAS;AAAA,IAC9B,cAAc;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEA,eAAsB,WAAW,YAAoD;AACnF,QAAM,WAAW,YAAY;AAC7B,QAAM,SAAS,aACX,SAAS,KAAK,UAAU,IACxB,SAAS,OAAO;AAEpB,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AAGA,QAAM,SAAS,OAAO,OAAO,WAAW,OAAO;AAG/C,MAAI,OAAO,WAAW,YAAY,CAAC,OAAO,OAAO;AAC/C,UAAM,WAAW,OAAO,KAAK,MAAM,EAAE,CAAC;AACtC,WAAO,OAAO,QAAQ;AAAA,EACxB;AAEA,SAAO;AACT;;;AD3BA,eAAsB,gBAAgB,SAA0B;AAE9D,QAAM,MAAM,MAAM,OAAO,KAAK,EAAE,KAAK,OAAK,EAAE,WAAW,CAAC;AACxD,QAAM,UAAU,IAAI,0BAA0B,EAAE,MAAM;AAEtD,MAAI;AAEF,QAAI;AAEJ,QAAI,QA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AC5DE,cAAW;;;AJUb,yBACG,KAAK,QAAQ,EACb,YAAY,uDAAuD,EACnE,QAAQ,OAAO;AAGlB,yBACG,QAAQ,UAAU,EAClB,MAAM,KAAK,EACX,YAAY,sCAAsC,EAClD,OAAO,uBAAuB,qBAAqB,EACnD,OAAO,sBAAsB,0BAA0B,EACvD,OAAO,uBAAuB,kBAAkB,EAChD,OAAO,mBAAmB,oCAAoC,KAAK,EACnE,OAAO,WAAW,mBAAmB,EACrC,OAAO,eAAe;AAGzB,yBACG,QAAQ,OAAO,EACf,YAAY,+CAA+C,EAC3D,OAAO,uBAAuB,qBAAqB,EACnD,OAAO,YAAY;AAGtB,yBACG,OAAO,MAAM;AACZ,UAAQ,IAAI,cAAAC,QAAM,KAAK;AAAA,oBACd,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAQf,CAAC;AACJ,CAAC;AAGH,yBAAQ,MAAM,QAAQ,IAAI;AAG1B,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,EAAE,QAAQ;AACjC,2BAAQ,WAAW;AACrB;","names":["import_chalk","chalk","import_chalk","import_core","chalk","chalk"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/bin/dorval.js
CHANGED
|
@@ -1,41 +1,17 @@
|
|
|
1
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 __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
2
|
|
|
26
3
|
// src/bin/dorval.ts
|
|
27
|
-
|
|
28
|
-
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
import chalk3 from "chalk";
|
|
29
6
|
|
|
30
7
|
// src/commands/generate.ts
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var import_core = require("@dorval/core");
|
|
8
|
+
import chalk from "chalk";
|
|
9
|
+
import { generateDartCode } from "@dorval/core";
|
|
34
10
|
|
|
35
11
|
// src/config.ts
|
|
36
|
-
|
|
12
|
+
import { cosmiconfigSync } from "cosmiconfig";
|
|
37
13
|
function getExplorer() {
|
|
38
|
-
return
|
|
14
|
+
return cosmiconfigSync("orval", {
|
|
39
15
|
searchPlaces: [
|
|
40
16
|
"orval.config.ts",
|
|
41
17
|
"orval.config.js",
|
|
@@ -64,7 +40,8 @@ async function loadConfig(configPath) {
|
|
|
64
40
|
|
|
65
41
|
// src/commands/generate.ts
|
|
66
42
|
async function generateCommand(options) {
|
|
67
|
-
const
|
|
43
|
+
const ora = await import("ora").then((m) => m.default || m);
|
|
44
|
+
const spinner = ora("Loading configuration...").start();
|
|
68
45
|
try {
|
|
69
46
|
let config;
|
|
70
47
|
if (options.input && options.output) {
|
|
@@ -88,65 +65,65 @@ async function generateCommand(options) {
|
|
|
88
65
|
} else {
|
|
89
66
|
try {
|
|
90
67
|
config = await loadConfig();
|
|
91
|
-
} catch
|
|
68
|
+
} catch {
|
|
92
69
|
throw new Error("Either provide a config file or use -i and -o options");
|
|
93
70
|
}
|
|
94
71
|
}
|
|
95
72
|
spinner.text = "Parsing OpenAPI specification...";
|
|
96
|
-
const files = await
|
|
97
|
-
spinner.succeed(
|
|
98
|
-
console.log(
|
|
73
|
+
const files = await generateDartCode(config);
|
|
74
|
+
spinner.succeed(chalk.green(`\u2705 Generated ${files.length} files`));
|
|
75
|
+
console.log(chalk.cyan("\nGenerated files:"));
|
|
99
76
|
files.forEach((file) => {
|
|
100
|
-
console.log(
|
|
77
|
+
console.log(chalk.gray(` - ${file.path}`));
|
|
101
78
|
});
|
|
102
79
|
if (config.hooks?.afterAllFilesWrite) {
|
|
103
80
|
spinner.start("Running post-generation hooks...");
|
|
104
81
|
spinner.succeed("Hooks completed");
|
|
105
82
|
}
|
|
106
|
-
console.log(
|
|
83
|
+
console.log(chalk.green("\n\u2728 Generation completed successfully!"));
|
|
107
84
|
} catch (error) {
|
|
108
|
-
spinner.fail(
|
|
109
|
-
console.error(
|
|
85
|
+
spinner.fail(chalk.red("Generation failed"));
|
|
86
|
+
console.error(chalk.red(`
|
|
110
87
|
Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
111
88
|
process.exit(1);
|
|
112
89
|
}
|
|
113
90
|
}
|
|
114
91
|
|
|
115
92
|
// src/commands/watch.ts
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
var import_core2 = require("@dorval/core");
|
|
93
|
+
import chalk2 from "chalk";
|
|
94
|
+
import * as fs from "fs";
|
|
95
|
+
import * as path from "path";
|
|
96
|
+
import { generateDartCode as generateDartCode2 } from "@dorval/core";
|
|
121
97
|
async function watchCommand(options) {
|
|
122
|
-
const
|
|
98
|
+
const ora = await import("ora").then((m) => m.default || m);
|
|
99
|
+
const spinner = ora("Starting watch mode...").start();
|
|
123
100
|
try {
|
|
124
101
|
const config = await loadConfig(options.config);
|
|
125
102
|
if (typeof config.input !== "string") {
|
|
126
103
|
throw new Error("Watch mode requires a file path input");
|
|
127
104
|
}
|
|
128
105
|
const inputPath = path.resolve(config.input);
|
|
129
|
-
spinner.succeed(
|
|
130
|
-
await (
|
|
131
|
-
console.log(
|
|
106
|
+
spinner.succeed(chalk2.green(`Watching ${inputPath} for changes...`));
|
|
107
|
+
await generateDartCode2(config);
|
|
108
|
+
console.log(chalk2.cyan("\u2705 Initial generation completed"));
|
|
132
109
|
fs.watchFile(inputPath, async () => {
|
|
133
|
-
console.log(
|
|
110
|
+
console.log(chalk2.yellow("\n\u{1F4DD} File changed, regenerating..."));
|
|
134
111
|
try {
|
|
135
|
-
await (
|
|
136
|
-
console.log(
|
|
112
|
+
await generateDartCode2(config);
|
|
113
|
+
console.log(chalk2.green("\u2705 Regeneration completed"));
|
|
137
114
|
} catch (error) {
|
|
138
|
-
console.error(
|
|
115
|
+
console.error(chalk2.red(`\u274C Regeneration failed: ${error instanceof Error ? error.message : String(error)}`));
|
|
139
116
|
}
|
|
140
117
|
});
|
|
141
118
|
process.stdin.resume();
|
|
142
119
|
process.on("SIGINT", () => {
|
|
143
|
-
console.log(
|
|
120
|
+
console.log(chalk2.yellow("\n\u{1F44B} Stopping watch mode..."));
|
|
144
121
|
fs.unwatchFile(inputPath);
|
|
145
122
|
process.exit(0);
|
|
146
123
|
});
|
|
147
124
|
} catch (error) {
|
|
148
|
-
spinner.fail(
|
|
149
|
-
console.error(
|
|
125
|
+
spinner.fail(chalk2.red("Watch mode failed"));
|
|
126
|
+
console.error(chalk2.red(`
|
|
150
127
|
Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
151
128
|
process.exit(1);
|
|
152
129
|
}
|
|
@@ -156,11 +133,11 @@ Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
|
156
133
|
var version = "0.1.7";
|
|
157
134
|
|
|
158
135
|
// src/bin/dorval.ts
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
console.log(
|
|
136
|
+
program.name("dorval").description("Generate Dart API clients from OpenAPI specifications").version(version);
|
|
137
|
+
program.command("generate").alias("gen").description("Generate Dart code from OpenAPI spec").option("-c, --config <path>", "Path to config file").option("-i, --input <path>", "OpenAPI spec file or URL").option("-o, --output <path>", "Output directory").option("--client <type>", "Client type (dio, http, chopper)", "dio").option("--watch", "Watch for changes").action(generateCommand);
|
|
138
|
+
program.command("watch").description("Watch OpenAPI spec for changes and regenerate").option("-c, --config <path>", "Path to config file").action(watchCommand);
|
|
139
|
+
program.action(() => {
|
|
140
|
+
console.log(chalk3.cyan(`
|
|
164
141
|
\u{1F3AF} Dorval v${version}
|
|
165
142
|
Generate type-safe Dart API clients from OpenAPI specifications.
|
|
166
143
|
|
|
@@ -171,8 +148,8 @@ Usage:
|
|
|
171
148
|
Run 'dorval --help' for more information.
|
|
172
149
|
`));
|
|
173
150
|
});
|
|
174
|
-
|
|
151
|
+
program.parse(process.argv);
|
|
175
152
|
if (!process.argv.slice(2).length) {
|
|
176
|
-
|
|
153
|
+
program.outputHelp();
|
|
177
154
|
}
|
|
178
155
|
//# sourceMappingURL=dorval.js.map
|
package/dist/bin/dorval.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bin/dorval.ts","../../src/commands/generate.ts","../../src/config.ts","../../src/commands/watch.ts","../../package.json"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Dorval CLI entry point\n */\n\nimport { program } from 'commander';\nimport chalk from 'chalk';\nimport { generateCommand } from '../commands/generate';\nimport { watchCommand } from '../commands/watch';\nimport { version } from '../../package.json';\n\nprogram\n .name('dorval')\n .description('Generate Dart API clients from OpenAPI specifications')\n .version(version);\n\n// Generate command\nprogram\n .command('generate')\n .alias('gen')\n .description('Generate Dart code from OpenAPI spec')\n .option('-c, --config <path>', 'Path to config file')\n .option('-i, --input <path>', 'OpenAPI spec file or URL')\n .option('-o, --output <path>', 'Output directory')\n .option('--client <type>', 'Client type (dio, http, chopper)', 'dio')\n .option('--watch', 'Watch for changes')\n .action(generateCommand);\n\n// Watch command\nprogram\n .command('watch')\n .description('Watch OpenAPI spec for changes and regenerate')\n .option('-c, --config <path>', 'Path to config file')\n .action(watchCommand);\n\n// Default action\nprogram\n .action(() => {\n console.log(chalk.cyan(`\n🎯 Dorval v${version}\nGenerate type-safe Dart API clients from OpenAPI specifications.\n\nUsage:\n dorval generate [options]\n dorval watch [options]\n\nRun 'dorval --help' for more information.\n `));\n });\n\n// Parse command line arguments\nprogram.parse(process.argv);\n\n// Show help if no arguments\nif (!process.argv.slice(2).length) {\n program.outputHelp();\n}","/**\n * Generate command implementation\n */\n\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport { generateDartCode, DartGeneratorOptions } from '@dorval/core';\nimport { loadConfig } from '../config';\n\ninterface GenerateOptions {\n config?: string;\n input?: string;\n output?: string;\n client?: 'dio' | 'http' | 'chopper';\n watch?: boolean;\n}\n\nexport async function generateCommand(options: GenerateOptions) {\n const spinner = ora('Loading configuration...').start();\n \n try {\n // Load configuration\n let config: DartGeneratorOptions;\n \n if (options.input && options.output) {\n // Use command line options\n config = {\n input: options.input,\n output: {\n target: options.output,\n client: options.client || 'dio',\n mode: 'split',\n override: {\n generator: {\n freezed: true,\n jsonSerializable: true,\n nullSafety: true\n }\n }\n }\n };\n } else if (options.config) {\n config = await loadConfig(options.config);\n } else {\n // Try to load from default locations\n try {\n config = await loadConfig();\n } catch (error) {\n throw new Error('Either provide a config file or use -i and -o options');\n }\n }\n \n spinner.text = 'Parsing OpenAPI specification...';\n \n // Generate code\n const files = await generateDartCode(config);\n \n spinner.succeed(chalk.green(`✅ Generated ${files.length} files`));\n \n // List generated files\n console.log(chalk.cyan('\\nGenerated files:'));\n files.forEach(file => {\n console.log(chalk.gray(` - ${file.path}`));\n });\n \n // Run post-generation hooks\n if (config.hooks?.afterAllFilesWrite) {\n spinner.start('Running post-generation hooks...');\n // TODO: Implement hook execution\n spinner.succeed('Hooks completed');\n }\n \n console.log(chalk.green('\\n✨ Generation completed successfully!'));\n \n } catch (error) {\n spinner.fail(chalk.red('Generation failed'));\n console.error(chalk.red(`\\nError: ${error instanceof Error ? error.message : String(error)}`));\n process.exit(1);\n }\n}","/**\n * Configuration loader\n */\n\nimport { cosmiconfigSync } from 'cosmiconfig';\nimport { DartGeneratorOptions } from '@dorval/core';\n\n// Create explorer lazily to avoid initialization issues\nfunction getExplorer() {\n return cosmiconfigSync('orval', {\n searchPlaces: [\n 'orval.config.ts',\n 'orval.config.js',\n 'orval.config.cjs',\n '.orvalrc',\n '.orvalrc.json',\n '.orvalrc.yaml',\n '.orvalrc.yml',\n 'package.json'\n ]\n });\n}\n\nexport async function loadConfig(configPath?: string): Promise<DartGeneratorOptions> {\n const explorer = getExplorer();\n const result = configPath\n ? explorer.load(configPath)\n : explorer.search();\n \n if (!result) {\n throw new Error('No configuration file found');\n }\n \n // Handle default export or direct config\n const config = result.config.default || result.config;\n \n // If config has multiple specs, use the first one\n if (typeof config === 'object' && !config.input) {\n const firstKey = Object.keys(config)[0];\n return config[firstKey];\n }\n \n return config;\n}","/**\n * Watch command implementation\n */\n\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { generateDartCode } from '@dorval/core';\nimport { loadConfig } from '../config';\n\ninterface WatchOptions {\n config?: string;\n}\n\nexport async function watchCommand(options: WatchOptions) {\n const spinner = ora('Starting watch mode...').start();\n \n try {\n // Load configuration\n const config = await loadConfig(options.config);\n \n if (typeof config.input !== 'string') {\n throw new Error('Watch mode requires a file path input');\n }\n \n const inputPath = path.resolve(config.input);\n \n spinner.succeed(chalk.green(`Watching ${inputPath} for changes...`));\n \n // Initial generation\n await generateDartCode(config);\n console.log(chalk.cyan('✅ Initial generation completed'));\n \n // Watch for changes\n fs.watchFile(inputPath, async () => {\n console.log(chalk.yellow('\\n📝 File changed, regenerating...'));\n \n try {\n await generateDartCode(config);\n console.log(chalk.green('✅ Regeneration completed'));\n } catch (error) {\n console.error(chalk.red(`❌ Regeneration failed: ${error instanceof Error ? error.message : String(error)}`));\n }\n });\n \n // Keep process alive\n process.stdin.resume();\n \n // Handle exit\n process.on('SIGINT', () => {\n console.log(chalk.yellow('\\n👋 Stopping watch mode...'));\n fs.unwatchFile(inputPath);\n process.exit(0);\n });\n \n } catch (error) {\n spinner.fail(chalk.red('Watch mode failed'));\n console.error(chalk.red(`\\nError: ${error instanceof Error ? error.message : String(error)}`));\n process.exit(1);\n }\n}","{\n \"name\": \"dorval\",\n \"version\": \"0.1.7\",\n \"description\": \"CLI tool for generating Dart/Flutter API clients from OpenAPI specifications\",\n \"keywords\": [\n \"cli\",\n \"dart\",\n \"flutter\",\n \"openapi\",\n \"swagger\",\n \"codegen\",\n \"code-generator\",\n \"api-client\",\n \"dio\",\n \"freezed\",\n \"rest-api\",\n \"orval\",\n \"dorval\",\n \"openapi3\",\n \"generator-cli\"\n ],\n \"homepage\": \"https://github.com/qwlong/dorval#readme\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/qwlong/dorval.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/qwlong/dorval/issues\"\n },\n \"license\": \"MIT\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"bin\": {\n \"dorval\": \"./dist/bin/dorval.js\"\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup ./src/index.ts ./src/bin/dorval.ts --clean --sourcemap\",\n \"dev\": \"tsup ./src/index.ts ./src/bin/dorval.ts --clean --sourcemap --watch src --dts\",\n \"lint\": \"eslint src/**/*.ts\",\n \"test\": \"vitest run\"\n },\n \"dependencies\": {\n \"@dorval/core\": \"0.1.7\",\n \"commander\": \"^11.0.0\",\n \"chalk\": \"^4.1.2\",\n \"ora\": \"5.4.1\",\n \"cosmiconfig\": \"^8.2.0\",\n \"fs-extra\": \"^11.3.0\",\n \"typescript\": \"^5.2.2\"\n },\n \"devDependencies\": {\n \"@types/fs-extra\": \"^11.0.4\",\n \"@types/node\": \"^20.13.0\",\n \"tsup\": \"^8.5.0\",\n \"vitest\": \"^0.6.3\"\n },\n \"engines\": {\n \"node\": \">=18\"\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,uBAAwB;AACxB,IAAAA,gBAAkB;;;ACHlB,mBAAkB;AAClB,iBAAgB;AAChB,kBAAuD;;;ACFvD,yBAAgC;AAIhC,SAAS,cAAc;AACrB,aAAO,oCAAgB,SAAS;AAAA,IAC9B,cAAc;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEA,eAAsB,WAAW,YAAoD;AACnF,QAAM,WAAW,YAAY;AAC7B,QAAM,SAAS,aACX,SAAS,KAAK,UAAU,IACxB,SAAS,OAAO;AAEpB,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AAGA,QAAM,SAAS,OAAO,OAAO,WAAW,OAAO;AAG/C,MAAI,OAAO,WAAW,YAAY,CAAC,OAAO,OAAO;AAC/C,UAAM,WAAW,OAAO,KAAK,MAAM,EAAE,CAAC;AACtC,WAAO,OAAO,QAAQ;AAAA,EACxB;AAEA,SAAO;AACT;;;AD1BA,eAAsB,gBAAgB,SAA0B;AAC9D,QAAM,cAAU,WAAAC,SAAI,0BAA0B,EAAE,MAAM;AAEtD,MAAI;AAEF,QAAI;AAEJ,QAAI,QAAQ,SAAS,QAAQ,QAAQ;AAEnC,eAAS;AAAA,QACP,OAAO,QAAQ;AAAA,QACf,QAAQ;AAAA,UACN,QAAQ,QAAQ;AAAA,UAChB,QAAQ,QA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AqB,EACnD,OAAO,sBAAsB,0BAA0B,EACvD,OAAO,uBAAuB,kBAAkB,EAChD,OAAO,mBAAmB,oCAAoC,KAAK,EACnE,OAAO,WAAW,mBAAmB,EACrC,OAAO,eAAe;AAGzB,yBACG,QAAQ,OAAO,EACf,YAAY,+CAA+C,EAC3D,OAAO,uBAAuB,qBAAqB,EACnD,OAAO,YAAY;AAGtB,yBACG,OAAO,MAAM;AACZ,UAAQ,IAAI,cAAAC,QAAM,KAAK;AAAA,oBACd,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAQf,CAAC;AACJ,CAAC;AAGH,yBAAQ,MAAM,QAAQ,IAAI;AAG1B,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,EAAE,QAAQ;AACjC,2BAAQ,WAAW;AACrB;","names":["import_chalk","ora","chalk","import_chalk","import_ora","import_core","ora","chalk","chalk"]}
|
|
1
|
+
{"version":3,"sources":["../../src/bin/dorval.ts","../../src/commands/generate.ts","../../src/config.ts","../../src/commands/watch.ts","../../package.json"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Dorval CLI entry point\n */\n\nimport { program } from 'commander';\nimport chalk from 'chalk';\nimport { generateCommand } from '../commands/generate.js';\nimport { watchCommand } from '../commands/watch.js';\nimport { version } from '../../package.json';\n\nprogram\n .name('dorval')\n .description('Generate Dart API clients from OpenAPI specifications')\n .version(version);\n\n// Generate command\nprogram\n .command('generate')\n .alias('gen')\n .description('Generate Dart code from OpenAPI spec')\n .option('-c, --config <path>', 'Path to config file')\n .option('-i, --input <path>', 'OpenAPI spec file or URL')\n .option('-o, --output <path>', 'Output directory')\n .option('--client <type>', 'Client type (dio, http, chopper)', 'dio')\n .option('--watch', 'Watch for changes')\n .action(generateCommand);\n\n// Watch command\nprogram\n .command('watch')\n .description('Watch OpenAPI spec for changes and regenerate')\n .option('-c, --config <path>', 'Path to config file')\n .action(watchCommand);\n\n// Default action\nprogram\n .action(() => {\n console.log(chalk.cyan(`\n🎯 Dorval v${version}\nGenerate type-safe Dart API clients from OpenAPI specifications.\n\nUsage:\n dorval generate [options]\n dorval watch [options]\n\nRun 'dorval --help' for more information.\n `));\n });\n\n// Parse command line arguments\nprogram.parse(process.argv);\n\n// Show help if no arguments\nif (!process.argv.slice(2).length) {\n program.outputHelp();\n}","/**\n * Generate command implementation\n */\n\nimport chalk from 'chalk';\nimport { generateDartCode, DartGeneratorOptions } from '@dorval/core';\nimport { loadConfig } from '../config.js';\n\ninterface GenerateOptions {\n config?: string;\n input?: string;\n output?: string;\n client?: 'dio' | 'http' | 'chopper';\n watch?: boolean;\n}\n\nexport async function generateCommand(options: GenerateOptions) {\n // Dynamic import for ora to support both CJS and ESM\n const ora = await import('ora').then(m => m.default || m);\n const spinner = ora('Loading configuration...').start();\n \n try {\n // Load configuration\n let config: DartGeneratorOptions;\n \n if (options.input && options.output) {\n // Use command line options\n config = {\n input: options.input,\n output: {\n target: options.output,\n client: options.client || 'dio',\n mode: 'split',\n override: {\n generator: {\n freezed: true,\n jsonSerializable: true,\n nullSafety: true\n }\n }\n }\n };\n } else if (options.config) {\n config = await loadConfig(options.config);\n } else {\n // Try to load from default locations\n try {\n config = await loadConfig();\n } catch {\n throw new Error('Either provide a config file or use -i and -o options');\n }\n }\n \n spinner.text = 'Parsing OpenAPI specification...';\n \n // Generate code\n const files = await generateDartCode(config);\n \n spinner.succeed(chalk.green(`✅ Generated ${files.length} files`));\n \n // List generated files\n console.log(chalk.cyan('\\nGenerated files:'));\n files.forEach(file => {\n console.log(chalk.gray(` - ${file.path}`));\n });\n \n // Run post-generation hooks\n if (config.hooks?.afterAllFilesWrite) {\n spinner.start('Running post-generation hooks...');\n // TODO: Implement hook execution\n spinner.succeed('Hooks completed');\n }\n \n console.log(chalk.green('\\n✨ Generation completed successfully!'));\n \n } catch (error) {\n spinner.fail(chalk.red('Generation failed'));\n console.error(chalk.red(`\\nError: ${error instanceof Error ? error.message : String(error)}`));\n process.exit(1);\n }\n}","/**\n * Configuration loader\n */\n\nimport { cosmiconfigSync } from 'cosmiconfig';\nimport { DartGeneratorOptions } from '@dorval/core';\n\n// Create explorer lazily to avoid initialization issues\nfunction getExplorer() {\n return cosmiconfigSync('orval', {\n searchPlaces: [\n 'orval.config.ts',\n 'orval.config.js',\n 'orval.config.cjs',\n '.orvalrc',\n '.orvalrc.json',\n '.orvalrc.yaml',\n '.orvalrc.yml',\n 'package.json'\n ]\n });\n}\n\nexport async function loadConfig(configPath?: string): Promise<DartGeneratorOptions> {\n const explorer = getExplorer();\n const result = configPath\n ? explorer.load(configPath)\n : explorer.search();\n \n if (!result) {\n throw new Error('No configuration file found');\n }\n \n // Handle default export or direct config\n const config = result.config.default || result.config;\n \n // If config has multiple specs, use the first one\n if (typeof config === 'object' && !config.input) {\n const firstKey = Object.keys(config)[0];\n return config[firstKey];\n }\n \n return config;\n}","/**\n * Watch command implementation\n */\n\nimport chalk from 'chalk';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { generateDartCode } from '@dorval/core';\nimport { loadConfig } from '../config.js';\n\ninterface WatchOptions {\n config?: string;\n}\n\nexport async function watchCommand(options: WatchOptions) {\n // Dynamic import for ora to support both CJS and ESM\n const ora = await import('ora').then(m => m.default || m);\n const spinner = ora('Starting watch mode...').start();\n \n try {\n // Load configuration\n const config = await loadConfig(options.config);\n \n if (typeof config.input !== 'string') {\n throw new Error('Watch mode requires a file path input');\n }\n \n const inputPath = path.resolve(config.input);\n \n spinner.succeed(chalk.green(`Watching ${inputPath} for changes...`));\n \n // Initial generation\n await generateDartCode(config);\n console.log(chalk.cyan('✅ Initial generation completed'));\n \n // Watch for changes\n fs.watchFile(inputPath, async () => {\n console.log(chalk.yellow('\\n📝 File changed, regenerating...'));\n \n try {\n await generateDartCode(config);\n console.log(chalk.green('✅ Regeneration completed'));\n } catch (error) {\n console.error(chalk.red(`❌ Regeneration failed: ${error instanceof Error ? error.message : String(error)}`));\n }\n });\n \n // Keep process alive\n process.stdin.resume();\n \n // Handle exit\n process.on('SIGINT', () => {\n console.log(chalk.yellow('\\n👋 Stopping watch mode...'));\n fs.unwatchFile(inputPath);\n process.exit(0);\n });\n \n } catch (error) {\n spinner.fail(chalk.red('Watch mode failed'));\n console.error(chalk.red(`\\nError: ${error instanceof Error ? error.message : String(error)}`));\n process.exit(1);\n }\n}","{\n \"name\": \"dorval\",\n \"version\": \"0.1.7\",\n \"description\": \"CLI tool for generating Dart/Flutter API clients from OpenAPI specifications\",\n \"keywords\": [\n \"cli\",\n \"dart\",\n \"flutter\",\n \"openapi\",\n \"swagger\",\n \"codegen\",\n \"code-generator\",\n \"api-client\",\n \"dio\",\n \"freezed\",\n \"rest-api\",\n \"orval\",\n \"dorval\",\n \"openapi3\",\n \"generator-cli\"\n ],\n \"homepage\": \"https://github.com/qwlong/dorval#readme\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/qwlong/dorval.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/qwlong/dorval/issues\"\n },\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"types\": \"./dist/index.d.ts\"\n }\n },\n \"bin\": {\n \"dorval\": \"./dist/bin/dorval.js\"\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup ./src/index.ts ./src/bin/dorval.ts --clean --sourcemap --watch src --dts\",\n \"lint\": \"eslint 'src/**/*.ts'\",\n \"test\": \"vitest run\"\n },\n \"dependencies\": {\n \"@dorval/core\": \"0.1.7\",\n \"chalk\": \"^4.1.2\",\n \"commander\": \"^11.0.0\",\n \"cosmiconfig\": \"^8.2.0\",\n \"ora\": \"^8.1.1\",\n \"typescript\": \"^5.2.2\"\n },\n \"devDependencies\": {\n \"@types/fs-extra\": \"^11.0.4\",\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zB,QACG,QAAQ,OAAO,EACf,YAAY,+CAA+C,EAC3D,OAAO,uBAAuB,qBAAqB,EACnD,OAAO,YAAY;AAGtB,QACG,OAAO,MAAM;AACZ,UAAQ,IAAIE,OAAM,KAAK;AAAA,oBACd,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAQf,CAAC;AACJ,CAAC;AAGH,QAAQ,MAAM,QAAQ,IAAI;AAG1B,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,EAAE,QAAQ;AACjC,UAAQ,WAAW;AACrB;","names":["chalk","chalk","generateDartCode","chalk","generateDartCode","chalk"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
generateCommand: () => generateCommand,
|
|
34
|
+
loadConfig: () => loadConfig,
|
|
35
|
+
runCLI: () => runCLI,
|
|
36
|
+
watchCommand: () => watchCommand
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(index_exports);
|
|
39
|
+
|
|
40
|
+
// src/cli.ts
|
|
41
|
+
var import_commander = require("commander");
|
|
42
|
+
|
|
43
|
+
// src/commands/generate.ts
|
|
44
|
+
var import_chalk = __toESM(require("chalk"), 1);
|
|
45
|
+
var import_core = require("@dorval/core");
|
|
46
|
+
|
|
47
|
+
// src/config.ts
|
|
48
|
+
var import_cosmiconfig = require("cosmiconfig");
|
|
49
|
+
function getExplorer() {
|
|
50
|
+
return (0, import_cosmiconfig.cosmiconfigSync)("orval", {
|
|
51
|
+
searchPlaces: [
|
|
52
|
+
"orval.config.ts",
|
|
53
|
+
"orval.config.js",
|
|
54
|
+
"orval.config.cjs",
|
|
55
|
+
".orvalrc",
|
|
56
|
+
".orvalrc.json",
|
|
57
|
+
".orvalrc.yaml",
|
|
58
|
+
".orvalrc.yml",
|
|
59
|
+
"package.json"
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
async function loadConfig(configPath) {
|
|
64
|
+
const explorer = getExplorer();
|
|
65
|
+
const result = configPath ? explorer.load(configPath) : explorer.search();
|
|
66
|
+
if (!result) {
|
|
67
|
+
throw new Error("No configuration file found");
|
|
68
|
+
}
|
|
69
|
+
const config = result.config.default || result.config;
|
|
70
|
+
if (typeof config === "object" && !config.input) {
|
|
71
|
+
const firstKey = Object.keys(config)[0];
|
|
72
|
+
return config[firstKey];
|
|
73
|
+
}
|
|
74
|
+
return config;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/commands/generate.ts
|
|
78
|
+
async function generateCommand(options) {
|
|
79
|
+
const ora = await import("ora").then((m) => m.default || m);
|
|
80
|
+
const spinner = ora("Loading configuration...").start();
|
|
81
|
+
try {
|
|
82
|
+
let config;
|
|
83
|
+
if (options.input && options.output) {
|
|
84
|
+
config = {
|
|
85
|
+
input: options.input,
|
|
86
|
+
output: {
|
|
87
|
+
target: options.output,
|
|
88
|
+
client: options.client || "dio",
|
|
89
|
+
mode: "split",
|
|
90
|
+
override: {
|
|
91
|
+
generator: {
|
|
92
|
+
freezed: true,
|
|
93
|
+
jsonSerializable: true,
|
|
94
|
+
nullSafety: true
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
} else if (options.config) {
|
|
100
|
+
config = await loadConfig(options.config);
|
|
101
|
+
} else {
|
|
102
|
+
try {
|
|
103
|
+
config = await loadConfig();
|
|
104
|
+
} catch {
|
|
105
|
+
throw new Error("Either provide a config file or use -i and -o options");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
spinner.text = "Parsing OpenAPI specification...";
|
|
109
|
+
const files = await (0, import_core.generateDartCode)(config);
|
|
110
|
+
spinner.succeed(import_chalk.default.green(`\u2705 Generated ${files.length} files`));
|
|
111
|
+
console.log(import_chalk.default.cyan("\nGenerated files:"));
|
|
112
|
+
files.forEach((file) => {
|
|
113
|
+
console.log(import_chalk.default.gray(` - ${file.path}`));
|
|
114
|
+
});
|
|
115
|
+
if (config.hooks?.afterAllFilesWrite) {
|
|
116
|
+
spinner.start("Running post-generation hooks...");
|
|
117
|
+
spinner.succeed("Hooks completed");
|
|
118
|
+
}
|
|
119
|
+
console.log(import_chalk.default.green("\n\u2728 Generation completed successfully!"));
|
|
120
|
+
} catch (error) {
|
|
121
|
+
spinner.fail(import_chalk.default.red("Generation failed"));
|
|
122
|
+
console.error(import_chalk.default.red(`
|
|
123
|
+
Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// src/commands/watch.ts
|
|
129
|
+
var import_chalk2 = __toESM(require("chalk"), 1);
|
|
130
|
+
var fs = __toESM(require("fs"), 1);
|
|
131
|
+
var path = __toESM(require("path"), 1);
|
|
132
|
+
var import_core2 = require("@dorval/core");
|
|
133
|
+
async function watchCommand(options) {
|
|
134
|
+
const ora = await import("ora").then((m) => m.default || m);
|
|
135
|
+
const spinner = ora("Starting watch mode...").start();
|
|
136
|
+
try {
|
|
137
|
+
const config = await loadConfig(options.config);
|
|
138
|
+
if (typeof config.input !== "string") {
|
|
139
|
+
throw new Error("Watch mode requires a file path input");
|
|
140
|
+
}
|
|
141
|
+
const inputPath = path.resolve(config.input);
|
|
142
|
+
spinner.succeed(import_chalk2.default.green(`Watching ${inputPath} for changes...`));
|
|
143
|
+
await (0, import_core2.generateDartCode)(config);
|
|
144
|
+
console.log(import_chalk2.default.cyan("\u2705 Initial generation completed"));
|
|
145
|
+
fs.watchFile(inputPath, async () => {
|
|
146
|
+
console.log(import_chalk2.default.yellow("\n\u{1F4DD} File changed, regenerating..."));
|
|
147
|
+
try {
|
|
148
|
+
await (0, import_core2.generateDartCode)(config);
|
|
149
|
+
console.log(import_chalk2.default.green("\u2705 Regeneration completed"));
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.error(import_chalk2.default.red(`\u274C Regeneration failed: ${error instanceof Error ? error.message : String(error)}`));
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
process.stdin.resume();
|
|
155
|
+
process.on("SIGINT", () => {
|
|
156
|
+
console.log(import_chalk2.default.yellow("\n\u{1F44B} Stopping watch mode..."));
|
|
157
|
+
fs.unwatchFile(inputPath);
|
|
158
|
+
process.exit(0);
|
|
159
|
+
});
|
|
160
|
+
} catch (error) {
|
|
161
|
+
spinner.fail(import_chalk2.default.red("Watch mode failed"));
|
|
162
|
+
console.error(import_chalk2.default.red(`
|
|
163
|
+
Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// src/cli.ts
|
|
169
|
+
function runCLI(args) {
|
|
170
|
+
const program = new import_commander.Command();
|
|
171
|
+
program.name("dorval").description("Generate Dart API clients from OpenAPI specifications");
|
|
172
|
+
program.command("generate").description("Generate Dart code").option("-c, --config <path>", "Config file path").option("-i, --input <path>", "Input spec").option("-o, --output <path>", "Output directory").action(generateCommand);
|
|
173
|
+
program.command("watch").description("Watch for changes").option("-c, --config <path>", "Config file path").action(watchCommand);
|
|
174
|
+
program.parse(args);
|
|
175
|
+
}
|
|
176
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
177
|
+
0 && (module.exports = {
|
|
178
|
+
generateCommand,
|
|
179
|
+
loadConfig,
|
|
180
|
+
runCLI,
|
|
181
|
+
watchCommand
|
|
182
|
+
});
|
|
183
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/cli.ts","../src/commands/generate.ts","../src/config.ts","../src/commands/watch.ts"],"sourcesContent":["/**\n * @dorval/cli\n * CLI exports for programmatic usage\n */\n\nexport { runCLI } from './cli';\nexport { loadConfig } from './config';\nexport { generateCommand } from './commands/generate';\nexport { watchCommand } from './commands/watch';","/**\n * CLI runner for programmatic usage\n */\n\nimport { Command } from 'commander';\nimport { generateCommand } from './commands/generate';\nimport { watchCommand } from './commands/watch';\n\nexport function runCLI(args: string[]): void {\n const program = new Command();\n \n program\n .name('dorval')\n .description('Generate Dart API clients from OpenAPI specifications');\n \n program\n .command('generate')\n .description('Generate Dart code')\n .option('-c, --config <path>', 'Config file path')\n .option('-i, --input <path>', 'Input spec')\n .option('-o, --output <path>', 'Output directory')\n .action(generateCommand);\n \n program\n .command('watch')\n .description('Watch for changes')\n .option('-c, --config <path>', 'Config file path')\n .action(watchCommand);\n \n program.parse(args);\n}","/**\n * Generate command implementation\n */\n\nimport chalk from 'chalk';\nimport { generateDartCode, DartGeneratorOptions } from '@dorval/core';\nimport { loadConfig } from '../config.js';\n\ninterface GenerateOptions {\n config?: string;\n input?: string;\n output?: string;\n client?: 'dio' | 'http' | 'chopper';\n watch?: boolean;\n}\n\nexport async function generateCommand(options: GenerateOptions) {\n // Dynamic import for ora to support both CJS and ESM\n const ora = await import('ora').then(m => m.default || m);\n const spinner = ora('Loading configuration...').start();\n \n try {\n // Load configuration\n let config: DartGeneratorOptions;\n \n if (options.input && options.output) {\n // Use command line options\n config = {\n input: options.input,\n output: {\n target: options.output,\n client: options.client || 'dio',\n mode: 'split',\n override: {\n generator: {\n freezed: true,\n jsonSerializable: true,\n nullSafety: true\n }\n }\n }\n };\n } else if (options.config) {\n config = await loadConfig(options.config);\n } else {\n // Try to load from default locations\n try {\n config = await loadConfig();\n } catch {\n throw new Error('Either provide a config file or use -i and -o options');\n }\n }\n \n spinner.text = 'Parsing OpenAPI specification...';\n \n // Generate code\n const files = await generateDartCode(config);\n \n spinner.succeed(chalk.green(`✅ Generated ${files.length} files`));\n \n // List generated files\n console.log(chalk.cyan('\\nGenerated files:'));\n files.forEach(file => {\n console.log(chalk.gray(` - ${file.path}`));\n });\n \n // Run post-generation hooks\n if (config.hooks?.afterAllFilesWrite) {\n spinner.start('Running post-generation hooks...');\n // TODO: Implement hook execution\n spinner.succeed('Hooks completed');\n }\n \n console.log(chalk.green('\\n✨ Generation completed successfully!'));\n \n } catch (error) {\n spinner.fail(chalk.red('Generation failed'));\n console.error(chalk.red(`\\nError: ${error instanceof Error ? error.message : String(error)}`));\n process.exit(1);\n }\n}","/**\n * Configuration loader\n */\n\nimport { cosmiconfigSync } from 'cosmiconfig';\nimport { DartGeneratorOptions } from '@dorval/core';\n\n// Create explorer lazily to avoid initialization issues\nfunction getExplorer() {\n return cosmiconfigSync('orval', {\n searchPlaces: [\n 'orval.config.ts',\n 'orval.config.js',\n 'orval.config.cjs',\n '.orvalrc',\n '.orvalrc.json',\n '.orvalrc.yaml',\n '.orvalrc.yml',\n 'package.json'\n ]\n });\n}\n\nexport async function loadConfig(configPath?: string): Promise<DartGeneratorOptions> {\n const explorer = getExplorer();\n const result = configPath\n ? explorer.load(configPath)\n : explorer.search();\n \n if (!result) {\n throw new Error('No configuration file found');\n }\n \n // Handle default export or direct config\n const config = result.config.default || result.config;\n \n // If config has multiple specs, use the first one\n if (typeof config === 'object' && !config.input) {\n const firstKey = Object.keys(config)[0];\n return config[firstKey];\n }\n \n return config;\n}","/**\n * Watch command implementation\n */\n\nimport chalk from 'chalk';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { generateDartCode } from '@dorval/core';\nimport { loadConfig } from '../config.js';\n\ninterface WatchOptions {\n config?: string;\n}\n\nexport async function watchCommand(options: WatchOptions) {\n // Dynamic import for ora to support both CJS and ESM\n const ora = await import('ora').then(m => m.default || m);\n const spinner = ora('Starting watch mode...').start();\n \n try {\n // Load configuration\n const config = await loadConfig(options.config);\n \n if (typeof config.input !== 'string') {\n throw new Error('Watch mode requires a file path input');\n }\n \n const inputPath = path.resolve(config.input);\n \n spinner.succeed(chalk.green(`Watching ${inputPath} for changes...`));\n \n // Initial generation\n await generateDartCode(config);\n console.log(chalk.cyan('✅ Initial generation completed'));\n \n // Watch for changes\n fs.watchFile(inputPath, async () => {\n console.log(chalk.yellow('\\n📝 File changed, regenerating...'));\n \n try {\n await generateDartCode(config);\n console.log(chalk.green('✅ Regeneration completed'));\n } catch (error) {\n console.error(chalk.red(`❌ Regeneration failed: ${error instanceof Error ? error.message : String(error)}`));\n }\n });\n \n // Keep process alive\n process.stdin.resume();\n \n // Handle exit\n process.on('SIGINT', () => {\n console.log(chalk.yellow('\\n👋 Stopping watch mode...'));\n fs.unwatchFile(inputPath);\n process.exit(0);\n });\n \n } catch (error) {\n spinner.fail(chalk.red('Watch mode failed'));\n console.error(chalk.red(`\\nError: ${error instanceof Error ? error.message : String(error)}`));\n process.exit(1);\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,uBAAwB;;;ACAxB,mBAAkB;AAClB,kBAAuD;;;ACDvD,yBAAgC;AAIhC,SAAS,cAAc;AACrB,aAAO,oCAAgB,SAAS;AAAA,IAC9B,cAAc;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEA,eAAsB,WAAW,YAAoD;AACnF,QAAM,WAAW,YAAY;AAC7B,QAAM,SAAS,aACX,SAAS,KAAK,UAAU,IACxB,SAAS,OAAO;AAEpB,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AAGA,QAAM,SAAS,OAAO,OAAO,WAAW,OAAO;AAG/C,MAAI,OAAO,WAAW,YAAY,CAAC,OAAO,OAAO;AAC/C,UAAM,WAAW,OAAO,KAAK,MAAM,EAAE,CAAC;AACtC,WAAO,OAAO,QAAQ;AAAA,EACxB;AAEA,SAAO;AACT;;;AD3BA,eAAsB,gBAAgB,SAA0B;AAE9D,QAAM,MAAM,MAAM,OAAO,KAAK,EAAE,KAAK,OAAK,EAAE,WAAW,CAAC;AACxD,QAAM,UAAU,IAAI,0BAA0B,EAAE,MAAM;AAEtD,MAAI;AAEF,QAAI;AAEJ,QAAI,QAAQ,SAAS,QAAQ,QAAQ;AAEnC,eAAS;AAAA,QACP,OAAO,QAAQ;AAAA,QACf,QAAQ;AAAA,UACN,QAAQ,QAAQ;AAAA,UAChB,QAAQ,QAAQ,UAAU;AAAA,UA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oB,EAChC,OAAO,uBAAuB,kBAAkB,EAChD,OAAO,sBAAsB,YAAY,EACzC,OAAO,uBAAuB,kBAAkB,EAChD,OAAO,eAAe;AAEzB,UACG,QAAQ,OAAO,EACf,YAAY,mBAAmB,EAC/B,OAAO,uBAAuB,kBAAkB,EAChD,OAAO,YAAY;AAEtB,UAAQ,MAAM,IAAI;AACpB;","names":["chalk","import_chalk","import_core","chalk"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DartGeneratorOptions } from '@dorval/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CLI runner for programmatic usage
|
|
5
|
+
*/
|
|
6
|
+
declare function runCLI(args: string[]): void;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Configuration loader
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare function loadConfig(configPath?: string): Promise<DartGeneratorOptions>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Generate command implementation
|
|
16
|
+
*/
|
|
17
|
+
interface GenerateOptions {
|
|
18
|
+
config?: string;
|
|
19
|
+
input?: string;
|
|
20
|
+
output?: string;
|
|
21
|
+
client?: 'dio' | 'http' | 'chopper';
|
|
22
|
+
watch?: boolean;
|
|
23
|
+
}
|
|
24
|
+
declare function generateCommand(options: GenerateOptions): Promise<void>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Watch command implementation
|
|
28
|
+
*/
|
|
29
|
+
interface WatchOptions {
|
|
30
|
+
config?: string;
|
|
31
|
+
}
|
|
32
|
+
declare function watchCommand(options: WatchOptions): Promise<void>;
|
|
33
|
+
|
|
34
|
+
export { generateCommand, loadConfig, runCLI, watchCommand };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DartGeneratorOptions } from '@dorval/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CLI runner for programmatic usage
|
|
5
|
+
*/
|
|
6
|
+
declare function runCLI(args: string[]): void;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Configuration loader
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare function loadConfig(configPath?: string): Promise<DartGeneratorOptions>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Generate command implementation
|
|
16
|
+
*/
|
|
17
|
+
interface GenerateOptions {
|
|
18
|
+
config?: string;
|
|
19
|
+
input?: string;
|
|
20
|
+
output?: string;
|
|
21
|
+
client?: 'dio' | 'http' | 'chopper';
|
|
22
|
+
watch?: boolean;
|
|
23
|
+
}
|
|
24
|
+
declare function generateCommand(options: GenerateOptions): Promise<void>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Watch command implementation
|
|
28
|
+
*/
|
|
29
|
+
interface WatchOptions {
|
|
30
|
+
config?: string;
|
|
31
|
+
}
|
|
32
|
+
declare function watchCommand(options: WatchOptions): Promise<void>;
|
|
33
|
+
|
|
34
|
+
export { generateCommand, loadConfig, runCLI, watchCommand };
|
package/dist/index.js
CHANGED
|
@@ -1,54 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var index_exports = {};
|
|
32
|
-
__export(index_exports, {
|
|
33
|
-
generateCommand: () => generateCommand,
|
|
34
|
-
loadConfig: () => loadConfig,
|
|
35
|
-
runCLI: () => runCLI,
|
|
36
|
-
watchCommand: () => watchCommand
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(index_exports);
|
|
39
|
-
|
|
40
1
|
// src/cli.ts
|
|
41
|
-
|
|
2
|
+
import { Command } from "commander";
|
|
42
3
|
|
|
43
4
|
// src/commands/generate.ts
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var import_core = require("@dorval/core");
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import { generateDartCode } from "@dorval/core";
|
|
47
7
|
|
|
48
8
|
// src/config.ts
|
|
49
|
-
|
|
9
|
+
import { cosmiconfigSync } from "cosmiconfig";
|
|
50
10
|
function getExplorer() {
|
|
51
|
-
return
|
|
11
|
+
return cosmiconfigSync("orval", {
|
|
52
12
|
searchPlaces: [
|
|
53
13
|
"orval.config.ts",
|
|
54
14
|
"orval.config.js",
|
|
@@ -77,7 +37,8 @@ async function loadConfig(configPath) {
|
|
|
77
37
|
|
|
78
38
|
// src/commands/generate.ts
|
|
79
39
|
async function generateCommand(options) {
|
|
80
|
-
const
|
|
40
|
+
const ora = await import("ora").then((m) => m.default || m);
|
|
41
|
+
const spinner = ora("Loading configuration...").start();
|
|
81
42
|
try {
|
|
82
43
|
let config;
|
|
83
44
|
if (options.input && options.output) {
|
|
@@ -101,65 +62,65 @@ async function generateCommand(options) {
|
|
|
101
62
|
} else {
|
|
102
63
|
try {
|
|
103
64
|
config = await loadConfig();
|
|
104
|
-
} catch
|
|
65
|
+
} catch {
|
|
105
66
|
throw new Error("Either provide a config file or use -i and -o options");
|
|
106
67
|
}
|
|
107
68
|
}
|
|
108
69
|
spinner.text = "Parsing OpenAPI specification...";
|
|
109
|
-
const files = await
|
|
110
|
-
spinner.succeed(
|
|
111
|
-
console.log(
|
|
70
|
+
const files = await generateDartCode(config);
|
|
71
|
+
spinner.succeed(chalk.green(`\u2705 Generated ${files.length} files`));
|
|
72
|
+
console.log(chalk.cyan("\nGenerated files:"));
|
|
112
73
|
files.forEach((file) => {
|
|
113
|
-
console.log(
|
|
74
|
+
console.log(chalk.gray(` - ${file.path}`));
|
|
114
75
|
});
|
|
115
76
|
if (config.hooks?.afterAllFilesWrite) {
|
|
116
77
|
spinner.start("Running post-generation hooks...");
|
|
117
78
|
spinner.succeed("Hooks completed");
|
|
118
79
|
}
|
|
119
|
-
console.log(
|
|
80
|
+
console.log(chalk.green("\n\u2728 Generation completed successfully!"));
|
|
120
81
|
} catch (error) {
|
|
121
|
-
spinner.fail(
|
|
122
|
-
console.error(
|
|
82
|
+
spinner.fail(chalk.red("Generation failed"));
|
|
83
|
+
console.error(chalk.red(`
|
|
123
84
|
Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
124
85
|
process.exit(1);
|
|
125
86
|
}
|
|
126
87
|
}
|
|
127
88
|
|
|
128
89
|
// src/commands/watch.ts
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
var import_core2 = require("@dorval/core");
|
|
90
|
+
import chalk2 from "chalk";
|
|
91
|
+
import * as fs from "fs";
|
|
92
|
+
import * as path from "path";
|
|
93
|
+
import { generateDartCode as generateDartCode2 } from "@dorval/core";
|
|
134
94
|
async function watchCommand(options) {
|
|
135
|
-
const
|
|
95
|
+
const ora = await import("ora").then((m) => m.default || m);
|
|
96
|
+
const spinner = ora("Starting watch mode...").start();
|
|
136
97
|
try {
|
|
137
98
|
const config = await loadConfig(options.config);
|
|
138
99
|
if (typeof config.input !== "string") {
|
|
139
100
|
throw new Error("Watch mode requires a file path input");
|
|
140
101
|
}
|
|
141
102
|
const inputPath = path.resolve(config.input);
|
|
142
|
-
spinner.succeed(
|
|
143
|
-
await (
|
|
144
|
-
console.log(
|
|
103
|
+
spinner.succeed(chalk2.green(`Watching ${inputPath} for changes...`));
|
|
104
|
+
await generateDartCode2(config);
|
|
105
|
+
console.log(chalk2.cyan("\u2705 Initial generation completed"));
|
|
145
106
|
fs.watchFile(inputPath, async () => {
|
|
146
|
-
console.log(
|
|
107
|
+
console.log(chalk2.yellow("\n\u{1F4DD} File changed, regenerating..."));
|
|
147
108
|
try {
|
|
148
|
-
await (
|
|
149
|
-
console.log(
|
|
109
|
+
await generateDartCode2(config);
|
|
110
|
+
console.log(chalk2.green("\u2705 Regeneration completed"));
|
|
150
111
|
} catch (error) {
|
|
151
|
-
console.error(
|
|
112
|
+
console.error(chalk2.red(`\u274C Regeneration failed: ${error instanceof Error ? error.message : String(error)}`));
|
|
152
113
|
}
|
|
153
114
|
});
|
|
154
115
|
process.stdin.resume();
|
|
155
116
|
process.on("SIGINT", () => {
|
|
156
|
-
console.log(
|
|
117
|
+
console.log(chalk2.yellow("\n\u{1F44B} Stopping watch mode..."));
|
|
157
118
|
fs.unwatchFile(inputPath);
|
|
158
119
|
process.exit(0);
|
|
159
120
|
});
|
|
160
121
|
} catch (error) {
|
|
161
|
-
spinner.fail(
|
|
162
|
-
console.error(
|
|
122
|
+
spinner.fail(chalk2.red("Watch mode failed"));
|
|
123
|
+
console.error(chalk2.red(`
|
|
163
124
|
Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
164
125
|
process.exit(1);
|
|
165
126
|
}
|
|
@@ -167,17 +128,16 @@ Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
|
167
128
|
|
|
168
129
|
// src/cli.ts
|
|
169
130
|
function runCLI(args) {
|
|
170
|
-
const program = new
|
|
131
|
+
const program = new Command();
|
|
171
132
|
program.name("dorval").description("Generate Dart API clients from OpenAPI specifications");
|
|
172
133
|
program.command("generate").description("Generate Dart code").option("-c, --config <path>", "Config file path").option("-i, --input <path>", "Input spec").option("-o, --output <path>", "Output directory").action(generateCommand);
|
|
173
134
|
program.command("watch").description("Watch for changes").option("-c, --config <path>", "Config file path").action(watchCommand);
|
|
174
135
|
program.parse(args);
|
|
175
136
|
}
|
|
176
|
-
|
|
177
|
-
0 && (module.exports = {
|
|
137
|
+
export {
|
|
178
138
|
generateCommand,
|
|
179
139
|
loadConfig,
|
|
180
140
|
runCLI,
|
|
181
141
|
watchCommand
|
|
182
|
-
}
|
|
142
|
+
};
|
|
183
143
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/commands/generate.ts","../src/config.ts","../src/commands/watch.ts"],"sourcesContent":["/**\n * CLI runner for programmatic usage\n */\n\nimport { Command } from 'commander';\nimport { generateCommand } from './commands/generate';\nimport { watchCommand } from './commands/watch';\n\nexport function runCLI(args: string[]): void {\n const program = new Command();\n \n program\n .name('dorval')\n .description('Generate Dart API clients from OpenAPI specifications');\n \n program\n .command('generate')\n .description('Generate Dart code')\n .option('-c, --config <path>', 'Config file path')\n .option('-i, --input <path>', 'Input spec')\n .option('-o, --output <path>', 'Output directory')\n .action(generateCommand);\n \n program\n .command('watch')\n .description('Watch for changes')\n .option('-c, --config <path>', 'Config file path')\n .action(watchCommand);\n \n program.parse(args);\n}","/**\n * Generate command implementation\n */\n\nimport chalk from 'chalk';\nimport { generateDartCode, DartGeneratorOptions } from '@dorval/core';\nimport { loadConfig } from '../config.js';\n\ninterface GenerateOptions {\n config?: string;\n input?: string;\n output?: string;\n client?: 'dio' | 'http' | 'chopper';\n watch?: boolean;\n}\n\nexport async function generateCommand(options: GenerateOptions) {\n // Dynamic import for ora to support both CJS and ESM\n const ora = await import('ora').then(m => m.default || m);\n const spinner = ora('Loading configuration...').start();\n \n try {\n // Load configuration\n let config: DartGeneratorOptions;\n \n if (options.input && options.output) {\n // Use command line options\n config = {\n input: options.input,\n output: {\n target: options.output,\n client: options.client || 'dio',\n mode: 'split',\n override: {\n generator: {\n freezed: true,\n jsonSerializable: true,\n nullSafety: true\n }\n }\n }\n };\n } else if (options.config) {\n config = await loadConfig(options.config);\n } else {\n // Try to load from default locations\n try {\n config = await loadConfig();\n } catch {\n throw new Error('Either provide a config file or use -i and -o options');\n }\n }\n \n spinner.text = 'Parsing OpenAPI specification...';\n \n // Generate code\n const files = await generateDartCode(config);\n \n spinner.succeed(chalk.green(`✅ Generated ${files.length} files`));\n \n // List generated files\n console.log(chalk.cyan('\\nGenerated files:'));\n files.forEach(file => {\n console.log(chalk.gray(` - ${file.path}`));\n });\n \n // Run post-generation hooks\n if (config.hooks?.afterAllFilesWrite) {\n spinner.start('Running post-generation hooks...');\n // TODO: Implement hook execution\n spinner.succeed('Hooks completed');\n }\n \n console.log(chalk.green('\\n✨ Generation completed successfully!'));\n \n } catch (error) {\n spinner.fail(chalk.red('Generation failed'));\n console.error(chalk.red(`\\nError: ${error instanceof Error ? error.message : String(error)}`));\n process.exit(1);\n }\n}","/**\n * Configuration loader\n */\n\nimport { cosmiconfigSync } from 'cosmiconfig';\nimport { DartGeneratorOptions } from '@dorval/core';\n\n// Create explorer lazily to avoid initialization issues\nfunction getExplorer() {\n return cosmiconfigSync('orval', {\n searchPlaces: [\n 'orval.config.ts',\n 'orval.config.js',\n 'orval.config.cjs',\n '.orvalrc',\n '.orvalrc.json',\n '.orvalrc.yaml',\n '.orvalrc.yml',\n 'package.json'\n ]\n });\n}\n\nexport async function loadConfig(configPath?: string): Promise<DartGeneratorOptions> {\n const explorer = getExplorer();\n const result = configPath\n ? explorer.load(configPath)\n : explorer.search();\n \n if (!result) {\n throw new Error('No configuration file found');\n }\n \n // Handle default export or direct config\n const config = result.config.default || result.config;\n \n // If config has multiple specs, use the first one\n if (typeof config === 'object' && !config.input) {\n const firstKey = Object.keys(config)[0];\n return config[firstKey];\n }\n \n return config;\n}","/**\n * Watch command implementation\n */\n\nimport chalk from 'chalk';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { generateDartCode } from '@dorval/core';\nimport { loadConfig } from '../config.js';\n\ninterface WatchOptions {\n config?: string;\n}\n\nexport async function watchCommand(options: WatchOptions) {\n // Dynamic import for ora to support both CJS and ESM\n const ora = await import('ora').then(m => m.default || m);\n const spinner = ora('Starting watch mode...').start();\n \n try {\n // Load configuration\n const config = await loadConfig(options.config);\n \n if (typeof config.input !== 'string') {\n throw new Error('Watch mode requires a file path input');\n }\n \n const inputPath = path.resolve(config.input);\n \n spinner.succeed(chalk.green(`Watching ${inputPath} for changes...`));\n \n // Initial generation\n await generateDartCode(config);\n console.log(chalk.cyan('✅ Initial generation completed'));\n \n // Watch for changes\n fs.watchFile(inputPath, async () => {\n console.log(chalk.yellow('\\n📝 File changed, regenerating...'));\n \n try {\n await generateDartCode(config);\n console.log(chalk.green('✅ Regeneration completed'));\n } catch (error) {\n console.error(chalk.red(`❌ Regeneration failed: ${error instanceof Error ? error.message : String(error)}`));\n }\n });\n \n // Keep process alive\n process.stdin.resume();\n \n // Handle exit\n process.on('SIGINT', () => {\n console.log(chalk.yellow('\\n👋 Stopping watch mode...'));\n fs.unwatchFile(inputPath);\n process.exit(0);\n });\n \n } catch (error) {\n spinner.fail(chalk.red('Watch mode failed'));\n console.error(chalk.red(`\\nError: ${error instanceof Error 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
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dorval",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "CLI tool for generating Dart/Flutter API clients from OpenAPI specifications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -28,8 +28,17 @@
|
|
|
28
28
|
"url": "https://github.com/qwlong/dorval/issues"
|
|
29
29
|
},
|
|
30
30
|
"license": "MIT",
|
|
31
|
-
"
|
|
31
|
+
"type": "module",
|
|
32
|
+
"main": "./dist/index.cjs",
|
|
33
|
+
"module": "./dist/index.js",
|
|
32
34
|
"types": "./dist/index.d.ts",
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"import": "./dist/index.js",
|
|
38
|
+
"require": "./dist/index.cjs",
|
|
39
|
+
"types": "./dist/index.d.ts"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
33
42
|
"bin": {
|
|
34
43
|
"dorval": "./dist/bin/dorval.js"
|
|
35
44
|
},
|
|
@@ -37,27 +46,27 @@
|
|
|
37
46
|
"dist"
|
|
38
47
|
],
|
|
39
48
|
"scripts": {
|
|
40
|
-
"build": "tsup
|
|
49
|
+
"build": "tsup",
|
|
41
50
|
"dev": "tsup ./src/index.ts ./src/bin/dorval.ts --clean --sourcemap --watch src --dts",
|
|
42
|
-
"lint": "eslint src/**/*.ts",
|
|
51
|
+
"lint": "eslint 'src/**/*.ts'",
|
|
43
52
|
"test": "vitest run"
|
|
44
53
|
},
|
|
45
54
|
"dependencies": {
|
|
46
55
|
"@dorval/core": "0.1.7",
|
|
47
|
-
"commander": "^11.0.0",
|
|
48
56
|
"chalk": "^4.1.2",
|
|
49
|
-
"
|
|
57
|
+
"commander": "^11.0.0",
|
|
50
58
|
"cosmiconfig": "^8.2.0",
|
|
51
|
-
"
|
|
59
|
+
"ora": "^8.1.1",
|
|
52
60
|
"typescript": "^5.2.2"
|
|
53
61
|
},
|
|
54
62
|
"devDependencies": {
|
|
55
63
|
"@types/fs-extra": "^11.0.4",
|
|
56
64
|
"@types/node": "^20.13.0",
|
|
65
|
+
"globals": "^16.3.0",
|
|
57
66
|
"tsup": "^8.5.0",
|
|
58
67
|
"vitest": "^0.6.3"
|
|
59
68
|
},
|
|
60
69
|
"engines": {
|
|
61
70
|
"node": ">=18"
|
|
62
71
|
}
|
|
63
|
-
}
|
|
72
|
+
}
|