@bratel/dgit 0.0.13 → 0.0.15
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.
- package/.github/workflows/nodejs.yml +17 -17
- package/README.en_US.md +20 -22
- package/README.md +25 -26
- package/eslint.config.mjs +15 -0
- package/lib/cmd/action.d.ts +3 -3
- package/lib/cmd/action.js +82 -78
- package/lib/cmd/main.js +18 -15
- package/lib/cmd/prompt.d.ts +4 -4
- package/lib/cmd/prompt.js +82 -76
- package/lib/cmd/type.d.ts +1 -0
- package/lib/cmd/utils.d.ts +5 -5
- package/lib/cmd/utils.js +25 -19
- package/lib/dgit.d.ts +2 -2
- package/lib/dgit.js +171 -157
- package/lib/log.d.ts +2 -2
- package/lib/log.js +11 -9
- package/lib/repo.d.ts +1 -1
- package/lib/repo.js +6 -4
- package/lib/request.d.ts +6 -6
- package/lib/request.js +29 -26
- package/lib/type.d.ts +2 -1
- package/package.json +61 -55
- package/renovate.json +19 -0
- package/src/cmd/action.ts +117 -108
- package/src/cmd/main.ts +52 -49
- package/src/cmd/prompt.ts +93 -92
- package/src/cmd/type.ts +28 -27
- package/src/cmd/utils.ts +78 -73
- package/src/dgit.ts +247 -228
- package/src/log.ts +9 -7
- package/src/repo.ts +6 -4
- package/src/request.ts +91 -92
- package/src/type.ts +37 -36
- package/test/dgit.test.ts +122 -119
- package/tsconfig.json +54 -51
- package/tsconfig.tsbuildinfo +1 -0
- package/.eslintignore +0 -6
- package/.eslintrc.js +0 -30
- package/x-npmrc +0 -2
package/lib/log.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createLogger =
|
|
3
|
+
exports.createLogger = createLogger;
|
|
4
4
|
const DEFAULT_PREFIX = '[dgit-logger]';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
5
|
+
function createLogger(option) {
|
|
6
|
+
return (...message) => {
|
|
7
|
+
if (option && option.log) {
|
|
8
|
+
const prefix = option
|
|
9
|
+
? option.logPrefix || DEFAULT_PREFIX
|
|
10
|
+
: DEFAULT_PREFIX;
|
|
11
|
+
console.log(prefix, ...message, '\n');
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
package/lib/repo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare function repoUtils(owner: string, repoName: string, ref: string, proxy: string | null): {
|
|
2
2
|
getRepoTreeUrl: () => string;
|
|
3
3
|
getDownloadUrl: (path: string) => string;
|
|
4
4
|
};
|
package/lib/repo.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
3
|
+
function repoUtils(owner, repoName, ref, proxy) {
|
|
4
|
+
return {
|
|
5
|
+
getRepoTreeUrl: () => `https://api.github.com/repos/${owner}/${repoName}/git/trees/${ref}?recursive=1`,
|
|
6
|
+
getDownloadUrl: (path) => `${proxy ? `${proxy}/` : ''}https://raw.githubusercontent.com/${owner}/${repoName}/${ref}/${path}`,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
7
9
|
exports.default = repoUtils;
|
package/lib/request.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import {
|
|
3
|
-
import { DgitGlobalOption, DgitLifeCycle } from './type';
|
|
4
|
-
|
|
5
|
-
export declare
|
|
6
|
-
export declare
|
|
1
|
+
import type fs from 'node:fs';
|
|
2
|
+
import type { CoreOptions, UrlOptions } from 'request';
|
|
3
|
+
import type { DgitGlobalOption, DgitLifeCycle } from './type';
|
|
4
|
+
type RequestOption = UrlOptions & CoreOptions;
|
|
5
|
+
export declare function requestGetPromise(options: RequestOption, dgitOptions: DgitGlobalOption, hooks?: DgitLifeCycle): Promise<any>;
|
|
6
|
+
export declare function requestOnStream(url: string, ws: fs.WriteStream, dgitOptions: DgitGlobalOption, hooks?: DgitLifeCycle): void;
|
|
7
7
|
export {};
|
package/lib/request.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.requestGetPromise = requestGetPromise;
|
|
4
|
+
exports.requestOnStream = requestOnStream;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const request_1 = tslib_1.__importDefault(require("request"));
|
|
6
7
|
const utils_1 = require("./cmd/utils");
|
|
7
8
|
const log_1 = require("./log");
|
|
8
9
|
const REQUEST_RETRY_DELAY = 1500;
|
|
9
10
|
const DEFAULT_MAX_RETRY_COUNT = 5;
|
|
10
|
-
|
|
11
|
+
function requestGet(options, maxRetryCount, hooks) {
|
|
11
12
|
const { onSuccess, onError, onFinish, onRetry, } = hooks || {};
|
|
12
13
|
request_1.default.get(options, (err, _, body) => {
|
|
13
14
|
if (err) {
|
|
@@ -25,33 +26,35 @@ const requestGet = (options, maxRetryCount, hooks) => {
|
|
|
25
26
|
onSuccess && onSuccess(body);
|
|
26
27
|
onFinish && onFinish();
|
|
27
28
|
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
}
|
|
30
|
+
function requestGetPromise(options, dgitOptions, hooks) {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
const { maxRetryCount = DEFAULT_MAX_RETRY_COUNT } = dgitOptions;
|
|
33
|
+
const { onSuccess, onError, onFinish, onRetry, } = hooks || {};
|
|
34
|
+
const newHooks = {
|
|
35
|
+
onSuccess(data) {
|
|
36
|
+
resolve(data);
|
|
37
|
+
onSuccess && onSuccess(data);
|
|
38
|
+
},
|
|
39
|
+
onError(err) {
|
|
40
|
+
reject(err);
|
|
41
|
+
onError && onError(err);
|
|
42
|
+
},
|
|
43
|
+
onFinish,
|
|
44
|
+
onRetry,
|
|
45
|
+
};
|
|
46
|
+
requestGet(options, maxRetryCount, newHooks);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function requestOnStream(url, ws, dgitOptions, hooks) {
|
|
47
50
|
const { maxRetryCount = DEFAULT_MAX_RETRY_COUNT } = dgitOptions;
|
|
48
|
-
const logger = log_1.createLogger(dgitOptions);
|
|
51
|
+
const logger = (0, log_1.createLogger)(dgitOptions);
|
|
49
52
|
const { onSuccess, onError, onFinish, onRetry, } = hooks || {};
|
|
50
53
|
const fn = (retryCount) => {
|
|
51
|
-
const downloadUrl = utils_1.AddExtraRandomQs(url);
|
|
54
|
+
const downloadUrl = (0, utils_1.AddExtraRandomQs)(url);
|
|
52
55
|
logger(` dowloading from ${downloadUrl}...`);
|
|
53
|
-
request_1.default(encodeURI(downloadUrl))
|
|
54
|
-
.on('error', err => {
|
|
56
|
+
(0, request_1.default)(encodeURI(downloadUrl))
|
|
57
|
+
.on('error', (err) => {
|
|
55
58
|
if (retryCount <= 0) {
|
|
56
59
|
onError && onError(err);
|
|
57
60
|
onFinish && onFinish();
|
|
@@ -72,4 +75,4 @@ exports.requestOnStream = (url, ws, dgitOptions, hooks) => {
|
|
|
72
75
|
logger(` ${url}, write stream failed.`);
|
|
73
76
|
});
|
|
74
77
|
fn(maxRetryCount);
|
|
75
|
-
}
|
|
78
|
+
}
|
package/lib/type.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type GithubRelativePath = string;
|
|
2
2
|
export interface DgitGlobalOption {
|
|
3
3
|
maxRetryCount?: number;
|
|
4
4
|
parallelLimit?: number;
|
|
@@ -6,6 +6,7 @@ export interface DgitGlobalOption {
|
|
|
6
6
|
logPrefix?: string;
|
|
7
7
|
exclude?: GithubRelativePath[];
|
|
8
8
|
include?: GithubRelativePath[];
|
|
9
|
+
exactMatch?: boolean;
|
|
9
10
|
}
|
|
10
11
|
export interface PrivateOption {
|
|
11
12
|
username?: string;
|
package/package.json
CHANGED
|
@@ -1,77 +1,83 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bratel/dgit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "@dking/hasaki-cli init application",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"keywords": [
|
|
11
|
-
"dgit",
|
|
12
|
-
"github download tool"
|
|
13
|
-
],
|
|
8
|
+
"author": "JohnApache",
|
|
9
|
+
"license": "MIT",
|
|
14
10
|
"repository": {
|
|
15
11
|
"type": "git",
|
|
16
12
|
"url": "https://github.com/lsq/dgit"
|
|
17
13
|
},
|
|
18
|
-
|
|
19
|
-
"
|
|
14
|
+
"keywords": [
|
|
15
|
+
"dgit",
|
|
16
|
+
"github download tool"
|
|
17
|
+
],
|
|
18
|
+
"main": "./lib/dgit.js",
|
|
19
|
+
"types": "./lib/dgit.d.ts",
|
|
20
|
+
"bin": {
|
|
21
|
+
"dgit": "./bin/cmd.js"
|
|
20
22
|
},
|
|
21
|
-
"author": "JohnApache",
|
|
22
|
-
"license": "MIT",
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build:ts": "tsc --build",
|
|
25
|
-
"lint": "eslint
|
|
26
|
-
"
|
|
27
|
-
"test:mocha
|
|
25
|
+
"lint": "eslint",
|
|
26
|
+
"lint:fix": "eslint src --ext .jsx --ext .js --ext .tsx --ext .ts --cache --fix",
|
|
27
|
+
"test:mocha": "nyc --reporter=text mocha --require ts-node/register test/**/*.{ts,tsx} -t 60000",
|
|
28
|
+
"test:mocha:reporter": "nyc --reporter=lcov --reporter=text mocha --require ts-node/register test/**/*.{ts,tsx} -t 60000 --reporter=mochawesome",
|
|
28
29
|
"watch:ts": "tsc --watch",
|
|
29
30
|
"prepublishOnly": "npm run test:mocha && npm run lint && npm run build:ts"
|
|
30
31
|
},
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@types/async": "^3.2.25",
|
|
34
|
+
"@types/commander": "^2.12.5",
|
|
35
|
+
"@types/inquirer": "^9.0.9",
|
|
36
|
+
"@types/ora": "^3.2.0",
|
|
37
|
+
"@types/progress": "^2.0.7",
|
|
38
|
+
"@types/request": "^2.48.13",
|
|
39
|
+
"async": "^3.2.6",
|
|
40
|
+
"chalk": "^5.6.2",
|
|
41
|
+
"commander": "^14.0.2",
|
|
42
|
+
"inquirer": "^13.1.0",
|
|
43
|
+
"ora": "^9.0.0",
|
|
44
|
+
"progress": "^2.0.3",
|
|
45
|
+
"request": "^2.88.2"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@antfu/eslint-config": "^6.7.3",
|
|
49
|
+
"@types/chai": "^5.2.3",
|
|
50
|
+
"@types/mocha": "^10.0.10",
|
|
51
|
+
"@types/node": "^25.0.3",
|
|
52
|
+
"@typescript-eslint/parser": "^8.50.1",
|
|
53
|
+
"chai": "^6.2.2",
|
|
54
|
+
"eslint": "^9.39.2",
|
|
55
|
+
"husky": "^9.1.7",
|
|
56
|
+
"lint-staged": "^16.2.7",
|
|
57
|
+
"mocha": "^11.7.5",
|
|
58
|
+
"nyc": "^17.1.0",
|
|
59
|
+
"ts-node": "^10.9.2",
|
|
60
|
+
"typescript": "^5.9.3"
|
|
61
|
+
},
|
|
62
|
+
"overrides": {
|
|
63
|
+
"request": {
|
|
64
|
+
"form-data": "^4.0.4",
|
|
65
|
+
"tough-cookie": "^4.1.3"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"resolutions": {
|
|
69
|
+
"form-data": "^4.0.4",
|
|
70
|
+
"tough-cookie": "^4.1.3"
|
|
36
71
|
},
|
|
37
72
|
"husky": {
|
|
38
73
|
"hooks": {
|
|
39
74
|
"pre-commit": "lint-staged"
|
|
40
75
|
}
|
|
41
76
|
},
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^2.13.0",
|
|
48
|
-
"@typescript-eslint/parser": "^2.13.0",
|
|
49
|
-
"chai": "^4.2.0",
|
|
50
|
-
"eslint": "^6.8.0",
|
|
51
|
-
"eslint-import-resolver-typescript": "^2.0.0",
|
|
52
|
-
"eslint-plugin-import": "^2.19.1",
|
|
53
|
-
"eslint-plugin-promise": "^4.1.1",
|
|
54
|
-
"husky": "^2.3.0",
|
|
55
|
-
"lint-staged": "^8.1.7",
|
|
56
|
-
"mocha": "^6.2.0",
|
|
57
|
-
"mochawesome": "^4.1.0",
|
|
58
|
-
"nyc": "^14.1.1",
|
|
59
|
-
"ts-node": "^8.3.0",
|
|
60
|
-
"typescript": "^3.7.4"
|
|
61
|
-
},
|
|
62
|
-
"dependencies": {
|
|
63
|
-
"@types/async": "^3.0.3",
|
|
64
|
-
"@types/commander": "^2.12.2",
|
|
65
|
-
"@types/inquirer": "^6.5.0",
|
|
66
|
-
"@types/ora": "^3.2.0",
|
|
67
|
-
"@types/progress": "^2.0.3",
|
|
68
|
-
"@types/request": "^2.48.3",
|
|
69
|
-
"async": "^3.1.0",
|
|
70
|
-
"chalk": "^3.0.0",
|
|
71
|
-
"commander": "^4.0.1",
|
|
72
|
-
"inquirer": "^7.0.0",
|
|
73
|
-
"ora": "^4.0.3",
|
|
74
|
-
"progress": "^2.0.3",
|
|
75
|
-
"request": "^2.88.0"
|
|
77
|
+
"lint-staged": {
|
|
78
|
+
"**/*.{jsx,js}": [
|
|
79
|
+
"npm run lint",
|
|
80
|
+
"git add"
|
|
81
|
+
]
|
|
76
82
|
}
|
|
77
83
|
}
|
package/renovate.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
3
|
+
"extends": ["config:recommended"],
|
|
4
|
+
"dependencyDashboard": true,
|
|
5
|
+
"prHourlyLimit": 2,
|
|
6
|
+
"prConcurrentLimit": 10,
|
|
7
|
+
"packageRules": [
|
|
8
|
+
{
|
|
9
|
+
"matchUpdateTypes": ["minor", "patch"],
|
|
10
|
+
"automerge": true
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"npm": {
|
|
14
|
+
"enabled": true
|
|
15
|
+
},
|
|
16
|
+
"github-actions": {
|
|
17
|
+
"enabled": true
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/cmd/action.ts
CHANGED
|
@@ -1,128 +1,137 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import type { Ora } from 'ora';
|
|
3
|
+
import type { CommandInfo } from './type';
|
|
4
|
+
import ora from 'ora';
|
|
3
5
|
import ProgressBar from 'progress';
|
|
4
6
|
import dgit from '../dgit';
|
|
5
|
-
import {
|
|
6
|
-
ParseGithubHttpsLink, TextEllipsis, isHttpsLink,
|
|
7
|
-
} from './utils';
|
|
8
|
-
import { CommandInfo } from './type';
|
|
9
7
|
|
|
10
8
|
import { DownloadPrompt, PasswordPrompt } from './prompt';
|
|
9
|
+
import {
|
|
10
|
+
isHttpsLink,
|
|
11
|
+
ParseGithubHttpsLink,
|
|
12
|
+
TextEllipsis,
|
|
13
|
+
} from './utils';
|
|
11
14
|
|
|
12
15
|
const MAX_TEXT_ELLIPSIS = 30;
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
relativePath = '',
|
|
24
|
-
password,
|
|
25
|
-
} = cmd;
|
|
17
|
+
async function DownloadAction(githubLink: string | undefined, cmd: Command & CommandInfo): Promise<any> {
|
|
18
|
+
let {
|
|
19
|
+
ref = '',
|
|
20
|
+
dest = '',
|
|
21
|
+
owner = '',
|
|
22
|
+
repoName = '',
|
|
23
|
+
relativePath = '',
|
|
24
|
+
password,
|
|
25
|
+
} = cmd;
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
const {
|
|
28
|
+
exclude = '',
|
|
29
|
+
include = '',
|
|
30
|
+
log = false,
|
|
31
|
+
logPrefix = '[dgit-logger]',
|
|
32
|
+
exactMatch = false, // 是否精确匹配
|
|
33
|
+
} = cmd;
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const {
|
|
36
|
+
parallelLimit = '',
|
|
37
|
+
username,
|
|
38
|
+
token,
|
|
39
|
+
} = cmd;
|
|
40
|
+
const {
|
|
41
|
+
proxy = '',
|
|
42
|
+
} = cmd;
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
if (githubLink && isHttpsLink(githubLink)) {
|
|
45
|
+
const parseResult = ParseGithubHttpsLink(githubLink);
|
|
46
|
+
ref = parseResult.ref;
|
|
47
|
+
owner = parseResult.owner;
|
|
48
|
+
repoName = parseResult.repoName;
|
|
49
|
+
relativePath = parseResult.relativePath;
|
|
50
|
+
}
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
if (username && !password) {
|
|
53
|
+
const pwdAnswer = await PasswordPrompt();
|
|
54
|
+
password = pwdAnswer.password;
|
|
55
|
+
}
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
const answer = await DownloadPrompt({
|
|
58
|
+
ref,
|
|
59
|
+
dest,
|
|
60
|
+
owner,
|
|
61
|
+
repoName,
|
|
62
|
+
relativePath,
|
|
63
|
+
});
|
|
59
64
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
ref = answer.ref;
|
|
66
|
+
dest = answer.dest;
|
|
67
|
+
owner = answer.owner;
|
|
68
|
+
repoName = answer.repoName;
|
|
69
|
+
relativePath = answer.relativePath;
|
|
65
70
|
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
const excludeList = exclude.split(',').filter(Boolean);
|
|
72
|
+
const includeList = include.split(',').filter(Boolean);
|
|
68
73
|
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
const spinner: Ora = ora(' loading remote repo tree...');
|
|
75
|
+
let bar: ProgressBar;
|
|
71
76
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
77
|
+
try {
|
|
78
|
+
await dgit(
|
|
79
|
+
{
|
|
80
|
+
ref,
|
|
81
|
+
owner,
|
|
82
|
+
repoName,
|
|
83
|
+
relativePath,
|
|
84
|
+
username,
|
|
85
|
+
password,
|
|
86
|
+
token,
|
|
87
|
+
proxy,
|
|
88
|
+
},
|
|
89
|
+
dest,
|
|
90
|
+
{
|
|
91
|
+
log,
|
|
92
|
+
logPrefix,
|
|
93
|
+
parallelLimit: Number(parallelLimit.trim()),
|
|
94
|
+
exclude: excludeList,
|
|
95
|
+
include: includeList,
|
|
96
|
+
exactMatch,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
beforeLoadTree() {
|
|
100
|
+
spinner.start();
|
|
101
|
+
},
|
|
102
|
+
afterLoadTree() {
|
|
103
|
+
spinner.succeed(' load remote repo tree succeed! ');
|
|
104
|
+
},
|
|
105
|
+
onResolved(status) {
|
|
106
|
+
if (log)
|
|
107
|
+
return;
|
|
108
|
+
const green = '\u001B[42m \u001B[0m';
|
|
109
|
+
const red = '\u001B[41m \u001B[0m';
|
|
110
|
+
const index = 0;
|
|
111
|
+
bar = new ProgressBar(
|
|
112
|
+
' DOWNLOAD |:bar| :current/:total :percent elapsed: :elapseds eta: :eta :file, done.',
|
|
92
113
|
{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
spinner.succeed(' load remote repo tree succeed! ');
|
|
98
|
-
},
|
|
99
|
-
onResolved (status) {
|
|
100
|
-
if (log) return;
|
|
101
|
-
const green = '\u001b[42m \u001b[0m';
|
|
102
|
-
const red = '\u001b[41m \u001b[0m';
|
|
103
|
-
const index = 0;
|
|
104
|
-
bar = new ProgressBar(
|
|
105
|
-
' DOWNLOAD |:bar| :current/:total :percent elapsed: :elapseds eta: :eta :file, done.',
|
|
106
|
-
{
|
|
107
|
-
total : status.totalCount,
|
|
108
|
-
width : 50,
|
|
109
|
-
complete : green,
|
|
110
|
-
incomplete: red,
|
|
111
|
-
},
|
|
112
|
-
);
|
|
113
|
-
bar.update(index);
|
|
114
|
-
},
|
|
115
|
-
onProgress (_, node) {
|
|
116
|
-
if (log) return;
|
|
117
|
-
bar.tick({ file: TextEllipsis(node.path, MAX_TEXT_ELLIPSIS) });
|
|
118
|
-
},
|
|
114
|
+
total: status.totalCount,
|
|
115
|
+
width: 50,
|
|
116
|
+
complete: green,
|
|
117
|
+
incomplete: red,
|
|
119
118
|
},
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
};
|
|
119
|
+
);
|
|
120
|
+
bar.update(index);
|
|
121
|
+
},
|
|
122
|
+
onProgress(_, node) {
|
|
123
|
+
if (log)
|
|
124
|
+
return;
|
|
125
|
+
bar.tick({ file: TextEllipsis(node.path, MAX_TEXT_ELLIPSIS) });
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
);
|
|
129
|
+
spinner.succeed(' download all files succeed!');
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
console.error(error);
|
|
133
|
+
spinner.fail(' download files failed!');
|
|
134
|
+
}
|
|
135
|
+
}
|
|
127
136
|
|
|
128
137
|
export default DownloadAction;
|