@pi-r/android 0.3.2 → 0.5.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.
@@ -142,27 +142,26 @@ function finalize(instance) {
142
142
  return;
143
143
  }
144
144
  const app = domutils.findOne(elem => elem.tagName === 'application', dom, true);
145
- if (!app) {
146
- return;
147
- }
148
- for (const { name, resource, value } of metaData) {
149
- if (name && (resource || value)) {
150
- let item = domutils.findOne(elem => elem.tagName === 'meta-data' && elem.attribs['android:name'] === name, app.childNodes);
151
- if (!item) {
152
- domutils.appendChild(app, item = new domhandler.Element('meta-data', { 'android:name': name }));
153
- domutils.append(item, new domhandler.Text('\n'));
154
- }
155
- else if (item.attribs['android:resource'] === resource || item.attribs['android:value'] === value) {
156
- continue;
157
- }
158
- if (resource) {
159
- item.attribs['android:resource'] = resource;
160
- }
161
- if (value) {
162
- item.attribs['android:value'] = value;
145
+ if (app) {
146
+ for (const { name, resource, value } of metaData) {
147
+ if (name && (resource || value)) {
148
+ let item = domutils.findOne(elem => elem.tagName === 'meta-data' && elem.attribs['android:name'] === name, app.childNodes);
149
+ if (!item) {
150
+ domutils.appendChild(app, item = new domhandler.Element('meta-data', { 'android:name': name }));
151
+ domutils.append(item, new domhandler.Text('\n'));
152
+ }
153
+ else if (item.attribs['android:resource'] === resource || item.attribs['android:value'] === value) {
154
+ continue;
155
+ }
156
+ if (resource) {
157
+ item.attribs['android:resource'] = resource;
158
+ }
159
+ if (value) {
160
+ item.attribs['android:value'] = value;
161
+ }
162
+ source = domserializer.default(dom, { xmlMode: true });
163
+ modified = true;
163
164
  }
164
- source = domserializer.default(dom, { xmlMode: true });
165
- modified = true;
166
165
  }
167
166
  }
168
167
  }), { xmlMode: true, decodeEntities: false }).end(source);
@@ -4,6 +4,30 @@ const path = require("path");
4
4
  const util_1 = require("@e-mc/document/util");
5
5
  const types_1 = require("@e-mc/types");
6
6
  const Document = require("@e-mc/document");
7
+ const REGEXP_SEMVER = /^((\s*,\s*)?[([\]]((\s*,\s*)?\d+\.\d+(\s*,\s*)?)+[)\][])+$/;
8
+ function isUpgrade(version, pending) {
9
+ if (REGEXP_SEMVER.test(pending)) {
10
+ return true;
11
+ }
12
+ if (!REGEXP_SEMVER.test(version)) {
13
+ const previous = version.split(/[.-]/);
14
+ const current = pending.split(/[.-]/);
15
+ for (let i = 0; i < previous.length; ++i) {
16
+ const a = parseInt(previous[i]);
17
+ const b = parseInt(current[i]);
18
+ if (isNaN(a) && isNaN(b)) {
19
+ continue;
20
+ }
21
+ if (isNaN(a) || b > a) {
22
+ return true;
23
+ }
24
+ if (isNaN(b) || b < a) {
25
+ break;
26
+ }
27
+ }
28
+ }
29
+ return false;
30
+ }
7
31
  function finalize(instance) {
8
32
  const config = instance.config;
9
33
  const { profileable, dependencies, dataBinding, versionName, versionCode } = config;
@@ -13,7 +37,7 @@ function finalize(instance) {
13
37
  const detect = this.incremental !== 'staging';
14
38
  let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir), "build.gradle", { detect, languageOf: 'gradle' });
15
39
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
16
- let { namespace, javaVersion } = config, jvmTarget, modified;
40
+ let { namespace, javaVersion, dependencyScopes } = config, jvmTarget, modified;
17
41
  const upgrade = javaVersion > 0;
18
42
  const setModified = (output) => {
19
43
  if (output !== source) {
@@ -22,24 +46,181 @@ function finalize(instance) {
22
46
  }
23
47
  };
24
48
  if (dependencies) {
25
- const items = dependencies.map(item => item.split(':'));
26
- if (!kotlin && items.some(value => value[1].endsWith('-ktx'))) {
49
+ let data;
50
+ const hasScope = (value) => (0, types_1.isArray)(dependencyScopes) && dependencyScopes.includes(value) || dependencyScopes === value;
51
+ const snapshot = hasScope('snapshot');
52
+ const getData = () => data || (data = instance.findData('google-maven' + (snapshot ? '-snapshot' : '') + '.json', 'json'));
53
+ const items = dependencies.map(item => {
54
+ let [groupId, artifactId, version, type] = item.split(':');
55
+ if (!version || version === 'maven') {
56
+ const maven = getData();
57
+ let artifact;
58
+ if (maven && (artifact = maven[groupId]?.find(child => child.artifactId === artifactId))) {
59
+ version = artifact.version;
60
+ }
61
+ else {
62
+ version = '';
63
+ }
64
+ }
65
+ return [groupId, artifactId, version || (snapshot ? 'latest.integration' : 'latest.release'), type];
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;
85
+ break;
86
+ case 'provided':
87
+ type = 2;
88
+ break;
89
+ case 'runtime':
90
+ type = 4;
91
+ break;
92
+ case 'test':
93
+ type = 5;
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
+ }
123
+ }
124
+ }
125
+ }
126
+ if (found && (snapshot || isUpgrade(item[2], target.version))) {
127
+ item[2] = target.version;
128
+ }
129
+ }
130
+ break;
131
+ }
132
+ }
133
+ }
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;
144
+ }
145
+ }
146
+ }
147
+ }
148
+ items.sort((a, b) => {
149
+ const tA = parseInt(a[3]) || 0;
150
+ const tB = parseInt(b[3]) || 0;
151
+ if (tA !== tB) {
152
+ return tA - tB;
153
+ }
154
+ const gA = a[0];
155
+ const gB = b[0];
156
+ if (gA !== gB) {
157
+ return gA < gB ? -1 : 1;
158
+ }
159
+ return a[1] < b[1] ? -1 : 1;
160
+ });
161
+ if (!kotlin && items.some(seg => seg[1].endsWith('-ktx'))) {
27
162
  setModified(Document.updateGradle(source, ['plugins'], "id 'kotlin-android'", { multiple: true }));
28
163
  }
29
- const match = /dependencies\s+\{([^}]+)\}/.exec(source);
164
+ const match = /dependencies\s+\{((?:{[^{]*{|{[^}]*}|}[^}]*}|\\}*?|[^{}+])+)\}/.exec(source);
30
165
  if (match) {
31
- const writeImpl = (item) => 'implementation' + (kotlin ? `("${item.join(':')}")` : ` '${item.join(':')}'`);
32
- const pattern = kotlin ? /([ \t]*)implementation\((?:\s*"([^"]+)"\s*\))?/g : /([ \t]*)implementation(?:\s*\(?\s*["']([^"']+)["']\s*\)?|\s+((?:\s*(?:group|name|version)\s*:\s*["'][^"']+["']\s*,?){3}))?/g;
33
- let content = match[1], indent, impl;
34
- while (impl = pattern.exec(match[1])) {
166
+ 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
+ let content = match[1], named = false, indent, method;
168
+ const writeMethod = (item, args, prefix = 'implementation') => {
169
+ switch (parseInt(item[3])) {
170
+ case 0:
171
+ prefix = 'implementation';
172
+ break;
173
+ case 1:
174
+ prefix = 'api';
175
+ break;
176
+ case 2:
177
+ prefix = 'compileOnly';
178
+ break;
179
+ case 3:
180
+ prefix = 'compileOnlyApi';
181
+ break;
182
+ case 4:
183
+ prefix = 'runtimeOnly';
184
+ break;
185
+ case 5:
186
+ prefix = 'testImplementation';
187
+ break;
188
+ case 6:
189
+ prefix = 'testCompileOnly';
190
+ break;
191
+ case 7:
192
+ prefix = 'testRuntimeOnly';
193
+ break;
194
+ case 8:
195
+ prefix = 'androidTestImplementation';
196
+ break;
197
+ case 9:
198
+ prefix = 'androidTestCompileOnly';
199
+ break;
200
+ case 10:
201
+ prefix = 'androidTestRuntimeOnly';
202
+ break;
203
+ }
204
+ let dependency;
205
+ if (args || named) {
206
+ const [group, name, version] = item;
207
+ dependency = kotlin ? `(group = "${group}", name = "${name}", version = "${version}")` : ` group: '${group}', name: '${name}', version: '${version}'` + (args?.endsWith(',') ? ',' : '');
208
+ }
209
+ else {
210
+ dependency = item.slice(0, 3).join(':');
211
+ dependency = kotlin ? `("${dependency}")` : ` '${dependency}'`;
212
+ }
213
+ return prefix + dependency;
214
+ };
215
+ while (method = pattern.exec(match[1])) {
35
216
  let group, name, version;
36
- if (impl[2]) {
37
- [group, name, version] = impl[2].trim().split(/\s*:\s*/);
217
+ if (method[3]) {
218
+ [group, name, version] = method[3].trim().split(/\s*:\s*/);
38
219
  }
39
- else if (impl[3]) {
40
- const method = /(group|name|version)\s*:\s*["']([^"']+)["']/g;
220
+ else if (method[4]) {
221
+ const params = /(group|name|version)\s*[=:]\s*["']([^"']+)["']/g;
41
222
  let param;
42
- while (param = method.exec(impl[3])) {
223
+ while (param = params.exec(method[4])) {
43
224
  const value = param[2].trim();
44
225
  switch (param[1]) {
45
226
  case 'group':
@@ -53,53 +234,45 @@ function finalize(instance) {
53
234
  break;
54
235
  }
55
236
  }
237
+ named = true;
56
238
  }
57
239
  if (group && name) {
58
240
  let found = 0, index = -1;
59
241
  if (version && (index = items.findIndex(seg => seg[0] === group && seg[1] === name)) !== -1) {
60
- found = 1;
61
- if (version[0] !== '$' || !kotlin && impl[0].indexOf("'") !== -1) {
62
- const current = items[index][2].split('.').map(seg => +seg);
63
- const parts = version.split('.');
64
- for (let i = 0, value; i < parts.length; ++i) {
65
- if (isNaN(value = +parts[i]) || +current[i] > value) {
66
- found = 2;
67
- break;
68
- }
69
- }
70
- }
242
+ found = (version[0] !== '$' || !kotlin && method[0].indexOf("'") !== -1) && isUpgrade(version, items[index][2]) ? 2 : 1;
71
243
  }
72
244
  if (found) {
73
245
  if (found === 2) {
74
- content = content.replace(impl[0].trim(), writeImpl(items[index]));
246
+ content = content.replace(method[0].trim(), writeMethod(items[index], method[4], method[2]));
75
247
  modified = true;
76
248
  }
77
249
  items.splice(index, 1);
78
250
  }
79
251
  }
80
- if (impl[1]) {
81
- indent = impl[1];
252
+ if (method[1]) {
253
+ indent = method[1];
82
254
  }
83
255
  }
84
256
  if (items.length) {
257
+ const newline = process.platform === 'win32' ? '\r\n' : '\n';
85
258
  indent || (indent = (0, util_1.getIndent)(source));
86
- content = items.reduce((a, b) => a + indent + writeImpl(b) + '\n', content);
259
+ content = items.reduce((a, b) => a + indent + writeMethod(b) + newline, content);
87
260
  modified = true;
88
261
  }
89
262
  if (modified || !existing) {
90
263
  setModified(source.substring(0, match.index) + `dependencies {${content}}` + source.substring(match.index + match[0].length));
91
264
  }
92
265
  }
93
- if (items.some(value => value[0] === 'androidx.compose.ui')) {
266
+ if (items.some(seg => seg[0] === 'androidx.compose.ui')) {
94
267
  let output = source;
95
268
  if (kotlin) {
96
269
  output = Document.updateGradle(output, ['plugins'], 'kotlin("android")');
97
270
  output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
98
271
  }
99
272
  else {
100
- 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.0")}'` });
273
+ 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")}'` });
101
274
  output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
102
- output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.0")}'`, true);
275
+ output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.9")}'`, true);
103
276
  if (upgrade) {
104
277
  output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
105
278
  }
@@ -8,7 +8,7 @@ function finalize(instance) {
8
8
  if (!dependencies && !projectName) {
9
9
  return;
10
10
  }
11
- let { localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, 'settings.gradle', { detect: this.incremental !== 'staging', languageOf: 'gradle' });
11
+ let { localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "settings.gradle", { detect: this.incremental !== 'staging', languageOf: 'gradle' });
12
12
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
13
13
  let targetName = projectName?.replace(/"/g, '\\"'), modified;
14
14
  if (existing) {
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const path = require("path");
4
4
  const fs = require("fs");
5
5
  const child_process = require("child_process");
6
+ const which = require("which");
6
7
  const types_1 = require("@e-mc/types");
7
8
  const Document = require("@e-mc/document");
9
+ const checkWin32 = (value) => value === "gradlew" && process.platform === 'win32' ? value + '.bat' : value;
8
10
  async function finalize(instance) {
9
11
  const commands = instance.config.commands;
10
12
  if (!commands || this.incremental === 'staging') {
@@ -27,38 +29,44 @@ async function finalize(instance) {
27
29
  }
28
30
  const settings = instance.settings.extensions?.task || {};
29
31
  const exec = settings.exec;
30
- let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title, name, foundCwd;
32
+ let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title, filename, altname, foundDir;
31
33
  if (command) {
32
34
  if (command.indexOf('mvn') !== -1) {
33
- title = 'maven';
35
+ title = "maven";
34
36
  }
35
37
  else {
36
- title = /([^\\/]+?)(?:\.[a-z]+)?$/i.exec(command)?.[1] || 'SPAWN';
38
+ title = /([^\\/]+?)(?:\.[a-z]+)?$/i.exec(command)?.[1] || 'spawn';
37
39
  }
38
- command = path.normalize(command);
39
- if (!command.includes(path.sep)) {
40
- name = command;
40
+ if (!/[\\/]/.test(command = path.normalize(command))) {
41
+ filename = checkWin32(command);
41
42
  }
42
43
  command = Document.sanitizeCmd(command);
43
44
  }
44
45
  else {
45
- name = 'gradlew';
46
- command = '.' + path.sep + name;
47
- title = 'gradle';
46
+ filename = checkWin32("gradlew");
47
+ command = '.' + path.sep + filename;
48
+ title = "gradle";
49
+ altname = "gradle";
48
50
  }
49
- if (name) {
51
+ if (filename) {
50
52
  try {
51
53
  let appDir = baseDirectory;
52
- while (!(foundCwd = fs.existsSync(path.join(appDir, name)))) {
54
+ while (!(foundDir = fs.existsSync(path.join(appDir, filename)))) {
53
55
  const parent = path.dirname(appDir);
54
56
  if (parent === appDir) {
55
57
  break;
56
58
  }
57
59
  appDir = parent;
58
60
  }
59
- if (foundCwd) {
61
+ if (foundDir) {
60
62
  baseDirectory = appDir;
61
63
  }
64
+ else if (altname) {
65
+ const bin = which.sync(altname, { nothrow: true });
66
+ if (bin) {
67
+ command = Document.sanitizeCmd(bin);
68
+ }
69
+ }
62
70
  }
63
71
  catch {
64
72
  }
@@ -89,7 +97,7 @@ async function finalize(instance) {
89
97
  resolve();
90
98
  }
91
99
  else {
92
- reject((0, types_1.errorValue)(message || (!foundCwd && code === 1 ? "Unable to execute file" : "Unknown"), "Error code" + ': ' + code));
100
+ reject((0, types_1.errorValue)(message || (!foundDir && code === 1 ? "Unable to execute file" : "Unknown"), "Error code" + ': ' + code));
93
101
  }
94
102
  })
95
103
  .on('error', err => reject(err));
package/index.js CHANGED
@@ -20,6 +20,7 @@ class AndroidDocument extends Document {
20
20
  namespace: undefined,
21
21
  profileable: undefined,
22
22
  dependencies: undefined,
23
+ dependencyScopes: undefined,
23
24
  commands: undefined
24
25
  };
25
26
  this.elements = [];
@@ -55,7 +56,7 @@ class AndroidDocument extends Document {
55
56
  }
56
57
  init(assets, config) {
57
58
  if (config) {
58
- const { targetAPI, mainParentDir, mainSrcDir, mainActivityFile, javaVersion, projectName, versionName, versionCode = 0, manifest, namespace, profileable, dependencies, dataBinding, commands, directories, elements, extensionData } = config;
59
+ const { targetAPI, mainParentDir, mainSrcDir, mainActivityFile, javaVersion, projectName, versionName, versionCode = 0, manifest, namespace, profileable, dependencies, dependencyScopes, dataBinding, commands, directories, elements, extensionData } = config;
59
60
  const target = this.config;
60
61
  if (projectName) {
61
62
  target.projectName = projectName;
@@ -75,7 +76,7 @@ class AndroidDocument extends Document {
75
76
  if (versionName) {
76
77
  target.versionName = versionName;
77
78
  }
78
- if (manifest) {
79
+ if ((0, types_1.isPlainObject)(manifest)) {
79
80
  target.manifest = manifest;
80
81
  }
81
82
  if (profileable !== undefined) {
@@ -88,7 +89,7 @@ class AndroidDocument extends Document {
88
89
  target.commands = commands;
89
90
  }
90
91
  if (javaVersion) {
91
- target.javaVersion = +(typeof javaVersion === 'string' ? javaVersion.toString().replace(/_/g, '.') : javaVersion);
92
+ target.javaVersion = typeof javaVersion === 'string' ? +javaVersion.replace(/_/g, '.') : javaVersion;
92
93
  }
93
94
  if (dataBinding) {
94
95
  target.dataBinding = true;
@@ -96,6 +97,9 @@ class AndroidDocument extends Document {
96
97
  if ((0, types_1.isArray)(dependencies)) {
97
98
  target.dependencies = dependencies;
98
99
  }
100
+ if (dependencyScopes) {
101
+ target.dependencyScopes = dependencyScopes;
102
+ }
99
103
  if (targetAPI) {
100
104
  this.targetAPI = targetAPI;
101
105
  }
@@ -197,6 +201,18 @@ class AndroidDocument extends Document {
197
201
  }
198
202
  return { kotlin, language };
199
203
  }
204
+ findData(filename, format) {
205
+ let localUri;
206
+ if ((localUri = this.resolveDir('data', filename)) || Document.isPath(localUri = path.join(__dirname, 'data', filename))) {
207
+ try {
208
+ return this.tryParse(fs.readFileSync(localUri, 'utf-8'), format || path.extname(localUri).substring(1));
209
+ }
210
+ catch (err) {
211
+ this.writeFail(["Unable to read file", path.basename(localUri)], err, 32);
212
+ }
213
+ }
214
+ return null;
215
+ }
200
216
  detectKts(...paths) {
201
217
  try {
202
218
  const file = path.join(...paths);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/android",
3
- "version": "0.3.2",
3
+ "version": "0.5.2",
4
4
  "description": "Android document constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -20,8 +20,9 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/pi-r#readme",
22
22
  "dependencies": {
23
- "@e-mc/document": "^0.6.1",
24
- "@e-mc/types": "^0.6.1",
25
- "htmlparser2": "^9.0.0"
23
+ "@e-mc/document": "^0.7.2",
24
+ "@e-mc/types": "^0.7.2",
25
+ "htmlparser2": "^9.0.0",
26
+ "which": "^2.0.2"
26
27
  }
27
28
  }
@@ -1,4 +1,4 @@
1
1
  plugins {
2
- id 'com.android.application' version '8.1.0' apply false
3
- id 'com.android.library' version '8.1.0' apply false
2
+ id 'com.android.application' version '8.2.0' apply false
3
+ id 'com.android.library' version '8.2.0' apply false
4
4
  }
@@ -37,7 +37,7 @@ android {
37
37
  }
38
38
 
39
39
  dependencies {
40
- implementation 'androidx.core:core-ktx:1.10.1'
40
+ implementation 'androidx.core:core-ktx:1.12.0'
41
41
  testImplementation 'junit:junit:4.13.2'
42
42
  androidTestImplementation 'androidx.test.ext:junit:1.1.5'
43
43
  androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
@@ -1,5 +1,5 @@
1
1
  plugins {
2
- id 'com.android.application' version '8.1.0' apply false
3
- id 'com.android.library' version '8.1.0' apply false
4
- id 'org.jetbrains.kotlin.android' version '1.9.0' apply false
2
+ id 'com.android.application' version '8.2.0' apply false
3
+ id 'com.android.library' version '8.2.0' apply false
4
+ id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
5
5
  }
@@ -38,8 +38,8 @@ java {
38
38
  }
39
39
 
40
40
  dependencies {
41
- implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.0")
42
- implementation("androidx.core:core-ktx:1.10.1")
41
+ implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.22")
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")
45
45
  androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
@@ -1,5 +1,5 @@
1
1
  plugins {
2
- id("com.android.application") version "8.1.0" apply false
3
- id("com.android.library") version "8.1.0" apply false
4
- id("org.jetbrains.kotlin.android") version "1.9.0" apply false
2
+ id("com.android.application") version "8.2.0" apply false
3
+ id("com.android.library") version "8.2.0" apply false
4
+ id("org.jetbrains.kotlin.android") version "1.9.22" apply false
5
5
  }
package/types/index.d.ts CHANGED
@@ -2,15 +2,15 @@ import type { FinalizedElement } from '@e-mc/types/lib/squared';
2
2
 
3
3
  import type { DocumentConstructor, IDocument, IFileManager } from '@e-mc/types/lib';
4
4
  import type { ExternalAsset } from '@e-mc/types/lib/asset';
5
- import type { DocumentDirectory as IDocumentDirectory, DocumentModule as IDocumentModule, ExecAction } from '@e-mc/types/lib/settings';
5
+ import type { DocumentModule as IDocumentModule, DocumentSettings as IDocumentSettings, ExecAction } from '@e-mc/types/lib/settings';
6
6
 
7
- import type { DocumentOutput } from './squared';
7
+ import type { DocumentOutput, MavenScopes } from './squared';
8
8
 
9
9
  interface DocumentDirectory extends IDocumentDirectory {
10
10
  template?: string;
11
11
  }
12
12
 
13
- interface AndroidDocumentSettings extends PlainObject {
13
+ interface AndroidDocumentSettings extends Pick<IDocumentSettings, "users" | "directory">, PlainObject {
14
14
  extensions?: {
15
15
  task?: {
16
16
  exec?: ExecAction;
@@ -20,7 +20,6 @@ interface AndroidDocumentSettings extends PlainObject {
20
20
  language?: {
21
21
  gradle?: "java" | "kotlin" | "java+kotlin";
22
22
  };
23
- directory?: DocumentDirectory;
24
23
  }
25
24
 
26
25
  type LanguageType = "gradle";
@@ -52,11 +51,20 @@ export interface FindTemplateOptions {
52
51
  subDir?: ArrayOf<string>;
53
52
  }
54
53
 
54
+ export interface MavenArtifact {
55
+ groupId: string;
56
+ artifactId: string;
57
+ version: string;
58
+ scope?: MavenScopes;
59
+ dependencies?: MavenArtifact[];
60
+ }
61
+
55
62
  export interface IAndroidDocument<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends IDocument<T, U>, Pick<DocumentOutput, DocumentProperties> {
56
63
  config: UserConfig;
57
64
  elements: FinalizedElement[];
58
65
  extensionData: PlainObject;
59
66
  findTemplate(baseDir: string, filename: string, options?: FindTemplateOptions): TemplateData;
67
+ findData<V = AnyObject>(filename: string, format?: string): Null<V>;
60
68
  detectKts(...paths: string[]): Null<boolean>;
61
69
  get settings(): AndroidDocumentSettings;
62
70
  }
@@ -9,6 +9,7 @@ export interface DocumentOutput {
9
9
  namespace?: string;
10
10
  profileable?: boolean | StringOfArray;
11
11
  dependencies?: string[];
12
+ dependencyScopes?: boolean | ArrayOf<DependencyScopes | "snapshot">;
12
13
  directories?: ControllerSettingsDirectoryUI;
13
14
  elements?: FinalizedElement[];
14
15
  projectName?: string;
@@ -50,4 +51,6 @@ export interface ControllerSettingsDirectoryUI extends IControllerSettingsDirect
50
51
  main: string;
51
52
  animation: string;
52
53
  theme: string;
53
- }
54
+ }
55
+
56
+ export type DependencyScopes = "compile" | "provided" | "runtime" | "test";