nativescript 8.2.4-alpha.1 → 8.3.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/test-deps-versions-generated.json +1 -1
- package/lib/commands/create-project.js +1 -1
- package/lib/commands/preview.js +59 -3
- package/lib/controllers/run-controller.js +1 -11
- package/lib/definitions/hmr-status-service.d.ts +0 -1
- package/lib/services/hmr-status-service.js +1 -14
- package/lib/services/webpack/webpack-compiler-service.js +11 -24
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"@jsdevtools/coverage-istanbul-loader":"3.0.5","karma":"6.
|
|
1
|
+
{"@jsdevtools/coverage-istanbul-loader":"3.0.5","karma":"6.4.0","karma-coverage":"2.2.0","karma-nativescript-launcher":"0.4.0","mocha":"10.0.0","karma-mocha":"2.0.1","karma-chai":"0.1.0","karma-jasmine":"5.1.0","karma-qunit":"4.1.2","@types/karma-chai":"0.1.3","@types/mocha":"9.1.1","@types/jasmine":"4.0.3","@types/qunit":"2.19.2","nyc":"15.1.0"}
|
|
@@ -82,7 +82,7 @@ class CreateProjectCommand {
|
|
|
82
82
|
selectedTemplate = yield this.interactiveFlavorAndTemplateSelection(getNextInteractiveAdverb(), getNextInteractiveAdverb());
|
|
83
83
|
}
|
|
84
84
|
this.createdProjectData = yield this.$projectService.createProject({
|
|
85
|
-
projectName,
|
|
85
|
+
projectName: projectName,
|
|
86
86
|
template: selectedTemplate,
|
|
87
87
|
appId: this.$options.appid,
|
|
88
88
|
pathToProject: this.$options.path,
|
package/lib/commands/preview.js
CHANGED
|
@@ -11,15 +11,71 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.PreviewCommand = void 0;
|
|
13
13
|
const yok_1 = require("../common/yok");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const resolve_package_path_1 = require("@rigor789/resolve-package-path");
|
|
16
|
+
const constants_1 = require("../constants");
|
|
17
|
+
const PREVIEW_CLI_PACKAGE = "@nativescript/preview-cli";
|
|
14
18
|
class PreviewCommand {
|
|
15
|
-
constructor($errors) {
|
|
19
|
+
constructor($logger, $errors, $projectData, $packageManager, $childProcess, $options) {
|
|
20
|
+
this.$logger = $logger;
|
|
16
21
|
this.$errors = $errors;
|
|
22
|
+
this.$projectData = $projectData;
|
|
23
|
+
this.$packageManager = $packageManager;
|
|
24
|
+
this.$childProcess = $childProcess;
|
|
25
|
+
this.$options = $options;
|
|
17
26
|
this.allowedParameters = [];
|
|
18
27
|
}
|
|
28
|
+
getPreviewCLIPath() {
|
|
29
|
+
return (0, resolve_package_path_1.resolvePackagePath)(PREVIEW_CLI_PACKAGE, {
|
|
30
|
+
paths: [this.$projectData.projectDir],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
19
33
|
execute(args) {
|
|
20
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
this.$
|
|
22
|
-
|
|
35
|
+
if (!this.$options.disableNpmInstall) {
|
|
36
|
+
yield this.$packageManager.install(`${PREVIEW_CLI_PACKAGE}@latest`, this.$projectData.projectDir, {
|
|
37
|
+
"save-dev": true,
|
|
38
|
+
"save-exact": true,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const previewCLIPath = this.getPreviewCLIPath();
|
|
42
|
+
if (!previewCLIPath) {
|
|
43
|
+
const packageManagerName = yield this.$packageManager.getPackageManagerName();
|
|
44
|
+
let installCommand = "";
|
|
45
|
+
switch (packageManagerName) {
|
|
46
|
+
case constants_1.PackageManagers.npm:
|
|
47
|
+
installCommand = "npm install --save-dev @nativescript/preview-cli";
|
|
48
|
+
break;
|
|
49
|
+
case constants_1.PackageManagers.yarn:
|
|
50
|
+
installCommand = "yarn add -D @nativescript/preview-cli";
|
|
51
|
+
break;
|
|
52
|
+
case constants_1.PackageManagers.pnpm:
|
|
53
|
+
installCommand = "pnpm install --save-dev @nativescript/preview-cli";
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
this.$logger.info([
|
|
57
|
+
`Uhh ohh, no Preview CLI found.`,
|
|
58
|
+
"",
|
|
59
|
+
`This should not happen under regular circumstances, but seems like it did somehow... :(`,
|
|
60
|
+
`Good news though, you can install the Preview CLI by running`,
|
|
61
|
+
"",
|
|
62
|
+
" " + installCommand.green,
|
|
63
|
+
"",
|
|
64
|
+
"Once installed, run this command again and everything should work!",
|
|
65
|
+
"If it still fails, you can invoke the preview-cli directly as a last resort with",
|
|
66
|
+
"",
|
|
67
|
+
" ./node_modules/.bin/preview-cli".cyan,
|
|
68
|
+
"",
|
|
69
|
+
"And if you are still having issues, try again - or reach out on Discord/open an issue on GitHub.",
|
|
70
|
+
].join("\n"));
|
|
71
|
+
this.$errors.fail("Running preview failed.");
|
|
72
|
+
}
|
|
73
|
+
const previewCLIBinPath = path.resolve(previewCLIPath, "./dist/index.js");
|
|
74
|
+
const commandIndex = process.argv.indexOf("preview");
|
|
75
|
+
const commandArgs = process.argv.slice(commandIndex + 1);
|
|
76
|
+
this.$childProcess.spawn(previewCLIBinPath, commandArgs, {
|
|
77
|
+
stdio: "inherit",
|
|
78
|
+
});
|
|
23
79
|
});
|
|
24
80
|
}
|
|
25
81
|
canExecute(args) {
|
|
@@ -47,7 +47,6 @@ class RunController extends events_1.EventEmitter {
|
|
|
47
47
|
this.$projectChangesService = $projectChangesService;
|
|
48
48
|
this.$projectDataService = $projectDataService;
|
|
49
49
|
this.prepareReadyEventHandler = null;
|
|
50
|
-
this.currentStartingHash = "";
|
|
51
50
|
}
|
|
52
51
|
run(runData) {
|
|
53
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -434,17 +433,8 @@ class RunController extends events_1.EventEmitter {
|
|
|
434
433
|
},
|
|
435
434
|
});
|
|
436
435
|
yield this.refreshApplication(projectData, liveSyncResultInfo, data, deviceDescriptor, fullSyncAction);
|
|
437
|
-
|
|
438
|
-
if (!liveSyncResultInfo.didRecover &&
|
|
439
|
-
isInHMRMode &&
|
|
440
|
-
filesToSync.some((file) => file.includes("hot-update")) &&
|
|
441
|
-
(!startingHash ||
|
|
442
|
-
this.currentStartingHash === startingHash ||
|
|
443
|
-
startingHash === data.hmrData.hash)) {
|
|
444
|
-
this.currentStartingHash = startingHash;
|
|
445
|
-
console.time("hmrStatus");
|
|
436
|
+
if (!liveSyncResultInfo.didRecover && isInHMRMode) {
|
|
446
437
|
const status = yield this.$hmrStatusService.getHmrStatus(device.deviceInfo.identifier, data.hmrData.hash);
|
|
447
|
-
console.timeEnd("hmrStatus");
|
|
448
438
|
if (status === constants_1.HmrConstants.HMR_ERROR_STATUS) {
|
|
449
439
|
yield fullSyncAction();
|
|
450
440
|
liveSyncResultInfo.isFullSync = true;
|
|
@@ -21,20 +21,13 @@ class HmrStatusService {
|
|
|
21
21
|
getHmrStatus(deviceId, operationHash) {
|
|
22
22
|
return new Promise((resolve, reject) => {
|
|
23
23
|
const key = `${deviceId}${operationHash}`;
|
|
24
|
-
this.$logger.trace("INITIAL CHECKING HASH STATUS", operationHash);
|
|
25
|
-
const status = this.getStatusByKey(operationHash);
|
|
26
|
-
if (status) {
|
|
27
|
-
resolve(status);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
24
|
let retryCount = 40;
|
|
31
25
|
this.intervals[key] = setInterval(() => {
|
|
32
|
-
this.$logger.trace("CHECKING HASH STATUS", operationHash);
|
|
33
26
|
const status = this.getStatusByKey(key);
|
|
34
27
|
if (status || retryCount === 0) {
|
|
35
28
|
clearInterval(this.intervals[key]);
|
|
36
29
|
this.intervals[key] = null;
|
|
37
|
-
resolve(status
|
|
30
|
+
resolve(status);
|
|
38
31
|
}
|
|
39
32
|
else {
|
|
40
33
|
retryCount--;
|
|
@@ -71,9 +64,6 @@ class HmrStatusService {
|
|
|
71
64
|
regex: /\[HMR]\[(.+)]\s*(\w+)\s*\|/,
|
|
72
65
|
handler: (matches, deviceId) => {
|
|
73
66
|
const [hash, status] = matches.slice(1);
|
|
74
|
-
if (status.trim() === "boot") {
|
|
75
|
-
this.startingBundleHash = hash;
|
|
76
|
-
}
|
|
77
67
|
const mappedStatus = statusStringMap[status.trim()];
|
|
78
68
|
if (mappedStatus) {
|
|
79
69
|
this.setData(deviceId, hash, statusStringMap[status]);
|
|
@@ -82,9 +72,6 @@ class HmrStatusService {
|
|
|
82
72
|
name: "hmr-status",
|
|
83
73
|
});
|
|
84
74
|
}
|
|
85
|
-
getStartingHash() {
|
|
86
|
-
return this.startingBundleHash;
|
|
87
|
-
}
|
|
88
75
|
handleAppCrash(matches, deviceId) {
|
|
89
76
|
for (const operationId in this.hashOperationStatuses) {
|
|
90
77
|
const operation = this.hashOperationStatuses[operationId];
|
|
@@ -40,8 +40,6 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
40
40
|
this.$packageInstallationManager = $packageInstallationManager;
|
|
41
41
|
this.webpackProcesses = {};
|
|
42
42
|
this.expectedHashes = {};
|
|
43
|
-
this.hashQueue = [];
|
|
44
|
-
this.lastEmittedHash = "";
|
|
45
43
|
}
|
|
46
44
|
compileWithWatch(platformData, projectData, prepareData) {
|
|
47
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -59,12 +57,6 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
59
57
|
if (typeof message === "object" &&
|
|
60
58
|
"version" in message &&
|
|
61
59
|
"type" in message) {
|
|
62
|
-
const currentHash = message.hash;
|
|
63
|
-
if (this.hashQueue.length == 0 ||
|
|
64
|
-
this.hashQueue[this.hashQueue.length - 1] !== currentHash) {
|
|
65
|
-
this.hashQueue.push(currentHash);
|
|
66
|
-
}
|
|
67
|
-
this.currentCompilationHash = currentHash;
|
|
68
60
|
if (isFirstWebpackWatchCompilation) {
|
|
69
61
|
isFirstWebpackWatchCompilation = false;
|
|
70
62
|
resolve(childProcess);
|
|
@@ -341,30 +333,25 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
341
333
|
this.$logger.trace("Webpack build done!");
|
|
342
334
|
const files = message.data.emittedAssets.map((asset) => path.join(platformData.appDestinationDirectoryPath, "app", asset));
|
|
343
335
|
const staleFiles = message.data.staleAssets.map((asset) => path.join(platformData.appDestinationDirectoryPath, "app", asset));
|
|
336
|
+
const lastHash = (() => {
|
|
337
|
+
const fileWithLastHash = files.find((fileName) => fileName.endsWith("hot-update.js"));
|
|
338
|
+
if (!fileWithLastHash) {
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
const matches = fileWithLastHash.match(/\.(.+).hot-update\.js/);
|
|
342
|
+
if (matches) {
|
|
343
|
+
return matches[1];
|
|
344
|
+
}
|
|
345
|
+
})();
|
|
344
346
|
if (!files.length) {
|
|
345
347
|
return;
|
|
346
348
|
}
|
|
347
|
-
let currentIdx = 0;
|
|
348
|
-
let lastHash = this.hashQueue.length > 0
|
|
349
|
-
? this.hashQueue[currentIdx]
|
|
350
|
-
: this.currentCompilationHash;
|
|
351
|
-
while (lastHash !== this.currentCompilationHash) {
|
|
352
|
-
if (files.some((f) => f.endsWith(`${lastHash}.hot-update.js`))) {
|
|
353
|
-
this.hashQueue.splice(0, currentIdx + 1);
|
|
354
|
-
break;
|
|
355
|
-
}
|
|
356
|
-
currentIdx++;
|
|
357
|
-
lastHash =
|
|
358
|
-
this.hashQueue.length > currentIdx
|
|
359
|
-
? this.hashQueue[currentIdx]
|
|
360
|
-
: this.currentCompilationHash;
|
|
361
|
-
}
|
|
362
349
|
this.emit(constants_1.WEBPACK_COMPILATION_COMPLETE, {
|
|
363
350
|
files,
|
|
364
351
|
staleFiles,
|
|
365
352
|
hasOnlyHotUpdateFiles: prepareData.hmr,
|
|
366
353
|
hmrData: {
|
|
367
|
-
hash: lastHash,
|
|
354
|
+
hash: lastHash || message.hash,
|
|
368
355
|
fallbackFiles: [],
|
|
369
356
|
},
|
|
370
357
|
platform: platformData.platformNameLowerCase,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nativescript",
|
|
3
3
|
"preferGlobal": true,
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.3.0-beta.0",
|
|
5
5
|
"author": "NativeScript <support@nativescript.org>",
|
|
6
6
|
"description": "Command-line interface for building NativeScript projects",
|
|
7
7
|
"bin": {
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"minimatch": "3.0.4",
|
|
87
87
|
"mkdirp": "1.0.4",
|
|
88
88
|
"mute-stream": "0.0.8",
|
|
89
|
-
"nativescript-dev-xcode": "0.
|
|
89
|
+
"nativescript-dev-xcode": "0.2.1",
|
|
90
90
|
"nativescript-preview-sdk": "0.4.2",
|
|
91
91
|
"open": "7.1.0",
|
|
92
92
|
"ora": "5.0.0",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"shelljs": "0.8.4",
|
|
107
107
|
"simple-git": "^2.20.1",
|
|
108
108
|
"simple-plist": "1.1.0",
|
|
109
|
-
"source-map": "0.7.
|
|
109
|
+
"source-map": "0.7.4",
|
|
110
110
|
"stringify-package": "1.0.1",
|
|
111
111
|
"tabtab": "https://github.com/Icenium/node-tabtab/tarball/master",
|
|
112
112
|
"tar": "6.0.2",
|