Update capacitor version
This commit is contained in:
parent
91155bce0a
commit
f3b3a86b32
610 changed files with 28718 additions and 7101 deletions
81
@capacitor/cli/dist/common.js
vendored
81
@capacitor/cli/dist/common.js
vendored
|
@ -2,8 +2,8 @@
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseApkNameFromFlavor = exports.checkJDKMajorVersion = exports.resolvePlatform = exports.checkPlatformVersions = exports.getAddedPlatforms = exports.getPlatformTargetName = exports.promptForPlatformTarget = exports.promptForPlatform = exports.isValidEnterprisePlatform = exports.getKnownEnterprisePlatforms = exports.isValidCommunityPlatform = exports.getKnownCommunityPlatforms = exports.isValidPlatform = exports.getKnownPlatforms = exports.selectPlatforms = exports.getProjectPlatformDirectory = exports.getCLIVersion = exports.getCoreVersion = exports.getCapacitorPackageVersion = exports.requireCapacitorPackage = exports.getCapacitorPackage = exports.runTask = exports.runPlatformHook = exports.runHooks = exports.wait = exports.checkAppName = exports.checkAppId = exports.checkAppDir = exports.checkAppConfig = exports.checkCapacitorPlatform = exports.checkPackage = exports.checkWebDir = exports.check = void 0;
|
||||
const tslib_1 = require("tslib");
|
||||
const utils_fs_1 = require("@ionic/utils-fs");
|
||||
const utils_terminal_1 = require("@ionic/utils-terminal");
|
||||
const fs_extra_1 = require("fs-extra");
|
||||
const path_1 = require("path");
|
||||
const colors_1 = tslib_1.__importDefault(require("./colors"));
|
||||
const errors_1 = require("./errors");
|
||||
|
@ -13,8 +13,8 @@ const monorepotools_1 = require("./util/monorepotools");
|
|||
const node_1 = require("./util/node");
|
||||
const subprocess_1 = require("./util/subprocess");
|
||||
async function check(checks) {
|
||||
const results = await Promise.all(checks.map(f => f()));
|
||||
const errors = results.filter(r => r != null);
|
||||
const results = await Promise.all(checks.map((f) => f()));
|
||||
const errors = results.filter((r) => r != null);
|
||||
if (errors.length > 0) {
|
||||
throw errors.join('\n');
|
||||
}
|
||||
|
@ -30,11 +30,11 @@ async function checkWebDir(config) {
|
|||
if (invalidFolders.includes(config.app.webDir)) {
|
||||
return `"${config.app.webDir}" is not a valid value for webDir`;
|
||||
}
|
||||
if (!(await (0, utils_fs_1.pathExists)(config.app.webDirAbs))) {
|
||||
if (!(await (0, fs_extra_1.pathExists)(config.app.webDirAbs))) {
|
||||
return (`Could not find the web assets directory: ${colors_1.default.strong((0, utils_terminal_1.prettyPath)(config.app.webDirAbs))}.\n` +
|
||||
`Please create it and make sure it has an ${colors_1.default.strong('index.html')} file. You can change the path of this directory in ${colors_1.default.strong(config.app.extConfigName)} (${colors_1.default.input('webDir')} option). You may need to compile the web assets for your app (typically ${colors_1.default.input('npm run build')}). More info: ${colors_1.default.strong('https://capacitorjs.com/docs/basics/workflow#sync-your-project')}`);
|
||||
}
|
||||
if (!(await (0, utils_fs_1.pathExists)((0, path_1.join)(config.app.webDirAbs, 'index.html')))) {
|
||||
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(config.app.webDirAbs, 'index.html')))) {
|
||||
return (`The web assets directory (${colors_1.default.strong((0, utils_terminal_1.prettyPath)(config.app.webDirAbs))}) must contain an ${colors_1.default.strong('index.html')} file.\n` +
|
||||
`It will be the entry point for the web portion of the Capacitor app.`);
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ async function checkWebDir(config) {
|
|||
}
|
||||
exports.checkWebDir = checkWebDir;
|
||||
async function checkPackage() {
|
||||
if (!(await (0, utils_fs_1.pathExists)('package.json'))) {
|
||||
if (await (0, utils_fs_1.pathExists)('project.json')) {
|
||||
if (!(await (0, fs_extra_1.pathExists)('package.json'))) {
|
||||
if (await (0, fs_extra_1.pathExists)('project.json')) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
|
@ -93,12 +93,20 @@ async function checkAppDir(config, dir) {
|
|||
exports.checkAppDir = checkAppDir;
|
||||
async function checkAppId(config, id) {
|
||||
if (!id) {
|
||||
return `Invalid App ID. Must be in Java package form with no dashes (ex: com.example.app)`;
|
||||
return `Invalid App ID. App ID is required and cannot be blank.`;
|
||||
}
|
||||
if (/^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+$/.test(id.toLowerCase())) {
|
||||
if (/^[a-zA-Z][\w]*(?:\.[a-zA-Z][\w]*)+$/.test(id.toLowerCase())) {
|
||||
return null;
|
||||
}
|
||||
return `Invalid App ID "${id}". Must be in Java package form with no dashes (ex: com.example.app)`;
|
||||
return `
|
||||
Invalid App ID "${id}". Your App ID must meet the following requirements to be valid on both iOS and Android:
|
||||
- Must be in Java package form with no dashes (ex: com.example.app)
|
||||
- It must have at least two segments (one or more dots).
|
||||
- Each segment must start with a letter.
|
||||
- All characters must be alphanumeric or an underscore [a-zA-Z][a-zA-Z0-9]+.
|
||||
|
||||
If you would like to skip validation, run "cap init" with the "--skip-appid-validation" flag.
|
||||
`;
|
||||
}
|
||||
exports.checkAppId = checkAppId;
|
||||
async function checkAppName(config, name) {
|
||||
|
@ -110,15 +118,15 @@ async function checkAppName(config, name) {
|
|||
}
|
||||
exports.checkAppName = checkAppName;
|
||||
async function wait(time) {
|
||||
return new Promise(resolve => setTimeout(resolve, time));
|
||||
return new Promise((resolve) => setTimeout(resolve, time));
|
||||
}
|
||||
exports.wait = wait;
|
||||
async function runHooks(config, platformName, dir, hook) {
|
||||
await runPlatformHook(config, platformName, dir, hook);
|
||||
const allPlugins = await (0, plugin_1.getPlugins)(config, platformName);
|
||||
allPlugins.forEach(async (p) => {
|
||||
for (const p of allPlugins) {
|
||||
await runPlatformHook(config, platformName, p.rootPath, hook);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.runHooks = runHooks;
|
||||
async function runPlatformHook(config, platformName, platformDir, hook) {
|
||||
|
@ -126,10 +134,10 @@ async function runPlatformHook(config, platformName, platformDir, hook) {
|
|||
const { spawn } = await Promise.resolve().then(() => tslib_1.__importStar(require('child_process')));
|
||||
let pkg;
|
||||
if ((0, monorepotools_1.isNXMonorepo)(platformDir)) {
|
||||
pkg = await (0, utils_fs_1.readJSON)((0, path_1.join)((0, monorepotools_1.findNXMonorepoRoot)(platformDir), 'package.json'));
|
||||
pkg = await (0, fs_extra_1.readJSON)((0, path_1.join)((0, monorepotools_1.findNXMonorepoRoot)(platformDir), 'package.json'));
|
||||
}
|
||||
else {
|
||||
pkg = await (0, utils_fs_1.readJSON)((0, path_1.join)(platformDir, 'package.json'));
|
||||
pkg = await (0, fs_extra_1.readJSON)((0, path_1.join)(platformDir, 'package.json'));
|
||||
}
|
||||
const cmd = (_a = pkg.scripts) === null || _a === void 0 ? void 0 : _a[hook];
|
||||
if (!cmd) {
|
||||
|
@ -149,10 +157,15 @@ async function runPlatformHook(config, platformName, platformDir, hook) {
|
|||
...process.env,
|
||||
},
|
||||
});
|
||||
p.on('close', () => {
|
||||
resolve();
|
||||
p.on('close', (code) => {
|
||||
if (code === 0) {
|
||||
resolve();
|
||||
}
|
||||
else {
|
||||
reject(new Error(`${hook} hook on ${platformName} failed with error code: ${code} while running command: ${cmd}`));
|
||||
}
|
||||
});
|
||||
p.on('error', err => {
|
||||
p.on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
@ -177,7 +190,7 @@ async function getCapacitorPackage(config, name) {
|
|||
if (!packagePath) {
|
||||
return null;
|
||||
}
|
||||
return (0, utils_fs_1.readJSON)(packagePath);
|
||||
return (0, fs_extra_1.readJSON)(packagePath);
|
||||
}
|
||||
exports.getCapacitorPackage = getCapacitorPackage;
|
||||
async function requireCapacitorPackage(config, name) {
|
||||
|
@ -214,7 +227,7 @@ function getPlatformDirectory(config, platform) {
|
|||
}
|
||||
async function getProjectPlatformDirectory(config, platform) {
|
||||
const platformPath = getPlatformDirectory(config, platform);
|
||||
if (platformPath && (await (0, utils_fs_1.pathExists)(platformPath))) {
|
||||
if (platformPath && (await (0, fs_extra_1.pathExists)(platformPath))) {
|
||||
return platformPath;
|
||||
}
|
||||
return null;
|
||||
|
@ -229,8 +242,7 @@ async function selectPlatforms(config, selectedPlatformName) {
|
|||
}
|
||||
else if (!(await getProjectPlatformDirectory(config, platformName))) {
|
||||
if (platformName === 'web') {
|
||||
(0, errors_1.fatal)(`Could not find the web platform directory.\n` +
|
||||
`Make sure ${colors_1.default.strong(config.app.webDir)} exists.`);
|
||||
(0, errors_1.fatal)(`Could not find the web platform directory.\n` + `Make sure ${colors_1.default.strong(config.app.webDir)} exists.`);
|
||||
}
|
||||
(0, errors_1.fatal)(`${colors_1.default.strong(platformName)} platform has not been added yet.\n` +
|
||||
`See the docs for adding the ${colors_1.default.strong(platformName)} platform: ${colors_1.default.strong(`https://capacitorjs.com/docs/${platformName}#adding-the-${platformName}-platform`)}`);
|
||||
|
@ -275,7 +287,7 @@ async function promptForPlatform(platforms, promptMessage, selectedPlatformName)
|
|||
type: 'select',
|
||||
name: 'mode',
|
||||
message: promptMessage,
|
||||
choices: platforms.map(p => ({ title: p, value: p })),
|
||||
choices: platforms.map((p) => ({ title: p, value: p })),
|
||||
},
|
||||
], { onCancel: () => process.exit(1) });
|
||||
return answers.mode.toLowerCase().trim();
|
||||
|
@ -283,15 +295,14 @@ async function promptForPlatform(platforms, promptMessage, selectedPlatformName)
|
|||
const platformName = selectedPlatformName.toLowerCase().trim();
|
||||
if (!(await isValidPlatform(platformName))) {
|
||||
const knownPlatforms = await getKnownPlatforms();
|
||||
(0, errors_1.fatal)(`Invalid platform: ${colors_1.default.input(platformName)}.\n` +
|
||||
`Valid platforms include: ${knownPlatforms.join(', ')}`);
|
||||
(0, errors_1.fatal)(`Invalid platform: ${colors_1.default.input(platformName)}.\n` + `Valid platforms include: ${knownPlatforms.join(', ')}`);
|
||||
}
|
||||
return platformName;
|
||||
}
|
||||
exports.promptForPlatform = promptForPlatform;
|
||||
async function promptForPlatformTarget(targets, selectedTarget) {
|
||||
const { prompt } = await Promise.resolve().then(() => tslib_1.__importStar(require('prompts')));
|
||||
const validTargets = targets.filter(t => t.id !== undefined);
|
||||
const validTargets = targets.filter((t) => t.id !== undefined);
|
||||
if (!selectedTarget) {
|
||||
if (validTargets.length === 1) {
|
||||
return validTargets[0];
|
||||
|
@ -302,7 +313,7 @@ async function promptForPlatformTarget(targets, selectedTarget) {
|
|||
type: 'select',
|
||||
name: 'target',
|
||||
message: 'Please choose a target device:',
|
||||
choices: validTargets.map(t => ({
|
||||
choices: validTargets.map((t) => ({
|
||||
title: `${getPlatformTargetName(t)} (${t.id})`,
|
||||
value: t,
|
||||
})),
|
||||
|
@ -312,19 +323,16 @@ async function promptForPlatformTarget(targets, selectedTarget) {
|
|||
}
|
||||
}
|
||||
const targetID = selectedTarget.trim();
|
||||
const target = targets.find(t => t.id === targetID);
|
||||
const target = targets.find((t) => t.id === targetID);
|
||||
if (!target) {
|
||||
(0, errors_1.fatal)(`Invalid target ID: ${colors_1.default.input(targetID)}.\n` +
|
||||
`Valid targets are: ${targets.map(t => t.id).join(', ')}`);
|
||||
(0, errors_1.fatal)(`Invalid target ID: ${colors_1.default.input(targetID)}.\n` + `Valid targets are: ${targets.map((t) => t.id).join(', ')}`);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
exports.promptForPlatformTarget = promptForPlatformTarget;
|
||||
function getPlatformTargetName(target) {
|
||||
var _a, _b, _c;
|
||||
return `${(_c = (_b = (_a = target.name) !== null && _a !== void 0 ? _a : target.model) !== null && _b !== void 0 ? _b : target.id) !== null && _c !== void 0 ? _c : '?'}${target.virtual
|
||||
? ` (${target.platform === 'ios' ? 'simulator' : 'emulator'})`
|
||||
: ''}`;
|
||||
return `${(_c = (_b = (_a = target.name) !== null && _a !== void 0 ? _a : target.model) !== null && _b !== void 0 ? _b : target.id) !== null && _c !== void 0 ? _c : '?'}${target.virtual ? ` (${target.platform === 'ios' ? 'simulator' : 'emulator'})` : ''}`;
|
||||
}
|
||||
exports.getPlatformTargetName = getPlatformTargetName;
|
||||
async function getAddedPlatforms(config) {
|
||||
|
@ -343,8 +351,7 @@ async function checkPlatformVersions(config, platform) {
|
|||
const semver = await Promise.resolve().then(() => tslib_1.__importStar(require('semver')));
|
||||
const coreVersion = await getCoreVersion(config);
|
||||
const platformVersion = await getCapacitorPackageVersion(config, platform);
|
||||
if (semver.diff(coreVersion, platformVersion) === 'minor' ||
|
||||
semver.diff(coreVersion, platformVersion) === 'major') {
|
||||
if (semver.diff(coreVersion, platformVersion) === 'minor' || semver.diff(coreVersion, platformVersion) === 'major') {
|
||||
log_1.logger.warn(`${colors_1.default.strong('@capacitor/core')}${colors_1.default.weak(`@${coreVersion}`)} version doesn't match ${colors_1.default.strong(`@capacitor/${platform}`)}${colors_1.default.weak(`@${platformVersion}`)} version.\n` +
|
||||
`Consider updating to a matching version, e.g. w/ ${colors_1.default.input(`npm install @capacitor/core@${platformVersion}`)}`);
|
||||
}
|
||||
|
@ -386,9 +393,7 @@ async function checkJDKMajorVersion() {
|
|||
if (typeof firstVersionNumber === 'number' && firstVersionNumber != 1) {
|
||||
return firstVersionNumber;
|
||||
}
|
||||
else if (typeof secondVersionNumber === 'number' &&
|
||||
firstVersionNumber == 1 &&
|
||||
secondVersionNumber < 9) {
|
||||
else if (typeof secondVersionNumber === 'number' && firstVersionNumber == 1 && secondVersionNumber < 9) {
|
||||
return secondVersionNumber;
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue