@pi-r/android 0.6.5 → 0.6.7

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.
@@ -8,7 +8,7 @@ const util_1 = require("@e-mc/document/util");
8
8
  const types_1 = require("@e-mc/types");
9
9
  const Parser = htmlparser2.Parser;
10
10
  const DomHandler = domhandler.DomHandler;
11
- function finalize(instance) {
11
+ module.exports = function finalize(instance) {
12
12
  const config = instance.config;
13
13
  if (!config.manifest) {
14
14
  return;
@@ -176,6 +176,4 @@ function finalize(instance) {
176
176
  }
177
177
  }
178
178
  }
179
- }
180
-
181
- module.exports = finalize;
179
+ };
@@ -27,16 +27,18 @@ function isUpgrade(version, pending) {
27
27
  }
28
28
  return false;
29
29
  }
30
- function finalize(instance) {
30
+ module.exports = function finalize(instance) {
31
+ var _a, _b;
31
32
  const config = instance.config;
32
- const { profileable, dependencies, dataBinding, versionName, versionCode } = config;
33
- if (!profileable && !dependencies && !dataBinding && !versionName && !versionCode && !config.namespace) {
33
+ const { profileable, dependencies, dataBinding, versionName, versionCode, namespace } = config;
34
+ if (!profileable && !dependencies && !dataBinding && !versionName && !versionCode && !namespace) {
34
35
  return;
35
36
  }
36
37
  const detect = this.incremental !== 'staging';
37
38
  let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir), "build.gradle", { detect, languageOf: 'gradle' });
38
39
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
39
- let { namespace, javaVersion, dependencyScopes } = config, jvmTarget, modified;
40
+ const { javaVersion, dependencyScopes } = config;
41
+ let jvmTarget, modified;
40
42
  const upgrade = javaVersion > 0;
41
43
  const setModified = (output) => {
42
44
  if (output !== source) {
@@ -50,11 +52,12 @@ function finalize(instance) {
50
52
  const snapshot = hasScope('snapshot');
51
53
  const getData = () => data || (data = instance.findData('google-maven' + (snapshot ? '-snapshot' : '') + '.json', 'json'));
52
54
  const items = dependencies.map(item => {
55
+ var _a;
53
56
  let [groupId, artifactId, version, type] = item.split(':');
54
57
  if (!version || version === 'maven') {
55
58
  const maven = getData();
56
59
  let artifact;
57
- if (maven && (artifact = maven[groupId]?.find(child => child.artifactId === artifactId))) {
60
+ if (maven && (artifact = (_a = maven[groupId]) === null || _a === void 0 ? void 0 : _a.find(child => child.artifactId === artifactId))) {
58
61
  version = artifact.version;
59
62
  }
60
63
  else {
@@ -67,7 +70,7 @@ function finalize(instance) {
67
70
  const supplement = [];
68
71
  for (const item of items) {
69
72
  const [gId, id] = item;
70
- const target = data[gId]?.find(group => id === group.artifactId);
73
+ const target = (_a = data[gId]) === null || _a === void 0 ? void 0 : _a.find(group => id === group.artifactId);
71
74
  if (!target) {
72
75
  continue;
73
76
  }
@@ -197,7 +200,7 @@ function finalize(instance) {
197
200
  let dependency;
198
201
  if (args || named) {
199
202
  const [group, name, version] = item;
200
- dependency = kotlin ? `(group = "${group}", name = "${name}", version = "${version}")` : ` group: '${group}', name: '${name}', version: '${version}'` + (args?.endsWith(',') ? ',' : '');
203
+ dependency = kotlin ? `(group = "${group}", name = "${name}", version = "${version}")` : ` group: '${group}', name: '${name}', version: '${version}'` + ((args === null || args === void 0 ? void 0 : args.endsWith(',')) ? ',' : '');
201
204
  }
202
205
  else {
203
206
  dependency = item.slice(0, 3).join(':');
@@ -263,9 +266,9 @@ function finalize(instance) {
263
266
  output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
264
267
  }
265
268
  else {
266
- output = Document.updateGradle(output, ['plugins'], "id 'org.jetbrains.kotlin.android'", { upgrade: true, multiple: true, addendum: `version '${instance.findVersion('org.jetbrains.kotlin:kotlin-stdlib', "1.9.22")}'` });
269
+ output = Document.updateGradle(output, ['plugins'], "id 'org.jetbrains.kotlin.android'", { upgrade: true, multiple: true, addendum: `version '${instance.findVersion('org.jetbrains.kotlin:kotlin-stdlib', "1.9.23")}'` });
267
270
  output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
268
- output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.9")}'`, true);
271
+ output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.11")}'`, true);
269
272
  if (upgrade) {
270
273
  output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
271
274
  }
@@ -316,8 +319,9 @@ function finalize(instance) {
316
319
  output = Document.updateGradle(output, ['android'], kotlin ? `buildToolsVersion = "${version}"` : `buildToolsVersion "${version}"`, true);
317
320
  }
318
321
  }
319
- if (namespace || (namespace = config.manifest?.package)) {
320
- output = Document.updateGradle(output, ['android', 'defaultConfig'], (kotlin ? 'applicationId = ' : 'applicationId ') + `"${namespace}"`, true);
322
+ const applicationId = (_b = config.manifest) === null || _b === void 0 ? void 0 : _b.package;
323
+ if (applicationId) {
324
+ output = Document.updateGradle(output, ['android', 'defaultConfig'], (kotlin ? 'applicationId = ' : 'applicationId ') + `"${applicationId}"`, true);
321
325
  }
322
326
  setModified(output);
323
327
  }
@@ -380,6 +384,4 @@ function finalize(instance) {
380
384
  }
381
385
  }
382
386
  }
383
- }
384
-
385
- module.exports = finalize;
387
+ };
@@ -2,14 +2,15 @@
2
2
  const path = require("path");
3
3
  const util_1 = require("@e-mc/document/util");
4
4
  const parse_1 = require("@e-mc/document/parse");
5
- function finalize(instance) {
6
- const { dependencies, projectName, manifest, mainParentDir } = instance.config;
5
+ module.exports = function finalize(instance) {
6
+ const { dependencies, projectName, mainParentDir } = instance.config;
7
7
  if (!dependencies && !projectName) {
8
8
  return;
9
9
  }
10
10
  let { localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "settings.gradle", { detect: this.incremental !== 'staging', languageOf: 'gradle' });
11
11
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
12
- let targetName = projectName?.replace(/"/g, '\\"'), modified;
12
+ const targetName = projectName === null || projectName === void 0 ? void 0 : projectName.replace(/"/g, '\\"');
13
+ let modified;
13
14
  if (existing) {
14
15
  let match;
15
16
  if (dependencies) {
@@ -49,10 +50,6 @@ function finalize(instance) {
49
50
  }
50
51
  }
51
52
  else {
52
- if (!targetName && (targetName = manifest?.package)) {
53
- const index = targetName.lastIndexOf('.');
54
- targetName = index !== -1 ? targetName.substring(index + 1) : '';
55
- }
56
53
  source = (0, util_1.replaceAll)(source, (name) => {
57
54
  switch (name) {
58
55
  case 'projectName':
@@ -63,6 +60,9 @@ function finalize(instance) {
63
60
  return '';
64
61
  }
65
62
  });
63
+ if (!targetName) {
64
+ source = source.replace(/rootProject\.name = ["']{2}[\r\n]*/, '');
65
+ }
66
66
  }
67
67
  if (modified || !existing) {
68
68
  try {
@@ -75,6 +75,4 @@ function finalize(instance) {
75
75
  }
76
76
  }
77
77
  }
78
- }
79
-
80
- module.exports = finalize;
78
+ };
@@ -6,7 +6,8 @@ const which = require("which");
6
6
  const types_1 = require("@e-mc/types");
7
7
  const Document = require("@e-mc/document");
8
8
  const checkWin32 = (value) => value === "gradlew" && process.platform === 'win32' ? value + '.bat' : value;
9
- async function finalize(instance) {
9
+ module.exports = async function finalize(instance) {
10
+ var _a, _b;
10
11
  const commands = instance.config.commands;
11
12
  if (!commands || this.incremental === 'staging') {
12
13
  return;
@@ -26,7 +27,7 @@ async function finalize(instance) {
26
27
  else {
27
28
  return;
28
29
  }
29
- const settings = instance.settings.extensions?.task || {};
30
+ const settings = ((_a = instance.settings.extensions) === null || _a === void 0 ? void 0 : _a.task) || {};
30
31
  const exec = settings.exec;
31
32
  let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title, filename, altname, foundDir;
32
33
  if (command) {
@@ -34,7 +35,7 @@ async function finalize(instance) {
34
35
  title = "maven";
35
36
  }
36
37
  else {
37
- title = /([^\\/]+?)(?:\.[a-z]+)?$/i.exec(command)?.[1] || 'spawn';
38
+ title = ((_b = /([^\\/]+?)(?:\.[a-z]+)?$/i.exec(command)) === null || _b === void 0 ? void 0 : _b[1]) || 'spawn';
38
39
  }
39
40
  if (!/[\\/]/.test(command = path.normalize(command))) {
40
41
  filename = checkWin32(command);
@@ -119,6 +120,4 @@ async function finalize(instance) {
119
120
  })
120
121
  .catch(err => instance.writeFail(["Unable to perform task", command + ' ' + task], err, { type: 4, startTime }));
121
122
  }
122
- }
123
-
124
- module.exports = finalize;
123
+ };
package/index.js CHANGED
@@ -165,13 +165,14 @@ class AndroidDocument extends Document {
165
165
  }
166
166
  }
167
167
  findTemplate(baseDir, filename, options) {
168
+ var _a;
168
169
  let detect, languageOf, subDir;
169
170
  if (options) {
170
171
  ({ detect, languageOf, subDir } = options);
171
172
  }
172
173
  let kotlin, language;
173
174
  if (languageOf) {
174
- kotlin = (language = this.settings.language?.[languageOf]) === 'kotlin';
175
+ kotlin = (language = (_a = this.settings.language) === null || _a === void 0 ? void 0 : _a[languageOf]) === 'kotlin';
175
176
  const isKts = this.detectKts(baseDir, filename);
176
177
  detect = isKts !== null && (kotlin && isKts || !kotlin && !isKts);
177
178
  if (kotlin) {
@@ -231,5 +232,4 @@ class AndroidDocument extends Document {
231
232
  return (_a = this.module).settings || (_a.settings = {});
232
233
  }
233
234
  }
234
-
235
235
  module.exports = AndroidDocument;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/android",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "description": "Android document constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -20,8 +20,8 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/pi-r#readme",
22
22
  "dependencies": {
23
- "@e-mc/document": "^0.8.6",
24
- "@e-mc/types": "^0.8.6",
23
+ "@e-mc/document": "^0.8.8",
24
+ "@e-mc/types": "^0.8.8",
25
25
  "htmlparser2": "^9.1.0",
26
26
  "which": "^2.0.2"
27
27
  }
@@ -1,4 +1,4 @@
1
1
  plugins {
2
- id 'com.android.application' version '8.2.2' apply false
3
- id 'com.android.library' version '8.2.2' apply false
2
+ id 'com.android.application' version '8.3.0' apply false
3
+ id 'com.android.library' version '8.3.0' apply false
4
4
  }
@@ -1,5 +1,5 @@
1
1
  plugins {
2
- id 'com.android.application' version '8.2.2' apply false
3
- id 'com.android.library' version '8.2.2' apply false
4
- id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
2
+ id 'com.android.application' version '8.3.0' apply false
3
+ id 'com.android.library' version '8.3.0' apply false
4
+ id 'org.jetbrains.kotlin.android' version '1.9.23' apply false
5
5
  }
@@ -38,7 +38,7 @@ java {
38
38
  }
39
39
 
40
40
  dependencies {
41
- implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.22")
41
+ implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.23")
42
42
  implementation("androidx.core:core-ktx:1.12.0")
43
43
  testImplementation("junit:junit:4.13.2")
44
44
  androidTestImplementation("androidx.test.ext:junit:1.1.5")
@@ -1,5 +1,5 @@
1
1
  plugins {
2
- id("com.android.application") version "8.2.2" apply false
3
- id("com.android.library") version "8.2.2" apply false
4
- id("org.jetbrains.kotlin.android") version "1.9.22" apply false
2
+ id("com.android.application") version "8.3.0" apply false
3
+ id("com.android.library") version "8.3.0" apply false
4
+ id("org.jetbrains.kotlin.android") version "1.9.23" apply false
5
5
  }