nativescript 9.0.6-dev.0 → 9.0.6-dev.1

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.
@@ -7,24 +7,52 @@ const yok_1 = require("../common/yok");
7
7
  const trapezedev_project_1 = require("@nstudio/trapezedev-project");
8
8
  const minimatch_1 = require("minimatch");
9
9
  const sourceExtensions = [
10
- '.swift', '.m', '.mm', '.c', '.cpp', '.cc', '.cxx', '.h', '.hpp'
10
+ ".swift",
11
+ ".m",
12
+ ".mm",
13
+ ".c",
14
+ ".cpp",
15
+ ".cc",
16
+ ".cxx",
17
+ ".h",
18
+ ".hpp",
11
19
  ];
12
20
  const resourceExtensions = [
13
- '.png', '.jpg', '.jpeg', '.gif', '.svg', '.pdf', // Images
14
- '.ttf', '.otf', '.woff', '.woff2', // Fonts
15
- '.xcassets', // Asset catalogs
16
- '.storyboard', '.xib', // Interface files
17
- '.strings', '.stringsdict', // Localization
18
- '.json', '.xml', '.plist', // Data files
19
- '.m4a', '.mp3', '.wav', '.caf', // Audio
20
- '.mp4', '.mov', // Video
21
- '.bundle', // Resource bundles
21
+ ".png",
22
+ ".jpg",
23
+ ".jpeg",
24
+ ".gif",
25
+ ".svg",
26
+ ".pdf", // Images
27
+ ".ttf",
28
+ ".otf",
29
+ ".woff",
30
+ ".woff2", // Fonts
31
+ ".xcassets", // Asset catalogs
32
+ ".storyboard",
33
+ ".xib", // Interface files
34
+ ".strings",
35
+ ".stringsdict", // Localization
36
+ ".json",
37
+ ".xml",
38
+ ".plist", // Data files
39
+ ".m4a",
40
+ ".mp3",
41
+ ".wav",
42
+ ".caf", // Audio
43
+ ".mp4",
44
+ ".mov", // Video
45
+ ".bundle", // Resource bundles
22
46
  ];
23
47
  const WATCH_APP_IDENTIFIER = "watchkitapp";
24
48
  const WACTCH_EXTENSION_IDENTIFIER = "watchkitextension";
25
49
  const CONFIG_FILE_WATCHAPP = "watchapp.json";
26
50
  const CONFIG_FILE_EXTENSION = "extension.json";
27
- const RESOURCES_TO_IGNORE = [CONFIG_FILE_WATCHAPP, CONFIG_FILE_EXTENSION, 'node_modules'];
51
+ const RESOURCES_TO_IGNORE = [
52
+ CONFIG_FILE_WATCHAPP,
53
+ CONFIG_FILE_EXTENSION,
54
+ "node_modules",
55
+ ];
28
56
  class IOSWatchAppService {
29
57
  constructor($fs, $pbxprojDomXcode, $xcode, $iOSNativeTargetService, $logger) {
30
58
  this.$fs = $fs;
@@ -33,11 +61,11 @@ class IOSWatchAppService {
33
61
  this.$iOSNativeTargetService = $iOSNativeTargetService;
34
62
  this.$logger = $logger;
35
63
  }
36
- addResourceFile(project, path, opt, group = 'WatchResources') {
64
+ addResourceFile(project, path, opt, group = "WatchResources") {
37
65
  const file = project.addResourceFile(path, opt, group);
38
66
  project.addToResourcesPbxGroup(file, group);
39
67
  }
40
- addSourceFile(project, path, opt, group = 'WatchSrc') {
68
+ addSourceFile(project, path, opt, group = "WatchSrc") {
41
69
  const file = project.addSourceFile(path, opt, group);
42
70
  project.addToResourcesPbxGroup(file, group);
43
71
  }
@@ -54,7 +82,9 @@ class IOSWatchAppService {
54
82
  const project = new this.$xcode.project(pbxProjPath);
55
83
  project.parseSync();
56
84
  const configPath = path.join(path.join(appPath, appFolder), "watchapp.json");
57
- const config = this.$fs.exists(configPath) ? this.$fs.readJson(configPath) : null;
85
+ const config = this.$fs.exists(configPath)
86
+ ? this.$fs.readJson(configPath)
87
+ : null;
58
88
  const targetType = (_a = config === null || config === void 0 ? void 0 : config.targetType) !== null && _a !== void 0 ? _a : constants_1.IOSNativeTargetTypes.watchApp;
59
89
  project.removeTargetsByProductType(constants_1.IOSNativeTargetProductTypes.watchApp);
60
90
  project.removeTargetsByProductType(targetType);
@@ -68,7 +98,9 @@ class IOSWatchAppService {
68
98
  if (this.$fs.exists(extensionPath)) {
69
99
  const extensionFolder = this.$iOSNativeTargetService.getTargetDirectories(extensionPath)[0];
70
100
  const configPath = path.join(path.join(extensionPath, extensionFolder), "extension.json");
71
- const config = this.$fs.exists(configPath) ? this.$fs.readJson(configPath) : null;
101
+ const config = this.$fs.exists(configPath)
102
+ ? this.$fs.readJson(configPath)
103
+ : null;
72
104
  const targetType = (_b = config === null || config === void 0 ? void 0 : config.targetType) !== null && _b !== void 0 ? _b : constants_1.IOSNativeTargetTypes.watchExtension;
73
105
  project.removeTargetsByProductType(constants_1.IOSNativeTargetProductTypes.watchExtension);
74
106
  project.removeTargetsByProductType(targetType);
@@ -96,7 +128,7 @@ class IOSWatchAppService {
96
128
  project.addBuildPhase([], "PBXSourcesBuildPhase", "Sources", target.uuid);
97
129
  project.addBuildPhase([], "PBXResourcesBuildPhase", "Resources", target.uuid);
98
130
  project.addBuildPhase([], "PBXFrameworksBuildPhase", "Frameworks", target.uuid);
99
- project.addBuildPhase([], "PBXCopyFilesBuildPhase", "Embed Frameworks", target.uuid);
131
+ project.addBuildPhase([], "PBXCopyFilesBuildPhase", "Embed Frameworks", target.uuid, "frameworks");
100
132
  project.addToHeaderSearchPaths(targetPath, target.pbxNativeTarget.productName);
101
133
  return target;
102
134
  }
@@ -137,20 +169,21 @@ class IOSWatchAppService {
137
169
  const items = this.$fs.readDirectory(dirPath);
138
170
  for (const item of items) {
139
171
  // Skip hidden files and excluded files/directories
140
- if (item.startsWith('.') || RESOURCES_TO_IGNORE.indexOf(item) !== -1) {
172
+ if (item.startsWith(".") || RESOURCES_TO_IGNORE.indexOf(item) !== -1) {
141
173
  continue;
142
174
  }
143
175
  const itemPath = path.join(dirPath, item);
144
176
  const stats = this.$fs.getFsStats(itemPath);
145
177
  const relativePath = path.relative(platformData.projectRoot, itemPath);
146
178
  // Check if file/directory should be excluded based on patterns
147
- if (excludePatterns && this.shouldExclude(relativePath, excludePatterns)) {
179
+ if (excludePatterns &&
180
+ this.shouldExclude(relativePath, excludePatterns)) {
148
181
  this.$logger.debug(`Excluding from resources: ${relativePath}`);
149
182
  continue;
150
183
  }
151
184
  if (stats.isDirectory()) {
152
185
  // Special handling for .xcassets, .bundle, and other resource bundles
153
- if (item.endsWith('.xcassets') || item.endsWith('.bundle')) {
186
+ if (item.endsWith(".xcassets") || item.endsWith(".bundle")) {
154
187
  this.$logger.debug(`Adding resource bundle: ${relativePath}`);
155
188
  this.addResourceFile(project, relativePath, { target: targetUuid }, groupName);
156
189
  }
@@ -224,7 +257,7 @@ class IOSWatchAppService {
224
257
  const relativeInfoPlistPath = path.relative(platformData.projectRoot, infoPlistPath);
225
258
  buildConfigProperties.push({
226
259
  name: "INFOPLIST_FILE",
227
- value: `"${infoPlistPath}"`
260
+ value: `"${infoPlistPath}"`,
228
261
  });
229
262
  resourcesExclude.push(relativeInfoPlistPath);
230
263
  }
@@ -248,7 +281,7 @@ class IOSWatchAppService {
248
281
  this.$iOSNativeTargetService.setConfigurationsFromJsonFile(configPath, target.uuid, targetName, project);
249
282
  project.addToHeaderSearchPaths(targetPath, target.pbxNativeTarget.productName);
250
283
  if ((config === null || config === void 0 ? void 0 : config.importSourcesFromMainFolder) !== false) {
251
- await this.addSourceFilesFromDirectory(path.dirname(configPath), target.uuid, project, platformData, targetName + 'Src', srcExclude);
284
+ await this.addSourceFilesFromDirectory(path.dirname(configPath), target.uuid, project, platformData, targetName + "Src", srcExclude);
252
285
  }
253
286
  if ((config === null || config === void 0 ? void 0 : config.importResourcesFromMainFolder) !== false) {
254
287
  await this.addTargetResources(path.dirname(configPath), [target.uuid], project, platformData, resourcesGroup, resourcesExclude);
@@ -270,7 +303,7 @@ class IOSWatchAppService {
270
303
  if (config.src && Array.isArray(config.src)) {
271
304
  this.$logger.debug(`Processing ${config.src.length} custom source file(s) for watch target: ${targetName}`);
272
305
  for (const srcPath of config.src) {
273
- this.addCustomSourceFile(srcPath, target.uuid, project, projectData, platformData, srcExclude, targetName + 'Src', basedir);
306
+ this.addCustomSourceFile(srcPath, target.uuid, project, projectData, platformData, srcExclude, targetName + "Src", basedir);
274
307
  }
275
308
  }
276
309
  if (config.SPMPackages && Array.isArray(config.SPMPackages)) {
@@ -301,7 +334,8 @@ class IOSWatchAppService {
301
334
  const stats = this.$fs.getFsStats(resolvedPath);
302
335
  if (stats.isDirectory()) {
303
336
  this.$logger.debug(`Recursively adding files from resource directory: ${resourcePath}`);
304
- if (relativePath.endsWith('.xcassets') || relativePath.endsWith('.bundle')) {
337
+ if (relativePath.endsWith(".xcassets") ||
338
+ relativePath.endsWith(".bundle")) {
305
339
  this.$logger.debug(`Adding resource bundle: ${relativePath} for target:${targetUuid}`);
306
340
  this.addResourceFile(project, relativePath, { target: targetUuid }, groupName);
307
341
  }
@@ -355,19 +389,20 @@ class IOSWatchAppService {
355
389
  addAllResourcesRecursively(dirPath, targetUuid, project, platformData, groupName, excludePatterns) {
356
390
  const items = this.$fs.readDirectory(dirPath);
357
391
  for (const item of items) {
358
- if (item.startsWith('.')) {
392
+ if (item.startsWith(".")) {
359
393
  continue;
360
394
  }
361
395
  const itemPath = path.join(dirPath, item);
362
396
  const stats = this.$fs.getFsStats(itemPath);
363
397
  const relativePath = path.relative(platformData.projectRoot, itemPath);
364
- if (excludePatterns && this.shouldExclude(relativePath, excludePatterns)) {
398
+ if (excludePatterns &&
399
+ this.shouldExclude(relativePath, excludePatterns)) {
365
400
  this.$logger.debug(`Excluding from resources: ${relativePath}`);
366
401
  return;
367
402
  }
368
403
  if (stats.isDirectory()) {
369
404
  // Special handling for .xcassets, .bundle - add as bundles, not recursively
370
- if (item.endsWith('.xcassets') || item.endsWith('.bundle')) {
405
+ if (item.endsWith(".xcassets") || item.endsWith(".bundle")) {
371
406
  this.$logger.debug(`Adding resource bundle: ${relativePath} for target:${targetUuid}`);
372
407
  this.addResourceFile(project, relativePath, { target: targetUuid }, groupName);
373
408
  }
@@ -391,7 +426,7 @@ class IOSWatchAppService {
391
426
  }
392
427
  const relativePath = path.relative(platformData.projectRoot, modulePath);
393
428
  const stats = this.$fs.getFsStats(modulePath);
394
- const isFramework = modulePath.endsWith('.framework') || modulePath.endsWith('.xcframework');
429
+ const isFramework = modulePath.endsWith(".framework") || modulePath.endsWith(".xcframework");
395
430
  const isFolder = stats.isDirectory() && !isFramework;
396
431
  this.$logger.debug(`Adding module dependency: ${JSON.stringify(moduleDef)} to ${targetName}, basedir:${basedir}, isFramework:${isFramework} isFolder:${isFolder}`);
397
432
  if (isFramework) {
@@ -405,7 +440,8 @@ class IOSWatchAppService {
405
440
  else {
406
441
  this.$logger.warn(`Unknown module type for: ${modulePath}`);
407
442
  }
408
- if (moduleDef.headerSearchPaths && Array.isArray(moduleDef.headerSearchPaths)) {
443
+ if (moduleDef.headerSearchPaths &&
444
+ Array.isArray(moduleDef.headerSearchPaths)) {
409
445
  for (const headerPath of moduleDef.headerSearchPaths) {
410
446
  const resolvedPath = this.resolvePathWithBasedir(headerPath, basedir, projectData.projectDir);
411
447
  const relPath = path.relative(platformData.projectRoot, resolvedPath);
@@ -430,12 +466,15 @@ class IOSWatchAppService {
430
466
  }
431
467
  getFolderFiles(dirPath, rootPath, excludePatterns) {
432
468
  const result = [];
433
- const files = this.$fs.readDirectory(dirPath).filter((fileName) => !fileName.startsWith("."));
469
+ const files = this.$fs
470
+ .readDirectory(dirPath)
471
+ .filter((fileName) => !fileName.startsWith("."));
434
472
  for (const item of files) {
435
473
  const itemPath = path.join(dirPath, item);
436
474
  const stats = this.$fs.getFsStats(itemPath);
437
475
  const relativePath = path.relative(rootPath, itemPath);
438
- if (excludePatterns && this.shouldExclude(relativePath, excludePatterns)) {
476
+ if (excludePatterns &&
477
+ this.shouldExclude(relativePath, excludePatterns)) {
439
478
  this.$logger.debug(`Excluding from src: ${relativePath}`);
440
479
  continue;
441
480
  }
@@ -458,22 +497,22 @@ class IOSWatchAppService {
458
497
  var _a;
459
498
  const moduleName = moduleDef.name || path.basename(modulePath);
460
499
  const targetRelativePath = path.relative(platformData.projectRoot, modulePath);
461
- const moduleTarget = project.addTarget(moduleName, (_a = moduleDef.targetType) !== null && _a !== void 0 ? _a : 'framework', targetRelativePath, target.uuid);
500
+ const moduleTarget = project.addTarget(moduleName, (_a = moduleDef.targetType) !== null && _a !== void 0 ? _a : "framework", targetRelativePath, target.uuid);
462
501
  this.$logger.debug(`Adding folder module ${moduleName} with path ${modulePath} with target uuid:${moduleTarget.uuid}`);
463
502
  const { path: filePath, name, dependencies, frameworks, buildConfigurationProperties, src, resources, SPMPackages, ...otherProps } = moduleDef;
464
- project.addFramework(moduleName + '.framework', {
503
+ project.addFramework(moduleName + ".framework", {
465
504
  target: target.uuid,
466
505
  basename: moduleName,
467
- path: moduleName + '.framework',
506
+ path: moduleName + ".framework",
468
507
  customFramework: true,
469
- explicitFileType: 'wrapper.framework',
470
- ...otherProps
508
+ explicitFileType: "wrapper.framework",
509
+ ...otherProps,
471
510
  });
472
511
  // Add build phases
473
512
  project.addBuildPhase([], "PBXSourcesBuildPhase", "Sources", moduleTarget.uuid);
474
513
  project.addBuildPhase([], "PBXResourcesBuildPhase", "Resources", moduleTarget.uuid);
475
514
  project.addBuildPhase([], "PBXFrameworksBuildPhase", "Frameworks", moduleTarget.uuid);
476
- project.addBuildPhase([], "PBXCopyFilesBuildPhase", "Embed Frameworks", moduleTarget.uuid);
515
+ project.addBuildPhase([], "PBXCopyFilesBuildPhase", "Embed Frameworks", moduleTarget.uuid, "frameworks");
477
516
  const files = this.getFolderFiles(modulePath, platformData.projectRoot, srcExclude);
478
517
  this.$logger.debug(`module ${moduleName} has ${files.length} files`);
479
518
  if (files.length > 0) {
@@ -487,11 +526,14 @@ class IOSWatchAppService {
487
526
  this.$logger.debug(`Adding ${moduleDef.frameworks.length} framework(s) for module ${JSON.stringify(moduleDef)}`);
488
527
  for (const framework of moduleDef.frameworks) {
489
528
  this.$logger.debug(`Adding framework ${JSON.stringify(framework)} for module ${JSON.stringify(moduleDef)}`);
490
- if (typeof framework === 'string') {
529
+ if (typeof framework === "string") {
491
530
  project.addFramework(framework, { target: moduleTarget.uuid });
492
531
  }
493
532
  else {
494
- project.addFramework(framework.path, { target: moduleTarget.uuid, ...framework });
533
+ project.addFramework(framework.path, {
534
+ target: moduleTarget.uuid,
535
+ ...framework,
536
+ });
495
537
  }
496
538
  this.$logger.debug(`Added framework dependency: ${framework}`);
497
539
  }
@@ -499,7 +541,7 @@ class IOSWatchAppService {
499
541
  if (moduleDef.src && Array.isArray(moduleDef.src)) {
500
542
  this.$logger.debug(`Processing ${config.src.length} custom source file(s) for target: ${moduleName}`);
501
543
  for (const srcPath of moduleDef.src) {
502
- this.addCustomSourceFile(srcPath, moduleTarget.uuid, project, projectData, platformData, srcExclude, moduleName + 'Src', basedir);
544
+ this.addCustomSourceFile(srcPath, moduleTarget.uuid, project, projectData, platformData, srcExclude, moduleName + "Src", basedir);
503
545
  }
504
546
  }
505
547
  if (moduleDef.resources && Array.isArray(moduleDef.resources)) {
@@ -510,28 +552,41 @@ class IOSWatchAppService {
510
552
  }
511
553
  if (moduleDef.dependencies && Array.isArray(moduleDef.dependencies)) {
512
554
  const currentTargets = project.pbxNativeTargetSection();
513
- const currentTargetsArray = Object.keys(currentTargets).map(k => currentTargets[k]['name'] ? ({ uuid: k, name: currentTargets[k]['name'] }) : null).filter(t => !!t);
514
- const targets = moduleDef.dependencies.map(dependency => currentTargetsArray.find(t => t.name === `\"${dependency}\"`)).filter(s => !!s);
555
+ const currentTargetsArray = Object.keys(currentTargets)
556
+ .map((k) => currentTargets[k]["name"]
557
+ ? { uuid: k, name: currentTargets[k]["name"] }
558
+ : null)
559
+ .filter((t) => !!t);
560
+ const targets = moduleDef.dependencies
561
+ .map((dependency) => currentTargetsArray.find((t) => t.name === `\"${dependency}\"`))
562
+ .filter((s) => !!s);
515
563
  if (targets.length) {
516
- this.$logger.debug(`Adding target dependencies ${moduleDef.dependencies} with uuids:${targets.map(t => t.uuid)} for module ${moduleDef.name}`);
517
- project.addTargetDependency(moduleTarget.uuid, targets.map(t => t.uuid));
564
+ this.$logger.debug(`Adding target dependencies ${moduleDef.dependencies} with uuids:${targets.map((t) => t.uuid)} for module ${moduleDef.name}`);
565
+ project.addTargetDependency(moduleTarget.uuid, targets.map((t) => t.uuid));
518
566
  }
519
567
  }
520
568
  if (moduleDef.SPMPackages && Array.isArray(moduleDef.SPMPackages)) {
521
569
  // to be able to add SPM the file needs to be saved
522
570
  // but it means we need to reload it again after spm packages addition
523
571
  this.$fs.writeFile(project.filepath, project.writeSync({ omitEmptyValues: true }));
524
- await this.applySPMPackagesToTargets([moduleName], platformData, basedir, moduleDef.SPMPackages.map(t => {
525
- if (typeof t === 'string') {
526
- return config.SPMPackages.find(s => s.name === t);
572
+ await this.applySPMPackagesToTargets([moduleName], platformData, basedir, moduleDef.SPMPackages.map((t) => {
573
+ if (typeof t === "string") {
574
+ return config.SPMPackages.find((s) => s.name === t);
527
575
  }
528
576
  return t;
529
577
  }));
530
578
  project.parseSync();
531
579
  }
532
- if (moduleDef.buildConfigurationProperties || config.sharedModulesBuildConfigurationProperties) {
533
- const configurationProperties = { ...(config.sharedModulesBuildConfigurationProperties || {}), ...(moduleDef.buildConfigurationProperties || {}) };
534
- this.$iOSNativeTargetService.setXcodeTargetBuildConfigurationProperties(Object.keys(configurationProperties).map(k => ({ name: k, value: configurationProperties[k] })), moduleName, project);
580
+ if (moduleDef.buildConfigurationProperties ||
581
+ config.sharedModulesBuildConfigurationProperties) {
582
+ const configurationProperties = {
583
+ ...(config.sharedModulesBuildConfigurationProperties || {}),
584
+ ...(moduleDef.buildConfigurationProperties || {}),
585
+ };
586
+ this.$iOSNativeTargetService.setXcodeTargetBuildConfigurationProperties(Object.keys(configurationProperties).map((k) => ({
587
+ name: k,
588
+ value: configurationProperties[k],
589
+ })), moduleName, project);
535
590
  }
536
591
  this.$logger.debug(`Added folder-based module ${moduleName} at ${relativePath}`);
537
592
  }
@@ -542,7 +597,9 @@ class IOSWatchAppService {
542
597
  for (const flag of flags) {
543
598
  const currentFlags = this.getBuildProperty("OTHER_LDFLAGS", targetName, project);
544
599
  const flagsArray = currentFlags
545
- ? (Array.isArray(currentFlags) ? currentFlags : [currentFlags])
600
+ ? Array.isArray(currentFlags)
601
+ ? currentFlags
602
+ : [currentFlags]
546
603
  : ['"$(inherited)"'];
547
604
  if (!flagsArray.includes(flag)) {
548
605
  flagsArray.push(flag);
@@ -566,7 +623,8 @@ class IOSWatchAppService {
566
623
  }
567
624
  for (const key in configurations) {
568
625
  const config = configurations[key];
569
- if (config && config.buildSettings &&
626
+ if (config &&
627
+ config.buildSettings &&
570
628
  (config.buildSettings.PRODUCT_NAME === targetName ||
571
629
  config.buildSettings.PRODUCT_NAME === `"${targetName}"`)) {
572
630
  return config.buildSettings[propertyName];
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.6-dev.0",
4
+ "version": "9.0.6-dev.1",
5
5
  "author": "NativeScript <oss@nativescript.org>",
6
6
  "description": "Command-line interface for building NativeScript projects",
7
7
  "bin": {