@@ -45,10 +45,12 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
45
45
public static final String NG_VERSION = "ngVersion" ;
46
46
public static final String NG_PACKAGR = "useNgPackagr" ;
47
47
public static final String PROVIDED_IN_ROOT ="providedInRoot" ;
48
+ public static final String KEBAB_FILE_NAME ="kebab-file-name" ;
48
49
49
50
protected String npmName = null ;
50
51
protected String npmVersion = "1.0.0" ;
51
52
protected String npmRepository = null ;
53
+ protected boolean kebabFileNaming ;
52
54
53
55
public TypeScriptAngularClientCodegen () {
54
56
super ();
@@ -121,20 +123,6 @@ public void processOpts() {
121
123
additionalProperties .put (NG_PACKAGR , true );
122
124
}
123
125
124
- // Set the typescript version compatible to the Angular version
125
- if (ngVersion .atLeast ("8.0.0" )) {
126
- additionalProperties .put ("tsVersion" , ">=3.4.0 <3.6.0" );
127
- } else if (ngVersion .atLeast ("7.0.0" )) {
128
- additionalProperties .put ("tsVersion" , ">=3.1.1 <3.2.0" );
129
- } else if (ngVersion .atLeast ("6.0.0" )) {
130
- additionalProperties .put ("tsVersion" , ">=2.7.2 and <2.10.0" );
131
- } else if (ngVersion .atLeast ("5.0.0" )) {
132
- additionalProperties .put ("tsVersion" , ">=2.1.5 <2.7.0" );
133
- } else {
134
- // Angular v2-v4 requires typescript ">=2.1.5 <2.8"
135
- additionalProperties .put ("tsVersion" , ">=2.1.5 <2.8.0" );
136
- }
137
-
138
126
// Set the rxJS version compatible to the Angular version
139
127
if (ngVersion .atLeast ("8.0.0" )) {
140
128
additionalProperties .put ("rxjsVersion" , "6.5.0" );
@@ -153,6 +141,11 @@ public void processOpts() {
153
141
supportingFiles .add (new SupportingFile ("rxjs-operators.mustache" , getIndexDirectory (), "rxjs-operators.ts" ));
154
142
}
155
143
144
+ // Version after Angular 10 require ModuleWithProviders to be generic. Compatible from version 7.
145
+ if (ngVersion .atLeast ("7.0.0" )) {
146
+ additionalProperties .put ("genericModuleWithProviders" , true );
147
+ }
148
+
156
149
// for Angular 2 AOT support we will use good-old ngc,
157
150
// Angular Package format wasn't invented at this time and building was much more easier
158
151
if (!ngVersion .atLeast ("4.0.0" )) {
@@ -167,50 +160,6 @@ public void processOpts() {
167
160
// Libraries generated with v2.x of ng-packagr will ship with AoT metadata in v4, which is intended for Angular v5 (and Angular v6).
168
161
additionalProperties .put ("useOldNgPackagr" , !ngVersion .atLeast ("5.0.0" ));
169
162
170
- // Specific ng-packagr configuration
171
- if (ngVersion .atLeast ("8.0.0" )) {
172
- additionalProperties .put ("ngPackagrVersion" , "5.4.0" );
173
- additionalProperties .put ("tsickleVersion" , "0.35.0" );
174
- } else if (ngVersion .atLeast ("7.0.0" )) {
175
- // compatible versions with typescript version
176
- additionalProperties .put ("ngPackagrVersion" , "5.1.0" );
177
- additionalProperties .put ("tsickleVersion" , "0.34.0" );
178
- } else if (ngVersion .atLeast ("6.0.0" )) {
179
- // compatible versions with typescript version
180
- additionalProperties .put ("ngPackagrVersion" , "3.0.6" );
181
- additionalProperties .put ("tsickleVersion" , "0.32.1" );
182
- } else if (ngVersion .atLeast ("5.0.0" )) {
183
- // compatible versions with typescript version
184
- additionalProperties .put ("ngPackagrVersion" , "2.4.5" );
185
- additionalProperties .put ("tsickleVersion" , "0.27.5" );
186
- } else {
187
- // Angular versions prior to v5
188
- additionalProperties .put ("ngPackagrVersion" , "1.6.0" );
189
- }
190
-
191
- // set zone.js version
192
- if (ngVersion .atLeast ("8.0.0" )) {
193
- additionalProperties .put ("zonejsVersion" , "0.9.1" );
194
- } else if (ngVersion .atLeast ("5.0.0" )) {
195
- // compatible versions to Angular 5+
196
- additionalProperties .put ("zonejsVersion" , "0.8.26" );
197
- } else {
198
- // Angular versions prior to v5
199
- additionalProperties .put ("zonejsVersion" , "0.7.6" );
200
- }
201
-
202
- // set http client usage
203
- if (ngVersion .atLeast ("8.0.0" )) {
204
- additionalProperties .put ("useHttpClient" , true );
205
- additionalProperties .put ("useHttpClientPackage" , false );
206
- } else if (ngVersion .atLeast ("4.3.0" )) {
207
- additionalProperties .put ("useHttpClient" , true );
208
- additionalProperties .put ("useHttpClientPackage" , true );
209
- } else {
210
- additionalProperties .put ("useHttpClient" , false );
211
- additionalProperties .put ("useHttpClientPackage" , false );
212
- }
213
-
214
163
if (additionalProperties .containsKey (PROVIDED_IN_ROOT ) && !ngVersion .atLeast ("6.0.0" )) {
215
164
additionalProperties .put (PROVIDED_IN_ROOT ,false );
216
165
}
@@ -219,7 +168,7 @@ public void processOpts() {
219
168
additionalProperties .put ("injectionTokenTyped" , ngVersion .atLeast ("4.0.0" ));
220
169
221
170
if (additionalProperties .containsKey (NPM_NAME )) {
222
- addNpmPackageGeneration ();
171
+ addNpmPackageGeneration (ngVersion );
223
172
}
224
173
225
174
if (additionalProperties .containsKey (WITH_INTERFACES )) {
@@ -229,6 +178,8 @@ public void processOpts() {
229
178
}
230
179
}
231
180
181
+ kebabFileNaming = Boolean .parseBoolean (String .valueOf (additionalProperties .get (KEBAB_FILE_NAME )));
182
+
232
183
}
233
184
234
185
private SemVer determineNgVersion () {
@@ -243,7 +194,7 @@ private SemVer determineNgVersion() {
243
194
return ngVersion ;
244
195
}
245
196
246
- private void addNpmPackageGeneration () {
197
+ private void addNpmPackageGeneration (SemVer ngVersion ) {
247
198
if (additionalProperties .containsKey (NPM_NAME )) {
248
199
this .setNpmName (additionalProperties .get (NPM_NAME ).toString ());
249
200
}
@@ -262,6 +213,60 @@ private void addNpmPackageGeneration() {
262
213
this .setNpmRepository (additionalProperties .get (NPM_REPOSITORY ).toString ());
263
214
}
264
215
216
+ additionalProperties .put ("useRxJS6" , true );
217
+ additionalProperties .put ("useHttpClient" , true );
218
+ additionalProperties .put ("useHttpClientPackage" , false );
219
+ if (ngVersion .atLeast ("11.0.0" )) {
220
+ additionalProperties .put ("tsVersion" , ">=4.0.0 <4.1.0" );
221
+ additionalProperties .put ("rxjsVersion" , "6.6.0" );
222
+ additionalProperties .put ("ngPackagrVersion" , "11.0.2" );
223
+ additionalProperties .put ("tsickleVersion" , "0.39.1" );
224
+ additionalProperties .put ("zonejsVersion" , "0.11.3" );
225
+ } else if (ngVersion .atLeast ("10.0.0" )) {
226
+ additionalProperties .put ("tsVersion" , ">=3.9.2 <4.0.0" );
227
+ additionalProperties .put ("rxjsVersion" , "6.6.0" );
228
+ additionalProperties .put ("ngPackagrVersion" , "10.0.3" );
229
+ additionalProperties .put ("tsickleVersion" , "0.39.1" );
230
+ additionalProperties .put ("zonejsVersion" , "0.10.2" );
231
+ } else if (ngVersion .atLeast ("9.0.0" )) {
232
+ additionalProperties .put ("tsVersion" , ">=3.6.0 <3.8.0" );
233
+ additionalProperties .put ("rxjsVersion" , "6.5.3" );
234
+ additionalProperties .put ("ngPackagrVersion" , "9.0.1" );
235
+ additionalProperties .put ("tsickleVersion" , "0.38.0" );
236
+ additionalProperties .put ("zonejsVersion" , "0.10.2" );
237
+ } else if (ngVersion .atLeast ("8.0.0" )) {
238
+ additionalProperties .put ("tsVersion" , ">=3.4.0 <3.6.0" );
239
+ additionalProperties .put ("rxjsVersion" , "6.5.0" );
240
+ additionalProperties .put ("ngPackagrVersion" , "5.4.0" );
241
+ additionalProperties .put ("tsickleVersion" , "0.35.0" );
242
+ additionalProperties .put ("zonejsVersion" , "0.9.1" );
243
+ } else if (ngVersion .atLeast ("7.0.0" )) {
244
+ additionalProperties .put ("tsVersion" , ">=3.1.1 <3.2.0" );
245
+ additionalProperties .put ("rxjsVersion" , "6.3.0" );
246
+ additionalProperties .put ("ngPackagrVersion" , "5.1.0" );
247
+ additionalProperties .put ("tsickleVersion" , "0.34.0" );
248
+ additionalProperties .put ("zonejsVersion" , "0.8.26" );
249
+
250
+ additionalProperties .put ("useHttpClientPackage" , true );
251
+ } else if (ngVersion .atLeast ("6.0.0" )) {
252
+ additionalProperties .put ("tsVersion" , ">=2.7.2 and <2.10.0" );
253
+ additionalProperties .put ("rxjsVersion" , "6.1.0" );
254
+ additionalProperties .put ("ngPackagrVersion" , "3.0.6" );
255
+ additionalProperties .put ("tsickleVersion" , "0.32.1" );
256
+ additionalProperties .put ("zonejsVersion" , "0.8.26" );
257
+
258
+ additionalProperties .put ("useHttpClientPackage" , true );
259
+ } else {
260
+ additionalProperties .put ("tsVersion" , ">=2.1.5 and <2.8" );
261
+ additionalProperties .put ("rxjsVersion" , "6.1.0" );
262
+ additionalProperties .put ("ngPackagrVersion" , "3.0.6" );
263
+ additionalProperties .put ("tsickleVersion" , "0.32.1" );
264
+ additionalProperties .put ("zonejsVersion" , "0.8.26" );
265
+
266
+ additionalProperties .put ("useRxJS6" , false );
267
+ additionalProperties .put ("useHttpClientPackage" , true );
268
+ }
269
+
265
270
//Files for building our lib
266
271
supportingFiles .add (new SupportingFile ("README.mustache" , getIndexDirectory (), "README.md" ));
267
272
supportingFiles .add (new SupportingFile ("package.mustache" , getIndexDirectory (), "package.json" ));
@@ -496,6 +501,9 @@ public String toApiFilename(String name) {
496
501
if (name .length () == 0 ) {
497
502
return "default.service" ;
498
503
}
504
+ if (kebabFileNaming ) {
505
+ return dashize (name );
506
+ }
499
507
return camelize (name , true ) + ".service" ;
500
508
}
501
509
@@ -506,6 +514,9 @@ public String toApiImport(String name) {
506
514
507
515
@ Override
508
516
public String toModelFilename (String name ) {
517
+ if (kebabFileNaming ) {
518
+ return dashize (name );
519
+ }
509
520
return camelize (toModelName (name ), true );
510
521
}
511
522
0 commit comments