@capacitor-plus/cli 8.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/LICENSE +21 -0
- package/README.md +84 -0
- 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/bin/capacitor +18 -0
- package/dist/android/add.js +52 -0
- package/dist/android/build.js +104 -0
- package/dist/android/common.js +94 -0
- package/dist/android/doctor.js +160 -0
- package/dist/android/open.js +28 -0
- package/dist/android/run.js +42 -0
- package/dist/android/update.js +317 -0
- package/dist/colors.js +26 -0
- package/dist/common.js +435 -0
- package/dist/config.js +404 -0
- package/dist/cordova.js +801 -0
- package/dist/declarations.d.ts +674 -0
- package/dist/declarations.js +2 -0
- package/dist/definitions.js +13 -0
- package/dist/errors.js +27 -0
- package/dist/framework-configs.js +109 -0
- package/dist/index.js +253 -0
- package/dist/ios/add.js +13 -0
- package/dist/ios/build.js +96 -0
- package/dist/ios/common.js +105 -0
- package/dist/ios/doctor.js +45 -0
- package/dist/ios/open.js +17 -0
- package/dist/ios/run.js +51 -0
- package/dist/ios/update.js +449 -0
- package/dist/ipc.js +61 -0
- package/dist/log.js +39 -0
- package/dist/plugin.js +182 -0
- package/dist/sysconfig.js +35 -0
- package/dist/tasks/add.js +115 -0
- package/dist/tasks/build.js +63 -0
- package/dist/tasks/config.js +28 -0
- package/dist/tasks/copy.js +210 -0
- package/dist/tasks/create.js +10 -0
- package/dist/tasks/doctor.js +68 -0
- package/dist/tasks/init.js +138 -0
- package/dist/tasks/list.js +50 -0
- package/dist/tasks/migrate-spm.js +19 -0
- package/dist/tasks/migrate.js +518 -0
- package/dist/tasks/new-plugin.js +10 -0
- package/dist/tasks/open.js +62 -0
- package/dist/tasks/run.js +118 -0
- package/dist/tasks/serve.js +11 -0
- package/dist/tasks/sourcemaps.js +39 -0
- package/dist/tasks/sync.js +55 -0
- package/dist/tasks/telemetry.js +41 -0
- package/dist/tasks/update.js +74 -0
- package/dist/telemetry.js +119 -0
- package/dist/util/cli.js +25 -0
- package/dist/util/emoji.js +13 -0
- package/dist/util/fn.js +13 -0
- package/dist/util/fs.js +43 -0
- package/dist/util/iosplugin.js +66 -0
- package/dist/util/js.js +21 -0
- package/dist/util/livereload.js +148 -0
- package/dist/util/monorepotools.js +109 -0
- package/dist/util/native-run.js +63 -0
- package/dist/util/node.js +54 -0
- package/dist/util/promise.js +35 -0
- package/dist/util/spm.js +187 -0
- package/dist/util/subprocess.js +37 -0
- package/dist/util/template.js +11 -0
- package/dist/util/term.js +30 -0
- package/dist/util/uuid.js +11 -0
- package/dist/util/xml.js +55 -0
- package/package.json +89 -0
package/dist/config.js
ADDED
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeConfig = exports.loadConfig = exports.CONFIG_FILE_NAME_JSON = exports.CONFIG_FILE_NAME_JS = exports.CONFIG_FILE_NAME_TS = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
6
|
+
const fs_extra_1 = require("fs-extra");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const colors_1 = tslib_1.__importDefault(require("./colors"));
|
|
9
|
+
const common_1 = require("./common");
|
|
10
|
+
const errors_1 = require("./errors");
|
|
11
|
+
const log_1 = require("./log");
|
|
12
|
+
const fn_1 = require("./util/fn");
|
|
13
|
+
const js_1 = require("./util/js");
|
|
14
|
+
const monorepotools_1 = require("./util/monorepotools");
|
|
15
|
+
const node_1 = require("./util/node");
|
|
16
|
+
const promise_1 = require("./util/promise");
|
|
17
|
+
const subprocess_1 = require("./util/subprocess");
|
|
18
|
+
const debug = (0, debug_1.default)('capacitor:config');
|
|
19
|
+
exports.CONFIG_FILE_NAME_TS = 'capacitor.config.ts';
|
|
20
|
+
exports.CONFIG_FILE_NAME_JS = 'capacitor.config.js';
|
|
21
|
+
exports.CONFIG_FILE_NAME_JSON = 'capacitor.config.json';
|
|
22
|
+
async function loadConfig() {
|
|
23
|
+
var _a, _b, _c, _d;
|
|
24
|
+
const appRootDir = process.cwd();
|
|
25
|
+
const cliRootDir = (0, path_1.dirname)(__dirname);
|
|
26
|
+
const conf = await loadExtConfig(appRootDir);
|
|
27
|
+
const depsForNx = await (async () => {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
if ((0, monorepotools_1.isNXMonorepo)(appRootDir)) {
|
|
30
|
+
const rootOfNXMonorepo = (0, monorepotools_1.findNXMonorepoRoot)(appRootDir);
|
|
31
|
+
const pkgJSONOfMonorepoRoot = await (0, fn_1.tryFn)(fs_extra_1.readJSON, (0, path_1.resolve)(rootOfNXMonorepo, 'package.json'));
|
|
32
|
+
const devDependencies = (_a = pkgJSONOfMonorepoRoot === null || pkgJSONOfMonorepoRoot === void 0 ? void 0 : pkgJSONOfMonorepoRoot.devDependencies) !== null && _a !== void 0 ? _a : {};
|
|
33
|
+
const dependencies = (_b = pkgJSONOfMonorepoRoot === null || pkgJSONOfMonorepoRoot === void 0 ? void 0 : pkgJSONOfMonorepoRoot.dependencies) !== null && _b !== void 0 ? _b : {};
|
|
34
|
+
return {
|
|
35
|
+
devDependencies,
|
|
36
|
+
dependencies,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {};
|
|
40
|
+
})();
|
|
41
|
+
const appId = (_a = conf.extConfig.appId) !== null && _a !== void 0 ? _a : '';
|
|
42
|
+
const appName = (_b = conf.extConfig.appName) !== null && _b !== void 0 ? _b : '';
|
|
43
|
+
const webDir = (_c = conf.extConfig.webDir) !== null && _c !== void 0 ? _c : 'www';
|
|
44
|
+
const cli = await loadCLIConfig(cliRootDir);
|
|
45
|
+
const config = {
|
|
46
|
+
android: await loadAndroidConfig(appRootDir, conf.extConfig, cli),
|
|
47
|
+
ios: await loadIOSConfig(appRootDir, conf.extConfig),
|
|
48
|
+
web: await loadWebConfig(appRootDir, webDir),
|
|
49
|
+
cli,
|
|
50
|
+
app: {
|
|
51
|
+
rootDir: appRootDir,
|
|
52
|
+
appId,
|
|
53
|
+
appName,
|
|
54
|
+
webDir,
|
|
55
|
+
webDirAbs: (0, path_1.resolve)(appRootDir, webDir),
|
|
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
|
+
name: appName,
|
|
58
|
+
version: '1.0.0',
|
|
59
|
+
...depsForNx,
|
|
60
|
+
},
|
|
61
|
+
...conf,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
debug('config: %O', config);
|
|
65
|
+
return config;
|
|
66
|
+
}
|
|
67
|
+
exports.loadConfig = loadConfig;
|
|
68
|
+
async function writeConfig(extConfig, extConfigFilePath) {
|
|
69
|
+
switch ((0, path_1.extname)(extConfigFilePath)) {
|
|
70
|
+
case '.json': {
|
|
71
|
+
await (0, fs_extra_1.writeJSON)(extConfigFilePath, extConfig, { spaces: 2 });
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case '.ts': {
|
|
75
|
+
await (0, fs_extra_1.writeFile)(extConfigFilePath, formatConfigTS(extConfig));
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.writeConfig = writeConfig;
|
|
81
|
+
async function loadExtConfigTS(rootDir, extConfigName, extConfigFilePath) {
|
|
82
|
+
var _a;
|
|
83
|
+
try {
|
|
84
|
+
const tsPath = (0, node_1.resolveNode)(rootDir, 'typescript');
|
|
85
|
+
if (!tsPath) {
|
|
86
|
+
(0, errors_1.fatal)('Could not find installation of TypeScript.\n' +
|
|
87
|
+
`To use ${colors_1.default.strong(extConfigName)} files, you must install TypeScript in your project, e.g. w/ ${colors_1.default.input('npm install -D typescript')}`);
|
|
88
|
+
}
|
|
89
|
+
const ts = require(tsPath); // eslint-disable-line @typescript-eslint/no-var-requires
|
|
90
|
+
const extConfigObject = (0, node_1.requireTS)(ts, extConfigFilePath);
|
|
91
|
+
const extConfig = extConfigObject.default ? await extConfigObject.default : extConfigObject;
|
|
92
|
+
return {
|
|
93
|
+
extConfigType: 'ts',
|
|
94
|
+
extConfigName,
|
|
95
|
+
extConfigFilePath: extConfigFilePath,
|
|
96
|
+
extConfig,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
if (!(0, errors_1.isFatal)(e)) {
|
|
101
|
+
(0, errors_1.fatal)(`Parsing ${colors_1.default.strong(extConfigName)} failed.\n\n${(_a = e.stack) !== null && _a !== void 0 ? _a : e}`);
|
|
102
|
+
}
|
|
103
|
+
throw e;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function loadExtConfigJS(rootDir, extConfigName, extConfigFilePath) {
|
|
107
|
+
var _a;
|
|
108
|
+
try {
|
|
109
|
+
return {
|
|
110
|
+
extConfigType: 'js',
|
|
111
|
+
extConfigName,
|
|
112
|
+
extConfigFilePath: extConfigFilePath,
|
|
113
|
+
extConfig: await require(extConfigFilePath),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
(0, errors_1.fatal)(`Parsing ${colors_1.default.strong(extConfigName)} failed.\n\n${(_a = e.stack) !== null && _a !== void 0 ? _a : e}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async function loadExtConfig(rootDir) {
|
|
121
|
+
var _a;
|
|
122
|
+
const extConfigFilePathTS = (0, path_1.resolve)(rootDir, exports.CONFIG_FILE_NAME_TS);
|
|
123
|
+
if (await (0, fs_extra_1.pathExists)(extConfigFilePathTS)) {
|
|
124
|
+
return loadExtConfigTS(rootDir, exports.CONFIG_FILE_NAME_TS, extConfigFilePathTS);
|
|
125
|
+
}
|
|
126
|
+
const extConfigFilePathJS = (0, path_1.resolve)(rootDir, exports.CONFIG_FILE_NAME_JS);
|
|
127
|
+
if (await (0, fs_extra_1.pathExists)(extConfigFilePathJS)) {
|
|
128
|
+
return loadExtConfigJS(rootDir, exports.CONFIG_FILE_NAME_JS, extConfigFilePathJS);
|
|
129
|
+
}
|
|
130
|
+
const extConfigFilePath = (0, path_1.resolve)(rootDir, exports.CONFIG_FILE_NAME_JSON);
|
|
131
|
+
return {
|
|
132
|
+
extConfigType: 'json',
|
|
133
|
+
extConfigName: exports.CONFIG_FILE_NAME_JSON,
|
|
134
|
+
extConfigFilePath: extConfigFilePath,
|
|
135
|
+
extConfig: (_a = (await (0, fn_1.tryFn)(fs_extra_1.readJSON, extConfigFilePath))) !== null && _a !== void 0 ? _a : {},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
async function loadCLIConfig(rootDir) {
|
|
139
|
+
const assetsDir = 'assets';
|
|
140
|
+
const assetsDirAbs = (0, path_1.join)(rootDir, assetsDir);
|
|
141
|
+
const iosPlatformTemplateArchive = 'ios-spm-template.tar.gz';
|
|
142
|
+
const iosCordovaPluginsTemplateArchive = 'capacitor-cordova-ios-plugins.tar.gz';
|
|
143
|
+
const androidPlatformTemplateArchive = 'android-template.tar.gz';
|
|
144
|
+
const androidCordovaPluginsTemplateArchive = 'capacitor-cordova-android-plugins.tar.gz';
|
|
145
|
+
return {
|
|
146
|
+
rootDir,
|
|
147
|
+
assetsDir,
|
|
148
|
+
assetsDirAbs,
|
|
149
|
+
assets: {
|
|
150
|
+
ios: {
|
|
151
|
+
platformTemplateArchive: iosPlatformTemplateArchive,
|
|
152
|
+
platformTemplateArchiveAbs: (0, path_1.resolve)(assetsDirAbs, iosPlatformTemplateArchive),
|
|
153
|
+
cordovaPluginsTemplateArchive: iosCordovaPluginsTemplateArchive,
|
|
154
|
+
cordovaPluginsTemplateArchiveAbs: (0, path_1.resolve)(assetsDirAbs, iosCordovaPluginsTemplateArchive),
|
|
155
|
+
},
|
|
156
|
+
android: {
|
|
157
|
+
platformTemplateArchive: androidPlatformTemplateArchive,
|
|
158
|
+
platformTemplateArchiveAbs: (0, path_1.resolve)(assetsDirAbs, androidPlatformTemplateArchive),
|
|
159
|
+
cordovaPluginsTemplateArchive: androidCordovaPluginsTemplateArchive,
|
|
160
|
+
cordovaPluginsTemplateArchiveAbs: (0, path_1.resolve)(assetsDirAbs, androidCordovaPluginsTemplateArchive),
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
package: await (0, fs_extra_1.readJSON)((0, path_1.resolve)(rootDir, 'package.json')),
|
|
164
|
+
os: determineOS(process.platform),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
async function loadAndroidConfig(rootDir, extConfig, cliConfig) {
|
|
168
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
169
|
+
const name = 'android';
|
|
170
|
+
const platformDir = (_b = (_a = extConfig.android) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : 'android';
|
|
171
|
+
const platformDirAbs = (0, path_1.resolve)(rootDir, platformDir);
|
|
172
|
+
const appDir = 'app';
|
|
173
|
+
const srcDir = `${appDir}/src`;
|
|
174
|
+
const srcMainDir = `${srcDir}/main`;
|
|
175
|
+
const assetsDir = `${srcMainDir}/assets`;
|
|
176
|
+
const webDir = `${assetsDir}/public`;
|
|
177
|
+
const resDir = `${srcMainDir}/res`;
|
|
178
|
+
let apkPath = `${appDir}/build/outputs/apk/`;
|
|
179
|
+
const flavor = ((_c = extConfig.android) === null || _c === void 0 ? void 0 : _c.flavor) || '';
|
|
180
|
+
if ((_d = extConfig.android) === null || _d === void 0 ? void 0 : _d.flavor) {
|
|
181
|
+
apkPath = `${apkPath}/${(_e = extConfig.android) === null || _e === void 0 ? void 0 : _e.flavor}`;
|
|
182
|
+
}
|
|
183
|
+
const apkName = (0, common_1.parseApkNameFromFlavor)(flavor);
|
|
184
|
+
const buildOutputDir = `${apkPath}/debug`;
|
|
185
|
+
const cordovaPluginsDir = 'capacitor-cordova-android-plugins';
|
|
186
|
+
const studioPath = (0, promise_1.lazy)(() => determineAndroidStudioPath(cliConfig.os));
|
|
187
|
+
const buildOptions = {
|
|
188
|
+
keystorePath: (_g = (_f = extConfig.android) === null || _f === void 0 ? void 0 : _f.buildOptions) === null || _g === void 0 ? void 0 : _g.keystorePath,
|
|
189
|
+
keystorePassword: (_j = (_h = extConfig.android) === null || _h === void 0 ? void 0 : _h.buildOptions) === null || _j === void 0 ? void 0 : _j.keystorePassword,
|
|
190
|
+
keystoreAlias: (_l = (_k = extConfig.android) === null || _k === void 0 ? void 0 : _k.buildOptions) === null || _l === void 0 ? void 0 : _l.keystoreAlias,
|
|
191
|
+
keystoreAliasPassword: (_o = (_m = extConfig.android) === null || _m === void 0 ? void 0 : _m.buildOptions) === null || _o === void 0 ? void 0 : _o.keystoreAliasPassword,
|
|
192
|
+
signingType: (_q = (_p = extConfig.android) === null || _p === void 0 ? void 0 : _p.buildOptions) === null || _q === void 0 ? void 0 : _q.signingType,
|
|
193
|
+
releaseType: (_s = (_r = extConfig.android) === null || _r === void 0 ? void 0 : _r.buildOptions) === null || _s === void 0 ? void 0 : _s.releaseType,
|
|
194
|
+
};
|
|
195
|
+
return {
|
|
196
|
+
name,
|
|
197
|
+
minVersion: '24',
|
|
198
|
+
studioPath,
|
|
199
|
+
platformDir,
|
|
200
|
+
platformDirAbs,
|
|
201
|
+
cordovaPluginsDir,
|
|
202
|
+
cordovaPluginsDirAbs: (0, path_1.resolve)(platformDirAbs, cordovaPluginsDir),
|
|
203
|
+
appDir,
|
|
204
|
+
appDirAbs: (0, path_1.resolve)(platformDirAbs, appDir),
|
|
205
|
+
srcDir,
|
|
206
|
+
srcDirAbs: (0, path_1.resolve)(platformDirAbs, srcDir),
|
|
207
|
+
srcMainDir,
|
|
208
|
+
srcMainDirAbs: (0, path_1.resolve)(platformDirAbs, srcMainDir),
|
|
209
|
+
assetsDir,
|
|
210
|
+
assetsDirAbs: (0, path_1.resolve)(platformDirAbs, assetsDir),
|
|
211
|
+
webDir,
|
|
212
|
+
webDirAbs: (0, path_1.resolve)(platformDirAbs, webDir),
|
|
213
|
+
resDir,
|
|
214
|
+
resDirAbs: (0, path_1.resolve)(platformDirAbs, resDir),
|
|
215
|
+
apkName,
|
|
216
|
+
buildOutputDir,
|
|
217
|
+
buildOutputDirAbs: (0, path_1.resolve)(platformDirAbs, buildOutputDir),
|
|
218
|
+
flavor,
|
|
219
|
+
buildOptions,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
async function loadIOSConfig(rootDir, extConfig) {
|
|
223
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
224
|
+
const name = 'ios';
|
|
225
|
+
const platformDir = (_b = (_a = extConfig.ios) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : 'ios';
|
|
226
|
+
const platformDirAbs = (0, path_1.resolve)(rootDir, platformDir);
|
|
227
|
+
const scheme = (_d = (_c = extConfig.ios) === null || _c === void 0 ? void 0 : _c.scheme) !== null && _d !== void 0 ? _d : 'App';
|
|
228
|
+
const nativeProjectDir = 'App';
|
|
229
|
+
const nativeProjectDirAbs = (0, path_1.resolve)(platformDirAbs, nativeProjectDir);
|
|
230
|
+
const nativeTargetDir = `${nativeProjectDir}/App`;
|
|
231
|
+
const nativeTargetDirAbs = (0, path_1.resolve)(platformDirAbs, nativeTargetDir);
|
|
232
|
+
const nativeXcodeProjDir = `${nativeProjectDir}/App.xcodeproj`;
|
|
233
|
+
const nativeXcodeProjDirAbs = (0, path_1.resolve)(platformDirAbs, nativeXcodeProjDir);
|
|
234
|
+
const nativeXcodeWorkspaceDirAbs = (0, promise_1.lazy)(() => determineXcodeWorkspaceDirAbs(nativeProjectDirAbs));
|
|
235
|
+
const podPath = (0, promise_1.lazy)(() => determineGemfileOrCocoapodPath(rootDir, platformDirAbs, nativeProjectDirAbs));
|
|
236
|
+
const webDirAbs = (0, promise_1.lazy)(() => determineIOSWebDirAbs(nativeProjectDirAbs, nativeTargetDirAbs, nativeXcodeProjDirAbs));
|
|
237
|
+
const cordovaPluginsDir = 'capacitor-cordova-ios-plugins';
|
|
238
|
+
const buildOptions = {
|
|
239
|
+
exportMethod: (_f = (_e = extConfig.ios) === null || _e === void 0 ? void 0 : _e.buildOptions) === null || _f === void 0 ? void 0 : _f.exportMethod,
|
|
240
|
+
xcodeSigningStyle: (_h = (_g = extConfig.ios) === null || _g === void 0 ? void 0 : _g.buildOptions) === null || _h === void 0 ? void 0 : _h.signingStyle,
|
|
241
|
+
signingCertificate: (_k = (_j = extConfig.ios) === null || _j === void 0 ? void 0 : _j.buildOptions) === null || _k === void 0 ? void 0 : _k.signingCertificate,
|
|
242
|
+
provisioningProfile: (_m = (_l = extConfig.ios) === null || _l === void 0 ? void 0 : _l.buildOptions) === null || _m === void 0 ? void 0 : _m.provisioningProfile,
|
|
243
|
+
};
|
|
244
|
+
return {
|
|
245
|
+
name,
|
|
246
|
+
minVersion: '15.0',
|
|
247
|
+
platformDir,
|
|
248
|
+
platformDirAbs,
|
|
249
|
+
scheme,
|
|
250
|
+
cordovaPluginsDir,
|
|
251
|
+
cordovaPluginsDirAbs: (0, path_1.resolve)(platformDirAbs, cordovaPluginsDir),
|
|
252
|
+
nativeProjectDir,
|
|
253
|
+
nativeProjectDirAbs,
|
|
254
|
+
nativeTargetDir,
|
|
255
|
+
nativeTargetDirAbs,
|
|
256
|
+
nativeXcodeProjDir,
|
|
257
|
+
nativeXcodeProjDirAbs,
|
|
258
|
+
nativeXcodeWorkspaceDir: (0, promise_1.lazy)(async () => (0, path_1.relative)(platformDirAbs, await nativeXcodeWorkspaceDirAbs)),
|
|
259
|
+
nativeXcodeWorkspaceDirAbs,
|
|
260
|
+
webDir: (0, promise_1.lazy)(async () => (0, path_1.relative)(platformDirAbs, await webDirAbs)),
|
|
261
|
+
webDirAbs,
|
|
262
|
+
podPath,
|
|
263
|
+
buildOptions,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
async function loadWebConfig(rootDir, webDir) {
|
|
267
|
+
const platformDir = webDir;
|
|
268
|
+
const platformDirAbs = (0, path_1.resolve)(rootDir, platformDir);
|
|
269
|
+
return {
|
|
270
|
+
name: 'web',
|
|
271
|
+
platformDir,
|
|
272
|
+
platformDirAbs,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function determineOS(os) {
|
|
276
|
+
switch (os) {
|
|
277
|
+
case 'darwin':
|
|
278
|
+
return "mac" /* OS.Mac */;
|
|
279
|
+
case 'win32':
|
|
280
|
+
return "windows" /* OS.Windows */;
|
|
281
|
+
case 'linux':
|
|
282
|
+
return "linux" /* OS.Linux */;
|
|
283
|
+
}
|
|
284
|
+
return "unknown" /* OS.Unknown */;
|
|
285
|
+
}
|
|
286
|
+
async function determineXcodeWorkspaceDirAbs(nativeProjectDirAbs) {
|
|
287
|
+
return (0, path_1.resolve)(nativeProjectDirAbs, 'App.xcworkspace');
|
|
288
|
+
}
|
|
289
|
+
async function determineIOSWebDirAbs(nativeProjectDirAbs, nativeTargetDirAbs, nativeXcodeProjDirAbs) {
|
|
290
|
+
const re = /path\s=\spublic[\s\S]+?sourceTree\s=\s([^;]+)/;
|
|
291
|
+
const pbxprojPath = (0, path_1.resolve)(nativeXcodeProjDirAbs, 'project.pbxproj');
|
|
292
|
+
try {
|
|
293
|
+
const pbxproj = await (0, fs_extra_1.readFile)(pbxprojPath, { encoding: 'utf8' });
|
|
294
|
+
const m = pbxproj.match(re);
|
|
295
|
+
if (m && m[1] === 'SOURCE_ROOT') {
|
|
296
|
+
log_1.logger.warn(`Using the iOS project root for the ${colors_1.default.strong('public')} directory is deprecated.\n` +
|
|
297
|
+
`Please follow the Upgrade Guide to move ${colors_1.default.strong('public')} inside the iOS target directory: ${colors_1.default.strong('https://capacitorjs.com/docs/updating/3-0#move-public-into-the-ios-target-directory')}`);
|
|
298
|
+
return (0, path_1.resolve)(nativeProjectDirAbs, 'public');
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
catch (e) {
|
|
302
|
+
// ignore
|
|
303
|
+
}
|
|
304
|
+
return (0, path_1.resolve)(nativeTargetDirAbs, 'public');
|
|
305
|
+
}
|
|
306
|
+
async function determineAndroidStudioPath(os) {
|
|
307
|
+
if (process.env.CAPACITOR_ANDROID_STUDIO_PATH) {
|
|
308
|
+
return process.env.CAPACITOR_ANDROID_STUDIO_PATH;
|
|
309
|
+
}
|
|
310
|
+
switch (os) {
|
|
311
|
+
case "mac" /* OS.Mac */:
|
|
312
|
+
return '/Applications/Android Studio.app';
|
|
313
|
+
case "windows" /* OS.Windows */: {
|
|
314
|
+
const { runCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./util/subprocess')));
|
|
315
|
+
let p = 'C:\\Program Files\\Android\\Android Studio\\bin\\studio64.exe';
|
|
316
|
+
try {
|
|
317
|
+
if (!(await (0, fs_extra_1.pathExists)(p))) {
|
|
318
|
+
let commandResult = await runCommand('REG', [
|
|
319
|
+
'QUERY',
|
|
320
|
+
'HKEY_LOCAL_MACHINE\\SOFTWARE\\Android Studio',
|
|
321
|
+
'/v',
|
|
322
|
+
'Path',
|
|
323
|
+
]);
|
|
324
|
+
commandResult = commandResult.replace(/(\r\n|\n|\r)/gm, '');
|
|
325
|
+
const i = commandResult.indexOf('REG_SZ');
|
|
326
|
+
if (i > 0) {
|
|
327
|
+
p = commandResult.substring(i + 6).trim() + '\\bin\\studio64.exe';
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
catch (e) {
|
|
332
|
+
debug(`Error checking registry for Android Studio path: %O`, e);
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
return p;
|
|
336
|
+
}
|
|
337
|
+
case "linux" /* OS.Linux */: {
|
|
338
|
+
const studioExecPath = '/usr/local/android-studio/bin/studio';
|
|
339
|
+
const studioShPath = '/usr/local/android-studio/bin/studio.sh';
|
|
340
|
+
try {
|
|
341
|
+
if (await (0, fs_extra_1.pathExists)(studioExecPath)) {
|
|
342
|
+
return studioExecPath;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
catch (e) {
|
|
346
|
+
debug(`Error checking for studio executable: %O`, e);
|
|
347
|
+
}
|
|
348
|
+
return studioShPath;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return '';
|
|
352
|
+
}
|
|
353
|
+
async function determineGemfileOrCocoapodPath(rootDir, platformDir, nativeProjectDirAbs) {
|
|
354
|
+
if (process.env.CAPACITOR_COCOAPODS_PATH) {
|
|
355
|
+
return process.env.CAPACITOR_COCOAPODS_PATH;
|
|
356
|
+
}
|
|
357
|
+
let gemfilePath = '';
|
|
358
|
+
if (await (0, fs_extra_1.pathExists)((0, path_1.resolve)(rootDir, 'Gemfile'))) {
|
|
359
|
+
gemfilePath = (0, path_1.resolve)(rootDir, 'Gemfile');
|
|
360
|
+
}
|
|
361
|
+
else if (await (0, fs_extra_1.pathExists)((0, path_1.resolve)(platformDir, 'Gemfile'))) {
|
|
362
|
+
gemfilePath = (0, path_1.resolve)(platformDir, 'Gemfile');
|
|
363
|
+
}
|
|
364
|
+
else if (await (0, fs_extra_1.pathExists)((0, path_1.resolve)(nativeProjectDirAbs, 'Gemfile'))) {
|
|
365
|
+
gemfilePath = (0, path_1.resolve)(nativeProjectDirAbs, 'Gemfile');
|
|
366
|
+
}
|
|
367
|
+
const appSpecificGemfileExists = gemfilePath != '';
|
|
368
|
+
// Multi-app projects might share a single global 'Gemfile' at the Git repository root directory.
|
|
369
|
+
if (!appSpecificGemfileExists) {
|
|
370
|
+
try {
|
|
371
|
+
const output = await (0, subprocess_1.getCommandOutput)('git', ['rev-parse', '--show-toplevel'], { cwd: rootDir });
|
|
372
|
+
if (output != null) {
|
|
373
|
+
gemfilePath = (0, path_1.resolve)(output, 'Gemfile');
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
catch (e) {
|
|
377
|
+
// Nothing
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
try {
|
|
381
|
+
const gemfileText = (await (0, fs_extra_1.readFile)(gemfilePath)).toString();
|
|
382
|
+
if (!gemfileText) {
|
|
383
|
+
return 'pod';
|
|
384
|
+
}
|
|
385
|
+
const cocoapodsInGemfile = new RegExp(/gem\s+['"]cocoapods/).test(gemfileText);
|
|
386
|
+
if (cocoapodsInGemfile) {
|
|
387
|
+
return 'bundle exec pod';
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
return 'pod';
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
catch {
|
|
394
|
+
return 'pod';
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
function formatConfigTS(extConfig) {
|
|
398
|
+
// TODO: <reference> tags
|
|
399
|
+
return `import type { CapacitorConfig } from '@capacitor/cli';
|
|
400
|
+
|
|
401
|
+
const config: CapacitorConfig = ${(0, js_1.formatJSObject)(extConfig)};
|
|
402
|
+
|
|
403
|
+
export default config;\n`;
|
|
404
|
+
}
|