@@ -11,7 +11,7 @@ import * as _ from "lodash";
11
11
export class AndroidToolsInfo implements NativeScriptDoctor . IAndroidToolsInfo {
12
12
public readonly ANDROID_TARGET_PREFIX = "android" ;
13
13
public getSupportedTargets ( projectDir : string ) {
14
- const runtimeVersion = this . getRuntimeVersion ( { projectDir} ) ;
14
+ const runtimeVersion = this . getRuntimeVersion ( { projectDir } ) ;
15
15
let baseTargets = [
16
16
"android-17" ,
17
17
"android-18" ,
@@ -126,7 +126,7 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
126
126
if ( semver . lt ( installedJavaCompilerSemverVersion , AndroidToolsInfo . MIN_JAVA_VERSION ) || semver . gte ( installedJavaCompilerSemverVersion , AndroidToolsInfo . MAX_JAVA_VERSION ) ) {
127
127
warning = `Javac version ${ installedJavaCompilerVersion } is not supported. You have to install at least ${ AndroidToolsInfo . MIN_JAVA_VERSION } and below ${ AndroidToolsInfo . MAX_JAVA_VERSION } .` ;
128
128
} else {
129
- runtimeVersion = this . getRuntimeVersion ( { runtimeVersion, projectDir} ) ;
129
+ runtimeVersion = this . getRuntimeVersion ( { runtimeVersion, projectDir } ) ;
130
130
if ( runtimeVersion ) {
131
131
// get the item from the dictionary that corresponds to our current Javac version:
132
132
let runtimeMinVersion : string = null ;
@@ -200,7 +200,7 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
200
200
return errors ;
201
201
}
202
202
203
- public validateMinSupportedTargetSdk ( { targetSdk, projectDir} : NativeScriptDoctor . ITargetValidationOptions ) : NativeScriptDoctor . IWarning [ ] {
203
+ public validateMinSupportedTargetSdk ( { targetSdk, projectDir } : NativeScriptDoctor . ITargetValidationOptions ) : NativeScriptDoctor . IWarning [ ] {
204
204
const errors : NativeScriptDoctor . IWarning [ ] = [ ] ;
205
205
const newTarget = `${ this . ANDROID_TARGET_PREFIX } -${ targetSdk } ` ;
206
206
const supportedTargets = this . getSupportedTargets ( projectDir ) ;
@@ -212,7 +212,7 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
212
212
213
213
if ( ! targetSupported && targetSdk && ( targetSdk < minSupportedVersion ) ) {
214
214
errors . push ( {
215
- warning :`The selected Android target SDK ${ newTarget } is not supported. You must target ${ minSupportedVersion } or later.` ,
215
+ warning : `The selected Android target SDK ${ newTarget } is not supported. You must target ${ minSupportedVersion } or later.` ,
216
216
additionalInformation : "" ,
217
217
platforms : [ Constants . ANDROID_PLATFORM_NAME ]
218
218
} ) ;
@@ -222,14 +222,14 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
222
222
return errors ;
223
223
}
224
224
225
- public validataMaxSupportedTargetSdk ( { targetSdk, projectDir} : NativeScriptDoctor . ITargetValidationOptions ) : NativeScriptDoctor . IWarning [ ] {
225
+ public validataMaxSupportedTargetSdk ( { targetSdk, projectDir } : NativeScriptDoctor . ITargetValidationOptions ) : NativeScriptDoctor . IWarning [ ] {
226
226
const errors : NativeScriptDoctor . IWarning [ ] = [ ] ;
227
227
const newTarget = `${ this . ANDROID_TARGET_PREFIX } -${ targetSdk } ` ;
228
228
const targetSupported = _ . includes ( this . getSupportedTargets ( projectDir ) , newTarget ) ;
229
229
230
230
if ( ! targetSupported && ! targetSdk || targetSdk > this . getMaxSupportedVersion ( projectDir ) ) {
231
231
errors . push ( {
232
- warning :`Support for the selected Android target SDK ${ newTarget } is not verified. Your Android app might not work as expected.` ,
232
+ warning : `Support for the selected Android target SDK ${ newTarget } is not verified. Your Android app might not work as expected.` ,
233
233
additionalInformation : "" ,
234
234
platforms : [ Constants . ANDROID_PLATFORM_NAME ]
235
235
} ) ;
@@ -369,68 +369,68 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
369
369
370
370
private getAndroidRuntimePackageFromProjectDir ( projectDir : string ) : { name : string , version : string } {
371
371
if ( ! projectDir || ! this . fs . exists ( projectDir ) ) {
372
- return null
373
- }
372
+ return null ;
373
+ }
374
374
const pathToPackageJson = path . join ( projectDir , Constants . PACKAGE_JSON ) ;
375
375
376
- if ( ! this . fs . exists ( pathToPackageJson ) ) {
377
- return null
378
- }
376
+ if ( ! this . fs . exists ( pathToPackageJson ) ) {
377
+ return null ;
378
+ }
379
379
380
- const content = this . fs . readJson < INativeScriptProjectPackageJson > ( pathToPackageJson ) ;
380
+ const content = this . fs . readJson < INativeScriptProjectPackageJson > ( pathToPackageJson ) ;
381
381
382
- if ( ! content ) {
383
- return null
384
- }
382
+ if ( ! content ) {
383
+ return null ;
384
+ }
385
385
386
386
// in case we have a nativescript key and a runtime with a version
387
- // we are dealing with a legacy project and should respect the values
388
- // in the nativescript key
389
- if ( content && content . nativescript && content . nativescript [ 'tns-android' ] && content . nativescript [ 'tns-android' ] . version ) {
390
- return {
391
- name : Constants . ANDROID_OLD_RUNTIME ,
392
- version : content . nativescript && content . nativescript [ 'tns-android' ] && content . nativescript [ 'tns-android' ] . version
393
- } ;
394
- }
395
-
396
- if ( content && content . devDependencies ) {
397
- const foundRuntime = Object . keys ( content . devDependencies ) . find ( depName => {
398
- return depName === Constants . ANDROID_SCOPED_RUNTIME || depName === Constants . ANDROID_OLD_RUNTIME
399
- } )
400
-
401
- if ( foundRuntime ) {
402
- let version = content . devDependencies [ foundRuntime ]
403
-
404
- if ( version . includes ( 'tgz' ) ) {
405
- try {
406
- const packagePath = require . resolve ( `${ foundRuntime } /package.json` , {
407
- paths : [ projectDir ]
408
- } )
409
- version = require ( packagePath ) . version ;
410
- } catch ( err ) {
411
- version = '*' ;
412
- }
413
- }
414
-
415
- return {
416
- name : foundRuntime ,
417
- version
418
- }
419
- }
420
- }
421
-
422
- return null
387
+ // we are dealing with a legacy project and should respect the values
388
+ // in the nativescript key
389
+ if ( content && content . nativescript && content . nativescript [ 'tns-android' ] && content . nativescript [ 'tns-android' ] . version ) {
390
+ return {
391
+ name : Constants . ANDROID_OLD_RUNTIME ,
392
+ version : content . nativescript && content . nativescript [ 'tns-android' ] && content . nativescript [ 'tns-android' ] . version
393
+ } ;
394
+ }
395
+
396
+ if ( content && content . devDependencies ) {
397
+ const foundRuntime = Object . keys ( content . devDependencies ) . find ( depName => {
398
+ return depName === Constants . ANDROID_SCOPED_RUNTIME || depName === Constants . ANDROID_OLD_RUNTIME ;
399
+ } ) ;
400
+
401
+ if ( foundRuntime ) {
402
+ let version = content . devDependencies [ foundRuntime ] ;
403
+
404
+ if ( version . includes ( 'tgz' ) ) {
405
+ try {
406
+ const packagePath = require . resolve ( `${ foundRuntime } /package.json` , {
407
+ paths : [ projectDir ]
408
+ } ) ;
409
+ version = require ( packagePath ) . version ;
410
+ } catch ( err ) {
411
+ version = '*' ;
412
+ }
413
+ }
414
+
415
+ return {
416
+ name : foundRuntime ,
417
+ version
418
+ } ;
419
+ }
420
+ }
421
+
422
+ return null ;
423
423
}
424
424
425
- private getRuntimeVersion ( { runtimeVersion, projectDir } : { runtimeVersion ?: string , projectDir ?: string } ) : string {
426
- let runtimePackage = {
427
- name : Constants . ANDROID_SCOPED_RUNTIME ,
428
- version : runtimeVersion
429
- }
430
- if ( ! runtimeVersion ) {
431
- runtimePackage = this . getAndroidRuntimePackageFromProjectDir ( projectDir )
432
- runtimeVersion = runtimePackage ? .version ;
433
- }
425
+ private getRuntimeVersion ( { runtimeVersion, projectDir } : { runtimeVersion ?: string , projectDir ?: string } ) : string {
426
+ let runtimePackage = {
427
+ name : Constants . ANDROID_SCOPED_RUNTIME ,
428
+ version : runtimeVersion
429
+ } ;
430
+ if ( ! runtimeVersion ) {
431
+ runtimePackage = this . getAndroidRuntimePackageFromProjectDir ( projectDir ) ;
432
+ runtimeVersion = runtimePackage && runtimePackage . version ;
433
+ }
434
434
435
435
if ( runtimeVersion ) {
436
436
// Check if the version is not "next" or "rc", i.e. tag from npm
@@ -454,7 +454,7 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
454
454
return runtimeVersion ;
455
455
}
456
456
457
- private getMaxSupportedCompileVersion ( config : Partial < NativeScriptDoctor . IProjectDir > & { runtimeVersion ?: string } ) : number {
457
+ private getMaxSupportedCompileVersion ( config : Partial < NativeScriptDoctor . IProjectDir > & { runtimeVersion ?: string } ) : number {
458
458
if ( config . runtimeVersion && semver . lt ( semver . coerce ( config . runtimeVersion ) , "6.1.0" ) ) {
459
459
return 28 ;
460
460
}
0 commit comments