Skip to content

Commit efd0e4e

Browse files
committed
feat: limu-x
1 parent 1a3f4e9 commit efd0e4e

File tree

8 files changed

+38
-34
lines changed

8 files changed

+38
-34
lines changed

README.en_US.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
99
[npm-image]: https://img.shields.io/npm/v/:packageName.svg?style=flat-square
1010
[npm-url]: https://npmjs.org/package/:packageName
11-
[travis-image]: https://www.travis-ci.org/JohnApache/:packageName.svg
12-
[travis-url]: https://travis-ci.org/JohnApache/:packageName
13-
[codecov-image]: https://codecov.io/gh/JohnApache/:packageName/branch/master/graph/badge.svg
14-
[codecov-url]: https://codecov.io/gh/JohnApache/:packageName
15-
[snyk-image]: https://snyk.io/test/github/JohnApache/:packageName/badge.svg?targetFile=package.json
16-
[snyk-url]: https://snyk.io/test/github/JohnApache/:packageName?targetFile=package.json
11+
[travis-image]: https://www.travis-ci.org/xlei1123/:packageName.svg
12+
[travis-url]: https://travis-ci.org/xlei1123/:packageName
13+
[codecov-image]: https://codecov.io/gh/xlei1123/:packageName/branch/master/graph/badge.svg
14+
[codecov-url]: https://codecov.io/gh/xlei1123/:packageName
15+
[snyk-image]: https://snyk.io/test/github/xlei1123/:packageName/badge.svg?targetFile=package.json
16+
[snyk-url]: https://snyk.io/test/github/xlei1123/:packageName?targetFile=package.json
1717
[download-image]: https://img.shields.io/npm/dm/:packageName.svg?style=flat-square
1818
[download-url]: https://npmjs.org/package/:packageName -->
1919

@@ -33,29 +33,29 @@
3333
## Install
3434
+ Global Installation
3535
```bash
36-
$ npm install @limu/dgit -g
36+
$ npm install @limu-x/dgit -g
3737
```
3838
+ Local Installation
3939
```bash
40-
$ npm install @limu/dgit --save
41-
$ yarn add @limu/dgit
40+
$ npm install @limu-x/dgit --save
41+
$ yarn add @limu-x/dgit
4242
```
4343

4444
## Usage
4545
+ Global installation, using as command line
4646
```bash
47-
$ dgit d https://github.com/JohnApache/hasaki-cli/tree/master/src -d ./abc
47+
$ dgit d https://github.com/xlei1123/limu-ele-pro/tree/master/src -d ./abc
4848
```
4949

5050
+ Local installation as module
5151
```js
52-
import dgit from '@limu/dgit';
52+
import dgit from '@limu-x/dgit';
5353

5454
(async () => {
5555
await dgit(
5656
{
57-
owner: 'JohnApache',
58-
repoName: 'hasaki-cli',
57+
owner: 'xlei1123',
58+
repoName: 'limu-ele-pro',
5959
ref: 'master',
6060
relativePath: 'src',
6161
},
@@ -86,11 +86,11 @@ import dgit from '@limu/dgit';
8686

8787
+ Local installation, configurable parameters when used as a module
8888
```js
89-
import dgit from '@limu/dgit';
89+
import dgit from '@limu-x/dgit';
9090
import path from 'path';
9191
const repoOption = {
92-
owner: 'JohnApache'; // Git repository author name
93-
repoName: 'hasaki-cli'; // Git repo name
92+
owner: 'xlei1123'; // Git repository author name
93+
repoName: 'limu-ele-pro'; // Git repo name
9494
ref: 'master'; // Git repo branch,commit hash or tagname,
9595
relativePath: '.'; // Specifies the relative location of the directory or file that git needs to download
9696
username: ''; // Specify git account name.
@@ -99,7 +99,7 @@ import dgit from '@limu/dgit';
9999
}
100100

101101
const githubLinkOption = {
102-
githubLink: 'https://github.com/JohnApache/hasaki-cli/blob/master/PLAN.txt',
102+
githubLink: 'https://github.com/xlei1123/limu-ele-pro/blob/master/package.json',
103103
// You can also directly specify the download path address of gitHub
104104
}
105105

@@ -147,7 +147,7 @@ When downloading the private repo, you need to provide download permission. At t
147147

148148
Download permission is provided by passing in user name and password. When passing in user name, password can not be provided explicitly. When password is not provided, password input option will appear password prompt;
149149
```bash
150-
$ dgit d https://github.com/JohnApache/hasaki-cli/tree/master/src -d ./abc -u JohnApache
150+
$ dgit d https://github.com/xlei1123/limu-ele-pro/tree/master/src -d ./abc -u xlei1123
151151
```
152152
+ OAuth2 token
153153

@@ -156,11 +156,11 @@ When downloading the private repo, you need to provide download permission. At t
156156
Set the token method, which is located in Github Settings -> Developer settings -> Personal access tokens
157157

158158
```bash
159-
$ dgit d https://github.com/JohnApache/hasaki-cli/tree/master/src -d ./abc -t OAUTH-TOKEN
159+
$ dgit d https://github.com/xlei1123/limu-ele-pro/tree/master/src -d ./abc -t OAUTH-TOKEN
160160
```
161161

162162
## Questions
163-
Please open an issue [here](https://github.com/JohnApache/dgit/issues).
163+
Please open an issue [here](https://github.com/xlei1123/dgit/issues).
164164

165165
## License
166166

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
## 安装
3434
+ 全局安装
3535
```bash
36-
$ npm install @limu/dgit -g
36+
$ npm install @limu-x/dgit -g
3737
```
3838
+ 本地安装
3939
```bash
40-
$ npm install @limu/dgit --save
41-
$ yarn add @limu/dgit
40+
$ npm install @limu-x/dgit --save
41+
$ yarn add @limu-x/dgit
4242
```
4343

4444
## 使用
@@ -51,7 +51,7 @@ $ dgit d https://github.com/xlei1123/limu-ele-pro/tree/master/src -d ./abc
5151

5252
+ 本地安装,作为模块使用
5353
```js
54-
import dgit from '@limu/dgit';
54+
import dgit from '@limu-x/dgit';
5555

5656
(async () => {
5757
await dgit(
@@ -88,7 +88,7 @@ import dgit from '@limu/dgit';
8888

8989
+ 局部安装,作为模块使用时,可配置参数
9090
```js
91-
import dgit from '@limu/dgit';
91+
import dgit from '@limu-x/dgit';
9292
import path from 'path';
9393
const repoOption = {
9494
owner: 'xlei1123'; // git 仓库作者名

lib/dgit.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const dgit = (repoOption, dPath, dgitOptions, hooks) => tslib_1.__awaiter(void 0
4141
onErrorReject = reject;
4242
});
4343
const repo = gitType === 'gitee' ? repo_1.giteeRepoUtils : repo_1.githubRepoUtils;
44-
const { getRepoTreeUrl, getDownloadUrl } = repo(owner, repoName, ref);
44+
const { getRepoTreeUrl, getDownloadUrl } = repo(owner, repoName, ref, token);
4545
const url = getRepoTreeUrl();
4646
const headers = {
4747
'User-Agent': UserAgent,
@@ -71,7 +71,6 @@ const dgit = (repoOption, dPath, dgitOptions, hooks) => tslib_1.__awaiter(void 0
7171
});
7272
logger(' loading remote repo tree succeed.');
7373
afterLoadTree && afterLoadTree();
74-
console.log(body, 1111);
7574
const result = JSON.parse(body);
7675
if (!result.tree || result.tree.length <= 0) {
7776
throw new Error('404 repo not found!');

lib/repo.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
declare const giteeRepoUtils: (owner: string, repoName: string, ref: string) => {
1+
declare const giteeRepoUtils: (owner: string, repoName: string, ref: string, token?: string | undefined) => {
22
getRepoTreeUrl: () => string;
33
getDownloadUrl: (path: string) => string;
44
};

lib/repo.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
33
exports.giteeRepoUtils = exports.githubRepoUtils = void 0;
4-
const giteeRepoUtils = (owner, repoName, ref) => ({
5-
getRepoTreeUrl: () => `https://gitee.com/api/v5/repos/${owner}/${repoName}/git/trees/${ref}?recursive=1`,
4+
const giteeRepoUtils = (owner, repoName, ref, token) => ({
5+
getRepoTreeUrl: () => {
6+
if (token) {
7+
return `https://gitee.com/api/v5/repos/${owner}/${repoName}/git/trees/${ref}?recursive=1&access_token=${token}`;
8+
}
9+
return `https://gitee.com/api/v5/repos/${owner}/${repoName}/git/trees/${ref}?recursive=1`;
10+
},
611
getDownloadUrl: (path) => `https://gitee.com/${owner}/${repoName}/raw/${ref}/${path}`,
712
});
813
exports.giteeRepoUtils = giteeRepoUtils;

lib/type.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface RepoOptionType extends PrivateOption {
2020
relativePath?: string;
2121
gitLink?: string;
2222
gitType: GitType;
23+
token?: string;
2324
}
2425
export interface RepoTreeNode {
2526
path: string;

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "@limu/dgit",
2+
"name": "@limu-x/dgit",
33
"version": "0.0.12",
4-
"description": "@limu/dgit download gitrepo file",
4+
"description": "@limu-x/dgit download gitrepo file",
55
"bin": {
66
"dgit": "./bin/cmd.js"
77
},

src/dgit.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
ParseGitHttpsLink, isHttpsLink, MakeDirs,
1616
} from './cmd/utils';
1717

18-
const UserAgent = '@limu/dgit';
18+
const UserAgent = '@limu-x/dgit';
1919
const DEFAULT_PARALLEL_LIMIT = 10;
2020
const MAX_PARALLEL_LIMIT = 100;
2121
const JSON_STRINGIFY_PADDING = 2;
@@ -113,7 +113,6 @@ const dgit = async (
113113

114114
logger(' loading remote repo tree succeed.');
115115
afterLoadTree && afterLoadTree();
116-
console.log(body, 1111);
117116
const result = JSON.parse(body);
118117

119118
if (!result.tree || result.tree.length <= 0) {

0 commit comments

Comments
 (0)