@capacitor/cli 9.0.0-rc.0 → 9.0.0-rc.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.
- package/assets/android-template.tar.gz +0 -0
- package/assets/capacitor-cordova-android-plugins.tar.gz +0 -0
- package/assets/capacitor-cordova-ios-plugins.tar.gz +0 -0
- package/assets/ios-pods-template.tar.gz +0 -0
- package/assets/ios-spm-template.tar.gz +0 -0
- package/dist/android/update.js +1 -1
- package/dist/ios/update.js +1 -2
- package/dist/util/capacitor-package.js +68 -6
- package/dist/util/cordova-ios.js +2 -5
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/android/update.js
CHANGED
|
@@ -252,7 +252,7 @@ async function handleCordovaPluginsGradle(config, cordovaPlugins) {
|
|
|
252
252
|
await (0, fs_extra_1.writeFile)(pluginsGradlePath, buildGradle);
|
|
253
253
|
const cordovaVariables = `// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
|
254
254
|
ext {
|
|
255
|
-
cdvMinSdkVersion =
|
|
255
|
+
cdvMinSdkVersion = rootProject.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : ${config.android.minVersion}
|
|
256
256
|
// Plugin gradle extensions can append to this to have code run at the end.
|
|
257
257
|
cdvPluginPostBuildExtras = []
|
|
258
258
|
cordovaConfig = [:]
|
package/dist/ios/update.js
CHANGED
|
@@ -55,7 +55,6 @@ async function updatePluginFiles(config, plugins, deployment) {
|
|
|
55
55
|
const iosPlatformVersion = await (0, common_1.getCapacitorPackageVersion)(config, config.ios.name);
|
|
56
56
|
const majorCapVersion = (0, semver_1.major)(iosPlatformVersion);
|
|
57
57
|
const capacitorPackagePath = await (0, capacitor_package_1.resolveCapacitorPackagePath)(config);
|
|
58
|
-
const iosVersion = (0, common_2.getMajoriOSVersion)(config);
|
|
59
58
|
await Promise.all(validSPMPackages.map(async (plugin) => {
|
|
60
59
|
const packageSwiftPath = (0, path_1.join)(plugin.rootPath, 'Package.swift');
|
|
61
60
|
const content = await (0, fs_extra_1.readFile)(packageSwiftPath, { encoding: 'utf-8' });
|
|
@@ -66,7 +65,7 @@ async function updatePluginFiles(config, plugins, deployment) {
|
|
|
66
65
|
// The plugin has to resolve to the same package identity as the app, or SPM ends up with
|
|
67
66
|
// two packages that both vend a Capacitor product.
|
|
68
67
|
let rewritten = (0, capacitor_package_1.rewriteCapacitorDependency)(content, capacitorPackagePath, plugin.rootPath);
|
|
69
|
-
rewritten = (0, capacitor_package_1.patchPackageSwiftDeploymentTarget)(rewritten,
|
|
68
|
+
rewritten = (0, capacitor_package_1.patchPackageSwiftDeploymentTarget)(rewritten, config.ios.minVersion).content;
|
|
70
69
|
if (rewritten !== content) {
|
|
71
70
|
await (0, fs_extra_1.writeFile)(packageSwiftPath, rewritten);
|
|
72
71
|
}
|
|
@@ -6,15 +6,26 @@ const path_1 = require("path");
|
|
|
6
6
|
const errors_1 = require("../errors");
|
|
7
7
|
const fs_1 = require("./fs");
|
|
8
8
|
const node_1 = require("./node");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
9
|
+
exports.SOURCE_PACKAGE_IDENTITY = 'capacitor-ios';
|
|
10
|
+
/** Matches the source package's git URL, with or without `.git`, but not repos sharing its prefix. */
|
|
11
|
+
const SOURCE_PACKAGE_URL = /url:\s*"https:\/\/github\.com\/ionic-team\/capacitor(?:\.git)?\/?"/i;
|
|
12
|
+
/**
|
|
13
|
+
* Names a path dependency on Capacitor may carry: the current identity, and the one syncs before
|
|
14
|
+
* the `capacitor-ios` rename pinned. A plugin rewritten by such a sync keeps the old name until
|
|
15
|
+
* it is synced again.
|
|
16
|
+
*/
|
|
17
|
+
const PINNED_PACKAGE_NAMES = [exports.SOURCE_PACKAGE_IDENTITY, 'capacitor'];
|
|
12
18
|
/** Product providing the Cordova compatibility layer. */
|
|
13
19
|
exports.CORDOVA_PRODUCT = 'CapacitorCordova';
|
|
14
20
|
/** The npm package the Swift package ships inside. */
|
|
15
21
|
const PLATFORM_PACKAGE = '@capacitor/ios';
|
|
16
22
|
/** Plugins published before Capacitor 9 depend on the platform as a prebuilt xcframework. */
|
|
17
23
|
const BINARY_PACKAGE_IDENTITY = 'capacitor-swift-pm';
|
|
24
|
+
/**
|
|
25
|
+
* Cordova plugins that ship their own `Package.swift` depend on `apache/cordova-ios` for the
|
|
26
|
+
* `Cordova` product, which the Capacitor source package also vends.
|
|
27
|
+
*/
|
|
28
|
+
const CORDOVA_PACKAGE_URL = /url:\s*"https:\/\/github\.com\/apache\/cordova-ios(?:\.git)?\/?"/i;
|
|
18
29
|
/**
|
|
19
30
|
* Resolves the Capacitor Swift package generated `Package.swift` files should depend on: the
|
|
20
31
|
* `@capacitor/ios` npm already installed in the app, which ships the package alongside the sources.
|
|
@@ -83,10 +94,57 @@ exports.renderCapacitorPackage = renderCapacitorPackage;
|
|
|
83
94
|
* copy of the framework. Rewriting keeps the whole graph on one identity.
|
|
84
95
|
*/
|
|
85
96
|
function rewriteCapacitorDependency(content, absolutePath, fromDir) {
|
|
86
|
-
const
|
|
87
|
-
|
|
97
|
+
const capacitorCalls = findPackageCalls(content).filter((call) => referencesCapacitor(call.text));
|
|
98
|
+
if (capacitorCalls.length === 0) {
|
|
99
|
+
return content;
|
|
100
|
+
}
|
|
101
|
+
// Collected before the calls are replaced: once they are, every one reads `capacitor-ios` and
|
|
102
|
+
// the name each target's `.product(package:)` was written against is gone. The pinned names are
|
|
103
|
+
// included because a sync that renamed only the `.package(...)` entry left products on the old
|
|
104
|
+
// name behind.
|
|
105
|
+
const previousNames = new Set([...capacitorCalls.flatMap((call) => packageReferenceNames(call.text)), ...PINNED_PACKAGE_NAMES].filter((name) => name !== exports.SOURCE_PACKAGE_IDENTITY));
|
|
106
|
+
let rewritten = replacePackageCalls(content, renderCapacitorPackage(absolutePath, fromDir));
|
|
107
|
+
// A name some other dependency still answers to belongs to that dependency, not Capacitor. SPM
|
|
108
|
+
// resolves `.product(package:)` against a dependency's pinned name and its derived identity alike,
|
|
109
|
+
// so both are reserved.
|
|
110
|
+
const remainingNames = new Set(findPackageCalls(rewritten)
|
|
111
|
+
.filter((call) => !referencesCapacitor(call.text))
|
|
112
|
+
.flatMap((call) => packageReferenceNames(call.text)));
|
|
113
|
+
for (const name of previousNames) {
|
|
114
|
+
if (remainingNames.has(name)) {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
rewritten = rewritten.replace(new RegExp(`(package:\\s*)"${escapeRegExp(name)}"`, 'gi'), `$1"${exports.SOURCE_PACKAGE_IDENTITY}"`);
|
|
118
|
+
}
|
|
119
|
+
return rewritten;
|
|
88
120
|
}
|
|
89
121
|
exports.rewriteCapacitorDependency = rewriteCapacitorDependency;
|
|
122
|
+
/**
|
|
123
|
+
* The names a `.product(package:)` may use to refer to the dependency a `.package(...)` call
|
|
124
|
+
* declares, lowercased: its explicit `name:` when it pins one, and the identity SPM derives from
|
|
125
|
+
* the last component of its URL or path. SPM accepts either, so a pinned name does not retire the
|
|
126
|
+
* derived identity.
|
|
127
|
+
*/
|
|
128
|
+
function packageReferenceNames(call) {
|
|
129
|
+
var _a;
|
|
130
|
+
const names = new Set();
|
|
131
|
+
const explicit = call.match(/name:\s*"([^"]+)"/);
|
|
132
|
+
if (explicit) {
|
|
133
|
+
names.add(explicit[1].toLowerCase());
|
|
134
|
+
}
|
|
135
|
+
const location = call.match(/(?:url|path):\s*"([^"]+)"/);
|
|
136
|
+
if (location) {
|
|
137
|
+
const lastComponent = (_a = location[1].replace(/\/+$/, '').split('/').pop()) !== null && _a !== void 0 ? _a : '';
|
|
138
|
+
const identity = lastComponent.replace(/\.git$/i, '').toLowerCase();
|
|
139
|
+
if (identity) {
|
|
140
|
+
names.add(identity);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return [...names];
|
|
144
|
+
}
|
|
145
|
+
function escapeRegExp(value) {
|
|
146
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
147
|
+
}
|
|
90
148
|
/** Reads the version an existing `Package.swift` pins Capacitor to, if it pins one. */
|
|
91
149
|
function findCapacitorDependencyVersion(content) {
|
|
92
150
|
for (const call of findPackageCalls(content)) {
|
|
@@ -134,7 +192,11 @@ exports.patchPackageSwiftDeploymentTarget = patchPackageSwiftDeploymentTarget;
|
|
|
134
192
|
* the app, or the package it points at, has moved.
|
|
135
193
|
*/
|
|
136
194
|
function referencesCapacitor(call) {
|
|
137
|
-
|
|
195
|
+
if (call.includes(BINARY_PACKAGE_IDENTITY) || SOURCE_PACKAGE_URL.test(call) || CORDOVA_PACKAGE_URL.test(call)) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
const pinned = call.match(/name:\s*"([^"]+)"/);
|
|
199
|
+
return pinned !== null && PINNED_PACKAGE_NAMES.includes(pinned[1].toLowerCase());
|
|
138
200
|
}
|
|
139
201
|
/**
|
|
140
202
|
* Locates `.package(...)` calls in code, skipping any inside a comment or string literal.
|
package/dist/util/cordova-ios.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.generateCordovaPackageFile = exports.generateCordovaPackageFiles = expor
|
|
|
4
4
|
const fs_extra_1 = require("fs-extra");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const cordova_1 = require("../cordova");
|
|
7
|
-
const common_1 = require("../ios/common");
|
|
8
7
|
const log_1 = require("../log");
|
|
9
8
|
const plugin_1 = require("../plugin");
|
|
10
9
|
const capacitor_package_1 = require("../util/capacitor-package");
|
|
@@ -440,7 +439,6 @@ ${entries.join(',\n')}
|
|
|
440
439
|
async function generateCordovaPackageFile(p, config) {
|
|
441
440
|
var _a;
|
|
442
441
|
const capacitorPackagePath = await (0, capacitor_package_1.resolveCapacitorPackagePath)(config);
|
|
443
|
-
const iosVersion = (0, common_1.getMajoriOSVersion)(config);
|
|
444
442
|
const headerFiles = (0, plugin_1.getPlatformElement)(p, platform, 'header-file');
|
|
445
443
|
let headersText = '';
|
|
446
444
|
if (headerFiles.length > 0) {
|
|
@@ -451,9 +449,8 @@ async function generateCordovaPackageFile(p, config) {
|
|
|
451
449
|
if ((_a = platformTag.$) === null || _a === void 0 ? void 0 : _a.package) {
|
|
452
450
|
const packageSwiftPath = (0, path_1.join)(p.rootPath, 'Package.swift');
|
|
453
451
|
let content = await (0, fs_extra_1.readFile)(packageSwiftPath, { encoding: 'utf-8' });
|
|
454
|
-
content = content.replace(`apache`, `ionic-team`).replaceAll(`cordova-ios`, capacitor_package_1.SOURCE_PACKAGE_IDENTITY);
|
|
455
452
|
content = (0, capacitor_package_1.rewriteCapacitorDependency)(content, capacitorPackagePath, p.rootPath);
|
|
456
|
-
content = (0, capacitor_package_1.patchPackageSwiftDeploymentTarget)(content,
|
|
453
|
+
content = (0, capacitor_package_1.patchPackageSwiftDeploymentTarget)(content, config.ios.minVersion).content;
|
|
457
454
|
await (0, fs_extra_1.writeFile)(packageSwiftPath, content);
|
|
458
455
|
}
|
|
459
456
|
else {
|
|
@@ -483,7 +480,7 @@ import PackageDescription
|
|
|
483
480
|
|
|
484
481
|
let package = Package(
|
|
485
482
|
name: "${p.name}",
|
|
486
|
-
platforms: [.iOS(.v${
|
|
483
|
+
platforms: [.iOS(.v${Math.trunc(parseFloat(config.ios.minVersion))})],
|
|
487
484
|
products: [
|
|
488
485
|
.library(
|
|
489
486
|
name: "${p.name}",${libraryTypeText}
|
package/package.json
CHANGED