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