Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Create a new pull request by comparing changes across two branches #216

Merged
merged 11 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
with:
run: node ./bin/pr.js
- name: Create pull request
uses: peter-evans/create-pull-request@v4
uses: peter-evans/create-pull-request@v6
id: cpr
with:
branch: release
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ jobs:
id: tag_version
with:
tag: "v${{ steps.package-version.outputs.current-version }}"
############# RESOLVE NPM TAG ##############
- name: NPM TAG
id: 'npm_tag'
run: node ./bin/resolveNPMTag.js
############# GITHUB RELEASE ##############
- name: "Create a GitHub release v${{ steps.package-version.outputs.current-version }}"
uses: ncipollo/release-action@v1
Expand All @@ -53,7 +57,7 @@ jobs:
${{ steps.extract-release-notes.outputs.release_notes }}
############# NPM RELEASE ##############
- name: Publish the release to NPM
run: npm publish --provenance --access public
run: npm publish --provenance --access public --tag ${{ steps.npm_tag.outputs.tag || 'latest' }}
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
notify:
Expand Down
1,689 changes: 865 additions & 824 deletions CHANGELOG.md

Large diffs are not rendered by default.

31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
- [🆕 Progress capturing](#-progress-capturing)
- [🆕 Rate limiting](#-progress-capturing)
- [🆕 AxiosHeaders](#-axiosheaders)
- [🔥 Fetch adapter](#-fetch-adapter)
- [Semver](#semver)
- [Promises](#promises)
- [TypeScript](#typescript)
Expand Down Expand Up @@ -481,10 +482,13 @@ These are the available config options for making requests. Only the `url` is re
withCredentials: false, // default

// `adapter` allows custom handling of requests which makes testing easier.
// Return a promise and supply a valid response (see lib/adapters/README.md).
// Return a promise and supply a valid response (see lib/adapters/README.md)
adapter: function (config) {
/* ... */
},
// Also, you can set the name of the built-in adapter, or provide an array with their names
// to choose the first available in the environment
adapter: 'xhr' // 'fetch' | 'http' | ['xhr', 'http', 'fetch']

// `auth` indicates that HTTP Basic auth should be used, and supplies credentials.
// This will set an `Authorization` header, overwriting any existing
Expand Down Expand Up @@ -1289,6 +1293,7 @@ Sending `Blobs`/`Files` as JSON (`base64`) is not currently supported.
## 🆕 Progress capturing

Axios supports both browser and node environments to capture request upload/download progress.
The frequency of progress events is forced to be limited to `3` times per second.

```js
await axios.post(url, data, {
Expand Down Expand Up @@ -1609,6 +1614,30 @@ The following shortcuts are available:

- `setContentEncoding`, `getContentEncoding`, `hasContentEncoding`

## 🔥 Fetch adapter

Fetch adapter was introduced in `v1.7.0`. By default, it will be used if `xhr` and `http` adapters are not available in the build,
or not supported by the environment.
To use it by default, it must be selected explicitly:

```js
const {data} = axios.get(url, {
adapter: 'fetch' // by default ['xhr', 'http', 'fetch']
})
```

You can create a separate instance for this:

```js
const fetchAxios = axios.create({
adapter: 'fetch'
});

const {data} = fetchAxios.get(url);
```

The adapter supports the same functionality as `xhr` adapter, **including upload and download progress capturing**.
Also, it supports additional response types such as `stream` and `formdata` (if supported by the environment).

## Semver

Expand Down
35 changes: 1 addition & 34 deletions bin/pr.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,8 @@
import util from "util";
import cp from "child_process";
import Handlebars from "handlebars";
import fs from "fs/promises";
import prettyBytes from 'pretty-bytes';
import {gzipSize} from 'gzip-size';

const exec = util.promisify(cp.exec);

const getBlobHistory = async (filepath, maxCount= 5) => {
const log = (await exec(
`git log --max-count=${maxCount} --no-walk --tags=v* --oneline --format=%H%d -- ${filepath}`
)).stdout;

const commits = [];

let match;

const regexp = /^(\w+) \(tag: (v?[.\d]+)\)$/gm;

while((match = regexp.exec(log))) {
commits.push({
sha: match[1],
tag: match[2],
size: await getBlobSize(filepath, match[1])
})
}

return commits;
}

const getBlobSize = async (filepath, sha ='HEAD') => {
const size = (await exec(
`git cat-file -s ${sha}:${filepath}`
)).stdout;

return size ? +size : 0;
}
import {getBlobHistory} from './repo.js';

const generateFileReport = async (files) => {
const stat = {};
Expand Down
42 changes: 42 additions & 0 deletions bin/repo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import util from "util";
import cp from "child_process";

export const exec = util.promisify(cp.exec);

export const getBlobSize = async (filepath, sha ='HEAD') => {
const size = (await exec(
`git cat-file -s ${sha}:${filepath}`
)).stdout;

return size ? +size : 0;
}

export const getBlobHistory = async (filepath, maxCount= 5) => {
const log = (await exec(
`git log --max-count=${maxCount} --no-walk --tags=v* --oneline --format=%H%d -- ${filepath}`
)).stdout;

const commits = [];

let match;

const regexp = /^(\w+) \(tag: (v?[.\d]+)\)$/gm;

while((match = regexp.exec(log))) {
commits.push({
sha: match[1],
tag: match[2],
size: await getBlobSize(filepath, match[1])
})
}

return commits;
}

export const getTags = async (pattern = 'v*', sort = '-v:refname') => {
const log = (await exec(
`git tag -l ${pattern} --sort=${sort}`
)).stdout;

return log.split(/\r?\n/);
}
18 changes: 18 additions & 0 deletions bin/resolveNPMTag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {exec, getTags} from "./repo.js";
import fs from "fs";
import {colorize} from "./helpers/colorize.js";

const {version} = JSON.parse(fs.readFileSync('./package.json'));

const [major] = version.split('.');
const tags = await getTags();
const latestTag = (tags[0] || '').replace(/^v/, '');

const isBeta = !/^v?(\d+).(\d)+.(\d)+$/.test(version);
const isLatest = latestTag === version;

let tag = isBeta ? 'next' : isLatest ? 'latest' : `v${major}`;

console.log(colorize()`Version [${version}] [${isBeta ? 'prerelease' : 'release'}] latest [${latestTag}]=> NPM Tag [${tag}]`);

await exec(`echo "tag=${tag}" >> $GITHUB_OUTPUT`);
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "axios",
"main": "./dist/axios.js",
"version": "1.7.0-beta.1",
"version": "1.7.1",
"homepage": "https://axios-http.com",
"authors": [
"Matt Zabriskie"
Expand Down
Loading
Loading