@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
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.doctor = exports.doctorCore = exports.doctorCommand = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs_extra_1 = require("fs-extra");
6
+ const doctor_1 = require("../android/doctor");
7
+ const colors_1 = tslib_1.__importDefault(require("../colors"));
8
+ const common_1 = require("../common");
9
+ const doctor_2 = require("../ios/doctor");
10
+ const log_1 = require("../log");
11
+ const emoji_1 = require("../util/emoji");
12
+ const node_1 = require("../util/node");
13
+ const subprocess_1 = require("../util/subprocess");
14
+ async function doctorCommand(config, selectedPlatformName) {
15
+ log_1.output.write(`${(0, emoji_1.emoji)('💊', '')} ${colors_1.default.strong('Capacitor Doctor')} ${(0, emoji_1.emoji)('💊', '')} \n\n`);
16
+ await doctorCore(config);
17
+ const platforms = await (0, common_1.selectPlatforms)(config, selectedPlatformName);
18
+ await Promise.all(platforms.map((platformName) => {
19
+ return doctor(config, platformName);
20
+ }));
21
+ }
22
+ exports.doctorCommand = doctorCommand;
23
+ async function doctorCore(config) {
24
+ const [cliVersion, coreVersion, androidVersion, iosVersion] = await Promise.all([
25
+ (0, subprocess_1.getCommandOutput)('npm', ['info', '@capacitor/cli', 'version']),
26
+ (0, subprocess_1.getCommandOutput)('npm', ['info', '@capacitor/core', 'version']),
27
+ (0, subprocess_1.getCommandOutput)('npm', ['info', '@capacitor/android', 'version']),
28
+ (0, subprocess_1.getCommandOutput)('npm', ['info', '@capacitor/ios', 'version']),
29
+ ]);
30
+ log_1.output.write(`${colors_1.default.strong('Latest Dependencies:')}\n\n` +
31
+ ` @capacitor/cli: ${colors_1.default.weak(cliVersion !== null && cliVersion !== void 0 ? cliVersion : 'unknown')}\n` +
32
+ ` @capacitor/core: ${colors_1.default.weak(coreVersion !== null && coreVersion !== void 0 ? coreVersion : 'unknown')}\n` +
33
+ ` @capacitor/android: ${colors_1.default.weak(androidVersion !== null && androidVersion !== void 0 ? androidVersion : 'unknown')}\n` +
34
+ ` @capacitor/ios: ${colors_1.default.weak(iosVersion !== null && iosVersion !== void 0 ? iosVersion : 'unknown')}\n\n` +
35
+ `${colors_1.default.strong('Installed Dependencies:')}\n\n`);
36
+ await printInstalledPackages(config);
37
+ log_1.output.write('\n');
38
+ }
39
+ exports.doctorCore = doctorCore;
40
+ async function printInstalledPackages(config) {
41
+ const packageNames = ['@capacitor/cli', '@capacitor/core', '@capacitor/android', '@capacitor/ios'];
42
+ await Promise.all(packageNames.map(async (packageName) => {
43
+ const packagePath = (0, node_1.resolveNode)(config.app.rootDir, packageName, 'package.json');
44
+ await printPackageVersion(packageName, packagePath);
45
+ }));
46
+ }
47
+ async function printPackageVersion(packageName, packagePath) {
48
+ let version;
49
+ if (packagePath) {
50
+ version = (await (0, fs_extra_1.readJSON)(packagePath)).version;
51
+ }
52
+ log_1.output.write(` ${packageName}: ${colors_1.default.weak(version || 'not installed')}\n`);
53
+ }
54
+ async function doctor(config, platformName) {
55
+ if (platformName === config.ios.name) {
56
+ await (0, doctor_2.doctorIOS)(config);
57
+ }
58
+ else if (platformName === config.android.name) {
59
+ await (0, doctor_1.doctorAndroid)(config);
60
+ }
61
+ else if (platformName === config.web.name) {
62
+ return Promise.resolve();
63
+ }
64
+ else {
65
+ throw `Platform ${platformName} is not valid.`;
66
+ }
67
+ }
68
+ exports.doctor = doctor;
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initCommand = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const open_1 = tslib_1.__importDefault(require("open"));
6
+ const path_1 = require("path");
7
+ const colors_1 = tslib_1.__importDefault(require("../colors"));
8
+ const common_1 = require("../common");
9
+ const config_1 = require("../config");
10
+ const cordova_1 = require("../cordova");
11
+ const errors_1 = require("../errors");
12
+ const framework_configs_1 = require("../framework-configs");
13
+ const log_1 = require("../log");
14
+ const sysconfig_1 = require("../sysconfig");
15
+ const node_1 = require("../util/node");
16
+ const term_1 = require("../util/term");
17
+ async function initCommand(config, name, id, webDirFromCLI, skipAppIDValidation) {
18
+ var _a, _b;
19
+ try {
20
+ if (!(0, term_1.checkInteractive)(name, id)) {
21
+ return;
22
+ }
23
+ if (config.app.extConfigType !== 'json') {
24
+ (0, errors_1.fatal)(`Cannot run ${colors_1.default.input('init')} for a project using a non-JSON configuration file.\n` +
25
+ `Delete ${colors_1.default.strong(config.app.extConfigName)} and try again.`);
26
+ }
27
+ const isNewConfig = Object.keys(config.app.extConfig).length === 0;
28
+ const tsInstalled = !!(0, node_1.resolveNode)(config.app.rootDir, 'typescript');
29
+ const appName = await getName(config, name);
30
+ const appId = await getAppId(config, id);
31
+ const webDir = (0, term_1.isInteractive)()
32
+ ? await getWebDir(config, webDirFromCLI)
33
+ : ((_a = webDirFromCLI !== null && webDirFromCLI !== void 0 ? webDirFromCLI : config.app.extConfig.webDir) !== null && _a !== void 0 ? _a : 'www');
34
+ if (skipAppIDValidation === true) {
35
+ await (0, common_1.check)([() => (0, common_1.checkAppName)(config, appName)]);
36
+ }
37
+ else {
38
+ await (0, common_1.check)([() => (0, common_1.checkAppName)(config, appName), () => (0, common_1.checkAppId)(config, appId)]);
39
+ }
40
+ const cordova = await (0, cordova_1.getCordovaPreferences)(config);
41
+ await runMergeConfig(config, {
42
+ appId,
43
+ appName,
44
+ webDir,
45
+ cordova,
46
+ }, isNewConfig && tsInstalled ? 'ts' : 'json');
47
+ }
48
+ catch (e) {
49
+ if (!(0, errors_1.isFatal)(e)) {
50
+ log_1.output.write('Usage: npx cap init appName appId\n' + 'Example: npx cap init "My App" "com.example.myapp"\n\n');
51
+ (0, errors_1.fatal)((_b = e.stack) !== null && _b !== void 0 ? _b : e);
52
+ }
53
+ throw e;
54
+ }
55
+ }
56
+ exports.initCommand = initCommand;
57
+ async function getName(config, name) {
58
+ var _a;
59
+ if (!name) {
60
+ const answers = await (0, log_1.logPrompt)(`${colors_1.default.strong(`What is the name of your app?`)}\n` +
61
+ `This should be a human-friendly app name, like what you'd see in the App Store.`, {
62
+ type: 'text',
63
+ name: 'name',
64
+ message: `Name`,
65
+ initial: config.app.appName ? config.app.appName : ((_a = config.app.package.name) !== null && _a !== void 0 ? _a : 'App'),
66
+ });
67
+ return answers.name;
68
+ }
69
+ return name;
70
+ }
71
+ async function getAppId(config, id) {
72
+ if (!id) {
73
+ const answers = await (0, log_1.logPrompt)(`${colors_1.default.strong(`What should be the Package ID for your app?`)}\n` +
74
+ `Package IDs (aka Bundle ID in iOS and Application ID in Android) are unique identifiers for apps. They must be in reverse domain name notation, generally representing a domain name that you or your company owns.`, {
75
+ type: 'text',
76
+ name: 'id',
77
+ message: `Package ID`,
78
+ initial: config.app.appId ? config.app.appId : 'com.example.app',
79
+ });
80
+ return answers.id;
81
+ }
82
+ return id;
83
+ }
84
+ async function getWebDir(config, webDir) {
85
+ if (!webDir) {
86
+ const framework = (0, framework_configs_1.detectFramework)(config);
87
+ if (framework === null || framework === void 0 ? void 0 : framework.webDir) {
88
+ return framework.webDir;
89
+ }
90
+ const answers = await (0, log_1.logPrompt)(`${colors_1.default.strong(`What is the web asset directory for your app?`)}\n` +
91
+ `This directory should contain the final ${colors_1.default.strong('index.html')} of your app.`, {
92
+ type: 'text',
93
+ name: 'webDir',
94
+ message: `Web asset directory`,
95
+ initial: config.app.webDir ? config.app.webDir : 'www',
96
+ });
97
+ return answers.webDir;
98
+ }
99
+ return webDir;
100
+ }
101
+ async function runMergeConfig(config, extConfig, type) {
102
+ const configDirectory = (0, path_1.dirname)(config.app.extConfigFilePath);
103
+ const newConfigPath = (0, path_1.resolve)(configDirectory, type === 'ts' ? config_1.CONFIG_FILE_NAME_TS : config_1.CONFIG_FILE_NAME_JSON);
104
+ await (0, common_1.runTask)(`Creating ${colors_1.default.strong((0, path_1.basename)(newConfigPath))} in ${colors_1.default.input(config.app.rootDir)}`, async () => {
105
+ await mergeConfig(config, extConfig, newConfigPath);
106
+ });
107
+ printNextSteps((0, path_1.basename)(newConfigPath));
108
+ if ((0, term_1.isInteractive)()) {
109
+ let sysconfig = await (0, sysconfig_1.readConfig)();
110
+ if (typeof sysconfig.signup === 'undefined') {
111
+ const signup = await promptToSignup();
112
+ sysconfig = { ...sysconfig, signup };
113
+ await (0, sysconfig_1.writeConfig)(sysconfig);
114
+ }
115
+ }
116
+ }
117
+ async function mergeConfig(config, extConfig, newConfigPath) {
118
+ const oldConfig = { ...config.app.extConfig };
119
+ const newConfig = { ...oldConfig, ...extConfig };
120
+ await (0, config_1.writeConfig)(newConfig, newConfigPath);
121
+ }
122
+ function printNextSteps(newConfigName) {
123
+ (0, log_1.logSuccess)(`${colors_1.default.strong(newConfigName)} created!`);
124
+ log_1.output.write(`\nNext steps: \n${colors_1.default.strong(`https://capacitorjs.com/docs/getting-started#where-to-go-next`)}\n`);
125
+ }
126
+ async function promptToSignup() {
127
+ const answers = await (0, log_1.logPrompt)(`Join the Ionic Community! 💙\n` +
128
+ `Connect with millions of developers on the Ionic Forum and get access to live events, news updates, and more.`, {
129
+ type: 'confirm',
130
+ name: 'create',
131
+ message: `Create free Ionic account?`,
132
+ initial: true,
133
+ });
134
+ if (answers.create) {
135
+ (0, open_1.default)(`http://ionicframework.com/signup?source=capacitor`);
136
+ }
137
+ return answers.create;
138
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.list = exports.listCommand = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("../android/common");
6
+ const colors_1 = tslib_1.__importDefault(require("../colors"));
7
+ const common_2 = require("../common");
8
+ const errors_1 = require("../errors");
9
+ const common_3 = require("../ios/common");
10
+ const log_1 = require("../log");
11
+ const plugin_1 = require("../plugin");
12
+ const promise_1 = require("../util/promise");
13
+ async function listCommand(config, selectedPlatformName) {
14
+ var _a;
15
+ const platforms = await (0, common_2.selectPlatforms)(config, selectedPlatformName);
16
+ try {
17
+ await (0, promise_1.allSerial)(platforms.map((platformName) => () => list(config, platformName)));
18
+ }
19
+ catch (e) {
20
+ if ((0, errors_1.isFatal)(e)) {
21
+ throw e;
22
+ }
23
+ log_1.logger.error((_a = e.stack) !== null && _a !== void 0 ? _a : e);
24
+ }
25
+ }
26
+ exports.listCommand = listCommand;
27
+ async function list(config, platform) {
28
+ const allPlugins = await (0, plugin_1.getPlugins)(config, platform);
29
+ let plugins = [];
30
+ if (platform === config.ios.name) {
31
+ plugins = await (0, common_3.getIOSPlugins)(allPlugins);
32
+ }
33
+ else if (platform === config.android.name) {
34
+ plugins = await (0, common_1.getAndroidPlugins)(allPlugins);
35
+ }
36
+ else if (platform === config.web.name) {
37
+ log_1.logger.info(`Listing plugins for ${colors_1.default.input(platform)} is not possible.`);
38
+ return;
39
+ }
40
+ else {
41
+ throw `Platform ${colors_1.default.input(platform)} is not valid.`;
42
+ }
43
+ const capacitorPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 0 /* PluginType.Core */);
44
+ (0, plugin_1.printPlugins)(capacitorPlugins, platform);
45
+ const cordovaPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 1 /* PluginType.Cordova */);
46
+ (0, plugin_1.printPlugins)(cordovaPlugins, platform, 'cordova');
47
+ const incompatibleCordovaPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 2 /* PluginType.Incompatible */);
48
+ (0, plugin_1.printPlugins)(incompatibleCordovaPlugins, platform, 'incompatible');
49
+ }
50
+ exports.list = list;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateToSPM = void 0;
4
+ const errors_1 = require("../errors");
5
+ const log_1 = require("../log");
6
+ const spm_1 = require("../util/spm");
7
+ const update_1 = require("./update");
8
+ async function migrateToSPM(config) {
9
+ if ((await (0, spm_1.checkPackageManager)(config)) == 'SPM') {
10
+ (0, errors_1.fatal)('Capacitor project is already using SPM, exiting.');
11
+ }
12
+ await (0, spm_1.extractSPMPackageDirectory)(config);
13
+ await (0, spm_1.runCocoapodsDeintegrate)(config);
14
+ await (0, spm_1.removeCocoapodsFiles)(config);
15
+ await (0, spm_1.addInfoPlistDebugIfNeeded)(config);
16
+ await (0, update_1.update)(config, 'ios', true);
17
+ log_1.logger.info('To complete migration follow the manual steps at https://capacitorjs.com/docs/ios/spm#using-our-migration-tool');
18
+ }
19
+ exports.migrateToSPM = migrateToSPM;