axios 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of axios might be problematic. Click here for more details.
- package/CHANGELOG.md +32 -9
- package/dist/axios.js +84 -4
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +82 -3
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +84 -4
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +1 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +89 -4
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +20 -12
- package/index.d.ts +4 -3
- package/index.js +2 -0
- package/lib/.DS_Store +0 -0
- package/lib/adapters/http.js +8 -1
- package/lib/axios.js +3 -0
- package/lib/env/data.js +1 -1
- package/lib/helpers/HttpStatusCode.js +71 -0
- package/lib/platform/browser/index.js +1 -0
- package/lib/utils.js +5 -1
- package/package.json +54 -6
- package/bin/ssl_hotfix.js +0 -22
- package/gulpfile.js +0 -88
- package/karma.conf.cjs +0 -250
- package/rollup.config.js +0 -117
- package/tsconfig.json +0 -9
- package/tslint.json +0 -11
package/index.d.cts
CHANGED
@@ -18,16 +18,9 @@ type AxiosHeaderGetter = ((parser?: RegExp) => RegExpExecArray | null) |
|
|
18
18
|
|
19
19
|
type AxiosHeaderTester = (matcher?: AxiosHeaderMatcher) => boolean;
|
20
20
|
|
21
|
-
type MaxUploadRate = number;
|
22
|
-
|
23
|
-
type MaxDownloadRate = number;
|
24
|
-
|
25
|
-
type Milliseconds = number;
|
26
|
-
|
27
21
|
declare class AxiosHeaders {
|
28
22
|
constructor(
|
29
|
-
headers?: RawAxiosHeaders | AxiosHeaders
|
30
|
-
defaultHeaders?: RawAxiosHeaders | AxiosHeaders
|
23
|
+
headers?: RawAxiosHeaders | AxiosHeaders
|
31
24
|
);
|
32
25
|
|
33
26
|
set(headerName?: string, value?: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
@@ -44,12 +37,16 @@ declare class AxiosHeaders {
|
|
44
37
|
|
45
38
|
normalize(format: boolean): AxiosHeaders;
|
46
39
|
|
40
|
+
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string>): AxiosHeaders;
|
41
|
+
|
47
42
|
toJSON(asStrings?: boolean): RawAxiosHeaders;
|
48
43
|
|
49
44
|
static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
|
50
45
|
|
51
46
|
static accessor(header: string | string[]): AxiosHeaders;
|
52
47
|
|
48
|
+
static concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string>): AxiosHeaders;
|
49
|
+
|
53
50
|
setContentType: AxiosHeaderSetter;
|
54
51
|
getContentType: AxiosHeaderGetter;
|
55
52
|
hasContentType: AxiosHeaderTester;
|
@@ -199,7 +196,7 @@ declare namespace axios {
|
|
199
196
|
|
200
197
|
type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders>;
|
201
198
|
|
202
|
-
type AxiosRequestHeaders =
|
199
|
+
type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders;
|
203
200
|
|
204
201
|
type RawAxiosResponseHeaders = Partial<Record<string, string> & {
|
205
202
|
"set-cookie"?: string[]
|
@@ -321,6 +318,10 @@ declare namespace axios {
|
|
321
318
|
serialize?: CustomParamsSerializer;
|
322
319
|
}
|
323
320
|
|
321
|
+
type MaxUploadRate = number;
|
322
|
+
|
323
|
+
type MaxDownloadRate = number;
|
324
|
+
|
324
325
|
type BrowserProgressEvent = any;
|
325
326
|
|
326
327
|
interface AxiosProgressEvent {
|
@@ -335,20 +336,26 @@ declare namespace axios {
|
|
335
336
|
event?: BrowserProgressEvent;
|
336
337
|
}
|
337
338
|
|
339
|
+
type Milliseconds = number;
|
340
|
+
|
341
|
+
type AxiosAdapterName = 'xhr' | 'http' | string;
|
342
|
+
|
343
|
+
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
344
|
+
|
338
345
|
interface AxiosRequestConfig<D = any> {
|
339
346
|
url?: string;
|
340
347
|
method?: Method | string;
|
341
348
|
baseURL?: string;
|
342
349
|
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
343
350
|
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
|
344
|
-
headers?: RawAxiosRequestHeaders;
|
351
|
+
headers?: RawAxiosRequestHeaders | AxiosHeaders;
|
345
352
|
params?: any;
|
346
353
|
paramsSerializer?: ParamsSerializerOptions;
|
347
354
|
data?: D;
|
348
355
|
timeout?: Milliseconds;
|
349
356
|
timeoutErrorMessage?: string;
|
350
357
|
withCredentials?: boolean;
|
351
|
-
adapter?:
|
358
|
+
adapter?: AxiosAdapterConfig | AxiosAdapterConfig[];
|
352
359
|
auth?: AxiosBasicCredentials;
|
353
360
|
responseType?: ResponseType;
|
354
361
|
responseEncoding?: responseEncoding | string;
|
@@ -396,7 +403,7 @@ declare namespace axios {
|
|
396
403
|
}
|
397
404
|
|
398
405
|
interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
399
|
-
headers?: RawAxiosRequestHeaders | Partial<HeadersDefaults>;
|
406
|
+
headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;
|
400
407
|
}
|
401
408
|
|
402
409
|
interface AxiosResponse<T = any, D = any> {
|
@@ -485,6 +492,7 @@ declare namespace axios {
|
|
485
492
|
isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>;
|
486
493
|
toFormData(sourceObj: object, targetFormData?: GenericFormData, options?: FormSerializerOptions): GenericFormData;
|
487
494
|
formToJSON(form: GenericFormData|GenericHTMLFormElement): object;
|
495
|
+
AxiosHeaders: typeof AxiosHeaders;
|
488
496
|
}
|
489
497
|
}
|
490
498
|
|
package/index.d.ts
CHANGED
@@ -71,7 +71,7 @@ export class AxiosHeaders {
|
|
71
71
|
|
72
72
|
export type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders>;
|
73
73
|
|
74
|
-
export type AxiosRequestHeaders =
|
74
|
+
export type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders;
|
75
75
|
|
76
76
|
export type RawAxiosResponseHeaders = Partial<Record<string, string> & {
|
77
77
|
"set-cookie"?: string[]
|
@@ -289,7 +289,7 @@ export interface AxiosRequestConfig<D = any> {
|
|
289
289
|
baseURL?: string;
|
290
290
|
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
291
291
|
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
|
292
|
-
headers?: RawAxiosRequestHeaders;
|
292
|
+
headers?: RawAxiosRequestHeaders | AxiosHeaders;
|
293
293
|
params?: any;
|
294
294
|
paramsSerializer?: ParamsSerializerOptions;
|
295
295
|
data?: D;
|
@@ -344,7 +344,7 @@ export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'hea
|
|
344
344
|
}
|
345
345
|
|
346
346
|
export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
347
|
-
headers?: RawAxiosRequestHeaders | Partial<HeadersDefaults>;
|
347
|
+
headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;
|
348
348
|
}
|
349
349
|
|
350
350
|
export interface AxiosResponse<T = any, D = any> {
|
@@ -499,6 +499,7 @@ export interface AxiosStatic extends AxiosInstance {
|
|
499
499
|
CancelToken: CancelTokenStatic;
|
500
500
|
Axios: typeof Axios;
|
501
501
|
AxiosError: typeof AxiosError;
|
502
|
+
HttpStatusCode: typeof HttpStatusCode;
|
502
503
|
readonly VERSION: string;
|
503
504
|
isCancel: typeof isCancel;
|
504
505
|
all: typeof all;
|
package/index.js
CHANGED
package/lib/.DS_Store
ADDED
Binary file
|
package/lib/adapters/http.js
CHANGED
@@ -23,6 +23,11 @@ import EventEmitter from 'events';
|
|
23
23
|
const zlibOptions = {
|
24
24
|
flush: zlib.constants.Z_SYNC_FLUSH,
|
25
25
|
finishFlush: zlib.constants.Z_SYNC_FLUSH
|
26
|
+
};
|
27
|
+
|
28
|
+
const brotliOptions = {
|
29
|
+
flush: zlib.constants.BROTLI_OPERATION_FLUSH,
|
30
|
+
finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH
|
26
31
|
}
|
27
32
|
|
28
33
|
const isBrotliSupported = utils.isFunction(zlib.createBrotliDecompress);
|
@@ -417,7 +422,9 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
417
422
|
switch (res.headers['content-encoding']) {
|
418
423
|
/*eslint default-case:0*/
|
419
424
|
case 'gzip':
|
425
|
+
case 'x-gzip':
|
420
426
|
case 'compress':
|
427
|
+
case 'x-compress':
|
421
428
|
case 'deflate':
|
422
429
|
// add the unzipper to the body stream processing pipeline
|
423
430
|
streams.push(zlib.createUnzip(zlibOptions));
|
@@ -427,7 +434,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
427
434
|
break;
|
428
435
|
case 'br':
|
429
436
|
if (isBrotliSupported) {
|
430
|
-
streams.push(zlib.createBrotliDecompress(
|
437
|
+
streams.push(zlib.createBrotliDecompress(brotliOptions));
|
431
438
|
delete res.headers['content-encoding'];
|
432
439
|
}
|
433
440
|
}
|
package/lib/axios.js
CHANGED
@@ -15,6 +15,7 @@ import AxiosError from './core/AxiosError.js';
|
|
15
15
|
import spread from './helpers/spread.js';
|
16
16
|
import isAxiosError from './helpers/isAxiosError.js';
|
17
17
|
import AxiosHeaders from "./core/AxiosHeaders.js";
|
18
|
+
import HttpStatusCode from './helpers/HttpStatusCode.js';
|
18
19
|
|
19
20
|
/**
|
20
21
|
* Create an instance of Axios
|
@@ -77,6 +78,8 @@ axios.AxiosHeaders = AxiosHeaders;
|
|
77
78
|
|
78
79
|
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
79
80
|
|
81
|
+
axios.HttpStatusCode = HttpStatusCode;
|
82
|
+
|
80
83
|
axios.default = axios;
|
81
84
|
|
82
85
|
// this module should only have a default export
|
package/lib/env/data.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const VERSION = "1.2.
|
1
|
+
export const VERSION = "1.2.2";
|
@@ -0,0 +1,71 @@
|
|
1
|
+
const HttpStatusCode = {
|
2
|
+
Continue: 100,
|
3
|
+
SwitchingProtocols: 101,
|
4
|
+
Processing: 102,
|
5
|
+
EarlyHints: 103,
|
6
|
+
Ok: 200,
|
7
|
+
Created: 201,
|
8
|
+
Accepted: 202,
|
9
|
+
NonAuthoritativeInformation: 203,
|
10
|
+
NoContent: 204,
|
11
|
+
ResetContent: 205,
|
12
|
+
PartialContent: 206,
|
13
|
+
MultiStatus: 207,
|
14
|
+
AlreadyReported: 208,
|
15
|
+
ImUsed: 226,
|
16
|
+
MultipleChoices: 300,
|
17
|
+
MovedPermanently: 301,
|
18
|
+
Found: 302,
|
19
|
+
SeeOther: 303,
|
20
|
+
NotModified: 304,
|
21
|
+
UseProxy: 305,
|
22
|
+
Unused: 306,
|
23
|
+
TemporaryRedirect: 307,
|
24
|
+
PermanentRedirect: 308,
|
25
|
+
BadRequest: 400,
|
26
|
+
Unauthorized: 401,
|
27
|
+
PaymentRequired: 402,
|
28
|
+
Forbidden: 403,
|
29
|
+
NotFound: 404,
|
30
|
+
MethodNotAllowed: 405,
|
31
|
+
NotAcceptable: 406,
|
32
|
+
ProxyAuthenticationRequired: 407,
|
33
|
+
RequestTimeout: 408,
|
34
|
+
Conflict: 409,
|
35
|
+
Gone: 410,
|
36
|
+
LengthRequired: 411,
|
37
|
+
PreconditionFailed: 412,
|
38
|
+
PayloadTooLarge: 413,
|
39
|
+
UriTooLong: 414,
|
40
|
+
UnsupportedMediaType: 415,
|
41
|
+
RangeNotSatisfiable: 416,
|
42
|
+
ExpectationFailed: 417,
|
43
|
+
ImATeapot: 418,
|
44
|
+
MisdirectedRequest: 421,
|
45
|
+
UnprocessableEntity: 422,
|
46
|
+
Locked: 423,
|
47
|
+
FailedDependency: 424,
|
48
|
+
TooEarly: 425,
|
49
|
+
UpgradeRequired: 426,
|
50
|
+
PreconditionRequired: 428,
|
51
|
+
TooManyRequests: 429,
|
52
|
+
RequestHeaderFieldsTooLarge: 431,
|
53
|
+
UnavailableForLegalReasons: 451,
|
54
|
+
InternalServerError: 500,
|
55
|
+
NotImplemented: 501,
|
56
|
+
BadGateway: 502,
|
57
|
+
ServiceUnavailable: 503,
|
58
|
+
GatewayTimeout: 504,
|
59
|
+
HttpVersionNotSupported: 505,
|
60
|
+
VariantAlsoNegotiates: 506,
|
61
|
+
InsufficientStorage: 507,
|
62
|
+
LoopDetected: 508,
|
63
|
+
NotExtended: 510,
|
64
|
+
NetworkAuthenticationRequired: 511,
|
65
|
+
};
|
66
|
+
|
67
|
+
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
68
|
+
HttpStatusCode[value] = key;
|
69
|
+
});
|
70
|
+
|
71
|
+
export default HttpStatusCode;
|
@@ -43,6 +43,7 @@ const isStandardBrowserEnv = (() => {
|
|
43
43
|
const isStandardBrowserWebWorkerEnv = (() => {
|
44
44
|
return (
|
45
45
|
typeof WorkerGlobalScope !== 'undefined' &&
|
46
|
+
// eslint-disable-next-line no-undef
|
46
47
|
self instanceof WorkerGlobalScope &&
|
47
48
|
typeof self.importScripts === 'function'
|
48
49
|
);
|
package/lib/utils.js
CHANGED
@@ -277,7 +277,11 @@ function findKey(obj, key) {
|
|
277
277
|
return null;
|
278
278
|
}
|
279
279
|
|
280
|
-
const _global =
|
280
|
+
const _global = (() => {
|
281
|
+
/*eslint no-undef:0*/
|
282
|
+
if (typeof globalThis !== "undefined") return globalThis;
|
283
|
+
return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
|
284
|
+
})();
|
281
285
|
|
282
286
|
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
283
287
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "axios",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.2",
|
4
4
|
"description": "Promise based HTTP client for the browser and node.js",
|
5
5
|
"main": "index.js",
|
6
6
|
"exports": {
|
@@ -23,22 +23,32 @@
|
|
23
23
|
"type": "module",
|
24
24
|
"types": "index.d.ts",
|
25
25
|
"scripts": {
|
26
|
-
"test": "npm run test:eslint && npm run test:mocha && npm run test:karma && npm run test:
|
26
|
+
"test": "npm run test:eslint && npm run test:mocha && npm run test:karma && npm run test:dtslint && npm run test:exports",
|
27
27
|
"test:eslint": "node bin/ssl_hotfix.js eslint lib/**/*.js",
|
28
28
|
"test:dtslint": "node bin/ssl_hotfix.js dtslint",
|
29
29
|
"test:mocha": "node bin/ssl_hotfix.js mocha test/unit/**/*.js --timeout 30000 --exit",
|
30
30
|
"test:exports": "node bin/ssl_hotfix.js mocha test/module/test.js --timeout 30000 --exit",
|
31
31
|
"test:karma": "node bin/ssl_hotfix.js cross-env LISTEN_ADDR=:: karma start karma.conf.cjs --single-run",
|
32
32
|
"test:karma:server": "node bin/ssl_hotfix.js cross-env karma start karma.conf.cjs",
|
33
|
+
"test:build:version": "node ./bin/check-build-version.js",
|
33
34
|
"start": "node ./sandbox/server.js",
|
34
35
|
"preversion": "gulp version && npm test",
|
35
36
|
"version": "npm run build && git add dist && git add package.json",
|
36
|
-
"prepublishOnly": "npm test",
|
37
|
+
"prepublishOnly": "npm run test:build:version",
|
37
38
|
"postpublish": "git push && git push --tags",
|
38
39
|
"build": "gulp clear && cross-env NODE_ENV=production rollup -c -m",
|
39
40
|
"examples": "node ./examples/server.js",
|
40
41
|
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
|
41
|
-
"fix": "eslint --fix lib/**/*.js"
|
42
|
+
"fix": "eslint --fix lib/**/*.js",
|
43
|
+
"prepare": "husky install && npm run prepare:hooks",
|
44
|
+
"prepare:hooks": "npx husky set .husky/commit-msg \"npx commitlint --edit $1\"",
|
45
|
+
"release:dry": "release-it --dry-run --no-npm",
|
46
|
+
"release:info": "release-it --release-version",
|
47
|
+
"release:beta:no-npm": "release-it --preRelease=beta --no-npm",
|
48
|
+
"release:beta": "release-it --preRelease=beta",
|
49
|
+
"release:no-npm": "release-it --no-npm",
|
50
|
+
"release:changelog:fix": "node ./bin/injectContributorsList.js",
|
51
|
+
"release": "release-it"
|
42
52
|
},
|
43
53
|
"repository": {
|
44
54
|
"type": "git",
|
@@ -60,12 +70,16 @@
|
|
60
70
|
"devDependencies": {
|
61
71
|
"@babel/core": "^7.18.2",
|
62
72
|
"@babel/preset-env": "^7.18.2",
|
73
|
+
"@commitlint/cli": "^17.3.0",
|
74
|
+
"@commitlint/config-conventional": "^17.3.0",
|
75
|
+
"@release-it/conventional-changelog": "^5.1.1",
|
63
76
|
"@rollup/plugin-babel": "^5.3.1",
|
64
77
|
"@rollup/plugin-commonjs": "^15.1.0",
|
65
78
|
"@rollup/plugin-json": "^4.1.0",
|
66
79
|
"@rollup/plugin-multi-entry": "^4.0.0",
|
67
80
|
"@rollup/plugin-node-resolve": "^9.0.0",
|
68
81
|
"abortcontroller-polyfill": "^1.7.3",
|
82
|
+
"auto-changelog": "^2.4.0",
|
69
83
|
"body-parser": "^1.20.0",
|
70
84
|
"coveralls": "^3.1.1",
|
71
85
|
"cross-env": "^7.0.3",
|
@@ -78,6 +92,8 @@
|
|
78
92
|
"fs-extra": "^10.1.0",
|
79
93
|
"get-stream": "^3.0.0",
|
80
94
|
"gulp": "^4.0.2",
|
95
|
+
"handlebars": "^4.7.7",
|
96
|
+
"husky": "^8.0.2",
|
81
97
|
"istanbul-instrumenter-loader": "^3.0.1",
|
82
98
|
"jasmine-core": "^2.4.1",
|
83
99
|
"karma": "^6.3.17",
|
@@ -90,15 +106,17 @@
|
|
90
106
|
"karma-sauce-launcher": "^4.3.6",
|
91
107
|
"karma-sinon": "^1.0.5",
|
92
108
|
"karma-sourcemap-loader": "^0.3.8",
|
93
|
-
"minimist": "^1.2.
|
109
|
+
"minimist": "^1.2.7",
|
94
110
|
"mocha": "^10.0.0",
|
95
111
|
"multer": "^1.4.4",
|
112
|
+
"release-it": "^15.5.1",
|
96
113
|
"rollup": "^2.67.0",
|
97
114
|
"rollup-plugin-auto-external": "^2.0.0",
|
98
115
|
"rollup-plugin-bundle-size": "^1.0.3",
|
99
116
|
"rollup-plugin-terser": "^7.0.2",
|
100
117
|
"sinon": "^4.5.0",
|
101
118
|
"stream-throttle": "^0.1.3",
|
119
|
+
"string-replace-async": "^3.0.2",
|
102
120
|
"terser-webpack-plugin": "^4.2.3",
|
103
121
|
"typescript": "^4.8.4",
|
104
122
|
"url-search-params": "^0.10.0"
|
@@ -137,5 +155,35 @@
|
|
137
155
|
"Ben Carp (https://github.com/carpben)",
|
138
156
|
"Daniel Lopretto (https://github.com/timemachine3030)"
|
139
157
|
],
|
140
|
-
"sideEffects": false
|
158
|
+
"sideEffects": false,
|
159
|
+
"release-it": {
|
160
|
+
"git": {
|
161
|
+
"commitMessage": "chore(release): v${version}"
|
162
|
+
},
|
163
|
+
"github": {
|
164
|
+
"release": true
|
165
|
+
},
|
166
|
+
"npm": {
|
167
|
+
"publish": false,
|
168
|
+
"ignoreVersion": false
|
169
|
+
},
|
170
|
+
"plugins": {
|
171
|
+
"@release-it/conventional-changelog": {
|
172
|
+
"preset": "angular",
|
173
|
+
"infile": "CHANGELOG.md",
|
174
|
+
"header": "# Changelog"
|
175
|
+
}
|
176
|
+
},
|
177
|
+
"hooks": {
|
178
|
+
"before:init": "npm test",
|
179
|
+
"after:bump": "gulp version --bump ${version} && npm run build && npm run test:build:version && git add ./dist",
|
180
|
+
"before:release": "npm run release:changelog:fix && git add CHANGELOG.md",
|
181
|
+
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
|
182
|
+
}
|
183
|
+
},
|
184
|
+
"commitlint": {
|
185
|
+
"extends": [
|
186
|
+
"@commitlint/config-conventional"
|
187
|
+
]
|
188
|
+
}
|
141
189
|
}
|
package/bin/ssl_hotfix.js
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
import {spawn} from 'child_process';
|
2
|
-
|
3
|
-
const args = process.argv.slice(2);
|
4
|
-
|
5
|
-
console.log(`Running ${args.join(' ')} on ${process.version}\n`);
|
6
|
-
|
7
|
-
const match = /v(\d+)/.exec(process.version);
|
8
|
-
|
9
|
-
const isHotfixNeeded = match && match[1] > 16;
|
10
|
-
|
11
|
-
isHotfixNeeded && console.warn('Setting --openssl-legacy-provider as ssl hotfix');
|
12
|
-
|
13
|
-
const test = spawn('cross-env',
|
14
|
-
isHotfixNeeded ? ['NODE_OPTIONS=--openssl-legacy-provider', ...args] : args, {
|
15
|
-
shell: true,
|
16
|
-
stdio: 'inherit'
|
17
|
-
}
|
18
|
-
);
|
19
|
-
|
20
|
-
test.on('exit', function (code) {
|
21
|
-
process.exit(code)
|
22
|
-
})
|
package/gulpfile.js
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
import gulp from 'gulp';
|
2
|
-
import fs from 'fs-extra';
|
3
|
-
import axios from './index.js';
|
4
|
-
|
5
|
-
gulp.task('default', async function(){
|
6
|
-
console.log('hello!');
|
7
|
-
});
|
8
|
-
|
9
|
-
const clear = gulp.task('clear', async function() {
|
10
|
-
await fs.emptyDir('./dist/')
|
11
|
-
});
|
12
|
-
|
13
|
-
const bower = gulp.task('bower', async function () {
|
14
|
-
const npm = JSON.parse(await fs.readFile('package.json'));
|
15
|
-
const bower = JSON.parse(await fs.readFile('bower.json'));
|
16
|
-
|
17
|
-
const fields = [
|
18
|
-
'name',
|
19
|
-
'description',
|
20
|
-
'version',
|
21
|
-
'homepage',
|
22
|
-
'license',
|
23
|
-
'keywords'
|
24
|
-
];
|
25
|
-
|
26
|
-
for (let i = 0, l = fields.length; i < l; i++) {
|
27
|
-
const field = fields[i];
|
28
|
-
bower[field] = npm[field];
|
29
|
-
}
|
30
|
-
|
31
|
-
await fs.writeFile('bower.json', JSON.stringify(bower, null, 2));
|
32
|
-
});
|
33
|
-
|
34
|
-
async function getContributors(user, repo, maxCount = 1) {
|
35
|
-
const contributors = (await axios.get(
|
36
|
-
`https://api.github.com/repos/${encodeURIComponent(user)}/${encodeURIComponent(repo)}/contributors`,
|
37
|
-
{ params: { per_page: maxCount } }
|
38
|
-
)).data;
|
39
|
-
|
40
|
-
return Promise.all(contributors.map(async (contributor)=> {
|
41
|
-
return {...contributor, ...(await axios.get(
|
42
|
-
`https://api.github.com/users/${encodeURIComponent(contributor.login)}`
|
43
|
-
)).data};
|
44
|
-
}))
|
45
|
-
}
|
46
|
-
|
47
|
-
const packageJSON = gulp.task('package', async function () {
|
48
|
-
const CONTRIBUTION_THRESHOLD = 3;
|
49
|
-
|
50
|
-
const npm = JSON.parse(await fs.readFile('package.json'));
|
51
|
-
|
52
|
-
try {
|
53
|
-
const contributors = await getContributors('axios', 'axios', 15);
|
54
|
-
|
55
|
-
npm.contributors = contributors
|
56
|
-
.filter(
|
57
|
-
({type, contributions}) => type.toLowerCase() === 'user' && contributions >= CONTRIBUTION_THRESHOLD
|
58
|
-
)
|
59
|
-
.map(({login, name, url}) => `${name || login} (https://github.com/${login})`);
|
60
|
-
|
61
|
-
await fs.writeFile('package.json', JSON.stringify(npm, null, 2));
|
62
|
-
} catch (err) {
|
63
|
-
if (axios.isAxiosError(err) && err.response && err.response.status === 403) {
|
64
|
-
throw Error(`GitHub API Error: ${err.response.data && err.response.data.message}`);
|
65
|
-
}
|
66
|
-
throw err;
|
67
|
-
}
|
68
|
-
});
|
69
|
-
|
70
|
-
const env = gulp.task('env', async function () {
|
71
|
-
var npm = JSON.parse(await fs.readFile('package.json'));
|
72
|
-
|
73
|
-
await fs.writeFile('./lib/env/data.js', Object.entries({
|
74
|
-
VERSION: npm.version
|
75
|
-
}).map(([key, value]) => {
|
76
|
-
return `export const ${key} = ${JSON.stringify(value)};`
|
77
|
-
}).join('\n'));
|
78
|
-
});
|
79
|
-
|
80
|
-
const version = gulp.series('bower', 'env', 'package');
|
81
|
-
|
82
|
-
export {
|
83
|
-
bower,
|
84
|
-
env,
|
85
|
-
clear,
|
86
|
-
version,
|
87
|
-
packageJSON
|
88
|
-
}
|