@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.
@@ -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" /* MANIFEST.FILENAME */, { detect: this.incremental !== 'staging' });
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" /* MANIFEST.FILENAME */], err, 0 /* LOG_TYPE.UNKNOWN */);
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" /* MANIFEST.FILENAME */], err, 0 /* LOG_TYPE.UNKNOWN */);
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" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
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" /* GRADLE.FILENAME */, { detect, languageOf: '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 /* DEPENDENCY_TYPE.IMPLEMENTATION */;
81
+ type = 0;
83
82
  break;
84
83
  case 'provided':
85
- type = 2 /* DEPENDENCY_TYPE.COMPILE_ONLY */;
84
+ type = 2;
86
85
  break;
87
86
  case 'runtime':
88
- type = 4 /* DEPENDENCY_TYPE.RUNTIME_ONLY */;
87
+ type = 4;
89
88
  break;
90
89
  case 'test':
91
- type = 5 /* DEPENDENCY_TYPE.TEST_IMPLEMENTATION */;
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 /* DEPENDENCY_TYPE.IMPLEMENTATION */:
163
+ case 0:
165
164
  prefix = 'implementation';
166
165
  break;
167
- case 1 /* DEPENDENCY_TYPE.API */:
166
+ case 1:
168
167
  prefix = 'api';
169
168
  break;
170
- case 2 /* DEPENDENCY_TYPE.COMPILE_ONLY */:
169
+ case 2:
171
170
  prefix = 'compileOnly';
172
171
  break;
173
- case 3 /* DEPENDENCY_TYPE.COMPILE_ONLY_API */:
172
+ case 3:
174
173
  prefix = 'compileOnlyApi';
175
174
  break;
176
- case 4 /* DEPENDENCY_TYPE.RUNTIME_ONLY */:
175
+ case 4:
177
176
  prefix = 'runtimeOnly';
178
177
  break;
179
- case 5 /* DEPENDENCY_TYPE.TEST_IMPLEMENTATION */:
178
+ case 5:
180
179
  prefix = 'testImplementation';
181
180
  break;
182
- case 6 /* DEPENDENCY_TYPE.TEST_COMPILE_ONLY */:
181
+ case 6:
183
182
  prefix = 'testCompileOnly';
184
183
  break;
185
- case 7 /* DEPENDENCY_TYPE.TEST_RUNTIME_ONLY */:
184
+ case 7:
186
185
  prefix = 'testRuntimeOnly';
187
186
  break;
188
- case 8 /* DEPENDENCY_TYPE.ANDROID_TEST_IMPLEMENTATION */:
187
+ case 8:
189
188
  prefix = 'androidTestImplementation';
190
189
  break;
191
- case 9 /* DEPENDENCY_TYPE.ANDROID_TEST_COMPILE_ONLY */:
190
+ case 9:
192
191
  prefix = 'androidTestCompileOnly';
193
192
  break;
194
- case 10 /* DEPENDENCY_TYPE.ANDROID_TEST_RUNTIME_ONLY */:
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" /* VERSIONS.KOTLIN_STDLIB */)}'` });
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" /* VERSIONS.KOTLIN_COMPILER */)}'`, true);
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" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
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" /* GRADLE.FILENAME */, { detect, languageOf: 'gradle', subDir: 'static' }));
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" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
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" /* GRADLE.FILENAME */, { detect: this.incremental !== 'staging', languageOf: '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" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
74
+ this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
76
75
  }
77
76
  }
78
77
  }
@@ -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" /* STRINGS.GRADLEW */ && process.platform === 'win32' ? value + '.bat' : value;
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" /* STRINGS.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" /* STRINGS.GRADLEW */);
45
+ filename = checkWin32("gradlew");
47
46
  command = '.' + path.sep + filename;
48
- title = "gradle" /* STRINGS.GRADLE */;
49
- altname = "gradle" /* STRINGS.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 /* LOG_TYPE.PROCESS */, title, ['Executing task...', task], baseDirectory);
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 /* LOG_TYPE.STDOUT */) && !broadcastId ? 'inherit' : undefined, signal: instance.signal, uid, gid })
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" /* ERR_MESSAGE.EXECUTE_FILE */ : "Unknown" /* ERR_MESSAGE.UNKNOWN */), "Error code" /* ERR_MESSAGE.ERROR_CODE */ + ': ' + code));
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" /* ERR_MESSAGE.PERFORM_TASK */, command + ' ' + task], err, { type: 4 /* LOG_TYPE.PROCESS */, startTime }));
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/types/lib';
1
+ import type { IFileManager } from '@e-mc/types/lib';
2
2
 
3
- import type { AndroidDocumentConstructor, DocumentAsset } from './types';
3
+ import type { AndroidDocumentConstructor } from './types';
4
4
 
5
- declare const Android: AndroidDocumentConstructor<IFileManager<DocumentAsset>>;
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" /* ERR_MESSAGE.COMPRESS_FILE */, err, 8 /* LOG_TYPE.COMPRESS */);
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" /* ERR_MESSAGE.NOTFOUND_FILE */, uri);
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" /* ERR_MESSAGE.READ_FILE */, path.basename(localUri)], err, 32 /* LOG_TYPE.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" /* ERR_MESSAGE.READ_FILE */, path.basename(localUri)], err, 32 /* LOG_TYPE.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.4",
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.4",
24
- "@e-mc/types": "^0.8.4",
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
  }