@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/errors.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFatal = exports.fatal = exports.FatalException = exports.BaseException = void 0;
|
|
4
|
+
class BaseException extends Error {
|
|
5
|
+
constructor(message, code) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.message = message;
|
|
8
|
+
this.code = code;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.BaseException = BaseException;
|
|
12
|
+
class FatalException extends BaseException {
|
|
13
|
+
constructor(message, exitCode = 1) {
|
|
14
|
+
super(message, 'FATAL');
|
|
15
|
+
this.message = message;
|
|
16
|
+
this.exitCode = exitCode;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.FatalException = FatalException;
|
|
20
|
+
function fatal(message) {
|
|
21
|
+
throw new FatalException(message);
|
|
22
|
+
}
|
|
23
|
+
exports.fatal = fatal;
|
|
24
|
+
function isFatal(e) {
|
|
25
|
+
return e && e instanceof FatalException;
|
|
26
|
+
}
|
|
27
|
+
exports.isFatal = isFatal;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectFramework = void 0;
|
|
4
|
+
const FRAMEWORK_CONFIGS = [
|
|
5
|
+
{
|
|
6
|
+
name: 'Angular',
|
|
7
|
+
isMatch: (config) => hasDependency(config, '@angular/cli'),
|
|
8
|
+
webDir: 'dist',
|
|
9
|
+
priority: 3,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: 'Create React App',
|
|
13
|
+
isMatch: (config) => hasDependency(config, 'react-scripts'),
|
|
14
|
+
webDir: 'build',
|
|
15
|
+
priority: 3,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'Ember',
|
|
19
|
+
isMatch: (config) => hasDependency(config, 'ember-cli'),
|
|
20
|
+
webDir: 'dist',
|
|
21
|
+
priority: 3,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'Gatsby',
|
|
25
|
+
isMatch: (config) => hasDependency(config, 'gatsby'),
|
|
26
|
+
webDir: 'public',
|
|
27
|
+
priority: 2,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Ionic Angular',
|
|
31
|
+
isMatch: (config) => hasDependency(config, '@ionic/angular'),
|
|
32
|
+
webDir: 'www',
|
|
33
|
+
priority: 1,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'Ionic React',
|
|
37
|
+
isMatch: (config) => hasDependency(config, '@ionic/react'),
|
|
38
|
+
webDir: 'build',
|
|
39
|
+
priority: 1,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'Ionic Vue',
|
|
43
|
+
isMatch: (config) => hasDependency(config, '@ionic/vue'),
|
|
44
|
+
webDir: 'public',
|
|
45
|
+
priority: 1,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'Next',
|
|
49
|
+
isMatch: (config) => hasDependency(config, 'next'),
|
|
50
|
+
webDir: 'public',
|
|
51
|
+
priority: 2,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'Preact',
|
|
55
|
+
isMatch: (config) => hasDependency(config, 'preact-cli'),
|
|
56
|
+
webDir: 'build',
|
|
57
|
+
priority: 3,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'Stencil',
|
|
61
|
+
isMatch: (config) => hasDependency(config, '@stencil/core'),
|
|
62
|
+
webDir: 'www',
|
|
63
|
+
priority: 3,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'Svelte',
|
|
67
|
+
isMatch: (config) => hasDependency(config, 'svelte') && hasDependency(config, 'sirv-cli'),
|
|
68
|
+
webDir: 'public',
|
|
69
|
+
priority: 3,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'Vite',
|
|
73
|
+
isMatch: (config) => hasDependency(config, 'vite'),
|
|
74
|
+
webDir: 'dist',
|
|
75
|
+
priority: 2,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'Vue',
|
|
79
|
+
isMatch: (config) => hasDependency(config, '@vue/cli-service'),
|
|
80
|
+
webDir: 'dist',
|
|
81
|
+
priority: 3,
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
function detectFramework(config) {
|
|
85
|
+
const frameworks = FRAMEWORK_CONFIGS.filter((f) => f.isMatch(config)).sort((a, b) => {
|
|
86
|
+
if (a.priority < b.priority)
|
|
87
|
+
return -1;
|
|
88
|
+
if (a.priority > b.priority)
|
|
89
|
+
return 1;
|
|
90
|
+
return 0;
|
|
91
|
+
});
|
|
92
|
+
return frameworks[0];
|
|
93
|
+
}
|
|
94
|
+
exports.detectFramework = detectFramework;
|
|
95
|
+
function hasDependency(config, depName) {
|
|
96
|
+
const deps = getDependencies(config);
|
|
97
|
+
return deps.includes(depName);
|
|
98
|
+
}
|
|
99
|
+
function getDependencies(config) {
|
|
100
|
+
var _a, _b, _c, _d;
|
|
101
|
+
const deps = [];
|
|
102
|
+
if ((_b = (_a = config === null || config === void 0 ? void 0 : config.app) === null || _a === void 0 ? void 0 : _a.package) === null || _b === void 0 ? void 0 : _b.dependencies) {
|
|
103
|
+
deps.push(...Object.keys(config.app.package.dependencies));
|
|
104
|
+
}
|
|
105
|
+
if ((_d = (_c = config === null || config === void 0 ? void 0 : config.app) === null || _c === void 0 ? void 0 : _c.package) === null || _d === void 0 ? void 0 : _d.devDependencies) {
|
|
106
|
+
deps.push(...Object.keys(config.app.package.devDependencies));
|
|
107
|
+
}
|
|
108
|
+
return deps;
|
|
109
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runProgram = exports.run = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const commander_1 = require("commander");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const colors_1 = tslib_1.__importDefault(require("./colors"));
|
|
8
|
+
const config_1 = require("./config");
|
|
9
|
+
const errors_1 = require("./errors");
|
|
10
|
+
const ipc_1 = require("./ipc");
|
|
11
|
+
const log_1 = require("./log");
|
|
12
|
+
const telemetry_1 = require("./telemetry");
|
|
13
|
+
const cli_1 = require("./util/cli");
|
|
14
|
+
const emoji_1 = require("./util/emoji");
|
|
15
|
+
process.on('unhandledRejection', (error) => {
|
|
16
|
+
console.error(colors_1.default.failure('[fatal]'), error);
|
|
17
|
+
});
|
|
18
|
+
process.on('message', ipc_1.receive);
|
|
19
|
+
async function run() {
|
|
20
|
+
try {
|
|
21
|
+
const config = await (0, config_1.loadConfig)();
|
|
22
|
+
runProgram(config);
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
process.exitCode = (0, errors_1.isFatal)(e) ? e.exitCode : 1;
|
|
26
|
+
log_1.logger.error(e.message ? e.message : String(e));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.run = run;
|
|
30
|
+
function runProgram(config) {
|
|
31
|
+
commander_1.program.version(config.cli.package.version);
|
|
32
|
+
commander_1.program
|
|
33
|
+
.command('config', { hidden: true })
|
|
34
|
+
.description(`print evaluated Capacitor config`)
|
|
35
|
+
.option('--json', 'Print in JSON format')
|
|
36
|
+
.action((0, cli_1.wrapAction)(async ({ json }) => {
|
|
37
|
+
const { configCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/config')));
|
|
38
|
+
await configCommand(config, json);
|
|
39
|
+
}));
|
|
40
|
+
commander_1.program
|
|
41
|
+
.command('create [directory] [name] [id]', { hidden: true })
|
|
42
|
+
.description('Creates a new Capacitor project')
|
|
43
|
+
.action((0, cli_1.wrapAction)(async () => {
|
|
44
|
+
const { createCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/create')));
|
|
45
|
+
await createCommand();
|
|
46
|
+
}));
|
|
47
|
+
commander_1.program
|
|
48
|
+
.command('init [appName] [appId]')
|
|
49
|
+
.description(`Initialize Capacitor configuration`)
|
|
50
|
+
.option('--web-dir <value>', 'Optional: Directory of your projects built web assets')
|
|
51
|
+
.option('--skip-appid-validation', 'Optional: Skip validating the app ID for iOS and Android compatibility')
|
|
52
|
+
.action((0, cli_1.wrapAction)((0, telemetry_1.telemetryAction)(config, async (appName, appId, { webDir, skipAppidValidation }) => {
|
|
53
|
+
const { initCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/init')));
|
|
54
|
+
await initCommand(config, appName, appId, webDir, skipAppidValidation);
|
|
55
|
+
})));
|
|
56
|
+
commander_1.program
|
|
57
|
+
.command('serve', { hidden: true })
|
|
58
|
+
.description('Serves a Capacitor Progressive Web App in the browser')
|
|
59
|
+
.action((0, cli_1.wrapAction)(async () => {
|
|
60
|
+
const { serveCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/serve')));
|
|
61
|
+
await serveCommand();
|
|
62
|
+
}));
|
|
63
|
+
commander_1.program
|
|
64
|
+
.command('sync [platform]')
|
|
65
|
+
.description(`${colors_1.default.input('copy')} + ${colors_1.default.input('update')}`)
|
|
66
|
+
.option('--deployment', 'Optional: if provided, pod install will use --deployment option')
|
|
67
|
+
.option('--inline', 'Optional: if true, all source maps will be inlined for easier debugging on mobile devices', false)
|
|
68
|
+
.action((0, cli_1.wrapAction)((0, telemetry_1.telemetryAction)(config, async (platform, { deployment, inline }) => {
|
|
69
|
+
const { syncCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/sync')));
|
|
70
|
+
await syncCommand(config, platform, deployment, inline);
|
|
71
|
+
})));
|
|
72
|
+
commander_1.program
|
|
73
|
+
.command('update [platform]')
|
|
74
|
+
.description(`updates the native plugins and dependencies based on ${colors_1.default.strong('package.json')}`)
|
|
75
|
+
.option('--deployment', 'Optional: if provided, pod install will use --deployment option')
|
|
76
|
+
.action((0, cli_1.wrapAction)((0, telemetry_1.telemetryAction)(config, async (platform, { deployment }) => {
|
|
77
|
+
const { updateCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/update')));
|
|
78
|
+
await updateCommand(config, platform, deployment);
|
|
79
|
+
})));
|
|
80
|
+
commander_1.program
|
|
81
|
+
.command('copy [platform]')
|
|
82
|
+
.description('copies the web app build into the native app')
|
|
83
|
+
.option('--inline', 'Optional: if true, all source maps will be inlined for easier debugging on mobile devices', false)
|
|
84
|
+
.action((0, cli_1.wrapAction)((0, telemetry_1.telemetryAction)(config, async (platform, { inline }) => {
|
|
85
|
+
const { copyCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/copy')));
|
|
86
|
+
await copyCommand(config, platform, inline);
|
|
87
|
+
})));
|
|
88
|
+
commander_1.program
|
|
89
|
+
.command('build <platform>')
|
|
90
|
+
.description('builds the release version of the selected platform')
|
|
91
|
+
.option('--scheme <schemeToBuild>', 'iOS Scheme to build')
|
|
92
|
+
.option('--flavor <flavorToBuild>', 'Android Flavor to build')
|
|
93
|
+
.option('--keystorepath <keystorePath>', 'Path to the keystore')
|
|
94
|
+
.option('--keystorepass <keystorePass>', 'Password to the keystore')
|
|
95
|
+
.option('--keystorealias <keystoreAlias>', 'Key Alias in the keystore')
|
|
96
|
+
.option('--configuration <name>', 'Configuration name of the iOS Scheme')
|
|
97
|
+
.option('--keystorealiaspass <keystoreAliasPass>', 'Password for the Key Alias')
|
|
98
|
+
.addOption(new commander_1.Option('--androidreleasetype <androidreleasetype>', 'Android release type; APK or AAB').choices([
|
|
99
|
+
'AAB',
|
|
100
|
+
'APK',
|
|
101
|
+
]))
|
|
102
|
+
.addOption(new commander_1.Option('--signing-type <signingtype>', 'Program used to sign apps (default: jarsigner)').choices([
|
|
103
|
+
'apksigner',
|
|
104
|
+
'jarsigner',
|
|
105
|
+
]))
|
|
106
|
+
.addOption(new commander_1.Option('--xcode-team-id <xcodeTeamID>', 'The Developer team to use for building and exporting the archive'))
|
|
107
|
+
.addOption(new commander_1.Option('--xcode-export-method <xcodeExportMethod>', 'Describes how xcodebuild should export the archive (default: app-store-connect)').choices([
|
|
108
|
+
'app-store-connect',
|
|
109
|
+
'release-testing',
|
|
110
|
+
'enterprise',
|
|
111
|
+
'debugging',
|
|
112
|
+
'developer-id',
|
|
113
|
+
'mac-application',
|
|
114
|
+
'validation',
|
|
115
|
+
]))
|
|
116
|
+
.addOption(new commander_1.Option('--xcode-signing-style <xcodeSigningStyle>', 'The iOS signing style to use when building the app for distribution (default: automatic)').choices(['automatic', 'manual']))
|
|
117
|
+
.addOption(new commander_1.Option('--xcode-signing-certificate <xcodeSigningCertificate>', 'A certificate name, SHA-1 hash, or automatic selector to use for signing for iOS builds'))
|
|
118
|
+
.addOption(new commander_1.Option('--xcode-provisioning-profile <xcodeProvisioningProfile>', 'A provisioning profile name or UUID for iOS builds'))
|
|
119
|
+
.action((0, cli_1.wrapAction)((0, telemetry_1.telemetryAction)(config, async (platform, { scheme, flavor, keystorepath, keystorepass, keystorealias, keystorealiaspass, androidreleasetype, signingType, configuration, xcodeTeamId, xcodeExportMethod, xcodeSigningStyle, xcodeSigningCertificate, xcodeProvisioningProfile, }) => {
|
|
120
|
+
const { buildCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/build')));
|
|
121
|
+
await buildCommand(config, platform, {
|
|
122
|
+
scheme,
|
|
123
|
+
flavor,
|
|
124
|
+
keystorepath,
|
|
125
|
+
keystorepass,
|
|
126
|
+
keystorealias,
|
|
127
|
+
keystorealiaspass,
|
|
128
|
+
androidreleasetype,
|
|
129
|
+
signingtype: signingType,
|
|
130
|
+
configuration,
|
|
131
|
+
xcodeTeamId,
|
|
132
|
+
xcodeExportMethod,
|
|
133
|
+
xcodeSigningType: xcodeSigningStyle,
|
|
134
|
+
xcodeSigningCertificate,
|
|
135
|
+
xcodeProvisioningProfile,
|
|
136
|
+
});
|
|
137
|
+
})));
|
|
138
|
+
commander_1.program
|
|
139
|
+
.command(`run [platform]`)
|
|
140
|
+
.description(`runs ${colors_1.default.input('sync')}, then builds and deploys the native app`)
|
|
141
|
+
.option('--scheme <schemeName>', 'set the scheme of the iOS project')
|
|
142
|
+
.option('--flavor <flavorName>', 'set the flavor of the Android project (flavor dimensions not yet supported)')
|
|
143
|
+
.option('--list', 'list targets, then quit')
|
|
144
|
+
.addOption(new commander_1.Option('--json').hideHelp())
|
|
145
|
+
.option('--target <id>', 'use a specific target')
|
|
146
|
+
.option('--target-name <name>', 'use a specific target by name')
|
|
147
|
+
.option('--target-name-sdk-version <version>', 'use a specific sdk version when using --target-name, ex: 26.0 (for iOS 26) or 35 (for Android API 35)')
|
|
148
|
+
.option('--no-sync', `do not run ${colors_1.default.input('sync')}`)
|
|
149
|
+
.option('--forwardPorts <port:port>', 'Automatically run "adb reverse" for better live-reloading support')
|
|
150
|
+
.option('-l, --live-reload', 'Enable Live Reload')
|
|
151
|
+
.option('--host <host>', 'Host used for live reload')
|
|
152
|
+
.option('--port <port>', 'Port used for live reload')
|
|
153
|
+
.option('--configuration <name>', 'Configuration name of the iOS Scheme')
|
|
154
|
+
.action((0, cli_1.wrapAction)((0, telemetry_1.telemetryAction)(config, async (platform, { scheme, flavor, list, json, target, targetName, targetNameSdkVersion, sync, forwardPorts, liveReload, host, port, configuration, }) => {
|
|
155
|
+
const { runCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/run')));
|
|
156
|
+
await runCommand(config, platform, {
|
|
157
|
+
scheme,
|
|
158
|
+
flavor,
|
|
159
|
+
list,
|
|
160
|
+
json,
|
|
161
|
+
target,
|
|
162
|
+
targetName,
|
|
163
|
+
targetNameSdkVersion,
|
|
164
|
+
sync,
|
|
165
|
+
forwardPorts,
|
|
166
|
+
liveReload,
|
|
167
|
+
host,
|
|
168
|
+
port,
|
|
169
|
+
configuration,
|
|
170
|
+
});
|
|
171
|
+
})));
|
|
172
|
+
commander_1.program
|
|
173
|
+
.command('open [platform]')
|
|
174
|
+
.description('opens the native project workspace (Xcode for iOS)')
|
|
175
|
+
.action((0, cli_1.wrapAction)((0, telemetry_1.telemetryAction)(config, async (platform) => {
|
|
176
|
+
const { openCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/open')));
|
|
177
|
+
await openCommand(config, platform);
|
|
178
|
+
})));
|
|
179
|
+
commander_1.program
|
|
180
|
+
.command('add [platform]')
|
|
181
|
+
.description('add a native platform project')
|
|
182
|
+
.option('--packagemanager <packageManager>', 'The package manager to use for dependency installs (CocoaPods or SPM)')
|
|
183
|
+
.action((0, cli_1.wrapAction)((0, telemetry_1.telemetryAction)(config, async (platform, { packagemanager }) => {
|
|
184
|
+
const { addCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/add')));
|
|
185
|
+
const configWritable = config;
|
|
186
|
+
if ((packagemanager === null || packagemanager === void 0 ? void 0 : packagemanager.toLowerCase()) === 'CocoaPods'.toLowerCase()) {
|
|
187
|
+
configWritable.cli.assets.ios.platformTemplateArchive = 'ios-pods-template.tar.gz';
|
|
188
|
+
configWritable.cli.assets.ios.platformTemplateArchiveAbs = (0, path_1.resolve)(configWritable.cli.assetsDirAbs, configWritable.cli.assets.ios.platformTemplateArchive);
|
|
189
|
+
}
|
|
190
|
+
await addCommand(configWritable, platform);
|
|
191
|
+
})));
|
|
192
|
+
commander_1.program
|
|
193
|
+
.command('ls [platform]')
|
|
194
|
+
.description('list installed Cordova and Capacitor plugins')
|
|
195
|
+
.action((0, cli_1.wrapAction)((0, telemetry_1.telemetryAction)(config, async (platform) => {
|
|
196
|
+
const { listCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/list')));
|
|
197
|
+
await listCommand(config, platform);
|
|
198
|
+
})));
|
|
199
|
+
commander_1.program
|
|
200
|
+
.command('doctor [platform]')
|
|
201
|
+
.description('checks the current setup for common errors')
|
|
202
|
+
.action((0, cli_1.wrapAction)((0, telemetry_1.telemetryAction)(config, async (platform) => {
|
|
203
|
+
const { doctorCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/doctor')));
|
|
204
|
+
await doctorCommand(config, platform);
|
|
205
|
+
})));
|
|
206
|
+
commander_1.program
|
|
207
|
+
.command('telemetry [on|off]', { hidden: true })
|
|
208
|
+
.description('enable or disable telemetry')
|
|
209
|
+
.action((0, cli_1.wrapAction)(async (onOrOff) => {
|
|
210
|
+
const { telemetryCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/telemetry')));
|
|
211
|
+
await telemetryCommand(onOrOff);
|
|
212
|
+
}));
|
|
213
|
+
commander_1.program
|
|
214
|
+
.command('📡', { hidden: true })
|
|
215
|
+
.description('IPC receiver command')
|
|
216
|
+
.action(() => {
|
|
217
|
+
// no-op: IPC messages are received via `process.on('message')`
|
|
218
|
+
});
|
|
219
|
+
commander_1.program
|
|
220
|
+
.command('plugin:generate', { hidden: true })
|
|
221
|
+
.description('start a new Capacitor plugin')
|
|
222
|
+
.action((0, cli_1.wrapAction)(async () => {
|
|
223
|
+
const { newPluginCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/new-plugin')));
|
|
224
|
+
await newPluginCommand();
|
|
225
|
+
}));
|
|
226
|
+
commander_1.program
|
|
227
|
+
.command('migrate')
|
|
228
|
+
.option('--noprompt', 'do not prompt for confirmation')
|
|
229
|
+
.option('--packagemanager <packageManager>', 'The package manager to use for dependency installs (npm, pnpm, yarn)')
|
|
230
|
+
.description('Migrate your current Capacitor app to the latest major version of Capacitor.')
|
|
231
|
+
.action((0, cli_1.wrapAction)(async ({ noprompt, packagemanager }) => {
|
|
232
|
+
const { migrateCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/migrate')));
|
|
233
|
+
await migrateCommand(config, noprompt, packagemanager);
|
|
234
|
+
}));
|
|
235
|
+
commander_1.program
|
|
236
|
+
.command('spm-migration-assistant')
|
|
237
|
+
.description('Remove Cocoapods from project and switch to Swift Package Manager')
|
|
238
|
+
.action((0, cli_1.wrapAction)(async () => {
|
|
239
|
+
const { migrateToSPM } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/migrate-spm')));
|
|
240
|
+
await migrateToSPM(config);
|
|
241
|
+
}));
|
|
242
|
+
commander_1.program.arguments('[command]').action((0, cli_1.wrapAction)(async (cmd) => {
|
|
243
|
+
if (typeof cmd === 'undefined') {
|
|
244
|
+
log_1.output.write(`\n ${(0, emoji_1.emoji)('⚡️', '--')} ${colors_1.default.strong('Capacitor - Cross-Platform apps with JavaScript and the Web')} ${(0, emoji_1.emoji)('⚡️', '--')}\n\n`);
|
|
245
|
+
commander_1.program.outputHelp();
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
(0, errors_1.fatal)(`Unknown command: ${colors_1.default.input(cmd)}`);
|
|
249
|
+
}
|
|
250
|
+
}));
|
|
251
|
+
commander_1.program.parse(process.argv);
|
|
252
|
+
}
|
|
253
|
+
exports.runProgram = runProgram;
|
package/dist/ios/add.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addIOS = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const colors_1 = tslib_1.__importDefault(require("../colors"));
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
const template_1 = require("../util/template");
|
|
8
|
+
async function addIOS(config) {
|
|
9
|
+
await (0, common_1.runTask)(`Adding native Xcode project in ${colors_1.default.strong(config.ios.platformDir)}`, () => {
|
|
10
|
+
return (0, template_1.extractTemplate)(config.cli.assets.ios.platformTemplateArchiveAbs, config.ios.platformDirAbs);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
exports.addIOS = addIOS;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildiOS = void 0;
|
|
4
|
+
const fs_extra_1 = require("fs-extra");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const rimraf_1 = require("rimraf");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
const definitions_1 = require("../definitions");
|
|
9
|
+
const log_1 = require("../log");
|
|
10
|
+
const spm_1 = require("../util/spm");
|
|
11
|
+
const subprocess_1 = require("../util/subprocess");
|
|
12
|
+
async function buildiOS(config, buildOptions) {
|
|
13
|
+
var _a, _b, _c, _d;
|
|
14
|
+
const theScheme = (_a = buildOptions.scheme) !== null && _a !== void 0 ? _a : 'App';
|
|
15
|
+
const packageManager = await (0, spm_1.checkPackageManager)(config);
|
|
16
|
+
let typeOfBuild;
|
|
17
|
+
let projectName;
|
|
18
|
+
if (packageManager == 'Cocoapods') {
|
|
19
|
+
typeOfBuild = '-workspace';
|
|
20
|
+
projectName = (0, path_1.basename)(await config.ios.nativeXcodeWorkspaceDirAbs);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
typeOfBuild = '-project';
|
|
24
|
+
projectName = (0, path_1.basename)(await config.ios.nativeXcodeProjDirAbs);
|
|
25
|
+
}
|
|
26
|
+
if (buildOptions.xcodeSigningType == 'manual' &&
|
|
27
|
+
(!buildOptions.xcodeSigningCertificate || !buildOptions.xcodeProvisioningProfile)) {
|
|
28
|
+
throw 'Manually signed Xcode builds require a signing certificate and provisioning profile.';
|
|
29
|
+
}
|
|
30
|
+
const buildArgs = [
|
|
31
|
+
typeOfBuild,
|
|
32
|
+
projectName,
|
|
33
|
+
'-scheme',
|
|
34
|
+
`${theScheme}`,
|
|
35
|
+
'-destination',
|
|
36
|
+
`generic/platform=iOS`,
|
|
37
|
+
'-archivePath',
|
|
38
|
+
`${theScheme}.xcarchive`,
|
|
39
|
+
'archive',
|
|
40
|
+
'-configuration',
|
|
41
|
+
buildOptions.configuration,
|
|
42
|
+
];
|
|
43
|
+
if (buildOptions.xcodeTeamId) {
|
|
44
|
+
buildArgs.push(`DEVELOPMENT_TEAM=${buildOptions.xcodeTeamId}`);
|
|
45
|
+
}
|
|
46
|
+
if (buildOptions.xcodeSigningType == 'manual') {
|
|
47
|
+
buildArgs.push(`PROVISIONING_PROFILE_SPECIFIER=${buildOptions.xcodeProvisioningProfile}`);
|
|
48
|
+
}
|
|
49
|
+
await (0, common_1.runTask)('Building xArchive', async () => (0, subprocess_1.runCommand)('xcodebuild', buildArgs, {
|
|
50
|
+
cwd: config.ios.nativeProjectDirAbs,
|
|
51
|
+
}));
|
|
52
|
+
const manualSigningContents = `<key>provisioningProfiles</key>
|
|
53
|
+
<dict>
|
|
54
|
+
<key>${config.app.appId}</key>
|
|
55
|
+
<string>${(_b = buildOptions.xcodeProvisioningProfile) !== null && _b !== void 0 ? _b : ''}</string>
|
|
56
|
+
</dict>
|
|
57
|
+
<key>signingCertificate</key>
|
|
58
|
+
<string>${(_c = buildOptions.xcodeSigningCertificate) !== null && _c !== void 0 ? _c : ''}</string>`;
|
|
59
|
+
const archivePlistContents = `<?xml version="1.0" encoding="UTF-8"?>
|
|
60
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
61
|
+
<plist version="1.0">
|
|
62
|
+
<dict>
|
|
63
|
+
<key>method</key>
|
|
64
|
+
<string>${(_d = buildOptions.xcodeExportMethod) !== null && _d !== void 0 ? _d : definitions_1.XcodeExportMethod.AppStoreConnect}</string>
|
|
65
|
+
<key>signingStyle</key>
|
|
66
|
+
<string>${buildOptions.xcodeSigningType}</string>
|
|
67
|
+
${buildOptions.xcodeSigningType == 'manual' ? manualSigningContents : ''}
|
|
68
|
+
</dict>
|
|
69
|
+
</plist>`;
|
|
70
|
+
const archivePlistPath = (0, path_1.join)(`${config.ios.nativeProjectDirAbs}`, 'archive.plist');
|
|
71
|
+
(0, fs_extra_1.writeFileSync)(archivePlistPath, archivePlistContents);
|
|
72
|
+
const archiveArgs = [
|
|
73
|
+
'archive',
|
|
74
|
+
'-archivePath',
|
|
75
|
+
`${theScheme}.xcarchive`,
|
|
76
|
+
'-exportArchive',
|
|
77
|
+
'-exportOptionsPlist',
|
|
78
|
+
'archive.plist',
|
|
79
|
+
'-exportPath',
|
|
80
|
+
'output',
|
|
81
|
+
'-configuration',
|
|
82
|
+
buildOptions.configuration,
|
|
83
|
+
];
|
|
84
|
+
if (buildOptions.xcodeSigningType == 'automatic') {
|
|
85
|
+
archiveArgs.push('-allowProvisioningUpdates');
|
|
86
|
+
}
|
|
87
|
+
await (0, common_1.runTask)('Building IPA', async () => (0, subprocess_1.runCommand)('xcodebuild', archiveArgs, {
|
|
88
|
+
cwd: config.ios.nativeProjectDirAbs,
|
|
89
|
+
}));
|
|
90
|
+
await (0, common_1.runTask)('Cleaning up', async () => {
|
|
91
|
+
(0, fs_extra_1.unlinkSync)(archivePlistPath);
|
|
92
|
+
rimraf_1.rimraf.sync((0, path_1.join)(config.ios.nativeProjectDirAbs, `${theScheme}.xcarchive`));
|
|
93
|
+
});
|
|
94
|
+
(0, log_1.logSuccess)(`Successfully generated an IPA at: ${(0, path_1.join)(config.ios.nativeProjectDirAbs, 'output')}`);
|
|
95
|
+
}
|
|
96
|
+
exports.buildiOS = buildiOS;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMajoriOSVersion = exports.editProjectSettingsIOS = exports.resolvePlugin = exports.getIOSPlugins = exports.checkCocoaPods = exports.checkBundler = exports.checkIOSPackage = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
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 cordova_1 = require("../cordova");
|
|
11
|
+
const log_1 = require("../log");
|
|
12
|
+
const plugin_1 = require("../plugin");
|
|
13
|
+
const subprocess_1 = require("../util/subprocess");
|
|
14
|
+
async function checkIOSPackage(config) {
|
|
15
|
+
return (0, common_1.checkCapacitorPlatform)(config, 'ios');
|
|
16
|
+
}
|
|
17
|
+
exports.checkIOSPackage = checkIOSPackage;
|
|
18
|
+
function execBundler() {
|
|
19
|
+
try {
|
|
20
|
+
const bundleOutput = (0, child_process_1.execSync)('bundle &> /dev/null ; echo $?');
|
|
21
|
+
return parseInt(bundleOutput.toString());
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
return -1;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function checkBundler(config) {
|
|
28
|
+
if (config.cli.os === "mac" /* OS.Mac */) {
|
|
29
|
+
let bundlerResult = execBundler();
|
|
30
|
+
if (bundlerResult === 1) {
|
|
31
|
+
// Bundler version is outdated
|
|
32
|
+
log_1.logger.info(`Using ${colors_1.default.strong('Gemfile')}: Bundler update needed...`);
|
|
33
|
+
await (0, subprocess_1.runCommand)('gem', ['install', 'bundler']);
|
|
34
|
+
bundlerResult = execBundler();
|
|
35
|
+
}
|
|
36
|
+
if (bundlerResult === 0) {
|
|
37
|
+
// Bundler in use, all gems current
|
|
38
|
+
log_1.logger.info(`Using ${colors_1.default.strong('Gemfile')}: RubyGems bundle installed`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
exports.checkBundler = checkBundler;
|
|
44
|
+
async function checkCocoaPods(config) {
|
|
45
|
+
if (!(await (0, subprocess_1.isInstalled)(await config.ios.podPath)) && config.cli.os === "mac" /* OS.Mac */) {
|
|
46
|
+
return (`CocoaPods is not installed.\n` +
|
|
47
|
+
`See this install guide: ${colors_1.default.strong('https://capacitorjs.com/docs/getting-started/environment-setup#homebrew')}`);
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
exports.checkCocoaPods = checkCocoaPods;
|
|
52
|
+
async function getIOSPlugins(allPlugins) {
|
|
53
|
+
const resolved = await Promise.all(allPlugins.map(async (plugin) => await resolvePlugin(plugin)));
|
|
54
|
+
return resolved.filter((plugin) => !!plugin);
|
|
55
|
+
}
|
|
56
|
+
exports.getIOSPlugins = getIOSPlugins;
|
|
57
|
+
async function resolvePlugin(plugin) {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
const platform = 'ios';
|
|
60
|
+
if ((_a = plugin.manifest) === null || _a === void 0 ? void 0 : _a.ios) {
|
|
61
|
+
plugin.ios = {
|
|
62
|
+
name: plugin.name,
|
|
63
|
+
type: 0 /* PluginType.Core */,
|
|
64
|
+
path: (_b = plugin.manifest.ios.src) !== null && _b !== void 0 ? _b : platform,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
else if (plugin.xml) {
|
|
68
|
+
plugin.ios = {
|
|
69
|
+
name: plugin.name,
|
|
70
|
+
type: 1 /* PluginType.Cordova */,
|
|
71
|
+
path: 'src/' + platform,
|
|
72
|
+
};
|
|
73
|
+
if ((0, cordova_1.getIncompatibleCordovaPlugins)(platform).includes(plugin.id) || !(0, plugin_1.getPluginPlatform)(plugin, platform)) {
|
|
74
|
+
plugin.ios.type = 2 /* PluginType.Incompatible */;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return plugin;
|
|
81
|
+
}
|
|
82
|
+
exports.resolvePlugin = resolvePlugin;
|
|
83
|
+
/**
|
|
84
|
+
* Update the native project files with the desired app id and app name
|
|
85
|
+
*/
|
|
86
|
+
async function editProjectSettingsIOS(config) {
|
|
87
|
+
const appId = config.app.appId;
|
|
88
|
+
const appName = config.app.appName.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
89
|
+
const pbxPath = `${config.ios.nativeXcodeProjDirAbs}/project.pbxproj`;
|
|
90
|
+
const plistPath = (0, path_1.resolve)(config.ios.nativeTargetDirAbs, 'Info.plist');
|
|
91
|
+
let plistContent = await (0, fs_extra_1.readFile)(plistPath, { encoding: 'utf-8' });
|
|
92
|
+
plistContent = plistContent.replace(/<key>CFBundleDisplayName<\/key>[\s\S]?\s+<string>([^<]*)<\/string>/, `<key>CFBundleDisplayName</key>\n <string>${appName}</string>`);
|
|
93
|
+
let pbxContent = await (0, fs_extra_1.readFile)(pbxPath, { encoding: 'utf-8' });
|
|
94
|
+
pbxContent = pbxContent.replace(/PRODUCT_BUNDLE_IDENTIFIER = ([^;]+)/g, `PRODUCT_BUNDLE_IDENTIFIER = ${appId}`);
|
|
95
|
+
await (0, fs_extra_1.writeFile)(plistPath, plistContent, { encoding: 'utf-8' });
|
|
96
|
+
await (0, fs_extra_1.writeFile)(pbxPath, pbxContent, { encoding: 'utf-8' });
|
|
97
|
+
}
|
|
98
|
+
exports.editProjectSettingsIOS = editProjectSettingsIOS;
|
|
99
|
+
function getMajoriOSVersion(config) {
|
|
100
|
+
const pbx = (0, fs_extra_1.readFileSync)((0, path_1.join)(config.ios.nativeXcodeProjDirAbs, 'project.pbxproj'), 'utf-8');
|
|
101
|
+
const searchString = 'IPHONEOS_DEPLOYMENT_TARGET = ';
|
|
102
|
+
const iosVersion = pbx.substring(pbx.indexOf(searchString) + searchString.length, pbx.indexOf(searchString) + searchString.length + 2);
|
|
103
|
+
return iosVersion;
|
|
104
|
+
}
|
|
105
|
+
exports.getMajoriOSVersion = getMajoriOSVersion;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.doctorIOS = void 0;
|
|
4
|
+
const common_1 = require("../common");
|
|
5
|
+
const errors_1 = require("../errors");
|
|
6
|
+
const log_1 = require("../log");
|
|
7
|
+
const subprocess_1 = require("../util/subprocess");
|
|
8
|
+
const common_2 = require("./common");
|
|
9
|
+
async function doctorIOS(config) {
|
|
10
|
+
var _a;
|
|
11
|
+
// DOCTOR ideas for iOS:
|
|
12
|
+
// plugin specific warnings
|
|
13
|
+
// check cocoapods installed
|
|
14
|
+
// check projects exist
|
|
15
|
+
// check content in www === ios/www
|
|
16
|
+
// check CLI versions
|
|
17
|
+
// check plugins versions
|
|
18
|
+
// check native project deps are up-to-date === npm install
|
|
19
|
+
// check if npm install was updated
|
|
20
|
+
// check online datebase of common errors
|
|
21
|
+
// check if www folder is empty (index.html does not exist)
|
|
22
|
+
try {
|
|
23
|
+
await (0, common_1.check)([() => (0, common_2.checkBundler)(config) || (0, common_2.checkCocoaPods)(config), () => (0, common_1.checkWebDir)(config), checkXcode]);
|
|
24
|
+
(0, log_1.logSuccess)('iOS looking great! 👌');
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
(0, errors_1.fatal)((_a = e.stack) !== null && _a !== void 0 ? _a : e);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.doctorIOS = doctorIOS;
|
|
31
|
+
async function checkXcode() {
|
|
32
|
+
if (!(await (0, subprocess_1.isInstalled)('xcodebuild'))) {
|
|
33
|
+
return `Xcode is not installed`;
|
|
34
|
+
}
|
|
35
|
+
// const matches = output.match(/^Xcode (.*)/);
|
|
36
|
+
// if (matches && matches.length === 2) {
|
|
37
|
+
// const minVersion = '9.0.0';
|
|
38
|
+
// const semver = await import('semver');
|
|
39
|
+
// console.log(matches[1]);
|
|
40
|
+
// if (semver.gt(minVersion, matches[1])) {
|
|
41
|
+
// return `Xcode version is too old, ${minVersion} is required`;
|
|
42
|
+
// }
|
|
43
|
+
// }
|
|
44
|
+
return null;
|
|
45
|
+
}
|
package/dist/ios/open.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.openIOS = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const open_1 = tslib_1.__importDefault(require("open"));
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
const spm_1 = require("../util/spm");
|
|
8
|
+
async function openIOS(config) {
|
|
9
|
+
if ((await (0, spm_1.checkPackageManager)(config)) == 'SPM') {
|
|
10
|
+
await (0, open_1.default)(config.ios.nativeXcodeProjDirAbs, { wait: false });
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
await (0, open_1.default)(await config.ios.nativeXcodeWorkspaceDirAbs, { wait: false });
|
|
14
|
+
}
|
|
15
|
+
await (0, common_1.wait)(3000);
|
|
16
|
+
}
|
|
17
|
+
exports.openIOS = openIOS;
|