@@ -39,6 +39,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
39
39
public static final String SNAPSHOT = "snapshot" ;
40
40
public static final String WITH_INTERFACES = "withInterfaces" ;
41
41
public static final String NG_VERSION = "ngVersion" ;
42
+ public static final String NG_PACKAGR = "useNgPackagr" ;
42
43
43
44
protected String npmName = null ;
44
45
protected String npmVersion = "1.0.0" ;
@@ -102,19 +103,9 @@ public void processOpts() {
102
103
supportingFiles .add (new SupportingFile ("variables.mustache" , getIndexDirectory (), "variables.ts" ));
103
104
supportingFiles .add (new SupportingFile ("encoder.mustache" , getIndexDirectory (), "encoder.ts" ));
104
105
supportingFiles .add (new SupportingFile ("gitignore" , "" , ".gitignore" ));
106
+ supportingFiles .add (new SupportingFile ("npmignore" , "" , ".npmignore" ));
105
107
supportingFiles .add (new SupportingFile ("git_push.sh.mustache" , "" , "git_push.sh" ));
106
108
107
- if (additionalProperties .containsKey (NPM_NAME )) {
108
- addNpmPackageGeneration ();
109
- }
110
-
111
- if (additionalProperties .containsKey (WITH_INTERFACES )) {
112
- boolean withInterfaces = Boolean .parseBoolean (additionalProperties .get (WITH_INTERFACES ).toString ());
113
- if (withInterfaces ) {
114
- apiTemplateFiles .put ("apiInterface.mustache" , "Interface.ts" );
115
- }
116
- }
117
-
118
109
// determine NG version
119
110
SemVer ngVersion ;
120
111
if (additionalProperties .containsKey (NG_VERSION )) {
@@ -125,13 +116,27 @@ public void processOpts() {
125
116
LOGGER .info (" (you can select the angular version by setting the additionalProperty ngVersion)" );
126
117
}
127
118
additionalProperties .put (NG_VERSION , ngVersion );
119
+ additionalProperties .put (NG_PACKAGR , ngVersion .atLeast ("8.0.0" ));
128
120
additionalProperties .put ("useRxJS6" , ngVersion .atLeast ("6.0.0" ));
129
121
additionalProperties .put ("injectionToken" , ngVersion .atLeast ("4.0.0" ) ? "InjectionToken" : "OpaqueToken" );
130
122
additionalProperties .put ("injectionTokenTyped" , ngVersion .atLeast ("4.0.0" ));
131
123
additionalProperties .put ("useHttpClient" , ngVersion .atLeast ("4.3.0" ));
124
+ additionalProperties .put ("useHttpClientPackage" , ngVersion .atLeast ("4.3.0" ) && !ngVersion .atLeast ("8.0.0" ));
132
125
if (!ngVersion .atLeast ("4.3.0" )) {
133
126
supportingFiles .add (new SupportingFile ("rxjs-operators.mustache" , getIndexDirectory (), "rxjs-operators.ts" ));
134
127
}
128
+
129
+ if (additionalProperties .containsKey (NPM_NAME )) {
130
+ addNpmPackageGeneration ();
131
+ }
132
+
133
+ if (additionalProperties .containsKey (WITH_INTERFACES )) {
134
+ boolean withInterfaces = Boolean .parseBoolean (additionalProperties .get (WITH_INTERFACES ).toString ());
135
+ if (withInterfaces ) {
136
+ apiTemplateFiles .put ("apiInterface.mustache" , "Interface.ts" );
137
+ }
138
+ }
139
+
135
140
}
136
141
137
142
private void addNpmPackageGeneration () {
@@ -158,6 +163,10 @@ private void addNpmPackageGeneration() {
158
163
supportingFiles .add (new SupportingFile ("package.mustache" , getIndexDirectory (), "package.json" ));
159
164
supportingFiles .add (new SupportingFile ("typings.mustache" , getIndexDirectory (), "typings.json" ));
160
165
supportingFiles .add (new SupportingFile ("tsconfig.mustache" , getIndexDirectory (), "tsconfig.json" ));
166
+ if (additionalProperties .containsKey (NG_PACKAGR )
167
+ && Boolean .valueOf (additionalProperties .get (NG_PACKAGR ).toString ())) {
168
+ supportingFiles .add (new SupportingFile ("ng-package.mustache" , getIndexDirectory (), "ng-package.json" ));
169
+ }
161
170
}
162
171
163
172
private String getIndexDirectory () {
0 commit comments