@akylas/nativescript-cli 8.7.2 → 8.8.2

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 (59) hide show
  1. package/config/test-deps-versions-generated.json +1 -1
  2. package/docs/man_pages/project/configuration/native/native-add-java.md +32 -0
  3. package/docs/man_pages/project/configuration/native/native-add-kotlin.md +34 -0
  4. package/docs/man_pages/project/configuration/native/native-add-objective-c.md +34 -0
  5. package/docs/man_pages/project/configuration/native/native-add-swift.md +32 -0
  6. package/docs/man_pages/project/configuration/native/native-add.md +31 -0
  7. package/docs/man_pages/project/configuration/native/native.md +31 -0
  8. package/lib/.d.ts +2 -0
  9. package/lib/bootstrap.js +8 -0
  10. package/lib/commands/embedding/embed.js +91 -0
  11. package/lib/commands/native-add.js +300 -0
  12. package/lib/commands/plugin/build-plugin.js +3 -9
  13. package/lib/commands/prepare.js +9 -0
  14. package/lib/commands/typings.js +1 -1
  15. package/lib/common/mobile/android/android-virtual-device-service.js +4 -1
  16. package/lib/common/mobile/android/logcat-helper.js +15 -6
  17. package/lib/common/mobile/emulator-helper.js +1 -0
  18. package/lib/common/utils.js +8 -1
  19. package/lib/controllers/migrate-controller.js +6 -6
  20. package/lib/controllers/platform-controller.js +4 -0
  21. package/lib/controllers/prepare-controller.js +61 -14
  22. package/lib/data/build-data.js +2 -0
  23. package/lib/data/prepare-data.js +1 -0
  24. package/lib/declarations.d.ts +14 -3
  25. package/lib/definitions/android-plugin-migrator.d.ts +1 -0
  26. package/lib/definitions/platform.d.ts +1 -0
  27. package/lib/definitions/prepare.d.ts +3 -0
  28. package/lib/definitions/project.d.ts +5 -0
  29. package/lib/helpers/platform-command-helper.js +10 -1
  30. package/lib/options.js +9 -2
  31. package/lib/project-data.js +4 -1
  32. package/lib/providers/project-files-provider.js +1 -1
  33. package/lib/services/android/gradle-build-args-service.js +4 -3
  34. package/lib/services/android/gradle-command-service.js +5 -1
  35. package/lib/services/android-plugin-build-service.js +34 -22
  36. package/lib/services/android-project-service.js +20 -23
  37. package/lib/services/assets-generation/assets-generation-service.js +5 -1
  38. package/lib/services/cocoapods-service.js +9 -3
  39. package/lib/services/files-hash-service.js +3 -2
  40. package/lib/services/ios-project-service.js +50 -17
  41. package/lib/services/livesync/android-device-livesync-sockets-service.js +3 -4
  42. package/lib/services/livesync/android-livesync-service.js +2 -2
  43. package/lib/services/livesync/ios-livesync-service.js +2 -2
  44. package/lib/services/livesync/platform-livesync-service-base.js +4 -3
  45. package/lib/services/log-source-map-service.js +3 -2
  46. package/lib/services/platform/add-platform-service.js +7 -2
  47. package/lib/services/platform/prepare-native-platform-service.js +6 -3
  48. package/lib/services/platform-environment-requirements.js +3 -1
  49. package/lib/services/plugins-service.js +7 -1
  50. package/lib/services/project-changes-service.js +8 -1
  51. package/lib/services/project-config-service.js +1 -1
  52. package/lib/services/project-data-service.js +15 -21
  53. package/lib/services/webpack/webpack-compiler-service.js +14 -6
  54. package/lib/services/xcproj-service.js +12 -0
  55. package/package.json +3 -3
  56. package/vendor/aab-tool/README.txt +1 -1
  57. package/vendor/aab-tool/bundletool.jar +0 -0
  58. package/vendor/gradle-app/app/build.gradle +12 -4
  59. package/vendor/gradle-plugin/build.gradle +12 -4
@@ -23,15 +23,17 @@ const xml2js_1 = require("xml2js");
23
23
  const yok_1 = require("../common/yok");
24
24
  const _ = require("lodash");
25
25
  const resolve_package_path_1 = require("@rigor789/resolve-package-path");
26
+ const process_1 = require("process");
26
27
  class AndroidPluginBuildService {
27
28
  get $platformsDataService() {
28
29
  return this.$injector.resolve("platformsDataService");
29
30
  }
30
- constructor($fs, $childProcess, $hostInfo, $androidToolsInfo, $logger, $packageManager, $projectData, $projectDataService, $devicePlatformsConstants, $errors, $filesHashService, $hooksService, $injector, $watchIgnoreListService) {
31
+ constructor($fs, $childProcess, $androidToolsInfo, $hostInfo, $options, $logger, $packageManager, $projectData, $projectDataService, $devicePlatformsConstants, $errors, $filesHashService, $hooksService, $injector, $watchIgnoreListService) {
31
32
  this.$fs = $fs;
32
33
  this.$childProcess = $childProcess;
33
- this.$hostInfo = $hostInfo;
34
34
  this.$androidToolsInfo = $androidToolsInfo;
35
+ this.$hostInfo = $hostInfo;
36
+ this.$options = $options;
35
37
  this.$logger = $logger;
36
38
  this.$packageManager = $packageManager;
37
39
  this.$projectData = $projectData;
@@ -133,7 +135,7 @@ class AndroidPluginBuildService {
133
135
  this.validateOptions(options);
134
136
  const manifestFilePath = this.getManifest(options.platformsAndroidDirPath);
135
137
  const androidSourceDirectories = this.getAndroidSourceDirectories(options.platformsAndroidDirPath);
136
- const shortPluginName = (0, helpers_1.getShortPluginName)(options.pluginName);
138
+ const shortPluginName = (0, helpers_1.getShortPluginName)(options.pluginName + (options.aarSuffix || ''));
137
139
  const pluginTempDir = path.join(options.tempPluginDirPath, shortPluginName);
138
140
  const pluginSourceFileHashesInfo = yield this.getSourceFilesHashes(options.platformsAndroidDirPath, shortPluginName);
139
141
  const shouldBuildAar = yield this.shouldBuildAar({
@@ -150,7 +152,7 @@ class AndroidPluginBuildService {
150
152
  yield this.updateManifest(manifestFilePath, pluginTempMainSrcDir, shortPluginName);
151
153
  this.copySourceSetDirectories(androidSourceDirectories, pluginTempMainSrcDir);
152
154
  yield this.setupGradle(pluginTempDir, options.platformsAndroidDirPath, options.projectDir, options.pluginName);
153
- const gradleArgs = (this.$projectData.nsConfig.android.gradleArgs || [].concat(options.gradleArgs || []));
155
+ const gradleArgs = (this.$projectData.nsConfig.android.gradleArgs || []).concat(options.gradleArgs || []);
154
156
  yield this.buildPlugin({
155
157
  gradlePath: options.gradlePath,
156
158
  gradleArgs,
@@ -265,6 +267,17 @@ class AndroidPluginBuildService {
265
267
  this.replaceFileContent(buildGradlePath, "{{pluginNamespace}}", pluginNamespace);
266
268
  this.replaceFileContent(buildGradlePath, "{{pluginName}}", pluginName);
267
269
  this.replaceFileContent(settingsGradlePath, "{{pluginName}}", pluginName);
270
+ const shortPluginName = (0, helpers_1.getShortPluginName)(pluginName);
271
+ const manifestPath = path.join(pluginTempDir, "src", "main", "AndroidManifest.xml");
272
+ const manifestContent = this.$fs.readText(manifestPath);
273
+ let packageName = `org.nativescript.${shortPluginName}`;
274
+ const xml = yield this.getXml(manifestContent);
275
+ if (xml["manifest"]) {
276
+ if (xml["manifest"]["$"]["package"]) {
277
+ packageName = xml["manifest"]["$"]["package"];
278
+ }
279
+ }
280
+ this.replaceFileContent(buildGradlePath, "{{pluginNamespace}}", packageName);
268
281
  });
269
282
  }
270
283
  getRuntimeGradleVersions(projectDir) {
@@ -443,25 +456,17 @@ class AndroidPluginBuildService {
443
456
  buildPlugin(pluginBuildSettings) {
444
457
  var _a;
445
458
  return __awaiter(this, void 0, void 0, function* () {
446
- if (!pluginBuildSettings.androidToolsInfo) {
447
- this.$androidToolsInfo.validateInfo({
448
- showWarningsAsErrors: true,
449
- validateTargetSdk: true,
450
- projectDir: pluginBuildSettings.projectDir,
451
- });
452
- pluginBuildSettings.androidToolsInfo =
453
- this.$androidToolsInfo.getToolsInfo({
454
- projectDir: pluginBuildSettings.projectDir,
455
- });
456
- }
457
459
  const gradlew = (_a = pluginBuildSettings.gradlePath) !== null && _a !== void 0 ? _a : (this.$hostInfo.isWindows ? "gradlew.bat" : "./gradlew");
460
+ const toolsInfo = this.$androidToolsInfo.getToolsInfo({
461
+ projectDir: this.$projectData.projectDir,
462
+ });
458
463
  const localArgs = [
459
464
  "-p",
460
465
  pluginBuildSettings.pluginDir,
461
466
  "assembleRelease",
462
467
  `-PtempBuild=true`,
463
- `-PcompileSdk=android-${pluginBuildSettings.androidToolsInfo.compileSdkVersion}`,
464
- `-PbuildToolsVersion=${pluginBuildSettings.androidToolsInfo.buildToolsVersion}`,
468
+ `-PcompileSdk=${toolsInfo.compileSdkVersion}`,
469
+ `-PbuildToolsVersion=${toolsInfo.buildToolsVersion}`,
465
470
  `-PprojectRoot=${this.$projectData.projectDir}`,
466
471
  `-DprojectRoot=${this.$projectData.projectDir}`,
467
472
  `-PappPath=${this.$projectData.getAppDirectoryPath()}`,
@@ -479,12 +484,19 @@ class AndroidPluginBuildService {
479
484
  if (this.$logger.getLevel() === "INFO") {
480
485
  localArgs.push("--quiet");
481
486
  }
487
+ const opts = {
488
+ cwd: pluginBuildSettings.pluginDir,
489
+ stdio: "inherit",
490
+ shell: this.$hostInfo.isWindows,
491
+ };
492
+ if (this.$options.hostProjectPath) {
493
+ opts.env = Object.assign({ USER_PROJECT_PLATFORMS_ANDROID: path.resolve((0, process_1.cwd)(), this.$options.hostProjectPath) }, process.env);
494
+ }
482
495
  try {
483
- yield this.$childProcess.spawnFromEvent(gradlew, localArgs, "close", {
484
- cwd: pluginBuildSettings.pluginDir,
485
- stdio: "inherit",
486
- shell: this.$hostInfo.isWindows,
487
- });
496
+ const sanitizedArgs = this.$hostInfo.isWindows
497
+ ? localArgs.map((arg) => (0, helpers_1.quoteString)(arg))
498
+ : localArgs;
499
+ yield this.$childProcess.spawnFromEvent(gradlew, sanitizedArgs, "close", opts);
488
500
  }
489
501
  catch (err) {
490
502
  this.$errors.fail(`Failed to build plugin ${pluginBuildSettings.pluginName} : \n${err}`);
@@ -71,24 +71,26 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
71
71
  throw new Error("First call of getPlatformData without providing projectData.");
72
72
  }
73
73
  if (projectData && projectData.platformsDir) {
74
- const projectRoot = path.join(projectData.platformsDir, AndroidProjectService.ANDROID_PLATFORM_NAME);
74
+ const projectRoot = this.$options.hostProjectPath
75
+ ? this.$options.hostProjectPath
76
+ : path.join(projectData.platformsDir, AndroidProjectService.ANDROID_PLATFORM_NAME);
75
77
  const appDestinationDirectoryArr = [
76
78
  projectRoot,
77
- constants.APP_FOLDER_NAME,
79
+ this.$options.hostProjectModuleName,
78
80
  constants.SRC_DIR,
79
81
  constants.MAIN_DIR,
80
82
  constants.ASSETS_DIR,
81
83
  ];
82
84
  const configurationsDirectoryArr = [
83
85
  projectRoot,
84
- constants.APP_FOLDER_NAME,
86
+ this.$options.hostProjectModuleName,
85
87
  constants.SRC_DIR,
86
88
  constants.MAIN_DIR,
87
89
  constants.MANIFEST_FILE_NAME,
88
90
  ];
89
91
  const deviceBuildOutputArr = [
90
92
  projectRoot,
91
- constants.APP_FOLDER_NAME,
93
+ this.$options.hostProjectModuleName,
92
94
  constants.BUILD_DIR,
93
95
  constants.OUTPUTS_DIR,
94
96
  constants.APK_DIR,
@@ -104,7 +106,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
104
106
  projectRoot: projectRoot,
105
107
  getBuildOutputPath: (buildOptions) => {
106
108
  if (buildOptions.androidBundle) {
107
- return path.join(projectRoot, constants.APP_FOLDER_NAME, constants.BUILD_DIR, constants.OUTPUTS_DIR, constants.BUNDLE_DIR);
109
+ return path.join(projectRoot, this.$options.hostProjectModuleName, constants.BUILD_DIR, constants.OUTPUTS_DIR, constants.BUNDLE_DIR);
108
110
  }
109
111
  return path.join(...deviceBuildOutputArr);
110
112
  },
@@ -115,8 +117,8 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
115
117
  if (buildOptions.androidBundle) {
116
118
  return {
117
119
  packageNames: [
118
- `${constants.APP_FOLDER_NAME}${constants.AAB_EXTENSION_NAME}`,
119
- `${constants.APP_FOLDER_NAME}-${buildMode}${constants.AAB_EXTENSION_NAME}`,
120
+ `${this.$options.hostProjectModuleName}${constants.AAB_EXTENSION_NAME}`,
121
+ `${this.$options.hostProjectModuleName}-${buildMode}${constants.AAB_EXTENSION_NAME}`,
120
122
  ],
121
123
  };
122
124
  }
@@ -125,10 +127,10 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
125
127
  `${packageName}-${buildMode}${constants.APK_EXTENSION_NAME}`,
126
128
  `${projectData.projectName}-${buildMode}${constants.APK_EXTENSION_NAME}`,
127
129
  `${projectData.projectName}${constants.APK_EXTENSION_NAME}`,
128
- `${constants.APP_FOLDER_NAME}-${buildMode}${constants.APK_EXTENSION_NAME}`,
130
+ `${this.$options.hostProjectModuleName}-${buildMode}${constants.APK_EXTENSION_NAME}`,
129
131
  ],
130
132
  regexes: [
131
- new RegExp(`(${packageName}|${constants.APP_FOLDER_NAME})-.*-(${constants_1.Configurations.Debug}|${constants_1.Configurations.Release})(-unsigned)?${constants.APK_EXTENSION_NAME}`, "i"),
133
+ new RegExp(`(${packageName}|${this.$options.hostProjectModuleName})-.*-(${constants_1.Configurations.Debug}|${constants_1.Configurations.Release})(-unsigned)?${constants.APK_EXTENSION_NAME}`, "i"),
132
134
  ],
133
135
  };
134
136
  },
@@ -308,7 +310,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
308
310
  });
309
311
  }
310
312
  isPlatformPrepared(projectRoot, projectData) {
311
- return this.$fs.exists(path.join(this.getPlatformData(projectData).appDestinationDirectoryPath, constants.APP_FOLDER_NAME));
313
+ return this.$fs.exists(path.join(this.getPlatformData(projectData).appDestinationDirectoryPath, this.$options.hostProjectModuleName));
312
314
  }
313
315
  getFrameworkFilesExtensions() {
314
316
  return [".jar", ".dat"];
@@ -371,16 +373,9 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
371
373
  return __awaiter(this, void 0, void 0, function* () {
372
374
  const pluginPlatformsFolderPath = this.getPluginPlatformsFolderPath(pluginData, AndroidProjectService.ANDROID_PLATFORM_NAME);
373
375
  if (this.$fs.exists(pluginPlatformsFolderPath)) {
374
- const gradleArgs = (projectData.nsConfig.android.gradleArgs || [].concat(this.$options.gradleArgs || []));
375
- const options = {
376
- gradlePath: this.$options.gradlePath,
377
- gradleArgs,
378
- projectDir: projectData.projectDir,
379
- pluginName: pluginData.name,
380
- platformsAndroidDirPath: pluginPlatformsFolderPath,
381
- aarOutputDir: pluginPlatformsFolderPath,
382
- tempPluginDirPath: path.join(projectData.platformsDir, "tempPlugin"),
383
- };
376
+ const gradleArgs = (projectData.nsConfig.android.gradleArgs || []).concat(this.$options.gradleArgs || []);
377
+ const pluginOptions = (projectData.nsConfig.android.plugins || {})[pluginData.name] || {};
378
+ const options = Object.assign({ gradlePath: this.$options.gradlePath, gradleArgs, projectDir: projectData.projectDir, pluginName: pluginData.name, platformsAndroidDirPath: pluginPlatformsFolderPath, aarOutputDir: pluginPlatformsFolderPath, tempPluginDirPath: path.join(projectData.platformsDir, "tempPlugin") }, pluginOptions);
384
379
  if (yield this.$androidPluginBuildService.buildAar(options)) {
385
380
  this.$logger.info(`Built aar for ${options.pluginName}`);
386
381
  }
@@ -421,7 +416,9 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
421
416
  return _.values(depsDictionary);
422
417
  }
423
418
  provideDependenciesJson(projectData, dependencies) {
424
- const platformDir = path.join(projectData.platformsDir, AndroidProjectService.ANDROID_PLATFORM_NAME);
419
+ const platformDir = this.$options.hostProjectPath
420
+ ? this.$options.hostProjectPath
421
+ : path.join(projectData.platformsDir, AndroidProjectService.ANDROID_PLATFORM_NAME);
425
422
  const dependenciesJsonPath = path.join(platformDir, constants.DEPENDENCIES_JSON_NAME);
426
423
  let nativeDependencyData = dependencies.filter(AndroidProjectService.isNativeAndroidDependency);
427
424
  let nativeDependencies = nativeDependencyData.map(({ name, directory, dependencies }) => {
@@ -525,7 +522,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
525
522
  }
526
523
  getLegacyAppResourcesDestinationDirPath(projectData) {
527
524
  const resourcePath = [
528
- constants.APP_FOLDER_NAME,
525
+ this.$options.hostProjectModuleName,
529
526
  constants.SRC_DIR,
530
527
  constants.MAIN_DIR,
531
528
  constants.RESOURCES_DIR,
@@ -534,7 +531,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
534
531
  }
535
532
  getUpdatedAppResourcesDestinationDirPath(projectData) {
536
533
  const resourcePath = [
537
- constants.APP_FOLDER_NAME,
534
+ this.$options.hostProjectModuleName,
538
535
  constants.SRC_DIR,
539
536
  ];
540
537
  return path.join(this.getPlatformData(projectData).projectRoot, ...resourcePath);
@@ -30,13 +30,17 @@ class AssetsGenerationService {
30
30
  splash: ["splashBackgrounds", "splashCenterImages", "splashImages"],
31
31
  };
32
32
  }
33
- constructor($logger, $projectDataService, $fs) {
33
+ constructor($logger, $projectDataService, $fs, $options) {
34
34
  this.$logger = $logger;
35
35
  this.$projectDataService = $projectDataService;
36
36
  this.$fs = $fs;
37
+ this.$options = $options;
37
38
  }
38
39
  generateIcons(resourceGenerationData) {
39
40
  return __awaiter(this, void 0, void 0, function* () {
41
+ if (this.$options.hostProjectPath) {
42
+ return;
43
+ }
40
44
  this.$logger.info("Generating icons ...");
41
45
  yield this.generateImagesForDefinitions(resourceGenerationData, this.propertiesToEnumerate.icon);
42
46
  this.$logger.info("Icons generation completed.");
@@ -18,7 +18,7 @@ const helpers_1 = require("../common/helpers");
18
18
  const yok_1 = require("../common/yok");
19
19
  const constants = require("../constants");
20
20
  class CocoaPodsService {
21
- constructor($cocoaPodsPlatformManager, $fs, $childProcess, $errors, $logger, $config, $xcconfigService, $xcodeSelectService) {
21
+ constructor($cocoaPodsPlatformManager, $fs, $childProcess, $errors, $logger, $config, $xcconfigService, $xcodeSelectService, $projectData) {
22
22
  this.$cocoaPodsPlatformManager = $cocoaPodsPlatformManager;
23
23
  this.$fs = $fs;
24
24
  this.$childProcess = $childProcess;
@@ -27,6 +27,7 @@ class CocoaPodsService {
27
27
  this.$config = $config;
28
28
  this.$xcconfigService = $xcconfigService;
29
29
  this.$xcodeSelectService = $xcodeSelectService;
30
+ this.$projectData = $projectData;
30
31
  this.getCocoaPodsFromPodfile = _.memoize(this._getCocoaPodsFromPodfile, helpers_1.getHash);
31
32
  }
32
33
  getPodfileHeader(targetName) {
@@ -39,13 +40,18 @@ class CocoaPodsService {
39
40
  return path.join(projectRoot, constants_1.PODFILE_NAME);
40
41
  }
41
42
  executePodInstall(projectRoot, xcodeProjPath) {
43
+ var _a;
42
44
  return __awaiter(this, void 0, void 0, function* () {
43
- this.$logger.info("Installing pods...");
45
+ const cocoapodUseBundleExec = (_a = this.$projectData.nsConfig.ios) === null || _a === void 0 ? void 0 : _a.cocoapodUseBundleExec;
44
46
  let podTool = this.$config.USE_POD_SANDBOX ? "sandbox-pod" : "pod";
47
+ if (cocoapodUseBundleExec === true) {
48
+ podTool = `bundle exec ${podTool}`;
49
+ }
50
+ this.$logger.info(`Installing pods using "${podTool}"...`);
45
51
  const args = ["install"];
46
52
  if (process.platform === "darwin" && process.arch === "arm64") {
47
53
  const res = yield this.$childProcess
48
- .exec("arch -x86_64 pod --version", null, {
54
+ .exec(`arch -x86_64 ${podTool} --version`, null, {
49
55
  showStderr: true,
50
56
  })
51
57
  .then((res) => res.stdout + " " + res.stderr)
@@ -17,9 +17,10 @@ const path = require("path");
17
17
  const _ = require("lodash");
18
18
  const yok_1 = require("../common/yok");
19
19
  class FilesHashService {
20
- constructor($fs, $logger) {
20
+ constructor($fs, $logger, $options) {
21
21
  this.$fs = $fs;
22
22
  this.$logger = $logger;
23
+ this.$options = $options;
23
24
  }
24
25
  generateHashes(files) {
25
26
  return __awaiter(this, void 0, void 0, function* () {
@@ -41,7 +42,7 @@ class FilesHashService {
41
42
  }
42
43
  generateHashesForProject(platformData) {
43
44
  return __awaiter(this, void 0, void 0, function* () {
44
- const appFilesPath = path.join(platformData.appDestinationDirectoryPath, constants_2.APP_FOLDER_NAME);
45
+ const appFilesPath = path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName);
45
46
  const files = this.$fs.enumerateFilesInDirectorySync(appFilesPath);
46
47
  const hashes = yield this.generateHashes(files);
47
48
  return hashes;
@@ -90,7 +90,9 @@ class IOSProjectService extends projectServiceBaseLib.PlatformProjectServiceBase
90
90
  projectData.platformsDir &&
91
91
  this._platformsDirCache !== projectData.platformsDir) {
92
92
  const platform = this.$mobileHelper.normalizePlatformName((_a = this.$options.platformOverride) !== null && _a !== void 0 ? _a : this.$devicePlatformsConstants.iOS);
93
- const projectRoot = path.join(projectData.platformsDir, platform.toLowerCase());
93
+ const projectRoot = this.$options.hostProjectPath
94
+ ? this.$options.hostProjectPath
95
+ : path.join(projectData.platformsDir, platform.toLowerCase());
94
96
  const runtimePackage = this.$projectDataService.getRuntimePackage(projectData.projectDir, platform.toLowerCase());
95
97
  this._platformData = {
96
98
  frameworkPackageName: runtimePackage.name,
@@ -297,20 +299,24 @@ class IOSProjectService extends projectServiceBaseLib.PlatformProjectServiceBase
297
299
  }
298
300
  addFramework(frameworkPath, projectData) {
299
301
  return __awaiter(this, void 0, void 0, function* () {
300
- if (!this.$hostInfo.isWindows) {
301
- this.validateFramework(frameworkPath);
302
- const project = this.createPbxProj(projectData);
303
- const frameworkAddOptions = { customFramework: true };
304
- const dynamic = yield this.isDynamicFramework(frameworkPath);
305
- if (dynamic) {
306
- frameworkAddOptions["embed"] = true;
307
- frameworkAddOptions["sign"] = true;
308
- }
309
- const frameworkRelativePath = "$(SRCROOT)/" +
310
- this.getLibSubpathRelativeToProjectPath(frameworkPath, projectData);
311
- project.addFramework(frameworkRelativePath, frameworkAddOptions);
312
- this.savePbxProj(project, projectData);
302
+ if (this.$hostInfo.isWindows) {
303
+ return;
313
304
  }
305
+ this.validateFramework(frameworkPath);
306
+ const project = this.createPbxProj(projectData);
307
+ const frameworkAddOptions = { customFramework: true };
308
+ const dynamic = yield this.isDynamicFramework(frameworkPath);
309
+ if (dynamic) {
310
+ frameworkAddOptions["embed"] = true;
311
+ frameworkAddOptions["sign"] = true;
312
+ }
313
+ if (this.$options.hostProjectPath) {
314
+ frameworkAddOptions["embed"] = true;
315
+ frameworkAddOptions["sign"] = false;
316
+ }
317
+ const frameworkRelativePath = this.getLibSubpathRelativeToProjectPath(frameworkPath, projectData);
318
+ project.addFramework(frameworkRelativePath, frameworkAddOptions);
319
+ this.savePbxProj(project, projectData);
314
320
  });
315
321
  }
316
322
  addStaticLibrary(staticLibPath, projectData) {
@@ -328,7 +334,9 @@ class IOSProjectService extends projectServiceBaseLib.PlatformProjectServiceBase
328
334
  }
329
335
  prepareProject(projectData, prepareData) {
330
336
  return __awaiter(this, void 0, void 0, function* () {
331
- const projectRoot = path.join(projectData.platformsDir, "ios");
337
+ const projectRoot = this.$options.hostProjectPath
338
+ ? this.$options.hostProjectPath
339
+ : path.join(projectData.platformsDir, this.$devicePlatformsConstants.iOS.toLowerCase());
332
340
  const platformData = this.getPlatformData(projectData);
333
341
  const pluginsData = this.getAllProductionPlugins(projectData);
334
342
  const pbxProjPath = this.getPbxProjPath(projectData);
@@ -344,8 +352,25 @@ class IOSProjectService extends projectServiceBaseLib.PlatformProjectServiceBase
344
352
  yield this.$iOSSigningService.setupSigningFromTeam(projectRoot, projectData, teamId);
345
353
  }
346
354
  const project = this.createPbxProj(projectData);
355
+ if (this.$options.hostProjectPath) {
356
+ try {
357
+ project.addPbxGroup([], "NativeScript", "NativeScript", null, {
358
+ isMain: true,
359
+ filesRelativeToProject: true,
360
+ uuid: "NATIVESCRIPTNATIVESCRIPT",
361
+ });
362
+ const buildFolderPath = path.join(this.$options.hostProjectPath, projectData.projectName);
363
+ project.addResourceFile(buildFolderPath, {}, "NATIVESCRIPTNATIVESCRIPT");
364
+ const metadataPath = path.relative(this.$options.hostProjectPath, buildFolderPath);
365
+ project.addToOtherLinkerFlags(JSON.stringify(`-sectcreate __DATA __TNSMetadata "${metadataPath}/metadata-arm64.bin"`));
366
+ this.savePbxProj(project, projectData);
367
+ }
368
+ catch (err) {
369
+ this.$logger.trace("Error adding NativeScript group to host project", err);
370
+ }
371
+ }
347
372
  const resources = project.pbxGroupByName("Resources");
348
- if (resources) {
373
+ if (resources && !this.$options.hostProjectPath) {
349
374
  const references = project.pbxFileReferenceSection();
350
375
  const xcodeProjectImages = _.map(resources.children, (resource) => this.replace(references[resource.value].name));
351
376
  this.$logger.trace("Images from Xcode project");
@@ -489,10 +514,18 @@ class IOSProjectService extends projectServiceBaseLib.PlatformProjectServiceBase
489
514
  return name.replace(/\\\"/g, '"');
490
515
  }
491
516
  getLibSubpathRelativeToProjectPath(targetPath, projectData) {
492
- const frameworkPath = path.relative(this.getPlatformData(projectData).projectRoot, targetPath);
517
+ const projectRoot = this.getPlatformData(projectData).projectRoot;
518
+ const frameworkPath = path.relative(projectRoot, targetPath);
493
519
  return frameworkPath;
494
520
  }
495
521
  getPbxProjPath(projectData) {
522
+ if (this.$options.hostProjectPath) {
523
+ let xcodeProjectPath = this.$xcprojService.findXcodeProject(this.$options.hostProjectPath);
524
+ if (!xcodeProjectPath) {
525
+ this.$errors.fail("Xcode project not found at the specified directory");
526
+ }
527
+ return path.join(xcodeProjectPath, "project.pbxproj");
528
+ }
496
529
  return path.join(this.$xcprojService.getXcodeprojPath(projectData, this.getPlatformData(projectData).projectRoot), "project.pbxproj");
497
530
  }
498
531
  createPbxProj(projectData) {
@@ -11,8 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AndroidDeviceSocketsLiveSyncService = void 0;
13
13
  const android_device_livesync_service_base_1 = require("./android-device-livesync-service-base");
14
- const constants_1 = require("../../constants");
15
- const constants_2 = require("../../common/constants");
14
+ const constants_1 = require("../../common/constants");
16
15
  const android_livesync_tool_1 = require("./android-livesync-tool");
17
16
  const path = require("path");
18
17
  const semver = require("semver");
@@ -57,7 +56,7 @@ class AndroidDeviceSocketsLiveSyncService extends android_device_livesync_servic
57
56
  });
58
57
  }
59
58
  getPathToLiveSyncFileOnDevice(appIdentifier) {
60
- return `${constants_2.LiveSyncPaths.ANDROID_TMP_DIR_NAME}/${appIdentifier}-livesync-in-progress`;
59
+ return `${constants_1.LiveSyncPaths.ANDROID_TMP_DIR_NAME}/${appIdentifier}-livesync-in-progress`;
61
60
  }
62
61
  finalizeSync(liveSyncInfo, projectData) {
63
62
  return __awaiter(this, void 0, void 0, function* () {
@@ -181,7 +180,7 @@ class AndroidDeviceSocketsLiveSyncService extends android_device_livesync_servic
181
180
  connectLivesyncTool(appIdentifier, connectTimeout) {
182
181
  return __awaiter(this, void 0, void 0, function* () {
183
182
  const platformData = this.platformsDataService.getPlatformData(this.$devicePlatformsConstants.Android, this.data);
184
- const projectFilesPath = path.join(platformData.appDestinationDirectoryPath, constants_1.APP_FOLDER_NAME);
183
+ const projectFilesPath = path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName);
185
184
  if (!this.livesyncTool.hasConnection()) {
186
185
  yield this.livesyncTool.connect({
187
186
  appIdentifier,
@@ -24,8 +24,8 @@ const semver = require("semver");
24
24
  const _ = require("lodash");
25
25
  const yok_1 = require("../../common/yok");
26
26
  class AndroidLiveSyncService extends platform_livesync_service_base_1.PlatformLiveSyncServiceBase {
27
- constructor($platformsDataService, $projectFilesManager, $injector, $devicePathProvider, $fs, $logger) {
28
- super($fs, $logger, $platformsDataService, $projectFilesManager, $devicePathProvider);
27
+ constructor($platformsDataService, $projectFilesManager, $injector, $devicePathProvider, $fs, $logger, $options) {
28
+ super($fs, $logger, $platformsDataService, $projectFilesManager, $devicePathProvider, $options);
29
29
  this.$platformsDataService = $platformsDataService;
30
30
  this.$projectFilesManager = $projectFilesManager;
31
31
  this.$injector = $injector;
@@ -23,8 +23,8 @@ const constants_1 = require("../../constants");
23
23
  const decorators_1 = require("../../common/decorators");
24
24
  const yok_1 = require("../../common/yok");
25
25
  class IOSLiveSyncService extends platform_livesync_service_base_1.PlatformLiveSyncServiceBase {
26
- constructor($fs, $platformsDataService, $projectFilesManager, $injector, $tempService, $devicePathProvider, $logger) {
27
- super($fs, $logger, $platformsDataService, $projectFilesManager, $devicePathProvider);
26
+ constructor($fs, $platformsDataService, $projectFilesManager, $injector, $tempService, $devicePathProvider, $logger, $options) {
27
+ super($fs, $logger, $platformsDataService, $projectFilesManager, $devicePathProvider, $options);
28
28
  this.$fs = $fs;
29
29
  this.$platformsDataService = $platformsDataService;
30
30
  this.$projectFilesManager = $projectFilesManager;
@@ -24,12 +24,13 @@ const helpers_1 = require("../../common/helpers");
24
24
  const decorators_1 = require("../../common/decorators");
25
25
  const color_1 = require("../../color");
26
26
  class PlatformLiveSyncServiceBase {
27
- constructor($fs, $logger, $platformsDataService, $projectFilesManager, $devicePathProvider) {
27
+ constructor($fs, $logger, $platformsDataService, $projectFilesManager, $devicePathProvider, $options) {
28
28
  this.$fs = $fs;
29
29
  this.$logger = $logger;
30
30
  this.$platformsDataService = $platformsDataService;
31
31
  this.$projectFilesManager = $projectFilesManager;
32
32
  this.$devicePathProvider = $devicePathProvider;
33
+ this.$options = $options;
33
34
  this._deviceLiveSyncServicesCache = {};
34
35
  }
35
36
  getDeviceLiveSyncService(device, projectData) {
@@ -81,7 +82,7 @@ class PlatformLiveSyncServiceBase {
81
82
  if (deviceLiveSyncService.beforeLiveSyncAction) {
82
83
  yield deviceLiveSyncService.beforeLiveSyncAction(deviceAppData);
83
84
  }
84
- const projectFilesPath = path.join(platformData.appDestinationDirectoryPath, constants_1.APP_FOLDER_NAME);
85
+ const projectFilesPath = path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName);
85
86
  const localToDevicePaths = yield this.$projectFilesManager.createLocalToDevicePaths(deviceAppData, projectFilesPath, null, []);
86
87
  const modifiedFilesData = yield this.transferFiles(deviceAppData, localToDevicePaths, projectFilesPath, projectData, syncInfo.liveSyncDeviceData, { isFullSync: true, force: syncInfo.force });
87
88
  return {
@@ -112,7 +113,7 @@ class PlatformLiveSyncServiceBase {
112
113
  }
113
114
  if (existingFiles.length) {
114
115
  const platformData = this.$platformsDataService.getPlatformData(device.deviceInfo.platform, projectData);
115
- const projectFilesPath = path.join(platformData.appDestinationDirectoryPath, constants_1.APP_FOLDER_NAME);
116
+ const projectFilesPath = path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName);
116
117
  const localToDevicePaths = yield this.$projectFilesManager.createLocalToDevicePaths(deviceAppData, projectFilesPath, existingFiles, []);
117
118
  modifiedLocalToDevicePaths.push(...localToDevicePaths);
118
119
  modifiedLocalToDevicePaths = yield this.transferFiles(deviceAppData, localToDevicePaths, projectFilesPath, projectData, liveSyncInfo.liveSyncDeviceData, { isFullSync: false, force: liveSyncInfo.force });
@@ -23,10 +23,11 @@ class LogSourceMapService {
23
23
  get $platformsDataService() {
24
24
  return this.$injector.resolve("platformsDataService");
25
25
  }
26
- constructor($fs, $projectDataService, $injector, $devicePlatformsConstants, $logger) {
26
+ constructor($fs, $projectDataService, $injector, $options, $devicePlatformsConstants, $logger) {
27
27
  this.$fs = $fs;
28
28
  this.$projectDataService = $projectDataService;
29
29
  this.$injector = $injector;
30
+ this.$options = $options;
30
31
  this.$devicePlatformsConstants = $devicePlatformsConstants;
31
32
  this.$logger = $logger;
32
33
  this.cache = {};
@@ -121,7 +122,7 @@ class LogSourceMapService {
121
122
  return runtimeVersion;
122
123
  }
123
124
  getOriginalFileLocation(platform, parsedLine, projectData) {
124
- const fileLocation = path.join(this.getFilesLocation(platform, projectData), constants_1.APP_FOLDER_NAME);
125
+ const fileLocation = path.join(this.getFilesLocation(platform, projectData), this.$options.hostProjectModuleName);
125
126
  if (parsedLine && parsedLine.filePath) {
126
127
  const sourceMapFile = path.join(fileLocation, parsedLine.filePath);
127
128
  const smc = this.cache[sourceMapFile];
@@ -21,13 +21,17 @@ const constants_1 = require("../../constants");
21
21
  const decorators_1 = require("../../common/decorators");
22
22
  const yok_1 = require("../../common/yok");
23
23
  class AddPlatformService {
24
- constructor($fs, $logger, $packageManager, $terminalSpinnerService, $analyticsService) {
24
+ constructor($fs, $logger, $options, $packageManager, $terminalSpinnerService, $analyticsService) {
25
25
  this.$fs = $fs;
26
26
  this.$logger = $logger;
27
+ this.$options = $options;
27
28
  this.$packageManager = $packageManager;
28
29
  this.$terminalSpinnerService = $terminalSpinnerService;
29
30
  this.$analyticsService = $analyticsService;
30
31
  }
32
+ addProjectHost() {
33
+ return __awaiter(this, void 0, void 0, function* () { });
34
+ }
31
35
  addPlatformSafe(projectData, platformData, packageToInstall, addPlatformData) {
32
36
  return __awaiter(this, void 0, void 0, function* () {
33
37
  const spinner = this.$terminalSpinnerService.createSpinner();
@@ -94,8 +98,9 @@ class AddPlatformService {
94
98
  return null;
95
99
  }
96
100
  addNativePlatform(platformData, projectData, frameworkDirPath, frameworkVersion) {
101
+ var _a;
97
102
  return __awaiter(this, void 0, void 0, function* () {
98
- const platformDir = path.join(projectData.platformsDir, platformData.normalizedPlatformName.toLowerCase());
103
+ const platformDir = (_a = this.$options.hostProjectPath) !== null && _a !== void 0 ? _a : path.join(projectData.platformsDir, platformData.normalizedPlatformName.toLowerCase());
99
104
  this.$fs.deleteDirectory(platformDir);
100
105
  yield platformData.platformProjectService.createProject(path.resolve(frameworkDirPath), frameworkVersion, projectData);
101
106
  platformData.platformProjectService.ensureConfigurationFileInAppResources(projectData);
@@ -20,11 +20,12 @@ const helpers_1 = require("../../common/helpers");
20
20
  const decorators_1 = require("../../common/decorators");
21
21
  const yok_1 = require("../../common/yok");
22
22
  class PrepareNativePlatformService {
23
- constructor($hooksService, $nodeModulesBuilder, $projectChangesService, $metadataFilteringService) {
23
+ constructor($hooksService, $nodeModulesBuilder, $projectChangesService, $metadataFilteringService, $options) {
24
24
  this.$hooksService = $hooksService;
25
25
  this.$nodeModulesBuilder = $nodeModulesBuilder;
26
26
  this.$projectChangesService = $projectChangesService;
27
27
  this.$metadataFilteringService = $metadataFilteringService;
28
+ this.$options = $options;
28
29
  }
29
30
  prepareNativePlatform(platformData, projectData, prepareData) {
30
31
  return __awaiter(this, void 0, void 0, function* () {
@@ -40,8 +41,10 @@ class PrepareNativePlatformService {
40
41
  if (changesInfo.hasChanges) {
41
42
  yield this.cleanProject(platformData, { release });
42
43
  }
43
- platformData.platformProjectService.prepareAppResources(projectData);
44
- if (hasChangesRequirePrepare) {
44
+ if (!this.$options.hostProjectPath) {
45
+ platformData.platformProjectService.prepareAppResources(projectData);
46
+ }
47
+ if (hasChangesRequirePrepare || this.$options.hostProjectPath) {
45
48
  yield platformData.platformProjectService.prepareProject(projectData, prepareData);
46
49
  }
47
50
  if (hasNativeModulesChange) {
@@ -74,7 +74,9 @@ class PlatformEnvironmentRequirements {
74
74
  win32: "windows",
75
75
  darwin: "macos",
76
76
  }[process.platform];
77
- const anchor = platform ? `#setting-up-${os}-for-${platform.toLowerCase()}` : "";
77
+ const anchor = platform
78
+ ? `#setting-up-${os}-for-${platform.toLowerCase()}`
79
+ : "";
78
80
  return (`Verify that your environment is configured according to the system requirements described at\n` +
79
81
  `https://docs.nativescript.org/setup/${os}${anchor}.`);
80
82
  }
@@ -412,7 +412,7 @@ This framework comes from ${dependencyName} plugin, which is installed multiple
412
412
  const isPlatformInstalled = this.$fs.exists(path.join(projectData.platformsDir, platform.toLowerCase()));
413
413
  if (isPlatformInstalled) {
414
414
  const platformData = this.$platformsDataService.getPlatformData(platform.toLowerCase(), projectData);
415
- const pluginDestinationPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME, "tns_modules");
415
+ const pluginDestinationPath = path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName, "tns_modules");
416
416
  yield action(pluginDestinationPath, platform.toLowerCase(), platformData);
417
417
  }
418
418
  }
@@ -450,6 +450,9 @@ This framework comes from ${dependencyName} plugin, which is installed multiple
450
450
  });
451
451
  }
452
452
  getAllPluginsNativeHashes(pathToPluginsBuildFile) {
453
+ if (this.$options.hostProjectPath) {
454
+ return {};
455
+ }
453
456
  let data = {};
454
457
  if (this.$fs.exists(pathToPluginsBuildFile)) {
455
458
  data = this.$fs.readJson(pathToPluginsBuildFile);
@@ -457,6 +460,9 @@ This framework comes from ${dependencyName} plugin, which is installed multiple
457
460
  return data;
458
461
  }
459
462
  setPluginNativeHashes(opts) {
463
+ if (this.$options.hostProjectPath) {
464
+ return;
465
+ }
460
466
  opts.allPluginsNativeHashes[opts.pluginData.name] =
461
467
  opts.currentPluginNativeHashes;
462
468
  this.$fs.writeJson(opts.pathToPluginsBuildFile, opts.allPluginsNativeHashes);