Skip to content

chore: merge release in master #4799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2ed8f26
fix: don't restart application when lazy loaded code is changed in an…
Fatme Jun 30, 2019
af2f20d
fix: release the console on deploy command
Fatme Jun 30, 2019
9a35f20
fix: add package.json files from nativescript plugins to watch patterns
Fatme Jun 30, 2019
888839c
fix: fix prepare from plugin's directory
Fatme Jul 1, 2019
5877dcf
Merge pull request #4788 from NativeScript/fatme/fix-ns-plugins-packa…
Fatme Jul 1, 2019
e69de5d
Merge pull request #4787 from NativeScript/fatme/fix-exit-deploy
Fatme Jul 1, 2019
648adbb
Merge pull request #4789 from NativeScript/fatme/fix-prepare-from-plu…
Fatme Jul 1, 2019
7d4f742
fix: remove debug qr code message
rosen-vladimirov Jul 1, 2019
83609a3
fix: do not start multiple watchers
rosen-vladimirov Jul 1, 2019
d6af7bf
fix: handle preview initial sync once per device
rosen-vladimirov Jul 1, 2019
59ea8a6
fix: update dependencies to latest rc versions
rosen-vladimirov Jul 1, 2019
66f57c7
Merge pull request #4791 from NativeScript/vladimirov/update-deps-ver…
Jul 1, 2019
a09c8c0
fix: set the proper root for the auto-generated files glob matching
DimitarTachev Jul 1, 2019
ece5c31
Merge pull request #4792 from NativeScript/tachev/fix-clean-generated…
rosen-vladimirov Jul 2, 2019
54e92e2
refactor(migrate): bump the version of {N} vue to 2.3.0-rc.1
sis0k0 Jul 2, 2019
5faf40d
Merge pull request #4790 from NativeScript/vladimirov/fix-preview
rosen-vladimirov Jul 2, 2019
84a5a0c
fix: fix stop livesync when the method is called with empty array
Fatme Jul 2, 2019
6e7d673
Merge pull request #4793 from NativeScript/sis0k0/update-vue-migrate-…
rosen-vladimirov Jul 2, 2019
e6613ab
Merge pull request #4794 from NativeScript/fatme/fix-stop-livesync
Fatme Jul 2, 2019
e92cb13
Merge pull request #4786 from NativeScript/fatme/fix-ng-uglify
Fatme Jul 2, 2019
46d2cf8
fix: update the version of nativescript-dev-webpack plugin on migrate…
Fatme Jul 2, 2019
49a148f
Merge pull request #4795 from NativeScript/fatme/update-webpack-version
Fatme Jul 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export class DeployOnDeviceCommand extends ValidatePlatformCommandBase implement
public allowedParameters: ICommandParameter[] = [];

public dashedOptions = {
watch: { type: OptionType.Boolean, default: false, hasSensitiveValue: false },
hmr: { type: OptionType.Boolean, default: false, hasSensitiveValue: false },
};

Expand Down
2 changes: 1 addition & 1 deletion lib/common/project-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class ProjectHelper implements IProjectHelper {
if (this.$staticConfig.CLIENT_NAME_KEY_IN_PROJECT_FILE) {
try {
const fileContent = this.$fs.readJson(projectFilePath);
const clientSpecificData = fileContent[this.$staticConfig.CLIENT_NAME_KEY_IN_PROJECT_FILE];
const clientSpecificData = fileContent[this.$staticConfig.CLIENT_NAME_KEY_IN_PROJECT_FILE] && fileContent[this.$staticConfig.CLIENT_NAME_KEY_IN_PROJECT_FILE].id;
return !!clientSpecificData;
} catch (err) {
this.$errors.failWithoutHelp("The project file is corrupted. Additional technical information: %s", err);
Expand Down
18 changes: 9 additions & 9 deletions lib/controllers/migrate-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ export class MigrateController extends UpdateControllerBase implements IMigrateC
];

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

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

Expand Down Expand Up @@ -165,7 +165,7 @@ export class MigrateController extends UpdateControllerBase implements IMigrateC
matchBase: true,
nodir: true,
absolute: false,
root: projectData.appDirectoryPath
cwd: projectData.appDirectoryPath
};

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

const allGeneratedFiles = autoGeneratedJsFiles.concat(autoGeneratedJsMapFiles).concat(autoGeneratedCssFiles);
for (const generatedFile of allGeneratedFiles) {
const sourceFile = path.join(projectData.projectDir, generatedFile);
const sourceFile = path.join(projectData.appDirectoryPath, generatedFile);
const destinationFile = path.join(backupDir, generatedFile);
const destinationFileDir = path.dirname(destinationFile);
this.$fs.ensureDirectoryExists(destinationFileDir);
Expand Down
36 changes: 20 additions & 16 deletions lib/controllers/prepare-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,24 @@ export class PrepareController extends EventEmitter {
nativeFilesWatcher: null,
webpackCompilerProcess: null
};
}
await this.startJSWatcherWithPrepare(platformData, projectData, prepareData); // -> start watcher + initial compilation
const hasNativeChanges = await this.startNativeWatcherWithPrepare(platformData, projectData, prepareData); // -> start watcher + initial prepare
const result = { platform: platformData.platformNameLowerCase, hasNativeChanges };

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

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

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

if (this.persistedData && this.persistedData.length) {
this.emitPrepareEvent({ files: [], hasOnlyHotUpdateFiles: false, hasNativeChanges: result.hasNativeChanges, hmrData: null, platform: platformData.platformNameLowerCase });
return result;
}

return result;
}

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

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

const patterns = [
path.join(projectData.projectDir, PACKAGE_JSON_FILE_NAME),
path.join(projectData.getAppDirectoryPath(), PACKAGE_JSON_FILE_NAME),
path.join(projectData.getAppResourcesRelativeDirectoryPath(), platformData.normalizedPlatformName),
].concat(pluginsNativeDirectories);
]
.concat(pluginsNativeDirectories)
.concat(pluginsPackageJsonFiles);

return patterns;
}
Expand Down
33 changes: 22 additions & 11 deletions lib/controllers/preview-app-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { PrepareDataService } from "../services/prepare-data-service";
import { PreviewAppLiveSyncEvents } from "../services/livesync/playground/preview-app-constants";

export class PreviewAppController extends EventEmitter implements IPreviewAppController {
private deviceInitializationPromise: IDictionary<Promise<FilesPayload>> = {};
private deviceInitializationPromise: IDictionary<boolean> = {};
private platformPrepareHandlers: IDictionary<boolean> = {};
private promise = Promise.resolve();

constructor(
Expand Down Expand Up @@ -49,9 +50,14 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon
}

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

this.deviceInitializationPromise[device.id] = true;

if (device.uniqueId) {
await this.$analyticsService.trackEventActionInGoogleAnalytics({
action: TrackActionNames.PreviewAppData,
Expand All @@ -68,20 +74,25 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon

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

this.$prepareController.on(PREPARE_READY_EVENT_NAME, async currentPrepareData => {
await this.handlePrepareReadyEvent(data, currentPrepareData.hmrData, currentPrepareData.files, device.platform);
});
if (!this.platformPrepareHandlers[device.platform]) {
// TODO: Unset this property once the preview operation for this platform is stopped
this.platformPrepareHandlers[device.platform] = true;

// TODO: Remove the handler once the preview operation for this platform is stopped
this.$prepareController.on(PREPARE_READY_EVENT_NAME, async currentPrepareData => {
await this.handlePrepareReadyEvent(data, currentPrepareData.hmrData, currentPrepareData.files, device.platform);
});

if (!data.env) { data.env = { }; }
}

data.env = data.env || {};
data.env.externals = this.$previewAppPluginsService.getExternalPlugins(device);

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

this.deviceInitializationPromise[device.id] = this.getInitialFilesForPlatformSafe(data, device.platform);

try {
const payloads = await this.deviceInitializationPromise[device.id];
const payloads = await this.getInitialFilesForPlatformSafe(data, device.platform);
return payloads;
} finally {
this.deviceInitializationPromise[device.id] = null;
Expand Down Expand Up @@ -116,7 +127,7 @@ export class PreviewAppController extends EventEmitter implements IPreviewAppCon
if (status === HmrConstants.HMR_ERROR_STATUS) {
const originalUseHotModuleReload = data.useHotModuleReload;
data.useHotModuleReload = false;
await this.syncFilesForPlatformSafe(data, { filesToSync: platformHmrData.fallbackFiles }, platform, previewDevice.id );
await this.syncFilesForPlatformSafe(data, { filesToSync: platformHmrData.fallbackFiles }, platform, previewDevice.id);
data.useHotModuleReload = originalUseHotModuleReload;
}
}));
Expand Down
2 changes: 1 addition & 1 deletion lib/controllers/run-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class RunController extends EventEmitter implements IRunController {
// so we cannot await it as this will cause infinite loop.
const shouldAwaitPendingOperation = !stopOptions || stopOptions.shouldAwaitAllActions;

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

const removedDeviceIdentifiers = _.remove(liveSyncProcessInfo.deviceDescriptors, descriptor => _.includes(deviceIdentifiersToRemove, descriptor.identifier))
.map(descriptor => descriptor.identifier);
Expand Down
2 changes: 0 additions & 2 deletions lib/services/livesync/playground/preview-qr-code-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ export class PreviewQrCodeService implements IPreviewQrCodeService {
const qrCodeUrl = this.$previewSdkService.getQrCodeUrl(options);
const url = await this.getShortenUrl(qrCodeUrl);

this.$logger.info("======== qrCodeUrl ======== ", qrCodeUrl);

this.$logger.info();
const message = `${EOL} Generating qrcode for url ${url}.`;
this.$logger.trace(message);
Expand Down
11 changes: 4 additions & 7 deletions lib/services/webpack/webpack-compiler-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
let result;

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

private getUpdatedEmittedFiles(emittedFiles: string[], webpackRuntimeFiles: string[], entryPointFiles: string[]) {
private getUpdatedEmittedFiles(emittedFiles: string[], chunkFiles: string[]) {
let fallbackFiles: string[] = [];
let hotHash;
let result = emittedFiles.slice();
const hotUpdateScripts = emittedFiles.filter(x => x.endsWith('.hot-update.js'));
if (webpackRuntimeFiles && webpackRuntimeFiles.length) {
result = result.filter(file => webpackRuntimeFiles.indexOf(file) === -1);
}
if (entryPointFiles && entryPointFiles.length) {
result = result.filter(file => entryPointFiles.indexOf(file) === -1);
if (chunkFiles && chunkFiles.length) {
result = result.filter(file => chunkFiles.indexOf(file) === -1);
}
hotUpdateScripts.forEach(hotUpdateScript => {
const { name, hash } = this.parseHotUpdateChunkName(hotUpdateScript);
Expand Down
3 changes: 1 addition & 2 deletions lib/services/webpack/webpack.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ declare global {

interface IWebpackEmitMessage {
emittedFiles: string[];
webpackRuntimeFiles: string[];
entryPointFiles: string[];
chunkFiles: string[];
}

interface IPlatformProjectService extends NodeJS.EventEmitter, IPlatformProjectServiceBase {
Expand Down
6 changes: 6 additions & 0 deletions test/controllers/run-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ describe("RunController", () => {
currentDeviceIdentifiers: ["device1", "device2", "device3"],
expectedDeviceIdentifiers: ["device1"],
deviceIdentifiersToBeStopped: ["device1", "device4"]
},
{
name: "stops LiveSync operation for all devices when stop method is called with empty array",
currentDeviceIdentifiers: ["device1", "device2", "device3"],
expectedDeviceIdentifiers: ["device1", "device2", "device3"],
deviceIdentifiersToBeStopped: []
}
];

Expand Down