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 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-WIU5E7EL.js");
11
+ const { generate } = await import("./generate-K6NGTXOH.js");
12
12
  return generate();
13
13
  });
14
14
  program.parse();
@@ -4,7 +4,7 @@ import {
4
4
  partitionApiModules,
5
5
  renderApiModules,
6
6
  transformPayloads
7
- } from "./chunk-P3SVS555.js";
7
+ } from "./chunk-FOIQWD3Q.js";
8
8
  import "./chunk-2227C45C.js";
9
9
  export {
10
10
  generate,
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
@@ -21,7 +21,7 @@ import {
21
21
  transformTypeValue,
22
22
  transformUrl,
23
23
  transformVerb
24
- } from "./chunk-P3SVS555.js";
24
+ } from "./chunk-FOIQWD3Q.js";
25
25
  import {
26
26
  createStatusCodesByStrategy,
27
27
  findObjectKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-farmer",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "API module generation tool based on Openapi3/Swagger2.",
5
5
  "keywords": [
6
6
  "cli",