mirror of
https://github.com/codecov/codecov-action.git
synced 2025-12-08 16:16:24 +00:00
Compare commits
92 Commits
thomasrock
...
v3.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3c560433a | ||
|
|
174efc5984 | ||
|
|
6243a75ef3 | ||
|
|
0d6466ff9c | ||
|
|
d4729eeb39 | ||
|
|
351baf62fa | ||
|
|
d8cf6802a8 | ||
|
|
b775e9013c | ||
|
|
2ebc2f0f6f | ||
|
|
8e2ef2bfcc | ||
|
|
5f458f03fe | ||
|
|
398eded4bc | ||
|
|
9af8a2b3c9 | ||
|
|
57fe0bb86d | ||
|
|
e0cb890d01 | ||
|
|
36c973b6e9 | ||
|
|
adc3ab95ef | ||
|
|
184819f51c | ||
|
|
351939570f | ||
|
|
86baaaf3a3 | ||
|
|
7ab2ce5d95 | ||
|
|
c3d40623c9 | ||
|
|
9e4b071621 | ||
|
|
ac6033346c | ||
|
|
c76bf12730 | ||
|
|
f37520c6b0 | ||
|
|
f78e7e3295 | ||
|
|
8930ac6d38 | ||
|
|
ef0a21c8b8 | ||
|
|
8b32ec40ba | ||
|
|
b049ab51f4 | ||
|
|
a85bdd422f | ||
|
|
108007e68f | ||
|
|
bf6b3a72da | ||
|
|
a485989079 | ||
|
|
7b31018a7e | ||
|
|
bcaaa7b51e | ||
|
|
d1701787c1 | ||
|
|
d7cfb89995 | ||
|
|
e01bbc8240 | ||
|
|
db6357e737 | ||
|
|
6f19c0f88c | ||
|
|
6c33a9bebe | ||
|
|
c2991883fa | ||
|
|
56370063d3 | ||
|
|
50287531e1 | ||
|
|
2f3807462c | ||
|
|
260aa3b4b2 | ||
|
|
42ece2600c | ||
|
|
f32b3a3741 | ||
|
|
72dfd4782e | ||
|
|
46edaeda0c | ||
|
|
b6fd8cc98b | ||
|
|
07a4e975bb | ||
|
|
c071c7087f | ||
|
|
f6d4366a4c | ||
|
|
2bbefc9105 | ||
|
|
5a8bb4701e | ||
|
|
3e9a2814f2 | ||
|
|
6feb914f25 | ||
|
|
9f40d310dd | ||
|
|
c4e74feb72 | ||
|
|
6ba3fb33c7 | ||
|
|
7efb9be09a | ||
|
|
514990d4ef | ||
|
|
cd6db5e313 | ||
|
|
678cc77a4f | ||
|
|
4d99e58921 | ||
|
|
92dc6d4776 | ||
|
|
b92422542f | ||
|
|
5a85075c68 | ||
|
|
53cd6a7259 | ||
|
|
be75906042 | ||
|
|
4af3634337 | ||
|
|
476c0d12c6 | ||
|
|
d37df59abd | ||
|
|
17debce911 | ||
|
|
ef233394d5 | ||
|
|
ef1306695a | ||
|
|
617d8c2876 | ||
|
|
d5d9accd2c | ||
|
|
0764691a81 | ||
|
|
b5f04a063c | ||
|
|
f059fc5a7a | ||
|
|
8f4c6c001f | ||
|
|
dc1883c9ed | ||
|
|
1266be0b5c | ||
|
|
71a740cb5b | ||
|
|
93f0e12d86 | ||
|
|
c31909abf8 | ||
|
|
71ef541ceb | ||
|
|
c452b99268 |
20
.github/workflows/main.yml
vendored
20
.github/workflows/main.yml
vendored
@@ -8,7 +8,7 @@ jobs:
|
|||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Upload coverage to Codecov (script)
|
- name: Upload coverage to Codecov (script)
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -22,6 +22,14 @@ jobs:
|
|||||||
file: ./coverage/coverage-final.json
|
file: ./coverage/coverage-final.json
|
||||||
flags: demo,${{ matrix.os }}
|
flags: demo,${{ matrix.os }}
|
||||||
name: codecov-demo
|
name: codecov-demo
|
||||||
|
- name: Upload coverage to Codecov (version)
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
|
||||||
|
file: ./coverage/coverage-final.json
|
||||||
|
flags: version,${{ matrix.os }}
|
||||||
|
name: codecov-version
|
||||||
|
version: v0.1.0_8880
|
||||||
run:
|
run:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
@@ -29,7 +37,7 @@ jobs:
|
|||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm install
|
run: npm install
|
||||||
- name: Lint
|
- name: Lint
|
||||||
@@ -49,3 +57,11 @@ jobs:
|
|||||||
file: ./coverage/coverage-final.json
|
file: ./coverage/coverage-final.json
|
||||||
flags: demo,${{ matrix.os }}
|
flags: demo,${{ matrix.os }}
|
||||||
name: codecov-demo
|
name: codecov-demo
|
||||||
|
- name: Upload coverage to Codecov (version)
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
|
||||||
|
file: ./coverage/coverage-final.json
|
||||||
|
flags: version,${{ matrix.os }}
|
||||||
|
name: codecov-version
|
||||||
|
version: v0.1.0_8880
|
||||||
|
|||||||
54
CHANGELOG.md
54
CHANGELOG.md
@@ -1,3 +1,57 @@
|
|||||||
|
## 3.0.0
|
||||||
|
### Breaking Changes
|
||||||
|
- #689 Bump to node16 and small fixes
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- #688 Incorporate `gcov` arguments for the Codecov uploader
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
- #548 build(deps-dev): bump jest-junit from 12.2.0 to 13.0.0
|
||||||
|
- #603 [Snyk] Upgrade @actions/core from 1.5.0 to 1.6.0
|
||||||
|
- #628 build(deps): bump node-fetch from 2.6.1 to 3.1.1
|
||||||
|
- #634 build(deps): bump node-fetch from 3.1.1 to 3.2.0
|
||||||
|
- #636 build(deps): bump openpgp from 5.0.1 to 5.1.0
|
||||||
|
- #652 build(deps-dev): bump @vercel/ncc from 0.30.0 to 0.33.3
|
||||||
|
- #653 build(deps-dev): bump @types/node from 16.11.21 to 17.0.18
|
||||||
|
- #659 build(deps-dev): bump @types/jest from 27.4.0 to 27.4.1
|
||||||
|
- #667 build(deps): bump actions/checkout from 2 to 3
|
||||||
|
- #673 build(deps): bump node-fetch from 3.2.0 to 3.2.3
|
||||||
|
- #683 build(deps): bump minimist from 1.2.5 to 1.2.6
|
||||||
|
- #685 build(deps): bump @actions/github from 5.0.0 to 5.0.1
|
||||||
|
- #681 build(deps-dev): bump @types/node from 17.0.18 to 17.0.23
|
||||||
|
- #682 build(deps-dev): bump typescript from 4.5.5 to 4.6.3
|
||||||
|
- #676 build(deps): bump @actions/exec from 1.1.0 to 1.1.1
|
||||||
|
- #675 build(deps): bump openpgp from 5.1.0 to 5.2.1
|
||||||
|
|
||||||
|
## 2.1.0
|
||||||
|
### Features
|
||||||
|
- #515 Allow specifying version of Codecov uploader
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
- #499 build(deps-dev): bump @vercel/ncc from 0.29.0 to 0.30.0
|
||||||
|
- #508 build(deps): bump openpgp from 5.0.0-5 to 5.0.0
|
||||||
|
- #514 build(deps-dev): bump @types/node from 16.6.0 to 16.9.0
|
||||||
|
|
||||||
|
## 2.0.3
|
||||||
|
### Fixes
|
||||||
|
- #464 Fix wrong link in the readme
|
||||||
|
- #485 fix: Add override OS and linux default to platform
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
- #447 build(deps): bump openpgp from 5.0.0-4 to 5.0.0-5
|
||||||
|
- #458 build(deps-dev): bump eslint from 7.31.0 to 7.32.0
|
||||||
|
- #465 build(deps-dev): bump @typescript-eslint/eslint-plugin from 4.28.4 to 4.29.1
|
||||||
|
- #466 build(deps-dev): bump @typescript-eslint/parser from 4.28.4 to 4.29.1
|
||||||
|
- #468 build(deps-dev): bump @types/jest from 26.0.24 to 27.0.0
|
||||||
|
- #470 build(deps-dev): bump @types/node from 16.4.0 to 16.6.0
|
||||||
|
- #472 build(deps): bump path-parse from 1.0.6 to 1.0.7
|
||||||
|
- #473 build(deps-dev): bump @types/jest from 27.0.0 to 27.0.1
|
||||||
|
- #478 build(deps-dev): bump @typescript-eslint/parser from 4.29.1 to 4.29.2
|
||||||
|
- #479 build(deps-dev): bump @typescript-eslint/eslint-plugin from 4.29.1 to 4.29.2
|
||||||
|
- #481 build(deps-dev): bump @types/node from 16.6.0 to 16.6.2
|
||||||
|
- #483 build(deps-dev): bump @vercel/ncc from 0.29.0 to 0.29.2
|
||||||
|
- #484 build(deps): bump @actions/core from 1.4.0 to 1.5.0
|
||||||
|
|
||||||
## 2.0.2
|
## 2.0.2
|
||||||
### Fixes
|
### Fixes
|
||||||
- Underlying uploader fixes issues with tokens not being sent properly for users seeing
|
- Underlying uploader fixes issues with tokens not being sent properly for users seeing
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -3,5 +3,5 @@ deploy:
|
|||||||
git tag -d v2
|
git tag -d v2
|
||||||
git push origin :v2
|
git push origin :v2
|
||||||
git tag v2
|
git tag v2
|
||||||
git tag v$(VERSION) -m ""
|
git tag v$(VERSION) -s -m ""
|
||||||
git push origin --tags
|
git push origin --tags
|
||||||
|
|||||||
13
README.md
13
README.md
@@ -1,6 +1,6 @@
|
|||||||
# Codecov GitHub Action
|
# Codecov GitHub Action
|
||||||
|
|
||||||
[](https://github.com/marketplace/actions/codecov)
|
[](https://github.com/marketplace/actions/codecov)
|
||||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fcodecov-action?ref=badge_shield)
|
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fcodecov-action?ref=badge_shield)
|
||||||
[](https://github.com/codecov/codecov-action/actions/workflows/main.yml)
|
[](https://github.com/codecov/codecov-action/actions/workflows/main.yml)
|
||||||
### Easily upload coverage reports to Codecov from GitHub Actions
|
### Easily upload coverage reports to Codecov from GitHub Actions
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
## ⚠️ Deprecration of v1
|
## ⚠️ Deprecration of v1
|
||||||
**On February 1, 2022, this version will be fully sunset and no longer function**
|
**On February 1, 2022, this version will be fully sunset and no longer function**
|
||||||
|
|
||||||
Due to the [deprecation](https://about.codecov.io/blog/introducting-codecovs-new-uploader/) of the underlying bash uploader,
|
Due to the [deprecation](https://about.codecov.io/blog/introducing-codecovs-new-uploader/) of the underlying bash uploader,
|
||||||
the Codecov GitHub Action has released `v2` which will use the new [uploader](https://github.com/codecov/uploader). You can learn
|
the Codecov GitHub Action has released `v2` which will use the new [uploader](https://github.com/codecov/uploader). You can learn
|
||||||
more about our deprecation plan and the new uploader on our [blog](https://about.codecov.io/blog/introducing-codecovs-new-uploader/).
|
more about our deprecation plan and the new uploader on our [blog](https://about.codecov.io/blog/introducing-codecovs-new-uploader/).
|
||||||
|
|
||||||
@@ -59,8 +59,12 @@ Codecov's Action currently supports five inputs from the user: `token`, `file`,
|
|||||||
| `commit_parent` | The commit SHA of the parent for which you are uploading coverage. If not present, the parent will be determined using the API of your repository provider. When using the repository provider's API, the parent is determined via finding the closest ancestor to the commit. | Optional
|
| `commit_parent` | The commit SHA of the parent for which you are uploading coverage. If not present, the parent will be determined using the API of your repository provider. When using the repository provider's API, the parent is determined via finding the closest ancestor to the commit. | Optional
|
||||||
| `env_vars` | Environment variables to tag the upload with. Multiple env variables can be separated with commas (e.g. `OS,PYTHON`) | Optional
|
| `env_vars` | Environment variables to tag the upload with. Multiple env variables can be separated with commas (e.g. `OS,PYTHON`) | Optional
|
||||||
| `fail_ci_if_error` | Specify if CI pipeline should fail when Codecov runs into errors during upload. *Defaults to **false*** | Optional
|
| `fail_ci_if_error` | Specify if CI pipeline should fail when Codecov runs into errors during upload. *Defaults to **false*** | Optional
|
||||||
-| `functionalities` | Toggle functionalities | Optional
|
| `functionalities` | Toggle functionalities | Optional
|
||||||
-| | `network` Disable uploading the file network |
|
| | `network` Disable uploading the file network |
|
||||||
|
| `gcov` | Run with gcov support |
|
||||||
|
| `gcov_args` | Extra arguments to pass to gcov |
|
||||||
|
| `gcov_ignore` | Paths to ignore during gcov gathering |
|
||||||
|
| `gcov_include` | Paths to include during gcov gathering |
|
||||||
| `move_coverage_to_trash` | Move discovered coverage reports to the trash | Optional
|
| `move_coverage_to_trash` | Move discovered coverage reports to the trash | Optional
|
||||||
| `name` | Custom defined name for the upload | Optional
|
| `name` | Custom defined name for the upload | Optional
|
||||||
| `override_branch` | Specify the branch name | Optional
|
| `override_branch` | Specify the branch name | Optional
|
||||||
@@ -73,6 +77,7 @@ Codecov's Action currently supports five inputs from the user: `token`, `file`,
|
|||||||
| `slug` | Specify the slug manually (Enterprise use) | Optional
|
| `slug` | Specify the slug manually (Enterprise use) | Optional
|
||||||
| `url` | Change the upload host (Enterprise use) | Optional
|
| `url` | Change the upload host (Enterprise use) | Optional
|
||||||
| `verbose` | Specify whether the Codecov output should be verbose | Optional
|
| `verbose` | Specify whether the Codecov output should be verbose | Optional
|
||||||
|
| `version` | Specify which version of the Codecov Uploader should be used. Defaults to `latest` | Optional
|
||||||
| `working-directory` | Directory in which to execute `codecov.sh` | Optional
|
| `working-directory` | Directory in which to execute `codecov.sh` | Optional
|
||||||
|
|
||||||
### Example `workflow.yml` with Codecov Action
|
### Example `workflow.yml` with Codecov Action
|
||||||
|
|||||||
20
action.yml
20
action.yml
@@ -32,6 +32,18 @@ inputs:
|
|||||||
functionalities:
|
functionalities:
|
||||||
description: 'Comma-separated list, see the README for options and their usage'
|
description: 'Comma-separated list, see the README for options and their usage'
|
||||||
required: false
|
required: false
|
||||||
|
gcov:
|
||||||
|
description: 'Run with gcov support'
|
||||||
|
required: false
|
||||||
|
gcov_args:
|
||||||
|
description: 'Extra arguments to pass to gcov'
|
||||||
|
required: false
|
||||||
|
gcov_ignore:
|
||||||
|
description: 'Paths to ignore during gcov gathering'
|
||||||
|
required: false
|
||||||
|
gcov_include:
|
||||||
|
description: 'Paths to include during gcov gathering'
|
||||||
|
required: false
|
||||||
move_coverage_to_trash:
|
move_coverage_to_trash:
|
||||||
description: 'Move discovered coverage reports to the trash'
|
description: 'Move discovered coverage reports to the trash'
|
||||||
required: false
|
required: false
|
||||||
@@ -53,6 +65,9 @@ inputs:
|
|||||||
override_tag:
|
override_tag:
|
||||||
description: 'Specify the git tag'
|
description: 'Specify the git tag'
|
||||||
required: false
|
required: false
|
||||||
|
os:
|
||||||
|
description: 'Override the assumed OS. Options are alpine | linux | macos | windows.'
|
||||||
|
required: false
|
||||||
root_dir:
|
root_dir:
|
||||||
description: 'Used when not in git/hg project to identify project root directory'
|
description: 'Used when not in git/hg project to identify project root directory'
|
||||||
required: false
|
required: false
|
||||||
@@ -65,6 +80,9 @@ inputs:
|
|||||||
verbose:
|
verbose:
|
||||||
description: 'Specify whether the Codecov output should be verbose'
|
description: 'Specify whether the Codecov output should be verbose'
|
||||||
required: false
|
required: false
|
||||||
|
version:
|
||||||
|
description: 'Specify which version of the Codecov Uploader should be used. Defaults to `latest`'
|
||||||
|
required: false
|
||||||
working-directory:
|
working-directory:
|
||||||
description: 'Directory in which to execute codecov.sh'
|
description: 'Directory in which to execute codecov.sh'
|
||||||
required: false
|
required: false
|
||||||
@@ -72,5 +90,5 @@ branding:
|
|||||||
color: 'red'
|
color: 'red'
|
||||||
icon: 'umbrella'
|
icon: 'umbrella'
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node16'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
453
dist/37.index.js
vendored
Normal file
453
dist/37.index.js
vendored
Normal file
@@ -0,0 +1,453 @@
|
|||||||
|
"use strict";
|
||||||
|
exports.id = 37;
|
||||||
|
exports.ids = [37];
|
||||||
|
exports.modules = {
|
||||||
|
|
||||||
|
/***/ 4037:
|
||||||
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||||
|
|
||||||
|
__webpack_require__.r(__webpack_exports__);
|
||||||
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
|
/* harmony export */ "toFormData": () => (/* binding */ toFormData)
|
||||||
|
/* harmony export */ });
|
||||||
|
/* harmony import */ var fetch_blob_from_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2777);
|
||||||
|
/* harmony import */ var formdata_polyfill_esm_min_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8010);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let s = 0;
|
||||||
|
const S = {
|
||||||
|
START_BOUNDARY: s++,
|
||||||
|
HEADER_FIELD_START: s++,
|
||||||
|
HEADER_FIELD: s++,
|
||||||
|
HEADER_VALUE_START: s++,
|
||||||
|
HEADER_VALUE: s++,
|
||||||
|
HEADER_VALUE_ALMOST_DONE: s++,
|
||||||
|
HEADERS_ALMOST_DONE: s++,
|
||||||
|
PART_DATA_START: s++,
|
||||||
|
PART_DATA: s++,
|
||||||
|
END: s++
|
||||||
|
};
|
||||||
|
|
||||||
|
let f = 1;
|
||||||
|
const F = {
|
||||||
|
PART_BOUNDARY: f,
|
||||||
|
LAST_BOUNDARY: f *= 2
|
||||||
|
};
|
||||||
|
|
||||||
|
const LF = 10;
|
||||||
|
const CR = 13;
|
||||||
|
const SPACE = 32;
|
||||||
|
const HYPHEN = 45;
|
||||||
|
const COLON = 58;
|
||||||
|
const A = 97;
|
||||||
|
const Z = 122;
|
||||||
|
|
||||||
|
const lower = c => c | 0x20;
|
||||||
|
|
||||||
|
const noop = () => {};
|
||||||
|
|
||||||
|
class MultipartParser {
|
||||||
|
/**
|
||||||
|
* @param {string} boundary
|
||||||
|
*/
|
||||||
|
constructor(boundary) {
|
||||||
|
this.index = 0;
|
||||||
|
this.flags = 0;
|
||||||
|
|
||||||
|
this.onHeaderEnd = noop;
|
||||||
|
this.onHeaderField = noop;
|
||||||
|
this.onHeadersEnd = noop;
|
||||||
|
this.onHeaderValue = noop;
|
||||||
|
this.onPartBegin = noop;
|
||||||
|
this.onPartData = noop;
|
||||||
|
this.onPartEnd = noop;
|
||||||
|
|
||||||
|
this.boundaryChars = {};
|
||||||
|
|
||||||
|
boundary = '\r\n--' + boundary;
|
||||||
|
const ui8a = new Uint8Array(boundary.length);
|
||||||
|
for (let i = 0; i < boundary.length; i++) {
|
||||||
|
ui8a[i] = boundary.charCodeAt(i);
|
||||||
|
this.boundaryChars[ui8a[i]] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.boundary = ui8a;
|
||||||
|
this.lookbehind = new Uint8Array(this.boundary.length + 8);
|
||||||
|
this.state = S.START_BOUNDARY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Uint8Array} data
|
||||||
|
*/
|
||||||
|
write(data) {
|
||||||
|
let i = 0;
|
||||||
|
const length_ = data.length;
|
||||||
|
let previousIndex = this.index;
|
||||||
|
let {lookbehind, boundary, boundaryChars, index, state, flags} = this;
|
||||||
|
const boundaryLength = this.boundary.length;
|
||||||
|
const boundaryEnd = boundaryLength - 1;
|
||||||
|
const bufferLength = data.length;
|
||||||
|
let c;
|
||||||
|
let cl;
|
||||||
|
|
||||||
|
const mark = name => {
|
||||||
|
this[name + 'Mark'] = i;
|
||||||
|
};
|
||||||
|
|
||||||
|
const clear = name => {
|
||||||
|
delete this[name + 'Mark'];
|
||||||
|
};
|
||||||
|
|
||||||
|
const callback = (callbackSymbol, start, end, ui8a) => {
|
||||||
|
if (start === undefined || start !== end) {
|
||||||
|
this[callbackSymbol](ui8a && ui8a.subarray(start, end));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const dataCallback = (name, clear) => {
|
||||||
|
const markSymbol = name + 'Mark';
|
||||||
|
if (!(markSymbol in this)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clear) {
|
||||||
|
callback(name, this[markSymbol], i, data);
|
||||||
|
delete this[markSymbol];
|
||||||
|
} else {
|
||||||
|
callback(name, this[markSymbol], data.length, data);
|
||||||
|
this[markSymbol] = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (i = 0; i < length_; i++) {
|
||||||
|
c = data[i];
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case S.START_BOUNDARY:
|
||||||
|
if (index === boundary.length - 2) {
|
||||||
|
if (c === HYPHEN) {
|
||||||
|
flags |= F.LAST_BOUNDARY;
|
||||||
|
} else if (c !== CR) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
|
break;
|
||||||
|
} else if (index - 1 === boundary.length - 2) {
|
||||||
|
if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
|
||||||
|
state = S.END;
|
||||||
|
flags = 0;
|
||||||
|
} else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
|
||||||
|
index = 0;
|
||||||
|
callback('onPartBegin');
|
||||||
|
state = S.HEADER_FIELD_START;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c !== boundary[index + 2]) {
|
||||||
|
index = -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c === boundary[index + 2]) {
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case S.HEADER_FIELD_START:
|
||||||
|
state = S.HEADER_FIELD;
|
||||||
|
mark('onHeaderField');
|
||||||
|
index = 0;
|
||||||
|
// falls through
|
||||||
|
case S.HEADER_FIELD:
|
||||||
|
if (c === CR) {
|
||||||
|
clear('onHeaderField');
|
||||||
|
state = S.HEADERS_ALMOST_DONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
|
if (c === HYPHEN) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c === COLON) {
|
||||||
|
if (index === 1) {
|
||||||
|
// empty header field
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataCallback('onHeaderField', true);
|
||||||
|
state = S.HEADER_VALUE_START;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cl = lower(c);
|
||||||
|
if (cl < A || cl > Z) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case S.HEADER_VALUE_START:
|
||||||
|
if (c === SPACE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mark('onHeaderValue');
|
||||||
|
state = S.HEADER_VALUE;
|
||||||
|
// falls through
|
||||||
|
case S.HEADER_VALUE:
|
||||||
|
if (c === CR) {
|
||||||
|
dataCallback('onHeaderValue', true);
|
||||||
|
callback('onHeaderEnd');
|
||||||
|
state = S.HEADER_VALUE_ALMOST_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case S.HEADER_VALUE_ALMOST_DONE:
|
||||||
|
if (c !== LF) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
state = S.HEADER_FIELD_START;
|
||||||
|
break;
|
||||||
|
case S.HEADERS_ALMOST_DONE:
|
||||||
|
if (c !== LF) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback('onHeadersEnd');
|
||||||
|
state = S.PART_DATA_START;
|
||||||
|
break;
|
||||||
|
case S.PART_DATA_START:
|
||||||
|
state = S.PART_DATA;
|
||||||
|
mark('onPartData');
|
||||||
|
// falls through
|
||||||
|
case S.PART_DATA:
|
||||||
|
previousIndex = index;
|
||||||
|
|
||||||
|
if (index === 0) {
|
||||||
|
// boyer-moore derrived algorithm to safely skip non-boundary data
|
||||||
|
i += boundaryEnd;
|
||||||
|
while (i < bufferLength && !(data[i] in boundaryChars)) {
|
||||||
|
i += boundaryLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
i -= boundaryEnd;
|
||||||
|
c = data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index < boundary.length) {
|
||||||
|
if (boundary[index] === c) {
|
||||||
|
if (index === 0) {
|
||||||
|
dataCallback('onPartData', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
|
} else {
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
} else if (index === boundary.length) {
|
||||||
|
index++;
|
||||||
|
if (c === CR) {
|
||||||
|
// CR = part boundary
|
||||||
|
flags |= F.PART_BOUNDARY;
|
||||||
|
} else if (c === HYPHEN) {
|
||||||
|
// HYPHEN = end boundary
|
||||||
|
flags |= F.LAST_BOUNDARY;
|
||||||
|
} else {
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
} else if (index - 1 === boundary.length) {
|
||||||
|
if (flags & F.PART_BOUNDARY) {
|
||||||
|
index = 0;
|
||||||
|
if (c === LF) {
|
||||||
|
// unset the PART_BOUNDARY flag
|
||||||
|
flags &= ~F.PART_BOUNDARY;
|
||||||
|
callback('onPartEnd');
|
||||||
|
callback('onPartBegin');
|
||||||
|
state = S.HEADER_FIELD_START;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (flags & F.LAST_BOUNDARY) {
|
||||||
|
if (c === HYPHEN) {
|
||||||
|
callback('onPartEnd');
|
||||||
|
state = S.END;
|
||||||
|
flags = 0;
|
||||||
|
} else {
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index > 0) {
|
||||||
|
// when matching a possible boundary, keep a lookbehind reference
|
||||||
|
// in case it turns out to be a false lead
|
||||||
|
lookbehind[index - 1] = c;
|
||||||
|
} else if (previousIndex > 0) {
|
||||||
|
// if our boundary turned out to be rubbish, the captured lookbehind
|
||||||
|
// belongs to partData
|
||||||
|
const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
|
||||||
|
callback('onPartData', 0, previousIndex, _lookbehind);
|
||||||
|
previousIndex = 0;
|
||||||
|
mark('onPartData');
|
||||||
|
|
||||||
|
// reconsider the current character even so it interrupted the sequence
|
||||||
|
// it could be the beginning of a new sequence
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case S.END:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error(`Unexpected state entered: ${state}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dataCallback('onHeaderField');
|
||||||
|
dataCallback('onHeaderValue');
|
||||||
|
dataCallback('onPartData');
|
||||||
|
|
||||||
|
// Update properties for the next call
|
||||||
|
this.index = index;
|
||||||
|
this.state = state;
|
||||||
|
this.flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
end() {
|
||||||
|
if ((this.state === S.HEADER_FIELD_START && this.index === 0) ||
|
||||||
|
(this.state === S.PART_DATA && this.index === this.boundary.length)) {
|
||||||
|
this.onPartEnd();
|
||||||
|
} else if (this.state !== S.END) {
|
||||||
|
throw new Error('MultipartParser.end(): stream ended unexpectedly');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _fileName(headerValue) {
|
||||||
|
// matches either a quoted-string or a token (RFC 2616 section 19.5.1)
|
||||||
|
const m = headerValue.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
|
||||||
|
if (!m) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const match = m[2] || m[3] || '';
|
||||||
|
let filename = match.slice(match.lastIndexOf('\\') + 1);
|
||||||
|
filename = filename.replace(/%22/g, '"');
|
||||||
|
filename = filename.replace(/&#(\d{4});/g, (m, code) => {
|
||||||
|
return String.fromCharCode(code);
|
||||||
|
});
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function toFormData(Body, ct) {
|
||||||
|
if (!/multipart/i.test(ct)) {
|
||||||
|
throw new TypeError('Failed to fetch');
|
||||||
|
}
|
||||||
|
|
||||||
|
const m = ct.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
|
||||||
|
|
||||||
|
if (!m) {
|
||||||
|
throw new TypeError('no or bad content-type header, no multipart boundary');
|
||||||
|
}
|
||||||
|
|
||||||
|
const parser = new MultipartParser(m[1] || m[2]);
|
||||||
|
|
||||||
|
let headerField;
|
||||||
|
let headerValue;
|
||||||
|
let entryValue;
|
||||||
|
let entryName;
|
||||||
|
let contentType;
|
||||||
|
let filename;
|
||||||
|
const entryChunks = [];
|
||||||
|
const formData = new formdata_polyfill_esm_min_js__WEBPACK_IMPORTED_MODULE_1__/* .FormData */ .Ct();
|
||||||
|
|
||||||
|
const onPartData = ui8a => {
|
||||||
|
entryValue += decoder.decode(ui8a, {stream: true});
|
||||||
|
};
|
||||||
|
|
||||||
|
const appendToFile = ui8a => {
|
||||||
|
entryChunks.push(ui8a);
|
||||||
|
};
|
||||||
|
|
||||||
|
const appendFileToFormData = () => {
|
||||||
|
const file = new fetch_blob_from_js__WEBPACK_IMPORTED_MODULE_0__/* .File */ .$B(entryChunks, filename, {type: contentType});
|
||||||
|
formData.append(entryName, file);
|
||||||
|
};
|
||||||
|
|
||||||
|
const appendEntryToFormData = () => {
|
||||||
|
formData.append(entryName, entryValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
const decoder = new TextDecoder('utf-8');
|
||||||
|
decoder.decode();
|
||||||
|
|
||||||
|
parser.onPartBegin = function () {
|
||||||
|
parser.onPartData = onPartData;
|
||||||
|
parser.onPartEnd = appendEntryToFormData;
|
||||||
|
|
||||||
|
headerField = '';
|
||||||
|
headerValue = '';
|
||||||
|
entryValue = '';
|
||||||
|
entryName = '';
|
||||||
|
contentType = '';
|
||||||
|
filename = null;
|
||||||
|
entryChunks.length = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
parser.onHeaderField = function (ui8a) {
|
||||||
|
headerField += decoder.decode(ui8a, {stream: true});
|
||||||
|
};
|
||||||
|
|
||||||
|
parser.onHeaderValue = function (ui8a) {
|
||||||
|
headerValue += decoder.decode(ui8a, {stream: true});
|
||||||
|
};
|
||||||
|
|
||||||
|
parser.onHeaderEnd = function () {
|
||||||
|
headerValue += decoder.decode();
|
||||||
|
headerField = headerField.toLowerCase();
|
||||||
|
|
||||||
|
if (headerField === 'content-disposition') {
|
||||||
|
// matches either a quoted-string or a token (RFC 2616 section 19.5.1)
|
||||||
|
const m = headerValue.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
|
||||||
|
|
||||||
|
if (m) {
|
||||||
|
entryName = m[2] || m[3] || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
filename = _fileName(headerValue);
|
||||||
|
|
||||||
|
if (filename) {
|
||||||
|
parser.onPartData = appendToFile;
|
||||||
|
parser.onPartEnd = appendFileToFormData;
|
||||||
|
}
|
||||||
|
} else if (headerField === 'content-type') {
|
||||||
|
contentType = headerValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
headerValue = '';
|
||||||
|
headerField = '';
|
||||||
|
};
|
||||||
|
|
||||||
|
for await (const chunk of Body) {
|
||||||
|
parser.write(chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
parser.end();
|
||||||
|
|
||||||
|
return formData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***/ })
|
||||||
|
|
||||||
|
};
|
||||||
|
;
|
||||||
|
//# sourceMappingURL=37.index.js.map
|
||||||
1
dist/37.index.js.map
vendored
Normal file
1
dist/37.index.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
453
dist/629.index.js
vendored
Normal file
453
dist/629.index.js
vendored
Normal file
@@ -0,0 +1,453 @@
|
|||||||
|
exports.id = 629;
|
||||||
|
exports.ids = [629];
|
||||||
|
exports.modules = {
|
||||||
|
|
||||||
|
/***/ 6629:
|
||||||
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
__webpack_require__.r(__webpack_exports__);
|
||||||
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
|
/* harmony export */ "toFormData": () => (/* binding */ toFormData)
|
||||||
|
/* harmony export */ });
|
||||||
|
/* harmony import */ var fetch_blob_from_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4818);
|
||||||
|
/* harmony import */ var formdata_polyfill_esm_min_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1402);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let s = 0;
|
||||||
|
const S = {
|
||||||
|
START_BOUNDARY: s++,
|
||||||
|
HEADER_FIELD_START: s++,
|
||||||
|
HEADER_FIELD: s++,
|
||||||
|
HEADER_VALUE_START: s++,
|
||||||
|
HEADER_VALUE: s++,
|
||||||
|
HEADER_VALUE_ALMOST_DONE: s++,
|
||||||
|
HEADERS_ALMOST_DONE: s++,
|
||||||
|
PART_DATA_START: s++,
|
||||||
|
PART_DATA: s++,
|
||||||
|
END: s++
|
||||||
|
};
|
||||||
|
|
||||||
|
let f = 1;
|
||||||
|
const F = {
|
||||||
|
PART_BOUNDARY: f,
|
||||||
|
LAST_BOUNDARY: f *= 2
|
||||||
|
};
|
||||||
|
|
||||||
|
const LF = 10;
|
||||||
|
const CR = 13;
|
||||||
|
const SPACE = 32;
|
||||||
|
const HYPHEN = 45;
|
||||||
|
const COLON = 58;
|
||||||
|
const A = 97;
|
||||||
|
const Z = 122;
|
||||||
|
|
||||||
|
const lower = c => c | 0x20;
|
||||||
|
|
||||||
|
const noop = () => {};
|
||||||
|
|
||||||
|
class MultipartParser {
|
||||||
|
/**
|
||||||
|
* @param {string} boundary
|
||||||
|
*/
|
||||||
|
constructor(boundary) {
|
||||||
|
this.index = 0;
|
||||||
|
this.flags = 0;
|
||||||
|
|
||||||
|
this.onHeaderEnd = noop;
|
||||||
|
this.onHeaderField = noop;
|
||||||
|
this.onHeadersEnd = noop;
|
||||||
|
this.onHeaderValue = noop;
|
||||||
|
this.onPartBegin = noop;
|
||||||
|
this.onPartData = noop;
|
||||||
|
this.onPartEnd = noop;
|
||||||
|
|
||||||
|
this.boundaryChars = {};
|
||||||
|
|
||||||
|
boundary = '\r\n--' + boundary;
|
||||||
|
const ui8a = new Uint8Array(boundary.length);
|
||||||
|
for (let i = 0; i < boundary.length; i++) {
|
||||||
|
ui8a[i] = boundary.charCodeAt(i);
|
||||||
|
this.boundaryChars[ui8a[i]] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.boundary = ui8a;
|
||||||
|
this.lookbehind = new Uint8Array(this.boundary.length + 8);
|
||||||
|
this.state = S.START_BOUNDARY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Uint8Array} data
|
||||||
|
*/
|
||||||
|
write(data) {
|
||||||
|
let i = 0;
|
||||||
|
const length_ = data.length;
|
||||||
|
let previousIndex = this.index;
|
||||||
|
let {lookbehind, boundary, boundaryChars, index, state, flags} = this;
|
||||||
|
const boundaryLength = this.boundary.length;
|
||||||
|
const boundaryEnd = boundaryLength - 1;
|
||||||
|
const bufferLength = data.length;
|
||||||
|
let c;
|
||||||
|
let cl;
|
||||||
|
|
||||||
|
const mark = name => {
|
||||||
|
this[name + 'Mark'] = i;
|
||||||
|
};
|
||||||
|
|
||||||
|
const clear = name => {
|
||||||
|
delete this[name + 'Mark'];
|
||||||
|
};
|
||||||
|
|
||||||
|
const callback = (callbackSymbol, start, end, ui8a) => {
|
||||||
|
if (start === undefined || start !== end) {
|
||||||
|
this[callbackSymbol](ui8a && ui8a.subarray(start, end));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const dataCallback = (name, clear) => {
|
||||||
|
const markSymbol = name + 'Mark';
|
||||||
|
if (!(markSymbol in this)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clear) {
|
||||||
|
callback(name, this[markSymbol], i, data);
|
||||||
|
delete this[markSymbol];
|
||||||
|
} else {
|
||||||
|
callback(name, this[markSymbol], data.length, data);
|
||||||
|
this[markSymbol] = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (i = 0; i < length_; i++) {
|
||||||
|
c = data[i];
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case S.START_BOUNDARY:
|
||||||
|
if (index === boundary.length - 2) {
|
||||||
|
if (c === HYPHEN) {
|
||||||
|
flags |= F.LAST_BOUNDARY;
|
||||||
|
} else if (c !== CR) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
|
break;
|
||||||
|
} else if (index - 1 === boundary.length - 2) {
|
||||||
|
if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
|
||||||
|
state = S.END;
|
||||||
|
flags = 0;
|
||||||
|
} else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
|
||||||
|
index = 0;
|
||||||
|
callback('onPartBegin');
|
||||||
|
state = S.HEADER_FIELD_START;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c !== boundary[index + 2]) {
|
||||||
|
index = -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c === boundary[index + 2]) {
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case S.HEADER_FIELD_START:
|
||||||
|
state = S.HEADER_FIELD;
|
||||||
|
mark('onHeaderField');
|
||||||
|
index = 0;
|
||||||
|
// falls through
|
||||||
|
case S.HEADER_FIELD:
|
||||||
|
if (c === CR) {
|
||||||
|
clear('onHeaderField');
|
||||||
|
state = S.HEADERS_ALMOST_DONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
|
if (c === HYPHEN) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c === COLON) {
|
||||||
|
if (index === 1) {
|
||||||
|
// empty header field
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataCallback('onHeaderField', true);
|
||||||
|
state = S.HEADER_VALUE_START;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cl = lower(c);
|
||||||
|
if (cl < A || cl > Z) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case S.HEADER_VALUE_START:
|
||||||
|
if (c === SPACE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mark('onHeaderValue');
|
||||||
|
state = S.HEADER_VALUE;
|
||||||
|
// falls through
|
||||||
|
case S.HEADER_VALUE:
|
||||||
|
if (c === CR) {
|
||||||
|
dataCallback('onHeaderValue', true);
|
||||||
|
callback('onHeaderEnd');
|
||||||
|
state = S.HEADER_VALUE_ALMOST_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case S.HEADER_VALUE_ALMOST_DONE:
|
||||||
|
if (c !== LF) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
state = S.HEADER_FIELD_START;
|
||||||
|
break;
|
||||||
|
case S.HEADERS_ALMOST_DONE:
|
||||||
|
if (c !== LF) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback('onHeadersEnd');
|
||||||
|
state = S.PART_DATA_START;
|
||||||
|
break;
|
||||||
|
case S.PART_DATA_START:
|
||||||
|
state = S.PART_DATA;
|
||||||
|
mark('onPartData');
|
||||||
|
// falls through
|
||||||
|
case S.PART_DATA:
|
||||||
|
previousIndex = index;
|
||||||
|
|
||||||
|
if (index === 0) {
|
||||||
|
// boyer-moore derrived algorithm to safely skip non-boundary data
|
||||||
|
i += boundaryEnd;
|
||||||
|
while (i < bufferLength && !(data[i] in boundaryChars)) {
|
||||||
|
i += boundaryLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
i -= boundaryEnd;
|
||||||
|
c = data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index < boundary.length) {
|
||||||
|
if (boundary[index] === c) {
|
||||||
|
if (index === 0) {
|
||||||
|
dataCallback('onPartData', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
|
} else {
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
} else if (index === boundary.length) {
|
||||||
|
index++;
|
||||||
|
if (c === CR) {
|
||||||
|
// CR = part boundary
|
||||||
|
flags |= F.PART_BOUNDARY;
|
||||||
|
} else if (c === HYPHEN) {
|
||||||
|
// HYPHEN = end boundary
|
||||||
|
flags |= F.LAST_BOUNDARY;
|
||||||
|
} else {
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
} else if (index - 1 === boundary.length) {
|
||||||
|
if (flags & F.PART_BOUNDARY) {
|
||||||
|
index = 0;
|
||||||
|
if (c === LF) {
|
||||||
|
// unset the PART_BOUNDARY flag
|
||||||
|
flags &= ~F.PART_BOUNDARY;
|
||||||
|
callback('onPartEnd');
|
||||||
|
callback('onPartBegin');
|
||||||
|
state = S.HEADER_FIELD_START;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (flags & F.LAST_BOUNDARY) {
|
||||||
|
if (c === HYPHEN) {
|
||||||
|
callback('onPartEnd');
|
||||||
|
state = S.END;
|
||||||
|
flags = 0;
|
||||||
|
} else {
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index > 0) {
|
||||||
|
// when matching a possible boundary, keep a lookbehind reference
|
||||||
|
// in case it turns out to be a false lead
|
||||||
|
lookbehind[index - 1] = c;
|
||||||
|
} else if (previousIndex > 0) {
|
||||||
|
// if our boundary turned out to be rubbish, the captured lookbehind
|
||||||
|
// belongs to partData
|
||||||
|
const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
|
||||||
|
callback('onPartData', 0, previousIndex, _lookbehind);
|
||||||
|
previousIndex = 0;
|
||||||
|
mark('onPartData');
|
||||||
|
|
||||||
|
// reconsider the current character even so it interrupted the sequence
|
||||||
|
// it could be the beginning of a new sequence
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case S.END:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error(`Unexpected state entered: ${state}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dataCallback('onHeaderField');
|
||||||
|
dataCallback('onHeaderValue');
|
||||||
|
dataCallback('onPartData');
|
||||||
|
|
||||||
|
// Update properties for the next call
|
||||||
|
this.index = index;
|
||||||
|
this.state = state;
|
||||||
|
this.flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
end() {
|
||||||
|
if ((this.state === S.HEADER_FIELD_START && this.index === 0) ||
|
||||||
|
(this.state === S.PART_DATA && this.index === this.boundary.length)) {
|
||||||
|
this.onPartEnd();
|
||||||
|
} else if (this.state !== S.END) {
|
||||||
|
throw new Error('MultipartParser.end(): stream ended unexpectedly');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _fileName(headerValue) {
|
||||||
|
// matches either a quoted-string or a token (RFC 2616 section 19.5.1)
|
||||||
|
const m = headerValue.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
|
||||||
|
if (!m) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const match = m[2] || m[3] || '';
|
||||||
|
let filename = match.slice(match.lastIndexOf('\\') + 1);
|
||||||
|
filename = filename.replace(/%22/g, '"');
|
||||||
|
filename = filename.replace(/&#(\d{4});/g, (m, code) => {
|
||||||
|
return String.fromCharCode(code);
|
||||||
|
});
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function toFormData(Body, ct) {
|
||||||
|
if (!/multipart/i.test(ct)) {
|
||||||
|
throw new TypeError('Failed to fetch');
|
||||||
|
}
|
||||||
|
|
||||||
|
const m = ct.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
|
||||||
|
|
||||||
|
if (!m) {
|
||||||
|
throw new TypeError('no or bad content-type header, no multipart boundary');
|
||||||
|
}
|
||||||
|
|
||||||
|
const parser = new MultipartParser(m[1] || m[2]);
|
||||||
|
|
||||||
|
let headerField;
|
||||||
|
let headerValue;
|
||||||
|
let entryValue;
|
||||||
|
let entryName;
|
||||||
|
let contentType;
|
||||||
|
let filename;
|
||||||
|
const entryChunks = [];
|
||||||
|
const formData = new formdata_polyfill_esm_min_js__WEBPACK_IMPORTED_MODULE_1__/* .FormData */ .Ct();
|
||||||
|
|
||||||
|
const onPartData = ui8a => {
|
||||||
|
entryValue += decoder.decode(ui8a, {stream: true});
|
||||||
|
};
|
||||||
|
|
||||||
|
const appendToFile = ui8a => {
|
||||||
|
entryChunks.push(ui8a);
|
||||||
|
};
|
||||||
|
|
||||||
|
const appendFileToFormData = () => {
|
||||||
|
const file = new fetch_blob_from_js__WEBPACK_IMPORTED_MODULE_0__/* .File */ .$B(entryChunks, filename, {type: contentType});
|
||||||
|
formData.append(entryName, file);
|
||||||
|
};
|
||||||
|
|
||||||
|
const appendEntryToFormData = () => {
|
||||||
|
formData.append(entryName, entryValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
const decoder = new TextDecoder('utf-8');
|
||||||
|
decoder.decode();
|
||||||
|
|
||||||
|
parser.onPartBegin = function () {
|
||||||
|
parser.onPartData = onPartData;
|
||||||
|
parser.onPartEnd = appendEntryToFormData;
|
||||||
|
|
||||||
|
headerField = '';
|
||||||
|
headerValue = '';
|
||||||
|
entryValue = '';
|
||||||
|
entryName = '';
|
||||||
|
contentType = '';
|
||||||
|
filename = null;
|
||||||
|
entryChunks.length = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
parser.onHeaderField = function (ui8a) {
|
||||||
|
headerField += decoder.decode(ui8a, {stream: true});
|
||||||
|
};
|
||||||
|
|
||||||
|
parser.onHeaderValue = function (ui8a) {
|
||||||
|
headerValue += decoder.decode(ui8a, {stream: true});
|
||||||
|
};
|
||||||
|
|
||||||
|
parser.onHeaderEnd = function () {
|
||||||
|
headerValue += decoder.decode();
|
||||||
|
headerField = headerField.toLowerCase();
|
||||||
|
|
||||||
|
if (headerField === 'content-disposition') {
|
||||||
|
// matches either a quoted-string or a token (RFC 2616 section 19.5.1)
|
||||||
|
const m = headerValue.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
|
||||||
|
|
||||||
|
if (m) {
|
||||||
|
entryName = m[2] || m[3] || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
filename = _fileName(headerValue);
|
||||||
|
|
||||||
|
if (filename) {
|
||||||
|
parser.onPartData = appendToFile;
|
||||||
|
parser.onPartEnd = appendFileToFormData;
|
||||||
|
}
|
||||||
|
} else if (headerField === 'content-type') {
|
||||||
|
contentType = headerValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
headerValue = '';
|
||||||
|
headerField = '';
|
||||||
|
};
|
||||||
|
|
||||||
|
for await (const chunk of Body) {
|
||||||
|
parser.write(chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
parser.end();
|
||||||
|
|
||||||
|
return formData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***/ })
|
||||||
|
|
||||||
|
};
|
||||||
|
;
|
||||||
|
//# sourceMappingURL=629.index.js.map
|
||||||
1
dist/629.index.js.map
vendored
Normal file
1
dist/629.index.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
14038
dist/index.js
vendored
14038
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/sourcemap-register.js
vendored
2
dist/sourcemap-register.js
vendored
File diff suppressed because one or more lines are too long
11257
package-lock.json
generated
11257
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
30
package.json
30
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codecov-action",
|
"name": "codecov-action",
|
||||||
"version": "2.0.2",
|
"version": "3.0.0",
|
||||||
"description": "Upload coverage reports to Codecov from GitHub Actions",
|
"description": "Upload coverage reports to Codecov from GitHub Actions",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -16,30 +16,30 @@
|
|||||||
"url": "git+https://github.com/codecov/codecov-action.git"
|
"url": "git+https://github.com/codecov/codecov-action.git"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Ibrahim Ali",
|
"author": "Codecov",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/codecov/codecov-action/issues"
|
"url": "https://github.com/codecov/codecov-action/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/codecov/codecov-action#readme",
|
"homepage": "https://github.com/codecov/codecov-action#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.4.0",
|
"@actions/core": "^1.6.0",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/github": "^5.0.0",
|
"@actions/github": "^5.0.1",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^3.2.3",
|
||||||
"openpgp": "^5.0.0-4"
|
"openpgp": "^5.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.24",
|
"@types/jest": "^27.4.1",
|
||||||
"@types/node": "^16.4.0",
|
"@types/node": "^17.0.23",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.28.4",
|
"@typescript-eslint/eslint-plugin": "^4.29.2",
|
||||||
"@typescript-eslint/parser": "^4.28.4",
|
"@typescript-eslint/parser": "^4.29.2",
|
||||||
"@vercel/ncc": "^0.29.0",
|
"@vercel/ncc": "^0.33.3",
|
||||||
"eslint": "^7.31.0",
|
"eslint": "^7.32.0",
|
||||||
"eslint-config-google": "^0.14.0",
|
"eslint-config-google": "^0.14.0",
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"jest-junit": "^12.2.0",
|
"jest-junit": "^13.0.0",
|
||||||
"ts-jest": "^26.5.6",
|
"ts-jest": "^26.5.6",
|
||||||
"typescript": "^4.3.5"
|
"typescript": "^4.6.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ test('all arguments', () => {
|
|||||||
'flags': 'test,test2',
|
'flags': 'test,test2',
|
||||||
'functionalities':
|
'functionalities':
|
||||||
'network',
|
'network',
|
||||||
|
'gcov': 'true',
|
||||||
|
'gcov_args': '-v',
|
||||||
|
'gcov_ignore': '*.fake',
|
||||||
|
'gcov_include': 'real_file',
|
||||||
'move_coverage_to_trash': 'true',
|
'move_coverage_to_trash': 'true',
|
||||||
'name': 'codecov',
|
'name': 'codecov',
|
||||||
'override_branch': 'thomasrockhu/test',
|
'override_branch': 'thomasrockhu/test',
|
||||||
@@ -80,6 +84,13 @@ test('all arguments', () => {
|
|||||||
'test',
|
'test',
|
||||||
'-F',
|
'-F',
|
||||||
'test2',
|
'test2',
|
||||||
|
'-g',
|
||||||
|
'--gcovArgs',
|
||||||
|
'-v',
|
||||||
|
'--gcovIgnore',
|
||||||
|
'*.fake',
|
||||||
|
'--gcovInclude',
|
||||||
|
'real_file',
|
||||||
'-B',
|
'-B',
|
||||||
'thomasrockhu/test',
|
'thomasrockhu/test',
|
||||||
'-b',
|
'-b',
|
||||||
|
|||||||
@@ -25,8 +25,13 @@ const buildExec = () => {
|
|||||||
const file = core.getInput('file');
|
const file = core.getInput('file');
|
||||||
const files = core.getInput('files');
|
const files = core.getInput('files');
|
||||||
const flags = core.getInput('flags');
|
const flags = core.getInput('flags');
|
||||||
|
const gcov = core.getInput('gcov');
|
||||||
|
const gcovArgs = core.getInput('gcov_args');
|
||||||
|
const gcovIgnore = core.getInput('gcov_ignore');
|
||||||
|
const gcovInclude = core.getInput('gcov_include');
|
||||||
const functionalities = core.getInput('functionalities');
|
const functionalities = core.getInput('functionalities');
|
||||||
const name = core.getInput('name');
|
const name = core.getInput('name');
|
||||||
|
const os = core.getInput('os');
|
||||||
const overrideBranch = core.getInput('override_branch');
|
const overrideBranch = core.getInput('override_branch');
|
||||||
const overrideBuild = core.getInput('override_build');
|
const overrideBuild = core.getInput('override_build');
|
||||||
const overrideCommit = core.getInput('override_commit');
|
const overrideCommit = core.getInput('override_commit');
|
||||||
@@ -36,8 +41,9 @@ const buildExec = () => {
|
|||||||
const searchDir = core.getInput('directory');
|
const searchDir = core.getInput('directory');
|
||||||
const slug = core.getInput('slug');
|
const slug = core.getInput('slug');
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
const verbose = isTrue(core.getInput('verbose'));
|
let uploaderVersion = core.getInput('version');
|
||||||
const url = core.getInput('url');
|
const url = core.getInput('url');
|
||||||
|
const verbose = isTrue(core.getInput('verbose'));
|
||||||
const workingDir = core.getInput('working-directory');
|
const workingDir = core.getInput('working-directory');
|
||||||
|
|
||||||
const execArgs = [];
|
const execArgs = [];
|
||||||
@@ -103,6 +109,20 @@ const buildExec = () => {
|
|||||||
execArgs.push('-F', `${f}`);
|
execArgs.push('-F', `${f}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gcov) {
|
||||||
|
execArgs.push('-g');
|
||||||
|
}
|
||||||
|
if (gcovArgs) {
|
||||||
|
execArgs.push('--gcovArgs', `${gcovArgs}`);
|
||||||
|
}
|
||||||
|
if (gcovIgnore) {
|
||||||
|
execArgs.push('--gcovIgnore', `${gcovIgnore}`);
|
||||||
|
}
|
||||||
|
if (gcovInclude) {
|
||||||
|
execArgs.push('--gcovInclude', `${gcovInclude}`);
|
||||||
|
}
|
||||||
|
|
||||||
if (overrideBranch) {
|
if (overrideBranch) {
|
||||||
execArgs.push('-B', `${overrideBranch}`);
|
execArgs.push('-B', `${overrideBranch}`);
|
||||||
}
|
}
|
||||||
@@ -146,7 +166,11 @@ const buildExec = () => {
|
|||||||
options.cwd = workingDir;
|
options.cwd = workingDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {execArgs, options, failCi};
|
if (uploaderVersion == '') {
|
||||||
|
uploaderVersion = 'latest';
|
||||||
|
}
|
||||||
|
|
||||||
|
return {execArgs, options, failCi, os, uploaderVersion};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default buildExec;
|
export default buildExec;
|
||||||
|
|||||||
70
src/helpers.test.ts
Normal file
70
src/helpers.test.ts
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import {
|
||||||
|
getBaseUrl,
|
||||||
|
getPlatform,
|
||||||
|
isValidPlatform,
|
||||||
|
isWindows,
|
||||||
|
PLATFORMS,
|
||||||
|
} from './helpers';
|
||||||
|
|
||||||
|
let OLDOS = process.env.RUNNER_OS;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
OLDOS = process.env.RUNNER_OS;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
process.env.RUNNER_OS = OLDOS;
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getPlatform', () => {
|
||||||
|
expect(getPlatform('linux')).toBe('linux');
|
||||||
|
expect(getPlatform('windows')).toBe('windows');
|
||||||
|
|
||||||
|
const defaultPlatform =
|
||||||
|
process.env.RUNNER_OS ? process.env.RUNNER_OS.toLowerCase() : 'linux';
|
||||||
|
expect(getPlatform('fakeos')).toBe(defaultPlatform);
|
||||||
|
expect(getPlatform()).toBe(defaultPlatform);
|
||||||
|
|
||||||
|
process.env.RUNNER_OS = 'macos';
|
||||||
|
expect(getPlatform('fakeos')).toBe('macos');
|
||||||
|
expect(getPlatform()).toBe('macos');
|
||||||
|
|
||||||
|
process.env.RUNNER_OS = 'alsofakeos';
|
||||||
|
expect(getPlatform()).toBe('linux');
|
||||||
|
expect(getPlatform('fakeos')).toBe('linux');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getBaseUrl', () => {
|
||||||
|
expect(PLATFORMS.map((platform) => {
|
||||||
|
return getBaseUrl(platform, 'latest');
|
||||||
|
})).toEqual([
|
||||||
|
'https://uploader.codecov.io/latest/alpine/codecov',
|
||||||
|
'https://uploader.codecov.io/latest/linux/codecov',
|
||||||
|
'https://uploader.codecov.io/latest/macos/codecov',
|
||||||
|
'https://uploader.codecov.io/latest/windows/codecov.exe',
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect(PLATFORMS.map((platform) => {
|
||||||
|
return getBaseUrl(platform, 'v0.1.0_8880');
|
||||||
|
})).toEqual([
|
||||||
|
'https://uploader.codecov.io/v0.1.0_8880/alpine/codecov',
|
||||||
|
'https://uploader.codecov.io/v0.1.0_8880/linux/codecov',
|
||||||
|
'https://uploader.codecov.io/v0.1.0_8880/macos/codecov',
|
||||||
|
'https://uploader.codecov.io/v0.1.0_8880/windows/codecov.exe',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('isWindows', () => {
|
||||||
|
expect(PLATFORMS.map((platform) => {
|
||||||
|
return isWindows(platform);
|
||||||
|
})).toEqual([false, false, false, true]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('isValidPlatform', () => {
|
||||||
|
expect(PLATFORMS.map((platform) => {
|
||||||
|
return isValidPlatform(platform);
|
||||||
|
})).toEqual([true, true, true, true]);
|
||||||
|
|
||||||
|
expect(isValidPlatform('fakeos')).toBeFalsy();
|
||||||
|
});
|
||||||
@@ -9,30 +9,47 @@ const setFailure = (message: string, failCi: boolean): void => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUploaderName = (): string => {
|
const getUploaderName = (platform: string): string => {
|
||||||
if (isWindows()) {
|
if (isWindows(platform)) {
|
||||||
return 'codecov.exe';
|
return 'codecov.exe';
|
||||||
} else {
|
} else {
|
||||||
return 'codecov';
|
return 'codecov';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const isValidPlatform = (): boolean => {
|
const isValidPlatform = (platform: string): boolean => {
|
||||||
return PLATFORMS.includes(getPlatform());
|
return PLATFORMS.includes(platform);
|
||||||
};
|
};
|
||||||
|
|
||||||
const isWindows = (): boolean => {
|
const isWindows = (platform: string): boolean => {
|
||||||
return getPlatform() === 'windows';
|
return platform === 'windows';
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPlatform = (): string => {
|
const getPlatform = (os?: string): string => {
|
||||||
return process.env.RUNNER_OS.toLowerCase();
|
if (isValidPlatform(os)) {
|
||||||
|
core.info(`==> ${os} OS provided`);
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
const platform = process.env.RUNNER_OS?.toLowerCase();
|
||||||
|
if (isValidPlatform(platform)) {
|
||||||
|
core.info(`==> ${platform} OS detected`);
|
||||||
|
return platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
core.info(
|
||||||
|
'==> Could not detect OS or provided OS is invalid. Defaulting to linux',
|
||||||
|
);
|
||||||
|
return 'linux';
|
||||||
};
|
};
|
||||||
|
|
||||||
const BASEURL = `https://uploader.codecov.io/latest/${getPlatform()}/${getUploaderName()}`;
|
const getBaseUrl = (platform: string, version: string): string => {
|
||||||
|
return `https://uploader.codecov.io/${version}/${platform}/${getUploaderName(platform)}`;
|
||||||
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
BASEURL,
|
PLATFORMS,
|
||||||
|
getBaseUrl,
|
||||||
getPlatform,
|
getPlatform,
|
||||||
getUploaderName,
|
getUploaderName,
|
||||||
isValidPlatform,
|
isValidPlatform,
|
||||||
|
|||||||
22
src/index.ts
22
src/index.ts
@@ -6,28 +6,23 @@ import * as exec from '@actions/exec';
|
|||||||
|
|
||||||
import buildExec from './buildExec';
|
import buildExec from './buildExec';
|
||||||
import {
|
import {
|
||||||
BASEURL,
|
getBaseUrl,
|
||||||
getPlatform,
|
getPlatform,
|
||||||
getUploaderName,
|
getUploaderName,
|
||||||
isValidPlatform,
|
|
||||||
setFailure,
|
setFailure,
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
|
|
||||||
import verify from './validate';
|
import verify from './validate';
|
||||||
|
import versionInfo from './version';
|
||||||
|
|
||||||
let failCi;
|
let failCi;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const {execArgs, options, failCi} = buildExec();
|
const {execArgs, options, failCi, os, uploaderVersion} = buildExec();
|
||||||
const platform = getPlatform();
|
const platform = getPlatform(os);
|
||||||
if (!isValidPlatform()) {
|
|
||||||
setFailure(
|
const filename = path.join( __dirname, getUploaderName(platform));
|
||||||
`Codecov: Encountered an unexpected platform: ${platform}`,
|
https.get(getBaseUrl(platform, uploaderVersion), (res) => {
|
||||||
failCi,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const filename = path.join( __dirname, getUploaderName());
|
|
||||||
https.get(BASEURL, (res) => {
|
|
||||||
// Image will be stored at this path
|
// Image will be stored at this path
|
||||||
const filePath = fs.createWriteStream(filename);
|
const filePath = fs.createWriteStream(filename);
|
||||||
res.pipe(filePath);
|
res.pipe(filePath);
|
||||||
@@ -40,7 +35,8 @@ try {
|
|||||||
}).on('finish', async () => {
|
}).on('finish', async () => {
|
||||||
filePath.close();
|
filePath.close();
|
||||||
|
|
||||||
await verify(filename);
|
await verify(filename, platform, uploaderVersion);
|
||||||
|
await versionInfo(platform, uploaderVersion);
|
||||||
await fs.chmodSync(filename, '777');
|
await fs.chmodSync(filename, '777');
|
||||||
|
|
||||||
const unlink = () => {
|
const unlink = () => {
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ import * as openpgp from 'openpgp';
|
|||||||
import * as fetch from 'node-fetch';
|
import * as fetch from 'node-fetch';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BASEURL,
|
getBaseUrl,
|
||||||
getUploaderName,
|
getUploaderName,
|
||||||
setFailure,
|
setFailure,
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
|
|
||||||
const verify = async (filename: string) => {
|
const verify = async (filename: string, platform: string, version: string) => {
|
||||||
try {
|
try {
|
||||||
const uploaderName = getUploaderName();
|
const uploaderName = getUploaderName(platform);
|
||||||
|
|
||||||
// Read in public key
|
// Read in public key
|
||||||
const publicKeyArmored = await fs.readFileSync(
|
const publicKeyArmored = await fs.readFileSync(
|
||||||
@@ -23,10 +23,15 @@ const verify = async (filename: string) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Get SHASUM and SHASUM signature files
|
// Get SHASUM and SHASUM signature files
|
||||||
const shasumRes = await fetch( `${BASEURL}.SHA256SUM`);
|
console.log(`${getBaseUrl(platform, version)}.SHA256SUM`);
|
||||||
|
const shasumRes = await fetch.default(
|
||||||
|
`${getBaseUrl(platform, version)}.SHA256SUM`,
|
||||||
|
);
|
||||||
const shasum = await shasumRes.text();
|
const shasum = await shasumRes.text();
|
||||||
|
|
||||||
const shaSigRes = await fetch( `${BASEURL}.SHA256SUM.sig`);
|
const shaSigRes = await fetch.default(
|
||||||
|
`${getBaseUrl(platform, version)}.SHA256SUM.sig`,
|
||||||
|
);
|
||||||
const shaSig = await shaSigRes.text();
|
const shaSig = await shaSigRes.text();
|
||||||
|
|
||||||
// Verify shasum
|
// Verify shasum
|
||||||
|
|||||||
19
src/version.ts
Normal file
19
src/version.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as fetch from 'node-fetch';
|
||||||
|
|
||||||
|
const versionInfo = async (platform: string, version?: string) => {
|
||||||
|
if (version) {
|
||||||
|
core.info(`==> Running version ${version}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const metadataRes = await fetch.default( `https://uploader.codecov.io/${platform}/latest`, {
|
||||||
|
headers: {'Accept': 'application/json'},
|
||||||
|
});
|
||||||
|
const metadata = await metadataRes.json();
|
||||||
|
core.info(`==> Running version ${metadata['version']}`);
|
||||||
|
} catch (err) {
|
||||||
|
core.info(`Could not pull latest version information: ${err}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export default versionInfo;
|
||||||
Reference in New Issue
Block a user