@pi-r/android 0.5.0 → 0.6.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.
@@ -64,85 +64,79 @@ function finalize(instance) {
64
64
  }
65
65
  return [groupId, artifactId, version || (snapshot ? 'latest.integration' : 'latest.release'), type];
66
66
  });
67
- if (dependencyScopes) {
68
- const maven = getData();
69
- if (maven) {
70
- const supplement = [];
71
- for (const item of items) {
72
- const group = maven[item[0]];
73
- if (group) {
74
- const id = item[1];
75
- for (const target of group) {
76
- if (id === target.artifactId) {
77
- if (target.dependencies) {
78
- let found;
79
- for (const { groupId, artifactId, version, scope } of target.dependencies) {
80
- if (scope && (dependencyScopes === true || hasScope(scope))) {
81
- let type = -1;
82
- switch (scope) {
83
- case 'compile':
84
- type = 0 /* DEPENDENCY_TYPE.IMPLEMENTATION */;
85
- break;
86
- case 'provided':
87
- type = 2 /* DEPENDENCY_TYPE.COMPILE_ONLY */;
88
- break;
89
- case 'runtime':
90
- type = 3 /* DEPENDENCY_TYPE.RUNTIME_ONLY */;
91
- break;
92
- case 'test':
93
- type = 4 /* DEPENDENCY_TYPE.TEST_IMPLEMENTATION */;
94
- break;
95
- }
96
- if (type !== -1) {
97
- const current = supplement.find(seg => seg[0] === groupId && seg[1] === artifactId);
98
- if (current) {
99
- const t = parseInt(current[3]);
100
- if (t !== type) {
101
- const rangeVer = REGEXP_SEMVER.test(version);
102
- if (!REGEXP_SEMVER.test(current[2])) {
103
- if (rangeVer || type < t) {
104
- current[2] = version;
105
- found = true;
106
- }
107
- }
108
- else if (rangeVer && type < t) {
109
- current[2] = version;
110
- found = true;
111
- }
112
- current[3] = '0';
113
- }
114
- else if (isUpgrade(current[2], version)) {
115
- current[2] = version;
116
- found = true;
117
- }
118
- }
119
- else {
120
- supplement.push([groupId, artifactId, version, type.toString()]);
121
- found = true;
122
- }
67
+ if (dependencyScopes && (data = getData())) {
68
+ const supplement = [];
69
+ for (const item of items) {
70
+ const [gId, id] = item;
71
+ const target = data[gId]?.find(group => id === group.artifactId);
72
+ if (!target) {
73
+ continue;
74
+ }
75
+ if (target.dependencies) {
76
+ let found;
77
+ for (const { groupId, artifactId, version, scope } of target.dependencies) {
78
+ if (scope && (dependencyScopes === true || hasScope(scope))) {
79
+ let type = -1;
80
+ switch (scope) {
81
+ case 'compile':
82
+ type = 0 /* DEPENDENCY_TYPE.IMPLEMENTATION */;
83
+ break;
84
+ case 'provided':
85
+ type = 2 /* DEPENDENCY_TYPE.COMPILE_ONLY */;
86
+ break;
87
+ case 'runtime':
88
+ type = 4 /* DEPENDENCY_TYPE.RUNTIME_ONLY */;
89
+ break;
90
+ case 'test':
91
+ type = 5 /* DEPENDENCY_TYPE.TEST_IMPLEMENTATION */;
92
+ break;
93
+ }
94
+ if (type !== -1) {
95
+ const current = supplement.find(seg => seg[0] === groupId && seg[1] === artifactId);
96
+ if (current) {
97
+ const t = parseInt(current[3]);
98
+ if (t !== type) {
99
+ const rangeVer = REGEXP_SEMVER.test(version);
100
+ if (!REGEXP_SEMVER.test(current[2])) {
101
+ if (rangeVer || type < t) {
102
+ current[2] = version;
103
+ found = true;
123
104
  }
124
105
  }
106
+ else if (rangeVer && type < t) {
107
+ current[2] = version;
108
+ found = true;
109
+ }
110
+ current[3] = '0';
125
111
  }
126
- if (found && (snapshot || isUpgrade(item[2], target.version))) {
127
- item[2] = target.version;
112
+ else if (isUpgrade(current[2], version)) {
113
+ current[2] = version;
114
+ found = true;
128
115
  }
129
116
  }
130
- break;
117
+ else {
118
+ supplement.push([groupId, artifactId, version, type.toString()]);
119
+ found = true;
120
+ }
131
121
  }
132
122
  }
133
123
  }
134
- }
135
- for (const item of supplement) {
136
- const [groupId, artifactId] = item;
137
- const index = items.findIndex(seg => seg[0] === groupId && seg[1] === artifactId);
138
- if (index === -1) {
139
- items.push(item);
140
- }
141
- else if (snapshot) {
142
- item[3] = items[index][3];
143
- items[index] = item;
124
+ if (found && (snapshot || isUpgrade(item[2], target.version))) {
125
+ item[2] = target.version;
144
126
  }
145
127
  }
128
+ break;
129
+ }
130
+ for (const item of supplement) {
131
+ const [groupId, artifactId] = item;
132
+ const index = items.findIndex(seg => seg[0] === groupId && seg[1] === artifactId);
133
+ if (index === -1) {
134
+ items.push(item);
135
+ }
136
+ else if (snapshot) {
137
+ item[3] = items[index][3];
138
+ items[index] = item;
139
+ }
146
140
  }
147
141
  }
148
142
  items.sort((a, b) => {
@@ -161,9 +155,9 @@ function finalize(instance) {
161
155
  if (!kotlin && items.some(seg => seg[1].endsWith('-ktx'))) {
162
156
  setModified(Document.updateGradle(source, ['plugins'], "id 'kotlin-android'", { multiple: true }));
163
157
  }
164
- const match = /dependencies\s+\{((?:{[^}]*}|(?![{}])[\S\s])+)\}/.exec(source);
158
+ const match = /dependencies\s+\{((?:{[^{]*{|{[^}]*}|}[^}]*}|\\}*?|[^{}+])+)\}/.exec(source);
165
159
  if (match) {
166
- const pattern = kotlin ? /([ \t]*)(implementation|api|compileOnly|runtimeOnly|(?:test|androidTest)Implementation)\((?:\s*(?:"([^"]+)"|((?:\s*(?:group|name|version)\s*=\s*"[^"]+"\s*,?){3}))\s*\))?/g : /([ \t]*)(implementation|api|compileOnly|runtimeOnly|(?:test|androidTest)Implementation)(?:\s*\(?\s*["']([^"']+)["']\s*\)?|\s+((?:\s*(?:group|name|version)\s*:\s*["'][^"']+["']\s*,?){3}))?/g;
160
+ const pattern = kotlin ? /([ \t]*)(implementation|api|compileOnly(?:Api)?|runtimeOnly|(?:test|androidTest)(?:Implementation|RuntimeOnly|CompileOnly))\((?:\s*(?:"([^"]+)"|((?:\s*(?:group|name|version)\s*=\s*"[^"]+"\s*,?){3}))\s*\))?/g : /([ \t]*)(implementation|api|compileOnly(?:Api)?|runtimeOnly|(?:test|androidTest)(?:Implementation|RuntimeOnly|CompileOnly))(?:\s*\(?\s*["']([^"']+)["']\s*\)?|\s+((?:\s*(?:group|name|version)\s*:\s*["'][^"']+["']\s*,?){3}))?/g;
167
161
  let content = match[1], named = false, indent, method;
168
162
  const writeMethod = (item, args, prefix = 'implementation') => {
169
163
  switch (parseInt(item[3])) {
@@ -176,15 +170,30 @@ function finalize(instance) {
176
170
  case 2 /* DEPENDENCY_TYPE.COMPILE_ONLY */:
177
171
  prefix = 'compileOnly';
178
172
  break;
179
- case 3 /* DEPENDENCY_TYPE.RUNTIME_ONLY */:
173
+ case 3 /* DEPENDENCY_TYPE.COMPILE_ONLY_API */:
174
+ prefix = 'compileOnlyApi';
175
+ break;
176
+ case 4 /* DEPENDENCY_TYPE.RUNTIME_ONLY */:
180
177
  prefix = 'runtimeOnly';
181
178
  break;
182
- case 4 /* DEPENDENCY_TYPE.TEST_IMPLEMENTATION */:
179
+ case 5 /* DEPENDENCY_TYPE.TEST_IMPLEMENTATION */:
183
180
  prefix = 'testImplementation';
184
181
  break;
185
- case 5 /* DEPENDENCY_TYPE.ANDROID_TEST_IMPLEMENTATION */:
182
+ case 6 /* DEPENDENCY_TYPE.TEST_COMPILE_ONLY */:
183
+ prefix = 'testCompileOnly';
184
+ break;
185
+ case 7 /* DEPENDENCY_TYPE.TEST_RUNTIME_ONLY */:
186
+ prefix = 'testRuntimeOnly';
187
+ break;
188
+ case 8 /* DEPENDENCY_TYPE.ANDROID_TEST_IMPLEMENTATION */:
186
189
  prefix = 'androidTestImplementation';
187
190
  break;
191
+ case 9 /* DEPENDENCY_TYPE.ANDROID_TEST_COMPILE_ONLY */:
192
+ prefix = 'androidTestCompileOnly';
193
+ break;
194
+ case 10 /* DEPENDENCY_TYPE.ANDROID_TEST_RUNTIME_ONLY */:
195
+ prefix = 'androidTestRuntimeOnly';
196
+ break;
188
197
  }
189
198
  let dependency;
190
199
  if (args || named) {
@@ -224,7 +233,7 @@ function finalize(instance) {
224
233
  if (group && name) {
225
234
  let found = 0, index = -1;
226
235
  if (version && (index = items.findIndex(seg => seg[0] === group && seg[1] === name)) !== -1) {
227
- found = (version[0] !== '$' || !kotlin && method[0].indexOf("'") !== -1) && isUpgrade(version, items[index][2]) ? 2 : 1;
236
+ found = (!version.startsWith('$') || !kotlin && method[0].includes("'")) && isUpgrade(version, items[index][2]) ? 2 : 1;
228
237
  }
229
238
  if (found) {
230
239
  if (found === 2) {
@@ -257,7 +266,7 @@ function finalize(instance) {
257
266
  else {
258
267
  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.21" /* VERSIONS.KOTLIN_STDLIB */)}'` });
259
268
  output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
260
- output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.6" /* VERSIONS.KOTLIN_COMPILER */)}'`, true);
269
+ output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.7" /* VERSIONS.KOTLIN_COMPILER */)}'`, true);
261
270
  if (upgrade) {
262
271
  output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
263
272
  }
@@ -31,7 +31,7 @@ async function finalize(instance) {
31
31
  const exec = settings.exec;
32
32
  let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title, filename, altname, foundDir;
33
33
  if (command) {
34
- if (command.indexOf('mvn') !== -1) {
34
+ if (command.includes('mvn')) {
35
35
  title = "maven" /* STRINGS.MAVEN */;
36
36
  }
37
37
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/android",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
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.7.0",
24
- "@e-mc/types": "^0.7.0",
23
+ "@e-mc/document": "^0.8.0",
24
+ "@e-mc/types": "^0.8.0",
25
25
  "htmlparser2": "^9.0.0",
26
26
  "which": "^2.0.2"
27
27
  }