@capacitor/cli 9.0.0-alpha.7 → 9.0.0-alpha.8

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.
Binary file
Binary file
Binary file
package/dist/common.js CHANGED
@@ -423,7 +423,7 @@ async function checkJDKMajorVersion() {
423
423
  return -1;
424
424
  }
425
425
  }
426
- catch (e) {
426
+ catch {
427
427
  return -1;
428
428
  }
429
429
  }
package/dist/config.js CHANGED
@@ -88,7 +88,7 @@ async function loadExtConfigTS(rootDir, extConfigName, extConfigFilePath) {
88
88
  (0, errors_1.fatal)('Could not find installation of TypeScript.\n' +
89
89
  `To use ${colors_1.default.strong(extConfigName)} files, you must install TypeScript in your project, e.g. w/ ${colors_1.default.input('npm install -D typescript')}`);
90
90
  }
91
- const ts = require(tsPath); // eslint-disable-line @typescript-eslint/no-var-requires
91
+ const ts = require(tsPath); // eslint-disable-line @typescript-eslint/no-require-imports
92
92
  const extConfigObject = (await (0, node_1.requireTS)(ts, extConfigFilePath));
93
93
  const extConfig = extConfigObject.default ? await extConfigObject.default : extConfigObject;
94
94
  return {
@@ -112,6 +112,7 @@ async function loadExtConfigJS(rootDir, extConfigName, extConfigFilePath) {
112
112
  extConfigType: 'js',
113
113
  extConfigName,
114
114
  extConfigFilePath: extConfigFilePath,
115
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
115
116
  extConfig: await require(extConfigFilePath),
116
117
  };
117
118
  }
@@ -302,7 +303,7 @@ async function determineIOSWebDirAbs(nativeProjectDirAbs, nativeTargetDirAbs, na
302
303
  return (0, path_1.resolve)(nativeProjectDirAbs, 'public');
303
304
  }
304
305
  }
305
- catch (e) {
306
+ catch {
306
307
  // ignore
307
308
  }
308
309
  return (0, path_1.resolve)(nativeTargetDirAbs, 'public');
@@ -386,7 +387,7 @@ async function determinePackageManager(rootDir, platformDir, nativeProjectDirAbs
386
387
  gemfilePath = (0, path_1.resolve)(output, 'Gemfile');
387
388
  }
388
389
  }
389
- catch (e) {
390
+ catch {
390
391
  // Nothing
391
392
  }
392
393
  }
@@ -21,7 +21,7 @@ function execBundler() {
21
21
  const bundleOutput = (0, child_process_1.execSync)('bundle &> /dev/null ; echo $?');
22
22
  return parseInt(bundleOutput.toString());
23
23
  }
24
- catch (e) {
24
+ catch {
25
25
  return -1;
26
26
  }
27
27
  }
@@ -56,6 +56,7 @@ async function updatePluginFiles(config, plugins, deployment) {
56
56
  const iosPlatformVersion = await (0, common_1.getCapacitorPackageVersion)(config, config.ios.name);
57
57
  const majorCapVersion = (0, semver_1.major)(iosPlatformVersion);
58
58
  const capacitorPackage = await (0, capacitor_package_1.resolveCapacitorPackage)(config, 'from');
59
+ const iosVersion = (0, common_2.getMajoriOSVersion)(config);
59
60
  await Promise.all(validSPMPackages.map(async (plugin) => {
60
61
  const packageSwiftPath = (0, path_1.join)(plugin.rootPath, 'Package.swift');
61
62
  let content = await (0, fs_extra_1.readFile)(packageSwiftPath, { encoding: 'utf-8' });
@@ -66,7 +67,8 @@ async function updatePluginFiles(config, plugins, deployment) {
66
67
  if (capacitorPackage.sourceBased) {
67
68
  // The plugin has to resolve to the same package identity as the app, or SPM ends up with
68
69
  // two packages that both vend a Capacitor product.
69
- const rewritten = (0, capacitor_package_1.rewriteCapacitorDependency)(content, capacitorPackage, plugin.rootPath);
70
+ let rewritten = (0, capacitor_package_1.rewriteCapacitorDependency)(content, capacitorPackage, plugin.rootPath);
71
+ rewritten = (0, capacitor_package_1.patchPackageSwiftDeploymentTarget)(rewritten, iosVersion).content;
70
72
  if (rewritten !== content) {
71
73
  await (0, fs_extra_1.writeFile)(packageSwiftPath, rewritten);
72
74
  }
package/dist/plugin.js CHANGED
@@ -59,7 +59,7 @@ async function resolvePlugin(config, name) {
59
59
  xml: xmlMeta.plugin,
60
60
  };
61
61
  }
62
- catch (e) {
62
+ catch {
63
63
  // ignore
64
64
  }
65
65
  return null;
@@ -26,7 +26,7 @@ async function listCommand(config, selectedPlatformName) {
26
26
  exports.listCommand = listCommand;
27
27
  async function list(config, platform) {
28
28
  const allPlugins = await (0, plugin_1.getPlugins)(config, platform);
29
- let plugins = [];
29
+ let plugins;
30
30
  if (platform === config.ios.name) {
31
31
  plugins = await (0, common_3.getIOSPlugins)(allPlugins);
32
32
  }
@@ -16,7 +16,6 @@ const subprocess_1 = require("../util/subprocess");
16
16
  const template_1 = require("../util/template");
17
17
  const migrate_edge_to_edge_1 = require("./migrate-edge-to-edge");
18
18
  const migrate_swiftui_1 = require("./migrate-swiftui");
19
- // eslint-disable-next-line prefer-const
20
19
  let allDependencies = {};
21
20
  const libs = ['@capacitor/core', '@capacitor/cli', '@capacitor/ios', '@capacitor/android'];
22
21
  const plugins = [
@@ -132,7 +131,7 @@ async function migrateCommand(config, noprompt, packagemanager) {
132
131
  return installLatestLibs(installerType, runNpmInstall, config);
133
132
  });
134
133
  }
135
- catch (ex) {
134
+ catch {
136
135
  log_1.logger.error(`${installerType} install failed. Try deleting node_modules folder and running ${colors_1.default.input(`${installerType} install --force`)} manually.`);
137
136
  installFailed = true;
138
137
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findCapacitorDependencyVersion = exports.rewriteCapacitorDependency = exports.renderCapacitorPackage = exports.resolveCapacitorPackage = void 0;
3
+ exports.patchPackageSwiftDeploymentTarget = exports.findCapacitorDependencyVersion = exports.rewriteCapacitorDependency = exports.renderCapacitorPackage = exports.resolveCapacitorPackage = void 0;
4
4
  const fs_extra_1 = require("fs-extra");
5
5
  const path_1 = require("path");
6
6
  const semver_1 = require("semver");
@@ -95,6 +95,33 @@ function findCapacitorDependencyVersion(content) {
95
95
  return undefined;
96
96
  }
97
97
  exports.findCapacitorDependencyVersion = findCapacitorDependencyVersion;
98
+ const IOS_PLATFORM_VERSION_REGEX = /\.iOS\(\s*(?:\.v(\d+)|"([\d.]+)")\s*\)/;
99
+ /**
100
+ * Bumps a Package.swift's declared iOS deployment target (e.g. `.iOS(.v13)` or `.iOS("14.0")`) up to
101
+ * `requiredIosVersion` if it's lower.
102
+ *
103
+ * Only relevant for the source package: it declares `platforms: [.iOS(.v16)]` on its own manifest,
104
+ * and SwiftPM enforces that across the whole graph, so a plugin still declaring an older, lower
105
+ * target fails to resolve with "requires minimum platform version X ... but this target supports Y" —
106
+ * even though the very same plugin links fine against the prebuilt `capacitor-swift-pm`, which never
107
+ * declared a `platforms:` entry for SwiftPM to check against.
108
+ */
109
+ function patchPackageSwiftDeploymentTarget(content, requiredIosVersion) {
110
+ const match = content.match(IOS_PLATFORM_VERSION_REGEX);
111
+ if (!match) {
112
+ return { content, changed: false, previousVersion: null };
113
+ }
114
+ const isSymbolic = match[1] !== undefined;
115
+ const previousVersion = isSymbolic ? match[1] : match[2];
116
+ const requiredMajor = Math.trunc(parseFloat(requiredIosVersion));
117
+ if (parseFloat(previousVersion) >= requiredMajor) {
118
+ return { content, changed: false, previousVersion };
119
+ }
120
+ const replacement = isSymbolic ? `.iOS(.v${requiredMajor})` : `.iOS("${requiredMajor}.0")`;
121
+ const patchedContent = content.replace(IOS_PLATFORM_VERSION_REGEX, replacement);
122
+ return { content: patchedContent, changed: true, previousVersion };
123
+ }
124
+ exports.patchPackageSwiftDeploymentTarget = patchPackageSwiftDeploymentTarget;
98
125
  function referencesCapacitor(call) {
99
126
  return call.includes(BINARY_PACKAGE_IDENTITY) || call.includes(`${SOURCE_PACKAGE_URL}`);
100
127
  }
@@ -218,6 +218,10 @@ async function copyPluginsNativeFiles(config, cordovaPlugins) {
218
218
  fileContent = fileContent.replace(/self.webView.superview/g, 'self.viewController.view');
219
219
  await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
220
220
  }
221
+ if (isSPM && fileContent.includes(`#import "AppDelegate.h"`)) {
222
+ fileContent = fileContent.replace(`#import "AppDelegate.h"`, `#import <Cordova/AppDelegate.h>`);
223
+ await (0, fs_extra_1.writeFile)(fileDest, fileContent, { encoding: 'utf-8' });
224
+ }
221
225
  }
222
226
  }
223
227
  }
@@ -449,6 +453,9 @@ async function generateCordovaPackageFile(p, config) {
449
453
  let content = await (0, fs_extra_1.readFile)(packageSwiftPath, { encoding: 'utf-8' });
450
454
  content = content.replace(`apache`, `ionic-team`).replaceAll(`cordova-ios`, capacitorPackage.identity);
451
455
  content = (0, capacitor_package_1.rewriteCapacitorDependency)(content, capacitorPackage, p.rootPath);
456
+ if (capacitorPackage.sourceBased) {
457
+ content = (0, capacitor_package_1.patchPackageSwiftDeploymentTarget)(content, iosVersion).content;
458
+ }
452
459
  await (0, fs_extra_1.writeFile)(packageSwiftPath, content);
453
460
  }
454
461
  else {
package/dist/util/js.js CHANGED
@@ -8,7 +8,7 @@ function formatJSObject(o) {
8
8
  o = JSON.parse(JSON.stringify(o));
9
9
  }
10
10
  catch (e) {
11
- throw new Error(`Cannot parse object as JSON: ${e.stack ? e.stack : e}`);
11
+ throw new Error(`Cannot parse object as JSON: ${e.stack ? e.stack : e}`, { cause: e });
12
12
  }
13
13
  return util_1.default.inspect(o, {
14
14
  compact: false,
@@ -87,7 +87,7 @@ function isMonorepo(currentPath) {
87
87
  findMonorepoRoot(currentPath);
88
88
  return true;
89
89
  }
90
- catch (error) {
90
+ catch {
91
91
  return false;
92
92
  }
93
93
  }
@@ -102,7 +102,7 @@ function isNXMonorepo(currentPath) {
102
102
  findNXMonorepoRoot(currentPath);
103
103
  return true;
104
104
  }
105
- catch (error) {
105
+ catch {
106
106
  return false;
107
107
  }
108
108
  }
package/dist/util/node.js CHANGED
@@ -38,7 +38,7 @@ const requireTS = async (ts, p) => {
38
38
  if ((e === null || e === void 0 ? void 0 : e.code) === 'ERR_UNKNOWN_FILE_EXTENSION') {
39
39
  throw new Error(`Your installed version of TypeScript (${ts.version}) no longer provides the compiler API Capacitor previously used to load .ts config files, ` +
40
40
  `and your Node.js runtime (${process.version}) doesn't support loading them natively either.\n` +
41
- 'Upgrade to Node.js 22.6+ (running with --experimental-strip-types), or Node.js 23.6+, to continue using capacitor.config.ts.');
41
+ 'Upgrade to Node.js 22.6+ (running with --experimental-strip-types), or Node.js 23.6+, to continue using capacitor.config.ts.', { cause: e });
42
42
  }
43
43
  throw e;
44
44
  }
@@ -68,7 +68,7 @@ const requireTS = async (ts, p) => {
68
68
  }
69
69
  (_a = module._compile) === null || _a === void 0 ? void 0 : _a.call(module, sourceText, fileName);
70
70
  };
71
- const m = require(id); // eslint-disable-line @typescript-eslint/no-var-requires
71
+ const m = require(id); // eslint-disable-line @typescript-eslint/no-require-imports
72
72
  delete require.extensions['.ts'];
73
73
  return m;
74
74
  };
@@ -77,7 +77,7 @@ function resolveNode(root, ...pathSegments) {
77
77
  try {
78
78
  return require.resolve(pathSegments.join('/'), { paths: [root] });
79
79
  }
80
- catch (e) {
80
+ catch {
81
81
  const path = [root, 'node_modules', ...pathSegments].join('/');
82
82
  if ((0, fs_1.existsSync)(path)) {
83
83
  return path;
@@ -20,7 +20,7 @@ async function getCommandOutput(command, args, options = {}) {
20
20
  try {
21
21
  return (await runCommand(command, args, options)).trim();
22
22
  }
23
- catch (e) {
23
+ catch {
24
24
  return null;
25
25
  }
26
26
  }
@@ -29,7 +29,7 @@ async function isInstalled(command) {
29
29
  try {
30
30
  await (0, utils_subprocess_1.which)(command);
31
31
  }
32
- catch (e) {
32
+ catch {
33
33
  return false;
34
34
  }
35
35
  return true;
package/dist/util/xml.js CHANGED
@@ -15,7 +15,7 @@ async function readXML(path) {
15
15
  throw `Error parsing: ${path}, ${(_a = e.stack) !== null && _a !== void 0 ? _a : e}`;
16
16
  }
17
17
  }
18
- catch (e) {
18
+ catch {
19
19
  throw `Unable to read: ${path}`;
20
20
  }
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/cli",
3
- "version": "9.0.0-alpha.7",
3
+ "version": "9.0.0-alpha.8",
4
4
  "description": "Capacitor: Cross-platform apps with JavaScript and the web",
5
5
  "homepage": "https://capacitorjs.com",
6
6
  "author": "Ionic Team <hi@ionic.io> (https://ionic.io)",