nativescript 9.1.0-alpha.14 → 9.1.0-alpha.15

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.
@@ -44,6 +44,12 @@ class BundlerCompilerService extends events_1.EventEmitter {
44
44
  getViteDistOutputPath(projectDir) {
45
45
  return path.join(projectDir, process.env.NS_VITE_DIST_DIR || constants_1.VITE_DIST_FOLDER_NAME);
46
46
  }
47
+ getViteBuildPaths(platformData, projectData) {
48
+ return {
49
+ distOutput: this.getViteDistOutputPath(projectData.projectDir),
50
+ destDir: path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName),
51
+ };
52
+ }
47
53
  async compileWithWatch(platformData, projectData, prepareData) {
48
54
  return new Promise(async (resolve, reject) => {
49
55
  if (this.bundlerProcesses[platformData.platformNameLowerCase]) {
@@ -88,8 +94,7 @@ class BundlerCompilerService extends events_1.EventEmitter {
88
94
  console.log("Received Vite IPC message:", message);
89
95
  }
90
96
  // Copy Vite output files directly to platform destination
91
- const distOutput = this.getViteDistOutputPath(projectData.projectDir);
92
- const destDir = path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName);
97
+ const { distOutput, destDir } = this.getViteBuildPaths(platformData, projectData);
93
98
  if (debugLog) {
94
99
  console.log(`Copying from ${distOutput} to ${destDir}.`);
95
100
  }
@@ -256,17 +261,19 @@ class BundlerCompilerService extends events_1.EventEmitter {
256
261
  // is left empty (or worse, runs stale dev/HMR artifacts from
257
262
  // a previous `ns debug` run) and the runtime crashes on
258
263
  // launch with `Check failed: has_pending_exception()`.
259
- if (isVite) {
260
- try {
261
- const distOutput = this.getViteDistOutputPath(projectData.projectDir);
262
- const destDir = path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName);
263
- this.copyViteBundleToNative(distOutput, destDir);
264
- }
265
- catch (copyErr) {
266
- this.$logger.warn(`Failed to copy Vite output to platform destination: ${copyErr.message}`);
264
+ // The copy must succeed for the build to succeed — a build
265
+ // whose bundle never reached the native app is not a
266
+ // successful build, so copy failures reject here.
267
+ try {
268
+ if (isVite) {
269
+ const { distOutput, destDir } = this.getViteBuildPaths(platformData, projectData);
270
+ this.copyViteBundleToNative(distOutput, destDir, null, true);
267
271
  }
272
+ resolve();
273
+ }
274
+ catch (error) {
275
+ reject(error);
268
276
  }
269
- resolve();
270
277
  }
271
278
  else {
272
279
  const error = new Error(`Executing ${projectData.bundler} failed with exit code ${exitCode}.`);
@@ -732,7 +739,7 @@ class BundlerCompilerService extends events_1.EventEmitter {
732
739
  getBundler() {
733
740
  return this.$projectConfigService.getValue(`bundler`, "webpack");
734
741
  }
735
- copyViteBundleToNative(distOutput, destDir, specificFiles = null) {
742
+ copyViteBundleToNative(distOutput, destDir, specificFiles = null, failOnError = false) {
736
743
  // Clean and copy Vite output to native platform folder
737
744
  if (debugLog) {
738
745
  console.log(`Copying Vite bundle from "${distOutput}" to "${destDir}".`);
@@ -764,22 +771,27 @@ class BundlerCompilerService extends events_1.EventEmitter {
764
771
  if (debugLog) {
765
772
  console.log("Full build: Copying all files.");
766
773
  }
774
+ // Validate the source before touching the destination — cleaning
775
+ // destDir first would wipe a previously good bundle and leave an
776
+ // empty app folder behind a missing Vite output.
777
+ if (!this.$fs.exists(distOutput)) {
778
+ throw new Error(`Vite output directory does not exist: ${distOutput}`);
779
+ }
767
780
  // Clean destination directory
768
781
  if (this.$fs.exists(destDir)) {
769
782
  this.$fs.deleteDirectory(destDir);
770
783
  }
771
784
  this.$fs.createDirectory(destDir);
772
785
  // Copy all files from dist to platform destination
773
- if (this.$fs.exists(distOutput)) {
774
- this.copyRecursiveSync(distOutput, destDir);
775
- }
776
- else {
777
- this.$logger.warn(`Vite output directory does not exist: ${distOutput}`);
778
- }
786
+ this.copyRecursiveSync(distOutput, destDir);
779
787
  }
780
788
  }
781
789
  catch (error) {
782
- this.$logger.warn(`Failed to copy Vite bundle: ${error.message}`);
790
+ const copyError = error instanceof Error ? error : new Error(String(error));
791
+ if (failOnError) {
792
+ throw copyError;
793
+ }
794
+ this.$logger.warn(`Failed to copy Vite bundle: ${copyError.message}`);
783
795
  }
784
796
  }
785
797
  getIncrementalFilesToCopy(emittedFiles) {
@@ -62,12 +62,10 @@ class SPMService {
62
62
  this.$logger.trace("SPM: no SPM packages to apply.");
63
63
  return;
64
64
  }
65
- // one compact line naming every package and where it comes from —
66
- // when resolution is slow or fails, this is the first thing needed
67
- // to tell WHICH dependency is responsible.
68
- this.$logger.info(`Swift Packages: ${spmPackages
69
- .map((pkg) => this.describePackageSource(pkg))
70
- .join(", ")}`);
65
+ // name every package and where it comes from — when resolution is
66
+ // slow or fails, this is the first thing needed to tell WHICH
67
+ // dependency is responsible.
68
+ this.$logger.info(this.formatPackageListing(spmPackages));
71
69
  const project = new trapezedev_project_1.MobileProject(platformData.projectRoot, {
72
70
  ios: {
73
71
  path: ".",
@@ -179,7 +177,7 @@ class SPMService {
179
177
  spinner.stopAndPersist({
180
178
  symbol: color_1.color.yellow("ℹ"),
181
179
  text: color_1.color.yellow(`the "${fetchingPackageRef}" package is hosted in a repository with a large git history — ` +
182
- `SwiftPM clones the entire repository on first fetch, which can take a long time.\n` +
180
+ `SwiftPM clones the entire repository on first fetch, which can take a long time.${os.EOL}` +
183
181
  ` cache: ${SPMService.SWIFTPM_REPO_CACHE}`),
184
182
  });
185
183
  spinner.start();
@@ -189,7 +187,8 @@ class SPMService {
189
187
  }, 1000);
190
188
  const onProgress = (chunk) => {
191
189
  lineBuffer += chunk.data;
192
- const lines = lineBuffer.split("\n");
190
+ // tolerate CRLF as well as LF so parsed lines never carry a stray \r
191
+ const lines = lineBuffer.split(/\r?\n/);
193
192
  // keep the last (possibly partial) line in the buffer
194
193
  lineBuffer = lines.pop();
195
194
  for (const line of lines) {
@@ -335,6 +334,17 @@ class SPMService {
335
334
  const seconds = totalSeconds % 60;
336
335
  return `${minutes}m ${seconds}s`;
337
336
  }
337
+ /**
338
+ * Multi-line listing of every package and its source — one package per
339
+ * line, separated by the platform EOL so entries never clump together in
340
+ * terminal output on macOS, Windows, or Linux.
341
+ */
342
+ formatPackageListing(spmPackages) {
343
+ return [
344
+ "Swift Packages:",
345
+ ...spmPackages.map((pkg) => ` ${this.describePackageSource(pkg)}`),
346
+ ].join(os.EOL);
347
+ }
338
348
  /**
339
349
  * One-line description of a package and where it resolves from, e.g.
340
350
  * "FontManager (1.0.12 · https://github.com/NativeScript/font-manager.git)"
@@ -364,8 +374,7 @@ class SPMService {
364
374
  let total = 0;
365
375
  for (const entry of entries) {
366
376
  if (entry.isDirectory() &&
367
- (entry.name === packageRef ||
368
- entry.name.startsWith(`${packageRef}-`))) {
377
+ (entry.name === packageRef || entry.name.startsWith(`${packageRef}-`))) {
369
378
  total += this.getDirectorySizeBytes(path.join(SPMService.SWIFTPM_REPO_CACHE, entry.name));
370
379
  }
371
380
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nativescript",
3
3
  "main": "./lib/nativescript-cli-lib.js",
4
- "version": "9.1.0-alpha.14",
4
+ "version": "9.1.0-alpha.15",
5
5
  "author": "NativeScript <oss@nativescript.org>",
6
6
  "description": "Command-line interface for building NativeScript projects",
7
7
  "bin": {
@@ -60,7 +60,7 @@
60
60
  "@npmcli/arborist": "9.1.8",
61
61
  "@nstudio/trapezedev-project": "7.2.4",
62
62
  "@rigor789/resolve-package-path": "1.0.7",
63
- "axios": "1.13.5",
63
+ "axios": "1.18.1",
64
64
  "byline": "5.0.0",
65
65
  "chokidar": "^3.6.0",
66
66
  "cli-table3": "0.6.5",
@@ -96,7 +96,7 @@
96
96
  "qrcode-terminal": "0.12.0",
97
97
  "semver": "7.7.3",
98
98
  "shelljs": "0.10.0",
99
- "simple-git": "3.30.0",
99
+ "simple-git": "3.36.0",
100
100
  "simple-plist": "1.4.0",
101
101
  "source-map": "0.7.6",
102
102
  "tar": "7.5.9",