dorval 0.2.1 → 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 -108
- 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 -120
- package/dist/index.js.map +1 -1
- package/package.json +14 -5
|
@@ -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,40 +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
|
-
|
|
8
|
+
import chalk from "chalk";
|
|
9
|
+
import { generateDartCode } from "@dorval/core";
|
|
33
10
|
|
|
34
11
|
// src/config.ts
|
|
35
|
-
|
|
12
|
+
import { cosmiconfigSync } from "cosmiconfig";
|
|
36
13
|
function getExplorer() {
|
|
37
|
-
return
|
|
14
|
+
return cosmiconfigSync("orval", {
|
|
38
15
|
searchPlaces: [
|
|
39
16
|
"orval.config.ts",
|
|
40
17
|
"orval.config.js",
|
|
@@ -62,32 +39,9 @@ async function loadConfig(configPath) {
|
|
|
62
39
|
}
|
|
63
40
|
|
|
64
41
|
// src/commands/generate.ts
|
|
65
|
-
var SimpleSpinner = class {
|
|
66
|
-
message;
|
|
67
|
-
constructor(message) {
|
|
68
|
-
this.message = message;
|
|
69
|
-
}
|
|
70
|
-
start() {
|
|
71
|
-
console.log(import_chalk.default.cyan(`\u23F3 ${this.message}`));
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
succeed(message) {
|
|
75
|
-
console.log(import_chalk.default.green(`\u2705 ${message || this.message}`));
|
|
76
|
-
return this;
|
|
77
|
-
}
|
|
78
|
-
fail(message) {
|
|
79
|
-
console.log(import_chalk.default.red(`\u274C ${message || this.message}`));
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
text(message) {
|
|
83
|
-
this.message = message;
|
|
84
|
-
console.log(import_chalk.default.cyan(`\u23F3 ${message}`));
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
42
|
async function generateCommand(options) {
|
|
89
|
-
const
|
|
90
|
-
spinner.start();
|
|
43
|
+
const ora = await import("ora").then((m) => m.default || m);
|
|
44
|
+
const spinner = ora("Loading configuration...").start();
|
|
91
45
|
try {
|
|
92
46
|
let config;
|
|
93
47
|
if (options.input && options.output) {
|
|
@@ -111,88 +65,65 @@ async function generateCommand(options) {
|
|
|
111
65
|
} else {
|
|
112
66
|
try {
|
|
113
67
|
config = await loadConfig();
|
|
114
|
-
} catch
|
|
68
|
+
} catch {
|
|
115
69
|
throw new Error("Either provide a config file or use -i and -o options");
|
|
116
70
|
}
|
|
117
71
|
}
|
|
118
72
|
spinner.text = "Parsing OpenAPI specification...";
|
|
119
|
-
const files = await
|
|
120
|
-
spinner.succeed(
|
|
121
|
-
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:"));
|
|
122
76
|
files.forEach((file) => {
|
|
123
|
-
console.log(
|
|
77
|
+
console.log(chalk.gray(` - ${file.path}`));
|
|
124
78
|
});
|
|
125
79
|
if (config.hooks?.afterAllFilesWrite) {
|
|
126
80
|
spinner.start("Running post-generation hooks...");
|
|
127
81
|
spinner.succeed("Hooks completed");
|
|
128
82
|
}
|
|
129
|
-
console.log(
|
|
83
|
+
console.log(chalk.green("\n\u2728 Generation completed successfully!"));
|
|
130
84
|
} catch (error) {
|
|
131
|
-
spinner.fail(
|
|
132
|
-
console.error(
|
|
85
|
+
spinner.fail(chalk.red("Generation failed"));
|
|
86
|
+
console.error(chalk.red(`
|
|
133
87
|
Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
134
88
|
process.exit(1);
|
|
135
89
|
}
|
|
136
90
|
}
|
|
137
91
|
|
|
138
92
|
// src/commands/watch.ts
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
var SimpleSpinner2 = class {
|
|
144
|
-
message;
|
|
145
|
-
constructor(message) {
|
|
146
|
-
this.message = message;
|
|
147
|
-
}
|
|
148
|
-
start() {
|
|
149
|
-
console.log(import_chalk2.default.cyan(`\u23F3 ${this.message}`));
|
|
150
|
-
return this;
|
|
151
|
-
}
|
|
152
|
-
succeed(message) {
|
|
153
|
-
console.log(import_chalk2.default.green(`\u2705 ${message || this.message}`));
|
|
154
|
-
return this;
|
|
155
|
-
}
|
|
156
|
-
fail(message) {
|
|
157
|
-
console.log(import_chalk2.default.red(`\u274C ${message || this.message}`));
|
|
158
|
-
return this;
|
|
159
|
-
}
|
|
160
|
-
text(message) {
|
|
161
|
-
this.message = message;
|
|
162
|
-
console.log(import_chalk2.default.cyan(`\u23F3 ${message}`));
|
|
163
|
-
return this;
|
|
164
|
-
}
|
|
165
|
-
};
|
|
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";
|
|
166
97
|
async function watchCommand(options) {
|
|
167
|
-
const
|
|
168
|
-
spinner.start();
|
|
98
|
+
const ora = await import("ora").then((m) => m.default || m);
|
|
99
|
+
const spinner = ora("Starting watch mode...").start();
|
|
169
100
|
try {
|
|
170
101
|
const config = await loadConfig(options.config);
|
|
171
102
|
if (typeof config.input !== "string") {
|
|
172
103
|
throw new Error("Watch mode requires a file path input");
|
|
173
104
|
}
|
|
174
105
|
const inputPath = path.resolve(config.input);
|
|
175
|
-
spinner.succeed(
|
|
176
|
-
await (
|
|
177
|
-
console.log(
|
|
106
|
+
spinner.succeed(chalk2.green(`Watching ${inputPath} for changes...`));
|
|
107
|
+
await generateDartCode2(config);
|
|
108
|
+
console.log(chalk2.cyan("\u2705 Initial generation completed"));
|
|
178
109
|
fs.watchFile(inputPath, async () => {
|
|
179
|
-
console.log(
|
|
110
|
+
console.log(chalk2.yellow("\n\u{1F4DD} File changed, regenerating..."));
|
|
180
111
|
try {
|
|
181
|
-
await (
|
|
182
|
-
console.log(
|
|
112
|
+
await generateDartCode2(config);
|
|
113
|
+
console.log(chalk2.green("\u2705 Regeneration completed"));
|
|
183
114
|
} catch (error) {
|
|
184
|
-
console.error(
|
|
115
|
+
console.error(chalk2.red(`\u274C Regeneration failed: ${error instanceof Error ? error.message : String(error)}`));
|
|
185
116
|
}
|
|
186
117
|
});
|
|
187
118
|
process.stdin.resume();
|
|
188
119
|
process.on("SIGINT", () => {
|
|
189
|
-
console.log(
|
|
120
|
+
console.log(chalk2.yellow("\n\u{1F44B} Stopping watch mode..."));
|
|
190
121
|
fs.unwatchFile(inputPath);
|
|
191
122
|
process.exit(0);
|
|
192
123
|
});
|
|
193
124
|
} catch (error) {
|
|
194
|
-
spinner.fail(
|
|
195
|
-
console.error(
|
|
125
|
+
spinner.fail(chalk2.red("Watch mode failed"));
|
|
126
|
+
console.error(chalk2.red(`
|
|
196
127
|
Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
197
128
|
process.exit(1);
|
|
198
129
|
}
|
|
@@ -202,11 +133,11 @@ Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
|
202
133
|
var version = "0.1.7";
|
|
203
134
|
|
|
204
135
|
// src/bin/dorval.ts
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
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(`
|
|
210
141
|
\u{1F3AF} Dorval v${version}
|
|
211
142
|
Generate type-safe Dart API clients from OpenAPI specifications.
|
|
212
143
|
|
|
@@ -217,8 +148,8 @@ Usage:
|
|
|
217
148
|
Run 'dorval --help' for more information.
|
|
218
149
|
`));
|
|
219
150
|
});
|
|
220
|
-
|
|
151
|
+
program.parse(process.argv);
|
|
221
152
|
if (!process.argv.slice(2).length) {
|
|
222
|
-
|
|
153
|
+
program.outputHelp();
|
|
223
154
|
}
|
|
224
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 { generateDartCode, DartGeneratorOptions } from '@dorval/core';\nimport { loadConfig } from '../config';\n\n// Simple spinner implementation\nclass SimpleSpinner {\n private message: string;\n \n constructor(message: string) {\n this.message = message;\n }\n \n start() {\n console.log(chalk.cyan(`⏳ ${this.message}`));\n return this;\n }\n \n succeed(message?: string) {\n console.log(chalk.green(`✅ ${message || this.message}`));\n return this;\n }\n \n fail(message?: string) {\n console.log(chalk.red(`❌ ${message || this.message}`));\n return this;\n }\n \n text(message: string) {\n this.message = message;\n console.log(chalk.cyan(`⏳ ${message}`));\n return this;\n }\n}\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 = new SimpleSpinner('Loading configuration...');\n spinner.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 * as fs from 'fs';\nimport * as path from 'path';\nimport { generateDartCode } from '@dorval/core';\nimport { loadConfig } from '../config';\n\n// Simple spinner implementation (same as in generate.ts)\nclass SimpleSpinner {\n private message: string;\n \n constructor(message: string) {\n this.message = message;\n }\n \n start() {\n console.log(chalk.cyan(`⏳ ${this.message}`));\n return this;\n }\n \n succeed(message?: string) {\n console.log(chalk.green(`✅ ${message || this.message}`));\n return this;\n }\n \n fail(message?: string) {\n console.log(chalk.red(`❌ ${message || this.message}`));\n return this;\n }\n \n text(message: string) {\n this.message = message;\n console.log(chalk.cyan(`⏳ ${message}`));\n return this;\n }\n}\n\ninterface WatchOptions {\n config?: string;\n}\n\nexport async function watchCommand(options: WatchOptions) {\n const spinner = new SimpleSpinner('Starting watch mode...');\n spinner.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,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,Q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AQ,KAAK,cAAAA,QAAM,IAAI,mBAAmB,CAAC;AAC3C,YAAQ,MAAM,cAAAA,QAAM,IAAI;AAAA,SAAY,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE,CAAC;AAC7F,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;;;ACzFE,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","SimpleSpinner","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\",\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,SAAS,eAAe;AACxB,OAAOA,YAAW;;;ACHlB,OAAO,WAAW;AAClB,SAAS,wBAA8C;;;ACDvD,SAAS,uBAAuB;AAIhC,SAAS,cAAc;AACrB,SAAO,gBAAgB,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,OA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E,CAAC;AAC7F,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;;;AC5DE,cAAW;;;AJUb,QACG,KAAK,QAAQ,EACb,YAAY,uDAAuD,EACnE,QAAQ,OAAO;AAGlB,QACG,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,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;AA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AAS,OAAO;AACd,YAAQ,KAAK,cAAAA,QAAM,IAAI,mBAAmB,CAAC;AAC3C,YAAQ,MAAM,cAAAA,QAAM,IAAI;AAAA,SAAY,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE,CAAC;AAC7F,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;;;AHtDO,SAAS,OAAO,MAAsB;AAC3C,QAAM,UAAU,IAAI,yBAAQ;AAE5B,UACG,KAAK,QAAQ,EACb,YAAY,uDAAuD;AAEtE,UACG,QAAQ,UAAU,EAClB,YAAY,oBAAoB,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,53 +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
|
-
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import { generateDartCode } from "@dorval/core";
|
|
46
7
|
|
|
47
8
|
// src/config.ts
|
|
48
|
-
|
|
9
|
+
import { cosmiconfigSync } from "cosmiconfig";
|
|
49
10
|
function getExplorer() {
|
|
50
|
-
return
|
|
11
|
+
return cosmiconfigSync("orval", {
|
|
51
12
|
searchPlaces: [
|
|
52
13
|
"orval.config.ts",
|
|
53
14
|
"orval.config.js",
|
|
@@ -75,32 +36,9 @@ async function loadConfig(configPath) {
|
|
|
75
36
|
}
|
|
76
37
|
|
|
77
38
|
// src/commands/generate.ts
|
|
78
|
-
var SimpleSpinner = class {
|
|
79
|
-
message;
|
|
80
|
-
constructor(message) {
|
|
81
|
-
this.message = message;
|
|
82
|
-
}
|
|
83
|
-
start() {
|
|
84
|
-
console.log(import_chalk.default.cyan(`\u23F3 ${this.message}`));
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
succeed(message) {
|
|
88
|
-
console.log(import_chalk.default.green(`\u2705 ${message || this.message}`));
|
|
89
|
-
return this;
|
|
90
|
-
}
|
|
91
|
-
fail(message) {
|
|
92
|
-
console.log(import_chalk.default.red(`\u274C ${message || this.message}`));
|
|
93
|
-
return this;
|
|
94
|
-
}
|
|
95
|
-
text(message) {
|
|
96
|
-
this.message = message;
|
|
97
|
-
console.log(import_chalk.default.cyan(`\u23F3 ${message}`));
|
|
98
|
-
return this;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
39
|
async function generateCommand(options) {
|
|
102
|
-
const
|
|
103
|
-
spinner.start();
|
|
40
|
+
const ora = await import("ora").then((m) => m.default || m);
|
|
41
|
+
const spinner = ora("Loading configuration...").start();
|
|
104
42
|
try {
|
|
105
43
|
let config;
|
|
106
44
|
if (options.input && options.output) {
|
|
@@ -124,88 +62,65 @@ async function generateCommand(options) {
|
|
|
124
62
|
} else {
|
|
125
63
|
try {
|
|
126
64
|
config = await loadConfig();
|
|
127
|
-
} catch
|
|
65
|
+
} catch {
|
|
128
66
|
throw new Error("Either provide a config file or use -i and -o options");
|
|
129
67
|
}
|
|
130
68
|
}
|
|
131
69
|
spinner.text = "Parsing OpenAPI specification...";
|
|
132
|
-
const files = await
|
|
133
|
-
spinner.succeed(
|
|
134
|
-
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:"));
|
|
135
73
|
files.forEach((file) => {
|
|
136
|
-
console.log(
|
|
74
|
+
console.log(chalk.gray(` - ${file.path}`));
|
|
137
75
|
});
|
|
138
76
|
if (config.hooks?.afterAllFilesWrite) {
|
|
139
77
|
spinner.start("Running post-generation hooks...");
|
|
140
78
|
spinner.succeed("Hooks completed");
|
|
141
79
|
}
|
|
142
|
-
console.log(
|
|
80
|
+
console.log(chalk.green("\n\u2728 Generation completed successfully!"));
|
|
143
81
|
} catch (error) {
|
|
144
|
-
spinner.fail(
|
|
145
|
-
console.error(
|
|
82
|
+
spinner.fail(chalk.red("Generation failed"));
|
|
83
|
+
console.error(chalk.red(`
|
|
146
84
|
Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
147
85
|
process.exit(1);
|
|
148
86
|
}
|
|
149
87
|
}
|
|
150
88
|
|
|
151
89
|
// src/commands/watch.ts
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
var SimpleSpinner2 = class {
|
|
157
|
-
message;
|
|
158
|
-
constructor(message) {
|
|
159
|
-
this.message = message;
|
|
160
|
-
}
|
|
161
|
-
start() {
|
|
162
|
-
console.log(import_chalk2.default.cyan(`\u23F3 ${this.message}`));
|
|
163
|
-
return this;
|
|
164
|
-
}
|
|
165
|
-
succeed(message) {
|
|
166
|
-
console.log(import_chalk2.default.green(`\u2705 ${message || this.message}`));
|
|
167
|
-
return this;
|
|
168
|
-
}
|
|
169
|
-
fail(message) {
|
|
170
|
-
console.log(import_chalk2.default.red(`\u274C ${message || this.message}`));
|
|
171
|
-
return this;
|
|
172
|
-
}
|
|
173
|
-
text(message) {
|
|
174
|
-
this.message = message;
|
|
175
|
-
console.log(import_chalk2.default.cyan(`\u23F3 ${message}`));
|
|
176
|
-
return this;
|
|
177
|
-
}
|
|
178
|
-
};
|
|
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";
|
|
179
94
|
async function watchCommand(options) {
|
|
180
|
-
const
|
|
181
|
-
spinner.start();
|
|
95
|
+
const ora = await import("ora").then((m) => m.default || m);
|
|
96
|
+
const spinner = ora("Starting watch mode...").start();
|
|
182
97
|
try {
|
|
183
98
|
const config = await loadConfig(options.config);
|
|
184
99
|
if (typeof config.input !== "string") {
|
|
185
100
|
throw new Error("Watch mode requires a file path input");
|
|
186
101
|
}
|
|
187
102
|
const inputPath = path.resolve(config.input);
|
|
188
|
-
spinner.succeed(
|
|
189
|
-
await (
|
|
190
|
-
console.log(
|
|
103
|
+
spinner.succeed(chalk2.green(`Watching ${inputPath} for changes...`));
|
|
104
|
+
await generateDartCode2(config);
|
|
105
|
+
console.log(chalk2.cyan("\u2705 Initial generation completed"));
|
|
191
106
|
fs.watchFile(inputPath, async () => {
|
|
192
|
-
console.log(
|
|
107
|
+
console.log(chalk2.yellow("\n\u{1F4DD} File changed, regenerating..."));
|
|
193
108
|
try {
|
|
194
|
-
await (
|
|
195
|
-
console.log(
|
|
109
|
+
await generateDartCode2(config);
|
|
110
|
+
console.log(chalk2.green("\u2705 Regeneration completed"));
|
|
196
111
|
} catch (error) {
|
|
197
|
-
console.error(
|
|
112
|
+
console.error(chalk2.red(`\u274C Regeneration failed: ${error instanceof Error ? error.message : String(error)}`));
|
|
198
113
|
}
|
|
199
114
|
});
|
|
200
115
|
process.stdin.resume();
|
|
201
116
|
process.on("SIGINT", () => {
|
|
202
|
-
console.log(
|
|
117
|
+
console.log(chalk2.yellow("\n\u{1F44B} Stopping watch mode..."));
|
|
203
118
|
fs.unwatchFile(inputPath);
|
|
204
119
|
process.exit(0);
|
|
205
120
|
});
|
|
206
121
|
} catch (error) {
|
|
207
|
-
spinner.fail(
|
|
208
|
-
console.error(
|
|
122
|
+
spinner.fail(chalk2.red("Watch mode failed"));
|
|
123
|
+
console.error(chalk2.red(`
|
|
209
124
|
Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
210
125
|
process.exit(1);
|
|
211
126
|
}
|
|
@@ -213,17 +128,16 @@ Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
|
213
128
|
|
|
214
129
|
// src/cli.ts
|
|
215
130
|
function runCLI(args) {
|
|
216
|
-
const program = new
|
|
131
|
+
const program = new Command();
|
|
217
132
|
program.name("dorval").description("Generate Dart API clients from OpenAPI specifications");
|
|
218
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);
|
|
219
134
|
program.command("watch").description("Watch for changes").option("-c, --config <path>", "Config file path").action(watchCommand);
|
|
220
135
|
program.parse(args);
|
|
221
136
|
}
|
|
222
|
-
|
|
223
|
-
0 && (module.exports = {
|
|
137
|
+
export {
|
|
224
138
|
generateCommand,
|
|
225
139
|
loadConfig,
|
|
226
140
|
runCLI,
|
|
227
141
|
watchCommand
|
|
228
|
-
}
|
|
142
|
+
};
|
|
229
143
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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';\n\n// Simple spinner implementation\nclass SimpleSpinner {\n private message: string;\n \n constructor(message: string) {\n this.message = message;\n }\n \n start() {\n console.log(chalk.cyan(`⏳ ${this.message}`));\n return this;\n }\n \n succeed(message?: string) {\n console.log(chalk.green(`✅ ${message || this.message}`));\n return this;\n }\n \n fail(message?: string) {\n console.log(chalk.red(`❌ ${message || this.message}`));\n return this;\n }\n \n text(message: string) {\n this.message = message;\n console.log(chalk.cyan(`⏳ ${message}`));\n return this;\n }\n}\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 = new SimpleSpinner('Loading configuration...');\n spinner.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 * as fs from 'fs';\nimport * as path from 'path';\nimport { generateDartCode } from '@dorval/core';\nimport { loadConfig } from '../config';\n\n// Simple spinner implementation (same as in generate.ts)\nclass SimpleSpinner {\n private message: string;\n \n constructor(message: string) {\n this.message = message;\n }\n \n start() {\n console.log(chalk.cyan(`⏳ ${this.message}`));\n return this;\n }\n \n succeed(message?: string) {\n console.log(chalk.green(`✅ ${message || this.message}`));\n return this;\n }\n \n fail(message?: string) {\n console.log(chalk.red(`❌ ${message || this.message}`));\n return this;\n }\n \n text(message: string) {\n this.message = message;\n console.log(chalk.cyan(`⏳ ${message}`));\n return this;\n }\n}\n\ninterface WatchOptions {\n config?: string;\n}\n\nexport async function watchCommand(options: WatchOptions) {\n const spinner = new SimpleSpinner('Starting watch mode...');\n spinner.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,W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AQ,GAAG,UAAU,MAAM;AACzB,cAAQ,IAAI,cAAAA,QAAM,OAAO,oCAA6B,CAAC;AACvD,MAAG,eAAY,SAAS;AACxB,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAAA,EAEH,SAAS,OAAO;AACd,YAAQ,KAAK,cAAAA,QAAM,IAAI,mBAAmB,CAAC;AAC3C,YAAQ,MAAM,cAAAA,QAAM,IAAI;AAAA,SAAY,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE,CAAC;AAC7F,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;;;AHnFO,SAAS,OAAO,MAAsB;AAC3C,QAAM,UAAU,IAAI,yBAAQ;AAE5B,UACG,KAAK,QAAQ,EACb,YAAY,uDAAuD;AAEtE,UACG,QAAQ,UAAU,EAClB,YAAY,oBAAoB,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","SimpleSpinner","chalk"]}
|
|
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 ? error.message : String(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6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dorval",
|
|
3
|
-
"version": "0.2.
|
|
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,7 +46,7 @@
|
|
|
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
51
|
"lint": "eslint 'src/**/*.ts'",
|
|
43
52
|
"test": "vitest run"
|
|
@@ -47,13 +56,13 @@
|
|
|
47
56
|
"chalk": "^4.1.2",
|
|
48
57
|
"commander": "^11.0.0",
|
|
49
58
|
"cosmiconfig": "^8.2.0",
|
|
50
|
-
"
|
|
51
|
-
"ora": "5.4.1",
|
|
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
|
},
|