@cyberskill/shared 1.208.0 → 1.209.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/config-CwzVfkkX.js +6 -0
- package/dist/index-BG1UznTl.js +628 -0
- package/dist/{magic-string.es-C6Zk6wMx.js → magic-string.es-BQ9KnLz-.js} +105 -117
- package/dist/src/config/config.type.d.ts +1 -1
- package/dist/src/config/config.util.d.ts +1 -1
- package/dist/src/config/config.util.js +48 -7
- package/dist/src/config/env/env.util.js +10 -10
- package/dist/src/config/eslint/index.js +4 -15
- package/dist/src/config/graphql-codegen/graphql-codegen.util.js +30 -39
- package/dist/src/config/index.js +1 -1
- package/dist/src/config/vitest/vitest.e2e.js +9 -19
- package/dist/src/config/vitest/vitest.unit.js +11 -22
- package/dist/src/config/vitest/vitest.unit.setup.js +9339 -9868
- package/dist/src/constant/common.js +1 -1
- package/dist/src/node/apollo-server/apollo-server.util.js +23 -54
- package/dist/src/node/cli/index.d.ts +2 -1
- package/dist/src/node/cli/index.js +108 -1
- package/dist/src/node/command/command.util.js +9 -10
- package/dist/src/node/command/index.js +1 -1
- package/dist/src/node/express/express.util.js +39 -77
- package/dist/src/node/express/index.js +9 -9
- package/dist/src/node/fs/fs.util.js +40 -59
- package/dist/src/node/log/index.js +6 -6
- package/dist/src/node/log/log.util.js +32 -33
- package/dist/src/node/mongo/mongo.util.js +381 -457
- package/dist/src/node/package/index.js +3 -3
- package/dist/src/node/package/package.util.js +2 -2
- package/dist/src/node/path/index.js +30 -30
- package/dist/src/node/path/path.constant.js +30 -30
- package/dist/src/node/storage/storage.util.js +40 -70
- package/dist/src/node/upload/index.js +1 -1
- package/dist/src/node/upload/upload.util.js +125 -6
- package/dist/src/react/apollo-client/apollo-client.component.js +15 -13
- package/dist/src/react/apollo-client/apollo-client.type.d.ts +1 -1
- package/dist/src/react/apollo-client/apollo-client.util.js +66 -81
- package/dist/src/react/apollo-client/index.js +25 -26
- package/dist/src/react/apollo-client-nextjs/apollo-client-nextjs.component.js +7 -8
- package/dist/src/react/apollo-client-nextjs/apollo-client-nextjs.util.js +11 -21
- package/dist/src/react/apollo-error/apollo-error.component.js +7 -7
- package/dist/src/react/apollo-error/apollo-error.util.js +7 -7
- package/dist/src/react/loading/loading.component.js +24 -45
- package/dist/src/react/loading/loading.provider.d.ts +1 -1
- package/dist/src/react/log/log.util.js +9 -9
- package/dist/src/react/next-intl/next-intl.hoc.d.ts +1 -1
- package/dist/src/react/next-intl/next-intl.hoc.js +17 -29
- package/dist/src/react/next-intl/next-intl.provider.js +18 -19
- package/dist/src/react/next-intl/next-intl.type.d.ts +1 -1
- package/dist/src/react/storage/storage.hook.js +37 -53
- package/dist/src/react/storage/storage.util.js +25 -50
- package/dist/src/react/userback/userback.component.js +16 -43
- package/dist/src/typescript/index.d.ts +2 -2
- package/dist/src/typescript/index.js +2 -2
- package/dist/src/typescript/style.d.js +1 -1
- package/dist/src/util/common/common.util.js +14 -25
- package/dist/src/util/object/object.util.d.ts +1 -1
- package/dist/src/util/object/object.util.js +39 -49
- package/dist/src/util/string/string.util.js +40 -53
- package/dist/style.css +1 -1
- package/package.json +43 -76
- package/dist/config-B7WSlzSh.js +0 -8
- package/dist/config-DDQ9k8fw.cjs +0 -1
- package/dist/config.util-Ci2CZDut.cjs +0 -1
- package/dist/config.util-DKBwEBKR.js +0 -61
- package/dist/favicon/android-icon-144x144.png +0 -0
- package/dist/favicon/android-icon-192x192.png +0 -0
- package/dist/favicon/android-icon-36x36.png +0 -0
- package/dist/favicon/android-icon-48x48.png +0 -0
- package/dist/favicon/android-icon-72x72.png +0 -0
- package/dist/favicon/android-icon-96x96.png +0 -0
- package/dist/favicon/apple-icon-114x114.png +0 -0
- package/dist/favicon/apple-icon-120x120.png +0 -0
- package/dist/favicon/apple-icon-144x144.png +0 -0
- package/dist/favicon/apple-icon-152x152.png +0 -0
- package/dist/favicon/apple-icon-180x180.png +0 -0
- package/dist/favicon/apple-icon-57x57.png +0 -0
- package/dist/favicon/apple-icon-60x60.png +0 -0
- package/dist/favicon/apple-icon-72x72.png +0 -0
- package/dist/favicon/apple-icon-76x76.png +0 -0
- package/dist/favicon/apple-icon-precomposed.png +0 -0
- package/dist/favicon/apple-icon.png +0 -0
- package/dist/favicon/browserconfig.xml +0 -2
- package/dist/favicon/favicon-16x16.png +0 -0
- package/dist/favicon/favicon-32x32.png +0 -0
- package/dist/favicon/favicon-96x96.png +0 -0
- package/dist/favicon/favicon.ico +0 -0
- package/dist/favicon/manifest.json +0 -41
- package/dist/favicon/ms-icon-144x144.png +0 -0
- package/dist/favicon/ms-icon-150x150.png +0 -0
- package/dist/favicon/ms-icon-310x310.png +0 -0
- package/dist/favicon/ms-icon-70x70.png +0 -0
- package/dist/log.type-CMvG6Box.cjs +0 -1
- package/dist/log.type-DTOvZHyz.js +0 -4
- package/dist/magic-string.es-CjWtD8Pa.cjs +0 -10
- package/dist/path.constant-CWtb99gS.cjs +0 -2
- package/dist/path.constant-CvSr0Rrx.js +0 -682
- package/dist/src/config/commitlint/index.cjs +0 -1
- package/dist/src/config/config.util.cjs +0 -1
- package/dist/src/config/env/env.constant.cjs +0 -1
- package/dist/src/config/env/env.d.cjs +0 -1
- package/dist/src/config/env/env.d.js +0 -1
- package/dist/src/config/env/env.util.cjs +0 -1
- package/dist/src/config/env/index.cjs +0 -1
- package/dist/src/config/eslint/index.cjs +0 -1
- package/dist/src/config/graphql-codegen/graphql-codegen.util.cjs +0 -1
- package/dist/src/config/graphql-codegen/index.cjs +0 -1
- package/dist/src/config/index.cjs +0 -1
- package/dist/src/config/lint-staged/index.cjs +0 -1
- package/dist/src/config/vitest/index.cjs +0 -1
- package/dist/src/config/vitest/vitest.e2e.cjs +0 -1
- package/dist/src/config/vitest/vitest.unit.cjs +0 -1
- package/dist/src/config/vitest/vitest.unit.setup.cjs +0 -508
- package/dist/src/constant/common.cjs +0 -1
- package/dist/src/constant/index.cjs +0 -1
- package/dist/src/constant/response-status.cjs +0 -1
- package/dist/src/node/apollo-server/apollo-server.util.cjs +0 -1
- package/dist/src/node/apollo-server/index.cjs +0 -1
- package/dist/src/node/cli/cli.util.cjs +0 -6
- package/dist/src/node/cli/cli.util.d.ts +0 -2
- package/dist/src/node/cli/cli.util.js +0 -171
- package/dist/src/node/cli/index.cjs +0 -1
- package/dist/src/node/command/command.util.cjs +0 -1
- package/dist/src/node/command/index.cjs +0 -1
- package/dist/src/node/express/express.util.cjs +0 -1
- package/dist/src/node/express/index.cjs +0 -1
- package/dist/src/node/fs/fs.util.cjs +0 -1
- package/dist/src/node/fs/index.cjs +0 -1
- package/dist/src/node/log/index.cjs +0 -1
- package/dist/src/node/log/log.util.cjs +0 -1
- package/dist/src/node/mongo/index.cjs +0 -1
- package/dist/src/node/mongo/mongo.constant.cjs +0 -1
- package/dist/src/node/mongo/mongo.util.cjs +0 -5
- package/dist/src/node/package/index.cjs +0 -1
- package/dist/src/node/package/package.util.cjs +0 -1
- package/dist/src/node/path/index.cjs +0 -1
- package/dist/src/node/path/path.constant.cjs +0 -1
- package/dist/src/node/path/path.util.cjs +0 -1
- package/dist/src/node/storage/index.cjs +0 -1
- package/dist/src/node/storage/storage.util.cjs +0 -1
- package/dist/src/node/upload/index.cjs +0 -1
- package/dist/src/node/upload/upload.util.cjs +0 -1
- package/dist/src/node/ws/index.cjs +0 -1
- package/dist/src/node/ws/ts.util.cjs +0 -1
- package/dist/src/react/apollo-client/apollo-client.component.cjs +0 -1
- package/dist/src/react/apollo-client/apollo-client.constant.cjs +0 -1
- package/dist/src/react/apollo-client/apollo-client.context.cjs +0 -1
- package/dist/src/react/apollo-client/apollo-client.hook.cjs +0 -1
- package/dist/src/react/apollo-client/apollo-client.util.cjs +0 -1
- package/dist/src/react/apollo-client/index.cjs +0 -1
- package/dist/src/react/apollo-client-nextjs/apollo-client-nextjs.component.cjs +0 -1
- package/dist/src/react/apollo-client-nextjs/apollo-client-nextjs.rsc.cjs +0 -1
- package/dist/src/react/apollo-client-nextjs/apollo-client-nextjs.util.cjs +0 -1
- package/dist/src/react/apollo-client-nextjs/index.cjs +0 -1
- package/dist/src/react/apollo-error/apollo-error.component.cjs +0 -1
- package/dist/src/react/apollo-error/apollo-error.context.cjs +0 -1
- package/dist/src/react/apollo-error/apollo-error.hook.cjs +0 -1
- package/dist/src/react/apollo-error/apollo-error.provider.cjs +0 -1
- package/dist/src/react/apollo-error/apollo-error.util.cjs +0 -1
- package/dist/src/react/apollo-error/index.cjs +0 -1
- package/dist/src/react/i18next/i18next.hook.cjs +0 -1
- package/dist/src/react/i18next/i18next.util.cjs +0 -1
- package/dist/src/react/i18next/index.cjs +0 -1
- package/dist/src/react/loading/index.cjs +0 -1
- package/dist/src/react/loading/loading.component.cjs +0 -6
- package/dist/src/react/loading/loading.context.cjs +0 -1
- package/dist/src/react/loading/loading.hook.cjs +0 -1
- package/dist/src/react/loading/loading.provider.cjs +0 -1
- package/dist/src/react/log/index.cjs +0 -1
- package/dist/src/react/log/log.util.cjs +0 -1
- package/dist/src/react/next-intl/index.cjs +0 -1
- package/dist/src/react/next-intl/next-intl.constant.cjs +0 -1
- package/dist/src/react/next-intl/next-intl.context.cjs +0 -1
- package/dist/src/react/next-intl/next-intl.hoc.cjs +0 -1
- package/dist/src/react/next-intl/next-intl.hook.cjs +0 -1
- package/dist/src/react/next-intl/next-intl.provider.cjs +0 -1
- package/dist/src/react/storage/index.cjs +0 -1
- package/dist/src/react/storage/storage.hook.cjs +0 -1
- package/dist/src/react/storage/storage.util.cjs +0 -1
- package/dist/src/react/toast/index.cjs +0 -1
- package/dist/src/react/userback/index.cjs +0 -1
- package/dist/src/react/userback/userback.component.cjs +0 -1
- package/dist/src/typescript/common.cjs +0 -1
- package/dist/src/typescript/common.js +0 -4
- package/dist/src/typescript/index.cjs +0 -1
- package/dist/src/typescript/react.cjs +0 -1
- package/dist/src/typescript/react.js +0 -1
- package/dist/src/typescript/style.d.cjs +0 -1
- package/dist/src/util/common/common.util.cjs +0 -1
- package/dist/src/util/common/index.cjs +0 -1
- package/dist/src/util/index.cjs +0 -1
- package/dist/src/util/object/index.cjs +0 -1
- package/dist/src/util/object/object.util.cjs +0 -1
- package/dist/src/util/serializer/index.cjs +0 -1
- package/dist/src/util/serializer/serializer.util.cjs +0 -1
- package/dist/src/util/string/index.cjs +0 -1
- package/dist/src/util/string/string.util.cjs +0 -1
- package/dist/src/util/validate/index.cjs +0 -1
- package/dist/src/util/validate/validate.util.cjs +0 -1
- package/dist/tsconfig.base.json +0 -37
- package/dist/upload.util-CE3MjBdh.cjs +0 -1
- package/dist/upload.util-D4aUdmPo.js +0 -160
- /package/dist/src/typescript/{common.d.ts → common.type.d.ts} +0 -0
- /package/dist/src/typescript/{react.d.ts → react.type.d.ts} +0 -0
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
import ne from "fs-extra";
|
|
2
|
+
import { join as h, resolveWorkingPath as p } from "./src/node/path/path.util.js";
|
|
3
|
+
import { exec as re } from "node:child_process";
|
|
4
|
+
import k from "node:process";
|
|
5
|
+
import * as ae from "node:util";
|
|
6
|
+
import { E_IssueType as f } from "./src/node/log/index.js";
|
|
7
|
+
import { storage as G } from "./src/node/storage/storage.util.js";
|
|
8
|
+
import oe from "node-fetch";
|
|
9
|
+
import { pathExistsSync as T, readJsonSync as y, writeFileSync as ie } from "./src/node/fs/fs.util.js";
|
|
10
|
+
import { log as C, catchError as I } from "./src/node/log/log.util.js";
|
|
11
|
+
import { getEnv as w } from "./src/config/env/env.util.js";
|
|
12
|
+
var o = /* @__PURE__ */ ((e) => (e.CLI = "CLI", e.STRING = "STRING", e.FUNCTION = "FUNCTION", e))(o || {}), a = /* @__PURE__ */ ((e) => (e.DEPENDENCY = "dependencies", e.DEV_DEPENDENCY = "devDependencies", e.PEER_DEPENDENCY = "peerDependencies", e.BUNDLE_DEPENDENCY = "bundleDependencies", e.OPTIONAL_DEPENDENCY = "optionalDependencies", e))(a || {});
|
|
13
|
+
const ce = w();
|
|
14
|
+
async function le(e) {
|
|
15
|
+
try {
|
|
16
|
+
const t = await oe(`https://registry.npmjs.org/${e}/latest`);
|
|
17
|
+
if (!t.ok)
|
|
18
|
+
throw new Error(`Failed to fetch latest version: ${t.status} ${t.statusText}`);
|
|
19
|
+
const { version: s } = await t.json();
|
|
20
|
+
return {
|
|
21
|
+
success: !0,
|
|
22
|
+
result: s
|
|
23
|
+
};
|
|
24
|
+
} catch (t) {
|
|
25
|
+
return I(t);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function K(e) {
|
|
29
|
+
try {
|
|
30
|
+
if (!e) {
|
|
31
|
+
if (T(i.PACKAGE_JSON)) {
|
|
32
|
+
const F = y(i.PACKAGE_JSON), { name: se = "", version: J = "" } = F;
|
|
33
|
+
return {
|
|
34
|
+
success: !0,
|
|
35
|
+
result: {
|
|
36
|
+
name: se,
|
|
37
|
+
currentVersion: J,
|
|
38
|
+
latestVersion: J,
|
|
39
|
+
isCurrentProject: !0,
|
|
40
|
+
isInstalled: !0,
|
|
41
|
+
isUpToDate: !0,
|
|
42
|
+
isDependency: !1,
|
|
43
|
+
isDevDependency: !1,
|
|
44
|
+
installedPath: i.PACKAGE_JSON,
|
|
45
|
+
file: F
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
success: !0,
|
|
51
|
+
result: {
|
|
52
|
+
name: "",
|
|
53
|
+
currentVersion: "",
|
|
54
|
+
latestVersion: "",
|
|
55
|
+
isCurrentProject: !1,
|
|
56
|
+
isInstalled: !1,
|
|
57
|
+
isUpToDate: !1,
|
|
58
|
+
isDependency: !1,
|
|
59
|
+
isDevDependency: !1,
|
|
60
|
+
installedPath: "",
|
|
61
|
+
file: {}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (!T(i.PACKAGE_JSON))
|
|
66
|
+
return {
|
|
67
|
+
success: !0,
|
|
68
|
+
result: {
|
|
69
|
+
name: e.name,
|
|
70
|
+
currentVersion: "",
|
|
71
|
+
latestVersion: "",
|
|
72
|
+
isCurrentProject: !1,
|
|
73
|
+
isInstalled: !1,
|
|
74
|
+
isUpToDate: !1,
|
|
75
|
+
isDependency: e.type === a.DEPENDENCY,
|
|
76
|
+
isDevDependency: e.type === a.DEV_DEPENDENCY,
|
|
77
|
+
installedPath: "",
|
|
78
|
+
file: {}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const t = y(i.PACKAGE_JSON), { name: s, version: r = "", dependencies: c = {}, devDependencies: l = {} } = t;
|
|
82
|
+
if (e.name === s)
|
|
83
|
+
return {
|
|
84
|
+
success: !0,
|
|
85
|
+
result: {
|
|
86
|
+
name: s,
|
|
87
|
+
currentVersion: r,
|
|
88
|
+
latestVersion: r,
|
|
89
|
+
isCurrentProject: !0,
|
|
90
|
+
isInstalled: !0,
|
|
91
|
+
isUpToDate: !0,
|
|
92
|
+
isDependency: e.type === a.DEPENDENCY,
|
|
93
|
+
isDevDependency: e.type === a.DEV_DEPENDENCY,
|
|
94
|
+
installedPath: i.PACKAGE_JSON,
|
|
95
|
+
file: t
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const m = e.name in c, n = e.name in l, u = await le(e.name);
|
|
99
|
+
if (!u.success)
|
|
100
|
+
return {
|
|
101
|
+
success: !0,
|
|
102
|
+
result: {
|
|
103
|
+
name: e.name,
|
|
104
|
+
currentVersion: "",
|
|
105
|
+
latestVersion: "",
|
|
106
|
+
isCurrentProject: !1,
|
|
107
|
+
isInstalled: !1,
|
|
108
|
+
isUpToDate: !1,
|
|
109
|
+
isDependency: m,
|
|
110
|
+
isDevDependency: n,
|
|
111
|
+
installedPath: "",
|
|
112
|
+
file: {}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
if (!m && !n)
|
|
116
|
+
return {
|
|
117
|
+
success: !0,
|
|
118
|
+
result: {
|
|
119
|
+
name: e.name,
|
|
120
|
+
currentVersion: "",
|
|
121
|
+
latestVersion: u.result,
|
|
122
|
+
isCurrentProject: !1,
|
|
123
|
+
isInstalled: !1,
|
|
124
|
+
isUpToDate: !1,
|
|
125
|
+
isDependency: e.type === a.DEPENDENCY,
|
|
126
|
+
isDevDependency: e.type === a.DEV_DEPENDENCY,
|
|
127
|
+
installedPath: "",
|
|
128
|
+
file: {}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const N = c[e.name] ?? l[e.name] ?? "", d = h(ce.CWD, v, e.name, U);
|
|
132
|
+
if (!T(d))
|
|
133
|
+
return {
|
|
134
|
+
success: !0,
|
|
135
|
+
result: {
|
|
136
|
+
name: e.name,
|
|
137
|
+
currentVersion: "",
|
|
138
|
+
latestVersion: u.result,
|
|
139
|
+
isCurrentProject: !1,
|
|
140
|
+
isInstalled: !1,
|
|
141
|
+
isUpToDate: !1,
|
|
142
|
+
isDependency: m,
|
|
143
|
+
isDevDependency: n,
|
|
144
|
+
installedPath: "",
|
|
145
|
+
file: {}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const P = y(d), { version: j = "" } = P;
|
|
149
|
+
return N !== j ? {
|
|
150
|
+
success: !0,
|
|
151
|
+
result: {
|
|
152
|
+
name: e.name,
|
|
153
|
+
currentVersion: j || N,
|
|
154
|
+
latestVersion: u.result,
|
|
155
|
+
isCurrentProject: !1,
|
|
156
|
+
isInstalled: !0,
|
|
157
|
+
isUpToDate: !1,
|
|
158
|
+
isDependency: m,
|
|
159
|
+
isDevDependency: n,
|
|
160
|
+
installedPath: d,
|
|
161
|
+
file: P
|
|
162
|
+
}
|
|
163
|
+
} : {
|
|
164
|
+
success: !0,
|
|
165
|
+
result: {
|
|
166
|
+
name: e.name,
|
|
167
|
+
currentVersion: N,
|
|
168
|
+
latestVersion: u.result,
|
|
169
|
+
isCurrentProject: !1,
|
|
170
|
+
isInstalled: !0,
|
|
171
|
+
isUpToDate: N === u.result,
|
|
172
|
+
isDependency: m,
|
|
173
|
+
isDevDependency: n,
|
|
174
|
+
installedPath: d,
|
|
175
|
+
file: P
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
} catch (t) {
|
|
179
|
+
return I(t);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
async function x(e) {
|
|
183
|
+
try {
|
|
184
|
+
const t = y(i.PACKAGE_JSON), s = t.dependencies ?? {}, r = t.devDependencies ?? {};
|
|
185
|
+
e.isDependency ? s[e.name] = e.latestVersion : e.isDevDependency && (r[e.name] = e.latestVersion), ie(i.PACKAGE_JSON, JSON.stringify(t, null, 4)), C.info(`Updated "${e.name}" to version ${e.latestVersion}`);
|
|
186
|
+
} catch (t) {
|
|
187
|
+
I(t);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
async function Ee() {
|
|
191
|
+
try {
|
|
192
|
+
const e = [
|
|
193
|
+
{ command: () => O.pnpmInstallStandard(), message: "Installing dependencies (standard)" },
|
|
194
|
+
{ command: () => O.pnpmInstallLegacy(), message: "Retrying with legacy peer dependencies" },
|
|
195
|
+
{ command: () => O.pnpmInstallForce(), message: "Retrying with force install" }
|
|
196
|
+
];
|
|
197
|
+
for (const { command: t, message: s } of e)
|
|
198
|
+
try {
|
|
199
|
+
const r = await t();
|
|
200
|
+
await Q(`${s} using: ${r}`, r);
|
|
201
|
+
return;
|
|
202
|
+
} catch (r) {
|
|
203
|
+
I(r);
|
|
204
|
+
}
|
|
205
|
+
} catch (e) {
|
|
206
|
+
I(e);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async function me(e, t) {
|
|
210
|
+
try {
|
|
211
|
+
if (!T(i.PACKAGE_JSON)) {
|
|
212
|
+
C.error("package.json not found. Aborting setup.");
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const r = (await Promise.all(e.map(K))).filter((n) => n.success && !!n.result && !n.result.isCurrentProject).map((n) => n.result), c = r.filter((n) => !n.isInstalled), l = r.filter((n) => !n.isUpToDate), m = [];
|
|
216
|
+
t?.install && c.length > 0 && m.push(...c.map(x)), t?.update && l.length > 0 && m.push(...l.map(x)), m.length > 0 && (await Promise.all(m), await Ee(), await Q("Running ESLint with auto-fix", await O.eslintFix()));
|
|
217
|
+
for (const n of t?.callbacks ?? [])
|
|
218
|
+
await n();
|
|
219
|
+
} catch (s) {
|
|
220
|
+
I(s);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const q = w(), pe = ae.promisify(re);
|
|
224
|
+
async function Y() {
|
|
225
|
+
const e = await K();
|
|
226
|
+
return e.success ? e.result.name : Date.now().toString();
|
|
227
|
+
}
|
|
228
|
+
async function z(e) {
|
|
229
|
+
if (e.length === 0)
|
|
230
|
+
return;
|
|
231
|
+
const t = await Y();
|
|
232
|
+
try {
|
|
233
|
+
await G.set(t, e), setTimeout(async () => {
|
|
234
|
+
const s = await G.getLogLink(t);
|
|
235
|
+
s && C.info(`📂 Open the error list manually: ${s}`);
|
|
236
|
+
}, 0);
|
|
237
|
+
} catch (s) {
|
|
238
|
+
I(s);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
async function qe() {
|
|
242
|
+
try {
|
|
243
|
+
const e = await Y();
|
|
244
|
+
return await G.get(e) ?? [];
|
|
245
|
+
} catch (e) {
|
|
246
|
+
return I(e, {
|
|
247
|
+
returnValue: []
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
async function ze() {
|
|
252
|
+
try {
|
|
253
|
+
const e = await Y();
|
|
254
|
+
await G.remove(e);
|
|
255
|
+
} catch (e) {
|
|
256
|
+
I(e);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function ue(e) {
|
|
260
|
+
const t = [], s = [];
|
|
261
|
+
let r = "";
|
|
262
|
+
const c = /^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/, l = /^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/, m = /^✖\s+(.*?)\s+\[(.*?)\]$/;
|
|
263
|
+
e.split(`
|
|
264
|
+
`).forEach((n) => {
|
|
265
|
+
if (n.startsWith("/"))
|
|
266
|
+
r = n.trim();
|
|
267
|
+
else {
|
|
268
|
+
const u = c.exec(n) || [], N = l.exec(n) || [], d = m.exec(n) || [];
|
|
269
|
+
u.length && r ? t.push({
|
|
270
|
+
file: r,
|
|
271
|
+
position: `${u[1]}:${u[2]}`,
|
|
272
|
+
type: u[3] === f.Error ? f.Error : f.Warning,
|
|
273
|
+
message: u?.[4]?.trim() ?? "",
|
|
274
|
+
rule: u?.[5]?.trim() ?? ""
|
|
275
|
+
}) : N.length ? t.push({
|
|
276
|
+
file: N?.[1] ?? "",
|
|
277
|
+
position: `${N[2]}:${N[3]}`,
|
|
278
|
+
type: N[4] === f.Error ? f.Error : f.Warning,
|
|
279
|
+
message: N?.[5]?.trim() ?? ""
|
|
280
|
+
}) : d.length ? t.push({
|
|
281
|
+
file: "commitlint",
|
|
282
|
+
type: f.Error,
|
|
283
|
+
message: d?.[1]?.trim() ?? "",
|
|
284
|
+
rule: d?.[2]?.trim() ?? ""
|
|
285
|
+
}) : s.push(n.trim());
|
|
286
|
+
}
|
|
287
|
+
}), t.length && z(t), q.DEBUG && s.length && (C.warn("Unmatched lines:"), s.forEach((n) => C.info(` ${n}`)));
|
|
288
|
+
}
|
|
289
|
+
function Ne(e) {
|
|
290
|
+
try {
|
|
291
|
+
const t = JSON.parse(e), s = [];
|
|
292
|
+
t.forEach(({ filePath: r, messages: c }) => {
|
|
293
|
+
c.forEach(({ severity: l, line: m, column: n, ruleId: u, message: N }) => {
|
|
294
|
+
s.push({
|
|
295
|
+
type: l === 2 ? f.Error : f.Warning,
|
|
296
|
+
file: r,
|
|
297
|
+
position: `${m}:${n}`,
|
|
298
|
+
rule: u,
|
|
299
|
+
message: N
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
}), s.length && z(s);
|
|
303
|
+
} catch {
|
|
304
|
+
ue(e);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
async function Ce(e, t = Ne) {
|
|
308
|
+
const s = new AbortController();
|
|
309
|
+
k.on("SIGINT", () => {
|
|
310
|
+
C.warn("Process interrupted. Terminating..."), s.abort(), k.exit();
|
|
311
|
+
});
|
|
312
|
+
try {
|
|
313
|
+
if (typeof e == "string") {
|
|
314
|
+
const { stdout: r, stderr: c } = await pe(e, {
|
|
315
|
+
maxBuffer: 104857600,
|
|
316
|
+
signal: s.signal
|
|
317
|
+
});
|
|
318
|
+
[r, c].forEach((l) => l && t(l));
|
|
319
|
+
}
|
|
320
|
+
} catch (r) {
|
|
321
|
+
const { stdout: c, stderr: l, message: m } = r;
|
|
322
|
+
[c, l].forEach((n) => n && t(n)), !l && !c && C.error(`Command failed: ${m}`);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function A(e) {
|
|
326
|
+
return { raw: !0, cmd: e };
|
|
327
|
+
}
|
|
328
|
+
function b(e, t) {
|
|
329
|
+
return t?.isCurrentProject ? `${R} ${_} ${Le} ${e}` : `${R} ${Se} ${e}`;
|
|
330
|
+
}
|
|
331
|
+
function $(e, t) {
|
|
332
|
+
return typeof e == "function" ? b(e(t), t) : typeof e == "object" && e?.raw === !0 ? e.cmd : typeof e == "string" ? b(e, t) : e;
|
|
333
|
+
}
|
|
334
|
+
async function Qe(e) {
|
|
335
|
+
const t = await K({ name: V });
|
|
336
|
+
if (t.success) {
|
|
337
|
+
const s = { isCurrentProject: t.result.isCurrentProject }, r = typeof e == "function" ? e(s) : e;
|
|
338
|
+
return Object.fromEntries(
|
|
339
|
+
Object.entries(r).map(([c, l]) => [c, $(l, s)])
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
async function Q(e, t) {
|
|
344
|
+
try {
|
|
345
|
+
C.start(`${e}`), q.DEBUG && C.info(`→ ${t}`), await Ce(t), C.success(`${e} done.`);
|
|
346
|
+
} catch (s) {
|
|
347
|
+
I(s);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
const Ie = w(), M = Ie.CWD, V = "@cyberskill/shared", v = "node_modules", fe = "dist", de = "public", U = "package.json", _e = "package-lock.json", De = "tsconfig.json", ge = ".gitignore", Te = ".simple-git-hooks.json", ye = "pnpm-lock.yaml", Oe = ".git/hooks/", Ge = ".git/COMMIT_EDITMSG", Pe = ".migrate-mongo.config.js", D = (() => {
|
|
351
|
+
const t = ne.readJsonSync(p(U)).name === V ? M : h(M, v, V);
|
|
352
|
+
return h(t, fe);
|
|
353
|
+
})(), Se = "cyberskill", Le = "src/node/cli/index.ts", H = "eslint", B = "eslint", W = "vitest", X = "vitest", he = "@commitlint/cli", Ae = "@commitlint/config-conventional", Z = "commitlint", $e = "lint-staged", ee = "lint-staged", Me = "typescript", Ve = "tsc", _ = "tsx", te = "git", g = "pnpm", R = "pnpm exec", Re = "simple-git-hooks", we = "simple-git-hooks", Ke = "@eslint/config-inspector", Ye = "eslint-config-inspector", ve = "node-modules-inspector", Ue = "node-modules-inspector", S = "migrate-mongo", L = "./node_modules/migrate-mongo/bin/migrate-mongo", i = {
|
|
354
|
+
CYBERSKILL_DIRECTORY: D,
|
|
355
|
+
WORKING_DIRECTORY: M,
|
|
356
|
+
PUBLIC_DIRECTORY: p(de),
|
|
357
|
+
TS_CONFIG: p(De),
|
|
358
|
+
GIT_IGNORE: p(ge),
|
|
359
|
+
GIT_HOOK: p(Oe),
|
|
360
|
+
GIT_COMMIT_MSG: p(Ge),
|
|
361
|
+
SIMPLE_GIT_HOOKS_JSON: p(Te),
|
|
362
|
+
PACKAGE_JSON: p(U),
|
|
363
|
+
PACKAGE_LOCK_JSON: p(_e),
|
|
364
|
+
PNPM_LOCK_YAML: p(ye),
|
|
365
|
+
NODE_MODULES: p(v),
|
|
366
|
+
MIGRATE_MONGO_CONFIG: p(Pe),
|
|
367
|
+
LINT_STAGED_CONFIG: p(`${D}/src/config/lint-staged/index.js`),
|
|
368
|
+
COMMITLINT_CONFIG: p(`${D}/src/config/commitlint/index.js`),
|
|
369
|
+
VITEST_UNIT_CONFIG: p(`${D}/src/config/vitest/vitest.unit.js`),
|
|
370
|
+
VITEST_UNIT_SETUP_CONFIG: p(`${D}/src/config/vitest/vitest.unit.setup.js`),
|
|
371
|
+
VITEST_E2E_CONFIG: p(`${D}/src/config/vitest/vitest.e2e.js`)
|
|
372
|
+
};
|
|
373
|
+
function Ze({ isCurrentProject: e }) {
|
|
374
|
+
return {
|
|
375
|
+
"pre-commit": ee,
|
|
376
|
+
"commit-msg": Z,
|
|
377
|
+
...e && { "pre-push": A(`${te} pull`) }
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
function E({ type: e, packages: t, command: s }) {
|
|
381
|
+
const r = t?.reduce((c, l) => (c.some((m) => m.name === l.name) || c.push(l), c), []);
|
|
382
|
+
return async () => {
|
|
383
|
+
switch (e) {
|
|
384
|
+
case o.CLI:
|
|
385
|
+
return r?.length && await me(r, {
|
|
386
|
+
install: !0
|
|
387
|
+
}), $(A(`${R} ${s}`));
|
|
388
|
+
case o.STRING:
|
|
389
|
+
return $(A(s));
|
|
390
|
+
default:
|
|
391
|
+
throw new Error("Unsupported command type");
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
const O = {
|
|
396
|
+
simpleGitHooks: E({
|
|
397
|
+
type: o.CLI,
|
|
398
|
+
packages: [
|
|
399
|
+
{
|
|
400
|
+
name: Re,
|
|
401
|
+
type: a.DEV_DEPENDENCY
|
|
402
|
+
}
|
|
403
|
+
],
|
|
404
|
+
command: we
|
|
405
|
+
}),
|
|
406
|
+
eslintInspect: E({
|
|
407
|
+
type: o.CLI,
|
|
408
|
+
packages: [
|
|
409
|
+
{
|
|
410
|
+
name: Ke,
|
|
411
|
+
type: a.DEV_DEPENDENCY
|
|
412
|
+
}
|
|
413
|
+
],
|
|
414
|
+
command: Ye
|
|
415
|
+
}),
|
|
416
|
+
nodeModulesInspect: E({
|
|
417
|
+
type: o.CLI,
|
|
418
|
+
packages: [
|
|
419
|
+
{
|
|
420
|
+
name: ve,
|
|
421
|
+
type: a.DEV_DEPENDENCY
|
|
422
|
+
}
|
|
423
|
+
],
|
|
424
|
+
command: Ue
|
|
425
|
+
}),
|
|
426
|
+
eslintCheck: E({
|
|
427
|
+
type: o.CLI,
|
|
428
|
+
packages: [
|
|
429
|
+
{
|
|
430
|
+
name: H,
|
|
431
|
+
type: a.DEV_DEPENDENCY
|
|
432
|
+
}
|
|
433
|
+
],
|
|
434
|
+
command: `${B} ${i.WORKING_DIRECTORY} --no-cache`
|
|
435
|
+
}),
|
|
436
|
+
eslintFix: E({
|
|
437
|
+
type: o.CLI,
|
|
438
|
+
packages: [
|
|
439
|
+
{
|
|
440
|
+
name: H,
|
|
441
|
+
type: a.DEV_DEPENDENCY
|
|
442
|
+
}
|
|
443
|
+
],
|
|
444
|
+
command: `${B} ${i.WORKING_DIRECTORY} --fix --no-cache`
|
|
445
|
+
}),
|
|
446
|
+
typescriptCheck: E({
|
|
447
|
+
type: o.CLI,
|
|
448
|
+
packages: [
|
|
449
|
+
{
|
|
450
|
+
name: Me,
|
|
451
|
+
type: a.DEV_DEPENDENCY
|
|
452
|
+
}
|
|
453
|
+
],
|
|
454
|
+
command: `${Ve} -p ${i.TS_CONFIG} --noEmit`
|
|
455
|
+
}),
|
|
456
|
+
testUnit: E({
|
|
457
|
+
type: o.CLI,
|
|
458
|
+
packages: [
|
|
459
|
+
{
|
|
460
|
+
name: W,
|
|
461
|
+
type: a.DEV_DEPENDENCY
|
|
462
|
+
}
|
|
463
|
+
],
|
|
464
|
+
command: `${X} --config ${i.VITEST_UNIT_CONFIG}`
|
|
465
|
+
}),
|
|
466
|
+
testE2e: E({
|
|
467
|
+
type: o.CLI,
|
|
468
|
+
packages: [
|
|
469
|
+
{
|
|
470
|
+
name: W,
|
|
471
|
+
type: a.DEV_DEPENDENCY
|
|
472
|
+
}
|
|
473
|
+
],
|
|
474
|
+
command: `${X} --config ${i.VITEST_E2E_CONFIG}`
|
|
475
|
+
}),
|
|
476
|
+
mongoMigrateCreate: (e) => E({
|
|
477
|
+
type: o.CLI,
|
|
478
|
+
packages: [
|
|
479
|
+
{
|
|
480
|
+
name: _,
|
|
481
|
+
type: a.DEPENDENCY
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
name: S,
|
|
485
|
+
type: a.DEPENDENCY
|
|
486
|
+
}
|
|
487
|
+
],
|
|
488
|
+
command: `${_} ${L} create ${e} -f ${i.MIGRATE_MONGO_CONFIG}`
|
|
489
|
+
})(),
|
|
490
|
+
mongoMigrateUp: E({
|
|
491
|
+
type: o.CLI,
|
|
492
|
+
packages: [
|
|
493
|
+
{
|
|
494
|
+
name: _,
|
|
495
|
+
type: a.DEPENDENCY
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
name: S,
|
|
499
|
+
type: a.DEPENDENCY
|
|
500
|
+
}
|
|
501
|
+
],
|
|
502
|
+
command: `${_} ${L} up -f ${i.MIGRATE_MONGO_CONFIG}`
|
|
503
|
+
}),
|
|
504
|
+
mongoMigrateDown: E({
|
|
505
|
+
type: o.CLI,
|
|
506
|
+
packages: [
|
|
507
|
+
{
|
|
508
|
+
name: _,
|
|
509
|
+
type: a.DEPENDENCY
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
name: S,
|
|
513
|
+
type: a.DEPENDENCY
|
|
514
|
+
}
|
|
515
|
+
],
|
|
516
|
+
command: `${_} ${L} down -f ${i.MIGRATE_MONGO_CONFIG}`
|
|
517
|
+
}),
|
|
518
|
+
commitLint: E({
|
|
519
|
+
type: o.CLI,
|
|
520
|
+
packages: [
|
|
521
|
+
{
|
|
522
|
+
name: he,
|
|
523
|
+
type: a.DEV_DEPENDENCY
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
name: Ae,
|
|
527
|
+
type: a.DEV_DEPENDENCY
|
|
528
|
+
}
|
|
529
|
+
],
|
|
530
|
+
command: `${Z} --edit ${i.GIT_COMMIT_MSG} --config ${i.COMMITLINT_CONFIG}`
|
|
531
|
+
}),
|
|
532
|
+
lintStaged: E({
|
|
533
|
+
type: o.CLI,
|
|
534
|
+
packages: [
|
|
535
|
+
{
|
|
536
|
+
name: $e,
|
|
537
|
+
type: a.DEV_DEPENDENCY
|
|
538
|
+
}
|
|
539
|
+
],
|
|
540
|
+
command: `${ee} --config ${i.LINT_STAGED_CONFIG}`
|
|
541
|
+
}),
|
|
542
|
+
configureGitHook: E({
|
|
543
|
+
type: o.STRING,
|
|
544
|
+
command: `${te} config core.hooksPath ${i.GIT_HOOK}`
|
|
545
|
+
}),
|
|
546
|
+
build: E({
|
|
547
|
+
type: o.STRING,
|
|
548
|
+
command: `${g} run --if-present build`
|
|
549
|
+
}),
|
|
550
|
+
pnpmInstallStandard: E({
|
|
551
|
+
type: o.STRING,
|
|
552
|
+
command: `${g} install --ignore-scripts`
|
|
553
|
+
}),
|
|
554
|
+
pnpmInstallLegacy: E({
|
|
555
|
+
type: o.STRING,
|
|
556
|
+
command: `${g} install --ignore-scripts --legacy-peer-deps`
|
|
557
|
+
}),
|
|
558
|
+
pnpmInstallForce: E({
|
|
559
|
+
type: o.STRING,
|
|
560
|
+
command: `${g} install --ignore-scripts --force`
|
|
561
|
+
}),
|
|
562
|
+
pnpmPruneStore: E({
|
|
563
|
+
type: o.STRING,
|
|
564
|
+
command: `${g} store prune`
|
|
565
|
+
}),
|
|
566
|
+
pnpmCleanCache: E({
|
|
567
|
+
type: o.STRING,
|
|
568
|
+
command: `${g} cache delete`
|
|
569
|
+
})
|
|
570
|
+
};
|
|
571
|
+
export {
|
|
572
|
+
Ue as $,
|
|
573
|
+
he as A,
|
|
574
|
+
fe as B,
|
|
575
|
+
Se as C,
|
|
576
|
+
Ae as D,
|
|
577
|
+
a as E,
|
|
578
|
+
Z as F,
|
|
579
|
+
ge as G,
|
|
580
|
+
ee as H,
|
|
581
|
+
Me as I,
|
|
582
|
+
Ve as J,
|
|
583
|
+
_ as K,
|
|
584
|
+
$e as L,
|
|
585
|
+
Pe as M,
|
|
586
|
+
v as N,
|
|
587
|
+
te as O,
|
|
588
|
+
i as P,
|
|
589
|
+
g as Q,
|
|
590
|
+
R,
|
|
591
|
+
Te as S,
|
|
592
|
+
De as T,
|
|
593
|
+
Re as U,
|
|
594
|
+
W as V,
|
|
595
|
+
M as W,
|
|
596
|
+
we as X,
|
|
597
|
+
Ke as Y,
|
|
598
|
+
Ye as Z,
|
|
599
|
+
ve as _,
|
|
600
|
+
O as a,
|
|
601
|
+
S as a0,
|
|
602
|
+
L as a1,
|
|
603
|
+
V as b,
|
|
604
|
+
ze as c,
|
|
605
|
+
qe as d,
|
|
606
|
+
Qe as e,
|
|
607
|
+
Ze as f,
|
|
608
|
+
K as g,
|
|
609
|
+
le as h,
|
|
610
|
+
Ee as i,
|
|
611
|
+
A as j,
|
|
612
|
+
$ as k,
|
|
613
|
+
o as l,
|
|
614
|
+
de as m,
|
|
615
|
+
U as n,
|
|
616
|
+
_e as o,
|
|
617
|
+
ye as p,
|
|
618
|
+
Oe as q,
|
|
619
|
+
Q as r,
|
|
620
|
+
me as s,
|
|
621
|
+
Ge as t,
|
|
622
|
+
x as u,
|
|
623
|
+
D as v,
|
|
624
|
+
Le as w,
|
|
625
|
+
H as x,
|
|
626
|
+
B as y,
|
|
627
|
+
X as z
|
|
628
|
+
};
|