@pi-r/android 0.11.2 → 0.11.4
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.
|
@@ -4,13 +4,13 @@ const fs = require("node:fs");
|
|
|
4
4
|
const Document = require("@e-mc/document");
|
|
5
5
|
const types_1 = require("@e-mc/types");
|
|
6
6
|
const util_1 = require("@e-mc/document/util");
|
|
7
|
-
const REGEXP_SEMVER = /^((
|
|
7
|
+
const REGEXP_SEMVER = /^(?:(?:\s*,\s*)?(?:[([\]](?:(?:\s*,\s*)?\d+\.\d+(?:\s*,\s*)?)+[)[\]]|!!\d+\.\d+\.\d+|\d+\.\d+\.\d+!!))+$/;
|
|
8
8
|
const REGEXP_DEPENDENCIES = /dependencies\s+\{((?:{[^{]*{|{[^}]*}|}[^}]*}|\\}*?|[^{}+])+)\}/;
|
|
9
9
|
const REGEXP_DEPENDENCY = /([ \t]*)([A-Za-z_$][\w$]*)(?:\s*\(?\s*(?:module\(?\s*)?["']([^"']+)["']\s*\)?|\s+((?:\s*(?:group|name|version)\s*:\s*(?:"(?:[^"]|(?<=\\)")+"|'(?:[^']|(?<=\\)')+')\s*,?){3}))?/gd;
|
|
10
10
|
const REGEXP_DEPENDENCY_KOTLIN = /([ \t]*)([A-Za-z_$][\w$]*)\((?:\s*(?:(?:module\(\s*)?"([^"]+)"|((?:\s*(?:group|name|version)\s*=\s*"(?:[^"]|(?<=\\)")+"\s*,?){3}))\s*\))?/gd;
|
|
11
11
|
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;
|
|
12
12
|
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;
|
|
13
|
-
const REGEXP_VERSIONS = /([^\s]+)\s*=\s*(?:"([^"]+)"|'([^']+)'
|
|
13
|
+
const REGEXP_VERSIONS = /([^\s]+)\s*=\s*(?:"([^"]+)"|'([^']+)')/g;
|
|
14
14
|
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;
|
|
15
15
|
function isUpgrade(version, pending) {
|
|
16
16
|
if (isSemVer(pending)) {
|
|
@@ -127,7 +127,7 @@ function finalize(instance) {
|
|
|
127
127
|
const hasScope = (value) => (0, types_1.isArray)(dependencyScopes) && dependencyScopes.includes(value) || dependencyScopes === value;
|
|
128
128
|
const snapshot = dependencyScopes === 1 || hasScope('snapshot');
|
|
129
129
|
const constraints = hasScope('constraints');
|
|
130
|
-
const checkVersion = (item, version, value) =>
|
|
130
|
+
const checkVersion = (item, version, value) => snapshot || constraints && !item[2] || (version.length > 0 && !version.startsWith('$') || !kotlin && !!value?.includes("'")) && isUpgrade(version, item[2]);
|
|
131
131
|
const getData = () => mavenData ||= instance.findData('google-maven' + (snapshot ? '-snapshot' : '') + '.json', 'json');
|
|
132
132
|
const items = dependencies.map(item => {
|
|
133
133
|
let [groupId, artifactId, version, type] = item.split(':');
|
|
@@ -247,7 +247,7 @@ function finalize(instance) {
|
|
|
247
247
|
const versions = {};
|
|
248
248
|
let config = template.source, catalog;
|
|
249
249
|
while (catalog = REGEXP_VERSIONS.exec(config)) {
|
|
250
|
-
versions[catalog[1]] = (catalog[2] || catalog[3]
|
|
250
|
+
versions[catalog[1]] = (catalog[2] || catalog[3]).trim();
|
|
251
251
|
}
|
|
252
252
|
while (catalog = REGEXP_VERSIONS_LIB.exec(config)) {
|
|
253
253
|
const lib = {};
|
|
@@ -280,10 +280,13 @@ function finalize(instance) {
|
|
|
280
280
|
const version = ref ? versions[ref] : lib.version;
|
|
281
281
|
if (version && checkVersion(item, version)) {
|
|
282
282
|
if (ref) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const
|
|
286
|
-
|
|
283
|
+
if (versions[ref] !== item[2]) {
|
|
284
|
+
const target = new RegExp(`\\s${(0, types_1.escapePattern)(ref)}\\s*=\\s*(?:"([^":]+)"|'([^':]+)')`, 'd').exec(config);
|
|
285
|
+
const indices = target?.indices;
|
|
286
|
+
if (indices) {
|
|
287
|
+
const [start, end] = indices[1] || indices[2];
|
|
288
|
+
config = (0, util_1.spliceString)(config, start, end, versions[ref] = item[2], REGEXP_VERSIONS_LIB);
|
|
289
|
+
}
|
|
287
290
|
}
|
|
288
291
|
}
|
|
289
292
|
else if (lib.version_indices) {
|
|
@@ -345,7 +348,7 @@ function finalize(instance) {
|
|
|
345
348
|
config = writeOutput(lib, config, output);
|
|
346
349
|
}
|
|
347
350
|
else {
|
|
348
|
-
config += output;
|
|
351
|
+
config += (config.endsWith(newLine) ? '' : newLine) + output;
|
|
349
352
|
}
|
|
350
353
|
if (outputVer) {
|
|
351
354
|
outputVer = '[versions]' + newLine + outputVer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/android",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4",
|
|
4
4
|
"description": "Android document constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -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.13.
|
|
24
|
-
"@e-mc/types": "^0.13.
|
|
23
|
+
"@e-mc/document": "^0.13.12",
|
|
24
|
+
"@e-mc/types": "^0.13.12",
|
|
25
25
|
"dom-serializer": "^2.0.0",
|
|
26
26
|
"domhandler": "^5.0.3",
|
|
27
27
|
"domutils": "^3.2.2",
|