@bratel/dgit 0.0.14 → 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/lib/cmd/action.js +3 -1
- package/lib/cmd/main.js +1 -0
- package/lib/cmd/type.d.ts +1 -0
- package/lib/dgit.js +11 -2
- package/lib/repo.d.ts +1 -1
- package/lib/type.d.ts +1 -0
- package/package.json +11 -1
- package/src/cmd/action.ts +2 -0
- package/src/cmd/main.ts +1 -0
- package/src/cmd/type.ts +1 -0
- package/src/dgit.ts +11 -2
- package/src/repo.ts +1 -1
- package/src/type.ts +1 -0
- package/tsconfig.json +4 -1
package/lib/cmd/action.js
CHANGED
|
@@ -10,7 +10,8 @@ const MAX_TEXT_ELLIPSIS = 30;
|
|
|
10
10
|
function DownloadAction(githubLink, cmd) {
|
|
11
11
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
12
|
let { ref = '', dest = '', owner = '', repoName = '', relativePath = '', password, } = cmd;
|
|
13
|
-
const { exclude = '', include = '', log = false, logPrefix = '[dgit-logger]',
|
|
13
|
+
const { exclude = '', include = '', log = false, logPrefix = '[dgit-logger]', exactMatch = false, // 是否精确匹配
|
|
14
|
+
} = cmd;
|
|
14
15
|
const { parallelLimit = '', username, token, } = cmd;
|
|
15
16
|
const { proxy = '', } = cmd;
|
|
16
17
|
if (githubLink && (0, utils_1.isHttpsLink)(githubLink)) {
|
|
@@ -56,6 +57,7 @@ function DownloadAction(githubLink, cmd) {
|
|
|
56
57
|
parallelLimit: Number(parallelLimit.trim()),
|
|
57
58
|
exclude: excludeList,
|
|
58
59
|
include: includeList,
|
|
60
|
+
exactMatch,
|
|
59
61
|
}, {
|
|
60
62
|
beforeLoadTree() {
|
|
61
63
|
spinner.start();
|
package/lib/cmd/main.js
CHANGED
|
@@ -29,6 +29,7 @@ program
|
|
|
29
29
|
.option('-t --token, <token>', 'specified git account personal access token.')
|
|
30
30
|
.option('-e --exclude, <relativePath,...,relativePath>', 'indicates which file paths need to be excluded in the current directory.')
|
|
31
31
|
.option('-i --include, <relativePath,...,relativePath>', 'indicates which files need to be included in the exclusion file list.')
|
|
32
|
+
.option('--exact-match', 'enable exact path matching instead of prefix matching.')
|
|
32
33
|
.option('--log', 'output dgit internal log details.')
|
|
33
34
|
.option('--log-prefix, <log>', 'dgit internal log prefix.')
|
|
34
35
|
.option('--proxy, <proxyHttp>', 'dgit proxy download url.')
|
package/lib/cmd/type.d.ts
CHANGED
package/lib/dgit.js
CHANGED
|
@@ -13,6 +13,7 @@ const UserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
|
|
|
13
13
|
const DEFAULT_PARALLEL_LIMIT = 10;
|
|
14
14
|
const MAX_PARALLEL_LIMIT = 100;
|
|
15
15
|
const JSON_STRINGIFY_PADDING = 2;
|
|
16
|
+
// https://deepwiki.com/search/python-node-treepythonjula-pyt_e06e7d62-6a9a-4d4b-9e74-0a1cf32f4946?mode=fast
|
|
16
17
|
function dgit(repoOption, dPath, dgitOptions, hooks) {
|
|
17
18
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
19
|
const { username, password, token, githubLink, proxy = '', } = repoOption;
|
|
@@ -28,7 +29,7 @@ function dgit(repoOption, dPath, dgitOptions, hooks) {
|
|
|
28
29
|
throw new Error('invalid repo option.');
|
|
29
30
|
}
|
|
30
31
|
const logger = (0, log_1.createLogger)(dgitOptions);
|
|
31
|
-
const { exclude = [], include = [] } = dgitOptions || {};
|
|
32
|
+
const { exclude = [], include = [], exactMatch = false } = dgitOptions || {};
|
|
32
33
|
let { parallelLimit = DEFAULT_PARALLEL_LIMIT } = dgitOptions || {};
|
|
33
34
|
if (!parallelLimit || parallelLimit <= 0) {
|
|
34
35
|
logger('parallelLimit value is invalid.');
|
|
@@ -82,7 +83,15 @@ function dgit(repoOption, dPath, dgitOptions, hooks) {
|
|
|
82
83
|
const includeTreeNodeList = treeNodeList.filter((node) => {
|
|
83
84
|
const nPath = node_path_1.default.resolve(__dirname, node.path);
|
|
84
85
|
const rPath = node_path_1.default.resolve(__dirname, relativePath);
|
|
85
|
-
|
|
86
|
+
let pathMatch;
|
|
87
|
+
if (exactMatch) {
|
|
88
|
+
// 精确匹配:路径完全相等或者路径后跟分隔符
|
|
89
|
+
pathMatch = nPath === rPath || nPath.startsWith(rPath + node_path_1.default.sep) || nPath.startsWith(`${rPath}/`);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
pathMatch = nPath.startsWith(rPath);
|
|
93
|
+
}
|
|
94
|
+
if (!pathMatch || node.type !== 'blob') {
|
|
86
95
|
return false;
|
|
87
96
|
}
|
|
88
97
|
if (exclude.some(v => nPath.startsWith(node_path_1.default.resolve(rPath, v)))
|
package/lib/repo.d.ts
CHANGED
package/lib/type.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -59,6 +59,16 @@
|
|
|
59
59
|
"ts-node": "^10.9.2",
|
|
60
60
|
"typescript": "^5.9.3"
|
|
61
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"
|
|
71
|
+
},
|
|
62
72
|
"husky": {
|
|
63
73
|
"hooks": {
|
|
64
74
|
"pre-commit": "lint-staged"
|
package/src/cmd/action.ts
CHANGED
|
@@ -29,6 +29,7 @@ async function DownloadAction(githubLink: string | undefined, cmd: Command & Com
|
|
|
29
29
|
include = '',
|
|
30
30
|
log = false,
|
|
31
31
|
logPrefix = '[dgit-logger]',
|
|
32
|
+
exactMatch = false, // 是否精确匹配
|
|
32
33
|
} = cmd;
|
|
33
34
|
|
|
34
35
|
const {
|
|
@@ -92,6 +93,7 @@ async function DownloadAction(githubLink: string | undefined, cmd: Command & Com
|
|
|
92
93
|
parallelLimit: Number(parallelLimit.trim()),
|
|
93
94
|
exclude: excludeList,
|
|
94
95
|
include: includeList,
|
|
96
|
+
exactMatch,
|
|
95
97
|
},
|
|
96
98
|
{
|
|
97
99
|
beforeLoadTree() {
|
package/src/cmd/main.ts
CHANGED
|
@@ -49,6 +49,7 @@ program
|
|
|
49
49
|
'-i --include, <relativePath,...,relativePath>',
|
|
50
50
|
'indicates which files need to be included in the exclusion file list.',
|
|
51
51
|
)
|
|
52
|
+
.option('--exact-match', 'enable exact path matching instead of prefix matching.')
|
|
52
53
|
.option('--log', 'output dgit internal log details.')
|
|
53
54
|
.option('--log-prefix, <log>', 'dgit internal log prefix.')
|
|
54
55
|
.option('--proxy, <proxyHttp>', 'dgit proxy download url.')
|
package/src/cmd/type.ts
CHANGED
package/src/dgit.ts
CHANGED
|
@@ -23,6 +23,7 @@ const DEFAULT_PARALLEL_LIMIT = 10;
|
|
|
23
23
|
const MAX_PARALLEL_LIMIT = 100;
|
|
24
24
|
const JSON_STRINGIFY_PADDING = 2;
|
|
25
25
|
|
|
26
|
+
// https://deepwiki.com/search/python-node-treepythonjula-pyt_e06e7d62-6a9a-4d4b-9e74-0a1cf32f4946?mode=fast
|
|
26
27
|
async function dgit(repoOption: RepoOptionType, dPath: string, dgitOptions?: DgitGlobalOption, hooks?: DgitLifeCycle & DgitLoadGitTree): Promise<void> {
|
|
27
28
|
const {
|
|
28
29
|
username,
|
|
@@ -53,7 +54,7 @@ async function dgit(repoOption: RepoOptionType, dPath: string, dgitOptions?: Dgi
|
|
|
53
54
|
|
|
54
55
|
const logger = createLogger(dgitOptions);
|
|
55
56
|
|
|
56
|
-
const { exclude = [], include = [] } = dgitOptions || {};
|
|
57
|
+
const { exclude = [], include = [], exactMatch = false } = dgitOptions || {};
|
|
57
58
|
|
|
58
59
|
let { parallelLimit = DEFAULT_PARALLEL_LIMIT } = dgitOptions || {};
|
|
59
60
|
if (!parallelLimit || parallelLimit <= 0) {
|
|
@@ -131,7 +132,15 @@ async function dgit(repoOption: RepoOptionType, dPath: string, dgitOptions?: Dgi
|
|
|
131
132
|
const includeTreeNodeList = treeNodeList.filter((node) => {
|
|
132
133
|
const nPath = path.resolve(__dirname, node.path);
|
|
133
134
|
const rPath = path.resolve(__dirname, relativePath);
|
|
134
|
-
|
|
135
|
+
let pathMatch: boolean;
|
|
136
|
+
if (exactMatch) {
|
|
137
|
+
// 精确匹配:路径完全相等或者路径后跟分隔符
|
|
138
|
+
pathMatch = nPath === rPath || nPath.startsWith(rPath + path.sep) || nPath.startsWith(`${rPath}/`);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
pathMatch = nPath.startsWith(rPath);
|
|
142
|
+
}
|
|
143
|
+
if (!pathMatch || node.type !== 'blob') {
|
|
135
144
|
return false;
|
|
136
145
|
}
|
|
137
146
|
if (
|
package/src/repo.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function repoUtils(owner: string, repoName: string, ref: string, proxy: string) {
|
|
1
|
+
function repoUtils(owner: string, repoName: string, ref: string, proxy: string | null) {
|
|
2
2
|
return {
|
|
3
3
|
getRepoTreeUrl: () => `https://api.github.com/repos/${owner}/${repoName}/git/trees/${ref}?recursive=1`,
|
|
4
4
|
getDownloadUrl: (path: string) => `${proxy ? `${proxy}/` : ''}https://raw.githubusercontent.com/${owner}/${repoName}/${ref}/${path}`,
|
package/src/type.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
/* Basic Options */
|
|
4
4
|
// "incremental": true, /* Enable incremental compilation */
|
|
5
|
-
"target": "
|
|
5
|
+
"target": "ES2016", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
|
6
6
|
|
|
7
7
|
"emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
8
8
|
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
@@ -65,6 +65,9 @@
|
|
|
65
65
|
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
66
66
|
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
67
67
|
},
|
|
68
|
+
"ts-node": {
|
|
69
|
+
"files": true
|
|
70
|
+
},
|
|
68
71
|
"include": [
|
|
69
72
|
"src/**/*"
|
|
70
73
|
],
|