Skip to content

Commit 585fc2b

Browse files
Merge remote-tracking branch 'origin/release' into vladimirov/merge-rel-master
2 parents ae25da3 + 95e9cbb commit 585fc2b

File tree

8 files changed

+37
-34
lines changed

8 files changed

+37
-34
lines changed

lib/commands/update.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export class UpdateCommand extends ValidatePlatformCommandBase implements IComma
1313
private $projectDataService: IProjectDataService,
1414
private $fs: IFileSystem,
1515
private $logger: ILogger) {
16-
super($options, $platformsData, $platformService, $projectData);
17-
this.$projectData.initializeProjectData();
16+
super($options, $platformsData, $platformService, $projectData);
17+
this.$projectData.initializeProjectData();
1818
}
1919

2020
static readonly folders: string[] = [
@@ -83,8 +83,10 @@ export class UpdateCommand extends ValidatePlatformCommandBase implements IComma
8383
}
8484

8585
await this.$platformService.removePlatforms(platforms.installed, this.$projectData);
86-
await this.$pluginsService.remove("tns-core-modules", this.$projectData);
87-
await this.$pluginsService.remove("tns-core-modules-widgets", this.$projectData);
86+
await this.$pluginsService.remove(constants.TNS_CORE_MODULES_NAME, this.$projectData);
87+
if (!!this.$projectData.dependencies[constants.TNS_CORE_MODULES_WIDGETS_NAME]) {
88+
await this.$pluginsService.remove(constants.TNS_CORE_MODULES_WIDGETS_NAME, this.$projectData);
89+
}
8890

8991
for (const folder of UpdateCommand.folders) {
9092
this.$fs.deleteDirectory(path.join(this.$projectData.projectDir, folder));
@@ -95,16 +97,16 @@ export class UpdateCommand extends ValidatePlatformCommandBase implements IComma
9597
await this.$platformService.addPlatforms([platform + "@" + args[0]], this.$options.platformTemplate, this.$projectData, this.$options, this.$options.frameworkPath);
9698
}
9799

98-
await this.$pluginsService.add("tns-core-modules@" + args[0], this.$projectData);
100+
await this.$pluginsService.add(`${constants.TNS_CORE_MODULES_NAME}@${args[0]}`, this.$projectData);
99101
} else {
100102
await this.$platformService.addPlatforms(platforms.packagePlatforms, this.$options.platformTemplate, this.$projectData, this.$options, this.$options.frameworkPath);
101-
await this.$pluginsService.add("tns-core-modules", this.$projectData);
103+
await this.$pluginsService.add(constants.TNS_CORE_MODULES_NAME, this.$projectData);
102104
}
103105

104106
await this.$pluginsService.ensureAllDependenciesAreInstalled(this.$projectData);
105107
}
106108

107-
private getPlatforms(): {installed: string[], packagePlatforms: string[]} {
109+
private getPlatforms(): { installed: string[], packagePlatforms: string[] } {
108110
const installedPlatforms = this.$platformService.getInstalledPlatforms(this.$projectData);
109111
const availablePlatforms = this.$platformService.getAvailablePlatforms(this.$projectData);
110112
const packagePlatforms: string[] = [];

lib/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const NATIVESCRIPT_KEY_NAME = "nativescript";
77
export const NODE_MODULES_FOLDER_NAME = "node_modules";
88
export const TNS_MODULES_FOLDER_NAME = "tns_modules";
99
export const TNS_CORE_MODULES_NAME = "tns-core-modules";
10+
export const TNS_CORE_MODULES_WIDGETS_NAME = "tns-core-modules-widgets";
1011
export const TNS_ANDROID_RUNTIME_NAME = "tns-android";
1112
export const TNS_IOS_RUNTIME_NAME = "tns-ios";
1213
export const PACKAGE_JSON_FILE_NAME = "package.json";

lib/services/android-device-debug-service.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,6 @@ export class AndroidDeviceDebugService extends DebugServiceBase implements IDevi
5959
return this.removePortForwarding();
6060
}
6161

62-
protected getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string {
63-
const debugOpts = _.cloneDeep(debugOptions);
64-
debugOpts.useBundledDevTools = debugOpts.useBundledDevTools === undefined ? true : debugOpts.useBundledDevTools;
65-
66-
const chromeDebugUrl = super.getChromeDebugUrl(debugOpts, port);
67-
return chromeDebugUrl;
68-
}
69-
7062
private async debugOnEmulator(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
7163
// Assure we've detected the emulator as device
7264
// For example in case deployOnEmulator had stated new emulator instance

lib/services/debug-service-base.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@ export abstract class DebugServiceBase extends EventEmitter implements IDeviceDe
3434

3535
protected getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string {
3636
// corresponds to 55.0.2883 Chrome version
37+
// SHA is taken from https://chromium.googlesource.com/chromium/src/+/55.0.2883.100
38+
// This SHA is old and does not support debugging with HMR.
39+
// In case we want to stick with concrete SHA, get it from one of the tags https://chromium.googlesource.com/chromium/src/
40+
// IMPORTANT: When you get the SHA, ensure you are using the `parent` commit, not the actual one.
41+
// Using the actual commit will result in 404 error in the remote serve.
3742
const commitSHA = debugOptions.devToolsCommit || "02e6bde1bbe34e43b309d4ef774b1168d25fd024";
38-
debugOptions.useHttpUrl = debugOptions.useHttpUrl === undefined ? false : debugOptions.useHttpUrl;
3943

4044
let chromeDevToolsPrefix = `chrome-devtools://devtools/remote/serve_file/@${commitSHA}`;
4145

42-
if (debugOptions.useBundledDevTools) {
46+
if (debugOptions.useBundledDevTools === undefined || debugOptions.useBundledDevTools) {
4347
chromeDevToolsPrefix = "chrome-devtools://devtools/bundled";
4448
}
4549

lib/services/ios-device-debug-service.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDe
6161
await this.stopAppDebuggerOnSimulator();
6262
}
6363

64-
protected getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string {
65-
const debugOpts = _.cloneDeep(debugOptions);
66-
debugOpts.useBundledDevTools = debugOpts.useBundledDevTools === undefined ? false : debugOpts.useBundledDevTools;
67-
68-
const chromeDebugUrl = super.getChromeDebugUrl(debugOpts, port);
69-
return chromeDebugUrl;
70-
}
71-
7264
private async startApp(debugData: IDebugData, debugOptions: IDebugOptions) {
7365
if (this.device.isEmulator) {
7466
await this.startAppOnSimulator(debugData, debugOptions);

lib/yarn-package-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class YarnPackageManager extends BasePackageManager {
9696
@exported("yarn")
9797
public async getCachePath(): Promise<string> {
9898
const result = await this.$childProcess.exec(`yarn cache dir`);
99-
return result;
99+
return result.toString().trim();
100100
}
101101
}
102102

test/services/ios-device-debug-service.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe("iOSDeviceDebugService", () => {
7878
{
7979
scenarioName: "useBundledDevTools and useHttpUrl are not passed",
8080
debugOptions: {},
81-
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
81+
expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
8282
},
8383

8484
// When useBundledDevTools is true
@@ -137,7 +137,7 @@ describe("iOSDeviceDebugService", () => {
137137
debugOptions: {
138138
useHttpUrl: false
139139
},
140-
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
140+
expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
141141
},
142142
{
143143
scenarioName: "useBundledDevTools is not passed and useHttpUrl is true",
@@ -149,16 +149,18 @@ describe("iOSDeviceDebugService", () => {
149149

150150
// devToolsCommit tests
151151
{
152-
scenarioName: "devToolsCommit defaults to ${expectedDevToolsCommitSha} and is used in result when useBundledDevTools is not passed",
153-
debugOptions: {},
152+
scenarioName: `devToolsCommit defaults to ${expectedDevToolsCommitSha} and is used in result when useBundledDevTools is not passed`,
153+
debugOptions: {
154+
useBundledDevTools: false
155+
},
154156
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${expectedDevToolsCommitSha}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
155157
},
156158
{
157-
scenarioName: "devToolsCommit is set to passed value when useBundledDevTools is not passed",
159+
scenarioName: "devToolsCommit is disregarded when useBundledDevTools is not passed",
158160
debugOptions: {
159161
devToolsCommit: customDevToolsCommit
160162
},
161-
expectedChromeUrl: `chrome-devtools://devtools/remote/serve_file/@${customDevToolsCommit}/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
163+
expectedChromeUrl: `chrome-devtools://devtools/bundled/inspector.html?experiments=true&ws=localhost:${expectedPort}`,
162164
},
163165
{
164166
scenarioName: "devToolsCommit is set to passed value when useBundledDevTools is set to false",

test/update.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ function createTestInjector(
3737
testInjector.register("staticConfig", StaticConfig);
3838
testInjector.register("androidProjectService", AndroidProjectService);
3939
testInjector.register("androidToolsInfo", stubs.AndroidToolsInfoStub);
40-
testInjector.register("projectData", { projectDir, initializeProjectData: () => { /* empty */ } });
40+
testInjector.register("projectData", {
41+
projectDir,
42+
initializeProjectData: () => { /* empty */ },
43+
dependencies: {}
44+
});
4145
testInjector.register("projectDataService", {
4246
getNSValue: () => {
4347
return "1.0.0";
@@ -134,7 +138,7 @@ describe("update command method tests", () => {
134138
sandbox.restore();
135139
});
136140

137-
it("if backup fails, pltforms not deleted and added, temp removed", async () => {
141+
it("if backup fails, platforms not deleted and added, temp removed", async () => {
138142
const installedPlatforms: string[] = ["android"];
139143
const testInjector = createTestInjector(installedPlatforms);
140144
const fs = testInjector.resolve("fs");
@@ -229,6 +233,12 @@ describe("update command method tests", () => {
229233
sandbox.spy(pluginsService, "remove");
230234
sandbox.spy(pluginsService, "add");
231235
sandbox.spy(pluginsService, "ensureAllDependenciesAreInstalled");
236+
const $projectData = testInjector.resolve("projectData");
237+
$projectData.dependencies = {
238+
"tns-core-modules": "1.0.0",
239+
"tns-core-modules-widgets": "1.0.0"
240+
};
241+
232242
const updateCommand = testInjector.resolve<UpdateCommand>(UpdateCommand);
233243
return updateCommand.execute([]).then(() => {
234244
assert(pluginsService.add.calledWith("tns-core-modules"));

0 commit comments

Comments
 (0)