mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-09-03 19:09:32 +00:00
Compare commits
71 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 76c2bf6f95 | |||
| 08a23a6229 | |||
| 5bd7b4aaec | |||
| 1e2ef7249a | |||
| 3045dbfaba | |||
| 4e0dd2c343 | |||
| 62d97062b0 | |||
| e35fd713f4 | |||
| 48744f2073 | |||
| 5b2310fbf0 | |||
| d15e7110de | |||
| cc46524d3f | |||
| a86d743e55 | |||
| 066fd9b4b0 | |||
| 9216c92cd9 | |||
| 219361aa4a | |||
| 2b2ebf2e51 | |||
| d203cdc3fb | |||
| 8896ab3615 | |||
| 8f0c30aea2 | |||
| d1f5d2c017 | |||
| d0dfd56912 | |||
| 7f2c89a896 | |||
| 1424075cfd | |||
| 0bc3ba22b5 | |||
| acdb69812b | |||
| f71c6d1f84 | |||
| 511d462729 | |||
| d83fb3d4fb | |||
| 1427331a62 | |||
| 1ded27b164 | |||
| 217e44e3c5 | |||
| 31d8d4204a | |||
| a5bc682448 | |||
| 4d1a61ed38 | |||
| 1bf9f17bc6 | |||
| 5de26e4bd2 | |||
| 5e487dbdfe | |||
| 08852ad83b | |||
| 25bcfbab74 | |||
| ac874f3db5 | |||
| 0c3db9cd7a | |||
| eba1fbfb59 | |||
| 6e775ef330 | |||
| 8a4333421e | |||
| 50ef0172a3 | |||
| 97449e998a | |||
| fe99eb10f3 | |||
| 6fa269535d | |||
| 9b7af03883 | |||
| 854ed15ed0 | |||
| 98e515da59 | |||
| 9e81ae6235 | |||
| 6f33a98fa4 | |||
| e94dda8413 | |||
| 226f26251f | |||
| 43421164e2 | |||
| a3d693d819 | |||
| 5e38ea2647 | |||
| 080a93d5e1 | |||
| 98e4e00ead | |||
| 599839e428 | |||
| 751bef68f6 | |||
| bbf0887eb9 | |||
| 84b9418977 | |||
| a732f125bb | |||
| 5201a33a90 | |||
| cf46dc4c18 | |||
| f790770d0f | |||
| 505c899f12 | |||
| 0d47f0813d |
@@ -1,6 +1,8 @@
|
|||||||
name: Main workflow
|
name: Main workflow
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
@@ -18,6 +20,7 @@ jobs:
|
|||||||
os: [macos-latest, ubuntu-latest]
|
os: [macos-latest, ubuntu-latest]
|
||||||
api-level: [16, 23, 29]
|
api-level: [16, 23, 29]
|
||||||
target: [default, google_apis]
|
target: [default, google_apis]
|
||||||
|
arch: [x86]
|
||||||
exclude:
|
exclude:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
api-level: 23
|
api-level: 23
|
||||||
@@ -30,15 +33,18 @@ jobs:
|
|||||||
- target: google_apis
|
- target: google_apis
|
||||||
api-level: 29
|
api-level: 29
|
||||||
include:
|
include:
|
||||||
- os: macos-11.0
|
|
||||||
api-level: 30
|
|
||||||
target: google_apis
|
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
api-level: 24
|
api-level: 24
|
||||||
target: playstore
|
target: playstore
|
||||||
|
arch: x86
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
api-level: 28
|
api-level: 30
|
||||||
|
target: aosp_atd
|
||||||
|
arch: x86
|
||||||
|
- os: macos-11
|
||||||
|
api-level: 31
|
||||||
target: google_apis
|
target: google_apis
|
||||||
|
arch: x86_64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
@@ -59,26 +65,55 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
java-version: 15
|
java-version: 15
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
|
id: avd-cache
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.gradle/caches
|
~/.android/avd/*
|
||||||
~/.gradle/wrapper
|
~/.android/adb*
|
||||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
~/.android/debug.keystore
|
||||||
|
key: avd-${{ matrix.api-level }}-${{ matrix.os }}-${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: assemble tests
|
||||||
|
uses: gradle/gradle-build-action@v2
|
||||||
|
with:
|
||||||
|
build-root-directory: test-fixture
|
||||||
|
arguments: assembleAndroidTest
|
||||||
|
|
||||||
|
- name: run emulator to generate snapshot for caching
|
||||||
|
if: steps.avd-cache.outputs.cache-hit != 'true'
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
api-level: ${{ matrix.api-level }}
|
||||||
|
target: ${{ matrix.target }}
|
||||||
|
arch: ${{ matrix.arch }}
|
||||||
|
profile: Galaxy Nexus
|
||||||
|
cores: 2
|
||||||
|
sdcard-path-or-size: 100M
|
||||||
|
avd-name: test
|
||||||
|
force-avd-creation: false
|
||||||
|
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||||
|
disable-animations: false
|
||||||
|
working-directory: ./test-fixture/
|
||||||
|
channel: canary
|
||||||
|
script: echo "Generated AVD snapshot for caching."
|
||||||
|
|
||||||
- name: run action
|
- name: run action
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
api-level: ${{ matrix.api-level }}
|
api-level: ${{ matrix.api-level }}
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
arch: x86
|
arch: ${{ matrix.arch }}
|
||||||
profile: Nexus 6
|
profile: Galaxy Nexus
|
||||||
cores: 2
|
cores: 2
|
||||||
|
ram-size: 2048M
|
||||||
sdcard-path-or-size: 100M
|
sdcard-path-or-size: 100M
|
||||||
avd-name: test
|
avd-name: test
|
||||||
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none
|
force-avd-creation: false
|
||||||
|
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||||
disable-animations: true
|
disable-animations: true
|
||||||
working-directory: ./test-fixture/
|
working-directory: ./test-fixture/
|
||||||
|
channel: canary
|
||||||
script: |
|
script: |
|
||||||
echo $GITHUB_REPOSITORY
|
echo $GITHUB_REPOSITORY
|
||||||
adb devices
|
adb devices
|
||||||
./gradlew help
|
|
||||||
./gradlew connectedDebugAndroidTest
|
./gradlew connectedDebugAndroidTest
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
name: Manually triggered workflow
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
os:
|
||||||
|
description: 'OS'
|
||||||
|
required: true
|
||||||
|
default: 'macos-latest'
|
||||||
|
api-level:
|
||||||
|
description: 'API level of the platform and system image'
|
||||||
|
required: true
|
||||||
|
default: '30'
|
||||||
|
target:
|
||||||
|
description: 'target of the system image - default, google_apis, google_apis_playstore, aosp_atd, google_atd, android-wear, android-wear-cn, android-tv or google-tv'
|
||||||
|
required: true
|
||||||
|
default: 'default'
|
||||||
|
arch:
|
||||||
|
description: 'CPU architecture of the system image - x86, x86_64 or arm64-v8a'
|
||||||
|
default: 'x86'
|
||||||
|
emulator-options:
|
||||||
|
description: 'command-line options used when launching the emulator'
|
||||||
|
default: '-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim'
|
||||||
|
emulator-build:
|
||||||
|
description: 'build number of a specific version of the emulator binary to use'
|
||||||
|
channel:
|
||||||
|
description: 'Channel to download the SDK components from - `stable`, `beta`, `dev`, `canary`'
|
||||||
|
default: 'stable'
|
||||||
|
script:
|
||||||
|
description: 'custom script to run - e.g. `./gradlew connectedCheck`'
|
||||||
|
required: true
|
||||||
|
default: './gradlew connectedDebugAndroidTest'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ${{ github.event.inputs.os }}
|
||||||
|
env:
|
||||||
|
JAVA_TOOL_OPTIONS: -Xmx4g
|
||||||
|
timeout-minutes: 15
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: validate gradle wrapper
|
||||||
|
uses: gradle/wrapper-validation-action@v1
|
||||||
|
|
||||||
|
- name: build, test and lint
|
||||||
|
run: |
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
npm run lint
|
||||||
|
npm test
|
||||||
|
|
||||||
|
- name: Java 15
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 15
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches
|
||||||
|
~/.gradle/wrapper
|
||||||
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
||||||
|
|
||||||
|
- name: run action
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
api-level: ${{ github.event.inputs.api-level }}
|
||||||
|
target: ${{ github.event.inputs.target }}
|
||||||
|
arch: ${{ github.event.inputs.arch }}
|
||||||
|
profile: Galaxy Nexus
|
||||||
|
emulator-options: ${{ github.event.inputs.emulator-options }}
|
||||||
|
emulator-build: ${{ github.event.inputs.emulator-build }}
|
||||||
|
channel: ${{ github.event.inputs.channel }}
|
||||||
|
working-directory: ./test-fixture/
|
||||||
|
script: ${{ github.event.inputs.script }}
|
||||||
@@ -1,5 +1,58 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## v2.23.0
|
||||||
|
|
||||||
|
* Update build tools to `32.0.0`. - [#212](https://github.com/ReactiveCircus/android-emulator-runner/pull/212)
|
||||||
|
* Update SDK command-line tools to `6.0`. - [#213](https://github.com/ReactiveCircus/android-emulator-runner/pull/213)
|
||||||
|
* Add option to specify `disk-size` for the AVD. - [#219](https://github.com/ReactiveCircus/android-emulator-runner/pull/219) @ViliusSutkus89.
|
||||||
|
* Improve logging by grouping log lines. - [#224](https://github.com/ReactiveCircus/android-emulator-runner/pull/224) @michaelkaye.
|
||||||
|
|
||||||
|
## v2.22.0
|
||||||
|
|
||||||
|
* Add option to enable hardware keyboard. - [#209](https://github.com/ReactiveCircus/android-emulator-runner/pull/209) (upstreamed from the [Doist fork](https://github.com/Doist/android-emulator-runner/commit/4b6ca99f0d657662beca3eb0c22d8e254fbd5b31)).
|
||||||
|
* Update README and fix typos. - [#203](https://github.com/ReactiveCircus/android-emulator-runner/pull/203) @JPrendy.
|
||||||
|
|
||||||
|
## v2.21.0
|
||||||
|
|
||||||
|
* Support new [ATD](https://developer.android.com/studio/preview/features#gmd-atd) targets optimized to reduce CPU and memory resources when running instrumented tests: `aosp_atd`, `google_atd`. - [#198](https://github.com/ReactiveCircus/android-emulator-runner/pull/198). Note that currently these targets require the following:
|
||||||
|
* `api-level: 30`
|
||||||
|
* `arch: x86` or `arch: arm64-v8a`
|
||||||
|
* `channel: canary`
|
||||||
|
|
||||||
|
## v2.20.0
|
||||||
|
|
||||||
|
* Support non-mobile targets: `android-wear`, `android-wear-cn`, `android-tv` and `google-tv`. - [#180](https://github.com/ReactiveCircus/android-emulator-runner/pull/180) @alexvanyo.
|
||||||
|
* Update SDK command-line tools to `5.0`. - [#174](https://github.com/ReactiveCircus/android-emulator-runner/pull/174)
|
||||||
|
* Update build tools to `31.0.0`. - [#174](https://github.com/ReactiveCircus/android-emulator-runner/pull/174)
|
||||||
|
* Add option to specify the `channel` to download SDK components from: `stable` (default), `beta`, `dev` and `canary`. - [#185](https://github.com/ReactiveCircus/android-emulator-runner/pull/185)
|
||||||
|
|
||||||
|
## v2.19.1
|
||||||
|
|
||||||
|
* Accept all Android SDK Licenses to fix `sdkmanager` installation. - [#172](https://github.com/ReactiveCircus/android-emulator-runner/pull/172) @marcuspridham.
|
||||||
|
|
||||||
|
## v2.19.0
|
||||||
|
|
||||||
|
* Add option to specify `ram-size` for the AVD. - [#165](https://github.com/ReactiveCircus/android-emulator-runner/pull/165).
|
||||||
|
|
||||||
|
|
||||||
|
## v2.18.1
|
||||||
|
|
||||||
|
* Added support for setting modern emulator build ids for `emulator-build`. Not all build ids are supported until we are able to figure out at which build id the download URL pattern changed. `7425822` (version 30.7.3) is currently the last known working build id.
|
||||||
|
|
||||||
|
## v2.18.0
|
||||||
|
|
||||||
|
* Add `force-avd-creation` which when set to `false` will skip avd creation if avd with same name exists. This enables AVD snapshot caching which can significantly reduce emulator startup time. See [README.md](https://github.com/ReactiveCircus/android-emulator-runner/blob/main/README.md#usage) for a sample workflow. - [#159](https://github.com/ReactiveCircus/android-emulator-runner/pull/159)
|
||||||
|
|
||||||
|
## v2.17.0
|
||||||
|
|
||||||
|
* Add option to toggle Linux hardware acceleration - [#154](https://github.com/ReactiveCircus/android-emulator-runner/pull/154) @stevestotter
|
||||||
|
|
||||||
|
## v2.16.0
|
||||||
|
|
||||||
|
* Avoid wrapping script code in quotes - [#134](https://github.com/ReactiveCircus/android-emulator-runner/pull/134) @hostilefork
|
||||||
|
* Add option to disable spellcheck - [#143](https://github.com/ReactiveCircus/android-emulator-runner/pull/143) @AfzalivE
|
||||||
|
* Add support for arm64-v8a for Apple Silicon Macs - [#146](https://github.com/ReactiveCircus/android-emulator-runner/pull/146) @Jeehut
|
||||||
|
|
||||||
## v2.15.0
|
## v2.15.0
|
||||||
|
|
||||||
* Added support for specifying the number of cores to use for the emulator - [#130](https://github.com/ReactiveCircus/android-emulator-runner/pull/130).
|
* Added support for specifying the number of cores to use for the emulator - [#130](https://github.com/ReactiveCircus/android-emulator-runner/pull/130).
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ A GitHub Action for installing, configuring and running hardware-accelerated And
|
|||||||
|
|
||||||
The old ARM-based emulators were slow and are no longer supported by Google. The modern Intel Atom (x86 and x86_64) emulators require hardware acceleration (HAXM on Mac & Windows, QEMU on Linux) from the host to run fast. This presents a challenge on CI as to be able to run hardware accelerated emulators within a docker container, **KVM** must be supported by the host VM which isn't the case for cloud-based CI providers due to infrastructural limits. If you want to learn more about this, here's an article I wrote: [Running Android Instrumented Tests on CI](https://dev.to/ychescale9/running-android-emulators-on-ci-from-bitrise-io-to-github-actions-3j76).
|
The old ARM-based emulators were slow and are no longer supported by Google. The modern Intel Atom (x86 and x86_64) emulators require hardware acceleration (HAXM on Mac & Windows, QEMU on Linux) from the host to run fast. This presents a challenge on CI as to be able to run hardware accelerated emulators within a docker container, **KVM** must be supported by the host VM which isn't the case for cloud-based CI providers due to infrastructural limits. If you want to learn more about this, here's an article I wrote: [Running Android Instrumented Tests on CI](https://dev.to/ychescale9/running-android-emulators-on-ci-from-bitrise-io-to-github-actions-3j76).
|
||||||
|
|
||||||
The **macOS** VM provided by **GitHub Actions** has **HAXM** installed so we are able to create a new AVD instance, launch an emulator with hardware acceleration, and run our Android
|
The **macOS** VM provided by **GitHub Actions** has **HAXM** installed so we are able to create a new AVD instance, launch an emulator with hardware acceleration, and run our Android
|
||||||
tests directly on the VM.
|
tests directly on the VM. You can also achieve this on a self-hosted Linux runner, but it will need to be on a compatible instance that allows you to enable KVM - for example AWS EC2 Bare Metal instances.
|
||||||
|
|
||||||
This action automates the process by doing the following:
|
This action automates the process by doing the following:
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ This action automates the process by doing the following:
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
It is recommended to run this action on a **macOS** VM, e.g. `macos-latest` or `macos-10.15` to take advantage of hardware accleration support provided by **HAXM**.
|
It is recommended to run this action on a **macOS** VM, e.g. `macos-latest`, `macos-10.15` or `macos-11` to take advantage of hardware acceleration support provided by **HAXM**.
|
||||||
|
|
||||||
A workflow that uses **android-emulator-runner** to run your instrumented tests on **API 29**:
|
A workflow that uses **android-emulator-runner** to run your instrumented tests on **API 29**:
|
||||||
|
|
||||||
@@ -31,14 +31,14 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: run tests
|
- name: run tests
|
||||||
uses: reactivecircus/android-emulator-runner@v2
|
uses: reactivecircus/android-emulator-runner@v2
|
||||||
with:
|
with:
|
||||||
api-level: 29
|
api-level: 29
|
||||||
script: ./gradlew connectedCheck
|
script: ./gradlew connectedCheck
|
||||||
```
|
```
|
||||||
|
|
||||||
We can also leverage GitHub Actions's build matrix to test across multiple configurations:
|
We can also leverage GitHub Actions's build matrix to test across multiple configurations:
|
||||||
@@ -52,17 +52,17 @@ jobs:
|
|||||||
api-level: [21, 23, 29]
|
api-level: [21, 23, 29]
|
||||||
target: [default, google_apis]
|
target: [default, google_apis]
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: run tests
|
- name: run tests
|
||||||
uses: reactivecircus/android-emulator-runner@v2
|
uses: reactivecircus/android-emulator-runner@v2
|
||||||
with:
|
with:
|
||||||
api-level: ${{ matrix.api-level }}
|
api-level: ${{ matrix.api-level }}
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
arch: x86_64
|
arch: x86_64
|
||||||
profile: Nexus 6
|
profile: Nexus 6
|
||||||
script: ./gradlew connectedCheck
|
script: ./gradlew connectedCheck
|
||||||
```
|
```
|
||||||
|
|
||||||
If you need specific versions of **NDK** and **CMake** installed:
|
If you need specific versions of **NDK** and **CMake** installed:
|
||||||
@@ -72,16 +72,70 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: run tests
|
- name: run tests
|
||||||
uses: reactivecircus/android-emulator-runner@v2
|
uses: reactivecircus/android-emulator-runner@v2
|
||||||
with:
|
with:
|
||||||
api-level: 29
|
api-level: 29
|
||||||
ndk: 21.0.6113669
|
ndk: 21.0.6113669
|
||||||
cmake: 3.10.2.4988404
|
cmake: 3.10.2.4988404
|
||||||
script: ./gradlew connectedCheck
|
script: ./gradlew connectedCheck
|
||||||
|
```
|
||||||
|
|
||||||
|
We can significantly reduce emulator startup time by setting up AVD snapshot caching:
|
||||||
|
|
||||||
|
1. add an `actions/cache@v2` step for caching the `avd`
|
||||||
|
2. add a `reactivecircus/android-emulator-runner@v2` step to generate a clean snapshot - specify `emulator-options` without `no-snapshot`
|
||||||
|
3. add another `reactivecircus/android-emulator-runner@v2` step to run your tests using existing AVD / snapshot - specify `emulator-options` with `no-snapshot-save`
|
||||||
|
|
||||||
|
```
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: macos-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
api-level: [21, 23, 29]
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Gradle cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches
|
||||||
|
~/.gradle/wrapper
|
||||||
|
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
|
||||||
|
|
||||||
|
- name: AVD cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
id: avd-cache
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.android/avd/*
|
||||||
|
~/.android/adb*
|
||||||
|
key: avd-${{ matrix.api-level }}
|
||||||
|
|
||||||
|
- name: create AVD and generate snapshot for caching
|
||||||
|
if: steps.avd-cache.outputs.cache-hit != 'true'
|
||||||
|
uses: reactivecircus/android-emulator-runner@v2
|
||||||
|
with:
|
||||||
|
api-level: ${{ matrix.api-level }}
|
||||||
|
force-avd-creation: false
|
||||||
|
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||||
|
disable-animations: false
|
||||||
|
script: echo "Generated AVD snapshot for caching."
|
||||||
|
|
||||||
|
- name: run tests
|
||||||
|
uses: reactivecircus/android-emulator-runner@v2
|
||||||
|
with:
|
||||||
|
api-level: ${{ matrix.api-level }}
|
||||||
|
force-avd-creation: false
|
||||||
|
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||||
|
disable-animations: true
|
||||||
|
script: ./gradlew connectedCheck
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configurations
|
## Configurations
|
||||||
@@ -89,25 +143,32 @@ jobs:
|
|||||||
| **Input** | **Required** | **Default** | **Description** |
|
| **Input** | **Required** | **Default** | **Description** |
|
||||||
|-|-|-|-|
|
|-|-|-|-|
|
||||||
| `api-level` | Required | N/A | API level of the platform system image - e.g. 23 for Android Marshmallow, 29 for Android 10. **Minimum API level supported is 15**. |
|
| `api-level` | Required | N/A | API level of the platform system image - e.g. 23 for Android Marshmallow, 29 for Android 10. **Minimum API level supported is 15**. |
|
||||||
| `target` | Optional | `default` | Target of the system image - `default`, `google_apis` or `playstore`. |
|
| `target` | Optional | `default` | Target of the system image - `default`, `google_apis`, `playstore`, `android-wear`, `android-wear-cn`, `android-tv`, `google-tv`, `aosp_atd` or `google_atd`. Note that `aosp_atd` and `google_atd` currently require the following: `api-level: 30`, `arch: x86` or `arch: arm64-v8` and `channel: canary`. |
|
||||||
| `arch` | Optional | `x86` | CPU architecture of the system image - `x86` or `x86_64`. Note that `x86_64` image is only available for API 21+. |
|
| `arch` | Optional | `x86` | CPU architecture of the system image - `x86`, `x86_64` or `arm64-v8a`. Note that `x86_64` image is only available for API 21+. `arm64-v8a` images require Android 4.2+ and are limited to fewer API levels (e.g. 30). |
|
||||||
| `profile` | Optional | N/A | Hardware profile used for creating the AVD - e.g. `Nexus 6`. For a list of all profiles available, run `avdmanager list` and refer to the results under "Available Android Virtual Devices". |
|
| `profile` | Optional | N/A | Hardware profile used for creating the AVD - e.g. `Nexus 6`. For a list of all profiles available, run `avdmanager list device`. |
|
||||||
| `cores` | Optional | 2 | Number of cores to use for the emulator (`hw.cpu.ncore` in config.ini). |
|
| `cores` | Optional | 2 | Number of cores to use for the emulator (`hw.cpu.ncore` in config.ini). |
|
||||||
|
| `ram-size` | Optional | N/A | Size of RAM to use for this AVD, in KB or MB, denoted with K or M. - e.g. `2048M` |
|
||||||
| `sdcard-path-or-size` | Optional | N/A | Path to the SD card image for this AVD or the size of a new SD card image to create for this AVD, in KB or MB, denoted with K or M. - e.g. `path/to/sdcard`, or `1000M`. |
|
| `sdcard-path-or-size` | Optional | N/A | Path to the SD card image for this AVD or the size of a new SD card image to create for this AVD, in KB or MB, denoted with K or M. - e.g. `path/to/sdcard`, or `1000M`. |
|
||||||
|
| `disk-size` | Optional | N/A | Disk size to use for this AVD. Either in bytes or KB, MB or GB, when denoted with K, M or G. - e.g. `2048M` |
|
||||||
| `avd-name` | Optional | `test` | Custom AVD name used for creating the Android Virtual Device. |
|
| `avd-name` | Optional | `test` | Custom AVD name used for creating the Android Virtual Device. |
|
||||||
|
| `force-avd-creation` | Optional | `true` | Whether to force create the AVD by overwriting an existing AVD with the same name as `avd-name` - `true` or `false`. |
|
||||||
| `emulator-options` | Optional | See below | Command-line options used when launching the emulator (replacing all default options) - e.g. `-no-window -no-snapshot -camera-back emulated`. |
|
| `emulator-options` | Optional | See below | Command-line options used when launching the emulator (replacing all default options) - e.g. `-no-window -no-snapshot -camera-back emulated`. |
|
||||||
| `disable-animations` | Optional | `true` | Whether to disable animations - `true` or `false`. |
|
| `disable-animations` | Optional | `true` | Whether to disable animations - `true` or `false`. |
|
||||||
|
| `disable-spellchecker` | Optional | `false` | Whether to disable spellchecker - `true` or `false`. |
|
||||||
|
| `disable-linux-hw-accel` | Optional | `true` | Whether to disable hardware acceleration on Linux machines - `true` or `false`. Note that this is true by default as Github-hosted Linux runners do not support hardware acceleration. |
|
||||||
|
| `enable-hw-keyboard` | Optional | `false` | Whether to enable hardware keyboard - `true` or `false`. |
|
||||||
| `emulator-build` | Optional | N/A | Build number of a specific version of the emulator binary to use e.g. `6061023` for emulator v29.3.0.0. |
|
| `emulator-build` | Optional | N/A | Build number of a specific version of the emulator binary to use e.g. `6061023` for emulator v29.3.0.0. |
|
||||||
| `working-directory` | Optional | `./` | A custom working directory - e.g. `./android` if your root Gradle project is under the `./android` sub-directory within your repository. |
|
| `working-directory` | Optional | `./` | A custom working directory - e.g. `./android` if your root Gradle project is under the `./android` sub-directory within your repository. |
|
||||||
| `ndk` | Optional | N/A | Version of NDK to install - e.g. `21.0.6113669` |
|
| `ndk` | Optional | N/A | Version of NDK to install - e.g. `21.0.6113669` |
|
||||||
| `cmake` | Optional | N/A | Version of CMake to install - e.g. `3.10.2.4988404` |
|
| `cmake` | Optional | N/A | Version of CMake to install - e.g. `3.10.2.4988404` |
|
||||||
|
| `channel` | Optional | stable | Channel to download the SDK components from - `stable`, `beta`, `dev`, `canary` |
|
||||||
| `script` | Required | N/A | Custom script to run - e.g. to run Android instrumented tests on the emulator: `./gradlew connectedCheck` |
|
| `script` | Required | N/A | Custom script to run - e.g. to run Android instrumented tests on the emulator: `./gradlew connectedCheck` |
|
||||||
|
|
||||||
Default `emulator-options`: `-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim`.
|
Default `emulator-options`: `-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim`.
|
||||||
|
|
||||||
## Can I use this action on Linux VMs?
|
## Can I use this action on Linux VMs?
|
||||||
|
|
||||||
The short answer is yes but it's expected to be a much worse experience (on some newer API levels it might not work at all) than running it on macOS.
|
The short answer is yes but on Github-hosted Linux runners it's expected to be a much worse experience (on some newer API levels it might not work at all) than running it on macOS. You can get it running much faster on self-hosted Linux runners but only if the underlying instances support KVM (which most don't).
|
||||||
|
|
||||||
For a longer answer please refer to [this issue](https://github.com/ReactiveCircus/android-emulator-runner/issues/46).
|
For a longer answer please refer to [this issue](https://github.com/ReactiveCircus/android-emulator-runner/issues/46).
|
||||||
|
|
||||||
@@ -138,5 +199,12 @@ These are some of the open-source projects using (or used) **Android Emulator Ru
|
|||||||
- [square/leakcanary](https://github.com/square/leakcanary/tree/main/.github/workflows)
|
- [square/leakcanary](https://github.com/square/leakcanary/tree/main/.github/workflows)
|
||||||
- [hash-checker/hash-checker](https://github.com/hash-checker/hash-checker/tree/master/.github/workflows)
|
- [hash-checker/hash-checker](https://github.com/hash-checker/hash-checker/tree/master/.github/workflows)
|
||||||
- [hash-checker/hash-checker-lite](https://github.com/hash-checker/hash-checker-lite/tree/master/.github/workflows)
|
- [hash-checker/hash-checker-lite](https://github.com/hash-checker/hash-checker-lite/tree/master/.github/workflows)
|
||||||
|
- [Kiwix/kiwix-android](https://github.com/kiwix/kiwix-android/blob/develop/.github/workflows)
|
||||||
|
- [wikimedia/apps-android-wikipedia](https://github.com/wikimedia/apps-android-wikipedia/blob/main/.github/workflows)
|
||||||
|
- [google/android-fhir](https://github.com/google/android-fhir/tree/master/.github/workflows)
|
||||||
|
- [google/accompanist](https://github.com/google/accompanist/blob/main/.github/workflows)
|
||||||
|
- [dotanuki-labs/norris](https://github.com/dotanuki-labs/norris/blob/master/.github/workflows/main.yml)
|
||||||
|
- [tinylog-org/tinylog](https://github.com/tinylog-org/tinylog/blob/v3.0/.github/workflows/build.yaml)
|
||||||
|
- [hzi-braunschweig/SORMAS-Project](https://github.com/hzi-braunschweig/SORMAS-Project/blob/development/.github/workflows/sormas_app_ci.yml)
|
||||||
|
|
||||||
If you are using **Android Emulator Runner** and want your project included in the list, please feel free to create an issue or open a pull request.
|
If you are using **Android Emulator Runner** and want your project included in the list, please feel free to create an issue or open a pull request.
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
# GitHub Action - Android Emulator Runner
|
# GitHub Action - Android Emulator Runner
|
||||||
|
|
||||||
Refer to the [recommendeations for versioning and releasing actions](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#recommendations).
|
Refer to the [recommendations for versioning and releasing actions](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#recommendations).
|
||||||
|
|
||||||
## New major release
|
## New major release
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import * as mapper from '../src/channel-id-mapper';
|
||||||
|
|
||||||
|
describe('channel id mapper tests', () => {
|
||||||
|
it('Throws if channelName is unknown', () => {
|
||||||
|
const func = () => {
|
||||||
|
mapper.getChannelId('unknown-channel');
|
||||||
|
};
|
||||||
|
expect(func).toThrowError(`Unexpected channel name: 'unknown-channel'.`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Returns expected channelId from channelName', () => {
|
||||||
|
expect(mapper.getChannelId('stable')).toBe(0);
|
||||||
|
expect(mapper.getChannelId('beta')).toBe(1);
|
||||||
|
expect(mapper.getChannelId('dev')).toBe(2);
|
||||||
|
expect(mapper.getChannelId('canary')).toBe(3);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -55,9 +55,39 @@ describe('target validator tests', () => {
|
|||||||
expect(func2).not.toThrow();
|
expect(func2).not.toThrow();
|
||||||
|
|
||||||
const func3 = () => {
|
const func3 = () => {
|
||||||
validator.checkTarget('google_apis');
|
validator.checkTarget('aosp_atd');
|
||||||
};
|
};
|
||||||
expect(func3).not.toThrow();
|
expect(func3).not.toThrow();
|
||||||
|
|
||||||
|
const func4 = () => {
|
||||||
|
validator.checkTarget('google_atd');
|
||||||
|
};
|
||||||
|
expect(func4).not.toThrow();
|
||||||
|
|
||||||
|
const func5 = () => {
|
||||||
|
validator.checkTarget('google_apis_playstore');
|
||||||
|
};
|
||||||
|
expect(func5).not.toThrow();
|
||||||
|
|
||||||
|
const func6 = () => {
|
||||||
|
validator.checkTarget('android-wear');
|
||||||
|
};
|
||||||
|
expect(func6).not.toThrow();
|
||||||
|
|
||||||
|
const func7 = () => {
|
||||||
|
validator.checkTarget('android-wear-cn');
|
||||||
|
};
|
||||||
|
expect(func7).not.toThrow();
|
||||||
|
|
||||||
|
const func8 = () => {
|
||||||
|
validator.checkTarget('android-tv');
|
||||||
|
};
|
||||||
|
expect(func8).not.toThrow();
|
||||||
|
|
||||||
|
const func9 = () => {
|
||||||
|
validator.checkTarget('google-tv');
|
||||||
|
};
|
||||||
|
expect(func9).not.toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -82,6 +112,58 @@ describe('arch validator tests', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('channel validator tests', () => {
|
||||||
|
it('Throws if channel is unknown', () => {
|
||||||
|
const func = () => {
|
||||||
|
validator.checkChannel('some-channel');
|
||||||
|
};
|
||||||
|
expect(func).toThrowError(`Value for input.channel 'some-channel' is unknown. Supported options: ${validator.VALID_CHANNELS}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Validates successfully with valid channel', () => {
|
||||||
|
const func1 = () => {
|
||||||
|
validator.checkChannel('stable');
|
||||||
|
};
|
||||||
|
expect(func1).not.toThrow();
|
||||||
|
|
||||||
|
const func2 = () => {
|
||||||
|
validator.checkChannel('beta');
|
||||||
|
};
|
||||||
|
expect(func2).not.toThrow();
|
||||||
|
|
||||||
|
const func3 = () => {
|
||||||
|
validator.checkChannel('dev');
|
||||||
|
};
|
||||||
|
expect(func3).not.toThrow();
|
||||||
|
|
||||||
|
const func4 = () => {
|
||||||
|
validator.checkChannel('canary');
|
||||||
|
};
|
||||||
|
expect(func4).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('force-avd-creation validator tests', () => {
|
||||||
|
it('Throws if force-avd-creation is not a boolean', () => {
|
||||||
|
const func = () => {
|
||||||
|
validator.checkForceAvdCreation('yes');
|
||||||
|
};
|
||||||
|
expect(func).toThrowError(`Input for input.force-avd-creation should be either 'true' or 'false'.`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Validates successfully if force-avd-creation is either true or false', () => {
|
||||||
|
const func1 = () => {
|
||||||
|
validator.checkForceAvdCreation('true');
|
||||||
|
};
|
||||||
|
expect(func1).not.toThrow();
|
||||||
|
|
||||||
|
const func2 = () => {
|
||||||
|
validator.checkForceAvdCreation('false');
|
||||||
|
};
|
||||||
|
expect(func2).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('disable-animations validator tests', () => {
|
describe('disable-animations validator tests', () => {
|
||||||
it('Throws if disable-animations is not a boolean', () => {
|
it('Throws if disable-animations is not a boolean', () => {
|
||||||
const func = () => {
|
const func = () => {
|
||||||
@@ -103,6 +185,69 @@ describe('disable-animations validator tests', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('disable-spellchecker validator tests', () => {
|
||||||
|
it('Throws if disable-spellchecker is not a boolean', () => {
|
||||||
|
const func = () => {
|
||||||
|
validator.checkDisableSpellchecker('yes');
|
||||||
|
};
|
||||||
|
expect(func).toThrowError(`Input for input.disable-spellchecker should be either 'true' or 'false'.`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Validates successfully if disable-spellchecker is either true or false', () => {
|
||||||
|
const func1 = () => {
|
||||||
|
validator.checkDisableSpellchecker('true');
|
||||||
|
};
|
||||||
|
expect(func1).not.toThrow();
|
||||||
|
|
||||||
|
const func2 = () => {
|
||||||
|
validator.checkDisableSpellchecker('false');
|
||||||
|
};
|
||||||
|
expect(func2).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('disable-linux-hw-accel validator tests', () => {
|
||||||
|
it('Throws if disable-linux-hw-accel is not a boolean', () => {
|
||||||
|
const func = () => {
|
||||||
|
validator.checkDisableLinuxHardwareAcceleration('yes');
|
||||||
|
};
|
||||||
|
expect(func).toThrowError(`Input for input.disable-linux-hw-accel should be either 'true' or 'false'.`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Validates successfully if disable-linux-hw-accel is either true or false', () => {
|
||||||
|
const func1 = () => {
|
||||||
|
validator.checkDisableLinuxHardwareAcceleration('true');
|
||||||
|
};
|
||||||
|
expect(func1).not.toThrow();
|
||||||
|
|
||||||
|
const func2 = () => {
|
||||||
|
validator.checkDisableLinuxHardwareAcceleration('false');
|
||||||
|
};
|
||||||
|
expect(func2).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('enable-hw-keyboard validator tests', () => {
|
||||||
|
it('Throws if enable-hw-keyboard is not a boolean', () => {
|
||||||
|
const func = () => {
|
||||||
|
validator.checkEnableHardwareKeyboard('yes');
|
||||||
|
};
|
||||||
|
expect(func).toThrowError(`Input for input.enable-hw-keyboard should be either 'true' or 'false'.`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Validates successfully if enable-hardware-keyboard is either true or false', () => {
|
||||||
|
const func1 = () => {
|
||||||
|
validator.checkEnableHardwareKeyboard('true');
|
||||||
|
};
|
||||||
|
expect(func1).not.toThrow();
|
||||||
|
|
||||||
|
const func2 = () => {
|
||||||
|
validator.checkEnableHardwareKeyboard('false');
|
||||||
|
};
|
||||||
|
expect(func2).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('emulator-build validator tests', () => {
|
describe('emulator-build validator tests', () => {
|
||||||
it('Throws if emulator-build is not a number', () => {
|
it('Throws if emulator-build is not a number', () => {
|
||||||
const func = () => {
|
const func = () => {
|
||||||
@@ -125,3 +270,54 @@ describe('emulator-build validator tests', () => {
|
|||||||
expect(func).not.toThrow();
|
expect(func).not.toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('checkDiskSize validator tests', () => {
|
||||||
|
it('Empty size is acceptable, means default', () => {
|
||||||
|
const func = () => {
|
||||||
|
validator.checkDiskSize('');
|
||||||
|
};
|
||||||
|
expect(func).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Numbers means bytes', () => {
|
||||||
|
expect(() => {
|
||||||
|
validator.checkDiskSize('8000000000');
|
||||||
|
}).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Uppercase size modifier', () => {
|
||||||
|
expect(() => {
|
||||||
|
validator.checkDiskSize('8000000K');
|
||||||
|
}).not.toThrow();
|
||||||
|
expect(() => {
|
||||||
|
validator.checkDiskSize('8000M');
|
||||||
|
}).not.toThrow();
|
||||||
|
expect(() => {
|
||||||
|
validator.checkDiskSize('8G');
|
||||||
|
}).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Lowercase size modifier', () => {
|
||||||
|
expect(() => {
|
||||||
|
validator.checkDiskSize('8000000k');
|
||||||
|
}).not.toThrow();
|
||||||
|
expect(() => {
|
||||||
|
validator.checkDiskSize('8000m');
|
||||||
|
}).not.toThrow();
|
||||||
|
expect(() => {
|
||||||
|
validator.checkDiskSize('8g');
|
||||||
|
}).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Modifier without a number is unacceptable', () => {
|
||||||
|
expect(() => {
|
||||||
|
validator.checkDiskSize('G');
|
||||||
|
}).toThrowError(`Unexpected disk size: 'G'.`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Double modifier is unacceptable', () => {
|
||||||
|
expect(() => {
|
||||||
|
validator.checkDiskSize('14gg');
|
||||||
|
}).toThrowError(`Unexpected disk size: '14gg'.`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
+22
-3
@@ -2,34 +2,50 @@ name: 'Android Emulator Runner'
|
|||||||
description: 'Installs, configures and starts an Android Emulator directly on macOS virtual machines.'
|
description: 'Installs, configures and starts an Android Emulator directly on macOS virtual machines.'
|
||||||
author: 'Reactive Circus'
|
author: 'Reactive Circus'
|
||||||
branding:
|
branding:
|
||||||
icon: 'smartphone'
|
icon: 'smartphone'
|
||||||
color: 'green'
|
color: 'green'
|
||||||
inputs:
|
inputs:
|
||||||
api-level:
|
api-level:
|
||||||
description: 'API level of the platform and system image - e.g. 23 for Android Marshmallow, 29 for Android 10'
|
description: 'API level of the platform and system image - e.g. 23 for Android Marshmallow, 29 for Android 10'
|
||||||
required: true
|
required: true
|
||||||
target:
|
target:
|
||||||
description: 'target of the system image - default, google_apis or playstore'
|
description: 'target of the system image - default, google_apis, google_apis_playstore, aosp_atd, google_atd, android-wear, android-wear-cn, android-tv or google-tv'
|
||||||
default: 'default'
|
default: 'default'
|
||||||
arch:
|
arch:
|
||||||
description: 'CPU architecture of the system image - x86 or x86_64'
|
description: 'CPU architecture of the system image - x86, x86_64 or arm64-v8a'
|
||||||
default: 'x86'
|
default: 'x86'
|
||||||
profile:
|
profile:
|
||||||
description: 'hardware profile used for creating the AVD - e.g. `Nexus 6`'
|
description: 'hardware profile used for creating the AVD - e.g. `Nexus 6`'
|
||||||
cores:
|
cores:
|
||||||
description: 'the number of cores to use for the emulator'
|
description: 'the number of cores to use for the emulator'
|
||||||
default: 2
|
default: 2
|
||||||
|
ram-size:
|
||||||
|
description: 'size of RAM to use for this AVD, in KB or MB, denoted with K or M. - e.g. `2048M`'
|
||||||
sdcard-path-or-size:
|
sdcard-path-or-size:
|
||||||
description: 'path to the SD card image for this AVD or the size of a new SD card image to create for this AVD, in KB or MB, denoted with K or M. - e.g. `path/to/sdcard`, or `1000M`'
|
description: 'path to the SD card image for this AVD or the size of a new SD card image to create for this AVD, in KB or MB, denoted with K or M. - e.g. `path/to/sdcard`, or `1000M`'
|
||||||
|
disk-size:
|
||||||
|
description: 'disk size to use for this AVD. Either in bytes or KB, MB or GB, when denoted with K, M or G'
|
||||||
avd-name:
|
avd-name:
|
||||||
description: 'custom AVD name used for creating the Android Virtual Device'
|
description: 'custom AVD name used for creating the Android Virtual Device'
|
||||||
default: 'test'
|
default: 'test'
|
||||||
|
force-avd-creation:
|
||||||
|
description: 'whether to force create the AVD by overwriting an existing AVD with the same name as `avd-name` - `true` or `false`'
|
||||||
|
default: 'true'
|
||||||
emulator-options:
|
emulator-options:
|
||||||
description: 'command-line options used when launching the emulator - e.g. `-no-window -no-snapshot -camera-back emulated`'
|
description: 'command-line options used when launching the emulator - e.g. `-no-window -no-snapshot -camera-back emulated`'
|
||||||
default: '-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim'
|
default: '-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim'
|
||||||
disable-animations:
|
disable-animations:
|
||||||
description: 'whether to disable animations - true or false'
|
description: 'whether to disable animations - true or false'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
|
disable-spellchecker:
|
||||||
|
description: 'whether to disable spellchecker - `true` or `false`'
|
||||||
|
default: 'false'
|
||||||
|
disable-linux-hw-accel:
|
||||||
|
description: 'whether to disable hardware acceleration on Linux machines - `true` or `false`'
|
||||||
|
default: 'true'
|
||||||
|
enable-hw-keyboard:
|
||||||
|
description: 'whether to enable hardware keyboard - `true` or `false`.'
|
||||||
|
default: 'false'
|
||||||
emulator-build:
|
emulator-build:
|
||||||
description: 'build number of a specific version of the emulator binary to use - e.g. `6061023` for emulator v29.3.0.0'
|
description: 'build number of a specific version of the emulator binary to use - e.g. `6061023` for emulator v29.3.0.0'
|
||||||
working-directory:
|
working-directory:
|
||||||
@@ -38,6 +54,9 @@ inputs:
|
|||||||
description: 'version of NDK to install - e.g. 21.0.6113669'
|
description: 'version of NDK to install - e.g. 21.0.6113669'
|
||||||
cmake:
|
cmake:
|
||||||
description: 'version of CMake to install - e.g. 3.10.2.4988404'
|
description: 'version of CMake to install - e.g. 3.10.2.4988404'
|
||||||
|
channel:
|
||||||
|
description: 'Channel to download the SDK components from - `stable`, `beta`, `dev`, `canary`'
|
||||||
|
default: 'stable'
|
||||||
script:
|
script:
|
||||||
description: 'custom script to run - e.g. `./gradlew connectedCheck`'
|
description: 'custom script to run - e.g. `./gradlew connectedCheck`'
|
||||||
required: true
|
required: true
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.getChannelId = void 0;
|
||||||
|
function getChannelId(channelName) {
|
||||||
|
if (channelName === 'stable') {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (channelName === 'beta') {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (channelName === 'dev') {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
else if (channelName === 'canary') {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new Error(`Unexpected channel name: '${channelName}'.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.getChannelId = getChannelId;
|
||||||
+62
-33
@@ -30,59 +30,88 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.killEmulator = exports.launchEmulator = void 0;
|
exports.killEmulator = exports.launchEmulator = void 0;
|
||||||
const exec = __importStar(require("@actions/exec"));
|
const exec = __importStar(require("@actions/exec"));
|
||||||
|
const fs = __importStar(require("fs"));
|
||||||
const EMULATOR_BOOT_TIMEOUT_SECONDS = 600;
|
const EMULATOR_BOOT_TIMEOUT_SECONDS = 600;
|
||||||
/**
|
/**
|
||||||
* Creates and launches a new AVD instance with the specified configurations.
|
* Creates and launches a new AVD instance with the specified configurations.
|
||||||
*/
|
*/
|
||||||
function launchEmulator(apiLevel, target, arch, profile, cores, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations) {
|
function launchEmulator(apiLevel, target, arch, profile, cores, ramSize, sdcardPathOrSize, diskSize, avdName, forceAvdCreation, emulatorOptions, disableAnimations, disableSpellChecker, disableLinuxHardwareAcceleration, enableHardwareKeyboard) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// create a new AVD
|
try {
|
||||||
const profileOption = profile.trim() !== '' ? `--device '${profile}'` : '';
|
console.log(`::group::Launch Emulator`);
|
||||||
const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard '${sdcardPathOrSize}'` : '';
|
// create a new AVD if AVD directory does not already exist or forceAvdCreation is true
|
||||||
console.log(`Creating AVD.`);
|
const avdPath = `${process.env.ANDROID_AVD_HOME}/${avdName}.avd`;
|
||||||
yield exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}' ${profileOption} ${sdcardPathOrSizeOption}"`);
|
if (!fs.existsSync(avdPath) || forceAvdCreation) {
|
||||||
if (cores) {
|
const profileOption = profile.trim() !== '' ? `--device '${profile}'` : '';
|
||||||
yield exec.exec(`sh -c \\"printf 'hw.cpu.ncore=${cores}\n' >> ~/.android/avd/"${avdName}".avd"/config.ini`);
|
const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard '${sdcardPathOrSize}'` : '';
|
||||||
}
|
console.log(`Creating AVD.`);
|
||||||
// start emulator
|
yield exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}' ${profileOption} ${sdcardPathOrSizeOption}"`);
|
||||||
console.log('Starting emulator.');
|
}
|
||||||
// turn off hardware acceleration on Linux
|
if (cores) {
|
||||||
if (process.platform === 'linux') {
|
yield exec.exec(`sh -c \\"printf 'hw.cpu.ncore=${cores}\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
|
||||||
emulatorOptions += ' -accel off';
|
}
|
||||||
}
|
if (ramSize) {
|
||||||
yield exec.exec(`sh -c \\"${process.env.ANDROID_SDK_ROOT}/emulator/emulator -avd "${avdName}" ${emulatorOptions} &"`, [], {
|
yield exec.exec(`sh -c \\"printf 'hw.ramSize=${ramSize}\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
|
||||||
listeners: {
|
}
|
||||||
stderr: (data) => {
|
if (enableHardwareKeyboard) {
|
||||||
if (data.toString().includes('invalid command-line parameter')) {
|
yield exec.exec(`sh -c \\"printf 'hw.keyboard=yes\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
|
||||||
throw new Error(data.toString());
|
}
|
||||||
|
if (diskSize) {
|
||||||
|
yield exec.exec(`sh -c \\"printf 'disk.dataPartition.size=${diskSize}\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
|
||||||
|
}
|
||||||
|
//turn off hardware acceleration on Linux
|
||||||
|
if (process.platform === 'linux' && disableLinuxHardwareAcceleration) {
|
||||||
|
console.log('Disabling Linux hardware acceleration.');
|
||||||
|
emulatorOptions += ' -accel off';
|
||||||
|
}
|
||||||
|
// start emulator
|
||||||
|
console.log('Starting emulator.');
|
||||||
|
yield exec.exec(`sh -c \\"${process.env.ANDROID_SDK_ROOT}/emulator/emulator -avd "${avdName}" ${emulatorOptions} &"`, [], {
|
||||||
|
listeners: {
|
||||||
|
stderr: (data) => {
|
||||||
|
if (data.toString().includes('invalid command-line parameter')) {
|
||||||
|
throw new Error(data.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
// wait for emulator to complete booting
|
||||||
|
yield waitForDevice();
|
||||||
|
yield exec.exec(`adb shell input keyevent 82`);
|
||||||
|
if (disableAnimations) {
|
||||||
|
console.log('Disabling animations.');
|
||||||
|
yield exec.exec(`adb shell settings put global window_animation_scale 0.0`);
|
||||||
|
yield exec.exec(`adb shell settings put global transition_animation_scale 0.0`);
|
||||||
|
yield exec.exec(`adb shell settings put global animator_duration_scale 0.0`);
|
||||||
}
|
}
|
||||||
});
|
if (disableSpellChecker) {
|
||||||
// wait for emulator to complete booting
|
yield exec.exec(`adb shell settings put secure spell_checker_enabled 0`);
|
||||||
yield waitForDevice();
|
}
|
||||||
yield exec.exec(`adb shell input keyevent 82`);
|
if (enableHardwareKeyboard) {
|
||||||
// disable animations
|
yield exec.exec(`adb shell settings put secure show_ime_with_hard_keyboard 0`);
|
||||||
if (disableAnimations) {
|
}
|
||||||
console.log('Disabling animations.');
|
}
|
||||||
yield exec.exec(`adb shell settings put global window_animation_scale 0.0`);
|
finally {
|
||||||
yield exec.exec(`adb shell settings put global transition_animation_scale 0.0`);
|
console.log(`::endgroup::`);
|
||||||
yield exec.exec(`adb shell settings put global animator_duration_scale 0.0`);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.launchEmulator = launchEmulator;
|
exports.launchEmulator = launchEmulator;
|
||||||
/**
|
/**
|
||||||
* Kills the running emulator on the defaut port.
|
* Kills the running emulator on the default port.
|
||||||
*/
|
*/
|
||||||
function killEmulator() {
|
function killEmulator() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
|
console.log(`::group::Terminate Emulator`);
|
||||||
yield exec.exec(`adb -s emulator-5554 emu kill`);
|
yield exec.exec(`adb -s emulator-5554 emu kill`);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.log(error.message);
|
console.log(error.message);
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
console.log(`::endgroup::`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.killEmulator = killEmulator;
|
exports.killEmulator = killEmulator;
|
||||||
@@ -94,7 +123,7 @@ function waitForDevice() {
|
|||||||
let booted = false;
|
let booted = false;
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
const retryInterval = 2; // retry every 2 seconds
|
const retryInterval = 2; // retry every 2 seconds
|
||||||
const maxAttemps = EMULATOR_BOOT_TIMEOUT_SECONDS / 2;
|
const maxAttempts = EMULATOR_BOOT_TIMEOUT_SECONDS / 2;
|
||||||
while (!booted) {
|
while (!booted) {
|
||||||
try {
|
try {
|
||||||
let result = '';
|
let result = '';
|
||||||
@@ -114,7 +143,7 @@ function waitForDevice() {
|
|||||||
catch (error) {
|
catch (error) {
|
||||||
console.warn(error.message);
|
console.warn(error.message);
|
||||||
}
|
}
|
||||||
if (attempts < maxAttemps) {
|
if (attempts < maxAttempts) {
|
||||||
yield delay(retryInterval * 1000);
|
yield delay(retryInterval * 1000);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
+55
-4
@@ -1,9 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.checkEmulatorBuild = exports.checkDisableAnimations = exports.checkArch = exports.checkTarget = exports.checkApiLevel = exports.VALID_ARCHS = exports.VALID_TARGETS = exports.MIN_API_LEVEL = void 0;
|
exports.checkDiskSize = exports.checkEmulatorBuild = exports.checkEnableHardwareKeyboard = exports.checkDisableLinuxHardwareAcceleration = exports.checkDisableSpellchecker = exports.checkDisableAnimations = exports.checkForceAvdCreation = exports.checkChannel = exports.checkArch = exports.checkTarget = exports.checkApiLevel = exports.VALID_CHANNELS = exports.VALID_ARCHS = exports.VALID_TARGETS = exports.MIN_API_LEVEL = void 0;
|
||||||
exports.MIN_API_LEVEL = 15;
|
exports.MIN_API_LEVEL = 15;
|
||||||
exports.VALID_TARGETS = ['default', 'google_apis', 'google_apis_playstore'];
|
exports.VALID_TARGETS = ['default', 'google_apis', 'aosp_atd', 'google_atd', 'google_apis_playstore', 'android-wear', 'android-wear-cn', 'android-tv', 'google-tv'];
|
||||||
exports.VALID_ARCHS = ['x86', 'x86_64'];
|
exports.VALID_ARCHS = ['x86', 'x86_64', 'arm64-v8a'];
|
||||||
|
exports.VALID_CHANNELS = ['stable', 'beta', 'dev', 'canary'];
|
||||||
function checkApiLevel(apiLevel) {
|
function checkApiLevel(apiLevel) {
|
||||||
if (isNaN(Number(apiLevel)) || !Number.isInteger(Number(apiLevel))) {
|
if (isNaN(Number(apiLevel)) || !Number.isInteger(Number(apiLevel))) {
|
||||||
throw new Error(`Unexpected API level: '${apiLevel}'.`);
|
throw new Error(`Unexpected API level: '${apiLevel}'.`);
|
||||||
@@ -25,15 +26,65 @@ function checkArch(arch) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.checkArch = checkArch;
|
exports.checkArch = checkArch;
|
||||||
|
function checkChannel(channel) {
|
||||||
|
if (!exports.VALID_CHANNELS.includes(channel)) {
|
||||||
|
throw new Error(`Value for input.channel '${channel}' is unknown. Supported options: ${exports.VALID_CHANNELS}.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.checkChannel = checkChannel;
|
||||||
|
function checkForceAvdCreation(forceAvdCreation) {
|
||||||
|
if (!isValidBoolean(forceAvdCreation)) {
|
||||||
|
throw new Error(`Input for input.force-avd-creation should be either 'true' or 'false'.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.checkForceAvdCreation = checkForceAvdCreation;
|
||||||
function checkDisableAnimations(disableAnimations) {
|
function checkDisableAnimations(disableAnimations) {
|
||||||
if (disableAnimations !== 'true' && disableAnimations !== 'false') {
|
if (!isValidBoolean(disableAnimations)) {
|
||||||
throw new Error(`Input for input.disable-animations should be either 'true' or 'false'.`);
|
throw new Error(`Input for input.disable-animations should be either 'true' or 'false'.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.checkDisableAnimations = checkDisableAnimations;
|
exports.checkDisableAnimations = checkDisableAnimations;
|
||||||
|
function checkDisableSpellchecker(disableSpellchecker) {
|
||||||
|
if (!isValidBoolean(disableSpellchecker)) {
|
||||||
|
throw new Error(`Input for input.disable-spellchecker should be either 'true' or 'false'.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.checkDisableSpellchecker = checkDisableSpellchecker;
|
||||||
|
function checkDisableLinuxHardwareAcceleration(disableLinuxHardwareAcceleration) {
|
||||||
|
if (!isValidBoolean(disableLinuxHardwareAcceleration)) {
|
||||||
|
throw new Error(`Input for input.disable-linux-hw-accel should be either 'true' or 'false'.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.checkDisableLinuxHardwareAcceleration = checkDisableLinuxHardwareAcceleration;
|
||||||
|
function checkEnableHardwareKeyboard(enableHardwareKeyboard) {
|
||||||
|
if (!isValidBoolean(enableHardwareKeyboard)) {
|
||||||
|
throw new Error(`Input for input.enable-hw-keyboard should be either 'true' or 'false'.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.checkEnableHardwareKeyboard = checkEnableHardwareKeyboard;
|
||||||
function checkEmulatorBuild(emulatorBuild) {
|
function checkEmulatorBuild(emulatorBuild) {
|
||||||
if (isNaN(Number(emulatorBuild)) || !Number.isInteger(Number(emulatorBuild))) {
|
if (isNaN(Number(emulatorBuild)) || !Number.isInteger(Number(emulatorBuild))) {
|
||||||
throw new Error(`Unexpected emulator build: '${emulatorBuild}'.`);
|
throw new Error(`Unexpected emulator build: '${emulatorBuild}'.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.checkEmulatorBuild = checkEmulatorBuild;
|
exports.checkEmulatorBuild = checkEmulatorBuild;
|
||||||
|
function isValidBoolean(value) {
|
||||||
|
return value === 'true' || value === 'false';
|
||||||
|
}
|
||||||
|
function checkDiskSize(diskSize) {
|
||||||
|
// Disk size can be empty - the default value
|
||||||
|
if (diskSize) {
|
||||||
|
// Can also be number of bytes
|
||||||
|
if (isNaN(Number(diskSize)) || !Number.isInteger(Number(diskSize))) {
|
||||||
|
// Disk size can have a size multiplier at the end K, M or G
|
||||||
|
const diskSizeUpperCase = diskSize.toUpperCase();
|
||||||
|
if (diskSizeUpperCase.endsWith('K') || diskSizeUpperCase.endsWith('M') || diskSizeUpperCase.endsWith('G')) {
|
||||||
|
const diskSizeNoModifier = diskSize.slice(0, -1);
|
||||||
|
if (0 == diskSizeNoModifier.length || isNaN(Number(diskSizeNoModifier)) || !Number.isInteger(Number(diskSizeNoModifier))) {
|
||||||
|
throw new Error(`Unexpected disk size: '${diskSize}'.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.checkDiskSize = checkDiskSize;
|
||||||
|
|||||||
+39
-3
@@ -34,9 +34,11 @@ const input_validator_1 = require("./input-validator");
|
|||||||
const emulator_manager_1 = require("./emulator-manager");
|
const emulator_manager_1 = require("./emulator-manager");
|
||||||
const exec = __importStar(require("@actions/exec"));
|
const exec = __importStar(require("@actions/exec"));
|
||||||
const script_parser_1 = require("./script-parser");
|
const script_parser_1 = require("./script-parser");
|
||||||
|
const channel_id_mapper_1 = require("./channel-id-mapper");
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
|
console.log(`::group::Configure emulator`);
|
||||||
// only support running on macOS or Linux
|
// only support running on macOS or Linux
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
@@ -66,12 +68,23 @@ function run() {
|
|||||||
// Number of cores to use for emulator
|
// Number of cores to use for emulator
|
||||||
const cores = core.getInput('cores');
|
const cores = core.getInput('cores');
|
||||||
console.log(`Cores: ${cores}`);
|
console.log(`Cores: ${cores}`);
|
||||||
|
// RAM to use for AVD
|
||||||
|
const ramSize = core.getInput('ram-size');
|
||||||
|
console.log(`RAM size: ${ramSize}`);
|
||||||
// SD card path or size used for creating the AVD
|
// SD card path or size used for creating the AVD
|
||||||
const sdcardPathOrSize = core.getInput('sdcard-path-or-size');
|
const sdcardPathOrSize = core.getInput('sdcard-path-or-size');
|
||||||
console.log(`SD card path or size: ${sdcardPathOrSize}`);
|
console.log(`SD card path or size: ${sdcardPathOrSize}`);
|
||||||
|
const diskSize = core.getInput('disk-size');
|
||||||
|
input_validator_1.checkDiskSize(diskSize);
|
||||||
|
console.log(`Disk size: ${diskSize}`);
|
||||||
// custom name used for creating the AVD
|
// custom name used for creating the AVD
|
||||||
const avdName = core.getInput('avd-name');
|
const avdName = core.getInput('avd-name');
|
||||||
console.log(`AVD name: ${avdName}`);
|
console.log(`AVD name: ${avdName}`);
|
||||||
|
// force AVD creation
|
||||||
|
const forceAvdCreationInput = core.getInput('force-avd-creation');
|
||||||
|
input_validator_1.checkForceAvdCreation(forceAvdCreationInput);
|
||||||
|
const forceAvdCreation = forceAvdCreationInput === 'true';
|
||||||
|
console.log(`force avd creation: ${forceAvdCreation}`);
|
||||||
// emulator options
|
// emulator options
|
||||||
const emulatorOptions = core.getInput('emulator-options').trim();
|
const emulatorOptions = core.getInput('emulator-options').trim();
|
||||||
console.log(`emulator options: ${emulatorOptions}`);
|
console.log(`emulator options: ${emulatorOptions}`);
|
||||||
@@ -80,6 +93,21 @@ function run() {
|
|||||||
input_validator_1.checkDisableAnimations(disableAnimationsInput);
|
input_validator_1.checkDisableAnimations(disableAnimationsInput);
|
||||||
const disableAnimations = disableAnimationsInput === 'true';
|
const disableAnimations = disableAnimationsInput === 'true';
|
||||||
console.log(`disable animations: ${disableAnimations}`);
|
console.log(`disable animations: ${disableAnimations}`);
|
||||||
|
// disable spellchecker
|
||||||
|
const disableSpellcheckerInput = core.getInput('disable-spellchecker');
|
||||||
|
input_validator_1.checkDisableSpellchecker(disableSpellcheckerInput);
|
||||||
|
const disableSpellchecker = disableSpellcheckerInput === 'true';
|
||||||
|
console.log(`disable spellchecker: ${disableSpellchecker}`);
|
||||||
|
// disable linux hardware acceleration
|
||||||
|
const disableLinuxHardwareAccelerationInput = core.getInput('disable-linux-hw-accel');
|
||||||
|
input_validator_1.checkDisableLinuxHardwareAcceleration(disableLinuxHardwareAccelerationInput);
|
||||||
|
const disableLinuxHardwareAcceleration = disableLinuxHardwareAccelerationInput === 'true';
|
||||||
|
console.log(`disable Linux hardware acceleration: ${disableLinuxHardwareAcceleration}`);
|
||||||
|
// enable hardware keyboard
|
||||||
|
const enableHardwareKeyboardInput = core.getInput('enable-hw-keyboard');
|
||||||
|
input_validator_1.checkEnableHardwareKeyboard(enableHardwareKeyboardInput);
|
||||||
|
const enableHardwareKeyboard = enableHardwareKeyboardInput === 'true';
|
||||||
|
console.log(`enable hardware keyboard: ${enableHardwareKeyboard}`);
|
||||||
// emulator build
|
// emulator build
|
||||||
const emulatorBuildInput = core.getInput('emulator-build');
|
const emulatorBuildInput = core.getInput('emulator-build');
|
||||||
if (emulatorBuildInput) {
|
if (emulatorBuildInput) {
|
||||||
@@ -105,6 +133,11 @@ function run() {
|
|||||||
console.log(`version of CMake to install: ${cmakeInput}`);
|
console.log(`version of CMake to install: ${cmakeInput}`);
|
||||||
}
|
}
|
||||||
const cmakeVersion = !cmakeInput ? undefined : cmakeInput;
|
const cmakeVersion = !cmakeInput ? undefined : cmakeInput;
|
||||||
|
// channelId (up to and including) to download the SDK packages from
|
||||||
|
const channelName = core.getInput('channel');
|
||||||
|
input_validator_1.checkChannel(channelName);
|
||||||
|
const channelId = channel_id_mapper_1.getChannelId(channelName);
|
||||||
|
console.log(`Channel: ${channelId} (${channelName})`);
|
||||||
// custom script to run
|
// custom script to run
|
||||||
const scriptInput = core.getInput('script', { required: true });
|
const scriptInput = core.getInput('script', { required: true });
|
||||||
const scripts = script_parser_1.parseScript(scriptInput);
|
const scripts = script_parser_1.parseScript(scriptInput);
|
||||||
@@ -112,10 +145,11 @@ function run() {
|
|||||||
scripts.forEach((script) => __awaiter(this, void 0, void 0, function* () {
|
scripts.forEach((script) => __awaiter(this, void 0, void 0, function* () {
|
||||||
console.log(`${script}`);
|
console.log(`${script}`);
|
||||||
}));
|
}));
|
||||||
|
console.log(`::endgroup::`);
|
||||||
// install SDK
|
// install SDK
|
||||||
yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion);
|
yield sdk_installer_1.installAndroidSdk(apiLevel, target, arch, channelId, emulatorBuild, ndkVersion, cmakeVersion);
|
||||||
// launch an emulator
|
// launch an emulator
|
||||||
yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, cores, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations);
|
yield emulator_manager_1.launchEmulator(apiLevel, target, arch, profile, cores, ramSize, sdcardPathOrSize, diskSize, avdName, forceAvdCreation, emulatorOptions, disableAnimations, disableSpellchecker, disableLinuxHardwareAcceleration, enableHardwareKeyboard);
|
||||||
// execute the custom script
|
// execute the custom script
|
||||||
try {
|
try {
|
||||||
// move to custom working directory if set
|
// move to custom working directory if set
|
||||||
@@ -123,7 +157,9 @@ function run() {
|
|||||||
process.chdir(workingDirectory);
|
process.chdir(workingDirectory);
|
||||||
}
|
}
|
||||||
for (const script of scripts) {
|
for (const script of scripts) {
|
||||||
yield exec.exec(`sh -c \\"${script}"`);
|
// use array form to avoid various quote escaping problems
|
||||||
|
// caused by exec(`sh -c "${script}"`)
|
||||||
|
yield exec.exec('sh', ['-c', script]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|||||||
+47
-51
@@ -34,65 +34,61 @@ const exec = __importStar(require("@actions/exec"));
|
|||||||
const io = __importStar(require("@actions/io"));
|
const io = __importStar(require("@actions/io"));
|
||||||
const tc = __importStar(require("@actions/tool-cache"));
|
const tc = __importStar(require("@actions/tool-cache"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const BUILD_TOOLS_VERSION = '30.0.3';
|
const BUILD_TOOLS_VERSION = '32.0.0';
|
||||||
const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-6858069_latest.zip';
|
const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-8092744_latest.zip';
|
||||||
const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip';
|
const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip';
|
||||||
/**
|
/**
|
||||||
* Installs & updates the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator,
|
* Installs & updates the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator,
|
||||||
* and the system image for the chosen API level, CPU arch, and target.
|
* and the system image for the chosen API level, CPU arch, and target.
|
||||||
*/
|
*/
|
||||||
function installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion) {
|
function installAndroidSdk(apiLevel, target, arch, channelId, emulatorBuild, ndkVersion, cmakeVersion) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const isOnMac = process.platform === 'darwin';
|
try {
|
||||||
if (!isOnMac) {
|
console.log(`::group::Install Android SDK`);
|
||||||
yield exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_SDK_ROOT} -R`);
|
const isOnMac = process.platform === 'darwin';
|
||||||
}
|
if (!isOnMac) {
|
||||||
const cmdlineToolsPath = `${process.env.ANDROID_SDK_ROOT}/cmdline-tools`;
|
yield exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_SDK_ROOT} -R`);
|
||||||
if (!fs.existsSync(cmdlineToolsPath)) {
|
}
|
||||||
console.log('Installing new cmdline-tools.');
|
const cmdlineToolsPath = `${process.env.ANDROID_SDK_ROOT}/cmdline-tools`;
|
||||||
const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX;
|
if (!fs.existsSync(cmdlineToolsPath)) {
|
||||||
const downloadPath = yield tc.downloadTool(sdkUrl);
|
console.log('Installing new cmdline-tools.');
|
||||||
yield tc.extractZip(downloadPath, cmdlineToolsPath);
|
const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX;
|
||||||
yield io.mv(`${cmdlineToolsPath}/cmdline-tools`, `${cmdlineToolsPath}/latest`);
|
const downloadPath = yield tc.downloadTool(sdkUrl);
|
||||||
}
|
yield tc.extractZip(downloadPath, cmdlineToolsPath);
|
||||||
// add paths for commandline-tools and platform-tools
|
yield io.mv(`${cmdlineToolsPath}/cmdline-tools`, `${cmdlineToolsPath}/latest`);
|
||||||
core.addPath(`${cmdlineToolsPath}/latest:${cmdlineToolsPath}/latest/bin:${process.env.ANDROID_SDK_ROOT}/platform-tools`);
|
}
|
||||||
// additional permission and license requirements for Linux
|
// add paths for commandline-tools and platform-tools
|
||||||
const sdkPreviewLicensePath = `${process.env.ANDROID_SDK_ROOT}/licenses/android-sdk-preview-license`;
|
core.addPath(`${cmdlineToolsPath}/latest:${cmdlineToolsPath}/latest/bin:${process.env.ANDROID_SDK_ROOT}/platform-tools`);
|
||||||
if (!isOnMac && !fs.existsSync(sdkPreviewLicensePath)) {
|
// set standard AVD path
|
||||||
fs.writeFileSync(sdkPreviewLicensePath, '\n84831b9409646a918e30573bab4c9c91346d8abd');
|
core.exportVariable('ANDROID_AVD_HOME', `${process.env.HOME}/.android/avd`);
|
||||||
}
|
// accept all Android SDK licenses
|
||||||
// license required for API 30 and non-default API 28 system images
|
yield exec.exec(`sh -c \\"yes | sdkmanager --licenses > /dev/null"`);
|
||||||
const sdkArmDbtLicensePath = `${process.env.ANDROID_SDK_ROOT}/licenses/android-sdk-arm-dbt-license`;
|
console.log('Installing latest build tools, platform tools, and platform.');
|
||||||
if (requiresArmDbtLicense(apiLevel, target) && !fs.existsSync(sdkArmDbtLicensePath)) {
|
yield exec.exec(`sh -c \\"sdkmanager --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`);
|
||||||
fs.writeFileSync(sdkArmDbtLicensePath, '\n859f317696f67ef3d7f30a50a5560e7834b43903');
|
|
||||||
}
|
|
||||||
console.log('Installing latest build tools, platform tools, and platform.');
|
|
||||||
yield exec.exec(`sh -c \\"sdkmanager --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`);
|
|
||||||
if (emulatorBuild) {
|
|
||||||
console.log(`Installing emulator build ${emulatorBuild}.`);
|
|
||||||
yield exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}-${emulatorBuild}.zip`);
|
|
||||||
yield io.rmRF(`${process.env.ANDROID_SDK_ROOT}/emulator`);
|
|
||||||
yield exec.exec(`unzip -q emulator.zip -d ${process.env.ANDROID_SDK_ROOT}`);
|
|
||||||
yield io.rmRF('emulator.zip');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log('Installing latest emulator.');
|
console.log('Installing latest emulator.');
|
||||||
yield exec.exec(`sh -c \\"sdkmanager --install emulator > /dev/null"`);
|
yield exec.exec(`sh -c \\"sdkmanager --install emulator --channel=${channelId} > /dev/null"`);
|
||||||
|
if (emulatorBuild) {
|
||||||
|
console.log(`Installing emulator build ${emulatorBuild}.`);
|
||||||
|
// TODO find out the correct download URLs for all build ids
|
||||||
|
const downloadUrlSuffix = Number(emulatorBuild.charAt(0)) > 6 ? `_x64-${emulatorBuild}` : `-${emulatorBuild}`;
|
||||||
|
yield exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}${downloadUrlSuffix}.zip`);
|
||||||
|
yield exec.exec(`unzip -o -q emulator.zip -d ${process.env.ANDROID_SDK_ROOT}`);
|
||||||
|
yield io.rmRF('emulator.zip');
|
||||||
|
}
|
||||||
|
console.log('Installing system images.');
|
||||||
|
yield exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${apiLevel};${target};${arch}' --channel=${channelId} > /dev/null"`);
|
||||||
|
if (ndkVersion) {
|
||||||
|
console.log(`Installing NDK ${ndkVersion}.`);
|
||||||
|
yield exec.exec(`sh -c \\"sdkmanager --install 'ndk;${ndkVersion}' --channel=${channelId} > /dev/null"`);
|
||||||
|
}
|
||||||
|
if (cmakeVersion) {
|
||||||
|
console.log(`Installing CMake ${cmakeVersion}.`);
|
||||||
|
yield exec.exec(`sh -c \\"sdkmanager --install 'cmake;${cmakeVersion}' --channel=${channelId} > /dev/null"`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
console.log('Installing system images.');
|
finally {
|
||||||
yield exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
|
console.log(`::endgroup::`);
|
||||||
if (ndkVersion) {
|
|
||||||
console.log(`Installing NDK ${ndkVersion}.`);
|
|
||||||
yield exec.exec(`sh -c \\"sdkmanager --install 'ndk;${ndkVersion}' > /dev/null"`);
|
|
||||||
}
|
|
||||||
if (cmakeVersion) {
|
|
||||||
console.log(`Installing CMake ${cmakeVersion}.`);
|
|
||||||
yield exec.exec(`sh -c \\"sdkmanager --install 'cmake;${cmakeVersion}' > /dev/null"`);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.installAndroidSdk = installAndroidSdk;
|
exports.installAndroidSdk = installAndroidSdk;
|
||||||
function requiresArmDbtLicense(apiLevel, target) {
|
|
||||||
return apiLevel === 30 || (apiLevel === 28 && target !== 'default');
|
|
||||||
}
|
|
||||||
|
|||||||
+124
@@ -0,0 +1,124 @@
|
|||||||
|
{
|
||||||
|
"name": "android-emulator-runner",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"node_modules/@actions/core": {
|
||||||
|
"version": "1.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz",
|
||||||
|
"integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/http-client": "^1.0.11"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@actions/exec": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-LImpN9AY0J1R1mEYJjVJfSZWU4zYOlEcwSTgPve1rFQqK5AwrEs6uWW5Rv70gbDIQIAUwI86z6B+9mPK4w9Sbg==",
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/io": "^1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@actions/http-client": {
|
||||||
|
"version": "1.0.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
|
||||||
|
"integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
|
||||||
|
"dependencies": {
|
||||||
|
"tunnel": "0.0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@actions/io": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-Qi4JoKXjmE0O67wAOH6y0n26QXhMKMFo7GD/4IXNVcrtLjUlGjGuVys6pQgwF3ArfGTQu0XpqaNr0YhED2RaRA=="
|
||||||
|
},
|
||||||
|
"node_modules/@actions/tool-cache": {
|
||||||
|
"version": "1.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.7.1.tgz",
|
||||||
|
"integrity": "sha512-y1xxxOhXaBUIUit3lhepmu/0xdgiTMpnZRLmVdtF0hTm521doi+MdRRRP62czHvM7wxH6epj4JPNJQ3iJpOrkQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/core": "^1.2.6",
|
||||||
|
"@actions/exec": "^1.0.0",
|
||||||
|
"@actions/http-client": "^1.0.8",
|
||||||
|
"@actions/io": "^1.1.1",
|
||||||
|
"semver": "^6.1.0",
|
||||||
|
"uuid": "^3.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/is-plain-object": {
|
||||||
|
"version": "2.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
|
||||||
|
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
|
||||||
|
"dependencies": {
|
||||||
|
"isobject": "^3.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/is-primitive": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-GljRxhWvlCNRfZyORiH77FwdFwGcMO620o37EOYC0ORWdq+WYNVqW0w2Juzew4M+L81l6/QS3t5gkkihyRqv9w==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/isobject": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
|
||||||
|
"integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/minimist": {
|
||||||
|
"version": "1.2.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
|
||||||
|
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
|
||||||
|
},
|
||||||
|
"node_modules/semver": {
|
||||||
|
"version": "6.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||||
|
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
|
||||||
|
"bin": {
|
||||||
|
"semver": "bin/semver.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/set-value": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/set-value/-/set-value-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-zTEg4HL0RwVrqcWs3ztF+x1vkxfm0lP+MQQFPiMJTKVceBwEV0A569Ou8l9IYQG8jOZdMVI1hGsc0tmeD2o/Lw==",
|
||||||
|
"funding": [
|
||||||
|
"https://github.com/sponsors/jonschlinkert",
|
||||||
|
"https://paypal.me/jonathanschlinkert",
|
||||||
|
"https://jonschlinkert.dev/sponsor"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"is-plain-object": "^2.0.4",
|
||||||
|
"is-primitive": "^3.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=11.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tunnel": {
|
||||||
|
"version": "0.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
||||||
|
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/uuid": {
|
||||||
|
"version": "3.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||||
|
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||||
|
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "bin/uuid"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+171
-6
@@ -16,11 +16,14 @@ import * as core from '@actions/core';
|
|||||||
|
|
||||||
#### Inputs/Outputs
|
#### Inputs/Outputs
|
||||||
|
|
||||||
Action inputs can be read with `getInput`. Outputs can be set with `setOutput` which makes them available to be mapped into inputs of other actions to ensure they are decoupled.
|
Action inputs can be read with `getInput` which returns a `string` or `getBooleanInput` which parses a boolean based on the [yaml 1.2 specification](https://yaml.org/spec/1.2/spec.html#id2804923). If `required` set to be false, the input should have a default value in `action.yml`.
|
||||||
|
|
||||||
|
Outputs can be set with `setOutput` which makes them available to be mapped into inputs of other actions to ensure they are decoupled.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const myInput = core.getInput('inputName', { required: true });
|
const myInput = core.getInput('inputName', { required: true });
|
||||||
|
const myBooleanInput = core.getBooleanInput('booleanInputName', { required: true });
|
||||||
|
const myMultilineInput = core.getMultilineInput('multilineInputName', { required: true });
|
||||||
core.setOutput('outputKey', 'outputVal');
|
core.setOutput('outputKey', 'outputVal');
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -62,11 +65,10 @@ catch (err) {
|
|||||||
// setFailed logs the message and sets a failing exit code
|
// setFailed logs the message and sets a failing exit code
|
||||||
core.setFailed(`Action failed with error ${err}`);
|
core.setFailed(`Action failed with error ${err}`);
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Note that `setNeutral` is not yet implemented in actions V2 but equivalent functionality is being planned.
|
Note that `setNeutral` is not yet implemented in actions V2 but equivalent functionality is being planned.
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Logging
|
#### Logging
|
||||||
|
|
||||||
Finally, this library provides some utilities for logging. Note that debug logging is hidden from the logs by default. This behavior can be toggled by enabling the [Step Debug Logs](../../docs/action-debugging.md#step-debug-logs).
|
Finally, this library provides some utilities for logging. Note that debug logging is hidden from the logs by default. This behavior can be toggled by enabling the [Step Debug Logs](../../docs/action-debugging.md#step-debug-logs).
|
||||||
@@ -90,6 +92,8 @@ try {
|
|||||||
|
|
||||||
// Do stuff
|
// Do stuff
|
||||||
core.info('Output to the actions build log')
|
core.info('Output to the actions build log')
|
||||||
|
|
||||||
|
core.notice('This is a message that will also emit an annotation')
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
core.error(`Error ${err}, action may still succeed though`);
|
core.error(`Error ${err}, action may still succeed though`);
|
||||||
@@ -113,11 +117,123 @@ const result = await core.group('Do something async', async () => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Annotations
|
||||||
|
|
||||||
|
This library has 3 methods that will produce [annotations](https://docs.github.com/en/rest/reference/checks#create-a-check-run).
|
||||||
|
```js
|
||||||
|
core.error('This is a bad error. This will also fail the build.')
|
||||||
|
|
||||||
|
core.warning('Something went wrong, but it\'s not bad enough to fail the build.')
|
||||||
|
|
||||||
|
core.notice('Something happened that you might want to know about.')
|
||||||
|
```
|
||||||
|
|
||||||
|
These will surface to the UI in the Actions page and on Pull Requests. They look something like this:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
These annotations can also be attached to particular lines and columns of your source files to show exactly where a problem is occuring.
|
||||||
|
|
||||||
|
These options are:
|
||||||
|
```typescript
|
||||||
|
export interface AnnotationProperties {
|
||||||
|
/**
|
||||||
|
* A title for the annotation.
|
||||||
|
*/
|
||||||
|
title?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the file for which the annotation should be created.
|
||||||
|
*/
|
||||||
|
file?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The start line for the annotation.
|
||||||
|
*/
|
||||||
|
startLine?: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The end line for the annotation. Defaults to `startLine` when `startLine` is provided.
|
||||||
|
*/
|
||||||
|
endLine?: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
|
||||||
|
*/
|
||||||
|
startColumn?: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
|
||||||
|
* Defaults to `startColumn` when `startColumn` is provided.
|
||||||
|
*/
|
||||||
|
endColumn?: number
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Styling output
|
||||||
|
|
||||||
|
Colored output is supported in the Action logs via standard [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code). 3/4 bit, 8 bit and 24 bit colors are all supported.
|
||||||
|
|
||||||
|
Foreground colors:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// 3/4 bit
|
||||||
|
core.info('\u001b[35mThis foreground will be magenta')
|
||||||
|
|
||||||
|
// 8 bit
|
||||||
|
core.info('\u001b[38;5;6mThis foreground will be cyan')
|
||||||
|
|
||||||
|
// 24 bit
|
||||||
|
core.info('\u001b[38;2;255;0;0mThis foreground will be bright red')
|
||||||
|
```
|
||||||
|
|
||||||
|
Background colors:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// 3/4 bit
|
||||||
|
core.info('\u001b[43mThis background will be yellow');
|
||||||
|
|
||||||
|
// 8 bit
|
||||||
|
core.info('\u001b[48;5;6mThis background will be cyan')
|
||||||
|
|
||||||
|
// 24 bit
|
||||||
|
core.info('\u001b[48;2;255;0;0mThis background will be bright red')
|
||||||
|
```
|
||||||
|
|
||||||
|
Special styles:
|
||||||
|
|
||||||
|
```js
|
||||||
|
core.info('\u001b[1mBold text')
|
||||||
|
core.info('\u001b[3mItalic text')
|
||||||
|
core.info('\u001b[4mUnderlined text')
|
||||||
|
```
|
||||||
|
|
||||||
|
ANSI escape codes can be combined with one another:
|
||||||
|
|
||||||
|
```js
|
||||||
|
core.info('\u001b[31;46mRed foreground with a cyan background and \u001b[1mbold text at the end');
|
||||||
|
```
|
||||||
|
|
||||||
|
> Note: Escape codes reset at the start of each line
|
||||||
|
|
||||||
|
```js
|
||||||
|
core.info('\u001b[35mThis foreground will be magenta')
|
||||||
|
core.info('This foreground will reset to the default')
|
||||||
|
```
|
||||||
|
|
||||||
|
Manually typing escape codes can be a little difficult, but you can use third party modules such as [ansi-styles](https://github.com/chalk/ansi-styles).
|
||||||
|
|
||||||
|
```js
|
||||||
|
const style = require('ansi-styles');
|
||||||
|
core.info(style.color.ansi16m.hex('#abcdef') + 'Hello world!')
|
||||||
|
```
|
||||||
|
|
||||||
#### Action state
|
#### Action state
|
||||||
|
|
||||||
You can use this library to save state and get state for sharing information between a given wrapper action:
|
You can use this library to save state and get state for sharing information between a given wrapper action:
|
||||||
|
|
||||||
|
**action.yml**:
|
||||||
|
|
||||||
**action.yml**
|
|
||||||
```yaml
|
```yaml
|
||||||
name: 'Wrapper action sample'
|
name: 'Wrapper action sample'
|
||||||
inputs:
|
inputs:
|
||||||
@@ -138,6 +254,7 @@ core.saveState("pidToKill", 12345);
|
|||||||
```
|
```
|
||||||
|
|
||||||
In action's `cleanup.js`:
|
In action's `cleanup.js`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
|
|
||||||
@@ -145,3 +262,51 @@ var pid = core.getState("pidToKill");
|
|||||||
|
|
||||||
process.kill(pid);
|
process.kill(pid);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### OIDC Token
|
||||||
|
|
||||||
|
You can use these methods to interact with the GitHub OIDC provider and get a JWT ID token which would help to get access token from third party cloud providers.
|
||||||
|
|
||||||
|
**Method Name**: getIDToken()
|
||||||
|
|
||||||
|
**Inputs**
|
||||||
|
|
||||||
|
audience : optional
|
||||||
|
|
||||||
|
**Outputs**
|
||||||
|
|
||||||
|
A [JWT](https://jwt.io/) ID Token
|
||||||
|
|
||||||
|
In action's `main.ts`:
|
||||||
|
```js
|
||||||
|
const core = require('@actions/core');
|
||||||
|
async function getIDTokenAction(): Promise<void> {
|
||||||
|
|
||||||
|
const audience = core.getInput('audience', {required: false})
|
||||||
|
|
||||||
|
const id_token1 = await core.getIDToken() // ID Token with default audience
|
||||||
|
const id_token2 = await core.getIDToken(audience) // ID token with custom audience
|
||||||
|
|
||||||
|
// this id_token can be used to get access token from third party cloud providers
|
||||||
|
}
|
||||||
|
getIDTokenAction()
|
||||||
|
```
|
||||||
|
|
||||||
|
In action's `actions.yml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: 'GetIDToken'
|
||||||
|
description: 'Get ID token from Github OIDC provider'
|
||||||
|
inputs:
|
||||||
|
audience:
|
||||||
|
description: 'Audience for which the ID token is intended for'
|
||||||
|
required: false
|
||||||
|
outputs:
|
||||||
|
id_token1:
|
||||||
|
description: 'ID token obtained from OIDC provider'
|
||||||
|
id_token2:
|
||||||
|
description: 'ID token obtained from OIDC provider'
|
||||||
|
runs:
|
||||||
|
using: 'node12'
|
||||||
|
main: 'dist/index.js'
|
||||||
|
```
|
||||||
+1
-2
@@ -1,4 +1,4 @@
|
|||||||
interface CommandProperties {
|
export interface CommandProperties {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -13,4 +13,3 @@ interface CommandProperties {
|
|||||||
*/
|
*/
|
||||||
export declare function issueCommand(command: string, properties: CommandProperties, message: any): void;
|
export declare function issueCommand(command: string, properties: CommandProperties, message: any): void;
|
||||||
export declare function issue(name: string, message?: string): void;
|
export declare function issue(name: string, message?: string): void;
|
||||||
export {};
|
|
||||||
|
|||||||
+15
-2
@@ -1,12 +1,25 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.issue = exports.issueCommand = void 0;
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const utils_1 = require("./utils");
|
const utils_1 = require("./utils");
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAwB;AACxB,mCAAsC;AAWtC;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAY;IAEZ,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAPD,oCAOC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,U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KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC"}
|
||||||
+68
-4
@@ -4,6 +4,8 @@
|
|||||||
export interface InputOptions {
|
export interface InputOptions {
|
||||||
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
|
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
|
/** Optional. Whether leading/trailing whitespace will be trimmed for the input. Defaults to true */
|
||||||
|
trimWhitespace?: boolean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* The code to exit an action
|
* The code to exit an action
|
||||||
@@ -18,6 +20,37 @@ export declare enum ExitCode {
|
|||||||
*/
|
*/
|
||||||
Failure = 1
|
Failure = 1
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Optional properties that can be sent with annotatation commands (notice, error, and warning)
|
||||||
|
* See: https://docs.github.com/en/rest/reference/checks#create-a-check-run for more information about annotations.
|
||||||
|
*/
|
||||||
|
export interface AnnotationProperties {
|
||||||
|
/**
|
||||||
|
* A title for the annotation.
|
||||||
|
*/
|
||||||
|
title?: string;
|
||||||
|
/**
|
||||||
|
* The path of the file for which the annotation should be created.
|
||||||
|
*/
|
||||||
|
file?: string;
|
||||||
|
/**
|
||||||
|
* The start line for the annotation.
|
||||||
|
*/
|
||||||
|
startLine?: number;
|
||||||
|
/**
|
||||||
|
* The end line for the annotation. Defaults to `startLine` when `startLine` is provided.
|
||||||
|
*/
|
||||||
|
endLine?: number;
|
||||||
|
/**
|
||||||
|
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
|
||||||
|
*/
|
||||||
|
startColumn?: number;
|
||||||
|
/**
|
||||||
|
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
|
||||||
|
* Defaults to `startColumn` when `startColumn` is provided.
|
||||||
|
*/
|
||||||
|
endColumn?: number;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Sets env variable for this action and future actions in the job
|
* Sets env variable for this action and future actions in the job
|
||||||
* @param name the name of the variable to set
|
* @param name the name of the variable to set
|
||||||
@@ -35,13 +68,35 @@ export declare function setSecret(secret: string): void;
|
|||||||
*/
|
*/
|
||||||
export declare function addPath(inputPath: string): void;
|
export declare function addPath(inputPath: string): void;
|
||||||
/**
|
/**
|
||||||
* Gets the value of an input. The value is also trimmed.
|
* Gets the value of an input.
|
||||||
|
* Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
|
||||||
|
* Returns an empty string if the value is not defined.
|
||||||
*
|
*
|
||||||
* @param name name of the input to get
|
* @param name name of the input to get
|
||||||
* @param options optional. See InputOptions.
|
* @param options optional. See InputOptions.
|
||||||
* @returns string
|
* @returns string
|
||||||
*/
|
*/
|
||||||
export declare function getInput(name: string, options?: InputOptions): string;
|
export declare function getInput(name: string, options?: InputOptions): string;
|
||||||
|
/**
|
||||||
|
* Gets the values of an multiline input. Each value is also trimmed.
|
||||||
|
*
|
||||||
|
* @param name name of the input to get
|
||||||
|
* @param options optional. See InputOptions.
|
||||||
|
* @returns string[]
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export declare function getMultilineInput(name: string, options?: InputOptions): string[];
|
||||||
|
/**
|
||||||
|
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
|
||||||
|
* Support boolean input list: `true | True | TRUE | false | False | FALSE` .
|
||||||
|
* The return value is also in boolean type.
|
||||||
|
* ref: https://yaml.org/spec/1.2/spec.html#id2804923
|
||||||
|
*
|
||||||
|
* @param name name of the input to get
|
||||||
|
* @param options optional. See InputOptions.
|
||||||
|
* @returns boolean
|
||||||
|
*/
|
||||||
|
export declare function getBooleanInput(name: string, options?: InputOptions): boolean;
|
||||||
/**
|
/**
|
||||||
* Sets the value of an output.
|
* Sets the value of an output.
|
||||||
*
|
*
|
||||||
@@ -73,13 +128,21 @@ export declare function debug(message: string): void;
|
|||||||
/**
|
/**
|
||||||
* Adds an error issue
|
* Adds an error issue
|
||||||
* @param message error issue message. Errors will be converted to string via toString()
|
* @param message error issue message. Errors will be converted to string via toString()
|
||||||
|
* @param properties optional properties to add to the annotation.
|
||||||
*/
|
*/
|
||||||
export declare function error(message: string | Error): void;
|
export declare function error(message: string | Error, properties?: AnnotationProperties): void;
|
||||||
/**
|
/**
|
||||||
* Adds an warning issue
|
* Adds a warning issue
|
||||||
* @param message warning issue message. Errors will be converted to string via toString()
|
* @param message warning issue message. Errors will be converted to string via toString()
|
||||||
|
* @param properties optional properties to add to the annotation.
|
||||||
*/
|
*/
|
||||||
export declare function warning(message: string | Error): void;
|
export declare function warning(message: string | Error, properties?: AnnotationProperties): void;
|
||||||
|
/**
|
||||||
|
* Adds a notice issue
|
||||||
|
* @param message notice issue message. Errors will be converted to string via toString()
|
||||||
|
* @param properties optional properties to add to the annotation.
|
||||||
|
*/
|
||||||
|
export declare function notice(message: string | Error, properties?: AnnotationProperties): void;
|
||||||
/**
|
/**
|
||||||
* Writes info to log with console.log.
|
* Writes info to log with console.log.
|
||||||
* @param message info message
|
* @param message info message
|
||||||
@@ -120,3 +183,4 @@ export declare function saveState(name: string, value: any): void;
|
|||||||
* @returns string
|
* @returns string
|
||||||
*/
|
*/
|
||||||
export declare function getState(name: string): string;
|
export declare function getState(name: string): string;
|
||||||
|
export declare function getIDToken(aud?: string): Promise<string>;
|
||||||
|
|||||||
+87
-13
@@ -1,4 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -8,19 +27,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
|
||||||
const command_1 = require("./command");
|
const command_1 = require("./command");
|
||||||
const file_command_1 = require("./file-command");
|
const file_command_1 = require("./file-command");
|
||||||
const utils_1 = require("./utils");
|
const utils_1 = require("./utils");
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
|
const oidc_utils_1 = require("./oidc-utils");
|
||||||
/**
|
/**
|
||||||
* The code to exit an action
|
* The code to exit an action
|
||||||
*/
|
*/
|
||||||
@@ -82,7 +96,9 @@ function addPath(inputPath) {
|
|||||||
}
|
}
|
||||||
exports.addPath = addPath;
|
exports.addPath = addPath;
|
||||||
/**
|
/**
|
||||||
* Gets the value of an input. The value is also trimmed.
|
* Gets the value of an input.
|
||||||
|
* Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
|
||||||
|
* Returns an empty string if the value is not defined.
|
||||||
*
|
*
|
||||||
* @param name name of the input to get
|
* @param name name of the input to get
|
||||||
* @param options optional. See InputOptions.
|
* @param options optional. See InputOptions.
|
||||||
@@ -93,9 +109,49 @@ function getInput(name, options) {
|
|||||||
if (options && options.required && !val) {
|
if (options && options.required && !val) {
|
||||||
throw new Error(`Input required and not supplied: ${name}`);
|
throw new Error(`Input required and not supplied: ${name}`);
|
||||||
}
|
}
|
||||||
|
if (options && options.trimWhitespace === false) {
|
||||||
|
return val;
|
||||||
|
}
|
||||||
return val.trim();
|
return val.trim();
|
||||||
}
|
}
|
||||||
exports.getInput = getInput;
|
exports.getInput = getInput;
|
||||||
|
/**
|
||||||
|
* Gets the values of an multiline input. Each value is also trimmed.
|
||||||
|
*
|
||||||
|
* @param name name of the input to get
|
||||||
|
* @param options optional. See InputOptions.
|
||||||
|
* @returns string[]
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function getMultilineInput(name, options) {
|
||||||
|
const inputs = getInput(name, options)
|
||||||
|
.split('\n')
|
||||||
|
.filter(x => x !== '');
|
||||||
|
return inputs;
|
||||||
|
}
|
||||||
|
exports.getMultilineInput = getMultilineInput;
|
||||||
|
/**
|
||||||
|
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
|
||||||
|
* Support boolean input list: `true | True | TRUE | false | False | FALSE` .
|
||||||
|
* The return value is also in boolean type.
|
||||||
|
* ref: https://yaml.org/spec/1.2/spec.html#id2804923
|
||||||
|
*
|
||||||
|
* @param name name of the input to get
|
||||||
|
* @param options optional. See InputOptions.
|
||||||
|
* @returns boolean
|
||||||
|
*/
|
||||||
|
function getBooleanInput(name, options) {
|
||||||
|
const trueValue = ['true', 'True', 'TRUE'];
|
||||||
|
const falseValue = ['false', 'False', 'FALSE'];
|
||||||
|
const val = getInput(name, options);
|
||||||
|
if (trueValue.includes(val))
|
||||||
|
return true;
|
||||||
|
if (falseValue.includes(val))
|
||||||
|
return false;
|
||||||
|
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` +
|
||||||
|
`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
|
||||||
|
}
|
||||||
|
exports.getBooleanInput = getBooleanInput;
|
||||||
/**
|
/**
|
||||||
* Sets the value of an output.
|
* Sets the value of an output.
|
||||||
*
|
*
|
||||||
@@ -104,6 +160,7 @@ exports.getInput = getInput;
|
|||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function setOutput(name, value) {
|
function setOutput(name, value) {
|
||||||
|
process.stdout.write(os.EOL);
|
||||||
command_1.issueCommand('set-output', { name }, value);
|
command_1.issueCommand('set-output', { name }, value);
|
||||||
}
|
}
|
||||||
exports.setOutput = setOutput;
|
exports.setOutput = setOutput;
|
||||||
@@ -150,19 +207,30 @@ exports.debug = debug;
|
|||||||
/**
|
/**
|
||||||
* Adds an error issue
|
* Adds an error issue
|
||||||
* @param message error issue message. Errors will be converted to string via toString()
|
* @param message error issue message. Errors will be converted to string via toString()
|
||||||
|
* @param properties optional properties to add to the annotation.
|
||||||
*/
|
*/
|
||||||
function error(message) {
|
function error(message, properties = {}) {
|
||||||
command_1.issue('error', message instanceof Error ? message.toString() : message);
|
command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
||||||
}
|
}
|
||||||
exports.error = error;
|
exports.error = error;
|
||||||
/**
|
/**
|
||||||
* Adds an warning issue
|
* Adds a warning issue
|
||||||
* @param message warning issue message. Errors will be converted to string via toString()
|
* @param message warning issue message. Errors will be converted to string via toString()
|
||||||
|
* @param properties optional properties to add to the annotation.
|
||||||
*/
|
*/
|
||||||
function warning(message) {
|
function warning(message, properties = {}) {
|
||||||
command_1.issue('warning', message instanceof Error ? message.toString() : message);
|
command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
||||||
}
|
}
|
||||||
exports.warning = warning;
|
exports.warning = warning;
|
||||||
|
/**
|
||||||
|
* Adds a notice issue
|
||||||
|
* @param message notice issue message. Errors will be converted to string via toString()
|
||||||
|
* @param properties optional properties to add to the annotation.
|
||||||
|
*/
|
||||||
|
function notice(message, properties = {}) {
|
||||||
|
command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
||||||
|
}
|
||||||
|
exports.notice = notice;
|
||||||
/**
|
/**
|
||||||
* Writes info to log with console.log.
|
* Writes info to log with console.log.
|
||||||
* @param message info message
|
* @param message info message
|
||||||
@@ -235,4 +303,10 @@ function getState(name) {
|
|||||||
return process.env[`STATE_${name}`] || '';
|
return process.env[`STATE_${name}`] || '';
|
||||||
}
|
}
|
||||||
exports.getState = getState;
|
exports.getState = getState;
|
||||||
|
function getIDToken(aud) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return yield oidc_utils_1.OidcClient.getIDToken(aud);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.getIDToken = getIDToken;
|
||||||
//# sourceMappingURL=core.js.map
|
//# sourceMappingURL=core.js.map
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAA6C;AAC7C,iDAA+D;AAC/D,mCAAsC;AAEtC,uCAAwB;AACxB,2CAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,8DAA8D;AAC9D,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAQ;IACnD,MAAM,YAAY,GAAG,sBAAc,CAAC,GAAG,CAAC,CAAA;IACxC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,YAAY,CAAA;IAEhC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAA;IAChD,IAAI,QAAQ,EAAE;QACZ,MAAM,SAAS,GAAG,qCAAqC,CAAA;QACvD,MAAM,YAAY,GAAG,GAAG,IAAI,KAAK,SAAS,GAAG,EAAE,CAAC,GAAG,GAAG,YAAY,GAAG,EAAE,CAAC,GAAG,GAAG,SAAS,EAAE,CAAA;QACzF,2BAAgB,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;KACtC;SAAM;QACL,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,YAAY,CAAC,CAAA;KAC9C;AACH,CAAC;AAZD,wCAYC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,MAAc;IACtC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,MAAM,CAAC,CAAA;AACtC,CAAC;AAFD,8BAEC;AAED;;;GAGG;AACH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CAAC,IAAI,EAAE,CAAA;AAC3C,CAAC;AAFD,4BAEC;AAED,SAAsB,UAAU,CAAC,GAAY;;QAC3C,OAAO,MAAM,uBAAU,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IACzC,CAAC;CAAA;AAFD,gCAEC"}
|
||||||
+15
-2
@@ -1,13 +1,26 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
// For internal use, subject to change.
|
// For internal use, subject to change.
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.issueCommand = void 0;
|
||||||
// We use any as a valid input type
|
// We use any as a valid input type
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"file-command.js","sourceRoot":"","sources":["../src/file-command.ts"],"names":[],"mappings":";AAAA,uCAAuC;;;;;;;;;AAEvC,mCAAmC;AACnC,uDAAuD;AAEvD,uCAAwB;AACxB,uCAAwB;AACxB,mCAAsC;AAEtC,SAAgB,YAAY,CAAC,OAAe,EAAE,OAAY;IACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,CAAC,CAAA;IACjD,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CACb,wDAAwD,OAAO,EAAE,CAClE,CAAA;KACF;IACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAA;KACrD;IAED,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,sBAAc,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;QACjE,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAA;AACJ,CAAC;AAdD,oCAcC"}
|
{"version":3,"file":"file-command.js","sourceRoot":"","sources":["../src/file-command.ts"],"names":[],"mappings":";AAAA,uCAAuC;;;;;;;;;;;;;;;;;;;;;;AAEvC,mCAAmC;AACnC,uDAAuD;AAEvD,uCAAwB;AACxB,uCAAwB;AACxB,mCAAsC;AAEtC,SAAgB,YAAY,CAAC,OAAe,EAAE,OAAY;IACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,CAAC,CAAA;IACjD,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CACb,wDAAwD,OAAO,EAAE,CAClE,CAAA;KACF;IACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAA;KACrD;IAED,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,sBAAc,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;QACjE,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAA;AACJ,CAAC;AAdD,oCAcC"}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
export declare class OidcClient {
|
||||||
|
private static createHttpClient;
|
||||||
|
private static getRequestToken;
|
||||||
|
private static getIDTokenUrl;
|
||||||
|
private static getCall;
|
||||||
|
static getIDToken(audience?: string): Promise<string>;
|
||||||
|
}
|
||||||
+77
@@ -0,0 +1,77 @@
|
|||||||
|
"use strict";
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.OidcClient = void 0;
|
||||||
|
const http_client_1 = require("@actions/http-client");
|
||||||
|
const auth_1 = require("@actions/http-client/auth");
|
||||||
|
const core_1 = require("./core");
|
||||||
|
class OidcClient {
|
||||||
|
static createHttpClient(allowRetry = true, maxRetry = 10) {
|
||||||
|
const requestOptions = {
|
||||||
|
allowRetries: allowRetry,
|
||||||
|
maxRetries: maxRetry
|
||||||
|
};
|
||||||
|
return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions);
|
||||||
|
}
|
||||||
|
static getRequestToken() {
|
||||||
|
const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN'];
|
||||||
|
if (!token) {
|
||||||
|
throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable');
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
static getIDTokenUrl() {
|
||||||
|
const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL'];
|
||||||
|
if (!runtimeUrl) {
|
||||||
|
throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable');
|
||||||
|
}
|
||||||
|
return runtimeUrl;
|
||||||
|
}
|
||||||
|
static getCall(id_token_url) {
|
||||||
|
var _a;
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const httpclient = OidcClient.createHttpClient();
|
||||||
|
const res = yield httpclient
|
||||||
|
.getJson(id_token_url)
|
||||||
|
.catch(error => {
|
||||||
|
throw new Error(`Failed to get ID Token. \n
|
||||||
|
Error Code : ${error.statusCode}\n
|
||||||
|
Error Message: ${error.result.message}`);
|
||||||
|
});
|
||||||
|
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
|
||||||
|
if (!id_token) {
|
||||||
|
throw new Error('Response json body do not have ID Token field');
|
||||||
|
}
|
||||||
|
return id_token;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static getIDToken(audience) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
try {
|
||||||
|
// New ID Token is requested from action service
|
||||||
|
let id_token_url = OidcClient.getIDTokenUrl();
|
||||||
|
if (audience) {
|
||||||
|
const encodedAudience = encodeURIComponent(audience);
|
||||||
|
id_token_url = `${id_token_url}&audience=${encodedAudience}`;
|
||||||
|
}
|
||||||
|
core_1.debug(`ID token url is ${id_token_url}`);
|
||||||
|
const id_token = yield OidcClient.getCall(id_token_url);
|
||||||
|
core_1.setSecret(id_token);
|
||||||
|
return id_token;
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
throw new Error(`Error message: ${error.message}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.OidcClient = OidcClient;
|
||||||
|
//# sourceMappingURL=oidc-utils.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"oidc-utils.js","sourceRoot":"","sources":["../src/oidc-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,sDAA+C;AAC/C,oDAAiE;AACjE,iCAAuC;AAKvC,MAAa,UAAU;IACb,MAAM,CAAC,gBAAgB,CAC7B,UAAU,GAAG,IAAI,EACjB,QAAQ,GAAG,EAAE;QAEb,MAAM,cAAc,GAAoB;YACtC,YAAY,EAAE,UAAU;YACxB,UAAU,EAAE,QAAQ;SACrB,CAAA;QAED,OAAO,IAAI,wBAAU,CACnB,qBAAqB,EACrB,CAAC,IAAI,8BAAuB,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC,EAC3D,cAAc,CACf,CAAA;IACH,CAAC;IAEO,MAAM,CAAC,eAAe;QAC5B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAA;QAC3D,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAA;SACF;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAEO,MAAM,CAAC,aAAa;QAC1B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAA;QAC9D,IAAI,CAAC,UAAU,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAA;SAC3E;QACD,OAAO,UAAU,CAAA;IACnB,CAAC;IAEO,MAAM,CAAO,OAAO,CAAC,YAAoB;;;YAC/C,MAAM,UAAU,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAA;YAEhD,MAAM,GAAG,GAAG,MAAM,UAAU;iBACzB,OAAO,CAAgB,YAAY,CAAC;iBACpC,KAAK,CAAC,KAAK,CAAC,EAAE;gBACb,MAAM,IAAI,KAAK,CACb;uBACa,KAAK,CAAC,UAAU;yBACd,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CACtC,CAAA;YACH,CAAC,CAAC,CAAA;YAEJ,MAAM,QAAQ,SAAG,GAAG,CAAC,MAAM,0CAAE,KAAK,CAAA;YAClC,IAAI,CAAC,QAAQ,EAAE;gBACb,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;aACjE;YACD,OAAO,QAAQ,CAAA;;KAChB;IAED,MAAM,CAAO,UAAU,CAAC,QAAiB;;YACvC,IAAI;gBACF,gDAAgD;gBAChD,IAAI,YAAY,GAAW,UAAU,CAAC,aAAa,EAAE,CAAA;gBACrD,IAAI,QAAQ,EAAE;oBACZ,MAAM,eAAe,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAA;oBACpD,YAAY,GAAG,GAAG,YAAY,aAAa,eAAe,EAAE,CAAA;iBAC7D;gBAED,YAAK,CAAC,mBAAmB,YAAY,EAAE,CAAC,CAAA;gBAExC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;gBACvD,gBAAS,CAAC,QAAQ,CAAC,CAAA;gBACnB,OAAO,QAAQ,CAAA;aAChB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;aACnD;QACH,CAAC;KAAA;CACF;AAzED,gCAyEC"}
|
||||||
+9
@@ -1,5 +1,14 @@
|
|||||||
|
import { AnnotationProperties } from './core';
|
||||||
|
import { CommandProperties } from './command';
|
||||||
/**
|
/**
|
||||||
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
||||||
* @param input input to sanitize into a string
|
* @param input input to sanitize into a string
|
||||||
*/
|
*/
|
||||||
export declare function toCommandValue(input: any): string;
|
export declare function toCommandValue(input: any): string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param annotationProperties
|
||||||
|
* @returns The command properties to send with the actual annotation command
|
||||||
|
* See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
|
||||||
|
*/
|
||||||
|
export declare function toCommandProperties(annotationProperties: AnnotationProperties): CommandProperties;
|
||||||
|
|||||||
+21
@@ -2,6 +2,7 @@
|
|||||||
// We use any as a valid input type
|
// We use any as a valid input type
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.toCommandProperties = exports.toCommandValue = void 0;
|
||||||
/**
|
/**
|
||||||
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
||||||
* @param input input to sanitize into a string
|
* @param input input to sanitize into a string
|
||||||
@@ -16,4 +17,24 @@ function toCommandValue(input) {
|
|||||||
return JSON.stringify(input);
|
return JSON.stringify(input);
|
||||||
}
|
}
|
||||||
exports.toCommandValue = toCommandValue;
|
exports.toCommandValue = toCommandValue;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param annotationProperties
|
||||||
|
* @returns The command properties to send with the actual annotation command
|
||||||
|
* See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
|
||||||
|
*/
|
||||||
|
function toCommandProperties(annotationProperties) {
|
||||||
|
if (!Object.keys(annotationProperties).length) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
title: annotationProperties.title,
|
||||||
|
file: annotationProperties.file,
|
||||||
|
line: annotationProperties.startLine,
|
||||||
|
endLine: annotationProperties.endLine,
|
||||||
|
col: annotationProperties.startColumn,
|
||||||
|
endColumn: annotationProperties.endColumn
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.toCommandProperties = toCommandProperties;
|
||||||
//# sourceMappingURL=utils.js.map
|
//# sourceMappingURL=utils.js.map
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC,uDAAuD;;AAEvD;;;GAGG;AACH,SAAgB,cAAc,CAAC,KAAU;IACvC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;QACzC,OAAO,EAAE,CAAA;KACV;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,MAAM,EAAE;QAC/D,OAAO,KAAe,CAAA;KACvB;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC;AAPD,wCAOC"}
|
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC,uDAAuD;;;AAKvD;;;GAGG;AACH,SAAgB,cAAc,CAAC,KAAU;IACvC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;QACzC,OAAO,EAAE,CAAA;KACV;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,MAAM,EAAE;QAC/D,OAAO,KAAe,CAAA;KACvB;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC;AAPD,wCAOC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CACjC,oBAA0C;IAE1C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,MAAM,EAAE;QAC7C,OAAO,EAAE,CAAA;KACV;IAED,OAAO;QACL,KAAK,EAAE,oBAAoB,CAAC,KAAK;QACjC,IAAI,EAAE,oBAAoB,CAAC,IAAI;QAC/B,IAAI,EAAE,oBAAoB,CAAC,SAAS;QACpC,OAAO,EAAE,oBAAoB,CAAC,OAAO;QACrC,GAAG,EAAE,oBAAoB,CAAC,WAAW;QACrC,SAAS,EAAE,oBAAoB,CAAC,SAAS;KAC1C,CAAA;AACH,CAAC;AAfD,kDAeC"}
|
||||||
+20
-47
@@ -1,41 +1,16 @@
|
|||||||
{
|
{
|
||||||
"_args": [
|
"name": "@actions/core",
|
||||||
[
|
"version": "1.6.0",
|
||||||
"@actions/core@1.2.6",
|
|
||||||
"."
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "@actions/core@1.2.6",
|
|
||||||
"_id": "@actions/core@1.2.6",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==",
|
|
||||||
"_location": "/@actions/core",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "version",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "@actions/core@1.2.6",
|
|
||||||
"name": "@actions/core",
|
|
||||||
"escapedName": "@actions%2fcore",
|
|
||||||
"scope": "@actions",
|
|
||||||
"rawSpec": "1.2.6",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "1.2.6"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/",
|
|
||||||
"/@actions/tool-cache"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
|
|
||||||
"_spec": "1.2.6",
|
|
||||||
"_where": ".",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/actions/toolkit/issues"
|
|
||||||
},
|
|
||||||
"description": "Actions core lib",
|
"description": "Actions core lib",
|
||||||
"devDependencies": {
|
"keywords": [
|
||||||
"@types/node": "^12.0.2"
|
"github",
|
||||||
},
|
"actions",
|
||||||
|
"core"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/actions/toolkit/tree/main/packages/core",
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "lib/core.js",
|
||||||
|
"types": "lib/core.d.ts",
|
||||||
"directories": {
|
"directories": {
|
||||||
"lib": "lib",
|
"lib": "lib",
|
||||||
"test": "__tests__"
|
"test": "__tests__"
|
||||||
@@ -44,15 +19,6 @@
|
|||||||
"lib",
|
"lib",
|
||||||
"!.DS_Store"
|
"!.DS_Store"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/main/packages/core",
|
|
||||||
"keywords": [
|
|
||||||
"github",
|
|
||||||
"actions",
|
|
||||||
"core"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "lib/core.js",
|
|
||||||
"name": "@actions/core",
|
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -66,6 +32,13 @@
|
|||||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||||
"tsc": "tsc"
|
"tsc": "tsc"
|
||||||
},
|
},
|
||||||
"types": "lib/core.d.ts",
|
"bugs": {
|
||||||
"version": "1.2.6"
|
"url": "https://github.com/actions/toolkit/issues"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/http-client": "^1.0.11"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^12.0.2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright 2019 GitHub
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
+13
-2
@@ -1,5 +1,5 @@
|
|||||||
import { ExecOptions } from './interfaces';
|
import { ExecOptions, ExecOutput, ExecListeners } from './interfaces';
|
||||||
export { ExecOptions };
|
export { ExecOptions, ExecOutput, ExecListeners };
|
||||||
/**
|
/**
|
||||||
* Exec a command.
|
* Exec a command.
|
||||||
* Output will be streamed to the live console.
|
* Output will be streamed to the live console.
|
||||||
@@ -11,3 +11,14 @@ export { ExecOptions };
|
|||||||
* @returns Promise<number> exit code
|
* @returns Promise<number> exit code
|
||||||
*/
|
*/
|
||||||
export declare function exec(commandLine: string, args?: string[], options?: ExecOptions): Promise<number>;
|
export declare function exec(commandLine: string, args?: string[], options?: ExecOptions): Promise<number>;
|
||||||
|
/**
|
||||||
|
* Exec a command and get the output.
|
||||||
|
* Output will be streamed to the live console.
|
||||||
|
* Returns promise with the exit code and collected stdout and stderr
|
||||||
|
*
|
||||||
|
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
|
||||||
|
* @param args optional arguments for tool. Escaping is handled by the lib.
|
||||||
|
* @param options optional exec options. See ExecOptions
|
||||||
|
* @returns Promise<ExecOutput> exit code, stdout, and stderr
|
||||||
|
*/
|
||||||
|
export declare function getExecOutput(commandLine: string, args?: string[], options?: ExecOptions): Promise<ExecOutput>;
|
||||||
|
|||||||
+66
-7
@@ -1,4 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -8,14 +27,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.getExecOutput = exports.exec = void 0;
|
||||||
|
const string_decoder_1 = require("string_decoder");
|
||||||
const tr = __importStar(require("./toolrunner"));
|
const tr = __importStar(require("./toolrunner"));
|
||||||
/**
|
/**
|
||||||
* Exec a command.
|
* Exec a command.
|
||||||
@@ -41,4 +55,49 @@ function exec(commandLine, args, options) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.exec = exec;
|
exports.exec = exec;
|
||||||
|
/**
|
||||||
|
* Exec a command and get the output.
|
||||||
|
* Output will be streamed to the live console.
|
||||||
|
* Returns promise with the exit code and collected stdout and stderr
|
||||||
|
*
|
||||||
|
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
|
||||||
|
* @param args optional arguments for tool. Escaping is handled by the lib.
|
||||||
|
* @param options optional exec options. See ExecOptions
|
||||||
|
* @returns Promise<ExecOutput> exit code, stdout, and stderr
|
||||||
|
*/
|
||||||
|
function getExecOutput(commandLine, args, options) {
|
||||||
|
var _a, _b;
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let stdout = '';
|
||||||
|
let stderr = '';
|
||||||
|
//Using string decoder covers the case where a mult-byte character is split
|
||||||
|
const stdoutDecoder = new string_decoder_1.StringDecoder('utf8');
|
||||||
|
const stderrDecoder = new string_decoder_1.StringDecoder('utf8');
|
||||||
|
const originalStdoutListener = (_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout;
|
||||||
|
const originalStdErrListener = (_b = options === null || options === void 0 ? void 0 : options.listeners) === null || _b === void 0 ? void 0 : _b.stderr;
|
||||||
|
const stdErrListener = (data) => {
|
||||||
|
stderr += stderrDecoder.write(data);
|
||||||
|
if (originalStdErrListener) {
|
||||||
|
originalStdErrListener(data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const stdOutListener = (data) => {
|
||||||
|
stdout += stdoutDecoder.write(data);
|
||||||
|
if (originalStdoutListener) {
|
||||||
|
originalStdoutListener(data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const listeners = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.listeners), { stdout: stdOutListener, stderr: stdErrListener });
|
||||||
|
const exitCode = yield exec(commandLine, args, Object.assign(Object.assign({}, options), { listeners }));
|
||||||
|
//flush any remaining characters
|
||||||
|
stdout += stdoutDecoder.end();
|
||||||
|
stderr += stderrDecoder.end();
|
||||||
|
return {
|
||||||
|
exitCode,
|
||||||
|
stdout,
|
||||||
|
stderr
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.getExecOutput = getExecOutput;
|
||||||
//# sourceMappingURL=exec.js.map
|
//# sourceMappingURL=exec.js.map
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../src/exec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,iDAAkC;AAIlC;;;;;;;;;GASG;AACH,SAAsB,IAAI,CACxB,WAAmB,EACnB,IAAe,EACf,OAAqB;;QAErB,MAAM,WAAW,GAAG,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAA;QACpD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;SACpE;QACD,8CAA8C;QAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;QAC/B,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAA;QAC9C,MAAM,MAAM,GAAkB,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ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sBAAsB,SAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,0CAAE,MAAM,CAAA;QAEzD,MAAM,cAAc,GAAG,CAAC,IAAY,EAAQ,EAAE;YAC5C,MAAM,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YACnC,IAAI,sBAAsB,EAAE;gBAC1B,sBAAsB,CAAC,IAAI,CAAC,CAAA;aAC7B;QACH,CAAC,CAAA;QAED,MAAM,cAAc,GAAG,CAAC,IAAY,EAAQ,EAAE;YAC5C,MAAM,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YACnC,IAAI,sBAAsB,EAAE;gBAC1B,sBAAsB,CAAC,IAAI,CAAC,CAAA;aAC7B;QACH,CAAC,CAAA;QAED,MAAM,SAAS,mCACV,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,KACrB,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,cAAc,GACvB,CAAA;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,IAAI,kCAAM,OAAO,KAAE,SAAS,IAAE,CAAA;QAEvE,gCAAgC;QAChC,MAAM,IAAI,aAAa,CAAC,GAAG,EAAE,CAAA;QAC7B,MAAM,IAAI,aAAa,CAAC,GAAG,EAAE,CAAA;QAE7B,OAAO;YACL,QAAQ;YACR,MAAM;YACN,MAAM;SACP,CAAA;;CACF;AA9CD,sCA8CC"}
|
||||||
+27
-7
@@ -27,11 +27,31 @@ export interface ExecOptions {
|
|||||||
/** optional. input to write to the process on STDIN. */
|
/** optional. input to write to the process on STDIN. */
|
||||||
input?: Buffer;
|
input?: Buffer;
|
||||||
/** optional. Listeners for output. Callback functions that will be called on these events */
|
/** optional. Listeners for output. Callback functions that will be called on these events */
|
||||||
listeners?: {
|
listeners?: ExecListeners;
|
||||||
stdout?: (data: Buffer) => void;
|
}
|
||||||
stderr?: (data: Buffer) => void;
|
/**
|
||||||
stdline?: (data: string) => void;
|
* Interface for the output of getExecOutput()
|
||||||
errline?: (data: string) => void;
|
*/
|
||||||
debug?: (data: string) => void;
|
export interface ExecOutput {
|
||||||
};
|
/**The exit code of the process */
|
||||||
|
exitCode: number;
|
||||||
|
/**The entire stdout of the process as a string */
|
||||||
|
stdout: string;
|
||||||
|
/**The entire stderr of the process as a string */
|
||||||
|
stderr: string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The user defined listeners for an exec call
|
||||||
|
*/
|
||||||
|
export interface ExecListeners {
|
||||||
|
/** A call back for each buffer of stdout */
|
||||||
|
stdout?: (data: Buffer) => void;
|
||||||
|
/** A call back for each buffer of stderr */
|
||||||
|
stderr?: (data: Buffer) => void;
|
||||||
|
/** A call back for each line of stdout */
|
||||||
|
stdline?: (data: string) => void;
|
||||||
|
/** A call back for each line of stderr */
|
||||||
|
errline?: (data: string) => void;
|
||||||
|
/** A call back for each debug log */
|
||||||
|
debug?: (data: string) => void;
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-15
@@ -1,4 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -8,20 +27,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.argStringToArray = exports.ToolRunner = void 0;
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const events = __importStar(require("events"));
|
const events = __importStar(require("events"));
|
||||||
const child = __importStar(require("child_process"));
|
const child = __importStar(require("child_process"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const io = __importStar(require("@actions/io"));
|
const io = __importStar(require("@actions/io"));
|
||||||
const ioUtil = __importStar(require("@actions/io/lib/io-util"));
|
const ioUtil = __importStar(require("@actions/io/lib/io-util"));
|
||||||
|
const timers_1 = require("timers");
|
||||||
/* eslint-disable @typescript-eslint/unbound-method */
|
/* eslint-disable @typescript-eslint/unbound-method */
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
/*
|
/*
|
||||||
@@ -91,11 +105,12 @@ class ToolRunner extends events.EventEmitter {
|
|||||||
s = s.substring(n + os.EOL.length);
|
s = s.substring(n + os.EOL.length);
|
||||||
n = s.indexOf(os.EOL);
|
n = s.indexOf(os.EOL);
|
||||||
}
|
}
|
||||||
strBuffer = s;
|
return s;
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
// streaming lines to console is best effort. Don't fail a build.
|
// streaming lines to console is best effort. Don't fail a build.
|
||||||
this._debug(`error processing line. Failed with error ${err}`);
|
this._debug(`error processing line. Failed with error ${err}`);
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_getSpawnFileName() {
|
_getSpawnFileName() {
|
||||||
@@ -377,7 +392,7 @@ class ToolRunner extends events.EventEmitter {
|
|||||||
// if the tool is only a file name, then resolve it from the PATH
|
// if the tool is only a file name, then resolve it from the PATH
|
||||||
// otherwise verify it exists (add extension on Windows if necessary)
|
// otherwise verify it exists (add extension on Windows if necessary)
|
||||||
this.toolPath = yield io.which(this.toolPath, true);
|
this.toolPath = yield io.which(this.toolPath, true);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
||||||
this._debug(`exec tool: ${this.toolPath}`);
|
this._debug(`exec tool: ${this.toolPath}`);
|
||||||
this._debug('arguments:');
|
this._debug('arguments:');
|
||||||
for (const arg of this.args) {
|
for (const arg of this.args) {
|
||||||
@@ -391,9 +406,12 @@ class ToolRunner extends events.EventEmitter {
|
|||||||
state.on('debug', (message) => {
|
state.on('debug', (message) => {
|
||||||
this._debug(message);
|
this._debug(message);
|
||||||
});
|
});
|
||||||
|
if (this.options.cwd && !(yield ioUtil.exists(this.options.cwd))) {
|
||||||
|
return reject(new Error(`The cwd: ${this.options.cwd} does not exist!`));
|
||||||
|
}
|
||||||
const fileName = this._getSpawnFileName();
|
const fileName = this._getSpawnFileName();
|
||||||
const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
|
const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
|
||||||
const stdbuffer = '';
|
let stdbuffer = '';
|
||||||
if (cp.stdout) {
|
if (cp.stdout) {
|
||||||
cp.stdout.on('data', (data) => {
|
cp.stdout.on('data', (data) => {
|
||||||
if (this.options.listeners && this.options.listeners.stdout) {
|
if (this.options.listeners && this.options.listeners.stdout) {
|
||||||
@@ -402,14 +420,14 @@ class ToolRunner extends events.EventEmitter {
|
|||||||
if (!optionsNonNull.silent && optionsNonNull.outStream) {
|
if (!optionsNonNull.silent && optionsNonNull.outStream) {
|
||||||
optionsNonNull.outStream.write(data);
|
optionsNonNull.outStream.write(data);
|
||||||
}
|
}
|
||||||
this._processLineBuffer(data, stdbuffer, (line) => {
|
stdbuffer = this._processLineBuffer(data, stdbuffer, (line) => {
|
||||||
if (this.options.listeners && this.options.listeners.stdline) {
|
if (this.options.listeners && this.options.listeners.stdline) {
|
||||||
this.options.listeners.stdline(line);
|
this.options.listeners.stdline(line);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const errbuffer = '';
|
let errbuffer = '';
|
||||||
if (cp.stderr) {
|
if (cp.stderr) {
|
||||||
cp.stderr.on('data', (data) => {
|
cp.stderr.on('data', (data) => {
|
||||||
state.processStderr = true;
|
state.processStderr = true;
|
||||||
@@ -424,7 +442,7 @@ class ToolRunner extends events.EventEmitter {
|
|||||||
: optionsNonNull.outStream;
|
: optionsNonNull.outStream;
|
||||||
s.write(data);
|
s.write(data);
|
||||||
}
|
}
|
||||||
this._processLineBuffer(data, errbuffer, (line) => {
|
errbuffer = this._processLineBuffer(data, errbuffer, (line) => {
|
||||||
if (this.options.listeners && this.options.listeners.errline) {
|
if (this.options.listeners && this.options.listeners.errline) {
|
||||||
this.options.listeners.errline(line);
|
this.options.listeners.errline(line);
|
||||||
}
|
}
|
||||||
@@ -471,7 +489,7 @@ class ToolRunner extends events.EventEmitter {
|
|||||||
}
|
}
|
||||||
cp.stdin.end(this.options.input);
|
cp.stdin.end(this.options.input);
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -557,7 +575,7 @@ class ExecState extends events.EventEmitter {
|
|||||||
this._setResult();
|
this._setResult();
|
||||||
}
|
}
|
||||||
else if (this.processExited) {
|
else if (this.processExited) {
|
||||||
this.timeout = setTimeout(ExecState.HandleTimeout, this.delay, this);
|
this.timeout = timers_1.setTimeout(ExecState.HandleTimeout, this.delay, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_debug(message) {
|
_debug(message) {
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+19
-48
@@ -1,57 +1,24 @@
|
|||||||
{
|
{
|
||||||
"_args": [
|
"name": "@actions/exec",
|
||||||
[
|
"version": "1.1.0",
|
||||||
"@actions/exec@1.0.4",
|
|
||||||
"."
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "@actions/exec@1.0.4",
|
|
||||||
"_id": "@actions/exec@1.0.4",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-4DPChWow9yc9W3WqEbUj8Nr86xkpyE29ZzWjXucHItclLbEW6jr80Zx4nqv18QL6KK65+cifiQZXvnqgTV6oHw==",
|
|
||||||
"_location": "/@actions/exec",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "version",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "@actions/exec@1.0.4",
|
|
||||||
"name": "@actions/exec",
|
|
||||||
"escapedName": "@actions%2fexec",
|
|
||||||
"scope": "@actions",
|
|
||||||
"rawSpec": "1.0.4",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "1.0.4"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/",
|
|
||||||
"/@actions/tool-cache"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.4.tgz",
|
|
||||||
"_spec": "1.0.4",
|
|
||||||
"_where": ".",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/actions/toolkit/issues"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@actions/io": "^1.0.1"
|
|
||||||
},
|
|
||||||
"description": "Actions exec lib",
|
"description": "Actions exec lib",
|
||||||
"directories": {
|
|
||||||
"lib": "lib",
|
|
||||||
"test": "__tests__"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"lib"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
|
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"github",
|
"github",
|
||||||
"actions",
|
"actions",
|
||||||
"exec"
|
"exec"
|
||||||
],
|
],
|
||||||
|
"homepage": "https://github.com/actions/toolkit/tree/main/packages/exec",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/exec.js",
|
"main": "lib/exec.js",
|
||||||
"name": "@actions/exec",
|
"types": "lib/exec.d.ts",
|
||||||
|
"directories": {
|
||||||
|
"lib": "lib",
|
||||||
|
"test": "__tests__"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"lib",
|
||||||
|
"!.DS_Store"
|
||||||
|
],
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -61,10 +28,14 @@
|
|||||||
"directory": "packages/exec"
|
"directory": "packages/exec"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"audit-moderate": "npm install && npm audit --audit-level=moderate",
|
"audit-moderate": "npm install && npm audit --json --audit-level=moderate > audit.json",
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||||
"tsc": "tsc"
|
"tsc": "tsc"
|
||||||
},
|
},
|
||||||
"types": "lib/exec.d.ts",
|
"bugs": {
|
||||||
"version": "1.0.4"
|
"url": "https://github.com/actions/toolkit/issues"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/io": "^1.0.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -1,5 +1,9 @@
|
|||||||
## Releases
|
## Releases
|
||||||
|
|
||||||
|
## 1.0.10
|
||||||
|
|
||||||
|
Contains a bug fix where proxy is defined without a user and password. see [PR here](https://github.com/actions/http-client/pull/42)
|
||||||
|
|
||||||
## 1.0.9
|
## 1.0.9
|
||||||
Throw HttpClientError instead of a generic Error from the \<verb>Json() helper methods when the server responds with a non-successful status code.
|
Throw HttpClientError instead of a generic Error from the \<verb>Json() helper methods when the server responds with a non-successful status code.
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -427,7 +427,9 @@ class HttpClient {
|
|||||||
maxSockets: maxSockets,
|
maxSockets: maxSockets,
|
||||||
keepAlive: this._keepAlive,
|
keepAlive: this._keepAlive,
|
||||||
proxy: {
|
proxy: {
|
||||||
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`,
|
...((proxyUrl.username || proxyUrl.password) && {
|
||||||
|
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
||||||
|
}),
|
||||||
host: proxyUrl.hostname,
|
host: proxyUrl.hostname,
|
||||||
port: proxyUrl.port
|
port: proxyUrl.port
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-54
@@ -1,43 +1,29 @@
|
|||||||
{
|
{
|
||||||
"_args": [
|
"name": "@actions/http-client",
|
||||||
[
|
"version": "1.0.11",
|
||||||
"@actions/http-client@1.0.9",
|
"description": "Actions Http Client",
|
||||||
"."
|
"main": "index.js",
|
||||||
]
|
"scripts": {
|
||||||
],
|
"build": "rm -Rf ./_out && tsc && cp package*.json ./_out && cp *.md ./_out && cp LICENSE ./_out && cp actions.png ./_out",
|
||||||
"_from": "@actions/http-client@1.0.9",
|
"test": "jest",
|
||||||
"_id": "@actions/http-client@1.0.9",
|
"format": "prettier --write *.ts && prettier --write **/*.ts",
|
||||||
"_inBundle": false,
|
"format-check": "prettier --check *.ts && prettier --check **/*.ts",
|
||||||
"_integrity": "sha512-0O4SsJ7q+MK0ycvXPl2e6bMXV7dxAXOGjrXS1eTF9s2S401Tp6c/P3c3Joz04QefC1J6Gt942Wl2jbm3f4mLcg==",
|
"audit-check": "npm audit --audit-level=moderate"
|
||||||
"_location": "/@actions/http-client",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "version",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "@actions/http-client@1.0.9",
|
|
||||||
"name": "@actions/http-client",
|
|
||||||
"escapedName": "@actions%2fhttp-client",
|
|
||||||
"scope": "@actions",
|
|
||||||
"rawSpec": "1.0.9",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "1.0.9"
|
|
||||||
},
|
},
|
||||||
"_requiredBy": [
|
"repository": {
|
||||||
"/@actions/tool-cache"
|
"type": "git",
|
||||||
],
|
"url": "git+https://github.com/actions/http-client.git"
|
||||||
"_resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.9.tgz",
|
|
||||||
"_spec": "1.0.9",
|
|
||||||
"_where": ".",
|
|
||||||
"author": {
|
|
||||||
"name": "GitHub, Inc."
|
|
||||||
},
|
},
|
||||||
|
"keywords": [
|
||||||
|
"Actions",
|
||||||
|
"Http"
|
||||||
|
],
|
||||||
|
"author": "GitHub, Inc.",
|
||||||
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/actions/http-client/issues"
|
"url": "https://github.com/actions/http-client/issues"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"homepage": "https://github.com/actions/http-client#readme",
|
||||||
"tunnel": "0.0.6"
|
|
||||||
},
|
|
||||||
"description": "Actions Http Client",
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^25.1.4",
|
"@types/jest": "^25.1.4",
|
||||||
"@types/node": "^12.12.31",
|
"@types/node": "^12.12.31",
|
||||||
@@ -47,24 +33,7 @@
|
|||||||
"ts-jest": "^25.2.1",
|
"ts-jest": "^25.2.1",
|
||||||
"typescript": "^3.8.3"
|
"typescript": "^3.8.3"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/actions/http-client#readme",
|
"dependencies": {
|
||||||
"keywords": [
|
"tunnel": "0.0.6"
|
||||||
"Actions",
|
}
|
||||||
"Http"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "index.js",
|
|
||||||
"name": "@actions/http-client",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/actions/http-client.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"audit-check": "npm audit --audit-level=moderate",
|
|
||||||
"build": "rm -Rf ./_out && tsc && cp package*.json ./_out && cp *.md ./_out && cp LICENSE ./_out && cp actions.png ./_out",
|
|
||||||
"format": "prettier --write *.ts && prettier --write **/*.ts",
|
|
||||||
"format-check": "prettier --check *.ts && prettier --check **/*.ts",
|
|
||||||
"test": "jest"
|
|
||||||
},
|
|
||||||
"version": "1.0.9"
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright 2019 GitHub
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
+1
-11
@@ -9,17 +9,6 @@ export declare function isDirectory(fsPath: string, useStat?: boolean): Promise<
|
|||||||
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
|
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
|
||||||
*/
|
*/
|
||||||
export declare function isRooted(p: string): boolean;
|
export declare function isRooted(p: string): boolean;
|
||||||
/**
|
|
||||||
* Recursively create a directory at `fsPath`.
|
|
||||||
*
|
|
||||||
* This implementation is optimistic, meaning it attempts to create the full
|
|
||||||
* path first, and backs up the path stack from there.
|
|
||||||
*
|
|
||||||
* @param fsPath The path to create
|
|
||||||
* @param maxDepth The maximum recursion depth
|
|
||||||
* @param depth The current recursion depth
|
|
||||||
*/
|
|
||||||
export declare function mkdirP(fsPath: string, maxDepth?: number, depth?: number): Promise<void>;
|
|
||||||
/**
|
/**
|
||||||
* Best effort attempt to determine whether a file exists and is executable.
|
* Best effort attempt to determine whether a file exists and is executable.
|
||||||
* @param filePath file path to check
|
* @param filePath file path to check
|
||||||
@@ -27,3 +16,4 @@ export declare function mkdirP(fsPath: string, maxDepth?: number, depth?: number
|
|||||||
* @return if file exists and is executable, returns the file path. otherwise empty string.
|
* @return if file exists and is executable, returns the file path. otherwise empty string.
|
||||||
*/
|
*/
|
||||||
export declare function tryGetExecutablePath(filePath: string, extensions: string[]): Promise<string>;
|
export declare function tryGetExecutablePath(filePath: string, extensions: string[]): Promise<string>;
|
||||||
|
export declare function getCmdPath(): string;
|
||||||
|
|||||||
+28
-46
@@ -1,4 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -10,9 +29,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
};
|
};
|
||||||
var _a;
|
var _a;
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const assert_1 = require("assert");
|
exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rename = exports.readlink = exports.readdir = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0;
|
||||||
const fs = require("fs");
|
const fs = __importStar(require("fs"));
|
||||||
const path = require("path");
|
const path = __importStar(require("path"));
|
||||||
_a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
|
_a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
|
||||||
exports.IS_WINDOWS = process.platform === 'win32';
|
exports.IS_WINDOWS = process.platform === 'win32';
|
||||||
function exists(fsPath) {
|
function exists(fsPath) {
|
||||||
@@ -53,49 +72,6 @@ function isRooted(p) {
|
|||||||
return p.startsWith('/');
|
return p.startsWith('/');
|
||||||
}
|
}
|
||||||
exports.isRooted = isRooted;
|
exports.isRooted = isRooted;
|
||||||
/**
|
|
||||||
* Recursively create a directory at `fsPath`.
|
|
||||||
*
|
|
||||||
* This implementation is optimistic, meaning it attempts to create the full
|
|
||||||
* path first, and backs up the path stack from there.
|
|
||||||
*
|
|
||||||
* @param fsPath The path to create
|
|
||||||
* @param maxDepth The maximum recursion depth
|
|
||||||
* @param depth The current recursion depth
|
|
||||||
*/
|
|
||||||
function mkdirP(fsPath, maxDepth = 1000, depth = 1) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
assert_1.ok(fsPath, 'a path argument must be provided');
|
|
||||||
fsPath = path.resolve(fsPath);
|
|
||||||
if (depth >= maxDepth)
|
|
||||||
return exports.mkdir(fsPath);
|
|
||||||
try {
|
|
||||||
yield exports.mkdir(fsPath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
switch (err.code) {
|
|
||||||
case 'ENOENT': {
|
|
||||||
yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1);
|
|
||||||
yield exports.mkdir(fsPath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
let stats;
|
|
||||||
try {
|
|
||||||
stats = yield exports.stat(fsPath);
|
|
||||||
}
|
|
||||||
catch (err2) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
if (!stats.isDirectory())
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.mkdirP = mkdirP;
|
|
||||||
/**
|
/**
|
||||||
* Best effort attempt to determine whether a file exists and is executable.
|
* Best effort attempt to determine whether a file exists and is executable.
|
||||||
* @param filePath file path to check
|
* @param filePath file path to check
|
||||||
@@ -192,4 +168,10 @@ function isUnixExecutable(stats) {
|
|||||||
((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
|
((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
|
||||||
((stats.mode & 64) > 0 && stats.uid === process.getuid()));
|
((stats.mode & 64) > 0 && stats.uid === process.getuid()));
|
||||||
}
|
}
|
||||||
|
// Get the path of cmd.exe in windows
|
||||||
|
function getCmdPath() {
|
||||||
|
var _a;
|
||||||
|
return (_a = process.env['COMSPEC']) !== null && _a !== void 0 ? _a : `cmd.exe`;
|
||||||
|
}
|
||||||
|
exports.getCmdPath = getCmdPath;
|
||||||
//# sourceMappingURL=io-util.js.map
|
//# sourceMappingURL=io-util.js.map
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"io-util.js","sourceRoot":"","sources":["../src/io-util.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAyB;A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KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC;QACpB,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;QACxD,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAC1D,CAAA;AACH,CAAC;AAED,qCAAqC;AACrC,SAAgB,UAAU;;IACxB,aAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,mCAAI,SAAS,CAAA;AAC5C,CAAC;AAFD,gCAEC"}
|
||||||
+8
@@ -6,6 +6,8 @@ export interface CopyOptions {
|
|||||||
recursive?: boolean;
|
recursive?: boolean;
|
||||||
/** Optional. Whether to overwrite existing files in the destination. Defaults to true */
|
/** Optional. Whether to overwrite existing files in the destination. Defaults to true */
|
||||||
force?: boolean;
|
force?: boolean;
|
||||||
|
/** Optional. Whether to copy the source directory along with all the files. Only takes effect when recursive=true and copying a directory. Default is true*/
|
||||||
|
copySourceDirectory?: boolean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Interface for cp/mv options
|
* Interface for cp/mv options
|
||||||
@@ -54,3 +56,9 @@ export declare function mkdirP(fsPath: string): Promise<void>;
|
|||||||
* @returns Promise<string> path to tool
|
* @returns Promise<string> path to tool
|
||||||
*/
|
*/
|
||||||
export declare function which(tool: string, check?: boolean): Promise<string>;
|
export declare function which(tool: string, check?: boolean): Promise<string>;
|
||||||
|
/**
|
||||||
|
* Returns a list of all occurrences of the given tool on the system path.
|
||||||
|
*
|
||||||
|
* @returns Promise<string[]> the paths of the tool
|
||||||
|
*/
|
||||||
|
export declare function findInPath(tool: string): Promise<string[]>;
|
||||||
|
|||||||
+108
-57
@@ -1,4 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -9,11 +28,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const childProcess = require("child_process");
|
exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0;
|
||||||
const path = require("path");
|
const assert_1 = require("assert");
|
||||||
|
const childProcess = __importStar(require("child_process"));
|
||||||
|
const path = __importStar(require("path"));
|
||||||
const util_1 = require("util");
|
const util_1 = require("util");
|
||||||
const ioUtil = require("./io-util");
|
const ioUtil = __importStar(require("./io-util"));
|
||||||
const exec = util_1.promisify(childProcess.exec);
|
const exec = util_1.promisify(childProcess.exec);
|
||||||
|
const execFile = util_1.promisify(childProcess.execFile);
|
||||||
/**
|
/**
|
||||||
* Copies a file or folder.
|
* Copies a file or folder.
|
||||||
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
|
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
|
||||||
@@ -24,14 +46,14 @@ const exec = util_1.promisify(childProcess.exec);
|
|||||||
*/
|
*/
|
||||||
function cp(source, dest, options = {}) {
|
function cp(source, dest, options = {}) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const { force, recursive } = readCopyOptions(options);
|
const { force, recursive, copySourceDirectory } = readCopyOptions(options);
|
||||||
const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
|
const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
|
||||||
// Dest is an existing file, but not forcing
|
// Dest is an existing file, but not forcing
|
||||||
if (destStat && destStat.isFile() && !force) {
|
if (destStat && destStat.isFile() && !force) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If dest is an existing directory, should copy inside.
|
// If dest is an existing directory, should copy inside.
|
||||||
const newDest = destStat && destStat.isDirectory()
|
const newDest = destStat && destStat.isDirectory() && copySourceDirectory
|
||||||
? path.join(dest, path.basename(source))
|
? path.join(dest, path.basename(source))
|
||||||
: dest;
|
: dest;
|
||||||
if (!(yield ioUtil.exists(source))) {
|
if (!(yield ioUtil.exists(source))) {
|
||||||
@@ -96,12 +118,22 @@ function rmRF(inputPath) {
|
|||||||
if (ioUtil.IS_WINDOWS) {
|
if (ioUtil.IS_WINDOWS) {
|
||||||
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
|
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
|
||||||
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
|
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
|
||||||
|
// Check for invalid characters
|
||||||
|
// https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
|
||||||
|
if (/[*"<>|]/.test(inputPath)) {
|
||||||
|
throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
|
const cmdPath = ioUtil.getCmdPath();
|
||||||
if (yield ioUtil.isDirectory(inputPath, true)) {
|
if (yield ioUtil.isDirectory(inputPath, true)) {
|
||||||
yield exec(`rd /s /q "${inputPath}"`);
|
yield exec(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, {
|
||||||
|
env: { inputPath }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yield exec(`del /f /a "${inputPath}"`);
|
yield exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, {
|
||||||
|
env: { inputPath }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -134,7 +166,7 @@ function rmRF(inputPath) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isDir) {
|
if (isDir) {
|
||||||
yield exec(`rm -rf "${inputPath}"`);
|
yield execFile(`rm`, [`-rf`, `${inputPath}`]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yield ioUtil.unlink(inputPath);
|
yield ioUtil.unlink(inputPath);
|
||||||
@@ -152,7 +184,8 @@ exports.rmRF = rmRF;
|
|||||||
*/
|
*/
|
||||||
function mkdirP(fsPath) {
|
function mkdirP(fsPath) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield ioUtil.mkdirP(fsPath);
|
assert_1.ok(fsPath, 'a path argument must be provided');
|
||||||
|
yield ioUtil.mkdir(fsPath, { recursive: true });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.mkdirP = mkdirP;
|
exports.mkdirP = mkdirP;
|
||||||
@@ -180,62 +213,80 @@ function which(tool, check) {
|
|||||||
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
|
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
try {
|
const matches = yield findInPath(tool);
|
||||||
// build the list of extensions to try
|
if (matches && matches.length > 0) {
|
||||||
const extensions = [];
|
return matches[0];
|
||||||
if (ioUtil.IS_WINDOWS && process.env.PATHEXT) {
|
|
||||||
for (const extension of process.env.PATHEXT.split(path.delimiter)) {
|
|
||||||
if (extension) {
|
|
||||||
extensions.push(extension);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if it's rooted, return it if exists. otherwise return empty.
|
|
||||||
if (ioUtil.isRooted(tool)) {
|
|
||||||
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
|
|
||||||
if (filePath) {
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
// if any path separators, return empty
|
|
||||||
if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
// build the list of directories
|
|
||||||
//
|
|
||||||
// Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
|
|
||||||
// it feels like we should not do this. Checking the current directory seems like more of a use
|
|
||||||
// case of a shell, and the which() function exposed by the toolkit should strive for consistency
|
|
||||||
// across platforms.
|
|
||||||
const directories = [];
|
|
||||||
if (process.env.PATH) {
|
|
||||||
for (const p of process.env.PATH.split(path.delimiter)) {
|
|
||||||
if (p) {
|
|
||||||
directories.push(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// return the first match
|
|
||||||
for (const directory of directories) {
|
|
||||||
const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions);
|
|
||||||
if (filePath) {
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
throw new Error(`which failed with message ${err.message}`);
|
|
||||||
}
|
}
|
||||||
|
return '';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.which = which;
|
exports.which = which;
|
||||||
|
/**
|
||||||
|
* Returns a list of all occurrences of the given tool on the system path.
|
||||||
|
*
|
||||||
|
* @returns Promise<string[]> the paths of the tool
|
||||||
|
*/
|
||||||
|
function findInPath(tool) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (!tool) {
|
||||||
|
throw new Error("parameter 'tool' is required");
|
||||||
|
}
|
||||||
|
// build the list of extensions to try
|
||||||
|
const extensions = [];
|
||||||
|
if (ioUtil.IS_WINDOWS && process.env['PATHEXT']) {
|
||||||
|
for (const extension of process.env['PATHEXT'].split(path.delimiter)) {
|
||||||
|
if (extension) {
|
||||||
|
extensions.push(extension);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if it's rooted, return it if exists. otherwise return empty.
|
||||||
|
if (ioUtil.isRooted(tool)) {
|
||||||
|
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
|
||||||
|
if (filePath) {
|
||||||
|
return [filePath];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
// if any path separators, return empty
|
||||||
|
if (tool.includes(path.sep)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
// build the list of directories
|
||||||
|
//
|
||||||
|
// Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
|
||||||
|
// it feels like we should not do this. Checking the current directory seems like more of a use
|
||||||
|
// case of a shell, and the which() function exposed by the toolkit should strive for consistency
|
||||||
|
// across platforms.
|
||||||
|
const directories = [];
|
||||||
|
if (process.env.PATH) {
|
||||||
|
for (const p of process.env.PATH.split(path.delimiter)) {
|
||||||
|
if (p) {
|
||||||
|
directories.push(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// find all matches
|
||||||
|
const matches = [];
|
||||||
|
for (const directory of directories) {
|
||||||
|
const filePath = yield ioUtil.tryGetExecutablePath(path.join(directory, tool), extensions);
|
||||||
|
if (filePath) {
|
||||||
|
matches.push(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return matches;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.findInPath = findInPath;
|
||||||
function readCopyOptions(options) {
|
function readCopyOptions(options) {
|
||||||
const force = options.force == null ? true : options.force;
|
const force = options.force == null ? true : options.force;
|
||||||
const recursive = Boolean(options.recursive);
|
const recursive = Boolean(options.recursive);
|
||||||
return { force, recursive };
|
const copySourceDirectory = options.copySourceDirectory == null
|
||||||
|
? true
|
||||||
|
: Boolean(options.copySourceDirectory);
|
||||||
|
return { force, recursive, copySourceDirectory };
|
||||||
}
|
}
|
||||||
function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
|
function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+15
-45
@@ -1,38 +1,16 @@
|
|||||||
{
|
{
|
||||||
"_args": [
|
"name": "@actions/io",
|
||||||
[
|
"version": "1.1.1",
|
||||||
"@actions/io@1.0.2",
|
|
||||||
"."
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "@actions/io@1.0.2",
|
|
||||||
"_id": "@actions/io@1.0.2",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-J8KuFqVPr3p6U8W93DOXlXW6zFvrQAJANdS+vw0YhusLIq+bszW8zmK2Fh1C2kDPX8FMvwIl1OUcFgvJoXLbAg==",
|
|
||||||
"_location": "/@actions/io",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "version",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "@actions/io@1.0.2",
|
|
||||||
"name": "@actions/io",
|
|
||||||
"escapedName": "@actions%2fio",
|
|
||||||
"scope": "@actions",
|
|
||||||
"rawSpec": "1.0.2",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "1.0.2"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/@actions/exec",
|
|
||||||
"/@actions/tool-cache"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.2.tgz",
|
|
||||||
"_spec": "1.0.2",
|
|
||||||
"_where": ".",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/actions/toolkit/issues"
|
|
||||||
},
|
|
||||||
"description": "Actions io lib",
|
"description": "Actions io lib",
|
||||||
|
"keywords": [
|
||||||
|
"github",
|
||||||
|
"actions",
|
||||||
|
"io"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/actions/toolkit/tree/main/packages/io",
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "lib/io.js",
|
||||||
|
"types": "lib/io.d.ts",
|
||||||
"directories": {
|
"directories": {
|
||||||
"lib": "lib",
|
"lib": "lib",
|
||||||
"test": "__tests__"
|
"test": "__tests__"
|
||||||
@@ -40,15 +18,6 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/io",
|
|
||||||
"keywords": [
|
|
||||||
"github",
|
|
||||||
"actions",
|
|
||||||
"io"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "lib/io.js",
|
|
||||||
"name": "@actions/io",
|
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -58,10 +27,11 @@
|
|||||||
"directory": "packages/io"
|
"directory": "packages/io"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"audit-moderate": "npm install && npm audit --audit-level=moderate",
|
"audit-moderate": "npm install && npm audit --json --audit-level=moderate > audit.json",
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||||
"tsc": "tsc"
|
"tsc": "tsc"
|
||||||
},
|
},
|
||||||
"types": "lib/io.d.ts",
|
"bugs": {
|
||||||
"version": "1.0.2"
|
"url": "https://github.com/actions/toolkit/issues"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+34
-12
@@ -1,4 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -8,14 +27,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports._readLinuxVersionFile = exports._getOsVersion = exports._findMatch = void 0;
|
||||||
const semver = __importStar(require("semver"));
|
const semver = __importStar(require("semver"));
|
||||||
const core_1 = require("@actions/core");
|
const core_1 = require("@actions/core");
|
||||||
// needs to be require for core node modules to be mocked
|
// needs to be require for core node modules to be mocked
|
||||||
@@ -84,8 +97,13 @@ function _getOsVersion() {
|
|||||||
const lines = lsbContents.split('\n');
|
const lines = lsbContents.split('\n');
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
const parts = line.split('=');
|
const parts = line.split('=');
|
||||||
if (parts.length === 2 && parts[0].trim() === 'DISTRIB_RELEASE') {
|
if (parts.length === 2 &&
|
||||||
version = parts[1].trim();
|
(parts[0].trim() === 'VERSION_ID' ||
|
||||||
|
parts[0].trim() === 'DISTRIB_RELEASE')) {
|
||||||
|
version = parts[1]
|
||||||
|
.trim()
|
||||||
|
.replace(/^"/, '')
|
||||||
|
.replace(/"$/, '');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,10 +113,14 @@ function _getOsVersion() {
|
|||||||
}
|
}
|
||||||
exports._getOsVersion = _getOsVersion;
|
exports._getOsVersion = _getOsVersion;
|
||||||
function _readLinuxVersionFile() {
|
function _readLinuxVersionFile() {
|
||||||
const lsbFile = '/etc/lsb-release';
|
const lsbReleaseFile = '/etc/lsb-release';
|
||||||
|
const osReleaseFile = '/etc/os-release';
|
||||||
let contents = '';
|
let contents = '';
|
||||||
if (fs.existsSync(lsbFile)) {
|
if (fs.existsSync(lsbReleaseFile)) {
|
||||||
contents = fs.readFileSync(lsbFile).toString();
|
contents = fs.readFileSync(lsbReleaseFile).toString();
|
||||||
|
}
|
||||||
|
else if (fs.existsSync(osReleaseFile)) {
|
||||||
|
contents = fs.readFileSync(osReleaseFile).toString();
|
||||||
}
|
}
|
||||||
return contents;
|
return contents;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+CAAgC;AAChC,wCAAmC;AAEnC,yDAAyD;AACzD,qDAAqD;AAErD,yBAAyB;AACzB,oCAAoC;AACpC,yBAAyB;AAqDzB,SAAsB,UAAU,CAC9B,WAAmB,EACnB,MAAe,EACf,UAA0B,EAC1B,UAAkB;;QAElB,MAAM,UAAU,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAA;QAEhC,IAAI,MAAgC,CAAA;QACpC,IAAI,KAA+B,CAAA;QAEnC,IAAI,IAAkC,CAAA;QACtC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YAClC,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAA;YAEjC,YAAK,CAAC,SAAS,OAAO,cAAc,WAAW,EAAE,CAAC,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,IAAI,EAAE,KAAK,iBAAiB,CAAC,EACxC;oBACA,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC;yBACf,IAAI,EAAE;yBACN,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;yBACjB,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;oBACpB,MAAK;iBACN;aACF;SACF;KACF;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AApCD,sCAoCC;AAED,SAAgB,qBAAqB;IACnC,MAAM,cAAc,GAAG,kBAAkB,CAAA;IACzC,MAAM,aAAa,GAAG,iBAAiB,CAAA;IACvC,IAAI,QAAQ,GAAG,EAAE,CAAA;IAEjB,IAAI,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE;QACjC,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,CAAA;KACtD;SAAM,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;QACvC,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,CAAA;KACrD;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC;AAZD,sDAYC"}
|
||||||
+20
-7
@@ -1,4 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -8,14 +27,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.RetryHelper = void 0;
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
/**
|
/**
|
||||||
* Internal class for retries
|
* Internal class for retries
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"retry-helper.js","sourceRoot":"","sources":["../src/retry-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,oDAAqC;AAErC;;GAEG;AACH,MAAa,WAAW;IAKtB,YAAY,WAAmB,EAAE,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BACR,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;gBACrC,IAAI,CAAC,IAAI,CAAC,WAAW,OAAO,8BAA8B,CAAC,CAAA;gBAC3D,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;gBACzB,OAAO,EAAE,CAAA;aACV;YAED,eAAe;YACf,OAAO,MAAM,MAAM,EAAE,CAAA;QACvB,CAAC;KAAA;IAEO,cAAc;QACpB,OAAO,CACL,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;YACnE,IAAI,CAAC,UAAU,CAChB,CAAA;IACH,CAAC;IAEa,KAAK,CAAC,OAAe;;YACjC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC,CAAA;QACpE,CAAC;KAAA;CACF;AAxDD,kCAwDC"}
|
||||||
+16
-1
@@ -1,4 +1,5 @@
|
|||||||
import * as mm from './manifest';
|
import * as mm from './manifest';
|
||||||
|
import { IHeaders } from '@actions/http-client/interfaces';
|
||||||
export declare class HTTPError extends Error {
|
export declare class HTTPError extends Error {
|
||||||
readonly httpStatusCode: number | undefined;
|
readonly httpStatusCode: number | undefined;
|
||||||
constructor(httpStatusCode: number | undefined);
|
constructor(httpStatusCode: number | undefined);
|
||||||
@@ -9,9 +10,10 @@ export declare class HTTPError extends Error {
|
|||||||
* @param url url of tool to download
|
* @param url url of tool to download
|
||||||
* @param dest path to download tool
|
* @param dest path to download tool
|
||||||
* @param auth authorization header
|
* @param auth authorization header
|
||||||
|
* @param headers other headers
|
||||||
* @returns path to downloaded tool
|
* @returns path to downloaded tool
|
||||||
*/
|
*/
|
||||||
export declare function downloadTool(url: string, dest?: string, auth?: string): Promise<string>;
|
export declare function downloadTool(url: string, dest?: string, auth?: string, headers?: IHeaders): Promise<string>;
|
||||||
/**
|
/**
|
||||||
* Extract a .7z file
|
* Extract a .7z file
|
||||||
*
|
*
|
||||||
@@ -93,3 +95,16 @@ export declare type IToolRelease = mm.IToolRelease;
|
|||||||
export declare type IToolReleaseFile = mm.IToolReleaseFile;
|
export declare type IToolReleaseFile = mm.IToolReleaseFile;
|
||||||
export declare function getManifestFromRepo(owner: string, repo: string, auth?: string, branch?: string): Promise<IToolRelease[]>;
|
export declare function getManifestFromRepo(owner: string, repo: string, auth?: string, branch?: string): Promise<IToolRelease[]>;
|
||||||
export declare function findFromManifest(versionSpec: string, stable: boolean, manifest: IToolRelease[], archFilter?: string): Promise<IToolRelease | undefined>;
|
export declare function findFromManifest(versionSpec: string, stable: boolean, manifest: IToolRelease[], archFilter?: string): Promise<IToolRelease | undefined>;
|
||||||
|
/**
|
||||||
|
* Check if version string is explicit
|
||||||
|
*
|
||||||
|
* @param versionSpec version string to check
|
||||||
|
*/
|
||||||
|
export declare function isExplicitVersion(versionSpec: string): boolean;
|
||||||
|
/**
|
||||||
|
* Get the highest satisfiying semantic version in `versions` which satisfies `versionSpec`
|
||||||
|
*
|
||||||
|
* @param versions array of versions to evaluate
|
||||||
|
* @param versionSpec semantic version spec to satisfy
|
||||||
|
*/
|
||||||
|
export declare function evaluateVersions(versions: string[], versionSpec: string): string;
|
||||||
|
|||||||
+92
-33
@@ -1,4 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -8,17 +27,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.evaluateVersions = exports.isExplicitVersion = exports.findFromManifest = exports.getManifestFromRepo = exports.findAllVersions = exports.find = exports.cacheFile = exports.cacheDir = exports.extractZip = exports.extractXar = exports.extractTar = exports.extract7z = exports.downloadTool = exports.HTTPError = void 0;
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const io = __importStar(require("@actions/io"));
|
const io = __importStar(require("@actions/io"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
@@ -50,9 +63,10 @@ const userAgent = 'actions/tool-cache';
|
|||||||
* @param url url of tool to download
|
* @param url url of tool to download
|
||||||
* @param dest path to download tool
|
* @param dest path to download tool
|
||||||
* @param auth authorization header
|
* @param auth authorization header
|
||||||
|
* @param headers other headers
|
||||||
* @returns path to downloaded tool
|
* @returns path to downloaded tool
|
||||||
*/
|
*/
|
||||||
function downloadTool(url, dest, auth) {
|
function downloadTool(url, dest, auth, headers) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
dest = dest || path.join(_getTempDirectory(), v4_1.default());
|
dest = dest || path.join(_getTempDirectory(), v4_1.default());
|
||||||
yield io.mkdirP(path.dirname(dest));
|
yield io.mkdirP(path.dirname(dest));
|
||||||
@@ -63,7 +77,7 @@ function downloadTool(url, dest, auth) {
|
|||||||
const maxSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20);
|
const maxSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20);
|
||||||
const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds);
|
const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds);
|
||||||
return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
|
return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
|
||||||
return yield downloadToolAttempt(url, dest || '', auth);
|
return yield downloadToolAttempt(url, dest || '', auth, headers);
|
||||||
}), (err) => {
|
}), (err) => {
|
||||||
if (err instanceof HTTPError && err.httpStatusCode) {
|
if (err instanceof HTTPError && err.httpStatusCode) {
|
||||||
// Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests
|
// Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests
|
||||||
@@ -79,7 +93,7 @@ function downloadTool(url, dest, auth) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.downloadTool = downloadTool;
|
exports.downloadTool = downloadTool;
|
||||||
function downloadToolAttempt(url, dest, auth) {
|
function downloadToolAttempt(url, dest, auth, headers) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (fs.existsSync(dest)) {
|
if (fs.existsSync(dest)) {
|
||||||
throw new Error(`Destination file path ${dest} already exists`);
|
throw new Error(`Destination file path ${dest} already exists`);
|
||||||
@@ -88,12 +102,12 @@ function downloadToolAttempt(url, dest, auth) {
|
|||||||
const http = new httpm.HttpClient(userAgent, [], {
|
const http = new httpm.HttpClient(userAgent, [], {
|
||||||
allowRetries: false
|
allowRetries: false
|
||||||
});
|
});
|
||||||
let headers;
|
|
||||||
if (auth) {
|
if (auth) {
|
||||||
core.debug('set auth');
|
core.debug('set auth');
|
||||||
headers = {
|
if (headers === undefined) {
|
||||||
authorization: auth
|
headers = {};
|
||||||
};
|
}
|
||||||
|
headers.authorization = auth;
|
||||||
}
|
}
|
||||||
const response = yield http.get(url, headers);
|
const response = yield http.get(url, headers);
|
||||||
if (response.message.statusCode !== 200) {
|
if (response.message.statusCode !== 200) {
|
||||||
@@ -251,6 +265,7 @@ function extractTar(file, dest, flags = 'xz') {
|
|||||||
if (isGnuTar) {
|
if (isGnuTar) {
|
||||||
// Suppress warnings when using GNU tar to extract archives created by BSD tar
|
// Suppress warnings when using GNU tar to extract archives created by BSD tar
|
||||||
args.push('--warning=no-unknown-keyword');
|
args.push('--warning=no-unknown-keyword');
|
||||||
|
args.push('--overwrite');
|
||||||
}
|
}
|
||||||
args.push('-C', destArg, '-f', fileArg);
|
args.push('-C', destArg, '-f', fileArg);
|
||||||
yield exec_1.exec(`tar`, args);
|
yield exec_1.exec(`tar`, args);
|
||||||
@@ -316,20 +331,50 @@ function extractZipWin(file, dest) {
|
|||||||
// build the powershell command
|
// build the powershell command
|
||||||
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
|
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
|
||||||
const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
||||||
const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`;
|
const pwshPath = yield io.which('pwsh', false);
|
||||||
// run powershell
|
//To match the file overwrite behavior on nix systems, we use the overwrite = true flag for ExtractToDirectory
|
||||||
const powershellPath = yield io.which('powershell', true);
|
//and the -Force flag for Expand-Archive as a fallback
|
||||||
const args = [
|
if (pwshPath) {
|
||||||
'-NoLogo',
|
//attempt to use pwsh with ExtractToDirectory, if this fails attempt Expand-Archive
|
||||||
'-Sta',
|
const pwshCommand = [
|
||||||
'-NoProfile',
|
`$ErrorActionPreference = 'Stop' ;`,
|
||||||
'-NonInteractive',
|
`try { Add-Type -AssemblyName System.IO.Compression.ZipFile } catch { } ;`,
|
||||||
'-ExecutionPolicy',
|
`try { [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}', $true) }`,
|
||||||
'Unrestricted',
|
`catch { if (($_.Exception.GetType().FullName -eq 'System.Management.Automation.MethodException') -or ($_.Exception.GetType().FullName -eq 'System.Management.Automation.RuntimeException') ){ Expand-Archive -LiteralPath '${escapedFile}' -DestinationPath '${escapedDest}' -Force } else { throw $_ } } ;`
|
||||||
'-Command',
|
].join(' ');
|
||||||
command
|
const args = [
|
||||||
];
|
'-NoLogo',
|
||||||
yield exec_1.exec(`"${powershellPath}"`, args);
|
'-NoProfile',
|
||||||
|
'-NonInteractive',
|
||||||
|
'-ExecutionPolicy',
|
||||||
|
'Unrestricted',
|
||||||
|
'-Command',
|
||||||
|
pwshCommand
|
||||||
|
];
|
||||||
|
core.debug(`Using pwsh at path: ${pwshPath}`);
|
||||||
|
yield exec_1.exec(`"${pwshPath}"`, args);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const powershellCommand = [
|
||||||
|
`$ErrorActionPreference = 'Stop' ;`,
|
||||||
|
`try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ;`,
|
||||||
|
`if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath '${escapedFile}' -DestinationPath '${escapedDest}' -Force }`,
|
||||||
|
`else {[System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}', $true) }`
|
||||||
|
].join(' ');
|
||||||
|
const args = [
|
||||||
|
'-NoLogo',
|
||||||
|
'-Sta',
|
||||||
|
'-NoProfile',
|
||||||
|
'-NonInteractive',
|
||||||
|
'-ExecutionPolicy',
|
||||||
|
'Unrestricted',
|
||||||
|
'-Command',
|
||||||
|
powershellCommand
|
||||||
|
];
|
||||||
|
const powershellPath = yield io.which('powershell', true);
|
||||||
|
core.debug(`Using powershell at path: ${powershellPath}`);
|
||||||
|
yield exec_1.exec(`"${powershellPath}"`, args);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function extractZipNix(file, dest) {
|
function extractZipNix(file, dest) {
|
||||||
@@ -339,6 +384,7 @@ function extractZipNix(file, dest) {
|
|||||||
if (!core.isDebug()) {
|
if (!core.isDebug()) {
|
||||||
args.unshift('-q');
|
args.unshift('-q');
|
||||||
}
|
}
|
||||||
|
args.unshift('-o'); //overwrite with -o, otherwise a prompt is shown which freezes the run
|
||||||
yield exec_1.exec(`"${unzipPath}"`, args, { cwd: dest });
|
yield exec_1.exec(`"${unzipPath}"`, args, { cwd: dest });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -421,9 +467,9 @@ function find(toolName, versionSpec, arch) {
|
|||||||
}
|
}
|
||||||
arch = arch || os.arch();
|
arch = arch || os.arch();
|
||||||
// attempt to resolve an explicit version
|
// attempt to resolve an explicit version
|
||||||
if (!_isExplicitVersion(versionSpec)) {
|
if (!isExplicitVersion(versionSpec)) {
|
||||||
const localVersions = findAllVersions(toolName, arch);
|
const localVersions = findAllVersions(toolName, arch);
|
||||||
const match = _evaluateVersions(localVersions, versionSpec);
|
const match = evaluateVersions(localVersions, versionSpec);
|
||||||
versionSpec = match;
|
versionSpec = match;
|
||||||
}
|
}
|
||||||
// check for the explicit version in the cache
|
// check for the explicit version in the cache
|
||||||
@@ -456,7 +502,7 @@ function findAllVersions(toolName, arch) {
|
|||||||
if (fs.existsSync(toolPath)) {
|
if (fs.existsSync(toolPath)) {
|
||||||
const children = fs.readdirSync(toolPath);
|
const children = fs.readdirSync(toolPath);
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
if (_isExplicitVersion(child)) {
|
if (isExplicitVersion(child)) {
|
||||||
const fullPath = path.join(toolPath, child, arch || '');
|
const fullPath = path.join(toolPath, child, arch || '');
|
||||||
if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) {
|
if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) {
|
||||||
versions.push(child);
|
versions.push(child);
|
||||||
@@ -539,14 +585,26 @@ function _completeToolPath(tool, version, arch) {
|
|||||||
fs.writeFileSync(markerPath, '');
|
fs.writeFileSync(markerPath, '');
|
||||||
core.debug('finished caching tool');
|
core.debug('finished caching tool');
|
||||||
}
|
}
|
||||||
function _isExplicitVersion(versionSpec) {
|
/**
|
||||||
|
* Check if version string is explicit
|
||||||
|
*
|
||||||
|
* @param versionSpec version string to check
|
||||||
|
*/
|
||||||
|
function isExplicitVersion(versionSpec) {
|
||||||
const c = semver.clean(versionSpec) || '';
|
const c = semver.clean(versionSpec) || '';
|
||||||
core.debug(`isExplicit: ${c}`);
|
core.debug(`isExplicit: ${c}`);
|
||||||
const valid = semver.valid(c) != null;
|
const valid = semver.valid(c) != null;
|
||||||
core.debug(`explicit? ${valid}`);
|
core.debug(`explicit? ${valid}`);
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
function _evaluateVersions(versions, versionSpec) {
|
exports.isExplicitVersion = isExplicitVersion;
|
||||||
|
/**
|
||||||
|
* Get the highest satisfiying semantic version in `versions` which satisfies `versionSpec`
|
||||||
|
*
|
||||||
|
* @param versions array of versions to evaluate
|
||||||
|
* @param versionSpec semantic version spec to satisfy
|
||||||
|
*/
|
||||||
|
function evaluateVersions(versions, versionSpec) {
|
||||||
let version = '';
|
let version = '';
|
||||||
core.debug(`evaluating ${versions.length} versions`);
|
core.debug(`evaluating ${versions.length} versions`);
|
||||||
versions = versions.sort((a, b) => {
|
versions = versions.sort((a, b) => {
|
||||||
@@ -571,6 +629,7 @@ function _evaluateVersions(versions, versionSpec) {
|
|||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
exports.evaluateVersions = evaluateVersions;
|
||||||
/**
|
/**
|
||||||
* Gets RUNNER_TOOL_CACHE
|
* Gets RUNNER_TOOL_CACHE
|
||||||
*/
|
*/
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+28
-57
@@ -1,51 +1,16 @@
|
|||||||
{
|
{
|
||||||
"_args": [
|
"name": "@actions/tool-cache",
|
||||||
[
|
"version": "1.7.1",
|
||||||
"@actions/tool-cache@1.6.1",
|
|
||||||
"."
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "@actions/tool-cache@1.6.1",
|
|
||||||
"_id": "@actions/tool-cache@1.6.1",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-F+vwEDwfqcHMKuSkj79pihOnsAMv23EkG76nMpc82UsnXwyQdyEsktGxrB0SNtm7pRqTXEIOoAPTgrSQclXYTg==",
|
|
||||||
"_location": "/@actions/tool-cache",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "version",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "@actions/tool-cache@1.6.1",
|
|
||||||
"name": "@actions/tool-cache",
|
|
||||||
"escapedName": "@actions%2ftool-cache",
|
|
||||||
"scope": "@actions",
|
|
||||||
"rawSpec": "1.6.1",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "1.6.1"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.6.1.tgz",
|
|
||||||
"_spec": "1.6.1",
|
|
||||||
"_where": ".",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/actions/toolkit/issues"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@actions/core": "^1.2.6",
|
|
||||||
"@actions/exec": "^1.0.0",
|
|
||||||
"@actions/http-client": "^1.0.8",
|
|
||||||
"@actions/io": "^1.0.1",
|
|
||||||
"semver": "^6.1.0",
|
|
||||||
"uuid": "^3.3.2"
|
|
||||||
},
|
|
||||||
"description": "Actions tool-cache lib",
|
"description": "Actions tool-cache lib",
|
||||||
"devDependencies": {
|
"keywords": [
|
||||||
"@types/nock": "^10.0.3",
|
"github",
|
||||||
"@types/semver": "^6.0.0",
|
"actions",
|
||||||
"@types/uuid": "^3.4.4",
|
"exec"
|
||||||
"nock": "^10.0.6"
|
],
|
||||||
},
|
"homepage": "https://github.com/actions/toolkit/tree/main/packages/tool-cache",
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "lib/tool-cache.js",
|
||||||
|
"types": "lib/tool-cache.d.ts",
|
||||||
"directories": {
|
"directories": {
|
||||||
"lib": "lib",
|
"lib": "lib",
|
||||||
"test": "__tests__"
|
"test": "__tests__"
|
||||||
@@ -54,15 +19,6 @@
|
|||||||
"lib",
|
"lib",
|
||||||
"scripts"
|
"scripts"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/main/packages/tool-cache",
|
|
||||||
"keywords": [
|
|
||||||
"github",
|
|
||||||
"actions",
|
|
||||||
"exec"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "lib/tool-cache.js",
|
|
||||||
"name": "@actions/tool-cache",
|
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
@@ -76,6 +32,21 @@
|
|||||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||||
"tsc": "tsc"
|
"tsc": "tsc"
|
||||||
},
|
},
|
||||||
"types": "lib/tool-cache.d.ts",
|
"bugs": {
|
||||||
"version": "1.6.1"
|
"url": "https://github.com/actions/toolkit/issues"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/core": "^1.2.6",
|
||||||
|
"@actions/exec": "^1.0.0",
|
||||||
|
"@actions/http-client": "^1.0.8",
|
||||||
|
"@actions/io": "^1.1.1",
|
||||||
|
"semver": "^6.1.0",
|
||||||
|
"uuid": "^3.3.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/nock": "^10.0.3",
|
||||||
|
"@types/semver": "^6.0.0",
|
||||||
|
"@types/uuid": "^3.4.4",
|
||||||
|
"nock": "^10.0.6"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014-2017, Jon Schlinkert.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
+104
@@ -0,0 +1,104 @@
|
|||||||
|
# is-plain-object [](https://www.npmjs.com/package/is-plain-object) [](https://npmjs.org/package/is-plain-object) [](https://npmjs.org/package/is-plain-object) [](https://travis-ci.org/jonschlinkert/is-plain-object)
|
||||||
|
|
||||||
|
> Returns true if an object was created by the `Object` constructor.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Install with [npm](https://www.npmjs.com/):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install --save is-plain-object
|
||||||
|
```
|
||||||
|
|
||||||
|
Use [isobject](https://github.com/jonschlinkert/isobject) if you only want to check if the value is an object and not an array or null.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
var isPlainObject = require('is-plain-object');
|
||||||
|
```
|
||||||
|
|
||||||
|
**true** when created by the `Object` constructor.
|
||||||
|
|
||||||
|
```js
|
||||||
|
isPlainObject(Object.create({}));
|
||||||
|
//=> true
|
||||||
|
isPlainObject(Object.create(Object.prototype));
|
||||||
|
//=> true
|
||||||
|
isPlainObject({foo: 'bar'});
|
||||||
|
//=> true
|
||||||
|
isPlainObject({});
|
||||||
|
//=> true
|
||||||
|
```
|
||||||
|
|
||||||
|
**false** when not created by the `Object` constructor.
|
||||||
|
|
||||||
|
```js
|
||||||
|
isPlainObject(1);
|
||||||
|
//=> false
|
||||||
|
isPlainObject(['foo', 'bar']);
|
||||||
|
//=> false
|
||||||
|
isPlainObject([]);
|
||||||
|
//=> false
|
||||||
|
isPlainObject(new Foo);
|
||||||
|
//=> false
|
||||||
|
isPlainObject(null);
|
||||||
|
//=> false
|
||||||
|
isPlainObject(Object.create(null));
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
### Related projects
|
||||||
|
|
||||||
|
* [is-number](https://www.npmjs.com/package/is-number): Returns true if the value is a number. comprehensive tests. | [homepage](https://github.com/jonschlinkert/is-number "Returns true if the value is a number. comprehensive tests.")
|
||||||
|
* [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject "Returns true if the value is an object and not an array or null.")
|
||||||
|
* [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of "Get the native type of a value.")
|
||||||
|
|
||||||
|
### Contributing
|
||||||
|
|
||||||
|
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||||
|
|
||||||
|
### Contributors
|
||||||
|
|
||||||
|
| **Commits** | **Contributor** |
|
||||||
|
| --- | --- |
|
||||||
|
| 17 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||||
|
| 6 | [stevenvachon](https://github.com/stevenvachon) |
|
||||||
|
| 3 | [onokumus](https://github.com/onokumus) |
|
||||||
|
| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
|
||||||
|
|
||||||
|
### Building docs
|
||||||
|
|
||||||
|
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||||
|
|
||||||
|
To generate the readme, run the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||||
|
```
|
||||||
|
|
||||||
|
### Running tests
|
||||||
|
|
||||||
|
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install && npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
### Author
|
||||||
|
|
||||||
|
**Jon Schlinkert**
|
||||||
|
|
||||||
|
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||||
|
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||||
|
|
||||||
|
### License
|
||||||
|
|
||||||
|
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||||
|
Released under the [MIT License](LICENSE).
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 11, 2017._
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
export = isPlainObject;
|
||||||
|
|
||||||
|
declare function isPlainObject(o: any): boolean;
|
||||||
|
|
||||||
|
declare namespace isPlainObject {}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
/*!
|
||||||
|
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||||||
|
* Released under the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var isObject = require('isobject');
|
||||||
|
|
||||||
|
function isObjectObject(o) {
|
||||||
|
return isObject(o) === true
|
||||||
|
&& Object.prototype.toString.call(o) === '[object Object]';
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = function isPlainObject(o) {
|
||||||
|
var ctor,prot;
|
||||||
|
|
||||||
|
if (isObjectObject(o) === false) return false;
|
||||||
|
|
||||||
|
// If has modified constructor
|
||||||
|
ctor = o.constructor;
|
||||||
|
if (typeof ctor !== 'function') return false;
|
||||||
|
|
||||||
|
// If has modified prototype
|
||||||
|
prot = ctor.prototype;
|
||||||
|
if (isObjectObject(prot) === false) return false;
|
||||||
|
|
||||||
|
// If constructor does not have an Object-specific method
|
||||||
|
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Most likely a plain Object
|
||||||
|
return true;
|
||||||
|
};
|
||||||
+79
@@ -0,0 +1,79 @@
|
|||||||
|
{
|
||||||
|
"name": "is-plain-object",
|
||||||
|
"description": "Returns true if an object was created by the `Object` constructor.",
|
||||||
|
"version": "2.0.4",
|
||||||
|
"homepage": "https://github.com/jonschlinkert/is-plain-object",
|
||||||
|
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||||
|
"contributors": [
|
||||||
|
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
||||||
|
"Osman Nuri Okumuş (http://onokumus.com)",
|
||||||
|
"Steven Vachon (https://svachon.com)",
|
||||||
|
"(https://github.com/wtgtybhertgeghgtwtg)"
|
||||||
|
],
|
||||||
|
"repository": "jonschlinkert/is-plain-object",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/jonschlinkert/is-plain-object/issues"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"files": [
|
||||||
|
"index.d.ts",
|
||||||
|
"index.js"
|
||||||
|
],
|
||||||
|
"main": "index.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"browserify": "browserify index.js --standalone isPlainObject | uglifyjs --compress --mangle -o browser/is-plain-object.js",
|
||||||
|
"test_browser": "mocha-phantomjs test/browser.html",
|
||||||
|
"test_node": "mocha",
|
||||||
|
"test": "npm run test_node && npm run browserify && npm run test_browser"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"isobject": "^3.0.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"browserify": "^14.4.0",
|
||||||
|
"chai": "^4.0.2",
|
||||||
|
"gulp-format-md": "^1.0.0",
|
||||||
|
"mocha": "^3.4.2",
|
||||||
|
"mocha-phantomjs": "^4.1.0",
|
||||||
|
"phantomjs": "^2.1.7",
|
||||||
|
"uglify-js": "^3.0.24"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"check",
|
||||||
|
"is",
|
||||||
|
"is-object",
|
||||||
|
"isobject",
|
||||||
|
"javascript",
|
||||||
|
"kind",
|
||||||
|
"kind-of",
|
||||||
|
"object",
|
||||||
|
"plain",
|
||||||
|
"type",
|
||||||
|
"typeof",
|
||||||
|
"value"
|
||||||
|
],
|
||||||
|
"types": "index.d.ts",
|
||||||
|
"verb": {
|
||||||
|
"toc": false,
|
||||||
|
"layout": "default",
|
||||||
|
"tasks": [
|
||||||
|
"readme"
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
"gulp-format-md"
|
||||||
|
],
|
||||||
|
"related": {
|
||||||
|
"list": [
|
||||||
|
"is-number",
|
||||||
|
"isobject",
|
||||||
|
"kind-of"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"lint": {
|
||||||
|
"reflinks": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014-present, Jon Schlinkert.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
+124
@@ -0,0 +1,124 @@
|
|||||||
|
# is-primitive [](https://www.npmjs.com/package/is-primitive) [](https://npmjs.org/package/is-primitive) [](https://npmjs.org/package/is-primitive) [](https://travis-ci.org/jonschlinkert/is-primitive)
|
||||||
|
|
||||||
|
> Returns `true` if the value is a primitive.
|
||||||
|
|
||||||
|
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Install with [npm](https://www.npmjs.com/):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install --save is-primitive
|
||||||
|
```
|
||||||
|
|
||||||
|
## Primitive values
|
||||||
|
|
||||||
|
The [Mozilla docs for "Primitive values"](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Primitive_values) defines specifies six data types that are primitives:
|
||||||
|
|
||||||
|
* `Boolean`
|
||||||
|
* `Null`
|
||||||
|
* `Undefined`
|
||||||
|
* `Number`
|
||||||
|
* `String`
|
||||||
|
* `Symbol` (new in ECMAScript 6)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
var isPrimitive = require('is-primitive');
|
||||||
|
```
|
||||||
|
|
||||||
|
## true
|
||||||
|
|
||||||
|
All of the following return `true`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(isPrimitive(false));
|
||||||
|
console.log(isPrimitive(true));
|
||||||
|
console.log(isPrimitive(null));
|
||||||
|
console.log(isPrimitive());
|
||||||
|
console.log(isPrimitive(42));
|
||||||
|
console.log(isPrimitive('abc'));
|
||||||
|
console.log(isPrimitive(Symbol()));
|
||||||
|
//=> true
|
||||||
|
```
|
||||||
|
|
||||||
|
## false
|
||||||
|
|
||||||
|
Everything else returns `false`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(isPrimitive({}));
|
||||||
|
console.log(isPrimitive([]));
|
||||||
|
console.log(isPrimitive(function(){}));
|
||||||
|
console.log(isPrimitive(new Date()));
|
||||||
|
// et cetera...
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>Contributing</strong></summary>
|
||||||
|
|
||||||
|
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>Running Tests</strong></summary>
|
||||||
|
|
||||||
|
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install && npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>Building docs</strong></summary>
|
||||||
|
|
||||||
|
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||||
|
|
||||||
|
To generate the readme, run the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
### Related projects
|
||||||
|
|
||||||
|
You might also be interested in these projects:
|
||||||
|
|
||||||
|
* [is-number](https://www.npmjs.com/package/is-number): Returns true if the value is a number. comprehensive tests. | [homepage](https://github.com/jonschlinkert/is-number "Returns true if the value is a number. comprehensive tests.")
|
||||||
|
* [is-plain-object](https://www.npmjs.com/package/is-plain-object): Returns true if an object was created by the `Object` constructor. | [homepage](https://github.com/jonschlinkert/is-plain-object "Returns true if an object was created by the `Object` constructor.")
|
||||||
|
* [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of "Get the native type of a value.")
|
||||||
|
|
||||||
|
### Contributors
|
||||||
|
|
||||||
|
| **Commits** | **Contributor** |
|
||||||
|
| --- | --- |
|
||||||
|
| 11 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||||
|
| 1 | [ljharb](https://github.com/ljharb) |
|
||||||
|
| 1 | [bttmly](https://github.com/bttmly) |
|
||||||
|
| 1 | [hemanth](https://github.com/hemanth) |
|
||||||
|
|
||||||
|
### Author
|
||||||
|
|
||||||
|
**Jon Schlinkert**
|
||||||
|
|
||||||
|
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||||
|
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||||
|
|
||||||
|
### License
|
||||||
|
|
||||||
|
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||||
|
Released under the [MIT License](LICENSE).
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on November 23, 2017._
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
/*!
|
||||||
|
* is-primitive <https://github.com/jonschlinkert/is-primitive>
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014-present, Jon Schlinkert.
|
||||||
|
* Released under the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = function isPrimitive(val) {
|
||||||
|
if (typeof val === 'object') {
|
||||||
|
return val === null;
|
||||||
|
}
|
||||||
|
return typeof val !== 'function';
|
||||||
|
};
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
{
|
||||||
|
"name": "is-primitive",
|
||||||
|
"description": "Returns `true` if the value is a primitive. ",
|
||||||
|
"version": "3.0.1",
|
||||||
|
"homepage": "https://github.com/jonschlinkert/is-primitive",
|
||||||
|
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||||
|
"contributors": [
|
||||||
|
"hemanth.hm (http://h3manth.com)",
|
||||||
|
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
||||||
|
"Jordan Harband (https://twitter.com/ljharb)",
|
||||||
|
"Nick Bottomley (https://github.com/bttmly)"
|
||||||
|
],
|
||||||
|
"repository": "jonschlinkert/is-primitive",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/jonschlinkert/is-primitive/issues"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"files": [
|
||||||
|
"index.js"
|
||||||
|
],
|
||||||
|
"main": "index.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"benchmark": "^2.1.4",
|
||||||
|
"gulp-format-md": "^1.0.0",
|
||||||
|
"mocha": "^3.5.3"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"boolean",
|
||||||
|
"check",
|
||||||
|
"is",
|
||||||
|
"number",
|
||||||
|
"primitive",
|
||||||
|
"string",
|
||||||
|
"symbol",
|
||||||
|
"type",
|
||||||
|
"typeof",
|
||||||
|
"util"
|
||||||
|
],
|
||||||
|
"verb": {
|
||||||
|
"toc": false,
|
||||||
|
"layout": "default",
|
||||||
|
"tasks": [
|
||||||
|
"readme"
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
"gulp-format-md"
|
||||||
|
],
|
||||||
|
"related": {
|
||||||
|
"list": [
|
||||||
|
"is-number",
|
||||||
|
"is-plain-object",
|
||||||
|
"kind-of"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"lint": {
|
||||||
|
"reflinks": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014-2017, Jon Schlinkert.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
+122
@@ -0,0 +1,122 @@
|
|||||||
|
# isobject [](https://www.npmjs.com/package/isobject) [](https://npmjs.org/package/isobject) [](https://npmjs.org/package/isobject) [](https://travis-ci.org/jonschlinkert/isobject)
|
||||||
|
|
||||||
|
> Returns true if the value is an object and not an array or null.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Install with [npm](https://www.npmjs.com/):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install --save isobject
|
||||||
|
```
|
||||||
|
|
||||||
|
Install with [yarn](https://yarnpkg.com):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ yarn add isobject
|
||||||
|
```
|
||||||
|
|
||||||
|
Use [is-plain-object](https://github.com/jonschlinkert/is-plain-object) if you want only objects that are created by the `Object` constructor.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Install with [npm](https://www.npmjs.com/):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install isobject
|
||||||
|
```
|
||||||
|
Install with [bower](https://bower.io/)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ bower install isobject
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
var isObject = require('isobject');
|
||||||
|
```
|
||||||
|
|
||||||
|
**True**
|
||||||
|
|
||||||
|
All of the following return `true`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
isObject({});
|
||||||
|
isObject(Object.create({}));
|
||||||
|
isObject(Object.create(Object.prototype));
|
||||||
|
isObject(Object.create(null));
|
||||||
|
isObject({});
|
||||||
|
isObject(new Foo);
|
||||||
|
isObject(/foo/);
|
||||||
|
```
|
||||||
|
|
||||||
|
**False**
|
||||||
|
|
||||||
|
All of the following return `false`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
isObject();
|
||||||
|
isObject(function () {});
|
||||||
|
isObject(1);
|
||||||
|
isObject([]);
|
||||||
|
isObject(undefined);
|
||||||
|
isObject(null);
|
||||||
|
```
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
### Related projects
|
||||||
|
|
||||||
|
* [extend-shallow](https://www.npmjs.com/package/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util. | [homepage](https://github.com/jonschlinkert/extend-shallow "Extend an object with the properties of additional objects. node.js/javascript util.")
|
||||||
|
* [is-plain-object](https://www.npmjs.com/package/is-plain-object): Returns true if an object was created by the `Object` constructor. | [homepage](https://github.com/jonschlinkert/is-plain-object "Returns true if an object was created by the `Object` constructor.")
|
||||||
|
* [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of "Get the native type of a value.")
|
||||||
|
* [merge-deep](https://www.npmjs.com/package/merge-deep): Recursively merge values in a javascript object. | [homepage](https://github.com/jonschlinkert/merge-deep "Recursively merge values in a javascript object.")
|
||||||
|
|
||||||
|
### Contributing
|
||||||
|
|
||||||
|
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||||
|
|
||||||
|
### Contributors
|
||||||
|
|
||||||
|
| **Commits** | **Contributor** |
|
||||||
|
| --- | --- |
|
||||||
|
| 29 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||||
|
| 4 | [doowb](https://github.com/doowb) |
|
||||||
|
| 1 | [magnudae](https://github.com/magnudae) |
|
||||||
|
| 1 | [LeSuisse](https://github.com/LeSuisse) |
|
||||||
|
| 1 | [tmcw](https://github.com/tmcw) |
|
||||||
|
|
||||||
|
### Building docs
|
||||||
|
|
||||||
|
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||||
|
|
||||||
|
To generate the readme, run the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||||
|
```
|
||||||
|
|
||||||
|
### Running tests
|
||||||
|
|
||||||
|
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install && npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
### Author
|
||||||
|
|
||||||
|
**Jon Schlinkert**
|
||||||
|
|
||||||
|
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||||
|
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||||
|
|
||||||
|
### License
|
||||||
|
|
||||||
|
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||||
|
Released under the [MIT License](LICENSE).
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on June 30, 2017._
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
export = isObject;
|
||||||
|
|
||||||
|
declare function isObject(val: any): boolean;
|
||||||
|
|
||||||
|
declare namespace isObject {}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
/*!
|
||||||
|
* isobject <https://github.com/jonschlinkert/isobject>
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||||||
|
* Released under the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = function isObject(val) {
|
||||||
|
return val != null && typeof val === 'object' && Array.isArray(val) === false;
|
||||||
|
};
|
||||||
+74
@@ -0,0 +1,74 @@
|
|||||||
|
{
|
||||||
|
"name": "isobject",
|
||||||
|
"description": "Returns true if the value is an object and not an array or null.",
|
||||||
|
"version": "3.0.1",
|
||||||
|
"homepage": "https://github.com/jonschlinkert/isobject",
|
||||||
|
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||||
|
"contributors": [
|
||||||
|
"(https://github.com/LeSuisse)",
|
||||||
|
"Brian Woodward (https://twitter.com/doowb)",
|
||||||
|
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
||||||
|
"Magnús Dæhlen (https://github.com/magnudae)",
|
||||||
|
"Tom MacWright (https://macwright.org)"
|
||||||
|
],
|
||||||
|
"repository": "jonschlinkert/isobject",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/jonschlinkert/isobject/issues"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"files": [
|
||||||
|
"index.d.ts",
|
||||||
|
"index.js"
|
||||||
|
],
|
||||||
|
"main": "index.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha"
|
||||||
|
},
|
||||||
|
"dependencies": {},
|
||||||
|
"devDependencies": {
|
||||||
|
"gulp-format-md": "^0.1.9",
|
||||||
|
"mocha": "^2.4.5"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"check",
|
||||||
|
"is",
|
||||||
|
"is-object",
|
||||||
|
"isobject",
|
||||||
|
"kind",
|
||||||
|
"kind-of",
|
||||||
|
"kindof",
|
||||||
|
"native",
|
||||||
|
"object",
|
||||||
|
"type",
|
||||||
|
"typeof",
|
||||||
|
"value"
|
||||||
|
],
|
||||||
|
"types": "index.d.ts",
|
||||||
|
"verb": {
|
||||||
|
"related": {
|
||||||
|
"list": [
|
||||||
|
"extend-shallow",
|
||||||
|
"is-plain-object",
|
||||||
|
"kind-of",
|
||||||
|
"merge-deep"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"toc": false,
|
||||||
|
"layout": "default",
|
||||||
|
"tasks": [
|
||||||
|
"readme"
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
"gulp-format-md"
|
||||||
|
],
|
||||||
|
"lint": {
|
||||||
|
"reflinks": true
|
||||||
|
},
|
||||||
|
"reflinks": [
|
||||||
|
"verb"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014-present, Jon Schlinkert.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
+302
@@ -0,0 +1,302 @@
|
|||||||
|
# set-value [](https://www.npmjs.com/package/set-value) [](https://npmjs.org/package/set-value) [](https://npmjs.org/package/set-value) [](https://github.com/jonschlinkert/set-value/actions/workflows/main.yml)
|
||||||
|
|
||||||
|
> Set nested properties on an object using dot notation.
|
||||||
|
|
||||||
|
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Install with [npm](https://www.npmjs.com/) (requires [Node.js](https://nodejs.org/en/) >=11.0):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install --save set-value
|
||||||
|
```
|
||||||
|
|
||||||
|
## Heads up!
|
||||||
|
|
||||||
|
[Please update](https://github.com/update/update) to version 3.0.1 or later, a critical bug was fixed in that version.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
const set = require('set-value');
|
||||||
|
|
||||||
|
const obj = {};
|
||||||
|
set(obj, 'a.b.c', 'd');
|
||||||
|
|
||||||
|
console.log(obj);
|
||||||
|
//=> { a: { b: { c: 'd' } } }
|
||||||
|
```
|
||||||
|
|
||||||
|
### Params
|
||||||
|
|
||||||
|
Signature:
|
||||||
|
|
||||||
|
```js
|
||||||
|
set(object, property_path, value[, options]);
|
||||||
|
```
|
||||||
|
|
||||||
|
* `object` **{Object}**: The object to set `value` on
|
||||||
|
* `path` **{String|Symbol|Array}**: The [path](#object-paths) of the property to set.
|
||||||
|
* `value` **{any}**: The value to set on `obj[prop]`
|
||||||
|
* `options` **{Object}**: See all [available options](#options)
|
||||||
|
|
||||||
|
### Object paths
|
||||||
|
|
||||||
|
You may pass a string, symbol, or array of strings or symbols. By default, when a string is passed this library will split the string on `.` or a [custom separator](#options-separator) It's useful to pass an array
|
||||||
|
|
||||||
|
### Escaping
|
||||||
|
|
||||||
|
**Escaping with backslashes**
|
||||||
|
|
||||||
|
Prevent set-value from splitting on a dot by prefixing it with backslashes:
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(set({}, 'a\\.b.c', 'd'));
|
||||||
|
//=> { 'a.b': { c: 'd' } }
|
||||||
|
|
||||||
|
console.log(set({}, 'a\\.b\\.c', 'd'));
|
||||||
|
//=> { 'a.b.c': 'd' }
|
||||||
|
```
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
### options.preservePaths
|
||||||
|
|
||||||
|
Do not split properties that include a `/`. By default, set-value assumes that properties with a `/` are not intended to be split. This option allows you to disable default behavior.
|
||||||
|
|
||||||
|
Note that this option cannot be used if `options.separator` is set to `/`.
|
||||||
|
|
||||||
|
**Type**: `boolean`
|
||||||
|
|
||||||
|
**Default**: `true`
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(set({}, 'https://github.com', true));
|
||||||
|
//=> { 'https://github.com': true }
|
||||||
|
|
||||||
|
console.log(set({}, 'https://github.com', true, { preservePaths: false }));
|
||||||
|
//=> { 'https://github': { com: true } }
|
||||||
|
```
|
||||||
|
|
||||||
|
### options.separator
|
||||||
|
|
||||||
|
Custom separator to use for splitting object paths.
|
||||||
|
|
||||||
|
**Type**: `string`
|
||||||
|
|
||||||
|
**Default**: `.`
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(set(obj, 'auth/userpass/users/bob', '*****', { separator: '/' }));
|
||||||
|
//=> { auth: { userpass: { users: { bob: '*****' } } } }
|
||||||
|
```
|
||||||
|
|
||||||
|
### options.split
|
||||||
|
|
||||||
|
Custom `.split()` function to use.
|
||||||
|
|
||||||
|
### options.merge
|
||||||
|
|
||||||
|
Allows you to update plain object values, instead of overwriting them.
|
||||||
|
|
||||||
|
**Type**: `boolean|function` - A custom `merge` function may be defined if you need to deep merge. Otherwise, when `merge` is `true`, a shallow merge will be performed by `Object.assign()`.
|
||||||
|
|
||||||
|
**Default**: `undefined`
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
|
```js
|
||||||
|
const obj = { foo: { bar: { baz: 'qux' } } };
|
||||||
|
set(obj, 'foo.bar.fez', 'zzz', { merge: true });
|
||||||
|
//=> { foo: { bar: { baz: 'qux', fez: 'zzz' } } }
|
||||||
|
```
|
||||||
|
|
||||||
|
## Benchmarks
|
||||||
|
|
||||||
|
Benchmarks were run on a MacBook Pro 2.5 GHz Intel Core i7, 16 GB 1600 MHz DDR3.
|
||||||
|
|
||||||
|
```
|
||||||
|
# deep (194 bytes)
|
||||||
|
deep-object x 823,287 ops/sec ±1.00% (90 runs sampled)
|
||||||
|
deep-property x 1,787,990 ops/sec ±0.82% (92 runs sampled)
|
||||||
|
deephas x 840,700 ops/sec ±0.95% (93 runs sampled)
|
||||||
|
dot-prop x 1,249,663 ops/sec ±0.89% (90 runs sampled)
|
||||||
|
dot2val x 2,067,212 ops/sec ±1.08% (91 runs sampled)
|
||||||
|
es5-dot-prop x 1,668,806 ops/sec ±0.92% (92 runs sampled)
|
||||||
|
lodash-set x 1,286,725 ops/sec ±0.82% (90 runs sampled)
|
||||||
|
object-path-set x 1,261,242 ops/sec ±1.63% (90 runs sampled)
|
||||||
|
object-set x 285,369 ops/sec ±0.91% (90 runs sampled)
|
||||||
|
set-value x 2,076,931 ops/sec ±0.86% (93 runs sampled)
|
||||||
|
|
||||||
|
fastest is set-value, dot2val (by 203% avg)
|
||||||
|
|
||||||
|
# medium (98 bytes)
|
||||||
|
deep-object x 5,811,161 ops/sec ±1.12% (90 runs sampled)
|
||||||
|
deep-property x 4,075,885 ops/sec ±0.91% (90 runs sampled)
|
||||||
|
deephas x 1,508,136 ops/sec ±0.82% (92 runs sampled)
|
||||||
|
dot-prop x 2,809,838 ops/sec ±1.16% (87 runs sampled)
|
||||||
|
dot2val x 4,600,890 ops/sec ±0.76% (91 runs sampled)
|
||||||
|
es5-dot-prop x 3,263,790 ops/sec ±0.97% (91 runs sampled)
|
||||||
|
lodash-set x 3,486,628 ops/sec ±1.20% (90 runs sampled)
|
||||||
|
object-path-set x 3,729,018 ops/sec ±0.90% (92 runs sampled)
|
||||||
|
object-set x 973,961 ops/sec ±0.80% (92 runs sampled)
|
||||||
|
set-value x 6,941,474 ops/sec ±1.24% (90 runs sampled)
|
||||||
|
|
||||||
|
fastest is set-value (by 206% avg)
|
||||||
|
|
||||||
|
# shallow (101 bytes)
|
||||||
|
deep-object x 9,416,410 ops/sec ±1.19% (89 runs sampled)
|
||||||
|
deep-property x 5,108,536 ops/sec ±0.98% (93 runs sampled)
|
||||||
|
deephas x 1,706,979 ops/sec ±0.98% (86 runs sampled)
|
||||||
|
dot-prop x 4,045,902 ops/sec ±1.10% (92 runs sampled)
|
||||||
|
dot2val x 5,862,418 ops/sec ±0.88% (91 runs sampled)
|
||||||
|
es5-dot-prop x 4,439,646 ops/sec ±1.18% (90 runs sampled)
|
||||||
|
lodash-set x 9,303,292 ops/sec ±1.19% (89 runs sampled)
|
||||||
|
object-path-set x 5,657,479 ops/sec ±0.95% (93 runs sampled)
|
||||||
|
object-set x 2,020,041 ops/sec ±0.92% (91 runs sampled)
|
||||||
|
set-value x 11,272,227 ops/sec ±1.36% (88 runs sampled)
|
||||||
|
|
||||||
|
fastest is set-value (by 213% avg)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Running the benchmarks
|
||||||
|
|
||||||
|
Clone this library into a local directory:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ git clone https://github.com/jonschlinkert/set-value.git
|
||||||
|
```
|
||||||
|
|
||||||
|
Then install devDependencies and run benchmarks:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install && node benchmark
|
||||||
|
```
|
||||||
|
|
||||||
|
## Comparisons to other libs, or _"the list of shame"_
|
||||||
|
|
||||||
|
These are just a few of the duplicate libraries on NPM.
|
||||||
|
|
||||||
|
* [bury](https://github.com/kalmbach/bury) fails all of the tests. I even wrapped it to have it return the object instead of the value, but with all of that work it still fails the vast majority of tests.
|
||||||
|
* [deep-get-set](https://github.com/acstll/deep-get-set) fails 22 of 26 unit tests.
|
||||||
|
* [deep-object](https://github.com/ayushgp/deep-object) fails 25 of 26 unit tests, completely butchered given objects.
|
||||||
|
* [deep-property](https://github.com/mikattack/node-deep-property) fails 17 of 26 unit tests.
|
||||||
|
* [deep-set](https://github.com/klaemo/deep-set) fails 13 of 26 unit tests.
|
||||||
|
* [deephas](https://github.com/sharpred/deepHas) fails 17 of 26 unit tests.
|
||||||
|
* [dot-prop](https://github.com/sindresorhus/dot-prop) fails 9 of 26 unit tests.
|
||||||
|
* [dot2val](https://github.com/yangg/dot2val) fails 17 of 26 unit tests.
|
||||||
|
* [es5-dot-prop](https://github.com/sindresorhus/dot-prop) fails 15 of 26 unit tests.
|
||||||
|
* [getsetdeep](https://github.com/bevry/getsetdeep) fails all unit tests due to `this` being used improperly in the methods. I was able to patch it by binding the (plain) object to the methods, but it still fails 17 of 26 unit tests.
|
||||||
|
* [lodash.set](https://lodash.com/) fails 11 of 26 unit tests.
|
||||||
|
* [object-path-set](https://github.com/skratchdot/object-path-set) fails 12 of 26 unit tests.
|
||||||
|
* [object-path](https://github.com/mariocasciaro/object-path) fails 16 of 26 unit tests.
|
||||||
|
* [object-set](https://github.com/gearcase/object-set) fails 13 of 26 unit tests.
|
||||||
|
* [set-nested-prop](https://github.com/tiaanduplessis/set-nested-prop) fails 24 of 26 unit tests.
|
||||||
|
* [setvalue](https://github.com/blakeembrey/setvalue) (this library is almost identical to a previous version of this library)
|
||||||
|
* Many dozens of others
|
||||||
|
|
||||||
|
**Others that do the same thing, but use a completely different API**
|
||||||
|
|
||||||
|
* [deep-set-in](https://github.com/KulikovskyIgor/deep-set-in)
|
||||||
|
* [set-deep](https://github.com/radubrehar/set-deep)
|
||||||
|
* [set-deep-prop](https://github.com/mmckelvy/set-deep-prop)
|
||||||
|
* [bury](https://github.com/kalmbach/bury)
|
||||||
|
* Many dozens of others
|
||||||
|
|
||||||
|
## History
|
||||||
|
|
||||||
|
### v3.0.0
|
||||||
|
|
||||||
|
* Added support for a custom `split` function to be passed on the options.
|
||||||
|
* Removed support for splitting on brackets, since a [custom function](https://github.com/jonschlinkert/split-string) can be passed to do this now.
|
||||||
|
|
||||||
|
### v2.0.0
|
||||||
|
|
||||||
|
* Adds support for escaping with double or single quotes. See [escaping](#escaping) for examples.
|
||||||
|
* Will no longer split inside brackets or braces. See [bracket support](#bracket-support) for examples.
|
||||||
|
|
||||||
|
If there are any regressions please create a [bug report](../../issues/new). Thanks!
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>Contributing</strong></summary>
|
||||||
|
|
||||||
|
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>Running Tests</strong></summary>
|
||||||
|
|
||||||
|
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install && npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>Building docs</strong></summary>
|
||||||
|
|
||||||
|
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||||
|
|
||||||
|
To generate the readme, run the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
### Related projects
|
||||||
|
|
||||||
|
You might also be interested in these projects:
|
||||||
|
|
||||||
|
* [assign-value](https://www.npmjs.com/package/assign-value): Assign a value or extend a deeply nested property of an object using object path… [more](https://github.com/jonschlinkert/assign-value) | [homepage](https://github.com/jonschlinkert/assign-value "Assign a value or extend a deeply nested property of an object using object path notation.")
|
||||||
|
* [get-value](https://www.npmjs.com/package/get-value): Use property paths like 'a.b.c' to get a nested value from an object. Even works… [more](https://github.com/jonschlinkert/get-value) | [homepage](https://github.com/jonschlinkert/get-value "Use property paths like 'a.b.c' to get a nested value from an object. Even works when keys have dots in them (no other dot-prop library can do this!).")
|
||||||
|
* [has-value](https://www.npmjs.com/package/has-value): Returns true if a value exists, false if empty. Works with deeply nested values using… [more](https://github.com/jonschlinkert/has-value) | [homepage](https://github.com/jonschlinkert/has-value "Returns true if a value exists, false if empty. Works with deeply nested values using object paths.")
|
||||||
|
* [merge-value](https://www.npmjs.com/package/merge-value): Similar to assign-value but deeply merges object values or nested values using object path/dot notation. | [homepage](https://github.com/jonschlinkert/merge-value "Similar to assign-value but deeply merges object values or nested values using object path/dot notation.")
|
||||||
|
* [omit-value](https://www.npmjs.com/package/omit-value): Omit properties from an object or deeply nested property of an object using object path… [more](https://github.com/jonschlinkert/omit-value) | [homepage](https://github.com/jonschlinkert/omit-value "Omit properties from an object or deeply nested property of an object using object path notation.")
|
||||||
|
* [set-value](https://www.npmjs.com/package/set-value): Set nested properties on an object using dot notation. | [homepage](https://github.com/jonschlinkert/set-value "Set nested properties on an object using dot notation.")
|
||||||
|
* [union-value](https://www.npmjs.com/package/union-value): Set an array of unique values as the property of an object. Supports setting deeply… [more](https://github.com/jonschlinkert/union-value) | [homepage](https://github.com/jonschlinkert/union-value "Set an array of unique values as the property of an object. Supports setting deeply nested properties using using object-paths/dot notation.")
|
||||||
|
* [unset-value](https://www.npmjs.com/package/unset-value): Delete nested properties from an object using dot notation. | [homepage](https://github.com/jonschlinkert/unset-value "Delete nested properties from an object using dot notation.")
|
||||||
|
|
||||||
|
### Contributors
|
||||||
|
|
||||||
|
| **Commits** | **Contributor** |
|
||||||
|
| --- | --- |
|
||||||
|
| 87 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||||
|
| 4 | [doowb](https://github.com/doowb) |
|
||||||
|
| 2 | [mbelsky](https://github.com/mbelsky) |
|
||||||
|
| 1 | [dkebler](https://github.com/dkebler) |
|
||||||
|
| 1 | [GlennKintscher](https://github.com/GlennKintscher) |
|
||||||
|
| 1 | [petermorlion](https://github.com/petermorlion) |
|
||||||
|
| 1 | [abetomo](https://github.com/abetomo) |
|
||||||
|
| 1 | [zeidoo](https://github.com/zeidoo) |
|
||||||
|
| 1 | [ready-research](https://github.com/ready-research) |
|
||||||
|
| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
|
||||||
|
|
||||||
|
### Author
|
||||||
|
|
||||||
|
**Jon Schlinkert**
|
||||||
|
|
||||||
|
* [GitHub Profile](https://github.com/jonschlinkert)
|
||||||
|
* [Twitter Profile](https://twitter.com/jonschlinkert)
|
||||||
|
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
|
||||||
|
|
||||||
|
### License
|
||||||
|
|
||||||
|
Copyright © 2021, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||||
|
Released under the [MIT License](LICENSE).
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on September 12, 2021._
|
||||||
+169
@@ -0,0 +1,169 @@
|
|||||||
|
/*!
|
||||||
|
* set-value <https://github.com/jonschlinkert/set-value>
|
||||||
|
*
|
||||||
|
* Copyright (c) Jon Schlinkert (https://github.com/jonschlinkert).
|
||||||
|
* Released under the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const { deleteProperty } = Reflect;
|
||||||
|
const isPrimitive = require('is-primitive');
|
||||||
|
const isPlainObject = require('is-plain-object');
|
||||||
|
|
||||||
|
const isObject = value => {
|
||||||
|
return (typeof value === 'object' && value !== null) || typeof value === 'function';
|
||||||
|
};
|
||||||
|
|
||||||
|
const isUnsafeKey = key => {
|
||||||
|
return key === '__proto__' || key === 'constructor' || key === 'prototype';
|
||||||
|
};
|
||||||
|
|
||||||
|
const validateKey = key => {
|
||||||
|
if (!isPrimitive(key)) {
|
||||||
|
throw new TypeError('Object keys must be strings or symbols');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isUnsafeKey(key)) {
|
||||||
|
throw new Error(`Cannot set unsafe key: "${key}"`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toStringKey = input => {
|
||||||
|
return Array.isArray(input) ? input.flat().map(String).join(',') : input;
|
||||||
|
};
|
||||||
|
|
||||||
|
const createMemoKey = (input, options) => {
|
||||||
|
if (typeof input !== 'string' || !options) return input;
|
||||||
|
let key = input + ';';
|
||||||
|
if (options.arrays !== undefined) key += `arrays=${options.arrays};`;
|
||||||
|
if (options.separator !== undefined) key += `separator=${options.separator};`;
|
||||||
|
if (options.split !== undefined) key += `split=${options.split};`;
|
||||||
|
if (options.merge !== undefined) key += `merge=${options.merge};`;
|
||||||
|
if (options.preservePaths !== undefined) key += `preservePaths=${options.preservePaths};`;
|
||||||
|
return key;
|
||||||
|
};
|
||||||
|
|
||||||
|
const memoize = (input, options, fn) => {
|
||||||
|
const key = toStringKey(options ? createMemoKey(input, options) : input);
|
||||||
|
validateKey(key);
|
||||||
|
|
||||||
|
const value = setValue.cache.get(key) || fn();
|
||||||
|
setValue.cache.set(key, value);
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
|
const splitString = (input, options = {}) => {
|
||||||
|
const sep = options.separator || '.';
|
||||||
|
const preserve = sep === '/' ? false : options.preservePaths;
|
||||||
|
|
||||||
|
if (typeof input === 'string' && preserve !== false && /\//.test(input)) {
|
||||||
|
return [input];
|
||||||
|
}
|
||||||
|
|
||||||
|
const parts = [];
|
||||||
|
let part = '';
|
||||||
|
|
||||||
|
const push = part => {
|
||||||
|
let number;
|
||||||
|
if (part.trim() !== '' && Number.isInteger((number = Number(part)))) {
|
||||||
|
parts.push(number);
|
||||||
|
} else {
|
||||||
|
parts.push(part);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (let i = 0; i < input.length; i++) {
|
||||||
|
const value = input[i];
|
||||||
|
|
||||||
|
if (value === '\\') {
|
||||||
|
part += input[++i];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value === sep) {
|
||||||
|
push(part);
|
||||||
|
part = '';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
part += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (part) {
|
||||||
|
push(part);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parts;
|
||||||
|
};
|
||||||
|
|
||||||
|
const split = (input, options) => {
|
||||||
|
if (options && typeof options.split === 'function') return options.split(input);
|
||||||
|
if (typeof input === 'symbol') return [input];
|
||||||
|
if (Array.isArray(input)) return input;
|
||||||
|
return memoize(input, options, () => splitString(input, options));
|
||||||
|
};
|
||||||
|
|
||||||
|
const assignProp = (obj, prop, value, options) => {
|
||||||
|
validateKey(prop);
|
||||||
|
|
||||||
|
// Delete property when "value" is undefined
|
||||||
|
if (value === undefined) {
|
||||||
|
deleteProperty(obj, prop);
|
||||||
|
|
||||||
|
} else if (options && options.merge) {
|
||||||
|
const merge = options.merge === 'function' ? options.merge : Object.assign;
|
||||||
|
|
||||||
|
// Only merge plain objects
|
||||||
|
if (merge && isPlainObject(obj[prop]) && isPlainObject(value)) {
|
||||||
|
obj[prop] = merge(obj[prop], value);
|
||||||
|
} else {
|
||||||
|
obj[prop] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
obj[prop] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
|
||||||
|
const setValue = (target, path, value, options) => {
|
||||||
|
if (!path || !isObject(target)) return target;
|
||||||
|
|
||||||
|
const keys = split(path, options);
|
||||||
|
let obj = target;
|
||||||
|
|
||||||
|
for (let i = 0; i < keys.length; i++) {
|
||||||
|
const key = keys[i];
|
||||||
|
const next = keys[i + 1];
|
||||||
|
|
||||||
|
validateKey(key);
|
||||||
|
|
||||||
|
if (next === undefined) {
|
||||||
|
assignProp(obj, key, value, options);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof next === 'number' && !Array.isArray(obj[key])) {
|
||||||
|
obj = obj[key] = [];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isObject(obj[key])) {
|
||||||
|
obj[key] = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
obj = obj[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
};
|
||||||
|
|
||||||
|
setValue.split = split;
|
||||||
|
setValue.cache = new Map();
|
||||||
|
setValue.clear = () => {
|
||||||
|
setValue.cache = new Map();
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = setValue;
|
||||||
+126
@@ -0,0 +1,126 @@
|
|||||||
|
{
|
||||||
|
"name": "set-value",
|
||||||
|
"version": "4.1.0",
|
||||||
|
"description": "Set nested properties on an object using dot notation.",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "jonschlinkert/set-value",
|
||||||
|
"homepage": "https://github.com/jonschlinkert/set-value",
|
||||||
|
"bugs": "https://github.com/jonschlinkert/set-value/issues",
|
||||||
|
"author": "Jon Schlinkert <jon.schlinkert@sellside.com> (https://github.com/jonschlinkert)",
|
||||||
|
"funding": [
|
||||||
|
"https://github.com/sponsors/jonschlinkert",
|
||||||
|
"https://paypal.me/jonathanschlinkert",
|
||||||
|
"https://jonschlinkert.dev/sponsor"
|
||||||
|
],
|
||||||
|
"contributors": [
|
||||||
|
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
||||||
|
"(https://github.com/wtgtybhertgeghgtwtg)",
|
||||||
|
"Vadim Demedes (https://vadimdemedes.com)"
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
"index.js"
|
||||||
|
],
|
||||||
|
"main": "index.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=11.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"is-plain-object": "^2.0.4",
|
||||||
|
"is-primitive": "^3.0.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"gulp-format-md": "^2.0.0",
|
||||||
|
"mocha": "^9.1.1",
|
||||||
|
"split-string": "^6.1.0"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"bury",
|
||||||
|
"deep-get-set",
|
||||||
|
"deep-object",
|
||||||
|
"deep-property",
|
||||||
|
"deep-set-in",
|
||||||
|
"deep-set",
|
||||||
|
"deephas",
|
||||||
|
"dot-prop",
|
||||||
|
"dot2val",
|
||||||
|
"es5-dot-prop",
|
||||||
|
"get",
|
||||||
|
"getsetdeep",
|
||||||
|
"has",
|
||||||
|
"hasown",
|
||||||
|
"key",
|
||||||
|
"keys",
|
||||||
|
"lodash.set",
|
||||||
|
"nested",
|
||||||
|
"notation",
|
||||||
|
"object-path-set",
|
||||||
|
"object-path",
|
||||||
|
"object-set",
|
||||||
|
"object",
|
||||||
|
"patch",
|
||||||
|
"prop",
|
||||||
|
"properties",
|
||||||
|
"property",
|
||||||
|
"props",
|
||||||
|
"put",
|
||||||
|
"set-deep-prop",
|
||||||
|
"set-deep",
|
||||||
|
"set-nested-prop",
|
||||||
|
"set",
|
||||||
|
"setvalue",
|
||||||
|
"split-string",
|
||||||
|
"value",
|
||||||
|
"values"
|
||||||
|
],
|
||||||
|
"verb": {
|
||||||
|
"toc": false,
|
||||||
|
"layout": "default",
|
||||||
|
"tasks": [
|
||||||
|
"readme"
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
"gulp-format-md"
|
||||||
|
],
|
||||||
|
"related": {
|
||||||
|
"list": [
|
||||||
|
"assign-value",
|
||||||
|
"get-value",
|
||||||
|
"has-value",
|
||||||
|
"merge-value",
|
||||||
|
"omit-value",
|
||||||
|
"set-value",
|
||||||
|
"union-value",
|
||||||
|
"unset-value"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"lint": {
|
||||||
|
"reflinks": true
|
||||||
|
},
|
||||||
|
"reflinks": [
|
||||||
|
"bury",
|
||||||
|
"deep-get-set",
|
||||||
|
"deep-object",
|
||||||
|
"deep-property",
|
||||||
|
"deep-set",
|
||||||
|
"deep-set-in",
|
||||||
|
"deephas",
|
||||||
|
"dot-prop",
|
||||||
|
"dot2val",
|
||||||
|
"es5-dot-prop",
|
||||||
|
"getsetdeep",
|
||||||
|
"lodash.set",
|
||||||
|
"object-path",
|
||||||
|
"object-path-set",
|
||||||
|
"object-set",
|
||||||
|
"set-deep",
|
||||||
|
"set-deep-prop",
|
||||||
|
"set-nested-prop",
|
||||||
|
"setvalue",
|
||||||
|
"split-string",
|
||||||
|
"update"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+12508
-4690
File diff suppressed because it is too large
Load Diff
+15
-14
@@ -21,24 +21,25 @@
|
|||||||
"author": "Reactive Circus",
|
"author": "Reactive Circus",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.6.0",
|
||||||
"@actions/exec": "^1.0.4",
|
"@actions/exec": "^1.1.0",
|
||||||
"@actions/tool-cache": "^1.6.1",
|
"@actions/tool-cache": "^1.7.1",
|
||||||
"minimist": "^1.2.5"
|
"minimist": "^1.2.5",
|
||||||
|
"set-value": "^4.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^24.9.1",
|
"@types/jest": "^27.0.3",
|
||||||
"@types/node": "^12.19.11",
|
"@types/node": "^12.20.34",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.34.0",
|
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
||||||
"@typescript-eslint/parser": "^2.34.0",
|
"@typescript-eslint/parser": "^5.4.0",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^8.3.0",
|
||||||
"eslint-config-prettier": "^6.15.0",
|
"eslint-config-prettier": "^6.15.0",
|
||||||
"eslint-plugin-import": "^2.22.1",
|
"eslint-plugin-import": "^2.25.2",
|
||||||
"eslint-plugin-prettier": "^3.3.0",
|
"eslint-plugin-prettier": "^3.4.1",
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"jest-circus": "^25.5.4",
|
"jest-circus": "^27.3.1",
|
||||||
"prettier": "^1.19.1",
|
"prettier": "^1.19.1",
|
||||||
"ts-jest": "^26.4.4",
|
"ts-jest": "^26.5.6",
|
||||||
"typescript": "^3.9.7"
|
"typescript": "^3.9.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
export function getChannelId(channelName: string): number {
|
||||||
|
if (channelName === 'stable') {
|
||||||
|
return 0;
|
||||||
|
} else if (channelName === 'beta') {
|
||||||
|
return 1;
|
||||||
|
} else if (channelName === 'dev') {
|
||||||
|
return 2;
|
||||||
|
} else if (channelName === 'canary') {
|
||||||
|
return 3;
|
||||||
|
} else {
|
||||||
|
throw new Error(`Unexpected channel name: '${channelName}'.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
+73
-37
@@ -1,4 +1,5 @@
|
|||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
const EMULATOR_BOOT_TIMEOUT_SECONDS = 600;
|
const EMULATOR_BOOT_TIMEOUT_SECONDS = 600;
|
||||||
|
|
||||||
@@ -11,62 +12,97 @@ export async function launchEmulator(
|
|||||||
arch: string,
|
arch: string,
|
||||||
profile: string,
|
profile: string,
|
||||||
cores: string,
|
cores: string,
|
||||||
|
ramSize: string,
|
||||||
sdcardPathOrSize: string,
|
sdcardPathOrSize: string,
|
||||||
|
diskSize: string,
|
||||||
avdName: string,
|
avdName: string,
|
||||||
|
forceAvdCreation: boolean,
|
||||||
emulatorOptions: string,
|
emulatorOptions: string,
|
||||||
disableAnimations: boolean
|
disableAnimations: boolean,
|
||||||
|
disableSpellChecker: boolean,
|
||||||
|
disableLinuxHardwareAcceleration: boolean,
|
||||||
|
enableHardwareKeyboard: boolean
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
// create a new AVD
|
try {
|
||||||
const profileOption = profile.trim() !== '' ? `--device '${profile}'` : '';
|
console.log(`::group::Launch Emulator`);
|
||||||
const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard '${sdcardPathOrSize}'` : '';
|
// create a new AVD if AVD directory does not already exist or forceAvdCreation is true
|
||||||
console.log(`Creating AVD.`);
|
const avdPath = `${process.env.ANDROID_AVD_HOME}/${avdName}.avd`;
|
||||||
await exec.exec(
|
if (!fs.existsSync(avdPath) || forceAvdCreation) {
|
||||||
`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}' ${profileOption} ${sdcardPathOrSizeOption}"`
|
const profileOption = profile.trim() !== '' ? `--device '${profile}'` : '';
|
||||||
);
|
const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard '${sdcardPathOrSize}'` : '';
|
||||||
|
console.log(`Creating AVD.`);
|
||||||
|
await exec.exec(
|
||||||
|
`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}' ${profileOption} ${sdcardPathOrSizeOption}"`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (cores) {
|
if (cores) {
|
||||||
await exec.exec(`sh -c \\"printf 'hw.cpu.ncore=${cores}\n' >> ~/.android/avd/"${avdName}".avd"/config.ini`);
|
await exec.exec(`sh -c \\"printf 'hw.cpu.ncore=${cores}\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// start emulator
|
if (ramSize) {
|
||||||
console.log('Starting emulator.');
|
await exec.exec(`sh -c \\"printf 'hw.ramSize=${ramSize}\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
|
||||||
|
}
|
||||||
|
|
||||||
// turn off hardware acceleration on Linux
|
if (enableHardwareKeyboard) {
|
||||||
if (process.platform === 'linux') {
|
await exec.exec(`sh -c \\"printf 'hw.keyboard=yes\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
|
||||||
emulatorOptions += ' -accel off';
|
}
|
||||||
}
|
|
||||||
|
|
||||||
await exec.exec(`sh -c \\"${process.env.ANDROID_SDK_ROOT}/emulator/emulator -avd "${avdName}" ${emulatorOptions} &"`, [], {
|
if (diskSize) {
|
||||||
listeners: {
|
await exec.exec(`sh -c \\"printf 'disk.dataPartition.size=${diskSize}\n' >> ${process.env.ANDROID_AVD_HOME}/"${avdName}".avd"/config.ini`);
|
||||||
stderr: (data: Buffer) => {
|
}
|
||||||
if (data.toString().includes('invalid command-line parameter')) {
|
|
||||||
throw new Error(data.toString());
|
//turn off hardware acceleration on Linux
|
||||||
|
if (process.platform === 'linux' && disableLinuxHardwareAcceleration) {
|
||||||
|
console.log('Disabling Linux hardware acceleration.');
|
||||||
|
emulatorOptions += ' -accel off';
|
||||||
|
}
|
||||||
|
|
||||||
|
// start emulator
|
||||||
|
console.log('Starting emulator.');
|
||||||
|
|
||||||
|
await exec.exec(`sh -c \\"${process.env.ANDROID_SDK_ROOT}/emulator/emulator -avd "${avdName}" ${emulatorOptions} &"`, [], {
|
||||||
|
listeners: {
|
||||||
|
stderr: (data: Buffer) => {
|
||||||
|
if (data.toString().includes('invalid command-line parameter')) {
|
||||||
|
throw new Error(data.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// wait for emulator to complete booting
|
||||||
|
await waitForDevice();
|
||||||
|
await exec.exec(`adb shell input keyevent 82`);
|
||||||
|
|
||||||
|
if (disableAnimations) {
|
||||||
|
console.log('Disabling animations.');
|
||||||
|
await exec.exec(`adb shell settings put global window_animation_scale 0.0`);
|
||||||
|
await exec.exec(`adb shell settings put global transition_animation_scale 0.0`);
|
||||||
|
await exec.exec(`adb shell settings put global animator_duration_scale 0.0`);
|
||||||
}
|
}
|
||||||
});
|
if (disableSpellChecker) {
|
||||||
|
await exec.exec(`adb shell settings put secure spell_checker_enabled 0`);
|
||||||
// wait for emulator to complete booting
|
}
|
||||||
await waitForDevice();
|
if (enableHardwareKeyboard) {
|
||||||
await exec.exec(`adb shell input keyevent 82`);
|
await exec.exec(`adb shell settings put secure show_ime_with_hard_keyboard 0`);
|
||||||
|
}
|
||||||
// disable animations
|
} finally {
|
||||||
if (disableAnimations) {
|
console.log(`::endgroup::`);
|
||||||
console.log('Disabling animations.');
|
|
||||||
await exec.exec(`adb shell settings put global window_animation_scale 0.0`);
|
|
||||||
await exec.exec(`adb shell settings put global transition_animation_scale 0.0`);
|
|
||||||
await exec.exec(`adb shell settings put global animator_duration_scale 0.0`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kills the running emulator on the defaut port.
|
* Kills the running emulator on the default port.
|
||||||
*/
|
*/
|
||||||
export async function killEmulator(): Promise<void> {
|
export async function killEmulator(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
|
console.log(`::group::Terminate Emulator`);
|
||||||
await exec.exec(`adb -s emulator-5554 emu kill`);
|
await exec.exec(`adb -s emulator-5554 emu kill`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error.message);
|
console.log(error.message);
|
||||||
|
} finally {
|
||||||
|
console.log(`::endgroup::`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +113,7 @@ async function waitForDevice(): Promise<void> {
|
|||||||
let booted = false;
|
let booted = false;
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
const retryInterval = 2; // retry every 2 seconds
|
const retryInterval = 2; // retry every 2 seconds
|
||||||
const maxAttemps = EMULATOR_BOOT_TIMEOUT_SECONDS / 2;
|
const maxAttempts = EMULATOR_BOOT_TIMEOUT_SECONDS / 2;
|
||||||
while (!booted) {
|
while (!booted) {
|
||||||
try {
|
try {
|
||||||
let result = '';
|
let result = '';
|
||||||
@@ -97,7 +133,7 @@ async function waitForDevice(): Promise<void> {
|
|||||||
console.warn(error.message);
|
console.warn(error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attempts < maxAttemps) {
|
if (attempts < maxAttempts) {
|
||||||
await delay(retryInterval * 1000);
|
await delay(retryInterval * 1000);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Timeout waiting for emulator to boot.`);
|
throw new Error(`Timeout waiting for emulator to boot.`);
|
||||||
|
|||||||
+55
-3
@@ -1,6 +1,7 @@
|
|||||||
export const MIN_API_LEVEL = 15;
|
export const MIN_API_LEVEL = 15;
|
||||||
export const VALID_TARGETS: Array<string> = ['default', 'google_apis', 'google_apis_playstore'];
|
export const VALID_TARGETS: Array<string> = ['default', 'google_apis', 'aosp_atd', 'google_atd', 'google_apis_playstore', 'android-wear', 'android-wear-cn', 'android-tv', 'google-tv'];
|
||||||
export const VALID_ARCHS: Array<string> = ['x86', 'x86_64'];
|
export const VALID_ARCHS: Array<string> = ['x86', 'x86_64', 'arm64-v8a'];
|
||||||
|
export const VALID_CHANNELS: Array<string> = ['stable', 'beta', 'dev', 'canary'];
|
||||||
|
|
||||||
export function checkApiLevel(apiLevel: string): void {
|
export function checkApiLevel(apiLevel: string): void {
|
||||||
if (isNaN(Number(apiLevel)) || !Number.isInteger(Number(apiLevel))) {
|
if (isNaN(Number(apiLevel)) || !Number.isInteger(Number(apiLevel))) {
|
||||||
@@ -23,14 +24,65 @@ export function checkArch(arch: string): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function checkChannel(channel: string): void {
|
||||||
|
if (!VALID_CHANNELS.includes(channel)) {
|
||||||
|
throw new Error(`Value for input.channel '${channel}' is unknown. Supported options: ${VALID_CHANNELS}.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkForceAvdCreation(forceAvdCreation: string): void {
|
||||||
|
if (!isValidBoolean(forceAvdCreation)) {
|
||||||
|
throw new Error(`Input for input.force-avd-creation should be either 'true' or 'false'.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function checkDisableAnimations(disableAnimations: string): void {
|
export function checkDisableAnimations(disableAnimations: string): void {
|
||||||
if (disableAnimations !== 'true' && disableAnimations !== 'false') {
|
if (!isValidBoolean(disableAnimations)) {
|
||||||
throw new Error(`Input for input.disable-animations should be either 'true' or 'false'.`);
|
throw new Error(`Input for input.disable-animations should be either 'true' or 'false'.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function checkDisableSpellchecker(disableSpellchecker: string): void {
|
||||||
|
if (!isValidBoolean(disableSpellchecker)) {
|
||||||
|
throw new Error(`Input for input.disable-spellchecker should be either 'true' or 'false'.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkDisableLinuxHardwareAcceleration(disableLinuxHardwareAcceleration: string): void {
|
||||||
|
if (!isValidBoolean(disableLinuxHardwareAcceleration)) {
|
||||||
|
throw new Error(`Input for input.disable-linux-hw-accel should be either 'true' or 'false'.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkEnableHardwareKeyboard(enableHardwareKeyboard: string): void {
|
||||||
|
if (!isValidBoolean(enableHardwareKeyboard)) {
|
||||||
|
throw new Error(`Input for input.enable-hw-keyboard should be either 'true' or 'false'.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function checkEmulatorBuild(emulatorBuild: string): void {
|
export function checkEmulatorBuild(emulatorBuild: string): void {
|
||||||
if (isNaN(Number(emulatorBuild)) || !Number.isInteger(Number(emulatorBuild))) {
|
if (isNaN(Number(emulatorBuild)) || !Number.isInteger(Number(emulatorBuild))) {
|
||||||
throw new Error(`Unexpected emulator build: '${emulatorBuild}'.`);
|
throw new Error(`Unexpected emulator build: '${emulatorBuild}'.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isValidBoolean(value: string): boolean {
|
||||||
|
return value === 'true' || value === 'false';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkDiskSize(diskSize: string): void {
|
||||||
|
// Disk size can be empty - the default value
|
||||||
|
if (diskSize) {
|
||||||
|
// Can also be number of bytes
|
||||||
|
if (isNaN(Number(diskSize)) || !Number.isInteger(Number(diskSize))) {
|
||||||
|
// Disk size can have a size multiplier at the end K, M or G
|
||||||
|
const diskSizeUpperCase = diskSize.toUpperCase();
|
||||||
|
if (diskSizeUpperCase.endsWith('K') || diskSizeUpperCase.endsWith('M') || diskSizeUpperCase.endsWith('G')) {
|
||||||
|
const diskSizeNoModifier: string = diskSize.slice(0, -1);
|
||||||
|
if (0 == diskSizeNoModifier.length || isNaN(Number(diskSizeNoModifier)) || !Number.isInteger(Number(diskSizeNoModifier))) {
|
||||||
|
throw new Error(`Unexpected disk size: '${diskSize}'.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+75
-4
@@ -1,12 +1,26 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import { installAndroidSdk } from './sdk-installer';
|
import { installAndroidSdk } from './sdk-installer';
|
||||||
import { checkApiLevel, checkTarget, checkArch, checkDisableAnimations, checkEmulatorBuild } from './input-validator';
|
import {
|
||||||
|
checkApiLevel,
|
||||||
|
checkTarget,
|
||||||
|
checkArch,
|
||||||
|
checkDisableAnimations,
|
||||||
|
checkEmulatorBuild,
|
||||||
|
checkDisableSpellchecker,
|
||||||
|
checkDisableLinuxHardwareAcceleration,
|
||||||
|
checkForceAvdCreation,
|
||||||
|
checkChannel,
|
||||||
|
checkEnableHardwareKeyboard,
|
||||||
|
checkDiskSize
|
||||||
|
} from './input-validator';
|
||||||
import { launchEmulator, killEmulator } from './emulator-manager';
|
import { launchEmulator, killEmulator } from './emulator-manager';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import { parseScript } from './script-parser';
|
import { parseScript } from './script-parser';
|
||||||
|
import { getChannelId } from './channel-id-mapper';
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
|
console.log(`::group::Configure emulator`);
|
||||||
// only support running on macOS or Linux
|
// only support running on macOS or Linux
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
@@ -43,14 +57,28 @@ async function run() {
|
|||||||
const cores = core.getInput('cores');
|
const cores = core.getInput('cores');
|
||||||
console.log(`Cores: ${cores}`);
|
console.log(`Cores: ${cores}`);
|
||||||
|
|
||||||
|
// RAM to use for AVD
|
||||||
|
const ramSize = core.getInput('ram-size');
|
||||||
|
console.log(`RAM size: ${ramSize}`);
|
||||||
|
|
||||||
// SD card path or size used for creating the AVD
|
// SD card path or size used for creating the AVD
|
||||||
const sdcardPathOrSize = core.getInput('sdcard-path-or-size');
|
const sdcardPathOrSize = core.getInput('sdcard-path-or-size');
|
||||||
console.log(`SD card path or size: ${sdcardPathOrSize}`);
|
console.log(`SD card path or size: ${sdcardPathOrSize}`);
|
||||||
|
|
||||||
|
const diskSize = core.getInput('disk-size');
|
||||||
|
checkDiskSize(diskSize);
|
||||||
|
console.log(`Disk size: ${diskSize}`);
|
||||||
|
|
||||||
// custom name used for creating the AVD
|
// custom name used for creating the AVD
|
||||||
const avdName = core.getInput('avd-name');
|
const avdName = core.getInput('avd-name');
|
||||||
console.log(`AVD name: ${avdName}`);
|
console.log(`AVD name: ${avdName}`);
|
||||||
|
|
||||||
|
// force AVD creation
|
||||||
|
const forceAvdCreationInput = core.getInput('force-avd-creation');
|
||||||
|
checkForceAvdCreation(forceAvdCreationInput);
|
||||||
|
const forceAvdCreation = forceAvdCreationInput === 'true';
|
||||||
|
console.log(`force avd creation: ${forceAvdCreation}`);
|
||||||
|
|
||||||
// emulator options
|
// emulator options
|
||||||
const emulatorOptions = core.getInput('emulator-options').trim();
|
const emulatorOptions = core.getInput('emulator-options').trim();
|
||||||
console.log(`emulator options: ${emulatorOptions}`);
|
console.log(`emulator options: ${emulatorOptions}`);
|
||||||
@@ -61,6 +89,24 @@ async function run() {
|
|||||||
const disableAnimations = disableAnimationsInput === 'true';
|
const disableAnimations = disableAnimationsInput === 'true';
|
||||||
console.log(`disable animations: ${disableAnimations}`);
|
console.log(`disable animations: ${disableAnimations}`);
|
||||||
|
|
||||||
|
// disable spellchecker
|
||||||
|
const disableSpellcheckerInput = core.getInput('disable-spellchecker');
|
||||||
|
checkDisableSpellchecker(disableSpellcheckerInput);
|
||||||
|
const disableSpellchecker = disableSpellcheckerInput === 'true';
|
||||||
|
console.log(`disable spellchecker: ${disableSpellchecker}`);
|
||||||
|
|
||||||
|
// disable linux hardware acceleration
|
||||||
|
const disableLinuxHardwareAccelerationInput = core.getInput('disable-linux-hw-accel');
|
||||||
|
checkDisableLinuxHardwareAcceleration(disableLinuxHardwareAccelerationInput);
|
||||||
|
const disableLinuxHardwareAcceleration = disableLinuxHardwareAccelerationInput === 'true';
|
||||||
|
console.log(`disable Linux hardware acceleration: ${disableLinuxHardwareAcceleration}`);
|
||||||
|
|
||||||
|
// enable hardware keyboard
|
||||||
|
const enableHardwareKeyboardInput = core.getInput('enable-hw-keyboard');
|
||||||
|
checkEnableHardwareKeyboard(enableHardwareKeyboardInput);
|
||||||
|
const enableHardwareKeyboard = enableHardwareKeyboardInput === 'true';
|
||||||
|
console.log(`enable hardware keyboard: ${enableHardwareKeyboard}`);
|
||||||
|
|
||||||
// emulator build
|
// emulator build
|
||||||
const emulatorBuildInput = core.getInput('emulator-build');
|
const emulatorBuildInput = core.getInput('emulator-build');
|
||||||
if (emulatorBuildInput) {
|
if (emulatorBuildInput) {
|
||||||
@@ -90,6 +136,12 @@ async function run() {
|
|||||||
}
|
}
|
||||||
const cmakeVersion = !cmakeInput ? undefined : cmakeInput;
|
const cmakeVersion = !cmakeInput ? undefined : cmakeInput;
|
||||||
|
|
||||||
|
// channelId (up to and including) to download the SDK packages from
|
||||||
|
const channelName = core.getInput('channel');
|
||||||
|
checkChannel(channelName);
|
||||||
|
const channelId = getChannelId(channelName);
|
||||||
|
console.log(`Channel: ${channelId} (${channelName})`);
|
||||||
|
|
||||||
// custom script to run
|
// custom script to run
|
||||||
const scriptInput = core.getInput('script', { required: true });
|
const scriptInput = core.getInput('script', { required: true });
|
||||||
const scripts = parseScript(scriptInput);
|
const scripts = parseScript(scriptInput);
|
||||||
@@ -97,12 +149,29 @@ async function run() {
|
|||||||
scripts.forEach(async (script: string) => {
|
scripts.forEach(async (script: string) => {
|
||||||
console.log(`${script}`);
|
console.log(`${script}`);
|
||||||
});
|
});
|
||||||
|
console.log(`::endgroup::`);
|
||||||
|
|
||||||
// install SDK
|
// install SDK
|
||||||
await installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cmakeVersion);
|
await installAndroidSdk(apiLevel, target, arch, channelId, emulatorBuild, ndkVersion, cmakeVersion);
|
||||||
|
|
||||||
// launch an emulator
|
// launch an emulator
|
||||||
await launchEmulator(apiLevel, target, arch, profile, cores, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations);
|
await launchEmulator(
|
||||||
|
apiLevel,
|
||||||
|
target,
|
||||||
|
arch,
|
||||||
|
profile,
|
||||||
|
cores,
|
||||||
|
ramSize,
|
||||||
|
sdcardPathOrSize,
|
||||||
|
diskSize,
|
||||||
|
avdName,
|
||||||
|
forceAvdCreation,
|
||||||
|
emulatorOptions,
|
||||||
|
disableAnimations,
|
||||||
|
disableSpellchecker,
|
||||||
|
disableLinuxHardwareAcceleration,
|
||||||
|
enableHardwareKeyboard
|
||||||
|
);
|
||||||
|
|
||||||
// execute the custom script
|
// execute the custom script
|
||||||
try {
|
try {
|
||||||
@@ -111,7 +180,9 @@ async function run() {
|
|||||||
process.chdir(workingDirectory);
|
process.chdir(workingDirectory);
|
||||||
}
|
}
|
||||||
for (const script of scripts) {
|
for (const script of scripts) {
|
||||||
await exec.exec(`sh -c \\"${script}"`);
|
// use array form to avoid various quote escaping problems
|
||||||
|
// caused by exec(`sh -c "${script}"`)
|
||||||
|
await exec.exec('sh', ['-c', script]);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
|||||||
+49
-52
@@ -4,71 +4,68 @@ import * as io from '@actions/io';
|
|||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
const BUILD_TOOLS_VERSION = '30.0.3';
|
const BUILD_TOOLS_VERSION = '32.0.0';
|
||||||
const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-6858069_latest.zip';
|
const CMDLINE_TOOLS_URL_MAC = 'https://dl.google.com/android/repository/commandlinetools-mac-8092744_latest.zip';
|
||||||
const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip';
|
const CMDLINE_TOOLS_URL_LINUX = 'https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installs & updates the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator,
|
* Installs & updates the Android SDK for the macOS platform, including SDK platform for the chosen API level, latest build tools, platform tools, Android Emulator,
|
||||||
* and the system image for the chosen API level, CPU arch, and target.
|
* and the system image for the chosen API level, CPU arch, and target.
|
||||||
*/
|
*/
|
||||||
export async function installAndroidSdk(apiLevel: number, target: string, arch: string, emulatorBuild?: string, ndkVersion?: string, cmakeVersion?: string): Promise<void> {
|
export async function installAndroidSdk(apiLevel: number, target: string, arch: string, channelId: number, emulatorBuild?: string, ndkVersion?: string, cmakeVersion?: string): Promise<void> {
|
||||||
const isOnMac = process.platform === 'darwin';
|
try {
|
||||||
|
console.log(`::group::Install Android SDK`);
|
||||||
|
const isOnMac = process.platform === 'darwin';
|
||||||
|
|
||||||
if (!isOnMac) {
|
if (!isOnMac) {
|
||||||
await exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_SDK_ROOT} -R`);
|
await exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_SDK_ROOT} -R`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const cmdlineToolsPath = `${process.env.ANDROID_SDK_ROOT}/cmdline-tools`;
|
const cmdlineToolsPath = `${process.env.ANDROID_SDK_ROOT}/cmdline-tools`;
|
||||||
if (!fs.existsSync(cmdlineToolsPath)) {
|
if (!fs.existsSync(cmdlineToolsPath)) {
|
||||||
console.log('Installing new cmdline-tools.');
|
console.log('Installing new cmdline-tools.');
|
||||||
const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX;
|
const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX;
|
||||||
const downloadPath = await tc.downloadTool(sdkUrl);
|
const downloadPath = await tc.downloadTool(sdkUrl);
|
||||||
await tc.extractZip(downloadPath, cmdlineToolsPath);
|
await tc.extractZip(downloadPath, cmdlineToolsPath);
|
||||||
await io.mv(`${cmdlineToolsPath}/cmdline-tools`, `${cmdlineToolsPath}/latest`);
|
await io.mv(`${cmdlineToolsPath}/cmdline-tools`, `${cmdlineToolsPath}/latest`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add paths for commandline-tools and platform-tools
|
// add paths for commandline-tools and platform-tools
|
||||||
core.addPath(`${cmdlineToolsPath}/latest:${cmdlineToolsPath}/latest/bin:${process.env.ANDROID_SDK_ROOT}/platform-tools`);
|
core.addPath(`${cmdlineToolsPath}/latest:${cmdlineToolsPath}/latest/bin:${process.env.ANDROID_SDK_ROOT}/platform-tools`);
|
||||||
|
|
||||||
// additional permission and license requirements for Linux
|
// set standard AVD path
|
||||||
const sdkPreviewLicensePath = `${process.env.ANDROID_SDK_ROOT}/licenses/android-sdk-preview-license`;
|
core.exportVariable('ANDROID_AVD_HOME', `${process.env.HOME}/.android/avd`);
|
||||||
if (!isOnMac && !fs.existsSync(sdkPreviewLicensePath)) {
|
|
||||||
fs.writeFileSync(sdkPreviewLicensePath, '\n84831b9409646a918e30573bab4c9c91346d8abd');
|
|
||||||
}
|
|
||||||
|
|
||||||
// license required for API 30 and non-default API 28 system images
|
// accept all Android SDK licenses
|
||||||
const sdkArmDbtLicensePath = `${process.env.ANDROID_SDK_ROOT}/licenses/android-sdk-arm-dbt-license`;
|
await exec.exec(`sh -c \\"yes | sdkmanager --licenses > /dev/null"`);
|
||||||
if (requiresArmDbtLicense(apiLevel, target) && !fs.existsSync(sdkArmDbtLicensePath)) {
|
|
||||||
fs.writeFileSync(sdkArmDbtLicensePath, '\n859f317696f67ef3d7f30a50a5560e7834b43903');
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Installing latest build tools, platform tools, and platform.');
|
console.log('Installing latest build tools, platform tools, and platform.');
|
||||||
|
|
||||||
|
await exec.exec(`sh -c \\"sdkmanager --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`);
|
||||||
|
|
||||||
await exec.exec(`sh -c \\"sdkmanager --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`);
|
|
||||||
if (emulatorBuild) {
|
|
||||||
console.log(`Installing emulator build ${emulatorBuild}.`);
|
|
||||||
await exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}-${emulatorBuild}.zip`);
|
|
||||||
await io.rmRF(`${process.env.ANDROID_SDK_ROOT}/emulator`);
|
|
||||||
await exec.exec(`unzip -q emulator.zip -d ${process.env.ANDROID_SDK_ROOT}`);
|
|
||||||
await io.rmRF('emulator.zip');
|
|
||||||
} else {
|
|
||||||
console.log('Installing latest emulator.');
|
console.log('Installing latest emulator.');
|
||||||
await exec.exec(`sh -c \\"sdkmanager --install emulator > /dev/null"`);
|
await exec.exec(`sh -c \\"sdkmanager --install emulator --channel=${channelId} > /dev/null"`);
|
||||||
}
|
|
||||||
console.log('Installing system images.');
|
|
||||||
await exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
|
|
||||||
|
|
||||||
if (ndkVersion) {
|
if (emulatorBuild) {
|
||||||
console.log(`Installing NDK ${ndkVersion}.`);
|
console.log(`Installing emulator build ${emulatorBuild}.`);
|
||||||
await exec.exec(`sh -c \\"sdkmanager --install 'ndk;${ndkVersion}' > /dev/null"`);
|
// TODO find out the correct download URLs for all build ids
|
||||||
}
|
const downloadUrlSuffix = Number(emulatorBuild.charAt(0)) > 6 ? `_x64-${emulatorBuild}` : `-${emulatorBuild}`;
|
||||||
if (cmakeVersion) {
|
await exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}${downloadUrlSuffix}.zip`);
|
||||||
console.log(`Installing CMake ${cmakeVersion}.`);
|
await exec.exec(`unzip -o -q emulator.zip -d ${process.env.ANDROID_SDK_ROOT}`);
|
||||||
await exec.exec(`sh -c \\"sdkmanager --install 'cmake;${cmakeVersion}' > /dev/null"`);
|
await io.rmRF('emulator.zip');
|
||||||
|
}
|
||||||
|
console.log('Installing system images.');
|
||||||
|
await exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${apiLevel};${target};${arch}' --channel=${channelId} > /dev/null"`);
|
||||||
|
|
||||||
|
if (ndkVersion) {
|
||||||
|
console.log(`Installing NDK ${ndkVersion}.`);
|
||||||
|
await exec.exec(`sh -c \\"sdkmanager --install 'ndk;${ndkVersion}' --channel=${channelId} > /dev/null"`);
|
||||||
|
}
|
||||||
|
if (cmakeVersion) {
|
||||||
|
console.log(`Installing CMake ${cmakeVersion}.`);
|
||||||
|
await exec.exec(`sh -c \\"sdkmanager --install 'cmake;${cmakeVersion}' --channel=${channelId} > /dev/null"`);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
console.log(`::endgroup::`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function requiresArmDbtLicense(apiLevel: number, target: string): boolean {
|
|
||||||
return apiLevel === 30 || (apiLevel === 28 && target !== 'default');
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ apply plugin: 'com.android.application'
|
|||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 30
|
compileSdkVersion 32
|
||||||
buildToolsVersion "30.0.3"
|
buildToolsVersion "32.0.0"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.example.testapp"
|
applicationId "com.example.testapp"
|
||||||
minSdkVersion 15
|
minSdkVersion 15
|
||||||
targetSdkVersion 30
|
targetSdkVersion 32
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
|
||||||
@@ -26,10 +26,7 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
implementation 'androidx.appcompat:appcompat:1.3.1'
|
||||||
implementation 'androidx.core:core-ktx:1.3.2'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||||
testImplementation 'junit:junit:4.13'
|
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
<activity android:name="com.example.testapp.MainActivity">
|
<activity
|
||||||
|
android:name="com.example.testapp.MainActivity"
|
||||||
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -10,9 +10,6 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Hello World!"
|
android:text="Hello World!"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
android:layout_gravity="center" />
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</FrameLayout>
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.4.21'
|
ext.kotlin_version = '1.5.30'
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.1'
|
classpath 'com.android.tools.build:gradle:7.0.1'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
org.gradle.configureondemand=true
|
org.gradle.configureondemand=true
|
||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
org.gradle.vfs.watch=true
|
|
||||||
|
|
||||||
# Enable Kotlin incremental compilation
|
# Enable Kotlin incremental compilation
|
||||||
kotlin.incremental=true
|
kotlin.incremental=true
|
||||||
|
|||||||
+1
-1
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||||
|
|||||||
Reference in New Issue
Block a user