@capacitor/cli 9.0.0-alpha.2 → 9.0.0-alpha.3

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/config.js CHANGED
@@ -244,7 +244,7 @@ async function loadIOSConfig(rootDir, extConfig) {
244
244
  };
245
245
  return {
246
246
  name,
247
- minVersion: '15.0',
247
+ minVersion: '16.0',
248
248
  platformDir,
249
249
  platformDirAbs,
250
250
  scheme,
@@ -511,6 +511,15 @@ export interface CapacitorConfig {
511
511
  packageTraits?: {
512
512
  [pluginId: string]: string[];
513
513
  };
514
+ /**
515
+ * Define options to apply to the package.
516
+ * The key is the plugin ID (e.g. `@capacitor-community/device`)
517
+ *
518
+ * @since 8.4.0
519
+ */
520
+ packageOptions?: {
521
+ [pluginId: string]: PackageOptions;
522
+ };
514
523
  };
515
524
  };
516
525
  };
@@ -546,7 +555,7 @@ export interface CapacitorConfig {
546
555
  * Configure the local scheme on Android.
547
556
  *
548
557
  * Custom schemes on Android are unable to change the URL path as of Webview 117. Changing this value from anything other than `http` or `https` can result in your
549
- * application unable to resolve routing. If you must change this for some reason, consider using a hash-based url strategy, but there are no guarentees that this
558
+ * application unable to resolve routing. If you must change this for some reason, consider using a hash-based url strategy, but there are no guarantees that this
550
559
  * will continue to work long term as allowing non-standard schemes to modify query parameters and url fragments is only allowed for compatibility reasons.
551
560
  * https://ionic.io/blog/capacitor-android-customscheme-issue-with-chrome-117
552
561
  *
@@ -732,3 +741,17 @@ export interface PluginsConfig {
732
741
  animation?: 'FADE' | 'NONE';
733
742
  };
734
743
  }
744
+ export interface PackageOptions {
745
+ /**
746
+ * Create a symlink to the plugin folder instead of pointing to the plugin path.
747
+ * Useful when plugin names conflict.
748
+ */
749
+ symlink?: boolean;
750
+ /**
751
+ * Useful to avoid target name conflicts in dependencies
752
+ * [see](https://docs.swift.org/swiftpm/documentation/packagemanagerdocs/modulealiasing/)
753
+ */
754
+ moduleAliases?: {
755
+ [target: string]: string;
756
+ };
757
+ }
package/dist/index.js CHANGED
@@ -156,12 +156,9 @@ function runProgram(config) {
156
156
  .option('--target-name-sdk-version <version>', 'use a specific sdk version when using --target-name, ex: 26.0 (for iOS 26) or 35 (for Android API 35)')
157
157
  .option('--no-sync', `do not run ${colors_1.default.input('sync')}`)
158
158
  .option('--forwardPorts <port:port>', 'Automatically run "adb reverse" for better live-reloading support')
159
- .option('-l, --live-reload', 'Set live-reload URL via CLI (uses defaults, overrides server.url config)')
160
- .option('--host <host>', 'Configure host for live-reload URL (used with --live-reload)')
161
- .option('--port <port>', 'Configure port for live-reload URL (used with --live-reload)')
159
+ .option('--url <url>', 'Load an external URL in the Web View, useful for live-reload (overrides server.url config)')
162
160
  .option('--configuration <name>', 'Configuration name of the iOS Scheme')
163
- .option('--https', 'Use https:// instead of http:// for live-reload URL (used with --live-reload)')
164
- .action((0, cli_1.wrapAction)((0, telemetry_1.telemetryAction)(config, async (platform, { scheme, flavor, list, json, target, targetName, targetNameSdkVersion, sync, forwardPorts, liveReload, host, port, configuration, https, }) => {
161
+ .action((0, cli_1.wrapAction)((0, telemetry_1.telemetryAction)(config, async (platform, { scheme, flavor, list, json, target, targetName, targetNameSdkVersion, sync, forwardPorts, url, configuration, }) => {
165
162
  const { runCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/run')));
166
163
  await runCommand(config, platform, {
167
164
  scheme,
@@ -173,11 +170,8 @@ function runProgram(config) {
173
170
  targetNameSdkVersion,
174
171
  sync,
175
172
  forwardPorts,
176
- liveReload,
177
- host,
178
- port,
173
+ url,
179
174
  configuration,
180
- https,
181
175
  });
182
176
  })));
183
177
  commander_1.program
@@ -47,7 +47,7 @@ const plugins = [
47
47
  const coreVersion = '^8.0.0';
48
48
  const pluginVersion = '^8.0.0';
49
49
  const gradleVersion = '8.14.3';
50
- const iOSVersion = '15';
50
+ const iOSVersion = '16';
51
51
  const kotlinVersion = '2.2.20';
52
52
  let installFailed = false;
53
53
  async function migrateCommand(config, noprompt, packagemanager) {
package/dist/tasks/run.js CHANGED
@@ -14,8 +14,19 @@ const livereload_1 = require("../util/livereload");
14
14
  const native_run_1 = require("../util/native-run");
15
15
  const sync_1 = require("./sync");
16
16
  async function runCommand(config, selectedPlatformName, options) {
17
- var _a, _b, _c;
18
- options.host = (_b = (_a = options.host) !== null && _a !== void 0 ? _a : livereload_1.CapLiveReloadHelper.getIpAddress()) !== null && _b !== void 0 ? _b : 'localhost';
17
+ var _a;
18
+ if (options.url) {
19
+ let parsed;
20
+ try {
21
+ parsed = new URL(options.url);
22
+ }
23
+ catch {
24
+ (0, errors_1.fatal)(`Invalid --url: "${options.url}" is not a valid URL`);
25
+ }
26
+ if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
27
+ (0, errors_1.fatal)(`Invalid --url: must use http:// or https:// (got "${parsed.protocol}//")`);
28
+ }
29
+ }
19
30
  if (selectedPlatformName && !(await (0, common_1.isValidPlatform)(selectedPlatformName))) {
20
31
  const platformDir = (0, common_1.resolvePlatform)(config, selectedPlatformName);
21
32
  if (platformDir) {
@@ -61,14 +72,14 @@ async function runCommand(config, selectedPlatformName, options) {
61
72
  await (0, sync_1.sync)(config, platformName, false, true);
62
73
  }
63
74
  const cordovaPlugins = await (0, cordova_1.getCordovaPlugins)(config, platformName);
64
- if (options.liveReload) {
75
+ if (options.url) {
65
76
  await livereload_1.CapLiveReloadHelper.editCapConfigForLiveReload(config, platformName, options);
66
77
  if (platformName === config.android.name) {
67
78
  await await (0, cordova_1.writeCordovaAndroidManifest)(cordovaPlugins, config, platformName, true);
68
79
  }
69
80
  }
70
81
  await run(config, platformName, options);
71
- if (options.liveReload) {
82
+ if (options.url) {
72
83
  new Promise((resolve) => process.on('SIGINT', resolve))
73
84
  .then(async () => {
74
85
  await livereload_1.CapLiveReloadHelper.revertCapConfigForLiveReload();
@@ -77,13 +88,16 @@ async function runCommand(config, selectedPlatformName, options) {
77
88
  }
78
89
  })
79
90
  .then(() => process.exit());
80
- log_1.logger.info(`App running with live reload listing for: ${options.https ? 'https' : 'http'}://${options.host}${options.port ? `:${options.port}` : ''}. Press Ctrl+C to quit.`);
91
+ log_1.logger.info(`App running with live reload listening for: ${options.url}. Press Ctrl+C to quit.`);
81
92
  await sleepForever();
82
93
  }
83
94
  }
84
95
  catch (e) {
96
+ if (options.url) {
97
+ await livereload_1.CapLiveReloadHelper.revertCapConfigForLiveReload();
98
+ }
85
99
  if (!(0, errors_1.isFatal)(e)) {
86
- (0, errors_1.fatal)((_c = e.stack) !== null && _c !== void 0 ? _c : e);
100
+ (0, errors_1.fatal)((_a = e.stack) !== null && _a !== void 0 ? _a : e);
87
101
  }
88
102
  throw e;
89
103
  }
package/dist/telemetry.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sendMetric = exports.telemetryAction = void 0;
3
+ exports.getIOSPackageManager = exports.sendMetric = exports.telemetryAction = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const commander_1 = require("commander");
6
6
  const debug_1 = tslib_1.__importDefault(require("debug"));
7
+ const fs_extra_1 = require("fs-extra");
7
8
  const colors_1 = tslib_1.__importDefault(require("./colors"));
8
9
  const ipc_1 = require("./ipc");
9
10
  const log_1 = require("./log");
@@ -51,8 +52,10 @@ function telemetryAction(config, action) {
51
52
  error: error ? (error.message ? error.message : String(error)) : null,
52
53
  node_version: process.version,
53
54
  os: config.cli.os,
55
+ ios_package_manager: await getIOSPackageManager(config),
54
56
  ...Object.fromEntries(versions),
55
57
  };
58
+ debug('metric payload: %O', data);
56
59
  if ((0, term_1.isInteractive)()) {
57
60
  let sysconfig = await (0, sysconfig_1.readConfig)();
58
61
  if (!error && typeof sysconfig.telemetry === 'undefined') {
@@ -88,6 +91,24 @@ async function sendMetric(sysconfig, name, data) {
88
91
  }
89
92
  }
90
93
  exports.sendMetric = sendMetric;
94
+ /**
95
+ * Resolve the iOS dependency manager for telemetry. Returns 'unknown' for
96
+ * non-iOS projects or when detection throws, so callers never have to handle
97
+ * errors from this signal.
98
+ */
99
+ async function getIOSPackageManager(config) {
100
+ try {
101
+ if (!(await (0, fs_extra_1.pathExists)(config.ios.platformDirAbs))) {
102
+ return 'unknown';
103
+ }
104
+ return await config.ios.packageManager;
105
+ }
106
+ catch (e) {
107
+ debug('Could not resolve iOS package manager for telemetry: %O', e);
108
+ return 'unknown';
109
+ }
110
+ }
111
+ exports.getIOSPackageManager = getIOSPackageManager;
91
112
  /**
92
113
  * Get a unique anonymous identifier for this app.
93
114
  */
@@ -236,6 +236,9 @@ async function copyPluginsNativeFiles(config, cordovaPlugins) {
236
236
  exports.copyPluginsNativeFiles = copyPluginsNativeFiles;
237
237
  async function removePluginsNativeFiles(config) {
238
238
  await (0, fs_extra_1.remove)(config.ios.cordovaPluginsDirAbs);
239
+ if ((await config.ios.packageManager) === 'SPM') {
240
+ await (0, fs_extra_1.remove)((0, path_1.join)(config.ios.nativeProjectDirAbs, 'CapApp-SPM', 'symlinks'));
241
+ }
239
242
  await (0, template_1.extractTemplate)(config.cli.assets.ios.cordovaPluginsTemplateArchiveAbs, config.ios.cordovaPluginsDirAbs);
240
243
  }
241
244
  exports.removePluginsNativeFiles = removePluginsNativeFiles;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CapLiveReloadHelper = void 0;
4
4
  const fs_extra_1 = require("fs-extra");
5
- const os_1 = require("os");
6
5
  const path_1 = require("path");
7
6
  class CapLiveReload {
8
7
  constructor() {
@@ -12,87 +11,6 @@ class CapLiveReload {
12
11
  };
13
12
  // nothing to do
14
13
  }
15
- getIpAddress(name, family) {
16
- var _a;
17
- const interfaces = (_a = (0, os_1.networkInterfaces)()) !== null && _a !== void 0 ? _a : {};
18
- const _normalizeFamily = (family) => {
19
- if (family === 4) {
20
- return 'ipv4';
21
- }
22
- if (family === 6) {
23
- return 'ipv6';
24
- }
25
- return family ? family.toLowerCase() : 'ipv4';
26
- };
27
- const isLoopback = (addr) => {
28
- return (/^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/.test(addr) ||
29
- /^fe80::1$/.test(addr) ||
30
- /^::1$/.test(addr) ||
31
- /^::$/.test(addr));
32
- };
33
- const isPrivate = (addr) => {
34
- return (/^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
35
- /^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
36
- /^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
37
- /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
38
- /^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
39
- /^f[cd][0-9a-f]{2}:/i.test(addr) ||
40
- /^fe80:/i.test(addr) ||
41
- /^::1$/.test(addr) ||
42
- /^::$/.test(addr));
43
- };
44
- const isPublic = (addr) => {
45
- return !isPrivate(addr);
46
- };
47
- const loopback = (family) => {
48
- //
49
- // Default to `ipv4`
50
- //
51
- family = _normalizeFamily(family);
52
- if (family !== 'ipv4' && family !== 'ipv6') {
53
- throw new Error('family must be ipv4 or ipv6');
54
- }
55
- return family === 'ipv4' ? '127.0.0.1' : 'fe80::1';
56
- };
57
- //
58
- // Default to `ipv4`
59
- //
60
- family = _normalizeFamily(family);
61
- //
62
- // If a specific network interface has been named,
63
- // return the address.
64
- //
65
- if (name && name !== 'private' && name !== 'public') {
66
- const res = interfaces[name].filter((details) => {
67
- const itemFamily = _normalizeFamily(details.family);
68
- return itemFamily === family;
69
- });
70
- if (res.length === 0) {
71
- return undefined;
72
- }
73
- return res[0].address;
74
- }
75
- const all = Object.keys(interfaces)
76
- .map((nic) => {
77
- //
78
- // Note: name will only be `public` or `private`
79
- // when this is called.
80
- //
81
- const addresses = interfaces[nic].filter((details) => {
82
- details.family = _normalizeFamily(details.family);
83
- if (details.family !== family || isLoopback(details.address)) {
84
- return false;
85
- }
86
- if (!name) {
87
- return true;
88
- }
89
- return name === 'public' ? isPrivate(details.address) : isPublic(details.address);
90
- });
91
- return addresses.length ? addresses[0].address : undefined;
92
- })
93
- .filter(Boolean);
94
- return !all.length ? loopback(family) : all[0];
95
- }
96
14
  async editCapConfigForLiveReload(config, platformName, options) {
97
15
  const platformAbsPath = platformName == config.ios.name
98
16
  ? config.ios.nativeTargetDirAbs
@@ -105,10 +23,9 @@ class CapLiveReload {
105
23
  const configJson = (0, fs_extra_1.readJSONSync)(capConfigPath);
106
24
  this.configJsonToRevertTo.json = JSON.stringify(configJson, null, 2);
107
25
  this.configJsonToRevertTo.platformPath = capConfigPath;
108
- const url = `${options.https ? 'https' : 'http'}://${options.host}${options.port ? `:${options.port}` : ''}`;
109
26
  configJson.server = {
110
27
  ...configJson.server,
111
- url,
28
+ url: options.url,
112
29
  };
113
30
  (0, fs_extra_1.writeJSONSync)(capConfigPath, configJson, { spaces: '\t' });
114
31
  }
package/dist/util/spm.js CHANGED
@@ -85,13 +85,14 @@ async function removeCocoapodsFiles(config) {
85
85
  }
86
86
  exports.removeCocoapodsFiles = removeCocoapodsFiles;
87
87
  async function generatePackageText(config, plugins) {
88
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
88
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
89
89
  const iosPlatformVersion = await (0, common_1.getCapacitorPackageVersion)(config, config.ios.name);
90
90
  const iosVersion = (0, common_2.getMajoriOSVersion)(config);
91
91
  const cordovaPlugins = await (0, cordova_1.getCordovaPlugins)(config, 'ios');
92
92
  const enableCordova = cordovaPlugins.length > 0;
93
93
  const packageTraits = (_d = (_c = (_b = (_a = config.app.extConfig.experimental) === null || _a === void 0 ? void 0 : _a.ios) === null || _b === void 0 ? void 0 : _b.spm) === null || _c === void 0 ? void 0 : _c.packageTraits) !== null && _d !== void 0 ? _d : {};
94
- const swiftToolsVersion = (_h = (_g = (_f = (_e = config.app.extConfig.experimental) === null || _e === void 0 ? void 0 : _e.ios) === null || _f === void 0 ? void 0 : _f.spm) === null || _g === void 0 ? void 0 : _g.swiftToolsVersion) !== null && _h !== void 0 ? _h : '5.9';
94
+ const packageOptions = (_h = (_g = (_f = (_e = config.app.extConfig.experimental) === null || _e === void 0 ? void 0 : _e.ios) === null || _f === void 0 ? void 0 : _f.spm) === null || _g === void 0 ? void 0 : _g.packageOptions) !== null && _h !== void 0 ? _h : {};
95
+ const swiftToolsVersion = (_m = (_l = (_k = (_j = config.app.extConfig.experimental) === null || _j === void 0 ? void 0 : _j.ios) === null || _k === void 0 ? void 0 : _k.spm) === null || _l === void 0 ? void 0 : _l.swiftToolsVersion) !== null && _m !== void 0 ? _m : '5.9';
95
96
  let packageSwiftText = `// swift-tools-version: ${swiftToolsVersion}
96
97
  import PackageDescription
97
98
 
@@ -109,7 +110,7 @@ let package = Package(
109
110
  for (const plugin of plugins) {
110
111
  if ((0, plugin_1.getPluginType)(plugin, config.ios.name) === 1 /* PluginType.Cordova */) {
111
112
  const platformTag = (0, plugin_1.getPluginPlatform)(plugin, config.ios.name);
112
- if ((_j = platformTag.$) === null || _j === void 0 ? void 0 : _j.package) {
113
+ if ((_o = platformTag.$) === null || _o === void 0 ? void 0 : _o.package) {
113
114
  const relPath = (0, path_1.relative)(config.ios.nativeXcodeProjDirAbs, plugin.rootPath);
114
115
  packageSwiftText += `,\n .package(name: "${plugin.id}", path: "${relPath}")`;
115
116
  }
@@ -123,7 +124,13 @@ let package = Package(
123
124
  }
124
125
  }
125
126
  else {
126
- const relPath = (0, path_1.relative)(config.ios.nativeXcodeProjDirAbs, plugin.rootPath);
127
+ const options = packageOptions[plugin.id];
128
+ const symlink = options === null || options === void 0 ? void 0 : options.symlink;
129
+ const symlinkFolder = (0, path_1.join)('symlinks', plugin.name);
130
+ const relPath = symlink ? symlinkFolder : (0, path_1.relative)(config.ios.nativeXcodeProjDirAbs, plugin.rootPath);
131
+ if (symlink) {
132
+ await (0, fs_extra_1.ensureSymlink)(plugin.rootPath, (0, path_1.resolve)(config.ios.nativeProjectDirAbs, 'CapApp-SPM', symlinkFolder));
133
+ }
127
134
  const traits = packageTraits[plugin.id];
128
135
  const traitsSuffix = (traits === null || traits === void 0 ? void 0 : traits.length)
129
136
  ? `, traits: [${traits
@@ -133,7 +140,7 @@ let package = Package(
133
140
  })
134
141
  .join(', ')}]`
135
142
  : '';
136
- packageSwiftText += `,\n .package(name: "${(_k = plugin.ios) === null || _k === void 0 ? void 0 : _k.name}", path: "${relPath}"${traitsSuffix})`;
143
+ packageSwiftText += `,\n .package(name: "${(_p = plugin.ios) === null || _p === void 0 ? void 0 : _p.name}", path: "${relPath}"${traitsSuffix})`;
137
144
  }
138
145
  }
139
146
  packageSwiftText += `
@@ -147,10 +154,18 @@ let package = Package(
147
154
  packageSwiftText += ` .product(name: "Cordova", package: "capacitor-swift-pm")`;
148
155
  }
149
156
  for (const plugin of plugins) {
150
- let pluginText = `,\n .product(name: "${(_l = plugin.ios) === null || _l === void 0 ? void 0 : _l.name}", package: "${(_m = plugin.ios) === null || _m === void 0 ? void 0 : _m.name}")`;
157
+ const aliases = Object.entries((_r = (_q = packageOptions[plugin.id]) === null || _q === void 0 ? void 0 : _q.moduleAliases) !== null && _r !== void 0 ? _r : {});
158
+ const aliasText = (aliases === null || aliases === void 0 ? void 0 : aliases.length)
159
+ ? `, moduleAliases: [${aliases
160
+ .map(([target, replacement]) => {
161
+ return `"${target}": "${replacement}"`;
162
+ })
163
+ .join(', ')}]`
164
+ : '';
165
+ let pluginText = `,\n .product(name: "${(_s = plugin.ios) === null || _s === void 0 ? void 0 : _s.name}", package: "${(_t = plugin.ios) === null || _t === void 0 ? void 0 : _t.name}"${aliasText})`;
151
166
  if ((0, plugin_1.getPluginType)(plugin, config.ios.name) === 1 /* PluginType.Cordova */) {
152
167
  const platformTag = (0, plugin_1.getPluginPlatform)(plugin, config.ios.name);
153
- if ((_o = platformTag.$) === null || _o === void 0 ? void 0 : _o.package) {
168
+ if ((_u = platformTag.$) === null || _u === void 0 ? void 0 : _u.package) {
154
169
  pluginText = `,\n .product(name: "${plugin.id}", package: "${plugin.id}")`;
155
170
  }
156
171
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/cli",
3
- "version": "9.0.0-alpha.2",
3
+ "version": "9.0.0-alpha.3",
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)",