@cyberskill/shared 2.27.0 → 3.0.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/config.util.cjs +1 -1
- package/dist/config/config.util.js +24 -33
- package/dist/config/eslint/index.cjs +1 -1
- package/dist/config/eslint/index.d.ts +6 -0
- package/dist/config/eslint/index.js +4 -12
- package/dist/config/graphql-codegen/graphql-codegen.util.cjs +1 -1
- package/dist/config/graphql-codegen/graphql-codegen.util.js +28 -33
- package/dist/config/storybook/storybook.preview.cjs +1 -1
- package/dist/config/storybook/storybook.preview.js +10 -13
- package/dist/config/vitest/vitest.e2e.cjs +1 -1
- package/dist/config/vitest/vitest.e2e.js +1 -1
- package/dist/config/vitest/vitest.unit.cjs +1 -1
- package/dist/config/vitest/vitest.unit.js +19 -8
- package/dist/constant/common.cjs +1 -1
- package/dist/constant/common.js +1 -1
- package/dist/node/apollo-server/apollo-server.util.cjs +1 -1
- package/dist/node/apollo-server/apollo-server.util.js +21 -48
- package/dist/node/cli/index.cjs +2 -5
- package/dist/node/cli/index.js +109 -170
- package/dist/node/command/command.util.cjs +2 -2
- package/dist/node/command/command.util.js +135 -170
- package/dist/node/express/express.util.cjs +1 -1
- package/dist/node/express/express.util.js +39 -72
- package/dist/node/fs/fs.util.cjs +4 -1
- package/dist/node/fs/fs.util.d.ts +8 -0
- package/dist/node/fs/fs.util.js +46 -53
- package/dist/node/fs/index.cjs +1 -1
- package/dist/node/fs/index.js +13 -12
- package/dist/node/log/log.util.cjs +1 -1
- package/dist/node/log/log.util.js +29 -30
- package/dist/node/mongo/mongo.controller.cjs +1 -1
- package/dist/node/mongo/mongo.controller.js +531 -629
- package/dist/node/mongo/mongo.type.js +3 -3
- package/dist/node/mongo/mongo.util.cjs +2 -5
- package/dist/node/mongo/mongo.util.js +308 -354
- package/dist/node/package/package.util.cjs +1 -1
- package/dist/node/package/package.util.js +197 -226
- package/dist/node/path/index.cjs +1 -1
- package/dist/node/path/index.js +26 -25
- package/dist/node/path/path.constant.cjs +1 -1
- package/dist/node/path/path.constant.d.ts +2 -0
- package/dist/node/path/path.constant.js +130 -150
- package/dist/node/storage/storage.util.cjs +1 -1
- package/dist/node/storage/storage.util.js +110 -158
- package/dist/node/upload/upload.util.cjs +1 -1
- package/dist/node/upload/upload.util.js +119 -150
- package/dist/node/ws/ts.util.cjs +1 -1
- package/dist/node/ws/ts.util.js +31 -54
- package/dist/react/apollo-client/apollo-client.component.cjs +1 -1
- package/dist/react/apollo-client/apollo-client.component.js +4 -4
- package/dist/react/apollo-client/apollo-client.util.cjs +1 -1
- package/dist/react/apollo-client/apollo-client.util.js +51 -58
- package/dist/react/apollo-client/links/upload.cjs +1 -1
- package/dist/react/apollo-client/links/upload.js +71 -74
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.cjs +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +11 -18
- package/dist/react/apollo-error/apollo-error.component.cjs +1 -1
- package/dist/react/apollo-error/apollo-error.component.js +61 -23
- package/dist/react/apollo-error/apollo-error.module.scss.cjs +1 -1
- package/dist/react/apollo-error/apollo-error.module.scss.js +6 -6
- package/dist/react/apollo-error/apollo-error.test.unit.d.ts +1 -0
- package/dist/react/apollo-error/apollo-error.util.cjs +1 -1
- package/dist/react/apollo-error/apollo-error.util.js +6 -6
- package/dist/react/loading/loading.component.cjs +2 -2
- package/dist/react/loading/loading.component.js +30 -46
- package/dist/react/log/log.util.cjs +1 -1
- package/dist/react/log/log.util.js +4 -4
- package/dist/react/next-intl/next-intl.hoc.cjs +1 -1
- package/dist/react/next-intl/next-intl.hoc.js +13 -22
- package/dist/react/next-intl/next-intl.provider.cjs +1 -1
- package/dist/react/next-intl/next-intl.provider.js +7 -7
- package/dist/react/storage/storage.hook.cjs +1 -1
- package/dist/react/storage/storage.hook.js +43 -59
- package/dist/react/storage/storage.util.cjs +1 -1
- package/dist/react/storage/storage.util.js +28 -53
- package/dist/react/userback/userback.component.cjs +1 -1
- package/dist/react/userback/userback.component.js +18 -42
- package/dist/style.css +1 -1
- package/dist/util/common/common.util.cjs +1 -1
- package/dist/util/common/common.util.d.ts +11 -0
- package/dist/util/common/common.util.js +33 -37
- package/dist/util/common/index.cjs +1 -1
- package/dist/util/common/index.js +6 -5
- package/dist/util/index.cjs +1 -1
- package/dist/util/index.js +22 -20
- package/dist/util/object/object.util.cjs +1 -1
- package/dist/util/object/object.util.js +70 -70
- package/dist/util/string/index.cjs +1 -1
- package/dist/util/string/index.js +4 -3
- package/dist/util/string/string.util.cjs +1 -1
- package/dist/util/string/string.util.d.ts +12 -0
- package/dist/util/string/string.util.js +63 -44
- package/package.json +53 -44
- package/public/tsconfig.base.json +7 -3
- package/README.md +0 -470
- package/dist/node/mongo/mongo.util.d.ts +0 -1040
- /package/dist/node_modules/.pnpm/{vitest@4.0.17_@types_node@25.0.9_jiti@2.6.1_jsdom@27.4.0_@noble_hashes@1.8.0__sass@1.97.2_tsx@4.21.0_yaml@2.8.2 → vitest@4.0.18_@types_node@25.3.3_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.cjs +0 -0
- /package/dist/node_modules/.pnpm/{vitest@4.0.17_@types_node@25.0.9_jiti@2.6.1_jsdom@27.4.0_@noble_hashes@1.8.0__sass@1.97.2_tsx@4.21.0_yaml@2.8.2 → vitest@4.0.18_@types_node@25.3.3_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.js +0 -0
package/dist/node/cli/index.js
CHANGED
|
@@ -1,185 +1,124 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import { hideBin as
|
|
4
|
-
import
|
|
5
|
-
import { runCommand as
|
|
6
|
-
import { getPackage as
|
|
7
|
-
import { pathExistsSync as
|
|
8
|
-
import { resolve as
|
|
9
|
-
import { CYBERSKILL_CLI as
|
|
10
|
-
import { log as
|
|
11
|
-
import { E_IssueType as
|
|
12
|
-
|
|
13
|
-
var T = (c) => {
|
|
14
|
-
try {
|
|
15
|
-
y(r.next(c));
|
|
16
|
-
} catch (p) {
|
|
17
|
-
h(p);
|
|
18
|
-
}
|
|
19
|
-
}, D = (c) => {
|
|
20
|
-
try {
|
|
21
|
-
y(r.throw(c));
|
|
22
|
-
} catch (p) {
|
|
23
|
-
h(p);
|
|
24
|
-
}
|
|
25
|
-
}, y = (c) => c.done ? l(c.value) : Promise.resolve(c.value).then(T, D);
|
|
26
|
-
y((r = r.apply(n, o)).next());
|
|
27
|
-
});
|
|
28
|
-
function H() {
|
|
2
|
+
import m from "node:process";
|
|
3
|
+
import { hideBin as M } from "yargs/helpers";
|
|
4
|
+
import _ from "yargs/yargs";
|
|
5
|
+
import { runCommand as n, clearAllErrorLists as g, getStoredErrorLists as L, resolveCommands as b } from "../command/command.util.js";
|
|
6
|
+
import { getPackage as T, installDependencies as w } from "../package/package.util.js";
|
|
7
|
+
import { pathExistsSync as y, addGitIgnoreEntry as f, removeSync as k, readFileSync as v, writeFileSync as D } from "../fs/fs.util.js";
|
|
8
|
+
import { resolve as O } from "../path/path.util.js";
|
|
9
|
+
import { CYBERSKILL_CLI as G, command as i, CYBERSKILL_PACKAGE_NAME as p, PATH as o, SIMPLE_GIT_HOOK_JSON as R, createGitHooksConfig as A, AG_KIT_PACKAGE_NAME as c, DOT_AGENT as B } from "../path/path.constant.js";
|
|
10
|
+
import { log as s, catchError as E } from "../log/log.util.js";
|
|
11
|
+
import { E_IssueType as d } from "../log/log.type.js";
|
|
12
|
+
function N() {
|
|
29
13
|
try {
|
|
30
14
|
return JSON.parse(
|
|
31
|
-
|
|
15
|
+
v(O(__dirname, "../../../package.json"), "utf-8")
|
|
32
16
|
).version;
|
|
33
|
-
} catch
|
|
17
|
+
} catch {
|
|
34
18
|
return "1.0.0";
|
|
35
19
|
}
|
|
36
20
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function v(n, o) {
|
|
53
|
-
if (!o.length)
|
|
21
|
+
async function S() {
|
|
22
|
+
y(o.TS_CONFIG) ? await n("Performing TypeScript validation", await i.typescriptCheck()) : s.warn("No TypeScript configuration found. Skipping type check.");
|
|
23
|
+
}
|
|
24
|
+
async function h(t = !1) {
|
|
25
|
+
const a = t ? await i.eslintFix() : await i.eslintCheck(), r = t ? "Running ESLint with auto-fix" : "Running ESLint check";
|
|
26
|
+
try {
|
|
27
|
+
await n(r, a, { timeout: 6e4, throwOnError: !0 });
|
|
28
|
+
} catch (e) {
|
|
29
|
+
e.code === "ETIMEDOUT" || e.killed || e.signal === "SIGTERM" ? (s.warn("Lint check timed out. Retrying with debug mode enabled..."), m.env.DEBUG = "true", await n(`${r} (Debug Mode)`, a)) : E(e);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function u(t, a) {
|
|
33
|
+
if (!a.length)
|
|
54
34
|
return;
|
|
55
|
-
const r =
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
function
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
function X() {
|
|
130
|
-
return i(this, null, function* () {
|
|
131
|
-
yield e("Running end-to-end tests", yield t.testE2e());
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
function Z(n) {
|
|
135
|
-
return i(this, null, function* () {
|
|
136
|
-
yield e("Creating MongoDB migration", yield t.mongoMigrateCreate(n));
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
function nn() {
|
|
140
|
-
return i(this, null, function* () {
|
|
141
|
-
yield e("Running MongoDB migrations", yield t.mongoMigrateUp());
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
function en() {
|
|
145
|
-
return i(this, null, function* () {
|
|
146
|
-
yield e("Rolling back MongoDB migration", yield t.mongoMigrateDown());
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
function tn() {
|
|
150
|
-
return i(this, null, function* () {
|
|
151
|
-
yield e("Starting Storybook development server", yield t.storybookDev());
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
function on() {
|
|
155
|
-
return i(this, null, function* () {
|
|
156
|
-
yield e("Building Storybook", yield t.storybookBuild());
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
function R() {
|
|
160
|
-
return i(this, null, function* () {
|
|
161
|
-
try {
|
|
162
|
-
yield e(`Checking for ${u}`, `pnpm list -g ${u}`);
|
|
163
|
-
} catch (n) {
|
|
164
|
-
yield e(`Installing ${u} globally`, `pnpm i -g ${u}`);
|
|
165
|
-
}
|
|
166
|
-
f(s.DOT_AGENT) ? yield e("Updating AI agent", "ag-kit update") : yield e("Initializing AI agent", "ag-kit init");
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
i(null, null, function* () {
|
|
35
|
+
const r = t === "Errors" ? "red" : "yellow";
|
|
36
|
+
s.printBoxedLog(t === "Errors" ? "✖ Errors" : "⚠ Warnings", a, r);
|
|
37
|
+
}
|
|
38
|
+
async function l() {
|
|
39
|
+
setTimeout(async () => {
|
|
40
|
+
const t = await L() || [], a = t.filter((e) => e.type === d.Error), r = t.filter((e) => e.type === d.Warning);
|
|
41
|
+
!a.length && !r.length ? s.printBoxedLog("✔ NO ISSUES FOUND", [], "green") : (u("Warnings", r), u("Errors", a), a.length > 0 && m.exit(1));
|
|
42
|
+
}, 0);
|
|
43
|
+
}
|
|
44
|
+
async function P() {
|
|
45
|
+
await g();
|
|
46
|
+
const t = await T({ name: p });
|
|
47
|
+
if (!t.success) {
|
|
48
|
+
s.error("Failed to retrieve package information. Aborting lint-staged.");
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
t.result.isCurrentProject && await n(`Building package: ${p}`, await i.build()), await n("Executing lint-staged", await i.lintStaged()), l();
|
|
52
|
+
}
|
|
53
|
+
async function U() {
|
|
54
|
+
await n("Inspecting ESLint configuration", await i.eslintInspect());
|
|
55
|
+
}
|
|
56
|
+
async function x() {
|
|
57
|
+
await g(), await S(), await h(), l();
|
|
58
|
+
}
|
|
59
|
+
async function K() {
|
|
60
|
+
await g(), await S(), await h(!0), l();
|
|
61
|
+
}
|
|
62
|
+
async function F() {
|
|
63
|
+
await g(), await n("Validating commit message", await i.commitLint()), l();
|
|
64
|
+
}
|
|
65
|
+
async function I() {
|
|
66
|
+
await n("Configuring Git hooks", await i.configureGitHook()), k(o.GIT_HOOK);
|
|
67
|
+
const t = await b(A);
|
|
68
|
+
D(o.SIMPLE_GIT_HOOKS_JSON, JSON.stringify(t, null, 4)), f(o.GIT_IGNORE, R), await n("Setting up simple-git-hooks", await i.simpleGitHooks());
|
|
69
|
+
}
|
|
70
|
+
async function C() {
|
|
71
|
+
try {
|
|
72
|
+
await n(`Checking for ${c}`, `pnpm list -g ${c}`);
|
|
73
|
+
} catch {
|
|
74
|
+
await n(`Installing ${c} globally`, `pnpm i -g ${c}`);
|
|
75
|
+
}
|
|
76
|
+
y(o.DOT_AGENT) ? await n("Updating AI agent", "ag-kit update -y") : await n("Initializing AI agent", "ag-kit init"), f(o.GIT_EXCLUDE, B);
|
|
77
|
+
}
|
|
78
|
+
async function H() {
|
|
79
|
+
await w(), await I();
|
|
80
|
+
}
|
|
81
|
+
async function $() {
|
|
82
|
+
k(o.NODE_MODULES, o.PNPM_LOCK_YAML), await n("Pruning pnpm store", await i.pnpmPruneStore()), await n("Clearing pnpm cache", await i.pnpmCleanCache()), await w(), await I(), await C();
|
|
83
|
+
}
|
|
84
|
+
async function j() {
|
|
85
|
+
await n("Inspecting project dependencies", await i.nodeModulesInspect());
|
|
86
|
+
}
|
|
87
|
+
async function J() {
|
|
88
|
+
await n("Running unit tests", await i.testUnit());
|
|
89
|
+
}
|
|
90
|
+
async function V() {
|
|
91
|
+
await n("Running end-to-end tests", await i.testE2e());
|
|
92
|
+
}
|
|
93
|
+
async function z(t) {
|
|
94
|
+
await n("Creating MongoDB migration", await i.mongoMigrateCreate(t));
|
|
95
|
+
}
|
|
96
|
+
async function W() {
|
|
97
|
+
await n("Running MongoDB migrations", await i.mongoMigrateUp());
|
|
98
|
+
}
|
|
99
|
+
async function Y() {
|
|
100
|
+
await n("Rolling back MongoDB migration", await i.mongoMigrateDown());
|
|
101
|
+
}
|
|
102
|
+
async function q() {
|
|
103
|
+
await n("Starting Storybook development server", await i.storybookDev());
|
|
104
|
+
}
|
|
105
|
+
async function X() {
|
|
106
|
+
await n("Building Storybook", await i.storybookBuild());
|
|
107
|
+
}
|
|
108
|
+
(async () => {
|
|
170
109
|
try {
|
|
171
|
-
|
|
110
|
+
await _(M(m.argv)).scriptName(G).usage("$0 <command> [options]").command("ai:setup", "Setup AI agent environment", C).command("lint", "Check code for linting issues", x).command("lint:fix", "Fix linting issues automatically", K).command("lint:inspect", "View active ESLint configuration", U).command("lint-staged", "Run lint checks on staged files", P).command("commitlint", "Validate commit message format", F).command("ready", "Initialize project and dependencies", H).command("reset", "Reset the project and reinstall dependencies", $).command("inspect", "Analyze installed project dependencies", j).command("test:unit", "Run unit test suite", J).command("test:e2e", "Run end-to-end test suite", V).command("mongo:migrate:create <name>", "Create a MongoDB migration", (t) => t.positional("name", {
|
|
172
111
|
describe: "Migration name",
|
|
173
112
|
type: "string"
|
|
174
|
-
}), (
|
|
175
|
-
if (!
|
|
176
|
-
|
|
113
|
+
}), async (t) => {
|
|
114
|
+
if (!t.name) {
|
|
115
|
+
s.error("Migration name is required.");
|
|
177
116
|
return;
|
|
178
117
|
}
|
|
179
|
-
|
|
180
|
-
})
|
|
118
|
+
await z(t.name);
|
|
119
|
+
}).command("mongo:migrate:up", "Apply all MongoDB migrations", W).command("mongo:migrate:down", "Rollback last MongoDB migration", Y).command("storybook:dev", "Start Storybook development server", q).command("storybook:build", "Build Storybook for production", X).demandCommand(1, "Please specify a valid command.").strict().help().alias("h", "help").alias("v", "version").version(N()).epilog(`💡 Tip: Use "--help" with any command to see options
|
|
181
120
|
`).parse();
|
|
182
|
-
} catch (
|
|
183
|
-
|
|
121
|
+
} catch (t) {
|
|
122
|
+
E(t), m.exit(1);
|
|
184
123
|
}
|
|
185
|
-
});
|
|
124
|
+
})();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`).forEach(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("node:child_process"),m=require("node:process"),P=require("node:util"),E=require("../storage/storage.util.cjs"),w=require("../package/package.util.cjs"),g=require("../path/path.constant.cjs"),l=require("../log/log.type.cjs"),i=require("../log/log.util.cjs"),d=require("../../config/env/env.util.cjs");function T(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const S=T(P),x=S.promisify(L.exec);async function y(){const r=await w.getPackage();return r.success?r.result.name:Date.now().toString()}async function _(r){if(r.length===0)return;const e=await y();try{const s=[...await C(),...r];await E.storage.set(e,s),setTimeout(async()=>{const o=await E.storage.getLogLink(e);o&&i.log.info(`📂 Open the error list manually: ${o}`)},0)}catch(t){i.catchError(t)}}async function C(){try{const r=await y();return await E.storage.get(r)??[]}catch(r){return i.catchError(r,{returnValue:[]})}}async function v(){try{const r=await y();await E.storage.remove(r)}catch(r){i.catchError(r)}}async function O(r){const e=[],t=[];let s="";const o=/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/,n=/^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/,u=/^✖\s+(.*?)\s+\[(.*?)\]$/;r.split(`
|
|
2
|
+
`).forEach(a=>{if(a.startsWith("/"))s=a.trim();else{const c=o.exec(a)||[],f=n.exec(a)||[],p=u.exec(a)||[];c.length&&s?e.push({file:s,position:`${c[1]}:${c[2]}`,type:c[3]===l.E_IssueType.Error?l.E_IssueType.Error:l.E_IssueType.Warning,message:c?.[4]?.trim()??"",rule:c?.[5]?.trim()??""}):f.length?e.push({file:f?.[1]??"",position:`${f[2]}:${f[3]}`,type:f[4]===l.E_IssueType.Error?l.E_IssueType.Error:l.E_IssueType.Warning,message:f?.[5]?.trim()??""}):p.length?e.push({file:"commitlint",type:l.E_IssueType.Error,message:p?.[1]?.trim()??"",rule:p?.[2]?.trim()??""}):t.push(a.trim())}}),e.length&&await _(e),d.getEnv().DEBUG&&t.length&&(i.log.warn("Unmatched lines:"),t.forEach(a=>i.log.info(` ${a}`)))}async function $(r){try{const e=JSON.parse(r),t=[];e.forEach(({filePath:s,messages:o})=>{o.forEach(({severity:n,line:u,column:a,ruleId:c,message:f})=>{t.push({type:n===2?l.E_IssueType.Error:l.E_IssueType.Warning,file:s,position:`${u}:${a}`,rule:c,message:f})})}),t.length&&await _(t)}catch{await O(r)}}async function b(r,e=$,t={}){const s=new AbortController;m.on("SIGINT",()=>{i.log.warn("Process interrupted. Terminating..."),s.abort(),m.exit()});try{if(typeof r=="string"){const{stdout:o,stderr:n}=await x(r,{maxBuffer:104857600,signal:s.signal,timeout:t.timeout});await Promise.all([o,n].map(u=>u&&e(u)))}}catch(o){const{stdout:n,stderr:u,message:a}=o;await Promise.all([n,u].map(c=>c&&e(c))),!u&&!n&&i.log.error(`Command failed: ${a}`)}}function j(r){return{raw:!0,cmd:r}}function h(r,e){return e?.isCurrentProject?`${g.PNPM_EXEC_CLI} ${g.TSX_CLI} ${g.CYBERSKILL_CLI_PATH} ${r}`:`${g.PNPM_EXEC_CLI} ${g.CYBERSKILL_CLI} ${r}`}function I(r,e){return typeof r=="function"?h(r(e),e):typeof r=="object"&&r?.raw===!0?r.cmd:typeof r=="string"?h(r,e):r}async function k(r){const e=await w.getPackage({name:g.CYBERSKILL_PACKAGE_NAME});if(e.success){const t={isCurrentProject:e.result.isCurrentProject},s=typeof r=="function"?r(t):r;return Object.fromEntries(Object.entries(s).map(([o,n])=>[o,I(n,t)]))}}async function N(r,e,t={}){let s;try{const o=Date.now();i.log.start(`${r}`),d.getEnv().DEBUG?i.log.info(`→ ${e}`):s=setInterval(()=>{const n=Math.floor((Date.now()-o)/1e3);n>0&&m.stdout.write(`\r⏳ ${r}... ${n}s`)},100),await b(e,$,t),s&&(clearInterval(s),m.stdout.write("\r\x1B[K")),i.log.success(`${r} done.`)}catch(o){if(s&&(clearInterval(s),m.stdout.write("\r\x1B[K")),t.throwOnError)throw o;i.catchError(o)}}exports.clearAllErrorLists=v;exports.formatCommand=I;exports.getStoredErrorLists=C;exports.rawCommand=j;exports.resolveCommands=k;exports.runCommand=N;
|