@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
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 工作空间类型
|
|
3
|
+
*/
|
|
4
|
+
export type WorkspaceType = 'single' | 'workspace' | 'monorepo';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 工作空间信息
|
|
8
|
+
*/
|
|
9
|
+
export interface Workspace {
|
|
10
|
+
/** 工作空间类型 */
|
|
11
|
+
type: WorkspaceType;
|
|
12
|
+
/** 根目录路径 */
|
|
13
|
+
rootPath: string;
|
|
14
|
+
/** 扫描模式 */
|
|
15
|
+
patterns: string[];
|
|
16
|
+
/** 是否是 npm workspace */
|
|
17
|
+
isNpmWorkspace: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 包信息
|
|
22
|
+
*/
|
|
23
|
+
export interface Package {
|
|
24
|
+
/** 包名 */
|
|
25
|
+
name: string;
|
|
26
|
+
/** 包路径 */
|
|
27
|
+
path: string;
|
|
28
|
+
/** 相对路径 */
|
|
29
|
+
relativePath: string;
|
|
30
|
+
/** 当前版本 */
|
|
31
|
+
version: string;
|
|
32
|
+
/** 私有包 */
|
|
33
|
+
private: boolean;
|
|
34
|
+
/** 描述 */
|
|
35
|
+
description?: string;
|
|
36
|
+
/** 是否有构建脚本 */
|
|
37
|
+
hasBuildScript: boolean;
|
|
38
|
+
/** 依赖项 */
|
|
39
|
+
dependencies: string[];
|
|
40
|
+
/** 开发依赖项 */
|
|
41
|
+
devDependencies: string[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 依赖分析结果
|
|
46
|
+
*/
|
|
47
|
+
export interface DependencyAnalysis {
|
|
48
|
+
/** 发布顺序(按依赖关系排序) */
|
|
49
|
+
order: Package[];
|
|
50
|
+
/** 依赖图 */
|
|
51
|
+
graph: Map<string, Set<string>>;
|
|
52
|
+
/** 是否有循环依赖 */
|
|
53
|
+
hasCycle: boolean;
|
|
54
|
+
/** 循环依赖链 */
|
|
55
|
+
cycles: string[][];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 发布进度
|
|
60
|
+
*/
|
|
61
|
+
export interface PublishProgress {
|
|
62
|
+
/** 总数 */
|
|
63
|
+
total: number;
|
|
64
|
+
/** 当前包 */
|
|
65
|
+
currentPackage: string;
|
|
66
|
+
/** 已发布 */
|
|
67
|
+
published: string[];
|
|
68
|
+
/** 失败 */
|
|
69
|
+
failed: Array<{ name: string; error: string }>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 发布选项
|
|
74
|
+
*/
|
|
75
|
+
export interface PublishOptions {
|
|
76
|
+
/** 注册源 ID */
|
|
77
|
+
registryId?: string;
|
|
78
|
+
/** 是否模拟运行 */
|
|
79
|
+
dryRun?: boolean;
|
|
80
|
+
/** 是否跳过构建 */
|
|
81
|
+
skipBuild?: boolean;
|
|
82
|
+
/** 是否跳过 Git 检查 */
|
|
83
|
+
skipGitCheck?: boolean;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 发布结果
|
|
88
|
+
*/
|
|
89
|
+
export interface PublishResult {
|
|
90
|
+
/** 成功数量 */
|
|
91
|
+
success: number;
|
|
92
|
+
/** 失败数量 */
|
|
93
|
+
failed: number;
|
|
94
|
+
/** 已发布的包 */
|
|
95
|
+
published: string[];
|
|
96
|
+
/** 失败的包 */
|
|
97
|
+
failures: Array<{ name: string; error: string }>;
|
|
98
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import fsExtra from 'fs-extra';
|
|
2
|
+
const { readJsonSync, writeJsonSync } = fsExtra;
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import semver from 'semver';
|
|
5
|
+
import type { Package } from './types.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 版本递增类型
|
|
9
|
+
*/
|
|
10
|
+
export type BumpType = 'major' | 'minor' | 'patch' | 'premajor' | 'preminor' | 'prepatch' | 'prerelease';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 递增包版本
|
|
14
|
+
*/
|
|
15
|
+
export function bumpVersion(pkg: Package, bumpType: BumpType, preId?: string): string {
|
|
16
|
+
const currentVersion = pkg.version;
|
|
17
|
+
|
|
18
|
+
if (!semver.valid(currentVersion)) {
|
|
19
|
+
throw new Error(`无效的版本号: ${currentVersion}`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const newVersion = semver.inc(currentVersion, bumpType, preId);
|
|
23
|
+
|
|
24
|
+
if (!newVersion) {
|
|
25
|
+
throw new Error(`无法递增版本: ${currentVersion} (${bumpType})`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return newVersion;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 批量递增版本
|
|
33
|
+
*/
|
|
34
|
+
export function bumpVersions(
|
|
35
|
+
packages: Package[],
|
|
36
|
+
bumpType: BumpType,
|
|
37
|
+
preId?: string
|
|
38
|
+
): Map<Package, string> {
|
|
39
|
+
const result = new Map<Package, string>();
|
|
40
|
+
|
|
41
|
+
for (const pkg of packages) {
|
|
42
|
+
const newVersion = bumpVersion(pkg, bumpType, preId);
|
|
43
|
+
result.set(pkg, newVersion);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 更新 package.json 中的版本号
|
|
51
|
+
*/
|
|
52
|
+
export function updatePackageVersion(pkg: Package, newVersion: string): void {
|
|
53
|
+
const packageJsonPath = join(pkg.path, 'package.json');
|
|
54
|
+
|
|
55
|
+
const packageJson = readJsonSync(packageJsonPath);
|
|
56
|
+
packageJson.version = newVersion;
|
|
57
|
+
|
|
58
|
+
writeJsonSync(packageJsonPath, packageJson, { spaces: 2 });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 应用版本变更
|
|
63
|
+
*/
|
|
64
|
+
export function applyVersionChanges(
|
|
65
|
+
versionChanges: Map<Package, string>
|
|
66
|
+
): void {
|
|
67
|
+
for (const [pkg, newVersion] of versionChanges) {
|
|
68
|
+
updatePackageVersion(pkg, newVersion);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 获取建议的版本递增类型
|
|
74
|
+
*/
|
|
75
|
+
export function suggestBumpType(
|
|
76
|
+
currentVersion: string,
|
|
77
|
+
hasBreakingChanges: boolean,
|
|
78
|
+
hasNewFeatures: boolean
|
|
79
|
+
): BumpType {
|
|
80
|
+
if (hasBreakingChanges) {
|
|
81
|
+
return 'major';
|
|
82
|
+
} else if (hasNewFeatures) {
|
|
83
|
+
return 'minor';
|
|
84
|
+
} else {
|
|
85
|
+
return 'patch';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 解析版本字符串
|
|
91
|
+
*/
|
|
92
|
+
export function parseVersion(version: string): semver.SemVer | null {
|
|
93
|
+
return semver.parse(version);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 比较版本
|
|
98
|
+
*/
|
|
99
|
+
export function compareVersions(v1: string, v2: string): number {
|
|
100
|
+
return semver.compare(v1, v2);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 检查版本是否有效
|
|
105
|
+
*/
|
|
106
|
+
export function isValidVersion(version: string): boolean {
|
|
107
|
+
return semver.valid(version) !== null;
|
|
108
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 通用配置管理器
|
|
6
|
+
*/
|
|
7
|
+
export class ConfigManager<T> {
|
|
8
|
+
constructor(
|
|
9
|
+
private configPath: string,
|
|
10
|
+
private defaultConfig: T
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 确保配置目录存在
|
|
15
|
+
*/
|
|
16
|
+
private ensureConfigDir(): void {
|
|
17
|
+
const dir = dirname(this.configPath);
|
|
18
|
+
if (!existsSync(dir)) {
|
|
19
|
+
mkdirSync(dir, { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 读取配置
|
|
25
|
+
*/
|
|
26
|
+
getConfig(): T {
|
|
27
|
+
if (!existsSync(this.configPath)) {
|
|
28
|
+
// 首次运行,创建默认配置
|
|
29
|
+
this.ensureConfigDir();
|
|
30
|
+
writeFileSync(this.configPath, JSON.stringify(this.defaultConfig, null, 2), 'utf-8');
|
|
31
|
+
return this.defaultConfig;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const content = readFileSync(this.configPath, 'utf-8');
|
|
36
|
+
return JSON.parse(content);
|
|
37
|
+
} catch {
|
|
38
|
+
return this.defaultConfig;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 写入配置
|
|
44
|
+
*/
|
|
45
|
+
setConfig(config: T): void {
|
|
46
|
+
this.ensureConfigDir();
|
|
47
|
+
writeFileSync(this.configPath, JSON.stringify(config, null, 2), 'utf-8');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 重置为默认配置
|
|
52
|
+
*/
|
|
53
|
+
resetConfig(): T {
|
|
54
|
+
this.setConfig(this.defaultConfig);
|
|
55
|
+
return this.defaultConfig;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ConfigManager } from './config-manager.js';
|