mirror of
https://github.com/logto-io/logto.git
synced 2025-01-13 21:30:30 -05:00
refactor(cli): support proxy
This commit is contained in:
parent
a59ba6e318
commit
50e5e5fa22
3 changed files with 16 additions and 3 deletions
|
@ -1,11 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@logto/cli",
|
"name": "@logto/cli",
|
||||||
"version": "1.0.0-beta.9",
|
"version": "1.0.0-beta.10",
|
||||||
"description": "Logto CLI.",
|
"description": "Logto CLI.",
|
||||||
"author": "Silverhand Inc. <contact@silverhand.io>",
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
||||||
"homepage": "https://github.com/logto-io/logto#readme",
|
"homepage": "https://github.com/logto-io/logto#readme",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
|
"bin": "lib/index.js",
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
],
|
],
|
||||||
|
@ -13,7 +14,6 @@
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/logto-io/logto.git"
|
"url": "git+https://github.com/logto-io/logto.git"
|
||||||
},
|
},
|
||||||
"bin": "lib/index.js",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"precommit": "lint-staged",
|
"precommit": "lint-staged",
|
||||||
"build": "rimraf lib && tsc",
|
"build": "rimraf lib && tsc",
|
||||||
|
@ -32,6 +32,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^4.1.2",
|
"chalk": "^4.1.2",
|
||||||
"got": "^11.8.2",
|
"got": "^11.8.2",
|
||||||
|
"hpagent": "^1.0.0",
|
||||||
"ora": "^5.0.0",
|
"ora": "^5.0.0",
|
||||||
"prompts": "^2.4.2",
|
"prompts": "^2.4.2",
|
||||||
"semver": "^7.3.7",
|
"semver": "^7.3.7",
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { createWriteStream } from 'fs';
|
||||||
|
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import got, { Progress } from 'got';
|
import got, { Progress } from 'got';
|
||||||
|
import { HttpsProxyAgent } from 'hpagent';
|
||||||
import ora from 'ora';
|
import ora from 'ora';
|
||||||
|
|
||||||
export const safeExecSync = (command: string) => {
|
export const safeExecSync = (command: string) => {
|
||||||
|
@ -32,8 +33,12 @@ export const log: Log = Object.freeze({
|
||||||
});
|
});
|
||||||
|
|
||||||
export const downloadFile = async (url: string, destination: string) => {
|
export const downloadFile = async (url: string, destination: string) => {
|
||||||
|
const { HTTPS_PROXY, HTTP_PROXY, https_proxy, http_proxy } = process.env;
|
||||||
const file = createWriteStream(destination);
|
const file = createWriteStream(destination);
|
||||||
const stream = got.stream(url);
|
const proxy = HTTPS_PROXY ?? https_proxy ?? HTTP_PROXY ?? http_proxy;
|
||||||
|
const stream = got.stream(url, {
|
||||||
|
...(proxy && { agent: { https: new HttpsProxyAgent({ proxy }) } }),
|
||||||
|
});
|
||||||
const spinner = ora({
|
const spinner = ora({
|
||||||
text: 'Connecting',
|
text: 'Connecting',
|
||||||
prefixText: chalk.blue('[info]'),
|
prefixText: chalk.blue('[info]'),
|
||||||
|
|
7
pnpm-lock.yaml
generated
7
pnpm-lock.yaml
generated
|
@ -30,6 +30,7 @@ importers:
|
||||||
chalk: ^4.1.2
|
chalk: ^4.1.2
|
||||||
eslint: ^8.21.0
|
eslint: ^8.21.0
|
||||||
got: ^11.8.2
|
got: ^11.8.2
|
||||||
|
hpagent: ^1.0.0
|
||||||
lint-staged: ^13.0.0
|
lint-staged: ^13.0.0
|
||||||
ora: ^5.0.0
|
ora: ^5.0.0
|
||||||
prettier: ^2.7.1
|
prettier: ^2.7.1
|
||||||
|
@ -42,6 +43,7 @@ importers:
|
||||||
dependencies:
|
dependencies:
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
got: 11.8.3
|
got: 11.8.3
|
||||||
|
hpagent: 1.0.0
|
||||||
ora: 5.4.1
|
ora: 5.4.1
|
||||||
prompts: 2.4.2
|
prompts: 2.4.2
|
||||||
semver: 7.3.7
|
semver: 7.3.7
|
||||||
|
@ -8110,6 +8112,11 @@ packages:
|
||||||
lru-cache: 7.10.1
|
lru-cache: 7.10.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/hpagent/1.0.0:
|
||||||
|
resolution: {integrity: sha512-SCleE2Uc1bM752ymxg8QXYGW0TWtAV4ZW3TqH1aOnyi6T6YW2xadCcclm5qeVjvMvfQ2RKNtZxO7uVb9CTPt1A==}
|
||||||
|
engines: {node: '>=14'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/html-encoding-sniffer/3.0.0:
|
/html-encoding-sniffer/3.0.0:
|
||||||
resolution: {integrity: sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==}
|
resolution: {integrity: sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
|
|
Loading…
Add table
Reference in a new issue