@akylas/nativescript-cli 8.8.7 → 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.
Files changed (85) hide show
  1. package/config/test-deps-versions-generated.json +16 -0
  2. package/docs/build-jekyll-md.sh +1 -1
  3. package/docs/man_pages/config/config-get.md +36 -0
  4. package/docs/man_pages/config/config-set.md +40 -0
  5. package/docs/man_pages/config/config.md +39 -0
  6. package/docs/man_pages/project/configuration/widget-ios.md +24 -0
  7. package/docs/man_pages/project/configuration/widget.md +24 -0
  8. package/docs/man_pages/project/hooks/hooks.md +35 -0
  9. package/docs/man_pages/start.md +2 -1
  10. package/lib/.d.ts +9 -3
  11. package/lib/bootstrap.js +4 -1
  12. package/lib/bun-package-manager.js +1 -1
  13. package/lib/color.js +38 -7
  14. package/lib/commands/build.js +18 -2
  15. package/lib/commands/clean.js +1 -2
  16. package/lib/commands/config.js +1 -1
  17. package/lib/commands/embedding/embed.js +1 -1
  18. package/lib/commands/generate.js +2 -41
  19. package/lib/commands/hooks/common.js +79 -0
  20. package/lib/commands/hooks/hooks-lock.js +100 -0
  21. package/lib/commands/hooks/hooks.js +71 -0
  22. package/lib/commands/post-install.js +2 -2
  23. package/lib/commands/typings.js +29 -18
  24. package/lib/commands/widget.js +799 -0
  25. package/lib/common/definitions/extensibility.d.ts +2 -2
  26. package/lib/common/definitions/mobile.d.ts +72 -72
  27. package/lib/common/file-system.js +1 -2
  28. package/lib/common/header.js +3 -3
  29. package/lib/common/logger/layouts/cli-layout.js +1 -1
  30. package/lib/common/logger/logger.js +5 -5
  31. package/lib/common/mobile/android/android-device.js +1 -1
  32. package/lib/common/mobile/android/android-emulator-services.js +9 -7
  33. package/lib/common/mobile/device-log-provider.js +3 -4
  34. package/lib/common/mobile/emulator-helper.js +1 -0
  35. package/lib/common/mobile/mobile-core/devices-service.js +2 -1
  36. package/lib/common/opener.js +2 -2
  37. package/lib/common/project-helper.js +15 -2
  38. package/lib/common/services/hooks-service.js +23 -6
  39. package/lib/common/verify-node-version.js +1 -1
  40. package/lib/constants.js +8 -5
  41. package/lib/controllers/migrate-controller.js +11 -12
  42. package/lib/controllers/prepare-controller.js +11 -13
  43. package/lib/controllers/run-controller.js +1 -1
  44. package/lib/declarations.d.ts +5 -0
  45. package/lib/definitions/hooks.d.ts +1 -0
  46. package/lib/definitions/ios.d.ts +11 -1
  47. package/lib/definitions/nativescript-dev-xcode.d.ts +25 -1
  48. package/lib/definitions/project.d.ts +102 -25
  49. package/lib/definitions/temp-service.d.ts +6 -2
  50. package/lib/helpers/key-command-helper.js +2 -1
  51. package/lib/nativescript-cli.js +28 -0
  52. package/lib/node-package-manager.js +1 -1
  53. package/lib/options.js +4 -0
  54. package/lib/project-data.js +10 -4
  55. package/lib/services/analytics/analytics-broker-process.js +1 -1
  56. package/lib/services/analytics/analytics-service.js +2 -1
  57. package/lib/services/analytics-settings-service.js +2 -1
  58. package/lib/services/android/gradle-build-args-service.js +8 -4
  59. package/lib/services/android/gradle-build-service.js +4 -1
  60. package/lib/services/android-plugin-build-service.js +1 -1
  61. package/lib/services/android-project-service.js +12 -10
  62. package/lib/services/assets-generation/assets-generation-service.js +33 -15
  63. package/lib/services/{webpack/webpack-compiler-service.js → bundler/bundler-compiler-service.js} +258 -88
  64. package/lib/services/bundler/bundler.js +2 -0
  65. package/lib/services/extensibility-service.js +1 -1
  66. package/lib/services/ios/spm-service.js +22 -2
  67. package/lib/services/ios/xcodebuild-args-service.js +7 -5
  68. package/lib/services/ios-debugger-port-service.js +1 -1
  69. package/lib/services/ios-project-service.js +45 -15
  70. package/lib/services/ios-watch-app-service.js +540 -16
  71. package/lib/services/livesync/android-livesync-tool.js +4 -2
  72. package/lib/services/plugins-service.js +1 -0
  73. package/lib/services/project-changes-service.js +1 -1
  74. package/lib/services/project-config-service.js +12 -3
  75. package/lib/services/temp-service.js +16 -4
  76. package/lib/services/versions-service.js +2 -1
  77. package/lib/tools/config-manipulation/config-transformer.js +9 -0
  78. package/package.json +59 -66
  79. package/vendor/aab-tool/README.txt +1 -1
  80. package/vendor/aab-tool/bundletool.jar +0 -0
  81. package/vendor/gradle-app/app/build.gradle +365 -130
  82. package/vendor/gradle-app/app/gradle.properties +45 -0
  83. package/vendor/gradle-app/build.gradle +7 -7
  84. package/vendor/gradle-plugin/build.gradle +7 -6
  85. package/lib/services/webpack/webpack.d.ts +0 -227
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HooksVerifyPluginCommand = exports.HooksLockPluginCommand = void 0;
4
+ const yok_1 = require("../../common/yok");
5
+ const path = require("path");
6
+ const crypto = require("crypto");
7
+ const common_1 = require("./common");
8
+ class HooksLockPluginCommand {
9
+ constructor($pluginsService, $projectData, $errors, $fs, $logger) {
10
+ this.$pluginsService = $pluginsService;
11
+ this.$projectData = $projectData;
12
+ this.$errors = $errors;
13
+ this.$fs = $fs;
14
+ this.$logger = $logger;
15
+ this.allowedParameters = [];
16
+ this.$projectData.initializeProjectData();
17
+ }
18
+ async execute() {
19
+ var _a, _b;
20
+ const plugins = await this.$pluginsService.getAllInstalledPlugins(this.$projectData);
21
+ if (plugins && plugins.length > 0) {
22
+ const pluginsWithHooks = [];
23
+ for (const plugin of plugins) {
24
+ if (((_b = (_a = plugin.nativescript) === null || _a === void 0 ? void 0 : _a.hooks) === null || _b === void 0 ? void 0 : _b.length) > 0) {
25
+ pluginsWithHooks.push(plugin);
26
+ }
27
+ }
28
+ await this.writeHooksLockFile(pluginsWithHooks, this.$projectData.projectDir);
29
+ }
30
+ else {
31
+ this.$logger.info("No plugins with hooks found.");
32
+ }
33
+ }
34
+ async canExecute(args) {
35
+ return true;
36
+ }
37
+ async writeHooksLockFile(plugins, outputDir) {
38
+ var _a;
39
+ const output = [];
40
+ for (const plugin of plugins) {
41
+ const hooks = [];
42
+ for (const hook of ((_a = plugin.nativescript) === null || _a === void 0 ? void 0 : _a.hooks) || []) {
43
+ try {
44
+ const fileContent = this.$fs.readFile(path.join(plugin.fullPath, hook.script));
45
+ const hash = crypto
46
+ .createHash("sha256")
47
+ .update(fileContent)
48
+ .digest("hex");
49
+ hooks.push({
50
+ type: hook.type,
51
+ hash,
52
+ });
53
+ }
54
+ catch (err) {
55
+ this.$logger.warn(`Warning: Failed to read script '${hook.script}' for plugin '${plugin.name}'. Skipping this hook.`);
56
+ continue;
57
+ }
58
+ }
59
+ output.push({ name: plugin.name, hooks });
60
+ }
61
+ const filePath = path.resolve(outputDir, common_1.LOCK_FILE_NAME);
62
+ try {
63
+ this.$fs.writeFile(filePath, JSON.stringify(output, null, 2), "utf8");
64
+ this.$logger.info(`✅ ${common_1.LOCK_FILE_NAME} written to: ${filePath}`);
65
+ }
66
+ catch (err) {
67
+ this.$errors.fail(`❌ Failed to write ${common_1.LOCK_FILE_NAME}: ${err}`);
68
+ }
69
+ }
70
+ }
71
+ exports.HooksLockPluginCommand = HooksLockPluginCommand;
72
+ class HooksVerifyPluginCommand extends common_1.HooksVerify {
73
+ constructor($pluginsService, $projectData, $errors, $fs, $logger) {
74
+ super($projectData, $errors, $fs, $logger);
75
+ this.$pluginsService = $pluginsService;
76
+ this.allowedParameters = [];
77
+ }
78
+ async execute() {
79
+ var _a, _b;
80
+ const plugins = await this.$pluginsService.getAllInstalledPlugins(this.$projectData);
81
+ if (plugins && plugins.length > 0) {
82
+ const pluginsWithHooks = [];
83
+ for (const plugin of plugins) {
84
+ if (((_b = (_a = plugin.nativescript) === null || _a === void 0 ? void 0 : _a.hooks) === null || _b === void 0 ? void 0 : _b.length) > 0) {
85
+ pluginsWithHooks.push(plugin);
86
+ }
87
+ }
88
+ await this.verifyHooksLock(pluginsWithHooks, path.join(this.$projectData.projectDir, common_1.LOCK_FILE_NAME));
89
+ }
90
+ else {
91
+ this.$logger.info("No plugins with hooks found.");
92
+ }
93
+ }
94
+ async canExecute(args) {
95
+ return true;
96
+ }
97
+ }
98
+ exports.HooksVerifyPluginCommand = HooksVerifyPluginCommand;
99
+ yok_1.injector.registerCommand(["hooks|lock"], HooksLockPluginCommand);
100
+ yok_1.injector.registerCommand(["hooks|verify"], HooksVerifyPluginCommand);
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HooksListPluginCommand = exports.HooksPluginCommand = void 0;
4
+ const yok_1 = require("../../common/yok");
5
+ const path = require("path");
6
+ const constants_1 = require("../../constants");
7
+ const helpers_1 = require("../../common/helpers");
8
+ const nsHooks = require("@nativescript/hook");
9
+ const common_1 = require("./common");
10
+ class HooksPluginCommand extends common_1.HooksVerify {
11
+ constructor($pluginsService, $projectData, $errors, $fs, $logger) {
12
+ super($projectData, $errors, $fs, $logger);
13
+ this.$pluginsService = $pluginsService;
14
+ this.allowedParameters = [];
15
+ }
16
+ async execute(args) {
17
+ var _a, _b;
18
+ const isList = args.length > 0 && args[0] === "list" ? true : false;
19
+ const plugins = await this.$pluginsService.getAllInstalledPlugins(this.$projectData);
20
+ if (plugins && plugins.length > 0) {
21
+ const hooksDir = path.join(this.$projectData.projectDir, constants_1.HOOKS_DIR_NAME);
22
+ const pluginsWithHooks = [];
23
+ for (const plugin of plugins) {
24
+ if (((_b = (_a = plugin.nativescript) === null || _a === void 0 ? void 0 : _a.hooks) === null || _b === void 0 ? void 0 : _b.length) > 0) {
25
+ pluginsWithHooks.push(plugin);
26
+ }
27
+ }
28
+ if (isList) {
29
+ const headers = ["Plugin", "HookName", "HookPath"];
30
+ const hookDataData = pluginsWithHooks.flatMap((plugin) => plugin.nativescript.hooks.map((hook) => {
31
+ return [plugin.name, hook.type, hook.script];
32
+ }));
33
+ const hookDataTable = (0, helpers_1.createTable)(headers, hookDataData);
34
+ this.$logger.info("Hooks:");
35
+ this.$logger.info(hookDataTable.toString());
36
+ }
37
+ else {
38
+ if (this.$fs.exists(path.join(this.$projectData.projectDir, common_1.LOCK_FILE_NAME))) {
39
+ await this.verifyHooksLock(pluginsWithHooks, path.join(this.$projectData.projectDir, common_1.LOCK_FILE_NAME));
40
+ }
41
+ if (pluginsWithHooks.length === 0) {
42
+ if (!this.$fs.exists(hooksDir)) {
43
+ this.$fs.createDirectory(hooksDir);
44
+ }
45
+ }
46
+ for (const plugin of pluginsWithHooks) {
47
+ nsHooks(plugin.fullPath).postinstall();
48
+ }
49
+ }
50
+ }
51
+ }
52
+ async canExecute(args) {
53
+ if (args.length > 0 && args[0] !== "list") {
54
+ this.$errors.failWithHelp(`Invalid argument ${args[0]}. Supported argument is "list".`);
55
+ }
56
+ return true;
57
+ }
58
+ }
59
+ exports.HooksPluginCommand = HooksPluginCommand;
60
+ class HooksListPluginCommand extends HooksPluginCommand {
61
+ constructor($pluginsService, $projectData, $errors, $fs, $logger) {
62
+ super($pluginsService, $projectData, $errors, $fs, $logger);
63
+ this.allowedParameters = [];
64
+ }
65
+ async execute() {
66
+ await super.execute(["list"]);
67
+ }
68
+ }
69
+ exports.HooksListPluginCommand = HooksListPluginCommand;
70
+ yok_1.injector.registerCommand(["hooks|install"], HooksPluginCommand);
71
+ yok_1.injector.registerCommand(["hooks|*list"], HooksListPluginCommand);
@@ -32,10 +32,10 @@ class PostInstallCliCommand {
32
32
  }
33
33
  async postCommandAction(args) {
34
34
  this.$logger.info("");
35
- this.$logger.info(color_1.color.green.bold("You have successfully installed the NativeScript CLI!"));
35
+ this.$logger.info(color_1.color.styleText(["green", "bold"], "You have successfully installed the NativeScript CLI!"));
36
36
  this.$logger.info("");
37
37
  this.$logger.info("Your next step is to create a new project:");
38
- this.$logger.info(color_1.color.green.bold("ns create"));
38
+ this.$logger.info(color_1.color.styleText(["green", "bold"], "ns create"));
39
39
  this.$logger.info("");
40
40
  this.$logger.printMarkdown("If you have any questions, check Stack Overflow: `https://stackoverflow.com/questions/tagged/nativescript` and our public Discord channel: `https://nativescript.org/discord`");
41
41
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TypingsCommand = void 0;
4
- const glob_1 = require("glob");
4
+ const promises_1 = require("node:fs/promises");
5
5
  const os_1 = require("os");
6
6
  const path = require("path");
7
7
  const color_1 = require("../color");
@@ -43,24 +43,20 @@ class TypingsCommand {
43
43
  return true;
44
44
  }
45
45
  async resolveGradleDependencies(target) {
46
- var _a;
46
+ var _a, _b;
47
47
  const gradleHome = path.resolve((_a = process.env.GRADLE_USER_HOME) !== null && _a !== void 0 ? _a : path.join((0, os_1.homedir)(), `/.gradle`));
48
- const gradleFiles = path.resolve(gradleHome, "caches/modules-2/files-2.1/");
48
+ const gradleFiles = (_b = this.$options.lookupPath) !== null && _b !== void 0 ? _b : path.resolve(gradleHome, "caches/modules-2/files-2.1/");
49
49
  if (!this.$fs.exists(gradleFiles)) {
50
50
  this.$logger.warn("No gradle files found");
51
51
  return;
52
52
  }
53
53
  const pattern = `${target.replaceAll(":", "/")}/**/*.{jar,aar}`;
54
- const res = await (0, glob_1.glob)(pattern, {
54
+ const items = [];
55
+ for await (const item of (0, promises_1.glob)(pattern, {
55
56
  cwd: gradleFiles,
56
- });
57
- if (!res || res.length === 0) {
58
- this.$logger.warn("No files found");
59
- return [];
60
- }
61
- const items = res.map((item) => {
57
+ })) {
62
58
  const [group, artifact, version, sha1, file] = item.split(path.sep);
63
- return {
59
+ items.push({
64
60
  id: sha1 + version,
65
61
  group,
66
62
  artifact,
@@ -68,8 +64,12 @@ class TypingsCommand {
68
64
  sha1,
69
65
  file,
70
66
  path: path.resolve(gradleFiles, item),
71
- };
72
- });
67
+ });
68
+ }
69
+ if (items.length === 0) {
70
+ this.$logger.warn("No files found");
71
+ return [];
72
+ }
73
73
  this.$logger.clearScreen();
74
74
  const choices = await this.$prompter.promptForChoice(`Select dependencies to generate typings for (${color_1.color.greenBright(target)})`, items
75
75
  .sort((a, b) => {
@@ -84,7 +84,7 @@ class TypingsCommand {
84
84
  })
85
85
  .map((item) => {
86
86
  return {
87
- title: `${color_1.color.white(item.group)}:${color_1.color.greenBright(item.artifact)}:${color_1.color.yellow(item.version)} - ${color_1.color.cyanBright.bold(item.file)}`,
87
+ title: `${color_1.color.white(item.group)}:${color_1.color.greenBright(item.artifact)}:${color_1.color.yellow(item.version)} - ${color_1.color.styleText(["cyanBright", "bold"], item.file)}`,
88
88
  value: item.id,
89
89
  };
90
90
  }), true, {
@@ -96,7 +96,7 @@ class TypingsCommand {
96
96
  .map((item) => item.path);
97
97
  }
98
98
  async handleAndroidTypings() {
99
- var _a;
99
+ var _a, _b;
100
100
  const targets = (_a = this.$options.argv._.slice(2)) !== null && _a !== void 0 ? _a : [];
101
101
  const paths = [];
102
102
  if (targets.length) {
@@ -118,10 +118,18 @@ class TypingsCommand {
118
118
  return false;
119
119
  }
120
120
  this.$fs.ensureDirectoryExists(path.resolve(this.$projectData.projectDir, "typings", "android"));
121
- const dtsGeneratorPath = path.resolve(this.$projectData.projectDir, this.$projectData.getBuildRelativeDirectoryPath(), "android", "build-tools", "dts-generator.jar");
121
+ const dtsGeneratorPath = (_b = this.$options.dtsGeneratorPath) !== null && _b !== void 0 ? _b : path.resolve(this.$projectData.projectDir, this.$projectData.getBuildRelativeDirectoryPath(), "android", "build-tools", "dts-generator.jar");
122
122
  if (!this.$fs.exists(dtsGeneratorPath)) {
123
- this.$logger.warn("No platforms folder found, preparing project now...");
124
- await this.$childProcess.spawnFromEvent(this.$hostInfo.isWindows ? "ns.cmd" : "ns", ["prepare", "android"], "exit", { stdio: "inherit", shell: this.$hostInfo.isWindows });
123
+ if (this.$options.dtsGeneratorPath) {
124
+ this.$logger.warn([
125
+ `dts-generator.jar not found at ${this.$options.dtsGeneratorPath} used with --dtsGeneratorPath`,
126
+ ].join("\n"));
127
+ return false;
128
+ }
129
+ else {
130
+ this.$logger.warn("No platforms folder found, preparing project now...");
131
+ await this.$childProcess.spawnFromEvent(this.$hostInfo.isWindows ? "ns.cmd" : "ns", ["prepare", "android"], "exit", { stdio: "inherit", shell: this.$hostInfo.isWindows });
132
+ }
125
133
  }
126
134
  const asArray = (input) => {
127
135
  if (!input) {
@@ -140,6 +148,9 @@ class TypingsCommand {
140
148
  await this.$childProcess.spawnFromEvent("java", [
141
149
  "-jar",
142
150
  dtsGeneratorPath,
151
+ ...(this.$options.skipDeclarations ? ["--skip-declarations"] : []),
152
+ ...(this.$options.super ? ["-super", this.$options.super] : []),
153
+ "-per-library",
143
154
  "-input",
144
155
  ...inputs,
145
156
  "-output",