Update capacitor version
This commit is contained in:
parent
91155bce0a
commit
f3b3a86b32
610 changed files with 28718 additions and 7101 deletions
140
@capacitor/cli/dist/util/spm.js
vendored
140
@capacitor/cli/dist/util/spm.js
vendored
|
|
@ -1,12 +1,20 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.generatePackageFile = exports.findPackageSwiftFile = exports.checkPackageManager = void 0;
|
||||
const utils_fs_1 = require("@ionic/utils-fs");
|
||||
exports.addInfoPlistDebugIfNeeded = exports.runCocoapodsDeintegrate = exports.generatePackageText = exports.removeCocoapodsFiles = exports.extractSPMPackageDirectory = exports.checkPluginsForPackageSwift = exports.generatePackageFile = exports.findPackageSwiftFile = exports.checkPackageManager = void 0;
|
||||
const fs_extra_1 = require("fs-extra");
|
||||
const os_1 = require("os");
|
||||
const path_1 = require("path");
|
||||
const plist_1 = require("plist");
|
||||
const tar_1 = require("tar");
|
||||
const common_1 = require("../common");
|
||||
const errors_1 = require("../errors");
|
||||
const common_2 = require("../ios/common");
|
||||
const log_1 = require("../log");
|
||||
const plugin_1 = require("../plugin");
|
||||
const subprocess_1 = require("../util/subprocess");
|
||||
async function checkPackageManager(config) {
|
||||
const iosDirectory = config.ios.nativeProjectDirAbs;
|
||||
if ((0, utils_fs_1.existsSync)((0, path_1.resolve)(iosDirectory, 'CapApp-SPM'))) {
|
||||
if ((0, fs_extra_1.existsSync)((0, path_1.resolve)(iosDirectory, 'CapApp-SPM'))) {
|
||||
return 'SPM';
|
||||
}
|
||||
return 'Cocoapods';
|
||||
|
|
@ -20,20 +28,60 @@ exports.findPackageSwiftFile = findPackageSwiftFile;
|
|||
async function generatePackageFile(config, plugins) {
|
||||
const packageSwiftFile = await findPackageSwiftFile(config);
|
||||
try {
|
||||
log_1.logger.warn('SPM Support is still experimental');
|
||||
const textToWrite = generatePackageText(config, plugins);
|
||||
(0, utils_fs_1.writeFileSync)(packageSwiftFile, textToWrite);
|
||||
log_1.logger.info('Writing Package.swift');
|
||||
const textToWrite = await generatePackageText(config, plugins);
|
||||
(0, fs_extra_1.writeFileSync)(packageSwiftFile, textToWrite);
|
||||
}
|
||||
catch (err) {
|
||||
log_1.logger.error(`Unable to write to ${packageSwiftFile}. Verify it is not already open. \n Error: ${err}`);
|
||||
}
|
||||
}
|
||||
exports.generatePackageFile = generatePackageFile;
|
||||
function generatePackageText(config, plugins) {
|
||||
async function checkPluginsForPackageSwift(config, plugins) {
|
||||
const iOSCapacitorPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, 'ios') === 0 /* PluginType.Core */);
|
||||
const packageSwiftPluginList = await pluginsWithPackageSwift(iOSCapacitorPlugins);
|
||||
if (plugins.length == packageSwiftPluginList.length) {
|
||||
log_1.logger.debug(`Found ${plugins.length} iOS plugins, ${packageSwiftPluginList.length} have a Package.swift file`);
|
||||
log_1.logger.info('All plugins have a Package.swift file and will be included in Package.swift');
|
||||
}
|
||||
else {
|
||||
log_1.logger.warn('Some installed packages my not be compatable with SPM');
|
||||
}
|
||||
return packageSwiftPluginList;
|
||||
}
|
||||
exports.checkPluginsForPackageSwift = checkPluginsForPackageSwift;
|
||||
async function extractSPMPackageDirectory(config) {
|
||||
const spmDirectory = (0, path_1.join)(config.ios.nativeProjectDirAbs, 'CapApp-SPM');
|
||||
const spmTemplate = (0, path_1.join)(config.cli.assetsDirAbs, 'ios-spm-template.tar.gz');
|
||||
const debugConfig = (0, path_1.join)(config.ios.platformDirAbs, 'debug.xcconfig');
|
||||
log_1.logger.info('Extracting ' + spmTemplate + ' to ' + spmDirectory);
|
||||
try {
|
||||
const tempCapDir = await (0, fs_extra_1.mkdtemp)((0, path_1.join)((0, os_1.tmpdir)(), 'cap-'));
|
||||
const tempCapSPM = (0, path_1.join)(tempCapDir, 'App', 'CapApp-SPM');
|
||||
const tempDebugXCConfig = (0, path_1.join)(tempCapDir, 'debug.xcconfig');
|
||||
await (0, tar_1.extract)({ file: spmTemplate, cwd: tempCapDir });
|
||||
await (0, fs_extra_1.move)(tempCapSPM, spmDirectory);
|
||||
await (0, fs_extra_1.move)(tempDebugXCConfig, debugConfig);
|
||||
}
|
||||
catch (err) {
|
||||
(0, errors_1.fatal)('Failed to create ' + spmDirectory + ' with error: ' + err);
|
||||
}
|
||||
}
|
||||
exports.extractSPMPackageDirectory = extractSPMPackageDirectory;
|
||||
async function removeCocoapodsFiles(config) {
|
||||
const iosDirectory = config.ios.nativeProjectDirAbs;
|
||||
const podFile = (0, path_1.resolve)(iosDirectory, 'Podfile');
|
||||
const podlockFile = (0, path_1.resolve)(iosDirectory, 'Podfile.lock');
|
||||
const xcworkspaceFile = (0, path_1.resolve)(iosDirectory, 'App.xcworkspace');
|
||||
await (0, fs_extra_1.remove)(podFile);
|
||||
await (0, fs_extra_1.remove)(podlockFile);
|
||||
await (0, fs_extra_1.remove)(xcworkspaceFile);
|
||||
}
|
||||
exports.removeCocoapodsFiles = removeCocoapodsFiles;
|
||||
async function generatePackageText(config, plugins) {
|
||||
var _a, _b, _c;
|
||||
const pbx = (0, utils_fs_1.readFileSync)((0, path_1.join)(config.ios.nativeXcodeProjDirAbs, 'project.pbxproj'), 'utf-8');
|
||||
const searchString = 'IPHONEOS_DEPLOYMENT_TARGET = ';
|
||||
const iosVersion = pbx.substring(pbx.indexOf(searchString) + searchString.length, pbx.indexOf(searchString) + searchString.length + 2);
|
||||
const iosPlatformVersion = await (0, common_1.getCapacitorPackageVersion)(config, config.ios.name);
|
||||
const iosVersion = (0, common_2.getMajoriOSVersion)(config);
|
||||
let packageSwiftText = `// swift-tools-version: 5.9
|
||||
import PackageDescription
|
||||
|
||||
|
|
@ -47,10 +95,15 @@ let package = Package(
|
|||
targets: ["CapApp-SPM"])
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", branch: "main")`;
|
||||
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", exact: "${iosPlatformVersion}")`;
|
||||
for (const plugin of plugins) {
|
||||
const relPath = (0, path_1.relative)(config.ios.nativeXcodeProjDirAbs, plugin.rootPath);
|
||||
packageSwiftText += `,\n .package(name: "${(_a = plugin.ios) === null || _a === void 0 ? void 0 : _a.name}", path: "${relPath}")`;
|
||||
if ((0, plugin_1.getPluginType)(plugin, config.ios.name) === 1 /* PluginType.Cordova */) {
|
||||
packageSwiftText += `,\n .package(name: "${plugin.name}", path: "../../capacitor-cordova-ios-plugins/sources/${plugin.name}")`;
|
||||
}
|
||||
else {
|
||||
const relPath = (0, path_1.relative)(config.ios.nativeXcodeProjDirAbs, plugin.rootPath);
|
||||
packageSwiftText += `,\n .package(name: "${(_a = plugin.ios) === null || _a === void 0 ? void 0 : _a.name}", path: "${relPath}")`;
|
||||
}
|
||||
}
|
||||
packageSwiftText += `
|
||||
],
|
||||
|
|
@ -71,3 +124,64 @@ let package = Package(
|
|||
`;
|
||||
return packageSwiftText;
|
||||
}
|
||||
exports.generatePackageText = generatePackageText;
|
||||
async function runCocoapodsDeintegrate(config) {
|
||||
const podPath = await config.ios.podPath;
|
||||
const projectFileName = config.ios.nativeXcodeProjDirAbs;
|
||||
const useBundler = podPath.startsWith('bundle') && (await (0, subprocess_1.isInstalled)('bundle'));
|
||||
const podCommandExists = await (0, subprocess_1.isInstalled)('pod');
|
||||
if (useBundler)
|
||||
log_1.logger.info('Found bundler, using it to run CocoaPods.');
|
||||
log_1.logger.info('Running pod deintegrate on project ' + projectFileName);
|
||||
if (useBundler || podCommandExists) {
|
||||
if (useBundler) {
|
||||
await (0, subprocess_1.runCommand)('bundle', ['exec', 'pod', 'deintegrate', projectFileName], {
|
||||
cwd: config.ios.nativeProjectDirAbs,
|
||||
});
|
||||
}
|
||||
else {
|
||||
await (0, subprocess_1.runCommand)(podPath, ['deintegrate', projectFileName], {
|
||||
cwd: config.ios.nativeProjectDirAbs,
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
log_1.logger.warn('Skipping pod deintegrate because CocoaPods is not installed - migration will be incomplete');
|
||||
}
|
||||
}
|
||||
exports.runCocoapodsDeintegrate = runCocoapodsDeintegrate;
|
||||
async function addInfoPlistDebugIfNeeded(config) {
|
||||
const infoPlist = (0, path_1.resolve)(config.ios.nativeTargetDirAbs, 'Info.plist');
|
||||
log_1.logger.info('Checking ' + infoPlist + ' for CAPACITOR_DEBUG');
|
||||
if ((0, fs_extra_1.existsSync)(infoPlist)) {
|
||||
const infoPlistContents = (0, fs_extra_1.readFileSync)(infoPlist, 'utf-8');
|
||||
const plistEntries = (0, plist_1.parse)(infoPlistContents);
|
||||
if (plistEntries['CAPACITOR_DEBUG'] === undefined) {
|
||||
log_1.logger.info('Writing CAPACITOR_DEBUG to ' + infoPlist);
|
||||
plistEntries['CAPACITOR_DEBUG'] = '$(CAPACITOR_DEBUG)';
|
||||
const plistToWrite = (0, plist_1.build)(plistEntries);
|
||||
(0, fs_extra_1.writeFileSync)(infoPlist, plistToWrite);
|
||||
}
|
||||
else {
|
||||
log_1.logger.warn('Found CAPACITOR_DEBUG set to ' + plistEntries['CAPACITOR_DEBUG'] + ', skipping.');
|
||||
}
|
||||
}
|
||||
else {
|
||||
log_1.logger.warn(infoPlist + ' not found.');
|
||||
}
|
||||
}
|
||||
exports.addInfoPlistDebugIfNeeded = addInfoPlistDebugIfNeeded;
|
||||
// Private Functions
|
||||
async function pluginsWithPackageSwift(plugins) {
|
||||
const pluginList = [];
|
||||
for (const plugin of plugins) {
|
||||
const packageSwiftFound = await (0, fs_extra_1.pathExists)((0, path_1.join)(plugin.rootPath, 'Package.swift'));
|
||||
if (packageSwiftFound) {
|
||||
pluginList.push(plugin);
|
||||
}
|
||||
else {
|
||||
log_1.logger.warn(plugin.id + ' does not have a Package.swift');
|
||||
}
|
||||
}
|
||||
return pluginList;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue