swagger-typescript-api 11.0.0--beta-4 → 11.0.0--beta-5

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.
@@ -129,7 +129,6 @@ ${outputTest}`);
129
129
  };
130
130
 
131
131
  const displayHelp = (commands, instance, command) => {
132
- const rootCommand = commands[root_command];
133
132
  if (command.name === root_command) return displayAllHelp(commands, instance);
134
133
 
135
134
  const { options, maxLength: maxOptionLength } = generateOptionsOutput(command.options);
package/index.js CHANGED
@@ -230,6 +230,11 @@ program.addCommand({
230
230
  description: "clean output folder before generate template. WARNING: May cause data loss",
231
231
  default: templateGenBaseConfig.cleanOutput,
232
232
  },
233
+ {
234
+ flags: "-r, --rewrite",
235
+ description: "rewrite content in existing templates",
236
+ default: templateGenBaseConfig.rewrite,
237
+ },
233
238
  {
234
239
  flags: "--silent",
235
240
  description: "Output only errors to console",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swagger-typescript-api",
3
- "version": "11.0.0--beta-4",
3
+ "version": "11.0.0--beta-5",
4
4
  "description": "Generate typescript/javascript api from swagger schema",
5
5
  "scripts": {
6
6
  "cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts",
@@ -11,6 +11,7 @@ class TemplatesGenConfig {
11
11
  modular = false;
12
12
  silent = false;
13
13
  version = PROJECT_VERSION;
14
+ rewrite = false;
14
15
 
15
16
  /**
16
17
  * @param config {GenerateTemplatesParams}
@@ -39,9 +39,12 @@ class TemplatesGenProcess {
39
39
  * @return {Promise<GenerateTemplatesOutput>}
40
40
  */
41
41
  async start() {
42
+ this.logger.event('start generating source templates ".ejs" for code generator');
43
+
42
44
  const templates = this.getTemplates();
43
45
 
44
46
  if (this.config.output) {
47
+ this.logger.log("preparing output directory for source templates");
45
48
  const outputPath = path.resolve(process.cwd(), this.config.output);
46
49
 
47
50
  if (this.fileSystem.pathIsExist(outputPath)) {
@@ -53,13 +56,16 @@ class TemplatesGenProcess {
53
56
  }
54
57
 
55
58
  templates.forEach((template) => {
56
- this.fileSystem.createFile({
57
- path: outputPath,
58
- fileName: template.name,
59
- content: template.content,
60
- withPrefix: false,
61
- });
59
+ if (!this.fileSystem.pathIsExist(resolve(outputPath, template.name)) || this.config.rewrite) {
60
+ this.fileSystem.createFile({
61
+ path: outputPath,
62
+ fileName: template.name,
63
+ content: template.content,
64
+ withPrefix: false,
65
+ });
66
+ }
62
67
  });
68
+ this.logger.event(`source templates has been successfully created in "${outputPath}"`);
63
69
  }
64
70
 
65
71
  return {
@@ -107,14 +113,17 @@ class TemplatesGenProcess {
107
113
  };
108
114
 
109
115
  fixTemplateContent = (content) => {
116
+ // includeFile("@base/
110
117
  const importsRegExp1 = new RegExp(
111
118
  `includeFile\\\("(${this.importTemplatePrefixes.map((v) => `(${v})`).join("|")})\/`,
112
119
  "g",
113
120
  );
121
+ // includeFile(`@base/
114
122
  const importsRegExp2 = new RegExp(
115
123
  `includeFile\\\(\`(${this.importTemplatePrefixes.map((v) => `(${v})`).join("|")})\/`,
116
124
  "g",
117
125
  );
126
+ // includeFile('@base/
118
127
  const importsRegExp3 = new RegExp(
119
128
  `includeFile\\\(\'(${this.importTemplatePrefixes.map((v) => `(${v})`).join("|")})\/`,
120
129
  "g",