@pi-r/android 0.3.6 → 0.3.7
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.
|
@@ -20,14 +20,14 @@ function finalize(instance) {
|
|
|
20
20
|
const profileable = config.profileable;
|
|
21
21
|
let modified;
|
|
22
22
|
if (!existing) {
|
|
23
|
-
source = (0, util_1.replaceAll)(source
|
|
23
|
+
source = (0, util_1.replaceAll)(source, (name) => {
|
|
24
24
|
switch (name) {
|
|
25
25
|
case 'supportsRtl':
|
|
26
26
|
return supportsRtl === false ? 'false' : 'true';
|
|
27
27
|
case 'label':
|
|
28
28
|
return '@string/' + (label || 'app_name');
|
|
29
29
|
case 'theme':
|
|
30
|
-
return
|
|
30
|
+
return '@style/' + (theme || 'Theme.Android2');
|
|
31
31
|
case 'activityName':
|
|
32
32
|
return activityName || '';
|
|
33
33
|
case 'profileable':
|
|
@@ -45,7 +45,7 @@ function finalize(instance) {
|
|
|
45
45
|
}
|
|
46
46
|
let target = null;
|
|
47
47
|
if (manifestPackage && (target = domutils.findOne(elem => elem.tagName === 'manifest', dom, true))) {
|
|
48
|
-
target.attribs
|
|
48
|
+
target.attribs.package = manifestPackage;
|
|
49
49
|
modified = true;
|
|
50
50
|
}
|
|
51
51
|
if (target = domutils.findOne(elem => elem.tagName === 'application', dom, true)) {
|
|
@@ -10,7 +10,8 @@ function finalize(instance) {
|
|
|
10
10
|
if (!profileable && !dependencies && !dataBinding && !versionName && !versionCode && !config.namespace) {
|
|
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", { detect, languageOf: 'gradle' });
|
|
14
15
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
15
16
|
let { namespace, javaVersion } = config, jvmTarget, modified;
|
|
16
17
|
const upgrade = javaVersion > 0;
|
|
@@ -96,9 +97,9 @@ function finalize(instance) {
|
|
|
96
97
|
output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
|
|
97
98
|
}
|
|
98
99
|
else {
|
|
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.
|
|
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.22")}'` });
|
|
100
101
|
output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
|
|
101
|
-
output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.
|
|
102
|
+
output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.9")}'`, true);
|
|
102
103
|
if (upgrade) {
|
|
103
104
|
output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
|
|
104
105
|
}
|
|
@@ -200,6 +201,19 @@ function finalize(instance) {
|
|
|
200
201
|
}
|
|
201
202
|
}
|
|
202
203
|
}
|
|
204
|
+
if (!existing) {
|
|
205
|
+
({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle", { detect, languageOf: 'gradle', subDir: 'static' }));
|
|
206
|
+
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
207
|
+
try {
|
|
208
|
+
if (instance.writeFile(localUri, source, { encoding: 'utf-8', ownPermissionOnly: true, throwsPermission: true })) {
|
|
209
|
+
this.add(localUri);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
catch (err) {
|
|
213
|
+
this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
203
217
|
}
|
|
204
218
|
|
|
205
219
|
module.exports = finalize;
|
|
@@ -3,14 +3,13 @@ const path = require("path");
|
|
|
3
3
|
const util_1 = require("@e-mc/document/util");
|
|
4
4
|
const parse_1 = require("@e-mc/document/parse");
|
|
5
5
|
function finalize(instance) {
|
|
6
|
-
const { dependencies, projectName, mainParentDir } = instance.config;
|
|
6
|
+
const { dependencies, projectName, manifest, mainParentDir } = instance.config;
|
|
7
7
|
if (!dependencies && !projectName) {
|
|
8
8
|
return;
|
|
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
|
-
|
|
13
|
-
let modified;
|
|
12
|
+
let targetName = projectName === null || projectName === void 0 ? void 0 : projectName.replace(/"/g, '\\"'), modified;
|
|
14
13
|
if (existing) {
|
|
15
14
|
let match;
|
|
16
15
|
if (dependencies) {
|
|
@@ -50,10 +49,14 @@ function finalize(instance) {
|
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
else {
|
|
52
|
+
if (!targetName && (targetName = manifest === null || manifest === void 0 ? void 0 : manifest.package)) {
|
|
53
|
+
const index = targetName.lastIndexOf('.');
|
|
54
|
+
targetName = index !== -1 ? targetName.substring(index + 1) : '';
|
|
55
|
+
}
|
|
53
56
|
source = (0, util_1.replaceAll)(source, (name) => {
|
|
54
57
|
switch (name) {
|
|
55
58
|
case 'projectName':
|
|
56
|
-
return targetName;
|
|
59
|
+
return targetName || '';
|
|
57
60
|
case 'name':
|
|
58
61
|
return ':' + mainParentDir;
|
|
59
62
|
default:
|
package/extensions/task/index.js
CHANGED
|
@@ -5,7 +5,7 @@ const child_process = require("child_process");
|
|
|
5
5
|
const types_1 = require("@e-mc/types");
|
|
6
6
|
const Document = require("@e-mc/document");
|
|
7
7
|
async function finalize(instance) {
|
|
8
|
-
var _a, _b
|
|
8
|
+
var _a, _b;
|
|
9
9
|
const commands = instance.config.commands;
|
|
10
10
|
if (!commands || this.incremental === 'staging') {
|
|
11
11
|
return;
|
|
@@ -25,13 +25,15 @@ async function finalize(instance) {
|
|
|
25
25
|
else {
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
const settings = ((_a = instance.settings.extensions) === null || _a === void 0 ? void 0 : _a.task) || {};
|
|
29
|
+
const exec = settings.exec;
|
|
30
|
+
let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title, name, foundCwd;
|
|
29
31
|
if (command) {
|
|
30
32
|
if (command.indexOf('mvn') !== -1) {
|
|
31
33
|
title = 'maven';
|
|
32
34
|
}
|
|
33
35
|
else {
|
|
34
|
-
title = ((
|
|
36
|
+
title = ((_b = /([^\\/]+?)(?:\.[a-z]+)?$/i.exec(command)) === null || _b === void 0 ? void 0 : _b[1]) || 'SPAWN';
|
|
35
37
|
}
|
|
36
38
|
command = path.normalize(command);
|
|
37
39
|
if (!command.includes(path.sep)) {
|
|
@@ -61,6 +63,15 @@ async function finalize(instance) {
|
|
|
61
63
|
catch {
|
|
62
64
|
}
|
|
63
65
|
}
|
|
66
|
+
if ((0, types_1.isPlainObject)(exec)) {
|
|
67
|
+
let { uid: u, gid: g } = exec;
|
|
68
|
+
if ((u = parseInt(u)) >= 0) {
|
|
69
|
+
uid = u;
|
|
70
|
+
}
|
|
71
|
+
if ((g = parseInt(g)) >= 0) {
|
|
72
|
+
gid = g;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
64
75
|
for (const args of taskArgs) {
|
|
65
76
|
if (instance.aborted) {
|
|
66
77
|
return Promise.reject((0, types_1.createAbortError)());
|
|
@@ -70,7 +81,7 @@ async function finalize(instance) {
|
|
|
70
81
|
await new Promise((resolve, reject) => {
|
|
71
82
|
this.formatMessage(4, title, ['Executing task...', task], baseDirectory);
|
|
72
83
|
let out = '', message = '';
|
|
73
|
-
const { stdout, stderr } = child_process.spawn(command, Document.sanitizeArgs(args), { cwd: baseDirectory, shell: true, stdio: Document.hasLogType(32768) && !broadcastId ? 'inherit' : undefined, signal: instance.signal })
|
|
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 })
|
|
74
85
|
.on('exit', code => {
|
|
75
86
|
if (!code) {
|
|
76
87
|
instance.addLog(types_1.STATUS_TYPE.INFO, out);
|
package/index.js
CHANGED
|
@@ -162,9 +162,9 @@ class AndroidDocument extends Document {
|
|
|
162
162
|
}
|
|
163
163
|
findTemplate(baseDir, filename, options) {
|
|
164
164
|
var _a;
|
|
165
|
-
let detect, languageOf;
|
|
165
|
+
let detect, languageOf, subDir;
|
|
166
166
|
if (options) {
|
|
167
|
-
({ detect, languageOf } = options);
|
|
167
|
+
({ detect, languageOf, subDir } = options);
|
|
168
168
|
}
|
|
169
169
|
let kotlin, language;
|
|
170
170
|
if (languageOf) {
|
|
@@ -178,7 +178,14 @@ class AndroidDocument extends Document {
|
|
|
178
178
|
const localUri = path.join(baseDir, filename);
|
|
179
179
|
try {
|
|
180
180
|
const existing = detect && fs.existsSync(localUri);
|
|
181
|
-
const paths =
|
|
181
|
+
const paths = [];
|
|
182
|
+
if (language) {
|
|
183
|
+
paths.push(language);
|
|
184
|
+
}
|
|
185
|
+
if (subDir) {
|
|
186
|
+
paths.push(...Array.isArray(subDir) ? subDir : [subDir]);
|
|
187
|
+
}
|
|
188
|
+
paths.push(filename);
|
|
182
189
|
let uri;
|
|
183
190
|
if (!existing && !(uri = this.resolveDir('template', ...paths)) && !fs.existsSync(uri = path.join(__dirname, 'template', ...paths))) {
|
|
184
191
|
throw (0, types_1.errorValue)("File not found", uri);
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ 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 } from '@e-mc/types/lib/settings';
|
|
5
|
+
import type { DocumentDirectory as IDocumentDirectory, DocumentModule as IDocumentModule, ExecAction } from '@e-mc/types/lib/settings';
|
|
6
6
|
|
|
7
7
|
import type { DocumentOutput } from './squared';
|
|
8
8
|
|
|
@@ -13,6 +13,7 @@ interface DocumentDirectory extends IDocumentDirectory {
|
|
|
13
13
|
interface AndroidDocumentSettings extends PlainObject {
|
|
14
14
|
extensions?: {
|
|
15
15
|
task?: {
|
|
16
|
+
exec?: ExecAction;
|
|
16
17
|
command?: string;
|
|
17
18
|
};
|
|
18
19
|
};
|
|
@@ -48,6 +49,7 @@ export interface TemplateData {
|
|
|
48
49
|
export interface FindTemplateOptions {
|
|
49
50
|
detect?: boolean;
|
|
50
51
|
languageOf?: LanguageType;
|
|
52
|
+
subDir?: ArrayOf<string>;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
export interface IAndroidDocument<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends IDocument<T, U>, Pick<DocumentOutput, DocumentProperties> {
|