@pi-r/android 0.8.2 → 0.9.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,5 +1,5 @@
1
1
  "use strict";
2
- const path = require("path");
2
+ const path = require("node:path");
3
3
  const htmlparser2 = require("htmlparser2");
4
4
  const domhandler = require("domhandler");
5
5
  const domutils = require("domutils");
@@ -19,7 +19,7 @@ function finalize(instance) {
19
19
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
20
20
  const { supportsRtl, label, theme, activity, metaData = [], activityName, fontProvider } = manifest.application || {};
21
21
  const profileable = config.profileable;
22
- let modified;
22
+ let modified = false;
23
23
  if (!existing) {
24
24
  source = (0, util_1.replaceAll)(source, (name) => {
25
25
  switch (name) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const path = require("path");
3
- const fs = require("fs");
2
+ const path = require("node:path");
3
+ const fs = require("node:fs");
4
4
  const Document = require("@e-mc/document");
5
5
  const types_1 = require("@e-mc/types");
6
6
  const util_1 = require("@e-mc/document/util");
@@ -99,7 +99,7 @@ function finalize(instance) {
99
99
  let { localUri, source, existing, kotlin = false, language } = instance.findTemplate(path.join(this.baseDirectory, mainParentDir), "build.gradle", { detect: instance.detect(this), languageOf: 'gradle' });
100
100
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
101
101
  const javaVersion = instance.config.javaVersion;
102
- let jvmTarget, modified;
102
+ let jvmTarget, modified = false;
103
103
  const upgrade = javaVersion > 0;
104
104
  const setModified = (output) => {
105
105
  if (output !== source) {
@@ -138,7 +138,7 @@ function finalize(instance) {
138
138
  continue;
139
139
  }
140
140
  if (target.dependencies) {
141
- let found;
141
+ let found = false;
142
142
  for (const { groupId, artifactId, version, scope } of target.dependencies) {
143
143
  if (scope && (dependencyScopes === true || dependencyScopes === 1 || hasScope(scope))) {
144
144
  let type = -1;
@@ -225,9 +225,9 @@ function finalize(instance) {
225
225
  const newLine = source.includes('\r\n') ? '\r\n' : '\n';
226
226
  const gradleDir = path.join(this.baseDirectory, 'gradle');
227
227
  const template = instance.findTemplate(gradleDir, "libs.versions.toml", { detect: true, subDir: kotlin ? 'kotlin' : undefined, throwsDoesNotExist: false });
228
- let content = match[1], named = false, versioning, indent;
228
+ let content = match[1], named = false, versioning = false, indent;
229
229
  if (template.localUri && template.source) {
230
- versioning = kotlin && versionCatalog !== false || versionCatalog;
230
+ versioning = kotlin && versionCatalog !== false || !!versionCatalog;
231
231
  if (versioning || template.existing) {
232
232
  const libraries = {};
233
233
  const versions = {};
@@ -424,11 +424,11 @@ function finalize(instance) {
424
424
  output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
425
425
  }
426
426
  else {
427
- const stdLib = instance.findVersion('org.jetbrains.kotlin:kotlin-stdlib', "2.0.20");
427
+ const stdLib = instance.findVersion('org.jetbrains.kotlin:kotlin-stdlib', "2.1.0");
428
428
  output = Document.updateGradle(output, ['plugins'], "id 'org.jetbrains.kotlin.android'", { upgrade: true, multiple: true, addendum: `version '${stdLib}'` });
429
429
  output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
430
430
  if (stdLib.startsWith('1.')) {
431
- output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.14")}'`, true);
431
+ output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.15")}'`, true);
432
432
  }
433
433
  if (upgrade) {
434
434
  output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
@@ -470,7 +470,7 @@ function finalize(instance) {
470
470
  let output = source;
471
471
  if (targetAPI) {
472
472
  const values = typeof targetAPI === 'string' ? [`"android-${targetAPI}"`, `"${targetAPI}"`] : [targetAPI, targetAPI];
473
- const updateOnly = +targetAPI >= 31;
473
+ const updateOnly = +targetAPI >= +"33";
474
474
  let revised = Document.updateGradle(output, ['android'], kotlin ? `compileSdkVersion(${values[0]})` : 'compileSdkVersion ' + values[0], { upgrade: true, updateOnly });
475
475
  if (revised === output) {
476
476
  output = Document.updateGradle(output, ['android'], kotlin ? `compileSdk(${values[0]})` : 'compileSdk ' + values[0], true);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
- const path = require("path");
3
- const util_1 = require("@e-mc/document/util");
2
+ const path = require("node:path");
4
3
  const parse_1 = require("@e-mc/document/parse");
4
+ const util_1 = require("@e-mc/document/util");
5
5
  function finalize(instance) {
6
6
  const { dependencies, projectName, mainParentDir } = instance.config;
7
7
  if (!dependencies && !projectName) {
@@ -10,7 +10,7 @@ function finalize(instance) {
10
10
  let { localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "settings.gradle", { detect: instance.detect(this), languageOf: 'gradle' });
11
11
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
12
12
  const targetName = projectName?.replace(/"/g, '\\"');
13
- let modified;
13
+ let modified = false;
14
14
  if (existing) {
15
15
  let match;
16
16
  if (dependencies) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
- const path = require("path");
3
- const fs = require("fs");
4
- const child_process = require("child_process");
2
+ const path = require("node:path");
3
+ const fs = require("node:fs");
4
+ const child_process = require("node:child_process");
5
5
  const which = require("which");
6
6
  const Document = require("@e-mc/document");
7
7
  const types_1 = require("@e-mc/types");
@@ -28,15 +28,16 @@ async function finalize(instance) {
28
28
  }
29
29
  const settings = instance.settings.extensions?.task || {};
30
30
  const exec = settings.exec;
31
- let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title, filename, altname, foundDir;
31
+ let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title, filename, altname, foundDir = false;
32
32
  if (command) {
33
+ command = path.normalize(command);
33
34
  if (command.includes('mvn')) {
34
35
  title = "maven";
35
36
  }
36
37
  else {
37
- title = /([^\\/]+?)(?:\.[a-z]+)?$/i.exec(command)?.[1] || 'spawn';
38
+ title = new RegExp(`([^${path.sep === '\\' ? '\\\\' : '/'}]+?)(?:\\.[a-z]+)?$`, 'i').exec(command)?.[1] || 'spawn';
38
39
  }
39
- if (!/[\\/]/.test(command = path.normalize(command))) {
40
+ if (!command.includes(path.sep)) {
40
41
  filename = checkWin32(command);
41
42
  }
42
43
  command = Document.sanitizeCmd(command);
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const fs = require("fs");
3
- const path = require("path");
2
+ const fs = require("node:fs");
3
+ const path = require("node:path");
4
4
  const types_1 = require("@e-mc/types");
5
5
  const Document = require('@e-mc/document');
6
6
  class AndroidDocument extends Document {
@@ -10,9 +10,9 @@ class AndroidDocument extends Document {
10
10
  }
11
11
  if (instance.extensions.length > 0) {
12
12
  const config = instance.config;
13
- const mainActivityFile = config.mainActivityFile;
14
- if (mainActivityFile && !path.isAbsolute(mainActivityFile)) {
15
- let pathname = /[\\/]/.test(mainActivityFile) && path.join(this.baseDirectory, mainActivityFile);
13
+ let mainActivityFile = config.mainActivityFile;
14
+ if (mainActivityFile && !path.isAbsolute(mainActivityFile = path.normalize(mainActivityFile))) {
15
+ let pathname = mainActivityFile.includes(path.sep) && path.join(this.baseDirectory, mainActivityFile);
16
16
  if (pathname && Document.isPath(pathname)) {
17
17
  config.mainActivityFile = pathname;
18
18
  }
@@ -188,7 +188,7 @@ class AndroidDocument extends Document {
188
188
  if (options) {
189
189
  ({ detect, languageOf, subDir } = options);
190
190
  }
191
- let kotlin, language;
191
+ let kotlin = false, language;
192
192
  if (languageOf) {
193
193
  kotlin = (language = this.languageOf(languageOf)) === 'kotlin';
194
194
  if (detect !== false) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/android",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "description": "Android document constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -14,16 +14,18 @@
14
14
  },
15
15
  "keywords": [
16
16
  "squared",
17
- "e-mc",
18
- "squared-functions"
17
+ "e-mc"
19
18
  ],
20
19
  "author": "An Pham <anpham6@gmail.com>",
21
20
  "license": "MIT",
22
21
  "homepage": "https://github.com/anpham6/pi-r#readme",
23
22
  "dependencies": {
24
- "@e-mc/document": "^0.10.2",
25
- "@e-mc/types": "^0.10.2",
23
+ "@e-mc/document": "^0.11.0",
24
+ "@e-mc/types": "^0.11.0",
25
+ "dom-serializer": "*",
26
+ "domhandler": "*",
27
+ "domutils": "*",
26
28
  "htmlparser2": "^9.1.0",
27
- "which": "^2.0.2"
29
+ "which": "^4.0.0"
28
30
  }
29
31
  }
@@ -1,4 +1,4 @@
1
- plugins {
2
- id 'com.android.application' version '8.5.2' apply false
3
- id 'com.android.library' version '8.5.2' apply false
1
+ plugins {
2
+ id 'com.android.application' version '8.7.3' apply false
3
+ id 'com.android.library' version '8.7.3' apply false
4
4
  }
@@ -25,19 +25,19 @@ android {
25
25
  }
26
26
  }
27
27
  compileOptions {
28
- sourceCompatibility JavaVersion.VERSION_1_8
29
- targetCompatibility JavaVersion.VERSION_1_8
28
+ sourceCompatibility JavaVersion.VERSION_11
29
+ targetCompatibility JavaVersion.VERSION_11
30
30
  }
31
31
  kotlinOptions {
32
- jvmTarget = '1.8'
32
+ jvmTarget = '11'
33
33
  }
34
34
  buildFeatures {
35
- viewBinding false
35
+ viewBinding true
36
36
  }
37
37
  }
38
38
 
39
39
  dependencies {
40
- implementation 'androidx.core:core-ktx:1.13.1'
40
+ implementation 'androidx.core:core-ktx:1.15.0'
41
41
  testImplementation 'junit:junit:4.13.2'
42
42
  androidTestImplementation 'androidx.test.ext:junit:1.1.5'
43
43
  androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
@@ -1,6 +1,12 @@
1
1
  pluginManagement {
2
2
  repositories {
3
- google()
3
+ google {
4
+ content {
5
+ includeGroupByRegex("com\\.android.*")
6
+ includeGroupByRegex("com\\.google.*")
7
+ includeGroupByRegex("androidx.*")
8
+ }
9
+ }
4
10
  mavenCentral()
5
11
  gradlePluginPortal()
6
12
  }
@@ -1,5 +1,5 @@
1
- plugins {
2
- id 'com.android.application' version '8.5.2' apply false
3
- id 'com.android.library' version '8.5.2' apply false
4
- id 'org.jetbrains.kotlin.android' version '1.9.25' apply false
1
+ plugins {
2
+ id 'com.android.application' version '8.7.3' apply false
3
+ id 'com.android.library' version '8.7.3' apply false
4
+ id 'org.jetbrains.kotlin.android' version '2.1.0' apply false
5
5
  }
@@ -34,8 +34,8 @@ android {
34
34
  }
35
35
 
36
36
  java {
37
- sourceCompatibility = JavaVersion.VERSION_1_8
38
- targetCompatibility = JavaVersion.VERSION_1_8
37
+ sourceCompatibility = JavaVersion.VERSION_11
38
+ targetCompatibility = JavaVersion.VERSION_11
39
39
  }
40
40
 
41
41
  dependencies {
@@ -1,23 +1,23 @@
1
- [versions]
2
- agp = "8.5.2"
3
- kotlin = "2.0.20"
4
- coreKtx = "1.13.1"
5
- junit = "4.13.2"
6
- junitVersion = "1.2.1"
7
- espressoCore = "3.6.1"
8
- appcompat = "1.7.0"
9
- constraintlayout = "2.1.4"
10
-
11
- [libraries]
12
- androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
13
- jetbrains-kotlin = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" }
14
- junit = { group = "junit", name = "junit", version.ref = "junit" }
15
- androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
16
- androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
17
- androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
18
- androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
19
-
20
- [plugins]
21
- android-application = { id = "com.android.application", version.ref = "agp" }
22
- jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
23
- jetbrains-kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
1
+ [versions]
2
+ agp = "8.7.3"
3
+ kotlin = "2.1.0"
4
+ coreKtx = "1.15.0"
5
+ junit = "4.13.2"
6
+ junitVersion = "1.2.1"
7
+ espressoCore = "3.6.1"
8
+ appcompat = "1.7.0"
9
+ constraintlayout = "2.2.0"
10
+
11
+ [libraries]
12
+ androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
13
+ jetbrains-kotlin = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" }
14
+ junit = { group = "junit", name = "junit", version.ref = "junit" }
15
+ androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
16
+ androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
17
+ androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
18
+ androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
19
+
20
+ [plugins]
21
+ android-application = { id = "com.android.application", version.ref = "agp" }
22
+ jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
23
+ jetbrains-kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
@@ -2,7 +2,13 @@ val snapshotVersion : String? = System.getenv("ANDROIDX_SNAPSHOT_ID")
2
2
 
3
3
  pluginManagement {
4
4
  repositories {
5
- google()
5
+ google {
6
+ content {
7
+ includeGroupByRegex("com\\.android.*")
8
+ includeGroupByRegex("com\\.google.*")
9
+ includeGroupByRegex("androidx.*")
10
+ }
11
+ }
6
12
  mavenCentral()
7
13
  gradlePluginPortal()
8
14
  }
package/types/index.d.ts CHANGED
@@ -1,80 +1,80 @@
1
- import type { DocumentConstructor, IDocument, IFileManager } from '@e-mc/types/lib';
2
- import type { ExternalAsset } from '@e-mc/types/lib/asset';
3
- import type { ExecAction, DocumentDirectory as IDocumentDirectory, DocumentModule as IDocumentModule, DocumentSettings as IDocumentSettings } from '@e-mc/types/lib/settings';
4
-
5
- import type { DependencyScopes, DocumentOutput, FinalizedElement } from './squared';
6
-
7
- interface DocumentDirectory extends IDocumentDirectory {
8
- template?: string;
9
- project?: string;
10
- }
11
-
12
- interface AndroidDocumentSettings extends Pick<IDocumentSettings, "users" | "directory">, PlainObject {
13
- extensions?: {
14
- task?: {
15
- exec?: ExecAction;
16
- command?: string;
17
- };
18
- };
19
- language?: {
20
- [T in LanguageOfType]?: LanguageType;
21
- };
22
- }
23
-
24
- type DocumentProperties = "targetAPI" | "elements" | "extensionData" | "directories";
25
-
26
- export interface UserConfig extends Omit<DocumentOutput, DocumentProperties> {
27
- mainParentDir: string;
28
- mainSrcDir: string;
29
- mainActivityFile: string;
30
- javaVersion: number;
31
- dataBinding: boolean;
32
- }
33
-
34
- export interface DocumentModule extends IDocumentModule {
35
- settings?: AndroidDocumentSettings;
36
- }
37
-
38
- export interface TemplateData {
39
- localUri?: string;
40
- source?: string;
41
- existing?: boolean;
42
- kotlin?: boolean;
43
- language?: LanguageType;
44
- }
45
-
46
- export interface FindTemplateOptions {
47
- detect?: boolean;
48
- languageOf?: LanguageOfType;
49
- subDir?: ArrayOf<string>;
50
- throwsDoesNotExist?: boolean;
51
- }
52
-
53
- export interface MavenArtifact {
54
- groupId: string;
55
- artifactId: string;
56
- version: string;
57
- scope?: DependencyScopes;
58
- dependencies?: MavenArtifact[];
59
- }
60
-
61
- export type LanguageType = "java" | "kotlin" | "java+kotlin";
62
- export type LanguageOfType = "gradle";
63
- export type DocumentAsset = ExternalAsset;
64
-
65
- export interface IAndroidDocument<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends IDocument<T, U, DocumentModule>, Pick<DocumentOutput, DocumentProperties> {
66
- config: UserConfig;
67
- elements: FinalizedElement[];
68
- extensionData: PlainObject;
69
- findTemplate(baseDir: string, filename: string, options?: FindTemplateOptions): TemplateData;
70
- findData<V = AnyObject>(filename: string, format?: string): Null<V>;
71
- languageOf(name: LanguageOfType, value?: LanguageType): Undef<LanguageType>;
72
- detectKts(...paths: string[]): Null<boolean>;
73
- detect(host?: T): boolean;
74
- get settings(): AndroidDocumentSettings;
75
- }
76
-
77
- export interface AndroidDocumentConstructor<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends ConstructorDerived<DocumentConstructor<T, U>> {
78
- readonly prototype: IAndroidDocument<T, U>;
79
- new(module?: DocumentModule, ...args: unknown[]): IAndroidDocument<T, U>;
1
+ import type { DocumentConstructor, IDocument, IFileManager } from '@e-mc/types/lib';
2
+ import type { ExternalAsset } from '@e-mc/types/lib/asset';
3
+ import type { ExecAction, DocumentDirectory as IDocumentDirectory, DocumentModule as IDocumentModule, DocumentSettings as IDocumentSettings } from '@e-mc/types/lib/settings';
4
+
5
+ import type { DependencyScopes, DocumentOutput, FinalizedElement } from './squared';
6
+
7
+ interface DocumentDirectory extends IDocumentDirectory {
8
+ template?: string;
9
+ project?: string;
10
+ }
11
+
12
+ interface AndroidDocumentSettings extends Pick<IDocumentSettings, "users" | "directory">, PlainObject {
13
+ extensions?: {
14
+ task?: {
15
+ exec?: ExecAction;
16
+ command?: string;
17
+ };
18
+ };
19
+ language?: {
20
+ [T in LanguageOfType]?: LanguageType;
21
+ };
22
+ }
23
+
24
+ type DocumentProperties = "targetAPI" | "elements" | "extensionData" | "directories";
25
+
26
+ export interface UserConfig extends Omit<DocumentOutput, DocumentProperties> {
27
+ mainParentDir: string;
28
+ mainSrcDir: string;
29
+ mainActivityFile: string;
30
+ javaVersion: number;
31
+ dataBinding: boolean;
32
+ }
33
+
34
+ export interface DocumentModule extends IDocumentModule {
35
+ settings?: AndroidDocumentSettings;
36
+ }
37
+
38
+ export interface TemplateData {
39
+ localUri?: string;
40
+ source?: string;
41
+ existing?: boolean;
42
+ kotlin?: boolean;
43
+ language?: LanguageType;
44
+ }
45
+
46
+ export interface FindTemplateOptions {
47
+ detect?: boolean;
48
+ languageOf?: LanguageOfType;
49
+ subDir?: string | string[];
50
+ throwsDoesNotExist?: boolean;
51
+ }
52
+
53
+ export interface MavenArtifact {
54
+ groupId: string;
55
+ artifactId: string;
56
+ version: string;
57
+ scope?: DependencyScopes;
58
+ dependencies?: MavenArtifact[];
59
+ }
60
+
61
+ export type LanguageType = "java" | "kotlin" | "java+kotlin";
62
+ export type LanguageOfType = "gradle";
63
+ export type DocumentAsset = ExternalAsset;
64
+
65
+ export interface IAndroidDocument<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends IDocument<T, U, DocumentModule>, Pick<DocumentOutput, DocumentProperties> {
66
+ config: UserConfig;
67
+ elements: FinalizedElement[];
68
+ extensionData: PlainObject;
69
+ findTemplate(baseDir: string, filename: string, options?: FindTemplateOptions): TemplateData;
70
+ findData<V = AnyObject>(filename: string, format?: string): V | null;
71
+ languageOf(name: LanguageOfType, value?: LanguageType): LanguageType | undefined;
72
+ detectKts(...paths: string[]): boolean | null;
73
+ detect(host?: T): boolean;
74
+ get settings(): AndroidDocumentSettings;
75
+ }
76
+
77
+ export interface AndroidDocumentConstructor<T extends IFileManager<U>, U extends DocumentAsset = DocumentAsset> extends ConstructorDerived<DocumentConstructor<T, U>> {
78
+ readonly prototype: IAndroidDocument<T, U>;
79
+ new(module?: DocumentModule, ...args: unknown[]): IAndroidDocument<T, U>;
80
80
  }