@pi-r/android 0.3.1 → 0.3.3
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/LICENSE +1 -1
- package/README.md +4 -2
- package/extensions/app/manifest/index.js +4 -5
- package/extensions/gradle/dependencies/index.js +13 -27
- package/extensions/gradle/settings/index.js +1 -2
- package/extensions/task/index.js +11 -13
- package/index.d.ts +1 -1
- package/index.js +3 -5
- package/package.json +4 -4
- package/template/java+kotlin/static/build.gradle +1 -1
- package/template/kotlin/build.gradle.kts +1 -1
- package/template/kotlin/static/build.gradle.kts +1 -1
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright 2023
|
|
1
|
+
Copyright 2023 Lisa Mishima
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
const path = require("path");
|
|
4
3
|
const htmlparser2 = require("htmlparser2");
|
|
5
4
|
const domhandler = require("domhandler");
|
|
@@ -14,7 +13,7 @@ function finalize(instance) {
|
|
|
14
13
|
if (!config.manifest) {
|
|
15
14
|
return;
|
|
16
15
|
}
|
|
17
|
-
let { localUri, source, existing } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir, config.mainSrcDir), "AndroidManifest.xml"
|
|
16
|
+
let { localUri, source, existing } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir, config.mainSrcDir), "AndroidManifest.xml", { detect: this.incremental !== 'staging' });
|
|
18
17
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
19
18
|
const { package: manifestPackage, application = {} } = config.manifest;
|
|
20
19
|
const { supportsRtl, label, theme, activity, metaData = [], activityName, fontProvider } = application;
|
|
@@ -41,7 +40,7 @@ function finalize(instance) {
|
|
|
41
40
|
else if (manifestPackage || theme || activityName || activity || supportsRtl !== undefined) {
|
|
42
41
|
new Parser(new DomHandler((err, dom) => {
|
|
43
42
|
if (err) {
|
|
44
|
-
instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"
|
|
43
|
+
instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"], err, 0);
|
|
45
44
|
return;
|
|
46
45
|
}
|
|
47
46
|
let target = null;
|
|
@@ -138,7 +137,7 @@ function finalize(instance) {
|
|
|
138
137
|
if ((0, types_1.isArray)(metaData)) {
|
|
139
138
|
new Parser(new DomHandler((err, dom) => {
|
|
140
139
|
if (err) {
|
|
141
|
-
instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"
|
|
140
|
+
instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"], err, 0);
|
|
142
141
|
return;
|
|
143
142
|
}
|
|
144
143
|
const app = domutils.findOne(elem => elem.tagName === 'application', dom, true);
|
|
@@ -174,7 +173,7 @@ function finalize(instance) {
|
|
|
174
173
|
}
|
|
175
174
|
}
|
|
176
175
|
catch (err) {
|
|
177
|
-
this.writeFail(["Unable to write file"
|
|
176
|
+
this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
179
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
const path = require("path");
|
|
4
3
|
const util_1 = require("@e-mc/document/util");
|
|
5
4
|
const types_1 = require("@e-mc/types");
|
|
@@ -11,7 +10,7 @@ function finalize(instance) {
|
|
|
11
10
|
return;
|
|
12
11
|
}
|
|
13
12
|
const detect = this.incremental !== 'staging';
|
|
14
|
-
let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir), "build.gradle"
|
|
13
|
+
let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir), "build.gradle", { detect, languageOf: 'gradle' });
|
|
15
14
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
16
15
|
let { namespace, javaVersion } = config, jvmTarget, modified;
|
|
17
16
|
const upgrade = javaVersion > 0;
|
|
@@ -26,7 +25,7 @@ function finalize(instance) {
|
|
|
26
25
|
if (!kotlin && items.some(value => value[1].endsWith('-ktx'))) {
|
|
27
26
|
setModified(Document.updateGradle(source, ['plugins'], "id 'kotlin-android'", { multiple: true }));
|
|
28
27
|
}
|
|
29
|
-
const match = /dependencies\s+\{(
|
|
28
|
+
const match = /dependencies\s+\{([^}]+)\}/.exec(source);
|
|
30
29
|
if (match) {
|
|
31
30
|
const writeImpl = (item) => 'implementation' + (kotlin ? `("${item.join(':')}")` : ` '${item.join(':')}'`);
|
|
32
31
|
const pattern = kotlin ? /([ \t]*)implementation\((?:\s*"([^"]+)"\s*\))?/g : /([ \t]*)implementation(?:\s*\(?\s*["']([^"']+)["']\s*\)?|\s+((?:\s*(?:group|name|version)\s*:\s*["'][^"']+["']\s*,?){3}))?/g;
|
|
@@ -59,25 +58,12 @@ function finalize(instance) {
|
|
|
59
58
|
if (version && (index = items.findIndex(seg => seg[0] === group && seg[1] === name)) !== -1) {
|
|
60
59
|
found = 1;
|
|
61
60
|
if (version[0] !== '$' || !kotlin && impl[0].indexOf("'") !== -1) {
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const getArray = (value) => value.split(/[.-]/).map(seg => +seg);
|
|
69
|
-
const current = getArray(pending);
|
|
70
|
-
const previous = getArray(version);
|
|
71
|
-
for (let i = 0; i < previous.length; ++i) {
|
|
72
|
-
const a = previous[i];
|
|
73
|
-
const b = current[i];
|
|
74
|
-
if (isNaN(a) || b > a) {
|
|
75
|
-
found = 2;
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
if (isNaN(b) || b < a) {
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
61
|
+
const current = items[index][2].split('.').map(seg => +seg);
|
|
62
|
+
const parts = version.split('.');
|
|
63
|
+
for (let i = 0, value; i < parts.length; ++i) {
|
|
64
|
+
if (isNaN(value = +parts[i]) || +current[i] > value) {
|
|
65
|
+
found = 2;
|
|
66
|
+
break;
|
|
81
67
|
}
|
|
82
68
|
}
|
|
83
69
|
}
|
|
@@ -110,9 +96,9 @@ function finalize(instance) {
|
|
|
110
96
|
output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
|
|
111
97
|
}
|
|
112
98
|
else {
|
|
113
|
-
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.
|
|
99
|
+
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")}'` });
|
|
114
100
|
output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
|
|
115
|
-
output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.
|
|
101
|
+
output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.9")}'`, true);
|
|
116
102
|
if (upgrade) {
|
|
117
103
|
output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
|
|
118
104
|
}
|
|
@@ -210,12 +196,12 @@ function finalize(instance) {
|
|
|
210
196
|
}
|
|
211
197
|
}
|
|
212
198
|
catch (err) {
|
|
213
|
-
this.writeFail(["Unable to write file"
|
|
199
|
+
this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
|
|
214
200
|
}
|
|
215
201
|
}
|
|
216
202
|
}
|
|
217
203
|
if (!existing) {
|
|
218
|
-
({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle"
|
|
204
|
+
({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle", { detect, languageOf: 'gradle', subDir: 'static' }));
|
|
219
205
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
220
206
|
try {
|
|
221
207
|
if (instance.writeFile(localUri, source, { encoding: 'utf-8', ownPermissionOnly: true, throwsPermission: true })) {
|
|
@@ -223,7 +209,7 @@ function finalize(instance) {
|
|
|
223
209
|
}
|
|
224
210
|
}
|
|
225
211
|
catch (err) {
|
|
226
|
-
this.writeFail(["Unable to write file"
|
|
212
|
+
this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
|
|
227
213
|
}
|
|
228
214
|
}
|
|
229
215
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
const path = require("path");
|
|
4
3
|
const util_1 = require("@e-mc/document/util");
|
|
5
4
|
const parse_1 = require("@e-mc/document/parse");
|
|
@@ -72,7 +71,7 @@ function finalize(instance) {
|
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
catch (err) {
|
|
75
|
-
this.writeFail(["Unable to write file"
|
|
74
|
+
this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
77
|
}
|
package/extensions/task/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
const path = require("path");
|
|
4
3
|
const fs = require("fs");
|
|
5
4
|
const child_process = require("child_process");
|
|
6
5
|
const types_1 = require("@e-mc/types");
|
|
7
6
|
const Document = require("@e-mc/document");
|
|
8
|
-
const checkWin32 = (value) => value === "gradlew" /* STRINGS.GRADLEW */ && process.platform === 'win32' ? value + '.bat' : value;
|
|
9
7
|
async function finalize(instance) {
|
|
10
8
|
const commands = instance.config.commands;
|
|
11
9
|
if (!commands || this.incremental === 'staging') {
|
|
@@ -28,7 +26,7 @@ async function finalize(instance) {
|
|
|
28
26
|
}
|
|
29
27
|
const settings = instance.settings.extensions?.task || {};
|
|
30
28
|
const exec = settings.exec;
|
|
31
|
-
let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title,
|
|
29
|
+
let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title, name, foundCwd;
|
|
32
30
|
if (command) {
|
|
33
31
|
if (command.indexOf('mvn') !== -1) {
|
|
34
32
|
title = 'maven';
|
|
@@ -37,20 +35,20 @@ async function finalize(instance) {
|
|
|
37
35
|
title = /([^\\/]+?)(?:\.[a-z]+)?$/i.exec(command)?.[1] || 'SPAWN';
|
|
38
36
|
}
|
|
39
37
|
command = path.normalize(command);
|
|
40
|
-
if (
|
|
41
|
-
|
|
38
|
+
if (!command.includes(path.sep)) {
|
|
39
|
+
name = command;
|
|
42
40
|
}
|
|
43
41
|
command = Document.sanitizeCmd(command);
|
|
44
42
|
}
|
|
45
43
|
else {
|
|
46
|
-
|
|
47
|
-
command = '.' + path.sep +
|
|
44
|
+
name = 'gradlew';
|
|
45
|
+
command = '.' + path.sep + name;
|
|
48
46
|
title = 'gradle';
|
|
49
47
|
}
|
|
50
|
-
if (
|
|
48
|
+
if (name) {
|
|
51
49
|
try {
|
|
52
50
|
let appDir = baseDirectory;
|
|
53
|
-
while (!(foundCwd = fs.existsSync(path.join(appDir,
|
|
51
|
+
while (!(foundCwd = fs.existsSync(path.join(appDir, name)))) {
|
|
54
52
|
const parent = path.dirname(appDir);
|
|
55
53
|
if (parent === appDir) {
|
|
56
54
|
break;
|
|
@@ -80,9 +78,9 @@ async function finalize(instance) {
|
|
|
80
78
|
const startTime = process.hrtime();
|
|
81
79
|
const task = args.join(' ');
|
|
82
80
|
await new Promise((resolve, reject) => {
|
|
83
|
-
this.formatMessage(4
|
|
81
|
+
this.formatMessage(4, title, ['Executing task...', task], baseDirectory);
|
|
84
82
|
let out = '', message = '';
|
|
85
|
-
const { stdout, stderr } = child_process.spawn(command, Document.sanitizeArgs(args), { cwd: baseDirectory, shell: true, stdio: Document.hasLogType(32768
|
|
83
|
+
const { stdout, stderr } = child_process.spawn(command, Document.sanitizeArgs(args), { cwd: baseDirectory, shell: true, stdio: Document.hasLogType(32768) && !broadcastId ? 'inherit' : undefined, signal: instance.signal, uid, gid })
|
|
86
84
|
.on('exit', code => {
|
|
87
85
|
if (!code) {
|
|
88
86
|
instance.addLog(types_1.STATUS_TYPE.INFO, out);
|
|
@@ -90,7 +88,7 @@ async function finalize(instance) {
|
|
|
90
88
|
resolve();
|
|
91
89
|
}
|
|
92
90
|
else {
|
|
93
|
-
reject((0, types_1.errorValue)(message || (!foundCwd && code === 1 ? "Unable to execute file"
|
|
91
|
+
reject((0, types_1.errorValue)(message || (!foundCwd && code === 1 ? "Unable to execute file" : "Unknown"), "Error code" + ': ' + code));
|
|
94
92
|
}
|
|
95
93
|
})
|
|
96
94
|
.on('error', err => reject(err));
|
|
@@ -111,7 +109,7 @@ async function finalize(instance) {
|
|
|
111
109
|
});
|
|
112
110
|
}
|
|
113
111
|
})
|
|
114
|
-
.catch(err => instance.writeFail(["Unable to perform task"
|
|
112
|
+
.catch(err => instance.writeFail(["Unable to perform task", command + ' ' + task], err, { type: 4, startTime }));
|
|
115
113
|
}
|
|
116
114
|
}
|
|
117
115
|
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
const fs = require("fs");
|
|
4
3
|
const path = require("path");
|
|
5
4
|
const types_1 = require("@e-mc/types");
|
|
6
5
|
const Document = require('@e-mc/document');
|
|
7
|
-
// @ts-ignore
|
|
8
6
|
class AndroidDocument extends Document {
|
|
9
7
|
constructor() {
|
|
10
8
|
super(...arguments);
|
|
@@ -151,7 +149,7 @@ class AndroidDocument extends Document {
|
|
|
151
149
|
await instance.tryFile(buffer, localUri, { format: 'ttf', etag: file.etag }, (err, result) => {
|
|
152
150
|
if (err) {
|
|
153
151
|
host.deleteFile(localUri);
|
|
154
|
-
host.writeFail("Unable to compress file"
|
|
152
|
+
host.writeFail("Unable to compress file", err, 8);
|
|
155
153
|
}
|
|
156
154
|
else if ((0, types_1.isString)(result)) {
|
|
157
155
|
host.replace(file, result);
|
|
@@ -189,12 +187,12 @@ class AndroidDocument extends Document {
|
|
|
189
187
|
paths.push(filename);
|
|
190
188
|
let uri;
|
|
191
189
|
if (!existing && !(uri = this.resolveDir('template', ...paths)) && !fs.existsSync(uri = path.join(__dirname, 'template', ...paths))) {
|
|
192
|
-
throw (0, types_1.errorValue)("File not found"
|
|
190
|
+
throw (0, types_1.errorValue)("File not found", uri);
|
|
193
191
|
}
|
|
194
192
|
return { localUri, source: fs.readFileSync(uri || localUri, 'utf-8'), existing, kotlin, language };
|
|
195
193
|
}
|
|
196
194
|
catch (err) {
|
|
197
|
-
this.writeFail(["Unable to read file"
|
|
195
|
+
this.writeFail(["Unable to read file", path.basename(localUri)], err, 32);
|
|
198
196
|
}
|
|
199
197
|
return { kotlin, language };
|
|
200
198
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/android",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Android document constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/anpham6/pi-r.git",
|
|
11
|
+
"url": "git+https://github.com/anpham6/pi-r.git",
|
|
12
12
|
"directory": "src/module/android"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
@@ -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.6.
|
|
24
|
-
"@e-mc/types": "^0.6.
|
|
23
|
+
"@e-mc/document": "^0.6.2",
|
|
24
|
+
"@e-mc/types": "^0.6.2",
|
|
25
25
|
"htmlparser2": "^9.0.0"
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -38,7 +38,7 @@ java {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
dependencies {
|
|
41
|
-
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.
|
|
41
|
+
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.22")
|
|
42
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")
|