@pi-r/android 0.6.4 → 0.6.5
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 +6 -3
- package/data/google-maven-snapshot.json +1 -1
- package/data/google-maven.json +1 -1
- package/extensions/app/manifest/index.js +4 -5
- package/extensions/gradle/dependencies/index.js +21 -22
- package/extensions/gradle/settings/index.js +2 -3
- package/extensions/task/index.js +9 -10
- package/index.d.ts +3 -3
- package/index.js +4 -6
- package/package.json +3 -3
|
@@ -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);
|
|
@@ -173,7 +172,7 @@ function finalize(instance) {
|
|
|
173
172
|
}
|
|
174
173
|
}
|
|
175
174
|
catch (err) {
|
|
176
|
-
this.writeFail(["Unable to write file"
|
|
175
|
+
this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
|
|
177
176
|
}
|
|
178
177
|
}
|
|
179
178
|
}
|
|
@@ -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");
|
|
@@ -35,7 +34,7 @@ function finalize(instance) {
|
|
|
35
34
|
return;
|
|
36
35
|
}
|
|
37
36
|
const detect = this.incremental !== 'staging';
|
|
38
|
-
let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir), "build.gradle"
|
|
37
|
+
let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir), "build.gradle", { detect, languageOf: 'gradle' });
|
|
39
38
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
40
39
|
let { namespace, javaVersion, dependencyScopes } = config, jvmTarget, modified;
|
|
41
40
|
const upgrade = javaVersion > 0;
|
|
@@ -79,16 +78,16 @@ function finalize(instance) {
|
|
|
79
78
|
let type = -1;
|
|
80
79
|
switch (scope) {
|
|
81
80
|
case 'compile':
|
|
82
|
-
type = 0
|
|
81
|
+
type = 0;
|
|
83
82
|
break;
|
|
84
83
|
case 'provided':
|
|
85
|
-
type = 2
|
|
84
|
+
type = 2;
|
|
86
85
|
break;
|
|
87
86
|
case 'runtime':
|
|
88
|
-
type = 4
|
|
87
|
+
type = 4;
|
|
89
88
|
break;
|
|
90
89
|
case 'test':
|
|
91
|
-
type = 5
|
|
90
|
+
type = 5;
|
|
92
91
|
break;
|
|
93
92
|
}
|
|
94
93
|
if (type !== -1) {
|
|
@@ -161,37 +160,37 @@ function finalize(instance) {
|
|
|
161
160
|
let content = match[1], named = false, indent, method;
|
|
162
161
|
const writeMethod = (item, args, prefix = 'implementation') => {
|
|
163
162
|
switch (parseInt(item[3])) {
|
|
164
|
-
case 0
|
|
163
|
+
case 0:
|
|
165
164
|
prefix = 'implementation';
|
|
166
165
|
break;
|
|
167
|
-
case 1
|
|
166
|
+
case 1:
|
|
168
167
|
prefix = 'api';
|
|
169
168
|
break;
|
|
170
|
-
case 2
|
|
169
|
+
case 2:
|
|
171
170
|
prefix = 'compileOnly';
|
|
172
171
|
break;
|
|
173
|
-
case 3
|
|
172
|
+
case 3:
|
|
174
173
|
prefix = 'compileOnlyApi';
|
|
175
174
|
break;
|
|
176
|
-
case 4
|
|
175
|
+
case 4:
|
|
177
176
|
prefix = 'runtimeOnly';
|
|
178
177
|
break;
|
|
179
|
-
case 5
|
|
178
|
+
case 5:
|
|
180
179
|
prefix = 'testImplementation';
|
|
181
180
|
break;
|
|
182
|
-
case 6
|
|
181
|
+
case 6:
|
|
183
182
|
prefix = 'testCompileOnly';
|
|
184
183
|
break;
|
|
185
|
-
case 7
|
|
184
|
+
case 7:
|
|
186
185
|
prefix = 'testRuntimeOnly';
|
|
187
186
|
break;
|
|
188
|
-
case 8
|
|
187
|
+
case 8:
|
|
189
188
|
prefix = 'androidTestImplementation';
|
|
190
189
|
break;
|
|
191
|
-
case 9
|
|
190
|
+
case 9:
|
|
192
191
|
prefix = 'androidTestCompileOnly';
|
|
193
192
|
break;
|
|
194
|
-
case 10
|
|
193
|
+
case 10:
|
|
195
194
|
prefix = 'androidTestRuntimeOnly';
|
|
196
195
|
break;
|
|
197
196
|
}
|
|
@@ -264,9 +263,9 @@ function finalize(instance) {
|
|
|
264
263
|
output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
|
|
265
264
|
}
|
|
266
265
|
else {
|
|
267
|
-
output = Document.updateGradle(output, ['plugins'], "id 'org.jetbrains.kotlin.android'", { upgrade: true, multiple: true, addendum: `version '${instance.findVersion('org.jetbrains.kotlin:kotlin-stdlib', "1.9.22"
|
|
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.22")}'` });
|
|
268
267
|
output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
|
|
269
|
-
output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.9"
|
|
268
|
+
output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.9")}'`, true);
|
|
270
269
|
if (upgrade) {
|
|
271
270
|
output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
|
|
272
271
|
}
|
|
@@ -364,12 +363,12 @@ function finalize(instance) {
|
|
|
364
363
|
}
|
|
365
364
|
}
|
|
366
365
|
catch (err) {
|
|
367
|
-
this.writeFail(["Unable to write file"
|
|
366
|
+
this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
|
|
368
367
|
}
|
|
369
368
|
}
|
|
370
369
|
}
|
|
371
370
|
if (!existing) {
|
|
372
|
-
({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle"
|
|
371
|
+
({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle", { detect, languageOf: 'gradle', subDir: 'static' }));
|
|
373
372
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
374
373
|
try {
|
|
375
374
|
if (instance.writeFile(localUri, source, { encoding: 'utf-8', ownPermissionOnly: true, throwsPermission: true })) {
|
|
@@ -377,7 +376,7 @@ function finalize(instance) {
|
|
|
377
376
|
}
|
|
378
377
|
}
|
|
379
378
|
catch (err) {
|
|
380
|
-
this.writeFail(["Unable to write file"
|
|
379
|
+
this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
|
|
381
380
|
}
|
|
382
381
|
}
|
|
383
382
|
}
|
|
@@ -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");
|
|
@@ -8,7 +7,7 @@ function finalize(instance) {
|
|
|
8
7
|
if (!dependencies && !projectName) {
|
|
9
8
|
return;
|
|
10
9
|
}
|
|
11
|
-
let { localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "settings.gradle"
|
|
10
|
+
let { localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "settings.gradle", { detect: this.incremental !== 'staging', languageOf: 'gradle' });
|
|
12
11
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
13
12
|
let targetName = projectName?.replace(/"/g, '\\"'), modified;
|
|
14
13
|
if (existing) {
|
|
@@ -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,12 +1,11 @@
|
|
|
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 which = require("which");
|
|
7
6
|
const types_1 = require("@e-mc/types");
|
|
8
7
|
const Document = require("@e-mc/document");
|
|
9
|
-
const checkWin32 = (value) => value === "gradlew"
|
|
8
|
+
const checkWin32 = (value) => value === "gradlew" && process.platform === 'win32' ? value + '.bat' : value;
|
|
10
9
|
async function finalize(instance) {
|
|
11
10
|
const commands = instance.config.commands;
|
|
12
11
|
if (!commands || this.incremental === 'staging') {
|
|
@@ -32,7 +31,7 @@ async function finalize(instance) {
|
|
|
32
31
|
let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title, filename, altname, foundDir;
|
|
33
32
|
if (command) {
|
|
34
33
|
if (command.includes('mvn')) {
|
|
35
|
-
title = "maven"
|
|
34
|
+
title = "maven";
|
|
36
35
|
}
|
|
37
36
|
else {
|
|
38
37
|
title = /([^\\/]+?)(?:\.[a-z]+)?$/i.exec(command)?.[1] || 'spawn';
|
|
@@ -43,10 +42,10 @@ async function finalize(instance) {
|
|
|
43
42
|
command = Document.sanitizeCmd(command);
|
|
44
43
|
}
|
|
45
44
|
else {
|
|
46
|
-
filename = checkWin32("gradlew"
|
|
45
|
+
filename = checkWin32("gradlew");
|
|
47
46
|
command = '.' + path.sep + filename;
|
|
48
|
-
title = "gradle"
|
|
49
|
-
altname = "gradle"
|
|
47
|
+
title = "gradle";
|
|
48
|
+
altname = "gradle";
|
|
50
49
|
}
|
|
51
50
|
if (filename) {
|
|
52
51
|
try {
|
|
@@ -87,9 +86,9 @@ async function finalize(instance) {
|
|
|
87
86
|
const startTime = process.hrtime();
|
|
88
87
|
const task = args.join(' ');
|
|
89
88
|
await new Promise((resolve, reject) => {
|
|
90
|
-
this.formatMessage(4
|
|
89
|
+
this.formatMessage(4, title, ['Executing task...', task], baseDirectory);
|
|
91
90
|
let out = '', message = '';
|
|
92
|
-
const { stdout, stderr } = child_process.spawn(command, Document.sanitizeArgs(args), { cwd: baseDirectory, shell: true, stdio: Document.hasLogType(32768
|
|
91
|
+
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 })
|
|
93
92
|
.on('exit', code => {
|
|
94
93
|
if (!code) {
|
|
95
94
|
instance.addLog(types_1.STATUS_TYPE.INFO, out);
|
|
@@ -97,7 +96,7 @@ async function finalize(instance) {
|
|
|
97
96
|
resolve();
|
|
98
97
|
}
|
|
99
98
|
else {
|
|
100
|
-
reject((0, types_1.errorValue)(message || (!foundDir && code === 1 ? "Unable to execute file"
|
|
99
|
+
reject((0, types_1.errorValue)(message || (!foundDir && code === 1 ? "Unable to execute file" : "Unknown"), "Error code" + ': ' + code));
|
|
101
100
|
}
|
|
102
101
|
})
|
|
103
102
|
.on('error', err => reject(err));
|
|
@@ -118,7 +117,7 @@ async function finalize(instance) {
|
|
|
118
117
|
});
|
|
119
118
|
}
|
|
120
119
|
})
|
|
121
|
-
.catch(err => instance.writeFail(["Unable to perform task"
|
|
120
|
+
.catch(err => instance.writeFail(["Unable to perform task", command + ' ' + task], err, { type: 4, startTime }));
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
123
|
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { IFileManager } from '@e-mc/types/
|
|
1
|
+
import type { IFileManager } from '@e-mc/types/lib';
|
|
2
2
|
|
|
3
|
-
import type { AndroidDocumentConstructor
|
|
3
|
+
import type { AndroidDocumentConstructor } from './types';
|
|
4
4
|
|
|
5
|
-
declare const Android: AndroidDocumentConstructor<IFileManager
|
|
5
|
+
declare const Android: AndroidDocumentConstructor<IFileManager>;
|
|
6
6
|
|
|
7
7
|
export = Android;
|
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);
|
|
@@ -155,7 +153,7 @@ class AndroidDocument extends Document {
|
|
|
155
153
|
await instance.tryFile(buffer, localUri, { format: 'ttf', etag: file.etag }, (err, result) => {
|
|
156
154
|
if (err) {
|
|
157
155
|
host.deleteFile(localUri);
|
|
158
|
-
host.writeFail("Unable to compress file"
|
|
156
|
+
host.writeFail("Unable to compress file", err, 8);
|
|
159
157
|
}
|
|
160
158
|
else if ((0, types_1.isString)(result)) {
|
|
161
159
|
host.replace(file, result);
|
|
@@ -193,12 +191,12 @@ class AndroidDocument extends Document {
|
|
|
193
191
|
paths.push(filename);
|
|
194
192
|
let uri;
|
|
195
193
|
if (!existing && !(uri = this.resolveDir('template', ...paths)) && !fs.existsSync(uri = path.join(__dirname, 'template', ...paths))) {
|
|
196
|
-
throw (0, types_1.errorValue)("File not found"
|
|
194
|
+
throw (0, types_1.errorValue)("File not found", uri);
|
|
197
195
|
}
|
|
198
196
|
return { localUri, source: fs.readFileSync(uri || localUri, 'utf-8'), existing, kotlin, language };
|
|
199
197
|
}
|
|
200
198
|
catch (err) {
|
|
201
|
-
this.writeFail(["Unable to read file"
|
|
199
|
+
this.writeFail(["Unable to read file", path.basename(localUri)], err, 32);
|
|
202
200
|
}
|
|
203
201
|
return { kotlin, language };
|
|
204
202
|
}
|
|
@@ -209,7 +207,7 @@ class AndroidDocument extends Document {
|
|
|
209
207
|
return this.tryParse(fs.readFileSync(localUri, 'utf-8'), format || path.extname(localUri).substring(1));
|
|
210
208
|
}
|
|
211
209
|
catch (err) {
|
|
212
|
-
this.writeFail(["Unable to read file"
|
|
210
|
+
this.writeFail(["Unable to read file", path.basename(localUri)], err, 32);
|
|
213
211
|
}
|
|
214
212
|
}
|
|
215
213
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/android",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
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.8.
|
|
24
|
-
"@e-mc/types": "^0.8.
|
|
23
|
+
"@e-mc/document": "^0.8.6",
|
|
24
|
+
"@e-mc/types": "^0.8.6",
|
|
25
25
|
"htmlparser2": "^9.1.0",
|
|
26
26
|
"which": "^2.0.2"
|
|
27
27
|
}
|