@mindbase/mindbase 1.0.0
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/LICENSE +201 -0
- package/bin/gitlog.ts +3 -0
- package/bin/iconfont-editor.ts +3 -0
- package/bin/index.ts +29 -0
- package/bin/nodeclear.ts +3 -0
- package/bin/npmpublish.ts +3 -0
- package/bin/shared.ts +141 -0
- package/package.json +63 -0
- package/scripts/ensure-tsx.cjs +18 -0
- package/src/clear/app.ts +152 -0
- package/src/clear/config.ts +108 -0
- package/src/clear/file-cleaner.ts +137 -0
- package/src/clear/index.ts +28 -0
- package/src/clear/scanner.ts +154 -0
- package/src/gitlog/app.ts +272 -0
- package/src/gitlog/config.ts +91 -0
- package/src/gitlog/display.ts +178 -0
- package/src/gitlog/index.ts +5 -0
- package/src/gitlog/log-fetcher.ts +150 -0
- package/src/gitlog/pager.ts +178 -0
- package/src/gitlog/scanner.ts +60 -0
- package/src/iconfont/frontend/index.html +12 -0
- package/src/iconfont/frontend/src/App.vue +14 -0
- package/src/iconfont/frontend/src/main.ts +8 -0
- package/src/iconfont/frontend/src/views/IconEditor.vue +819 -0
- package/src/iconfont/frontend/vite.config.ts +15 -0
- package/src/iconfont/lib/css-generator.js +37 -0
- package/src/iconfont/lib/font-builder.js +82 -0
- package/src/iconfont/lib/glyph-extractor.js +69 -0
- package/src/iconfont/server/api.js +256 -0
- package/src/iconfont/server/index.js +64 -0
- package/src/index.ts +0 -0
- package/src/publish/app.ts +316 -0
- package/src/publish/builder.ts +120 -0
- package/src/publish/dependency.ts +144 -0
- package/src/publish/detector.ts +93 -0
- package/src/publish/index.ts +66 -0
- package/src/publish/npm-query.ts +244 -0
- package/src/publish/registry/adapters/npm.ts +128 -0
- package/src/publish/registry/registry-manager.ts +107 -0
- package/src/publish/scanner.ts +90 -0
- package/src/publish/types.ts +98 -0
- package/src/publish/version.ts +108 -0
- package/src/shared/config-manager.ts +57 -0
- package/src/shared/index.ts +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/bin/gitlog.ts
ADDED
package/bin/index.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import {
|
|
4
|
+
createGitlogProgram,
|
|
5
|
+
createNodeclearProgram,
|
|
6
|
+
createNpmpublishProgram,
|
|
7
|
+
createIconfontEditorProgram,
|
|
8
|
+
} from './shared.js';
|
|
9
|
+
|
|
10
|
+
const program = new Command();
|
|
11
|
+
program
|
|
12
|
+
.name('mindbase')
|
|
13
|
+
.description('MindBase 开发工具集')
|
|
14
|
+
.version('1.0.0');
|
|
15
|
+
|
|
16
|
+
// 将各独立命令注册为子命令
|
|
17
|
+
const gitlogProgram = createGitlogProgram();
|
|
18
|
+
program.addCommand(gitlogProgram);
|
|
19
|
+
|
|
20
|
+
const nodeclearProgram = createNodeclearProgram();
|
|
21
|
+
program.addCommand(nodeclearProgram);
|
|
22
|
+
|
|
23
|
+
const npmpublishProgram = createNpmpublishProgram();
|
|
24
|
+
program.addCommand(npmpublishProgram);
|
|
25
|
+
|
|
26
|
+
const iconfontProgram = createIconfontEditorProgram();
|
|
27
|
+
program.addCommand(iconfontProgram);
|
|
28
|
+
|
|
29
|
+
program.parse();
|
package/bin/nodeclear.ts
ADDED
package/bin/shared.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import * as clack from '@clack/prompts';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
|
|
5
|
+
// 静态导入子命令模块
|
|
6
|
+
import { runApp as runGitlogApp, showConfig as showGitlogConfig } from '../src/gitlog/app.js';
|
|
7
|
+
import { runApp as runClearApp, showConfig as showClearConfig, doResetConfig, doEditConfig } from '../src/clear/app.js';
|
|
8
|
+
import { runApp as runPublishApp, showConfig as showPublishConfig } from '../src/publish/app.js';
|
|
9
|
+
import { createServer } from '../src/iconfont/server/index.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 创建 gitlog 命令程序
|
|
13
|
+
*/
|
|
14
|
+
export function createGitlogProgram(): Command {
|
|
15
|
+
const program = new Command();
|
|
16
|
+
program
|
|
17
|
+
.name('gitlog')
|
|
18
|
+
.description('Git 日志查看工具')
|
|
19
|
+
.version('2.0.0')
|
|
20
|
+
.argument('[path]', '要扫描的目录路径', '.')
|
|
21
|
+
.action(async (path: string) => {
|
|
22
|
+
clack.intro('gitlog');
|
|
23
|
+
try {
|
|
24
|
+
await runGitlogApp(resolve(path));
|
|
25
|
+
} catch (err) {
|
|
26
|
+
clack.log.error(`执行失败: ${err}`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
clack.outro('再见');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
program
|
|
33
|
+
.command('config')
|
|
34
|
+
.description('筛选条件管理')
|
|
35
|
+
.option('--show', '显示保存的筛选条件')
|
|
36
|
+
.option('--reset', '重置筛选条件')
|
|
37
|
+
.action(async (options: { show?: boolean; reset?: boolean }) => {
|
|
38
|
+
await showGitlogConfig(options);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return program;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 创建 nodeclear 命令程序
|
|
46
|
+
*/
|
|
47
|
+
export function createNodeclearProgram(): Command {
|
|
48
|
+
const program = new Command();
|
|
49
|
+
program
|
|
50
|
+
.name('nodeclear')
|
|
51
|
+
.description('清理 node_modules 和锁文件')
|
|
52
|
+
.version('2.0.0')
|
|
53
|
+
.argument('[path]', '要清理的目录路径', '.')
|
|
54
|
+
.action(async (path: string) => {
|
|
55
|
+
clack.intro('nodeclear');
|
|
56
|
+
try {
|
|
57
|
+
await runClearApp(resolve(path));
|
|
58
|
+
} catch (err) {
|
|
59
|
+
clack.log.error(`执行失败: ${err}`);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
clack.outro('再见');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
program
|
|
66
|
+
.command('config')
|
|
67
|
+
.description('配置管理')
|
|
68
|
+
.option('--show', '显示当前配置')
|
|
69
|
+
.option('--reset', '重置为默认配置')
|
|
70
|
+
.action(async (options: { show?: boolean; reset?: boolean }) => {
|
|
71
|
+
if (options.reset) {
|
|
72
|
+
doResetConfig();
|
|
73
|
+
} else {
|
|
74
|
+
showClearConfig();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
program
|
|
79
|
+
.command('editConfig')
|
|
80
|
+
.description('打开编辑器编辑配置文件')
|
|
81
|
+
.action(async () => {
|
|
82
|
+
doEditConfig();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
return program;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 创建 npmpublish 命令程序
|
|
90
|
+
*/
|
|
91
|
+
export function createNpmpublishProgram(): Command {
|
|
92
|
+
const program = new Command();
|
|
93
|
+
program
|
|
94
|
+
.name('npmpublish')
|
|
95
|
+
.description('NPM 包发布工具')
|
|
96
|
+
.version('2.0.0')
|
|
97
|
+
.argument('[path]', '要发布的目录路径', '.')
|
|
98
|
+
.option('--dry-run', '模拟运行,不实际发布')
|
|
99
|
+
.action(async (path: string, options: { dryRun?: boolean }) => {
|
|
100
|
+
clack.intro('npmpublish');
|
|
101
|
+
try {
|
|
102
|
+
await runPublishApp(resolve(path), { dryRun: options.dryRun });
|
|
103
|
+
} catch (err) {
|
|
104
|
+
clack.log.error(`执行失败: ${err}`);
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
clack.outro('再见');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
program
|
|
111
|
+
.command('config')
|
|
112
|
+
.description('配置管理')
|
|
113
|
+
.option('--show', '显示当前配置')
|
|
114
|
+
.option('--reset', '重置为默认配置')
|
|
115
|
+
.action(async () => {
|
|
116
|
+
await showPublishConfig();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
return program;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 创建 iconfont-editor 命令程序
|
|
124
|
+
*/
|
|
125
|
+
export function createIconfontEditorProgram(): Command {
|
|
126
|
+
const program = new Command();
|
|
127
|
+
program
|
|
128
|
+
.name('iconfont-editor')
|
|
129
|
+
.description('iconfont 图标编辑器')
|
|
130
|
+
.version('1.0.0')
|
|
131
|
+
.option('-d, --dir <path>', '指定 iconfont 目录', process.cwd())
|
|
132
|
+
.option('-p, --port <port>', '指定端口号', '3000')
|
|
133
|
+
.action(async (options: { dir: string; port: string }) => {
|
|
134
|
+
await createServer({
|
|
135
|
+
dir: resolve(options.dir),
|
|
136
|
+
port: parseInt(options.port, 10)
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
return program;
|
|
141
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mindbase/mindbase",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MindBase 开发工具集",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mindbase": "./bin/index.ts",
|
|
8
|
+
"gitlog": "./bin/gitlog.ts",
|
|
9
|
+
"nodeclear": "./bin/nodeclear.ts",
|
|
10
|
+
"npmpublish": "./bin/npmpublish.ts",
|
|
11
|
+
"iconfont-editor": "./bin/iconfont-editor.ts"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"bin",
|
|
15
|
+
"src",
|
|
16
|
+
"scripts"
|
|
17
|
+
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=20.0.0"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@clack/prompts": "^1.2.0",
|
|
26
|
+
"commander": "^12.0.0",
|
|
27
|
+
"dayjs": "^1.11.20",
|
|
28
|
+
"express": "^4.21.0",
|
|
29
|
+
"multer": "^1.4.5-lts.1",
|
|
30
|
+
"opentype.js": "^1.3.4",
|
|
31
|
+
"picocolors": "^1.1.1",
|
|
32
|
+
"subset-font": "^2.4.0",
|
|
33
|
+
"svg2ttf": "^6.0.3",
|
|
34
|
+
"svgicons2svgfont": "^12.0.0",
|
|
35
|
+
"svgo": "^3.3.2",
|
|
36
|
+
"open": "^10.1.0",
|
|
37
|
+
"editor": "^1.0.0",
|
|
38
|
+
"fs-extra": "^11.1.1",
|
|
39
|
+
"glob": "^13.0.2",
|
|
40
|
+
"semver": "^7.7.4",
|
|
41
|
+
"simple-git": "^3.20.0",
|
|
42
|
+
"tsx": "^4.19.0",
|
|
43
|
+
"@mindbase/deploy": "1.0.1",
|
|
44
|
+
"@mindbase/cli-ui": "1.0.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/fs-extra": "^11.0.4",
|
|
48
|
+
"@types/node": "^20.0.0",
|
|
49
|
+
"@types/semver": "^7.7.1",
|
|
50
|
+
"@vitejs/plugin-vue": "^5.2.0",
|
|
51
|
+
"element-plus": "^2.9.0",
|
|
52
|
+
"typescript": "^5.1.3",
|
|
53
|
+
"vite": "^6.0.0",
|
|
54
|
+
"vue": "^3.5.0"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"dev": "tsx bin/index.ts",
|
|
58
|
+
"start": "tsx bin/index.ts",
|
|
59
|
+
"test": "tsx src/test.ts",
|
|
60
|
+
"build:iconfont-frontend": "cd src/iconfont/frontend && npx vite build",
|
|
61
|
+
"postinstall": "node scripts/ensure-tsx.cjs"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
|
|
3
|
+
// 跳过检查(用于 CI/CD)
|
|
4
|
+
if (process.env.MINDBASE_SKIP_TSX_CHECK) {
|
|
5
|
+
process.exit(0);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
execSync('tsx --version', { stdio: 'pipe' });
|
|
10
|
+
} catch (err) {
|
|
11
|
+
console.log('\n📦 未检测到 tsx,正在全局安装...\n');
|
|
12
|
+
try {
|
|
13
|
+
execSync('npm install -g tsx', { stdio: 'inherit' });
|
|
14
|
+
} catch (installErr) {
|
|
15
|
+
console.error('\n❌ 安装失败,请手动执行:npm install -g tsx\n');
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/clear/app.ts
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import * as clack from "@clack/prompts";
|
|
2
|
+
import { noteBox } from "@mindbase/cli-ui";
|
|
3
|
+
import { resolve } from "path";
|
|
4
|
+
import {
|
|
5
|
+
scan,
|
|
6
|
+
cleanAsync,
|
|
7
|
+
formatSize,
|
|
8
|
+
getConfig,
|
|
9
|
+
setConfig,
|
|
10
|
+
resetConfig,
|
|
11
|
+
getConfigForDisplay,
|
|
12
|
+
editConfig,
|
|
13
|
+
type ScanItem,
|
|
14
|
+
type CleanConfig,
|
|
15
|
+
} from "./index.js";
|
|
16
|
+
|
|
17
|
+
/** 统一取消处理 */
|
|
18
|
+
function handleCancel<T>(result: T | symbol): T {
|
|
19
|
+
if (clack.isCancel(result)) {
|
|
20
|
+
clack.cancel("操作已取消");
|
|
21
|
+
process.exit(0);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 运行 nodeclear 主流程
|
|
28
|
+
*/
|
|
29
|
+
export async function runApp(scanPath: string): Promise<void> {
|
|
30
|
+
const config = getConfig();
|
|
31
|
+
|
|
32
|
+
// 扫描(带进度)
|
|
33
|
+
const s = clack.spinner();
|
|
34
|
+
s.start(`扫描目录: ${scanPath}`);
|
|
35
|
+
const items = scan(scanPath, config);
|
|
36
|
+
s.stop(`找到 ${items.length} 个可清理项目`);
|
|
37
|
+
|
|
38
|
+
if (items.length === 0) {
|
|
39
|
+
clack.log.success("目录很干净,无需清理");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const selected = handleCancel(
|
|
44
|
+
await clack.multiselect({
|
|
45
|
+
message: "选择要清理的项目(空格切换,a 全选)",
|
|
46
|
+
options: [
|
|
47
|
+
...items.map((i) => ({
|
|
48
|
+
value: i.path,
|
|
49
|
+
label: `${i.type === "dir" ? "📁" : "📄"} ${i.relativePath}`,
|
|
50
|
+
hint: "←",
|
|
51
|
+
})),
|
|
52
|
+
],
|
|
53
|
+
required: true,
|
|
54
|
+
})
|
|
55
|
+
) as string[];
|
|
56
|
+
|
|
57
|
+
// 处理全选
|
|
58
|
+
const toClean = items.filter((i) => selected.includes(i.path));
|
|
59
|
+
const cleanSize = toClean.reduce((sum, i) => sum + (i.size || 0), 0);
|
|
60
|
+
|
|
61
|
+
// 确认
|
|
62
|
+
const confirmed = handleCancel(
|
|
63
|
+
await clack.confirm({
|
|
64
|
+
message: `确认清理 ${toClean.length} 个项目 (${formatSize(cleanSize)})?`,
|
|
65
|
+
})
|
|
66
|
+
) as boolean;
|
|
67
|
+
|
|
68
|
+
if (!confirmed) {
|
|
69
|
+
clack.log.info("已取消");
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const s2 = clack.spinner();
|
|
74
|
+
s2.start("清理中...");
|
|
75
|
+
const stats = await cleanAsync(toClean);
|
|
76
|
+
s2.stop(`清理完成: 成功 ${stats.success},失败 ${stats.failed}`);
|
|
77
|
+
|
|
78
|
+
// 结果汇总
|
|
79
|
+
if (stats.failed > 0) {
|
|
80
|
+
const failures = stats.details
|
|
81
|
+
.filter((d) => d.status === "failed")
|
|
82
|
+
.map((d) => `✗ ${d.relativePath}: ${d.error?.message || "未知错误"}`)
|
|
83
|
+
.join("\n");
|
|
84
|
+
noteBox(failures, "失败项");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 显示配置
|
|
90
|
+
*/
|
|
91
|
+
export function showConfig(): void {
|
|
92
|
+
const display = getConfigForDisplay();
|
|
93
|
+
noteBox(display, "当前配置");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 重置配置
|
|
98
|
+
*/
|
|
99
|
+
export function doResetConfig(): void {
|
|
100
|
+
resetConfig();
|
|
101
|
+
clack.log.success("配置已重置为默认值");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 编辑配置
|
|
106
|
+
*/
|
|
107
|
+
export function doEditConfig(): void {
|
|
108
|
+
clack.log.info("正在打开编辑器...");
|
|
109
|
+
editConfig((success) => {
|
|
110
|
+
if (success) {
|
|
111
|
+
clack.log.success("配置已保存");
|
|
112
|
+
} else {
|
|
113
|
+
clack.log.warn("编辑器退出异常");
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 交互式选择子命令(不带子命令时)
|
|
120
|
+
*/
|
|
121
|
+
export async function interactiveMenu(): Promise<void> {
|
|
122
|
+
const action = handleCancel(
|
|
123
|
+
await clack.select({
|
|
124
|
+
message: "选择操作",
|
|
125
|
+
options: [
|
|
126
|
+
{ value: "clean", label: "清理 node_modules", hint: "扫描并清理" },
|
|
127
|
+
{ value: "config", label: "查看配置", hint: "显示当前配置" },
|
|
128
|
+
{ value: "reset", label: "重置配置", hint: "恢复默认配置" },
|
|
129
|
+
{ value: "edit", label: "编辑配置", hint: "用编辑器打开" },
|
|
130
|
+
{ value: "quit", label: "退出" },
|
|
131
|
+
],
|
|
132
|
+
})
|
|
133
|
+
) as string;
|
|
134
|
+
|
|
135
|
+
switch (action) {
|
|
136
|
+
case "clean": {
|
|
137
|
+
await runApp(resolve("."));
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case "config":
|
|
141
|
+
showConfig();
|
|
142
|
+
break;
|
|
143
|
+
case "reset":
|
|
144
|
+
doResetConfig();
|
|
145
|
+
break;
|
|
146
|
+
case "edit":
|
|
147
|
+
doEditConfig();
|
|
148
|
+
break;
|
|
149
|
+
case "quit":
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|