@cyberskill/shared 2.20.0 → 2.25.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/eslint/index.cjs +1 -1
- package/dist/config/eslint/index.d.ts +2 -7
- package/dist/config/eslint/index.js +1 -1
- package/dist/config/storybook/storybook.main.cjs +1 -1
- package/dist/config/storybook/storybook.main.js +1 -1
- package/dist/config/vitest/vitest.e2e.cjs +1 -1
- package/dist/config/vitest/vitest.e2e.js +6 -6
- package/dist/config/vitest/vitest.unit.cjs +1 -1
- package/dist/config/vitest/vitest.unit.js +5 -5
- package/dist/config/vitest/vitest.unit.setup.d.ts +0 -1
- package/dist/node/cli/index.cjs +4 -4
- package/dist/node/cli/index.js +56 -51
- package/dist/node/command/command.util.cjs +2 -2
- package/dist/node/command/command.util.d.ts +4 -1
- package/dist/node/command/command.util.js +125 -112
- package/dist/node/express/express.util.cjs +1 -1
- package/dist/node/express/express.util.js +24 -23
- package/dist/node/mongo/index.cjs +1 -1
- package/dist/node/mongo/index.d.ts +1 -0
- package/dist/node/mongo/index.js +15 -12
- package/dist/node/mongo/mongo.controller.cjs +1 -0
- package/dist/node/mongo/mongo.controller.d.ts +317 -0
- package/dist/node/mongo/mongo.controller.js +956 -0
- package/dist/node/mongo/mongo.controller.test.unit.d.ts +1 -0
- package/dist/node/mongo/mongo.type.d.ts +9 -10
- package/dist/node/mongo/mongo.util.cjs +5 -5
- package/dist/node/mongo/mongo.util.d.ts +32 -515
- package/dist/node/mongo/mongo.util.js +314 -1239
- package/dist/node/mongo/mongo.util.test.unit.d.ts +1 -0
- package/dist/node/path/path.constant.cjs +1 -1
- package/dist/node/path/path.constant.d.ts +2 -2
- package/dist/node/path/path.constant.js +120 -116
- package/dist/node/path/path.test.unit.d.ts +1 -0
- package/dist/node/path/path.util.d.ts +2 -2
- package/dist/react/loading/loading.component.cjs +2 -2
- package/dist/react/loading/loading.component.js +32 -19
- package/dist/react/loading/loading.test.unit.d.ts +1 -0
- package/dist/react/loading/loading.type.d.ts +2 -1
- package/dist/util/common/common.test.unit.d.ts +1 -0
- package/dist/util/common/common.util.cjs +1 -1
- package/dist/util/common/common.util.d.ts +3 -0
- package/dist/util/common/common.util.js +35 -35
- package/dist/util/index.cjs +1 -1
- package/dist/util/index.js +16 -15
- package/dist/util/object/index.cjs +1 -1
- package/dist/util/object/index.js +4 -3
- package/dist/util/object/object.test.unit.d.ts +1 -0
- package/dist/util/object/object.util.cjs +1 -1
- package/dist/util/object/object.util.d.ts +10 -30
- package/dist/util/object/object.util.js +110 -73
- package/dist/util/serializer/serializer.test.unit.d.ts +1 -0
- package/dist/util/serializer/serializer.util.cjs +1 -1
- package/dist/util/serializer/serializer.util.js +19 -16
- package/dist/util/string/string.test.unit.d.ts +1 -0
- package/dist/util/string/string.util.cjs +1 -1
- package/dist/util/string/string.util.d.ts +4 -3
- package/dist/util/string/string.util.js +32 -41
- package/dist/util/validate/validate.test.unit.d.ts +1 -0
- package/dist/util/validate/validate.util.cjs +1 -1
- package/dist/util/validate/validate.util.js +9 -9
- package/package.json +44 -51
- /package/dist/node_modules/.pnpm/{vitest@4.0.13_@types_debug@4.1.12_@types_node@24.10.1_jiti@2.6.1_jsdom@27.2.0_sass@1.94.2_tsx@4.20.6_yaml@2.8.1 → vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.4.0_sass@1.97.2_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.cjs +0 -0
- /package/dist/node_modules/.pnpm/{vitest@4.0.13_@types_debug@4.1.12_@types_node@24.10.1_jiti@2.6.1_jsdom@27.2.0_sass@1.94.2_tsx@4.20.6_yaml@2.8.1 → vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.4.0_sass@1.97.2_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("globals");function u(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const n=u(i);var c=Object.defineProperty,a=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,l=(t,e,r)=>e in t?c(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,s=(t,e)=>{for(var r in e||(e={}))f.call(e,r)&&l(t,r,e[r]);if(a)for(var r of a(e))p.call(e,r)&&l(t,r,e[r]);return t};const d=[{languageOptions:{globals:s(s({},n.node),n.browser)},rules:{"perfectionist/sort-imports":["error",{internalPattern:["^#.*","^@/.*"]}],"dot-notation":"off"},ignores:["build","dist"]}];exports.default=d;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("globals");function u(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const n=u(i);var c=Object.defineProperty,a=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,l=(t,e,r)=>e in t?c(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,s=(t,e)=>{for(var r in e||(e={}))f.call(e,r)&&l(t,r,e[r]);if(a)for(var r of a(e))p.call(e,r)&&l(t,r,e[r]);return t};const d=[{languageOptions:{globals:s(s({},n.node),n.browser)},rules:{"perfectionist/sort-imports":["error",{internalPattern:["^#.*","^@/.*"]}],"dot-notation":"off"},ignores:["**/node_modules/**","**/.git/**","build","dist"]}];exports.default=d;
|
|
@@ -41,9 +41,7 @@ declare const _default: {
|
|
|
41
41
|
AudioScheduledSourceNode: false;
|
|
42
42
|
AudioSinkInfo: false;
|
|
43
43
|
AudioWorklet: false;
|
|
44
|
-
AudioWorkletGlobalScope: false;
|
|
45
44
|
AudioWorkletNode: false;
|
|
46
|
-
AudioWorkletProcessor: false;
|
|
47
45
|
AuthenticatorAssertionResponse: false;
|
|
48
46
|
AuthenticatorAttestationResponse: false;
|
|
49
47
|
AuthenticatorResponse: false;
|
|
@@ -177,6 +175,7 @@ declare const _default: {
|
|
|
177
175
|
CSSSkewY: false;
|
|
178
176
|
CSSStartingStyleRule: false;
|
|
179
177
|
CSSStyleDeclaration: false;
|
|
178
|
+
CSSStyleProperties: false;
|
|
180
179
|
CSSStyleRule: false;
|
|
181
180
|
CSSStyleSheet: false;
|
|
182
181
|
CSSStyleValue: false;
|
|
@@ -189,8 +188,6 @@ declare const _default: {
|
|
|
189
188
|
CSSUnparsedValue: false;
|
|
190
189
|
CSSVariableReferenceValue: false;
|
|
191
190
|
CSSViewTransitionRule: false;
|
|
192
|
-
currentFrame: false;
|
|
193
|
-
currentTime: false;
|
|
194
191
|
CustomElementRegistry: false;
|
|
195
192
|
customElements: false;
|
|
196
193
|
CustomEvent: false;
|
|
@@ -787,7 +784,6 @@ declare const _default: {
|
|
|
787
784
|
ReadableStreamBYOBRequest: false;
|
|
788
785
|
ReadableStreamDefaultController: false;
|
|
789
786
|
ReadableStreamDefaultReader: false;
|
|
790
|
-
registerProcessor: false;
|
|
791
787
|
RelativeOrientationSensor: false;
|
|
792
788
|
RemotePlayback: false;
|
|
793
789
|
removeEventListener: false;
|
|
@@ -827,7 +823,6 @@ declare const _default: {
|
|
|
827
823
|
RTCSessionDescription: false;
|
|
828
824
|
RTCStatsReport: false;
|
|
829
825
|
RTCTrackEvent: false;
|
|
830
|
-
sampleRate: false;
|
|
831
826
|
scheduler: false;
|
|
832
827
|
Scheduler: false;
|
|
833
828
|
Scheduling: false;
|
|
@@ -1012,6 +1007,7 @@ declare const _default: {
|
|
|
1012
1007
|
TaskController: false;
|
|
1013
1008
|
TaskPriorityChangeEvent: false;
|
|
1014
1009
|
TaskSignal: false;
|
|
1010
|
+
Temporal: false;
|
|
1015
1011
|
TEMPORARY: false;
|
|
1016
1012
|
Text: false;
|
|
1017
1013
|
TextDecoder: false;
|
|
@@ -1123,7 +1119,6 @@ declare const _default: {
|
|
|
1123
1119
|
WindowControlsOverlayGeometryChangeEvent: false;
|
|
1124
1120
|
Worker: false;
|
|
1125
1121
|
Worklet: false;
|
|
1126
|
-
WorkletGlobalScope: false;
|
|
1127
1122
|
WritableStream: false;
|
|
1128
1123
|
WritableStreamDefaultController: false;
|
|
1129
1124
|
WritableStreamDefaultWriter: false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../util/object/object.util.cjs");function e(o){const t={stories:["../src/**/*.stories.@(js|jsx|mjs|ts|tsx|mdx)"],addons:["@storybook/addon-essentials","@storybook/addon-interactions","@storybook/addon-links"],framework:{name:"@storybook/react-vite",options:{}}};return s.deepMerge(t,o)}exports.storybookMain=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@vitejs/plugin-react-swc"),i=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@vitejs/plugin-react-swc"),i=require("../../node_modules/.pnpm/vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.4.0_sass@1.97.2_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.cjs"),o=require("../../util/object/object.util.cjs");function n(e){const r={plugins:[t()],test:{include:["**/*.test.e2e.?(c|m)[jt]s?(x)"],browser:{enabled:!0,provider:"playwright",instances:[{browser:"chromium"},{browser:"firefox"},{browser:"webkit"}]}}};return i.defineConfig(o.deepMerge(r,e))}exports.vitestE2E=n;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import t from "@vitejs/plugin-react-swc";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
function
|
|
5
|
-
const
|
|
2
|
+
import { defineConfig as o } from "../../node_modules/.pnpm/vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.4.0_sass@1.97.2_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.js";
|
|
3
|
+
import { deepMerge as i } from "../../util/object/object.util.js";
|
|
4
|
+
function m(e) {
|
|
5
|
+
const r = {
|
|
6
6
|
plugins: [t()],
|
|
7
7
|
test: {
|
|
8
8
|
include: ["**/*.test.e2e.?(c|m)[jt]s?(x)"],
|
|
@@ -17,8 +17,8 @@ function f(r) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
-
return i(
|
|
20
|
+
return o(i(r, e));
|
|
21
21
|
}
|
|
22
22
|
export {
|
|
23
|
-
|
|
23
|
+
m as vitestE2E
|
|
24
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@vitejs/plugin-react-swc"),n=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@vitejs/plugin-react-swc"),n=require("../../node_modules/.pnpm/vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.4.0_sass@1.97.2_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.cjs"),s=require("../../util/object/object.util.cjs");function r(e){const t={plugins:[i()],test:{globals:!0,environment:"jsdom",pool:"vmThreads",include:["**/*.test.unit.?(c|m)[jt]s?(x)"],setupFiles:["./vitest.unit.setup.ts"]}};return n.defineConfig(s.deepMerge(t,e))}exports.vitestUnit=r;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import i from "@vitejs/plugin-react-swc";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
function
|
|
2
|
+
import { defineConfig as o } from "../../node_modules/.pnpm/vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.4.0_sass@1.97.2_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.js";
|
|
3
|
+
import { deepMerge as n } from "../../util/object/object.util.js";
|
|
4
|
+
function p(t) {
|
|
5
5
|
const e = {
|
|
6
6
|
plugins: [i()],
|
|
7
7
|
test: {
|
|
@@ -12,8 +12,8 @@ function u(t) {
|
|
|
12
12
|
setupFiles: ["./vitest.unit.setup.ts"]
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
-
return n(
|
|
15
|
+
return o(n(e, t));
|
|
16
16
|
}
|
|
17
17
|
export {
|
|
18
|
-
|
|
18
|
+
p as vitestUnit
|
|
19
19
|
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/node/cli/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";const
|
|
2
|
+
"use strict";const u=require("node:process"),I=require("yargs/helpers"),T=require("yargs/yargs"),i=require("../command/command.util.cjs"),y=require("../package/package.util.cjs"),a=require("../fs/fs.util.cjs"),v=require("../path/path.util.cjs"),n=require("../path/path.constant.cjs"),c=require("../log/log.util.cjs"),f=require("../log/log.type.cjs");var t=(e,o,r)=>new Promise((l,p)=>{var k=s=>{try{m(r.next(s))}catch(g){p(g)}},_=s=>{try{m(r.throw(s))}catch(g){p(g)}},m=s=>s.done?l(s.value):Promise.resolve(s.value).then(k,_);m((r=r.apply(e,o)).next())});function L(){try{return JSON.parse(a.readFileSync(v.resolve(__dirname,"../../../package.json"),"utf-8")).version}catch(e){return"1.0.0"}}function E(){return t(this,null,function*(){a.pathExistsSync(n.PATH.TS_CONFIG)?yield i.runCommand("Performing TypeScript validation",yield n.command.typescriptCheck()):c.log.warn("No TypeScript configuration found. Skipping type check.")})}function S(e=!1){return t(this,null,function*(){const o=e?yield n.command.eslintFix():yield n.command.eslintCheck(),r=e?"Running ESLint with auto-fix":"Running ESLint check";try{yield i.runCommand(r,o,{timeout:6e4,throwOnError:!0})}catch(l){l.code==="ETIMEDOUT"||l.killed||l.signal==="SIGTERM"?(c.log.warn("Lint check timed out. Retrying with debug mode enabled..."),u.env.DEBUG="true",yield i.runCommand(`${r} (Debug Mode)`,o)):c.catchError(l)}})}function h(e,o){if(!o.length)return;const r=e==="Errors"?"red":"yellow";c.log.printBoxedLog(e==="Errors"?"✖ Errors":"⚠ Warnings",o,r)}function d(){return t(this,null,function*(){setTimeout(()=>t(null,null,function*(){const e=(yield i.getStoredErrorLists())||[],o=e.filter(l=>l.type===f.E_IssueType.Error),r=e.filter(l=>l.type===f.E_IssueType.Warning);!o.length&&!r.length?c.log.printBoxedLog("✔ NO ISSUES FOUND",[],"green"):(h("Warnings",r),h("Errors",o),o.length>0&&u.exit(1))}),0)})}function M(){return t(this,null,function*(){yield i.clearAllErrorLists();const e=yield y.getPackage({name:n.CYBERSKILL_PACKAGE_NAME});if(!e.success){c.log.error("Failed to retrieve package information. Aborting lint-staged.");return}e.result.isCurrentProject&&(yield i.runCommand(`Building package: ${n.CYBERSKILL_PACKAGE_NAME}`,yield n.command.build())),yield i.runCommand("Executing lint-staged",yield n.command.lintStaged()),d()})}function O(){return t(this,null,function*(){yield i.runCommand("Inspecting ESLint configuration",yield n.command.eslintInspect())})}function P(){return t(this,null,function*(){yield i.clearAllErrorLists(),yield E(),yield S(),d()})}function A(){return t(this,null,function*(){yield i.clearAllErrorLists(),yield E(),yield S(!0),d()})}function R(){return t(this,null,function*(){yield i.clearAllErrorLists(),yield i.runCommand("Validating commit message",yield n.command.commitLint()),d()})}function C(){return t(this,null,function*(){yield i.runCommand("Configuring Git hooks",yield n.command.configureGitHook()),a.removeSync(n.PATH.GIT_HOOK);const e=yield i.resolveCommands(n.createGitHooksConfig);a.writeFileSync(n.PATH.SIMPLE_GIT_HOOKS_JSON,JSON.stringify(e,null,4));const o=`
|
|
3
3
|
${n.SIMPLE_GIT_HOOK_JSON}
|
|
4
|
-
`;
|
|
5
|
-
`).includes(n.SIMPLE_GIT_HOOK_JSON)||
|
|
6
|
-
`).parse()}catch(e){
|
|
4
|
+
`;a.pathExistsSync(n.PATH.GIT_IGNORE)?a.readFileSync(n.PATH.GIT_IGNORE,"utf-8").split(`
|
|
5
|
+
`).includes(n.SIMPLE_GIT_HOOK_JSON)||a.appendFileSync(n.PATH.GIT_IGNORE,o):a.writeFileSync(n.PATH.GIT_IGNORE,o),yield i.runCommand("Setting up simple-git-hooks",yield n.command.simpleGitHooks())})}function G(){return t(this,null,function*(){yield y.installDependencies(),yield C()})}function b(){return t(this,null,function*(){a.removeSync(n.PATH.NODE_MODULES,n.PATH.PNPM_LOCK_YAML),yield i.runCommand("Pruning pnpm store",yield n.command.pnpmPruneStore()),yield i.runCommand("Clearing pnpm cache",yield n.command.pnpmCleanCache()),yield y.installDependencies(),yield C()})}function D(){return t(this,null,function*(){yield i.runCommand("Inspecting project dependencies",yield n.command.nodeModulesInspect())})}function B(){return t(this,null,function*(){yield i.runCommand("Running unit tests",yield n.command.testUnit())})}function N(){return t(this,null,function*(){yield i.runCommand("Running end-to-end tests",yield n.command.testE2e())})}function w(e){return t(this,null,function*(){yield i.runCommand("Creating MongoDB migration",yield n.command.mongoMigrateCreate(e))})}function H(){return t(this,null,function*(){yield i.runCommand("Running MongoDB migrations",yield n.command.mongoMigrateUp())})}function q(){return t(this,null,function*(){yield i.runCommand("Rolling back MongoDB migration",yield n.command.mongoMigrateDown())})}function x(){return t(this,null,function*(){yield i.runCommand("Starting Storybook development server",yield n.command.storybookDev())})}function F(){return t(this,null,function*(){yield i.runCommand("Building Storybook",yield n.command.storybookBuild())})}t(null,null,function*(){try{yield T(I.hideBin(u.argv)).scriptName(n.CYBERSKILL_CLI).usage("$0 <command> [options]").command("lint","Check code for linting issues",P).command("lint:fix","Fix linting issues automatically",A).command("lint:inspect","View active ESLint configuration",O).command("lint-staged","Run lint checks on staged files",M).command("commitlint","Validate commit message format",R).command("ready","Initialize project and dependencies",G).command("reset","Reset the project and reinstall dependencies",b).command("inspect","Analyze installed project dependencies",D).command("test:unit","Run unit test suite",B).command("test:e2e","Run end-to-end test suite",N).command("mongo:migrate:create <name>","Create a MongoDB migration",e=>e.positional("name",{describe:"Migration name",type:"string"}),e=>t(null,null,function*(){if(!e.name){c.log.error("Migration name is required.");return}yield w(e.name)})).command("mongo:migrate:up","Apply all MongoDB migrations",H).command("mongo:migrate:down","Rollback last MongoDB migration",q).command("storybook:dev","Start Storybook development server",x).command("storybook:build","Build Storybook for production",F).demandCommand(1,"Please specify a valid command.").strict().help().alias("h","help").alias("v","version").version(L()).epilog(`💡 Tip: Use "--help" with any command to see options
|
|
6
|
+
`).parse()}catch(e){c.catchError(e),u.exit(1)}});
|
package/dist/node/cli/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import { hideBin as
|
|
4
|
-
import
|
|
5
|
-
import { clearAllErrorLists as
|
|
6
|
-
import { getPackage as
|
|
7
|
-
import { removeSync as
|
|
8
|
-
import { resolve as
|
|
9
|
-
import { CYBERSKILL_CLI as
|
|
10
|
-
import { log as u, catchError as
|
|
11
|
-
import { E_IssueType as
|
|
12
|
-
var e = (n, o, r) => new Promise((
|
|
13
|
-
var
|
|
2
|
+
import a from "node:process";
|
|
3
|
+
import { hideBin as T } from "yargs/helpers";
|
|
4
|
+
import D from "yargs/yargs";
|
|
5
|
+
import { clearAllErrorLists as d, runCommand as i, getStoredErrorLists as B, resolveCommands as w } from "../command/command.util.js";
|
|
6
|
+
import { getPackage as N, installDependencies as I } from "../package/package.util.js";
|
|
7
|
+
import { removeSync as v, readFileSync as C, pathExistsSync as M, writeFileSync as f, appendFileSync as P } from "../fs/fs.util.js";
|
|
8
|
+
import { resolve as x } from "../path/path.util.js";
|
|
9
|
+
import { CYBERSKILL_CLI as U, command as t, CYBERSKILL_PACKAGE_NAME as h, PATH as s, SIMPLE_GIT_HOOK_JSON as k, createGitHooksConfig as A } from "../path/path.constant.js";
|
|
10
|
+
import { log as u, catchError as _ } from "../log/log.util.js";
|
|
11
|
+
import { E_IssueType as E } from "../log/log.type.js";
|
|
12
|
+
var e = (n, o, r) => new Promise((l, p) => {
|
|
13
|
+
var b = (c) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
16
|
-
} catch (
|
|
17
|
-
p(
|
|
15
|
+
g(r.next(c));
|
|
16
|
+
} catch (y) {
|
|
17
|
+
p(y);
|
|
18
18
|
}
|
|
19
|
-
}, G = (
|
|
19
|
+
}, G = (c) => {
|
|
20
20
|
try {
|
|
21
|
-
|
|
22
|
-
} catch (
|
|
23
|
-
p(
|
|
21
|
+
g(r.throw(c));
|
|
22
|
+
} catch (y) {
|
|
23
|
+
p(y);
|
|
24
24
|
}
|
|
25
|
-
},
|
|
26
|
-
|
|
25
|
+
}, g = (c) => c.done ? l(c.value) : Promise.resolve(c.value).then(b, G);
|
|
26
|
+
g((r = r.apply(n, o)).next());
|
|
27
27
|
});
|
|
28
|
-
function
|
|
28
|
+
function F() {
|
|
29
29
|
try {
|
|
30
30
|
return JSON.parse(
|
|
31
|
-
C(
|
|
31
|
+
C(x(__dirname, "../../../package.json"), "utf-8")
|
|
32
32
|
).version;
|
|
33
33
|
} catch (n) {
|
|
34
34
|
return "1.0.0";
|
|
@@ -36,37 +36,42 @@ function H() {
|
|
|
36
36
|
}
|
|
37
37
|
function L() {
|
|
38
38
|
return e(this, null, function* () {
|
|
39
|
-
|
|
39
|
+
M(s.TS_CONFIG) ? yield i("Performing TypeScript validation", yield t.typescriptCheck()) : u.warn("No TypeScript configuration found. Skipping type check.");
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function O(n = !1) {
|
|
43
43
|
return e(this, null, function* () {
|
|
44
|
-
n ? yield
|
|
44
|
+
const o = n ? yield t.eslintFix() : yield t.eslintCheck(), r = n ? "Running ESLint with auto-fix" : "Running ESLint check";
|
|
45
|
+
try {
|
|
46
|
+
yield i(r, o, { timeout: 6e4, throwOnError: !0 });
|
|
47
|
+
} catch (l) {
|
|
48
|
+
l.code === "ETIMEDOUT" || l.killed || l.signal === "SIGTERM" ? (u.warn("Lint check timed out. Retrying with debug mode enabled..."), a.env.DEBUG = "true", yield i(`${r} (Debug Mode)`, o)) : _(l);
|
|
49
|
+
}
|
|
45
50
|
});
|
|
46
51
|
}
|
|
47
|
-
function
|
|
52
|
+
function S(n, o) {
|
|
48
53
|
if (!o.length)
|
|
49
54
|
return;
|
|
50
55
|
const r = n === "Errors" ? "red" : "yellow";
|
|
51
56
|
u.printBoxedLog(n === "Errors" ? "✖ Errors" : "⚠ Warnings", o, r);
|
|
52
57
|
}
|
|
53
|
-
function
|
|
58
|
+
function m() {
|
|
54
59
|
return e(this, null, function* () {
|
|
55
60
|
setTimeout(() => e(null, null, function* () {
|
|
56
|
-
const n = yield
|
|
57
|
-
!o.length && !r.length ? u.printBoxedLog("✔ NO ISSUES FOUND", [], "green") : (
|
|
61
|
+
const n = (yield B()) || [], o = n.filter((l) => l.type === E.Error), r = n.filter((l) => l.type === E.Warning);
|
|
62
|
+
!o.length && !r.length ? u.printBoxedLog("✔ NO ISSUES FOUND", [], "green") : (S("Warnings", r), S("Errors", o), o.length > 0 && a.exit(1));
|
|
58
63
|
}), 0);
|
|
59
64
|
});
|
|
60
65
|
}
|
|
61
|
-
function
|
|
66
|
+
function H() {
|
|
62
67
|
return e(this, null, function* () {
|
|
63
|
-
yield
|
|
64
|
-
const n = yield
|
|
68
|
+
yield d();
|
|
69
|
+
const n = yield N({ name: h });
|
|
65
70
|
if (!n.success) {
|
|
66
71
|
u.error("Failed to retrieve package information. Aborting lint-staged.");
|
|
67
72
|
return;
|
|
68
73
|
}
|
|
69
|
-
n.result.isCurrentProject && (yield i(`Building package: ${h}`, yield t.build())), yield i("Executing lint-staged", yield t.lintStaged()),
|
|
74
|
+
n.result.isCurrentProject && (yield i(`Building package: ${h}`, yield t.build())), yield i("Executing lint-staged", yield t.lintStaged()), m();
|
|
70
75
|
});
|
|
71
76
|
}
|
|
72
77
|
function K() {
|
|
@@ -76,42 +81,42 @@ function K() {
|
|
|
76
81
|
}
|
|
77
82
|
function j() {
|
|
78
83
|
return e(this, null, function* () {
|
|
79
|
-
yield
|
|
84
|
+
yield d(), yield L(), yield O(), m();
|
|
80
85
|
});
|
|
81
86
|
}
|
|
82
87
|
function J() {
|
|
83
88
|
return e(this, null, function* () {
|
|
84
|
-
yield
|
|
89
|
+
yield d(), yield L(), yield O(!0), m();
|
|
85
90
|
});
|
|
86
91
|
}
|
|
87
92
|
function V() {
|
|
88
93
|
return e(this, null, function* () {
|
|
89
|
-
yield
|
|
94
|
+
yield d(), yield i("Validating commit message", yield t.commitLint()), m();
|
|
90
95
|
});
|
|
91
96
|
}
|
|
92
|
-
function
|
|
97
|
+
function R() {
|
|
93
98
|
return e(this, null, function* () {
|
|
94
|
-
yield i("Configuring Git hooks", yield t.configureGitHook()),
|
|
95
|
-
const n = yield
|
|
96
|
-
f(
|
|
99
|
+
yield i("Configuring Git hooks", yield t.configureGitHook()), v(s.GIT_HOOK);
|
|
100
|
+
const n = yield w(A);
|
|
101
|
+
f(s.SIMPLE_GIT_HOOKS_JSON, JSON.stringify(n, null, 4));
|
|
97
102
|
const o = `
|
|
98
103
|
${k}
|
|
99
104
|
`;
|
|
100
|
-
|
|
101
|
-
`).includes(k) ||
|
|
105
|
+
M(s.GIT_IGNORE) ? C(s.GIT_IGNORE, "utf-8").split(`
|
|
106
|
+
`).includes(k) || P(s.GIT_IGNORE, o) : f(s.GIT_IGNORE, o), yield i("Setting up simple-git-hooks", yield t.simpleGitHooks());
|
|
102
107
|
});
|
|
103
108
|
}
|
|
104
|
-
function
|
|
109
|
+
function $() {
|
|
105
110
|
return e(this, null, function* () {
|
|
106
|
-
yield
|
|
111
|
+
yield I(), yield R();
|
|
107
112
|
});
|
|
108
113
|
}
|
|
109
|
-
function
|
|
114
|
+
function W() {
|
|
110
115
|
return e(this, null, function* () {
|
|
111
|
-
|
|
116
|
+
v(s.NODE_MODULES, s.PNPM_LOCK_YAML), yield i("Pruning pnpm store", yield t.pnpmPruneStore()), yield i("Clearing pnpm cache", yield t.pnpmCleanCache()), yield I(), yield R();
|
|
112
117
|
});
|
|
113
118
|
}
|
|
114
|
-
function
|
|
119
|
+
function Y() {
|
|
115
120
|
return e(this, null, function* () {
|
|
116
121
|
yield i("Inspecting project dependencies", yield t.nodeModulesInspect());
|
|
117
122
|
});
|
|
@@ -153,7 +158,7 @@ function en() {
|
|
|
153
158
|
}
|
|
154
159
|
e(null, null, function* () {
|
|
155
160
|
try {
|
|
156
|
-
yield
|
|
161
|
+
yield D(T(a.argv)).scriptName(U).usage("$0 <command> [options]").command("lint", "Check code for linting issues", j).command("lint:fix", "Fix linting issues automatically", J).command("lint:inspect", "View active ESLint configuration", K).command("lint-staged", "Run lint checks on staged files", H).command("commitlint", "Validate commit message format", V).command("ready", "Initialize project and dependencies", $).command("reset", "Reset the project and reinstall dependencies", W).command("inspect", "Analyze installed project dependencies", Y).command("test:unit", "Run unit test suite", z).command("test:e2e", "Run end-to-end test suite", q).command("mongo:migrate:create <name>", "Create a MongoDB migration", (n) => n.positional("name", {
|
|
157
162
|
describe: "Migration name",
|
|
158
163
|
type: "string"
|
|
159
164
|
}), (n) => e(null, null, function* () {
|
|
@@ -162,9 +167,9 @@ e(null, null, function* () {
|
|
|
162
167
|
return;
|
|
163
168
|
}
|
|
164
169
|
yield Q(n.name);
|
|
165
|
-
})).command("mongo:migrate:up", "Apply all MongoDB migrations", X).command("mongo:migrate:down", "Rollback last MongoDB migration", Z).command("storybook:dev", "Start Storybook development server", nn).command("storybook:build", "Build Storybook for production", en).demandCommand(1, "Please specify a valid command.").strict().help().alias("h", "help").alias("v", "version").version(
|
|
170
|
+
})).command("mongo:migrate:up", "Apply all MongoDB migrations", X).command("mongo:migrate:down", "Rollback last MongoDB migration", Z).command("storybook:dev", "Start Storybook development server", nn).command("storybook:build", "Build Storybook for production", en).demandCommand(1, "Please specify a valid command.").strict().help().alias("h", "help").alias("v", "version").version(F()).epilog(`💡 Tip: Use "--help" with any command to see options
|
|
166
171
|
`).parse();
|
|
167
172
|
} catch (n) {
|
|
168
|
-
|
|
173
|
+
_(n), a.exit(1);
|
|
169
174
|
}
|
|
170
175
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`).forEach(n=>{var
|
|
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;
|
|
@@ -60,4 +60,7 @@ export declare function resolveCommands(input: T_CommandMapInput): Promise<{
|
|
|
60
60
|
* @param command - The command string to execute, or undefined if no command should be run.
|
|
61
61
|
* @returns A promise that resolves when the command execution is complete.
|
|
62
62
|
*/
|
|
63
|
-
export declare function runCommand(label: string, command: string | void
|
|
63
|
+
export declare function runCommand(label: string, command: string | void, options?: {
|
|
64
|
+
timeout?: number;
|
|
65
|
+
throwOnError?: boolean;
|
|
66
|
+
}): Promise<void>;
|