@bratel/dgit 0.0.13 → 0.0.14

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/package.json CHANGED
@@ -1,77 +1,73 @@
1
1
  {
2
2
  "name": "@bratel/dgit",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "@dking/hasaki-cli init application",
5
- "bin": {
6
- "dgit": "./bin/cmd.js"
5
+ "publishConfig": {
6
+ "access": "public"
7
7
  },
8
- "main": "./lib/dgit.js",
9
- "types": "./lib/dgit.d.ts",
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
- "publishConfig": {
19
- "access": "public"
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 src --ext .jsx --ext .js --ext .tsx --ext .ts --cache --fix",
26
- "test:mocha": "nyc --reporter=text mocha --require ts-node/register 'test/**/*.{ts,tsx}' -t 60000",
27
- "test:mocha:reporter": "nyc --reporter=lcov --reporter=text mocha --require ts-node/register 'test/**/*.{ts,tsx}' -t 60000 --reporter=mochawesome",
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
- "lint-staged": {
32
- "**/*.{jsx,js}": [
33
- "npm run lint",
34
- "git add"
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"
36
61
  },
37
62
  "husky": {
38
63
  "hooks": {
39
64
  "pre-commit": "lint-staged"
40
65
  }
41
66
  },
42
- "devDependencies": {
43
- "@dking/eslint-config-typescript": "^0.0.4",
44
- "@types/chai": "^4.2.0",
45
- "@types/mocha": "^5.2.7",
46
- "@types/node": "^12.7.5",
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"
67
+ "lint-staged": {
68
+ "**/*.{jsx,js}": [
69
+ "npm run lint",
70
+ "git add"
71
+ ]
76
72
  }
77
73
  }
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,135 @@
1
- import { Command } from 'commander';
2
- import ora, { Ora } from 'ora';
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
- const DownloadAction = async (
15
- githubLink: string | undefined,
16
- cmd: Command & CommandInfo,
17
- ): Promise<any> => {
18
- let {
19
- ref = '',
20
- dest = '',
21
- owner = '',
22
- repoName = '',
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
- const {
28
- exclude = '',
29
- include = '',
30
- log = false,
31
- logPrefix = '[dgit-logger]',
32
- } = cmd;
27
+ const {
28
+ exclude = '',
29
+ include = '',
30
+ log = false,
31
+ logPrefix = '[dgit-logger]',
32
+ } = cmd;
33
33
 
34
- const {
35
- parallelLimit = '', username, token,
36
- } = cmd;
37
- const { proxy = '' } = cmd;
34
+ const {
35
+ parallelLimit = '',
36
+ username,
37
+ token,
38
+ } = cmd;
39
+ const {
40
+ proxy = '',
41
+ } = cmd;
38
42
 
39
- if (githubLink && isHttpsLink(githubLink)) {
40
- const parseResult = ParseGithubHttpsLink(githubLink);
41
- ref = parseResult.ref;
42
- owner = parseResult.owner;
43
- repoName = parseResult.repoName;
44
- relativePath = parseResult.relativePath;
45
- }
43
+ if (githubLink && isHttpsLink(githubLink)) {
44
+ const parseResult = ParseGithubHttpsLink(githubLink);
45
+ ref = parseResult.ref;
46
+ owner = parseResult.owner;
47
+ repoName = parseResult.repoName;
48
+ relativePath = parseResult.relativePath;
49
+ }
46
50
 
47
- if (username && !password) {
48
- const pwdAnswer = await PasswordPrompt();
49
- password = pwdAnswer.password;
50
- }
51
+ if (username && !password) {
52
+ const pwdAnswer = await PasswordPrompt();
53
+ password = pwdAnswer.password;
54
+ }
51
55
 
52
- const answer = await DownloadPrompt({
53
- ref,
54
- dest,
55
- owner,
56
- repoName,
57
- relativePath,
58
- });
56
+ const answer = await DownloadPrompt({
57
+ ref,
58
+ dest,
59
+ owner,
60
+ repoName,
61
+ relativePath,
62
+ });
59
63
 
60
- ref = answer.ref;
61
- dest = answer.dest;
62
- owner = answer.owner;
63
- repoName = answer.repoName;
64
- relativePath = answer.relativePath;
64
+ ref = answer.ref;
65
+ dest = answer.dest;
66
+ owner = answer.owner;
67
+ repoName = answer.repoName;
68
+ relativePath = answer.relativePath;
65
69
 
66
- const excludeList = exclude.split(',').filter(Boolean);
67
- const includeList = include.split(',').filter(Boolean);
70
+ const excludeList = exclude.split(',').filter(Boolean);
71
+ const includeList = include.split(',').filter(Boolean);
68
72
 
69
- const spinner: Ora = ora(' loading remote repo tree...');
70
- let bar: ProgressBar;
73
+ const spinner: Ora = ora(' loading remote repo tree...');
74
+ let bar: ProgressBar;
71
75
 
72
- try {
73
- await dgit(
74
- {
75
- ref,
76
- owner,
77
- repoName,
78
- relativePath,
79
- username,
80
- password,
81
- token,
82
- proxy,
83
- },
84
- dest,
85
- {
86
- log,
87
- logPrefix,
88
- parallelLimit: Number(parallelLimit.trim()),
89
- exclude : excludeList,
90
- include : includeList,
91
- },
76
+ try {
77
+ await dgit(
78
+ {
79
+ ref,
80
+ owner,
81
+ repoName,
82
+ relativePath,
83
+ username,
84
+ password,
85
+ token,
86
+ proxy,
87
+ },
88
+ dest,
89
+ {
90
+ log,
91
+ logPrefix,
92
+ parallelLimit: Number(parallelLimit.trim()),
93
+ exclude: excludeList,
94
+ include: includeList,
95
+ },
96
+ {
97
+ beforeLoadTree() {
98
+ spinner.start();
99
+ },
100
+ afterLoadTree() {
101
+ spinner.succeed(' load remote repo tree succeed! ');
102
+ },
103
+ onResolved(status) {
104
+ if (log)
105
+ return;
106
+ const green = '\u001B[42m \u001B[0m';
107
+ const red = '\u001B[41m \u001B[0m';
108
+ const index = 0;
109
+ bar = new ProgressBar(
110
+ ' DOWNLOAD |:bar| :current/:total :percent elapsed: :elapseds eta: :eta :file, done.',
92
111
  {
93
- beforeLoadTree () {
94
- spinner.start();
95
- },
96
- afterLoadTree () {
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
- },
112
+ total: status.totalCount,
113
+ width: 50,
114
+ complete: green,
115
+ incomplete: red,
119
116
  },
120
- );
121
- spinner.succeed(' download all files succeed!');
122
- } catch (error) {
123
- console.error(error);
124
- spinner.fail(' download files failed!');
125
- }
126
- };
117
+ );
118
+ bar.update(index);
119
+ },
120
+ onProgress(_, node) {
121
+ if (log)
122
+ return;
123
+ bar.tick({ file: TextEllipsis(node.path, MAX_TEXT_ELLIPSIS) });
124
+ },
125
+ },
126
+ );
127
+ spinner.succeed(' download all files succeed!');
128
+ }
129
+ catch (error) {
130
+ console.error(error);
131
+ spinner.fail(' download files failed!');
132
+ }
133
+ }
127
134
 
128
135
  export default DownloadAction;
package/src/cmd/main.ts CHANGED
@@ -1,70 +1,72 @@
1
- import program from 'commander';
1
+ import type { PackageInfo } from './type';
2
+ import process from 'node:process';
2
3
  import chalk from 'chalk';
3
4
 
4
- import { PackageInfo } from './type';
5
- import { GetPackageInfo } from './utils';
5
+ import { Command } from 'commander';
6
6
  import DownloadAction from './action';
7
+ import { GetPackageInfo } from './utils';
7
8
 
8
9
  const EXIT_CODE = 1;
10
+ const program = new Command();
9
11
 
10
- const Exit = (): void => {
11
- process.exit(EXIT_CODE);
12
- };
12
+ function Exit(): void {
13
+ process.exit(EXIT_CODE);
14
+ }
13
15
 
14
- const UnknownCommand = (cmdName: string): void => {
15
- console.log(`${ chalk.red('Unknown command') } ${ chalk.yellow(cmdName) }.`);
16
- };
16
+ function UnknownCommand(cmdName: string): void {
17
+ console.log(`${chalk.red('Unknown command')} ${chalk.yellow(cmdName)}.`);
18
+ }
17
19
 
18
20
  const packageInfo: PackageInfo = GetPackageInfo();
19
21
 
20
22
  program.version(packageInfo.version);
21
23
 
22
24
  program
23
- .command('download [githubLink]')
24
- .option('--owner <ownerName>', 'git repo author.')
25
- .option('--repo-name <repoName>', 'git repo name.')
26
- .option('--ref <refName>', 'git repo branch, commit hash or tagname.')
27
- .option(
28
- '--relative-path <relativePath>',
29
- 'specified repo relative path to download.',
30
- )
31
- .option('-d, --dest <destPath>', 'specified dest path.')
32
- .option(
33
- '-l, --parallel-limit, <number>',
34
- 'specified download max parallel limit.',
35
- )
36
- .option('-u, --username, <username>', 'specified git account username.')
37
- .option('-p --password, <password>', 'specified git account password.')
38
- .option(
39
- '-t --token, <token>',
40
- 'specified git account personal access token.',
41
- )
42
- .option(
43
- '-e --exclude, <relativePath,...,relativePath>',
44
- 'indicates which file paths need to be excluded in the current directory.',
45
- )
46
- .option(
47
- '-i --include, <relativePath,...,relativePath>',
48
- 'indicates which files need to be included in the exclusion file list.',
49
- )
50
- .option('--log', 'output dgit internal log details.')
51
- .option('--log-prefix, <log>', 'dgit internal log prefix.')
52
- .option('--proxy, <proxyHttp>', 'dgit proxy download url.')
53
- .alias('d')
54
- .description('download the file with the specified path of the remote repo.')
55
- .action(DownloadAction);
25
+ .command('download [githubLink]')
26
+ .option('--owner <ownerName>', 'git repo author.')
27
+ .option('--repo-name <repoName>', 'git repo name.')
28
+ .option('--ref <refName>', 'git repo branch, commit hash or tagname.')
29
+ .option(
30
+ '--relative-path <relativePath>',
31
+ 'specified repo relative path to download.',
32
+ )
33
+ .option('-d, --dest <destPath>', 'specified dest path.')
34
+ .option(
35
+ '-l, --parallel-limit, <number>',
36
+ 'specified download max parallel limit.',
37
+ )
38
+ .option('-u, --username, <username>', 'specified git account username.')
39
+ .option('-p --password, <password>', 'specified git account password.')
40
+ .option(
41
+ '-t --token, <token>',
42
+ 'specified git account personal access token.',
43
+ )
44
+ .option(
45
+ '-e --exclude, <relativePath,...,relativePath>',
46
+ 'indicates which file paths need to be excluded in the current directory.',
47
+ )
48
+ .option(
49
+ '-i --include, <relativePath,...,relativePath>',
50
+ 'indicates which files need to be included in the exclusion file list.',
51
+ )
52
+ .option('--log', 'output dgit internal log details.')
53
+ .option('--log-prefix, <log>', 'dgit internal log prefix.')
54
+ .option('--proxy, <proxyHttp>', 'dgit proxy download url.')
55
+ .alias('d')
56
+ .description('download the file with the specified path of the remote repo.')
57
+ .action(DownloadAction);
56
58
 
57
59
  program.on('command:*', (cmdObj = []) => {
58
- const [ cmd ] = cmdObj;
59
- if (cmd) {
60
- program.outputHelp();
61
- UnknownCommand(cmd);
62
- Exit();
63
- }
60
+ const [cmd] = cmdObj;
61
+ if (cmd) {
62
+ program.outputHelp();
63
+ UnknownCommand(cmd);
64
+ Exit();
65
+ }
64
66
  });
65
67
 
66
68
  if (process.argv.slice(2).length <= 0) {
67
- program.help();
69
+ program.help();
68
70
  }
69
71
 
70
72
  program.parse(process.argv);