Skip to content

Commit 946dda4

Browse files
authored
Merge pull request #4799 from NativeScript/release
chore: merge release in master
2 parents 3cabd7e + 49a148f commit 946dda4

File tree

10 files changed

+65
-49
lines changed

10 files changed

+65
-49
lines changed

lib/commands/deploy.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export class DeployOnDeviceCommand extends ValidatePlatformCommandBase implement
66
public allowedParameters: ICommandParameter[] = [];
77

88
public dashedOptions = {
9+
watch: { type: OptionType.Boolean, default: false, hasSensitiveValue: false },
910
hmr: { type: OptionType.Boolean, default: false, hasSensitiveValue: false },
1011
};
1112

lib/common/project-helper.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class ProjectHelper implements IProjectHelper {
5959
if (this.$staticConfig.CLIENT_NAME_KEY_IN_PROJECT_FILE) {
6060
try {
6161
const fileContent = this.$fs.readJson(projectFilePath);
62-
const clientSpecificData = fileContent[this.$staticConfig.CLIENT_NAME_KEY_IN_PROJECT_FILE];
62+
const clientSpecificData = fileContent[this.$staticConfig.CLIENT_NAME_KEY_IN_PROJECT_FILE] && fileContent[this.$staticConfig.CLIENT_NAME_KEY_IN_PROJECT_FILE].id;
6363
return !!clientSpecificData;
6464
} catch (err) {
6565
this.$errors.failWithoutHelp("The project file is corrupted. Additional technical information: %s", err);

lib/controllers/migrate-controller.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ export class MigrateController extends UpdateControllerBase implements IMigrateC
3737
];
3838

3939
private migrationDependencies: IMigrationDependency[] = [
40-
{ packageName: constants.TNS_CORE_MODULES_NAME, verifiedVersion: "6.0.0-next-2019-06-20-155941-01" },
41-
{ packageName: constants.TNS_CORE_MODULES_WIDGETS_NAME, verifiedVersion: "6.0.0-next-2019-06-20-155941-01" },
42-
{ packageName: "tns-platform-declarations", verifiedVersion: "6.0.0-next-2019-06-27-082418-01" },
40+
{ packageName: constants.TNS_CORE_MODULES_NAME, verifiedVersion: "6.0.0-rc-2019-06-28-175837-02" },
41+
{ packageName: constants.TNS_CORE_MODULES_WIDGETS_NAME, verifiedVersion: "6.0.0" },
42+
{ packageName: "tns-platform-declarations", isDev: true, verifiedVersion: "6.0.0-rc-2019-06-28-175837-02" },
4343
{ packageName: "node-sass", isDev: true, verifiedVersion: "4.12.0" },
4444
{ packageName: "typescript", isDev: true, verifiedVersion: "3.4.1" },
4545
{ packageName: "less", isDev: true, verifiedVersion: "3.9.0" },
4646
{ packageName: "nativescript-dev-sass", isDev: true, replaceWith: "node-sass" },
4747
{ packageName: "nativescript-dev-typescript", isDev: true, replaceWith: "typescript" },
4848
{ packageName: "nativescript-dev-less", isDev: true, replaceWith: "less" },
49-
{ packageName: constants.WEBPACK_PLUGIN_NAME, isDev: true, shouldAddIfMissing: true, verifiedVersion: "0.25.0-next-2019-06-21-150426-03" },
49+
{ packageName: constants.WEBPACK_PLUGIN_NAME, isDev: true, shouldAddIfMissing: true, verifiedVersion: "1.0.0-rc-2019-07-02-161545-02" },
5050
{ packageName: "nativescript-camera", verifiedVersion: "4.5.0" },
5151
{ packageName: "nativescript-geolocation", verifiedVersion: "5.1.0" },
5252
{ packageName: "nativescript-imagepicker", verifiedVersion: "6.2.0" },
@@ -64,7 +64,7 @@ export class MigrateController extends UpdateControllerBase implements IMigrateC
6464
//TODO update with compatible with webpack only hooks
6565
{ packageName: "nativescript-plugin-firebase", verifiedVersion: "9.0.1" },
6666
//TODO update with no prerelease version compatible with webpack only hooks
67-
{ packageName: "nativescript-vue", verifiedVersion: "2.3.0-rc.0" },
67+
{ packageName: "nativescript-vue", verifiedVersion: "2.3.0-rc.1" },
6868
{ packageName: "nativescript-permissions", verifiedVersion: "1.3.0" },
6969
{ packageName: "nativescript-cardview", verifiedVersion: "3.2.0" },
7070
{
@@ -76,8 +76,8 @@ export class MigrateController extends UpdateControllerBase implements IMigrateC
7676

7777
get verifiedPlatformVersions(): IDictionary<string> {
7878
return {
79-
[this.$devicePlatformsConstants.Android.toLowerCase()]: "6.0.0-2019-06-11-172137-01",
80-
[this.$devicePlatformsConstants.iOS.toLowerCase()]: "6.0.0-2019-06-10-154118-03"
79+
[this.$devicePlatformsConstants.Android.toLowerCase()]: "6.0.0-rc-2019-06-27-172817-03",
80+
[this.$devicePlatformsConstants.iOS.toLowerCase()]: "6.0.0-rc-2019-06-28-105002-01"
8181
};
8282
}
8383

@@ -165,7 +165,7 @@ export class MigrateController extends UpdateControllerBase implements IMigrateC
165165
matchBase: true,
166166
nodir: true,
167167
absolute: false,
168-
root: projectData.appDirectoryPath
168+
cwd: projectData.appDirectoryPath
169169
};
170170

171171
const jsFiles = glob.sync("*.@(js|ts|js.map)", globOptions);
@@ -176,7 +176,7 @@ export class MigrateController extends UpdateControllerBase implements IMigrateC
176176

177177
const allGeneratedFiles = autoGeneratedJsFiles.concat(autoGeneratedJsMapFiles).concat(autoGeneratedCssFiles);
178178
for (const generatedFile of allGeneratedFiles) {
179-
const sourceFile = path.join(projectData.projectDir, generatedFile);
179+
const sourceFile = path.join(projectData.appDirectoryPath, generatedFile);
180180
const destinationFile = path.join(backupDir, generatedFile);
181181
const destinationFileDir = path.dirname(destinationFile);
182182
this.$fs.ensureDirectoryExists(destinationFileDir);

lib/controllers/prepare-controller.ts

+20-16
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,24 @@ export class PrepareController extends EventEmitter {
8080
nativeFilesWatcher: null,
8181
webpackCompilerProcess: null
8282
};
83-
}
83+
await this.startJSWatcherWithPrepare(platformData, projectData, prepareData); // -> start watcher + initial compilation
84+
const hasNativeChanges = await this.startNativeWatcherWithPrepare(platformData, projectData, prepareData); // -> start watcher + initial prepare
85+
const result = { platform: platformData.platformNameLowerCase, hasNativeChanges };
8486

85-
await this.startJSWatcherWithPrepare(platformData, projectData, prepareData); // -> start watcher + initial compilation
86-
const hasNativeChanges = await this.startNativeWatcherWithPrepare(platformData, projectData, prepareData); // -> start watcher + initial prepare
87+
const hasPersistedDataWithNativeChanges = this.persistedData.find(data => data.platform === result.platform && data.hasNativeChanges);
88+
if (hasPersistedDataWithNativeChanges) {
89+
result.hasNativeChanges = true;
90+
}
8791

88-
const result = { platform: platformData.platformNameLowerCase, hasNativeChanges };
89-
const hasPersistedDataWithNativeChanges = this.persistedData.find(data => data.platform === result.platform && data.hasNativeChanges);
90-
if (hasPersistedDataWithNativeChanges) {
91-
result.hasNativeChanges = true;
92-
}
92+
// TODO: Do not persist this in `this` context. Also it should be per platform.
93+
this.isInitialPrepareReady = true;
9394

94-
this.isInitialPrepareReady = true;
95+
if (this.persistedData && this.persistedData.length) {
96+
this.emitPrepareEvent({ files: [], hasOnlyHotUpdateFiles: false, hasNativeChanges: result.hasNativeChanges, hmrData: null, platform: platformData.platformNameLowerCase });
97+
}
9598

96-
if (this.persistedData && this.persistedData.length) {
97-
this.emitPrepareEvent({ files: [], hasOnlyHotUpdateFiles: false, hasNativeChanges: result.hasNativeChanges, hmrData: null, platform: platformData.platformNameLowerCase });
99+
return result;
98100
}
99-
100-
return result;
101101
}
102102

103103
private async startJSWatcherWithPrepare(platformData: IPlatformData, projectData: IProjectData, prepareData: IPrepareData): Promise<void> {
@@ -149,15 +149,19 @@ export class PrepareController extends EventEmitter {
149149

150150
@hook('watchPatterns')
151151
public async getWatcherPatterns(platformData: IPlatformData, projectData: IProjectData): Promise<string[]> {
152-
const pluginsNativeDirectories = this.$nodeModulesDependenciesBuilder.getProductionDependencies(projectData.projectDir)
153-
.filter(dep => dep.nativescript)
152+
const dependencies = this.$nodeModulesDependenciesBuilder.getProductionDependencies(projectData.projectDir)
153+
.filter(dep => dep.nativescript);
154+
const pluginsNativeDirectories = dependencies
154155
.map(dep => path.join(dep.directory, PLATFORMS_DIR_NAME, platformData.platformNameLowerCase));
156+
const pluginsPackageJsonFiles = dependencies.map(dep => path.join(dep.directory, PACKAGE_JSON_FILE_NAME));
155157

156158
const patterns = [
157159
path.join(projectData.projectDir, PACKAGE_JSON_FILE_NAME),
158160
path.join(projectData.getAppDirectoryPath(), PACKAGE_JSON_FILE_NAME),
159161
path.join(projectData.getAppResourcesRelativeDirectoryPath(), platformData.normalizedPlatformName),
160-
].concat(pluginsNativeDirectories);
162+
]
163+
.concat(pluginsNativeDirectories)
164+
.concat(pluginsPackageJsonFiles);
161165

162166
return patterns;
163167
}

lib/controllers/preview-app-controller.ts

+22-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import { PrepareDataService } from "../services/prepare-data-service";
99
import { PreviewAppLiveSyncEvents } from "../services/livesync/playground/preview-app-constants";
1010

1111
export class PreviewAppController extends EventEmitter implements IPreviewAppController {
12-
private deviceInitializationPromise: IDictionary<Promise<FilesPayload>> = {};
12+
private deviceInitializationPromise: IDictionary<boolean> = {};
13+
private platformPrepareHandlers: IDictionary<boolean> = {};
1314
private promise = Promise.resolve();
1415

1516
constructor(
@@ -49,9 +50,14 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon
4950
}
5051

5152
if (this.deviceInitializationPromise[device.id]) {
52-
return this.deviceInitializationPromise[device.id];
53+
// In some cases devices are reported several times during initialization.
54+
// In case we are already preparing the sending of initial files, disregard consecutive requests for initial files
55+
// until we send the files we are currently preparing.
56+
return null;
5357
}
5458

59+
this.deviceInitializationPromise[device.id] = true;
60+
5561
if (device.uniqueId) {
5662
await this.$analyticsService.trackEventActionInGoogleAnalytics({
5763
action: TrackActionNames.PreviewAppData,
@@ -68,20 +74,25 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon
6874

6975
await this.$previewAppPluginsService.comparePluginsOnDevice(data, device);
7076

71-
this.$prepareController.on(PREPARE_READY_EVENT_NAME, async currentPrepareData => {
72-
await this.handlePrepareReadyEvent(data, currentPrepareData.hmrData, currentPrepareData.files, device.platform);
73-
});
77+
if (!this.platformPrepareHandlers[device.platform]) {
78+
// TODO: Unset this property once the preview operation for this platform is stopped
79+
this.platformPrepareHandlers[device.platform] = true;
80+
81+
// TODO: Remove the handler once the preview operation for this platform is stopped
82+
this.$prepareController.on(PREPARE_READY_EVENT_NAME, async currentPrepareData => {
83+
await this.handlePrepareReadyEvent(data, currentPrepareData.hmrData, currentPrepareData.files, device.platform);
84+
});
7485

75-
if (!data.env) { data.env = { }; }
86+
}
87+
88+
data.env = data.env || {};
7689
data.env.externals = this.$previewAppPluginsService.getExternalPlugins(device);
7790

78-
const prepareData = this.$prepareDataService.getPrepareData(data.projectDir, device.platform.toLowerCase(), { ...data, nativePrepare: { skipNativePrepare: true }, watch: true });
91+
const prepareData = this.$prepareDataService.getPrepareData(data.projectDir, device.platform.toLowerCase(), { ...data, nativePrepare: { skipNativePrepare: true }, watch: true });
7992
await this.$prepareController.prepare(prepareData);
8093

81-
this.deviceInitializationPromise[device.id] = this.getInitialFilesForPlatformSafe(data, device.platform);
82-
8394
try {
84-
const payloads = await this.deviceInitializationPromise[device.id];
95+
const payloads = await this.getInitialFilesForPlatformSafe(data, device.platform);
8596
return payloads;
8697
} finally {
8798
this.deviceInitializationPromise[device.id] = null;
@@ -116,7 +127,7 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon
116127
if (status === HmrConstants.HMR_ERROR_STATUS) {
117128
const originalUseHotModuleReload = data.useHotModuleReload;
118129
data.useHotModuleReload = false;
119-
await this.syncFilesForPlatformSafe(data, { filesToSync: platformHmrData.fallbackFiles }, platform, previewDevice.id );
130+
await this.syncFilesForPlatformSafe(data, { filesToSync: platformHmrData.fallbackFiles }, platform, previewDevice.id);
120131
data.useHotModuleReload = originalUseHotModuleReload;
121132
}
122133
}));

lib/controllers/run-controller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class RunController extends EventEmitter implements IRunController {
6262
// so we cannot await it as this will cause infinite loop.
6363
const shouldAwaitPendingOperation = !stopOptions || stopOptions.shouldAwaitAllActions;
6464

65-
const deviceIdentifiersToRemove = deviceIdentifiers || _.map(liveSyncProcessInfo.deviceDescriptors, d => d.identifier);
65+
const deviceIdentifiersToRemove = (deviceIdentifiers && deviceIdentifiers.length) ? deviceIdentifiers : _.map(liveSyncProcessInfo.deviceDescriptors, d => d.identifier);
6666

6767
const removedDeviceIdentifiers = _.remove(liveSyncProcessInfo.deviceDescriptors, descriptor => _.includes(deviceIdentifiersToRemove, descriptor.identifier))
6868
.map(descriptor => descriptor.identifier);

lib/services/livesync/playground/preview-qr-code-service.ts

-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ export class PreviewQrCodeService implements IPreviewQrCodeService {
4444
const qrCodeUrl = this.$previewSdkService.getQrCodeUrl(options);
4545
const url = await this.getShortenUrl(qrCodeUrl);
4646

47-
this.$logger.info("======== qrCodeUrl ======== ", qrCodeUrl);
48-
4947
this.$logger.info();
5048
const message = `${EOL} Generating qrcode for url ${url}.`;
5149
this.$logger.trace(message);

lib/services/webpack/webpack-compiler-service.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
4545
let result;
4646

4747
if (prepareData.hmr) {
48-
result = this.getUpdatedEmittedFiles(message.emittedFiles, message.webpackRuntimeFiles, message.entryPointFiles);
48+
result = this.getUpdatedEmittedFiles(message.emittedFiles, message.chunkFiles);
4949
} else {
5050
result = { emittedFiles: message.emittedFiles, fallbackFiles: <string[]>[], hash: "" };
5151
}
@@ -218,16 +218,13 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
218218
return args;
219219
}
220220

221-
private getUpdatedEmittedFiles(emittedFiles: string[], webpackRuntimeFiles: string[], entryPointFiles: string[]) {
221+
private getUpdatedEmittedFiles(emittedFiles: string[], chunkFiles: string[]) {
222222
let fallbackFiles: string[] = [];
223223
let hotHash;
224224
let result = emittedFiles.slice();
225225
const hotUpdateScripts = emittedFiles.filter(x => x.endsWith('.hot-update.js'));
226-
if (webpackRuntimeFiles && webpackRuntimeFiles.length) {
227-
result = result.filter(file => webpackRuntimeFiles.indexOf(file) === -1);
228-
}
229-
if (entryPointFiles && entryPointFiles.length) {
230-
result = result.filter(file => entryPointFiles.indexOf(file) === -1);
226+
if (chunkFiles && chunkFiles.length) {
227+
result = result.filter(file => chunkFiles.indexOf(file) === -1);
231228
}
232229
hotUpdateScripts.forEach(hotUpdateScript => {
233230
const { name, hash } = this.parseHotUpdateChunkName(hotUpdateScript);

lib/services/webpack/webpack.d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ declare global {
3434

3535
interface IWebpackEmitMessage {
3636
emittedFiles: string[];
37-
webpackRuntimeFiles: string[];
38-
entryPointFiles: string[];
37+
chunkFiles: string[];
3938
}
4039

4140
interface IPlatformProjectService extends NodeJS.EventEmitter, IPlatformProjectServiceBase {

test/controllers/run-controller.ts

+6
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ describe("RunController", () => {
240240
currentDeviceIdentifiers: ["device1", "device2", "device3"],
241241
expectedDeviceIdentifiers: ["device1"],
242242
deviceIdentifiersToBeStopped: ["device1", "device4"]
243+
},
244+
{
245+
name: "stops LiveSync operation for all devices when stop method is called with empty array",
246+
currentDeviceIdentifiers: ["device1", "device2", "device3"],
247+
expectedDeviceIdentifiers: ["device1", "device2", "device3"],
248+
deviceIdentifiersToBeStopped: []
243249
}
244250
];
245251

0 commit comments

Comments
 (0)