@cyberskill/shared 1.50.0 → 1.52.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.
Files changed (147) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +100 -129
  2. package/dist/_tsup-dts-rollup.d.ts +100 -129
  3. package/dist/cli.cjs +1 -2146
  4. package/dist/cli.d.cts +1 -2
  5. package/dist/cli.d.ts +1 -2
  6. package/dist/cli.js +1 -2066
  7. package/dist/configs/commitlint/base.cjs +1 -64
  8. package/dist/configs/commitlint/base.js +1 -7
  9. package/dist/configs/eslint/base.cjs +1 -121
  10. package/dist/configs/eslint/base.js +1 -52
  11. package/dist/configs/eslint/nestjs.cjs +1 -155
  12. package/dist/configs/eslint/nestjs.js +1 -85
  13. package/dist/configs/eslint/nextjs.cjs +1 -155
  14. package/dist/configs/eslint/nextjs.js +1 -85
  15. package/dist/configs/eslint/nodejs.cjs +1 -156
  16. package/dist/configs/eslint/nodejs.js +1 -86
  17. package/dist/configs/eslint/vite-react.cjs +1 -159
  18. package/dist/configs/eslint/vite-react.js +1 -89
  19. package/dist/configs/graphql/graphql-codegen.cjs +1 -125
  20. package/dist/configs/graphql/graphql-codegen.js +1 -64
  21. package/dist/configs/graphql/index.cjs +1 -126
  22. package/dist/configs/graphql/index.js +1 -64
  23. package/dist/configs/i18n/react/i18next.cjs +1 -80
  24. package/dist/configs/i18n/react/i18next.js +1 -7
  25. package/dist/configs/i18n/react/index.cjs +1 -81
  26. package/dist/configs/i18n/react/index.js +1 -7
  27. package/dist/configs/index.cjs +1 -232
  28. package/dist/configs/index.js +1 -166
  29. package/dist/configs/lint-staged/base.cjs +1 -64
  30. package/dist/configs/lint-staged/base.js +1 -7
  31. package/dist/configs/vitest/react/e2e.cjs +1 -128
  32. package/dist/configs/vitest/react/e2e.js +1 -59
  33. package/dist/configs/vitest/react/unit.cjs +1 -305
  34. package/dist/configs/vitest/react/unit.js +1 -228
  35. package/dist/configs/vitest/react/unit.setup.cjs +1 -60
  36. package/dist/configs/vitest/react/unit.setup.js +1 -8
  37. package/dist/constants/index.cjs +1 -677
  38. package/dist/constants/index.d.cts +8 -3
  39. package/dist/constants/index.d.ts +8 -3
  40. package/dist/constants/index.js +1 -468
  41. package/dist/constants/path.cjs +1 -422
  42. package/dist/constants/path.d.cts +8 -3
  43. package/dist/constants/path.d.ts +8 -3
  44. package/dist/constants/path.js +1 -217
  45. package/dist/constants/response-status.cjs +1 -313
  46. package/dist/constants/response-status.js +1 -252
  47. package/dist/index.cjs +1 -4559
  48. package/dist/index.d.cts +13 -8
  49. package/dist/index.d.ts +13 -8
  50. package/dist/index.js +1 -4142
  51. package/dist/nodejs/index.cjs +1 -2138
  52. package/dist/nodejs/index.js +1 -2054
  53. package/dist/nodejs/mongo.cjs +1 -2137
  54. package/dist/nodejs/mongo.js +1 -2054
  55. package/dist/react/apollo-client.cjs +1 -177
  56. package/dist/react/apollo-client.js +1 -116
  57. package/dist/react/index.cjs +1 -990
  58. package/dist/react/index.js +1 -876
  59. package/dist/react/loading.cjs +1 -301
  60. package/dist/react/loading.js +1 -216
  61. package/dist/react/next-intl.cjs +1 -744
  62. package/dist/react/next-intl.js +1 -655
  63. package/dist/react/storage.cjs +1 -631
  64. package/dist/react/storage.js +1 -558
  65. package/dist/typescript/api-response.cjs +1 -48
  66. package/dist/typescript/apollo.cjs +1 -48
  67. package/dist/typescript/command.cjs +1 -68
  68. package/dist/typescript/command.d.cts +3 -0
  69. package/dist/typescript/command.d.ts +3 -0
  70. package/dist/typescript/command.js +1 -7
  71. package/dist/typescript/config.cjs +1 -48
  72. package/dist/typescript/fs.cjs +1 -48
  73. package/dist/typescript/graphql-codegen.cjs +1 -48
  74. package/dist/typescript/index.cjs +1 -175
  75. package/dist/typescript/index.d.cts +3 -0
  76. package/dist/typescript/index.d.ts +3 -0
  77. package/dist/typescript/index.js +1 -151
  78. package/dist/typescript/loading.cjs +1 -48
  79. package/dist/typescript/log.cjs +1 -48
  80. package/dist/typescript/mongo.cjs +1 -164
  81. package/dist/typescript/mongo.js +1 -145
  82. package/dist/typescript/next-intl.cjs +1 -48
  83. package/dist/typescript/react.cjs +1 -48
  84. package/dist/typescript/serializer.cjs +1 -48
  85. package/dist/typescript/string.cjs +1 -48
  86. package/dist/utils/command.cjs +1 -1387
  87. package/dist/utils/command.d.cts +2 -2
  88. package/dist/utils/command.d.ts +2 -2
  89. package/dist/utils/command.js +1 -1287
  90. package/dist/utils/common.cjs +1 -300
  91. package/dist/utils/common.js +1 -219
  92. package/dist/utils/config.cjs +1 -146
  93. package/dist/utils/config.js +1 -89
  94. package/dist/utils/fs.cjs +1 -132
  95. package/dist/utils/fs.js +1 -47
  96. package/dist/utils/index-nodejs.cjs +1 -1752
  97. package/dist/utils/index-nodejs.d.cts +2 -5
  98. package/dist/utils/index-nodejs.d.ts +2 -5
  99. package/dist/utils/index-nodejs.js +1 -1581
  100. package/dist/utils/index.cjs +1 -727
  101. package/dist/utils/index.js +1 -625
  102. package/dist/utils/log.cjs +1 -330
  103. package/dist/utils/log.js +1 -269
  104. package/dist/utils/package.cjs +1 -941
  105. package/dist/utils/package.js +1 -857
  106. package/dist/utils/path.cjs +1 -291
  107. package/dist/utils/path.d.cts +0 -3
  108. package/dist/utils/path.d.ts +0 -3
  109. package/dist/utils/path.js +1 -191
  110. package/dist/utils/serializer.cjs +1 -91
  111. package/dist/utils/serializer.js +1 -30
  112. package/dist/utils/storage-client.cjs +1 -349
  113. package/dist/utils/storage-client.js +1 -276
  114. package/dist/utils/storage-server.cjs +1 -636
  115. package/dist/utils/storage-server.js +1 -550
  116. package/dist/utils/string.cjs +1 -152
  117. package/dist/utils/string.js +1 -75
  118. package/dist/utils/validate.cjs +1 -90
  119. package/dist/utils/validate.js +1 -33
  120. package/package.json +15 -13
  121. /package/{src/public → public}/favicon/android-icon-144x144.png +0 -0
  122. /package/{src/public → public}/favicon/android-icon-192x192.png +0 -0
  123. /package/{src/public → public}/favicon/android-icon-36x36.png +0 -0
  124. /package/{src/public → public}/favicon/android-icon-48x48.png +0 -0
  125. /package/{src/public → public}/favicon/android-icon-72x72.png +0 -0
  126. /package/{src/public → public}/favicon/android-icon-96x96.png +0 -0
  127. /package/{src/public → public}/favicon/apple-icon-114x114.png +0 -0
  128. /package/{src/public → public}/favicon/apple-icon-120x120.png +0 -0
  129. /package/{src/public → public}/favicon/apple-icon-144x144.png +0 -0
  130. /package/{src/public → public}/favicon/apple-icon-152x152.png +0 -0
  131. /package/{src/public → public}/favicon/apple-icon-180x180.png +0 -0
  132. /package/{src/public → public}/favicon/apple-icon-57x57.png +0 -0
  133. /package/{src/public → public}/favicon/apple-icon-60x60.png +0 -0
  134. /package/{src/public → public}/favicon/apple-icon-72x72.png +0 -0
  135. /package/{src/public → public}/favicon/apple-icon-76x76.png +0 -0
  136. /package/{src/public → public}/favicon/apple-icon-precomposed.png +0 -0
  137. /package/{src/public → public}/favicon/apple-icon.png +0 -0
  138. /package/{src/public → public}/favicon/browserconfig.xml +0 -0
  139. /package/{src/public → public}/favicon/favicon-16x16.png +0 -0
  140. /package/{src/public → public}/favicon/favicon-32x32.png +0 -0
  141. /package/{src/public → public}/favicon/favicon-96x96.png +0 -0
  142. /package/{src/public → public}/favicon/favicon.ico +0 -0
  143. /package/{src/public → public}/favicon/manifest.json +0 -0
  144. /package/{src/public → public}/favicon/ms-icon-144x144.png +0 -0
  145. /package/{src/public → public}/favicon/ms-icon-150x150.png +0 -0
  146. /package/{src/public → public}/favicon/ms-icon-310x310.png +0 -0
  147. /package/{src/public → public}/favicon/ms-icon-70x70.png +0 -0
package/dist/cli.cjs CHANGED
@@ -1,2147 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- function _array_like_to_array(arr, len) {
4
- if (len == null || len > arr.length) len = arr.length;
5
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
6
- return arr2;
7
- }
8
- function _array_with_holes(arr) {
9
- if (Array.isArray(arr)) return arr;
10
- }
11
- function _array_without_holes(arr) {
12
- if (Array.isArray(arr)) return _array_like_to_array(arr);
13
- }
14
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
15
- try {
16
- var info = gen[key](arg);
17
- var value = info.value;
18
- } catch (error) {
19
- reject(error);
20
- return;
21
- }
22
- if (info.done) {
23
- resolve(value);
24
- } else {
25
- Promise.resolve(value).then(_next, _throw);
26
- }
27
- }
28
- function _async_to_generator(fn) {
29
- return function() {
30
- var self = this, args = arguments;
31
- return new Promise(function(resolve, reject) {
32
- var gen = fn.apply(self, args);
33
- function _next(value) {
34
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
35
- }
36
- function _throw(err) {
37
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
38
- }
39
- _next(undefined);
40
- });
41
- };
42
- }
43
- function _define_property(obj, key, value) {
44
- if (key in obj) {
45
- Object.defineProperty(obj, key, {
46
- value: value,
47
- enumerable: true,
48
- configurable: true,
49
- writable: true
50
- });
51
- } else {
52
- obj[key] = value;
53
- }
54
- return obj;
55
- }
56
- function _iterable_to_array(iter) {
57
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
58
- }
59
- function _iterable_to_array_limit(arr, i) {
60
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
61
- if (_i == null) return;
62
- var _arr = [];
63
- var _n = true;
64
- var _d = false;
65
- var _s, _e;
66
- try {
67
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
68
- _arr.push(_s.value);
69
- if (i && _arr.length === i) break;
70
- }
71
- } catch (err) {
72
- _d = true;
73
- _e = err;
74
- } finally{
75
- try {
76
- if (!_n && _i["return"] != null) _i["return"]();
77
- } finally{
78
- if (_d) throw _e;
79
- }
80
- }
81
- return _arr;
82
- }
83
- function _non_iterable_rest() {
84
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
85
- }
86
- function _non_iterable_spread() {
87
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
88
- }
89
- function _object_spread(target) {
90
- for(var i = 1; i < arguments.length; i++){
91
- var source = arguments[i] != null ? arguments[i] : {};
92
- var ownKeys = Object.keys(source);
93
- if (typeof Object.getOwnPropertySymbols === "function") {
94
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
95
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
96
- }));
97
- }
98
- ownKeys.forEach(function(key) {
99
- _define_property(target, key, source[key]);
100
- });
101
- }
102
- return target;
103
- }
104
- function ownKeys(object, enumerableOnly) {
105
- var keys = Object.keys(object);
106
- if (Object.getOwnPropertySymbols) {
107
- var symbols = Object.getOwnPropertySymbols(object);
108
- if (enumerableOnly) {
109
- symbols = symbols.filter(function(sym) {
110
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
111
- });
112
- }
113
- keys.push.apply(keys, symbols);
114
- }
115
- return keys;
116
- }
117
- function _object_spread_props(target, source) {
118
- source = source != null ? source : {};
119
- if (Object.getOwnPropertyDescriptors) {
120
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
121
- } else {
122
- ownKeys(Object(source)).forEach(function(key) {
123
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
124
- });
125
- }
126
- return target;
127
- }
128
- function _sliced_to_array(arr, i) {
129
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
130
- }
131
- function _to_consumable_array(arr) {
132
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
133
- }
134
- function _type_of(obj) {
135
- "@swc/helpers - typeof";
136
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
137
- }
138
- function _unsupported_iterable_to_array(o, minLen) {
139
- if (!o) return;
140
- if (typeof o === "string") return _array_like_to_array(o, minLen);
141
- var n = Object.prototype.toString.call(o).slice(8, -1);
142
- if (n === "Object" && o.constructor) n = o.constructor.name;
143
- if (n === "Map" || n === "Set") return Array.from(n);
144
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
145
- }
146
- function _ts_generator(thisArg, body) {
147
- var f, y, t, g, _ = {
148
- label: 0,
149
- sent: function() {
150
- if (t[0] & 1) throw t[1];
151
- return t[1];
152
- },
153
- trys: [],
154
- ops: []
155
- };
156
- return g = {
157
- next: verb(0),
158
- "throw": verb(1),
159
- "return": verb(2)
160
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
161
- return this;
162
- }), g;
163
- function verb(n) {
164
- return function(v) {
165
- return step([
166
- n,
167
- v
168
- ]);
169
- };
170
- }
171
- function step(op) {
172
- if (f) throw new TypeError("Generator is already executing.");
173
- while(_)try {
174
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
175
- if (y = 0, t) op = [
176
- op[0] & 2,
177
- t.value
178
- ];
179
- switch(op[0]){
180
- case 0:
181
- case 1:
182
- t = op;
183
- break;
184
- case 4:
185
- _.label++;
186
- return {
187
- value: op[1],
188
- done: false
189
- };
190
- case 5:
191
- _.label++;
192
- y = op[1];
193
- op = [
194
- 0
195
- ];
196
- continue;
197
- case 7:
198
- op = _.ops.pop();
199
- _.trys.pop();
200
- continue;
201
- default:
202
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
203
- _ = 0;
204
- continue;
205
- }
206
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
207
- _.label = op[1];
208
- break;
209
- }
210
- if (op[0] === 6 && _.label < t[1]) {
211
- _.label = t[1];
212
- t = op;
213
- break;
214
- }
215
- if (t && _.label < t[2]) {
216
- _.label = t[2];
217
- _.ops.push(op);
218
- break;
219
- }
220
- if (t[2]) _.ops.pop();
221
- _.trys.pop();
222
- continue;
223
- }
224
- op = body.call(thisArg, _);
225
- } catch (e) {
226
- op = [
227
- 6,
228
- e
229
- ];
230
- y = 0;
231
- } finally{
232
- f = t = 0;
233
- }
234
- if (op[0] & 5) throw op[1];
235
- return {
236
- value: op[0] ? op[1] : void 0,
237
- done: true
238
- };
239
- }
240
- }
241
- var __create = Object.create;
242
- var __defProp = Object.defineProperty;
243
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
244
- var __getOwnPropNames = Object.getOwnPropertyNames;
245
- var __getProtoOf = Object.getPrototypeOf;
246
- var __hasOwnProp = Object.prototype.hasOwnProperty;
247
- var __export = function(target, all) {
248
- for(var name in all)__defProp(target, name, {
249
- get: all[name],
250
- enumerable: true
251
- });
252
- };
253
- var __copyProps = function(to, from, except, desc) {
254
- if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
255
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
256
- try {
257
- var _loop = function() {
258
- var key = _step.value;
259
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
260
- get: function() {
261
- return from[key];
262
- },
263
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
264
- });
265
- };
266
- for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
267
- } catch (err) {
268
- _didIteratorError = true;
269
- _iteratorError = err;
270
- } finally{
271
- try {
272
- if (!_iteratorNormalCompletion && _iterator.return != null) {
273
- _iterator.return();
274
- }
275
- } finally{
276
- if (_didIteratorError) {
277
- throw _iteratorError;
278
- }
279
- }
280
- }
281
- }
282
- return to;
283
- };
284
- var __toESM = function(mod, isNodeMode, target) {
285
- return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
286
- // file that has been converted to a CommonJS file using a Babel-
287
- // compatible transform (i.e. "__esModule" has not been set), then set
288
- // "default" to the CommonJS "module.exports" for node compatibility.
289
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
290
- value: mod,
291
- enumerable: true
292
- }) : target, mod);
293
- };
294
- var __toCommonJS = function(mod) {
295
- return __copyProps(__defProp({}, "__esModule", {
296
- value: true
297
- }), mod);
298
- };
299
- // src/cli.ts
300
- var cli_exports = {};
301
- __export(cli_exports, {
302
- installDependencies: function() {
303
- return installDependencies;
304
- },
305
- updatePackage: function() {
306
- return updatePackage;
307
- }
308
- });
309
- module.exports = __toCommonJS(cli_exports);
310
- // node_modules/.pnpm/tsup@8.4.0_@microsoft+api-extractor@7.52.2_@types+node@22.13.17__@swc+core@1.11.16_@swc_95e38cac10676cdf66b55e0093c30cae/node_modules/tsup/assets/cjs_shims.js
311
- var getImportMetaUrl = function() {
312
- return typeof document === "undefined" ? new URL("file:".concat(__filename)).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
313
- };
314
- var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
315
- // src/cli.ts
316
- var import_node_process4 = __toESM(require("process"), 1);
317
- var import_helpers = require("yargs/helpers");
318
- var import_yargs = __toESM(require("yargs/yargs"), 1);
319
- // src/constants/path.ts
320
- var import_node_process3 = __toESM(require("process"), 1);
321
- var import_node_url = require("url");
322
- // src/utils/command.ts
323
- var import_boxen = __toESM(require("boxen"), 1);
324
- var import_chalk = __toESM(require("chalk"), 1);
325
- var import_node_child_process = require("child_process");
326
- var import_node_process2 = __toESM(require("process"), 1);
327
- var util = __toESM(require("util"), 1);
328
- // src/utils/package.ts
329
- var import_node_fetch = __toESM(require("node-fetch"), 1);
330
- // src/utils/fs.ts
331
- var fs = __toESM(require("fs"), 1);
332
- var existsSync2 = function(filePath) {
333
- return fs.existsSync(filePath);
334
- };
335
- function readFileSync2(filePath, options) {
336
- var content = fs.readFileSync(filePath, "utf-8");
337
- if (options === null || options === void 0 ? void 0 : options.asJson) {
338
- try {
339
- var parsed = JSON.parse(content);
340
- if ((typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) === "object" && parsed !== null) {
341
- return parsed;
342
- }
343
- throw new Error("Parsed JSON is not an object or array");
344
- } catch (e) {
345
- throw new Error("Failed to parse JSON from file: ".concat(filePath));
346
- }
347
- }
348
- return content;
349
- }
350
- function writeFileSync2(filePath, data) {
351
- var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
352
- var _options_isJson = options.isJson, isJson = _options_isJson === void 0 ? false : _options_isJson;
353
- var content = isJson && (typeof data === "undefined" ? "undefined" : _type_of(data)) === "object" ? JSON.stringify(data, null, 4) : String(data);
354
- fs.writeFileSync(filePath, content, "utf-8");
355
- }
356
- function appendFileSync2(filePath, data) {
357
- var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
358
- var _options_isJson = options.isJson, isJson = _options_isJson === void 0 ? false : _options_isJson;
359
- var content = isJson && (typeof data === "undefined" ? "undefined" : _type_of(data)) === "object" ? JSON.stringify(data, null, 4) : String(data);
360
- fs.appendFileSync(filePath, content, "utf-8");
361
- }
362
- function rmSync2(filePaths) {
363
- filePaths.forEach(function(filePath) {
364
- if (existsSync2(filePath)) {
365
- fs.rmSync(filePath, {
366
- recursive: true,
367
- force: true
368
- });
369
- }
370
- });
371
- }
372
- // src/utils/path.ts
373
- var import_node_module = require("module");
374
- var path = __toESM(require("path"), 1);
375
- function resolveCyberSkillPath() {
376
- for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
377
- urls[_key] = arguments[_key];
378
- }
379
- var _path;
380
- return (_path = path).resolve.apply(_path, [
381
- CYBERSKILL_DIRECTORY
382
- ].concat(_to_consumable_array(urls)));
383
- }
384
- function resolveWorkingPath() {
385
- for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
386
- urls[_key] = arguments[_key];
387
- }
388
- var _path;
389
- return (_path = path).resolve.apply(_path, [
390
- WORKING_DIRECTORY
391
- ].concat(_to_consumable_array(urls)));
392
- }
393
- function resolve2() {
394
- for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
395
- urls[_key] = arguments[_key];
396
- }
397
- var _path;
398
- return (_path = path).resolve.apply(_path, _to_consumable_array(urls));
399
- }
400
- function dirname2(url) {
401
- return path.dirname(url);
402
- }
403
- function join2() {
404
- for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
405
- urls[_key] = arguments[_key];
406
- }
407
- var _path;
408
- return (_path = path).join.apply(_path, _to_consumable_array(urls));
409
- }
410
- // src/utils/storage-server.ts
411
- var import_node_persist = __toESM(require("node-persist"), 1);
412
- var import_node_os = __toESM(require("os"), 1);
413
- var import_node_path = __toESM(require("path"), 1);
414
- var import_node_process = __toESM(require("process"), 1);
415
- function getStorageDir() {
416
- return import_node_process.default.env.CYBERSKILL_STORAGE_DIR || import_node_path.default.join(import_node_os.default.homedir(), CYBERSKILL_STORAGE);
417
- }
418
- function initNodePersist() {
419
- return _initNodePersist.apply(this, arguments);
420
- }
421
- function _initNodePersist() {
422
- _initNodePersist = _async_to_generator(function() {
423
- return _ts_generator(this, function(_state) {
424
- switch(_state.label){
425
- case 0:
426
- if (!!import_node_persist.default.defaultInstance) return [
427
- 3,
428
- 2
429
- ];
430
- return [
431
- 4,
432
- import_node_persist.default.init({
433
- dir: getStorageDir(),
434
- stringify: JSON.stringify,
435
- parse: JSON.parse,
436
- encoding: "utf8",
437
- logging: false,
438
- forgiveParseErrors: true
439
- })
440
- ];
441
- case 1:
442
- _state.sent();
443
- _state.label = 2;
444
- case 2:
445
- return [
446
- 2
447
- ];
448
- }
449
- });
450
- });
451
- return _initNodePersist.apply(this, arguments);
452
- }
453
- var storageServer = {
454
- get: function get(key) {
455
- return _async_to_generator(function() {
456
- var result, error;
457
- return _ts_generator(this, function(_state) {
458
- switch(_state.label){
459
- case 0:
460
- _state.trys.push([
461
- 0,
462
- 3,
463
- ,
464
- 4
465
- ]);
466
- return [
467
- 4,
468
- initNodePersist()
469
- ];
470
- case 1:
471
- _state.sent();
472
- return [
473
- 4,
474
- import_node_persist.default.getItem(key)
475
- ];
476
- case 2:
477
- result = _state.sent();
478
- return [
479
- 2,
480
- result !== null && result !== void 0 ? result : null
481
- ];
482
- case 3:
483
- error = _state.sent();
484
- console.error('❌ [Storage:get] Error getting key "'.concat(key, '":'), error);
485
- return [
486
- 2,
487
- null
488
- ];
489
- case 4:
490
- return [
491
- 2
492
- ];
493
- }
494
- });
495
- })();
496
- },
497
- set: function set(key, value) {
498
- return _async_to_generator(function() {
499
- var error;
500
- return _ts_generator(this, function(_state) {
501
- switch(_state.label){
502
- case 0:
503
- _state.trys.push([
504
- 0,
505
- 3,
506
- ,
507
- 4
508
- ]);
509
- return [
510
- 4,
511
- initNodePersist()
512
- ];
513
- case 1:
514
- _state.sent();
515
- return [
516
- 4,
517
- import_node_persist.default.setItem(key, value)
518
- ];
519
- case 2:
520
- _state.sent();
521
- return [
522
- 3,
523
- 4
524
- ];
525
- case 3:
526
- error = _state.sent();
527
- console.error('❌ [Storage:set] Error setting key "'.concat(key, '":'), error);
528
- return [
529
- 3,
530
- 4
531
- ];
532
- case 4:
533
- return [
534
- 2
535
- ];
536
- }
537
- });
538
- })();
539
- },
540
- remove: function remove(key) {
541
- return _async_to_generator(function() {
542
- var error;
543
- return _ts_generator(this, function(_state) {
544
- switch(_state.label){
545
- case 0:
546
- _state.trys.push([
547
- 0,
548
- 3,
549
- ,
550
- 4
551
- ]);
552
- return [
553
- 4,
554
- initNodePersist()
555
- ];
556
- case 1:
557
- _state.sent();
558
- return [
559
- 4,
560
- import_node_persist.default.removeItem(key)
561
- ];
562
- case 2:
563
- _state.sent();
564
- return [
565
- 3,
566
- 4
567
- ];
568
- case 3:
569
- error = _state.sent();
570
- console.error('❌ [Storage:remove] Error removing key "'.concat(key, '":'), error);
571
- return [
572
- 3,
573
- 4
574
- ];
575
- case 4:
576
- return [
577
- 2
578
- ];
579
- }
580
- });
581
- })();
582
- },
583
- keys: function keys() {
584
- return _async_to_generator(function() {
585
- var keys, error;
586
- return _ts_generator(this, function(_state) {
587
- switch(_state.label){
588
- case 0:
589
- _state.trys.push([
590
- 0,
591
- 3,
592
- ,
593
- 4
594
- ]);
595
- return [
596
- 4,
597
- initNodePersist()
598
- ];
599
- case 1:
600
- _state.sent();
601
- return [
602
- 4,
603
- import_node_persist.default.keys()
604
- ];
605
- case 2:
606
- keys = _state.sent();
607
- if (!Array.isArray(keys)) {
608
- console.warn("⚠️ [Storage:keys] Invalid keys response:", keys);
609
- return [
610
- 2,
611
- []
612
- ];
613
- }
614
- return [
615
- 2,
616
- keys
617
- ];
618
- case 3:
619
- error = _state.sent();
620
- console.error("❌ [Storage:keys] Error getting keys:", error);
621
- return [
622
- 2,
623
- []
624
- ];
625
- case 4:
626
- return [
627
- 2
628
- ];
629
- }
630
- });
631
- })();
632
- },
633
- getLogLink: function getLogLink(key) {
634
- return _async_to_generator(function() {
635
- var storagePath;
636
- return _ts_generator(this, function(_state) {
637
- try {
638
- storagePath = getStorageDir();
639
- return [
640
- 2,
641
- "".concat(storagePath, " (key: ").concat(key, ")")
642
- ];
643
- } catch (error) {
644
- console.error("❌ [Storage:getLogLink] Error getting log link:", error);
645
- return [
646
- 2,
647
- null
648
- ];
649
- }
650
- return [
651
- 2
652
- ];
653
- });
654
- })();
655
- }
656
- };
657
- // src/utils/package.ts
658
- var CACHE_EXPIRATION_MS = 24 * 60 * 60 * 1e3;
659
- function getPackageJson(packageName) {
660
- var workingPackageJsonPath = join2(WORKING_DIRECTORY, PACKAGE_JSON);
661
- if (existsSync2(workingPackageJsonPath)) {
662
- try {
663
- var pkg = readFileSync2(workingPackageJsonPath, {
664
- asJson: true
665
- });
666
- if (pkg.name === packageName) {
667
- return {
668
- path: workingPackageJsonPath,
669
- file: pkg
670
- };
671
- }
672
- } catch (error) {
673
- commandLog.warning("Failed to read local package.json: ".concat(error.message));
674
- }
675
- }
676
- var externalPackageJsonPath = join2(WORKING_DIRECTORY, NODE_MODULES, packageName, PACKAGE_JSON);
677
- if (existsSync2(externalPackageJsonPath)) {
678
- try {
679
- var pkg1 = readFileSync2(externalPackageJsonPath, {
680
- asJson: true
681
- });
682
- if (pkg1.name === packageName) {
683
- return {
684
- path: externalPackageJsonPath,
685
- file: pkg1
686
- };
687
- }
688
- } catch (error) {
689
- commandLog.warning("Failed to read node_modules package.json for ".concat(packageName, ": ").concat(error.message));
690
- }
691
- }
692
- return false;
693
- }
694
- function getLatestPackageVersion(packageName) {
695
- return _getLatestPackageVersion.apply(this, arguments);
696
- }
697
- function _getLatestPackageVersion() {
698
- _getLatestPackageVersion = _async_to_generator(function(packageName) {
699
- var forceRefresh, versionCacheKey, metadataCacheKey, cached, metadata, isCacheValid, headers, response, data, latestVersion, error;
700
- var _arguments = arguments;
701
- return _ts_generator(this, function(_state) {
702
- switch(_state.label){
703
- case 0:
704
- forceRefresh = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : false;
705
- versionCacheKey = "npm_version:".concat(packageName);
706
- metadataCacheKey = "npm_metadata:".concat(packageName);
707
- return [
708
- 4,
709
- storageServer.get(versionCacheKey)
710
- ];
711
- case 1:
712
- cached = _state.sent();
713
- return [
714
- 4,
715
- storageServer.get(metadataCacheKey)
716
- ];
717
- case 2:
718
- metadata = _state.sent();
719
- isCacheValid = cached && Date.now() - cached.timestamp < CACHE_EXPIRATION_MS;
720
- if (!forceRefresh && isCacheValid) {
721
- return [
722
- 2,
723
- cached.version
724
- ];
725
- }
726
- headers = {};
727
- if (metadata === null || metadata === void 0 ? void 0 : metadata.etag) {
728
- headers["If-None-Match"] = metadata.etag;
729
- }
730
- if (metadata === null || metadata === void 0 ? void 0 : metadata.lastModified) {
731
- headers["If-Modified-Since"] = metadata.lastModified;
732
- }
733
- _state.label = 3;
734
- case 3:
735
- _state.trys.push([
736
- 3,
737
- 8,
738
- ,
739
- 9
740
- ]);
741
- return [
742
- 4,
743
- (0, import_node_fetch.default)("https://registry.npmjs.org/".concat(packageName, "/latest"), {
744
- headers: headers
745
- })
746
- ];
747
- case 4:
748
- response = _state.sent();
749
- if (response.status === 304 && cached) {
750
- return [
751
- 2,
752
- cached.version
753
- ];
754
- }
755
- if (!response.ok) {
756
- throw new Error("Failed to fetch latest version: ".concat(response.statusText));
757
- }
758
- return [
759
- 4,
760
- response.json()
761
- ];
762
- case 5:
763
- data = _state.sent();
764
- latestVersion = data.version;
765
- return [
766
- 4,
767
- storageServer.set(versionCacheKey, {
768
- version: latestVersion,
769
- timestamp: Date.now()
770
- })
771
- ];
772
- case 6:
773
- _state.sent();
774
- return [
775
- 4,
776
- storageServer.set(metadataCacheKey, {
777
- etag: response.headers.get("ETag") || void 0,
778
- lastModified: response.headers.get("Last-Modified") || void 0
779
- })
780
- ];
781
- case 7:
782
- _state.sent();
783
- return [
784
- 2,
785
- latestVersion
786
- ];
787
- case 8:
788
- error = _state.sent();
789
- commandLog.error("Error fetching latest version for ".concat(packageName, ": ").concat(error.message));
790
- if (cached) {
791
- commandLog.warning("Falling back to cached version for ".concat(packageName, ": ").concat(cached.version));
792
- return [
793
- 2,
794
- cached.version
795
- ];
796
- }
797
- throw error;
798
- case 9:
799
- return [
800
- 2
801
- ];
802
- }
803
- });
804
- });
805
- return _getLatestPackageVersion.apply(this, arguments);
806
- }
807
- function checkPackage(packageName) {
808
- return _checkPackage.apply(this, arguments);
809
- }
810
- function _checkPackage() {
811
- _checkPackage = _async_to_generator(function(packageName) {
812
- var result, packageFound, cyberskillPackageJsonPath, isCurrentProject, _tmp, error;
813
- return _ts_generator(this, function(_state) {
814
- switch(_state.label){
815
- case 0:
816
- result = {
817
- isInstalled: false,
818
- isCurrentProject: false,
819
- installedPath: "",
820
- installedVersion: "",
821
- latestVersion: "",
822
- file: {}
823
- };
824
- _state.label = 1;
825
- case 1:
826
- _state.trys.push([
827
- 1,
828
- 5,
829
- ,
830
- 6
831
- ]);
832
- packageFound = getPackageJson(packageName);
833
- if (!packageFound) {
834
- return [
835
- 2,
836
- result
837
- ];
838
- }
839
- cyberskillPackageJsonPath = resolveCyberSkillPath(PACKAGE_JSON);
840
- isCurrentProject = packageFound.path === cyberskillPackageJsonPath;
841
- result.file = packageFound.file;
842
- result.isInstalled = true;
843
- result.installedPath = packageFound.path;
844
- result.installedVersion = packageFound.file.version;
845
- result.isCurrentProject = isCurrentProject;
846
- if (!isCurrentProject) return [
847
- 3,
848
- 2
849
- ];
850
- _tmp = packageFound.file.version;
851
- return [
852
- 3,
853
- 4
854
- ];
855
- case 2:
856
- return [
857
- 4,
858
- getLatestPackageVersion(packageName, true)
859
- ];
860
- case 3:
861
- _tmp = _state.sent();
862
- _state.label = 4;
863
- case 4:
864
- result.latestVersion = _tmp;
865
- return [
866
- 2,
867
- result
868
- ];
869
- case 5:
870
- error = _state.sent();
871
- commandLog.error('Error checking package "'.concat(packageName, '": ').concat(error.message));
872
- return [
873
- 2,
874
- result
875
- ];
876
- case 6:
877
- return [
878
- 2
879
- ];
880
- }
881
- });
882
- });
883
- return _checkPackage.apply(this, arguments);
884
- }
885
- // src/utils/command.ts
886
- var DEBUG = import_node_process2.default.env.DEBUG === "true";
887
- var execPromise = util.promisify(import_node_child_process.exec);
888
- var _import_chalk_default = import_chalk.default, gray = _import_chalk_default.gray, blue = _import_chalk_default.blue;
889
- var getTimeStamp = function() {
890
- return gray("[".concat(/* @__PURE__ */ new Date().toLocaleTimeString(), "]"));
891
- };
892
- function chalkKeyword(color) {
893
- var chalkColor = import_chalk.default[color];
894
- return typeof chalkColor === "function" ? chalkColor : import_chalk.default.green;
895
- }
896
- function printLog(type, color, icon, message) {
897
- var chalkColor = chalkKeyword(color);
898
- console.log("".concat(getTimeStamp(), " ").concat(chalkColor("".concat(icon, " ").concat(type)), " ").concat(message));
899
- }
900
- function printBoxedLog(title, content) {
901
- var _ref = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, _ref_color = _ref.color, color = _ref_color === void 0 ? "green" : _ref_color, _ref_padding = _ref.padding, padding = _ref_padding === void 0 ? 1 : _ref_padding, _ref_margin = _ref.margin, margin = _ref_margin === void 0 ? 1 : _ref_margin, _ref_borderStyle = _ref.borderStyle, borderStyle = _ref_borderStyle === void 0 ? "round" : _ref_borderStyle, _ref_titleColor = _ref.titleColor, titleColor = _ref_titleColor === void 0 ? "bold" : _ref_titleColor;
902
- var chalkColor = chalkKeyword(color);
903
- var chalkTitleColor = chalkKeyword(titleColor);
904
- if (typeof content === "string") {
905
- console.log((0, import_boxen.default)(chalkTitleColor(chalkColor("".concat(title, "\n").concat(content))), {
906
- padding: padding,
907
- margin: margin,
908
- borderStyle: borderStyle,
909
- borderColor: color
910
- }));
911
- return;
912
- }
913
- if (Array.isArray(content) && content.length) {
914
- content.forEach(function(param) {
915
- var file = param.file, position = param.position, rule = param.rule, message = param.message;
916
- console.log("".concat(getTimeStamp(), " ").concat(chalkColor("File:"), " ").concat(blue("".concat(file).concat(position ? ":".concat(position) : ""))));
917
- if (rule) console.log(" ".concat(chalkColor("Rule:"), " ").concat(chalkColor(rule)));
918
- console.log(" ".concat(chalkColor("Message:"), " ").concat(chalkColor(message)));
919
- });
920
- console.log((0, import_boxen.default)(chalkTitleColor(chalkColor("".concat(title, ": ").concat(content.length))), {
921
- padding: padding,
922
- margin: margin,
923
- borderStyle: borderStyle,
924
- borderColor: color
925
- }));
926
- console.log(gray("\u2500".repeat(40)));
927
- }
928
- }
929
- var commandLog = {
930
- success: function(message) {
931
- return printLog("SUCCESS", "green", "\u2714", message);
932
- },
933
- error: function(message) {
934
- return printLog("ERROR", "red", "\u2716", message);
935
- },
936
- warning: function(message) {
937
- return printLog("WARNING", "yellow", "\u26A0", message);
938
- },
939
- info: function(message) {
940
- return printLog("INFO", "blue", "\u2139", message);
941
- },
942
- printBoxedLog: printBoxedLog
943
- };
944
- var getErrorListKey = function(timestamp) {
945
- return "error_list:".concat(timestamp);
946
- };
947
- function saveErrorListToStorage(errorList) {
948
- return _saveErrorListToStorage.apply(this, arguments);
949
- }
950
- function _saveErrorListToStorage() {
951
- _saveErrorListToStorage = _async_to_generator(function(errorList) {
952
- var timestamp, key, error;
953
- return _ts_generator(this, function(_state) {
954
- switch(_state.label){
955
- case 0:
956
- if (errorList.length === 0) {
957
- return [
958
- 2
959
- ];
960
- }
961
- timestamp = Date.now();
962
- key = getErrorListKey(timestamp);
963
- _state.label = 1;
964
- case 1:
965
- _state.trys.push([
966
- 1,
967
- 3,
968
- ,
969
- 4
970
- ]);
971
- return [
972
- 4,
973
- storageServer.set(key, {
974
- errors: errorList,
975
- timestamp: timestamp
976
- })
977
- ];
978
- case 2:
979
- _state.sent();
980
- setTimeout(/*#__PURE__*/ _async_to_generator(function() {
981
- var logPath;
982
- return _ts_generator(this, function(_state) {
983
- switch(_state.label){
984
- case 0:
985
- return [
986
- 4,
987
- storageServer.getLogLink(key)
988
- ];
989
- case 1:
990
- logPath = _state.sent();
991
- if (logPath) {
992
- commandLog.info("\uD83D\uDCC2 Open the error list manually: ".concat(logPath));
993
- }
994
- return [
995
- 2
996
- ];
997
- }
998
- });
999
- }), 10);
1000
- return [
1001
- 3,
1002
- 4
1003
- ];
1004
- case 3:
1005
- error = _state.sent();
1006
- commandLog.error("Failed to save errors: ".concat(error.message));
1007
- return [
1008
- 3,
1009
- 4
1010
- ];
1011
- case 4:
1012
- return [
1013
- 2
1014
- ];
1015
- }
1016
- });
1017
- });
1018
- return _saveErrorListToStorage.apply(this, arguments);
1019
- }
1020
- function getStoredErrorLists() {
1021
- return _getStoredErrorLists.apply(this, arguments);
1022
- }
1023
- function _getStoredErrorLists() {
1024
- _getStoredErrorLists = _async_to_generator(function() {
1025
- var keys, errorKeys, allErrors, error;
1026
- return _ts_generator(this, function(_state) {
1027
- switch(_state.label){
1028
- case 0:
1029
- _state.trys.push([
1030
- 0,
1031
- 3,
1032
- ,
1033
- 4
1034
- ]);
1035
- return [
1036
- 4,
1037
- storageServer.keys()
1038
- ];
1039
- case 1:
1040
- keys = _state.sent();
1041
- errorKeys = Array.isArray(keys) ? keys.filter(function(key) {
1042
- var _key_startsWith;
1043
- return key === null || key === void 0 ? void 0 : (_key_startsWith = key.startsWith) === null || _key_startsWith === void 0 ? void 0 : _key_startsWith.call(key, "error_list:");
1044
- }) : [];
1045
- return [
1046
- 4,
1047
- Promise.all(errorKeys.map(/*#__PURE__*/ function() {
1048
- var _ref = _async_to_generator(function(key) {
1049
- var entry;
1050
- return _ts_generator(this, function(_state) {
1051
- switch(_state.label){
1052
- case 0:
1053
- return [
1054
- 4,
1055
- storageServer.get(key)
1056
- ];
1057
- case 1:
1058
- entry = _state.sent();
1059
- return [
1060
- 2,
1061
- (entry === null || entry === void 0 ? void 0 : entry.errors) || []
1062
- ];
1063
- }
1064
- });
1065
- });
1066
- return function(key) {
1067
- return _ref.apply(this, arguments);
1068
- };
1069
- }()))
1070
- ];
1071
- case 2:
1072
- allErrors = _state.sent();
1073
- return [
1074
- 2,
1075
- allErrors.flat()
1076
- ];
1077
- case 3:
1078
- error = _state.sent();
1079
- commandLog.error("Failed to retrieve stored errors: ".concat(error.message));
1080
- return [
1081
- 2,
1082
- []
1083
- ];
1084
- case 4:
1085
- return [
1086
- 2
1087
- ];
1088
- }
1089
- });
1090
- });
1091
- return _getStoredErrorLists.apply(this, arguments);
1092
- }
1093
- function clearAllErrorLists() {
1094
- return _clearAllErrorLists.apply(this, arguments);
1095
- }
1096
- function _clearAllErrorLists() {
1097
- _clearAllErrorLists = _async_to_generator(function() {
1098
- var keys, errorKeys, error;
1099
- return _ts_generator(this, function(_state) {
1100
- switch(_state.label){
1101
- case 0:
1102
- _state.trys.push([
1103
- 0,
1104
- 3,
1105
- ,
1106
- 4
1107
- ]);
1108
- return [
1109
- 4,
1110
- storageServer.keys()
1111
- ];
1112
- case 1:
1113
- keys = _state.sent();
1114
- errorKeys = Array.isArray(keys) ? keys.filter(function(key) {
1115
- var _key_startsWith;
1116
- return key === null || key === void 0 ? void 0 : (_key_startsWith = key.startsWith) === null || _key_startsWith === void 0 ? void 0 : _key_startsWith.call(key, "error_list:");
1117
- }) : [];
1118
- return [
1119
- 4,
1120
- Promise.all(errorKeys.map(function(key) {
1121
- return storageServer.remove(key);
1122
- }))
1123
- ];
1124
- case 2:
1125
- _state.sent();
1126
- return [
1127
- 3,
1128
- 4
1129
- ];
1130
- case 3:
1131
- error = _state.sent();
1132
- commandLog.error("Failed to clear error lists: ".concat(error.message));
1133
- return [
1134
- 3,
1135
- 4
1136
- ];
1137
- case 4:
1138
- return [
1139
- 2
1140
- ];
1141
- }
1142
- });
1143
- });
1144
- return _clearAllErrorLists.apply(this, arguments);
1145
- }
1146
- function parseTextErrors(output) {
1147
- var errorList = [];
1148
- var unmatchedLines = [];
1149
- var lastFilePath = "";
1150
- var eslintErrorDetailsRegex = /^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/;
1151
- var tsRegex = /^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/;
1152
- var commitlintRegex = /^✖\s+(.*?)\s+\[(.*?)\]$/;
1153
- output.split("\n").forEach(function(line) {
1154
- if (line.startsWith("/")) {
1155
- lastFilePath = line.trim();
1156
- } else {
1157
- var eslintMatch = eslintErrorDetailsRegex.exec(line) || [];
1158
- var tsMatch = tsRegex.exec(line) || [];
1159
- var commitlintMatch = commitlintRegex.exec(line) || [];
1160
- if (eslintMatch.length && lastFilePath) {
1161
- errorList.push({
1162
- file: lastFilePath,
1163
- position: "".concat(eslintMatch[1], ":").concat(eslintMatch[2]),
1164
- type: eslintMatch[3] === "error" /* Error */ ? "error" /* Error */ : "warning" /* Warning */ ,
1165
- message: eslintMatch[4].trim(),
1166
- rule: eslintMatch[5].trim()
1167
- });
1168
- } else if (tsMatch.length) {
1169
- errorList.push({
1170
- file: tsMatch[1],
1171
- position: "".concat(tsMatch[2], ":").concat(tsMatch[3]),
1172
- type: tsMatch[4] === "error" /* Error */ ? "error" /* Error */ : "warning" /* Warning */ ,
1173
- message: tsMatch[5].trim()
1174
- });
1175
- } else if (commitlintMatch.length) {
1176
- errorList.push({
1177
- file: "commitlint",
1178
- type: "error" /* Error */ ,
1179
- message: commitlintMatch[1].trim(),
1180
- rule: commitlintMatch[2].trim()
1181
- });
1182
- } else {
1183
- unmatchedLines.push(line.trim());
1184
- }
1185
- }
1186
- });
1187
- if (errorList.length) {
1188
- saveErrorListToStorage(errorList);
1189
- }
1190
- if (unmatchedLines.length && DEBUG) {
1191
- commandLog.warning("Unmatched lines:");
1192
- unmatchedLines.forEach(function(line) {
1193
- return console.log(" ".concat(line));
1194
- });
1195
- }
1196
- }
1197
- function parseCommandOutput(output) {
1198
- try {
1199
- var results = JSON.parse(output);
1200
- var errorList = [];
1201
- results.forEach(function(param) {
1202
- var filePath = param.filePath, messages = param.messages;
1203
- messages.forEach(function(param) {
1204
- var severity = param.severity, line = param.line, column = param.column, ruleId = param.ruleId, message = param.message;
1205
- errorList.push({
1206
- type: severity === 2 ? "error" /* Error */ : "warning" /* Warning */ ,
1207
- file: filePath,
1208
- position: "".concat(line, ":").concat(column),
1209
- rule: ruleId,
1210
- message: message
1211
- });
1212
- });
1213
- });
1214
- if (errorList.length) {
1215
- saveErrorListToStorage(errorList);
1216
- }
1217
- } catch (e) {
1218
- parseTextErrors(output);
1219
- }
1220
- }
1221
- function executeCommand(command) {
1222
- return _executeCommand.apply(this, arguments);
1223
- }
1224
- function _executeCommand() {
1225
- _executeCommand = _async_to_generator(function(command) {
1226
- var parser, controller, _ref, stdout, stderr, error, stdout1, stderr1, message;
1227
- var _arguments = arguments;
1228
- return _ts_generator(this, function(_state) {
1229
- switch(_state.label){
1230
- case 0:
1231
- parser = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : parseCommandOutput;
1232
- controller = new AbortController();
1233
- import_node_process2.default.on("SIGINT", function() {
1234
- commandLog.warning("Process interrupted. Terminating...");
1235
- controller.abort();
1236
- import_node_process2.default.exit();
1237
- });
1238
- _state.label = 1;
1239
- case 1:
1240
- _state.trys.push([
1241
- 1,
1242
- 3,
1243
- ,
1244
- 4
1245
- ]);
1246
- return [
1247
- 4,
1248
- execPromise(command, {
1249
- maxBuffer: 1024 * 1024 * 100,
1250
- signal: controller.signal
1251
- })
1252
- ];
1253
- case 2:
1254
- _ref = _state.sent(), stdout = _ref.stdout, stderr = _ref.stderr;
1255
- [
1256
- stdout,
1257
- stderr
1258
- ].forEach(function(output) {
1259
- return output && parser(output);
1260
- });
1261
- return [
1262
- 3,
1263
- 4
1264
- ];
1265
- case 3:
1266
- error = _state.sent();
1267
- stdout1 = error.stdout, stderr1 = error.stderr, message = error.message;
1268
- [
1269
- stdout1,
1270
- stderr1
1271
- ].forEach(function(output) {
1272
- return output && parser(output);
1273
- });
1274
- if (!stderr1 && !stdout1) {
1275
- commandLog.error("Command failed: ".concat(message));
1276
- }
1277
- return [
1278
- 3,
1279
- 4
1280
- ];
1281
- case 4:
1282
- return [
1283
- 2
1284
- ];
1285
- }
1286
- });
1287
- });
1288
- return _executeCommand.apply(this, arguments);
1289
- }
1290
- var commandFormatter = {
1291
- raw: function(cmd) {
1292
- return {
1293
- raw: true,
1294
- cmd: cmd
1295
- };
1296
- },
1297
- isRaw: function isRaw(cmd) {
1298
- return (typeof cmd === "undefined" ? "undefined" : _type_of(cmd)) === "object" && cmd !== null && cmd.raw === true;
1299
- },
1300
- format: function format(command, context) {
1301
- if (typeof command === "function") {
1302
- return commandFormatter.formatCLI(command(context), context);
1303
- }
1304
- if (commandFormatter.isRaw(command)) {
1305
- return command.cmd;
1306
- }
1307
- return commandFormatter.formatCLI(command, context);
1308
- },
1309
- formatCLI: function formatCLI(command, context) {
1310
- if (context === null || context === void 0 ? void 0 : context.isRemote) {
1311
- return "".concat(PNPM_DLX_CLI, " ").concat(CYBERSKILL_PACKAGE_NAME, " ").concat(command);
1312
- }
1313
- if (context === null || context === void 0 ? void 0 : context.isCurrentProject) {
1314
- return "".concat(PNPM_EXEC_CLI, " ").concat(TSX_CLI, " src/cli.ts ").concat(command);
1315
- }
1316
- return "".concat(PNPM_EXEC_CLI, " ").concat(CYBERSKILL_CLI, " ").concat(command);
1317
- }
1318
- };
1319
- function resolveCommands(input) {
1320
- return _resolveCommands.apply(this, arguments);
1321
- }
1322
- function _resolveCommands() {
1323
- _resolveCommands = _async_to_generator(function(input) {
1324
- var context, _context_isRemote, isRemote, isCurrentProject, _tmp, ctx, commands;
1325
- var _arguments = arguments;
1326
- return _ts_generator(this, function(_state) {
1327
- switch(_state.label){
1328
- case 0:
1329
- context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
1330
- isRemote = (_context_isRemote = context === null || context === void 0 ? void 0 : context.isRemote) !== null && _context_isRemote !== void 0 ? _context_isRemote : false;
1331
- if (!isRemote) return [
1332
- 3,
1333
- 1
1334
- ];
1335
- _tmp = false;
1336
- return [
1337
- 3,
1338
- 3
1339
- ];
1340
- case 1:
1341
- return [
1342
- 4,
1343
- checkPackage(CYBERSKILL_PACKAGE_NAME)
1344
- ];
1345
- case 2:
1346
- _tmp = _state.sent().isCurrentProject;
1347
- _state.label = 3;
1348
- case 3:
1349
- isCurrentProject = _tmp;
1350
- ctx = {
1351
- isRemote: isRemote,
1352
- isCurrentProject: isCurrentProject
1353
- };
1354
- commands = typeof input === "function" ? input(ctx) : input;
1355
- return [
1356
- 2,
1357
- Object.fromEntries(Object.entries(commands).map(function(param) {
1358
- var _param = _sliced_to_array(param, 2), key = _param[0], cmd = _param[1];
1359
- return [
1360
- key,
1361
- commandFormatter.format(cmd, ctx)
1362
- ];
1363
- }))
1364
- ];
1365
- }
1366
- });
1367
- });
1368
- return _resolveCommands.apply(this, arguments);
1369
- }
1370
- // src/constants/path.ts
1371
- var __filename2 = (0, import_node_url.fileURLToPath)(importMetaUrl);
1372
- var __dirname = dirname2(__filename2);
1373
- var CYBERSKILL_DIRECTORY = resolve2(__dirname, "../../");
1374
- var WORKING_DIRECTORY = import_node_process3.default.env.INIT_CWD || import_node_process3.default.cwd();
1375
- var CYBERSKILL_PACKAGE_NAME = "@cyberskill/shared";
1376
- var CYBERSKILL_STORAGE = ".cyberskill-storage";
1377
- var NODE_MODULES = "node_modules";
1378
- var BUILD_DIRECTORY = "dist";
1379
- var PACKAGE_JSON = "package.json";
1380
- var PACKAGE_LOCK_JSON = "package-lock.json";
1381
- var TSCONFIG_JSON = "tsconfig.json";
1382
- var GIT_IGNORE = ".gitignore";
1383
- var SIMPLE_GIT_HOOK_JSON = ".simple-git-hooks.json";
1384
- var PNPM_LOCK_YAML = "pnpm-lock.yaml";
1385
- var GIT_HOOK = ".git/hooks";
1386
- var GIT_COMMIT_EDITMSG = ".git/COMMIT_EDITMSG";
1387
- var CYBERSKILL_CLI = "cyberskill";
1388
- var ESLINT_CLI = "eslint";
1389
- var VITEST_CLI = "vitest";
1390
- var COMMIT_LINT_CLI = "commitlint";
1391
- var LINT_STAGED_CLI = "lint-staged";
1392
- var RIMRAF_CLI = "rimraf";
1393
- var TSC_CLI = "tsc";
1394
- var TSX_CLI = "tsx";
1395
- var GIT_CLI = "git";
1396
- var PNPM_CLI = "pnpm";
1397
- var PNPM_DLX_CLI = "pnpm dlx";
1398
- var PNPM_EXEC_CLI = "pnpm exec";
1399
- var SIMPLE_GIT_HOOK_CLI = "simple-git-hooks";
1400
- var ESLINT_INSPECT_CLI = "@eslint/config-inspector";
1401
- var NODE_MODULES_INSPECT_CLI = "node_modules-inspect";
1402
- var PATH = {
1403
- CYBERSKILL_DIRECTORY: CYBERSKILL_DIRECTORY,
1404
- WORKING_DIRECTORY: WORKING_DIRECTORY,
1405
- TS_CONFIG: resolveWorkingPath(TSCONFIG_JSON),
1406
- GIT_IGNORE: resolveWorkingPath(GIT_IGNORE),
1407
- GIT_HOOK: resolveWorkingPath(GIT_HOOK),
1408
- GIT_COMMIT_MSG: resolveWorkingPath(GIT_COMMIT_EDITMSG),
1409
- SIMPLE_GIT_HOOKS_JSON: resolveWorkingPath(SIMPLE_GIT_HOOK_JSON),
1410
- PACKAGE_JSON: resolveWorkingPath(PACKAGE_JSON),
1411
- PACKAGE_LOCK_JSON: resolveWorkingPath(PACKAGE_LOCK_JSON),
1412
- PNPM_LOCK_YAML: resolveWorkingPath(PNPM_LOCK_YAML),
1413
- NODE_MODULES: resolveWorkingPath(NODE_MODULES),
1414
- CYBERSKILL: {
1415
- LINT_STAGED_CONFIG: resolveCyberSkillPath("./configs/lint-staged/base.js"),
1416
- COMMITLINT_CONFIG: resolveCyberSkillPath("./configs/commitlint/base.js"),
1417
- UNIT_TEST_CONFIG: resolveCyberSkillPath("./configs/vitest/react/unit.js"),
1418
- E2E_TEST_CONFIG: resolveCyberSkillPath("./configs/vitest/react/e2e.js")
1419
- }
1420
- };
1421
- function HOOK(param) {
1422
- var isCurrentProject = param.isCurrentProject;
1423
- return _object_spread({
1424
- "pre-commit": LINT_STAGED_CLI,
1425
- "commit-msg": COMMIT_LINT_CLI
1426
- }, isCurrentProject && {
1427
- "pre-push": commandFormatter.raw("".concat(GIT_CLI, " pull"))
1428
- });
1429
- }
1430
- var COMMAND = {
1431
- SIMPLE_GIT_HOOKS: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(SIMPLE_GIT_HOOK_CLI)),
1432
- ESLINT_INSPECT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_INSPECT_CLI)),
1433
- NODE_MODULES_INSPECT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(NODE_MODULES_INSPECT_CLI)),
1434
- RESET: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(RIMRAF_CLI, " ").concat(NODE_MODULES, " ").concat(PNPM_LOCK_YAML)),
1435
- ESLINT_CHECK: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_CLI, " ").concat(PATH.WORKING_DIRECTORY)),
1436
- ESLINT_FIX: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_CLI, " ").concat(PATH.WORKING_DIRECTORY, " --fix")),
1437
- TYPESCRIPT_CHECK: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(TSC_CLI, " -p ").concat(PATH.TS_CONFIG, " --noEmit")),
1438
- CYBERSKILL: {
1439
- TEST_UNIT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(VITEST_CLI, " --config ").concat(PATH.CYBERSKILL.UNIT_TEST_CONFIG)),
1440
- TEST_E2E: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(VITEST_CLI, " --config ").concat(PATH.CYBERSKILL.E2E_TEST_CONFIG)),
1441
- COMMIT_LINT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(COMMIT_LINT_CLI, " --edit ").concat(PATH.GIT_COMMIT_MSG, " --config ").concat(PATH.CYBERSKILL.COMMITLINT_CONFIG)),
1442
- LINT_STAGED: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(LINT_STAGED_CLI, " --config ").concat(PATH.CYBERSKILL.LINT_STAGED_CONFIG))
1443
- },
1444
- CONFIGURE_GIT_HOOK: commandFormatter.raw("".concat(GIT_CLI, " config core.hooksPath ").concat(PATH.GIT_HOOK)),
1445
- BUILD: commandFormatter.raw("".concat(PNPM_CLI, " run build")),
1446
- STAGE_BUILD_DIRECTORY: commandFormatter.raw("".concat(GIT_CLI, " add ").concat(BUILD_DIRECTORY)),
1447
- PNPM_INSTALL_STANDARD: commandFormatter.raw("".concat(PNPM_CLI, " install")),
1448
- PNPM_INSTALL_LEGACY: commandFormatter.raw("".concat(PNPM_CLI, " install --legacy-peer-deps")),
1449
- PNPM_INSTALL_FORCE: commandFormatter.raw("".concat(PNPM_CLI, " install --force"))
1450
- };
1451
- function runCommand(description, command) {
1452
- return _runCommand.apply(this, arguments);
1453
- }
1454
- function _runCommand() {
1455
- _runCommand = // src/cli.ts
1456
- _async_to_generator(function(description, command) {
1457
- return _ts_generator(this, function(_state) {
1458
- switch(_state.label){
1459
- case 0:
1460
- commandLog.info("".concat(description, "..."));
1461
- return [
1462
- 4,
1463
- executeCommand(commandFormatter.format(command))
1464
- ];
1465
- case 1:
1466
- _state.sent();
1467
- commandLog.success("".concat(description, " completed successfully."));
1468
- return [
1469
- 2
1470
- ];
1471
- }
1472
- });
1473
- });
1474
- return _runCommand.apply(this, arguments);
1475
- }
1476
- function checkTypescript() {
1477
- return _checkTypescript.apply(this, arguments);
1478
- }
1479
- function _checkTypescript() {
1480
- _checkTypescript = _async_to_generator(function() {
1481
- return _ts_generator(this, function(_state) {
1482
- switch(_state.label){
1483
- case 0:
1484
- if (!existsSync2(PATH.TS_CONFIG)) return [
1485
- 3,
1486
- 2
1487
- ];
1488
- return [
1489
- 4,
1490
- runCommand("Performing TypeScript validation", COMMAND.TYPESCRIPT_CHECK)
1491
- ];
1492
- case 1:
1493
- _state.sent();
1494
- return [
1495
- 3,
1496
- 3
1497
- ];
1498
- case 2:
1499
- commandLog.warning("No TypeScript configuration found. Skipping type check.");
1500
- _state.label = 3;
1501
- case 3:
1502
- return [
1503
- 2
1504
- ];
1505
- }
1506
- });
1507
- });
1508
- return _checkTypescript.apply(this, arguments);
1509
- }
1510
- function checkEslint() {
1511
- return _checkEslint.apply(this, arguments);
1512
- }
1513
- function _checkEslint() {
1514
- _checkEslint = _async_to_generator(function() {
1515
- var fix;
1516
- var _arguments = arguments;
1517
- return _ts_generator(this, function(_state) {
1518
- switch(_state.label){
1519
- case 0:
1520
- fix = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : false;
1521
- if (!fix) return [
1522
- 3,
1523
- 2
1524
- ];
1525
- return [
1526
- 4,
1527
- runCommand("Running ESLint with auto-fix", COMMAND.ESLINT_FIX)
1528
- ];
1529
- case 1:
1530
- _state.sent();
1531
- return [
1532
- 3,
1533
- 4
1534
- ];
1535
- case 2:
1536
- return [
1537
- 4,
1538
- runCommand("Running ESLint check", COMMAND.ESLINT_CHECK)
1539
- ];
1540
- case 3:
1541
- _state.sent();
1542
- _state.label = 4;
1543
- case 4:
1544
- return [
1545
- 2
1546
- ];
1547
- }
1548
- });
1549
- });
1550
- return _checkEslint.apply(this, arguments);
1551
- }
1552
- function showCheckResult() {
1553
- return _showCheckResult.apply(this, arguments);
1554
- }
1555
- function _showCheckResult() {
1556
- _showCheckResult = _async_to_generator(function() {
1557
- var allResults, errors, warnings;
1558
- return _ts_generator(this, function(_state) {
1559
- switch(_state.label){
1560
- case 0:
1561
- return [
1562
- 4,
1563
- getStoredErrorLists()
1564
- ];
1565
- case 1:
1566
- allResults = _state.sent();
1567
- errors = allResults.filter(function(e) {
1568
- return e.type === "error" /* Error */ ;
1569
- });
1570
- warnings = allResults.filter(function(e) {
1571
- return e.type === "warning" /* Warning */ ;
1572
- });
1573
- if (!errors.length && !warnings.length) {
1574
- commandLog.printBoxedLog("\u2714 NO ISSUES FOUND", "", {
1575
- color: "green"
1576
- });
1577
- } else {
1578
- commandLog.printBoxedLog("\u26A0 Warnings", warnings, {
1579
- color: "yellow"
1580
- });
1581
- commandLog.printBoxedLog("\u2716 Errors", errors, {
1582
- color: "red"
1583
- });
1584
- }
1585
- return [
1586
- 2
1587
- ];
1588
- }
1589
- });
1590
- });
1591
- return _showCheckResult.apply(this, arguments);
1592
- }
1593
- function lintStaged() {
1594
- return _lintStaged.apply(this, arguments);
1595
- }
1596
- function _lintStaged() {
1597
- _lintStaged = _async_to_generator(function() {
1598
- var isCurrentProject, error;
1599
- return _ts_generator(this, function(_state) {
1600
- switch(_state.label){
1601
- case 0:
1602
- return [
1603
- 4,
1604
- checkPackage(CYBERSKILL_PACKAGE_NAME)
1605
- ];
1606
- case 1:
1607
- isCurrentProject = _state.sent().isCurrentProject;
1608
- if (!isCurrentProject) return [
1609
- 3,
1610
- 6
1611
- ];
1612
- _state.label = 2;
1613
- case 2:
1614
- _state.trys.push([
1615
- 2,
1616
- 5,
1617
- ,
1618
- 6
1619
- ]);
1620
- return [
1621
- 4,
1622
- runCommand("Building package: ".concat(CYBERSKILL_PACKAGE_NAME), COMMAND.BUILD)
1623
- ];
1624
- case 3:
1625
- _state.sent();
1626
- return [
1627
- 4,
1628
- runCommand("Staging build artifacts", COMMAND.STAGE_BUILD_DIRECTORY)
1629
- ];
1630
- case 4:
1631
- _state.sent();
1632
- return [
1633
- 3,
1634
- 6
1635
- ];
1636
- case 5:
1637
- error = _state.sent();
1638
- commandLog.error("Error building and staging ".concat(CYBERSKILL_PACKAGE_NAME, ": ").concat(error.message));
1639
- throw error;
1640
- case 6:
1641
- return [
1642
- 4,
1643
- runCommand("Executing lint-staged", COMMAND.CYBERSKILL.LINT_STAGED)
1644
- ];
1645
- case 7:
1646
- _state.sent();
1647
- showCheckResult();
1648
- return [
1649
- 2
1650
- ];
1651
- }
1652
- });
1653
- });
1654
- return _lintStaged.apply(this, arguments);
1655
- }
1656
- function inspectLint() {
1657
- return _inspectLint.apply(this, arguments);
1658
- }
1659
- function _inspectLint() {
1660
- _inspectLint = _async_to_generator(function() {
1661
- return _ts_generator(this, function(_state) {
1662
- switch(_state.label){
1663
- case 0:
1664
- return [
1665
- 4,
1666
- runCommand("Inspecting ESLint configuration", COMMAND.ESLINT_INSPECT)
1667
- ];
1668
- case 1:
1669
- _state.sent();
1670
- return [
1671
- 2
1672
- ];
1673
- }
1674
- });
1675
- });
1676
- return _inspectLint.apply(this, arguments);
1677
- }
1678
- function lintCheck() {
1679
- return _lintCheck.apply(this, arguments);
1680
- }
1681
- function _lintCheck() {
1682
- _lintCheck = _async_to_generator(function() {
1683
- return _ts_generator(this, function(_state) {
1684
- switch(_state.label){
1685
- case 0:
1686
- return [
1687
- 4,
1688
- clearAllErrorLists()
1689
- ];
1690
- case 1:
1691
- _state.sent();
1692
- return [
1693
- 4,
1694
- Promise.all([
1695
- checkTypescript(),
1696
- checkEslint()
1697
- ])
1698
- ];
1699
- case 2:
1700
- _state.sent();
1701
- showCheckResult();
1702
- return [
1703
- 2
1704
- ];
1705
- }
1706
- });
1707
- });
1708
- return _lintCheck.apply(this, arguments);
1709
- }
1710
- function lintFix() {
1711
- return _lintFix.apply(this, arguments);
1712
- }
1713
- function _lintFix() {
1714
- _lintFix = _async_to_generator(function() {
1715
- return _ts_generator(this, function(_state) {
1716
- switch(_state.label){
1717
- case 0:
1718
- return [
1719
- 4,
1720
- clearAllErrorLists()
1721
- ];
1722
- case 1:
1723
- _state.sent();
1724
- return [
1725
- 4,
1726
- Promise.all([
1727
- checkTypescript(),
1728
- checkEslint(true)
1729
- ])
1730
- ];
1731
- case 2:
1732
- _state.sent();
1733
- showCheckResult();
1734
- return [
1735
- 2
1736
- ];
1737
- }
1738
- });
1739
- });
1740
- return _lintFix.apply(this, arguments);
1741
- }
1742
- function commitLint() {
1743
- return _commitLint.apply(this, arguments);
1744
- }
1745
- function _commitLint() {
1746
- _commitLint = _async_to_generator(function() {
1747
- return _ts_generator(this, function(_state) {
1748
- switch(_state.label){
1749
- case 0:
1750
- return [
1751
- 4,
1752
- runCommand("Validating commit message", COMMAND.CYBERSKILL.COMMIT_LINT)
1753
- ];
1754
- case 1:
1755
- _state.sent();
1756
- showCheckResult();
1757
- return [
1758
- 2
1759
- ];
1760
- }
1761
- });
1762
- });
1763
- return _commitLint.apply(this, arguments);
1764
- }
1765
- function setupGitHook() {
1766
- return _setupGitHook.apply(this, arguments);
1767
- }
1768
- function _setupGitHook() {
1769
- _setupGitHook = _async_to_generator(function() {
1770
- var hooks, gitIgnoreEntry, gitignore;
1771
- return _ts_generator(this, function(_state) {
1772
- switch(_state.label){
1773
- case 0:
1774
- rmSync2([
1775
- PATH.GIT_HOOK
1776
- ]);
1777
- return [
1778
- 4,
1779
- runCommand("Configuring Git hooks", COMMAND.CONFIGURE_GIT_HOOK)
1780
- ];
1781
- case 1:
1782
- _state.sent();
1783
- return [
1784
- 4,
1785
- resolveCommands(HOOK)
1786
- ];
1787
- case 2:
1788
- hooks = _state.sent();
1789
- writeFileSync2(PATH.SIMPLE_GIT_HOOKS_JSON, hooks, {
1790
- isJson: true
1791
- });
1792
- gitIgnoreEntry = "\n".concat(SIMPLE_GIT_HOOK_JSON, "\n");
1793
- if (existsSync2(PATH.GIT_IGNORE)) {
1794
- gitignore = readFileSync2(PATH.GIT_IGNORE).split("\n");
1795
- if (!gitignore.includes(SIMPLE_GIT_HOOK_JSON)) {
1796
- appendFileSync2(PATH.GIT_IGNORE, gitIgnoreEntry);
1797
- }
1798
- } else {
1799
- writeFileSync2(PATH.GIT_IGNORE, gitIgnoreEntry);
1800
- }
1801
- return [
1802
- 4,
1803
- runCommand("Installing simple-git-hooks", COMMAND.SIMPLE_GIT_HOOKS)
1804
- ];
1805
- case 3:
1806
- _state.sent();
1807
- return [
1808
- 2
1809
- ];
1810
- }
1811
- });
1812
- });
1813
- return _setupGitHook.apply(this, arguments);
1814
- }
1815
- function installDependencies() {
1816
- return _installDependencies.apply(this, arguments);
1817
- }
1818
- function _installDependencies() {
1819
- _installDependencies = _async_to_generator(function() {
1820
- var strategies, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, command, message, error, err;
1821
- return _ts_generator(this, function(_state) {
1822
- switch(_state.label){
1823
- case 0:
1824
- strategies = [
1825
- {
1826
- command: COMMAND.PNPM_INSTALL_STANDARD,
1827
- message: "Installing dependencies (standard)"
1828
- },
1829
- {
1830
- command: COMMAND.PNPM_INSTALL_LEGACY,
1831
- message: "Retrying with legacy peer dependencies"
1832
- },
1833
- {
1834
- command: COMMAND.PNPM_INSTALL_FORCE,
1835
- message: "Retrying with force install"
1836
- }
1837
- ];
1838
- _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1839
- _state.label = 1;
1840
- case 1:
1841
- _state.trys.push([
1842
- 1,
1843
- 8,
1844
- 9,
1845
- 10
1846
- ]);
1847
- _iterator = strategies[Symbol.iterator]();
1848
- _state.label = 2;
1849
- case 2:
1850
- if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
1851
- 3,
1852
- 7
1853
- ];
1854
- _step_value = _step.value, command = _step_value.command, message = _step_value.message;
1855
- _state.label = 3;
1856
- case 3:
1857
- _state.trys.push([
1858
- 3,
1859
- 5,
1860
- ,
1861
- 6
1862
- ]);
1863
- return [
1864
- 4,
1865
- runCommand("".concat(message, " using: ").concat(command.cmd), command)
1866
- ];
1867
- case 4:
1868
- _state.sent();
1869
- return [
1870
- 2
1871
- ];
1872
- case 5:
1873
- error = _state.sent();
1874
- commandLog.warning("Installation attempt failed: ".concat(command.cmd));
1875
- commandLog.error("Details: ".concat(error.message));
1876
- return [
1877
- 3,
1878
- 6
1879
- ];
1880
- case 6:
1881
- _iteratorNormalCompletion = true;
1882
- return [
1883
- 3,
1884
- 2
1885
- ];
1886
- case 7:
1887
- return [
1888
- 3,
1889
- 10
1890
- ];
1891
- case 8:
1892
- err = _state.sent();
1893
- _didIteratorError = true;
1894
- _iteratorError = err;
1895
- return [
1896
- 3,
1897
- 10
1898
- ];
1899
- case 9:
1900
- try {
1901
- if (!_iteratorNormalCompletion && _iterator.return != null) {
1902
- _iterator.return();
1903
- }
1904
- } finally{
1905
- if (_didIteratorError) {
1906
- throw _iteratorError;
1907
- }
1908
- }
1909
- return [
1910
- 7
1911
- ];
1912
- case 10:
1913
- throw new Error("All dependency installation strategies failed.");
1914
- }
1915
- });
1916
- });
1917
- return _installDependencies.apply(this, arguments);
1918
- }
1919
- function updatePackage(packageName) {
1920
- return _updatePackage.apply(this, arguments);
1921
- }
1922
- function _updatePackage() {
1923
- _updatePackage = _async_to_generator(function(packageName) {
1924
- var _ref, installedPath, latestVersion, file, error;
1925
- return _ts_generator(this, function(_state) {
1926
- switch(_state.label){
1927
- case 0:
1928
- _state.trys.push([
1929
- 0,
1930
- 4,
1931
- ,
1932
- 5
1933
- ]);
1934
- return [
1935
- 4,
1936
- checkPackage(packageName)
1937
- ];
1938
- case 1:
1939
- _ref = _state.sent(), installedPath = _ref.installedPath, latestVersion = _ref.latestVersion, file = _ref.file;
1940
- file.dependencies = _object_spread_props(_object_spread({}, file.dependencies), _define_property({}, file.name, latestVersion));
1941
- writeFileSync2(installedPath, file, {
1942
- isJson: true
1943
- });
1944
- return [
1945
- 4,
1946
- installDependencies()
1947
- ];
1948
- case 2:
1949
- _state.sent();
1950
- return [
1951
- 4,
1952
- lintFix()
1953
- ];
1954
- case 3:
1955
- _state.sent();
1956
- return [
1957
- 3,
1958
- 5
1959
- ];
1960
- case 4:
1961
- error = _state.sent();
1962
- commandLog.error('Failed to update "'.concat(packageName, '": ').concat(error.message));
1963
- throw error;
1964
- case 5:
1965
- return [
1966
- 2
1967
- ];
1968
- }
1969
- });
1970
- });
1971
- return _updatePackage.apply(this, arguments);
1972
- }
1973
- function setup() {
1974
- return _setup.apply(this, arguments);
1975
- }
1976
- function _setup() {
1977
- _setup = _async_to_generator(function() {
1978
- var _ref, isInstalled, installedVersion, latestVersion, isCurrentProject, isUpToDate, error;
1979
- return _ts_generator(this, function(_state) {
1980
- switch(_state.label){
1981
- case 0:
1982
- if (!existsSync2(PATH.PACKAGE_JSON)) {
1983
- commandLog.error("package.json not found. Aborting setup.");
1984
- return [
1985
- 2
1986
- ];
1987
- }
1988
- _state.label = 1;
1989
- case 1:
1990
- _state.trys.push([
1991
- 1,
1992
- 7,
1993
- ,
1994
- 8
1995
- ]);
1996
- return [
1997
- 4,
1998
- checkPackage(CYBERSKILL_PACKAGE_NAME)
1999
- ];
2000
- case 2:
2001
- _ref = _state.sent(), isInstalled = _ref.isInstalled, installedVersion = _ref.installedVersion, latestVersion = _ref.latestVersion, isCurrentProject = _ref.isCurrentProject;
2002
- isUpToDate = isCurrentProject || isInstalled && installedVersion === latestVersion;
2003
- if (!isUpToDate) return [
2004
- 3,
2005
- 3
2006
- ];
2007
- commandLog.success("Cyberskill package is already up to date.");
2008
- return [
2009
- 3,
2010
- 5
2011
- ];
2012
- case 3:
2013
- return [
2014
- 4,
2015
- updatePackage(CYBERSKILL_PACKAGE_NAME)
2016
- ];
2017
- case 4:
2018
- _state.sent();
2019
- _state.label = 5;
2020
- case 5:
2021
- return [
2022
- 4,
2023
- setupGitHook()
2024
- ];
2025
- case 6:
2026
- _state.sent();
2027
- return [
2028
- 3,
2029
- 8
2030
- ];
2031
- case 7:
2032
- error = _state.sent();
2033
- commandLog.error("Project setup failed: ".concat(error.message));
2034
- throw error;
2035
- case 8:
2036
- return [
2037
- 2
2038
- ];
2039
- }
2040
- });
2041
- });
2042
- return _setup.apply(this, arguments);
2043
- }
2044
- function reset() {
2045
- return _reset.apply(this, arguments);
2046
- }
2047
- function _reset() {
2048
- _reset = _async_to_generator(function() {
2049
- return _ts_generator(this, function(_state) {
2050
- switch(_state.label){
2051
- case 0:
2052
- rmSync2([
2053
- PATH.NODE_MODULES,
2054
- PATH.PNPM_LOCK_YAML
2055
- ]);
2056
- return [
2057
- 4,
2058
- installDependencies()
2059
- ];
2060
- case 1:
2061
- _state.sent();
2062
- return [
2063
- 4,
2064
- setupGitHook()
2065
- ];
2066
- case 2:
2067
- _state.sent();
2068
- return [
2069
- 2
2070
- ];
2071
- }
2072
- });
2073
- });
2074
- return _reset.apply(this, arguments);
2075
- }
2076
- function inspect() {
2077
- return _inspect.apply(this, arguments);
2078
- }
2079
- function _inspect() {
2080
- _inspect = _async_to_generator(function() {
2081
- return _ts_generator(this, function(_state) {
2082
- switch(_state.label){
2083
- case 0:
2084
- return [
2085
- 4,
2086
- runCommand("Inspecting project dependencies", COMMAND.NODE_MODULES_INSPECT)
2087
- ];
2088
- case 1:
2089
- _state.sent();
2090
- return [
2091
- 2
2092
- ];
2093
- }
2094
- });
2095
- });
2096
- return _inspect.apply(this, arguments);
2097
- }
2098
- function testUnit() {
2099
- return _testUnit.apply(this, arguments);
2100
- }
2101
- function _testUnit() {
2102
- _testUnit = _async_to_generator(function() {
2103
- return _ts_generator(this, function(_state) {
2104
- switch(_state.label){
2105
- case 0:
2106
- return [
2107
- 4,
2108
- runCommand("Running unit tests", COMMAND.CYBERSKILL.TEST_UNIT)
2109
- ];
2110
- case 1:
2111
- _state.sent();
2112
- return [
2113
- 2
2114
- ];
2115
- }
2116
- });
2117
- });
2118
- return _testUnit.apply(this, arguments);
2119
- }
2120
- function testE2E() {
2121
- return _testE2E.apply(this, arguments);
2122
- }
2123
- function _testE2E() {
2124
- _testE2E = _async_to_generator(function() {
2125
- return _ts_generator(this, function(_state) {
2126
- switch(_state.label){
2127
- case 0:
2128
- return [
2129
- 4,
2130
- runCommand("Running end-to-end tests", COMMAND.CYBERSKILL.TEST_E2E)
2131
- ];
2132
- case 1:
2133
- _state.sent();
2134
- return [
2135
- 2
2136
- ];
2137
- }
2138
- });
2139
- });
2140
- return _testE2E.apply(this, arguments);
2141
- }
2142
- (0, import_yargs.default)((0, import_helpers.hideBin)(import_node_process4.default.argv)).scriptName(CYBERSKILL_CLI).usage("$0 <command> [options]").command("lint", "Check code for linting issues", lintCheck).command("lint:fix", "Fix linting issues automatically", lintFix).command("lint:inspect", "View active ESLint configuration", inspectLint).command("lint-staged", "Run lint checks on staged files", lintStaged).command("commitlint", "Validate commit message format", commitLint).command("setup", "Initialize project setup and dependencies", setup).command("reset", "Reset the project and reinstall dependencies", reset).command("inspect", "Analyze installed project dependencies", inspect).command("test:unit", "Run unit test suite", testUnit).command("test:e2e", "Run end-to-end test suite", testE2E).demandCommand(1, "Please specify a valid command.").strict().help().alias("h", "help").alias("v", "version").epilog('\u{1F4A1} Tip: Use "--help" with any command to see options\n').parse();
2143
- // Annotate the CommonJS export names for ESM import in node:
2144
- 0 && (module.exports = {
2145
- installDependencies: installDependencies,
2146
- updatePackage: updatePackage
2147
- });
2
+ "use strict";function e(e,t){if(t==null||t>e.length)t=e.length;for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(e){if(Array.isArray(e))return e}function n(t){if(Array.isArray(t))return e(t)}function r(e,t,n,r,i,a,c){try{var o=e[a](c);var s=o.value}catch(e){n(e);return}if(o.done){t(s)}else{Promise.resolve(s).then(r,i)}}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){var c=e.apply(t,n);function o(e){r(c,i,a,o,s,"next",e)}function s(e){r(c,i,a,o,s,"throw",e)}o(undefined)})}}function a(e,t,n){if(t in e){Object.defineProperty(e,t,{value:n,enumerable:true,configurable:true,writable:true})}else{e[t]=n}return e}function c(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function o(e,t){var n=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n==null)return;var r=[];var i=true;var a=false;var c,o;try{for(n=n.call(e);!(i=(c=n.next()).done);i=true){r.push(c.value);if(t&&r.length===t)break}}catch(e){a=true;o=e}finally{try{if(!i&&n["return"]!=null)n["return"]()}finally{if(a)throw o}}return r}function s(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var r=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}r.forEach(function(t){a(e,t,n[t])})}return e}function f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);if(t){r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})}n.push.apply(n,r)}return n}function p(e,t){t=t!=null?t:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}else{f(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function d(e,n){return t(e)||o(e,n)||y(e,n)||s()}function h(e){return n(e)||c(e)||y(e)||u()}function g(e){"@swc/helpers - typeof";return e&&typeof Symbol!=="undefined"&&e.constructor===Symbol?"symbol":typeof e}function y(t,n){if(!t)return;if(typeof t==="string")return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor)r=t.constructor.name;if(r==="Map"||r==="Set")return Array.from(r);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e(t,n)}function m(e,t){var n,r,i,a,c={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]};return a={next:o(0),"throw":o(1),"return":o(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(e){return function(t){return s([e,t])}}function s(a){if(n)throw new TypeError("Generator is already executing.");while(c)try{if(n=1,r&&(i=a[0]&2?r["return"]:a[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;if(r=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:c.label++;return{value:a[1],done:false};case 5:c.label++;r=a[1];a=[0];continue;case 7:a=c.ops.pop();c.trys.pop();continue;default:if(!(i=c.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){c=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){c.label=a[1];break}if(a[0]===6&&c.label<i[1]){c.label=i[1];i=a;break}if(i&&c.label<i[2]){c.label=i[2];c.ops.push(a);break}if(i[2])c.ops.pop();c.trys.pop();continue}a=t.call(e,c)}catch(e){a=[6,e];r=0}finally{n=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}var v=Object.create;var b=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var w=function(e,t,n,r){var i=true,a=false,c=undefined;if(t&&(typeof t==="undefined"?"undefined":g(t))=="object"||typeof t=="function")try{var o=function(){var i=u.value;!O.call(e,i)&&i!==n&&b(e,i,{get:function(){return t[i]},enumerable:!(r=E(t,i))||r.enumerable})};for(var s=I(t)[Symbol.iterator](),u;!(i=(u=s.next()).done);i=true)o()}catch(e){a=true;c=e}finally{try{if(!i&&s.return!=null){s.return()}}finally{if(a){throw c}}}return e};var _=function(e,t,n){return n=e!=null?v(S(e)):{},w(t||!e||!e.__esModule?b(n,"default",{value:e,enumerable:!0}):n,e)};var T=_(require("process"),1),C=require("yargs/helpers"),N=_(require("yargs/yargs"),1);var L=_(require("process"),1);var P=_(require("boxen"),1),A=_(require("chalk"),1),j=require("child_process"),R=_(require("process"),1),G=_(require("util"),1);var k=_(require("node-fetch"),1);var M=_(require("fs"),1),D=function(e){return M.existsSync(e)};function x(e,t){var n=M.readFileSync(e,"utf-8");if(t===null||t===void 0?void 0:t.asJson)try{var r=JSON.parse(n);if((typeof r==="undefined"?"undefined":g(r))=="object"&&r!==null)return r;throw new Error("Parsed JSON is not an object or array")}catch(t){throw new Error("Failed to parse JSON from file: ".concat(e))}return n}function K(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var r=n.isJson,i=r===void 0?!1:r,a=i&&(typeof t==="undefined"?"undefined":g(t))=="object"?JSON.stringify(t,null,4):String(t);M.writeFileSync(e,a,"utf-8")}function F(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var r=n.isJson,i=r===void 0?!1:r,a=i&&(typeof t==="undefined"?"undefined":g(t))=="object"?JSON.stringify(t,null,4):String(t);M.appendFileSync(e,a,"utf-8")}function B(e){e.forEach(function(e){D(e)&&M.rmSync(e,{recursive:!0,force:!0})})}var Y=_(require("path"),1);function U(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=Y).resolve.apply(r,[eP].concat(h(t)))}function J(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}var r;return(r=Y).join.apply(r,h(t))}var q=_(require("node-persist"),1),H=_(require("os"),1),V=_(require("process"),1);function W(){return V.default.env.CYBERSKILL_STORAGE_DIR||J(H.default.homedir(),ej)}function $(){return z.apply(this,arguments)}function z(){z=i(function(){var e;return m(this,function(t){switch(t.label){case 0:e=q.default.defaultInstance;if(e)return[3,2];return[4,q.default.init({dir:W(),stringify:JSON.stringify,parse:JSON.parse,encoding:"utf8",logging:!1,forgiveParseErrors:!0})];case 1:e=t.sent();t.label=2;case 2:e;return[2]}})});return z.apply(this,arguments)}var X={get:function e(e){return i(function(){var t,n;return m(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,$()];case 1:r.sent();return[4,q.default.getItem(e)];case 2:return[2,(t=r.sent())!==null&&t!==void 0?t:null];case 3:n=r.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),n),null)];case 4:return[2]}})})()},set:function e(e,t){return i(function(){var n;return m(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,$()];case 1:r.sent();return[4,q.default.setItem(e,t)];case 2:r.sent();return[3,4];case 3:n=r.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),n);return[3,4];case 4:return[2]}})})()},remove:function e(e){return i(function(){var t;return m(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,$()];case 1:n.sent();return[4,q.default.removeItem(e)];case 2:n.sent();return[3,4];case 3:t=n.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),t);return[3,4];case 4:return[2]}})})()},keys:function e(){return i(function(){var e,t;return m(this,function(n){switch(n.label){case 0:n.trys.push([0,3,,4]);return[4,$()];case 1:n.sent();return[4,q.default.keys()];case 2:e=n.sent();return[2,Array.isArray(e)?e:(console.warn("⚠️ [Storage:keys] Invalid keys response:",e),[])];case 3:t=n.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",t),[])];case 4:return[2]}})})()},getLogLink:function e(e){return i(function(){return m(this,function(t){try{return[2,"".concat(W()," (key: ").concat(e,")")]}catch(e){return[2,(console.error("❌ [Storage:getLogLink] Error getting log link:",e),null)]}return[2]})})()}};var Q=24*60*60*1e3;function Z(e){var t=J(eP,ek);if(D(t))try{var n=x(t,{asJson:!0});if(n.name===e)return{path:t,file:n,isCurrentProject:!0}}catch(e){ed.warning("Failed to read local package.json: ".concat(e.message))}var r=J(eP,eR,e,ek);if(D(r))try{var i=x(r,{asJson:!0});if(i.name===e)return{path:r,file:i,isCurrentProject:!1}}catch(t){ed.warning("Failed to read node_modules package.json for ".concat(e,": ").concat(t.message))}return!1}function ee(e){return et.apply(this,arguments)}function et(){et=i(function(e){var t,n,r,i,a,c,o,s,u,l;var f=arguments;return m(this,function(p){switch(p.label){case 0:t=f.length>1&&f[1]!==void 0?f[1]:!1;n="npm_version:".concat(e),r="npm_metadata:".concat(e);return[4,X.get(n)];case 1:i=p.sent();return[4,X.get(r)];case 2:a=p.sent(),c=i&&Date.now()-i.timestamp<Q;if(!t&&c)return[2,i.version];o={};(a===null||a===void 0?void 0:a.etag)&&(o["If-None-Match"]=a.etag),(a===null||a===void 0?void 0:a.lastModified)&&(o["If-Modified-Since"]=a.lastModified);p.label=3;case 3:p.trys.push([3,8,,9]);return[4,(0,k.default)("https://registry.npmjs.org/".concat(e,"/latest"),{headers:o})];case 4:s=p.sent();if(s.status===304&&i)return[2,i.version];if(!s.ok)throw new Error("Failed to fetch latest version: ".concat(s.statusText));return[4,s.json()];case 5:u=p.sent().version;return[4,X.set(n,{version:u,timestamp:Date.now()})];case 6:p.sent();return[4,X.set(r,{etag:s.headers.get("ETag")||void 0,lastModified:s.headers.get("Last-Modified")||void 0})];case 7:return[2,(p.sent(),u)];case 8:l=p.sent();if(ed.error("Error fetching latest version for ".concat(e,": ").concat(l.message)),i)return[2,(ed.warning("Falling back to cached version for ".concat(e,": ").concat(i.version)),i.version)];throw l;case 9:return[2]}})});return et.apply(this,arguments)}function en(e){return er.apply(this,arguments)}function er(){er=i(function(e){var t,n,r,i,a;return m(this,function(c){switch(c.label){case 0:t={isInstalled:!1,isCurrentProject:!1,installedPath:"",installedVersion:"",latestVersion:"",file:{}};c.label=1;case 1:c.trys.push([1,6,,7]);n=Z(e);r=n;if(!r)return[3,5];t.file=n.file,t.isInstalled=!0,t.installedPath=n.path,t.installedVersion=n.file.version,t.isCurrentProject=n.isCurrentProject;if(!n.isCurrentProject)return[3,2];i=n.file.version;return[3,4];case 2:return[4,ee(e,!0)];case 3:i=c.sent();c.label=4;case 4:r=t.latestVersion=i;c.label=5;case 5:return[2,(r,t)];case 6:a=c.sent();return[2,(ed.error('Error checking package "'.concat(e,'": ').concat(a.message)),t)];case 7:return[2]}})});return er.apply(this,arguments)}var ei=R.default.env.DEBUG==="true",ea=G.promisify(j.exec),ec=A.default,eo=ec.gray,es=ec.blue;function eu(){return eo("[".concat(new Date().toLocaleTimeString(),"]"))}function el(e){var t=A.default[e];return typeof t=="function"?t:A.default.green}function ef(e,t,n,r){var i=el(t);console.log("".concat(eu()," ").concat(i("".concat(n," ").concat(e))," ").concat(r))}function ep(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.color,i=r===void 0?"green":r,a=n.padding,c=a===void 0?1:a,o=n.margin,s=o===void 0?1:o,u=n.borderStyle,l=u===void 0?"round":u,f=n.titleColor,p=f===void 0?"bold":f;var d=el(i),h=el(p);if(typeof t=="string"){console.log((0,P.default)(h(d("".concat(e,"\n").concat(t))),{padding:c,margin:s,borderStyle:l,borderColor:i}));return}Array.isArray(t)&&t.length&&(t.forEach(function(e){var t=e.file,n=e.position,r=e.rule,i=e.message;console.log("".concat(eu()," ").concat(d("File:")," ").concat(es("".concat(t).concat(n?":".concat(n):"")))),r&&console.log(" ".concat(d("Rule:")," ").concat(d(r))),console.log(" ".concat(d("Message:")," ").concat(d(i)))}),console.log((0,P.default)(h(d("".concat(e,": ").concat(t.length))),{padding:c,margin:s,borderStyle:l,borderColor:i})),console.log(eo("─".repeat(40))))}var ed={success:function(e){return ef("SUCCESS","green","✔",e)},error:function(e){return ef("ERROR","red","✖",e)},warning:function(e){return ef("WARNING","yellow","⚠",e)},info:function(e){return ef("INFO","blue","ℹ",e)},printBoxedLog:ep};function eh(e){return"error_list:".concat(e)}function eg(e){return ey.apply(this,arguments)}function ey(){ey=i(function(e){var t,n,r;return m(this,function(a){switch(a.label){case 0:if(e.length===0)return[2];t=Date.now(),n=eh(t);a.label=1;case 1:a.trys.push([1,3,,4]);return[4,X.set(n,{errors:e,timestamp:t})];case 2:a.sent(),setTimeout(/*#__PURE__*/i(function(){var e;return m(this,function(t){switch(t.label){case 0:return[4,X.getLogLink(n)];case 1:e=t.sent();e&&ed.info("\uD83D\uDCC2 Open the error list manually: ".concat(e));return[2]}})}),10);return[3,4];case 3:r=a.sent();ed.error("Failed to save errors: ".concat(r.message));return[3,4];case 4:return[2]}})});return ey.apply(this,arguments)}function em(){return ev.apply(this,arguments)}function ev(){ev=i(function(){var e,t,n;return m(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,X.keys()];case 1:e=r.sent(),t=Array.isArray(e)?e.filter(function(e){var t;return e===null||e===void 0?void 0:(t=e.startsWith)===null||t===void 0?void 0:t.call(e,"error_list:")}):[];return[4,Promise.all(t.map(/*#__PURE__*/function(){var e=i(function(e){var t;return m(this,function(n){switch(n.label){case 0:return[4,X.get(e)];case 1:return[2,((t=n.sent())===null||t===void 0?void 0:t.errors)||[]]}})});return function(t){return e.apply(this,arguments)}}()))];case 2:return[2,r.sent().flat()];case 3:n=r.sent();return[2,(ed.error("Failed to retrieve stored errors: ".concat(n.message)),[])];case 4:return[2]}})});return ev.apply(this,arguments)}function eb(){return eE.apply(this,arguments)}function eE(){eE=i(function(){var e,t,n;return m(this,function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);return[4,X.keys()];case 1:e=r.sent(),t=Array.isArray(e)?e.filter(function(e){var t;return e===null||e===void 0?void 0:(t=e.startsWith)===null||t===void 0?void 0:t.call(e,"error_list:")}):[];return[4,Promise.all(t.map(function(e){return X.remove(e)}))];case 2:r.sent();return[3,4];case 3:n=r.sent();ed.error("Failed to clear error lists: ".concat(n.message));return[3,4];case 4:return[2]}})});return eE.apply(this,arguments)}function eI(e){var t=[],n=[],r="",i=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,a=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,c=/^✖\s+(.*?)\s+\[(.*?)\]$/;e.split("\n").forEach(function(e){if(e.startsWith("/"))r=e.trim();else{var o=i.exec(e)||[],s=a.exec(e)||[],u=c.exec(e)||[];o.length&&r?t.push({file:r,position:"".concat(o[1],":").concat(o[2]),type:o[3]==="error"?"error":"warning",message:o[4].trim(),rule:o[5].trim()}):s.length?t.push({file:s[1],position:"".concat(s[2],":").concat(s[3]),type:s[4]==="error"?"error":"warning",message:s[5].trim()}):u.length?t.push({file:"commitlint",type:"error",message:u[1].trim(),rule:u[2].trim()}):n.push(e.trim())}}),t.length&&eg(t),n.length&&ei&&(ed.warning("Unmatched lines:"),n.forEach(function(e){return console.log(" ".concat(e))}))}function eS(e){try{var t=JSON.parse(e),n=[];t.forEach(function(e){var t=e.filePath,r=e.messages;r.forEach(function(e){var r=e.severity,i=e.line,a=e.column,c=e.ruleId,o=e.message;n.push({type:r===2?"error":"warning",file:t,position:"".concat(i,":").concat(a),rule:c,message:o})})}),n.length&&eg(n)}catch(t){eI(e)}}function eO(e){return ew.apply(this,arguments)}function ew(){ew=i(function(e){var t,n,r,i,a,c,o,s,u;var l=arguments;return m(this,function(f){switch(f.label){case 0:t=l.length>1&&l[1]!==void 0?l[1]:eS;n=new AbortController;R.default.on("SIGINT",function(){ed.warning("Process interrupted. Terminating..."),n.abort(),R.default.exit()});f.label=1;case 1:f.trys.push([1,3,,4]);return[4,ea(e,{maxBuffer:0x6400000,signal:n.signal})];case 2:r=f.sent(),i=r.stdout,a=r.stderr;[i,a].forEach(function(e){return e&&t(e)});return[3,4];case 3:c=f.sent();o=c.stdout,s=c.stderr,u=c.message;[o,s].forEach(function(e){return e&&t(e)}),!s&&!o&&ed.error("Command failed: ".concat(u));return[3,4];case 4:return[2]}})});return ew.apply(this,arguments)}function e_(e){return{raw:!0,cmd:e}}function eT(e,t){return(t===null||t===void 0?void 0:t.isRemote)?"".concat(e4," ").concat(eA," ").concat(e):(t===null||t===void 0?void 0:t.isCurrentProject)?"".concat(e4," ").concat(e0," src/cli.ts ").concat(e):"".concat(e4," ").concat(eJ," ").concat(e)}function eC(e,t){return typeof e=="function"?eT(e(t),t):(typeof e==="undefined"?"undefined":g(e))=="object"&&(e===null||e===void 0?void 0:e.raw)===!0?e.cmd:typeof e=="string"?eT(e,t):e}function eN(e){return eL.apply(this,arguments)}function eL(){eL=i(function(e){var t,n,r,i,a,c,o;var s=arguments;return m(this,function(u){switch(u.label){case 0:t=s.length>1&&s[1]!==void 0?s[1]:{};r=(n=t===null||t===void 0?void 0:t.isRemote)!==null&&n!==void 0?n:!1;if(!r)return[3,1];o=!1;return[3,3];case 1:return[4,en(eA)];case 2:o=u.sent().isCurrentProject;u.label=3;case 3:i=o,a={isRemote:r,isCurrentProject:i},c=typeof e=="function"?e(a):e;return[2,Object.fromEntries(Object.entries(c).map(function(e){var t=d(e,2),n=t[0],r=t[1];return[n,eC(r,a)]}))]}})});return eL.apply(this,arguments)}var eP=L.default.env.INIT_CWD||L.default.cwd(),eA="@cyberskill/shared",ej=".cyberskill-storage",eR="node_modules",eG="dist",ek="package.json",eM="package-lock.json",eD="tsconfig.json",ex=".gitignore",eK=".simple-git-hooks.json",eF="pnpm-lock.yaml",eB=".git/hooks/",eY=".git/COMMIT_EDITMSG",eU=J(eP,eR,eA,eG),eJ="cyberskill",eq="eslint",eH="vitest",eV="vitest",eW="@commitlint/cli",e$="commitlint",ez="lint-staged",eX="lint-staged",eQ="tsc",eZ="tsc",e0="tsx",e1="git",e2="pnpm",e4="pnpm exec",e3="simple-git-hooks",e5="simple-git-hooks",e6="@eslint/config-inspector",e8="eslint-config-inspector",e7="node-modules-inspector",e9="node-modules-inspector",te={CYBERSKILL_DIRECTORY:eU,WORKING_DIRECTORY:eP,TS_CONFIG:U(eD),GIT_IGNORE:U(ex),GIT_HOOK:U(eB),GIT_COMMIT_MSG:U(eY),SIMPLE_GIT_HOOKS_JSON:U(eK),PACKAGE_JSON:U(ek),PACKAGE_LOCK_JSON:U(eM),PNPM_LOCK_YAML:U(eF),NODE_MODULES:U(eR),CYBERSKILL:{LINT_STAGED_CONFIG:U("".concat(eU,"/configs/lint-staged/base.js")),COMMITLINT_CONFIG:U("".concat(eU,"/configs/commitlint/base.js")),UNIT_TEST_CONFIG:U("".concat(eU,"/configs/vitest/react/unit.js")),E2E_TEST_CONFIG:U("".concat(eU,"/configs/vitest/react/e2e.js"))}};function tt(e){var t=e.isCurrentProject;return l({"pre-commit":eX,"commit-msg":e$},t&&{"pre-push":e_("".concat(e1," pull"))})}function tn(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++){n[r-1]=arguments[r]}var i=d(n,2),a=i[0],c=i[1];switch(e){case"pnpmAddAndExec":return eC(e_("".concat(e2," add -D ").concat(a," && ").concat(e4," ").concat(c)));case"pnpmExec":return eC(e_("".concat(e4," ").concat(a," ").concat(c||"").trim()));case"raw":return eC(e_(a))}}var tr={SIMPLE_GIT_HOOKS:tn("pnpmAddAndExec",e3,e5),ESLINT_INSPECT:tn("pnpmAddAndExec",e6,e8),NODE_MODULES_INSPECT:tn("pnpmAddAndExec",e7,e9),ESLINT_CHECK:tn("pnpmExec",eq,te.WORKING_DIRECTORY),ESLINT_FIX:tn("pnpmExec",eq,"".concat(te.WORKING_DIRECTORY," --fix")),TYPESCRIPT_CHECK:tn("pnpmAddAndExec",eQ,"".concat(eZ," -p ").concat(te.TS_CONFIG," --noEmit")),CONFIGURE_GIT_HOOK:tn("raw","".concat(e1," config core.hooksPath ").concat(te.GIT_HOOK)),BUILD:tn("raw","".concat(e2," run build")),STAGE_BUILD_DIRECTORY:tn("raw","".concat(e1," add ").concat(eG)),PNPM_INSTALL_STANDARD:tn("raw","".concat(e2," install")),PNPM_INSTALL_LEGACY:tn("raw","".concat(e2," install --legacy-peer-deps")),PNPM_INSTALL_FORCE:tn("raw","".concat(e2," install --force")),CYBERSKILL:{TEST_UNIT:tn("pnpmAddAndExec",eH,"".concat(eV," --config ").concat(te.CYBERSKILL.UNIT_TEST_CONFIG)),TEST_E2E:tn("pnpmAddAndExec",eH,"".concat(eV," --config ").concat(te.CYBERSKILL.E2E_TEST_CONFIG)),COMMIT_LINT:tn("pnpmAddAndExec",eW,"".concat(e$," --edit ").concat(te.GIT_COMMIT_MSG," --config ").concat(te.CYBERSKILL.COMMITLINT_CONFIG)),LINT_STAGED:tn("pnpmAddAndExec",ez,"".concat(eX," --config ").concat(te.CYBERSKILL.LINT_STAGED_CONFIG))}};function ti(e,t){return ta.apply(this,arguments)}function ta(){ta=i(function(e,t){return m(this,function(n){switch(n.label){case 0:ed.info("".concat(e,"..."));return[4,eO(t)];case 1:n.sent(),ed.success("".concat(e," completed successfully."));return[2]}})});return ta.apply(this,arguments)}function tc(){return to.apply(this,arguments)}function to(){to=i(function(){var e;return m(this,function(t){switch(t.label){case 0:if(!D(te.TS_CONFIG))return[3,2];return[4,ti("Performing TypeScript validation",tr.TYPESCRIPT_CHECK)];case 1:e=t.sent();return[3,3];case 2:e=ed.warning("No TypeScript configuration found. Skipping type check.");t.label=3;case 3:e;return[2]}})});return to.apply(this,arguments)}function ts(){return tu.apply(this,arguments)}function tu(){tu=i(function(){var e,t;var n=arguments;return m(this,function(r){switch(r.label){case 0:e=n.length>0&&n[0]!==void 0?n[0]:!1;if(!e)return[3,2];return[4,ti("Running ESLint with auto-fix",tr.ESLINT_FIX)];case 1:t=r.sent();return[3,4];case 2:return[4,ti("Running ESLint check",tr.ESLINT_CHECK)];case 3:t=r.sent();r.label=4;case 4:t;return[2]}})});return tu.apply(this,arguments)}function tl(){return tf.apply(this,arguments)}function tf(){tf=i(function(){var e,t,n;return m(this,function(r){switch(r.label){case 0:return[4,em()];case 1:e=r.sent(),t=e.filter(function(e){return e.type==="error"}),n=e.filter(function(e){return e.type==="warning"});!t.length&&!n.length?ed.printBoxedLog("✔ NO ISSUES FOUND","",{color:"green"}):(ed.printBoxedLog("⚠ Warnings",n,{color:"yellow"}),ed.printBoxedLog("✖ Errors",t,{color:"red"}));return[2]}})});return tf.apply(this,arguments)}function tp(){return td.apply(this,arguments)}function td(){td=i(function(){var e,t,n;return m(this,function(r){switch(r.label){case 0:return[4,eb()];case 1:r.sent();return[4,en(eA)];case 2:e=r.sent(),t=e.isCurrentProject;if(!t)return[3,7];r.label=3;case 3:r.trys.push([3,6,,7]);return[4,ti("Building package: ".concat(eA),tr.BUILD)];case 4:r.sent();return[4,ti("Staging build artifacts",tr.STAGE_BUILD_DIRECTORY)];case 5:r.sent();return[3,7];case 6:n=r.sent();throw ed.error("Error building and staging ".concat(eA,": ").concat(n.message)),n;case 7:return[4,ti("Executing lint-staged",tr.CYBERSKILL.LINT_STAGED)];case 8:r.sent(),tl();return[2]}})});return td.apply(this,arguments)}function th(){return tg.apply(this,arguments)}function tg(){tg=i(function(){return m(this,function(e){switch(e.label){case 0:return[4,ti("Inspecting ESLint configuration",tr.ESLINT_INSPECT)];case 1:e.sent();return[2]}})});return tg.apply(this,arguments)}function ty(){return tm.apply(this,arguments)}function tm(){tm=i(function(){return m(this,function(e){switch(e.label){case 0:return[4,eb()];case 1:e.sent();return[4,Promise.all([tc(),ts()])];case 2:e.sent(),tl();return[2]}})});return tm.apply(this,arguments)}function tv(){return tb.apply(this,arguments)}function tb(){tb=i(function(){return m(this,function(e){switch(e.label){case 0:return[4,eb()];case 1:e.sent();return[4,Promise.all([tc(),ts(!0)])];case 2:e.sent(),tl();return[2]}})});return tb.apply(this,arguments)}function tE(){return tI.apply(this,arguments)}function tI(){tI=i(function(){return m(this,function(e){switch(e.label){case 0:return[4,eb()];case 1:e.sent();return[4,ti("Validating commit message",tr.CYBERSKILL.COMMIT_LINT)];case 2:e.sent(),tl();return[2]}})});return tI.apply(this,arguments)}function tS(){return tO.apply(this,arguments)}function tO(){tO=i(function(){var e,t;return m(this,function(n){switch(n.label){case 0:return[4,ti("Configuring Git hooks",tr.CONFIGURE_GIT_HOOK)];case 1:n.sent(),B([te.GIT_HOOK]);return[4,eN(tt)];case 2:e=n.sent();K(te.SIMPLE_GIT_HOOKS_JSON,e,{isJson:!0});t="\n".concat(eK,"\n");D(te.GIT_IGNORE)?x(te.GIT_IGNORE).split("\n").includes(eK)||F(te.GIT_IGNORE,t):K(te.GIT_IGNORE,t);return[4,ti("Installing simple-git-hooks",tr.SIMPLE_GIT_HOOKS)];case 3:n.sent();return[2]}})});return tO.apply(this,arguments)}function tw(){return t_.apply(this,arguments)}function t_(){t_=i(function(){var e,t,n,r,i,a,c,o,s,u,l;return m(this,function(f){switch(f.label){case 0:e=[{command:tr.PNPM_INSTALL_STANDARD,message:"Installing dependencies (standard)"},{command:tr.PNPM_INSTALL_LEGACY,message:"Retrying with legacy peer dependencies"},{command:tr.PNPM_INSTALL_FORCE,message:"Retrying with force install"}];t=true,n=false,r=undefined;f.label=1;case 1:f.trys.push([1,8,9,10]);i=e[Symbol.iterator]();f.label=2;case 2:if(!!(t=(a=i.next()).done))return[3,7];c=a.value,o=c.command,s=c.message;f.label=3;case 3:f.trys.push([3,5,,6]);return[4,ti("".concat(s," using: ").concat(o),o)];case 4:f.sent();return[2];case 5:u=f.sent();ed.warning("Installation attempt failed: ".concat(o)),ed.error("Details: ".concat(u.message));return[3,6];case 6:t=true;return[3,2];case 7:return[3,10];case 8:l=f.sent();n=true;r=l;return[3,10];case 9:try{if(!t&&i.return!=null){i.return()}}finally{if(n){throw r}}return[7];case 10:throw new Error("All dependency installation strategies failed.")}})});return t_.apply(this,arguments)}function tT(e){return tC.apply(this,arguments)}function tC(){tC=i(function(e){var t,n,r,i,c;return m(this,function(o){switch(o.label){case 0:o.trys.push([0,4,,5]);return[4,en(e)];case 1:t=o.sent(),n=t.installedPath,r=t.latestVersion,i=t.file;i.dependencies=p(l({},i.dependencies),a({},i.name,r)),K(n,i,{isJson:!0});return[4,tw()];case 2:o.sent();return[4,tv()];case 3:o.sent();return[3,5];case 4:c=o.sent();throw ed.error('Failed to update "'.concat(e,'": ').concat(c.message)),c;case 5:return[2]}})});return tC.apply(this,arguments)}function tN(){return tL.apply(this,arguments)}function tL(){tL=i(function(){var e,t,n,r,i,a,c;return m(this,function(o){switch(o.label){case 0:if(!D(te.PACKAGE_JSON)){ed.error("package.json not found. Aborting setup.");return[2]}o.label=1;case 1:o.trys.push([1,7,,8]);return[4,en(eA)];case 2:e=o.sent(),t=e.isInstalled,n=e.installedVersion,r=e.latestVersion,i=e.isCurrentProject;if(!(i||t&&n===r))return[3,3];a=ed.success("Cyberskill package is already up to date.");return[3,5];case 3:return[4,tT(eA)];case 4:a=o.sent();o.label=5;case 5:a;return[4,tS()];case 6:o.sent();return[3,8];case 7:c=o.sent();throw ed.error("Project setup failed: ".concat(c.message)),c;case 8:return[2]}})});return tL.apply(this,arguments)}function tP(){return tA.apply(this,arguments)}function tA(){tA=i(function(){return m(this,function(e){switch(e.label){case 0:B([te.NODE_MODULES,te.PNPM_LOCK_YAML]);return[4,tw()];case 1:e.sent();return[4,tS()];case 2:e.sent();return[2]}})});return tA.apply(this,arguments)}function tj(){return tR.apply(this,arguments)}function tR(){tR=i(function(){return m(this,function(e){switch(e.label){case 0:return[4,ti("Inspecting project dependencies",tr.NODE_MODULES_INSPECT)];case 1:e.sent();return[2]}})});return tR.apply(this,arguments)}function tG(){return tk.apply(this,arguments)}function tk(){tk=i(function(){return m(this,function(e){switch(e.label){case 0:return[4,ti("Running unit tests",tr.CYBERSKILL.TEST_UNIT)];case 1:e.sent();return[2]}})});return tk.apply(this,arguments)}function tM(){return tD.apply(this,arguments)}function tD(){tD=i(function(){return m(this,function(e){switch(e.label){case 0:return[4,ti("Running end-to-end tests",tr.CYBERSKILL.TEST_E2E)];case 1:e.sent();return[2]}})});return tD.apply(this,arguments)}(0,N.default)((0,C.hideBin)(T.default.argv)).scriptName(eJ).usage("$0 <command> [options]").command("lint","Check code for linting issues",ty).command("lint:fix","Fix linting issues automatically",tv).command("lint:inspect","View active ESLint configuration",th).command("lint-staged","Run lint checks on staged files",tp).command("commitlint","Validate commit message format",tE).command("setup","Initialize project setup and dependencies",tN).command("reset","Reset the project and reinstall dependencies",tP).command("inspect","Analyze installed project dependencies",tj).command("test:unit","Run unit test suite",tG).command("test:e2e","Run end-to-end test suite",tM).demandCommand(1,"Please specify a valid command.").strict().help().alias("h","help").alias("v","version").epilog('\uD83D\uDCA1 Tip: Use "--help" with any command to see options\n').parse();