@capacitor/cli 7.0.0-alpha.2 → 7.0.0-beta.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/android/add.js +3 -3
- package/dist/android/common.js +13 -13
- package/dist/android/doctor.js +13 -12
- package/dist/android/open.js +2 -2
- package/dist/android/update.js +20 -20
- package/dist/common.js +9 -9
- package/dist/config.js +15 -15
- package/dist/cordova.js +23 -23
- package/dist/declarations.d.ts +26 -0
- package/dist/index.js +3 -3
- package/dist/ios/build.js +5 -6
- package/dist/ios/common.js +5 -5
- package/dist/ios/update.js +16 -16
- package/dist/ipc.js +3 -3
- package/dist/plugin.js +2 -2
- package/dist/sysconfig.js +4 -4
- package/dist/tasks/add.js +2 -2
- package/dist/tasks/copy.js +9 -9
- package/dist/tasks/doctor.js +2 -2
- package/dist/tasks/migrate.js +48 -56
- package/dist/tasks/run.js +1 -2
- package/dist/tasks/sourcemaps.js +8 -8
- package/dist/tasks/telemetry.js +1 -1
- package/dist/telemetry.js +1 -1
- package/dist/util/fs.js +26 -7
- package/dist/util/iosplugin.js +6 -5
- package/dist/util/livereload.js +4 -4
- package/dist/util/node.js +2 -2
- package/dist/util/spm.js +4 -4
- package/dist/util/subprocess.js +1 -1
- package/dist/util/template.js +2 -2
- package/dist/util/xml.js +2 -2
- package/package.json +25 -24
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/android/add.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLocalProperties = exports.addAndroid = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const fs_extra_1 = require("fs-extra");
|
|
6
6
|
const os_1 = require("os");
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const colors_1 = tslib_1.__importDefault(require("../colors"));
|
|
@@ -17,7 +17,7 @@ async function addAndroid(config) {
|
|
|
17
17
|
exports.addAndroid = addAndroid;
|
|
18
18
|
async function createLocalProperties(platformDir) {
|
|
19
19
|
const defaultAndroidPath = (0, path_1.join)((0, os_1.homedir)(), 'Library/Android/sdk');
|
|
20
|
-
if (await (0,
|
|
20
|
+
if (await (0, fs_extra_1.pathExists)(defaultAndroidPath)) {
|
|
21
21
|
const localSettings = `
|
|
22
22
|
## This file is automatically generated by Android Studio.
|
|
23
23
|
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
|
@@ -30,7 +30,7 @@ async function createLocalProperties(platformDir) {
|
|
|
30
30
|
# header note.
|
|
31
31
|
sdk.dir=${defaultAndroidPath}
|
|
32
32
|
`;
|
|
33
|
-
await (0,
|
|
33
|
+
await (0, fs_extra_1.writeFile)((0, path_1.join)(platformDir, 'local.properties'), localSettings, {
|
|
34
34
|
encoding: 'utf-8',
|
|
35
35
|
});
|
|
36
36
|
// Only sync if we were able to create the local properties above, otherwise
|
package/dist/android/common.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.editProjectSettingsAndroid = exports.resolvePlugin = exports.getAndroidPlugins = exports.checkAndroidPackage = void 0;
|
|
4
|
-
const
|
|
4
|
+
const fs_extra_1 = require("fs-extra");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const common_1 = require("../common");
|
|
7
7
|
const cordova_1 = require("../cordova");
|
|
@@ -23,7 +23,7 @@ async function resolvePlugin(plugin) {
|
|
|
23
23
|
let pluginFilesPath = plugin.manifest.android.src ? plugin.manifest.android.src : platform;
|
|
24
24
|
const absolutePath = (0, path_1.join)(plugin.rootPath, pluginFilesPath, plugin.id);
|
|
25
25
|
// Android folder shouldn't have subfolders, but they used to, so search for them for compatibility reasons
|
|
26
|
-
if (await (0,
|
|
26
|
+
if (await (0, fs_extra_1.pathExists)(absolutePath)) {
|
|
27
27
|
pluginFilesPath = (0, path_1.join)(platform, plugin.id);
|
|
28
28
|
}
|
|
29
29
|
plugin.android = {
|
|
@@ -62,33 +62,33 @@ async function editProjectSettingsAndroid(config) {
|
|
|
62
62
|
const domainPath = appId.split('.').join('/');
|
|
63
63
|
// Make the package source path to the new plugin Java file
|
|
64
64
|
const newJavaPath = (0, path_1.resolve)(config.android.srcMainDirAbs, `java/${domainPath}`);
|
|
65
|
-
if (!(await (0,
|
|
66
|
-
await (0,
|
|
65
|
+
if (!(await (0, fs_extra_1.pathExists)(newJavaPath))) {
|
|
66
|
+
await (0, fs_extra_1.mkdirp)(newJavaPath);
|
|
67
67
|
}
|
|
68
|
-
await (0,
|
|
68
|
+
await (0, fs_extra_1.copy)((0, path_1.resolve)(config.android.srcMainDirAbs, 'java/com/getcapacitor/myapp/MainActivity.java'), (0, path_1.resolve)(newJavaPath, 'MainActivity.java'));
|
|
69
69
|
if (appId.split('.')[1] !== 'getcapacitor') {
|
|
70
|
-
await (0,
|
|
70
|
+
await (0, fs_extra_1.remove)((0, path_1.resolve)(config.android.srcMainDirAbs, 'java/com/getcapacitor'));
|
|
71
71
|
}
|
|
72
72
|
// Remove our template 'com' folder if their ID doesn't have it
|
|
73
73
|
if (appId.split('.')[0] !== 'com') {
|
|
74
|
-
await (0,
|
|
74
|
+
await (0, fs_extra_1.remove)((0, path_1.resolve)(config.android.srcMainDirAbs, 'java/com/'));
|
|
75
75
|
}
|
|
76
76
|
// Update the package in the MainActivity java file
|
|
77
77
|
const activityPath = (0, path_1.resolve)(newJavaPath, 'MainActivity.java');
|
|
78
|
-
let activityContent = await (0,
|
|
78
|
+
let activityContent = await (0, fs_extra_1.readFile)(activityPath, { encoding: 'utf-8' });
|
|
79
79
|
activityContent = activityContent.replace(/package ([^;]*)/, `package ${appId}`);
|
|
80
|
-
await (0,
|
|
80
|
+
await (0, fs_extra_1.writeFile)(activityPath, activityContent, { encoding: 'utf-8' });
|
|
81
81
|
// Update the applicationId in build.gradle
|
|
82
|
-
let gradleContent = await (0,
|
|
82
|
+
let gradleContent = await (0, fs_extra_1.readFile)(buildGradlePath, { encoding: 'utf-8' });
|
|
83
83
|
gradleContent = gradleContent.replace(/applicationId "[^"]+"/, `applicationId "${appId}"`);
|
|
84
84
|
// Update the namespace in build.gradle
|
|
85
85
|
gradleContent = gradleContent.replace(/namespace "[^"]+"/, `namespace "${appId}"`);
|
|
86
|
-
await (0,
|
|
86
|
+
await (0, fs_extra_1.writeFile)(buildGradlePath, gradleContent, { encoding: 'utf-8' });
|
|
87
87
|
// Update the settings in res/values/strings.xml
|
|
88
88
|
const stringsPath = (0, path_1.resolve)(config.android.resDirAbs, 'values/strings.xml');
|
|
89
|
-
let stringsContent = await (0,
|
|
89
|
+
let stringsContent = await (0, fs_extra_1.readFile)(stringsPath, { encoding: 'utf-8' });
|
|
90
90
|
stringsContent = stringsContent.replace(/com.getcapacitor.myapp/g, appId);
|
|
91
91
|
stringsContent = stringsContent.replace(/My App/g, appName);
|
|
92
|
-
await (0,
|
|
92
|
+
await (0, fs_extra_1.writeFile)(stringsPath, stringsContent);
|
|
93
93
|
}
|
|
94
94
|
exports.editProjectSettingsAndroid = editProjectSettingsAndroid;
|
package/dist/android/doctor.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.doctorAndroid = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const fs_extra_1 = require("fs-extra");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const colors_1 = tslib_1.__importDefault(require("../colors"));
|
|
8
8
|
const common_1 = require("../common");
|
|
9
9
|
const errors_1 = require("../errors");
|
|
10
10
|
const log_1 = require("../log");
|
|
11
|
+
const fs_1 = require("../util/fs");
|
|
11
12
|
const xml_1 = require("../util/xml");
|
|
12
13
|
async function doctorAndroid(config) {
|
|
13
14
|
var _a;
|
|
@@ -24,20 +25,20 @@ async function doctorAndroid(config) {
|
|
|
24
25
|
}
|
|
25
26
|
exports.doctorAndroid = doctorAndroid;
|
|
26
27
|
async function checkAppSrcDirs(config) {
|
|
27
|
-
if (!(await (0,
|
|
28
|
+
if (!(await (0, fs_extra_1.pathExists)(config.android.appDirAbs))) {
|
|
28
29
|
return `${colors_1.default.strong(config.android.appDir)} directory is missing in ${colors_1.default.strong(config.android.platformDir)}`;
|
|
29
30
|
}
|
|
30
|
-
if (!(await (0,
|
|
31
|
+
if (!(await (0, fs_extra_1.pathExists)(config.android.srcMainDirAbs))) {
|
|
31
32
|
return `${colors_1.default.strong(config.android.srcMainDir)} directory is missing in ${colors_1.default.strong(config.android.platformDir)}`;
|
|
32
33
|
}
|
|
33
|
-
if (!(await (0,
|
|
34
|
+
if (!(await (0, fs_extra_1.pathExists)(config.android.assetsDirAbs))) {
|
|
34
35
|
return `${colors_1.default.strong(config.android.assetsDir)} directory is missing in ${colors_1.default.strong(config.android.platformDir)}`;
|
|
35
36
|
}
|
|
36
|
-
if (!(await (0,
|
|
37
|
+
if (!(await (0, fs_extra_1.pathExists)(config.android.webDirAbs))) {
|
|
37
38
|
return `${colors_1.default.strong(config.android.webDir)} directory is missing in ${colors_1.default.strong(config.android.platformDir)}`;
|
|
38
39
|
}
|
|
39
40
|
const appSrcMainAssetsWwwIndexHtmlDir = (0, path_1.join)(config.android.webDirAbs, 'index.html');
|
|
40
|
-
if (!(await (0,
|
|
41
|
+
if (!(await (0, fs_extra_1.pathExists)(appSrcMainAssetsWwwIndexHtmlDir))) {
|
|
41
42
|
return `${colors_1.default.strong('index.html')} file is missing in ${colors_1.default.strong(config.android.webDirAbs)}`;
|
|
42
43
|
}
|
|
43
44
|
return checkAndroidManifestFile(config);
|
|
@@ -45,7 +46,7 @@ async function checkAppSrcDirs(config) {
|
|
|
45
46
|
async function checkAndroidManifestFile(config) {
|
|
46
47
|
const manifestFileName = 'AndroidManifest.xml';
|
|
47
48
|
const manifestFilePath = (0, path_1.join)(config.android.srcMainDirAbs, manifestFileName);
|
|
48
|
-
if (!(await (0,
|
|
49
|
+
if (!(await (0, fs_extra_1.pathExists)(manifestFilePath))) {
|
|
49
50
|
return `${colors_1.default.strong(manifestFileName)} is missing in ${colors_1.default.strong(config.android.srcMainDir)}`;
|
|
50
51
|
}
|
|
51
52
|
try {
|
|
@@ -113,11 +114,11 @@ async function checkAndroidManifestData(config, xmlData) {
|
|
|
113
114
|
}
|
|
114
115
|
async function checkPackage(config, mainActivityClassPath) {
|
|
115
116
|
const appSrcMainJavaDir = (0, path_1.join)(config.android.srcMainDirAbs, 'java');
|
|
116
|
-
if (!(await (0,
|
|
117
|
+
if (!(await (0, fs_extra_1.pathExists)(appSrcMainJavaDir))) {
|
|
117
118
|
return `${colors_1.default.strong('java')} directory is missing in ${colors_1.default.strong(appSrcMainJavaDir)}`;
|
|
118
119
|
}
|
|
119
120
|
const mainActivityClassName = mainActivityClassPath.split('.').pop();
|
|
120
|
-
const srcFiles = await (0,
|
|
121
|
+
const srcFiles = await (0, fs_1.readdirp)(appSrcMainJavaDir, {
|
|
121
122
|
filter: (entry) => !entry.stats.isDirectory() &&
|
|
122
123
|
['.java', '.kt'].includes((0, path_1.extname)(entry.path)) &&
|
|
123
124
|
mainActivityClassName === (0, path_1.parse)(entry.path).name,
|
|
@@ -130,10 +131,10 @@ async function checkPackage(config, mainActivityClassPath) {
|
|
|
130
131
|
async function checkBuildGradle(config) {
|
|
131
132
|
const fileName = 'build.gradle';
|
|
132
133
|
const filePath = (0, path_1.join)(config.android.appDirAbs, fileName);
|
|
133
|
-
if (!(await (0,
|
|
134
|
+
if (!(await (0, fs_extra_1.pathExists)(filePath))) {
|
|
134
135
|
return `${colors_1.default.strong(fileName)} file is missing in ${colors_1.default.strong(config.android.appDir)}`;
|
|
135
136
|
}
|
|
136
|
-
let fileContent = await (0,
|
|
137
|
+
let fileContent = await (0, fs_extra_1.readFile)(filePath, { encoding: 'utf-8' });
|
|
137
138
|
fileContent = fileContent.replace(/'|"/g, '').replace(/\s+/g, ' ');
|
|
138
139
|
const searchFor = `applicationId`;
|
|
139
140
|
if (fileContent.indexOf(searchFor) === -1) {
|
|
@@ -144,7 +145,7 @@ async function checkBuildGradle(config) {
|
|
|
144
145
|
async function checkGradlew(config) {
|
|
145
146
|
const fileName = 'gradlew';
|
|
146
147
|
const filePath = (0, path_1.join)(config.android.platformDirAbs, fileName);
|
|
147
|
-
if (!(await (0,
|
|
148
|
+
if (!(await (0, fs_extra_1.pathExists)(filePath))) {
|
|
148
149
|
return `${colors_1.default.strong(fileName)} file is missing in ${colors_1.default.strong(config.android.platformDir)}`;
|
|
149
150
|
}
|
|
150
151
|
return null;
|
package/dist/android/open.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.openAndroid = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const utils_fs_1 = require("@ionic/utils-fs");
|
|
6
5
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
6
|
+
const fs_extra_1 = require("fs-extra");
|
|
7
7
|
const open_1 = tslib_1.__importDefault(require("open"));
|
|
8
8
|
const colors_1 = tslib_1.__importDefault(require("../colors"));
|
|
9
9
|
const log_1 = require("../log");
|
|
@@ -12,7 +12,7 @@ async function openAndroid(config) {
|
|
|
12
12
|
const androidStudioPath = await config.android.studioPath;
|
|
13
13
|
const dir = config.android.platformDirAbs;
|
|
14
14
|
try {
|
|
15
|
-
if (!(await (0,
|
|
15
|
+
if (!(await (0, fs_extra_1.pathExists)(androidStudioPath))) {
|
|
16
16
|
throw new Error(`Android Studio does not exist at: ${androidStudioPath}`);
|
|
17
17
|
}
|
|
18
18
|
await (0, open_1.default)(dir, { app: { name: androidStudioPath }, wait: false });
|
package/dist/android/update.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleCordovaPluginsGradle = exports.installGradlePlugins = exports.updateAndroid = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const utils_fs_1 = require("@ionic/utils-fs");
|
|
6
5
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
6
|
+
const fs_extra_1 = require("fs-extra");
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const colors_1 = tslib_1.__importDefault(require("../colors"));
|
|
9
9
|
const common_1 = require("../common");
|
|
@@ -29,7 +29,7 @@ async function updateAndroid(config) {
|
|
|
29
29
|
if (cordovaPlugins.length > 0) {
|
|
30
30
|
await copyPluginsNativeFiles(config, cordovaPlugins);
|
|
31
31
|
}
|
|
32
|
-
if (!(await (0,
|
|
32
|
+
if (!(await (0, fs_extra_1.pathExists)(config.android.webDirAbs))) {
|
|
33
33
|
await (0, copy_1.copy)(config, platform);
|
|
34
34
|
}
|
|
35
35
|
await (0, cordova_1.handleCordovaPluginsJS)(cordovaPlugins, config, platform);
|
|
@@ -48,7 +48,7 @@ function getGradlePackageName(id) {
|
|
|
48
48
|
async function writePluginsJson(config, plugins) {
|
|
49
49
|
const classes = await findAndroidPluginClasses(plugins);
|
|
50
50
|
const pluginsJsonPath = (0, path_1.resolve)(config.android.assetsDirAbs, 'capacitor.plugins.json');
|
|
51
|
-
await (0,
|
|
51
|
+
await (0, fs_extra_1.writeJSON)(pluginsJsonPath, classes, { spaces: '\t' });
|
|
52
52
|
}
|
|
53
53
|
async function findAndroidPluginClasses(plugins) {
|
|
54
54
|
const entries = [];
|
|
@@ -62,14 +62,14 @@ async function findAndroidPluginClassesInPlugin(plugin) {
|
|
|
62
62
|
return [];
|
|
63
63
|
}
|
|
64
64
|
const srcPath = (0, path_1.resolve)(plugin.rootPath, plugin.android.path, 'src/main');
|
|
65
|
-
const srcFiles = await (0,
|
|
65
|
+
const srcFiles = await (0, fs_1.readdirp)(srcPath, {
|
|
66
66
|
filter: (entry) => !entry.stats.isDirectory() && ['.java', '.kt'].includes((0, path_1.extname)(entry.path)),
|
|
67
67
|
});
|
|
68
68
|
const classRegex = /^@(?:CapacitorPlugin|NativePlugin)[\s\S]+?class ([\w]+)/gm;
|
|
69
69
|
const packageRegex = /^package ([\w.]+);?$/gm;
|
|
70
70
|
debug('Searching %O source files in %O by %O regex', srcFiles.length, srcPath, classRegex);
|
|
71
71
|
const entries = await Promise.all(srcFiles.map(async (srcFile) => {
|
|
72
|
-
const srcFileContents = await (0,
|
|
72
|
+
const srcFileContents = await (0, fs_extra_1.readFile)(srcFile, { encoding: 'utf-8' });
|
|
73
73
|
classRegex.lastIndex = 0;
|
|
74
74
|
const classMatch = classRegex.exec(srcFileContents);
|
|
75
75
|
if (classMatch) {
|
|
@@ -146,8 +146,8 @@ project(':${getGradlePackageName(p.id)}').projectDir = new File('${relativePlugi
|
|
|
146
146
|
|
|
147
147
|
android {
|
|
148
148
|
compileOptions {
|
|
149
|
-
sourceCompatibility JavaVersion.
|
|
150
|
-
targetCompatibility JavaVersion.
|
|
149
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
150
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
@@ -166,15 +166,15 @@ if (hasProperty('postBuildExtras')) {
|
|
|
166
166
|
postBuildExtras()
|
|
167
167
|
}
|
|
168
168
|
`;
|
|
169
|
-
await (0,
|
|
170
|
-
await (0,
|
|
169
|
+
await (0, fs_extra_1.writeFile)((0, path_1.join)(settingsPath, 'capacitor.settings.gradle'), settingsLines);
|
|
170
|
+
await (0, fs_extra_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
175
|
const pluginsGradlePath = (0, path_1.join)(config.android.cordovaPluginsDirAbs, 'build.gradle');
|
|
176
176
|
const kotlinNeeded = await kotlinNeededCheck(config, cordovaPlugins);
|
|
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.9.
|
|
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.9.25';
|
|
178
178
|
const frameworksArray = [];
|
|
179
179
|
let prefsArray = [];
|
|
180
180
|
const applyArray = [];
|
|
@@ -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 (0,
|
|
214
|
+
let buildGradle = await (0, fs_extra_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 (0,
|
|
224
|
+
await (0, fs_extra_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 (0,
|
|
232
|
+
await (0, fs_extra_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) {
|
|
@@ -266,7 +266,7 @@ async function copyPluginsNativeFiles(config, cordovaPlugins) {
|
|
|
266
266
|
baseFolder = 'aidl/';
|
|
267
267
|
}
|
|
268
268
|
const target = sourceFile.$['target-dir'].replace('app/src/main/', '').replace('src/', baseFolder);
|
|
269
|
-
await (0,
|
|
269
|
+
await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, sourceFile.$.src), (0, path_1.join)(pluginsPath, target, fileName));
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
const resourceFiles = androidPlatform['resource-file'];
|
|
@@ -274,22 +274,22 @@ async function copyPluginsNativeFiles(config, cordovaPlugins) {
|
|
|
274
274
|
for (const resourceFile of resourceFiles) {
|
|
275
275
|
const target = resourceFile.$['target'];
|
|
276
276
|
if (resourceFile.$.src.split('.').pop() === 'aar') {
|
|
277
|
-
await (0,
|
|
277
|
+
await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, resourceFile.$.src), (0, path_1.join)(pluginsPath, 'libs', target.split('/').pop()));
|
|
278
278
|
}
|
|
279
279
|
else if (target !== '.') {
|
|
280
|
-
await (0,
|
|
280
|
+
await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, resourceFile.$.src), (0, path_1.join)(pluginsPath, target));
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
const libFiles = (0, plugin_1.getPlatformElement)(p, platform, 'lib-file');
|
|
285
285
|
for (const libFile of libFiles) {
|
|
286
|
-
await (0,
|
|
286
|
+
await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, libFile.$.src), (0, path_1.join)(pluginsPath, 'libs', libFile.$.src.split('/').pop()));
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
async function removePluginsNativeFiles(config) {
|
|
292
|
-
await (0,
|
|
292
|
+
await (0, fs_extra_1.remove)(config.android.cordovaPluginsDirAbs);
|
|
293
293
|
await (0, template_1.extractTemplate)(config.cli.assets.android.cordovaPluginsTemplateArchiveAbs, config.android.cordovaPluginsDirAbs);
|
|
294
294
|
}
|
|
295
295
|
async function getPluginsTask(config) {
|
|
@@ -302,8 +302,8 @@ async function getPluginsTask(config) {
|
|
|
302
302
|
async function getVariablesGradleFile(config) {
|
|
303
303
|
const variablesFile = (0, path_1.resolve)(config.android.platformDirAbs, 'variables.gradle');
|
|
304
304
|
let variablesGradle = '';
|
|
305
|
-
if (await (0,
|
|
306
|
-
variablesGradle = await (0,
|
|
305
|
+
if (await (0, fs_extra_1.pathExists)(variablesFile)) {
|
|
306
|
+
variablesGradle = await (0, fs_extra_1.readFile)(variablesFile, { encoding: 'utf-8' });
|
|
307
307
|
}
|
|
308
308
|
return variablesGradle;
|
|
309
309
|
}
|
package/dist/common.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
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;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const utils_fs_1 = require("@ionic/utils-fs");
|
|
6
5
|
const utils_terminal_1 = require("@ionic/utils-terminal");
|
|
6
|
+
const fs_extra_1 = require("fs-extra");
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const colors_1 = tslib_1.__importDefault(require("./colors"));
|
|
9
9
|
const errors_1 = require("./errors");
|
|
@@ -30,11 +30,11 @@ async function checkWebDir(config) {
|
|
|
30
30
|
if (invalidFolders.includes(config.app.webDir)) {
|
|
31
31
|
return `"${config.app.webDir}" is not a valid value for webDir`;
|
|
32
32
|
}
|
|
33
|
-
if (!(await (0,
|
|
33
|
+
if (!(await (0, fs_extra_1.pathExists)(config.app.webDirAbs))) {
|
|
34
34
|
return (`Could not find the web assets directory: ${colors_1.default.strong((0, utils_terminal_1.prettyPath)(config.app.webDirAbs))}.\n` +
|
|
35
35
|
`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')}`);
|
|
36
36
|
}
|
|
37
|
-
if (!(await (0,
|
|
37
|
+
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(config.app.webDirAbs, 'index.html')))) {
|
|
38
38
|
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` +
|
|
39
39
|
`It will be the entry point for the web portion of the Capacitor app.`);
|
|
40
40
|
}
|
|
@@ -42,8 +42,8 @@ async function checkWebDir(config) {
|
|
|
42
42
|
}
|
|
43
43
|
exports.checkWebDir = checkWebDir;
|
|
44
44
|
async function checkPackage() {
|
|
45
|
-
if (!(await (0,
|
|
46
|
-
if (await (0,
|
|
45
|
+
if (!(await (0, fs_extra_1.pathExists)('package.json'))) {
|
|
46
|
+
if (await (0, fs_extra_1.pathExists)('project.json')) {
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
@@ -134,10 +134,10 @@ async function runPlatformHook(config, platformName, platformDir, hook) {
|
|
|
134
134
|
const { spawn } = await Promise.resolve().then(() => tslib_1.__importStar(require('child_process')));
|
|
135
135
|
let pkg;
|
|
136
136
|
if ((0, monorepotools_1.isNXMonorepo)(platformDir)) {
|
|
137
|
-
pkg = await (0,
|
|
137
|
+
pkg = await (0, fs_extra_1.readJSON)((0, path_1.join)((0, monorepotools_1.findNXMonorepoRoot)(platformDir), 'package.json'));
|
|
138
138
|
}
|
|
139
139
|
else {
|
|
140
|
-
pkg = await (0,
|
|
140
|
+
pkg = await (0, fs_extra_1.readJSON)((0, path_1.join)(platformDir, 'package.json'));
|
|
141
141
|
}
|
|
142
142
|
const cmd = (_a = pkg.scripts) === null || _a === void 0 ? void 0 : _a[hook];
|
|
143
143
|
if (!cmd) {
|
|
@@ -185,7 +185,7 @@ async function getCapacitorPackage(config, name) {
|
|
|
185
185
|
if (!packagePath) {
|
|
186
186
|
return null;
|
|
187
187
|
}
|
|
188
|
-
return (0,
|
|
188
|
+
return (0, fs_extra_1.readJSON)(packagePath);
|
|
189
189
|
}
|
|
190
190
|
exports.getCapacitorPackage = getCapacitorPackage;
|
|
191
191
|
async function requireCapacitorPackage(config, name) {
|
|
@@ -222,7 +222,7 @@ function getPlatformDirectory(config, platform) {
|
|
|
222
222
|
}
|
|
223
223
|
async function getProjectPlatformDirectory(config, platform) {
|
|
224
224
|
const platformPath = getPlatformDirectory(config, platform);
|
|
225
|
-
if (platformPath && (await (0,
|
|
225
|
+
if (platformPath && (await (0, fs_extra_1.pathExists)(platformPath))) {
|
|
226
226
|
return platformPath;
|
|
227
227
|
}
|
|
228
228
|
return null;
|
package/dist/config.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.writeConfig = exports.loadConfig = exports.CONFIG_FILE_NAME_JSON = exports.CONFIG_FILE_NAME_JS = exports.CONFIG_FILE_NAME_TS = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const utils_fs_1 = require("@ionic/utils-fs");
|
|
6
5
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
6
|
+
const fs_extra_1 = require("fs-extra");
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const colors_1 = tslib_1.__importDefault(require("./colors"));
|
|
9
9
|
const common_1 = require("./common");
|
|
@@ -28,7 +28,7 @@ async function loadConfig() {
|
|
|
28
28
|
var _a, _b;
|
|
29
29
|
if ((0, monorepotools_1.isNXMonorepo)(appRootDir)) {
|
|
30
30
|
const rootOfNXMonorepo = (0, monorepotools_1.findNXMonorepoRoot)(appRootDir);
|
|
31
|
-
const pkgJSONOfMonorepoRoot = await (0, fn_1.tryFn)(
|
|
31
|
+
const pkgJSONOfMonorepoRoot = await (0, fn_1.tryFn)(fs_extra_1.readJSON, (0, path_1.resolve)(rootOfNXMonorepo, 'package.json'));
|
|
32
32
|
const devDependencies = (_a = pkgJSONOfMonorepoRoot === null || pkgJSONOfMonorepoRoot === void 0 ? void 0 : pkgJSONOfMonorepoRoot.devDependencies) !== null && _a !== void 0 ? _a : {};
|
|
33
33
|
const dependencies = (_b = pkgJSONOfMonorepoRoot === null || pkgJSONOfMonorepoRoot === void 0 ? void 0 : pkgJSONOfMonorepoRoot.dependencies) !== null && _b !== void 0 ? _b : {};
|
|
34
34
|
return {
|
|
@@ -53,7 +53,7 @@ async function loadConfig() {
|
|
|
53
53
|
appName,
|
|
54
54
|
webDir,
|
|
55
55
|
webDirAbs: (0, path_1.resolve)(appRootDir, webDir),
|
|
56
|
-
package: (_d = (await (0, fn_1.tryFn)(
|
|
56
|
+
package: (_d = (await (0, fn_1.tryFn)(fs_extra_1.readJSON, (0, path_1.resolve)(appRootDir, 'package.json')))) !== null && _d !== void 0 ? _d : {
|
|
57
57
|
name: appName,
|
|
58
58
|
version: '1.0.0',
|
|
59
59
|
...depsForNx,
|
|
@@ -68,11 +68,11 @@ exports.loadConfig = loadConfig;
|
|
|
68
68
|
async function writeConfig(extConfig, extConfigFilePath) {
|
|
69
69
|
switch ((0, path_1.extname)(extConfigFilePath)) {
|
|
70
70
|
case '.json': {
|
|
71
|
-
await (0,
|
|
71
|
+
await (0, fs_extra_1.writeJSON)(extConfigFilePath, extConfig, { spaces: 2 });
|
|
72
72
|
break;
|
|
73
73
|
}
|
|
74
74
|
case '.ts': {
|
|
75
|
-
await (0,
|
|
75
|
+
await (0, fs_extra_1.writeFile)(extConfigFilePath, formatConfigTS(extConfig));
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -120,11 +120,11 @@ async function loadExtConfigJS(rootDir, extConfigName, extConfigFilePath) {
|
|
|
120
120
|
async function loadExtConfig(rootDir) {
|
|
121
121
|
var _a;
|
|
122
122
|
const extConfigFilePathTS = (0, path_1.resolve)(rootDir, exports.CONFIG_FILE_NAME_TS);
|
|
123
|
-
if (await (0,
|
|
123
|
+
if (await (0, fs_extra_1.pathExists)(extConfigFilePathTS)) {
|
|
124
124
|
return loadExtConfigTS(rootDir, exports.CONFIG_FILE_NAME_TS, extConfigFilePathTS);
|
|
125
125
|
}
|
|
126
126
|
const extConfigFilePathJS = (0, path_1.resolve)(rootDir, exports.CONFIG_FILE_NAME_JS);
|
|
127
|
-
if (await (0,
|
|
127
|
+
if (await (0, fs_extra_1.pathExists)(extConfigFilePathJS)) {
|
|
128
128
|
return loadExtConfigJS(rootDir, exports.CONFIG_FILE_NAME_JS, extConfigFilePathJS);
|
|
129
129
|
}
|
|
130
130
|
const extConfigFilePath = (0, path_1.resolve)(rootDir, exports.CONFIG_FILE_NAME_JSON);
|
|
@@ -132,7 +132,7 @@ async function loadExtConfig(rootDir) {
|
|
|
132
132
|
extConfigType: 'json',
|
|
133
133
|
extConfigName: exports.CONFIG_FILE_NAME_JSON,
|
|
134
134
|
extConfigFilePath: extConfigFilePath,
|
|
135
|
-
extConfig: (_a = (await (0, fn_1.tryFn)(
|
|
135
|
+
extConfig: (_a = (await (0, fn_1.tryFn)(fs_extra_1.readJSON, extConfigFilePath))) !== null && _a !== void 0 ? _a : {},
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
async function loadCLIConfig(rootDir) {
|
|
@@ -160,7 +160,7 @@ async function loadCLIConfig(rootDir) {
|
|
|
160
160
|
cordovaPluginsTemplateArchiveAbs: (0, path_1.resolve)(assetsDirAbs, androidCordovaPluginsTemplateArchive),
|
|
161
161
|
},
|
|
162
162
|
},
|
|
163
|
-
package: await (0,
|
|
163
|
+
package: await (0, fs_extra_1.readJSON)((0, path_1.resolve)(rootDir, 'package.json')),
|
|
164
164
|
os: determineOS(process.platform),
|
|
165
165
|
};
|
|
166
166
|
}
|
|
@@ -283,7 +283,7 @@ async function determineIOSWebDirAbs(nativeProjectDirAbs, nativeTargetDirAbs, na
|
|
|
283
283
|
const re = /path\s=\spublic[\s\S]+?sourceTree\s=\s([^;]+)/;
|
|
284
284
|
const pbxprojPath = (0, path_1.resolve)(nativeXcodeProjDirAbs, 'project.pbxproj');
|
|
285
285
|
try {
|
|
286
|
-
const pbxproj = await (0,
|
|
286
|
+
const pbxproj = await (0, fs_extra_1.readFile)(pbxprojPath, { encoding: 'utf8' });
|
|
287
287
|
const m = pbxproj.match(re);
|
|
288
288
|
if (m && m[1] === 'SOURCE_ROOT') {
|
|
289
289
|
log_1.logger.warn(`Using the iOS project root for the ${colors_1.default.strong('public')} directory is deprecated.\n` +
|
|
@@ -307,7 +307,7 @@ async function determineAndroidStudioPath(os) {
|
|
|
307
307
|
const { runCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./util/subprocess')));
|
|
308
308
|
let p = 'C:\\Program Files\\Android\\Android Studio\\bin\\studio64.exe';
|
|
309
309
|
try {
|
|
310
|
-
if (!(await (0,
|
|
310
|
+
if (!(await (0, fs_extra_1.pathExists)(p))) {
|
|
311
311
|
let commandResult = await runCommand('REG', [
|
|
312
312
|
'QUERY',
|
|
313
313
|
'HKEY_LOCAL_MACHINE\\SOFTWARE\\Android Studio',
|
|
@@ -337,13 +337,13 @@ async function determineGemfileOrCocoapodPath(rootDir, platformDir, nativeProjec
|
|
|
337
337
|
return process.env.CAPACITOR_COCOAPODS_PATH;
|
|
338
338
|
}
|
|
339
339
|
let gemfilePath = '';
|
|
340
|
-
if (await (0,
|
|
340
|
+
if (await (0, fs_extra_1.pathExists)((0, path_1.resolve)(rootDir, 'Gemfile'))) {
|
|
341
341
|
gemfilePath = (0, path_1.resolve)(rootDir, 'Gemfile');
|
|
342
342
|
}
|
|
343
|
-
else if (await (0,
|
|
343
|
+
else if (await (0, fs_extra_1.pathExists)((0, path_1.resolve)(platformDir, 'Gemfile'))) {
|
|
344
344
|
gemfilePath = (0, path_1.resolve)(platformDir, 'Gemfile');
|
|
345
345
|
}
|
|
346
|
-
else if (await (0,
|
|
346
|
+
else if (await (0, fs_extra_1.pathExists)((0, path_1.resolve)(nativeProjectDirAbs, 'Gemfile'))) {
|
|
347
347
|
gemfilePath = (0, path_1.resolve)(nativeProjectDirAbs, 'Gemfile');
|
|
348
348
|
}
|
|
349
349
|
const appSpecificGemfileExists = gemfilePath != '';
|
|
@@ -360,7 +360,7 @@ async function determineGemfileOrCocoapodPath(rootDir, platformDir, nativeProjec
|
|
|
360
360
|
}
|
|
361
361
|
}
|
|
362
362
|
try {
|
|
363
|
-
const gemfileText = (await (0,
|
|
363
|
+
const gemfileText = (await (0, fs_extra_1.readFile)(gemfilePath)).toString();
|
|
364
364
|
if (!gemfileText) {
|
|
365
365
|
return 'pod';
|
|
366
366
|
}
|