@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.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +84 -0
  3. package/assets/android-template.tar.gz +0 -0
  4. package/assets/capacitor-cordova-android-plugins.tar.gz +0 -0
  5. package/assets/capacitor-cordova-ios-plugins.tar.gz +0 -0
  6. package/assets/ios-pods-template.tar.gz +0 -0
  7. package/assets/ios-spm-template.tar.gz +0 -0
  8. package/bin/capacitor +18 -0
  9. package/dist/android/add.js +52 -0
  10. package/dist/android/build.js +104 -0
  11. package/dist/android/common.js +94 -0
  12. package/dist/android/doctor.js +160 -0
  13. package/dist/android/open.js +28 -0
  14. package/dist/android/run.js +42 -0
  15. package/dist/android/update.js +317 -0
  16. package/dist/colors.js +26 -0
  17. package/dist/common.js +435 -0
  18. package/dist/config.js +404 -0
  19. package/dist/cordova.js +801 -0
  20. package/dist/declarations.d.ts +674 -0
  21. package/dist/declarations.js +2 -0
  22. package/dist/definitions.js +13 -0
  23. package/dist/errors.js +27 -0
  24. package/dist/framework-configs.js +109 -0
  25. package/dist/index.js +253 -0
  26. package/dist/ios/add.js +13 -0
  27. package/dist/ios/build.js +96 -0
  28. package/dist/ios/common.js +105 -0
  29. package/dist/ios/doctor.js +45 -0
  30. package/dist/ios/open.js +17 -0
  31. package/dist/ios/run.js +51 -0
  32. package/dist/ios/update.js +449 -0
  33. package/dist/ipc.js +61 -0
  34. package/dist/log.js +39 -0
  35. package/dist/plugin.js +182 -0
  36. package/dist/sysconfig.js +35 -0
  37. package/dist/tasks/add.js +115 -0
  38. package/dist/tasks/build.js +63 -0
  39. package/dist/tasks/config.js +28 -0
  40. package/dist/tasks/copy.js +210 -0
  41. package/dist/tasks/create.js +10 -0
  42. package/dist/tasks/doctor.js +68 -0
  43. package/dist/tasks/init.js +138 -0
  44. package/dist/tasks/list.js +50 -0
  45. package/dist/tasks/migrate-spm.js +19 -0
  46. package/dist/tasks/migrate.js +518 -0
  47. package/dist/tasks/new-plugin.js +10 -0
  48. package/dist/tasks/open.js +62 -0
  49. package/dist/tasks/run.js +118 -0
  50. package/dist/tasks/serve.js +11 -0
  51. package/dist/tasks/sourcemaps.js +39 -0
  52. package/dist/tasks/sync.js +55 -0
  53. package/dist/tasks/telemetry.js +41 -0
  54. package/dist/tasks/update.js +74 -0
  55. package/dist/telemetry.js +119 -0
  56. package/dist/util/cli.js +25 -0
  57. package/dist/util/emoji.js +13 -0
  58. package/dist/util/fn.js +13 -0
  59. package/dist/util/fs.js +43 -0
  60. package/dist/util/iosplugin.js +66 -0
  61. package/dist/util/js.js +21 -0
  62. package/dist/util/livereload.js +148 -0
  63. package/dist/util/monorepotools.js +109 -0
  64. package/dist/util/native-run.js +63 -0
  65. package/dist/util/node.js +54 -0
  66. package/dist/util/promise.js +35 -0
  67. package/dist/util/spm.js +187 -0
  68. package/dist/util/subprocess.js +37 -0
  69. package/dist/util/template.js +11 -0
  70. package/dist/util/term.js +30 -0
  71. package/dist/util/uuid.js +11 -0
  72. package/dist/util/xml.js +55 -0
  73. package/package.json +89 -0
package/dist/common.js ADDED
@@ -0,0 +1,435 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
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
+ const tslib_1 = require("tslib");
5
+ const utils_terminal_1 = require("@ionic/utils-terminal");
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 errors_1 = require("./errors");
10
+ const log_1 = require("./log");
11
+ const plugin_1 = require("./plugin");
12
+ const monorepotools_1 = require("./util/monorepotools");
13
+ const node_1 = require("./util/node");
14
+ const subprocess_1 = require("./util/subprocess");
15
+ async function check(checks) {
16
+ const results = await Promise.all(checks.map((f) => f()));
17
+ const errors = results.filter((r) => r != null);
18
+ if (errors.length > 0) {
19
+ throw errors.join('\n');
20
+ }
21
+ }
22
+ exports.check = check;
23
+ async function checkWebDir(config) {
24
+ var _a;
25
+ // We can skip checking the web dir if a server URL is set.
26
+ if ((_a = config.app.extConfig.server) === null || _a === void 0 ? void 0 : _a.url) {
27
+ return null;
28
+ }
29
+ const invalidFolders = ['', '.', '..', '../', './'];
30
+ if (invalidFolders.includes(config.app.webDir)) {
31
+ return `"${config.app.webDir}" is not a valid value for webDir`;
32
+ }
33
+ if (!(await (0, fs_extra_1.pathExists)(config.app.webDirAbs))) {
34
+ return (`Could not find the web assets directory: ${colors_1.default.strong((0, utils_terminal_1.prettyPath)(config.app.webDirAbs))}.\n` +
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
+ }
37
+ if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(config.app.webDirAbs, 'index.html')))) {
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
+ `It will be the entry point for the web portion of the Capacitor app.`);
40
+ }
41
+ return null;
42
+ }
43
+ exports.checkWebDir = checkWebDir;
44
+ async function checkPackage() {
45
+ if (!(await (0, fs_extra_1.pathExists)('package.json'))) {
46
+ if (await (0, fs_extra_1.pathExists)('project.json')) {
47
+ return null;
48
+ }
49
+ else {
50
+ return (`The Capacitor CLI needs to run at the root of an npm package or in a valid NX monorepo.\n` +
51
+ `Make sure you have a package.json or project.json file in the directory where you run the Capacitor CLI.\n` +
52
+ `More info: ${colors_1.default.strong('https://docs.npmjs.com/cli/init')}`);
53
+ }
54
+ }
55
+ return null;
56
+ }
57
+ exports.checkPackage = checkPackage;
58
+ async function checkCapacitorPlatform(config, platform) {
59
+ const pkg = await getCapacitorPackage(config, platform);
60
+ if (!pkg) {
61
+ return (`Could not find the ${colors_1.default.input(platform)} platform.\n` +
62
+ `You must install it in your project first, e.g. w/ ${colors_1.default.input(`npm install @capacitor/${platform}`)}`);
63
+ }
64
+ return null;
65
+ }
66
+ exports.checkCapacitorPlatform = checkCapacitorPlatform;
67
+ async function checkAppConfig(config) {
68
+ if (!config.app.appId) {
69
+ return (`Missing ${colors_1.default.input('appId')} for new platform.\n` +
70
+ `Please add it in ${config.app.extConfigName} or run ${colors_1.default.input('npx cap init')}.`);
71
+ }
72
+ if (!config.app.appName) {
73
+ return (`Missing ${colors_1.default.input('appName')} for new platform.\n` +
74
+ `Please add it in ${config.app.extConfigName} or run ${colors_1.default.input('npx cap init')}.`);
75
+ }
76
+ const appIdError = await checkAppId(config, config.app.appId);
77
+ if (appIdError) {
78
+ return appIdError;
79
+ }
80
+ const appNameError = await checkAppName(config, config.app.appName);
81
+ if (appNameError) {
82
+ return appNameError;
83
+ }
84
+ return null;
85
+ }
86
+ exports.checkAppConfig = checkAppConfig;
87
+ async function checkAppDir(config, dir) {
88
+ if (!/^\S*$/.test(dir)) {
89
+ return `Your app directory should not contain spaces`;
90
+ }
91
+ return null;
92
+ }
93
+ exports.checkAppDir = checkAppDir;
94
+ async function checkAppId(config, id) {
95
+ if (!id) {
96
+ return `Invalid App ID. App ID is required and cannot be blank.`;
97
+ }
98
+ if (/^[a-zA-Z][\w]*(?:\.[a-zA-Z][\w]*)+$/.test(id.toLowerCase())) {
99
+ return null;
100
+ }
101
+ return `
102
+ Invalid App ID "${id}". Your App ID must meet the following requirements to be valid on both iOS and Android:
103
+ - Must be in Java package form with no dashes (ex: com.example.app)
104
+ - It must have at least two segments (one or more dots).
105
+ - Each segment must start with a letter.
106
+ - All characters must be alphanumeric or an underscore [a-zA-Z][a-zA-Z0-9]+.
107
+
108
+ If you would like to skip validation, run "cap init" with the "--skip-appid-validation" flag.
109
+ `;
110
+ }
111
+ exports.checkAppId = checkAppId;
112
+ async function checkAppName(config, name) {
113
+ // We allow pretty much anything right now, have fun
114
+ if (!(name === null || name === void 0 ? void 0 : name.length)) {
115
+ return `Must provide an app name. For example: 'Spacebook'`;
116
+ }
117
+ return null;
118
+ }
119
+ exports.checkAppName = checkAppName;
120
+ async function wait(time) {
121
+ return new Promise((resolve) => setTimeout(resolve, time));
122
+ }
123
+ exports.wait = wait;
124
+ async function runHooks(config, platformName, dir, hook) {
125
+ await runPlatformHook(config, platformName, dir, hook);
126
+ const allPlugins = await (0, plugin_1.getPlugins)(config, platformName);
127
+ for (const p of allPlugins) {
128
+ await runPlatformHook(config, platformName, p.rootPath, hook);
129
+ }
130
+ }
131
+ exports.runHooks = runHooks;
132
+ async function runPlatformHook(config, platformName, platformDir, hook) {
133
+ var _a;
134
+ const { spawn } = await Promise.resolve().then(() => tslib_1.__importStar(require('child_process')));
135
+ let pkg;
136
+ if ((0, monorepotools_1.isNXMonorepo)(platformDir)) {
137
+ pkg = await (0, fs_extra_1.readJSON)((0, path_1.join)((0, monorepotools_1.findNXMonorepoRoot)(platformDir), 'package.json'));
138
+ }
139
+ else {
140
+ pkg = await (0, fs_extra_1.readJSON)((0, path_1.join)(platformDir, 'package.json'));
141
+ }
142
+ const cmd = (_a = pkg.scripts) === null || _a === void 0 ? void 0 : _a[hook];
143
+ if (!cmd) {
144
+ return;
145
+ }
146
+ return new Promise((resolve, reject) => {
147
+ const p = spawn(cmd, {
148
+ stdio: 'inherit',
149
+ shell: true,
150
+ cwd: platformDir,
151
+ env: {
152
+ INIT_CWD: platformDir,
153
+ CAPACITOR_ROOT_DIR: config.app.rootDir,
154
+ CAPACITOR_WEB_DIR: config.app.webDirAbs,
155
+ CAPACITOR_CONFIG: JSON.stringify(config.app.extConfig),
156
+ CAPACITOR_PLATFORM_NAME: platformName,
157
+ ...process.env,
158
+ },
159
+ });
160
+ p.on('close', (code) => {
161
+ if (code === 0) {
162
+ resolve();
163
+ }
164
+ else {
165
+ reject(new Error(`${hook} hook on ${platformName} failed with error code: ${code} while running command: ${cmd}`));
166
+ }
167
+ });
168
+ p.on('error', (err) => {
169
+ reject(err);
170
+ });
171
+ });
172
+ }
173
+ exports.runPlatformHook = runPlatformHook;
174
+ async function runTask(title, fn) {
175
+ const chain = log_1.output.createTaskChain();
176
+ chain.next(title);
177
+ try {
178
+ const value = await fn();
179
+ chain.end();
180
+ return value;
181
+ }
182
+ catch (e) {
183
+ chain.fail();
184
+ throw e;
185
+ }
186
+ }
187
+ exports.runTask = runTask;
188
+ async function getCapacitorPackage(config, name) {
189
+ const packagePath = (0, node_1.resolveNode)(config.app.rootDir, `@capacitor/${name}`, 'package.json');
190
+ if (!packagePath) {
191
+ return null;
192
+ }
193
+ return (0, fs_extra_1.readJSON)(packagePath);
194
+ }
195
+ exports.getCapacitorPackage = getCapacitorPackage;
196
+ async function requireCapacitorPackage(config, name) {
197
+ const pkg = await getCapacitorPackage(config, name);
198
+ if (!pkg) {
199
+ (0, errors_1.fatal)(`Unable to find node_modules/@capacitor/${name}.\n` +
200
+ `Are you sure ${colors_1.default.strong(`@capacitor/${name}`)} is installed?`);
201
+ }
202
+ return pkg;
203
+ }
204
+ exports.requireCapacitorPackage = requireCapacitorPackage;
205
+ async function getCapacitorPackageVersion(config, platform) {
206
+ return (await requireCapacitorPackage(config, platform)).version;
207
+ }
208
+ exports.getCapacitorPackageVersion = getCapacitorPackageVersion;
209
+ async function getCoreVersion(config) {
210
+ return getCapacitorPackageVersion(config, 'core');
211
+ }
212
+ exports.getCoreVersion = getCoreVersion;
213
+ async function getCLIVersion(config) {
214
+ return getCapacitorPackageVersion(config, 'cli');
215
+ }
216
+ exports.getCLIVersion = getCLIVersion;
217
+ function getPlatformDirectory(config, platform) {
218
+ switch (platform) {
219
+ case 'android':
220
+ return config.android.platformDirAbs;
221
+ case 'ios':
222
+ return config.ios.platformDirAbs;
223
+ case 'web':
224
+ return config.web.platformDirAbs;
225
+ }
226
+ return null;
227
+ }
228
+ async function getProjectPlatformDirectory(config, platform) {
229
+ const platformPath = getPlatformDirectory(config, platform);
230
+ if (platformPath && (await (0, fs_extra_1.pathExists)(platformPath))) {
231
+ return platformPath;
232
+ }
233
+ return null;
234
+ }
235
+ exports.getProjectPlatformDirectory = getProjectPlatformDirectory;
236
+ async function selectPlatforms(config, selectedPlatformName) {
237
+ if (selectedPlatformName) {
238
+ // already passed in a platform name
239
+ const platformName = selectedPlatformName.toLowerCase().trim();
240
+ if (!(await isValidPlatform(platformName))) {
241
+ (0, errors_1.fatal)(`Invalid platform: ${colors_1.default.input(platformName)}`);
242
+ }
243
+ else if (!(await getProjectPlatformDirectory(config, platformName))) {
244
+ if (platformName === 'web') {
245
+ (0, errors_1.fatal)(`Could not find the web platform directory.\n` + `Make sure ${colors_1.default.strong(config.app.webDir)} exists.`);
246
+ }
247
+ (0, errors_1.fatal)(`${colors_1.default.strong(platformName)} platform has not been added yet.\n` +
248
+ `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`)}`);
249
+ }
250
+ // return the platform in an string array
251
+ return [platformName];
252
+ }
253
+ // wasn't given a platform name, so let's
254
+ // get the platforms that have already been created
255
+ return getAddedPlatforms(config);
256
+ }
257
+ exports.selectPlatforms = selectPlatforms;
258
+ async function getKnownPlatforms() {
259
+ return ['web', 'android', 'ios'];
260
+ }
261
+ exports.getKnownPlatforms = getKnownPlatforms;
262
+ async function isValidPlatform(platform) {
263
+ return (await getKnownPlatforms()).includes(platform);
264
+ }
265
+ exports.isValidPlatform = isValidPlatform;
266
+ async function getKnownCommunityPlatforms() {
267
+ return ['electron'];
268
+ }
269
+ exports.getKnownCommunityPlatforms = getKnownCommunityPlatforms;
270
+ async function isValidCommunityPlatform(platform) {
271
+ return (await getKnownCommunityPlatforms()).includes(platform);
272
+ }
273
+ exports.isValidCommunityPlatform = isValidCommunityPlatform;
274
+ async function getKnownEnterprisePlatforms() {
275
+ return ['windows'];
276
+ }
277
+ exports.getKnownEnterprisePlatforms = getKnownEnterprisePlatforms;
278
+ async function isValidEnterprisePlatform(platform) {
279
+ return (await getKnownEnterprisePlatforms()).includes(platform);
280
+ }
281
+ exports.isValidEnterprisePlatform = isValidEnterprisePlatform;
282
+ async function promptForPlatform(platforms, promptMessage, selectedPlatformName) {
283
+ const { prompt } = await Promise.resolve().then(() => tslib_1.__importStar(require('prompts')));
284
+ if (!selectedPlatformName) {
285
+ const answers = await prompt([
286
+ {
287
+ type: 'select',
288
+ name: 'mode',
289
+ message: promptMessage,
290
+ choices: platforms.map((p) => ({ title: p, value: p })),
291
+ },
292
+ ], { onCancel: () => process.exit(1) });
293
+ return answers.mode.toLowerCase().trim();
294
+ }
295
+ const platformName = selectedPlatformName.toLowerCase().trim();
296
+ if (!(await isValidPlatform(platformName))) {
297
+ const knownPlatforms = await getKnownPlatforms();
298
+ (0, errors_1.fatal)(`Invalid platform: ${colors_1.default.input(platformName)}.\n` + `Valid platforms include: ${knownPlatforms.join(', ')}`);
299
+ }
300
+ return platformName;
301
+ }
302
+ exports.promptForPlatform = promptForPlatform;
303
+ async function promptForPlatformTarget(targets, selectedTarget, selectedTargetSdkVersion, selectByName) {
304
+ const { prompt } = await Promise.resolve().then(() => tslib_1.__importStar(require('prompts')));
305
+ const validTargets = targets.filter((t) => t.id !== undefined);
306
+ if (!selectedTarget) {
307
+ if (validTargets.length === 1) {
308
+ return validTargets[0];
309
+ }
310
+ else {
311
+ const answers = await prompt([
312
+ {
313
+ type: 'select',
314
+ name: 'target',
315
+ message: 'Please choose a target device:',
316
+ choices: validTargets.map((t) => ({
317
+ title: `${getPlatformTargetName(t)} (${t.id})`,
318
+ value: t,
319
+ })),
320
+ },
321
+ ], { onCancel: () => process.exit(1) });
322
+ return answers.target;
323
+ }
324
+ }
325
+ const targetID = selectedTarget.trim();
326
+ const target = targets.find((t) => {
327
+ var _a;
328
+ if (selectByName === true) {
329
+ let name = (_a = t.name) !== null && _a !== void 0 ? _a : t.model;
330
+ if (name) {
331
+ // Apple device names may have "smart quotes" in the name,
332
+ // strip them and replace them with the "straight" versions
333
+ name = name.replace(/[\u2018\u2019]/g, "'").replace(/[\u201C\u201D]/g, '"');
334
+ }
335
+ if (selectedTargetSdkVersion) {
336
+ return name === targetID && t.sdkVersion === selectedTargetSdkVersion;
337
+ }
338
+ return name === targetID;
339
+ }
340
+ return t.id === targetID;
341
+ });
342
+ if (!target) {
343
+ if (selectByName) {
344
+ let invalidTargetName = targetID;
345
+ if (selectedTargetSdkVersion) {
346
+ invalidTargetName += ` [${selectedTargetSdkVersion}]`;
347
+ }
348
+ (0, errors_1.fatal)(`Invalid target name: ${colors_1.default.input(invalidTargetName)}.\n` +
349
+ `Valid targets are:\n ${targets.map((t) => { var _a; return `${(_a = t.name) !== null && _a !== void 0 ? _a : t.model} [${t.sdkVersion}]`; }).join('\n')}`);
350
+ }
351
+ (0, errors_1.fatal)(`Invalid target ID: ${colors_1.default.input(targetID)}.\n` + `Valid targets are:\n ${targets.map((t) => t.id).join('\n')}`);
352
+ }
353
+ return target;
354
+ }
355
+ exports.promptForPlatformTarget = promptForPlatformTarget;
356
+ function getPlatformTargetName(target) {
357
+ var _a, _b, _c;
358
+ return `${(_c = (_b = (_a = target.name) !== null && _a !== void 0 ? _a : target.model) !== null && _b !== void 0 ? _b : target.id) !== null && _c !== void 0 ? _c : '?'}${target.virtual ? ` (${target.platform === 'ios' ? 'simulator' : 'emulator'})` : ''}`;
359
+ }
360
+ exports.getPlatformTargetName = getPlatformTargetName;
361
+ async function getAddedPlatforms(config) {
362
+ const platforms = [];
363
+ if (await getProjectPlatformDirectory(config, config.android.name)) {
364
+ platforms.push(config.android.name);
365
+ }
366
+ if (await getProjectPlatformDirectory(config, config.ios.name)) {
367
+ platforms.push(config.ios.name);
368
+ }
369
+ platforms.push(config.web.name);
370
+ return platforms;
371
+ }
372
+ exports.getAddedPlatforms = getAddedPlatforms;
373
+ async function checkPlatformVersions(config, platform) {
374
+ const semver = await Promise.resolve().then(() => tslib_1.__importStar(require('semver')));
375
+ const coreVersion = await getCoreVersion(config);
376
+ const platformVersion = await getCapacitorPackageVersion(config, platform);
377
+ if (semver.diff(coreVersion, platformVersion) === 'minor' || semver.diff(coreVersion, platformVersion) === 'major') {
378
+ log_1.logger.warn(`${colors_1.default.strong('@capacitor/core')}${colors_1.default.weak(`@${coreVersion}`)} version doesn't match ${colors_1.default.strong(`@capacitor/${platform}`)}${colors_1.default.weak(`@${platformVersion}`)} version.\n` +
379
+ `Consider updating to a matching version, e.g. w/ ${colors_1.default.input(`npm install @capacitor/core@${platformVersion}`)}`);
380
+ }
381
+ }
382
+ exports.checkPlatformVersions = checkPlatformVersions;
383
+ function resolvePlatform(config, platform) {
384
+ if (platform[0] !== '@') {
385
+ const core = (0, node_1.resolveNode)(config.app.rootDir, `@capacitor/${platform}`, 'package.json');
386
+ if (core) {
387
+ return (0, path_1.dirname)(core);
388
+ }
389
+ const community = (0, node_1.resolveNode)(config.app.rootDir, `@capacitor-community/${platform}`, 'package.json');
390
+ if (community) {
391
+ return (0, path_1.dirname)(community);
392
+ }
393
+ const enterprise = (0, node_1.resolveNode)(config.app.rootDir, `@ionic-enterprise/capacitor-${platform}`, 'package.json');
394
+ if (enterprise) {
395
+ return (0, path_1.dirname)(enterprise);
396
+ }
397
+ }
398
+ // third-party
399
+ const thirdParty = (0, node_1.resolveNode)(config.app.rootDir, platform, 'package.json');
400
+ if (thirdParty) {
401
+ return (0, path_1.dirname)(thirdParty);
402
+ }
403
+ return null;
404
+ }
405
+ exports.resolvePlatform = resolvePlatform;
406
+ async function checkJDKMajorVersion() {
407
+ try {
408
+ const string = await (0, subprocess_1.runCommand)('java', ['--version']);
409
+ const versionRegex = RegExp(/([0-9]+)\.?([0-9]*)\.?([0-9]*)/);
410
+ const versionMatch = versionRegex.exec(string);
411
+ if (versionMatch === null) {
412
+ return -1;
413
+ }
414
+ const firstVersionNumber = parseInt(versionMatch[1]);
415
+ const secondVersionNumber = parseInt(versionMatch[2]);
416
+ if (typeof firstVersionNumber === 'number' && firstVersionNumber != 1) {
417
+ return firstVersionNumber;
418
+ }
419
+ else if (typeof secondVersionNumber === 'number' && firstVersionNumber == 1 && secondVersionNumber < 9) {
420
+ return secondVersionNumber;
421
+ }
422
+ else {
423
+ return -1;
424
+ }
425
+ }
426
+ catch (e) {
427
+ return -1;
428
+ }
429
+ }
430
+ exports.checkJDKMajorVersion = checkJDKMajorVersion;
431
+ function parseApkNameFromFlavor(flavor) {
432
+ const convertedName = flavor.replace(/([A-Z])/g, '$1').toLowerCase();
433
+ return `app-${convertedName ? `${convertedName}-` : ''}debug.apk`;
434
+ }
435
+ exports.parseApkNameFromFlavor = parseApkNameFromFlavor;