Skip to content

Commit

Permalink
Merge pull request #727 from acacode/organise-deps
Browse files Browse the repository at this point in the history
Cleanup dependencies
  • Loading branch information
smorimoto authored May 5, 2024
2 parents 007b577 + 93939e7 commit b882444
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 335 deletions.
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"test:--another-array-type": "node tests/spec/another-array-type/test.js",
"test:--axios": "node tests/spec/axios/test.js",
"test:--axios--single-http-client": "node tests/spec/axiosSingleHttpClient/test.js",
"test:--cli": "rimraf tests/spec/cli/schema.ts && node index.js -p tests/spec/cli/schema.json -o tests/spec/cli -n schema.ts --extract-response-body --extract-response-error --api-class-name MySuperApi --type-prefix Prefix && node tests/spec/cli/test.js",
"test:--cli": "shx rm -rf tests/spec/cli/schema.ts && node index.js -p tests/spec/cli/schema.json -o tests/spec/cli -n schema.ts --extract-response-body --extract-response-error --api-class-name MySuperApi --type-prefix Prefix && node tests/spec/cli/test.js",
"test:--default-as-success": "node tests/spec/defaultAsSuccess/test.js",
"test:--default-response": "node tests/spec/defaultResponse/test.js",
"test:--dot-path-params": "node tests/spec/dot-path-params/test.js",
Expand Down Expand Up @@ -101,31 +101,31 @@
"validate:debug": "node --nolazy tests/validate.js"
},
"dependencies": {
"@types/swagger-schema-official": "2.0.25",
"cosmiconfig": "9.0.0",
"@types/swagger-schema-official": "^2.0.25",
"cosmiconfig": "^9.0.0",
"didyoumean": "^1.2.2",
"eta": "^2.2.0",
"js-yaml": "4.1.0",
"lodash": "4.17.21",
"make-dir": "4.0.0",
"nanoid": "3.3.6",
"node-emoji": "2.1.3",
"node-fetch": "^3.3.1",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"nanoid": "^3.3.7",
"node-emoji": "^2.1.3",
"prettier": "3.2.5",
"swagger-schema-official": "2.0.0-bab6bed",
"swagger2openapi": "7.0.8",
"swagger2openapi": "^7.0.8",
"typescript": "5.4.5"
},
"devDependencies": {
"@biomejs/biome": "1.7.2",
"@types/lodash": "^4.14.195",
"@types/node": "^20.4.1",
"@types/prettier": "^3.0.0",
"axios": "^1.4.0",
"cross-env": "^7.0.3",
"dotenv": "^16.3.1",
"git-diff": "^2.0.6",
"rimraf": "^5.0.1"
"@types/lodash": "4.17.1",
"@types/node": "20.12.8",
"axios": "1.6.8",
"cross-env": "7.0.3",
"dotenv": "16.4.5",
"git-diff": "2.0.6",
"shx": "0.3.4"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"engines": {
"node": ">=18.0.0"
}
}
3 changes: 1 addition & 2 deletions src/util/file-system.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const fs = require("node:fs");
const makeDir = require("make-dir");
const { resolve } = require("node:path");
const _ = require("lodash");
const { Logger } = require("./logger");
Expand Down Expand Up @@ -68,7 +67,7 @@ class FileSystem {

createDir = (path) => {
try {
makeDir.sync(path);
fs.mkdirSync(path, { recursive: true });
} catch (e) {
this.logger.debug("failed to create dir", e);
}
Expand Down
19 changes: 12 additions & 7 deletions src/util/request.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const _ = require("lodash");
const https = require("node:https");
const fetch = require("node-fetch-h2");

class Request {
/**
Expand All @@ -18,23 +16,30 @@ class Request {
}

/**
*
* @param url {string}
* @param disableStrictSSL
* @param authToken
* @param options {Partial<import("node-fetch").RequestInit>}
* @param options {Partial<RequestInit>}
* @return {Promise<string>}
*/
async download({ url, disableStrictSSL, authToken, ...options }) {
/**
* @type {Partial<import("node-fetch").RequestInit>}
* @type {Partial<RequestInit>}
*/
const requestOptions = {};

if (disableStrictSSL && !_.startsWith(url, "http://")) {
requestOptions.agent = new https.Agent({
rejectUnauthorized: false,
const undiciGlobalDispatcher =
global[Symbol.for("undici.globalDispatcher.1")];
if (!undiciGlobalDispatcher) {
throw new Error("Could not find the global Undici dispatcher");
}
const newDispatcher = new undiciGlobalDispatcher.constructor({
connect: {
rejectUnauthorized: false,
},
});
global[unidiciGlobalDispatcherSymbol] = newDispatcher;
}
if (authToken) {
requestOptions.headers = {
Expand Down
Loading

0 comments on commit b882444

Please sign in to comment.