@cyberskill/shared 1.47.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/dist/_tsup-dts-rollup.d.cts +410 -30
- package/dist/_tsup-dts-rollup.d.ts +410 -30
- 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 -7
- package/dist/index.d.ts +51 -7
- 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 -6
- package/dist/utils/index-nodejs.d.ts +15 -6
- 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 +11 -11
- 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,291 @@
|
|
|
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 _iterable_to_array(iter) {
|
|
11
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
12
|
+
}
|
|
13
|
+
function _non_iterable_spread() {
|
|
14
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
15
|
+
}
|
|
16
|
+
function _to_consumable_array(arr) {
|
|
17
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
18
|
+
}
|
|
19
|
+
function _type_of(obj) {
|
|
20
|
+
"@swc/helpers - typeof";
|
|
21
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
22
|
+
}
|
|
23
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
24
|
+
if (!o) return;
|
|
25
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
26
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
27
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
28
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
29
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
30
|
+
}
|
|
31
|
+
var __create = Object.create;
|
|
32
|
+
var __defProp = Object.defineProperty;
|
|
33
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
34
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
35
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
36
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
37
|
+
var __export = function(target, all) {
|
|
38
|
+
for(var name in all)__defProp(target, name, {
|
|
39
|
+
get: all[name],
|
|
40
|
+
enumerable: true
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
var __copyProps = function(to, from, except, desc) {
|
|
44
|
+
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
45
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
46
|
+
try {
|
|
47
|
+
var _loop = function() {
|
|
48
|
+
var key = _step.value;
|
|
49
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
50
|
+
get: function() {
|
|
51
|
+
return from[key];
|
|
52
|
+
},
|
|
53
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
57
|
+
} catch (err) {
|
|
58
|
+
_didIteratorError = true;
|
|
59
|
+
_iteratorError = err;
|
|
60
|
+
} finally{
|
|
61
|
+
try {
|
|
62
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
63
|
+
_iterator.return();
|
|
64
|
+
}
|
|
65
|
+
} finally{
|
|
66
|
+
if (_didIteratorError) {
|
|
67
|
+
throw _iteratorError;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return to;
|
|
73
|
+
};
|
|
74
|
+
var __toESM = function(mod, isNodeMode, target) {
|
|
75
|
+
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
76
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
77
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
78
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
79
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
80
|
+
value: mod,
|
|
81
|
+
enumerable: true
|
|
82
|
+
}) : target, mod);
|
|
83
|
+
};
|
|
84
|
+
var __toCommonJS = function(mod) {
|
|
85
|
+
return __copyProps(__defProp({}, "__esModule", {
|
|
86
|
+
value: true
|
|
87
|
+
}), mod);
|
|
88
|
+
};
|
|
89
|
+
// src/utils/path.ts
|
|
90
|
+
var path_exports = {};
|
|
91
|
+
__export(path_exports, {
|
|
92
|
+
dirname: function() {
|
|
93
|
+
return dirname;
|
|
94
|
+
},
|
|
95
|
+
join: function() {
|
|
96
|
+
return join;
|
|
97
|
+
},
|
|
98
|
+
require: function() {
|
|
99
|
+
return require2;
|
|
100
|
+
},
|
|
101
|
+
resolve: function() {
|
|
102
|
+
return resolve;
|
|
103
|
+
},
|
|
104
|
+
resolveCyberSkillPath: function() {
|
|
105
|
+
return resolveCyberSkillPath;
|
|
106
|
+
},
|
|
107
|
+
resolveWorkingPath: function() {
|
|
108
|
+
return resolveWorkingPath;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
module.exports = __toCommonJS(path_exports);
|
|
112
|
+
// node_modules/.pnpm/tsup@8.4.0_@microsoft+api-extractor@7.52.2_@types+node@22.13.15__@swc+core@1.11.16_@swc_2cf618e3551c9a9c667a9bb2a289f06e/node_modules/tsup/assets/cjs_shims.js
|
|
113
|
+
var getImportMetaUrl = function() {
|
|
114
|
+
return typeof document === "undefined" ? new URL("file:".concat(__filename)).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
115
|
+
};
|
|
116
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
117
|
+
// src/utils/path.ts
|
|
118
|
+
var import_node_module = require("module");
|
|
119
|
+
var path2 = __toESM(require("path"), 1);
|
|
120
|
+
// src/constants/path.ts
|
|
121
|
+
var import_node_process3 = __toESM(require("process"), 1);
|
|
122
|
+
var import_node_url = require("url");
|
|
123
|
+
// src/utils/command.ts
|
|
124
|
+
var import_boxen = __toESM(require("boxen"), 1);
|
|
125
|
+
var import_chalk = __toESM(require("chalk"), 1);
|
|
126
|
+
var import_node_child_process = require("child_process");
|
|
127
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
128
|
+
var util = __toESM(require("util"), 1);
|
|
129
|
+
// src/utils/package.ts
|
|
130
|
+
var import_node_fetch = __toESM(require("node-fetch"), 1);
|
|
131
|
+
// src/utils/fs.ts
|
|
132
|
+
var fs = __toESM(require("fs"), 1);
|
|
133
|
+
// src/utils/storage-server.ts
|
|
134
|
+
var import_node_persist = __toESM(require("node-persist"), 1);
|
|
135
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
136
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
137
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
138
|
+
// src/utils/package.ts
|
|
139
|
+
var CACHE_EXPIRATION_MS = 24 * 60 * 60 * 1e3;
|
|
140
|
+
// src/utils/command.ts
|
|
141
|
+
var DEBUG = import_node_process2.default.env.DEBUG === "true";
|
|
142
|
+
var execPromise = util.promisify(import_node_child_process.exec);
|
|
143
|
+
var _import_chalk_default = import_chalk.default, gray = _import_chalk_default.gray, blue = _import_chalk_default.blue;
|
|
144
|
+
var commandFormatter = {
|
|
145
|
+
raw: function(cmd) {
|
|
146
|
+
return {
|
|
147
|
+
raw: true,
|
|
148
|
+
cmd: cmd
|
|
149
|
+
};
|
|
150
|
+
},
|
|
151
|
+
isRaw: function isRaw(cmd) {
|
|
152
|
+
return (typeof cmd === "undefined" ? "undefined" : _type_of(cmd)) === "object" && cmd !== null && cmd.raw === true;
|
|
153
|
+
},
|
|
154
|
+
format: function format(command, context) {
|
|
155
|
+
if (typeof command === "function") {
|
|
156
|
+
return commandFormatter.formatCLI(command(context), context);
|
|
157
|
+
}
|
|
158
|
+
if (commandFormatter.isRaw(command)) {
|
|
159
|
+
return command.cmd;
|
|
160
|
+
}
|
|
161
|
+
return commandFormatter.formatCLI(command, context);
|
|
162
|
+
},
|
|
163
|
+
formatCLI: function formatCLI(command, context) {
|
|
164
|
+
if (context === null || context === void 0 ? void 0 : context.isRemote) {
|
|
165
|
+
return "".concat(PNPM_DLX_CLI, " ").concat(CYBERSKILL_PACKAGE_NAME, " ").concat(command);
|
|
166
|
+
}
|
|
167
|
+
if (context === null || context === void 0 ? void 0 : context.isCurrentProject) {
|
|
168
|
+
return "".concat(PNPM_EXEC_CLI, " ").concat(TSX_CLI, " src/cli.ts ").concat(command);
|
|
169
|
+
}
|
|
170
|
+
return "".concat(PNPM_EXEC_CLI, " ").concat(CYBERSKILL_CLI, " ").concat(command);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
// src/constants/path.ts
|
|
174
|
+
var __filename2 = (0, import_node_url.fileURLToPath)(importMetaUrl);
|
|
175
|
+
var __dirname = dirname(__filename2);
|
|
176
|
+
var CYBERSKILL_DIRECTORY = resolve(__dirname, "../../");
|
|
177
|
+
var WORKING_DIRECTORY = import_node_process3.default.env.INIT_CWD || import_node_process3.default.cwd();
|
|
178
|
+
var CYBERSKILL_PACKAGE_NAME = "@cyberskill/shared";
|
|
179
|
+
var NODE_MODULES = "node_modules";
|
|
180
|
+
var BUILD_DIRECTORY = "dist";
|
|
181
|
+
var PACKAGE_JSON = "package.json";
|
|
182
|
+
var PACKAGE_LOCK_JSON = "package-lock.json";
|
|
183
|
+
var TSCONFIG_JSON = "tsconfig.json";
|
|
184
|
+
var GIT_IGNORE = ".gitignore";
|
|
185
|
+
var SIMPLE_GIT_HOOK_JSON = ".simple-git-hooks.json";
|
|
186
|
+
var PNPM_LOCK_YAML = "pnpm-lock.yaml";
|
|
187
|
+
var GIT_HOOK = ".git/hooks";
|
|
188
|
+
var GIT_COMMIT_EDITMSG = ".git/COMMIT_EDITMSG";
|
|
189
|
+
var CYBERSKILL_CLI = "cyberskill";
|
|
190
|
+
var ESLINT_CLI = "eslint";
|
|
191
|
+
var VITEST_CLI = "vitest";
|
|
192
|
+
var COMMIT_LINT_CLI = "commitlint";
|
|
193
|
+
var LINT_STAGED_CLI = "lint-staged";
|
|
194
|
+
var RIMRAF_CLI = "rimraf";
|
|
195
|
+
var TSC_CLI = "tsc";
|
|
196
|
+
var TSX_CLI = "tsx";
|
|
197
|
+
var GIT_CLI = "git";
|
|
198
|
+
var PNPM_CLI = "pnpm";
|
|
199
|
+
var PNPM_DLX_CLI = "pnpm dlx";
|
|
200
|
+
var PNPM_EXEC_CLI = "pnpm exec";
|
|
201
|
+
var SIMPLE_GIT_HOOK_CLI = "simple-git-hooks";
|
|
202
|
+
var ESLINT_INSPECT_CLI = "@eslint/config-inspector";
|
|
203
|
+
var NODE_MODULES_INSPECT_CLI = "node_modules-inspect";
|
|
204
|
+
var PATH = {
|
|
205
|
+
CYBERSKILL_DIRECTORY: CYBERSKILL_DIRECTORY,
|
|
206
|
+
WORKING_DIRECTORY: WORKING_DIRECTORY,
|
|
207
|
+
TS_CONFIG: resolveWorkingPath(TSCONFIG_JSON),
|
|
208
|
+
GIT_IGNORE: resolveWorkingPath(GIT_IGNORE),
|
|
209
|
+
GIT_HOOK: resolveWorkingPath(GIT_HOOK),
|
|
210
|
+
GIT_COMMIT_MSG: resolveWorkingPath(GIT_COMMIT_EDITMSG),
|
|
211
|
+
SIMPLE_GIT_HOOKS: resolveWorkingPath(SIMPLE_GIT_HOOK_JSON),
|
|
212
|
+
PACKAGE_JSON: resolveWorkingPath(PACKAGE_JSON),
|
|
213
|
+
PACKAGE_LOCK_JSON: resolveWorkingPath(PACKAGE_LOCK_JSON),
|
|
214
|
+
PNPM_LOCK_YAML: resolveWorkingPath(PNPM_LOCK_YAML),
|
|
215
|
+
NODE_MODULES: resolveWorkingPath(NODE_MODULES),
|
|
216
|
+
CYBERSKILL: {
|
|
217
|
+
LINT_STAGED_CONFIG: resolveCyberSkillPath("./configs/lint-staged/base.js"),
|
|
218
|
+
COMMITLINT_CONFIG: resolveCyberSkillPath("./configs/commitlint/base.js"),
|
|
219
|
+
UNIT_TEST_CONFIG: resolveCyberSkillPath("./configs/vitest/react/unit.js"),
|
|
220
|
+
E2E_TEST_CONFIG: resolveCyberSkillPath("./configs/vitest/react/e2e.js")
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
var COMMAND = {
|
|
224
|
+
SIMPLE_GIT_HOOKS: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(SIMPLE_GIT_HOOK_CLI)),
|
|
225
|
+
ESLINT_INSPECT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_INSPECT_CLI)),
|
|
226
|
+
NODE_MODULES_INSPECT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(NODE_MODULES_INSPECT_CLI)),
|
|
227
|
+
RESET: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(RIMRAF_CLI, " ").concat(NODE_MODULES, " ").concat(PNPM_LOCK_YAML)),
|
|
228
|
+
ESLINT_CHECK: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_CLI, " ").concat(PATH.WORKING_DIRECTORY)),
|
|
229
|
+
ESLINT_FIX: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_CLI, " ").concat(PATH.WORKING_DIRECTORY, " --fix")),
|
|
230
|
+
TYPESCRIPT_CHECK: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(TSC_CLI, " -p ").concat(PATH.TS_CONFIG, " --noEmit")),
|
|
231
|
+
CYBERSKILL: {
|
|
232
|
+
TEST_UNIT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(VITEST_CLI, " --config ").concat(PATH.CYBERSKILL.UNIT_TEST_CONFIG)),
|
|
233
|
+
TEST_E2E: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(VITEST_CLI, " --config ").concat(PATH.CYBERSKILL.E2E_TEST_CONFIG)),
|
|
234
|
+
COMMIT_LINT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(COMMIT_LINT_CLI, " --edit ").concat(PATH.GIT_COMMIT_MSG, " --config ").concat(PATH.CYBERSKILL.COMMITLINT_CONFIG)),
|
|
235
|
+
LINT_STAGED: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(LINT_STAGED_CLI, " --config ").concat(PATH.CYBERSKILL.LINT_STAGED_CONFIG))
|
|
236
|
+
},
|
|
237
|
+
CONFIGURE_GIT_HOOK: commandFormatter.raw("".concat(GIT_CLI, " config core.hooksPath ").concat(PATH.GIT_HOOK)),
|
|
238
|
+
BUILD: commandFormatter.raw("".concat(PNPM_CLI, " run build")),
|
|
239
|
+
STAGE_BUILD_DIRECTORY: commandFormatter.raw("".concat(GIT_CLI, " add ").concat(BUILD_DIRECTORY)),
|
|
240
|
+
PNPM_INSTALL_STANDARD: commandFormatter.raw("".concat(PNPM_CLI, " install")),
|
|
241
|
+
PNPM_INSTALL_LEGACY: commandFormatter.raw("".concat(PNPM_CLI, " install --legacy-peer-deps")),
|
|
242
|
+
PNPM_INSTALL_FORCE: commandFormatter.raw("".concat(PNPM_CLI, " install --force"))
|
|
243
|
+
};
|
|
244
|
+
// src/utils/path.ts
|
|
245
|
+
function resolveCyberSkillPath() {
|
|
246
|
+
for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
|
|
247
|
+
urls[_key] = arguments[_key];
|
|
248
|
+
}
|
|
249
|
+
var _path2;
|
|
250
|
+
return (_path2 = path2).resolve.apply(_path2, [
|
|
251
|
+
CYBERSKILL_DIRECTORY
|
|
252
|
+
].concat(_to_consumable_array(urls)));
|
|
253
|
+
}
|
|
254
|
+
function resolveWorkingPath() {
|
|
255
|
+
for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
|
|
256
|
+
urls[_key] = arguments[_key];
|
|
257
|
+
}
|
|
258
|
+
var _path2;
|
|
259
|
+
return (_path2 = path2).resolve.apply(_path2, [
|
|
260
|
+
WORKING_DIRECTORY
|
|
261
|
+
].concat(_to_consumable_array(urls)));
|
|
262
|
+
}
|
|
263
|
+
function resolve() {
|
|
264
|
+
for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
|
|
265
|
+
urls[_key] = arguments[_key];
|
|
266
|
+
}
|
|
267
|
+
var _path2;
|
|
268
|
+
return (_path2 = path2).resolve.apply(_path2, _to_consumable_array(urls));
|
|
269
|
+
}
|
|
270
|
+
function dirname(url) {
|
|
271
|
+
return path2.dirname(url);
|
|
272
|
+
}
|
|
273
|
+
function require2() {
|
|
274
|
+
return (0, import_node_module.createRequire)(CYBERSKILL_DIRECTORY);
|
|
275
|
+
}
|
|
276
|
+
function join() {
|
|
277
|
+
for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
|
|
278
|
+
urls[_key] = arguments[_key];
|
|
279
|
+
}
|
|
280
|
+
var _path2;
|
|
281
|
+
return (_path2 = path2).join.apply(_path2, _to_consumable_array(urls));
|
|
282
|
+
}
|
|
283
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
284
|
+
0 && (module.exports = {
|
|
285
|
+
dirname: dirname,
|
|
286
|
+
join: join,
|
|
287
|
+
require: require,
|
|
288
|
+
resolve: resolve,
|
|
289
|
+
resolveCyberSkillPath: resolveCyberSkillPath,
|
|
290
|
+
resolveWorkingPath: resolveWorkingPath
|
|
291
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { resolveCyberSkillPath_alias_2 as resolveCyberSkillPath } from '../_tsup-dts-rollup.cjs';
|
|
2
|
+
export { resolveWorkingPath_alias_2 as resolveWorkingPath } from '../_tsup-dts-rollup.cjs';
|
|
3
|
+
export { resolve_alias_2 as resolve } from '../_tsup-dts-rollup.cjs';
|
|
4
|
+
export { dirname_alias_2 as dirname } from '../_tsup-dts-rollup.cjs';
|
|
5
|
+
export { require_alias_2 as require } from '../_tsup-dts-rollup.cjs';
|
|
6
|
+
export { join_alias_2 as join } from '../_tsup-dts-rollup.cjs';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { resolveCyberSkillPath_alias_2 as resolveCyberSkillPath } from '../_tsup-dts-rollup.js';
|
|
2
|
+
export { resolveWorkingPath_alias_2 as resolveWorkingPath } from '../_tsup-dts-rollup.js';
|
|
3
|
+
export { resolve_alias_2 as resolve } from '../_tsup-dts-rollup.js';
|
|
4
|
+
export { dirname_alias_2 as dirname } from '../_tsup-dts-rollup.js';
|
|
5
|
+
export { require_alias_2 as require } from '../_tsup-dts-rollup.js';
|
|
6
|
+
export { join_alias_2 as join } from '../_tsup-dts-rollup.js';
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// src/utils/path.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 _iterable_to_array(iter) {
|
|
11
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
12
|
+
}
|
|
13
|
+
function _non_iterable_spread() {
|
|
14
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
15
|
+
}
|
|
16
|
+
function _to_consumable_array(arr) {
|
|
17
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
18
|
+
}
|
|
19
|
+
function _type_of(obj) {
|
|
20
|
+
"@swc/helpers - typeof";
|
|
21
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
22
|
+
}
|
|
23
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
24
|
+
if (!o) return;
|
|
25
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
26
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
27
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
28
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
29
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
30
|
+
}
|
|
31
|
+
import { createRequire } from "node:module";
|
|
32
|
+
import * as path from "node:path";
|
|
33
|
+
// src/constants/path.ts
|
|
34
|
+
import process2 from "node:process";
|
|
35
|
+
import { fileURLToPath } from "node:url";
|
|
36
|
+
// src/utils/command.ts
|
|
37
|
+
import boxen from "boxen";
|
|
38
|
+
import chalk from "chalk";
|
|
39
|
+
import { exec } from "node:child_process";
|
|
40
|
+
import process from "node:process";
|
|
41
|
+
import * as util from "node:util";
|
|
42
|
+
// src/utils/package.ts
|
|
43
|
+
import fetch from "node-fetch";
|
|
44
|
+
// src/utils/storage-server.ts
|
|
45
|
+
import nodePersist from "node-persist";
|
|
46
|
+
// src/utils/package.ts
|
|
47
|
+
var CACHE_EXPIRATION_MS = 24 * 60 * 60 * 1e3;
|
|
48
|
+
// src/utils/command.ts
|
|
49
|
+
var DEBUG = process.env.DEBUG === "true";
|
|
50
|
+
var execPromise = util.promisify(exec);
|
|
51
|
+
var gray = chalk.gray, blue = chalk.blue;
|
|
52
|
+
var commandFormatter = {
|
|
53
|
+
raw: function(cmd) {
|
|
54
|
+
return {
|
|
55
|
+
raw: true,
|
|
56
|
+
cmd: cmd
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
isRaw: function isRaw(cmd) {
|
|
60
|
+
return (typeof cmd === "undefined" ? "undefined" : _type_of(cmd)) === "object" && cmd !== null && cmd.raw === true;
|
|
61
|
+
},
|
|
62
|
+
format: function format(command, context) {
|
|
63
|
+
if (typeof command === "function") {
|
|
64
|
+
return commandFormatter.formatCLI(command(context), context);
|
|
65
|
+
}
|
|
66
|
+
if (commandFormatter.isRaw(command)) {
|
|
67
|
+
return command.cmd;
|
|
68
|
+
}
|
|
69
|
+
return commandFormatter.formatCLI(command, context);
|
|
70
|
+
},
|
|
71
|
+
formatCLI: function formatCLI(command, context) {
|
|
72
|
+
if (context === null || context === void 0 ? void 0 : context.isRemote) {
|
|
73
|
+
return "".concat(PNPM_DLX_CLI, " ").concat(CYBERSKILL_PACKAGE_NAME, " ").concat(command);
|
|
74
|
+
}
|
|
75
|
+
if (context === null || context === void 0 ? void 0 : context.isCurrentProject) {
|
|
76
|
+
return "".concat(PNPM_EXEC_CLI, " ").concat(TSX_CLI, " src/cli.ts ").concat(command);
|
|
77
|
+
}
|
|
78
|
+
return "".concat(PNPM_EXEC_CLI, " ").concat(CYBERSKILL_CLI, " ").concat(command);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
// src/constants/path.ts
|
|
82
|
+
var __filename2 = fileURLToPath(import.meta.url);
|
|
83
|
+
var __dirname2 = dirname(__filename2);
|
|
84
|
+
var CYBERSKILL_DIRECTORY = resolve(__dirname2, "../../");
|
|
85
|
+
var WORKING_DIRECTORY = process2.env.INIT_CWD || process2.cwd();
|
|
86
|
+
var CYBERSKILL_PACKAGE_NAME = "@cyberskill/shared";
|
|
87
|
+
var NODE_MODULES = "node_modules";
|
|
88
|
+
var BUILD_DIRECTORY = "dist";
|
|
89
|
+
var PACKAGE_JSON = "package.json";
|
|
90
|
+
var PACKAGE_LOCK_JSON = "package-lock.json";
|
|
91
|
+
var TSCONFIG_JSON = "tsconfig.json";
|
|
92
|
+
var GIT_IGNORE = ".gitignore";
|
|
93
|
+
var SIMPLE_GIT_HOOK_JSON = ".simple-git-hooks.json";
|
|
94
|
+
var PNPM_LOCK_YAML = "pnpm-lock.yaml";
|
|
95
|
+
var GIT_HOOK = ".git/hooks";
|
|
96
|
+
var GIT_COMMIT_EDITMSG = ".git/COMMIT_EDITMSG";
|
|
97
|
+
var CYBERSKILL_CLI = "cyberskill";
|
|
98
|
+
var ESLINT_CLI = "eslint";
|
|
99
|
+
var VITEST_CLI = "vitest";
|
|
100
|
+
var COMMIT_LINT_CLI = "commitlint";
|
|
101
|
+
var LINT_STAGED_CLI = "lint-staged";
|
|
102
|
+
var RIMRAF_CLI = "rimraf";
|
|
103
|
+
var TSC_CLI = "tsc";
|
|
104
|
+
var TSX_CLI = "tsx";
|
|
105
|
+
var GIT_CLI = "git";
|
|
106
|
+
var PNPM_CLI = "pnpm";
|
|
107
|
+
var PNPM_DLX_CLI = "pnpm dlx";
|
|
108
|
+
var PNPM_EXEC_CLI = "pnpm exec";
|
|
109
|
+
var SIMPLE_GIT_HOOK_CLI = "simple-git-hooks";
|
|
110
|
+
var ESLINT_INSPECT_CLI = "@eslint/config-inspector";
|
|
111
|
+
var NODE_MODULES_INSPECT_CLI = "node_modules-inspect";
|
|
112
|
+
var PATH = {
|
|
113
|
+
CYBERSKILL_DIRECTORY: CYBERSKILL_DIRECTORY,
|
|
114
|
+
WORKING_DIRECTORY: WORKING_DIRECTORY,
|
|
115
|
+
TS_CONFIG: resolveWorkingPath(TSCONFIG_JSON),
|
|
116
|
+
GIT_IGNORE: resolveWorkingPath(GIT_IGNORE),
|
|
117
|
+
GIT_HOOK: resolveWorkingPath(GIT_HOOK),
|
|
118
|
+
GIT_COMMIT_MSG: resolveWorkingPath(GIT_COMMIT_EDITMSG),
|
|
119
|
+
SIMPLE_GIT_HOOKS: resolveWorkingPath(SIMPLE_GIT_HOOK_JSON),
|
|
120
|
+
PACKAGE_JSON: resolveWorkingPath(PACKAGE_JSON),
|
|
121
|
+
PACKAGE_LOCK_JSON: resolveWorkingPath(PACKAGE_LOCK_JSON),
|
|
122
|
+
PNPM_LOCK_YAML: resolveWorkingPath(PNPM_LOCK_YAML),
|
|
123
|
+
NODE_MODULES: resolveWorkingPath(NODE_MODULES),
|
|
124
|
+
CYBERSKILL: {
|
|
125
|
+
LINT_STAGED_CONFIG: resolveCyberSkillPath("./configs/lint-staged/base.js"),
|
|
126
|
+
COMMITLINT_CONFIG: resolveCyberSkillPath("./configs/commitlint/base.js"),
|
|
127
|
+
UNIT_TEST_CONFIG: resolveCyberSkillPath("./configs/vitest/react/unit.js"),
|
|
128
|
+
E2E_TEST_CONFIG: resolveCyberSkillPath("./configs/vitest/react/e2e.js")
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
var COMMAND = {
|
|
132
|
+
SIMPLE_GIT_HOOKS: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(SIMPLE_GIT_HOOK_CLI)),
|
|
133
|
+
ESLINT_INSPECT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_INSPECT_CLI)),
|
|
134
|
+
NODE_MODULES_INSPECT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(NODE_MODULES_INSPECT_CLI)),
|
|
135
|
+
RESET: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(RIMRAF_CLI, " ").concat(NODE_MODULES, " ").concat(PNPM_LOCK_YAML)),
|
|
136
|
+
ESLINT_CHECK: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_CLI, " ").concat(PATH.WORKING_DIRECTORY)),
|
|
137
|
+
ESLINT_FIX: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(ESLINT_CLI, " ").concat(PATH.WORKING_DIRECTORY, " --fix")),
|
|
138
|
+
TYPESCRIPT_CHECK: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(TSC_CLI, " -p ").concat(PATH.TS_CONFIG, " --noEmit")),
|
|
139
|
+
CYBERSKILL: {
|
|
140
|
+
TEST_UNIT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(VITEST_CLI, " --config ").concat(PATH.CYBERSKILL.UNIT_TEST_CONFIG)),
|
|
141
|
+
TEST_E2E: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(VITEST_CLI, " --config ").concat(PATH.CYBERSKILL.E2E_TEST_CONFIG)),
|
|
142
|
+
COMMIT_LINT: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(COMMIT_LINT_CLI, " --edit ").concat(PATH.GIT_COMMIT_MSG, " --config ").concat(PATH.CYBERSKILL.COMMITLINT_CONFIG)),
|
|
143
|
+
LINT_STAGED: commandFormatter.raw("".concat(PNPM_EXEC_CLI, " ").concat(LINT_STAGED_CLI, " --config ").concat(PATH.CYBERSKILL.LINT_STAGED_CONFIG))
|
|
144
|
+
},
|
|
145
|
+
CONFIGURE_GIT_HOOK: commandFormatter.raw("".concat(GIT_CLI, " config core.hooksPath ").concat(PATH.GIT_HOOK)),
|
|
146
|
+
BUILD: commandFormatter.raw("".concat(PNPM_CLI, " run build")),
|
|
147
|
+
STAGE_BUILD_DIRECTORY: commandFormatter.raw("".concat(GIT_CLI, " add ").concat(BUILD_DIRECTORY)),
|
|
148
|
+
PNPM_INSTALL_STANDARD: commandFormatter.raw("".concat(PNPM_CLI, " install")),
|
|
149
|
+
PNPM_INSTALL_LEGACY: commandFormatter.raw("".concat(PNPM_CLI, " install --legacy-peer-deps")),
|
|
150
|
+
PNPM_INSTALL_FORCE: commandFormatter.raw("".concat(PNPM_CLI, " install --force"))
|
|
151
|
+
};
|
|
152
|
+
// src/utils/path.ts
|
|
153
|
+
function resolveCyberSkillPath() {
|
|
154
|
+
for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
|
|
155
|
+
urls[_key] = arguments[_key];
|
|
156
|
+
}
|
|
157
|
+
var _path;
|
|
158
|
+
return (_path = path).resolve.apply(_path, [
|
|
159
|
+
CYBERSKILL_DIRECTORY
|
|
160
|
+
].concat(_to_consumable_array(urls)));
|
|
161
|
+
}
|
|
162
|
+
function resolveWorkingPath() {
|
|
163
|
+
for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
|
|
164
|
+
urls[_key] = arguments[_key];
|
|
165
|
+
}
|
|
166
|
+
var _path;
|
|
167
|
+
return (_path = path).resolve.apply(_path, [
|
|
168
|
+
WORKING_DIRECTORY
|
|
169
|
+
].concat(_to_consumable_array(urls)));
|
|
170
|
+
}
|
|
171
|
+
function resolve() {
|
|
172
|
+
for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
|
|
173
|
+
urls[_key] = arguments[_key];
|
|
174
|
+
}
|
|
175
|
+
var _path;
|
|
176
|
+
return (_path = path).resolve.apply(_path, _to_consumable_array(urls));
|
|
177
|
+
}
|
|
178
|
+
function dirname(url) {
|
|
179
|
+
return path.dirname(url);
|
|
180
|
+
}
|
|
181
|
+
function require2() {
|
|
182
|
+
return createRequire(CYBERSKILL_DIRECTORY);
|
|
183
|
+
}
|
|
184
|
+
function join() {
|
|
185
|
+
for(var _len = arguments.length, urls = new Array(_len), _key = 0; _key < _len; _key++){
|
|
186
|
+
urls[_key] = arguments[_key];
|
|
187
|
+
}
|
|
188
|
+
var _path;
|
|
189
|
+
return (_path = path).join.apply(_path, _to_consumable_array(urls));
|
|
190
|
+
}
|
|
191
|
+
export { dirname, join, require2 as require, resolve, resolveCyberSkillPath, resolveWorkingPath };
|
|
@@ -1 +1,91 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
function _instanceof(left, right) {
|
|
3
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
4
|
+
return !!right[Symbol.hasInstance](left);
|
|
5
|
+
} else {
|
|
6
|
+
return left instanceof right;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function _type_of(obj) {
|
|
10
|
+
"@swc/helpers - typeof";
|
|
11
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
12
|
+
}
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
|
+
var __export = function(target, all) {
|
|
18
|
+
for(var name in all)__defProp(target, name, {
|
|
19
|
+
get: all[name],
|
|
20
|
+
enumerable: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var __copyProps = function(to, from, except, desc) {
|
|
24
|
+
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
25
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
26
|
+
try {
|
|
27
|
+
var _loop = function() {
|
|
28
|
+
var key = _step.value;
|
|
29
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
30
|
+
get: function() {
|
|
31
|
+
return from[key];
|
|
32
|
+
},
|
|
33
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
37
|
+
} catch (err) {
|
|
38
|
+
_didIteratorError = true;
|
|
39
|
+
_iteratorError = err;
|
|
40
|
+
} finally{
|
|
41
|
+
try {
|
|
42
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
43
|
+
_iterator.return();
|
|
44
|
+
}
|
|
45
|
+
} finally{
|
|
46
|
+
if (_didIteratorError) {
|
|
47
|
+
throw _iteratorError;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return to;
|
|
53
|
+
};
|
|
54
|
+
var __toCommonJS = function(mod) {
|
|
55
|
+
return __copyProps(__defProp({}, "__esModule", {
|
|
56
|
+
value: true
|
|
57
|
+
}), mod);
|
|
58
|
+
};
|
|
59
|
+
// src/utils/serializer.ts
|
|
60
|
+
var serializer_exports = {};
|
|
61
|
+
__export(serializer_exports, {
|
|
62
|
+
serializer: function() {
|
|
63
|
+
return serializer;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
module.exports = __toCommonJS(serializer_exports);
|
|
67
|
+
var serializer = {
|
|
68
|
+
serialize: function(value) {
|
|
69
|
+
return JSON.stringify(value, function(_, v) {
|
|
70
|
+
if (_instanceof(v, Date)) {
|
|
71
|
+
return {
|
|
72
|
+
__type: "Date",
|
|
73
|
+
value: v.toISOString()
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return v;
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
deserialize: function(value) {
|
|
80
|
+
return JSON.parse(value, function(_, v) {
|
|
81
|
+
if ((v === null || v === void 0 ? void 0 : v.__type) === "Date") {
|
|
82
|
+
return new Date(v.value);
|
|
83
|
+
}
|
|
84
|
+
return v;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
90
|
+
serializer: serializer
|
|
91
|
+
});
|
package/dist/utils/serializer.js
CHANGED
|
@@ -1 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
// src/utils/serializer.ts
|
|
2
|
+
function _instanceof(left, right) {
|
|
3
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
4
|
+
return !!right[Symbol.hasInstance](left);
|
|
5
|
+
} else {
|
|
6
|
+
return left instanceof right;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
var serializer = {
|
|
10
|
+
serialize: function(value) {
|
|
11
|
+
return JSON.stringify(value, function(_, v) {
|
|
12
|
+
if (_instanceof(v, Date)) {
|
|
13
|
+
return {
|
|
14
|
+
__type: "Date",
|
|
15
|
+
value: v.toISOString()
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return v;
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
deserialize: function(value) {
|
|
22
|
+
return JSON.parse(value, function(_, v) {
|
|
23
|
+
if ((v === null || v === void 0 ? void 0 : v.__type) === "Date") {
|
|
24
|
+
return new Date(v.value);
|
|
25
|
+
}
|
|
26
|
+
return v;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export { serializer };
|