@povio/openapi-codegen-cli 2.0.8-rc.30 → 2.0.8-rc.32

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.
@@ -1,4 +1,4 @@
1
- import { t as GenerateOptions } from "./options-DmeJPSRO.mjs";
1
+ import { t as GenerateOptions } from "./options-D9TC-n26.mjs";
2
2
 
3
3
  //#region src/generators/types/config.d.ts
4
4
  type OpenAPICodegenConfig = Partial<GenerateOptions>;
@@ -1,4 +1,4 @@
1
- import { a as deepMerge, p as DEFAULT_GENERATE_OPTIONS, r as writeGenerateFileData, t as generateCodeFromOpenAPIDoc, x as Profiler } from "./generateCodeFromOpenAPIDoc-CesDBC83.mjs";
1
+ import { a as deepMerge, p as DEFAULT_GENERATE_OPTIONS, r as writeGenerateFileData, t as generateCodeFromOpenAPIDoc, x as Profiler } from "./generateCodeFromOpenAPIDoc-DkNqNy-S.mjs";
2
2
  import fs from "fs";
3
3
  import path from "path";
4
4
  import SwaggerParser from "@apidevtools/swagger-parser";
@@ -17,40 +17,26 @@ function resolveConfig({ fileConfig = {}, params: { includeTags, excludeTags, in
17
17
 
18
18
  //#endregion
19
19
  //#region src/generators/run/generate.runner.ts
20
- const CACHE_FILE_NAME = ".openapi-codegen-cache.json";
21
20
  async function runGenerate({ fileConfig, params, formatGeneratedFile, profiler = new Profiler(process.env.OPENAPI_CODEGEN_PROFILE === "1") }) {
22
21
  const config = profiler.runSync("config.resolve", () => resolveConfig({
23
22
  fileConfig,
24
23
  params: params ?? {}
25
24
  }));
26
25
  const openApiDoc = await getOpenApiDoc(config.input, profiler);
27
- const openApiHash = hashString(stableStringify(openApiDoc));
28
- const optionsHash = hashString(stableStringify(getCacheableConfig(config)));
29
- const cacheFilePath = path.resolve(config.output, CACHE_FILE_NAME);
30
- if (config.incremental) {
31
- const cached = readCache(cacheFilePath);
32
- if (cached && cached.openApiHash === openApiHash && cached.optionsHash === optionsHash) return {
33
- skipped: true,
34
- config,
35
- stats: {
36
- generatedFilesCount: 0,
37
- generatedModulesCount: 0
38
- }
39
- };
40
- }
41
26
  const filesData = profiler.runSync("generate.total", () => generateCodeFromOpenAPIDoc(openApiDoc, config, profiler));
27
+ if (config.clearOutput) profiler.runSync("files.clearOutput", () => {
28
+ fs.rmSync(config.output, {
29
+ force: true,
30
+ recursive: true
31
+ });
32
+ });
42
33
  await profiler.runAsync("files.write", async () => {
43
34
  await writeGenerateFileData(filesData, { formatGeneratedFile });
44
35
  });
45
- const stats = getGenerateStats(filesData, config);
46
- if (config.incremental) await writeCache(cacheFilePath, {
47
- openApiHash,
48
- optionsHash
49
- }, formatGeneratedFile);
50
36
  return {
51
37
  skipped: false,
52
38
  config,
53
- stats
39
+ stats: getGenerateStats(filesData, config)
54
40
  };
55
41
  }
56
42
  async function getOpenApiDoc(input, profiler) {
@@ -71,38 +57,6 @@ function hasExternalRef(value) {
71
57
  }
72
58
  return false;
73
59
  }
74
- function getCacheableConfig(config) {
75
- const { output, incremental, ...cacheableConfig } = config;
76
- return cacheableConfig;
77
- }
78
- function readCache(filePath) {
79
- if (!fs.existsSync(filePath)) return null;
80
- try {
81
- return JSON.parse(fs.readFileSync(filePath, "utf-8"));
82
- } catch {
83
- return null;
84
- }
85
- }
86
- async function writeCache(filePath, data, formatGeneratedFile) {
87
- await writeGenerateFileData([{
88
- fileName: filePath,
89
- content: JSON.stringify(data)
90
- }], { formatGeneratedFile });
91
- }
92
- function hashString(input) {
93
- let hash = 2166136261;
94
- for (let i = 0; i < input.length; i += 1) {
95
- hash ^= input.charCodeAt(i);
96
- hash = Math.imul(hash, 16777619);
97
- }
98
- return (hash >>> 0).toString(16);
99
- }
100
- function stableStringify(input) {
101
- if (input === null || typeof input !== "object") return JSON.stringify(input);
102
- if (Array.isArray(input)) return `[${input.map((item) => stableStringify(item)).join(",")}]`;
103
- const obj = input;
104
- return `{${Object.keys(obj).sort((a, b) => a.localeCompare(b)).map((key) => `${JSON.stringify(key)}:${stableStringify(obj[key])}`).join(",")}}`;
105
- }
106
60
  function getGenerateStats(filesData, config) {
107
61
  const generatedFilesCount = filesData.length;
108
62
  if (generatedFilesCount === 0) return {
@@ -594,6 +594,7 @@ const CASL_ABILITY_IMPORT = {
594
594
  const DEFAULT_GENERATE_OPTIONS = {
595
595
  input: "http://localhost:4000/docs-json/",
596
596
  output: "output",
597
+ clearOutput: false,
597
598
  incremental: true,
598
599
  splitByTags: true,
599
600
  defaultTag: "Common",
@@ -1,4 +1,4 @@
1
- import { n as GenerateFileData, t as GenerateOptions } from "./options-DmeJPSRO.mjs";
1
+ import { n as GenerateFileData, t as GenerateOptions } from "./options-D9TC-n26.mjs";
2
2
  import { OpenAPIV3 } from "openapi-types";
3
3
 
4
4
  //#region src/generators/types/metadata.d.ts
@@ -1,4 +1,4 @@
1
- import { _ as isMediaTypeAllowed, b as formatTag, c as getSchemaTsMetaType, d as getTagImportPath, f as getQueryName, h as GenerateType, i as getDataFromOpenAPIDoc, l as getTsTypeBase, m as getNamespaceName, o as isMutation, p as DEFAULT_GENERATE_OPTIONS, s as isQuery, t as generateCodeFromOpenAPIDoc, v as isParamMediaTypeAllowed, y as invalidVariableNameCharactersToCamel } from "./generateCodeFromOpenAPIDoc-CesDBC83.mjs";
1
+ import { _ as isMediaTypeAllowed, b as formatTag, c as getSchemaTsMetaType, d as getTagImportPath, f as getQueryName, h as GenerateType, i as getDataFromOpenAPIDoc, l as getTsTypeBase, m as getNamespaceName, o as isMutation, p as DEFAULT_GENERATE_OPTIONS, s as isQuery, t as generateCodeFromOpenAPIDoc, v as isParamMediaTypeAllowed, y as invalidVariableNameCharactersToCamel } from "./generateCodeFromOpenAPIDoc-DkNqNy-S.mjs";
2
2
  import SwaggerParser from "@apidevtools/swagger-parser";
3
3
 
4
4
  //#region src/generators/core/getMetadataFromOpenAPIDoc.ts
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as GeneralErrorCodes, i as ErrorHandlerOptions, n as ErrorEntry, o as SharedErrorHandler, r as ErrorHandler, t as ApplicationException } from "./error-handling-CXeVTk1T.mjs";
2
- import "./options-DmeJPSRO.mjs";
3
- import { t as OpenAPICodegenConfig } from "./config-BRQts1Ob.mjs";
2
+ import "./options-D9TC-n26.mjs";
3
+ import { t as OpenAPICodegenConfig } from "./config-KffSntOs.mjs";
4
4
  import { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosResponseHeaders, CreateAxiosDefaults } from "axios";
5
5
  import { z } from "zod";
6
6
  import "i18next";
@@ -73,6 +73,7 @@ interface GenerateConfig {
73
73
  interface BaseGenerateOptions {
74
74
  input: string;
75
75
  output: string;
76
+ clearOutput?: boolean;
76
77
  incremental?: boolean;
77
78
  splitByTags: boolean;
78
79
  defaultTag: string;
package/dist/sh.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { S as VALIDATION_ERROR_TYPE_TITLE, g as groupByType, h as GenerateType, i as getDataFromOpenAPIDoc, n as getOutputFileName, u as getTagFileName, x as Profiler } from "./generateCodeFromOpenAPIDoc-CesDBC83.mjs";
3
- import { n as resolveConfig, t as runGenerate } from "./generate.runner-CY2Topy5.mjs";
2
+ import { S as VALIDATION_ERROR_TYPE_TITLE, g as groupByType, h as GenerateType, i as getDataFromOpenAPIDoc, n as getOutputFileName, u as getTagFileName, x as Profiler } from "./generateCodeFromOpenAPIDoc-DkNqNy-S.mjs";
3
+ import { n as resolveConfig, t as runGenerate } from "./generate.runner-CMi5XAiu.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  import yargs from "yargs";
6
6
  import { hideBin } from "yargs/helpers";
@@ -39,7 +39,7 @@ function logBanner(message) {
39
39
  * Fetch the version from package.json
40
40
  */
41
41
  function getVersion() {
42
- return "2.0.8-rc.30";
42
+ return "2.0.8-rc.32";
43
43
  }
44
44
 
45
45
  //#endregion
@@ -300,6 +300,7 @@ var GenerateOptions = class {
300
300
  config;
301
301
  input;
302
302
  output;
303
+ clearOutput;
303
304
  incremental;
304
305
  tsNamespaces;
305
306
  tsPath;
@@ -332,6 +333,10 @@ var GenerateOptions = class {
332
333
  __decorate([YargOption({ envAlias: "config" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "config", void 0);
333
334
  __decorate([YargOption({ envAlias: "input" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "input", void 0);
334
335
  __decorate([YargOption({ envAlias: "output" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "output", void 0);
336
+ __decorate([YargOption({
337
+ envAlias: "clearOutput",
338
+ type: "boolean"
339
+ }), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "clearOutput", void 0);
335
340
  __decorate([YargOption({
336
341
  envAlias: "incremental",
337
342
  type: "boolean"
package/dist/vite.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { r as GenerateFileFormatter } from "./options-DmeJPSRO.mjs";
2
- import { t as OpenAPICodegenConfig } from "./config-BRQts1Ob.mjs";
1
+ import { r as GenerateFileFormatter } from "./options-D9TC-n26.mjs";
2
+ import { t as OpenAPICodegenConfig } from "./config-KffSntOs.mjs";
3
3
  import { Plugin } from "vite";
4
4
 
5
5
  //#region src/vite/openapi-codegen.plugin.d.ts
package/dist/vite.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { x as Profiler } from "./generateCodeFromOpenAPIDoc-CesDBC83.mjs";
2
- import { t as runGenerate } from "./generate.runner-CY2Topy5.mjs";
1
+ import { x as Profiler } from "./generateCodeFromOpenAPIDoc-DkNqNy-S.mjs";
2
+ import { t as runGenerate } from "./generate.runner-CMi5XAiu.mjs";
3
3
  import path from "path";
4
4
 
5
5
  //#region src/vite/openapi-codegen.plugin.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/openapi-codegen-cli",
3
- "version": "2.0.8-rc.30",
3
+ "version": "2.0.8-rc.32",
4
4
  "keywords": [
5
5
  "codegen",
6
6
  "openapi",