nativescript 9.0.0-alpha.11 → 9.0.0-alpha.13

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.
@@ -3,12 +3,12 @@
3
3
  "karma": "6.4.4",
4
4
  "karma-coverage": "2.2.1",
5
5
  "karma-nativescript-launcher": "1.0.0",
6
- "mocha": "11.7.2",
6
+ "mocha": "11.7.3",
7
7
  "karma-mocha": "2.0.1",
8
8
  "karma-chai": "0.1.0",
9
9
  "karma-jasmine": "4.0.2",
10
10
  "karma-qunit": "4.2.1",
11
- "@types/karma-chai": "0.1.7",
11
+ "@types/karma-chai": "0.1.8",
12
12
  "@types/mocha": "10.0.10",
13
13
  "@types/jasmine": "5.1.9",
14
14
  "@types/qunit": "2.19.13",
@@ -75,7 +75,7 @@ class ConfigSetCommand {
75
75
  const convertedValue = this.getConvertedValue(value);
76
76
  const existingKey = current !== undefined;
77
77
  const keyDisplay = color_1.color.green(key);
78
- const currentDisplay = color_1.color.yellow(current);
78
+ const currentDisplay = current ? color_1.color.yellow(current) : "";
79
79
  const updatedDisplay = color_1.color.cyan(convertedValue);
80
80
  this.$logger.info(`${existingKey ? "Updating" : "Setting"} ${keyDisplay}${existingKey ? ` from ${currentDisplay} ` : " "}to ${updatedDisplay}`);
81
81
  try {
@@ -5,6 +5,34 @@ require("./bootstrap");
5
5
  const shelljs = require("shelljs");
6
6
  shelljs.config.silent = true;
7
7
  shelljs.config.fatal = true;
8
+ if (process.platform === "win32") {
9
+ const realcp = shelljs.cp;
10
+ shelljs.cp = (...args) => {
11
+ if (args.length === 3) {
12
+ args[1] = replaceDashes(args[1]);
13
+ }
14
+ else {
15
+ args[0] = replaceDashes(args[0]);
16
+ }
17
+ if (args.length == 2) {
18
+ realcp(args[0], args[1]);
19
+ }
20
+ else {
21
+ realcp(args[0], args[1], args[2]);
22
+ }
23
+ };
24
+ function replaceDashes(values) {
25
+ if (Array.isArray(values)) {
26
+ for (let i = 0; i < values.length; ++i) {
27
+ values[i] = replaceDashes(values[i]);
28
+ }
29
+ return values;
30
+ }
31
+ else {
32
+ return values.replace(/\\/g, "/");
33
+ }
34
+ }
35
+ }
8
36
  const errors_1 = require("./common/errors");
9
37
  const helpers_1 = require("./common/helpers");
10
38
  const yok_1 = require("./common/yok");
@@ -10,6 +10,7 @@ exports.BundlerCompilerService = void 0;
10
10
  const path = require("path");
11
11
  const semver = require("semver");
12
12
  const _ = require("lodash");
13
+ const fs_1 = require("fs");
13
14
  const events_1 = require("events");
14
15
  const decorators_1 = require("../../common/decorators");
15
16
  const constants_1 = require("../../constants");
@@ -60,50 +61,23 @@ class BundlerCompilerService extends events_1.EventEmitter {
60
61
  if (debugLog) {
61
62
  console.log("Received Vite IPC message:", message);
62
63
  }
63
- const distOutput = path.join(projectData.projectDir, "dist");
64
+ const distOutput = path.join(projectData.projectDir, ".ns-vite-build");
64
65
  const destDir = path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName);
65
66
  if (debugLog) {
66
- console.log(`🔥 Copying from ${distOutput} to ${destDir}`);
67
+ console.log(`Copying from ${distOutput} to ${destDir}.`);
67
68
  }
68
- if (message.isHMR) {
69
+ if (message.buildType === "incremental" &&
70
+ message.emittedFiles &&
71
+ message.emittedFiles.length > 0) {
72
+ const filesToCopy = this.getIncrementalFilesToCopy(message.emittedFiles);
69
73
  if (debugLog) {
70
- console.log("🔥 HMR update - copying only changed files for:", message.changedFiles);
71
- }
72
- let filesToCopy = message.emittedFiles;
73
- const hasHTMLChanges = message.changedFiles.some((f) => f.endsWith(".html"));
74
- if (hasHTMLChanges) {
75
- filesToCopy = message.emittedFiles.filter((f) => f.includes(".component") ||
76
- f === "bundle.mjs" ||
77
- f === "bundle.mjs.map");
78
- if (debugLog) {
79
- console.log("🔥 HTML change detected - copying component files:", filesToCopy);
80
- }
81
- }
82
- this.copyViteBundleToNative(distOutput, destDir, filesToCopy);
83
- }
84
- else if (message.buildType === "incremental" &&
85
- message.changedFiles &&
86
- message.changedFiles.length > 0) {
87
- if (debugLog) {
88
- console.log("🔥 Incremental build - copying only relevant files for:", message.changedFiles);
89
- }
90
- const filesToCopy = this.getIncrementalFilesToCopy(message.emittedFiles, message.changedFiles);
91
- if (debugLog) {
92
- console.log("🔥 Incremental build - files to copy:", filesToCopy);
74
+ console.log("Incremental build - files to copy:", filesToCopy);
93
75
  }
94
76
  this.copyViteBundleToNative(distOutput, destDir, filesToCopy);
95
77
  }
96
- else if (message.buildType === "incremental" &&
97
- message.changedFiles &&
98
- message.changedFiles.length > 0) {
99
- console.log("🔥 Incremental build - copying only relevant files for:", message.changedFiles);
100
- const filesToCopy = this.getIncrementalFilesToCopy(message.emittedFiles, message.changedFiles);
101
- console.log("🔥 Incremental build - files to copy:", filesToCopy);
102
- this.copyViteBundleToNative(distOutput, destDir, filesToCopy);
103
- }
104
78
  else {
105
79
  if (debugLog) {
106
- console.log("🔥 Full build - copying all files");
80
+ console.log("Full build - copying all files.");
107
81
  }
108
82
  this.copyViteBundleToNative(distOutput, destDir);
109
83
  }
@@ -125,24 +99,10 @@ class BundlerCompilerService extends events_1.EventEmitter {
125
99
  platform: platformData.platformNameLowerCase,
126
100
  };
127
101
  this.$logger.info(`Vite build completed! Files copied to native platform.`);
128
- this.notifyHMRClients({
129
- type: message.isHMR ? "js-update" : "build-complete",
130
- timestamp: Date.now(),
131
- changedFiles: message.changedFiles || [],
132
- buildType: message.buildType || "incremental",
133
- isHMR: message.isHMR || false,
134
- });
135
- if (message.isHMR) {
136
- if (debugLog) {
137
- console.log("🔥 Skipping BUNDLER_COMPILATION_COMPLETE for HMR update - app will not restart");
138
- }
139
- }
140
- else {
141
- if (debugLog) {
142
- console.log("🔥 Emitting BUNDLER_COMPILATION_COMPLETE for full build");
143
- }
144
- this.emit(constants_1.BUNDLER_COMPILATION_COMPLETE, data);
102
+ if (debugLog) {
103
+ console.log("Emitting BUNDLER_COMPILATION_COMPLETE for full build.");
145
104
  }
105
+ this.emit(constants_1.BUNDLER_COMPILATION_COMPLETE, data);
146
106
  return;
147
107
  }
148
108
  if (typeof message === "object" &&
@@ -300,7 +260,7 @@ class BundlerCompilerService extends events_1.EventEmitter {
300
260
  const args = [
301
261
  ...additionalNodeArgs,
302
262
  this.getBundlerExecutablePath(projectData),
303
- isVite ? "build" : this.isModernBundler(projectData) ? `build` : null,
263
+ isVite || this.isModernBundler(projectData) ? "build" : null,
304
264
  `--config=${projectData.bundlerConfigPath}`,
305
265
  ...envParams,
306
266
  ].filter(Boolean);
@@ -530,37 +490,36 @@ class BundlerCompilerService extends events_1.EventEmitter {
530
490
  }
531
491
  copyViteBundleToNative(distOutput, destDir, specificFiles = null) {
532
492
  if (debugLog) {
533
- console.log(`Copying Vite bundle from "${distOutput}" to "${destDir}"`);
493
+ console.log(`Copying Vite bundle from "${distOutput}" to "${destDir}".`);
534
494
  }
535
- const fs = require("fs");
536
495
  try {
537
496
  if (specificFiles) {
538
497
  if (debugLog) {
539
- console.log("🔥 Selective copy - copying specific files:", specificFiles);
498
+ console.log("Selective copy - copying specific files:", specificFiles);
540
499
  }
541
- fs.mkdirSync(destDir, { recursive: true });
500
+ (0, fs_1.mkdirSync)(destDir, { recursive: true });
542
501
  for (const file of specificFiles) {
543
502
  const srcPath = path.join(distOutput, file);
544
503
  const destPath = path.join(destDir, file);
545
- if (!fs.existsSync(srcPath))
504
+ if (!(0, fs_1.existsSync)(srcPath))
546
505
  continue;
547
- fs.mkdirSync(path.dirname(destPath), { recursive: true });
548
- fs.copyFileSync(srcPath, destPath);
506
+ (0, fs_1.mkdirSync)(path.dirname(destPath), { recursive: true });
507
+ (0, fs_1.copyFileSync)(srcPath, destPath);
549
508
  if (debugLog) {
550
- console.log(`🔥 Copied ${file}`);
509
+ console.log(`Copied ${file}`);
551
510
  }
552
511
  }
553
512
  }
554
513
  else {
555
514
  if (debugLog) {
556
- console.log("🔥 Full build: Copying all files");
515
+ console.log("Full build: Copying all files.");
557
516
  }
558
- if (fs.existsSync(destDir)) {
559
- fs.rmSync(destDir, { recursive: true, force: true });
517
+ if ((0, fs_1.existsSync)(destDir)) {
518
+ (0, fs_1.rmSync)(destDir, { recursive: true, force: true });
560
519
  }
561
- fs.mkdirSync(destDir, { recursive: true });
562
- if (fs.existsSync(distOutput)) {
563
- this.copyRecursiveSync(distOutput, destDir, fs);
520
+ (0, fs_1.mkdirSync)(destDir, { recursive: true });
521
+ if ((0, fs_1.existsSync)(distOutput)) {
522
+ this.copyRecursiveSync(distOutput, destDir);
564
523
  }
565
524
  else {
566
525
  this.$logger.warn(`Vite output directory does not exist: ${distOutput}`);
@@ -571,62 +530,32 @@ class BundlerCompilerService extends events_1.EventEmitter {
571
530
  this.$logger.warn(`Failed to copy Vite bundle: ${error.message}`);
572
531
  }
573
532
  }
574
- getIncrementalFilesToCopy(emittedFiles, changedFiles) {
533
+ getIncrementalFilesToCopy(emittedFiles) {
575
534
  const filesToCopy = [];
576
535
  const bundleFiles = emittedFiles.filter((file) => !file.includes("vendor") &&
577
- (file.includes("bundle") ||
578
- file.includes("main") ||
579
- file.includes("app") ||
580
- file.endsWith(".mjs") ||
581
- file.endsWith(".js")));
536
+ (file.endsWith(".mjs") ||
537
+ file.endsWith(".js") ||
538
+ file.endsWith(".map")));
582
539
  filesToCopy.push(...bundleFiles);
583
- const sourceMapFiles = emittedFiles.filter((file) => !file.includes("vendor") && file.endsWith(".map"));
584
- filesToCopy.push(...sourceMapFiles);
585
- const hasAssetChanges = changedFiles.some((file) => file.includes("/assets/") ||
586
- file.includes("/static/") ||
587
- file.includes("/public/"));
588
- if (hasAssetChanges) {
589
- const assetFiles = emittedFiles.filter((file) => file.includes("assets/") ||
590
- file.includes("static/") ||
591
- file.includes("fonts/") ||
592
- file.includes("images/"));
540
+ const assetFiles = emittedFiles.filter((file) => file.includes("assets/") ||
541
+ file.includes("static/") ||
542
+ file.includes("fonts/") ||
543
+ file.includes("images/"));
544
+ if (assetFiles.length > 0) {
593
545
  filesToCopy.push(...assetFiles);
594
546
  }
595
547
  return [...new Set(filesToCopy)];
596
548
  }
597
- notifyHMRClients(message) {
598
- try {
599
- const WebSocket = require("ws");
600
- const ws = new WebSocket("ws://localhost:24678");
601
- ws.on("open", () => {
602
- if (debugLog) {
603
- console.log("🔥 Sending HMR notification to bridge:", message.type);
604
- }
605
- ws.send(JSON.stringify(message));
606
- ws.close();
607
- });
608
- ws.on("error", () => {
609
- if (debugLog) {
610
- console.log("🔥 HMR bridge not available (this is normal without HMR)");
611
- }
612
- });
613
- }
614
- catch (error) {
615
- if (debugLog) {
616
- console.log("🔥 WebSocket not available for HMR notifications");
617
- }
618
- }
619
- }
620
- copyRecursiveSync(src, dest, fs) {
621
- for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
549
+ copyRecursiveSync(src, dest) {
550
+ for (const entry of (0, fs_1.readdirSync)(src, { withFileTypes: true })) {
622
551
  const srcPath = path.join(src, entry.name);
623
552
  const destPath = path.join(dest, entry.name);
624
553
  if (entry.isDirectory()) {
625
- fs.mkdirSync(destPath, { recursive: true });
626
- this.copyRecursiveSync(srcPath, destPath, fs);
554
+ (0, fs_1.mkdirSync)(destPath, { recursive: true });
555
+ this.copyRecursiveSync(srcPath, destPath);
627
556
  }
628
557
  else if (entry.isFile() || entry.isSymbolicLink()) {
629
- fs.copyFileSync(srcPath, destPath);
558
+ (0, fs_1.copyFileSync)(srcPath, destPath);
630
559
  }
631
560
  }
632
561
  }
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.0.0-alpha.11",
4
+ "version": "9.0.0-alpha.13",
5
5
  "author": "NativeScript <oss@nativescript.org>",
6
6
  "description": "Command-line interface for building NativeScript projects",
7
7
  "bin": {