Skip to content

Commit c6e9b8e

Browse files
authored
Merge pull request #3 from wtto00/dev
fix: type error
2 parents 7741001 + 7bd61d1 commit c6e9b8e

File tree

13 files changed

+132
-112
lines changed

13 files changed

+132
-112
lines changed

.eslintrc.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
"quotes": ["error", "single"],
2222
"semi": ["error", "always"],
2323
"@typescript-eslint/ban-types": "off",
24-
"@typescript-eslint/prefer-nullish-coalescing": "off"
24+
"@typescript-eslint/prefer-nullish-coalescing": "off",
25+
"@typescript-eslint/no-unsafe-assignment": "off",
26+
"@typescript-eslint/no-unsafe-call": "off",
27+
"@typescript-eslint/no-unsafe-member-access": "off"
2528
}
2629
}

.github/workflows/test-publish.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: 'TestPublish'
22
on:
33
pull_request:
44
push:
5-
branches:
6-
- main
75
tags:
86
- 'v*'
97

README-ZH_CN.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ android
134134
});
135135
```
136136

137-
| field | type | required | default | note |
138-
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------- | ----------------------------------------------------------------------------------- |
139-
| apiLevel | number | false | - | 平台系统镜像的API级别 - 例如,Android Marshmallow的级别为23,Android 10的级别为29。 |
140-
| target | 'default'<br>'google_apis'<br>'playstore'<br>'android-wear'<br>'android-wear-cn'<br>'android-tv'<br>'google-tv'<br>'aosp_atd '<br>'google_atd' | false | 'default' | 系统镜像的目标。 |
141-
| arch | 'x86_64'<br>'x86'<br>'arm64-v8a'<br>'armeabi-v7a' | false | 'x86_64' | 系统镜像的CPU架构 |
142-
| package | string | true | - | 此模拟器的系统镜像的路径(例如 'system-images;android-19;google_apis;x86')。 |
143-
| name | string | false | - | 新模拟器的名称。 |
144-
| force | boolean | false | - | 创建虚拟设备(覆盖现有的模拟器)。 |
137+
| field | type | required | default | note |
138+
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------------- | ----------------------------------------------------------------------------------- |
139+
| apiLevel | number | false | - | 平台系统镜像的API级别 - 例如,Android Marshmallow的级别为23,Android 10的级别为29。 |
140+
| target | 'default'<br>'google_apis'<br>'playstore'<br>'android-wear'<br>'android-wear-cn'<br>'android-tv'<br>'google-tv'<br>'aosp_atd '<br>'google_atd' | false | 'default' | 系统镜像的目标。 |
141+
| arch | 'x86_64'<br>'x86'<br>'arm64-v8a'<br>'armeabi-v7a' | false | 当前系统CPU架构 | 系统镜像的CPU架构 |
142+
| package | string | true | - | 此模拟器的系统镜像的路径(例如 'system-images;android-19;google_apis;x86')。 |
143+
| name | string | false | - | 新模拟器的名称。 |
144+
| force | boolean | false | - | 创建虚拟设备(覆盖现有的模拟器)。 |
145145

146146
- 如果你传了`package`,则参数`apiLevel``target``arch`将被会略。如果你没有传参`package`,则`apiLevel`参数是必须的。
147147

@@ -361,7 +361,7 @@ android
361361
.then((res) => {
362362
res.forEach((item) => {
363363
console.log(
364-
`name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, vendor: ${item.vendor}, arch: ${item.arch}`
364+
`name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, target: ${item.target}, arch: ${item.arch}`
365365
);
366366
});
367367
})
@@ -380,7 +380,7 @@ android
380380
.then((res) => {
381381
res.forEach((item) => {
382382
console.log(
383-
`name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, vendor: ${item.vendor}, arch: ${item.arch}`
383+
`name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, target: ${item.target}, arch: ${item.arch}`
384384
);
385385
});
386386
})

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ android
134134
});
135135
```
136136

137-
| field | type | required | default | note |
138-
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------- | ------------------------------------------------------------------------------------------------ |
139-
| apiLevel | number | false | - | API level of the platform system image - e.g. 23 for Android Marshmallow, 29 for Android 10. |
140-
| target | 'default'<br>'google_apis'<br>'playstore'<br>'android-wear'<br>'android-wear-cn'<br>'android-tv'<br>'google-tv'<br>'aosp_atd '<br>'google_atd' | false | 'default' | Target of the system image . |
141-
| arch | 'x86_64'<br>'x86'<br>'arm64-v8a'<br>'armeabi-v7a' | false | 'x86_64' | CPU architecture of the system image |
142-
| package | string | false | - | Package path of the system image for this AVD (e.g. 'system-images;android-19;google_apis;x86'). |
143-
| name | string | false | - | Name of the new AVD. |
144-
| force | boolean | false | - | Forces creation (overwrites an existing AVD) |
137+
| field | type | required | default | note |
138+
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------- | ------------------------------------------------------------------------------------------------ |
139+
| apiLevel | number | false | - | API level of the platform system image - e.g. 23 for Android Marshmallow, 29 for Android 10. |
140+
| target | 'default'<br>'google_apis'<br>'playstore'<br>'android-wear'<br>'android-wear-cn'<br>'android-tv'<br>'google-tv'<br>'aosp_atd '<br>'google_atd' | false | 'default' | Target of the system image . |
141+
| arch | 'x86_64'<br>'x86'<br>'arm64-v8a'<br>'armeabi-v7a' | false | Current system CPU architecture | CPU architecture of the system image |
142+
| package | string | false | - | Package path of the system image for this AVD (e.g. 'system-images;android-19;google_apis;x86'). |
143+
| name | string | false | - | Name of the new AVD. |
144+
| force | boolean | false | - | Forces creation (overwrites an existing AVD) |
145145

146146
- If you pass a `package`, the parameters `apiLevel`, `target`, and `arch` will be ignored. If you don't pass a `package`, the `apiLevel` parameter is required.
147147

@@ -361,7 +361,7 @@ android
361361
.then((res) => {
362362
res.forEach((item) => {
363363
console.log(
364-
`name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, vendor: ${item.vendor}, arch: ${item.arch}`
364+
`name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, target: ${item.target}, arch: ${item.arch}`
365365
);
366366
});
367367
})
@@ -380,7 +380,7 @@ android
380380
.then((res) => {
381381
res.forEach((item) => {
382382
console.log(
383-
`name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, vendor: ${item.vendor}, arch: ${item.arch}`
383+
`name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, target: ${item.target}, arch: ${item.arch}`
384384
);
385385
});
386386
})

package.json

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
{
22
"name": "@wtto00/android-tools",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Node module for managing and controlling the Android Devices.",
55
"type": "module",
6-
"main": "dist/lib/index.js",
7-
"module": "dist/esm/index.js",
6+
"main": "dist/lib/index.cjs",
7+
"module": "dist/esm/index.mjs",
88
"types": "dist/index.d.ts",
99
"exports": {
1010
".": {
11-
"import": "./dist/esm/index.js",
12-
"require": "./dist/lib/index.js",
11+
"import": "./dist/esm/index.mjs",
12+
"require": "./dist/lib/index.cjs",
1313
"types": "./dist/index.d.ts"
14-
},
15-
"./util": {
16-
"import": "./dist/esm/util.js",
17-
"require": "./dist/lib/util.js",
18-
"types": "./dist/util.d.ts"
1914
}
2015
},
2116
"files": [
@@ -53,10 +48,12 @@
5348
"@rollup/plugin-commonjs": "^25.0.4",
5449
"@rollup/plugin-node-resolve": "^15.2.1",
5550
"@rollup/plugin-typescript": "^11.1.3",
51+
"@types/debug": "^4.1.9",
5652
"@types/jest": "^29.5.4",
5753
"@types/node": "^20.6.1",
5854
"@typescript-eslint/eslint-plugin": "^6.7.0",
5955
"@typescript-eslint/parser": "^6.7.0",
56+
"debug": "^4.3.4",
6057
"eslint": "^8.49.0",
6158
"husky": "^8.0.3",
6259
"jest": "^29.7.0",

pnpm-lock.yaml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rollup.config.mjs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,16 @@ import commonjs from '@rollup/plugin-commonjs';
66

77
export default defineConfig([
88
{
9-
input: ['src/index.ts', 'src/util.ts'],
9+
input: 'src/index.ts',
1010
output: [
11-
{ dir: 'dist/esm', format: 'esm' },
12-
{ dir: 'dist/lib', format: 'cjs' }
11+
{ file: 'dist/esm/index.mjs', format: 'esm' },
12+
{ file: 'dist/lib/index.cjs', format: 'cjs' }
1313
],
1414
plugins: [typescript(), resolve(), commonjs()]
1515
},
1616
{
1717
input: 'src/index.ts',
1818
output: [{ file: 'dist/index.d.ts', format: 'esm' }],
1919
plugins: [resolve(), commonjs(), dts({ respectExternal: true })]
20-
},
21-
{
22-
input: 'src/util.ts',
23-
output: [{ file: 'dist/util.d.ts', format: 'esm' }],
24-
plugins: [resolve(), commonjs(), dts({ respectExternal: true })]
2520
}
2621
]);

spec/afterStart.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import path from 'path';
22
import Android from '../src/index.js';
3-
import { EmulatorGpu } from '../src/emulator.js';
43

54
const android = new Android();
65

@@ -10,21 +9,20 @@ beforeAll(async () => {
109
let avdName = '';
1110
if (avds.length === 0) {
1211
avdName = `TestCreate_${Math.random().toString().substring(2)}`;
13-
const images = (await android.listImages()).filter((item) => item.vendor === 'default' && item.arch === 'x86_64');
12+
const images = (await android.listImages()).filter((item) => item.target === 'default' && item.arch === 'x86_64');
1413
if (images.length === 0) return;
1514
await android.createAVD({ name: avdName, apiLevel: 31, force: false });
1615
} else {
1716
avdName = avds[0].Name;
1817
}
1918
const res = await android.start({
2019
avd: avdName,
21-
verbose: true,
2220
noaudio: true,
2321
noBootAnim: true,
2422
noSnapshot: true,
2523
noSnapshotSave: true,
2624
noWindow: true,
27-
gpu: EmulatorGpu.SWIFTSHADER_INDIRECT
25+
gpu: 'swiftshader_indirect'
2826
});
2927
emulatorId = res.id;
3028
if (emulatorId) {

spec/emulatorAVD.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('emulator AVD', () => {
55

66
test('create AVD', async () => {
77
const avdName = `TestCreate_${Math.random()}`;
8-
const images = (await android.listInstalledImages()).filter((item) => item.vendor === 'default');
8+
const images = (await android.listInstalledImages()).filter((item) => item.target === 'default');
99
if (images.length === 0) return;
1010
await android.createAVD({ name: avdName, package: images[images.length - 1].name, force: false });
1111
const res = await android.hasAVD(avdName);
@@ -16,7 +16,7 @@ describe('emulator AVD', () => {
1616
test('create an existing AVD', async () => {
1717
const avds = await android.listAVDs();
1818
if (avds.length === 0) return;
19-
const images = (await android.listInstalledImages()).filter((item) => item.vendor === 'default');
19+
const images = (await android.listInstalledImages()).filter((item) => item.target === 'default');
2020
if (images.length === 0) return;
2121
await expect(async () => {
2222
await android.createAVD({ name: avds[0].Name, package: images[images.length - 1].name });
@@ -26,7 +26,7 @@ describe('emulator AVD', () => {
2626
test('force create an existing AVD', async () => {
2727
const avds = await android.listAVDs();
2828
if (avds.length === 0) return;
29-
const images = (await android.listInstalledImages()).filter((item) => item.vendor === 'default');
29+
const images = (await android.listInstalledImages()).filter((item) => item.target === 'default');
3030
if (images.length === 0) return;
3131
await android.createAVD({ name: avds[0].Name, package: images[images.length - 1].name, force: true });
3232
const res = await android.hasAVD(avds[0].Name);

spec/start.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ describe('start', () => {
66
test('start a non-existent AVD.', async () => {
77
await expect(async () => {
88
await android.start({
9-
verbose: true,
109
avd: `${Math.random()}`,
1110
noaudio: true,
1211
noBootAnim: true,

0 commit comments

Comments
 (0)