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

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-6",
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,17 @@ 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
+ const templateExist = this.fileSystem.pathIsExist(path.resolve(outputPath, template.name));
60
+ if (!templateExist || this.config.rewrite) {
61
+ this.fileSystem.createFile({
62
+ path: outputPath,
63
+ fileName: template.name,
64
+ content: template.content,
65
+ withPrefix: false,
66
+ });
67
+ }
62
68
  });
69
+ this.logger.event(`source templates has been successfully created in "${outputPath}"`);
63
70
  }
64
71
 
65
72
  return {
@@ -107,14 +114,17 @@ class TemplatesGenProcess {
107
114
  };
108
115
 
109
116
  fixTemplateContent = (content) => {
117
+ // includeFile("@base/
110
118
  const importsRegExp1 = new RegExp(
111
119
  `includeFile\\\("(${this.importTemplatePrefixes.map((v) => `(${v})`).join("|")})\/`,
112
120
  "g",
113
121
  );
122
+ // includeFile(`@base/
114
123
  const importsRegExp2 = new RegExp(
115
124
  `includeFile\\\(\`(${this.importTemplatePrefixes.map((v) => `(${v})`).join("|")})\/`,
116
125
  "g",
117
126
  );
127
+ // includeFile('@base/
118
128
  const importsRegExp3 = new RegExp(
119
129
  `includeFile\\\(\'(${this.importTemplatePrefixes.map((v) => `(${v})`).join("|")})\/`,
120
130
  "g",