@pi-r/android 0.3.0 → 0.3.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.
- package/LICENSE +1 -1
- package/README.md +4 -2
- package/extensions/app/manifest/index.js +9 -5
- package/extensions/gradle/dependencies/index.js +11 -7
- package/extensions/gradle/settings/index.js +6 -2
- package/extensions/task/index.js +9 -5
- package/index.d.ts +6 -6
- package/index.js +8 -5
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright 2023
|
|
1
|
+
Copyright 2023 Studio Trigger
|
|
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
|
@@ -14,7 +14,7 @@ function finalize(instance) {
|
|
|
14
14
|
if (!config.manifest) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
let { localUri, source, existing } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir, config.mainSrcDir), "AndroidManifest.xml"
|
|
17
|
+
let { localUri, source, existing } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir, config.mainSrcDir), "AndroidManifest.xml", { detect: this.incremental !== 'staging' });
|
|
18
18
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
19
19
|
const { package: manifestPackage, application = {} } = config.manifest;
|
|
20
20
|
const { supportsRtl, label, theme, activity, metaData = [], activityName, fontProvider } = application;
|
|
@@ -41,7 +41,7 @@ function finalize(instance) {
|
|
|
41
41
|
else if (manifestPackage || theme || activityName || activity || supportsRtl !== undefined) {
|
|
42
42
|
new Parser(new DomHandler((err, dom) => {
|
|
43
43
|
if (err) {
|
|
44
|
-
instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"
|
|
44
|
+
instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"], err, 0);
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
let target = null;
|
|
@@ -138,7 +138,7 @@ function finalize(instance) {
|
|
|
138
138
|
if ((0, types_1.isArray)(metaData)) {
|
|
139
139
|
new Parser(new DomHandler((err, dom) => {
|
|
140
140
|
if (err) {
|
|
141
|
-
instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"
|
|
141
|
+
instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"], err, 0);
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
144
|
const app = domutils.findOne(elem => elem.tagName === 'application', dom, true);
|
|
@@ -174,10 +174,14 @@ function finalize(instance) {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
catch (err) {
|
|
177
|
-
this.writeFail(["Unable to write file"
|
|
177
|
+
this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
+
exports.default = finalize;
|
|
182
183
|
|
|
183
|
-
|
|
184
|
+
if (exports.default) {
|
|
185
|
+
module.exports = exports.default;
|
|
186
|
+
module.exports.default = exports.default;
|
|
187
|
+
}
|
|
@@ -11,7 +11,7 @@ function finalize(instance) {
|
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
const detect = this.incremental !== 'staging';
|
|
14
|
-
let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir), "build.gradle"
|
|
14
|
+
let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir), "build.gradle", { detect, languageOf: 'gradle' });
|
|
15
15
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
16
16
|
let { namespace, javaVersion } = config, jvmTarget, modified;
|
|
17
17
|
const upgrade = javaVersion > 0;
|
|
@@ -97,9 +97,9 @@ function finalize(instance) {
|
|
|
97
97
|
output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
|
|
98
98
|
}
|
|
99
99
|
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"
|
|
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")}'` });
|
|
101
101
|
output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
|
|
102
|
-
output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.0"
|
|
102
|
+
output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.0")}'`, true);
|
|
103
103
|
if (upgrade) {
|
|
104
104
|
output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
|
|
105
105
|
}
|
|
@@ -197,12 +197,12 @@ function finalize(instance) {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
catch (err) {
|
|
200
|
-
this.writeFail(["Unable to write file"
|
|
200
|
+
this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
if (!existing) {
|
|
205
|
-
({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle"
|
|
205
|
+
({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle", { detect, languageOf: 'gradle', subDir: 'static' }));
|
|
206
206
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
207
207
|
try {
|
|
208
208
|
if (instance.writeFile(localUri, source, { encoding: 'utf-8', ownPermissionOnly: true, throwsPermission: true })) {
|
|
@@ -210,10 +210,14 @@ function finalize(instance) {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
catch (err) {
|
|
213
|
-
this.writeFail(["Unable to write file"
|
|
213
|
+
this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
+
exports.default = finalize;
|
|
218
219
|
|
|
219
|
-
|
|
220
|
+
if (exports.default) {
|
|
221
|
+
module.exports = exports.default;
|
|
222
|
+
module.exports.default = exports.default;
|
|
223
|
+
}
|
|
@@ -72,10 +72,14 @@ function finalize(instance) {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
catch (err) {
|
|
75
|
-
this.writeFail(["Unable to write file"
|
|
75
|
+
this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
+
exports.default = finalize;
|
|
80
81
|
|
|
81
|
-
|
|
82
|
+
if (exports.default) {
|
|
83
|
+
module.exports = exports.default;
|
|
84
|
+
module.exports.default = exports.default;
|
|
85
|
+
}
|
package/extensions/task/index.js
CHANGED
|
@@ -79,9 +79,9 @@ async function finalize(instance) {
|
|
|
79
79
|
const startTime = process.hrtime();
|
|
80
80
|
const task = args.join(' ');
|
|
81
81
|
await new Promise((resolve, reject) => {
|
|
82
|
-
this.formatMessage(4
|
|
82
|
+
this.formatMessage(4, title, ['Executing task...', task], baseDirectory);
|
|
83
83
|
let out = '', message = '';
|
|
84
|
-
const { stdout, stderr } = child_process.spawn(command, Document.sanitizeArgs(args), { cwd: baseDirectory, shell: true, stdio: Document.hasLogType(32768
|
|
84
|
+
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 })
|
|
85
85
|
.on('exit', code => {
|
|
86
86
|
if (!code) {
|
|
87
87
|
instance.addLog(types_1.STATUS_TYPE.INFO, out);
|
|
@@ -89,7 +89,7 @@ async function finalize(instance) {
|
|
|
89
89
|
resolve();
|
|
90
90
|
}
|
|
91
91
|
else {
|
|
92
|
-
reject((0, types_1.errorValue)(message || (!foundCwd && code === 1 ? "Unable to execute file"
|
|
92
|
+
reject((0, types_1.errorValue)(message || (!foundCwd && code === 1 ? "Unable to execute file" : "Unknown"), "Error code" + ': ' + code));
|
|
93
93
|
}
|
|
94
94
|
})
|
|
95
95
|
.on('error', err => reject(err));
|
|
@@ -110,8 +110,12 @@ async function finalize(instance) {
|
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
})
|
|
113
|
-
.catch(err => instance.writeFail(["Unable to perform task"
|
|
113
|
+
.catch(err => instance.writeFail(["Unable to perform task", command + ' ' + task], err, { type: 4, startTime }));
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
+
exports.default = finalize;
|
|
116
117
|
|
|
117
|
-
|
|
118
|
+
if (exports.default) {
|
|
119
|
+
module.exports = exports.default;
|
|
120
|
+
module.exports.default = exports.default;
|
|
121
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { IFileManager } from '@e-mc/types/
|
|
2
|
-
|
|
3
|
-
import type { AndroidDocumentConstructor, DocumentAsset } from './types';
|
|
4
|
-
|
|
5
|
-
declare const Android: AndroidDocumentConstructor<IFileManager<DocumentAsset>>;
|
|
6
|
-
|
|
1
|
+
import type { IFileManager } from '@e-mc/types/lib';
|
|
2
|
+
|
|
3
|
+
import type { AndroidDocumentConstructor, DocumentAsset } from './types';
|
|
4
|
+
|
|
5
|
+
declare const Android: AndroidDocumentConstructor<IFileManager<DocumentAsset>>;
|
|
6
|
+
|
|
7
7
|
export = Android;
|
package/index.js
CHANGED
|
@@ -4,7 +4,6 @@ const fs = require("fs");
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const types_1 = require("@e-mc/types");
|
|
6
6
|
const Document = require('@e-mc/document');
|
|
7
|
-
// @ts-ignore
|
|
8
7
|
class AndroidDocument extends Document {
|
|
9
8
|
constructor() {
|
|
10
9
|
super(...arguments);
|
|
@@ -151,7 +150,7 @@ class AndroidDocument extends Document {
|
|
|
151
150
|
await instance.tryFile(buffer, localUri, { format: 'ttf', etag: file.etag }, (err, result) => {
|
|
152
151
|
if (err) {
|
|
153
152
|
host.deleteFile(localUri);
|
|
154
|
-
host.writeFail("Unable to compress file"
|
|
153
|
+
host.writeFail("Unable to compress file", err, 8);
|
|
155
154
|
}
|
|
156
155
|
else if ((0, types_1.isString)(result)) {
|
|
157
156
|
host.replace(file, result);
|
|
@@ -189,12 +188,12 @@ class AndroidDocument extends Document {
|
|
|
189
188
|
paths.push(filename);
|
|
190
189
|
let uri;
|
|
191
190
|
if (!existing && !(uri = this.resolveDir('template', ...paths)) && !fs.existsSync(uri = path.join(__dirname, 'template', ...paths))) {
|
|
192
|
-
throw (0, types_1.errorValue)("File not found"
|
|
191
|
+
throw (0, types_1.errorValue)("File not found", uri);
|
|
193
192
|
}
|
|
194
193
|
return { localUri, source: fs.readFileSync(uri || localUri, 'utf-8'), existing, kotlin, language };
|
|
195
194
|
}
|
|
196
195
|
catch (err) {
|
|
197
|
-
this.writeFail(["Unable to read file"
|
|
196
|
+
this.writeFail(["Unable to read file", path.basename(localUri)], err, 32);
|
|
198
197
|
}
|
|
199
198
|
return { kotlin, language };
|
|
200
199
|
}
|
|
@@ -217,5 +216,9 @@ class AndroidDocument extends Document {
|
|
|
217
216
|
return (_a = this.module).settings || (_a.settings = {});
|
|
218
217
|
}
|
|
219
218
|
}
|
|
219
|
+
exports.default = AndroidDocument;
|
|
220
220
|
|
|
221
|
-
|
|
221
|
+
if (exports.default) {
|
|
222
|
+
module.exports = exports.default;
|
|
223
|
+
module.exports.default = exports.default;
|
|
224
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/android",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
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.1",
|
|
24
|
+
"@e-mc/types": "^0.6.1",
|
|
25
25
|
"htmlparser2": "^9.0.0"
|
|
26
26
|
}
|
|
27
27
|
}
|