@@ -5,20 +5,20 @@ import { parseJson } from "./common/helpers";
5
5
import { EOL } from "os" ;
6
6
import { cache } from "./common/decorators" ;
7
7
import {
8
- IProjectData ,
9
8
INsConfig ,
10
9
IProjectConfigService ,
10
+ IProjectData ,
11
11
} from "./definitions/project" ;
12
12
import {
13
13
IAndroidResourcesMigrationService ,
14
- IStaticConfig ,
15
14
IOptions ,
15
+ IStaticConfig ,
16
16
} from "./declarations" ;
17
17
import {
18
- IStringDictionary ,
19
- IFileSystem ,
20
18
IErrors ,
19
+ IFileSystem ,
21
20
IProjectHelper ,
21
+ IStringDictionary ,
22
22
} from "./common/declarations" ;
23
23
import { injector } from "./common/yok" ;
24
24
import { IInjector } from "./common/definitions/yok" ;
@@ -68,16 +68,19 @@ export class ProjectData implements IProjectData {
68
68
public platformsDir : string ;
69
69
public projectFilePath : string ;
70
70
public projectIdentifiers : Mobile . IProjectIdentifier ;
71
+
71
72
get projectId ( ) : string {
72
73
this . warnProjectId ( ) ;
73
74
return this . projectIdentifiers . ios ;
74
75
}
76
+
75
77
//just in case hook/extension modifies it.
76
78
set projectId ( identifier : string ) {
77
79
this . warnProjectId ( ) ;
78
80
this . projectIdentifiers . ios = identifier ;
79
81
this . projectIdentifiers . android = identifier ;
80
82
}
83
+
81
84
public projectName : string ;
82
85
public packageJsonData : any ;
83
86
public nsConfig : INsConfig ;
@@ -137,16 +140,23 @@ export class ProjectData implements IProjectData {
137
140
) : void {
138
141
projectDir = projectDir || this . $projectHelper . projectDir || "" ;
139
142
const projectFilePath = this . getProjectFilePath ( projectDir ) ;
140
- // If no project found, projectDir should be null
141
- // handle migration cases
142
- let isMigrate = false ;
143
- if ( this . $options . argv && this . $options . argv . _ && this . $options . argv . _ . length ) {
144
- this . $logger . info ( 'this.$options.argv._[0]:' , this . $options . argv . _ [ 0 ] ) ;
145
- isMigrate = this . $options . argv . _ [ 0 ] === 'migrate' ;
146
- }
147
- this . $logger . info ( 'about to call readConfig...' )
148
- this . $logger . info ( 'isMigrate:' , isMigrate ) ;
149
- const nsConfig : INsConfig = isMigrate ? null : this . projectConfig . readConfig ( projectDir ) ;
143
+ // If no project found, projectDir should be null
144
+ // handle migration cases
145
+ let isMigrate = false ;
146
+ if (
147
+ this . $options . argv &&
148
+ this . $options . argv . _ &&
149
+ this . $options . argv . _ . length
150
+ ) {
151
+ this . $logger . debug (
152
+ "the value of this.$options.argv._[0] is: " + this . $options . argv . _ [ 0 ]
153
+ ) ;
154
+ isMigrate = this . $options . argv . _ [ 0 ] === "migrate" ;
155
+ }
156
+ this . $logger . debug ( `'initializingProjectData, isMigrate is ${ isMigrate } .` ) ;
157
+ const nsConfig : INsConfig = isMigrate
158
+ ? null
159
+ : this . projectConfig . readConfig ( projectDir ) ;
150
160
let packageJsonData = null ;
151
161
152
162
try {
@@ -272,15 +282,14 @@ export class ProjectData implements IProjectData {
272
282
public getAppDirectoryRelativePath ( ) : string {
273
283
if ( this . nsConfig && this . nsConfig [ constants . CONFIG_NS_APP_ENTRY ] ) {
274
284
return this . nsConfig [ constants . CONFIG_NS_APP_ENTRY ] ;
275
- }
276
-
277
- if ( this . $fs . exists ( path . resolve ( this . projectDir , constants . SRC_DIR ) ) ) {
278
- return constants . SRC_DIR ;
279
- } else {
280
- // legacy project setup often uses app folder
281
- return constants . APP_FOLDER_NAME ;
282
- }
285
+ }
283
286
287
+ if ( this . $fs . exists ( path . resolve ( this . projectDir , constants . SRC_DIR ) ) ) {
288
+ return constants . SRC_DIR ;
289
+ } else {
290
+ // legacy project setup often uses app folder
291
+ return constants . APP_FOLDER_NAME ;
292
+ }
284
293
}
285
294
286
295
public getNsConfigRelativePath ( ) : string {
@@ -305,27 +314,27 @@ export class ProjectData implements IProjectData {
305
314
private initializeProjectIdentifiers (
306
315
config : INsConfig
307
316
) : Mobile . IProjectIdentifier {
308
- if ( config ) {
309
- const identifier : Mobile . IProjectIdentifier = {
310
- ios : config . id ,
311
- android : config . id ,
312
- } ;
313
-
314
- if ( config . ios && config . ios . id ) {
315
- identifier . ios = config . ios . id ;
316
- }
317
- if ( config . android && config . android . id ) {
318
- identifier . android = config . android . id ;
319
- }
320
-
321
- return identifier ;
322
- } else {
323
- // when migrating projects this can be ignored
324
- return {
325
- ios : '' ,
326
- android : ''
327
- } ;
328
- }
317
+ if ( config ) {
318
+ const identifier : Mobile . IProjectIdentifier = {
319
+ ios : config . id ,
320
+ android : config . id ,
321
+ } ;
322
+
323
+ if ( config . ios && config . ios . id ) {
324
+ identifier . ios = config . ios . id ;
325
+ }
326
+ if ( config . android && config . android . id ) {
327
+ identifier . android = config . android . id ;
328
+ }
329
+
330
+ return identifier ;
331
+ } else {
332
+ // when migrating projects this can be ignored
333
+ return {
334
+ ios : "" ,
335
+ android : "" ,
336
+ } ;
337
+ }
329
338
}
330
339
331
340
private getProjectType ( ) : string {
@@ -360,4 +369,5 @@ export class ProjectData implements IProjectData {
360
369
) ;
361
370
}
362
371
}
372
+
363
373
injector . register ( "projectData" , ProjectData , true ) ;
0 commit comments