@pi-r/android 0.6.7 → 0.7.1
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.
- package/README.md +3 -6
- package/data/google-maven-snapshot.json +1 -1
- package/data/google-maven.json +1 -1
- package/extensions/app/manifest/index.js +87 -81
- package/extensions/gradle/dependencies/index.js +24 -24
- package/extensions/gradle/settings/index.js +1 -1
- package/extensions/task/index.js +4 -5
- package/index.js +48 -37
- package/package.json +3 -3
- package/template/java/static/build.gradle +2 -2
- package/template/java+kotlin/build.gradle +1 -1
- package/template/java+kotlin/static/build.gradle +3 -3
- package/template/kotlin/build.gradle.kts +2 -2
- package/template/kotlin/static/build.gradle.kts +3 -3
- package/types/squared.d.ts +7 -6
|
@@ -8,15 +8,16 @@ const util_1 = require("@e-mc/document/util");
|
|
|
8
8
|
const types_1 = require("@e-mc/types");
|
|
9
9
|
const Parser = htmlparser2.Parser;
|
|
10
10
|
const DomHandler = domhandler.DomHandler;
|
|
11
|
+
const MANIFEST_ATTR = ['package', 'android:sharedUserId', 'android:sharedUserLabel', 'android:sharedUserMaxSdkVersion', 'android:versionCode', 'android:versionName', 'android:installLocation'];
|
|
11
12
|
module.exports = function finalize(instance) {
|
|
12
13
|
const config = instance.config;
|
|
13
|
-
|
|
14
|
+
const manifest = config.manifest;
|
|
15
|
+
if (!manifest) {
|
|
14
16
|
return;
|
|
15
17
|
}
|
|
16
18
|
let { localUri, source, existing } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir, config.mainSrcDir), "AndroidManifest.xml", { detect: this.incremental !== 'staging' });
|
|
17
19
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
18
|
-
const {
|
|
19
|
-
const { supportsRtl, label, theme, activity, metaData = [], activityName, fontProvider } = application;
|
|
20
|
+
const { supportsRtl, label, theme, activity, metaData = [], activityName, fontProvider } = manifest.application || {};
|
|
20
21
|
const profileable = config.profileable;
|
|
21
22
|
let modified;
|
|
22
23
|
if (!existing) {
|
|
@@ -37,116 +38,121 @@ module.exports = function finalize(instance) {
|
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
|
-
else if (
|
|
41
|
+
else if (theme || activityName || activity || supportsRtl !== undefined) {
|
|
41
42
|
new Parser(new DomHandler((err, dom) => {
|
|
42
43
|
if (err) {
|
|
43
44
|
instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"], err, 0);
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
|
|
47
|
+
const target = domutils.findOne(elem => elem.tagName === 'application', dom, true);
|
|
48
|
+
if (!target) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (label) {
|
|
52
|
+
target.attribs['android:label'] = '@string/' + label;
|
|
49
53
|
modified = true;
|
|
50
54
|
}
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const attribs = item.attribs;
|
|
73
|
-
attribs['android:name'] = activityName;
|
|
74
|
-
attribs['android:exported'] = 'true';
|
|
75
|
-
modified = true;
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
55
|
+
if (theme) {
|
|
56
|
+
target.attribs['android:theme'] = '@style/' + theme;
|
|
57
|
+
modified = true;
|
|
58
|
+
}
|
|
59
|
+
if (supportsRtl !== undefined) {
|
|
60
|
+
target.attribs['android:supportsRtl'] = supportsRtl.toString();
|
|
61
|
+
modified = true;
|
|
62
|
+
}
|
|
63
|
+
if (activityName || activity) {
|
|
64
|
+
const activities = domutils.getElementsByTagName('activity', target, true);
|
|
65
|
+
if (activityName) {
|
|
66
|
+
for (const item of activities) {
|
|
67
|
+
const intentFilter = domutils.findAll(elem => elem.tagName === 'intent-filter', [item]);
|
|
68
|
+
if (intentFilter.length) {
|
|
69
|
+
const action = domutils.findOne(elem => elem.tagName === 'action' && elem.attribs['android:name'] === 'android.intent.action.MAIN', intentFilter);
|
|
70
|
+
if (action) {
|
|
71
|
+
const attribs = item.attribs;
|
|
72
|
+
attribs['android:name'] = activityName;
|
|
73
|
+
attribs['android:exported'] = 'true';
|
|
74
|
+
modified = true;
|
|
75
|
+
break;
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
78
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
79
|
+
}
|
|
80
|
+
for (const name in activity) {
|
|
81
|
+
const { layout: attribs } = activity[name];
|
|
82
|
+
if (attribs) {
|
|
83
|
+
let element = domutils.findOne(elem => elem.attribs['android:name'] === name, activities);
|
|
84
|
+
if (!element) {
|
|
85
|
+
domutils.appendChild(target, element = new domhandler.Element('activity', { 'android:name': name }));
|
|
86
|
+
domutils.append(element, new domhandler.Text('\n'));
|
|
87
|
+
}
|
|
88
|
+
let layout = domutils.findOne(elem => elem.tagName === 'layout', [element]), found = true;
|
|
89
|
+
if (!layout) {
|
|
90
|
+
domutils.appendChild(element, layout = new domhandler.Element('layout', {}));
|
|
91
|
+
domutils.append(layout, new domhandler.Text('\n'));
|
|
92
|
+
found = false;
|
|
93
|
+
}
|
|
94
|
+
for (const attr in attribs) {
|
|
95
|
+
switch (attr) {
|
|
96
|
+
case 'defaultHeight':
|
|
97
|
+
case 'defaultWidth':
|
|
98
|
+
case 'minHeight':
|
|
99
|
+
case 'minWidth':
|
|
100
|
+
case 'gravity': {
|
|
101
|
+
const value = attribs[attr];
|
|
102
|
+
if (!found || layout.attribs['android:' + attr] !== value) {
|
|
103
|
+
layout.attribs['android:' + attr] = value;
|
|
104
|
+
modified = true;
|
|
110
105
|
}
|
|
106
|
+
break;
|
|
111
107
|
}
|
|
112
108
|
}
|
|
113
109
|
}
|
|
114
110
|
}
|
|
115
111
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
else if (profileable) {
|
|
123
|
-
domutils.appendChild(target, new domhandler.Element('profileable', attribs));
|
|
124
|
-
domutils.appendChild(target, new domhandler.Text('\n'));
|
|
125
|
-
}
|
|
126
|
-
modified = true;
|
|
112
|
+
}
|
|
113
|
+
if (profileable !== undefined) {
|
|
114
|
+
const attribs = profileable ? { 'android:shell': 'true', 'android:enabled': 'true' } : { 'android:enabled': 'false' };
|
|
115
|
+
const element = domutils.findOne(elem => elem.tagName === 'profileable', [target]);
|
|
116
|
+
if (element) {
|
|
117
|
+
Object.assign(element.attribs, attribs);
|
|
127
118
|
}
|
|
128
|
-
if (
|
|
129
|
-
|
|
119
|
+
else if (profileable) {
|
|
120
|
+
domutils.appendChild(target, new domhandler.Element('profileable', attribs));
|
|
121
|
+
domutils.appendChild(target, new domhandler.Text('\n'));
|
|
130
122
|
}
|
|
123
|
+
modified = true;
|
|
124
|
+
}
|
|
125
|
+
if (modified) {
|
|
126
|
+
source = domserializer.default(dom, { xmlMode: true });
|
|
131
127
|
}
|
|
132
128
|
}), { xmlMode: true, decodeEntities: false }).end(source);
|
|
133
129
|
}
|
|
134
130
|
if (fontProvider) {
|
|
135
131
|
metaData.push({ name: 'preloaded_fonts', resource: '@array/' + fontProvider });
|
|
136
132
|
}
|
|
137
|
-
|
|
133
|
+
const keys = Object.keys(manifest).map(attr => MANIFEST_ATTR.includes(attr) ? attr : attr !== 'package' && MANIFEST_ATTR.includes('android:' + attr) ? attr : '').filter(item => item);
|
|
134
|
+
if (keys.length || (0, types_1.isArray)(metaData)) {
|
|
138
135
|
new Parser(new DomHandler((err, dom) => {
|
|
139
136
|
if (err) {
|
|
140
137
|
instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"], err, 0);
|
|
141
138
|
return;
|
|
142
139
|
}
|
|
143
|
-
|
|
144
|
-
if (
|
|
140
|
+
let target = null;
|
|
141
|
+
if (keys.length && (target = domutils.findOne(elem => elem.tagName === 'manifest', dom, true))) {
|
|
142
|
+
for (let key of keys) {
|
|
143
|
+
if (!key.startsWith('android:') && key !== 'package') {
|
|
144
|
+
key = 'android:' + key;
|
|
145
|
+
}
|
|
146
|
+
target.attribs[key] = manifest[key]?.toString() || '';
|
|
147
|
+
modified = true;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if ((0, types_1.isArray)(metaData) && (target = domutils.findOne(elem => elem.tagName === 'application', dom, true))) {
|
|
145
151
|
for (const { name, resource, value } of metaData) {
|
|
146
152
|
if (name && (resource || value)) {
|
|
147
|
-
let item = domutils.findOne(elem => elem.tagName === 'meta-data' && elem.attribs['android:name'] === name,
|
|
153
|
+
let item = domutils.findOne(elem => elem.tagName === 'meta-data' && elem.attribs['android:name'] === name, target.childNodes);
|
|
148
154
|
if (!item) {
|
|
149
|
-
domutils.appendChild(
|
|
155
|
+
domutils.appendChild(target, item = new domhandler.Element('meta-data', { 'android:name': name }));
|
|
150
156
|
domutils.append(item, new domhandler.Text('\n'));
|
|
151
157
|
}
|
|
152
158
|
else if (item.attribs['android:resource'] === resource || item.attribs['android:value'] === value) {
|
|
@@ -28,16 +28,14 @@ function isUpgrade(version, pending) {
|
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
30
|
module.exports = function finalize(instance) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const { profileable, dependencies, dataBinding, versionName, versionCode, namespace } = config;
|
|
34
|
-
if (!profileable && !dependencies && !dataBinding && !versionName && !versionCode && !namespace) {
|
|
31
|
+
const { profileable, dependencies, dataBinding, versionName, versionCode, namespace, applicationId, mainParentDir } = instance.config;
|
|
32
|
+
if (!profileable && !dependencies && !dataBinding && !versionName && !versionCode && !namespace && !applicationId) {
|
|
35
33
|
return;
|
|
36
34
|
}
|
|
37
|
-
const
|
|
38
|
-
let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory,
|
|
35
|
+
const options = { detect: this.incremental !== 'staging', languageOf: 'gradle' };
|
|
36
|
+
let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, mainParentDir), "build.gradle", options);
|
|
39
37
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
40
|
-
const { javaVersion, dependencyScopes } = config;
|
|
38
|
+
const { javaVersion, dependencyScopes } = instance.config;
|
|
41
39
|
let jvmTarget, modified;
|
|
42
40
|
const upgrade = javaVersion > 0;
|
|
43
41
|
const setModified = (output) => {
|
|
@@ -49,15 +47,14 @@ module.exports = function finalize(instance) {
|
|
|
49
47
|
if (dependencies) {
|
|
50
48
|
let data;
|
|
51
49
|
const hasScope = (value) => (0, types_1.isArray)(dependencyScopes) && dependencyScopes.includes(value) || dependencyScopes === value;
|
|
52
|
-
const snapshot = hasScope('snapshot');
|
|
53
|
-
const getData = () => data
|
|
50
|
+
const snapshot = dependencyScopes === 1 || hasScope('snapshot');
|
|
51
|
+
const getData = () => data ||= instance.findData('google-maven' + (snapshot ? '-snapshot' : '') + '.json', 'json');
|
|
54
52
|
const items = dependencies.map(item => {
|
|
55
|
-
var _a;
|
|
56
53
|
let [groupId, artifactId, version, type] = item.split(':');
|
|
57
54
|
if (!version || version === 'maven') {
|
|
58
55
|
const maven = getData();
|
|
59
56
|
let artifact;
|
|
60
|
-
if (maven && (artifact =
|
|
57
|
+
if (maven && (artifact = maven[groupId]?.find(child => child.artifactId === artifactId))) {
|
|
61
58
|
version = artifact.version;
|
|
62
59
|
}
|
|
63
60
|
else {
|
|
@@ -70,14 +67,14 @@ module.exports = function finalize(instance) {
|
|
|
70
67
|
const supplement = [];
|
|
71
68
|
for (const item of items) {
|
|
72
69
|
const [gId, id] = item;
|
|
73
|
-
const target =
|
|
70
|
+
const target = data[gId]?.find(group => id === group.artifactId);
|
|
74
71
|
if (!target) {
|
|
75
72
|
continue;
|
|
76
73
|
}
|
|
77
74
|
if (target.dependencies) {
|
|
78
75
|
let found;
|
|
79
76
|
for (const { groupId, artifactId, version, scope } of target.dependencies) {
|
|
80
|
-
if (scope && (dependencyScopes === true || hasScope(scope))) {
|
|
77
|
+
if (scope && (dependencyScopes === true || dependencyScopes === 1 || hasScope(scope))) {
|
|
81
78
|
let type = -1;
|
|
82
79
|
switch (scope) {
|
|
83
80
|
case 'compile':
|
|
@@ -200,7 +197,7 @@ module.exports = function finalize(instance) {
|
|
|
200
197
|
let dependency;
|
|
201
198
|
if (args || named) {
|
|
202
199
|
const [group, name, version] = item;
|
|
203
|
-
dependency = kotlin ? `(group = "${group}", name = "${name}", version = "${version}")` : ` group: '${group}', name: '${name}', version: '${version}'` + (
|
|
200
|
+
dependency = kotlin ? `(group = "${group}", name = "${name}", version = "${version}")` : ` group: '${group}', name: '${name}', version: '${version}'` + (args?.endsWith(',') ? ',' : '');
|
|
204
201
|
}
|
|
205
202
|
else {
|
|
206
203
|
dependency = item.slice(0, 3).join(':');
|
|
@@ -251,7 +248,7 @@ module.exports = function finalize(instance) {
|
|
|
251
248
|
}
|
|
252
249
|
if (items.length) {
|
|
253
250
|
const newline = process.platform === 'win32' ? '\r\n' : '\n';
|
|
254
|
-
indent
|
|
251
|
+
indent ||= (0, util_1.getIndent)(source);
|
|
255
252
|
content = items.reduce((a, b) => a + indent + writeMethod(b) + newline, content);
|
|
256
253
|
modified = true;
|
|
257
254
|
}
|
|
@@ -266,9 +263,9 @@ module.exports = function finalize(instance) {
|
|
|
266
263
|
output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
|
|
267
264
|
}
|
|
268
265
|
else {
|
|
269
|
-
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.
|
|
266
|
+
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.24")}'` });
|
|
270
267
|
output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
|
|
271
|
-
output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.
|
|
268
|
+
output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.14")}'`, true);
|
|
272
269
|
if (upgrade) {
|
|
273
270
|
output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
|
|
274
271
|
}
|
|
@@ -319,7 +316,6 @@ module.exports = function finalize(instance) {
|
|
|
319
316
|
output = Document.updateGradle(output, ['android'], kotlin ? `buildToolsVersion = "${version}"` : `buildToolsVersion "${version}"`, true);
|
|
320
317
|
}
|
|
321
318
|
}
|
|
322
|
-
const applicationId = (_b = config.manifest) === null || _b === void 0 ? void 0 : _b.package;
|
|
323
319
|
if (applicationId) {
|
|
324
320
|
output = Document.updateGradle(output, ['android', 'defaultConfig'], (kotlin ? 'applicationId = ' : 'applicationId ') + `"${applicationId}"`, true);
|
|
325
321
|
}
|
|
@@ -333,11 +329,15 @@ module.exports = function finalize(instance) {
|
|
|
333
329
|
}
|
|
334
330
|
if (profileable) {
|
|
335
331
|
let name, items;
|
|
336
|
-
if (
|
|
337
|
-
|
|
338
|
-
|
|
332
|
+
if ((0, types_1.isArray)(profileable)) {
|
|
333
|
+
name = profileable[0];
|
|
334
|
+
if (typeof name === 'string' && !name.startsWith('--')) {
|
|
335
|
+
items = profileable.slice(1);
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
name = '';
|
|
339
|
+
items = profileable;
|
|
339
340
|
}
|
|
340
|
-
items = profileable;
|
|
341
341
|
}
|
|
342
342
|
else if (typeof profileable === 'string') {
|
|
343
343
|
if (profileable.startsWith('--')) {
|
|
@@ -347,7 +347,7 @@ module.exports = function finalize(instance) {
|
|
|
347
347
|
name = profileable;
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
|
-
name
|
|
350
|
+
name ||= 'debug';
|
|
351
351
|
setModified(Document.updateGradle(source, ['android', 'buildTypes', kotlin ? 'getByName("release")' : 'release'], 'signingConfig ' + (kotlin ? `= signingConfigs.getByName("${name}")` : 'signingConfigs.' + name), true));
|
|
352
352
|
if ((0, types_1.isArray)(items)) {
|
|
353
353
|
const parameters = items.map(value => `"${value}"`).join(', ');
|
|
@@ -372,7 +372,7 @@ module.exports = function finalize(instance) {
|
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
374
|
if (!existing) {
|
|
375
|
-
({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle", {
|
|
375
|
+
({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle", { ...options, subDir: 'static' }));
|
|
376
376
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
377
377
|
try {
|
|
378
378
|
if (instance.writeFile(localUri, source, { encoding: 'utf-8', ownPermissionOnly: true, throwsPermission: true })) {
|
|
@@ -9,7 +9,7 @@ module.exports = function finalize(instance) {
|
|
|
9
9
|
}
|
|
10
10
|
let { localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "settings.gradle", { detect: this.incremental !== 'staging', languageOf: 'gradle' });
|
|
11
11
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
12
|
-
const targetName = projectName
|
|
12
|
+
const targetName = projectName?.replace(/"/g, '\\"');
|
|
13
13
|
let modified;
|
|
14
14
|
if (existing) {
|
|
15
15
|
let match;
|
package/extensions/task/index.js
CHANGED
|
@@ -7,7 +7,6 @@ const types_1 = require("@e-mc/types");
|
|
|
7
7
|
const Document = require("@e-mc/document");
|
|
8
8
|
const checkWin32 = (value) => value === "gradlew" && process.platform === 'win32' ? value + '.bat' : value;
|
|
9
9
|
module.exports = async function finalize(instance) {
|
|
10
|
-
var _a, _b;
|
|
11
10
|
const commands = instance.config.commands;
|
|
12
11
|
if (!commands || this.incremental === 'staging') {
|
|
13
12
|
return;
|
|
@@ -21,13 +20,13 @@ module.exports = async function finalize(instance) {
|
|
|
21
20
|
taskArgs = [commands];
|
|
22
21
|
}
|
|
23
22
|
else {
|
|
24
|
-
taskArgs = commands.map(value =>
|
|
23
|
+
taskArgs = commands.map(value => Array.isArray(value) ? value : [value]);
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
else {
|
|
28
27
|
return;
|
|
29
28
|
}
|
|
30
|
-
const settings =
|
|
29
|
+
const settings = instance.settings.extensions?.task || {};
|
|
31
30
|
const exec = settings.exec;
|
|
32
31
|
let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title, filename, altname, foundDir;
|
|
33
32
|
if (command) {
|
|
@@ -35,7 +34,7 @@ module.exports = async function finalize(instance) {
|
|
|
35
34
|
title = "maven";
|
|
36
35
|
}
|
|
37
36
|
else {
|
|
38
|
-
title =
|
|
37
|
+
title = /([^\\/]+?)(?:\.[a-z]+)?$/i.exec(command)?.[1] || 'spawn';
|
|
39
38
|
}
|
|
40
39
|
if (!/[\\/]/.test(command = path.normalize(command))) {
|
|
41
40
|
filename = checkWin32(command);
|
|
@@ -118,6 +117,6 @@ module.exports = async function finalize(instance) {
|
|
|
118
117
|
});
|
|
119
118
|
}
|
|
120
119
|
})
|
|
121
|
-
.catch(err => instance.writeFail(["Unable to perform task", command + ' ' + task], err, { type: 4, startTime }));
|
|
120
|
+
.catch((err) => instance.writeFail(["Unable to perform task", command + ' ' + task], err, { type: 4, startTime }));
|
|
122
121
|
}
|
|
123
122
|
};
|
package/index.js
CHANGED
|
@@ -4,29 +4,6 @@ const path = require("path");
|
|
|
4
4
|
const types_1 = require("@e-mc/types");
|
|
5
5
|
const Document = require('@e-mc/document');
|
|
6
6
|
class AndroidDocument extends Document {
|
|
7
|
-
constructor() {
|
|
8
|
-
super(...arguments);
|
|
9
|
-
this.config = {
|
|
10
|
-
mainParentDir: 'app',
|
|
11
|
-
mainSrcDir: 'src/main',
|
|
12
|
-
mainActivityFile: '',
|
|
13
|
-
javaVersion: 0,
|
|
14
|
-
dataBinding: false,
|
|
15
|
-
projectName: undefined,
|
|
16
|
-
versionName: undefined,
|
|
17
|
-
versionCode: 0,
|
|
18
|
-
manifest: undefined,
|
|
19
|
-
namespace: undefined,
|
|
20
|
-
profileable: undefined,
|
|
21
|
-
dependencies: undefined,
|
|
22
|
-
dependencyScopes: undefined,
|
|
23
|
-
commands: undefined
|
|
24
|
-
};
|
|
25
|
-
this.elements = [];
|
|
26
|
-
this.extensionData = {};
|
|
27
|
-
this._moduleName = 'android';
|
|
28
|
-
this._threadable = true;
|
|
29
|
-
}
|
|
30
7
|
static async finalize(instance) {
|
|
31
8
|
if (instance.aborted) {
|
|
32
9
|
return Promise.reject((0, types_1.createAbortError)());
|
|
@@ -53,9 +30,32 @@ class AndroidDocument extends Document {
|
|
|
53
30
|
}
|
|
54
31
|
return super.finalize.call(this, instance);
|
|
55
32
|
}
|
|
33
|
+
config = {
|
|
34
|
+
mainParentDir: 'app',
|
|
35
|
+
mainSrcDir: 'src/main',
|
|
36
|
+
mainActivityFile: '',
|
|
37
|
+
javaVersion: 0,
|
|
38
|
+
dataBinding: false,
|
|
39
|
+
projectName: undefined,
|
|
40
|
+
versionName: undefined,
|
|
41
|
+
versionCode: 0,
|
|
42
|
+
manifest: undefined,
|
|
43
|
+
namespace: undefined,
|
|
44
|
+
applicationId: undefined,
|
|
45
|
+
profileable: undefined,
|
|
46
|
+
dependencies: undefined,
|
|
47
|
+
dependencyScopes: undefined,
|
|
48
|
+
commands: undefined
|
|
49
|
+
};
|
|
50
|
+
elements = [];
|
|
51
|
+
extensionData = {};
|
|
52
|
+
targetAPI;
|
|
53
|
+
directories;
|
|
54
|
+
_moduleName = 'android';
|
|
55
|
+
_threadable = true;
|
|
56
56
|
init(assets, config) {
|
|
57
57
|
if (config) {
|
|
58
|
-
const { targetAPI, mainParentDir, mainSrcDir, mainActivityFile, javaVersion, projectName, versionName, versionCode = 0, manifest, namespace, profileable, dependencies, dependencyScopes, dataBinding, commands, directories, elements, extensionData } = config;
|
|
58
|
+
const { targetAPI, mainParentDir, mainSrcDir, mainActivityFile, javaVersion, projectName, versionName, versionCode = 0, manifest, namespace, applicationId, profileable, dependencies, dependencyScopes, dataBinding, commands, directories, elements, extensionData } = config;
|
|
59
59
|
const target = this.config;
|
|
60
60
|
if (projectName) {
|
|
61
61
|
target.projectName = projectName;
|
|
@@ -63,6 +63,9 @@ class AndroidDocument extends Document {
|
|
|
63
63
|
if (namespace) {
|
|
64
64
|
target.namespace = namespace;
|
|
65
65
|
}
|
|
66
|
+
if (applicationId) {
|
|
67
|
+
target.applicationId = applicationId;
|
|
68
|
+
}
|
|
66
69
|
if (mainParentDir) {
|
|
67
70
|
target.mainParentDir = mainParentDir;
|
|
68
71
|
}
|
|
@@ -150,14 +153,16 @@ class AndroidDocument extends Document {
|
|
|
150
153
|
const instance = host.loadModule('compress');
|
|
151
154
|
const buffer = host.getBuffer(file);
|
|
152
155
|
if (instance && buffer) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
else if ((0, types_1.isString)(result)) {
|
|
159
|
-
host.replace(file, result);
|
|
156
|
+
const options = { format: 'ttf', etag: file.etag };
|
|
157
|
+
await instance.tryFile(buffer, localUri, options)
|
|
158
|
+
.then(() => {
|
|
159
|
+
if (options.outFile) {
|
|
160
|
+
host.replace(file, options.outFile);
|
|
160
161
|
}
|
|
162
|
+
})
|
|
163
|
+
.catch((err) => {
|
|
164
|
+
host.deleteFile(localUri);
|
|
165
|
+
host.writeFail("Unable to compress file", err, 8);
|
|
161
166
|
});
|
|
162
167
|
}
|
|
163
168
|
break;
|
|
@@ -165,16 +170,23 @@ class AndroidDocument extends Document {
|
|
|
165
170
|
}
|
|
166
171
|
}
|
|
167
172
|
findTemplate(baseDir, filename, options) {
|
|
168
|
-
var _a;
|
|
169
173
|
let detect, languageOf, subDir;
|
|
170
174
|
if (options) {
|
|
171
175
|
({ detect, languageOf, subDir } = options);
|
|
172
176
|
}
|
|
173
177
|
let kotlin, language;
|
|
174
178
|
if (languageOf) {
|
|
175
|
-
kotlin = (language =
|
|
176
|
-
|
|
177
|
-
|
|
179
|
+
kotlin = (language = this.settings.language?.[languageOf]) === 'kotlin';
|
|
180
|
+
if (detect !== false) {
|
|
181
|
+
const isKts = this.detectKts(baseDir, filename);
|
|
182
|
+
if (isKts && language === 'java') {
|
|
183
|
+
kotlin = true;
|
|
184
|
+
detect = true;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
detect = typeof isKts === 'boolean' && (kotlin && isKts || !kotlin && !isKts);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
178
190
|
if (kotlin) {
|
|
179
191
|
filename += '.kts';
|
|
180
192
|
}
|
|
@@ -228,8 +240,7 @@ class AndroidDocument extends Document {
|
|
|
228
240
|
return null;
|
|
229
241
|
}
|
|
230
242
|
get settings() {
|
|
231
|
-
|
|
232
|
-
return (_a = this.module).settings || (_a.settings = {});
|
|
243
|
+
return this.module.settings ||= {};
|
|
233
244
|
}
|
|
234
245
|
}
|
|
235
246
|
module.exports = AndroidDocument;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/android",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
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.
|
|
24
|
-
"@e-mc/types": "^0.
|
|
23
|
+
"@e-mc/document": "^0.9.2",
|
|
24
|
+
"@e-mc/types": "^0.9.2",
|
|
25
25
|
"htmlparser2": "^9.1.0",
|
|
26
26
|
"which": "^2.0.2"
|
|
27
27
|
}
|
|
@@ -37,7 +37,7 @@ android {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
dependencies {
|
|
40
|
-
implementation 'androidx.core:core-ktx:1.
|
|
40
|
+
implementation 'androidx.core:core-ktx:1.13.1'
|
|
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.
|
|
3
|
-
id 'com.android.library' version '8.
|
|
4
|
-
id 'org.jetbrains.kotlin.android' version '1.9.
|
|
2
|
+
id 'com.android.application' version '8.4.0' apply false
|
|
3
|
+
id 'com.android.library' version '8.4.0' apply false
|
|
4
|
+
id 'org.jetbrains.kotlin.android' version '1.9.24' 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.
|
|
42
|
-
implementation("androidx.core:core-ktx:1.
|
|
41
|
+
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.24")
|
|
42
|
+
implementation("androidx.core:core-ktx:1.13.1")
|
|
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.
|
|
3
|
-
id("com.android.library") version "8.
|
|
4
|
-
id("org.jetbrains.kotlin.android") version "1.9.
|
|
2
|
+
id("com.android.application") version "8.4.0" apply false
|
|
3
|
+
id("com.android.library") version "8.4.0" apply false
|
|
4
|
+
id("org.jetbrains.kotlin.android") version "1.9.24" apply false
|
|
5
5
|
}
|