Skip to content

Commit 8bb96c3

Browse files
Merge pull request #3627 from NativeScript/vladimirov/merge-rel-master
chore: Merge release in master
2 parents 3b7644d + b2c643d commit 8bb96c3

14 files changed

+99
-63
lines changed

lib/commands/platform-clean.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class CleanCommand implements ICommand {
55
private $projectData: IProjectData,
66
private $platformService: IPlatformService,
77
private $errors: IErrors,
8-
private $platformsData: IPlatformsData) {
8+
private $platformEnvironmentRequirements: IPlatformEnvironmentRequirements) {
99
this.$projectData.initializeProjectData();
1010
}
1111

@@ -18,12 +18,15 @@ export class CleanCommand implements ICommand {
1818
this.$errors.fail("No platform specified. Please specify a platform to clean");
1919
}
2020

21+
_.each(args, platform => {
22+
this.$platformService.validatePlatform(platform, this.$projectData);
23+
});
24+
2125
for (const platform of args) {
2226
this.$platformService.validatePlatformInstalled(platform, this.$projectData);
2327

24-
const platformData = this.$platformsData.getPlatformData(platform, this.$projectData);
25-
const platformProjectService = platformData.platformProjectService;
26-
await platformProjectService.validate(this.$projectData);
28+
const currentRuntimeVersion = this.$platformService.getCurrentPlatformVersion(platform, this.$projectData);
29+
await this.$platformEnvironmentRequirements.checkEnvironmentRequirements(platform, this.$projectData.projectDir, currentRuntimeVersion);
2730
}
2831

2932
return true;

lib/commands/remove-platform.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ export class RemovePlatformCommand implements ICommand {
33

44
constructor(private $platformService: IPlatformService,
55
private $projectData: IProjectData,
6-
private $errors: IErrors,
7-
private $platformsData: IPlatformsData) {
6+
private $errors: IErrors) {
87
this.$projectData.initializeProjectData();
98
}
109

@@ -17,12 +16,9 @@ export class RemovePlatformCommand implements ICommand {
1716
this.$errors.fail("No platform specified. Please specify a platform to remove");
1817
}
1918

20-
for (const platform of args) {
21-
this.$platformService.validatePlatformInstalled(platform, this.$projectData);
22-
const platformData = this.$platformsData.getPlatformData(platform, this.$projectData);
23-
const platformProjectService = platformData.platformProjectService;
24-
await platformProjectService.validate(this.$projectData);
25-
}
19+
_.each(args, platform => {
20+
this.$platformService.validatePlatform(platform, this.$projectData);
21+
});
2622

2723
return true;
2824
}

lib/commands/update-platform.ts

+18-6
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export class UpdatePlatformCommand implements ICommand {
44
constructor(private $options: IOptions,
55
private $projectData: IProjectData,
66
private $platformService: IPlatformService,
7-
private $errors: IErrors,
8-
private $platformsData: IPlatformsData) {
7+
private $platformEnvironmentRequirements: IPlatformEnvironmentRequirements,
8+
private $errors: IErrors) {
99
this.$projectData.initializeProjectData();
1010
}
1111

@@ -18,12 +18,24 @@ export class UpdatePlatformCommand implements ICommand {
1818
this.$errors.fail("No platform specified. Please specify platforms to update.");
1919
}
2020

21-
for (const arg of args) {
21+
_.each(args, arg => {
2222
const platform = arg.split("@")[0];
2323
this.$platformService.validatePlatform(platform, this.$projectData);
24-
const platformData = this.$platformsData.getPlatformData(platform, this.$projectData);
25-
const platformProjectService = platformData.platformProjectService;
26-
await platformProjectService.validate(this.$projectData);
24+
});
25+
26+
for (const arg of args) {
27+
const [ platform, versionToBeInstalled ] = arg.split("@");
28+
this.$platformService.validatePlatformInstalled(platform, this.$projectData);
29+
const argsToCheckEnvironmentRequirements: string[] = [ platform ];
30+
// If version is not specified, we know the command will install the latest compatible Android runtime.
31+
// The latest compatible Android runtime supports Java version, so we do not need to pass it here.
32+
// Passing projectDir to the nativescript-doctor validation will cause it to check the runtime from the current package.json
33+
// So in this case, where we do not want to validate the runtime, just do not pass both projectDir and runtimeVersion.
34+
if (versionToBeInstalled) {
35+
argsToCheckEnvironmentRequirements.push(this.$projectData.projectDir, versionToBeInstalled);
36+
}
37+
38+
await this.$platformEnvironmentRequirements.checkEnvironmentRequirements(...argsToCheckEnvironmentRequirements);
2739
}
2840

2941
return true;

lib/common

lib/definitions/platform.d.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,14 @@ interface IPlatformService extends IBuildPlatformAction, NodeJS.EventEmitter {
214214
* @returns {void}
215215
*/
216216
saveBuildInfoFile(platform: string, projectDir: string, buildInfoFileDirname: string): void;
217+
218+
/**
219+
* Gives information for the current version of the runtime.
220+
* @param {string} platform The platform to be checked.
221+
* @param {IProjectData} projectData The data describing the project
222+
* @returns {string} Runtime version
223+
*/
224+
getCurrentPlatformVersion(platform: string, projectData: IProjectData): string;
217225
}
218226

219227
interface IPlatformOptions extends IPlatformSpecificData, ICreateProjectOptions { }
@@ -381,5 +389,5 @@ interface IUpdateAppOptions extends IOptionalFilesToSync, IOptionalFilesToRemove
381389
}
382390

383391
interface IPlatformEnvironmentRequirements {
384-
checkEnvironmentRequirements(platform?: string, projectDir?: string): Promise<boolean>;
385-
}
392+
checkEnvironmentRequirements(platform?: string, projectDir?: string, runtimeVersion?: string): Promise<boolean>;
393+
}

lib/services/doctor-service.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ class DoctorService implements IDoctorService {
1717
private $terminalSpinnerService: ITerminalSpinnerService,
1818
private $versionsService: IVersionsService) { }
1919

20-
public async printWarnings(configOptions?: { trackResult: boolean , projectDir?: string }): Promise<void> {
20+
public async printWarnings(configOptions?: { trackResult: boolean , projectDir?: string, runtimeVersion?: string }): Promise<void> {
2121
const infos = await this.$terminalSpinnerService.execute<NativeScriptDoctor.IInfo[]>({
2222
text: `Getting environment information ${EOL}`
23-
}, () => doctor.getInfos({ projectDir: configOptions && configOptions.projectDir }));
23+
}, () => doctor.getInfos({ projectDir: configOptions && configOptions.projectDir, androidRuntimeVersion: configOptions && configOptions.runtimeVersion }));
2424

2525
const warnings = infos.filter(info => info.type === constants.WARNING_TYPE_NAME);
2626
const hasWarnings = warnings.length > 0;
@@ -34,12 +34,11 @@ class DoctorService implements IDoctorService {
3434
await this.$analyticsService.track("DoctorEnvironmentSetup", hasWarnings ? "incorrect" : "correct");
3535
}
3636

37-
this.printInfosCore(infos);
38-
3937
if (hasWarnings) {
4038
this.$logger.info("There seem to be issues with your configuration.");
4139
} else {
4240
this.$logger.out("No issues were detected.".bold);
41+
this.printInfosCore(infos);
4342
}
4443

4544
try {
@@ -81,12 +80,12 @@ class DoctorService implements IDoctorService {
8180
});
8281
}
8382

84-
public async canExecuteLocalBuild(platform?: string, projectDir?: string): Promise<boolean> {
83+
public async canExecuteLocalBuild(platform?: string, projectDir?: string, runtimeVersion?: string): Promise<boolean> {
8584
await this.$analyticsService.trackEventActionInGoogleAnalytics({
8685
action: TrackActionNames.CheckLocalBuildSetup,
8786
additionalData: "Starting",
8887
});
89-
const infos = await doctor.getInfos({ platform, projectDir });
88+
const infos = await doctor.getInfos({ platform, projectDir, androidRuntimeVersion: runtimeVersion });
9089

9190
const warnings = this.filterInfosByType(infos, constants.WARNING_TYPE_NAME);
9291
const hasWarnings = warnings.length > 0;

lib/services/platform-environment-requirements.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
3030
"deploy": "tns cloud deploy"
3131
};
3232

33-
public async checkEnvironmentRequirements(platform?: string, projectDir?: string): Promise<boolean> {
33+
public async checkEnvironmentRequirements(platform?: string, projectDir?: string, runtimeVersion?: string): Promise<boolean> {
3434
if (process.env.NS_SKIP_ENV_CHECK) {
3535
await this.$analyticsService.trackEventActionInGoogleAnalytics({
3636
action: TrackActionNames.CheckEnvironmentRequirements,
@@ -39,7 +39,7 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
3939
return true;
4040
}
4141

42-
const canExecute = await this.$doctorService.canExecuteLocalBuild(platform, projectDir);
42+
const canExecute = await this.$doctorService.canExecuteLocalBuild(platform, projectDir, runtimeVersion);
4343
if (!canExecute) {
4444
if (!isInteractive()) {
4545
await this.$analyticsService.trackEventActionInGoogleAnalytics({
@@ -71,7 +71,7 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
7171
if (selectedOption === PlatformEnvironmentRequirements.LOCAL_SETUP_OPTION_NAME) {
7272
await this.$doctorService.runSetupScript();
7373

74-
if (await this.$doctorService.canExecuteLocalBuild(platform, projectDir)) {
74+
if (await this.$doctorService.canExecuteLocalBuild(platform, projectDir, runtimeVersion)) {
7575
return true;
7676
}
7777

@@ -102,7 +102,7 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
102102

103103
if (selectedOption === PlatformEnvironmentRequirements.BOTH_CLOUD_SETUP_AND_LOCAL_SETUP_OPTION_NAME) {
104104
await this.processBothCloudBuildsAndSetupScript();
105-
if (await this.$doctorService.canExecuteLocalBuild(platform, projectDir)) {
105+
if (await this.$doctorService.canExecuteLocalBuild(platform, projectDir, runtimeVersion)) {
106106
return true;
107107
}
108108

lib/services/platform-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
7474
}
7575
}
7676

77-
private getCurrentPlatformVersion(platform: string, projectData: IProjectData): string {
77+
public getCurrentPlatformVersion(platform: string, projectData: IProjectData): string {
7878
const platformData = this.$platformsData.getPlatformData(platform, projectData);
7979
const currentPlatformData: any = this.$projectDataService.getNSValue(projectData.projectDir, platformData.frameworkPackageName);
8080
let version: string;

lib/services/versions-service.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,15 @@ class VersionsService implements IVersionsService {
100100
allComponents.push(nativescriptCliInformation);
101101
}
102102

103-
const nativescriptCoreModulesInformation: IVersionInformation = await this.getTnsCoreModulesVersion();
104-
if (nativescriptCoreModulesInformation) {
105-
allComponents.push(nativescriptCoreModulesInformation);
106-
}
107-
108-
const runtimesVersions: IVersionInformation[] = await this.getRuntimesVersions();
103+
if (this.projectData) {
104+
const nativescriptCoreModulesInformation: IVersionInformation = await this.getTnsCoreModulesVersion();
105+
if (nativescriptCoreModulesInformation) {
106+
allComponents.push(nativescriptCoreModulesInformation);
107+
}
109108

110-
allComponents = allComponents.concat(runtimesVersions);
109+
const runtimesVersions: IVersionInformation[] = await this.getRuntimesVersions();
110+
allComponents = allComponents.concat(runtimesVersions);
111+
}
111112

112113
return allComponents
113114
.map(componentInformation => {

npm-shrinkwrap.json

+20-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)