@akylas/nativescript-cli 8.9.4 → 8.10.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 +10 -10
- package/docs/build-jekyll-md.sh +1 -1
- package/docs/man_pages/config/config-get.md +36 -0
- package/docs/man_pages/config/config-set.md +40 -0
- package/docs/man_pages/config/config.md +39 -0
- package/docs/man_pages/project/hooks/hooks.md +35 -0
- package/docs/man_pages/start.md +1 -0
- package/lib/.d.ts +8 -3
- package/lib/bootstrap.js +3 -1
- package/lib/color.js +38 -7
- package/lib/commands/build.js +18 -2
- package/lib/commands/clean.js +1 -2
- package/lib/commands/config.js +1 -1
- package/lib/commands/embedding/embed.js +1 -1
- package/lib/commands/hooks/common.js +79 -0
- package/lib/commands/hooks/hooks-lock.js +100 -0
- package/lib/commands/hooks/hooks.js +71 -0
- package/lib/commands/post-install.js +2 -2
- package/lib/commands/typings.js +29 -18
- package/lib/common/definitions/extensibility.d.ts +2 -2
- package/lib/common/definitions/mobile.d.ts +72 -72
- package/lib/common/header.js +3 -3
- package/lib/common/logger/layouts/cli-layout.js +1 -1
- package/lib/common/logger/logger.js +3 -3
- package/lib/common/mobile/android/android-device.js +1 -1
- package/lib/common/mobile/android/android-emulator-services.js +8 -6
- package/lib/common/mobile/device-log-provider.js +3 -4
- package/lib/common/project-helper.js +15 -2
- package/lib/common/verify-node-version.js +1 -1
- package/lib/constants.js +7 -4
- package/lib/controllers/migrate-controller.js +3 -4
- package/lib/controllers/prepare-controller.js +9 -9
- package/lib/controllers/run-controller.js +1 -1
- package/lib/declarations.d.ts +5 -0
- package/lib/definitions/hooks.d.ts +1 -0
- package/lib/definitions/nativescript-dev-xcode.d.ts +25 -1
- package/lib/definitions/project.d.ts +52 -1
- package/lib/definitions/temp-service.d.ts +6 -2
- package/lib/helpers/key-command-helper.js +2 -1
- package/lib/nativescript-cli.js +28 -0
- package/lib/options.js +4 -0
- package/lib/project-data.js +10 -4
- package/lib/services/analytics/analytics-broker-process.js +1 -1
- package/lib/services/analytics-settings-service.js +2 -1
- package/lib/services/android/gradle-build-args-service.js +7 -3
- package/lib/services/android/gradle-build-service.js +4 -1
- package/lib/services/android-project-service.js +12 -10
- package/lib/services/{webpack/webpack-compiler-service.js → bundler/bundler-compiler-service.js} +254 -85
- package/lib/services/bundler/bundler.js +2 -0
- package/lib/services/extensibility-service.js +1 -1
- package/lib/services/ios/spm-service.js +13 -2
- package/lib/services/ios/xcodebuild-args-service.js +7 -5
- package/lib/services/ios-project-service.js +0 -1
- package/lib/services/ios-watch-app-service.js +540 -16
- package/lib/services/livesync/android-livesync-tool.js +3 -1
- package/lib/services/plugins-service.js +1 -0
- package/lib/services/project-changes-service.js +1 -1
- package/lib/services/temp-service.js +16 -4
- package/lib/services/versions-service.js +2 -1
- package/package.json +35 -36
- package/vendor/aab-tool/README.txt +1 -1
- package/vendor/aab-tool/bundletool.jar +0 -0
- package/vendor/gradle-app/app/build.gradle +20 -13
- package/vendor/gradle-app/app/gradle.properties +45 -0
- package/vendor/gradle-plugin/build.gradle +7 -6
- package/lib/services/webpack/webpack.d.ts +0 -227
|
@@ -17,7 +17,10 @@ class GradleBuildService extends events_1.EventEmitter {
|
|
|
17
17
|
const buildTaskArgs = await this.$gradleBuildArgsService.getBuildTaskArgs(buildData);
|
|
18
18
|
if (buildData.buildFilterDevicesArch) {
|
|
19
19
|
let devices = this.$devicesService.getDevicesForPlatform(buildData.platform);
|
|
20
|
-
if (buildData.
|
|
20
|
+
if (buildData.device) {
|
|
21
|
+
devices = devices.filter((d) => d.deviceInfo.identifier === buildData.device);
|
|
22
|
+
}
|
|
23
|
+
else if (buildData.emulator) {
|
|
21
24
|
devices = devices.filter((d) => d.isEmulator);
|
|
22
25
|
}
|
|
23
26
|
const abis = devices
|
|
@@ -448,17 +448,19 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
|
|
|
448
448
|
if (!this.$fs.exists(apkOutputPath)) {
|
|
449
449
|
return;
|
|
450
450
|
}
|
|
451
|
-
const device = this.$devicesService
|
|
452
|
-
.getDevicesForPlatform(deviceDescriptor.buildData.platform)
|
|
453
|
-
.filter((d) => d.deviceInfo.identifier === deviceDescriptor.identifier)[0];
|
|
454
|
-
const abis = device.deviceInfo.abis.filter((a) => !!a && a.length)[0];
|
|
455
451
|
const directoryContent = this.$fs.readDirectory(apkOutputPath);
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
452
|
+
if (!directoryContent.find(f => f.indexOf("universal") !== -1)) {
|
|
453
|
+
const device = this.$devicesService
|
|
454
|
+
.getDevicesForPlatform(deviceDescriptor.buildData.platform)
|
|
455
|
+
.filter((d) => d.deviceInfo.identifier === deviceDescriptor.identifier)[0];
|
|
456
|
+
const abis = device.deviceInfo.abis.filter((a) => !!a && a.length)[0];
|
|
457
|
+
const regexp = new RegExp(`${abis}.*\.apk`);
|
|
458
|
+
const files = _.filter(directoryContent, (entry) => {
|
|
459
|
+
return regexp.test(entry);
|
|
460
|
+
});
|
|
461
|
+
if (files.length === 0) {
|
|
462
|
+
changesInfo.nativeChanged = true;
|
|
463
|
+
}
|
|
462
464
|
}
|
|
463
465
|
}
|
|
464
466
|
});
|
package/lib/services/{webpack/webpack-compiler-service.js → bundler/bundler-compiler-service.js}
RENAMED
|
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.BundlerCompilerService = void 0;
|
|
10
10
|
const path = require("path");
|
|
11
11
|
const semver = require("semver");
|
|
12
12
|
const _ = require("lodash");
|
|
@@ -15,8 +15,9 @@ const decorators_1 = require("../../common/decorators");
|
|
|
15
15
|
const constants_1 = require("../../constants");
|
|
16
16
|
const yok_1 = require("../../common/yok");
|
|
17
17
|
const package_path_helper_1 = require("../../helpers/package-path-helper");
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const debugLog = false;
|
|
19
|
+
class BundlerCompilerService extends events_1.EventEmitter {
|
|
20
|
+
constructor($options, $errors, $childProcess, $fs, $hooksService, $hostInfo, $logger, $mobileHelper, $cleanupService, $packageManager, $packageInstallationManager, $projectConfigService) {
|
|
20
21
|
super();
|
|
21
22
|
this.$options = $options;
|
|
22
23
|
this.$errors = $errors;
|
|
@@ -29,19 +30,21 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
29
30
|
this.$cleanupService = $cleanupService;
|
|
30
31
|
this.$packageManager = $packageManager;
|
|
31
32
|
this.$packageInstallationManager = $packageInstallationManager;
|
|
32
|
-
this
|
|
33
|
+
this.$projectConfigService = $projectConfigService;
|
|
34
|
+
this.bundlerProcesses = {};
|
|
33
35
|
this.expectedHashes = {};
|
|
34
36
|
}
|
|
35
37
|
async compileWithWatch(platformData, projectData, prepareData) {
|
|
36
38
|
return new Promise(async (resolve, reject) => {
|
|
37
|
-
if (this.
|
|
39
|
+
if (this.bundlerProcesses[platformData.platformNameLowerCase]) {
|
|
38
40
|
resolve(void 0);
|
|
39
41
|
return;
|
|
40
42
|
}
|
|
41
|
-
let
|
|
43
|
+
let isFirstBundlerWatchCompilation = true;
|
|
42
44
|
prepareData.watch = true;
|
|
43
45
|
try {
|
|
44
|
-
const childProcess = await this.
|
|
46
|
+
const childProcess = await this.startBundleProcess(platformData, projectData, prepareData);
|
|
47
|
+
const isVite = this.getBundler() === "vite";
|
|
45
48
|
childProcess.stdout.on("data", function (data) {
|
|
46
49
|
process.stdout.write(data);
|
|
47
50
|
});
|
|
@@ -49,25 +52,77 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
49
52
|
process.stderr.write(data);
|
|
50
53
|
});
|
|
51
54
|
childProcess.on("message", (message) => {
|
|
52
|
-
this.$logger.trace(
|
|
55
|
+
this.$logger.trace(`Message from ${projectData.bundler}`, message);
|
|
56
|
+
if (isVite &&
|
|
57
|
+
message &&
|
|
58
|
+
message.emittedFiles) {
|
|
59
|
+
message = message;
|
|
60
|
+
if (debugLog) {
|
|
61
|
+
console.log("Received Vite IPC message:", message);
|
|
62
|
+
}
|
|
63
|
+
const distOutput = path.join(projectData.projectDir, ".ns-vite-build");
|
|
64
|
+
const destDir = path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName);
|
|
65
|
+
if (debugLog) {
|
|
66
|
+
console.log(`Copying from ${distOutput} to ${destDir}.`);
|
|
67
|
+
}
|
|
68
|
+
if (message.buildType === "incremental" &&
|
|
69
|
+
message.emittedFiles &&
|
|
70
|
+
message.emittedFiles.length > 0) {
|
|
71
|
+
const filesToCopy = this.getIncrementalFilesToCopy(message.emittedFiles);
|
|
72
|
+
if (debugLog) {
|
|
73
|
+
console.log("Incremental build - files to copy:", filesToCopy);
|
|
74
|
+
}
|
|
75
|
+
this.copyViteBundleToNative(distOutput, destDir, filesToCopy);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
if (debugLog) {
|
|
79
|
+
console.log("Full build - copying all files.");
|
|
80
|
+
}
|
|
81
|
+
this.copyViteBundleToNative(distOutput, destDir);
|
|
82
|
+
}
|
|
83
|
+
if (isFirstBundlerWatchCompilation) {
|
|
84
|
+
isFirstBundlerWatchCompilation = false;
|
|
85
|
+
if (debugLog) {
|
|
86
|
+
console.log("Vite first build completed, resolving compileWithWatch");
|
|
87
|
+
}
|
|
88
|
+
resolve(childProcess);
|
|
89
|
+
}
|
|
90
|
+
const files = message.emittedFiles.map((file) => path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName, file));
|
|
91
|
+
const data = {
|
|
92
|
+
files,
|
|
93
|
+
hasOnlyHotUpdateFiles: message.isHMR || false,
|
|
94
|
+
hmrData: {
|
|
95
|
+
hash: message.hash || "",
|
|
96
|
+
fallbackFiles: [],
|
|
97
|
+
},
|
|
98
|
+
platform: platformData.platformNameLowerCase,
|
|
99
|
+
};
|
|
100
|
+
this.$logger.info(`Vite build completed! Files copied to native platform.`);
|
|
101
|
+
if (debugLog) {
|
|
102
|
+
console.log("Emitting BUNDLER_COMPILATION_COMPLETE for full build.");
|
|
103
|
+
}
|
|
104
|
+
this.emit(constants_1.BUNDLER_COMPILATION_COMPLETE, data);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
53
107
|
if (typeof message === "object" &&
|
|
54
108
|
"version" in message &&
|
|
55
109
|
"type" in message) {
|
|
56
|
-
if (
|
|
57
|
-
|
|
110
|
+
if (isFirstBundlerWatchCompilation) {
|
|
111
|
+
isFirstBundlerWatchCompilation = false;
|
|
58
112
|
resolve(childProcess);
|
|
59
113
|
return;
|
|
60
114
|
}
|
|
61
115
|
return this.handleHMRMessage(message, platformData, projectData, prepareData);
|
|
62
116
|
}
|
|
63
|
-
if (message ===
|
|
64
|
-
|
|
117
|
+
if (message ===
|
|
118
|
+
`${capitalizeFirstLetter(projectData.bundler)} compilation complete.`) {
|
|
119
|
+
this.$logger.info(`${capitalizeFirstLetter(projectData.bundler)} build done!`);
|
|
65
120
|
resolve(childProcess);
|
|
66
121
|
}
|
|
67
122
|
message = message;
|
|
68
123
|
if (message.emittedFiles) {
|
|
69
|
-
if (
|
|
70
|
-
|
|
124
|
+
if (isFirstBundlerWatchCompilation) {
|
|
125
|
+
isFirstBundlerWatchCompilation = false;
|
|
71
126
|
this.expectedHashes[platformData.platformNameLowerCase] =
|
|
72
127
|
prepareData.hmr ? message.hash : "";
|
|
73
128
|
return;
|
|
@@ -95,27 +150,27 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
95
150
|
},
|
|
96
151
|
platform: platformData.platformNameLowerCase,
|
|
97
152
|
};
|
|
98
|
-
this.$logger.trace(
|
|
153
|
+
this.$logger.trace(`Generated data from ${projectData.bundler} message:`, data);
|
|
99
154
|
if (data.hasOnlyHotUpdateFiles && previousHash === message.hash) {
|
|
100
155
|
return;
|
|
101
156
|
}
|
|
102
157
|
if (data.files.length) {
|
|
103
|
-
this.emit(constants_1.
|
|
158
|
+
this.emit(constants_1.BUNDLER_COMPILATION_COMPLETE, data);
|
|
104
159
|
}
|
|
105
160
|
}
|
|
106
161
|
});
|
|
107
162
|
childProcess.on("error", (err) => {
|
|
108
|
-
this.$logger.trace(`Unable to start
|
|
109
|
-
delete this.
|
|
163
|
+
this.$logger.trace(`Unable to start ${projectData.bundler} process in watch mode. Error is: ${err}`);
|
|
164
|
+
delete this.bundlerProcesses[platformData.platformNameLowerCase];
|
|
110
165
|
reject(err);
|
|
111
166
|
});
|
|
112
167
|
childProcess.on("close", async (arg) => {
|
|
113
|
-
await this.$cleanupService.removeKillProcess(childProcess.pid.toString());
|
|
114
168
|
const exitCode = typeof arg === "number" ? arg : arg && arg.code;
|
|
115
|
-
this.$logger.trace(
|
|
116
|
-
|
|
169
|
+
this.$logger.trace(`${capitalizeFirstLetter(projectData.bundler)} process exited with code ${exitCode} when we expected it to be long living with watch.`);
|
|
170
|
+
await this.$cleanupService.removeKillProcess(childProcess.pid.toString());
|
|
171
|
+
const error = new Error(`Executing ${projectData.bundler} failed with exit code ${exitCode}.`);
|
|
117
172
|
error.code = exitCode;
|
|
118
|
-
delete this.
|
|
173
|
+
delete this.bundlerProcesses[platformData.platformNameLowerCase];
|
|
119
174
|
reject(error);
|
|
120
175
|
});
|
|
121
176
|
}
|
|
@@ -126,26 +181,26 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
126
181
|
}
|
|
127
182
|
async compileWithoutWatch(platformData, projectData, prepareData) {
|
|
128
183
|
return new Promise(async (resolve, reject) => {
|
|
129
|
-
if (this.
|
|
184
|
+
if (this.bundlerProcesses[platformData.platformNameLowerCase]) {
|
|
130
185
|
resolve();
|
|
131
186
|
return;
|
|
132
187
|
}
|
|
133
188
|
try {
|
|
134
|
-
const childProcess = await this.
|
|
189
|
+
const childProcess = await this.startBundleProcess(platformData, projectData, prepareData);
|
|
135
190
|
childProcess.on("error", (err) => {
|
|
136
|
-
this.$logger.trace(`Unable to start
|
|
137
|
-
delete this.
|
|
191
|
+
this.$logger.trace(`Unable to start ${projectData.bundler} process in non-watch mode. Error is: ${err}`);
|
|
192
|
+
delete this.bundlerProcesses[platformData.platformNameLowerCase];
|
|
138
193
|
reject(err);
|
|
139
194
|
});
|
|
140
195
|
childProcess.on("close", async (arg) => {
|
|
141
196
|
await this.$cleanupService.removeKillProcess(childProcess.pid.toString());
|
|
142
|
-
delete this.
|
|
197
|
+
delete this.bundlerProcesses[platformData.platformNameLowerCase];
|
|
143
198
|
const exitCode = typeof arg === "number" ? arg : arg && arg.code;
|
|
144
199
|
if (exitCode === 0) {
|
|
145
200
|
resolve();
|
|
146
201
|
}
|
|
147
202
|
else {
|
|
148
|
-
const error = new Error(`Executing
|
|
203
|
+
const error = new Error(`Executing ${projectData.bundler} failed with exit code ${exitCode}.`);
|
|
149
204
|
error.code = exitCode;
|
|
150
205
|
reject(error);
|
|
151
206
|
}
|
|
@@ -156,14 +211,14 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
156
211
|
}
|
|
157
212
|
});
|
|
158
213
|
}
|
|
159
|
-
async
|
|
214
|
+
async stopBundlerCompiler(platform) {
|
|
160
215
|
if (platform) {
|
|
161
|
-
await this.
|
|
216
|
+
await this.stopBundlerForPlatform(platform);
|
|
162
217
|
}
|
|
163
218
|
else {
|
|
164
|
-
const
|
|
165
|
-
for (let i = 0; i <
|
|
166
|
-
await this.
|
|
219
|
+
const bundlerPlatforms = Object.keys(this.bundlerProcesses);
|
|
220
|
+
for (let i = 0; i < bundlerPlatforms.length; i++) {
|
|
221
|
+
await this.stopBundlerForPlatform(bundlerPlatforms[i]);
|
|
167
222
|
}
|
|
168
223
|
}
|
|
169
224
|
}
|
|
@@ -172,12 +227,28 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
172
227
|
const res = currentPackageManager !== constants_1.PackageManagers.pnpm;
|
|
173
228
|
return res;
|
|
174
229
|
}
|
|
175
|
-
async
|
|
176
|
-
if (
|
|
177
|
-
this.$
|
|
230
|
+
async startBundleProcess(platformData, projectData, prepareData) {
|
|
231
|
+
if (projectData.bundlerConfigPath) {
|
|
232
|
+
if (!this.$fs.exists(projectData.bundlerConfigPath)) {
|
|
233
|
+
this.$errors.fail(`The bundler configuration file ${projectData.bundlerConfigPath} does not exist. Ensure the file exists, or update the path in ${constants_1.CONFIG_FILE_NAME_DISPLAY}.`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
if (!this.$fs.exists(projectData.bundlerConfigPath)) {
|
|
238
|
+
this.$errors.fail(`The ${projectData.bundler} configuration file ${projectData.bundlerConfigPath} does not exist. Ensure the file exists, or update the path in ${constants_1.CONFIG_FILE_NAME_DISPLAY}.`);
|
|
239
|
+
}
|
|
178
240
|
}
|
|
179
241
|
const envData = this.buildEnvData(platformData.platformNameLowerCase, projectData, prepareData);
|
|
180
|
-
const
|
|
242
|
+
const isVite = this.getBundler() === "vite";
|
|
243
|
+
const cliArgs = await this.buildEnvCommandLineParams(envData, platformData, projectData, prepareData);
|
|
244
|
+
const envParams = isVite
|
|
245
|
+
? [
|
|
246
|
+
`--mode=${prepareData.release ? "production" : "development"}`,
|
|
247
|
+
`--watch`,
|
|
248
|
+
"--",
|
|
249
|
+
...cliArgs,
|
|
250
|
+
]
|
|
251
|
+
: cliArgs;
|
|
181
252
|
const additionalNodeArgs = semver.major(process.version) <= 8 ? ["--harmony"] : [];
|
|
182
253
|
if (await this.shouldUsePreserveSymlinksOption()) {
|
|
183
254
|
additionalNodeArgs.push("--preserve-symlinks");
|
|
@@ -187,15 +258,17 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
187
258
|
}
|
|
188
259
|
const args = [
|
|
189
260
|
...additionalNodeArgs,
|
|
190
|
-
this.
|
|
191
|
-
this.
|
|
192
|
-
`--config=${projectData.
|
|
261
|
+
this.getBundlerExecutablePath(projectData),
|
|
262
|
+
isVite || this.isModernBundler(projectData) ? "build" : null,
|
|
263
|
+
`--config=${projectData.bundlerConfigPath}`,
|
|
193
264
|
...envParams,
|
|
194
265
|
].filter(Boolean);
|
|
195
|
-
if (
|
|
196
|
-
|
|
266
|
+
if (!isVite) {
|
|
267
|
+
if (prepareData.watch) {
|
|
268
|
+
args.push("--watch");
|
|
269
|
+
}
|
|
197
270
|
}
|
|
198
|
-
const stdio = prepareData.watch ? ["ipc"] : "inherit";
|
|
271
|
+
const stdio = prepareData.watch || isVite ? ["ipc"] : "inherit";
|
|
199
272
|
const options = {
|
|
200
273
|
cwd: projectData.projectDir,
|
|
201
274
|
stdio,
|
|
@@ -203,6 +276,7 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
203
276
|
options.env = {
|
|
204
277
|
...process.env,
|
|
205
278
|
NATIVESCRIPT_WEBPACK_ENV: JSON.stringify(envData),
|
|
279
|
+
NATIVESCRIPT_BUNDLER_ENV: JSON.stringify(envData),
|
|
206
280
|
};
|
|
207
281
|
if (this.$hostInfo.isWindows) {
|
|
208
282
|
Object.assign(options.env, { APPDATA: process.env.appData });
|
|
@@ -214,8 +288,11 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
214
288
|
USER_PROJECT_PLATFORMS_IOS: this.$options.hostProjectPath,
|
|
215
289
|
});
|
|
216
290
|
}
|
|
291
|
+
if (debugLog) {
|
|
292
|
+
console.log("args:", args);
|
|
293
|
+
}
|
|
217
294
|
const childProcess = this.$childProcess.spawn(process.execPath, args, options);
|
|
218
|
-
this.
|
|
295
|
+
this.bundlerProcesses[platformData.platformNameLowerCase] = childProcess;
|
|
219
296
|
await this.$cleanupService.addKillProcess(childProcess.pid.toString());
|
|
220
297
|
return childProcess;
|
|
221
298
|
}
|
|
@@ -261,13 +338,15 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
261
338
|
envFlagNames.splice(envFlagNames.indexOf("snapshot"), 1);
|
|
262
339
|
}
|
|
263
340
|
else if (this.$hostInfo.isWindows) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
341
|
+
if (projectData.bundler === "webpack") {
|
|
342
|
+
const minWebpackPluginWithWinSnapshotsVersion = "1.3.0";
|
|
343
|
+
const installedWebpackPluginVersion = await this.$packageInstallationManager.getInstalledDependencyVersion(constants_1.WEBPACK_PLUGIN_NAME, projectData.projectDir);
|
|
344
|
+
const hasWebpackPluginWithWinSnapshotsSupport = !!installedWebpackPluginVersion
|
|
345
|
+
? semver.gte(semver.coerce(installedWebpackPluginVersion), minWebpackPluginWithWinSnapshotsVersion)
|
|
346
|
+
: true;
|
|
347
|
+
if (!hasWebpackPluginWithWinSnapshotsSupport) {
|
|
348
|
+
this.$errors.fail(`In order to generate Snapshots on Windows, please upgrade your Webpack plugin version (npm i ${constants_1.WEBPACK_PLUGIN_NAME}@latest).`);
|
|
349
|
+
}
|
|
271
350
|
}
|
|
272
351
|
}
|
|
273
352
|
}
|
|
@@ -318,21 +397,21 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
318
397
|
}
|
|
319
398
|
return hotHash || "";
|
|
320
399
|
}
|
|
321
|
-
async
|
|
322
|
-
this.$logger.trace(`Stopping
|
|
323
|
-
const
|
|
324
|
-
await this.$cleanupService.removeKillProcess(
|
|
325
|
-
if (
|
|
326
|
-
|
|
327
|
-
delete this.
|
|
400
|
+
async stopBundlerForPlatform(platform) {
|
|
401
|
+
this.$logger.trace(`Stopping ${this.getBundler()} watch for platform ${platform}.`);
|
|
402
|
+
const bundlerProcess = this.bundlerProcesses[platform];
|
|
403
|
+
await this.$cleanupService.removeKillProcess(bundlerProcess.pid.toString());
|
|
404
|
+
if (bundlerProcess) {
|
|
405
|
+
bundlerProcess.kill("SIGINT");
|
|
406
|
+
delete this.bundlerProcesses[platform];
|
|
328
407
|
}
|
|
329
408
|
}
|
|
330
409
|
handleHMRMessage(message, platformData, projectData, prepareData) {
|
|
331
|
-
this.$logger.trace(
|
|
410
|
+
this.$logger.trace(`Received message from ${projectData.bundler} process:`, message);
|
|
332
411
|
if (message.type !== "compilation") {
|
|
333
412
|
return;
|
|
334
413
|
}
|
|
335
|
-
this.$logger.trace(
|
|
414
|
+
this.$logger.trace(`${capitalizeFirstLetter(projectData.bundler)} build done!`);
|
|
336
415
|
const files = message.data.emittedAssets.map((asset) => path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName, asset));
|
|
337
416
|
const staleFiles = message.data.staleAssets.map((asset) => path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName, asset));
|
|
338
417
|
const lastHash = (() => {
|
|
@@ -349,7 +428,7 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
349
428
|
if (!files.length) {
|
|
350
429
|
return;
|
|
351
430
|
}
|
|
352
|
-
this.emit(constants_1.
|
|
431
|
+
this.emit(constants_1.BUNDLER_COMPILATION_COMPLETE, {
|
|
353
432
|
files,
|
|
354
433
|
staleFiles,
|
|
355
434
|
hasOnlyHotUpdateFiles: prepareData.hmr,
|
|
@@ -360,41 +439,131 @@ class WebpackCompilerService extends events_1.EventEmitter {
|
|
|
360
439
|
platform: platformData.platformNameLowerCase,
|
|
361
440
|
});
|
|
362
441
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
442
|
+
getBundlerExecutablePath(projectData) {
|
|
443
|
+
const bundler = this.getBundler();
|
|
444
|
+
if (bundler === "vite") {
|
|
445
|
+
const packagePath = (0, package_path_helper_1.resolvePackagePath)(`vite`, {
|
|
367
446
|
paths: [projectData.projectDir],
|
|
368
447
|
});
|
|
369
448
|
if (packagePath) {
|
|
370
|
-
return path.resolve(packagePath, "
|
|
449
|
+
return path.resolve(packagePath, "bin", "vite.js");
|
|
371
450
|
}
|
|
372
451
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
452
|
+
else if (this.isModernBundler(projectData)) {
|
|
453
|
+
const webpackPluginName = this.$projectConfigService.getValue(`webpackPackageName`, constants_1.WEBPACK_PLUGIN_NAME);
|
|
454
|
+
const packagePath = (0, package_path_helper_1.resolvePackagePath)(webpackPluginName, {
|
|
455
|
+
paths: [projectData.projectDir],
|
|
456
|
+
});
|
|
457
|
+
if (packagePath) {
|
|
458
|
+
return path.resolve(packagePath, "dist", "bin", "index.js");
|
|
459
|
+
}
|
|
378
460
|
}
|
|
379
|
-
|
|
461
|
+
throw new Error('could not find bundler executable');
|
|
380
462
|
}
|
|
381
|
-
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
});
|
|
386
|
-
if (packageJSONPath) {
|
|
387
|
-
const packageData = this.$fs.readJson(packageJSONPath);
|
|
388
|
-
const ver = semver.coerce(packageData.version);
|
|
389
|
-
if (semver.satisfies(ver, ">= 5.0.0")) {
|
|
463
|
+
isModernBundler(projectData) {
|
|
464
|
+
const bundler = this.getBundler();
|
|
465
|
+
switch (bundler) {
|
|
466
|
+
case "rspack":
|
|
390
467
|
return true;
|
|
391
|
-
|
|
468
|
+
default:
|
|
469
|
+
const webpackPluginName = this.$projectConfigService.getValue(`webpackPackageName`, constants_1.WEBPACK_PLUGIN_NAME);
|
|
470
|
+
const packageJSONPath = (0, package_path_helper_1.resolvePackageJSONPath)(webpackPluginName, {
|
|
471
|
+
paths: [projectData.projectDir],
|
|
472
|
+
});
|
|
473
|
+
if (packageJSONPath) {
|
|
474
|
+
const packageData = this.$fs.readJson(packageJSONPath);
|
|
475
|
+
const ver = semver.coerce(packageData.version);
|
|
476
|
+
if (semver.satisfies(ver, ">= 5.0.0")) {
|
|
477
|
+
return true;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
break;
|
|
392
481
|
}
|
|
393
482
|
return false;
|
|
394
483
|
}
|
|
484
|
+
getBundler() {
|
|
485
|
+
return this.$projectConfigService.getValue(`bundler`, "webpack");
|
|
486
|
+
}
|
|
487
|
+
copyViteBundleToNative(distOutput, destDir, specificFiles = null) {
|
|
488
|
+
if (debugLog) {
|
|
489
|
+
console.log(`Copying Vite bundle from "${distOutput}" to "${destDir}".`);
|
|
490
|
+
}
|
|
491
|
+
try {
|
|
492
|
+
if (specificFiles) {
|
|
493
|
+
if (debugLog) {
|
|
494
|
+
console.log("Selective copy - copying specific files:", specificFiles);
|
|
495
|
+
}
|
|
496
|
+
this.$fs.createDirectory(destDir);
|
|
497
|
+
for (const file of specificFiles) {
|
|
498
|
+
const srcPath = path.join(distOutput, file);
|
|
499
|
+
const destPath = path.join(destDir, file);
|
|
500
|
+
if (!this.$fs.exists(srcPath))
|
|
501
|
+
continue;
|
|
502
|
+
this.$fs.createDirectory(path.dirname(destPath));
|
|
503
|
+
this.$fs.copyFile(srcPath, destPath);
|
|
504
|
+
if (debugLog) {
|
|
505
|
+
console.log(`Copied ${file}`);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
if (debugLog) {
|
|
511
|
+
console.log("Full build: Copying all files.");
|
|
512
|
+
}
|
|
513
|
+
if (this.$fs.exists(destDir)) {
|
|
514
|
+
this.$fs.deleteDirectory(destDir);
|
|
515
|
+
}
|
|
516
|
+
this.$fs.createDirectory(destDir);
|
|
517
|
+
if (this.$fs.exists(distOutput)) {
|
|
518
|
+
this.copyRecursiveSync(distOutput, destDir);
|
|
519
|
+
}
|
|
520
|
+
else {
|
|
521
|
+
this.$logger.warn(`Vite output directory does not exist: ${distOutput}`);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
catch (error) {
|
|
526
|
+
this.$logger.warn(`Failed to copy Vite bundle: ${error.message}`);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
getIncrementalFilesToCopy(emittedFiles) {
|
|
530
|
+
const filesToCopy = [];
|
|
531
|
+
const bundleFiles = emittedFiles.filter((file) => !file.includes("vendor") &&
|
|
532
|
+
(file.endsWith(".mjs") ||
|
|
533
|
+
file.endsWith(".js") ||
|
|
534
|
+
file.endsWith(".map")));
|
|
535
|
+
filesToCopy.push(...bundleFiles);
|
|
536
|
+
const assetFiles = emittedFiles.filter((file) => file.includes("assets/") ||
|
|
537
|
+
file.includes("static/") ||
|
|
538
|
+
file.includes("fonts/") ||
|
|
539
|
+
file.includes("images/"));
|
|
540
|
+
if (assetFiles.length > 0) {
|
|
541
|
+
filesToCopy.push(...assetFiles);
|
|
542
|
+
}
|
|
543
|
+
return [...new Set(filesToCopy)];
|
|
544
|
+
}
|
|
545
|
+
copyRecursiveSync(src, dest) {
|
|
546
|
+
this.$fs.createDirectory(dest);
|
|
547
|
+
const entries = this.$fs.readDirectory(src);
|
|
548
|
+
for (const name of entries) {
|
|
549
|
+
const srcPath = path.join(src, name);
|
|
550
|
+
const destPath = path.join(dest, name);
|
|
551
|
+
const lstats = this.$fs.getLsStats(srcPath);
|
|
552
|
+
if (lstats.isDirectory()) {
|
|
553
|
+
this.copyRecursiveSync(srcPath, destPath);
|
|
554
|
+
}
|
|
555
|
+
else if (lstats.isFile() || lstats.isSymbolicLink()) {
|
|
556
|
+
this.$fs.createDirectory(path.dirname(destPath));
|
|
557
|
+
this.$fs.copyFile(srcPath, destPath);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
395
561
|
}
|
|
396
|
-
exports.
|
|
562
|
+
exports.BundlerCompilerService = BundlerCompilerService;
|
|
397
563
|
__decorate([
|
|
398
564
|
(0, decorators_1.performanceLog)()
|
|
399
|
-
],
|
|
400
|
-
|
|
565
|
+
], BundlerCompilerService.prototype, "startBundleProcess", null);
|
|
566
|
+
function capitalizeFirstLetter(val) {
|
|
567
|
+
return String(val).charAt(0).toUpperCase() + String(val).slice(1);
|
|
568
|
+
}
|
|
569
|
+
yok_1.injector.register("bundlerCompilerService", BundlerCompilerService);
|
|
@@ -138,7 +138,7 @@ class ExtensibilityService {
|
|
|
138
138
|
return {
|
|
139
139
|
extensionName,
|
|
140
140
|
registeredCommandName: currentCommand,
|
|
141
|
-
installationMessage: `The command ${beautifiedCommandName} is registered in extension ${extensionName}. You can install it by executing '
|
|
141
|
+
installationMessage: `The command ${beautifiedCommandName} is registered in extension ${extensionName}. You can install it by executing 'ns extension install ${extensionName}'`,
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
copyOfFullArgs.splice(-1, 1);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SPMService = void 0;
|
|
4
4
|
const yok_1 = require("../../common/yok");
|
|
5
|
-
const trapezedev_project_1 = require("@
|
|
5
|
+
const trapezedev_project_1 = require("@nstudio/trapezedev-project");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
class SPMService {
|
|
8
8
|
constructor($logger, $projectConfigService, $xcodebuildCommandService, $xcodebuildArgsService) {
|
|
@@ -15,12 +15,23 @@ class SPMService {
|
|
|
15
15
|
const spmPackages = this.$projectConfigService.getValue(`${platform}.SPMPackages`, []);
|
|
16
16
|
return spmPackages;
|
|
17
17
|
}
|
|
18
|
+
mergePluginSPMPackages(appPackages, pluginPackages) {
|
|
19
|
+
const appPackageNames = new Set(appPackages.map(pkg => pkg.name));
|
|
20
|
+
for (const pluginPkg of pluginPackages) {
|
|
21
|
+
if (appPackageNames.has(pluginPkg.name)) {
|
|
22
|
+
this.$logger.trace(`SPM: app package overrides plugin package: ${pluginPkg.name}`);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
appPackages.push(pluginPkg);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
18
29
|
async applySPMPackages(platformData, projectData, pluginSpmPackages) {
|
|
19
30
|
var _a;
|
|
20
31
|
try {
|
|
21
32
|
const spmPackages = this.getSPMPackages(projectData, platformData.platformNameLowerCase);
|
|
22
33
|
if (pluginSpmPackages === null || pluginSpmPackages === void 0 ? void 0 : pluginSpmPackages.length) {
|
|
23
|
-
|
|
34
|
+
this.mergePluginSPMPackages(spmPackages, pluginSpmPackages);
|
|
24
35
|
}
|
|
25
36
|
if (!spmPackages.length) {
|
|
26
37
|
this.$logger.trace("SPM: no SPM packages to apply.");
|