@cyberskill/shared 1.47.0 → 1.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_tsup-dts-rollup.d.cts +415 -30
- package/dist/_tsup-dts-rollup.d.ts +415 -30
- package/dist/cli.cjs +2144 -1
- package/dist/cli.d.cts +2 -1
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +2064 -1
- package/dist/configs/commitlint/base.cjs +64 -1
- package/dist/configs/commitlint/base.js +7 -1
- package/dist/configs/eslint/base.cjs +121 -1
- package/dist/configs/eslint/base.js +52 -1
- package/dist/configs/eslint/nestjs.cjs +155 -1
- package/dist/configs/eslint/nestjs.js +85 -1
- package/dist/configs/eslint/nextjs.cjs +155 -1
- package/dist/configs/eslint/nextjs.js +85 -1
- package/dist/configs/eslint/nodejs.cjs +156 -1
- package/dist/configs/eslint/nodejs.js +86 -1
- package/dist/configs/eslint/vite-react.cjs +159 -1
- package/dist/configs/eslint/vite-react.js +89 -1
- package/dist/configs/graphql/graphql-codegen.cjs +125 -1
- package/dist/configs/graphql/graphql-codegen.js +64 -1
- package/dist/configs/graphql/index.cjs +126 -1
- package/dist/configs/graphql/index.js +64 -1
- package/dist/configs/i18n/react/i18next.cjs +80 -1
- package/dist/configs/i18n/react/i18next.js +7 -1
- package/dist/configs/i18n/react/index.cjs +81 -1
- package/dist/configs/i18n/react/index.js +7 -1
- package/dist/configs/index.cjs +232 -1
- package/dist/configs/index.js +166 -1
- package/dist/configs/lint-staged/base.cjs +64 -1
- package/dist/configs/lint-staged/base.js +7 -1
- package/dist/configs/vitest/react/e2e.cjs +128 -1
- package/dist/configs/vitest/react/e2e.js +59 -1
- package/dist/configs/vitest/react/unit.cjs +305 -1
- package/dist/configs/vitest/react/unit.js +228 -1
- package/dist/configs/vitest/react/unit.setup.cjs +60 -1
- package/dist/configs/vitest/react/unit.setup.js +8 -1
- package/dist/constants/index.cjs +678 -1
- package/dist/constants/index.d.cts +31 -1
- package/dist/constants/index.d.ts +31 -1
- package/dist/constants/index.js +469 -1
- package/dist/constants/path.cjs +423 -1
- package/dist/constants/path.d.cts +31 -1
- package/dist/constants/path.d.ts +31 -1
- package/dist/constants/path.js +218 -1
- package/dist/constants/response-status.cjs +313 -1
- package/dist/constants/response-status.js +252 -1
- package/dist/index.cjs +4560 -1
- package/dist/index.d.cts +52 -7
- package/dist/index.d.ts +52 -7
- package/dist/index.js +4143 -1
- package/dist/nodejs/index.cjs +2138 -1
- package/dist/nodejs/index.js +2054 -1
- package/dist/nodejs/mongo.cjs +2137 -1
- package/dist/nodejs/mongo.js +2054 -1
- package/dist/react/apollo-client.cjs +177 -1
- package/dist/react/apollo-client.js +116 -1
- package/dist/react/index.cjs +990 -1
- package/dist/react/index.js +876 -1
- package/dist/react/loading.cjs +301 -1
- package/dist/react/loading.js +216 -1
- package/dist/react/next-intl.cjs +744 -1
- package/dist/react/next-intl.js +655 -1
- package/dist/react/storage.cjs +631 -1
- package/dist/react/storage.js +558 -1
- package/dist/typescript/api-response.cjs +48 -1
- package/dist/typescript/apollo.cjs +48 -1
- package/dist/typescript/command.cjs +68 -1
- package/dist/typescript/command.d.cts +4 -0
- package/dist/typescript/command.d.ts +4 -0
- package/dist/typescript/command.js +7 -1
- package/dist/typescript/config.cjs +48 -1
- package/dist/typescript/fs.cjs +48 -0
- package/dist/typescript/fs.d.cts +1 -0
- package/dist/typescript/fs.d.ts +1 -0
- package/dist/typescript/fs.js +0 -0
- package/dist/typescript/graphql-codegen.cjs +48 -1
- package/dist/typescript/index.cjs +175 -1
- package/dist/typescript/index.d.cts +5 -0
- package/dist/typescript/index.d.ts +5 -0
- package/dist/typescript/index.js +151 -1
- package/dist/typescript/loading.cjs +48 -1
- package/dist/typescript/log.cjs +48 -1
- package/dist/typescript/mongo.cjs +164 -1
- package/dist/typescript/mongo.js +145 -1
- package/dist/typescript/next-intl.cjs +48 -1
- package/dist/typescript/react.cjs +48 -1
- package/dist/typescript/serializer.cjs +48 -1
- package/dist/typescript/string.cjs +48 -1
- package/dist/utils/command.cjs +1387 -1
- package/dist/utils/command.d.cts +2 -0
- package/dist/utils/command.d.ts +2 -0
- package/dist/utils/command.js +1287 -1
- package/dist/utils/common.cjs +300 -1
- package/dist/utils/common.js +219 -1
- package/dist/utils/config.cjs +146 -1
- package/dist/utils/config.js +89 -1
- package/dist/utils/fs.cjs +132 -1
- package/dist/utils/fs.d.cts +5 -1
- package/dist/utils/fs.d.ts +5 -1
- package/dist/utils/fs.js +47 -1
- package/dist/utils/index-nodejs.cjs +1752 -1
- package/dist/utils/index-nodejs.d.cts +16 -6
- package/dist/utils/index-nodejs.d.ts +16 -6
- package/dist/utils/index-nodejs.js +1581 -1
- package/dist/utils/index.cjs +727 -1
- package/dist/utils/index.js +625 -1
- package/dist/utils/log.cjs +330 -1
- package/dist/utils/log.js +269 -1
- package/dist/utils/package.cjs +941 -0
- package/dist/utils/package.d.cts +3 -0
- package/dist/utils/package.d.ts +3 -0
- package/dist/utils/package.js +857 -0
- package/dist/utils/path.cjs +291 -0
- package/dist/utils/path.d.cts +6 -0
- package/dist/utils/path.d.ts +6 -0
- package/dist/utils/path.js +191 -0
- package/dist/utils/serializer.cjs +91 -1
- package/dist/utils/serializer.js +30 -1
- package/dist/utils/storage-client.cjs +349 -1
- package/dist/utils/storage-client.js +276 -1
- package/dist/utils/storage-server.cjs +636 -1
- package/dist/utils/storage-server.d.cts +1 -1
- package/dist/utils/storage-server.d.ts +1 -1
- package/dist/utils/storage-server.js +550 -1
- package/dist/utils/string.cjs +152 -1
- package/dist/utils/string.js +75 -1
- package/dist/utils/validate.cjs +90 -1
- package/dist/utils/validate.js +33 -1
- package/package.json +11 -12
- package/dist/utils/npm-package.cjs +0 -1
- package/dist/utils/npm-package.d.cts +0 -5
- package/dist/utils/npm-package.d.ts +0 -5
- package/dist/utils/npm-package.js +0 -1
|
@@ -0,0 +1,941 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_without_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
9
|
+
}
|
|
10
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
11
|
+
try {
|
|
12
|
+
var info = gen[key](arg);
|
|
13
|
+
var value = info.value;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
reject(error);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (info.done) {
|
|
19
|
+
resolve(value);
|
|
20
|
+
} else {
|
|
21
|
+
Promise.resolve(value).then(_next, _throw);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function _async_to_generator(fn) {
|
|
25
|
+
return function() {
|
|
26
|
+
var self = this, args = arguments;
|
|
27
|
+
return new Promise(function(resolve, reject) {
|
|
28
|
+
var gen = fn.apply(self, args);
|
|
29
|
+
function _next(value) {
|
|
30
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
31
|
+
}
|
|
32
|
+
function _throw(err) {
|
|
33
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
34
|
+
}
|
|
35
|
+
_next(undefined);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function _iterable_to_array(iter) {
|
|
40
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
41
|
+
}
|
|
42
|
+
function _non_iterable_spread() {
|
|
43
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
44
|
+
}
|
|
45
|
+
function _to_consumable_array(arr) {
|
|
46
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
47
|
+
}
|
|
48
|
+
function _type_of(obj) {
|
|
49
|
+
"@swc/helpers - typeof";
|
|
50
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
51
|
+
}
|
|
52
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
53
|
+
if (!o) return;
|
|
54
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
55
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
56
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
57
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
58
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
59
|
+
}
|
|
60
|
+
function _ts_generator(thisArg, body) {
|
|
61
|
+
var f, y, t, g, _ = {
|
|
62
|
+
label: 0,
|
|
63
|
+
sent: function() {
|
|
64
|
+
if (t[0] & 1) throw t[1];
|
|
65
|
+
return t[1];
|
|
66
|
+
},
|
|
67
|
+
trys: [],
|
|
68
|
+
ops: []
|
|
69
|
+
};
|
|
70
|
+
return g = {
|
|
71
|
+
next: verb(0),
|
|
72
|
+
"throw": verb(1),
|
|
73
|
+
"return": verb(2)
|
|
74
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
75
|
+
return this;
|
|
76
|
+
}), g;
|
|
77
|
+
function verb(n) {
|
|
78
|
+
return function(v) {
|
|
79
|
+
return step([
|
|
80
|
+
n,
|
|
81
|
+
v
|
|
82
|
+
]);
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function step(op) {
|
|
86
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
87
|
+
while(_)try {
|
|
88
|
+
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;
|
|
89
|
+
if (y = 0, t) op = [
|
|
90
|
+
op[0] & 2,
|
|
91
|
+
t.value
|
|
92
|
+
];
|
|
93
|
+
switch(op[0]){
|
|
94
|
+
case 0:
|
|
95
|
+
case 1:
|
|
96
|
+
t = op;
|
|
97
|
+
break;
|
|
98
|
+
case 4:
|
|
99
|
+
_.label++;
|
|
100
|
+
return {
|
|
101
|
+
value: op[1],
|
|
102
|
+
done: false
|
|
103
|
+
};
|
|
104
|
+
case 5:
|
|
105
|
+
_.label++;
|
|
106
|
+
y = op[1];
|
|
107
|
+
op = [
|
|
108
|
+
0
|
|
109
|
+
];
|
|
110
|
+
continue;
|
|
111
|
+
case 7:
|
|
112
|
+
op = _.ops.pop();
|
|
113
|
+
_.trys.pop();
|
|
114
|
+
continue;
|
|
115
|
+
default:
|
|
116
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
117
|
+
_ = 0;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
121
|
+
_.label = op[1];
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
125
|
+
_.label = t[1];
|
|
126
|
+
t = op;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
if (t && _.label < t[2]) {
|
|
130
|
+
_.label = t[2];
|
|
131
|
+
_.ops.push(op);
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
if (t[2]) _.ops.pop();
|
|
135
|
+
_.trys.pop();
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
op = body.call(thisArg, _);
|
|
139
|
+
} catch (e) {
|
|
140
|
+
op = [
|
|
141
|
+
6,
|
|
142
|
+
e
|
|
143
|
+
];
|
|
144
|
+
y = 0;
|
|
145
|
+
} finally{
|
|
146
|
+
f = t = 0;
|
|
147
|
+
}
|
|
148
|
+
if (op[0] & 5) throw op[1];
|
|
149
|
+
return {
|
|
150
|
+
value: op[0] ? op[1] : void 0,
|
|
151
|
+
done: true
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
var __create = Object.create;
|
|
156
|
+
var __defProp = Object.defineProperty;
|
|
157
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
158
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
159
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
160
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
161
|
+
var __export = function(target, all) {
|
|
162
|
+
for(var name in all)__defProp(target, name, {
|
|
163
|
+
get: all[name],
|
|
164
|
+
enumerable: true
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
var __copyProps = function(to, from, except, desc) {
|
|
168
|
+
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
169
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
170
|
+
try {
|
|
171
|
+
var _loop = function() {
|
|
172
|
+
var key = _step.value;
|
|
173
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
174
|
+
get: function() {
|
|
175
|
+
return from[key];
|
|
176
|
+
},
|
|
177
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
181
|
+
} catch (err) {
|
|
182
|
+
_didIteratorError = true;
|
|
183
|
+
_iteratorError = err;
|
|
184
|
+
} finally{
|
|
185
|
+
try {
|
|
186
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
187
|
+
_iterator.return();
|
|
188
|
+
}
|
|
189
|
+
} finally{
|
|
190
|
+
if (_didIteratorError) {
|
|
191
|
+
throw _iteratorError;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return to;
|
|
197
|
+
};
|
|
198
|
+
var __toESM = function(mod, isNodeMode, target) {
|
|
199
|
+
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
200
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
201
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
202
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
203
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
204
|
+
value: mod,
|
|
205
|
+
enumerable: true
|
|
206
|
+
}) : target, mod);
|
|
207
|
+
};
|
|
208
|
+
var __toCommonJS = function(mod) {
|
|
209
|
+
return __copyProps(__defProp({}, "__esModule", {
|
|
210
|
+
value: true
|
|
211
|
+
}), mod);
|
|
212
|
+
};
|
|
213
|
+
// src/utils/package.ts
|
|
214
|
+
var package_exports = {};
|
|
215
|
+
__export(package_exports, {
|
|
216
|
+
checkPackage: function() {
|
|
217
|
+
return checkPackage;
|
|
218
|
+
},
|
|
219
|
+
getLatestPackageVersion: function() {
|
|
220
|
+
return getLatestPackageVersion;
|
|
221
|
+
},
|
|
222
|
+
getPackageJson: function() {
|
|
223
|
+
return getPackageJson;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
module.exports = __toCommonJS(package_exports);
|
|
227
|
+
// 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
|
|
228
|
+
var getImportMetaUrl = function() {
|
|
229
|
+
return typeof document === "undefined" ? new URL("file:".concat(__filename)).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
230
|
+
};
|
|
231
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
232
|
+
// src/utils/package.ts
|
|
233
|
+
var import_node_fetch = __toESM(require("node-fetch"), 1);
|
|
234
|
+
// src/constants/path.ts
|
|
235
|
+
var import_node_process3 = __toESM(require("process"), 1);
|
|
236
|
+
var import_node_url = require("url");
|
|
237
|
+
// src/utils/command.ts
|
|
238
|
+
var import_boxen = __toESM(require("boxen"), 1);
|
|
239
|
+
var import_chalk = __toESM(require("chalk"), 1);
|
|
240
|
+
var import_node_child_process = require("child_process");
|
|
241
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
242
|
+
var util = __toESM(require("util"), 1);
|
|
243
|
+
// src/utils/storage-server.ts
|
|
244
|
+
var import_node_persist = __toESM(require("node-persist"), 1);
|
|
245
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
246
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
247
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
248
|
+
function getStorageDir() {
|
|
249
|
+
return import_node_process.default.env.CYBERSKILL_STORAGE_DIR || import_node_path.default.join(import_node_os.default.homedir(), CYBERSKILL_STORAGE);
|
|
250
|
+
}
|
|
251
|
+
function initNodePersist() {
|
|
252
|
+
return _initNodePersist.apply(this, arguments);
|
|
253
|
+
}
|
|
254
|
+
function _initNodePersist() {
|
|
255
|
+
_initNodePersist = _async_to_generator(function() {
|
|
256
|
+
return _ts_generator(this, function(_state) {
|
|
257
|
+
switch(_state.label){
|
|
258
|
+
case 0:
|
|
259
|
+
if (!!import_node_persist.default.defaultInstance) return [
|
|
260
|
+
3,
|
|
261
|
+
2
|
|
262
|
+
];
|
|
263
|
+
return [
|
|
264
|
+
4,
|
|
265
|
+
import_node_persist.default.init({
|
|
266
|
+
dir: getStorageDir(),
|
|
267
|
+
stringify: JSON.stringify,
|
|
268
|
+
parse: JSON.parse,
|
|
269
|
+
encoding: "utf8",
|
|
270
|
+
logging: false,
|
|
271
|
+
forgiveParseErrors: true
|
|
272
|
+
})
|
|
273
|
+
];
|
|
274
|
+
case 1:
|
|
275
|
+
_state.sent();
|
|
276
|
+
_state.label = 2;
|
|
277
|
+
case 2:
|
|
278
|
+
return [
|
|
279
|
+
2
|
|
280
|
+
];
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
return _initNodePersist.apply(this, arguments);
|
|
285
|
+
}
|
|
286
|
+
var storageServer = {
|
|
287
|
+
get: function get(key) {
|
|
288
|
+
return _async_to_generator(function() {
|
|
289
|
+
var result, error;
|
|
290
|
+
return _ts_generator(this, function(_state) {
|
|
291
|
+
switch(_state.label){
|
|
292
|
+
case 0:
|
|
293
|
+
_state.trys.push([
|
|
294
|
+
0,
|
|
295
|
+
3,
|
|
296
|
+
,
|
|
297
|
+
4
|
|
298
|
+
]);
|
|
299
|
+
return [
|
|
300
|
+
4,
|
|
301
|
+
initNodePersist()
|
|
302
|
+
];
|
|
303
|
+
case 1:
|
|
304
|
+
_state.sent();
|
|
305
|
+
return [
|
|
306
|
+
4,
|
|
307
|
+
import_node_persist.default.getItem(key)
|
|
308
|
+
];
|
|
309
|
+
case 2:
|
|
310
|
+
result = _state.sent();
|
|
311
|
+
return [
|
|
312
|
+
2,
|
|
313
|
+
result !== null && result !== void 0 ? result : null
|
|
314
|
+
];
|
|
315
|
+
case 3:
|
|
316
|
+
error = _state.sent();
|
|
317
|
+
console.error('❌ [Storage:get] Error getting key "'.concat(key, '":'), error);
|
|
318
|
+
return [
|
|
319
|
+
2,
|
|
320
|
+
null
|
|
321
|
+
];
|
|
322
|
+
case 4:
|
|
323
|
+
return [
|
|
324
|
+
2
|
|
325
|
+
];
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
})();
|
|
329
|
+
},
|
|
330
|
+
set: function set(key, value) {
|
|
331
|
+
return _async_to_generator(function() {
|
|
332
|
+
var error;
|
|
333
|
+
return _ts_generator(this, function(_state) {
|
|
334
|
+
switch(_state.label){
|
|
335
|
+
case 0:
|
|
336
|
+
_state.trys.push([
|
|
337
|
+
0,
|
|
338
|
+
3,
|
|
339
|
+
,
|
|
340
|
+
4
|
|
341
|
+
]);
|
|
342
|
+
return [
|
|
343
|
+
4,
|
|
344
|
+
initNodePersist()
|
|
345
|
+
];
|
|
346
|
+
case 1:
|
|
347
|
+
_state.sent();
|
|
348
|
+
return [
|
|
349
|
+
4,
|
|
350
|
+
import_node_persist.default.setItem(key, value)
|
|
351
|
+
];
|
|
352
|
+
case 2:
|
|
353
|
+
_state.sent();
|
|
354
|
+
return [
|
|
355
|
+
3,
|
|
356
|
+
4
|
|
357
|
+
];
|
|
358
|
+
case 3:
|
|
359
|
+
error = _state.sent();
|
|
360
|
+
console.error('❌ [Storage:set] Error setting key "'.concat(key, '":'), error);
|
|
361
|
+
return [
|
|
362
|
+
3,
|
|
363
|
+
4
|
|
364
|
+
];
|
|
365
|
+
case 4:
|
|
366
|
+
return [
|
|
367
|
+
2
|
|
368
|
+
];
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
})();
|
|
372
|
+
},
|
|
373
|
+
remove: function remove(key) {
|
|
374
|
+
return _async_to_generator(function() {
|
|
375
|
+
var error;
|
|
376
|
+
return _ts_generator(this, function(_state) {
|
|
377
|
+
switch(_state.label){
|
|
378
|
+
case 0:
|
|
379
|
+
_state.trys.push([
|
|
380
|
+
0,
|
|
381
|
+
3,
|
|
382
|
+
,
|
|
383
|
+
4
|
|
384
|
+
]);
|
|
385
|
+
return [
|
|
386
|
+
4,
|
|
387
|
+
initNodePersist()
|
|
388
|
+
];
|
|
389
|
+
case 1:
|
|
390
|
+
_state.sent();
|
|
391
|
+
return [
|
|
392
|
+
4,
|
|
393
|
+
import_node_persist.default.removeItem(key)
|
|
394
|
+
];
|
|
395
|
+
case 2:
|
|
396
|
+
_state.sent();
|
|
397
|
+
return [
|
|
398
|
+
3,
|
|
399
|
+
4
|
|
400
|
+
];
|
|
401
|
+
case 3:
|
|
402
|
+
error = _state.sent();
|
|
403
|
+
console.error('❌ [Storage:remove] Error removing key "'.concat(key, '":'), error);
|
|
404
|
+
return [
|
|
405
|
+
3,
|
|
406
|
+
4
|
|
407
|
+
];
|
|
408
|
+
case 4:
|
|
409
|
+
return [
|
|
410
|
+
2
|
|
411
|
+
];
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
})();
|
|
415
|
+
},
|
|
416
|
+
keys: function keys() {
|
|
417
|
+
return _async_to_generator(function() {
|
|
418
|
+
var keys, error;
|
|
419
|
+
return _ts_generator(this, function(_state) {
|
|
420
|
+
switch(_state.label){
|
|
421
|
+
case 0:
|
|
422
|
+
_state.trys.push([
|
|
423
|
+
0,
|
|
424
|
+
3,
|
|
425
|
+
,
|
|
426
|
+
4
|
|
427
|
+
]);
|
|
428
|
+
return [
|
|
429
|
+
4,
|
|
430
|
+
initNodePersist()
|
|
431
|
+
];
|
|
432
|
+
case 1:
|
|
433
|
+
_state.sent();
|
|
434
|
+
return [
|
|
435
|
+
4,
|
|
436
|
+
import_node_persist.default.keys()
|
|
437
|
+
];
|
|
438
|
+
case 2:
|
|
439
|
+
keys = _state.sent();
|
|
440
|
+
if (!Array.isArray(keys)) {
|
|
441
|
+
console.warn("⚠️ [Storage:keys] Invalid keys response:", keys);
|
|
442
|
+
return [
|
|
443
|
+
2,
|
|
444
|
+
[]
|
|
445
|
+
];
|
|
446
|
+
}
|
|
447
|
+
return [
|
|
448
|
+
2,
|
|
449
|
+
keys
|
|
450
|
+
];
|
|
451
|
+
case 3:
|
|
452
|
+
error = _state.sent();
|
|
453
|
+
console.error("❌ [Storage:keys] Error getting keys:", error);
|
|
454
|
+
return [
|
|
455
|
+
2,
|
|
456
|
+
[]
|
|
457
|
+
];
|
|
458
|
+
case 4:
|
|
459
|
+
return [
|
|
460
|
+
2
|
|
461
|
+
];
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
})();
|
|
465
|
+
},
|
|
466
|
+
getLogLink: function getLogLink(key) {
|
|
467
|
+
return _async_to_generator(function() {
|
|
468
|
+
var storagePath;
|
|
469
|
+
return _ts_generator(this, function(_state) {
|
|
470
|
+
try {
|
|
471
|
+
storagePath = getStorageDir();
|
|
472
|
+
return [
|
|
473
|
+
2,
|
|
474
|
+
"".concat(storagePath, " (key: ").concat(key, ")")
|
|
475
|
+
];
|
|
476
|
+
} catch (error) {
|
|
477
|
+
console.error("❌ [Storage:getLogLink] Error getting log link:", error);
|
|
478
|
+
return [
|
|
479
|
+
2,
|
|
480
|
+
null
|
|
481
|
+
];
|
|
482
|
+
}
|
|
483
|
+
return [
|
|
484
|
+
2
|
|
485
|
+
];
|
|
486
|
+
});
|
|
487
|
+
})();
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
// src/utils/command.ts
|
|
491
|
+
var DEBUG = import_node_process2.default.env.DEBUG === "true";
|
|
492
|
+
var execPromise = util.promisify(import_node_child_process.exec);
|
|
493
|
+
var _import_chalk_default = import_chalk.default, gray = _import_chalk_default.gray, blue = _import_chalk_default.blue;
|
|
494
|
+
var getTimeStamp = function() {
|
|
495
|
+
return gray("[".concat(/* @__PURE__ */ new Date().toLocaleTimeString(), "]"));
|
|
496
|
+
};
|
|
497
|
+
function chalkKeyword(color) {
|
|
498
|
+
var chalkColor = import_chalk.default[color];
|
|
499
|
+
return typeof chalkColor === "function" ? chalkColor : import_chalk.default.green;
|
|
500
|
+
}
|
|
501
|
+
function printLog(type, color, icon, message) {
|
|
502
|
+
var chalkColor = chalkKeyword(color);
|
|
503
|
+
console.log("".concat(getTimeStamp(), " ").concat(chalkColor("".concat(icon, " ").concat(type)), " ").concat(message));
|
|
504
|
+
}
|
|
505
|
+
function printBoxedLog(title, content) {
|
|
506
|
+
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;
|
|
507
|
+
var chalkColor = chalkKeyword(color);
|
|
508
|
+
var chalkTitleColor = chalkKeyword(titleColor);
|
|
509
|
+
if (typeof content === "string") {
|
|
510
|
+
console.log((0, import_boxen.default)(chalkTitleColor(chalkColor("".concat(title, "\n").concat(content))), {
|
|
511
|
+
padding: padding,
|
|
512
|
+
margin: margin,
|
|
513
|
+
borderStyle: borderStyle,
|
|
514
|
+
borderColor: color
|
|
515
|
+
}));
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
if (Array.isArray(content) && content.length) {
|
|
519
|
+
content.forEach(function(param) {
|
|
520
|
+
var file = param.file, position = param.position, rule = param.rule, message = param.message;
|
|
521
|
+
console.log("".concat(getTimeStamp(), " ").concat(chalkColor("File:"), " ").concat(blue("".concat(file).concat(position ? ":".concat(position) : ""))));
|
|
522
|
+
if (rule) console.log(" ".concat(chalkColor("Rule:"), " ").concat(chalkColor(rule)));
|
|
523
|
+
console.log(" ".concat(chalkColor("Message:"), " ").concat(chalkColor(message)));
|
|
524
|
+
});
|
|
525
|
+
console.log((0, import_boxen.default)(chalkTitleColor(chalkColor("".concat(title, ": ").concat(content.length))), {
|
|
526
|
+
padding: padding,
|
|
527
|
+
margin: margin,
|
|
528
|
+
borderStyle: borderStyle,
|
|
529
|
+
borderColor: color
|
|
530
|
+
}));
|
|
531
|
+
console.log(gray("\u2500".repeat(40)));
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
var commandLog = {
|
|
535
|
+
success: function(message) {
|
|
536
|
+
return printLog("SUCCESS", "green", "\u2714", message);
|
|
537
|
+
},
|
|
538
|
+
error: function(message) {
|
|
539
|
+
return printLog("ERROR", "red", "\u2716", message);
|
|
540
|
+
},
|
|
541
|
+
warning: function(message) {
|
|
542
|
+
return printLog("WARNING", "yellow", "\u26A0", message);
|
|
543
|
+
},
|
|
544
|
+
info: function(message) {
|
|
545
|
+
return printLog("INFO", "blue", "\u2139", message);
|
|
546
|
+
},
|
|
547
|
+
printBoxedLog: printBoxedLog
|
|
548
|
+
};
|
|
549
|
+
var commandFormatter = {
|
|
550
|
+
raw: function(cmd) {
|
|
551
|
+
return {
|
|
552
|
+
raw: true,
|
|
553
|
+
cmd: cmd
|
|
554
|
+
};
|
|
555
|
+
},
|
|
556
|
+
isRaw: function isRaw(cmd) {
|
|
557
|
+
return (typeof cmd === "undefined" ? "undefined" : _type_of(cmd)) === "object" && cmd !== null && cmd.raw === true;
|
|
558
|
+
},
|
|
559
|
+
format: function format(command, context) {
|
|
560
|
+
if (typeof command === "function") {
|
|
561
|
+
return commandFormatter.formatCLI(command(context), context);
|
|
562
|
+
}
|
|
563
|
+
if (commandFormatter.isRaw(command)) {
|
|
564
|
+
return command.cmd;
|
|
565
|
+
}
|
|
566
|
+
return commandFormatter.formatCLI(command, context);
|
|
567
|
+
},
|
|
568
|
+
formatCLI: function formatCLI(command, context) {
|
|
569
|
+
if (context === null || context === void 0 ? void 0 : context.isRemote) {
|
|
570
|
+
return "".concat(PNPM_DLX_CLI, " ").concat(CYBERSKILL_PACKAGE_NAME, " ").concat(command);
|
|
571
|
+
}
|
|
572
|
+
if (context === null || context === void 0 ? void 0 : context.isCurrentProject) {
|
|
573
|
+
return "".concat(PNPM_EXEC_CLI, " ").concat(TSX_CLI, " src/cli.ts ").concat(command);
|
|
574
|
+
}
|
|
575
|
+
return "".concat(PNPM_EXEC_CLI, " ").concat(CYBERSKILL_CLI, " ").concat(command);
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
// src/utils/path.ts
|
|
579
|
+
var import_node_module = require("module");
|
|
580
|
+
var path2 = __toESM(require("path"), 1);
|
|
581
|
+
function resolveCyberSkillPath() {
|
|
582
|
+
for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
|
|
583
|
+
urls[_key] = arguments[_key];
|
|
584
|
+
}
|
|
585
|
+
var _path2;
|
|
586
|
+
return (_path2 = path2).resolve.apply(_path2, [
|
|
587
|
+
CYBERSKILL_DIRECTORY
|
|
588
|
+
].concat(_to_consumable_array(urls)));
|
|
589
|
+
}
|
|
590
|
+
function resolveWorkingPath() {
|
|
591
|
+
for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
|
|
592
|
+
urls[_key] = arguments[_key];
|
|
593
|
+
}
|
|
594
|
+
var _path2;
|
|
595
|
+
return (_path2 = path2).resolve.apply(_path2, [
|
|
596
|
+
WORKING_DIRECTORY
|
|
597
|
+
].concat(_to_consumable_array(urls)));
|
|
598
|
+
}
|
|
599
|
+
function resolve2() {
|
|
600
|
+
for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
|
|
601
|
+
urls[_key] = arguments[_key];
|
|
602
|
+
}
|
|
603
|
+
var _path2;
|
|
604
|
+
return (_path2 = path2).resolve.apply(_path2, _to_consumable_array(urls));
|
|
605
|
+
}
|
|
606
|
+
function dirname2(url) {
|
|
607
|
+
return path2.dirname(url);
|
|
608
|
+
}
|
|
609
|
+
function join2() {
|
|
610
|
+
for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
|
|
611
|
+
urls[_key] = arguments[_key];
|
|
612
|
+
}
|
|
613
|
+
var _path2;
|
|
614
|
+
return (_path2 = path2).join.apply(_path2, _to_consumable_array(urls));
|
|
615
|
+
}
|
|
616
|
+
// src/constants/path.ts
|
|
617
|
+
var __filename2 = (0, import_node_url.fileURLToPath)(importMetaUrl);
|
|
618
|
+
var __dirname = dirname2(__filename2);
|
|
619
|
+
var CYBERSKILL_DIRECTORY = resolve2(__dirname, "../../");
|
|
620
|
+
var WORKING_DIRECTORY = import_node_process3.default.env.INIT_CWD || import_node_process3.default.cwd();
|
|
621
|
+
var CYBERSKILL_PACKAGE_NAME = "@cyberskill/shared";
|
|
622
|
+
var CYBERSKILL_STORAGE = ".cyberskill-storage";
|
|
623
|
+
var NODE_MODULES = "node_modules";
|
|
624
|
+
var BUILD_DIRECTORY = "dist";
|
|
625
|
+
var PACKAGE_JSON = "package.json";
|
|
626
|
+
var PACKAGE_LOCK_JSON = "package-lock.json";
|
|
627
|
+
var TSCONFIG_JSON = "tsconfig.json";
|
|
628
|
+
var GIT_IGNORE = ".gitignore";
|
|
629
|
+
var SIMPLE_GIT_HOOK_JSON = ".simple-git-hooks.json";
|
|
630
|
+
var PNPM_LOCK_YAML = "pnpm-lock.yaml";
|
|
631
|
+
var GIT_HOOK = ".git/hooks";
|
|
632
|
+
var GIT_COMMIT_EDITMSG = ".git/COMMIT_EDITMSG";
|
|
633
|
+
var CYBERSKILL_CLI = "cyberskill";
|
|
634
|
+
var ESLINT_CLI = "eslint";
|
|
635
|
+
var VITEST_CLI = "vitest";
|
|
636
|
+
var COMMIT_LINT_CLI = "commitlint";
|
|
637
|
+
var LINT_STAGED_CLI = "lint-staged";
|
|
638
|
+
var RIMRAF_CLI = "rimraf";
|
|
639
|
+
var TSC_CLI = "tsc";
|
|
640
|
+
var TSX_CLI = "tsx";
|
|
641
|
+
var GIT_CLI = "git";
|
|
642
|
+
var PNPM_CLI = "pnpm";
|
|
643
|
+
var PNPM_DLX_CLI = "pnpm dlx";
|
|
644
|
+
var PNPM_EXEC_CLI = "pnpm exec";
|
|
645
|
+
var SIMPLE_GIT_HOOK_CLI = "simple-git-hooks";
|
|
646
|
+
var ESLINT_INSPECT_CLI = "@eslint/config-inspector";
|
|
647
|
+
var NODE_MODULES_INSPECT_CLI = "node_modules-inspect";
|
|
648
|
+
var PATH = {
|
|
649
|
+
CYBERSKILL_DIRECTORY: CYBERSKILL_DIRECTORY,
|
|
650
|
+
WORKING_DIRECTORY: WORKING_DIRECTORY,
|
|
651
|
+
TS_CONFIG: resolveWorkingPath(TSCONFIG_JSON),
|
|
652
|
+
GIT_IGNORE: resolveWorkingPath(GIT_IGNORE),
|
|
653
|
+
GIT_HOOK: resolveWorkingPath(GIT_HOOK),
|
|
654
|
+
GIT_COMMIT_MSG: resolveWorkingPath(GIT_COMMIT_EDITMSG),
|
|
655
|
+
SIMPLE_GIT_HOOKS: resolveWorkingPath(SIMPLE_GIT_HOOK_JSON),
|
|
656
|
+
PACKAGE_JSON: resolveWorkingPath(PACKAGE_JSON),
|
|
657
|
+
PACKAGE_LOCK_JSON: resolveWorkingPath(PACKAGE_LOCK_JSON),
|
|
658
|
+
PNPM_LOCK_YAML: resolveWorkingPath(PNPM_LOCK_YAML),
|
|
659
|
+
NODE_MODULES: resolveWorkingPath(NODE_MODULES),
|
|
660
|
+
CYBERSKILL: {
|
|
661
|
+
LINT_STAGED_CONFIG: resolveCyberSkillPath("./configs/lint-staged/base.js"),
|
|
662
|
+
COMMITLINT_CONFIG: resolveCyberSkillPath("./configs/commitlint/base.js"),
|
|
663
|
+
UNIT_TEST_CONFIG: resolveCyberSkillPath("./configs/vitest/react/unit.js"),
|
|
664
|
+
E2E_TEST_CONFIG: resolveCyberSkillPath("./configs/vitest/react/e2e.js")
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
var COMMAND = {
|
|
668
|
+
SIMPLE_GIT_HOOKS: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(SIMPLE_GIT_HOOK_CLI)),
|
|
669
|
+
ESLINT_INSPECT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_INSPECT_CLI)),
|
|
670
|
+
NODE_MODULES_INSPECT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(NODE_MODULES_INSPECT_CLI)),
|
|
671
|
+
RESET: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(RIMRAF_CLI, " ").concat(NODE_MODULES, " ").concat(PNPM_LOCK_YAML)),
|
|
672
|
+
ESLINT_CHECK: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_CLI, " ").concat(PATH.WORKING_DIRECTORY)),
|
|
673
|
+
ESLINT_FIX: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_CLI, " ").concat(PATH.WORKING_DIRECTORY, " --fix")),
|
|
674
|
+
TYPESCRIPT_CHECK: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(TSC_CLI, " -p ").concat(PATH.TS_CONFIG, " --noEmit")),
|
|
675
|
+
CYBERSKILL: {
|
|
676
|
+
TEST_UNIT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(VITEST_CLI, " --config ").concat(PATH.CYBERSKILL.UNIT_TEST_CONFIG)),
|
|
677
|
+
TEST_E2E: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(VITEST_CLI, " --config ").concat(PATH.CYBERSKILL.E2E_TEST_CONFIG)),
|
|
678
|
+
COMMIT_LINT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(COMMIT_LINT_CLI, " --edit ").concat(PATH.GIT_COMMIT_MSG, " --config ").concat(PATH.CYBERSKILL.COMMITLINT_CONFIG)),
|
|
679
|
+
LINT_STAGED: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(LINT_STAGED_CLI, " --config ").concat(PATH.CYBERSKILL.LINT_STAGED_CONFIG))
|
|
680
|
+
},
|
|
681
|
+
CONFIGURE_GIT_HOOK: commandFormatter.raw("".concat(GIT_CLI, " config core.hooksPath ").concat(PATH.GIT_HOOK)),
|
|
682
|
+
BUILD: commandFormatter.raw("".concat(PNPM_CLI, " run build")),
|
|
683
|
+
STAGE_BUILD_DIRECTORY: commandFormatter.raw("".concat(GIT_CLI, " add ").concat(BUILD_DIRECTORY)),
|
|
684
|
+
PNPM_INSTALL_STANDARD: commandFormatter.raw("".concat(PNPM_CLI, " install")),
|
|
685
|
+
PNPM_INSTALL_LEGACY: commandFormatter.raw("".concat(PNPM_CLI, " install --legacy-peer-deps")),
|
|
686
|
+
PNPM_INSTALL_FORCE: commandFormatter.raw("".concat(PNPM_CLI, " install --force"))
|
|
687
|
+
};
|
|
688
|
+
// src/utils/fs.ts
|
|
689
|
+
var fs = __toESM(require("fs"), 1);
|
|
690
|
+
var existsSync2 = function(filePath) {
|
|
691
|
+
return fs.existsSync(filePath);
|
|
692
|
+
};
|
|
693
|
+
function readFileSync2(filePath, options) {
|
|
694
|
+
var content = fs.readFileSync(filePath, "utf-8");
|
|
695
|
+
if (options === null || options === void 0 ? void 0 : options.asJson) {
|
|
696
|
+
try {
|
|
697
|
+
var parsed = JSON.parse(content);
|
|
698
|
+
if ((typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) === "object" && parsed !== null) {
|
|
699
|
+
return parsed;
|
|
700
|
+
}
|
|
701
|
+
throw new Error("Parsed JSON is not an object or array");
|
|
702
|
+
} catch (e) {
|
|
703
|
+
throw new Error("Failed to parse JSON from file: ".concat(filePath));
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return content;
|
|
707
|
+
}
|
|
708
|
+
// src/utils/package.ts
|
|
709
|
+
var CACHE_EXPIRATION_MS = 24 * 60 * 60 * 1e3;
|
|
710
|
+
function getPackageJson(packageName) {
|
|
711
|
+
var workingPackageJsonPath = join2(WORKING_DIRECTORY, PACKAGE_JSON);
|
|
712
|
+
if (existsSync2(workingPackageJsonPath)) {
|
|
713
|
+
try {
|
|
714
|
+
var pkg = readFileSync2(workingPackageJsonPath, {
|
|
715
|
+
asJson: true
|
|
716
|
+
});
|
|
717
|
+
if (pkg.name === packageName) {
|
|
718
|
+
return {
|
|
719
|
+
path: workingPackageJsonPath,
|
|
720
|
+
file: pkg
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
} catch (error) {
|
|
724
|
+
commandLog.warning("Failed to read local package.json: ".concat(error.message));
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
var externalPackageJsonPath = join2(WORKING_DIRECTORY, NODE_MODULES, packageName, PACKAGE_JSON);
|
|
728
|
+
if (existsSync2(externalPackageJsonPath)) {
|
|
729
|
+
try {
|
|
730
|
+
var pkg1 = readFileSync2(externalPackageJsonPath, {
|
|
731
|
+
asJson: true
|
|
732
|
+
});
|
|
733
|
+
if (pkg1.name === packageName) {
|
|
734
|
+
return {
|
|
735
|
+
path: externalPackageJsonPath,
|
|
736
|
+
file: pkg1
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
} catch (error) {
|
|
740
|
+
commandLog.warning("Failed to read node_modules package.json for ".concat(packageName, ": ").concat(error.message));
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
return false;
|
|
744
|
+
}
|
|
745
|
+
function getLatestPackageVersion(packageName) {
|
|
746
|
+
return _getLatestPackageVersion.apply(this, arguments);
|
|
747
|
+
}
|
|
748
|
+
function _getLatestPackageVersion() {
|
|
749
|
+
_getLatestPackageVersion = _async_to_generator(function(packageName) {
|
|
750
|
+
var forceRefresh, versionCacheKey, metadataCacheKey, cached, metadata, isCacheValid, headers, response, data, latestVersion, error;
|
|
751
|
+
var _arguments = arguments;
|
|
752
|
+
return _ts_generator(this, function(_state) {
|
|
753
|
+
switch(_state.label){
|
|
754
|
+
case 0:
|
|
755
|
+
forceRefresh = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : false;
|
|
756
|
+
versionCacheKey = "npm_version:".concat(packageName);
|
|
757
|
+
metadataCacheKey = "npm_metadata:".concat(packageName);
|
|
758
|
+
return [
|
|
759
|
+
4,
|
|
760
|
+
storageServer.get(versionCacheKey)
|
|
761
|
+
];
|
|
762
|
+
case 1:
|
|
763
|
+
cached = _state.sent();
|
|
764
|
+
return [
|
|
765
|
+
4,
|
|
766
|
+
storageServer.get(metadataCacheKey)
|
|
767
|
+
];
|
|
768
|
+
case 2:
|
|
769
|
+
metadata = _state.sent();
|
|
770
|
+
isCacheValid = cached && Date.now() - cached.timestamp < CACHE_EXPIRATION_MS;
|
|
771
|
+
if (!forceRefresh && isCacheValid) {
|
|
772
|
+
return [
|
|
773
|
+
2,
|
|
774
|
+
cached.version
|
|
775
|
+
];
|
|
776
|
+
}
|
|
777
|
+
headers = {};
|
|
778
|
+
if (metadata === null || metadata === void 0 ? void 0 : metadata.etag) {
|
|
779
|
+
headers["If-None-Match"] = metadata.etag;
|
|
780
|
+
}
|
|
781
|
+
if (metadata === null || metadata === void 0 ? void 0 : metadata.lastModified) {
|
|
782
|
+
headers["If-Modified-Since"] = metadata.lastModified;
|
|
783
|
+
}
|
|
784
|
+
_state.label = 3;
|
|
785
|
+
case 3:
|
|
786
|
+
_state.trys.push([
|
|
787
|
+
3,
|
|
788
|
+
8,
|
|
789
|
+
,
|
|
790
|
+
9
|
|
791
|
+
]);
|
|
792
|
+
return [
|
|
793
|
+
4,
|
|
794
|
+
(0, import_node_fetch.default)("https://registry.npmjs.org/".concat(packageName, "/latest"), {
|
|
795
|
+
headers: headers
|
|
796
|
+
})
|
|
797
|
+
];
|
|
798
|
+
case 4:
|
|
799
|
+
response = _state.sent();
|
|
800
|
+
if (response.status === 304 && cached) {
|
|
801
|
+
return [
|
|
802
|
+
2,
|
|
803
|
+
cached.version
|
|
804
|
+
];
|
|
805
|
+
}
|
|
806
|
+
if (!response.ok) {
|
|
807
|
+
throw new Error("Failed to fetch latest version: ".concat(response.statusText));
|
|
808
|
+
}
|
|
809
|
+
return [
|
|
810
|
+
4,
|
|
811
|
+
response.json()
|
|
812
|
+
];
|
|
813
|
+
case 5:
|
|
814
|
+
data = _state.sent();
|
|
815
|
+
latestVersion = data.version;
|
|
816
|
+
return [
|
|
817
|
+
4,
|
|
818
|
+
storageServer.set(versionCacheKey, {
|
|
819
|
+
version: latestVersion,
|
|
820
|
+
timestamp: Date.now()
|
|
821
|
+
})
|
|
822
|
+
];
|
|
823
|
+
case 6:
|
|
824
|
+
_state.sent();
|
|
825
|
+
return [
|
|
826
|
+
4,
|
|
827
|
+
storageServer.set(metadataCacheKey, {
|
|
828
|
+
etag: response.headers.get("ETag") || void 0,
|
|
829
|
+
lastModified: response.headers.get("Last-Modified") || void 0
|
|
830
|
+
})
|
|
831
|
+
];
|
|
832
|
+
case 7:
|
|
833
|
+
_state.sent();
|
|
834
|
+
return [
|
|
835
|
+
2,
|
|
836
|
+
latestVersion
|
|
837
|
+
];
|
|
838
|
+
case 8:
|
|
839
|
+
error = _state.sent();
|
|
840
|
+
commandLog.error("Error fetching latest version for ".concat(packageName, ": ").concat(error.message));
|
|
841
|
+
if (cached) {
|
|
842
|
+
commandLog.warning("Falling back to cached version for ".concat(packageName, ": ").concat(cached.version));
|
|
843
|
+
return [
|
|
844
|
+
2,
|
|
845
|
+
cached.version
|
|
846
|
+
];
|
|
847
|
+
}
|
|
848
|
+
throw error;
|
|
849
|
+
case 9:
|
|
850
|
+
return [
|
|
851
|
+
2
|
|
852
|
+
];
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
});
|
|
856
|
+
return _getLatestPackageVersion.apply(this, arguments);
|
|
857
|
+
}
|
|
858
|
+
function checkPackage(packageName) {
|
|
859
|
+
return _checkPackage.apply(this, arguments);
|
|
860
|
+
}
|
|
861
|
+
function _checkPackage() {
|
|
862
|
+
_checkPackage = _async_to_generator(function(packageName) {
|
|
863
|
+
var result, packageFound, cyberskillPackageJsonPath, isCurrentProject, _tmp, error;
|
|
864
|
+
return _ts_generator(this, function(_state) {
|
|
865
|
+
switch(_state.label){
|
|
866
|
+
case 0:
|
|
867
|
+
result = {
|
|
868
|
+
isInstalled: false,
|
|
869
|
+
isCurrentProject: false,
|
|
870
|
+
installedPath: "",
|
|
871
|
+
installedVersion: "",
|
|
872
|
+
latestVersion: "",
|
|
873
|
+
file: {}
|
|
874
|
+
};
|
|
875
|
+
_state.label = 1;
|
|
876
|
+
case 1:
|
|
877
|
+
_state.trys.push([
|
|
878
|
+
1,
|
|
879
|
+
5,
|
|
880
|
+
,
|
|
881
|
+
6
|
|
882
|
+
]);
|
|
883
|
+
packageFound = getPackageJson(packageName);
|
|
884
|
+
if (!packageFound) {
|
|
885
|
+
return [
|
|
886
|
+
2,
|
|
887
|
+
result
|
|
888
|
+
];
|
|
889
|
+
}
|
|
890
|
+
cyberskillPackageJsonPath = resolveCyberSkillPath(PACKAGE_JSON);
|
|
891
|
+
isCurrentProject = packageFound.path === cyberskillPackageJsonPath;
|
|
892
|
+
result.file = packageFound.file;
|
|
893
|
+
result.isInstalled = true;
|
|
894
|
+
result.installedPath = packageFound.path;
|
|
895
|
+
result.installedVersion = packageFound.file.version;
|
|
896
|
+
result.isCurrentProject = isCurrentProject;
|
|
897
|
+
if (!isCurrentProject) return [
|
|
898
|
+
3,
|
|
899
|
+
2
|
|
900
|
+
];
|
|
901
|
+
_tmp = packageFound.file.version;
|
|
902
|
+
return [
|
|
903
|
+
3,
|
|
904
|
+
4
|
|
905
|
+
];
|
|
906
|
+
case 2:
|
|
907
|
+
return [
|
|
908
|
+
4,
|
|
909
|
+
getLatestPackageVersion(packageName, true)
|
|
910
|
+
];
|
|
911
|
+
case 3:
|
|
912
|
+
_tmp = _state.sent();
|
|
913
|
+
_state.label = 4;
|
|
914
|
+
case 4:
|
|
915
|
+
result.latestVersion = _tmp;
|
|
916
|
+
return [
|
|
917
|
+
2,
|
|
918
|
+
result
|
|
919
|
+
];
|
|
920
|
+
case 5:
|
|
921
|
+
error = _state.sent();
|
|
922
|
+
commandLog.error('Error checking package "'.concat(packageName, '": ').concat(error.message));
|
|
923
|
+
return [
|
|
924
|
+
2,
|
|
925
|
+
result
|
|
926
|
+
];
|
|
927
|
+
case 6:
|
|
928
|
+
return [
|
|
929
|
+
2
|
|
930
|
+
];
|
|
931
|
+
}
|
|
932
|
+
});
|
|
933
|
+
});
|
|
934
|
+
return _checkPackage.apply(this, arguments);
|
|
935
|
+
}
|
|
936
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
937
|
+
0 && (module.exports = {
|
|
938
|
+
checkPackage: checkPackage,
|
|
939
|
+
getLatestPackageVersion: getLatestPackageVersion,
|
|
940
|
+
getPackageJson: getPackageJson
|
|
941
|
+
});
|