@pi-r/android 0.3.0 → 0.5.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.
@@ -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" /* GRADLE.FILENAME */, { 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,166 @@ 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 /* 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
+ }
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+\{((?:{[^}]*}|(?![{}])[\S\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|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;
167
+ let content = match[1], named = false, indent, method;
168
+ const writeMethod = (item, args, prefix = 'implementation') => {
169
+ switch (parseInt(item[3])) {
170
+ case 0 /* DEPENDENCY_TYPE.IMPLEMENTATION */:
171
+ prefix = 'implementation';
172
+ break;
173
+ case 1 /* DEPENDENCY_TYPE.API */:
174
+ prefix = 'api';
175
+ break;
176
+ case 2 /* DEPENDENCY_TYPE.COMPILE_ONLY */:
177
+ prefix = 'compileOnly';
178
+ break;
179
+ case 3 /* DEPENDENCY_TYPE.RUNTIME_ONLY */:
180
+ prefix = 'runtimeOnly';
181
+ break;
182
+ case 4 /* DEPENDENCY_TYPE.TEST_IMPLEMENTATION */:
183
+ prefix = 'testImplementation';
184
+ break;
185
+ case 5 /* DEPENDENCY_TYPE.ANDROID_TEST_IMPLEMENTATION */:
186
+ prefix = 'androidTestImplementation';
187
+ break;
188
+ }
189
+ let dependency;
190
+ if (args || named) {
191
+ const [group, name, version] = item;
192
+ dependency = kotlin ? `(group = "${group}", name = "${name}", version = "${version}")` : ` group: '${group}', name: '${name}', version: '${version}'` + (args?.endsWith(',') ? ',' : '');
193
+ }
194
+ else {
195
+ dependency = item.slice(0, 3).join(':');
196
+ dependency = kotlin ? `("${dependency}")` : ` '${dependency}'`;
197
+ }
198
+ return prefix + dependency;
199
+ };
200
+ while (method = pattern.exec(match[1])) {
35
201
  let group, name, version;
36
- if (impl[2]) {
37
- [group, name, version] = impl[2].trim().split(/\s*:\s*/);
202
+ if (method[3]) {
203
+ [group, name, version] = method[3].trim().split(/\s*:\s*/);
38
204
  }
39
- else if (impl[3]) {
40
- const method = /(group|name|version)\s*:\s*["']([^"']+)["']/g;
205
+ else if (method[4]) {
206
+ const params = /(group|name|version)\s*[=:]\s*["']([^"']+)["']/g;
41
207
  let param;
42
- while (param = method.exec(impl[3])) {
208
+ while (param = params.exec(method[4])) {
43
209
  const value = param[2].trim();
44
210
  switch (param[1]) {
45
211
  case 'group':
@@ -53,53 +219,45 @@ function finalize(instance) {
53
219
  break;
54
220
  }
55
221
  }
222
+ named = true;
56
223
  }
57
224
  if (group && name) {
58
225
  let found = 0, index = -1;
59
226
  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
- }
227
+ found = (version[0] !== '$' || !kotlin && method[0].indexOf("'") !== -1) && isUpgrade(version, items[index][2]) ? 2 : 1;
71
228
  }
72
229
  if (found) {
73
230
  if (found === 2) {
74
- content = content.replace(impl[0].trim(), writeImpl(items[index]));
231
+ content = content.replace(method[0].trim(), writeMethod(items[index], method[4], method[2]));
75
232
  modified = true;
76
233
  }
77
234
  items.splice(index, 1);
78
235
  }
79
236
  }
80
- if (impl[1]) {
81
- indent = impl[1];
237
+ if (method[1]) {
238
+ indent = method[1];
82
239
  }
83
240
  }
84
241
  if (items.length) {
242
+ const newline = process.platform === 'win32' ? '\r\n' : '\n';
85
243
  indent || (indent = (0, util_1.getIndent)(source));
86
- content = items.reduce((a, b) => a + indent + writeImpl(b) + '\n', content);
244
+ content = items.reduce((a, b) => a + indent + writeMethod(b) + newline, content);
87
245
  modified = true;
88
246
  }
89
247
  if (modified || !existing) {
90
248
  setModified(source.substring(0, match.index) + `dependencies {${content}}` + source.substring(match.index + match[0].length));
91
249
  }
92
250
  }
93
- if (items.some(value => value[0] === 'androidx.compose.ui')) {
251
+ if (items.some(seg => seg[0] === 'androidx.compose.ui')) {
94
252
  let output = source;
95
253
  if (kotlin) {
96
254
  output = Document.updateGradle(output, ['plugins'], 'kotlin("android")');
97
255
  output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
98
256
  }
99
257
  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" /* VERSIONS.KOTLIN_STDLIB */)}'` });
258
+ 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 */)}'` });
101
259
  output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
102
- output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.0" /* VERSIONS.KOTLIN_COMPILER */)}'`, true);
260
+ output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.6" /* VERSIONS.KOTLIN_COMPILER */)}'`, true);
103
261
  if (upgrade) {
104
262
  output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
105
263
  }
@@ -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" /* GRADLE.FILENAME */, { 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" /* STRINGS.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" /* STRINGS.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" /* STRINGS.GRADLEW */);
47
+ command = '.' + path.sep + filename;
48
+ title = "gradle" /* STRINGS.GRADLE */;
49
+ altname = "gradle" /* STRINGS.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" /* ERR_MESSAGE.EXECUTE_FILE */ : "Unknown" /* ERR_MESSAGE.UNKNOWN */), "Error code" /* ERR_MESSAGE.ERROR_CODE */ + ': ' + code));
100
+ reject((0, types_1.errorValue)(message || (!foundDir && code === 1 ? "Unable to execute file" /* ERR_MESSAGE.EXECUTE_FILE */ : "Unknown" /* ERR_MESSAGE.UNKNOWN */), "Error code" /* ERR_MESSAGE.ERROR_CODE */ + ': ' + code));
93
101
  }
94
102
  })
95
103
  .on('error', err => reject(err));
package/index.js CHANGED
@@ -21,6 +21,7 @@ class AndroidDocument extends Document {
21
21
  namespace: undefined,
22
22
  profileable: undefined,
23
23
  dependencies: undefined,
24
+ dependencyScopes: undefined,
24
25
  commands: undefined
25
26
  };
26
27
  this.elements = [];
@@ -56,7 +57,7 @@ class AndroidDocument extends Document {
56
57
  }
57
58
  init(assets, config) {
58
59
  if (config) {
59
- const { targetAPI, mainParentDir, mainSrcDir, mainActivityFile, javaVersion, projectName, versionName, versionCode = 0, manifest, namespace, profileable, dependencies, dataBinding, commands, directories, elements, extensionData } = config;
60
+ const { targetAPI, mainParentDir, mainSrcDir, mainActivityFile, javaVersion, projectName, versionName, versionCode = 0, manifest, namespace, profileable, dependencies, dependencyScopes, dataBinding, commands, directories, elements, extensionData } = config;
60
61
  const target = this.config;
61
62
  if (projectName) {
62
63
  target.projectName = projectName;
@@ -76,7 +77,7 @@ class AndroidDocument extends Document {
76
77
  if (versionName) {
77
78
  target.versionName = versionName;
78
79
  }
79
- if (manifest) {
80
+ if ((0, types_1.isPlainObject)(manifest)) {
80
81
  target.manifest = manifest;
81
82
  }
82
83
  if (profileable !== undefined) {
@@ -89,7 +90,7 @@ class AndroidDocument extends Document {
89
90
  target.commands = commands;
90
91
  }
91
92
  if (javaVersion) {
92
- target.javaVersion = +(typeof javaVersion === 'string' ? javaVersion.toString().replace(/_/g, '.') : javaVersion);
93
+ target.javaVersion = typeof javaVersion === 'string' ? +javaVersion.replace(/_/g, '.') : javaVersion;
93
94
  }
94
95
  if (dataBinding) {
95
96
  target.dataBinding = true;
@@ -97,6 +98,9 @@ class AndroidDocument extends Document {
97
98
  if ((0, types_1.isArray)(dependencies)) {
98
99
  target.dependencies = dependencies;
99
100
  }
101
+ if (dependencyScopes) {
102
+ target.dependencyScopes = dependencyScopes;
103
+ }
100
104
  if (targetAPI) {
101
105
  this.targetAPI = targetAPI;
102
106
  }
@@ -198,6 +202,18 @@ class AndroidDocument extends Document {
198
202
  }
199
203
  return { kotlin, language };
200
204
  }
205
+ findData(filename, format) {
206
+ let localUri;
207
+ if ((localUri = this.resolveDir('data', filename)) || Document.isPath(localUri = path.join(__dirname, 'data', filename))) {
208
+ try {
209
+ return this.tryParse(fs.readFileSync(localUri, 'utf-8'), format || path.extname(localUri).substring(1));
210
+ }
211
+ catch (err) {
212
+ this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(localUri)], err, 32 /* LOG_TYPE.FILE */);
213
+ }
214
+ }
215
+ return null;
216
+ }
201
217
  detectKts(...paths) {
202
218
  try {
203
219
  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.0",
3
+ "version": "0.5.0",
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.0",
24
- "@e-mc/types": "^0.6.0",
25
- "htmlparser2": "^9.0.0"
23
+ "@e-mc/document": "^0.7.0",
24
+ "@e-mc/types": "^0.7.0",
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.21' 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.21")
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.21" 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";