Skip to content

Commit 862a48e

Browse files
authored
revert(again)!: bring back #245 (#249)
This reverts commit c65e264 (#247) and re-adds the changes from #245, this time as a breaking change.
1 parent 70faf2e commit 862a48e

File tree

162 files changed

+334
-1443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+334
-1443
lines changed

.github/workflows/ci.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ jobs:
1313
strategy:
1414
matrix:
1515
node-version:
16-
- 18
17-
- 20
16+
- lts/-1
17+
- lts/*
18+
- latest
1819

1920
steps:
2021
- uses: actions/checkout@v4

.vscode/settings.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
23
"editor.codeActionsOnSave": {
34
"source.fixAll": "explicit"
45
},
5-
"editor.defaultFormatter": "esbenp.prettier-vscode",
6+
"editor.formatOnSave": true,
67

78
// controlled by the .editorconfig at root since we can't map vscode settings directly to files
89
// https://github.com/microsoft/vscode/issues/35350
9-
"files.insertFinalNewline": false
10+
"files.insertFinalNewline": false,
11+
12+
"search.exclude": {
13+
"coverage": true
14+
}
1015
}

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ console.log(
109109
}),
110110
);
111111

112-
// generate Node.js: Unirest output
113-
console.log(snippet.convert('node', 'unirest'));
112+
// generate Node.js: Axios output
113+
console.log(snippet.convert('node', 'axios'));
114114
```
115115

116116
### addTarget(target)

integrations/node.Dockerfile

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ WORKDIR /src
1313
ADD package.json /src/
1414

1515
# https://www.npmjs.com/package/axios
16-
# https://www.npmjs.com/package/request
17-
# Installing node-fetch@2 because as of 3.0 is't now an ESM-only package.
18-
# https://www.npmjs.com/package/node-fetch
19-
RUN npm install axios request node-fetch@2 && \
16+
RUN npm install axios && \
2017
npm install
2118

2219
ADD . /src

package.json

-2
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,12 @@
5353
"ocaml",
5454
"php",
5555
"python",
56-
"request",
5756
"requests",
5857
"ruby",
5958
"shell",
6059
"snippet",
6160
"swift",
6261
"swift",
63-
"unirest",
6462
"xhr",
6563
"xmlhttprequest"
6664
],

src/fixtures/customTarget.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import type { Target } from '../targets/index.js';
22

3-
import { request } from '../targets/node/request/client.js';
3+
import { axios } from '../targets/node/axios/client.js';
44

55
export const customTarget = {
66
info: {
7-
key: 'js-variant',
8-
title: 'JavaScript Variant',
7+
key: 'node-variant',
8+
title: 'Node Variant',
99
extname: '.js',
10-
default: 'request',
10+
default: 'axios',
1111
},
1212
clientsById: {
13-
request,
13+
axios,
1414
},
1515
} as unknown as Target;

src/helpers/__snapshots__/utils.test.ts.snap

+7-23
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ exports[`availableTargets > returns all available targets 1`] = `
150150
"title": "jQuery",
151151
},
152152
],
153-
"default": "xhr",
153+
"default": "fetch",
154154
"key": "javascript",
155155
"title": "JavaScript",
156156
},
@@ -192,39 +192,23 @@ exports[`availableTargets > returns all available targets 1`] = `
192192
"link": "http://nodejs.org/api/http.html#http_http_request_options_callback",
193193
"title": "HTTP",
194194
},
195-
{
196-
"description": "Simplified HTTP request client",
197-
"extname": ".cjs",
198-
"installation": "npm install request --save",
199-
"key": "request",
200-
"link": "https://github.com/request/request",
201-
"title": "Request",
202-
},
203-
{
204-
"description": "Lightweight HTTP Request Client Library",
205-
"extname": ".cjs",
206-
"key": "unirest",
207-
"link": "http://unirest.io/nodejs.html",
208-
"title": "Unirest",
209-
},
210195
{
211196
"description": "Promise based HTTP client for the browser and node.js",
212-
"extname": ".cjs",
197+
"extname": ".js",
213198
"installation": "npm install axios --save",
214199
"key": "axios",
215200
"link": "https://github.com/axios/axios",
216201
"title": "Axios",
217202
},
218203
{
219-
"description": "Simplified HTTP node-fetch client",
220-
"extname": ".cjs",
221-
"installation": "npm install node-fetch@2 --save",
204+
"description": "Perform asynchronous HTTP requests with the Fetch API",
205+
"extname": ".js",
222206
"key": "fetch",
223-
"link": "https://github.com/bitinn/node-fetch",
224-
"title": "Fetch",
207+
"link": "https://nodejs.org/docs/latest/api/globals.html#fetch",
208+
"title": "fetch",
225209
},
226210
],
227-
"default": "native",
211+
"default": "fetch",
228212
"key": "node",
229213
"title": "Node.js",
230214
},

src/helpers/utils.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('extname', () => {
2222
expect(extname('c', 'libcurl')).toBe('.c');
2323
expect(extname('clojure', 'clj_http')).toBe('.clj');
2424
expect(extname('javascript', 'axios')).toBe('.js');
25-
expect(extname('node', 'axios')).toBe('.cjs');
25+
expect(extname('node', 'axios')).toBe('.js');
2626
});
2727

2828
it('returns empty string if the extension is not found', () => {

src/integration.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const ENVIRONMENT_CONFIG = {
2121
c: ['libcurl'],
2222
csharp: ['httpclient', 'restsharp'],
2323
go: ['native'],
24-
node: ['axios', 'fetch', 'native', 'request'],
24+
node: ['axios', 'fetch'],
2525
php: ['curl', 'guzzle'],
2626
python: ['requests'],
2727
shell: ['curl'],
@@ -30,7 +30,7 @@ const ENVIRONMENT_CONFIG = {
3030
// When running tests locally, or within a CI environment, we shold limit the targets that
3131
// we're testing so as to not require a mess of dependency requirements that would be better
3232
// served within a container.
33-
node: ['native'],
33+
node: ['fetch'],
3434
php: ['curl'],
3535
python: ['requests'],
3636
shell: ['curl'],

src/targets/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const targetFilter: TargetId[] = [
3131
/** useful for debuggin, only run a particular set of targets */
3232
const clientFilter: ClientId[] = [
3333
// put your clientId here:
34-
// 'unirest',
34+
// 'axios',
3535
];
3636

3737
/** useful for debuggin, only run a particular set of fixtures */

src/targets/javascript/axios/client.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,8 @@ export const axios: Client = {
9999

100100
push('axios');
101101
push('.request(options)', 1);
102-
push('.then(function (response) {', 1);
103-
push('console.log(response.data);', 2);
104-
push('})', 1);
105-
push('.catch(function (error) {', 1);
106-
push('console.error(error);', 2);
107-
push('});', 1);
102+
push('.then(res => console.log(res.data))', 1);
103+
push('.catch(err => console.error(err));', 1);
108104

109105
return join();
110106
},

src/targets/javascript/axios/fixtures/application-form-encoded.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,5 @@ const options = {
1313

1414
axios
1515
.request(options)
16-
.then(function (response) {
17-
console.log(response.data);
18-
})
19-
.catch(function (error) {
20-
console.error(error);
21-
});
16+
.then(res => console.log(res.data))
17+
.catch(err => console.error(err));

src/targets/javascript/axios/fixtures/application-json.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,5 @@ const options = {
1616

1717
axios
1818
.request(options)
19-
.then(function (response) {
20-
console.log(response.data);
21-
})
22-
.catch(function (error) {
23-
console.error(error);
24-
});
19+
.then(res => console.log(res.data))
20+
.catch(err => console.error(err));

src/targets/javascript/axios/fixtures/cookies.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,5 @@ const options = {
88

99
axios
1010
.request(options)
11-
.then(function (response) {
12-
console.log(response.data);
13-
})
14-
.catch(function (error) {
15-
console.error(error);
16-
});
11+
.then(res => console.log(res.data))
12+
.catch(err => console.error(err));

src/targets/javascript/axios/fixtures/custom-method.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,5 @@ const options = {method: 'PROPFIND', url: 'https://httpbin.org/anything'};
44

55
axios
66
.request(options)
7-
.then(function (response) {
8-
console.log(response.data);
9-
})
10-
.catch(function (error) {
11-
console.error(error);
12-
});
7+
.then(res => console.log(res.data))
8+
.catch(err => console.error(err));

src/targets/javascript/axios/fixtures/full.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,5 @@ const options = {
1717

1818
axios
1919
.request(options)
20-
.then(function (response) {
21-
console.log(response.data);
22-
})
23-
.catch(function (error) {
24-
console.error(error);
25-
});
20+
.then(res => console.log(res.data))
21+
.catch(err => console.error(err));

src/targets/javascript/axios/fixtures/headers.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,5 @@ const options = {
1313

1414
axios
1515
.request(options)
16-
.then(function (response) {
17-
console.log(response.data);
18-
})
19-
.catch(function (error) {
20-
console.error(error);
21-
});
16+
.then(res => console.log(res.data))
17+
.catch(err => console.error(err));

src/targets/javascript/axios/fixtures/http-insecure.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,5 @@ const options = {method: 'GET', url: 'http://httpbin.org/anything'};
44

55
axios
66
.request(options)
7-
.then(function (response) {
8-
console.log(response.data);
9-
})
10-
.catch(function (error) {
11-
console.error(error);
12-
});
7+
.then(res => console.log(res.data))
8+
.catch(err => console.error(err));

src/targets/javascript/axios/fixtures/jsonObj-multiline.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,5 @@ const options = {
99

1010
axios
1111
.request(options)
12-
.then(function (response) {
13-
console.log(response.data);
14-
})
15-
.catch(function (error) {
16-
console.error(error);
17-
});
12+
.then(res => console.log(res.data))
13+
.catch(err => console.error(err));

src/targets/javascript/axios/fixtures/jsonObj-null-value.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,5 @@ const options = {
99

1010
axios
1111
.request(options)
12-
.then(function (response) {
13-
console.log(response.data);
14-
})
15-
.catch(function (error) {
16-
console.error(error);
17-
});
12+
.then(res => console.log(res.data))
13+
.catch(err => console.error(err));

src/targets/javascript/axios/fixtures/multipart-data.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,5 @@ const options = {
1313

1414
axios
1515
.request(options)
16-
.then(function (response) {
17-
console.log(response.data);
18-
})
19-
.catch(function (error) {
20-
console.error(error);
21-
});
16+
.then(res => console.log(res.data))
17+
.catch(err => console.error(err));

src/targets/javascript/axios/fixtures/multipart-file.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,5 @@ const options = {
1212

1313
axios
1414
.request(options)
15-
.then(function (response) {
16-
console.log(response.data);
17-
})
18-
.catch(function (error) {
19-
console.error(error);
20-
});
15+
.then(res => console.log(res.data))
16+
.catch(err => console.error(err));

src/targets/javascript/axios/fixtures/multipart-form-data-no-params.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,5 @@ const options = {
88

99
axios
1010
.request(options)
11-
.then(function (response) {
12-
console.log(response.data);
13-
})
14-
.catch(function (error) {
15-
console.error(error);
16-
});
11+
.then(res => console.log(res.data))
12+
.catch(err => console.error(err));

src/targets/javascript/axios/fixtures/multipart-form-data.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,5 @@ const options = {
1212

1313
axios
1414
.request(options)
15-
.then(function (response) {
16-
console.log(response.data);
17-
})
18-
.catch(function (error) {
19-
console.error(error);
20-
});
15+
.then(res => console.log(res.data))
16+
.catch(err => console.error(err));

src/targets/javascript/axios/fixtures/nested.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,5 @@ const options = {
88

99
axios
1010
.request(options)
11-
.then(function (response) {
12-
console.log(response.data);
13-
})
14-
.catch(function (error) {
15-
console.error(error);
16-
});
11+
.then(res => console.log(res.data))
12+
.catch(err => console.error(err));

0 commit comments

Comments
 (0)