@e-mc/document 0.1.0 → 0.3.0

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.
@@ -1,212 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const path = require("path");
4
- const util_1 = require("../../../../util");
5
- const types_1 = require("../../../../../types");
6
- const index_1 = require("../../../../index");
7
- function finalize(instance) {
8
- const config = instance.config;
9
- const { profileable, dependencies, dataBinding, versionName, versionCode } = config;
10
- if (!profileable && !dependencies && !dataBinding && !versionName && !versionCode && !config.namespace) {
11
- return;
12
- }
13
- let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir), 'build.gradle', { detect: !this.archiving, languageOf: 'gradle' });
14
- if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
15
- let { namespace, javaVersion } = config, jvmTarget, modified;
16
- const upgrade = javaVersion > 0;
17
- const setModified = (output) => {
18
- if (output !== source) {
19
- source = output;
20
- modified = true;
21
- }
22
- };
23
- if (dependencies) {
24
- const items = dependencies.map(item => item.split(':'));
25
- if (!kotlin && items.some(value => value[1].endsWith('-ktx'))) {
26
- setModified(index_1.default.updateGradle(source, ['plugins'], "id 'kotlin-android'", { multiple: true }));
27
- }
28
- const match = /dependencies\s+\{([^}]+)\}/.exec(source);
29
- if (match) {
30
- const writeImpl = (item) => 'implementation' + (kotlin ? `("${item.join(':')}")` : ` '${item.join(':')}'`);
31
- const pattern = kotlin ? /([ \t]*)implementation\((?:\s*"([^"]+)"\s*\))?/g : /([ \t]*)implementation(?:\s*\(?\s*["']([^"']+)["']\s*\)?|\s+((?:\s*(?:group|name|version)\s*:\s*["'][^"']+["']\s*,?){3}))?/g;
32
- let content = match[1], indent, impl;
33
- while (impl = pattern.exec(match[1])) {
34
- let group, name, version;
35
- if (impl[2]) {
36
- [group, name, version] = impl[2].trim().split(/\s*:\s*/);
37
- }
38
- else if (impl[3]) {
39
- const method = /(group|name|version)\s*:\s*["']([^"']+)["']/g;
40
- let param;
41
- while (param = method.exec(impl[3])) {
42
- const value = param[2].trim();
43
- switch (param[1]) {
44
- case 'group':
45
- group = value;
46
- break;
47
- case 'name':
48
- name = value;
49
- break;
50
- case 'version':
51
- version = value;
52
- break;
53
- }
54
- }
55
- }
56
- if (group && name) {
57
- let found = 0, index = -1;
58
- if (version) {
59
- index = items.findIndex(seg => seg[0] === group && seg[1] === name);
60
- if (index !== -1) {
61
- found = 1;
62
- if (version[0] !== '$' || !kotlin && impl[0].indexOf("'") !== -1) {
63
- const current = items[index][2].split('.').map(seg => +seg);
64
- const parts = version.split('.');
65
- for (let i = 0, value; i < parts.length; ++i) {
66
- if (isNaN(value = +parts[i]) || +current[i] > value) {
67
- found = 2;
68
- break;
69
- }
70
- }
71
- }
72
- }
73
- }
74
- if (found) {
75
- if (found === 2) {
76
- content = content.replace(impl[0].trim(), writeImpl(items[index]));
77
- modified = true;
78
- }
79
- items.splice(index, 1);
80
- }
81
- }
82
- if (impl[1]) {
83
- indent = impl[1];
84
- }
85
- }
86
- if (items.length) {
87
- indent || (indent = (0, util_1.getIndent)(source));
88
- content = items.reduce((a, b) => a + indent + writeImpl(b) + '\n', content);
89
- modified = true;
90
- }
91
- if (modified || !existing) {
92
- setModified(source.substring(0, match.index) + `dependencies {${content}}` + source.substring(match.index + match[0].length));
93
- }
94
- }
95
- if (items.some(value => value[0] === 'androidx.compose.ui')) {
96
- let output = source;
97
- if (kotlin) {
98
- output = index_1.default.updateGradle(output, ['plugins'], 'kotlin("android")');
99
- output = index_1.default.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
100
- }
101
- else {
102
- output = index_1.default.updateGradle(output, ['plugins'], "id 'org.jetbrains.kotlin.android'", { upgrade: true, multiple: true, addendum: `version '${instance.findVersion('org.jetbrains.kotlin:kotlin-stdlib', "1.8.10" /* VERSIONS.KOTLIN_STDLIB */)}'` });
103
- output = index_1.default.updateGradle(output, ['android', 'buildFeatures'], "compose true");
104
- output = index_1.default.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.4.3" /* VERSIONS.KOTLIN_COMPILER */)}'`, true);
105
- if (upgrade) {
106
- output = index_1.default.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
107
- }
108
- else {
109
- output = index_1.default.updateGradle(output, ['android', 'kotlinOptions'], "jvmTarget = '1.8'");
110
- jvmTarget = '1_8';
111
- }
112
- }
113
- setModified(output);
114
- }
115
- }
116
- if (upgrade || jvmTarget) {
117
- const compatibility = 'JavaVersion.VERSION_' + (upgrade ? javaVersion.toString().replace(/\./g, '_') : jvmTarget);
118
- let output = source;
119
- if (kotlin) {
120
- output = index_1.default.updateGradle(output, ['java'], 'sourceCompatibility = ' + compatibility, upgrade);
121
- output = index_1.default.updateGradle(output, ['java'], 'targetCompatibility = ' + compatibility, upgrade);
122
- output = index_1.default.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = "${javaVersion}"`, upgrade);
123
- }
124
- else {
125
- output = index_1.default.updateGradle(output, ['android', 'compileOptions'], 'sourceCompatibility ' + compatibility, upgrade);
126
- output = index_1.default.updateGradle(output, ['android', 'compileOptions'], 'targetCompatibility ' + compatibility, upgrade);
127
- }
128
- setModified(output);
129
- }
130
- if (!existing) {
131
- const targetAPI = instance.targetAPI;
132
- let output = source;
133
- if (targetAPI) {
134
- const values = typeof targetAPI === 'string' ? [`"android-${targetAPI}"`, `"${targetAPI}"`] : [targetAPI, targetAPI];
135
- const updateOnly = +targetAPI >= 31;
136
- let revised = index_1.default.updateGradle(output, ['android'], kotlin ? `compileSdkVersion(${values[0]})` : 'compileSdkVersion ' + values[0], { upgrade: true, updateOnly });
137
- if (revised === output) {
138
- output = index_1.default.updateGradle(output, ['android'], kotlin ? `compileSdk(${values[0]})` : 'compileSdk ' + values[0], true);
139
- }
140
- else {
141
- output = revised;
142
- }
143
- revised = index_1.default.updateGradle(output, ['android', 'defaultConfig'], kotlin ? `targetSdkVersion(${values[1]})` : 'targetSdkVersion ' + values[1], { upgrade: true, updateOnly });
144
- if (revised === output) {
145
- output = index_1.default.updateGradle(output, ['android', 'defaultConfig'], kotlin ? `targetSdk(${values[1]})` : 'targetSdk ' + values[1], true);
146
- }
147
- else {
148
- output = revised;
149
- }
150
- const version = instance.findVersion('buildToolsVersion');
151
- if (version) {
152
- output = index_1.default.updateGradle(output, ['android'], kotlin ? `buildToolsVersion = "${version}"` : `buildToolsVersion "${version}"`, true);
153
- }
154
- }
155
- if (namespace || (namespace = config.manifest?.package)) {
156
- output = index_1.default.updateGradle(output, ['android', 'defaultConfig'], (kotlin ? 'applicationId = ' : 'applicationId ') + `"${namespace}"`, true);
157
- }
158
- setModified(output);
159
- }
160
- if (dataBinding) {
161
- setModified(index_1.default.updateGradle(source, ['android', 'buildFeatures'], kotlin ? 'dataBinding = true' : 'dataBinding true', true));
162
- }
163
- if (namespace) {
164
- setModified(index_1.default.updateGradle(source, ['android'], (kotlin ? 'namespace = ' : 'namespace ') + `"${namespace}"`, true));
165
- }
166
- if (profileable) {
167
- let name, items;
168
- if (Array.isArray(profileable)) {
169
- if (profileable.length && !profileable[0].startsWith('--')) {
170
- name = profileable.shift();
171
- }
172
- items = profileable;
173
- }
174
- else if (typeof profileable === 'string') {
175
- if (profileable.startsWith('--')) {
176
- items = [profileable];
177
- }
178
- else {
179
- name = profileable;
180
- }
181
- }
182
- name || (name = 'debug');
183
- setModified(index_1.default.updateGradle(source, ['android', 'buildTypes', kotlin ? 'getByName("release")' : 'release'], 'signingConfig ' + (kotlin ? `= signingConfigs.getByName("${name}")` : 'signingConfigs.' + name), true));
184
- if ((0, types_1.isArray)(items)) {
185
- const parameters = items.map(value => `"${value}"`).join(', ');
186
- setModified(index_1.default.updateGradle(source, ['android', 'aaptOptions'], 'additionalParameters ' + (kotlin ? `= [${parameters}]` : parameters), true));
187
- }
188
- }
189
- if (versionName) {
190
- setModified(index_1.default.updateGradle(source, ['android', 'defaultConfig'], (kotlin ? 'versionName = ' : 'versionName ') + `"${versionName}"`, true));
191
- }
192
- if (versionCode) {
193
- setModified(index_1.default.updateGradle(source, ['android', 'defaultConfig'], (kotlin ? 'versionCode = ' : 'versionCode ') + versionCode, true));
194
- }
195
- if (modified || !existing) {
196
- try {
197
- if (instance.writeFile(localUri, source, { encoding: 'utf-8', ownPermissionOnly: true, throwsPermission: true }) && !existing) {
198
- this.add(localUri);
199
- }
200
- }
201
- catch (err) {
202
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
203
- }
204
- }
205
- }
206
- }
207
- exports.default = finalize;
208
-
209
- if (exports.default) {
210
- module.exports = exports.default;
211
- module.exports.default = exports.default;
212
- }
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const path = require("path");
4
- const util_1 = require("../../../../util");
5
- const parse_1 = require("../../../../parse");
6
- function finalize(instance) {
7
- const { dependencies, projectName, mainParentDir } = instance.config;
8
- if (!dependencies && !projectName) {
9
- return;
10
- }
11
- let { localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, 'settings.gradle', { detect: !this.archiving, languageOf: 'gradle' });
12
- if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
13
- const targetName = projectName ? projectName.replace(/"/g, '\\"') : '';
14
- let modified;
15
- if (existing) {
16
- let match;
17
- if (dependencies) {
18
- found: {
19
- const pattern = kotlin ? /^\s*include\(((?:\s*"[^"]+"\s*,?\s*)+)\)/gm : /^\s*include\s*((?:(?:"[^"]+"|'[^']+')\s*,?\s*)+)/gm;
20
- while (match = pattern.exec(source)) {
21
- const namespace = /":?([^"]+)"|':?([^']+)'/g;
22
- let app;
23
- while (app = namespace.exec(match[1])) {
24
- if (app[1] === mainParentDir || app[2] === mainParentDir) {
25
- break found;
26
- }
27
- }
28
- }
29
- pattern.lastIndex = 0;
30
- if (match = pattern.exec(source)) {
31
- const index = match.index + match[0].length;
32
- if (kotlin) {
33
- source = source.substring(0, index - 1).trimEnd() + `, "${mainParentDir}")` + source.substring(index);
34
- }
35
- else {
36
- source = parse_1.XmlWriter.replaceMatch(match, source, `, '${mainParentDir}'`, { trimLeading: true });
37
- }
38
- modified = true;
39
- }
40
- }
41
- }
42
- if (targetName) {
43
- const value = `rootProject.name = "${targetName}"`;
44
- if (match = new RegExp('^\\s*rootProject\\.name\\s*=\\s*' + parse_1.XmlWriter.PATTERN_QUOTEVALUE, 'm').exec(source)) {
45
- source = parse_1.XmlWriter.replaceMatch(match, source, value);
46
- }
47
- else {
48
- source += (0, util_1.getNewline)(source) + value;
49
- }
50
- modified = true;
51
- }
52
- }
53
- else {
54
- source = (0, util_1.replaceAll)(source, (name) => {
55
- switch (name) {
56
- case 'projectName':
57
- return targetName;
58
- case 'name':
59
- return ':' + mainParentDir;
60
- default:
61
- return '';
62
- }
63
- });
64
- }
65
- if (modified || !existing) {
66
- try {
67
- if (instance.writeFile(localUri, source, { encoding: 'utf-8', ownPermissionOnly: true, throwsPermission: true }) && !existing) {
68
- this.add(localUri);
69
- }
70
- }
71
- catch (err) {
72
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
73
- }
74
- }
75
- }
76
- }
77
- exports.default = finalize;
78
-
79
- if (exports.default) {
80
- module.exports = exports.default;
81
- module.exports.default = exports.default;
82
- }
@@ -1,110 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const path = require("path");
4
- const fs = require("fs");
5
- const child_process = require("child_process");
6
- const types_1 = require("../../../../types");
7
- const module_1 = require("../../../../module");
8
- async function finalize(instance) {
9
- const commands = instance.config.commands;
10
- if (!commands || this.archiving) {
11
- return;
12
- }
13
- let taskArgs;
14
- if (typeof commands === 'string') {
15
- taskArgs = [[commands]];
16
- }
17
- else if ((0, types_1.isArray)(commands)) {
18
- if (commands.every(value => typeof value === 'string')) {
19
- taskArgs = [commands];
20
- }
21
- else {
22
- taskArgs = commands.map(value => typeof value === 'string' ? [value] : value);
23
- }
24
- }
25
- else {
26
- return;
27
- }
28
- let { broadcastId, baseDirectory } = this, command = instance.settings.extensions?.task?.command, title, name, foundCwd;
29
- if (command) {
30
- if (command.indexOf('mvn') !== -1) {
31
- title = 'maven';
32
- }
33
- else {
34
- title = /([^\\/]+?)(?:\.[a-z]+)?$/i.exec(command)?.[1] || 'SPAWN';
35
- }
36
- command = path.normalize(command);
37
- if (!command.includes(path.sep)) {
38
- name = command;
39
- }
40
- command = module_1.default.sanitizeCmd(command);
41
- }
42
- else {
43
- name = 'gradlew';
44
- command = '.' + path.sep + name;
45
- title = 'gradle';
46
- }
47
- if (name) {
48
- try {
49
- let appDir = baseDirectory;
50
- while (!(foundCwd = fs.existsSync(path.join(appDir, name)))) {
51
- const parent = path.dirname(appDir);
52
- if (parent === appDir) {
53
- break;
54
- }
55
- appDir = parent;
56
- }
57
- if (foundCwd) {
58
- baseDirectory = appDir;
59
- }
60
- }
61
- catch {
62
- }
63
- }
64
- for (const args of taskArgs) {
65
- if (instance.aborted) {
66
- return Promise.reject((0, types_1.createAbortError)());
67
- }
68
- const startTime = process.hrtime();
69
- const task = args.join(' ');
70
- await new Promise((resolve, reject) => {
71
- this.formatMessage(4 /* LOG_TYPE.PROCESS */, title, ['Executing task...', task], baseDirectory);
72
- let out = '', message = '';
73
- const { stdout, stderr } = child_process.spawn(command, module_1.default.sanitizeArgs(args), { cwd: baseDirectory, shell: true, stdio: module_1.default.hasLogType(32768 /* LOG_TYPE.STDOUT */) && !broadcastId ? 'inherit' : undefined, signal: instance.signal })
74
- .on('exit', code => {
75
- if (!code) {
76
- instance.addLog(types_1.STATUS_TYPE.INFO, out);
77
- this.writeTimeProcess(title, 'Success -> ' + task, startTime);
78
- resolve();
79
- }
80
- else {
81
- reject((0, types_1.errorValue)(message || (!foundCwd && code === 1 ? "Unable to execute file" /* ERR_MESSAGE.EXECUTE_FILE */ : "Unknown" /* ERR_MESSAGE.UNKNOWN */), "Error code" /* ERR_MESSAGE.ERROR_CODE */ + ': ' + code));
82
- }
83
- })
84
- .on('error', err => reject(err));
85
- if (stdout) {
86
- stdout.setEncoding('utf-8').on('data', (value) => {
87
- if (broadcastId) {
88
- this.formatMessage(types_1.STATUS_TYPE.INFO, '', value, null, { sessionId: '' });
89
- }
90
- out += value;
91
- });
92
- }
93
- if (stderr) {
94
- stderr.setEncoding('utf-8').on('data', (value) => {
95
- if (broadcastId) {
96
- this.formatMessage(types_1.STATUS_TYPE.ERROR, '', value, null, { sessionId: '' });
97
- }
98
- message += value;
99
- });
100
- }
101
- })
102
- .catch(err => instance.writeFail(["Unable to perform task" /* ERR_MESSAGE.PERFORM_TASK */, command + ' ' + task], err, { type: 4 /* LOG_TYPE.PROCESS */, startTime }));
103
- }
104
- }
105
- exports.default = finalize;
106
-
107
- if (exports.default) {
108
- module.exports = exports.default;
109
- module.exports.default = exports.default;
110
- }
@@ -1,7 +0,0 @@
1
- import type { IFileManager } from '../../types/lib';
2
-
3
- import type { AndroidDocumentConstructor, DocumentAsset } from './document';
4
-
5
- declare const Android: AndroidDocumentConstructor<IFileManager<DocumentAsset>>;
6
-
7
- export = Android;
package/android/index.js DELETED
@@ -1,217 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fs = require("fs");
4
- const path = require("path");
5
- const types_1 = require("../../types");
6
- const index_1 = require("../index");
7
- class AndroidDocument extends index_1.default {
8
- constructor() {
9
- super(...arguments);
10
- this.config = {
11
- mainParentDir: 'app',
12
- mainSrcDir: 'src/main',
13
- mainActivityFile: '',
14
- javaVersion: 0,
15
- dataBinding: false,
16
- projectName: undefined,
17
- versionName: undefined,
18
- versionCode: 0,
19
- manifest: undefined,
20
- namespace: undefined,
21
- profileable: undefined,
22
- dependencies: undefined,
23
- commands: undefined
24
- };
25
- this.elements = [];
26
- this.extensionData = {};
27
- this._moduleName = 'android';
28
- this._threadable = true;
29
- }
30
- static async finalize(instance) {
31
- if (instance.aborted) {
32
- return Promise.reject((0, types_1.createAbortError)());
33
- }
34
- if (instance.extensions.length) {
35
- const config = instance.config;
36
- const mainActivityFile = config.mainActivityFile;
37
- if (mainActivityFile && !path.isAbsolute(mainActivityFile)) {
38
- let pathname = /[\\/]/.test(mainActivityFile) && path.join(this.baseDirectory, mainActivityFile);
39
- if (pathname && index_1.default.isPath(pathname)) {
40
- config.mainActivityFile = pathname;
41
- }
42
- else {
43
- const directories = [this.baseDirectory, config.mainParentDir, config.mainSrcDir];
44
- do {
45
- if (index_1.default.isPath(pathname = path.join(...directories.concat(mainActivityFile)))) {
46
- config.mainActivityFile = pathname;
47
- break;
48
- }
49
- directories.pop();
50
- } while (directories.length);
51
- }
52
- }
53
- }
54
- return super.finalize.call(this, instance);
55
- }
56
- init(assets, config) {
57
- if (config) {
58
- const { targetAPI, mainParentDir, mainSrcDir, mainActivityFile, javaVersion, projectName, versionName, versionCode = 0, manifest, namespace, profileable, dependencies, dataBinding, commands, directories, elements, extensionData } = config;
59
- const target = this.config;
60
- if (projectName) {
61
- target.projectName = projectName;
62
- }
63
- if (namespace) {
64
- target.namespace = namespace;
65
- }
66
- if (mainParentDir) {
67
- target.mainParentDir = mainParentDir;
68
- }
69
- if (mainSrcDir) {
70
- target.mainSrcDir = mainSrcDir;
71
- }
72
- if (mainActivityFile) {
73
- target.mainActivityFile = mainActivityFile;
74
- }
75
- if (versionName) {
76
- target.versionName = versionName;
77
- }
78
- if (manifest) {
79
- target.manifest = manifest;
80
- }
81
- if (profileable !== undefined) {
82
- target.profileable = profileable;
83
- }
84
- if (versionCode >= 1) {
85
- target.versionCode = Math.min(Math.ceil(versionCode), 2100000000);
86
- }
87
- if (commands) {
88
- target.commands = commands;
89
- }
90
- if (javaVersion) {
91
- target.javaVersion = +(typeof javaVersion === 'string' ? javaVersion.toString().replace(/_/g, '.') : javaVersion);
92
- }
93
- if (dataBinding) {
94
- target.dataBinding = true;
95
- }
96
- if ((0, types_1.isArray)(dependencies)) {
97
- target.dependencies = dependencies;
98
- }
99
- if (targetAPI) {
100
- this.targetAPI = targetAPI;
101
- }
102
- if ((0, types_1.isPlainObject)(directories)) {
103
- this.directories = directories;
104
- }
105
- if ((0, types_1.isArray)(elements)) {
106
- this.elements = elements;
107
- }
108
- if ((0, types_1.isPlainObject)(extensionData)) {
109
- this.extensionData = extensionData;
110
- }
111
- }
112
- return super.init(assets, config);
113
- }
114
- findVersion(name, fallback) {
115
- const targetAPI = this.targetAPI;
116
- if (targetAPI) {
117
- if (!Array.isArray(name)) {
118
- name = [name];
119
- }
120
- for (let i = 0; i < name.length; i += 2) {
121
- name.splice(i, 0, name[i] + '-' + targetAPI);
122
- }
123
- }
124
- return super.findVersion(name, fallback);
125
- }
126
- async using(data) {
127
- if (this.aborted) {
128
- return Promise.reject((0, types_1.createAbortError)());
129
- }
130
- const { host, file } = data;
131
- const localUri = file.localUri;
132
- switch (file.mimeType) {
133
- case 'font/unknown':
134
- switch (await host.findMime(file, true)) {
135
- case 'font/ttf':
136
- case 'font/otf':
137
- return;
138
- case 'font/woff':
139
- case 'font/woff2':
140
- break;
141
- default:
142
- host.deleteFile(localUri);
143
- return;
144
- }
145
- case 'font/woff':
146
- case 'font/woff2': {
147
- const instance = host.loadModule('compress');
148
- const buffer = host.getBuffer(file);
149
- if (instance && buffer) {
150
- await instance.tryFile(buffer, localUri, { format: 'ttf', etag: file.etag }, (err, result) => {
151
- if (err) {
152
- host.deleteFile(localUri);
153
- host.writeFail("Unable to compress file" /* ERR_MESSAGE.COMPRESS_FILE */, err, 8 /* LOG_TYPE.COMPRESS */);
154
- }
155
- else if ((0, types_1.isString)(result)) {
156
- host.replace(file, result);
157
- }
158
- });
159
- }
160
- break;
161
- }
162
- }
163
- }
164
- findTemplate(baseDir, filename, options) {
165
- let detect, languageOf;
166
- if (options) {
167
- ({ detect, languageOf } = options);
168
- }
169
- let kotlin, language;
170
- if (languageOf) {
171
- kotlin = (language = this.settings.language?.[languageOf]) === 'kotlin';
172
- const isKts = this.detectKts(baseDir, filename);
173
- detect = isKts !== null && (kotlin && isKts || !kotlin && !isKts);
174
- if (kotlin) {
175
- filename += '.kts';
176
- }
177
- }
178
- const localUri = path.join(baseDir, filename);
179
- try {
180
- const existing = detect && fs.existsSync(localUri);
181
- const paths = language ? [language, filename] : [filename];
182
- let uri;
183
- if (!existing && !(uri = this.resolveDir('template', ...paths)) && !fs.existsSync(uri = path.join(__dirname, 'template', ...paths))) {
184
- throw (0, types_1.errorValue)("File not found" /* ERR_MESSAGE.NOTFOUND_FILE */, uri);
185
- }
186
- return { localUri, source: fs.readFileSync(uri || localUri, 'utf-8'), existing, kotlin, language };
187
- }
188
- catch (err) {
189
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(localUri)], err, 32 /* LOG_TYPE.FILE */);
190
- }
191
- return { kotlin, language };
192
- }
193
- detectKts(...paths) {
194
- try {
195
- const file = path.join(...paths);
196
- if (fs.existsSync(file)) {
197
- return false;
198
- }
199
- if (fs.existsSync(file + '.kts')) {
200
- return true;
201
- }
202
- }
203
- catch {
204
- }
205
- return null;
206
- }
207
- get settings() {
208
- var _a;
209
- return (_a = this.module).settings || (_a.settings = {});
210
- }
211
- }
212
- exports.default = AndroidDocument;
213
-
214
- if (exports.default) {
215
- module.exports = exports.default;
216
- module.exports.default = exports.default;
217
- }
@@ -1,23 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="{{package}}">
3
-
4
- <application
5
- android:icon="@mipmap/ic_launcher"
6
- android:label="{{label}}"
7
- android:supportsRtl="{{supportsRtl}}"
8
- android:theme="{{theme}}">
9
- <activity
10
- android:name="{{activityName}}"
11
- android:exported="true"
12
- android:label="{{label}}"
13
- android:theme="{{theme}}">
14
- <intent-filter>
15
- <action android:name="android.intent.action.MAIN" />
16
-
17
- <category android:name="android.intent.category.LAUNCHER" />
18
- </intent-filter>
19
- </activity>
20
- <profileable android:shell="true" android:enabled="{{profileable}}" />
21
- </application>
22
-
23
- </manifest>