@capacitor/cli 4.0.1-alpha.0 → 4.0.2-nightly-76f28e70.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/CHANGELOG.md +121 -1
- 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-template.tar.gz +0 -0
- package/dist/android/open.js +1 -1
- package/dist/android/update.js +54 -5
- package/dist/declarations.d.ts +55 -0
- package/dist/index.js +30 -22
- package/dist/tasks/add.js +1 -1
- package/dist/tasks/copy.js +47 -5
- package/dist/tasks/migrate.js +653 -0
- package/dist/tasks/run.js +1 -1
- package/dist/tasks/sourcemaps.js +40 -0
- package/dist/tasks/sync.js +7 -3
- package/dist/util/fs.js +18 -1
- package/package.json +22 -24
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,40 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [4.0.1
|
|
6
|
+
## [4.0.1](https://github.com/ionic-team/capacitor/compare/4.0.0...4.0.1) (2022-07-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **cli:** Correct Splash theme update ([#5805](https://github.com/ionic-team/capacitor/issues/5805)) ([25b82a8](https://github.com/ionic-team/capacitor/commit/25b82a84425bf09b2be45b213788b0e13982b9b3))
|
|
12
|
+
* **cli:** Revert some splash migration errors ([#5806](https://github.com/ionic-team/capacitor/issues/5806)) ([471feed](https://github.com/ionic-team/capacitor/commit/471feedc07bef357ac798fcba664bd373e9f8ebf))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# [4.0.0](https://github.com/ionic-team/capacitor/compare/4.0.0-beta.2...4.0.0) (2022-07-27)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* **android:** Add android.minWebviewVersion configuration option ([#5768](https://github.com/ionic-team/capacitor/issues/5768)) ([ad83827](https://github.com/ionic-team/capacitor/commit/ad838279e9cd190ce6f1a020a0ac9e3916786324))
|
|
24
|
+
* **cli:** add migrator for cap3 to cap4 ([#5762](https://github.com/ionic-team/capacitor/issues/5762)) ([7cb660a](https://github.com/ionic-team/capacitor/commit/7cb660a34d9a87274761d4492d0d77c9ef44ace8))
|
|
25
|
+
* Add option for custom error page ([#5723](https://github.com/ionic-team/capacitor/issues/5723)) ([e8bdef3](https://github.com/ionic-team/capacitor/commit/e8bdef3b4634e4ad45fa8fc34c7c0ab8dfa383f3))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# [4.0.0-beta.2](https://github.com/ionic-team/capacitor/compare/4.0.0-beta.1...4.0.0-beta.2) (2022-07-08)
|
|
32
|
+
|
|
33
|
+
**Note:** Version bump only for package @capacitor/cli
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# [4.0.0-beta.1](https://github.com/ionic-team/capacitor/compare/4.0.0-beta.0...4.0.0-beta.1) (2022-06-27)
|
|
7
40
|
|
|
8
41
|
**Note:** Version bump only for package @capacitor/cli
|
|
9
42
|
|
|
@@ -11,6 +44,93 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
11
44
|
|
|
12
45
|
|
|
13
46
|
|
|
47
|
+
# [4.0.0-beta.0](https://github.com/ionic-team/capacitor/compare/3.6.0...4.0.0-beta.0) (2022-06-17)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Features
|
|
51
|
+
|
|
52
|
+
* **android:** Use java 11 ([#5552](https://github.com/ionic-team/capacitor/issues/5552)) ([e47959f](https://github.com/ionic-team/capacitor/commit/e47959fcbd6a89b97b1275a5814fdb4e7ce30672))
|
|
53
|
+
* **ios:** Add preferredContentMode configuration option ([#5583](https://github.com/ionic-team/capacitor/issues/5583)) ([5b6dfa3](https://github.com/ionic-team/capacitor/commit/5b6dfa3fe29c85632546b299f03cc04a77cf7475))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
# [3.6.0](https://github.com/ionic-team/capacitor/compare/3.5.1...3.6.0) (2022-06-17)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Features
|
|
63
|
+
|
|
64
|
+
* **android:** update support for Portals for Capacitor to include Live Updates ([#5660](https://github.com/ionic-team/capacitor/issues/5660)) ([62f0a5e](https://github.com/ionic-team/capacitor/commit/62f0a5eaa40776aad79dbf8f8c0900037d3cc97e))
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# [4.0.0-alpha.2](https://github.com/ionic-team/capacitor/compare/3.4.1...4.0.0-alpha.2) (2022-05-12)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### Features
|
|
74
|
+
|
|
75
|
+
* **android:** Use java 11 ([#5552](https://github.com/ionic-team/capacitor/issues/5552)) ([e47959f](https://github.com/ionic-team/capacitor/commit/e47959fcbd6a89b97b1275a5814fdb4e7ce30672))
|
|
76
|
+
* **ios:** Add preferredContentMode configuration option ([#5583](https://github.com/ionic-team/capacitor/issues/5583)) ([5b6dfa3](https://github.com/ionic-team/capacitor/commit/5b6dfa3fe29c85632546b299f03cc04a77cf7475))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
## [3.5.1](https://github.com/ionic-team/capacitor/compare/3.5.0...3.5.1) (2022-05-04)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
### Bug Fixes
|
|
86
|
+
|
|
87
|
+
* **android:** move initialFocus on webview into config ([#5579](https://github.com/ionic-team/capacitor/issues/5579)) ([8b4e861](https://github.com/ionic-team/capacitor/commit/8b4e861514b0fbe08e9296f49c280234f54742e1))
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
# [3.5.0](https://github.com/ionic-team/capacitor/compare/3.4.3...3.5.0) (2022-04-22)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
### Features
|
|
97
|
+
|
|
98
|
+
* **cli:** support capacitor portals plugin changes needed ([#5558](https://github.com/ionic-team/capacitor/issues/5558)) ([6810a19](https://github.com/ionic-team/capacitor/commit/6810a19ae2bbda1f4b2afad61d37ca822ca157f5))
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# [4.0.0-alpha.1](https://github.com/ionic-team/capacitor/compare/3.4.1...4.0.0-alpha.1) (2022-03-25)
|
|
105
|
+
|
|
106
|
+
**Note:** Version bump only for package @capacitor/cli
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
## [3.4.3](https://github.com/ionic-team/capacitor/compare/3.4.2...3.4.3) (2022-03-04)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
### Bug Fixes
|
|
117
|
+
|
|
118
|
+
* **cli:** avoid srcFiles is not iterable on kotlinNeededCheck ([#5481](https://github.com/ionic-team/capacitor/issues/5481)) ([3c2b579](https://github.com/ionic-team/capacitor/commit/3c2b579c6edb1fc69d85689b268eb92067b7821b))
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
## [3.4.2](https://github.com/ionic-team/capacitor/compare/3.4.1...3.4.2) (2022-03-03)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
### Bug Fixes
|
|
128
|
+
|
|
129
|
+
* **android:** compatibility with cordova kotlin plugins ([#5438](https://github.com/ionic-team/capacitor/issues/5438)) ([55bf004](https://github.com/ionic-team/capacitor/commit/55bf004897b3feb280ab6b6575d2a2c1a0a183e2))
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
14
134
|
## [3.4.1](https://github.com/ionic-team/capacitor/compare/3.4.0...3.4.1) (2022-02-09)
|
|
15
135
|
|
|
16
136
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/android/open.js
CHANGED
|
@@ -15,7 +15,7 @@ async function openAndroid(config) {
|
|
|
15
15
|
if (!(await utils_fs_1.pathExists(androidStudioPath))) {
|
|
16
16
|
throw new Error(`Android Studio does not exist at: ${androidStudioPath}`);
|
|
17
17
|
}
|
|
18
|
-
await open_1.default(dir, { app: androidStudioPath, wait: false });
|
|
18
|
+
await open_1.default(dir, { app: { name: androidStudioPath }, wait: false });
|
|
19
19
|
log_1.logger.info(`Opening Android project at: ${colors_1.default.strong(config.android.platformDir)}.`);
|
|
20
20
|
}
|
|
21
21
|
catch (e) {
|
package/dist/android/update.js
CHANGED
|
@@ -130,7 +130,12 @@ project(':${getGradlePackageName(p.id)}').projectDir = new File('${relativePlugi
|
|
|
130
130
|
applyArray.push(`apply from: "${relativePluginPath}/${framework.$.src}"`);
|
|
131
131
|
}
|
|
132
132
|
else if (!framework.$.type && !framework.$.custom) {
|
|
133
|
-
|
|
133
|
+
if (framework.$.src.startsWith('platform(')) {
|
|
134
|
+
frameworksArray.push(` implementation ${framework.$.src}`);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
frameworksArray.push(` implementation "${framework.$.src}"`);
|
|
138
|
+
}
|
|
134
139
|
}
|
|
135
140
|
});
|
|
136
141
|
prefsArray = prefsArray.concat(plugin_1.getAllElements(p, platform, 'preference'));
|
|
@@ -141,8 +146,8 @@ project(':${getGradlePackageName(p.id)}').projectDir = new File('${relativePlugi
|
|
|
141
146
|
|
|
142
147
|
android {
|
|
143
148
|
compileOptions {
|
|
144
|
-
sourceCompatibility JavaVersion.
|
|
145
|
-
targetCompatibility JavaVersion.
|
|
149
|
+
sourceCompatibility JavaVersion.VERSION_11
|
|
150
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
146
151
|
}
|
|
147
152
|
}
|
|
148
153
|
|
|
@@ -166,7 +171,10 @@ if (hasProperty('postBuildExtras')) {
|
|
|
166
171
|
}
|
|
167
172
|
exports.installGradlePlugins = installGradlePlugins;
|
|
168
173
|
async function handleCordovaPluginsGradle(config, cordovaPlugins) {
|
|
174
|
+
var _a, _b, _c;
|
|
169
175
|
const pluginsGradlePath = path_1.join(config.android.cordovaPluginsDirAbs, 'build.gradle');
|
|
176
|
+
const kotlinNeeded = await kotlinNeededCheck(config, cordovaPlugins);
|
|
177
|
+
const kotlinVersionString = (_c = (_b = (_a = config.app.extConfig.cordova) === null || _a === void 0 ? void 0 : _a.preferences) === null || _b === void 0 ? void 0 : _b.GradlePluginKotlinVersion) !== null && _c !== void 0 ? _c : '1.7.0';
|
|
170
178
|
const frameworksArray = [];
|
|
171
179
|
let prefsArray = [];
|
|
172
180
|
const applyArray = [];
|
|
@@ -189,14 +197,30 @@ async function handleCordovaPluginsGradle(config, cordovaPlugins) {
|
|
|
189
197
|
});
|
|
190
198
|
let frameworkString = frameworksArray
|
|
191
199
|
.map(f => {
|
|
192
|
-
|
|
200
|
+
if (f.startsWith('platform(')) {
|
|
201
|
+
return ` implementation ${f}`;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
return ` implementation "${f}"`;
|
|
205
|
+
}
|
|
193
206
|
})
|
|
194
207
|
.join('\n');
|
|
195
208
|
frameworkString = await replaceFrameworkVariables(config, prefsArray, frameworkString);
|
|
209
|
+
if (kotlinNeeded) {
|
|
210
|
+
frameworkString += `\n implementation "androidx.core:core-ktx:$androidxCoreKTXVersion"`;
|
|
211
|
+
frameworkString += `\n implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"`;
|
|
212
|
+
}
|
|
196
213
|
const applyString = applyArray.join('\n');
|
|
197
214
|
let buildGradle = await utils_fs_1.readFile(pluginsGradlePath, { encoding: 'utf-8' });
|
|
198
215
|
buildGradle = buildGradle.replace(/(SUB-PROJECT DEPENDENCIES START)[\s\S]*(\/\/ SUB-PROJECT DEPENDENCIES END)/, '$1\n' + frameworkString.concat('\n') + ' $2');
|
|
199
216
|
buildGradle = buildGradle.replace(/(PLUGIN GRADLE EXTENSIONS START)[\s\S]*(\/\/ PLUGIN GRADLE EXTENSIONS END)/, '$1\n' + applyString.concat('\n') + '$2');
|
|
217
|
+
if (kotlinNeeded) {
|
|
218
|
+
buildGradle = buildGradle.replace(/(buildscript\s{\n(\t|\s{4})repositories\s{\n((\t{2}|\s{8}).+\n)+(\t|\s{4})}\n(\t|\s{4})dependencies\s{\n(\t{2}|\s{8}).+)\n((\t|\s{4})}\n}\n)/, `$1\n classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"\n$8`);
|
|
219
|
+
buildGradle = buildGradle.replace(/(ext\s{)/, `$1\n androidxCoreKTXVersion = project.hasProperty('androidxCoreKTXVersion') ? rootProject.ext.androidxCoreKTXVersion : '1.8.0'`);
|
|
220
|
+
buildGradle = buildGradle.replace(/(buildscript\s{)/, `$1\n ext.kotlin_version = project.hasProperty('kotlin_version') ? rootProject.ext.kotlin_version : '${kotlinVersionString}'`);
|
|
221
|
+
buildGradle = buildGradle.replace(/(apply\splugin:\s'com\.android\.library')/, `$1\napply plugin: 'kotlin-android'`);
|
|
222
|
+
buildGradle = buildGradle.replace(/(compileOptions\s{\n((\t{2}|\s{8}).+\n)+(\t|\s{4})})\n(})/, `$1\n sourceSets {\n main.java.srcDirs += 'src/main/kotlin'\n }\n$5`);
|
|
223
|
+
}
|
|
200
224
|
await utils_fs_1.writeFile(pluginsGradlePath, buildGradle);
|
|
201
225
|
const cordovaVariables = `// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
|
202
226
|
ext {
|
|
@@ -208,6 +232,27 @@ ext {
|
|
|
208
232
|
await utils_fs_1.writeFile(path_1.join(config.android.cordovaPluginsDirAbs, 'cordova.variables.gradle'), cordovaVariables);
|
|
209
233
|
}
|
|
210
234
|
exports.handleCordovaPluginsGradle = handleCordovaPluginsGradle;
|
|
235
|
+
async function kotlinNeededCheck(config, cordovaPlugins) {
|
|
236
|
+
var _a, _b;
|
|
237
|
+
if (((_b = (_a = config.app.extConfig.cordova) === null || _a === void 0 ? void 0 : _a.preferences) === null || _b === void 0 ? void 0 : _b.GradlePluginKotlinEnabled) !==
|
|
238
|
+
'true') {
|
|
239
|
+
for (const plugin of cordovaPlugins) {
|
|
240
|
+
const androidPlatform = plugin_1.getPluginPlatform(plugin, platform);
|
|
241
|
+
const sourceFiles = androidPlatform['source-file'];
|
|
242
|
+
if (sourceFiles) {
|
|
243
|
+
for (const srcFile of sourceFiles) {
|
|
244
|
+
if (/^.*\.kt$/.test(srcFile['$'].src)) {
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
211
256
|
async function copyPluginsNativeFiles(config, cordovaPlugins) {
|
|
212
257
|
const pluginsPath = path_1.join(config.android.cordovaPluginsDirAbs, 'src', 'main');
|
|
213
258
|
for (const p of cordovaPlugins) {
|
|
@@ -257,12 +302,16 @@ async function getPluginsTask(config) {
|
|
|
257
302
|
return androidPlugins;
|
|
258
303
|
});
|
|
259
304
|
}
|
|
260
|
-
async function
|
|
305
|
+
async function getVariablesGradleFile(config) {
|
|
261
306
|
const variablesFile = path_1.resolve(config.android.platformDirAbs, 'variables.gradle');
|
|
262
307
|
let variablesGradle = '';
|
|
263
308
|
if (await utils_fs_1.pathExists(variablesFile)) {
|
|
264
309
|
variablesGradle = await utils_fs_1.readFile(variablesFile, { encoding: 'utf-8' });
|
|
265
310
|
}
|
|
311
|
+
return variablesGradle;
|
|
312
|
+
}
|
|
313
|
+
async function replaceFrameworkVariables(config, prefsArray, frameworkString) {
|
|
314
|
+
const variablesGradle = await getVariablesGradleFile(config);
|
|
266
315
|
prefsArray.map((preference) => {
|
|
267
316
|
if (!variablesGradle.includes(preference.$.name)) {
|
|
268
317
|
frameworkString = frameworkString.replace(new RegExp(('$' + preference.$.name).replace('$', '\\$&'), 'g'), preference.$.default);
|
package/dist/declarations.d.ts
CHANGED
|
@@ -184,6 +184,22 @@ export interface CapacitorConfig {
|
|
|
184
184
|
* @since 3.1.0
|
|
185
185
|
*/
|
|
186
186
|
flavor?: string;
|
|
187
|
+
/**
|
|
188
|
+
* Whether to give the webview initial focus.
|
|
189
|
+
*
|
|
190
|
+
* @since 3.5.1
|
|
191
|
+
* @default true
|
|
192
|
+
*/
|
|
193
|
+
initialFocus?: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* The minimum supported webview version on Android supported by your app.
|
|
196
|
+
*
|
|
197
|
+
* The minimum supported cannot be lower than version `55`, which is required for Capacitor.
|
|
198
|
+
*
|
|
199
|
+
* @since 4.0.0
|
|
200
|
+
* @default 60
|
|
201
|
+
*/
|
|
202
|
+
minWebViewVersion?: number;
|
|
187
203
|
};
|
|
188
204
|
ios?: {
|
|
189
205
|
/**
|
|
@@ -314,6 +330,17 @@ export interface CapacitorConfig {
|
|
|
314
330
|
* @default false
|
|
315
331
|
*/
|
|
316
332
|
limitsNavigationsToAppBoundDomains?: boolean;
|
|
333
|
+
/**
|
|
334
|
+
* The content mode for the web view to use when it loads and renders web content.
|
|
335
|
+
*
|
|
336
|
+
* - 'recommended': The content mode that is appropriate for the current device.
|
|
337
|
+
* - 'desktop': The content mode that represents a desktop experience.
|
|
338
|
+
* - 'mobile': The content mode that represents a mobile experience.
|
|
339
|
+
*
|
|
340
|
+
* @since 4.0.0
|
|
341
|
+
* @default recommended
|
|
342
|
+
*/
|
|
343
|
+
preferredContentMode?: 'recommended' | 'desktop' | 'mobile';
|
|
317
344
|
};
|
|
318
345
|
server?: {
|
|
319
346
|
/**
|
|
@@ -385,6 +412,13 @@ export interface CapacitorConfig {
|
|
|
385
412
|
* @default []
|
|
386
413
|
*/
|
|
387
414
|
allowNavigation?: string[];
|
|
415
|
+
/**
|
|
416
|
+
* Specify path to a local html page to display in case of errors.
|
|
417
|
+
*
|
|
418
|
+
* @since 4.0.0
|
|
419
|
+
* @default null
|
|
420
|
+
*/
|
|
421
|
+
errorPath?: string;
|
|
388
422
|
};
|
|
389
423
|
cordova?: {
|
|
390
424
|
/**
|
|
@@ -432,6 +466,18 @@ export interface CapacitorConfig {
|
|
|
432
466
|
*/
|
|
433
467
|
includePlugins?: string[];
|
|
434
468
|
}
|
|
469
|
+
export interface Portal {
|
|
470
|
+
name: string;
|
|
471
|
+
webDir: string;
|
|
472
|
+
liveUpdateConfig?: LiveUpdateConfig;
|
|
473
|
+
}
|
|
474
|
+
export interface LiveUpdateConfig {
|
|
475
|
+
appId: string;
|
|
476
|
+
channel: string;
|
|
477
|
+
autoUpdateMethod: AutoUpdateMethod;
|
|
478
|
+
maxVersions?: number;
|
|
479
|
+
}
|
|
480
|
+
export declare type AutoUpdateMethod = 'none' | 'background';
|
|
435
481
|
export interface PluginsConfig {
|
|
436
482
|
/**
|
|
437
483
|
* Plugin configuration by class name.
|
|
@@ -441,4 +487,13 @@ export interface PluginsConfig {
|
|
|
441
487
|
[key: string]: {
|
|
442
488
|
[key: string]: any;
|
|
443
489
|
} | undefined;
|
|
490
|
+
/**
|
|
491
|
+
* Capacitor Portals plugin configuration
|
|
492
|
+
*
|
|
493
|
+
* @since 3.5.0
|
|
494
|
+
*/
|
|
495
|
+
Portals?: {
|
|
496
|
+
shell: Portal;
|
|
497
|
+
apps: Portal[];
|
|
498
|
+
};
|
|
444
499
|
}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runProgram = exports.run = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const commander_1 =
|
|
5
|
+
const commander_1 = require("commander");
|
|
6
6
|
const colors_1 = tslib_1.__importDefault(require("./colors"));
|
|
7
7
|
const config_1 = require("./config");
|
|
8
8
|
const errors_1 = require("./errors");
|
|
@@ -27,8 +27,8 @@ async function run() {
|
|
|
27
27
|
}
|
|
28
28
|
exports.run = run;
|
|
29
29
|
function runProgram(config) {
|
|
30
|
-
commander_1.
|
|
31
|
-
commander_1.
|
|
30
|
+
commander_1.program.version(config.cli.package.version);
|
|
31
|
+
commander_1.program
|
|
32
32
|
.command('config', { hidden: true })
|
|
33
33
|
.description(`print evaluated Capacitor config`)
|
|
34
34
|
.option('--json', 'Print in JSON format')
|
|
@@ -36,14 +36,14 @@ function runProgram(config) {
|
|
|
36
36
|
const { configCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/config')));
|
|
37
37
|
await configCommand(config, json);
|
|
38
38
|
}));
|
|
39
|
-
commander_1.
|
|
39
|
+
commander_1.program
|
|
40
40
|
.command('create [directory] [name] [id]', { hidden: true })
|
|
41
41
|
.description('Creates a new Capacitor project')
|
|
42
42
|
.action(cli_1.wrapAction(async () => {
|
|
43
43
|
const { createCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/create')));
|
|
44
44
|
await createCommand();
|
|
45
45
|
}));
|
|
46
|
-
commander_1.
|
|
46
|
+
commander_1.program
|
|
47
47
|
.command('init [appName] [appId]')
|
|
48
48
|
.description(`Initialize Capacitor configuration`)
|
|
49
49
|
.option('--web-dir <value>', 'Optional: Directory of your projects built web assets')
|
|
@@ -51,23 +51,24 @@ function runProgram(config) {
|
|
|
51
51
|
const { initCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/init')));
|
|
52
52
|
await initCommand(config, appName, appId, webDir);
|
|
53
53
|
})));
|
|
54
|
-
commander_1.
|
|
54
|
+
commander_1.program
|
|
55
55
|
.command('serve', { hidden: true })
|
|
56
56
|
.description('Serves a Capacitor Progressive Web App in the browser')
|
|
57
57
|
.action(cli_1.wrapAction(async () => {
|
|
58
58
|
const { serveCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/serve')));
|
|
59
59
|
await serveCommand();
|
|
60
60
|
}));
|
|
61
|
-
commander_1.
|
|
61
|
+
commander_1.program
|
|
62
62
|
.command('sync [platform]')
|
|
63
63
|
.description(`${colors_1.default.input('copy')} + ${colors_1.default.input('update')}`)
|
|
64
64
|
.option('--deployment', "Optional: if provided, Podfile.lock won't be deleted and pod install will use --deployment option")
|
|
65
|
-
.
|
|
65
|
+
.option('--inline', 'Optional: if true, all source maps will be inlined for easier debugging on mobile devices', false)
|
|
66
|
+
.action(cli_1.wrapAction(telemetry_1.telemetryAction(config, async (platform, { deployment, inline }) => {
|
|
66
67
|
config_1.checkExternalConfig(config.app);
|
|
67
68
|
const { syncCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/sync')));
|
|
68
|
-
await syncCommand(config, platform, deployment);
|
|
69
|
+
await syncCommand(config, platform, deployment, inline);
|
|
69
70
|
})));
|
|
70
|
-
commander_1.
|
|
71
|
+
commander_1.program
|
|
71
72
|
.command('update [platform]')
|
|
72
73
|
.description(`updates the native plugins and dependencies based on ${colors_1.default.strong('package.json')}`)
|
|
73
74
|
.option('--deployment', "Optional: if provided, Podfile.lock won't be deleted and pod install will use --deployment option")
|
|
@@ -76,7 +77,7 @@ function runProgram(config) {
|
|
|
76
77
|
const { updateCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/update')));
|
|
77
78
|
await updateCommand(config, platform, deployment);
|
|
78
79
|
})));
|
|
79
|
-
commander_1.
|
|
80
|
+
commander_1.program
|
|
80
81
|
.command('copy [platform]')
|
|
81
82
|
.description('copies the web app build into the native app')
|
|
82
83
|
.action(cli_1.wrapAction(telemetry_1.telemetryAction(config, async (platform) => {
|
|
@@ -84,7 +85,7 @@ function runProgram(config) {
|
|
|
84
85
|
const { copyCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/copy')));
|
|
85
86
|
await copyCommand(config, platform);
|
|
86
87
|
})));
|
|
87
|
-
commander_1.
|
|
88
|
+
commander_1.program
|
|
88
89
|
.command(`run [platform]`)
|
|
89
90
|
.description(`runs ${colors_1.default.input('sync')}, then builds and deploys the native app`)
|
|
90
91
|
.option('--list', 'list targets, then quit')
|
|
@@ -96,14 +97,14 @@ function runProgram(config) {
|
|
|
96
97
|
const { runCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/run')));
|
|
97
98
|
await runCommand(config, platform, { list, target, sync });
|
|
98
99
|
})));
|
|
99
|
-
commander_1.
|
|
100
|
+
commander_1.program
|
|
100
101
|
.command('open [platform]')
|
|
101
102
|
.description('opens the native project workspace (Xcode for iOS)')
|
|
102
103
|
.action(cli_1.wrapAction(telemetry_1.telemetryAction(config, async (platform) => {
|
|
103
104
|
const { openCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/open')));
|
|
104
105
|
await openCommand(config, platform);
|
|
105
106
|
})));
|
|
106
|
-
commander_1.
|
|
107
|
+
commander_1.program
|
|
107
108
|
.command('add [platform]')
|
|
108
109
|
.description('add a native platform project')
|
|
109
110
|
.action(cli_1.wrapAction(telemetry_1.telemetryAction(config, async (platform) => {
|
|
@@ -111,7 +112,7 @@ function runProgram(config) {
|
|
|
111
112
|
const { addCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/add')));
|
|
112
113
|
await addCommand(config, platform);
|
|
113
114
|
})));
|
|
114
|
-
commander_1.
|
|
115
|
+
commander_1.program
|
|
115
116
|
.command('ls [platform]')
|
|
116
117
|
.description('list installed Cordova and Capacitor plugins')
|
|
117
118
|
.action(cli_1.wrapAction(telemetry_1.telemetryAction(config, async (platform) => {
|
|
@@ -119,7 +120,7 @@ function runProgram(config) {
|
|
|
119
120
|
const { listCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/list')));
|
|
120
121
|
await listCommand(config, platform);
|
|
121
122
|
})));
|
|
122
|
-
commander_1.
|
|
123
|
+
commander_1.program
|
|
123
124
|
.command('doctor [platform]')
|
|
124
125
|
.description('checks the current setup for common errors')
|
|
125
126
|
.action(cli_1.wrapAction(telemetry_1.telemetryAction(config, async (platform) => {
|
|
@@ -127,35 +128,42 @@ function runProgram(config) {
|
|
|
127
128
|
const { doctorCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/doctor')));
|
|
128
129
|
await doctorCommand(config, platform);
|
|
129
130
|
})));
|
|
130
|
-
commander_1.
|
|
131
|
+
commander_1.program
|
|
131
132
|
.command('telemetry [on|off]', { hidden: true })
|
|
132
133
|
.description('enable or disable telemetry')
|
|
133
134
|
.action(cli_1.wrapAction(async (onOrOff) => {
|
|
134
135
|
const { telemetryCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/telemetry')));
|
|
135
136
|
await telemetryCommand(onOrOff);
|
|
136
137
|
}));
|
|
137
|
-
commander_1.
|
|
138
|
+
commander_1.program
|
|
138
139
|
.command('📡', { hidden: true })
|
|
139
140
|
.description('IPC receiver command')
|
|
140
141
|
.action(() => {
|
|
141
142
|
// no-op: IPC messages are received via `process.on('message')`
|
|
142
143
|
});
|
|
143
|
-
commander_1.
|
|
144
|
+
commander_1.program
|
|
144
145
|
.command('plugin:generate', { hidden: true })
|
|
145
146
|
.description('start a new Capacitor plugin')
|
|
146
147
|
.action(cli_1.wrapAction(async () => {
|
|
147
148
|
const { newPluginCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/new-plugin')));
|
|
148
149
|
await newPluginCommand();
|
|
149
150
|
}));
|
|
150
|
-
commander_1.
|
|
151
|
+
commander_1.program
|
|
152
|
+
.command('migrate')
|
|
153
|
+
.description('Migrate your current Capacitor app to the latest major version of Capacitor.')
|
|
154
|
+
.action(cli_1.wrapAction(async () => {
|
|
155
|
+
const { migrateCommand } = await Promise.resolve().then(() => tslib_1.__importStar(require('./tasks/migrate')));
|
|
156
|
+
await migrateCommand(config);
|
|
157
|
+
}));
|
|
158
|
+
commander_1.program.arguments('[command]').action(cli_1.wrapAction(async (cmd) => {
|
|
151
159
|
if (typeof cmd === 'undefined') {
|
|
152
160
|
log_1.output.write(`\n ${emoji_1.emoji('⚡️', '--')} ${colors_1.default.strong('Capacitor - Cross-Platform apps with JavaScript and the Web')} ${emoji_1.emoji('⚡️', '--')}\n\n`);
|
|
153
|
-
commander_1.
|
|
161
|
+
commander_1.program.outputHelp();
|
|
154
162
|
}
|
|
155
163
|
else {
|
|
156
164
|
errors_1.fatal(`Unknown command: ${colors_1.default.input(cmd)}`);
|
|
157
165
|
}
|
|
158
166
|
}));
|
|
159
|
-
commander_1.
|
|
167
|
+
commander_1.program.parse(process.argv);
|
|
160
168
|
}
|
|
161
169
|
exports.runProgram = runProgram;
|
package/dist/tasks/add.js
CHANGED
|
@@ -55,7 +55,7 @@ async function addCommand(config, selectedPlatformName) {
|
|
|
55
55
|
await doAdd(config, platformName);
|
|
56
56
|
await editPlatforms(config, platformName);
|
|
57
57
|
if (await utils_fs_1.pathExists(config.app.webDirAbs)) {
|
|
58
|
-
await sync_1.sync(config, platformName, false);
|
|
58
|
+
await sync_1.sync(config, platformName, false, false);
|
|
59
59
|
if (platformName === config.android.name) {
|
|
60
60
|
await common_2.runTask('Syncing Gradle', async () => {
|
|
61
61
|
return add_1.createLocalProperties(config.android.platformDirAbs);
|
package/dist/tasks/copy.js
CHANGED
|
@@ -9,6 +9,7 @@ const common_1 = require("../common");
|
|
|
9
9
|
const cordova_1 = require("../cordova");
|
|
10
10
|
const errors_1 = require("../errors");
|
|
11
11
|
const log_1 = require("../log");
|
|
12
|
+
const plugin_1 = require("../plugin");
|
|
12
13
|
const promise_1 = require("../util/promise");
|
|
13
14
|
const copy_1 = require("../web/copy");
|
|
14
15
|
async function copyCommand(config, selectedPlatformName) {
|
|
@@ -43,21 +44,41 @@ async function copy(config, platformName) {
|
|
|
43
44
|
throw result;
|
|
44
45
|
}
|
|
45
46
|
await common_1.runPlatformHook(config, platformName, config.app.rootDir, 'capacitor:copy:before');
|
|
47
|
+
const allPlugins = await plugin_1.getPlugins(config, platformName);
|
|
48
|
+
let usesCapacitorPortals = false;
|
|
49
|
+
if (allPlugins.filter(plugin => plugin.id === '@ionic-enterprise/capacitor-portals').length > 0) {
|
|
50
|
+
usesCapacitorPortals = true;
|
|
51
|
+
}
|
|
46
52
|
if (platformName === config.ios.name) {
|
|
47
|
-
|
|
53
|
+
if (usesCapacitorPortals) {
|
|
54
|
+
await copyFederatedWebDirs(config, await config.ios.webDirAbs);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
await copyWebDir(config, await config.ios.webDirAbs, config.app.webDirAbs);
|
|
58
|
+
}
|
|
48
59
|
await copyCapacitorConfig(config, config.ios.nativeTargetDirAbs);
|
|
49
60
|
const cordovaPlugins = await cordova_1.getCordovaPlugins(config, platformName);
|
|
50
61
|
await cordova_1.handleCordovaPluginsJS(cordovaPlugins, config, platformName);
|
|
51
62
|
}
|
|
52
63
|
else if (platformName === config.android.name) {
|
|
53
|
-
|
|
64
|
+
if (usesCapacitorPortals) {
|
|
65
|
+
await copyFederatedWebDirs(config, config.android.webDirAbs);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
await copyWebDir(config, config.android.webDirAbs, config.app.webDirAbs);
|
|
69
|
+
}
|
|
54
70
|
await copyCapacitorConfig(config, config.android.assetsDirAbs);
|
|
55
71
|
const cordovaPlugins = await cordova_1.getCordovaPlugins(config, platformName);
|
|
56
72
|
await cordova_1.handleCordovaPluginsJS(cordovaPlugins, config, platformName);
|
|
57
73
|
await cordova_1.writeCordovaAndroidManifest(cordovaPlugins, config, platformName);
|
|
58
74
|
}
|
|
59
75
|
else if (platformName === config.web.name) {
|
|
60
|
-
|
|
76
|
+
if (usesCapacitorPortals) {
|
|
77
|
+
log_1.logger.info('Capacitor Portals Plugin installed, skipping web bundling...');
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
await copy_1.copyWeb(config);
|
|
81
|
+
}
|
|
61
82
|
}
|
|
62
83
|
else {
|
|
63
84
|
throw `Platform ${platformName} is not valid.`;
|
|
@@ -76,9 +97,8 @@ async function copyCapacitorConfig(config, nativeAbsDir) {
|
|
|
76
97
|
});
|
|
77
98
|
});
|
|
78
99
|
}
|
|
79
|
-
async function copyWebDir(config, nativeAbsDir) {
|
|
100
|
+
async function copyWebDir(config, nativeAbsDir, webAbsDir) {
|
|
80
101
|
var _a;
|
|
81
|
-
const webAbsDir = config.app.webDirAbs;
|
|
82
102
|
const webRelDir = path_1.basename(webAbsDir);
|
|
83
103
|
const nativeRelDir = path_1.relative(config.app.rootDir, nativeAbsDir);
|
|
84
104
|
if (((_a = config.app.extConfig.server) === null || _a === void 0 ? void 0 : _a.url) && !(await utils_fs_1.pathExists(webAbsDir))) {
|
|
@@ -91,3 +111,25 @@ async function copyWebDir(config, nativeAbsDir) {
|
|
|
91
111
|
return utils_fs_1.copy(webAbsDir, nativeAbsDir);
|
|
92
112
|
});
|
|
93
113
|
}
|
|
114
|
+
async function copyFederatedWebDirs(config, nativeAbsDir) {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
log_1.logger.info('Capacitor Portals Plugin Loaded - Copying Web Assets');
|
|
117
|
+
if (!((_b = (_a = config.app.extConfig) === null || _a === void 0 ? void 0 : _a.plugins) === null || _b === void 0 ? void 0 : _b.Portals)) {
|
|
118
|
+
throw `Capacitor Portals plugin is present but no valid config is defined.`;
|
|
119
|
+
}
|
|
120
|
+
const portalsConfig = config.app.extConfig.plugins.Portals;
|
|
121
|
+
if (!isPortal(portalsConfig.shell)) {
|
|
122
|
+
throw `Capacitor Portals plugin is present but no valid Shell application is defined in the config.`;
|
|
123
|
+
}
|
|
124
|
+
if (!portalsConfig.apps.every(isPortal)) {
|
|
125
|
+
throw `Capacitor Portals plugin is present but there is a problem with the apps defined in the config.`;
|
|
126
|
+
}
|
|
127
|
+
await Promise.all([...portalsConfig.apps, portalsConfig.shell].map(app => {
|
|
128
|
+
const appDir = path_1.resolve(config.app.rootDir, app.webDir);
|
|
129
|
+
return copyWebDir(config, path_1.resolve(nativeAbsDir, app.name), appDir);
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
function isPortal(config) {
|
|
133
|
+
return (config.webDir !== undefined &&
|
|
134
|
+
config.name !== undefined);
|
|
135
|
+
}
|