@@ -5,6 +5,7 @@ import { parseJson } from "./common/helpers";
5
5
import { EOL } from "os" ;
6
6
import { cache } from "./common/decorators" ;
7
7
import {
8
+ BundlerType ,
8
9
INsConfig ,
9
10
IProjectConfigService ,
10
11
IProjectData ,
@@ -99,6 +100,8 @@ export class ProjectData implements IProjectData {
99
100
public podfilePath : string ;
100
101
public isShared : boolean ;
101
102
public webpackConfigPath : string ;
103
+ public bundlerConfigPath : string ;
104
+ public bundler : BundlerType ;
102
105
public initialized : boolean ;
103
106
104
107
constructor (
@@ -110,7 +113,7 @@ export class ProjectData implements IProjectData {
110
113
private $logger : ILogger ,
111
114
private $injector : IInjector ,
112
115
private $androidResourcesMigrationService : IAndroidResourcesMigrationService ,
113
- private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants
116
+ private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
114
117
) { }
115
118
116
119
get projectConfig ( ) : IProjectConfigService {
@@ -142,7 +145,7 @@ export class ProjectData implements IProjectData {
142
145
143
146
public initializeProjectDataFromContent (
144
147
packageJsonContent : string ,
145
- projectDir ?: string
148
+ projectDir ?: string ,
146
149
) : void {
147
150
projectDir = projectDir || this . $projectHelper . projectDir || "" ;
148
151
this . projectDir = projectDir ;
@@ -157,7 +160,7 @@ export class ProjectData implements IProjectData {
157
160
this . $errors . fail (
158
161
`The project file ${ this . projectFilePath } is corrupted. ${ EOL } ` +
159
162
`Consider restoring an earlier version from your source control or backup.${ EOL } ` +
160
- `Additional technical info: ${ err . toString ( ) } `
163
+ `Additional technical info: ${ err . toString ( ) } ` ,
161
164
) ;
162
165
}
163
166
@@ -178,36 +181,43 @@ export class ProjectData implements IProjectData {
178
181
this . appDirectoryPath = this . getAppDirectoryPath ( ) ;
179
182
this . appResourcesDirectoryPath = this . getAppResourcesDirectoryPath ( ) ;
180
183
this . androidManifestPath = this . getPathToAndroidManifest (
181
- this . appResourcesDirectoryPath
184
+ this . appResourcesDirectoryPath ,
182
185
) ;
183
186
this . gradleFilesDirectoryPath = path . join (
184
187
this . appResourcesDirectoryPath ,
185
- this . $devicePlatformsConstants . Android
188
+ this . $devicePlatformsConstants . Android ,
186
189
) ;
187
190
this . appGradlePath = path . join (
188
191
this . gradleFilesDirectoryPath ,
189
- constants . APP_GRADLE_FILE_NAME
192
+ constants . APP_GRADLE_FILE_NAME ,
190
193
) ;
191
194
this . infoPlistPath = path . join (
192
195
this . appResourcesDirectoryPath ,
193
196
this . $devicePlatformsConstants . iOS ,
194
- constants . INFO_PLIST_FILE_NAME
197
+ constants . INFO_PLIST_FILE_NAME ,
195
198
) ;
196
199
this . buildXcconfigPath = path . join (
197
200
this . appResourcesDirectoryPath ,
198
201
this . $devicePlatformsConstants . iOS ,
199
- constants . BUILD_XCCONFIG_FILE_NAME
202
+ constants . BUILD_XCCONFIG_FILE_NAME ,
200
203
) ;
201
204
this . podfilePath = path . join (
202
205
this . appResourcesDirectoryPath ,
203
206
this . $devicePlatformsConstants . iOS ,
204
- constants . PODFILE_NAME
207
+ constants . PODFILE_NAME ,
205
208
) ;
206
209
this . isShared = ! ! ( this . nsConfig && this . nsConfig . shared ) ;
207
- this . webpackConfigPath =
210
+
211
+ const webpackConfigPath =
208
212
this . nsConfig && this . nsConfig . webpackConfigPath
209
213
? path . resolve ( this . projectDir , this . nsConfig . webpackConfigPath )
210
214
: path . join ( this . projectDir , "webpack.config.js" ) ;
215
+ this . webpackConfigPath = webpackConfigPath ;
216
+ this . bundlerConfigPath =
217
+ this . nsConfig && this . nsConfig . bundlerConfigPath
218
+ ? path . resolve ( this . projectDir , this . nsConfig . bundlerConfigPath )
219
+ : webpackConfigPath ;
220
+ this . bundler = this ?. nsConfig ?. bundler ?? "webpack" ;
211
221
return ;
212
222
}
213
223
@@ -217,7 +227,7 @@ export class ProjectData implements IProjectData {
217
227
private getPathToAndroidManifest ( appResourcesDir : string ) : string {
218
228
const androidDirPath = path . join (
219
229
appResourcesDir ,
220
- this . $devicePlatformsConstants . Android
230
+ this . $devicePlatformsConstants . Android ,
221
231
) ;
222
232
const androidManifestDir =
223
233
this . $androidResourcesMigrationService . hasMigrated ( appResourcesDir )
@@ -230,13 +240,13 @@ export class ProjectData implements IProjectData {
230
240
private errorInvalidProject ( projectDir : string ) : void {
231
241
const currentDir = path . resolve ( "." ) ;
232
242
this . $logger . trace (
233
- `Unable to find project. projectDir: ${ projectDir } , options.path: ${ this . $options . path } , ${ currentDir } `
243
+ `Unable to find project. projectDir: ${ projectDir } , options.path: ${ this . $options . path } , ${ currentDir } ` ,
234
244
) ;
235
245
236
246
// This is the case when no project file found
237
247
this . $errors . fail (
238
248
"No project found at or above '%s' and neither was a --path specified." ,
239
- projectDir || this . $options . path || currentDir
249
+ projectDir || this . $options . path || currentDir ,
240
250
) ;
241
251
}
242
252
@@ -291,7 +301,7 @@ export class ProjectData implements IProjectData {
291
301
292
302
private resolveToProjectDir (
293
303
pathToResolve : string ,
294
- projectDir ?: string
304
+ projectDir ?: string ,
295
305
) : string {
296
306
if ( ! projectDir ) {
297
307
projectDir = this . projectDir ;
@@ -306,7 +316,7 @@ export class ProjectData implements IProjectData {
306
316
307
317
@cache ( )
308
318
private initializeProjectIdentifiers (
309
- config : INsConfig
319
+ config : INsConfig ,
310
320
) : Mobile . IProjectIdentifier {
311
321
this . $logger . trace ( `Initializing project identifiers. Config: ` , config ) ;
312
322
@@ -341,18 +351,18 @@ export class ProjectData implements IProjectData {
341
351
private getProjectType ( ) : string {
342
352
let detectedProjectType = _ . find (
343
353
ProjectData . PROJECT_TYPES ,
344
- ( projectType ) => projectType . isDefaultProjectType
354
+ ( projectType ) => projectType . isDefaultProjectType ,
345
355
) . type ;
346
356
347
357
const deps : string [ ] = _ . keys ( this . dependencies ) . concat (
348
- _ . keys ( this . devDependencies )
358
+ _ . keys ( this . devDependencies ) ,
349
359
) ;
350
360
351
361
_ . each ( ProjectData . PROJECT_TYPES , ( projectType ) => {
352
362
if (
353
363
_ . some (
354
364
projectType . requiredDependencies ,
355
- ( requiredDependency ) => deps . indexOf ( requiredDependency ) !== - 1
365
+ ( requiredDependency ) => deps . indexOf ( requiredDependency ) !== - 1 ,
356
366
)
357
367
) {
358
368
detectedProjectType = projectType . type ;
@@ -366,7 +376,7 @@ export class ProjectData implements IProjectData {
366
376
@cache ( )
367
377
private warnProjectId ( ) : void {
368
378
this . $logger . warn (
369
- "[WARNING]: IProjectData.projectId is deprecated. Please use IProjectData.projectIdentifiers[platform]."
379
+ "[WARNING]: IProjectData.projectId is deprecated. Please use IProjectData.projectIdentifiers[platform]." ,
370
380
) ;
371
381
}
372
382
}
0 commit comments