Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: type error #3

Merged
merged 2 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"quotes": ["error", "single"],
"semi": ["error", "always"],
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off"
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off"
}
}
2 changes: 0 additions & 2 deletions .github/workflows/test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: 'TestPublish'
on:
pull_request:
push:
branches:
- main
tags:
- 'v*'

Expand Down
20 changes: 10 additions & 10 deletions README-ZH_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ android
});
```

| field | type | required | default | note |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------- | ----------------------------------------------------------------------------------- |
| apiLevel | number | false | - | 平台系统镜像的API级别 - 例如,Android Marshmallow的级别为23,Android 10的级别为29。 |
| 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' | 系统镜像的目标。 |
| arch | 'x86_64'<br>'x86'<br>'arm64-v8a'<br>'armeabi-v7a' | false | 'x86_64' | 系统镜像的CPU架构 |
| package | string | true | - | 此模拟器的系统镜像的路径(例如 'system-images;android-19;google_apis;x86')。 |
| name | string | false | - | 新模拟器的名称。 |
| force | boolean | false | - | 创建虚拟设备(覆盖现有的模拟器)。 |
| field | type | required | default | note |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------------- | ----------------------------------------------------------------------------------- |
| apiLevel | number | false | - | 平台系统镜像的API级别 - 例如,Android Marshmallow的级别为23,Android 10的级别为29。 |
| 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' | 系统镜像的目标。 |
| arch | 'x86_64'<br>'x86'<br>'arm64-v8a'<br>'armeabi-v7a' | false | 当前系统CPU架构 | 系统镜像的CPU架构 |
| package | string | true | - | 此模拟器的系统镜像的路径(例如 'system-images;android-19;google_apis;x86')。 |
| name | string | false | - | 新模拟器的名称。 |
| force | boolean | false | - | 创建虚拟设备(覆盖现有的模拟器)。 |

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

Expand Down Expand Up @@ -361,7 +361,7 @@ android
.then((res) => {
res.forEach((item) => {
console.log(
`name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, vendor: ${item.vendor}, arch: ${item.arch}`
`name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, target: ${item.target}, arch: ${item.arch}`
);
});
})
Expand All @@ -380,7 +380,7 @@ android
.then((res) => {
res.forEach((item) => {
console.log(
`name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, vendor: ${item.vendor}, arch: ${item.arch}`
`name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, target: ${item.target}, arch: ${item.arch}`
);
});
})
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ android
});
```

| field | type | required | default | note |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------- | ------------------------------------------------------------------------------------------------ |
| apiLevel | number | false | - | API level of the platform system image - e.g. 23 for Android Marshmallow, 29 for Android 10. |
| 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 . |
| arch | 'x86_64'<br>'x86'<br>'arm64-v8a'<br>'armeabi-v7a' | false | 'x86_64' | CPU architecture of the system image |
| package | string | false | - | Package path of the system image for this AVD (e.g. 'system-images;android-19;google_apis;x86'). |
| name | string | false | - | Name of the new AVD. |
| force | boolean | false | - | Forces creation (overwrites an existing AVD) |
| field | type | required | default | note |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------- | ------------------------------------------------------------------------------------------------ |
| apiLevel | number | false | - | API level of the platform system image - e.g. 23 for Android Marshmallow, 29 for Android 10. |
| 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 . |
| arch | 'x86_64'<br>'x86'<br>'arm64-v8a'<br>'armeabi-v7a' | false | Current system CPU architecture | CPU architecture of the system image |
| package | string | false | - | Package path of the system image for this AVD (e.g. 'system-images;android-19;google_apis;x86'). |
| name | string | false | - | Name of the new AVD. |
| force | boolean | false | - | Forces creation (overwrites an existing AVD) |

- 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.

Expand Down Expand Up @@ -361,7 +361,7 @@ android
.then((res) => {
res.forEach((item) => {
console.log(
`name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, vendor: ${item.vendor}, arch: ${item.arch}`
`name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, target: ${item.target}, arch: ${item.arch}`
);
});
})
Expand All @@ -380,7 +380,7 @@ android
.then((res) => {
res.forEach((item) => {
console.log(
`name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, vendor: ${item.vendor}, arch: ${item.arch}`
`name: ${item.name}, type: ${item.type}, sdk: ${item.sdk}, target: ${item.target}, arch: ${item.arch}`
);
});
})
Expand Down
17 changes: 7 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
{
"name": "@wtto00/android-tools",
"version": "1.0.1",
"version": "1.0.2",
"description": "Node module for managing and controlling the Android Devices.",
"type": "module",
"main": "dist/lib/index.js",
"module": "dist/esm/index.js",
"main": "dist/lib/index.cjs",
"module": "dist/esm/index.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/lib/index.js",
"import": "./dist/esm/index.mjs",
"require": "./dist/lib/index.cjs",
"types": "./dist/index.d.ts"
},
"./util": {
"import": "./dist/esm/util.js",
"require": "./dist/lib/util.js",
"types": "./dist/util.d.ts"
}
},
"files": [
Expand Down Expand Up @@ -53,10 +48,12 @@
"@rollup/plugin-commonjs": "^25.0.4",
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-typescript": "^11.1.3",
"@types/debug": "^4.1.9",
"@types/jest": "^29.5.4",
"@types/node": "^20.6.1",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"debug": "^4.3.4",
"eslint": "^8.49.0",
"husky": "^8.0.3",
"jest": "^29.7.0",
Expand Down
18 changes: 18 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,16 @@ import commonjs from '@rollup/plugin-commonjs';

export default defineConfig([
{
input: ['src/index.ts', 'src/util.ts'],
input: 'src/index.ts',
output: [
{ dir: 'dist/esm', format: 'esm' },
{ dir: 'dist/lib', format: 'cjs' }
{ file: 'dist/esm/index.mjs', format: 'esm' },
{ file: 'dist/lib/index.cjs', format: 'cjs' }
],
plugins: [typescript(), resolve(), commonjs()]
},
{
input: 'src/index.ts',
output: [{ file: 'dist/index.d.ts', format: 'esm' }],
plugins: [resolve(), commonjs(), dts({ respectExternal: true })]
},
{
input: 'src/util.ts',
output: [{ file: 'dist/util.d.ts', format: 'esm' }],
plugins: [resolve(), commonjs(), dts({ respectExternal: true })]
}
]);
6 changes: 2 additions & 4 deletions spec/afterStart.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import path from 'path';
import Android from '../src/index.js';
import { EmulatorGpu } from '../src/emulator.js';

const android = new Android();

Expand All @@ -10,21 +9,20 @@ beforeAll(async () => {
let avdName = '';
if (avds.length === 0) {
avdName = `TestCreate_${Math.random().toString().substring(2)}`;
const images = (await android.listImages()).filter((item) => item.vendor === 'default' && item.arch === 'x86_64');
const images = (await android.listImages()).filter((item) => item.target === 'default' && item.arch === 'x86_64');
if (images.length === 0) return;
await android.createAVD({ name: avdName, apiLevel: 31, force: false });
} else {
avdName = avds[0].Name;
}
const res = await android.start({
avd: avdName,
verbose: true,
noaudio: true,
noBootAnim: true,
noSnapshot: true,
noSnapshotSave: true,
noWindow: true,
gpu: EmulatorGpu.SWIFTSHADER_INDIRECT
gpu: 'swiftshader_indirect'
});
emulatorId = res.id;
if (emulatorId) {
Expand Down
6 changes: 3 additions & 3 deletions spec/emulatorAVD.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('emulator AVD', () => {

test('create AVD', async () => {
const avdName = `TestCreate_${Math.random()}`;
const images = (await android.listInstalledImages()).filter((item) => item.vendor === 'default');
const images = (await android.listInstalledImages()).filter((item) => item.target === 'default');
if (images.length === 0) return;
await android.createAVD({ name: avdName, package: images[images.length - 1].name, force: false });
const res = await android.hasAVD(avdName);
Expand All @@ -16,7 +16,7 @@ describe('emulator AVD', () => {
test('create an existing AVD', async () => {
const avds = await android.listAVDs();
if (avds.length === 0) return;
const images = (await android.listInstalledImages()).filter((item) => item.vendor === 'default');
const images = (await android.listInstalledImages()).filter((item) => item.target === 'default');
if (images.length === 0) return;
await expect(async () => {
await android.createAVD({ name: avds[0].Name, package: images[images.length - 1].name });
Expand All @@ -26,7 +26,7 @@ describe('emulator AVD', () => {
test('force create an existing AVD', async () => {
const avds = await android.listAVDs();
if (avds.length === 0) return;
const images = (await android.listInstalledImages()).filter((item) => item.vendor === 'default');
const images = (await android.listInstalledImages()).filter((item) => item.target === 'default');
if (images.length === 0) return;
await android.createAVD({ name: avds[0].Name, package: images[images.length - 1].name, force: true });
const res = await android.hasAVD(avds[0].Name);
Expand Down
1 change: 0 additions & 1 deletion spec/start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ describe('start', () => {
test('start a non-existent AVD.', async () => {
await expect(async () => {
await android.start({
verbose: true,
avd: `${Math.random()}`,
noaudio: true,
noBootAnim: true,
Expand Down
Loading
Loading