@cyberskill/shared 1.46.0 → 1.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -18
- package/dist/_tsup-dts-rollup.d.cts +413 -31
- package/dist/_tsup-dts-rollup.d.ts +413 -31
- package/dist/cli.cjs +2136 -1
- package/dist/cli.d.cts +2 -1
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +2056 -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 +4546 -1
- package/dist/index.d.cts +51 -6
- package/dist/index.d.ts +51 -6
- package/dist/index.js +4133 -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 +118 -1
- package/dist/utils/fs.d.cts +4 -1
- package/dist/utils/fs.d.ts +4 -1
- package/dist/utils/fs.js +37 -1
- package/dist/utils/index-nodejs.cjs +1738 -1
- package/dist/utils/index-nodejs.d.cts +15 -5
- package/dist/utils/index-nodejs.d.ts +15 -5
- package/dist/utils/index-nodejs.js +1571 -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 +19 -16
- package/dist/utils/npm-package.cjs +0 -1
- package/dist/utils/npm-package.d.cts +0 -4
- package/dist/utils/npm-package.d.ts +0 -4
- package/dist/utils/npm-package.js +0 -1
|
@@ -0,0 +1,857 @@
|
|
|
1
|
+
// src/utils/package.ts
|
|
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
|
+
import fetch from "node-fetch";
|
|
156
|
+
// src/constants/path.ts
|
|
157
|
+
import process3 from "node:process";
|
|
158
|
+
import { fileURLToPath } from "node:url";
|
|
159
|
+
// src/utils/command.ts
|
|
160
|
+
import boxen from "boxen";
|
|
161
|
+
import chalk from "chalk";
|
|
162
|
+
import { exec } from "node:child_process";
|
|
163
|
+
import process2 from "node:process";
|
|
164
|
+
import * as util from "node:util";
|
|
165
|
+
// src/utils/storage-server.ts
|
|
166
|
+
import nodePersist from "node-persist";
|
|
167
|
+
import os from "node:os";
|
|
168
|
+
import path from "node:path";
|
|
169
|
+
import process from "node:process";
|
|
170
|
+
function getStorageDir() {
|
|
171
|
+
return process.env.CYBERSKILL_STORAGE_DIR || path.join(os.homedir(), CYBERSKILL_STORAGE);
|
|
172
|
+
}
|
|
173
|
+
function initNodePersist() {
|
|
174
|
+
return _initNodePersist.apply(this, arguments);
|
|
175
|
+
}
|
|
176
|
+
function _initNodePersist() {
|
|
177
|
+
_initNodePersist = _async_to_generator(function() {
|
|
178
|
+
return _ts_generator(this, function(_state) {
|
|
179
|
+
switch(_state.label){
|
|
180
|
+
case 0:
|
|
181
|
+
if (!!nodePersist.defaultInstance) return [
|
|
182
|
+
3,
|
|
183
|
+
2
|
|
184
|
+
];
|
|
185
|
+
return [
|
|
186
|
+
4,
|
|
187
|
+
nodePersist.init({
|
|
188
|
+
dir: getStorageDir(),
|
|
189
|
+
stringify: JSON.stringify,
|
|
190
|
+
parse: JSON.parse,
|
|
191
|
+
encoding: "utf8",
|
|
192
|
+
logging: false,
|
|
193
|
+
forgiveParseErrors: true
|
|
194
|
+
})
|
|
195
|
+
];
|
|
196
|
+
case 1:
|
|
197
|
+
_state.sent();
|
|
198
|
+
_state.label = 2;
|
|
199
|
+
case 2:
|
|
200
|
+
return [
|
|
201
|
+
2
|
|
202
|
+
];
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
return _initNodePersist.apply(this, arguments);
|
|
207
|
+
}
|
|
208
|
+
var storageServer = {
|
|
209
|
+
get: function get(key) {
|
|
210
|
+
return _async_to_generator(function() {
|
|
211
|
+
var result, error;
|
|
212
|
+
return _ts_generator(this, function(_state) {
|
|
213
|
+
switch(_state.label){
|
|
214
|
+
case 0:
|
|
215
|
+
_state.trys.push([
|
|
216
|
+
0,
|
|
217
|
+
3,
|
|
218
|
+
,
|
|
219
|
+
4
|
|
220
|
+
]);
|
|
221
|
+
return [
|
|
222
|
+
4,
|
|
223
|
+
initNodePersist()
|
|
224
|
+
];
|
|
225
|
+
case 1:
|
|
226
|
+
_state.sent();
|
|
227
|
+
return [
|
|
228
|
+
4,
|
|
229
|
+
nodePersist.getItem(key)
|
|
230
|
+
];
|
|
231
|
+
case 2:
|
|
232
|
+
result = _state.sent();
|
|
233
|
+
return [
|
|
234
|
+
2,
|
|
235
|
+
result !== null && result !== void 0 ? result : null
|
|
236
|
+
];
|
|
237
|
+
case 3:
|
|
238
|
+
error = _state.sent();
|
|
239
|
+
console.error('❌ [Storage:get] Error getting key "'.concat(key, '":'), error);
|
|
240
|
+
return [
|
|
241
|
+
2,
|
|
242
|
+
null
|
|
243
|
+
];
|
|
244
|
+
case 4:
|
|
245
|
+
return [
|
|
246
|
+
2
|
|
247
|
+
];
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
})();
|
|
251
|
+
},
|
|
252
|
+
set: function set(key, value) {
|
|
253
|
+
return _async_to_generator(function() {
|
|
254
|
+
var error;
|
|
255
|
+
return _ts_generator(this, function(_state) {
|
|
256
|
+
switch(_state.label){
|
|
257
|
+
case 0:
|
|
258
|
+
_state.trys.push([
|
|
259
|
+
0,
|
|
260
|
+
3,
|
|
261
|
+
,
|
|
262
|
+
4
|
|
263
|
+
]);
|
|
264
|
+
return [
|
|
265
|
+
4,
|
|
266
|
+
initNodePersist()
|
|
267
|
+
];
|
|
268
|
+
case 1:
|
|
269
|
+
_state.sent();
|
|
270
|
+
return [
|
|
271
|
+
4,
|
|
272
|
+
nodePersist.setItem(key, value)
|
|
273
|
+
];
|
|
274
|
+
case 2:
|
|
275
|
+
_state.sent();
|
|
276
|
+
return [
|
|
277
|
+
3,
|
|
278
|
+
4
|
|
279
|
+
];
|
|
280
|
+
case 3:
|
|
281
|
+
error = _state.sent();
|
|
282
|
+
console.error('❌ [Storage:set] Error setting key "'.concat(key, '":'), error);
|
|
283
|
+
return [
|
|
284
|
+
3,
|
|
285
|
+
4
|
|
286
|
+
];
|
|
287
|
+
case 4:
|
|
288
|
+
return [
|
|
289
|
+
2
|
|
290
|
+
];
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
})();
|
|
294
|
+
},
|
|
295
|
+
remove: function remove(key) {
|
|
296
|
+
return _async_to_generator(function() {
|
|
297
|
+
var error;
|
|
298
|
+
return _ts_generator(this, function(_state) {
|
|
299
|
+
switch(_state.label){
|
|
300
|
+
case 0:
|
|
301
|
+
_state.trys.push([
|
|
302
|
+
0,
|
|
303
|
+
3,
|
|
304
|
+
,
|
|
305
|
+
4
|
|
306
|
+
]);
|
|
307
|
+
return [
|
|
308
|
+
4,
|
|
309
|
+
initNodePersist()
|
|
310
|
+
];
|
|
311
|
+
case 1:
|
|
312
|
+
_state.sent();
|
|
313
|
+
return [
|
|
314
|
+
4,
|
|
315
|
+
nodePersist.removeItem(key)
|
|
316
|
+
];
|
|
317
|
+
case 2:
|
|
318
|
+
_state.sent();
|
|
319
|
+
return [
|
|
320
|
+
3,
|
|
321
|
+
4
|
|
322
|
+
];
|
|
323
|
+
case 3:
|
|
324
|
+
error = _state.sent();
|
|
325
|
+
console.error('❌ [Storage:remove] Error removing key "'.concat(key, '":'), error);
|
|
326
|
+
return [
|
|
327
|
+
3,
|
|
328
|
+
4
|
|
329
|
+
];
|
|
330
|
+
case 4:
|
|
331
|
+
return [
|
|
332
|
+
2
|
|
333
|
+
];
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
})();
|
|
337
|
+
},
|
|
338
|
+
keys: function keys() {
|
|
339
|
+
return _async_to_generator(function() {
|
|
340
|
+
var keys, error;
|
|
341
|
+
return _ts_generator(this, function(_state) {
|
|
342
|
+
switch(_state.label){
|
|
343
|
+
case 0:
|
|
344
|
+
_state.trys.push([
|
|
345
|
+
0,
|
|
346
|
+
3,
|
|
347
|
+
,
|
|
348
|
+
4
|
|
349
|
+
]);
|
|
350
|
+
return [
|
|
351
|
+
4,
|
|
352
|
+
initNodePersist()
|
|
353
|
+
];
|
|
354
|
+
case 1:
|
|
355
|
+
_state.sent();
|
|
356
|
+
return [
|
|
357
|
+
4,
|
|
358
|
+
nodePersist.keys()
|
|
359
|
+
];
|
|
360
|
+
case 2:
|
|
361
|
+
keys = _state.sent();
|
|
362
|
+
if (!Array.isArray(keys)) {
|
|
363
|
+
console.warn("⚠️ [Storage:keys] Invalid keys response:", keys);
|
|
364
|
+
return [
|
|
365
|
+
2,
|
|
366
|
+
[]
|
|
367
|
+
];
|
|
368
|
+
}
|
|
369
|
+
return [
|
|
370
|
+
2,
|
|
371
|
+
keys
|
|
372
|
+
];
|
|
373
|
+
case 3:
|
|
374
|
+
error = _state.sent();
|
|
375
|
+
console.error("❌ [Storage:keys] Error getting keys:", error);
|
|
376
|
+
return [
|
|
377
|
+
2,
|
|
378
|
+
[]
|
|
379
|
+
];
|
|
380
|
+
case 4:
|
|
381
|
+
return [
|
|
382
|
+
2
|
|
383
|
+
];
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
})();
|
|
387
|
+
},
|
|
388
|
+
getLogLink: function getLogLink(key) {
|
|
389
|
+
return _async_to_generator(function() {
|
|
390
|
+
var storagePath;
|
|
391
|
+
return _ts_generator(this, function(_state) {
|
|
392
|
+
try {
|
|
393
|
+
storagePath = getStorageDir();
|
|
394
|
+
return [
|
|
395
|
+
2,
|
|
396
|
+
"".concat(storagePath, " (key: ").concat(key, ")")
|
|
397
|
+
];
|
|
398
|
+
} catch (error) {
|
|
399
|
+
console.error("❌ [Storage:getLogLink] Error getting log link:", error);
|
|
400
|
+
return [
|
|
401
|
+
2,
|
|
402
|
+
null
|
|
403
|
+
];
|
|
404
|
+
}
|
|
405
|
+
return [
|
|
406
|
+
2
|
|
407
|
+
];
|
|
408
|
+
});
|
|
409
|
+
})();
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
// src/utils/command.ts
|
|
413
|
+
var DEBUG = process2.env.DEBUG === "true";
|
|
414
|
+
var execPromise = util.promisify(exec);
|
|
415
|
+
var gray = chalk.gray, blue = chalk.blue;
|
|
416
|
+
var getTimeStamp = function() {
|
|
417
|
+
return gray("[".concat(/* @__PURE__ */ new Date().toLocaleTimeString(), "]"));
|
|
418
|
+
};
|
|
419
|
+
function chalkKeyword(color) {
|
|
420
|
+
var chalkColor = chalk[color];
|
|
421
|
+
return typeof chalkColor === "function" ? chalkColor : chalk.green;
|
|
422
|
+
}
|
|
423
|
+
function printLog(type, color, icon, message) {
|
|
424
|
+
var chalkColor = chalkKeyword(color);
|
|
425
|
+
console.log("".concat(getTimeStamp(), " ").concat(chalkColor("".concat(icon, " ").concat(type)), " ").concat(message));
|
|
426
|
+
}
|
|
427
|
+
function printBoxedLog(title, content) {
|
|
428
|
+
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;
|
|
429
|
+
var chalkColor = chalkKeyword(color);
|
|
430
|
+
var chalkTitleColor = chalkKeyword(titleColor);
|
|
431
|
+
if (typeof content === "string") {
|
|
432
|
+
console.log(boxen(chalkTitleColor(chalkColor("".concat(title, "\n").concat(content))), {
|
|
433
|
+
padding: padding,
|
|
434
|
+
margin: margin,
|
|
435
|
+
borderStyle: borderStyle,
|
|
436
|
+
borderColor: color
|
|
437
|
+
}));
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
if (Array.isArray(content) && content.length) {
|
|
441
|
+
content.forEach(function(param) {
|
|
442
|
+
var file = param.file, position = param.position, rule = param.rule, message = param.message;
|
|
443
|
+
console.log("".concat(getTimeStamp(), " ").concat(chalkColor("File:"), " ").concat(blue("".concat(file).concat(position ? ":".concat(position) : ""))));
|
|
444
|
+
if (rule) console.log(" ".concat(chalkColor("Rule:"), " ").concat(chalkColor(rule)));
|
|
445
|
+
console.log(" ".concat(chalkColor("Message:"), " ").concat(chalkColor(message)));
|
|
446
|
+
});
|
|
447
|
+
console.log(boxen(chalkTitleColor(chalkColor("".concat(title, ": ").concat(content.length))), {
|
|
448
|
+
padding: padding,
|
|
449
|
+
margin: margin,
|
|
450
|
+
borderStyle: borderStyle,
|
|
451
|
+
borderColor: color
|
|
452
|
+
}));
|
|
453
|
+
console.log(gray("\u2500".repeat(40)));
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
var commandLog = {
|
|
457
|
+
success: function(message) {
|
|
458
|
+
return printLog("SUCCESS", "green", "\u2714", message);
|
|
459
|
+
},
|
|
460
|
+
error: function(message) {
|
|
461
|
+
return printLog("ERROR", "red", "\u2716", message);
|
|
462
|
+
},
|
|
463
|
+
warning: function(message) {
|
|
464
|
+
return printLog("WARNING", "yellow", "\u26A0", message);
|
|
465
|
+
},
|
|
466
|
+
info: function(message) {
|
|
467
|
+
return printLog("INFO", "blue", "\u2139", message);
|
|
468
|
+
},
|
|
469
|
+
printBoxedLog: printBoxedLog
|
|
470
|
+
};
|
|
471
|
+
var commandFormatter = {
|
|
472
|
+
raw: function(cmd) {
|
|
473
|
+
return {
|
|
474
|
+
raw: true,
|
|
475
|
+
cmd: cmd
|
|
476
|
+
};
|
|
477
|
+
},
|
|
478
|
+
isRaw: function isRaw(cmd) {
|
|
479
|
+
return (typeof cmd === "undefined" ? "undefined" : _type_of(cmd)) === "object" && cmd !== null && cmd.raw === true;
|
|
480
|
+
},
|
|
481
|
+
format: function format(command, context) {
|
|
482
|
+
if (typeof command === "function") {
|
|
483
|
+
return commandFormatter.formatCLI(command(context), context);
|
|
484
|
+
}
|
|
485
|
+
if (commandFormatter.isRaw(command)) {
|
|
486
|
+
return command.cmd;
|
|
487
|
+
}
|
|
488
|
+
return commandFormatter.formatCLI(command, context);
|
|
489
|
+
},
|
|
490
|
+
formatCLI: function formatCLI(command, context) {
|
|
491
|
+
if (context === null || context === void 0 ? void 0 : context.isRemote) {
|
|
492
|
+
return "".concat(PNPM_DLX_CLI, " ").concat(CYBERSKILL_PACKAGE_NAME, " ").concat(command);
|
|
493
|
+
}
|
|
494
|
+
if (context === null || context === void 0 ? void 0 : context.isCurrentProject) {
|
|
495
|
+
return "".concat(PNPM_EXEC_CLI, " ").concat(TSX_CLI, " src/cli.ts ").concat(command);
|
|
496
|
+
}
|
|
497
|
+
return "".concat(PNPM_EXEC_CLI, " ").concat(CYBERSKILL_CLI, " ").concat(command);
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
// src/utils/path.ts
|
|
501
|
+
import * as path2 from "node:path";
|
|
502
|
+
function resolveCyberSkillPath() {
|
|
503
|
+
for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
|
|
504
|
+
urls[_key] = arguments[_key];
|
|
505
|
+
}
|
|
506
|
+
var _path2;
|
|
507
|
+
return (_path2 = path2).resolve.apply(_path2, [
|
|
508
|
+
CYBERSKILL_DIRECTORY
|
|
509
|
+
].concat(_to_consumable_array(urls)));
|
|
510
|
+
}
|
|
511
|
+
function resolveWorkingPath() {
|
|
512
|
+
for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
|
|
513
|
+
urls[_key] = arguments[_key];
|
|
514
|
+
}
|
|
515
|
+
var _path2;
|
|
516
|
+
return (_path2 = path2).resolve.apply(_path2, [
|
|
517
|
+
WORKING_DIRECTORY
|
|
518
|
+
].concat(_to_consumable_array(urls)));
|
|
519
|
+
}
|
|
520
|
+
function resolve2() {
|
|
521
|
+
for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
|
|
522
|
+
urls[_key] = arguments[_key];
|
|
523
|
+
}
|
|
524
|
+
var _path2;
|
|
525
|
+
return (_path2 = path2).resolve.apply(_path2, _to_consumable_array(urls));
|
|
526
|
+
}
|
|
527
|
+
function dirname2(url) {
|
|
528
|
+
return path2.dirname(url);
|
|
529
|
+
}
|
|
530
|
+
function join2() {
|
|
531
|
+
for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
|
|
532
|
+
urls[_key] = arguments[_key];
|
|
533
|
+
}
|
|
534
|
+
var _path2;
|
|
535
|
+
return (_path2 = path2).join.apply(_path2, _to_consumable_array(urls));
|
|
536
|
+
}
|
|
537
|
+
// src/constants/path.ts
|
|
538
|
+
var __filename2 = fileURLToPath(import.meta.url);
|
|
539
|
+
var __dirname2 = dirname2(__filename2);
|
|
540
|
+
var CYBERSKILL_DIRECTORY = resolve2(__dirname2, "../../");
|
|
541
|
+
var WORKING_DIRECTORY = process3.env.INIT_CWD || process3.cwd();
|
|
542
|
+
var CYBERSKILL_PACKAGE_NAME = "@cyberskill/shared";
|
|
543
|
+
var CYBERSKILL_STORAGE = ".cyberskill-storage";
|
|
544
|
+
var NODE_MODULES = "node_modules";
|
|
545
|
+
var BUILD_DIRECTORY = "dist";
|
|
546
|
+
var PACKAGE_JSON = "package.json";
|
|
547
|
+
var PACKAGE_LOCK_JSON = "package-lock.json";
|
|
548
|
+
var TSCONFIG_JSON = "tsconfig.json";
|
|
549
|
+
var GIT_IGNORE = ".gitignore";
|
|
550
|
+
var SIMPLE_GIT_HOOK_JSON = ".simple-git-hooks.json";
|
|
551
|
+
var PNPM_LOCK_YAML = "pnpm-lock.yaml";
|
|
552
|
+
var GIT_HOOK = ".git/hooks";
|
|
553
|
+
var GIT_COMMIT_EDITMSG = ".git/COMMIT_EDITMSG";
|
|
554
|
+
var CYBERSKILL_CLI = "cyberskill";
|
|
555
|
+
var ESLINT_CLI = "eslint";
|
|
556
|
+
var VITEST_CLI = "vitest";
|
|
557
|
+
var COMMIT_LINT_CLI = "commitlint";
|
|
558
|
+
var LINT_STAGED_CLI = "lint-staged";
|
|
559
|
+
var RIMRAF_CLI = "rimraf";
|
|
560
|
+
var TSC_CLI = "tsc";
|
|
561
|
+
var TSX_CLI = "tsx";
|
|
562
|
+
var GIT_CLI = "git";
|
|
563
|
+
var PNPM_CLI = "pnpm";
|
|
564
|
+
var PNPM_DLX_CLI = "pnpm dlx";
|
|
565
|
+
var PNPM_EXEC_CLI = "pnpm exec";
|
|
566
|
+
var SIMPLE_GIT_HOOK_CLI = "simple-git-hooks";
|
|
567
|
+
var ESLINT_INSPECT_CLI = "@eslint/config-inspector";
|
|
568
|
+
var NODE_MODULES_INSPECT_CLI = "node_modules-inspect";
|
|
569
|
+
var PATH = {
|
|
570
|
+
CYBERSKILL_DIRECTORY: CYBERSKILL_DIRECTORY,
|
|
571
|
+
WORKING_DIRECTORY: WORKING_DIRECTORY,
|
|
572
|
+
TS_CONFIG: resolveWorkingPath(TSCONFIG_JSON),
|
|
573
|
+
GIT_IGNORE: resolveWorkingPath(GIT_IGNORE),
|
|
574
|
+
GIT_HOOK: resolveWorkingPath(GIT_HOOK),
|
|
575
|
+
GIT_COMMIT_MSG: resolveWorkingPath(GIT_COMMIT_EDITMSG),
|
|
576
|
+
SIMPLE_GIT_HOOKS: resolveWorkingPath(SIMPLE_GIT_HOOK_JSON),
|
|
577
|
+
PACKAGE_JSON: resolveWorkingPath(PACKAGE_JSON),
|
|
578
|
+
PACKAGE_LOCK_JSON: resolveWorkingPath(PACKAGE_LOCK_JSON),
|
|
579
|
+
PNPM_LOCK_YAML: resolveWorkingPath(PNPM_LOCK_YAML),
|
|
580
|
+
NODE_MODULES: resolveWorkingPath(NODE_MODULES),
|
|
581
|
+
CYBERSKILL: {
|
|
582
|
+
LINT_STAGED_CONFIG: resolveCyberSkillPath("./configs/lint-staged/base.js"),
|
|
583
|
+
COMMITLINT_CONFIG: resolveCyberSkillPath("./configs/commitlint/base.js"),
|
|
584
|
+
UNIT_TEST_CONFIG: resolveCyberSkillPath("./configs/vitest/react/unit.js"),
|
|
585
|
+
E2E_TEST_CONFIG: resolveCyberSkillPath("./configs/vitest/react/e2e.js")
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
var COMMAND = {
|
|
589
|
+
SIMPLE_GIT_HOOKS: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(SIMPLE_GIT_HOOK_CLI)),
|
|
590
|
+
ESLINT_INSPECT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_INSPECT_CLI)),
|
|
591
|
+
NODE_MODULES_INSPECT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(NODE_MODULES_INSPECT_CLI)),
|
|
592
|
+
RESET: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(RIMRAF_CLI, " ").concat(NODE_MODULES, " ").concat(PNPM_LOCK_YAML)),
|
|
593
|
+
ESLINT_CHECK: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_CLI, " ").concat(PATH.WORKING_DIRECTORY)),
|
|
594
|
+
ESLINT_FIX: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_CLI, " ").concat(PATH.WORKING_DIRECTORY, " --fix")),
|
|
595
|
+
TYPESCRIPT_CHECK: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(TSC_CLI, " -p ").concat(PATH.TS_CONFIG, " --noEmit")),
|
|
596
|
+
CYBERSKILL: {
|
|
597
|
+
TEST_UNIT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(VITEST_CLI, " --config ").concat(PATH.CYBERSKILL.UNIT_TEST_CONFIG)),
|
|
598
|
+
TEST_E2E: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(VITEST_CLI, " --config ").concat(PATH.CYBERSKILL.E2E_TEST_CONFIG)),
|
|
599
|
+
COMMIT_LINT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(COMMIT_LINT_CLI, " --edit ").concat(PATH.GIT_COMMIT_MSG, " --config ").concat(PATH.CYBERSKILL.COMMITLINT_CONFIG)),
|
|
600
|
+
LINT_STAGED: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(LINT_STAGED_CLI, " --config ").concat(PATH.CYBERSKILL.LINT_STAGED_CONFIG))
|
|
601
|
+
},
|
|
602
|
+
CONFIGURE_GIT_HOOK: commandFormatter.raw("".concat(GIT_CLI, " config core.hooksPath ").concat(PATH.GIT_HOOK)),
|
|
603
|
+
BUILD: commandFormatter.raw("".concat(PNPM_CLI, " run build")),
|
|
604
|
+
STAGE_BUILD_DIRECTORY: commandFormatter.raw("".concat(GIT_CLI, " add ").concat(BUILD_DIRECTORY)),
|
|
605
|
+
PNPM_INSTALL_STANDARD: commandFormatter.raw("".concat(PNPM_CLI, " install")),
|
|
606
|
+
PNPM_INSTALL_LEGACY: commandFormatter.raw("".concat(PNPM_CLI, " install --legacy-peer-deps")),
|
|
607
|
+
PNPM_INSTALL_FORCE: commandFormatter.raw("".concat(PNPM_CLI, " install --force"))
|
|
608
|
+
};
|
|
609
|
+
// src/utils/fs.ts
|
|
610
|
+
import * as fs from "node:fs";
|
|
611
|
+
var existsSync2 = function(filePath) {
|
|
612
|
+
return fs.existsSync(filePath);
|
|
613
|
+
};
|
|
614
|
+
function readFileSync2(filePath, options) {
|
|
615
|
+
var content = fs.readFileSync(filePath, "utf-8");
|
|
616
|
+
if (options === null || options === void 0 ? void 0 : options.asJson) {
|
|
617
|
+
try {
|
|
618
|
+
var parsed = JSON.parse(content);
|
|
619
|
+
if ((typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) === "object" && parsed !== null) {
|
|
620
|
+
return parsed;
|
|
621
|
+
}
|
|
622
|
+
throw new Error("Parsed JSON is not an object or array");
|
|
623
|
+
} catch (e) {
|
|
624
|
+
throw new Error("Failed to parse JSON from file: ".concat(filePath));
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
return content;
|
|
628
|
+
}
|
|
629
|
+
// src/utils/package.ts
|
|
630
|
+
var CACHE_EXPIRATION_MS = 24 * 60 * 60 * 1e3;
|
|
631
|
+
function getPackageJson(packageName) {
|
|
632
|
+
var workingPackageJsonPath = join2(WORKING_DIRECTORY, PACKAGE_JSON);
|
|
633
|
+
if (existsSync2(workingPackageJsonPath)) {
|
|
634
|
+
try {
|
|
635
|
+
var pkg = readFileSync2(workingPackageJsonPath, {
|
|
636
|
+
asJson: true
|
|
637
|
+
});
|
|
638
|
+
if (pkg.name === packageName) {
|
|
639
|
+
return {
|
|
640
|
+
path: workingPackageJsonPath,
|
|
641
|
+
file: pkg
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
} catch (error) {
|
|
645
|
+
commandLog.warning("Failed to read local package.json: ".concat(error.message));
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
var externalPackageJsonPath = join2(WORKING_DIRECTORY, NODE_MODULES, packageName, PACKAGE_JSON);
|
|
649
|
+
if (existsSync2(externalPackageJsonPath)) {
|
|
650
|
+
try {
|
|
651
|
+
var pkg1 = readFileSync2(externalPackageJsonPath, {
|
|
652
|
+
asJson: true
|
|
653
|
+
});
|
|
654
|
+
if (pkg1.name === packageName) {
|
|
655
|
+
return {
|
|
656
|
+
path: externalPackageJsonPath,
|
|
657
|
+
file: pkg1
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
} catch (error) {
|
|
661
|
+
commandLog.warning("Failed to read node_modules package.json for ".concat(packageName, ": ").concat(error.message));
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return false;
|
|
665
|
+
}
|
|
666
|
+
function getLatestPackageVersion(packageName) {
|
|
667
|
+
return _getLatestPackageVersion.apply(this, arguments);
|
|
668
|
+
}
|
|
669
|
+
function _getLatestPackageVersion() {
|
|
670
|
+
_getLatestPackageVersion = _async_to_generator(function(packageName) {
|
|
671
|
+
var forceRefresh, versionCacheKey, metadataCacheKey, cached, metadata, isCacheValid, headers, response, data, latestVersion, error;
|
|
672
|
+
var _arguments = arguments;
|
|
673
|
+
return _ts_generator(this, function(_state) {
|
|
674
|
+
switch(_state.label){
|
|
675
|
+
case 0:
|
|
676
|
+
forceRefresh = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : false;
|
|
677
|
+
versionCacheKey = "npm_version:".concat(packageName);
|
|
678
|
+
metadataCacheKey = "npm_metadata:".concat(packageName);
|
|
679
|
+
return [
|
|
680
|
+
4,
|
|
681
|
+
storageServer.get(versionCacheKey)
|
|
682
|
+
];
|
|
683
|
+
case 1:
|
|
684
|
+
cached = _state.sent();
|
|
685
|
+
return [
|
|
686
|
+
4,
|
|
687
|
+
storageServer.get(metadataCacheKey)
|
|
688
|
+
];
|
|
689
|
+
case 2:
|
|
690
|
+
metadata = _state.sent();
|
|
691
|
+
isCacheValid = cached && Date.now() - cached.timestamp < CACHE_EXPIRATION_MS;
|
|
692
|
+
if (!forceRefresh && isCacheValid) {
|
|
693
|
+
return [
|
|
694
|
+
2,
|
|
695
|
+
cached.version
|
|
696
|
+
];
|
|
697
|
+
}
|
|
698
|
+
headers = {};
|
|
699
|
+
if (metadata === null || metadata === void 0 ? void 0 : metadata.etag) {
|
|
700
|
+
headers["If-None-Match"] = metadata.etag;
|
|
701
|
+
}
|
|
702
|
+
if (metadata === null || metadata === void 0 ? void 0 : metadata.lastModified) {
|
|
703
|
+
headers["If-Modified-Since"] = metadata.lastModified;
|
|
704
|
+
}
|
|
705
|
+
_state.label = 3;
|
|
706
|
+
case 3:
|
|
707
|
+
_state.trys.push([
|
|
708
|
+
3,
|
|
709
|
+
8,
|
|
710
|
+
,
|
|
711
|
+
9
|
|
712
|
+
]);
|
|
713
|
+
return [
|
|
714
|
+
4,
|
|
715
|
+
fetch("https://registry.npmjs.org/".concat(packageName, "/latest"), {
|
|
716
|
+
headers: headers
|
|
717
|
+
})
|
|
718
|
+
];
|
|
719
|
+
case 4:
|
|
720
|
+
response = _state.sent();
|
|
721
|
+
if (response.status === 304 && cached) {
|
|
722
|
+
return [
|
|
723
|
+
2,
|
|
724
|
+
cached.version
|
|
725
|
+
];
|
|
726
|
+
}
|
|
727
|
+
if (!response.ok) {
|
|
728
|
+
throw new Error("Failed to fetch latest version: ".concat(response.statusText));
|
|
729
|
+
}
|
|
730
|
+
return [
|
|
731
|
+
4,
|
|
732
|
+
response.json()
|
|
733
|
+
];
|
|
734
|
+
case 5:
|
|
735
|
+
data = _state.sent();
|
|
736
|
+
latestVersion = data.version;
|
|
737
|
+
return [
|
|
738
|
+
4,
|
|
739
|
+
storageServer.set(versionCacheKey, {
|
|
740
|
+
version: latestVersion,
|
|
741
|
+
timestamp: Date.now()
|
|
742
|
+
})
|
|
743
|
+
];
|
|
744
|
+
case 6:
|
|
745
|
+
_state.sent();
|
|
746
|
+
return [
|
|
747
|
+
4,
|
|
748
|
+
storageServer.set(metadataCacheKey, {
|
|
749
|
+
etag: response.headers.get("ETag") || void 0,
|
|
750
|
+
lastModified: response.headers.get("Last-Modified") || void 0
|
|
751
|
+
})
|
|
752
|
+
];
|
|
753
|
+
case 7:
|
|
754
|
+
_state.sent();
|
|
755
|
+
return [
|
|
756
|
+
2,
|
|
757
|
+
latestVersion
|
|
758
|
+
];
|
|
759
|
+
case 8:
|
|
760
|
+
error = _state.sent();
|
|
761
|
+
commandLog.error("Error fetching latest version for ".concat(packageName, ": ").concat(error.message));
|
|
762
|
+
if (cached) {
|
|
763
|
+
commandLog.warning("Falling back to cached version for ".concat(packageName, ": ").concat(cached.version));
|
|
764
|
+
return [
|
|
765
|
+
2,
|
|
766
|
+
cached.version
|
|
767
|
+
];
|
|
768
|
+
}
|
|
769
|
+
throw error;
|
|
770
|
+
case 9:
|
|
771
|
+
return [
|
|
772
|
+
2
|
|
773
|
+
];
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
});
|
|
777
|
+
return _getLatestPackageVersion.apply(this, arguments);
|
|
778
|
+
}
|
|
779
|
+
function checkPackage(packageName) {
|
|
780
|
+
return _checkPackage.apply(this, arguments);
|
|
781
|
+
}
|
|
782
|
+
function _checkPackage() {
|
|
783
|
+
_checkPackage = _async_to_generator(function(packageName) {
|
|
784
|
+
var result, packageFound, cyberskillPackageJsonPath, isCurrentProject, _tmp, error;
|
|
785
|
+
return _ts_generator(this, function(_state) {
|
|
786
|
+
switch(_state.label){
|
|
787
|
+
case 0:
|
|
788
|
+
result = {
|
|
789
|
+
isInstalled: false,
|
|
790
|
+
isCurrentProject: false,
|
|
791
|
+
installedPath: "",
|
|
792
|
+
installedVersion: "",
|
|
793
|
+
latestVersion: "",
|
|
794
|
+
file: {}
|
|
795
|
+
};
|
|
796
|
+
_state.label = 1;
|
|
797
|
+
case 1:
|
|
798
|
+
_state.trys.push([
|
|
799
|
+
1,
|
|
800
|
+
5,
|
|
801
|
+
,
|
|
802
|
+
6
|
|
803
|
+
]);
|
|
804
|
+
packageFound = getPackageJson(packageName);
|
|
805
|
+
if (!packageFound) {
|
|
806
|
+
return [
|
|
807
|
+
2,
|
|
808
|
+
result
|
|
809
|
+
];
|
|
810
|
+
}
|
|
811
|
+
cyberskillPackageJsonPath = resolveCyberSkillPath(PACKAGE_JSON);
|
|
812
|
+
isCurrentProject = packageFound.path === cyberskillPackageJsonPath;
|
|
813
|
+
result.file = packageFound.file;
|
|
814
|
+
result.isInstalled = true;
|
|
815
|
+
result.installedPath = packageFound.path;
|
|
816
|
+
result.installedVersion = packageFound.file.version;
|
|
817
|
+
result.isCurrentProject = isCurrentProject;
|
|
818
|
+
if (!isCurrentProject) return [
|
|
819
|
+
3,
|
|
820
|
+
2
|
|
821
|
+
];
|
|
822
|
+
_tmp = packageFound.file.version;
|
|
823
|
+
return [
|
|
824
|
+
3,
|
|
825
|
+
4
|
|
826
|
+
];
|
|
827
|
+
case 2:
|
|
828
|
+
return [
|
|
829
|
+
4,
|
|
830
|
+
getLatestPackageVersion(packageName, true)
|
|
831
|
+
];
|
|
832
|
+
case 3:
|
|
833
|
+
_tmp = _state.sent();
|
|
834
|
+
_state.label = 4;
|
|
835
|
+
case 4:
|
|
836
|
+
result.latestVersion = _tmp;
|
|
837
|
+
return [
|
|
838
|
+
2,
|
|
839
|
+
result
|
|
840
|
+
];
|
|
841
|
+
case 5:
|
|
842
|
+
error = _state.sent();
|
|
843
|
+
commandLog.error('Error checking package "'.concat(packageName, '": ').concat(error.message));
|
|
844
|
+
return [
|
|
845
|
+
2,
|
|
846
|
+
result
|
|
847
|
+
];
|
|
848
|
+
case 6:
|
|
849
|
+
return [
|
|
850
|
+
2
|
|
851
|
+
];
|
|
852
|
+
}
|
|
853
|
+
});
|
|
854
|
+
});
|
|
855
|
+
return _checkPackage.apply(this, arguments);
|
|
856
|
+
}
|
|
857
|
+
export { checkPackage, getLatestPackageVersion, getPackageJson };
|