Skip to content

Commit

Permalink
fix(cli): fix issue on CLI when npm is on v9
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Jul 17, 2023
1 parent 1925b11 commit 88f92ef
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
28 changes: 24 additions & 4 deletions packages/cli-core/src/services/CliProxyAgent.ts
Expand Up @@ -4,6 +4,7 @@ import {CliExeca} from "./CliExeca";
import {camelCase} from "change-case";
import {URL} from "url";
import {coerce} from "../utils/coerce";
import {ProjectPackageJson} from "./ProjectPackageJson";

export interface CliProxySettings {
url: string;
Expand All @@ -21,6 +22,9 @@ export class CliProxyAgent {
@Value("proxy", {})
proxySettings: CliProxySettings;

@Inject()
protected projectPackageJson: ProjectPackageJson;

@Inject()
protected cliExeca: CliExeca;

Expand Down Expand Up @@ -61,10 +65,26 @@ export class CliProxyAgent {
}

const result = await Promise.all([
this.cliExeca.getAsync("npm", ["config", "get", "proxy"]),
this.cliExeca.getAsync("npm", ["config", "get", "http-proxy"]),
this.cliExeca.getAsync("npm", ["config", "get", "https-proxy"]),
this.cliExeca.getAsync("npm", ["config", "get", "strict-ssl"])
this.cliExeca
.getAsync("npm", ["config", "get", "proxy"], {
cwd: this.projectPackageJson.dir
})
.catch(() => ""),
this.cliExeca
.getAsync("npm", ["config", "get", "http-proxy"], {
cwd: this.projectPackageJson.dir
})
.catch(() => ""),
this.cliExeca
.getAsync("npm", ["config", "get", "https-proxy"], {
cwd: this.projectPackageJson.dir
})
.catch(() => ""),
this.cliExeca
.getAsync("npm", ["config", "get", "strict-ssl"], {
cwd: this.projectPackageJson.dir
})
.catch(() => "")
]);

const [proxy, httpProxy, httpsProxy, strictSsl] = result.map(coerce);
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/jest.config.js
Expand Up @@ -7,10 +7,10 @@ module.exports = {

coverageThreshold: {
global: {
statements: 91.69,
branches: 78.62,
statements: 91.73,
branches: 79.51,
functions: 76.25,
lines: 91.69
lines: 91.73
}
}
};
13 changes: 10 additions & 3 deletions packages/cli/package.json
Expand Up @@ -63,7 +63,7 @@
"node": ">=14"
},
"dependencies": {
"@tsed/cli-core": "4.6.2",
"@tsed/cli-core": ">=4.6.2",
"@tsed/core": ">=7.14.2",
"@tsed/di": ">=7.14.2",
"@tsed/logger": ">=6.2.1",
Expand All @@ -88,5 +88,12 @@
"eslint": "8.22.0",
"jest": "29.5.0"
},
"peerDependencies": {}
}
"peerDependencies": {
"@tsed/core": ">=7.14.2",
"@tsed/cli-core": ">=4.6.2",
"@tsed/di": ">=7.14.2",
"@tsed/logger": ">=6.2.1",
"@tsed/openspec": ">=7.14.2",
"@tsed/schema": ">=7.14.2"
}
}

0 comments on commit 88f92ef

Please sign in to comment.