openspec-stat 1.1.0 → 1.3.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/README.md +44 -0
- package/README.zh-CN.md +44 -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 +268 -30
- package/dist/cjs/git-analyzer.d.ts +1 -0
- package/dist/cjs/git-analyzer.js +6 -0
- package/dist/cjs/i18n/locales/en.json +80 -1
- package/dist/cjs/i18n/locales/zh-CN.json +80 -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/stats-aggregator.js +25 -0
- package/dist/cjs/types.d.ts +57 -0
- package/dist/esm/cli.js +43 -137
- 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 +361 -55
- package/dist/esm/git-analyzer.d.ts +1 -0
- package/dist/esm/git-analyzer.js +104 -77
- package/dist/esm/i18n/locales/en.json +80 -1
- package/dist/esm/i18n/locales/zh-CN.json +80 -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/stats-aggregator.js +29 -0
- package/dist/esm/types.d.ts +57 -0
- package/package.json +1 -1
|
@@ -0,0 +1,535 @@
|
|
|
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 _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
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); }
|
|
8
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
10
|
+
import { input, select, confirm } from '@inquirer/prompts';
|
|
11
|
+
import chalk from 'chalk';
|
|
12
|
+
import { writeFileSync } from 'fs';
|
|
13
|
+
import { t } from "../i18n/index.js";
|
|
14
|
+
export function runConfigWizard() {
|
|
15
|
+
return _runConfigWizard.apply(this, arguments);
|
|
16
|
+
}
|
|
17
|
+
function _runConfigWizard() {
|
|
18
|
+
_runConfigWizard = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
19
|
+
var isMultiRepo,
|
|
20
|
+
configName,
|
|
21
|
+
singleRepoConfig,
|
|
22
|
+
repositories,
|
|
23
|
+
addMore,
|
|
24
|
+
repo,
|
|
25
|
+
timeConfig,
|
|
26
|
+
advancedConfig,
|
|
27
|
+
config,
|
|
28
|
+
confirmed,
|
|
29
|
+
_args = arguments;
|
|
30
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
31
|
+
while (1) switch (_context.prev = _context.next) {
|
|
32
|
+
case 0:
|
|
33
|
+
isMultiRepo = _args.length > 0 && _args[0] !== undefined ? _args[0] : false;
|
|
34
|
+
console.log(chalk.blue.bold(isMultiRepo ? t('init.welcomeMulti') : t('init.welcome')));
|
|
35
|
+
_context.next = 4;
|
|
36
|
+
return input({
|
|
37
|
+
message: t('init.configName'),
|
|
38
|
+
default: isMultiRepo ? '.openspec-stats.multi.json' : '.openspec-stats.json'
|
|
39
|
+
});
|
|
40
|
+
case 4:
|
|
41
|
+
configName = _context.sent;
|
|
42
|
+
if (isMultiRepo) {
|
|
43
|
+
_context.next = 11;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
_context.next = 8;
|
|
47
|
+
return createSingleRepoConfig();
|
|
48
|
+
case 8:
|
|
49
|
+
singleRepoConfig = _context.sent;
|
|
50
|
+
saveConfig(configName, singleRepoConfig);
|
|
51
|
+
return _context.abrupt("return");
|
|
52
|
+
case 11:
|
|
53
|
+
repositories = [];
|
|
54
|
+
addMore = true;
|
|
55
|
+
case 13:
|
|
56
|
+
if (!addMore) {
|
|
57
|
+
_context.next = 24;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
console.log(chalk.cyan(t('init.addRepository', {
|
|
61
|
+
number: String(repositories.length + 1)
|
|
62
|
+
})));
|
|
63
|
+
_context.next = 17;
|
|
64
|
+
return addRepository();
|
|
65
|
+
case 17:
|
|
66
|
+
repo = _context.sent;
|
|
67
|
+
repositories.push(repo);
|
|
68
|
+
_context.next = 21;
|
|
69
|
+
return confirm({
|
|
70
|
+
message: t('init.addMore'),
|
|
71
|
+
default: false
|
|
72
|
+
});
|
|
73
|
+
case 21:
|
|
74
|
+
addMore = _context.sent;
|
|
75
|
+
_context.next = 13;
|
|
76
|
+
break;
|
|
77
|
+
case 24:
|
|
78
|
+
console.log(chalk.cyan(t('init.timeConfig')));
|
|
79
|
+
_context.next = 27;
|
|
80
|
+
return configureTimeRange();
|
|
81
|
+
case 27:
|
|
82
|
+
timeConfig = _context.sent;
|
|
83
|
+
console.log(chalk.cyan(t('init.advanced')));
|
|
84
|
+
_context.next = 31;
|
|
85
|
+
return configureAdvanced();
|
|
86
|
+
case 31:
|
|
87
|
+
advancedConfig = _context.sent;
|
|
88
|
+
config = _objectSpread(_objectSpread({
|
|
89
|
+
mode: 'multi-repo',
|
|
90
|
+
repositories: repositories
|
|
91
|
+
}, timeConfig), advancedConfig);
|
|
92
|
+
console.log(chalk.green(t('init.preview')));
|
|
93
|
+
console.log(JSON.stringify(config, null, 2));
|
|
94
|
+
_context.next = 37;
|
|
95
|
+
return confirm({
|
|
96
|
+
message: t('init.save'),
|
|
97
|
+
default: true
|
|
98
|
+
});
|
|
99
|
+
case 37:
|
|
100
|
+
confirmed = _context.sent;
|
|
101
|
+
if (confirmed) {
|
|
102
|
+
saveConfig(configName, config);
|
|
103
|
+
console.log(chalk.green(t('init.saved', {
|
|
104
|
+
path: configName
|
|
105
|
+
})));
|
|
106
|
+
console.log(chalk.blue(t('init.runCommand', {
|
|
107
|
+
path: configName
|
|
108
|
+
})));
|
|
109
|
+
}
|
|
110
|
+
case 39:
|
|
111
|
+
case "end":
|
|
112
|
+
return _context.stop();
|
|
113
|
+
}
|
|
114
|
+
}, _callee);
|
|
115
|
+
}));
|
|
116
|
+
return _runConfigWizard.apply(this, arguments);
|
|
117
|
+
}
|
|
118
|
+
function createSingleRepoConfig() {
|
|
119
|
+
return _createSingleRepoConfig.apply(this, arguments);
|
|
120
|
+
}
|
|
121
|
+
function _createSingleRepoConfig() {
|
|
122
|
+
_createSingleRepoConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
123
|
+
var timeConfig, branches, advancedConfig;
|
|
124
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
125
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
126
|
+
case 0:
|
|
127
|
+
console.log(chalk.cyan(t('init.timeConfig')));
|
|
128
|
+
_context2.next = 3;
|
|
129
|
+
return configureTimeRange();
|
|
130
|
+
case 3:
|
|
131
|
+
timeConfig = _context2.sent;
|
|
132
|
+
_context2.next = 6;
|
|
133
|
+
return input({
|
|
134
|
+
message: t('init.branches'),
|
|
135
|
+
default: 'origin/master'
|
|
136
|
+
});
|
|
137
|
+
case 6:
|
|
138
|
+
branches = _context2.sent;
|
|
139
|
+
_context2.next = 9;
|
|
140
|
+
return configureAdvanced();
|
|
141
|
+
case 9:
|
|
142
|
+
advancedConfig = _context2.sent;
|
|
143
|
+
return _context2.abrupt("return", _objectSpread(_objectSpread({
|
|
144
|
+
defaultBranches: branches.split(',').map(function (b) {
|
|
145
|
+
return b.trim();
|
|
146
|
+
}).filter(Boolean)
|
|
147
|
+
}, timeConfig), advancedConfig));
|
|
148
|
+
case 11:
|
|
149
|
+
case "end":
|
|
150
|
+
return _context2.stop();
|
|
151
|
+
}
|
|
152
|
+
}, _callee2);
|
|
153
|
+
}));
|
|
154
|
+
return _createSingleRepoConfig.apply(this, arguments);
|
|
155
|
+
}
|
|
156
|
+
function addRepository() {
|
|
157
|
+
return _addRepository.apply(this, arguments);
|
|
158
|
+
}
|
|
159
|
+
function _addRepository() {
|
|
160
|
+
_addRepository = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
161
|
+
var type, name, repo, useFullClone, depth, branchInput;
|
|
162
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
163
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
164
|
+
case 0:
|
|
165
|
+
_context3.next = 2;
|
|
166
|
+
return select({
|
|
167
|
+
message: t('init.repoType'),
|
|
168
|
+
choices: [{
|
|
169
|
+
name: t('init.repoType.local'),
|
|
170
|
+
value: 'local'
|
|
171
|
+
}, {
|
|
172
|
+
name: t('init.repoType.remote'),
|
|
173
|
+
value: 'remote'
|
|
174
|
+
}]
|
|
175
|
+
});
|
|
176
|
+
case 2:
|
|
177
|
+
type = _context3.sent;
|
|
178
|
+
_context3.next = 5;
|
|
179
|
+
return input({
|
|
180
|
+
message: t('init.repoName'),
|
|
181
|
+
validate: function validate(value) {
|
|
182
|
+
return value.length > 0 || 'Name is required';
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
case 5:
|
|
186
|
+
name = _context3.sent;
|
|
187
|
+
repo = {
|
|
188
|
+
name: name,
|
|
189
|
+
type: type,
|
|
190
|
+
branches: []
|
|
191
|
+
};
|
|
192
|
+
if (!(type === 'local')) {
|
|
193
|
+
_context3.next = 13;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
_context3.next = 10;
|
|
197
|
+
return input({
|
|
198
|
+
message: t('init.repoPath'),
|
|
199
|
+
default: '.',
|
|
200
|
+
validate: function validate(value) {
|
|
201
|
+
return value.length > 0 || 'Path is required';
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
case 10:
|
|
205
|
+
repo.path = _context3.sent;
|
|
206
|
+
_context3.next = 27;
|
|
207
|
+
break;
|
|
208
|
+
case 13:
|
|
209
|
+
_context3.next = 15;
|
|
210
|
+
return input({
|
|
211
|
+
message: t('init.repoUrl'),
|
|
212
|
+
validate: function validate(value) {
|
|
213
|
+
if (!value.length) return 'URL is required';
|
|
214
|
+
if (!value.match(/^(git@|https:\/\/)/)) {
|
|
215
|
+
return t('init.repoUrlInvalid');
|
|
216
|
+
}
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
case 15:
|
|
221
|
+
repo.url = _context3.sent;
|
|
222
|
+
_context3.next = 18;
|
|
223
|
+
return confirm({
|
|
224
|
+
message: t('init.useFullClone'),
|
|
225
|
+
default: true
|
|
226
|
+
});
|
|
227
|
+
case 18:
|
|
228
|
+
useFullClone = _context3.sent;
|
|
229
|
+
if (useFullClone) {
|
|
230
|
+
_context3.next = 26;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
_context3.next = 22;
|
|
234
|
+
return input({
|
|
235
|
+
message: t('init.cloneDepth'),
|
|
236
|
+
default: '100',
|
|
237
|
+
validate: function validate(value) {
|
|
238
|
+
return !isNaN(Number(value)) || 'Must be a number';
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
case 22:
|
|
242
|
+
depth = _context3.sent;
|
|
243
|
+
repo.cloneOptions = {
|
|
244
|
+
depth: Number(depth)
|
|
245
|
+
};
|
|
246
|
+
_context3.next = 27;
|
|
247
|
+
break;
|
|
248
|
+
case 26:
|
|
249
|
+
repo.cloneOptions = {
|
|
250
|
+
depth: null
|
|
251
|
+
};
|
|
252
|
+
case 27:
|
|
253
|
+
_context3.next = 29;
|
|
254
|
+
return input({
|
|
255
|
+
message: t('init.branches'),
|
|
256
|
+
default: 'origin/master'
|
|
257
|
+
});
|
|
258
|
+
case 29:
|
|
259
|
+
branchInput = _context3.sent;
|
|
260
|
+
repo.branches = branchInput.split(',').map(function (b) {
|
|
261
|
+
return b.trim();
|
|
262
|
+
}).filter(Boolean);
|
|
263
|
+
return _context3.abrupt("return", repo);
|
|
264
|
+
case 32:
|
|
265
|
+
case "end":
|
|
266
|
+
return _context3.stop();
|
|
267
|
+
}
|
|
268
|
+
}, _callee3);
|
|
269
|
+
}));
|
|
270
|
+
return _addRepository.apply(this, arguments);
|
|
271
|
+
}
|
|
272
|
+
function configureTimeRange() {
|
|
273
|
+
return _configureTimeRange.apply(this, arguments);
|
|
274
|
+
}
|
|
275
|
+
function _configureTimeRange() {
|
|
276
|
+
_configureTimeRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
277
|
+
var useDefault, sinceHours, untilHours;
|
|
278
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
279
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
280
|
+
case 0:
|
|
281
|
+
_context4.next = 2;
|
|
282
|
+
return confirm({
|
|
283
|
+
message: t('init.useDefaultTime'),
|
|
284
|
+
default: true
|
|
285
|
+
});
|
|
286
|
+
case 2:
|
|
287
|
+
useDefault = _context4.sent;
|
|
288
|
+
if (!useDefault) {
|
|
289
|
+
_context4.next = 5;
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
return _context4.abrupt("return", {
|
|
293
|
+
defaultSinceHours: -30,
|
|
294
|
+
defaultUntilHours: 20
|
|
295
|
+
});
|
|
296
|
+
case 5:
|
|
297
|
+
_context4.next = 7;
|
|
298
|
+
return input({
|
|
299
|
+
message: t('init.sinceHours'),
|
|
300
|
+
default: '-30',
|
|
301
|
+
validate: function validate(value) {
|
|
302
|
+
return !isNaN(Number(value)) || 'Must be a number';
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
case 7:
|
|
306
|
+
sinceHours = _context4.sent;
|
|
307
|
+
_context4.next = 10;
|
|
308
|
+
return input({
|
|
309
|
+
message: t('init.untilHours'),
|
|
310
|
+
default: '20',
|
|
311
|
+
validate: function validate(value) {
|
|
312
|
+
var num = Number(value);
|
|
313
|
+
return !isNaN(num) && num >= 0 && num <= 23 || 'Must be 0-23';
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
case 10:
|
|
317
|
+
untilHours = _context4.sent;
|
|
318
|
+
return _context4.abrupt("return", {
|
|
319
|
+
defaultSinceHours: Number(sinceHours),
|
|
320
|
+
defaultUntilHours: Number(untilHours)
|
|
321
|
+
});
|
|
322
|
+
case 12:
|
|
323
|
+
case "end":
|
|
324
|
+
return _context4.stop();
|
|
325
|
+
}
|
|
326
|
+
}, _callee4);
|
|
327
|
+
}));
|
|
328
|
+
return _configureTimeRange.apply(this, arguments);
|
|
329
|
+
}
|
|
330
|
+
function configureAdvanced() {
|
|
331
|
+
return _configureAdvanced.apply(this, arguments);
|
|
332
|
+
}
|
|
333
|
+
function _configureAdvanced() {
|
|
334
|
+
_configureAdvanced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
335
|
+
var configureAdvanced, config, maxConcurrent, addAuthorMapping;
|
|
336
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
337
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
338
|
+
case 0:
|
|
339
|
+
_context5.next = 2;
|
|
340
|
+
return confirm({
|
|
341
|
+
message: t('init.configureAdvanced'),
|
|
342
|
+
default: false
|
|
343
|
+
});
|
|
344
|
+
case 2:
|
|
345
|
+
configureAdvanced = _context5.sent;
|
|
346
|
+
if (configureAdvanced) {
|
|
347
|
+
_context5.next = 5;
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
return _context5.abrupt("return", getDefaultAdvancedConfig());
|
|
351
|
+
case 5:
|
|
352
|
+
config = {};
|
|
353
|
+
_context5.next = 8;
|
|
354
|
+
return input({
|
|
355
|
+
message: t('init.openspecDir'),
|
|
356
|
+
default: 'openspec/'
|
|
357
|
+
});
|
|
358
|
+
case 8:
|
|
359
|
+
config.openspecDir = _context5.sent;
|
|
360
|
+
_context5.next = 11;
|
|
361
|
+
return input({
|
|
362
|
+
message: t('init.maxConcurrent'),
|
|
363
|
+
default: '3',
|
|
364
|
+
validate: function validate(value) {
|
|
365
|
+
var num = Number(value);
|
|
366
|
+
return !isNaN(num) && num > 0 || 'Must be positive number';
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
case 11:
|
|
370
|
+
maxConcurrent = _context5.sent;
|
|
371
|
+
config.parallelism = {
|
|
372
|
+
maxConcurrent: Number(maxConcurrent),
|
|
373
|
+
timeout: 600000
|
|
374
|
+
};
|
|
375
|
+
config.remoteCache = {
|
|
376
|
+
dir: '/tmp/openspec-stat-cache',
|
|
377
|
+
autoCleanup: true,
|
|
378
|
+
cleanupOnComplete: true,
|
|
379
|
+
cleanupOnError: true
|
|
380
|
+
};
|
|
381
|
+
config.excludeExtensions = ['.md', '.txt', '.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico', '.webp'];
|
|
382
|
+
config.activeUserWeeks = 2;
|
|
383
|
+
_context5.next = 18;
|
|
384
|
+
return confirm({
|
|
385
|
+
message: t('init.authorMapping'),
|
|
386
|
+
default: false
|
|
387
|
+
});
|
|
388
|
+
case 18:
|
|
389
|
+
addAuthorMapping = _context5.sent;
|
|
390
|
+
if (!addAuthorMapping) {
|
|
391
|
+
_context5.next = 25;
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
_context5.next = 22;
|
|
395
|
+
return configureAuthorMapping();
|
|
396
|
+
case 22:
|
|
397
|
+
config.authorMapping = _context5.sent;
|
|
398
|
+
_context5.next = 26;
|
|
399
|
+
break;
|
|
400
|
+
case 25:
|
|
401
|
+
config.authorMapping = {};
|
|
402
|
+
case 26:
|
|
403
|
+
return _context5.abrupt("return", config);
|
|
404
|
+
case 27:
|
|
405
|
+
case "end":
|
|
406
|
+
return _context5.stop();
|
|
407
|
+
}
|
|
408
|
+
}, _callee5);
|
|
409
|
+
}));
|
|
410
|
+
return _configureAdvanced.apply(this, arguments);
|
|
411
|
+
}
|
|
412
|
+
function configureAuthorMapping() {
|
|
413
|
+
return _configureAuthorMapping.apply(this, arguments);
|
|
414
|
+
}
|
|
415
|
+
function _configureAuthorMapping() {
|
|
416
|
+
_configureAuthorMapping = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
417
|
+
var mapping, addMore, gitIdentity, unifiedName;
|
|
418
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
419
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
420
|
+
case 0:
|
|
421
|
+
console.log(chalk.gray(t('init.authorMappingInfo')));
|
|
422
|
+
mapping = {};
|
|
423
|
+
addMore = true;
|
|
424
|
+
case 3:
|
|
425
|
+
if (!addMore) {
|
|
426
|
+
_context6.next = 18;
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
_context6.next = 6;
|
|
430
|
+
return input({
|
|
431
|
+
message: t('init.gitIdentity')
|
|
432
|
+
});
|
|
433
|
+
case 6:
|
|
434
|
+
gitIdentity = _context6.sent;
|
|
435
|
+
if (gitIdentity) {
|
|
436
|
+
_context6.next = 9;
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
return _context6.abrupt("break", 18);
|
|
440
|
+
case 9:
|
|
441
|
+
_context6.next = 11;
|
|
442
|
+
return input({
|
|
443
|
+
message: t('init.unifiedName', {
|
|
444
|
+
identity: gitIdentity
|
|
445
|
+
})
|
|
446
|
+
});
|
|
447
|
+
case 11:
|
|
448
|
+
unifiedName = _context6.sent;
|
|
449
|
+
mapping[gitIdentity] = unifiedName;
|
|
450
|
+
_context6.next = 15;
|
|
451
|
+
return confirm({
|
|
452
|
+
message: t('init.addMoreMapping'),
|
|
453
|
+
default: false
|
|
454
|
+
});
|
|
455
|
+
case 15:
|
|
456
|
+
addMore = _context6.sent;
|
|
457
|
+
_context6.next = 3;
|
|
458
|
+
break;
|
|
459
|
+
case 18:
|
|
460
|
+
return _context6.abrupt("return", mapping);
|
|
461
|
+
case 19:
|
|
462
|
+
case "end":
|
|
463
|
+
return _context6.stop();
|
|
464
|
+
}
|
|
465
|
+
}, _callee6);
|
|
466
|
+
}));
|
|
467
|
+
return _configureAuthorMapping.apply(this, arguments);
|
|
468
|
+
}
|
|
469
|
+
function getDefaultAdvancedConfig() {
|
|
470
|
+
return {
|
|
471
|
+
openspecDir: 'openspec/',
|
|
472
|
+
excludeExtensions: ['.md', '.txt', '.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico', '.webp'],
|
|
473
|
+
activeUserWeeks: 2,
|
|
474
|
+
authorMapping: {},
|
|
475
|
+
parallelism: {
|
|
476
|
+
maxConcurrent: 3,
|
|
477
|
+
timeout: 600000
|
|
478
|
+
},
|
|
479
|
+
remoteCache: {
|
|
480
|
+
dir: '/tmp/openspec-stat-cache',
|
|
481
|
+
autoCleanup: true,
|
|
482
|
+
cleanupOnComplete: true,
|
|
483
|
+
cleanupOnError: true
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
function saveConfig(path, config) {
|
|
488
|
+
writeFileSync(path, JSON.stringify(config, null, 2));
|
|
489
|
+
}
|
|
490
|
+
export var SINGLE_REPO_TEMPLATE = {
|
|
491
|
+
defaultBranches: ['origin/master'],
|
|
492
|
+
defaultSinceHours: -30,
|
|
493
|
+
defaultUntilHours: 20,
|
|
494
|
+
authorMapping: {
|
|
495
|
+
'user@email1.com': 'User Name',
|
|
496
|
+
'user@email2.com': 'User Name'
|
|
497
|
+
},
|
|
498
|
+
openspecDir: 'openspec/',
|
|
499
|
+
excludeExtensions: ['.md', '.txt', '.png', '.jpg'],
|
|
500
|
+
activeUserWeeks: 2
|
|
501
|
+
};
|
|
502
|
+
export var MULTI_REPO_TEMPLATE = {
|
|
503
|
+
mode: 'multi-repo',
|
|
504
|
+
repositories: [{
|
|
505
|
+
name: 'example-local-repo',
|
|
506
|
+
type: 'local',
|
|
507
|
+
path: './path/to/repo',
|
|
508
|
+
branches: ['origin/master']
|
|
509
|
+
}, {
|
|
510
|
+
name: 'example-remote-repo',
|
|
511
|
+
type: 'remote',
|
|
512
|
+
url: 'git@github.com:org/repo.git',
|
|
513
|
+
branches: ['origin/main'],
|
|
514
|
+
cloneOptions: {
|
|
515
|
+
depth: null,
|
|
516
|
+
singleBranch: false
|
|
517
|
+
}
|
|
518
|
+
}],
|
|
519
|
+
defaultSinceHours: -30,
|
|
520
|
+
defaultUntilHours: 20,
|
|
521
|
+
authorMapping: {},
|
|
522
|
+
openspecDir: 'openspec/',
|
|
523
|
+
excludeExtensions: ['.md', '.txt', '.png', '.jpg'],
|
|
524
|
+
activeUserWeeks: 2,
|
|
525
|
+
parallelism: {
|
|
526
|
+
maxConcurrent: 3,
|
|
527
|
+
timeout: 600000
|
|
528
|
+
},
|
|
529
|
+
remoteCache: {
|
|
530
|
+
dir: '/tmp/openspec-stat-cache',
|
|
531
|
+
autoCleanup: true,
|
|
532
|
+
cleanupOnComplete: true,
|
|
533
|
+
cleanupOnError: true
|
|
534
|
+
}
|
|
535
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MultiRepoConfig, RepositoryResult } from '../types.js';
|
|
2
|
+
export declare class MultiRepoAnalyzer {
|
|
3
|
+
private config;
|
|
4
|
+
private tempDirs;
|
|
5
|
+
constructor(config: MultiRepoConfig);
|
|
6
|
+
analyzeAll(since: Date, until: Date): Promise<RepositoryResult[]>;
|
|
7
|
+
private analyzeRepository;
|
|
8
|
+
private cloneRemoteRepository;
|
|
9
|
+
private resolveLocalPath;
|
|
10
|
+
private processInBatches;
|
|
11
|
+
private withTimeout;
|
|
12
|
+
cleanupTempDirs(): Promise<void>;
|
|
13
|
+
registerCleanupHandlers(): void;
|
|
14
|
+
}
|