Add dependency
Some checks failed
/ build_android (push) Failing after 21s

This commit is contained in:
Pieter Vander Vennet 2025-06-18 18:50:46 +02:00
parent 55470c090d
commit 6947a1adba
1260 changed files with 111297 additions and 0 deletions

25
@capacitor/cli/dist/util/cli.js vendored Normal file
View file

@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapAction = exports.ENV_PATHS = void 0;
const tslib_1 = require("tslib");
const env_paths_1 = tslib_1.__importDefault(require("env-paths"));
const errors_1 = require("../errors");
const log_1 = require("../log");
exports.ENV_PATHS = (0, env_paths_1.default)('capacitor', { suffix: '' });
function wrapAction(action) {
return async (...args) => {
try {
await action(...args);
}
catch (e) {
if ((0, errors_1.isFatal)(e)) {
process.exitCode = e.exitCode;
log_1.logger.error(e.message);
}
else {
throw e;
}
}
};
}
exports.wrapAction = wrapAction;

13
@capacitor/cli/dist/util/emoji.js vendored Normal file
View file

@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.emoji = void 0;
// Emoji falback, right now just uses fallback on windows,
// but could expand to be more sophisticated to allow emoji
// on Hyper term on windows, for example.
const emoji = (x, fallback) => {
if (process.platform === 'win32') {
return fallback;
}
return x;
};
exports.emoji = emoji;

13
@capacitor/cli/dist/util/fn.js vendored Normal file
View file

@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tryFn = void 0;
const tryFn = async (fn, ...args) => {
try {
return await fn(...args);
}
catch {
// ignore
}
return null;
};
exports.tryFn = tryFn;

24
@capacitor/cli/dist/util/fs.js vendored Normal file
View file

@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deleteFolderRecursive = exports.convertToUnixPath = void 0;
const utils_fs_1 = require("@ionic/utils-fs");
const path_1 = require("path");
const convertToUnixPath = (path) => {
return path.replace(/\\/g, '/');
};
exports.convertToUnixPath = convertToUnixPath;
const deleteFolderRecursive = (directoryPath) => {
if ((0, utils_fs_1.existsSync)(directoryPath)) {
(0, utils_fs_1.readdirSync)(directoryPath).forEach(file => {
const curPath = (0, path_1.join)(directoryPath, file);
if ((0, utils_fs_1.lstatSync)(curPath).isDirectory()) {
(0, exports.deleteFolderRecursive)(curPath);
}
else {
(0, utils_fs_1.unlinkSync)(curPath);
}
});
(0, utils_fs_1.rmdirSync)(directoryPath);
}
};
exports.deleteFolderRecursive = deleteFolderRecursive;

66
@capacitor/cli/dist/util/iosplugin.js vendored Normal file
View file

@ -0,0 +1,66 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateIOSPackageJSON = exports.writePluginJSON = exports.findPluginClasses = exports.getPluginFiles = void 0;
const utils_fs_1 = require("@ionic/utils-fs");
const path_1 = require("path");
const cordova_1 = require("../cordova");
const plugin_1 = require("../plugin");
async function getPluginFiles(plugins) {
var _a;
let filenameList = [];
const options = {
filter: item => {
if (item.stats.isFile() &&
(item.path.endsWith('.swift') || item.path.endsWith('.m'))) {
return true;
}
else {
return false;
}
},
};
for (const plugin of plugins) {
if (plugin.ios && (0, plugin_1.getPluginType)(plugin, 'ios') === 0 /* PluginType.Core */) {
const pluginPath = (0, path_1.resolve)(plugin.rootPath, (_a = plugin.ios) === null || _a === void 0 ? void 0 : _a.path);
const filenames = await (0, utils_fs_1.readdirp)(pluginPath, options);
filenameList = filenameList.concat(filenames);
}
}
return filenameList;
}
exports.getPluginFiles = getPluginFiles;
async function findPluginClasses(files) {
const classList = [];
for (const file of files) {
const fileData = (0, utils_fs_1.readFileSync)(file, 'utf-8');
const swiftPluginRegex = RegExp(/@objc\(([A-Za-z0-9_-]+)\)/);
const objcPluginRegex = RegExp(/CAP_PLUGIN\(([A-Za-z0-9_-]+)/);
const swiftMatches = swiftPluginRegex.exec(fileData);
if ((swiftMatches === null || swiftMatches === void 0 ? void 0 : swiftMatches[1]) && !classList.includes(swiftMatches[1])) {
classList.push(swiftMatches[1]);
}
const objcMatches = objcPluginRegex.exec(fileData);
if ((objcMatches === null || objcMatches === void 0 ? void 0 : objcMatches[1]) && !classList.includes(objcMatches[1])) {
classList.push(objcMatches[1]);
}
}
return classList;
}
exports.findPluginClasses = findPluginClasses;
async function writePluginJSON(config, classList) {
const capJSONFile = (0, path_1.resolve)(config.ios.nativeTargetDirAbs, 'capacitor.config.json');
const capJSON = (0, utils_fs_1.readJSONSync)(capJSONFile);
capJSON['packageClassList'] = classList;
(0, utils_fs_1.writeJSONSync)(capJSONFile, capJSON, { spaces: '\t' });
}
exports.writePluginJSON = writePluginJSON;
async function generateIOSPackageJSON(config, plugins) {
const fileList = await getPluginFiles(plugins);
const classList = await findPluginClasses(fileList);
const cordovaPlugins = await (0, cordova_1.getCordovaPlugins)(config, 'ios');
if (cordovaPlugins.length > 0) {
classList.push('CDVPlugin');
}
writePluginJSON(config, classList);
}
exports.generateIOSPackageJSON = generateIOSPackageJSON;

21
@capacitor/cli/dist/util/js.js vendored Normal file
View file

@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatJSObject = void 0;
const tslib_1 = require("tslib");
const util_1 = tslib_1.__importDefault(require("util"));
function formatJSObject(o) {
try {
o = JSON.parse(JSON.stringify(o));
}
catch (e) {
throw new Error(`Cannot parse object as JSON: ${e.stack ? e.stack : e}`);
}
return util_1.default.inspect(o, {
compact: false,
breakLength: Infinity,
depth: Infinity,
maxArrayLength: Infinity,
maxStringLength: Infinity,
});
}
exports.formatJSObject = formatJSObject;

151
@capacitor/cli/dist/util/livereload.js vendored Normal file
View file

@ -0,0 +1,151 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CapLiveReloadHelper = void 0;
const utils_fs_1 = require("@ionic/utils-fs");
const os_1 = require("os");
const path_1 = require("path");
class CapLiveReload {
constructor() {
this.configJsonToRevertTo = {
json: null,
platformPath: null,
};
// nothing to do
}
getIpAddress(name, family) {
var _a;
const interfaces = (_a = (0, os_1.networkInterfaces)()) !== null && _a !== void 0 ? _a : {};
const _normalizeFamily = (family) => {
if (family === 4) {
return 'ipv4';
}
if (family === 6) {
return 'ipv6';
}
return family ? family.toLowerCase() : 'ipv4';
};
const isLoopback = (addr) => {
return (/^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/.test(addr) ||
/^fe80::1$/.test(addr) ||
/^::1$/.test(addr) ||
/^::$/.test(addr));
};
const isPrivate = (addr) => {
return (/^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
/^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
/^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
/^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
/^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
/^f[cd][0-9a-f]{2}:/i.test(addr) ||
/^fe80:/i.test(addr) ||
/^::1$/.test(addr) ||
/^::$/.test(addr));
};
const isPublic = (addr) => {
return !isPrivate(addr);
};
const loopback = (family) => {
//
// Default to `ipv4`
//
family = _normalizeFamily(family);
if (family !== 'ipv4' && family !== 'ipv6') {
throw new Error('family must be ipv4 or ipv6');
}
return family === 'ipv4' ? '127.0.0.1' : 'fe80::1';
};
//
// Default to `ipv4`
//
family = _normalizeFamily(family);
//
// If a specific network interface has been named,
// return the address.
//
if (name && name !== 'private' && name !== 'public') {
const res = interfaces[name].filter((details) => {
const itemFamily = _normalizeFamily(details.family);
return itemFamily === family;
});
if (res.length === 0) {
return undefined;
}
return res[0].address;
}
const all = Object.keys(interfaces)
.map(nic => {
//
// Note: name will only be `public` or `private`
// when this is called.
//
const addresses = interfaces[nic].filter((details) => {
details.family = _normalizeFamily(details.family);
if (details.family !== family || isLoopback(details.address)) {
return false;
}
if (!name) {
return true;
}
return name === 'public'
? isPrivate(details.address)
: isPublic(details.address);
});
return addresses.length ? addresses[0].address : undefined;
})
.filter(Boolean);
return !all.length ? loopback(family) : all[0];
}
// TODO remove on next major as it's unused
async editExtConfigForLiveReload(config, platformName, options, rootConfigChange = false) {
const platformAbsPath = platformName == config.ios.name
? config.ios.nativeTargetDirAbs
: platformName == config.android.name
? config.android.assetsDirAbs
: null;
if (platformAbsPath == null)
throw new Error('Platform not found.');
const capConfigPath = rootConfigChange
? config.app.extConfigFilePath
: (0, path_1.join)(platformAbsPath, 'capacitor.config.json');
const configJson = { ...config.app.extConfig };
this.configJsonToRevertTo.json = JSON.stringify(configJson, null, 2);
this.configJsonToRevertTo.platformPath = capConfigPath;
const url = `http://${options.host}:${options.port}`;
configJson.server = {
url,
};
return configJson;
}
// TODO remove rootConfigChange param on next major as it's unused
async editCapConfigForLiveReload(config, platformName, options, rootConfigChange = false) {
const platformAbsPath = platformName == config.ios.name
? config.ios.nativeTargetDirAbs
: platformName == config.android.name
? config.android.assetsDirAbs
: null;
if (platformAbsPath == null)
throw new Error('Platform not found.');
const capConfigPath = rootConfigChange
? config.app.extConfigFilePath
: (0, path_1.join)(platformAbsPath, 'capacitor.config.json');
const configJson = (0, utils_fs_1.readJSONSync)(capConfigPath);
this.configJsonToRevertTo.json = JSON.stringify(configJson, null, 2);
this.configJsonToRevertTo.platformPath = capConfigPath;
const url = `http://${options.host}:${options.port}`;
configJson.server = {
url,
};
(0, utils_fs_1.writeJSONSync)(capConfigPath, configJson, { spaces: '\t' });
}
async revertCapConfigForLiveReload() {
if (this.configJsonToRevertTo.json == null ||
this.configJsonToRevertTo.platformPath == null)
return;
const capConfigPath = this.configJsonToRevertTo.platformPath;
const configJson = this.configJsonToRevertTo.json;
(0, utils_fs_1.writeJSONSync)(capConfigPath, JSON.parse(configJson), { spaces: '\t' });
this.configJsonToRevertTo.json = null;
this.configJsonToRevertTo.platformPath = null;
}
}
exports.CapLiveReloadHelper = new CapLiveReload();

View file

@ -0,0 +1,110 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isNXMonorepo = exports.isMonorepo = exports.findPackageRelativePathInMonorepo = exports.findPackagePath = exports.findNXMonorepoRoot = exports.findMonorepoRoot = void 0;
const node_fs_1 = require("node:fs");
const node_path_1 = require("node:path");
/**
* Finds the monorepo root from the given path.
* @param currentPath - The current path to start searching from.
* @returns The path to the monorepo root.
* @throws An error if the monorepo root is not found.
*/
function findMonorepoRoot(currentPath) {
const packageJsonPath = (0, node_path_1.join)(currentPath, 'package.json');
const pnpmWorkspacePath = (0, node_path_1.join)(currentPath, 'pnpm-workspace.yaml');
if ((0, node_fs_1.existsSync)(pnpmWorkspacePath) ||
((0, node_fs_1.existsSync)(packageJsonPath) &&
JSON.parse((0, node_fs_1.readFileSync)(packageJsonPath, 'utf-8')).workspaces)) {
return currentPath;
}
const parentPath = (0, node_path_1.dirname)(currentPath);
if (parentPath === currentPath) {
throw new Error('Monorepo root not found');
}
return findMonorepoRoot(parentPath);
}
exports.findMonorepoRoot = findMonorepoRoot;
/**
* Finds the NX monorepo root from the given path.
* @param currentPath - The current path to start searching from.
* @returns The path to the monorepo root.
* @throws An error if the monorepo root is not found.
*/
function findNXMonorepoRoot(currentPath) {
const nxJsonPath = (0, node_path_1.join)(currentPath, 'nx.json');
if ((0, node_fs_1.existsSync)(nxJsonPath)) {
return currentPath;
}
const parentPath = (0, node_path_1.dirname)(currentPath);
if (parentPath === currentPath) {
throw new Error('Monorepo root not found');
}
return findNXMonorepoRoot(parentPath);
}
exports.findNXMonorepoRoot = findNXMonorepoRoot;
/**
* Finds the path to a package within the node_modules folder,
* searching up the directory hierarchy until the last possible directory is reached.
* @param packageName - The name of the package to find.
* @param currentPath - The current path to start searching from.
* @param lastPossibleDirectory - The last possible directory to search for the package.
* @returns The path to the package, or null if not found.
*/
function findPackagePath(packageName, currentPath, lastPossibleDirectory) {
const nodeModulesPath = (0, node_path_1.join)(currentPath, 'node_modules', packageName);
if ((0, node_fs_1.existsSync)(nodeModulesPath)) {
return nodeModulesPath;
}
if (currentPath === lastPossibleDirectory) {
return null;
}
const parentPath = (0, node_path_1.dirname)(currentPath);
return findPackagePath(packageName, parentPath, lastPossibleDirectory);
}
exports.findPackagePath = findPackagePath;
/**
* Finds the relative path to a package from the current directory,
* using the monorepo root as the last possible directory.
* @param packageName - The name of the package to find.
* @param currentPath - The current path to start searching from.
* @returns The relative path to the package, or null if not found.
*/
function findPackageRelativePathInMonorepo(packageName, currentPath) {
const monorepoRoot = findMonorepoRoot(currentPath);
const packagePath = findPackagePath(packageName, currentPath, monorepoRoot);
if (packagePath) {
return (0, node_path_1.relative)(currentPath, packagePath);
}
return null;
}
exports.findPackageRelativePathInMonorepo = findPackageRelativePathInMonorepo;
/**
* Detects if the current directory is part of a monorepo (npm, yarn, pnpm).
* @param currentPath - The current path to start searching from.
* @returns True if the current directory is part of a monorepo, false otherwise.
*/
function isMonorepo(currentPath) {
try {
findMonorepoRoot(currentPath);
return true;
}
catch (error) {
return false;
}
}
exports.isMonorepo = isMonorepo;
/**
* Detects if the current directory is part of a nx integrated monorepo.
* @param currentPath - The current path to start searching from.
* @returns True if the current directory is part of a monorepo, false otherwise.
*/
function isNXMonorepo(currentPath) {
try {
findNXMonorepoRoot(currentPath);
return true;
}
catch (error) {
return false;
}
}
exports.isNXMonorepo = isNXMonorepo;

53
@capacitor/cli/dist/util/native-run.js vendored Normal file
View file

@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPlatformTargets = exports.runNativeRun = void 0;
const tslib_1 = require("tslib");
const path_1 = require("path");
const colors_1 = tslib_1.__importDefault(require("../colors"));
const errors_1 = require("../errors");
const node_1 = require("./node");
const subprocess_1 = require("./subprocess");
async function runNativeRun(args, options = {}) {
const p = (0, node_1.resolveNode)(__dirname, (0, path_1.dirname)('native-run/package'), 'bin/native-run');
if (!p) {
(0, errors_1.fatal)(`${colors_1.default.input('native-run')} not found.`);
}
return await (0, subprocess_1.runCommand)(p, args, options);
}
exports.runNativeRun = runNativeRun;
async function getPlatformTargets(platformName) {
const errors = [];
try {
const output = await runNativeRun([platformName, '--list', '--json']);
const parsedOutput = JSON.parse(output);
if (parsedOutput.devices.length || parsedOutput.virtualDevices.length) {
return [
...parsedOutput.devices.map((t) => ({ ...t, virtual: false })),
...parsedOutput.virtualDevices.map((t) => ({
...t,
virtual: true,
})),
];
}
else {
parsedOutput.errors.map((e) => {
errors.push(e);
});
}
}
catch (e) {
const err = JSON.parse(e);
errors.push(err);
}
const plural = errors.length > 1 ? 's' : '';
const errMsg = `${colors_1.default.strong('native-run')} failed with error${plural}\n
${errors
.map((e) => {
return `\t${colors_1.default.strong(e.code)}: ${e.error}`;
})
.join('\n')}
\n\tMore details for this error${plural} may be available online: ${colors_1.default.strong('https://github.com/ionic-team/native-run/wiki/Android-Errors')}
`;
throw errMsg;
}
exports.getPlatformTargets = getPlatformTargets;

54
@capacitor/cli/dist/util/node.js vendored Normal file
View file

@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveNode = exports.requireTS = void 0;
const utils_fs_1 = require("@ionic/utils-fs");
const fs_1 = require("fs");
const path_1 = require("path");
/**
* @see https://github.com/ionic-team/stencil/blob/HEAD/src/compiler/sys/node-require.ts
*/
const requireTS = (ts, p) => {
const id = (0, path_1.resolve)(p);
delete require.cache[id];
require.extensions['.ts'] = (module, fileName) => {
var _a;
let sourceText = (0, utils_fs_1.readFileSync)(fileName, 'utf8');
if (fileName.endsWith('.ts')) {
const tsResults = ts.transpileModule(sourceText, {
fileName,
compilerOptions: {
module: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
esModuleInterop: true,
strict: true,
target: ts.ScriptTarget.ES2017,
},
reportDiagnostics: true,
});
sourceText = tsResults.outputText;
}
else {
// quick hack to turn a modern es module
// into and old school commonjs module
sourceText = sourceText.replace(/export\s+\w+\s+(\w+)/gm, 'exports.$1');
}
(_a = module._compile) === null || _a === void 0 ? void 0 : _a.call(module, sourceText, fileName);
};
const m = require(id); // eslint-disable-line @typescript-eslint/no-var-requires
delete require.extensions['.ts'];
return m;
};
exports.requireTS = requireTS;
function resolveNode(root, ...pathSegments) {
try {
return require.resolve(pathSegments.join('/'), { paths: [root] });
}
catch (e) {
const path = [root, 'node_modules', ...pathSegments].join('/');
if ((0, fs_1.existsSync)(path)) {
return path;
}
return null;
}
}
exports.resolveNode = resolveNode;

35
@capacitor/cli/dist/util/promise.js vendored Normal file
View file

@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.lazy = exports.LazyPromise = exports.allSerial = void 0;
function allSerial(funcs) {
return funcs.reduce((promise, func) => promise.then(result => func().then(x => result.concat(x))), Promise.resolve([]));
}
exports.allSerial = allSerial;
class LazyPromise extends Promise {
constructor(executor) {
super(() => {
/* ignore */
});
this._executor = executor;
}
then(onfulfilled, onrejected) {
this._promise = this._promise || new Promise(this._executor);
return this._promise.then(onfulfilled, onrejected);
}
catch(onrejected) {
this._promise = this._promise || new Promise(this._executor);
return this._promise.catch(onrejected);
}
}
exports.LazyPromise = LazyPromise;
function lazy(fn) {
return new LazyPromise(async (resolve, reject) => {
try {
resolve(await fn());
}
catch (e) {
reject(e);
}
});
}
exports.lazy = lazy;

73
@capacitor/cli/dist/util/spm.js vendored Normal file
View file

@ -0,0 +1,73 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generatePackageFile = exports.findPackageSwiftFile = exports.checkPackageManager = void 0;
const utils_fs_1 = require("@ionic/utils-fs");
const path_1 = require("path");
const log_1 = require("../log");
async function checkPackageManager(config) {
const iosDirectory = config.ios.nativeProjectDirAbs;
if ((0, utils_fs_1.existsSync)((0, path_1.resolve)(iosDirectory, 'CapApp-SPM'))) {
return 'SPM';
}
return 'Cocoapods';
}
exports.checkPackageManager = checkPackageManager;
async function findPackageSwiftFile(config) {
const packageDirectory = (0, path_1.resolve)(config.ios.nativeProjectDirAbs, 'CapApp-SPM');
return (0, path_1.resolve)(packageDirectory, 'Package.swift');
}
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);
}
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) {
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);
let packageSwiftText = `// swift-tools-version: 5.9
import PackageDescription
// DO NOT MODIFY THIS FILE - managed by Capacitor CLI commands
let package = Package(
name: "CapApp-SPM",
platforms: [.iOS(.v${iosVersion})],
products: [
.library(
name: "CapApp-SPM",
targets: ["CapApp-SPM"])
],
dependencies: [
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", branch: "main")`;
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}")`;
}
packageSwiftText += `
],
targets: [
.target(
name: "CapApp-SPM",
dependencies: [
.product(name: "Capacitor", package: "capacitor-swift-pm"),
.product(name: "Cordova", package: "capacitor-swift-pm")`;
for (const plugin of plugins) {
packageSwiftText += `,\n .product(name: "${(_b = plugin.ios) === null || _b === void 0 ? void 0 : _b.name}", package: "${(_c = plugin.ios) === null || _c === void 0 ? void 0 : _c.name}")`;
}
packageSwiftText += `
]
)
]
)
`;
return packageSwiftText;
}

43
@capacitor/cli/dist/util/subprocess.js vendored Normal file
View file

@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isInstalled = exports.getCommandOutput = exports.runCommand = void 0;
const utils_subprocess_1 = require("@ionic/utils-subprocess");
async function runCommand(command, args, options = {}) {
const p = new utils_subprocess_1.Subprocess(command, args, options);
try {
return await p.output();
}
catch (e) {
if (e instanceof utils_subprocess_1.SubprocessError) {
// old behavior of just throwing the stdout/stderr strings
throw e.output
? e.output
: e.code
? e.code
: e.error
? e.error.message
: 'Unknown error';
}
throw e;
}
}
exports.runCommand = runCommand;
async function getCommandOutput(command, args, options = {}) {
try {
return (await runCommand(command, args, options)).trim();
}
catch (e) {
return null;
}
}
exports.getCommandOutput = getCommandOutput;
async function isInstalled(command) {
try {
await (0, utils_subprocess_1.which)(command);
}
catch (e) {
return false;
}
return true;
}
exports.isInstalled = isInstalled;

11
@capacitor/cli/dist/util/template.js vendored Normal file
View file

@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractTemplate = void 0;
const tslib_1 = require("tslib");
const utils_fs_1 = require("@ionic/utils-fs");
const tar_1 = tslib_1.__importDefault(require("tar"));
async function extractTemplate(src, dir) {
await (0, utils_fs_1.mkdirp)(dir);
await tar_1.default.extract({ file: src, cwd: dir });
}
exports.extractTemplate = extractTemplate;

30
@capacitor/cli/dist/util/term.js vendored Normal file
View file

@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isInteractive = exports.checkInteractive = void 0;
const tslib_1 = require("tslib");
const utils_terminal_1 = require("@ionic/utils-terminal");
const colors_1 = tslib_1.__importDefault(require("../colors"));
const log_1 = require("../log");
// Given input variables to a command, make sure all are provided if the terminal
// is not interactive (because we won't be able to prompt the user)
const checkInteractive = (...args) => {
if ((0, exports.isInteractive)()) {
return true;
}
// Fail if no args are provided, treat this as just a check of whether the term is
// interactive or not.
if (!args.length) {
return false;
}
// Make sure none of the provided args are empty, otherwise print the interactive
// warning and return false
if (args.filter(arg => !arg).length) {
log_1.logger.error(`Non-interactive shell detected.\n` +
`Run the command with ${colors_1.default.input('--help')} to see a list of arguments that must be provided.`);
return false;
}
return true;
};
exports.checkInteractive = checkInteractive;
const isInteractive = () => utils_terminal_1.TERMINAL_INFO.tty && !utils_terminal_1.TERMINAL_INFO.ci;
exports.isInteractive = isInteractive;

11
@capacitor/cli/dist/util/uuid.js vendored Normal file
View file

@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.uuidv4 = void 0;
function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
const r = (Math.random() * 16) | 0;
const v = c == 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
}
exports.uuidv4 = uuidv4;

57
@capacitor/cli/dist/util/xml.js vendored Normal file
View file

@ -0,0 +1,57 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildXmlElement = exports.writeXML = exports.parseXML = exports.readXML = void 0;
const tslib_1 = require("tslib");
const utils_fs_1 = require("@ionic/utils-fs");
const xml2js_1 = tslib_1.__importDefault(require("xml2js"));
async function readXML(path) {
var _a;
try {
const xmlStr = await (0, utils_fs_1.readFile)(path, { encoding: 'utf-8' });
try {
return await xml2js_1.default.parseStringPromise(xmlStr);
}
catch (e) {
throw `Error parsing: ${path}, ${(_a = e.stack) !== null && _a !== void 0 ? _a : e}`;
}
}
catch (e) {
throw `Unable to read: ${path}`;
}
}
exports.readXML = readXML;
function parseXML(xmlStr, options) {
const parser = options !== undefined
? new xml2js_1.default.Parser({ ...options })
: new xml2js_1.default.Parser();
let xmlObj;
parser.parseString(xmlStr, (err, result) => {
if (!err) {
xmlObj = result;
}
});
return xmlObj;
}
exports.parseXML = parseXML;
async function writeXML(object) {
return new Promise(resolve => {
const builder = new xml2js_1.default.Builder({
headless: true,
explicitRoot: false,
rootName: 'deleteme',
});
let xml = builder.buildObject(object);
xml = xml.replace('<deleteme>', '').replace('</deleteme>', '');
resolve(xml);
});
}
exports.writeXML = writeXML;
function buildXmlElement(configElement, rootName) {
const builder = new xml2js_1.default.Builder({
headless: true,
explicitRoot: false,
rootName: rootName,
});
return builder.buildObject(configElement);
}
exports.buildXmlElement = buildXmlElement;