api-farmer 0.1.1 → 0.1.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/README.md +5 -0
- package/dist/{chunk-P3SVS555.js → chunk-FOIQWD3Q.js} +5 -0
- package/dist/cli.cjs +5 -0
- package/dist/cli.js +1 -1
- package/dist/{generate-WIU5E7EL.js → generate-K6NGTXOH.js} +1 -1
- package/dist/index.cjs +5 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -153,6 +153,11 @@ export interface Config {
|
|
|
153
153
|
* Certain uncountable nouns that do not change from singular to plural
|
|
154
154
|
*/
|
|
155
155
|
uncountableNouns?: string[]
|
|
156
|
+
/**
|
|
157
|
+
* Whether to clean the output directory before generating.
|
|
158
|
+
* @default false
|
|
159
|
+
*/
|
|
160
|
+
clean?: boolean
|
|
156
161
|
/**
|
|
157
162
|
* The options for the openapiTS library.
|
|
158
163
|
* @see https://openapi-ts.dev/node
|
|
@@ -280,6 +280,7 @@ async function generate(userOptions = {}) {
|
|
|
280
280
|
input = "./schema.json",
|
|
281
281
|
output = "./src/apis/generated",
|
|
282
282
|
typesFilename = "_types.ts",
|
|
283
|
+
clean = false,
|
|
283
284
|
validateStatus = (status) => status >= 200 && status < 300,
|
|
284
285
|
transformer = {},
|
|
285
286
|
uncountableNouns = [],
|
|
@@ -287,6 +288,10 @@ async function generate(userOptions = {}) {
|
|
|
287
288
|
} = options;
|
|
288
289
|
const mergedTransformer = { ...createTransformer(), ...transformer };
|
|
289
290
|
const schema = await readSchema(input);
|
|
291
|
+
if (clean) {
|
|
292
|
+
fse.removeSync(resolve(CWD, output));
|
|
293
|
+
logger.info(`Cleaned output directory: ${resolve(CWD, output)}`);
|
|
294
|
+
}
|
|
290
295
|
logger.info("Generating API modules...");
|
|
291
296
|
if (ts2) {
|
|
292
297
|
await generateTypes(schema, output, typesFilename, openapiTsOptions);
|
package/dist/cli.cjs
CHANGED
|
@@ -407,6 +407,7 @@ async function generate(userOptions = {}) {
|
|
|
407
407
|
input = "./schema.json",
|
|
408
408
|
output = "./src/apis/generated",
|
|
409
409
|
typesFilename = "_types.ts",
|
|
410
|
+
clean = false,
|
|
410
411
|
validateStatus = (status) => status >= 200 && status < 300,
|
|
411
412
|
transformer = {},
|
|
412
413
|
uncountableNouns = [],
|
|
@@ -414,6 +415,10 @@ async function generate(userOptions = {}) {
|
|
|
414
415
|
} = options;
|
|
415
416
|
const mergedTransformer = { ...createTransformer(), ...transformer };
|
|
416
417
|
const schema = await readSchema(input);
|
|
418
|
+
if (clean) {
|
|
419
|
+
import_fs_extra2.default.removeSync((0, import_path3.resolve)(CWD, output));
|
|
420
|
+
import_rslog2.logger.info(`Cleaned output directory: ${(0, import_path3.resolve)(CWD, output)}`);
|
|
421
|
+
}
|
|
417
422
|
import_rslog2.logger.info("Generating API modules...");
|
|
418
423
|
if (ts2) {
|
|
419
424
|
await generateTypes(schema, output, typesFilename, openapiTsOptions);
|
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import { Command } from "commander";
|
|
|
8
8
|
var program = new Command();
|
|
9
9
|
program.version(getCliVersion());
|
|
10
10
|
program.action(async () => {
|
|
11
|
-
const { generate } = await import("./generate-
|
|
11
|
+
const { generate } = await import("./generate-K6NGTXOH.js");
|
|
12
12
|
return generate();
|
|
13
13
|
});
|
|
14
14
|
program.parse();
|
package/dist/index.cjs
CHANGED
|
@@ -448,6 +448,7 @@ async function generate(userOptions = {}) {
|
|
|
448
448
|
input = "./schema.json",
|
|
449
449
|
output = "./src/apis/generated",
|
|
450
450
|
typesFilename = "_types.ts",
|
|
451
|
+
clean = false,
|
|
451
452
|
validateStatus = (status) => status >= 200 && status < 300,
|
|
452
453
|
transformer = {},
|
|
453
454
|
uncountableNouns = [],
|
|
@@ -455,6 +456,10 @@ async function generate(userOptions = {}) {
|
|
|
455
456
|
} = options;
|
|
456
457
|
const mergedTransformer = { ...createTransformer(), ...transformer };
|
|
457
458
|
const schema = await readSchema(input);
|
|
459
|
+
if (clean) {
|
|
460
|
+
import_fs_extra2.default.removeSync((0, import_path3.resolve)(CWD, output));
|
|
461
|
+
import_rslog2.logger.info(`Cleaned output directory: ${(0, import_path3.resolve)(CWD, output)}`);
|
|
462
|
+
}
|
|
458
463
|
import_rslog2.logger.info("Generating API modules...");
|
|
459
464
|
if (ts2) {
|
|
460
465
|
await generateTypes(schema, output, typesFilename, openapiTsOptions);
|
package/dist/index.d.cts
CHANGED
|
@@ -285,6 +285,11 @@ interface GenerateOptions {
|
|
|
285
285
|
* Certain uncountable nouns that do not change from singular to plural
|
|
286
286
|
*/
|
|
287
287
|
uncountableNouns?: string[];
|
|
288
|
+
/**
|
|
289
|
+
* Whether to clean the output directory before generating.
|
|
290
|
+
* @default false
|
|
291
|
+
*/
|
|
292
|
+
clean?: boolean;
|
|
288
293
|
/**
|
|
289
294
|
* A function to transform the generated types AST before printing to string.
|
|
290
295
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -285,6 +285,11 @@ interface GenerateOptions {
|
|
|
285
285
|
* Certain uncountable nouns that do not change from singular to plural
|
|
286
286
|
*/
|
|
287
287
|
uncountableNouns?: string[];
|
|
288
|
+
/**
|
|
289
|
+
* Whether to clean the output directory before generating.
|
|
290
|
+
* @default false
|
|
291
|
+
*/
|
|
292
|
+
clean?: boolean;
|
|
288
293
|
/**
|
|
289
294
|
* A function to transform the generated types AST before printing to string.
|
|
290
295
|
*/
|
package/dist/index.js
CHANGED