@capacitor/cli 4.0.0 → 4.0.2-nightly-0ad41d05.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 CHANGED
@@ -3,6 +3,18 @@
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](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
+
6
18
  # [4.0.0](https://github.com/ionic-team/capacitor/compare/4.0.0-beta.2...4.0.0) (2022-07-27)
7
19
 
8
20
 
Binary file
Binary file
@@ -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
- frameworksArray.push(` implementation "${framework.$.src}"`);
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'));
@@ -192,7 +197,12 @@ async function handleCordovaPluginsGradle(config, cordovaPlugins) {
192
197
  });
193
198
  let frameworkString = frameworksArray
194
199
  .map(f => {
195
- return ` implementation "${f}"`;
200
+ if (f.startsWith('platform(')) {
201
+ return ` implementation ${f}`;
202
+ }
203
+ else {
204
+ return ` implementation "${f}"`;
205
+ }
196
206
  })
197
207
  .join('\n');
198
208
  frameworkString = await replaceFrameworkVariables(config, prefsArray, frameworkString);
package/dist/index.js CHANGED
@@ -62,10 +62,11 @@ function runProgram(config) {
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
- .action(cli_1.wrapAction(telemetry_1.telemetryAction(config, async (platform, { deployment }) => {
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
71
  commander_1.program
71
72
  .command('update [platform]')
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);
@@ -37,6 +37,7 @@ const plugins = [
37
37
  '@capacitor/local-notifications',
38
38
  '@capacitor/motion',
39
39
  '@capacitor/network',
40
+ '@capacitor/preferences',
40
41
  '@capacitor/push-notifications',
41
42
  '@capacitor/screen-reader',
42
43
  '@capacitor/share',
@@ -45,8 +46,8 @@ const plugins = [
45
46
  '@capacitor/text-zoom',
46
47
  '@capacitor/toast',
47
48
  ];
48
- const coreVersion = 'latest';
49
- const pluginVersion = 'latest';
49
+ const coreVersion = '^4.0.0';
50
+ const pluginVersion = '^4.0.0';
50
51
  async function migrateCommand(config) {
51
52
  if (config === null) {
52
53
  errors_1.fatal('Config data missing');
@@ -143,14 +144,21 @@ async function migrateCommand(config) {
143
144
  // Variables gradle
144
145
  await common_1.runTask(`Migrating variables.gradle file.`, () => {
145
146
  return (async () => {
147
+ const variablesPath = path_1.join(config.android.platformDirAbs, 'variables.gradle');
148
+ let txt = readFile(variablesPath);
149
+ if (!txt) {
150
+ return;
151
+ }
152
+ txt = txt.replace(/= {2}'/g, `= '`);
153
+ utils_fs_1.writeFileSync(variablesPath, txt, { encoding: 'utf-8' });
146
154
  for (const variable of Object.keys(variablesAndClasspaths.variables)) {
147
- if (!(await updateFile(config, path_1.join(config.android.platformDirAbs, 'variables.gradle'), `${variable} = '`, `'`, variablesAndClasspaths.variables[variable].toString(), true))) {
148
- const didWork = await updateFile(config, path_1.join(config.android.platformDirAbs, 'variables.gradle'), `${variable} = `, `\n`, variablesAndClasspaths.variables[variable].toString(), true);
155
+ if (!(await updateFile(config, variablesPath, `${variable} = '`, `'`, variablesAndClasspaths.variables[variable].toString(), true))) {
156
+ const didWork = await updateFile(config, variablesPath, `${variable} = `, `\n`, variablesAndClasspaths.variables[variable].toString(), true);
149
157
  if (!didWork) {
150
- let file = readFile(path_1.join(config.android.platformDirAbs, 'variables.gradle'));
158
+ let file = readFile(variablesPath);
151
159
  if (file) {
152
- file = file.replace('ext {', `ext {\n ${variable} = '${variablesAndClasspaths.variables[variable].toString()}'`);
153
- utils_fs_1.writeFileSync(path_1.join(config.android.platformDirAbs, 'variables.gradle'), file);
160
+ file = file.replace('}', ` ${variable} = '${variablesAndClasspaths.variables[variable].toString()}'\n}`);
161
+ utils_fs_1.writeFileSync(variablesPath, file);
154
162
  }
155
163
  }
156
164
  }
@@ -158,12 +166,12 @@ async function migrateCommand(config) {
158
166
  })();
159
167
  });
160
168
  // remove init
161
- await common_1.runTask('Migrating MainActivity by removing init().', () => {
162
- return removeOldInitAndroid(config);
169
+ await common_1.runTask('Migrating MainActivity', () => {
170
+ return migrateMainActivity(config);
163
171
  });
164
172
  rimraf_1.default.sync(path_1.join(config.android.appDirAbs, 'build'));
165
173
  // add new splashscreen
166
- await common_1.runTask('Migrate to Android 12 Splashscreen.', () => {
174
+ await common_1.runTask('Migrate to Android 12 Splashscreen and apply DayNight theme.', () => {
167
175
  return addNewSplashScreen(config);
168
176
  });
169
177
  }
@@ -251,7 +259,7 @@ async function writeBreakingChanges() {
251
259
  }
252
260
  }
253
261
  if (broken.length > 0) {
254
- log_1.logger.info(`IMPORTANT: Review https://next.capacitorjs.com/docs/updating/4-0#plugins for breaking changes in these plugins that you use: ${broken.join(', ')}.`);
262
+ log_1.logger.info(`IMPORTANT: Review https://capacitorjs.com/docs/updating/4-0#plugins for breaking changes in these plugins that you use: ${broken.join(', ')}.`);
255
263
  }
256
264
  if (allDependencies['@capacitor/android']) {
257
265
  log_1.logger.info('Warning: The Android Gradle plugin was updated and it requires Java 11 to run. You may need to select this in Android Studio.');
@@ -287,7 +295,7 @@ async function updateAndroidManifest(filename) {
287
295
  async function updateBuildGradle(filename, leaveJCenter, variablesAndClasspaths) {
288
296
  // In build.gradle add dependencies:
289
297
  // classpath 'com.android.tools.build:gradle:7.2.1'
290
- // classpath 'com.google.gms:google-services:4.3.10'
298
+ // classpath 'com.google.gms:google-services:4.3.13'
291
299
  const txt = readFile(filename);
292
300
  if (!txt) {
293
301
  return;
@@ -298,11 +306,7 @@ async function updateBuildGradle(filename, leaveJCenter, variablesAndClasspaths)
298
306
  };
299
307
  let replaced = txt;
300
308
  for (const dep of Object.keys(neededDeps)) {
301
- if (!replaced.includes(`classpath '${dep}`)) {
302
- replaced = txt.replace('dependencies {', `dependencies {\n classpath '${dep}:${neededDeps[dep]}'`);
303
- }
304
- else {
305
- // Update
309
+ if (replaced.includes(`classpath '${dep}`)) {
306
310
  replaced = setAllStringIn(replaced, `classpath '${dep}:`, `'`, neededDeps[dep]);
307
311
  log_1.logger.info(`Set ${dep} = ${neededDeps[dep]}.`);
308
312
  }
@@ -409,7 +413,7 @@ async function updateGradleWrapper(filename) {
409
413
  }
410
414
  const replaced = setAllStringIn(txt, 'distributionUrl=', '\n',
411
415
  // eslint-disable-next-line no-useless-escape
412
- `https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip`);
416
+ `https\\://services.gradle.org/distributions/gradle-7.4.2-all.zip`);
413
417
  utils_fs_1.writeFileSync(filename, replaced, 'utf-8');
414
418
  }
415
419
  async function updateFile(config, filename, textStart, textEnd, replacement, skipIfNotFound) {
@@ -565,7 +569,7 @@ async function podfileAssertDeploymentTarget(filename) {
565
569
  }
566
570
  utils_fs_1.writeFileSync(filename, replaced, 'utf-8');
567
571
  }
568
- async function removeOldInitAndroid(config) {
572
+ async function migrateMainActivity(config) {
569
573
  const xmlData = await xml_1.readXML(path_1.join(config.android.srcMainDirAbs, 'AndroidManifest.xml'));
570
574
  const manifestNode = xmlData.manifest;
571
575
  const applicationChildNodes = manifestNode.application;
@@ -615,11 +619,22 @@ async function removeOldInitAndroid(config) {
615
619
  let data = readFile(mainActivityClassFilePath);
616
620
  if (data) {
617
621
  const bindex = data.indexOf('this.init(savedInstanceState');
618
- if (bindex == -1)
622
+ if (bindex !== -1) {
623
+ const eindex = data.indexOf('}});', bindex) + 4;
624
+ data = data.replace(data.substring(bindex, eindex), '');
625
+ data = data.replace('// Initializes the Bridge', '');
626
+ }
627
+ const rindex = data.indexOf('registerPlugin');
628
+ if (rindex !== -1) {
629
+ if (data.indexOf('super.onCreate(savedInstanceState);') < rindex) {
630
+ data = data.replace('super.onCreate(savedInstanceState);\n ', '');
631
+ const eindex = data.lastIndexOf('.class);') + 8;
632
+ data = data.replace(data.substring(bindex, eindex), `${data.substring(bindex, eindex)}\n super.onCreate(savedInstanceState);`);
633
+ }
634
+ }
635
+ if (bindex == -1 && rindex == -1) {
619
636
  return;
620
- const eindex = data.indexOf('}});', bindex) + 4;
621
- data = data.replace(data.substring(bindex, eindex), '');
622
- data = data.replace('// Initializes the Bridge', '');
637
+ }
623
638
  utils_fs_1.writeFileSync(mainActivityClassFilePath, data);
624
639
  }
625
640
  }
@@ -628,6 +643,11 @@ async function addNewSplashScreen(config) {
628
643
  let stylesXml = readFile(stylePath);
629
644
  if (!stylesXml)
630
645
  return;
631
- stylesXml = stylesXml.replace('AppTheme.NoActionBar', 'Theme.SplashScreen');
646
+ stylesXml = stylesXml.replace(`parent="AppTheme.NoActionBar"`, `parent="Theme.SplashScreen"`);
647
+ // revert wrong replaces
648
+ stylesXml = stylesXml.replace(`name="Theme.SplashScreen"`, `name="AppTheme.NoActionBar"`);
649
+ stylesXml = stylesXml.replace(`name="Theme.SplashScreenLaunch"`, `name="AppTheme.NoActionBarLaunch"`);
650
+ // Apply DayNight theme
651
+ stylesXml = stylesXml.replace(`parent="Theme.AppCompat.NoActionBar"`, `parent="Theme.AppCompat.DayNight.NoActionBar"`);
632
652
  utils_fs_1.writeFileSync(stylePath, stylesXml);
633
653
  }
package/dist/tasks/run.js CHANGED
@@ -56,7 +56,7 @@ async function runCommand(config, selectedPlatformName, options) {
56
56
  }
57
57
  try {
58
58
  if (options.sync) {
59
- await sync_1.sync(config, platformName, false);
59
+ await sync_1.sync(config, platformName, false, true);
60
60
  }
61
61
  await run(config, platformName, options);
62
62
  }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.inlineSourceMaps = void 0;
4
+ const utils_fs_1 = require("@ionic/utils-fs");
5
+ const path_1 = require("path");
6
+ const log_1 = require("../log");
7
+ function walkDirectory(dirPath) {
8
+ const files = utils_fs_1.readdirSync(dirPath);
9
+ files.forEach(file => {
10
+ const targetFile = path_1.join(dirPath, file);
11
+ if (utils_fs_1.existsSync(targetFile) && utils_fs_1.lstatSync(targetFile).isDirectory()) {
12
+ walkDirectory(targetFile);
13
+ }
14
+ else {
15
+ const mapFile = path_1.join(dirPath, `${file}.map`);
16
+ if (path_1.extname(file) === '.js' && utils_fs_1.existsSync(mapFile)) {
17
+ const bufMap = utils_fs_1.readFileSync(mapFile).toString('base64');
18
+ const bufFile = utils_fs_1.readFileSync(targetFile, 'utf8');
19
+ const result = bufFile.replace(`sourceMappingURL=${file}.map`, 'sourceMappingURL=data:application/json;charset=utf-8;base64,' +
20
+ bufMap);
21
+ utils_fs_1.writeFileSync(targetFile, result);
22
+ utils_fs_1.unlinkSync(mapFile);
23
+ }
24
+ }
25
+ });
26
+ }
27
+ async function inlineSourceMaps(config, platformName) {
28
+ let buildDir = '';
29
+ if (platformName == config.ios.name) {
30
+ buildDir = await config.ios.webDirAbs;
31
+ }
32
+ if (platformName == config.android.name) {
33
+ buildDir = await config.android.webDirAbs;
34
+ }
35
+ if (buildDir) {
36
+ log_1.logger.info('Inlining sourcemaps');
37
+ walkDirectory(buildDir);
38
+ }
39
+ }
40
+ exports.inlineSourceMaps = inlineSourceMaps;
@@ -6,11 +6,12 @@ const errors_1 = require("../errors");
6
6
  const log_1 = require("../log");
7
7
  const promise_1 = require("../util/promise");
8
8
  const copy_1 = require("./copy");
9
+ const sourcemaps_1 = require("./sourcemaps");
9
10
  const update_1 = require("./update");
10
11
  /**
11
12
  * Sync is a copy and an update in one.
12
13
  */
13
- async function syncCommand(config, selectedPlatformName, deployment) {
14
+ async function syncCommand(config, selectedPlatformName, deployment, inline) {
14
15
  var _a, _b;
15
16
  if (selectedPlatformName && !(await common_1.isValidPlatform(selectedPlatformName))) {
16
17
  try {
@@ -30,7 +31,7 @@ async function syncCommand(config, selectedPlatformName, deployment) {
30
31
  () => common_1.checkWebDir(config),
31
32
  ...update_1.updateChecks(config, platforms),
32
33
  ]);
33
- await promise_1.allSerial(platforms.map(platformName => () => sync(config, platformName, deployment)));
34
+ await promise_1.allSerial(platforms.map(platformName => () => sync(config, platformName, deployment, inline)));
34
35
  const now = +new Date();
35
36
  const diff = (now - then) / 1000;
36
37
  log_1.logger.info(`Sync finished in ${diff}s`);
@@ -44,11 +45,14 @@ async function syncCommand(config, selectedPlatformName, deployment) {
44
45
  }
45
46
  }
46
47
  exports.syncCommand = syncCommand;
47
- async function sync(config, platformName, deployment) {
48
+ async function sync(config, platformName, deployment, inline) {
48
49
  var _a;
49
50
  await common_1.runPlatformHook(config, platformName, config.app.rootDir, 'capacitor:sync:before');
50
51
  try {
51
52
  await copy_1.copy(config, platformName);
53
+ if (inline) {
54
+ await sourcemaps_1.inlineSourceMaps(config, platformName);
55
+ }
52
56
  }
53
57
  catch (e) {
54
58
  log_1.logger.error((_a = e.stack) !== null && _a !== void 0 ? _a : e);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/cli",
3
- "version": "4.0.0",
3
+ "version": "4.0.2-nightly-0ad41d05.0",
4
4
  "description": "Capacitor: Cross-platform apps with JavaScript and the web",
5
5
  "homepage": "https://capacitorjs.com",
6
6
  "author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
@@ -83,5 +83,5 @@
83
83
  "publishConfig": {
84
84
  "access": "public"
85
85
  },
86
- "gitHead": "434b1a0ff32f513973ef35258032a4df0cb331c1"
86
+ "gitHead": "0ad41d0567e69d31e65c92d4890fc8860d0344ac"
87
87
  }