@capacitor/cli 4.0.1 → 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.
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',
@@ -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
160
  file = file.replace('}', ` ${variable} = '${variablesAndClasspaths.variables[variable].toString()}'\n}`);
153
- utils_fs_1.writeFileSync(path_1.join(config.android.platformDirAbs, 'variables.gradle'), file);
161
+ utils_fs_1.writeFileSync(variablesPath, file);
154
162
  }
155
163
  }
156
164
  }
@@ -158,8 +166,8 @@ 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
@@ -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
  }
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.1",
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": "a14824b660ccd39b7ed150a26debb15e9a161303"
86
+ "gitHead": "0ad41d0567e69d31e65c92d4890fc8860d0344ac"
87
87
  }