@capacitor/cli 7.3.1-nightly-20250618T150603.0 → 7.4.0
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/index.js +7 -0
- package/dist/ios/update.js +2 -1
- package/dist/tasks/migrate-spm.js +19 -0
- package/dist/util/spm.js +109 -1
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -228,6 +228,13 @@ function runProgram(config) {
|
|
|
228
228
|
const { migrateCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/migrate')));
|
|
229
229
|
await migrateCommand(config, noprompt, packagemanager);
|
|
230
230
|
}));
|
|
231
|
+
commander_1.program
|
|
232
|
+
.command('spm-migration-assistant')
|
|
233
|
+
.description('Remove Cocoapods from project and switch to Swift Package Manager')
|
|
234
|
+
.action((0, cli_1.wrapAction)(async () => {
|
|
235
|
+
const { migrateToSPM } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/migrate-spm')));
|
|
236
|
+
await migrateToSPM(config);
|
|
237
|
+
}));
|
|
231
238
|
commander_1.program.arguments('[command]').action((0, cli_1.wrapAction)(async (cmd) => {
|
|
232
239
|
if (typeof cmd === 'undefined') {
|
|
233
240
|
log_1.output.write(`\n ${(0, emoji_1.emoji)('⚡️', '--')} ${colors_1.default.strong('Capacitor - Cross-Platform apps with JavaScript and the Web')} ${(0, emoji_1.emoji)('⚡️', '--')}\n\n`);
|
package/dist/ios/update.js
CHANGED
|
@@ -42,7 +42,8 @@ async function updatePluginFiles(config, plugins, deployment) {
|
|
|
42
42
|
await (0, cordova_1.checkPluginDependencies)(plugins, platform, (_a = config.app.extConfig.cordova) === null || _a === void 0 ? void 0 : _a.failOnUninstalledPlugins);
|
|
43
43
|
if ((await (0, spm_1.checkPackageManager)(config)) === 'SPM') {
|
|
44
44
|
await generateCordovaPackageFiles(cordovaPlugins, config);
|
|
45
|
-
await (0, spm_1.
|
|
45
|
+
const validSPMPackages = await (0, spm_1.checkPluginsForPackageSwift)(config, plugins);
|
|
46
|
+
await (0, spm_1.generatePackageFile)(config, validSPMPackages);
|
|
46
47
|
}
|
|
47
48
|
else {
|
|
48
49
|
await generateCordovaPodspecs(cordovaPlugins, config);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrateToSPM = void 0;
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
const log_1 = require("../log");
|
|
6
|
+
const spm_1 = require("../util/spm");
|
|
7
|
+
const update_1 = require("./update");
|
|
8
|
+
async function migrateToSPM(config) {
|
|
9
|
+
if ((await (0, spm_1.checkPackageManager)(config)) == 'SPM') {
|
|
10
|
+
(0, errors_1.fatal)('Capacitor project is already using SPM, exiting.');
|
|
11
|
+
}
|
|
12
|
+
await (0, spm_1.extractSPMPackageDirectory)(config);
|
|
13
|
+
await (0, spm_1.runCocoapodsDeintegrate)(config);
|
|
14
|
+
await (0, spm_1.removeCocoapodsFiles)(config);
|
|
15
|
+
await (0, spm_1.addInfoPlistDebugIfNeeded)(config);
|
|
16
|
+
await (0, update_1.update)(config, 'ios', true);
|
|
17
|
+
log_1.logger.info('To complete migration follow the manual steps at https://capacitorjs.com/docs/ios/spm#using-our-migration-tool');
|
|
18
|
+
}
|
|
19
|
+
exports.migrateToSPM = migrateToSPM;
|
package/dist/util/spm.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generatePackageFile = exports.findPackageSwiftFile = exports.checkPackageManager = void 0;
|
|
3
|
+
exports.addInfoPlistDebugIfNeeded = exports.runCocoapodsDeintegrate = exports.generatePackageText = exports.removeCocoapodsFiles = exports.extractSPMPackageDirectory = exports.checkPluginsForPackageSwift = exports.generatePackageFile = exports.findPackageSwiftFile = exports.checkPackageManager = void 0;
|
|
4
4
|
const fs_extra_1 = require("fs-extra");
|
|
5
|
+
const os_1 = require("os");
|
|
5
6
|
const path_1 = require("path");
|
|
7
|
+
const plist_1 = require("plist");
|
|
8
|
+
const tar_1 = require("tar");
|
|
6
9
|
const common_1 = require("../common");
|
|
10
|
+
const errors_1 = require("../errors");
|
|
7
11
|
const common_2 = require("../ios/common");
|
|
8
12
|
const log_1 = require("../log");
|
|
9
13
|
const plugin_1 = require("../plugin");
|
|
14
|
+
const subprocess_1 = require("../util/subprocess");
|
|
10
15
|
async function checkPackageManager(config) {
|
|
11
16
|
const iosDirectory = config.ios.nativeProjectDirAbs;
|
|
12
17
|
if ((0, fs_extra_1.existsSync)((0, path_1.resolve)(iosDirectory, 'CapApp-SPM'))) {
|
|
@@ -23,6 +28,7 @@ exports.findPackageSwiftFile = findPackageSwiftFile;
|
|
|
23
28
|
async function generatePackageFile(config, plugins) {
|
|
24
29
|
const packageSwiftFile = await findPackageSwiftFile(config);
|
|
25
30
|
try {
|
|
31
|
+
log_1.logger.info('Writing Package.swift');
|
|
26
32
|
const textToWrite = await generatePackageText(config, plugins);
|
|
27
33
|
(0, fs_extra_1.writeFileSync)(packageSwiftFile, textToWrite);
|
|
28
34
|
}
|
|
@@ -31,6 +37,47 @@ async function generatePackageFile(config, plugins) {
|
|
|
31
37
|
}
|
|
32
38
|
}
|
|
33
39
|
exports.generatePackageFile = generatePackageFile;
|
|
40
|
+
async function checkPluginsForPackageSwift(config, plugins) {
|
|
41
|
+
const iOSCapacitorPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, 'ios') === 0 /* PluginType.Core */);
|
|
42
|
+
const packageSwiftPluginList = await pluginsWithPackageSwift(iOSCapacitorPlugins);
|
|
43
|
+
if (plugins.length == packageSwiftPluginList.length) {
|
|
44
|
+
log_1.logger.debug(`Found ${plugins.length} iOS plugins, ${packageSwiftPluginList.length} have a Package.swift file`);
|
|
45
|
+
log_1.logger.info('All plugins have a Package.swift file and will be included in Package.swift');
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
log_1.logger.warn('Some installed packages my not be compatable with SPM');
|
|
49
|
+
}
|
|
50
|
+
return packageSwiftPluginList;
|
|
51
|
+
}
|
|
52
|
+
exports.checkPluginsForPackageSwift = checkPluginsForPackageSwift;
|
|
53
|
+
async function extractSPMPackageDirectory(config) {
|
|
54
|
+
const spmDirectory = (0, path_1.join)(config.ios.nativeProjectDirAbs, 'CapApp-SPM');
|
|
55
|
+
const spmTemplate = (0, path_1.join)(config.cli.assetsDirAbs, 'ios-spm-template.tar.gz');
|
|
56
|
+
const debugConfig = (0, path_1.join)(config.ios.platformDirAbs, 'debug.xcconfig');
|
|
57
|
+
log_1.logger.info('Extracting ' + spmTemplate + ' to ' + spmDirectory);
|
|
58
|
+
try {
|
|
59
|
+
const tempCapDir = await (0, fs_extra_1.mkdtemp)((0, path_1.join)((0, os_1.tmpdir)(), 'cap-'));
|
|
60
|
+
const tempCapSPM = (0, path_1.join)(tempCapDir, 'App', 'CapApp-SPM');
|
|
61
|
+
const tempDebugXCConfig = (0, path_1.join)(tempCapDir, 'debug.xcconfig');
|
|
62
|
+
await (0, tar_1.extract)({ file: spmTemplate, cwd: tempCapDir });
|
|
63
|
+
await (0, fs_extra_1.move)(tempCapSPM, spmDirectory);
|
|
64
|
+
await (0, fs_extra_1.move)(tempDebugXCConfig, debugConfig);
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
(0, errors_1.fatal)('Failed to create ' + spmDirectory + ' with error: ' + err);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.extractSPMPackageDirectory = extractSPMPackageDirectory;
|
|
71
|
+
async function removeCocoapodsFiles(config) {
|
|
72
|
+
const iosDirectory = config.ios.nativeProjectDirAbs;
|
|
73
|
+
const podFile = (0, path_1.resolve)(iosDirectory, 'Podfile');
|
|
74
|
+
const podlockFile = (0, path_1.resolve)(iosDirectory, 'Podfile.lock');
|
|
75
|
+
const xcworkspaceFile = (0, path_1.resolve)(iosDirectory, 'App.xcworkspace');
|
|
76
|
+
await (0, fs_extra_1.remove)(podFile);
|
|
77
|
+
await (0, fs_extra_1.remove)(podlockFile);
|
|
78
|
+
await (0, fs_extra_1.remove)(xcworkspaceFile);
|
|
79
|
+
}
|
|
80
|
+
exports.removeCocoapodsFiles = removeCocoapodsFiles;
|
|
34
81
|
async function generatePackageText(config, plugins) {
|
|
35
82
|
var _a, _b, _c;
|
|
36
83
|
const iosPlatformVersion = await (0, common_1.getCapacitorPackageVersion)(config, config.ios.name);
|
|
@@ -77,3 +124,64 @@ let package = Package(
|
|
|
77
124
|
`;
|
|
78
125
|
return packageSwiftText;
|
|
79
126
|
}
|
|
127
|
+
exports.generatePackageText = generatePackageText;
|
|
128
|
+
async function runCocoapodsDeintegrate(config) {
|
|
129
|
+
const podPath = await config.ios.podPath;
|
|
130
|
+
const projectFileName = config.ios.nativeXcodeProjDirAbs;
|
|
131
|
+
const useBundler = podPath.startsWith('bundle') && (await (0, subprocess_1.isInstalled)('bundle'));
|
|
132
|
+
const podCommandExists = await (0, subprocess_1.isInstalled)('pod');
|
|
133
|
+
if (useBundler)
|
|
134
|
+
log_1.logger.info('Found bundler, using it to run CocoaPods.');
|
|
135
|
+
log_1.logger.info('Running pod deintegrate on project ' + projectFileName);
|
|
136
|
+
if (useBundler || podCommandExists) {
|
|
137
|
+
if (useBundler) {
|
|
138
|
+
await (0, subprocess_1.runCommand)('bundle', ['exec', 'pod', 'deintegrate', projectFileName], {
|
|
139
|
+
cwd: config.ios.nativeProjectDirAbs,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
await (0, subprocess_1.runCommand)(podPath, ['deintegrate', projectFileName], {
|
|
144
|
+
cwd: config.ios.nativeProjectDirAbs,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
log_1.logger.warn('Skipping pod deintegrate because CocoaPods is not installed - migration will be incomplete');
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.runCocoapodsDeintegrate = runCocoapodsDeintegrate;
|
|
153
|
+
async function addInfoPlistDebugIfNeeded(config) {
|
|
154
|
+
const infoPlist = (0, path_1.resolve)(config.ios.nativeTargetDirAbs, 'Info.plist');
|
|
155
|
+
log_1.logger.info('Checking ' + infoPlist + ' for CAPACITOR_DEBUG');
|
|
156
|
+
if ((0, fs_extra_1.existsSync)(infoPlist)) {
|
|
157
|
+
const infoPlistContents = (0, fs_extra_1.readFileSync)(infoPlist, 'utf-8');
|
|
158
|
+
const plistEntries = (0, plist_1.parse)(infoPlistContents);
|
|
159
|
+
if (plistEntries['CAPACITOR_DEBUG'] === undefined) {
|
|
160
|
+
log_1.logger.info('Writing CAPACITOR_DEBUG to ' + infoPlist);
|
|
161
|
+
plistEntries['CAPACITOR_DEBUG'] = '$(CAPACITOR_DEBUG)';
|
|
162
|
+
const plistToWrite = (0, plist_1.build)(plistEntries);
|
|
163
|
+
(0, fs_extra_1.writeFileSync)(infoPlist, plistToWrite);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
log_1.logger.warn('Found CAPACITOR_DEBUG set to ' + plistEntries['CAPACITOR_DEBUG'] + ', skipping.');
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
log_1.logger.warn(infoPlist + ' not found.');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.addInfoPlistDebugIfNeeded = addInfoPlistDebugIfNeeded;
|
|
174
|
+
// Private Functions
|
|
175
|
+
async function pluginsWithPackageSwift(plugins) {
|
|
176
|
+
const pluginList = [];
|
|
177
|
+
for (const plugin of plugins) {
|
|
178
|
+
const packageSwiftFound = await (0, fs_extra_1.pathExists)((0, path_1.join)(plugin.rootPath, 'Package.swift'));
|
|
179
|
+
if (packageSwiftFound) {
|
|
180
|
+
pluginList.push(plugin);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
log_1.logger.warn(plugin.id + ' does not have a Package.swift');
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return pluginList;
|
|
187
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/cli",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
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)",
|