openspec-stat 1.2.0 → 1.3.1
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/README.md +28 -0
- package/README.zh-CN.md +28 -0
- package/dist/cjs/cli.js +12 -127
- package/dist/cjs/commands/init.d.ts +7 -0
- package/dist/cjs/commands/init.js +58 -0
- package/dist/cjs/commands/multi.d.ts +16 -0
- package/dist/cjs/commands/multi.js +172 -0
- package/dist/cjs/commands/single.d.ts +2 -0
- package/dist/cjs/commands/single.js +148 -0
- package/dist/cjs/formatters.d.ts +4 -4
- package/dist/cjs/formatters.js +128 -36
- package/dist/cjs/git-analyzer.d.ts +1 -0
- package/dist/cjs/git-analyzer.js +6 -0
- package/dist/cjs/i18n/locales/en.json +74 -1
- package/dist/cjs/i18n/locales/zh-CN.json +74 -1
- package/dist/cjs/multi/config-validator.d.ts +3 -0
- package/dist/cjs/multi/config-validator.js +130 -0
- package/dist/cjs/multi/config-wizard.d.ts +50 -0
- package/dist/cjs/multi/config-wizard.js +331 -0
- package/dist/cjs/multi/multi-repo-analyzer.d.ts +14 -0
- package/dist/cjs/multi/multi-repo-analyzer.js +210 -0
- package/dist/cjs/types.d.ts +46 -0
- package/dist/esm/cli.js +54 -139
- package/dist/esm/commands/init.d.ts +7 -0
- package/dist/esm/commands/init.js +49 -0
- package/dist/esm/commands/multi.d.ts +16 -0
- package/dist/esm/commands/multi.js +192 -0
- package/dist/esm/commands/single.d.ts +2 -0
- package/dist/esm/commands/single.js +162 -0
- package/dist/esm/formatters.d.ts +4 -4
- package/dist/esm/formatters.js +173 -52
- package/dist/esm/git-analyzer.d.ts +1 -0
- package/dist/esm/git-analyzer.js +104 -77
- package/dist/esm/i18n/locales/en.json +74 -1
- package/dist/esm/i18n/locales/zh-CN.json +74 -1
- package/dist/esm/multi/config-validator.d.ts +3 -0
- package/dist/esm/multi/config-validator.js +109 -0
- package/dist/esm/multi/config-wizard.d.ts +50 -0
- package/dist/esm/multi/config-wizard.js +535 -0
- package/dist/esm/multi/multi-repo-analyzer.d.ts +14 -0
- package/dist/esm/multi/multi-repo-analyzer.js +446 -0
- package/dist/esm/types.d.ts +46 -0
- package/package.json +1 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import { t } from "../i18n/index.js";
|
|
9
|
+
var DEFAULT_MULTI_REPO_CONFIG = {
|
|
10
|
+
mode: 'multi-repo',
|
|
11
|
+
defaultSinceHours: -30,
|
|
12
|
+
defaultUntilHours: 20,
|
|
13
|
+
openspecDir: 'openspec/',
|
|
14
|
+
excludeExtensions: ['.md', '.txt', '.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico', '.webp'],
|
|
15
|
+
activeUserWeeks: 2,
|
|
16
|
+
authorMapping: {},
|
|
17
|
+
parallelism: {
|
|
18
|
+
maxConcurrent: 3,
|
|
19
|
+
timeout: 600000
|
|
20
|
+
},
|
|
21
|
+
remoteCache: {
|
|
22
|
+
dir: '/tmp/openspec-stat-cache',
|
|
23
|
+
autoCleanup: true,
|
|
24
|
+
cleanupOnComplete: true,
|
|
25
|
+
cleanupOnError: true
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
export function validateAndFillDefaults(config) {
|
|
31
|
+
if (!config.repositories || !Array.isArray(config.repositories)) {
|
|
32
|
+
throw new Error(t('config.validation.noRepos'));
|
|
33
|
+
}
|
|
34
|
+
if (config.repositories.length === 0) {
|
|
35
|
+
throw new Error(t('config.validation.emptyRepos'));
|
|
36
|
+
}
|
|
37
|
+
config.repositories.forEach(function (repo, index) {
|
|
38
|
+
if (!repo.name) {
|
|
39
|
+
throw new Error(t('config.validation.noName', {
|
|
40
|
+
index: String(index + 1)
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
if (!repo.type || !['local', 'remote'].includes(repo.type)) {
|
|
44
|
+
throw new Error(t('config.validation.invalidType', {
|
|
45
|
+
name: repo.name
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
if (repo.type === 'local' && !repo.path) {
|
|
49
|
+
throw new Error(t('config.validation.noPath', {
|
|
50
|
+
name: repo.name
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
if (repo.type === 'remote' && !repo.url) {
|
|
54
|
+
throw new Error(t('config.validation.noUrl', {
|
|
55
|
+
name: repo.name
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
if (!repo.branches || !Array.isArray(repo.branches) || repo.branches.length === 0) {
|
|
59
|
+
throw new Error(t('config.validation.noBranches', {
|
|
60
|
+
name: repo.name
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
if (repo.enabled === undefined) {
|
|
64
|
+
repo.enabled = true;
|
|
65
|
+
}
|
|
66
|
+
if (repo.type === 'remote' && !repo.cloneOptions) {
|
|
67
|
+
repo.cloneOptions = {
|
|
68
|
+
depth: null,
|
|
69
|
+
singleBranch: false
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
var mergedConfig = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_MULTI_REPO_CONFIG), config), {}, {
|
|
74
|
+
parallelism: _objectSpread(_objectSpread({}, DEFAULT_MULTI_REPO_CONFIG.parallelism), config.parallelism),
|
|
75
|
+
remoteCache: _objectSpread(_objectSpread({}, DEFAULT_MULTI_REPO_CONFIG.remoteCache), config.remoteCache)
|
|
76
|
+
});
|
|
77
|
+
return mergedConfig;
|
|
78
|
+
}
|
|
79
|
+
export function printConfigSummary(config) {
|
|
80
|
+
var _config$repositories, _config$parallelism, _config$remoteCache, _config$remoteCache2;
|
|
81
|
+
console.log(chalk.blue(t('config.summary.title')));
|
|
82
|
+
console.log(chalk.cyan(t('config.summary.repositories')));
|
|
83
|
+
(_config$repositories = config.repositories) === null || _config$repositories === void 0 || _config$repositories.forEach(function (repo, i) {
|
|
84
|
+
var icon = repo.type === 'local' ? '📁' : '☁️';
|
|
85
|
+
var location = repo.type === 'local' ? repo.path : repo.url;
|
|
86
|
+
console.log(" ".concat(i + 1, ". ").concat(icon, " ").concat(chalk.bold(repo.name), " (").concat(repo.type, ")"));
|
|
87
|
+
console.log(" ".concat(chalk.gray(location)));
|
|
88
|
+
console.log(" ".concat(chalk.gray('Branches:'), " ").concat(repo.branches.join(', ')));
|
|
89
|
+
});
|
|
90
|
+
console.log(chalk.cyan(t('config.summary.timeRange')));
|
|
91
|
+
console.log(t('config.summary.since', {
|
|
92
|
+
hours: String(config.defaultSinceHours)
|
|
93
|
+
}));
|
|
94
|
+
console.log(t('config.summary.until', {
|
|
95
|
+
hours: String(config.defaultUntilHours)
|
|
96
|
+
}));
|
|
97
|
+
console.log(chalk.cyan(t('config.summary.parallelism')));
|
|
98
|
+
console.log(t('config.summary.maxConcurrent', {
|
|
99
|
+
count: String(((_config$parallelism = config.parallelism) === null || _config$parallelism === void 0 ? void 0 : _config$parallelism.maxConcurrent) || 3)
|
|
100
|
+
}));
|
|
101
|
+
console.log(chalk.cyan(t('config.summary.remoteCache')));
|
|
102
|
+
console.log(t('config.summary.cacheDir', {
|
|
103
|
+
dir: ((_config$remoteCache = config.remoteCache) === null || _config$remoteCache === void 0 ? void 0 : _config$remoteCache.dir) || '/tmp/openspec-stat-cache'
|
|
104
|
+
}));
|
|
105
|
+
console.log(t('config.summary.autoCleanup', {
|
|
106
|
+
enabled: (_config$remoteCache2 = config.remoteCache) !== null && _config$remoteCache2 !== void 0 && _config$remoteCache2.cleanupOnComplete ? 'Yes' : 'No'
|
|
107
|
+
}));
|
|
108
|
+
console.log();
|
|
109
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare function runConfigWizard(isMultiRepo?: boolean): Promise<void>;
|
|
2
|
+
export declare const SINGLE_REPO_TEMPLATE: {
|
|
3
|
+
defaultBranches: string[];
|
|
4
|
+
defaultSinceHours: number;
|
|
5
|
+
defaultUntilHours: number;
|
|
6
|
+
authorMapping: {
|
|
7
|
+
'user@email1.com': string;
|
|
8
|
+
'user@email2.com': string;
|
|
9
|
+
};
|
|
10
|
+
openspecDir: string;
|
|
11
|
+
excludeExtensions: string[];
|
|
12
|
+
activeUserWeeks: number;
|
|
13
|
+
};
|
|
14
|
+
export declare const MULTI_REPO_TEMPLATE: {
|
|
15
|
+
mode: string;
|
|
16
|
+
repositories: ({
|
|
17
|
+
name: string;
|
|
18
|
+
type: string;
|
|
19
|
+
path: string;
|
|
20
|
+
branches: string[];
|
|
21
|
+
url?: undefined;
|
|
22
|
+
cloneOptions?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
name: string;
|
|
25
|
+
type: string;
|
|
26
|
+
url: string;
|
|
27
|
+
branches: string[];
|
|
28
|
+
cloneOptions: {
|
|
29
|
+
depth: null;
|
|
30
|
+
singleBranch: boolean;
|
|
31
|
+
};
|
|
32
|
+
path?: undefined;
|
|
33
|
+
})[];
|
|
34
|
+
defaultSinceHours: number;
|
|
35
|
+
defaultUntilHours: number;
|
|
36
|
+
authorMapping: {};
|
|
37
|
+
openspecDir: string;
|
|
38
|
+
excludeExtensions: string[];
|
|
39
|
+
activeUserWeeks: number;
|
|
40
|
+
parallelism: {
|
|
41
|
+
maxConcurrent: number;
|
|
42
|
+
timeout: number;
|
|
43
|
+
};
|
|
44
|
+
remoteCache: {
|
|
45
|
+
dir: string;
|
|
46
|
+
autoCleanup: boolean;
|
|
47
|
+
cleanupOnComplete: boolean;
|
|
48
|
+
cleanupOnError: boolean;
|
|
49
|
+
};
|
|
50
|
+
};
|