@pi-r/android 0.12.0 → 0.12.2

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.
@@ -7,10 +7,12 @@ const { escapePattern, isArray, isString } = require('@e-mc/types');
7
7
  const { getIndent, getNewline, spliceString, trimQuote, wrapQuote } = require('@e-mc/document/util');
8
8
  const REGEXP_SEMVER = /^((\s*,\s*)?[([\]]((\s*,\s*)?\d+\.\d+(\s*,\s*)?)+[)[\]])+$/;
9
9
  const REGEXP_DEPENDENCIES = /dependencies\s+\{((?:{[^{]*{|{[^}]*}|}[^}]*}|\\}*?|[^{}+])+)\}/;
10
- const REGEXP_DEPENDENCY = /([ \t]*)([A-Za-z_$][\w$]*)(?:\s*\(?\s*(?:module\(?\s*)?["']([^"']+)["']\s*\)?|\s+((?:\s*(?:group|name|version)\s*:\s*(?:"(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')\s*,?){3}))?/gd;
11
- const REGEXP_DEPENDENCY_KOTLIN = /([ \t]*)([A-Za-z_$][\w$]*)\((?:\s*(?:(?:module\(\s*)?"([^"]+)"|((?:\s*(?:group|name|version)\s*=\s*"(?:[^"]|(?<=\\)")+"\s*,?){3}))\s*\))?/gd;
12
- const REGEXP_LIBRARY = /([ \t]*)implementation\s+(?:(project|files)\s*\(\s*("(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')\s*\)|(fileTree)\s*\(\s*((?:\s*(?:dir|include)\s*:\s*(?:"(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+'|\[[^\]]+\])\s*,?){2})\s*\))[ \t\r]*\n/gd;
13
- const REGEXP_LIBRARY_KOTLIN = /([ \t]*)implementation\(\s*(?:(project|files)\(\s*"(.+)"\s*\)|(fileTree)\(\s*mapOf\(((?:\s*"(?:dir|include)"\s+to\s+(?:"(?:[^"]|(?<=\\)")+"|listOf\([^)]+\))\s*,?){2})\)\s*\))\s*\)[ \t\r]*\n/gd;
10
+ const REGEXP_DEPENDENCY = /([ \t]*)([A-Za-z_$][\w$]*)(?:\s*\(?\s*(?:module\(?\s*)?["']([^"']+)["']\s*\)?|\s+((?:\s*(?:group|name|version)\s*:\s*(?:"(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')\s*,?){3}))?/g;
11
+ const REGEXP_DEPENDENCY_KOTLIN = /([ \t]*)([A-Za-z_$][\w$]*)\((?:\s*(?:(?:module\(\s*)?"([^"]+)"|((?:\s*(?:group|name|version)\s*=\s*"(?:[^"]|(?<=\\)")+"\s*,?){3}))\s*\))?/g;
12
+ const REGEXP_LIBRARY = /([ \t]*)implementation\s+(?:(project|files)\(\s*("(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')\s*\)|(fileTree)\(\s*((?:\s*(?:dir|include)\s*:\s*(?:"(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+'|\[[^\]]+\])\s*,?){2})\s*\))[ \t\r]*\n/g;
13
+ const REGEXP_LIBRARY_KOTLIN = /([ \t]*)implementation\(\s*(?:(project|files)\(\s*"(.+)"\s*\)|(fileTree)\(\s*mapOf\(((?:\s*"(?:dir|include)"\s+to\s+(?:"(?:[^"]|(?<=\\)")+"|listOf\([^)]+\))\s*,?){2})\)\s*\))\s*\)[ \t\r]*\n/g;
14
+ const REGEXP_PLATFORM = /([ \t]*)implementation\s+platform\(\s*("(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')\s*\)[ \t\r]*\n/g;
15
+ const REGEXP_PLATFORM_KOTLIN = /([ \t]*)implementation\(\s*platform\(\s*"(.+)"\s*\)\s*\)[ \t\r]*\n/g;
14
16
  const REGEXP_VERSIONS = /(\S+)\s*=\s*(?:"([^"]+)"|'([^']+)'|(\{(?:\s*(?:require|strictly|prefer|reject(?:All)?)\s*=\s*(?:"[^"]+"|'[^']+')\s*,?)+\s*\}))/g;
15
17
  const REGEXP_VERSIONS_LIB = /(\S+)\s*=\s*(?:\{\s*(group|name|module|version(?:\.ref)?)\s*=\s*(?:"([^"]+)"|'([^']+)'|(\{[^}]+\}))\s*,\s*(group|name|module|version(?:\.ref)?)\s*=\s*(?:"([^"]+)"|'([^']+)'|(\{[^}]+\}))(?:\s*,\s*(group|name|module|version(?:\.ref)?)\s*=\s*(?:"([^"]+)"|'([^']+)')|(\{[^}]+\}))?\s*\}|(?:"([^:]+:[^"]+)"|'([^:]+:[^']+)'))/gd;
16
18
  function isUpgrade(version, pending) {
@@ -154,8 +156,7 @@ function finalize(instance) {
154
156
  if (dependencyScopes && (mavenData = getData())) {
155
157
  const supplement = [];
156
158
  for (const item of items) {
157
- const [gId, id] = item;
158
- const target = mavenData[gId]?.find(group => id === group.artifactId);
159
+ const target = mavenData[item[0]]?.find(group => group.artifactId === item[1]);
159
160
  if (target) {
160
161
  if (target.dependencies) {
161
162
  let found = false;
@@ -214,8 +215,7 @@ function finalize(instance) {
214
215
  }
215
216
  }
216
217
  for (const item of supplement) {
217
- const [groupId, artifactId] = item;
218
- const index = items.findIndex(seg => seg[0] === groupId && seg[1] === artifactId);
218
+ const index = items.findIndex(seg => seg[0] === item[0] && seg[1] === item[1]);
219
219
  if (index === -1) {
220
220
  items.push(item);
221
221
  }
@@ -243,7 +243,20 @@ function finalize(instance) {
243
243
  const newLine = getNewline(source);
244
244
  const gradleDir = path.join(this.baseDirectory, 'gradle');
245
245
  const template = instance.findTemplate(gradleDir, "libs.versions.toml", { detect: true, subDir: language, throwsDoesNotExist: false });
246
+ const removeGroup = (id) => {
247
+ for (let i = 0; i < items.length; ++i) {
248
+ if (items[i][0] === id) {
249
+ items.splice(i--, 1);
250
+ }
251
+ }
252
+ };
246
253
  let content = match[1], named = false, versioning = false, indent;
254
+ for (const platform of content.matchAll(kotlin ? REGEXP_PLATFORM_KOTLIN : REGEXP_PLATFORM)) {
255
+ const [group, name] = trimQuote(platform[1]).trim().split(':');
256
+ if (name.endsWith('-bom')) {
257
+ removeGroup(group);
258
+ }
259
+ }
247
260
  if (template.source && template.localUri && instance.canWrite(template.localUri, { ownPermissionOnly: true })) {
248
261
  versioning = kotlin && versionCatalog !== false || !!versionCatalog;
249
262
  if (versioning || template.existing) {
@@ -276,6 +289,10 @@ function finalize(instance) {
276
289
  [group, name] = lib.module.split(':');
277
290
  }
278
291
  if (group && name) {
292
+ if (name.endsWith('-bom')) {
293
+ removeGroup(group);
294
+ continue;
295
+ }
279
296
  const index = items.findIndex(seg => seg[0] === group && seg[1] === name);
280
297
  if (index !== -1) {
281
298
  const item = items[index];
@@ -320,7 +337,7 @@ function finalize(instance) {
320
337
  }
321
338
  }
322
339
  if (versions[versionRef = toCamelCase(name)]) {
323
- const prefix = group.split('.').filter(seg => seg !== name).pop();
340
+ const prefix = group.split('.').filter(seg => seg !== name).at(-1);
324
341
  if (prefix) {
325
342
  versionRef = toCamelCase(prefix + '-' + name);
326
343
  }
@@ -448,8 +465,8 @@ function finalize(instance) {
448
465
  break;
449
466
  }
450
467
  case 'fileTree': {
451
- const dir = /"dir"\s+to\s+"(.+?)"(?:\s*,|$)/.exec(match[5])?.[1];
452
- const include = /"include"\s+to\s+listOf\((.+?)\)(?:\s*,|$)/.exec(match[5])?.[1];
468
+ const dir = (kotlin ? /"dir"\s+to\s+"(.+)"(?:\s*,|$)/ : /\bdir\s*:\s*["'](.+)["'](?:\s*,|$)/).exec(match[5])?.[1];
469
+ const include = (kotlin ? /"include"\s+to\s+listOf\(([^)]+)\)(?:\s*,|$)/ : /\binclude\s*:\s*\[(.+)\](?:\s*,|$)/).exec(match[5])?.[1];
453
470
  if (dir && include) {
454
471
  const compare = (from, orig) => {
455
472
  try {
package/package.json CHANGED
@@ -1,12 +1,9 @@
1
1
  {
2
2
  "name": "@pi-r/android",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "Android document constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
- "publishConfig": {
8
- "access": "public"
9
- },
10
7
  "repository": {
11
8
  "type": "git",
12
9
  "url": "git+https://github.com/anpham6/pi-r.git",
@@ -20,8 +17,8 @@
20
17
  "license": "MIT",
21
18
  "homepage": "https://github.com/anpham6/pi-r#readme",
22
19
  "dependencies": {
23
- "@e-mc/document": "^0.14.0",
24
- "@e-mc/types": "^0.14.0",
20
+ "@e-mc/document": "^0.14.3",
21
+ "@e-mc/types": "^0.14.3",
25
22
  "dom-serializer": "^2.0.0",
26
23
  "domhandler": "^5.0.3",
27
24
  "domutils": "^3.2.2",
@@ -1,5 +1,5 @@
1
1
  distributionBase=GRADLE_USER_HOME
2
2
  distributionPath=wrapper/dists
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
@@ -1,4 +1,4 @@
1
1
  plugins {
2
- id 'com.android.application' version '9.2.0' apply false
3
- id 'com.android.library' version '9.2.0' apply false
2
+ id 'com.android.application' version '9.2.1' apply false
3
+ id 'com.android.library' version '9.2.1' apply false
4
4
  }
@@ -1,7 +1,7 @@
1
1
  [versions]
2
- agp = "9.2.0"
3
- coreKtx = "1.18.0"
4
- kotlin = "2.3.21"
2
+ agp = "9.2.1"
3
+ coreKtx = "1.19.0"
4
+ kotlin = "2.4.0"
5
5
  junit = "4.13.2"
6
6
  junitVersion = "1.3.0"
7
7
  espressoCore = "3.7.0"
@@ -1,12 +1,12 @@
1
1
  [versions]
2
- agp = "9.2.0"
3
- coreKtx = "1.18.0"
4
- kotlin = "2.3.21"
2
+ agp = "9.2.1"
3
+ coreKtx = "1.19.0"
4
+ kotlin = "2.4.0"
5
5
  junit = "4.13.2"
6
6
  junitVersion = "1.3.0"
7
7
  espressoCore = "3.7.0"
8
8
  appcompat = "1.7.1"
9
- material = "1.13.0"
9
+ material = "1.14.0"
10
10
  constraintlayout = "2.2.1"
11
11
 
12
12
  [libraries]