@capacitor/cli 4.7.3 → 5.0.0-alpha.2
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-template.tar.gz +0 -0
- package/dist/android/add.js +6 -6
- package/dist/android/build.js +12 -9
- package/dist/android/common.js +27 -29
- package/dist/android/doctor.js +24 -24
- package/dist/android/open.js +3 -3
- package/dist/android/run.js +9 -6
- package/dist/android/update.js +53 -53
- package/dist/common.js +23 -23
- package/dist/config.js +67 -61
- package/dist/cordova.js +75 -75
- package/dist/declarations.d.ts +17 -1
- package/dist/index.js +32 -29
- package/dist/ios/add.js +2 -2
- package/dist/ios/build.js +9 -9
- package/dist/ios/common.js +12 -12
- package/dist/ios/doctor.js +6 -6
- package/dist/ios/open.js +2 -2
- package/dist/ios/run.js +7 -7
- package/dist/ios/update.js +58 -62
- package/dist/ipc.js +6 -6
- package/dist/log.js +2 -2
- package/dist/plugin.js +11 -11
- package/dist/sysconfig.js +6 -6
- package/dist/tasks/add.js +27 -27
- package/dist/tasks/build.js +7 -6
- package/dist/tasks/copy.js +42 -42
- package/dist/tasks/create.js +1 -1
- package/dist/tasks/doctor.js +10 -10
- package/dist/tasks/init.js +30 -27
- package/dist/tasks/list.js +12 -12
- package/dist/tasks/migrate.js +189 -407
- package/dist/tasks/new-plugin.js +1 -1
- package/dist/tasks/open.js +10 -10
- package/dist/tasks/run.js +13 -13
- package/dist/tasks/serve.js +1 -1
- package/dist/tasks/sourcemaps.js +9 -9
- package/dist/tasks/sync.js +15 -15
- package/dist/tasks/telemetry.js +4 -4
- package/dist/tasks/update.js +14 -14
- package/dist/telemetry.js +8 -8
- package/dist/util/cli.js +2 -2
- package/dist/util/fs.js +7 -7
- package/dist/util/native-run.js +3 -3
- package/dist/util/node.js +2 -2
- package/dist/util/subprocess.js +1 -1
- package/dist/util/template.js +1 -1
- package/dist/util/term.js +1 -1
- package/dist/util/xml.js +1 -1
- package/dist/web/copy.js +4 -4
- package/package.json +12 -11
- package/CHANGELOG.md +0 -805
package/dist/android/update.js
CHANGED
|
@@ -16,28 +16,28 @@ const node_1 = require("../util/node");
|
|
|
16
16
|
const template_1 = require("../util/template");
|
|
17
17
|
const common_2 = require("./common");
|
|
18
18
|
const platform = 'android';
|
|
19
|
-
const debug = debug_1.default('capacitor:android:update');
|
|
19
|
+
const debug = (0, debug_1.default)('capacitor:android:update');
|
|
20
20
|
async function updateAndroid(config) {
|
|
21
21
|
const plugins = await getPluginsTask(config);
|
|
22
|
-
const capacitorPlugins = plugins.filter(p => plugin_1.getPluginType(p, platform) === 0 /* Core */);
|
|
23
|
-
plugin_1.printPlugins(capacitorPlugins, 'android');
|
|
22
|
+
const capacitorPlugins = plugins.filter(p => (0, plugin_1.getPluginType)(p, platform) === 0 /* PluginType.Core */);
|
|
23
|
+
(0, plugin_1.printPlugins)(capacitorPlugins, 'android');
|
|
24
24
|
await writePluginsJson(config, capacitorPlugins);
|
|
25
25
|
await removePluginsNativeFiles(config);
|
|
26
|
-
const cordovaPlugins = plugins.filter(p => plugin_1.getPluginType(p, platform) === 1 /* Cordova */);
|
|
26
|
+
const cordovaPlugins = plugins.filter(p => (0, plugin_1.getPluginType)(p, platform) === 1 /* PluginType.Cordova */);
|
|
27
27
|
if (cordovaPlugins.length > 0) {
|
|
28
28
|
await copyPluginsNativeFiles(config, cordovaPlugins);
|
|
29
29
|
}
|
|
30
|
-
if (!(await utils_fs_1.pathExists(config.android.webDirAbs))) {
|
|
31
|
-
await copy_1.copy(config, platform);
|
|
30
|
+
if (!(await (0, utils_fs_1.pathExists)(config.android.webDirAbs))) {
|
|
31
|
+
await (0, copy_1.copy)(config, platform);
|
|
32
32
|
}
|
|
33
|
-
await cordova_1.handleCordovaPluginsJS(cordovaPlugins, config, platform);
|
|
34
|
-
await cordova_1.checkPluginDependencies(plugins, platform);
|
|
33
|
+
await (0, cordova_1.handleCordovaPluginsJS)(cordovaPlugins, config, platform);
|
|
34
|
+
await (0, cordova_1.checkPluginDependencies)(plugins, platform);
|
|
35
35
|
await installGradlePlugins(config, capacitorPlugins, cordovaPlugins);
|
|
36
36
|
await handleCordovaPluginsGradle(config, cordovaPlugins);
|
|
37
|
-
await cordova_1.writeCordovaAndroidManifest(cordovaPlugins, config, platform);
|
|
38
|
-
const incompatibleCordovaPlugins = plugins.filter(p => plugin_1.getPluginType(p, platform) === 2 /* Incompatible */);
|
|
39
|
-
plugin_1.printPlugins(incompatibleCordovaPlugins, platform, 'incompatible');
|
|
40
|
-
await common_1.checkPlatformVersions(config, platform);
|
|
37
|
+
await (0, cordova_1.writeCordovaAndroidManifest)(cordovaPlugins, config, platform);
|
|
38
|
+
const incompatibleCordovaPlugins = plugins.filter(p => (0, plugin_1.getPluginType)(p, platform) === 2 /* PluginType.Incompatible */);
|
|
39
|
+
(0, plugin_1.printPlugins)(incompatibleCordovaPlugins, platform, 'incompatible');
|
|
40
|
+
await (0, common_1.checkPlatformVersions)(config, platform);
|
|
41
41
|
}
|
|
42
42
|
exports.updateAndroid = updateAndroid;
|
|
43
43
|
function getGradlePackageName(id) {
|
|
@@ -45,8 +45,8 @@ function getGradlePackageName(id) {
|
|
|
45
45
|
}
|
|
46
46
|
async function writePluginsJson(config, plugins) {
|
|
47
47
|
const classes = await findAndroidPluginClasses(plugins);
|
|
48
|
-
const pluginsJsonPath = path_1.resolve(config.android.assetsDirAbs, 'capacitor.plugins.json');
|
|
49
|
-
await utils_fs_1.writeJSON(pluginsJsonPath, classes, { spaces: '\t' });
|
|
48
|
+
const pluginsJsonPath = (0, path_1.resolve)(config.android.assetsDirAbs, 'capacitor.plugins.json');
|
|
49
|
+
await (0, utils_fs_1.writeJSON)(pluginsJsonPath, classes, { spaces: '\t' });
|
|
50
50
|
}
|
|
51
51
|
async function findAndroidPluginClasses(plugins) {
|
|
52
52
|
const entries = [];
|
|
@@ -56,19 +56,19 @@ async function findAndroidPluginClasses(plugins) {
|
|
|
56
56
|
return entries;
|
|
57
57
|
}
|
|
58
58
|
async function findAndroidPluginClassesInPlugin(plugin) {
|
|
59
|
-
if (!plugin.android || plugin_1.getPluginType(plugin, platform) !== 0 /* Core */) {
|
|
59
|
+
if (!plugin.android || (0, plugin_1.getPluginType)(plugin, platform) !== 0 /* PluginType.Core */) {
|
|
60
60
|
return [];
|
|
61
61
|
}
|
|
62
|
-
const srcPath = path_1.resolve(plugin.rootPath, plugin.android.path, 'src/main');
|
|
63
|
-
const srcFiles = await utils_fs_1.readdirp(srcPath, {
|
|
62
|
+
const srcPath = (0, path_1.resolve)(plugin.rootPath, plugin.android.path, 'src/main');
|
|
63
|
+
const srcFiles = await (0, utils_fs_1.readdirp)(srcPath, {
|
|
64
64
|
filter: entry => !entry.stats.isDirectory() &&
|
|
65
|
-
['.java', '.kt'].includes(path_1.extname(entry.path)),
|
|
65
|
+
['.java', '.kt'].includes((0, path_1.extname)(entry.path)),
|
|
66
66
|
});
|
|
67
67
|
const classRegex = /^@(?:CapacitorPlugin|NativePlugin)[\s\S]+?class ([\w]+)/gm;
|
|
68
68
|
const packageRegex = /^package ([\w.]+);?$/gm;
|
|
69
69
|
debug('Searching %O source files in %O by %O regex', srcFiles.length, srcPath, classRegex);
|
|
70
70
|
const entries = await Promise.all(srcFiles.map(async (srcFile) => {
|
|
71
|
-
const srcFileContents = await utils_fs_1.readFile(srcFile, { encoding: 'utf-8' });
|
|
71
|
+
const srcFileContents = await (0, utils_fs_1.readFile)(srcFile, { encoding: 'utf-8' });
|
|
72
72
|
classRegex.lastIndex = 0;
|
|
73
73
|
const classMatch = classRegex.exec(srcFileContents);
|
|
74
74
|
if (classMatch) {
|
|
@@ -77,7 +77,7 @@ async function findAndroidPluginClassesInPlugin(plugin) {
|
|
|
77
77
|
packageRegex.lastIndex = 0;
|
|
78
78
|
const packageMatch = packageRegex.exec(srcFileContents.substring(0, classMatch.index));
|
|
79
79
|
if (!packageMatch) {
|
|
80
|
-
errors_1.fatal(`Package could not be parsed from Android plugin.\n` +
|
|
80
|
+
(0, errors_1.fatal)(`Package could not be parsed from Android plugin.\n` +
|
|
81
81
|
`Location: ${colors_1.default.strong(srcFile)}`);
|
|
82
82
|
}
|
|
83
83
|
const packageName = packageMatch[1];
|
|
@@ -92,15 +92,15 @@ async function findAndroidPluginClassesInPlugin(plugin) {
|
|
|
92
92
|
return entries.filter((entry) => !!entry);
|
|
93
93
|
}
|
|
94
94
|
async function installGradlePlugins(config, capacitorPlugins, cordovaPlugins) {
|
|
95
|
-
const capacitorAndroidPackagePath = node_1.resolveNode(config.app.rootDir, '@capacitor/android', 'package.json');
|
|
95
|
+
const capacitorAndroidPackagePath = (0, node_1.resolveNode)(config.app.rootDir, '@capacitor/android', 'package.json');
|
|
96
96
|
if (!capacitorAndroidPackagePath) {
|
|
97
|
-
errors_1.fatal(`Unable to find ${colors_1.default.strong('node_modules/@capacitor/android')}.\n` +
|
|
97
|
+
(0, errors_1.fatal)(`Unable to find ${colors_1.default.strong('node_modules/@capacitor/android')}.\n` +
|
|
98
98
|
`Are you sure ${colors_1.default.strong('@capacitor/android')} is installed?`);
|
|
99
99
|
}
|
|
100
|
-
const capacitorAndroidPath = path_1.resolve(path_1.dirname(capacitorAndroidPackagePath), 'capacitor');
|
|
100
|
+
const capacitorAndroidPath = (0, path_1.resolve)((0, path_1.dirname)(capacitorAndroidPackagePath), 'capacitor');
|
|
101
101
|
const settingsPath = config.android.platformDirAbs;
|
|
102
102
|
const dependencyPath = config.android.appDirAbs;
|
|
103
|
-
const relativeCapcitorAndroidPath = fs_1.convertToUnixPath(path_1.relative(settingsPath, capacitorAndroidPath));
|
|
103
|
+
const relativeCapcitorAndroidPath = (0, fs_1.convertToUnixPath)((0, path_1.relative)(settingsPath, capacitorAndroidPath));
|
|
104
104
|
const settingsLines = `// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
|
105
105
|
include ':capacitor-android'
|
|
106
106
|
project(':capacitor-android').projectDir = new File('${relativeCapcitorAndroidPath}')
|
|
@@ -109,7 +109,7 @@ ${capacitorPlugins
|
|
|
109
109
|
if (!p.android) {
|
|
110
110
|
return '';
|
|
111
111
|
}
|
|
112
|
-
const relativePluginPath = fs_1.convertToUnixPath(path_1.relative(settingsPath, p.rootPath));
|
|
112
|
+
const relativePluginPath = (0, fs_1.convertToUnixPath)((0, path_1.relative)(settingsPath, p.rootPath));
|
|
113
113
|
return `
|
|
114
114
|
include ':${getGradlePackageName(p.id)}'
|
|
115
115
|
project(':${getGradlePackageName(p.id)}').projectDir = new File('${relativePluginPath}/${p.android.path}')
|
|
@@ -120,8 +120,8 @@ project(':${getGradlePackageName(p.id)}').projectDir = new File('${relativePlugi
|
|
|
120
120
|
const frameworksArray = [];
|
|
121
121
|
let prefsArray = [];
|
|
122
122
|
cordovaPlugins.map(p => {
|
|
123
|
-
const relativePluginPath = fs_1.convertToUnixPath(path_1.relative(dependencyPath, p.rootPath));
|
|
124
|
-
const frameworks = plugin_1.getPlatformElement(p, platform, 'framework');
|
|
123
|
+
const relativePluginPath = (0, fs_1.convertToUnixPath)((0, path_1.relative)(dependencyPath, p.rootPath));
|
|
124
|
+
const frameworks = (0, plugin_1.getPlatformElement)(p, platform, 'framework');
|
|
125
125
|
frameworks.map((framework) => {
|
|
126
126
|
if (framework.$.custom &&
|
|
127
127
|
framework.$.custom === 'true' &&
|
|
@@ -138,7 +138,7 @@ project(':${getGradlePackageName(p.id)}').projectDir = new File('${relativePlugi
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
});
|
|
141
|
-
prefsArray = prefsArray.concat(plugin_1.getAllElements(p, platform, 'preference'));
|
|
141
|
+
prefsArray = prefsArray.concat((0, plugin_1.getAllElements)(p, platform, 'preference'));
|
|
142
142
|
});
|
|
143
143
|
let frameworkString = frameworksArray.join('\n');
|
|
144
144
|
frameworkString = await replaceFrameworkVariables(config, prefsArray, frameworkString);
|
|
@@ -166,13 +166,13 @@ if (hasProperty('postBuildExtras')) {
|
|
|
166
166
|
postBuildExtras()
|
|
167
167
|
}
|
|
168
168
|
`;
|
|
169
|
-
await utils_fs_1.writeFile(path_1.join(settingsPath, 'capacitor.settings.gradle'), settingsLines);
|
|
170
|
-
await utils_fs_1.writeFile(path_1.join(dependencyPath, 'capacitor.build.gradle'), dependencyLines);
|
|
169
|
+
await (0, utils_fs_1.writeFile)((0, path_1.join)(settingsPath, 'capacitor.settings.gradle'), settingsLines);
|
|
170
|
+
await (0, utils_fs_1.writeFile)((0, path_1.join)(dependencyPath, 'capacitor.build.gradle'), dependencyLines);
|
|
171
171
|
}
|
|
172
172
|
exports.installGradlePlugins = installGradlePlugins;
|
|
173
173
|
async function handleCordovaPluginsGradle(config, cordovaPlugins) {
|
|
174
174
|
var _a, _b, _c;
|
|
175
|
-
const pluginsGradlePath = path_1.join(config.android.cordovaPluginsDirAbs, 'build.gradle');
|
|
175
|
+
const pluginsGradlePath = (0, path_1.join)(config.android.cordovaPluginsDirAbs, 'build.gradle');
|
|
176
176
|
const kotlinNeeded = await kotlinNeededCheck(config, cordovaPlugins);
|
|
177
177
|
const kotlinVersionString = (_c = (_b = (_a = config.app.extConfig.cordova) === null || _a === void 0 ? void 0 : _a.preferences) === null || _b === void 0 ? void 0 : _b.GradlePluginKotlinVersion) !== null && _c !== void 0 ? _c : '1.7.0';
|
|
178
178
|
const frameworksArray = [];
|
|
@@ -180,8 +180,8 @@ async function handleCordovaPluginsGradle(config, cordovaPlugins) {
|
|
|
180
180
|
const applyArray = [];
|
|
181
181
|
applyArray.push(`apply from: "cordova.variables.gradle"`);
|
|
182
182
|
cordovaPlugins.map(p => {
|
|
183
|
-
const relativePluginPath = fs_1.convertToUnixPath(path_1.relative(config.android.cordovaPluginsDirAbs, p.rootPath));
|
|
184
|
-
const frameworks = plugin_1.getPlatformElement(p, platform, 'framework');
|
|
183
|
+
const relativePluginPath = (0, fs_1.convertToUnixPath)((0, path_1.relative)(config.android.cordovaPluginsDirAbs, p.rootPath));
|
|
184
|
+
const frameworks = (0, plugin_1.getPlatformElement)(p, platform, 'framework');
|
|
185
185
|
frameworks.map((framework) => {
|
|
186
186
|
if (!framework.$.type && !framework.$.custom) {
|
|
187
187
|
frameworksArray.push(framework.$.src);
|
|
@@ -193,7 +193,7 @@ async function handleCordovaPluginsGradle(config, cordovaPlugins) {
|
|
|
193
193
|
applyArray.push(`apply from: "${relativePluginPath}/${framework.$.src}"`);
|
|
194
194
|
}
|
|
195
195
|
});
|
|
196
|
-
prefsArray = prefsArray.concat(plugin_1.getAllElements(p, platform, 'preference'));
|
|
196
|
+
prefsArray = prefsArray.concat((0, plugin_1.getAllElements)(p, platform, 'preference'));
|
|
197
197
|
});
|
|
198
198
|
let frameworkString = frameworksArray
|
|
199
199
|
.map(f => {
|
|
@@ -211,7 +211,7 @@ async function handleCordovaPluginsGradle(config, cordovaPlugins) {
|
|
|
211
211
|
frameworkString += `\n implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"`;
|
|
212
212
|
}
|
|
213
213
|
const applyString = applyArray.join('\n');
|
|
214
|
-
let buildGradle = await utils_fs_1.readFile(pluginsGradlePath, { encoding: 'utf-8' });
|
|
214
|
+
let buildGradle = await (0, utils_fs_1.readFile)(pluginsGradlePath, { encoding: 'utf-8' });
|
|
215
215
|
buildGradle = buildGradle.replace(/(SUB-PROJECT DEPENDENCIES START)[\s\S]*(\/\/ SUB-PROJECT DEPENDENCIES END)/, '$1\n' + frameworkString.concat('\n') + ' $2');
|
|
216
216
|
buildGradle = buildGradle.replace(/(PLUGIN GRADLE EXTENSIONS START)[\s\S]*(\/\/ PLUGIN GRADLE EXTENSIONS END)/, '$1\n' + applyString.concat('\n') + '$2');
|
|
217
217
|
if (kotlinNeeded) {
|
|
@@ -221,7 +221,7 @@ async function handleCordovaPluginsGradle(config, cordovaPlugins) {
|
|
|
221
221
|
buildGradle = buildGradle.replace(/(apply\splugin:\s'com\.android\.library')/, `$1\napply plugin: 'kotlin-android'`);
|
|
222
222
|
buildGradle = buildGradle.replace(/(compileOptions\s{\n((\t{2}|\s{8}).+\n)+(\t|\s{4})})\n(})/, `$1\n sourceSets {\n main.java.srcDirs += 'src/main/kotlin'\n }\n$5`);
|
|
223
223
|
}
|
|
224
|
-
await utils_fs_1.writeFile(pluginsGradlePath, buildGradle);
|
|
224
|
+
await (0, utils_fs_1.writeFile)(pluginsGradlePath, buildGradle);
|
|
225
225
|
const cordovaVariables = `// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
|
226
226
|
ext {
|
|
227
227
|
cdvMinSdkVersion = project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : ${config.android.minVersion}
|
|
@@ -229,7 +229,7 @@ ext {
|
|
|
229
229
|
cdvPluginPostBuildExtras = []
|
|
230
230
|
cordovaConfig = [:]
|
|
231
231
|
}`;
|
|
232
|
-
await utils_fs_1.writeFile(path_1.join(config.android.cordovaPluginsDirAbs, 'cordova.variables.gradle'), cordovaVariables);
|
|
232
|
+
await (0, utils_fs_1.writeFile)((0, path_1.join)(config.android.cordovaPluginsDirAbs, 'cordova.variables.gradle'), cordovaVariables);
|
|
233
233
|
}
|
|
234
234
|
exports.handleCordovaPluginsGradle = handleCordovaPluginsGradle;
|
|
235
235
|
async function kotlinNeededCheck(config, cordovaPlugins) {
|
|
@@ -237,7 +237,7 @@ async function kotlinNeededCheck(config, cordovaPlugins) {
|
|
|
237
237
|
if (((_b = (_a = config.app.extConfig.cordova) === null || _a === void 0 ? void 0 : _a.preferences) === null || _b === void 0 ? void 0 : _b.GradlePluginKotlinEnabled) !==
|
|
238
238
|
'true') {
|
|
239
239
|
for (const plugin of cordovaPlugins) {
|
|
240
|
-
const androidPlatform = plugin_1.getPluginPlatform(plugin, platform);
|
|
240
|
+
const androidPlatform = (0, plugin_1.getPluginPlatform)(plugin, platform);
|
|
241
241
|
const sourceFiles = androidPlatform['source-file'];
|
|
242
242
|
if (sourceFiles) {
|
|
243
243
|
for (const srcFile of sourceFiles) {
|
|
@@ -254,9 +254,9 @@ async function kotlinNeededCheck(config, cordovaPlugins) {
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
async function copyPluginsNativeFiles(config, cordovaPlugins) {
|
|
257
|
-
const pluginsPath = path_1.join(config.android.cordovaPluginsDirAbs, 'src', 'main');
|
|
257
|
+
const pluginsPath = (0, path_1.join)(config.android.cordovaPluginsDirAbs, 'src', 'main');
|
|
258
258
|
for (const p of cordovaPlugins) {
|
|
259
|
-
const androidPlatform = plugin_1.getPluginPlatform(p, platform);
|
|
259
|
+
const androidPlatform = (0, plugin_1.getPluginPlatform)(p, platform);
|
|
260
260
|
if (androidPlatform) {
|
|
261
261
|
const sourceFiles = androidPlatform['source-file'];
|
|
262
262
|
if (sourceFiles) {
|
|
@@ -269,7 +269,7 @@ async function copyPluginsNativeFiles(config, cordovaPlugins) {
|
|
|
269
269
|
const target = sourceFile.$['target-dir']
|
|
270
270
|
.replace('app/src/main/', '')
|
|
271
271
|
.replace('src/', baseFolder);
|
|
272
|
-
await utils_fs_1.copy(plugin_1.getFilePath(config, p, sourceFile.$.src), path_1.join(pluginsPath, target, fileName));
|
|
272
|
+
await (0, utils_fs_1.copy)((0, plugin_1.getFilePath)(config, p, sourceFile.$.src), (0, path_1.join)(pluginsPath, target, fileName));
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
const resourceFiles = androidPlatform['resource-file'];
|
|
@@ -277,36 +277,36 @@ async function copyPluginsNativeFiles(config, cordovaPlugins) {
|
|
|
277
277
|
for (const resourceFile of resourceFiles) {
|
|
278
278
|
const target = resourceFile.$['target'];
|
|
279
279
|
if (resourceFile.$.src.split('.').pop() === 'aar') {
|
|
280
|
-
await utils_fs_1.copy(plugin_1.getFilePath(config, p, resourceFile.$.src), path_1.join(pluginsPath, 'libs', target.split('/').pop()));
|
|
280
|
+
await (0, utils_fs_1.copy)((0, plugin_1.getFilePath)(config, p, resourceFile.$.src), (0, path_1.join)(pluginsPath, 'libs', target.split('/').pop()));
|
|
281
281
|
}
|
|
282
282
|
else if (target !== '.') {
|
|
283
|
-
await utils_fs_1.copy(plugin_1.getFilePath(config, p, resourceFile.$.src), path_1.join(pluginsPath, target));
|
|
283
|
+
await (0, utils_fs_1.copy)((0, plugin_1.getFilePath)(config, p, resourceFile.$.src), (0, path_1.join)(pluginsPath, target));
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
const libFiles = plugin_1.getPlatformElement(p, platform, 'lib-file');
|
|
287
|
+
const libFiles = (0, plugin_1.getPlatformElement)(p, platform, 'lib-file');
|
|
288
288
|
for (const libFile of libFiles) {
|
|
289
|
-
await utils_fs_1.copy(plugin_1.getFilePath(config, p, libFile.$.src), path_1.join(pluginsPath, 'libs', libFile.$.src.split('/').pop()));
|
|
289
|
+
await (0, utils_fs_1.copy)((0, plugin_1.getFilePath)(config, p, libFile.$.src), (0, path_1.join)(pluginsPath, 'libs', libFile.$.src.split('/').pop()));
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
async function removePluginsNativeFiles(config) {
|
|
295
|
-
await utils_fs_1.remove(config.android.cordovaPluginsDirAbs);
|
|
296
|
-
await template_1.extractTemplate(config.cli.assets.android.cordovaPluginsTemplateArchiveAbs, config.android.cordovaPluginsDirAbs);
|
|
295
|
+
await (0, utils_fs_1.remove)(config.android.cordovaPluginsDirAbs);
|
|
296
|
+
await (0, template_1.extractTemplate)(config.cli.assets.android.cordovaPluginsTemplateArchiveAbs, config.android.cordovaPluginsDirAbs);
|
|
297
297
|
}
|
|
298
298
|
async function getPluginsTask(config) {
|
|
299
|
-
return await common_1.runTask('Updating Android plugins', async () => {
|
|
300
|
-
const allPlugins = await plugin_1.getPlugins(config, 'android');
|
|
301
|
-
const androidPlugins = await common_2.getAndroidPlugins(allPlugins);
|
|
299
|
+
return await (0, common_1.runTask)('Updating Android plugins', async () => {
|
|
300
|
+
const allPlugins = await (0, plugin_1.getPlugins)(config, 'android');
|
|
301
|
+
const androidPlugins = await (0, common_2.getAndroidPlugins)(allPlugins);
|
|
302
302
|
return androidPlugins;
|
|
303
303
|
});
|
|
304
304
|
}
|
|
305
305
|
async function getVariablesGradleFile(config) {
|
|
306
|
-
const variablesFile = path_1.resolve(config.android.platformDirAbs, 'variables.gradle');
|
|
306
|
+
const variablesFile = (0, path_1.resolve)(config.android.platformDirAbs, 'variables.gradle');
|
|
307
307
|
let variablesGradle = '';
|
|
308
|
-
if (await utils_fs_1.pathExists(variablesFile)) {
|
|
309
|
-
variablesGradle = await utils_fs_1.readFile(variablesFile, { encoding: 'utf-8' });
|
|
308
|
+
if (await (0, utils_fs_1.pathExists)(variablesFile)) {
|
|
309
|
+
variablesGradle = await (0, utils_fs_1.readFile)(variablesFile, { encoding: 'utf-8' });
|
|
310
310
|
}
|
|
311
311
|
return variablesGradle;
|
|
312
312
|
}
|
package/dist/common.js
CHANGED
|
@@ -27,19 +27,19 @@ async function checkWebDir(config) {
|
|
|
27
27
|
if (invalidFolders.includes(config.app.webDir)) {
|
|
28
28
|
return `"${config.app.webDir}" is not a valid value for webDir`;
|
|
29
29
|
}
|
|
30
|
-
if (!(await utils_fs_1.pathExists(config.app.webDirAbs))) {
|
|
31
|
-
return (`Could not find the web assets directory: ${colors_1.default.strong(utils_terminal_1.prettyPath(config.app.webDirAbs))}.\n` +
|
|
30
|
+
if (!(await (0, utils_fs_1.pathExists)(config.app.webDirAbs))) {
|
|
31
|
+
return (`Could not find the web assets directory: ${colors_1.default.strong((0, utils_terminal_1.prettyPath)(config.app.webDirAbs))}.\n` +
|
|
32
32
|
`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')}`);
|
|
33
33
|
}
|
|
34
|
-
if (!(await utils_fs_1.pathExists(path_1.join(config.app.webDirAbs, 'index.html')))) {
|
|
35
|
-
return (`The web assets directory (${colors_1.default.strong(utils_terminal_1.prettyPath(config.app.webDirAbs))}) must contain an ${colors_1.default.strong('index.html')} file.\n` +
|
|
34
|
+
if (!(await (0, utils_fs_1.pathExists)((0, path_1.join)(config.app.webDirAbs, 'index.html')))) {
|
|
35
|
+
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` +
|
|
36
36
|
`It will be the entry point for the web portion of the Capacitor app.`);
|
|
37
37
|
}
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
40
|
exports.checkWebDir = checkWebDir;
|
|
41
41
|
async function checkPackage() {
|
|
42
|
-
if (!(await utils_fs_1.pathExists('package.json'))) {
|
|
42
|
+
if (!(await (0, utils_fs_1.pathExists)('package.json'))) {
|
|
43
43
|
return (`The Capacitor CLI needs to run at the root of an npm package.\n` +
|
|
44
44
|
`Make sure you have a package.json file in the directory where you run the Capacitor CLI.\n` +
|
|
45
45
|
`More info: ${colors_1.default.strong('https://docs.npmjs.com/cli/init')}`);
|
|
@@ -108,7 +108,7 @@ exports.wait = wait;
|
|
|
108
108
|
async function runPlatformHook(config, platformName, platformDir, hook) {
|
|
109
109
|
var _a;
|
|
110
110
|
const { spawn } = await Promise.resolve().then(() => tslib_1.__importStar(require('child_process')));
|
|
111
|
-
const pkg = await utils_fs_1.readJSON(path_1.join(platformDir, 'package.json'));
|
|
111
|
+
const pkg = await (0, utils_fs_1.readJSON)((0, path_1.join)(platformDir, 'package.json'));
|
|
112
112
|
const cmd = (_a = pkg.scripts) === null || _a === void 0 ? void 0 : _a[hook];
|
|
113
113
|
if (!cmd) {
|
|
114
114
|
return;
|
|
@@ -151,17 +151,17 @@ async function runTask(title, fn) {
|
|
|
151
151
|
}
|
|
152
152
|
exports.runTask = runTask;
|
|
153
153
|
async function getCapacitorPackage(config, name) {
|
|
154
|
-
const packagePath = node_1.resolveNode(config.app.rootDir, `@capacitor/${name}`, 'package.json');
|
|
154
|
+
const packagePath = (0, node_1.resolveNode)(config.app.rootDir, `@capacitor/${name}`, 'package.json');
|
|
155
155
|
if (!packagePath) {
|
|
156
156
|
return null;
|
|
157
157
|
}
|
|
158
|
-
return utils_fs_1.readJSON(packagePath);
|
|
158
|
+
return (0, utils_fs_1.readJSON)(packagePath);
|
|
159
159
|
}
|
|
160
160
|
exports.getCapacitorPackage = getCapacitorPackage;
|
|
161
161
|
async function requireCapacitorPackage(config, name) {
|
|
162
162
|
const pkg = await getCapacitorPackage(config, name);
|
|
163
163
|
if (!pkg) {
|
|
164
|
-
errors_1.fatal(`Unable to find node_modules/@capacitor/${name}.\n` +
|
|
164
|
+
(0, errors_1.fatal)(`Unable to find node_modules/@capacitor/${name}.\n` +
|
|
165
165
|
`Are you sure ${colors_1.default.strong(`@capacitor/${name}`)} is installed?`);
|
|
166
166
|
}
|
|
167
167
|
return pkg;
|
|
@@ -192,7 +192,7 @@ function getPlatformDirectory(config, platform) {
|
|
|
192
192
|
}
|
|
193
193
|
async function getProjectPlatformDirectory(config, platform) {
|
|
194
194
|
const platformPath = getPlatformDirectory(config, platform);
|
|
195
|
-
if (platformPath && (await utils_fs_1.pathExists(platformPath))) {
|
|
195
|
+
if (platformPath && (await (0, utils_fs_1.pathExists)(platformPath))) {
|
|
196
196
|
return platformPath;
|
|
197
197
|
}
|
|
198
198
|
return null;
|
|
@@ -203,14 +203,14 @@ async function selectPlatforms(config, selectedPlatformName) {
|
|
|
203
203
|
// already passed in a platform name
|
|
204
204
|
const platformName = selectedPlatformName.toLowerCase().trim();
|
|
205
205
|
if (!(await isValidPlatform(platformName))) {
|
|
206
|
-
errors_1.fatal(`Invalid platform: ${colors_1.default.input(platformName)}`);
|
|
206
|
+
(0, errors_1.fatal)(`Invalid platform: ${colors_1.default.input(platformName)}`);
|
|
207
207
|
}
|
|
208
208
|
else if (!(await getProjectPlatformDirectory(config, platformName))) {
|
|
209
209
|
if (platformName === 'web') {
|
|
210
|
-
errors_1.fatal(`Could not find the web platform directory.\n` +
|
|
210
|
+
(0, errors_1.fatal)(`Could not find the web platform directory.\n` +
|
|
211
211
|
`Make sure ${colors_1.default.strong(config.app.webDir)} exists.`);
|
|
212
212
|
}
|
|
213
|
-
errors_1.fatal(`${colors_1.default.strong(platformName)} platform has not been added yet.\n` +
|
|
213
|
+
(0, errors_1.fatal)(`${colors_1.default.strong(platformName)} platform has not been added yet.\n` +
|
|
214
214
|
`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`)}`);
|
|
215
215
|
}
|
|
216
216
|
// return the platform in an string array
|
|
@@ -261,7 +261,7 @@ async function promptForPlatform(platforms, promptMessage, selectedPlatformName)
|
|
|
261
261
|
const platformName = selectedPlatformName.toLowerCase().trim();
|
|
262
262
|
if (!(await isValidPlatform(platformName))) {
|
|
263
263
|
const knownPlatforms = await getKnownPlatforms();
|
|
264
|
-
errors_1.fatal(`Invalid platform: ${colors_1.default.input(platformName)}.\n` +
|
|
264
|
+
(0, errors_1.fatal)(`Invalid platform: ${colors_1.default.input(platformName)}.\n` +
|
|
265
265
|
`Valid platforms include: ${knownPlatforms.join(', ')}`);
|
|
266
266
|
}
|
|
267
267
|
return platformName;
|
|
@@ -292,7 +292,7 @@ async function promptForPlatformTarget(targets, selectedTarget) {
|
|
|
292
292
|
const targetID = selectedTarget.trim();
|
|
293
293
|
const target = targets.find(t => t.id === targetID);
|
|
294
294
|
if (!target) {
|
|
295
|
-
errors_1.fatal(`Invalid target ID: ${colors_1.default.input(targetID)}.\n` +
|
|
295
|
+
(0, errors_1.fatal)(`Invalid target ID: ${colors_1.default.input(targetID)}.\n` +
|
|
296
296
|
`Valid targets are: ${targets.map(t => t.id).join(', ')}`);
|
|
297
297
|
}
|
|
298
298
|
return target;
|
|
@@ -330,23 +330,23 @@ async function checkPlatformVersions(config, platform) {
|
|
|
330
330
|
exports.checkPlatformVersions = checkPlatformVersions;
|
|
331
331
|
function resolvePlatform(config, platform) {
|
|
332
332
|
if (platform[0] !== '@') {
|
|
333
|
-
const core = node_1.resolveNode(config.app.rootDir, `@capacitor/${platform}`, 'package.json');
|
|
333
|
+
const core = (0, node_1.resolveNode)(config.app.rootDir, `@capacitor/${platform}`, 'package.json');
|
|
334
334
|
if (core) {
|
|
335
|
-
return path_1.dirname(core);
|
|
335
|
+
return (0, path_1.dirname)(core);
|
|
336
336
|
}
|
|
337
|
-
const community = node_1.resolveNode(config.app.rootDir, `@capacitor-community/${platform}`, 'package.json');
|
|
337
|
+
const community = (0, node_1.resolveNode)(config.app.rootDir, `@capacitor-community/${platform}`, 'package.json');
|
|
338
338
|
if (community) {
|
|
339
|
-
return path_1.dirname(community);
|
|
339
|
+
return (0, path_1.dirname)(community);
|
|
340
340
|
}
|
|
341
|
-
const enterprise = node_1.resolveNode(config.app.rootDir, `@ionic-enterprise/capacitor-${platform}`, 'package.json');
|
|
341
|
+
const enterprise = (0, node_1.resolveNode)(config.app.rootDir, `@ionic-enterprise/capacitor-${platform}`, 'package.json');
|
|
342
342
|
if (enterprise) {
|
|
343
|
-
return path_1.dirname(enterprise);
|
|
343
|
+
return (0, path_1.dirname)(enterprise);
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
// third-party
|
|
347
|
-
const thirdParty = node_1.resolveNode(config.app.rootDir, platform, 'package.json');
|
|
347
|
+
const thirdParty = (0, node_1.resolveNode)(config.app.rootDir, platform, 'package.json');
|
|
348
348
|
if (thirdParty) {
|
|
349
|
-
return path_1.dirname(thirdParty);
|
|
349
|
+
return (0, path_1.dirname)(thirdParty);
|
|
350
350
|
}
|
|
351
351
|
return null;
|
|
352
352
|
}
|