@cyberskill/shared 2.27.0 → 2.28.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.d.ts +2 -0
- 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 +1 -1
- package/dist/node/cli/index.cjs +2 -5
- package/dist/node/cli/index.js +64 -69
- 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 +58 -50
- package/dist/node/fs/index.cjs +1 -1
- package/dist/node/fs/index.js +13 -12
- 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 +206 -211
- package/dist/node/storage/storage.util.cjs +1 -1
- package/dist/node/storage/storage.util.js +1 -1
- package/dist/node/upload/upload.util.js +3 -3
- package/dist/util/common/common.util.cjs +1 -1
- package/dist/util/common/common.util.d.ts +9 -0
- package/dist/util/common/common.util.js +33 -29
- 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 +23 -22
- package/dist/util/object/object.util.cjs +1 -1
- package/dist/util/object/object.util.js +40 -36
- package/package.json +40 -40
- 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.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}/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.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}/node_modules/vitest/dist/config.js +0 -0
|
@@ -373,6 +373,7 @@ declare const _default: {
|
|
|
373
373
|
HTMLFormElement: false;
|
|
374
374
|
HTMLFrameElement: false;
|
|
375
375
|
HTMLFrameSetElement: false;
|
|
376
|
+
HTMLGeolocationElement: false;
|
|
376
377
|
HTMLHeadElement: false;
|
|
377
378
|
HTMLHeadingElement: false;
|
|
378
379
|
HTMLHRElement: false;
|
|
@@ -1165,6 +1166,7 @@ declare const _default: {
|
|
|
1165
1166
|
XRView: false;
|
|
1166
1167
|
XRViewerPose: false;
|
|
1167
1168
|
XRViewport: false;
|
|
1169
|
+
XRVisibilityMaskChangeEvent: false;
|
|
1168
1170
|
XRWebGLBinding: false;
|
|
1169
1171
|
XRWebGLDepthInformation: false;
|
|
1170
1172
|
XRWebGLLayer: false;
|
|
@@ -1 +1 @@
|
|
|
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.
|
|
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.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/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,5 +1,5 @@
|
|
|
1
1
|
import t from "@vitejs/plugin-react-swc";
|
|
2
|
-
import { defineConfig as o } from "../../node_modules/.pnpm/vitest@4.0.
|
|
2
|
+
import { defineConfig as o } from "../../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/node_modules/vitest/dist/config.js";
|
|
3
3
|
import { deepMerge as i } from "../../util/object/object.util.js";
|
|
4
4
|
function m(e) {
|
|
5
5
|
const r = {
|
|
@@ -1 +1 @@
|
|
|
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.
|
|
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.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/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,5 +1,5 @@
|
|
|
1
1
|
import i from "@vitejs/plugin-react-swc";
|
|
2
|
-
import { defineConfig as o } from "../../node_modules/.pnpm/vitest@4.0.
|
|
2
|
+
import { defineConfig as o } from "../../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/node_modules/vitest/dist/config.js";
|
|
3
3
|
import { deepMerge as n } from "../../util/object/object.util.js";
|
|
4
4
|
function p(t) {
|
|
5
5
|
const e = {
|
package/dist/node/cli/index.cjs
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";const
|
|
3
|
-
|
|
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 e.runCommand("Setting up simple-git-hooks",yield n.command.simpleGitHooks())})}function R(){return t(this,null,function*(){yield y.installDependencies(),yield S()})}function b(){return t(this,null,function*(){a.removeSync(n.PATH.NODE_MODULES,n.PATH.PNPM_LOCK_YAML),yield e.runCommand("Pruning pnpm store",yield n.command.pnpmPruneStore()),yield e.runCommand("Clearing pnpm cache",yield n.command.pnpmCleanCache()),yield y.installDependencies(),yield S(),yield _()})}function D(){return t(this,null,function*(){yield e.runCommand("Inspecting project dependencies",yield n.command.nodeModulesInspect())})}function B(){return t(this,null,function*(){yield e.runCommand("Running unit tests",yield n.command.testUnit())})}function H(){return t(this,null,function*(){yield e.runCommand("Running end-to-end tests",yield n.command.testE2e())})}function K(i){return t(this,null,function*(){yield e.runCommand("Creating MongoDB migration",yield n.command.mongoMigrateCreate(i))})}function w(){return t(this,null,function*(){yield e.runCommand("Running MongoDB migrations",yield n.command.mongoMigrateUp())})}function x(){return t(this,null,function*(){yield e.runCommand("Rolling back MongoDB migration",yield n.command.mongoMigrateDown())})}function q(){return t(this,null,function*(){yield e.runCommand("Starting Storybook development server",yield n.command.storybookDev())})}function F(){return t(this,null,function*(){yield e.runCommand("Building Storybook",yield n.command.storybookBuild())})}function _(){return t(this,null,function*(){try{yield e.runCommand(`Checking for ${n.AG_KIT_PACKAGE_NAME}`,`pnpm list -g ${n.AG_KIT_PACKAGE_NAME}`)}catch(i){yield e.runCommand(`Installing ${n.AG_KIT_PACKAGE_NAME} globally`,`pnpm i -g ${n.AG_KIT_PACKAGE_NAME}`)}a.pathExistsSync(n.PATH.DOT_AGENT)?yield e.runCommand("Updating AI agent","ag-kit update"):yield e.runCommand("Initializing AI agent","ag-kit init")})}t(null,null,function*(){try{yield T(I.hideBin(s.argv)).scriptName(n.CYBERSKILL_CLI).usage("$0 <command> [options]").command("ai:setup","Setup AI agent environment",_).command("lint","Check code for linting issues",L).command("lint:fix","Fix linting issues automatically",O).command("lint:inspect","View active ESLint configuration",P).command("lint-staged","Run lint checks on staged files",v).command("commitlint","Validate commit message format",N).command("ready","Initialize project and dependencies",R).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",H).command("mongo:migrate:create <name>","Create a MongoDB migration",i=>i.positional("name",{describe:"Migration name",type:"string"}),i=>t(null,null,function*(){if(!i.name){c.log.error("Migration name is required.");return}yield K(i.name)})).command("mongo:migrate:up","Apply all MongoDB migrations",w).command("mongo:migrate:down","Rollback last MongoDB migration",x).command("storybook:dev","Start Storybook development server",q).command("storybook:build","Build Storybook for production",F).demandCommand(1,"Please specify a valid command.").strict().help().alias("h","help").alias("v","version").version(M()).epilog(`💡 Tip: Use "--help" with any command to see options
|
|
6
|
-
`).parse()}catch(i){c.catchError(i),s.exit(1)}});
|
|
2
|
+
"use strict";const d=require("node:process"),I=require("yargs/helpers"),T=require("yargs/yargs"),e=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"),u=require("../log/log.util.cjs"),f=require("../log/log.type.cjs");var t=(i,r,o)=>new Promise((l,p)=>{var A=c=>{try{m(o.next(c))}catch(g){p(g)}},S=c=>{try{m(o.throw(c))}catch(g){p(g)}},m=c=>c.done?l(c.value):Promise.resolve(c.value).then(A,S);m((o=o.apply(i,r)).next())});function M(){try{return JSON.parse(a.readFileSync(v.resolve(__dirname,"../../../package.json"),"utf-8")).version}catch(i){return"1.0.0"}}function E(){return t(this,null,function*(){a.pathExistsSync(n.PATH.TS_CONFIG)?yield e.runCommand("Performing TypeScript validation",yield n.command.typescriptCheck()):u.log.warn("No TypeScript configuration found. Skipping type check.")})}function C(i=!1){return t(this,null,function*(){const r=i?yield n.command.eslintFix():yield n.command.eslintCheck(),o=i?"Running ESLint with auto-fix":"Running ESLint check";try{yield e.runCommand(o,r,{timeout:6e4,throwOnError:!0})}catch(l){l.code==="ETIMEDOUT"||l.killed||l.signal==="SIGTERM"?(u.log.warn("Lint check timed out. Retrying with debug mode enabled..."),d.env.DEBUG="true",yield e.runCommand(`${o} (Debug Mode)`,r)):u.catchError(l)}})}function h(i,r){if(!r.length)return;const o=i==="Errors"?"red":"yellow";u.log.printBoxedLog(i==="Errors"?"✖ Errors":"⚠ Warnings",r,o)}function s(){return t(this,null,function*(){setTimeout(()=>t(null,null,function*(){const i=(yield e.getStoredErrorLists())||[],r=i.filter(l=>l.type===f.E_IssueType.Error),o=i.filter(l=>l.type===f.E_IssueType.Warning);!r.length&&!o.length?u.log.printBoxedLog("✔ NO ISSUES FOUND",[],"green"):(h("Warnings",o),h("Errors",r),r.length>0&&d.exit(1))}),0)})}function G(){return t(this,null,function*(){yield e.clearAllErrorLists();const i=yield y.getPackage({name:n.CYBERSKILL_PACKAGE_NAME});if(!i.success){u.log.error("Failed to retrieve package information. Aborting lint-staged.");return}i.result.isCurrentProject&&(yield e.runCommand(`Building package: ${n.CYBERSKILL_PACKAGE_NAME}`,yield n.command.build())),yield e.runCommand("Executing lint-staged",yield n.command.lintStaged()),s()})}function L(){return t(this,null,function*(){yield e.runCommand("Inspecting ESLint configuration",yield n.command.eslintInspect())})}function P(){return t(this,null,function*(){yield e.clearAllErrorLists(),yield E(),yield C(),s()})}function b(){return t(this,null,function*(){yield e.clearAllErrorLists(),yield E(),yield C(!0),s()})}function O(){return t(this,null,function*(){yield e.clearAllErrorLists(),yield e.runCommand("Validating commit message",yield n.command.commitLint()),s()})}function _(){return t(this,null,function*(){yield e.runCommand("Configuring Git hooks",yield n.command.configureGitHook()),a.removeSync(n.PATH.GIT_HOOK);const i=yield e.resolveCommands(n.createGitHooksConfig);a.writeFileSync(n.PATH.SIMPLE_GIT_HOOKS_JSON,JSON.stringify(i,null,4)),a.addGitIgnoreEntry(n.PATH.GIT_IGNORE,n.SIMPLE_GIT_HOOK_JSON),yield e.runCommand("Setting up simple-git-hooks",yield n.command.simpleGitHooks())})}function k(){return t(this,null,function*(){try{yield e.runCommand(`Checking for ${n.AG_KIT_PACKAGE_NAME}`,`pnpm list -g ${n.AG_KIT_PACKAGE_NAME}`)}catch(i){yield e.runCommand(`Installing ${n.AG_KIT_PACKAGE_NAME} globally`,`pnpm i -g ${n.AG_KIT_PACKAGE_NAME}`)}a.pathExistsSync(n.PATH.DOT_AGENT)?yield e.runCommand("Updating AI agent","ag-kit update -y"):yield e.runCommand("Initializing AI agent","ag-kit init"),a.addGitIgnoreEntry(n.PATH.GIT_IGNORE,n.DOT_AGENT)})}function D(){return t(this,null,function*(){yield y.installDependencies(),yield _()})}function N(){return t(this,null,function*(){a.removeSync(n.PATH.NODE_MODULES,n.PATH.PNPM_LOCK_YAML),yield e.runCommand("Pruning pnpm store",yield n.command.pnpmPruneStore()),yield e.runCommand("Clearing pnpm cache",yield n.command.pnpmCleanCache()),yield y.installDependencies(),yield _(),yield k()})}function R(){return t(this,null,function*(){yield e.runCommand("Inspecting project dependencies",yield n.command.nodeModulesInspect())})}function B(){return t(this,null,function*(){yield e.runCommand("Running unit tests",yield n.command.testUnit())})}function K(){return t(this,null,function*(){yield e.runCommand("Running end-to-end tests",yield n.command.testE2e())})}function w(i){return t(this,null,function*(){yield e.runCommand("Creating MongoDB migration",yield n.command.mongoMigrateCreate(i))})}function H(){return t(this,null,function*(){yield e.runCommand("Running MongoDB migrations",yield n.command.mongoMigrateUp())})}function q(){return t(this,null,function*(){yield e.runCommand("Rolling back MongoDB migration",yield n.command.mongoMigrateDown())})}function x(){return t(this,null,function*(){yield e.runCommand("Starting Storybook development server",yield n.command.storybookDev())})}function U(){return t(this,null,function*(){yield e.runCommand("Building Storybook",yield n.command.storybookBuild())})}t(null,null,function*(){try{yield T(I.hideBin(d.argv)).scriptName(n.CYBERSKILL_CLI).usage("$0 <command> [options]").command("ai:setup","Setup AI agent environment",k).command("lint","Check code for linting issues",P).command("lint:fix","Fix linting issues automatically",b).command("lint:inspect","View active ESLint configuration",L).command("lint-staged","Run lint checks on staged files",G).command("commitlint","Validate commit message format",O).command("ready","Initialize project and dependencies",D).command("reset","Reset the project and reinstall dependencies",N).command("inspect","Analyze installed project dependencies",R).command("test:unit","Run unit test suite",B).command("test:e2e","Run end-to-end test suite",K).command("mongo:migrate:create <name>","Create a MongoDB migration",i=>i.positional("name",{describe:"Migration name",type:"string"}),i=>t(null,null,function*(){if(!i.name){u.log.error("Migration name is required.");return}yield w(i.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",U).demandCommand(1,"Please specify a valid command.").strict().help().alias("h","help").alias("v","version").version(M()).epilog(`💡 Tip: Use "--help" with any command to see options
|
|
3
|
+
`).parse()}catch(i){u.catchError(i),d.exit(1)}});
|
package/dist/node/cli/index.js
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import d from "node:process";
|
|
3
|
-
import { hideBin as
|
|
4
|
-
import
|
|
5
|
-
import { runCommand as e, clearAllErrorLists as m, getStoredErrorLists as
|
|
6
|
-
import { getPackage as
|
|
7
|
-
import { pathExistsSync as
|
|
8
|
-
import { resolve as
|
|
9
|
-
import { CYBERSKILL_CLI as
|
|
10
|
-
import { log as a, catchError as
|
|
11
|
-
import { E_IssueType as
|
|
12
|
-
var i = (n,
|
|
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
13
|
var T = (c) => {
|
|
14
14
|
try {
|
|
15
|
-
y(
|
|
15
|
+
y(o.next(c));
|
|
16
16
|
} catch (p) {
|
|
17
|
-
|
|
17
|
+
f(p);
|
|
18
18
|
}
|
|
19
19
|
}, D = (c) => {
|
|
20
20
|
try {
|
|
21
|
-
y(
|
|
21
|
+
y(o.throw(c));
|
|
22
22
|
} catch (p) {
|
|
23
|
-
|
|
23
|
+
f(p);
|
|
24
24
|
}
|
|
25
25
|
}, y = (c) => c.done ? l(c.value) : Promise.resolve(c.value).then(T, D);
|
|
26
|
-
y((
|
|
26
|
+
y((o = o.apply(n, r)).next());
|
|
27
27
|
});
|
|
28
|
-
function
|
|
28
|
+
function $() {
|
|
29
29
|
try {
|
|
30
30
|
return JSON.parse(
|
|
31
|
-
|
|
31
|
+
w(U(__dirname, "../../../package.json"), "utf-8")
|
|
32
32
|
).version;
|
|
33
33
|
} catch (n) {
|
|
34
34
|
return "1.0.0";
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function M() {
|
|
38
38
|
return i(this, null, function* () {
|
|
39
|
-
|
|
39
|
+
I(s.TS_CONFIG) ? yield e("Performing TypeScript validation", yield t.typescriptCheck()) : a.warn("No TypeScript configuration found. Skipping type check.");
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function b(n = !1) {
|
|
43
43
|
return i(this, null, function* () {
|
|
44
|
-
const
|
|
44
|
+
const r = n ? yield t.eslintFix() : yield t.eslintCheck(), o = n ? "Running ESLint with auto-fix" : "Running ESLint check";
|
|
45
45
|
try {
|
|
46
|
-
yield e(
|
|
46
|
+
yield e(o, r, { timeout: 6e4, throwOnError: !0 });
|
|
47
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(`${
|
|
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
49
|
}
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
if (!
|
|
52
|
+
function E(n, r) {
|
|
53
|
+
if (!r.length)
|
|
54
54
|
return;
|
|
55
|
-
const
|
|
56
|
-
a.printBoxedLog(n === "Errors" ? "✖ Errors" : "⚠ Warnings",
|
|
55
|
+
const o = n === "Errors" ? "red" : "yellow";
|
|
56
|
+
a.printBoxedLog(n === "Errors" ? "✖ Errors" : "⚠ Warnings", r, o);
|
|
57
57
|
}
|
|
58
58
|
function g() {
|
|
59
59
|
return i(this, null, function* () {
|
|
60
60
|
setTimeout(() => i(null, null, function* () {
|
|
61
|
-
const n = (yield
|
|
62
|
-
!
|
|
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
63
|
}), 0);
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function j() {
|
|
67
67
|
return i(this, null, function* () {
|
|
68
68
|
yield m();
|
|
69
|
-
const n = yield
|
|
69
|
+
const n = yield N({ name: h });
|
|
70
70
|
if (!n.success) {
|
|
71
71
|
a.error("Failed to retrieve package information. Aborting lint-staged.");
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
n.result.isCurrentProject && (yield e(`Building package: ${
|
|
74
|
+
n.result.isCurrentProject && (yield e(`Building package: ${h}`, yield t.build())), yield e("Executing lint-staged", yield t.lintStaged()), g();
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function J() {
|
|
78
78
|
return i(this, null, function* () {
|
|
79
79
|
yield e("Inspecting ESLint configuration", yield t.eslintInspect());
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function V() {
|
|
83
83
|
return i(this, null, function* () {
|
|
84
|
-
yield m(), yield
|
|
84
|
+
yield m(), yield M(), yield b(), g();
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function z() {
|
|
88
88
|
return i(this, null, function* () {
|
|
89
|
-
yield m(), yield
|
|
89
|
+
yield m(), yield M(), yield b(!0), g();
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function W() {
|
|
93
93
|
return i(this, null, function* () {
|
|
94
94
|
yield m(), yield e("Validating commit message", yield t.commitLint()), g();
|
|
95
95
|
});
|
|
@@ -97,78 +97,73 @@ function z() {
|
|
|
97
97
|
function L() {
|
|
98
98
|
return i(this, null, function* () {
|
|
99
99
|
yield e("Configuring Git hooks", yield t.configureGitHook()), C(s.GIT_HOOK);
|
|
100
|
-
const n = yield
|
|
101
|
-
|
|
102
|
-
const o = `
|
|
103
|
-
${S}
|
|
104
|
-
`;
|
|
105
|
-
f(s.GIT_IGNORE) ? M(s.GIT_IGNORE, "utf-8").split(`
|
|
106
|
-
`).includes(S) || U(s.GIT_IGNORE, o) : k(s.GIT_IGNORE, o), yield e("Setting up simple-git-hooks", yield t.simpleGitHooks());
|
|
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());
|
|
107
102
|
});
|
|
108
103
|
}
|
|
109
|
-
function
|
|
104
|
+
function O() {
|
|
110
105
|
return i(this, null, function* () {
|
|
111
|
-
|
|
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
112
|
});
|
|
113
113
|
}
|
|
114
114
|
function Y() {
|
|
115
115
|
return i(this, null, function* () {
|
|
116
|
-
|
|
116
|
+
yield S(), yield L();
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
function q() {
|
|
120
120
|
return i(this, null, function* () {
|
|
121
|
-
yield e("
|
|
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
122
|
});
|
|
123
123
|
}
|
|
124
124
|
function Q() {
|
|
125
125
|
return i(this, null, function* () {
|
|
126
|
-
yield e("
|
|
126
|
+
yield e("Inspecting project dependencies", yield t.nodeModulesInspect());
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
129
|
function X() {
|
|
130
130
|
return i(this, null, function* () {
|
|
131
|
-
yield e("Running
|
|
131
|
+
yield e("Running unit tests", yield t.testUnit());
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
function Z(
|
|
134
|
+
function Z() {
|
|
135
135
|
return i(this, null, function* () {
|
|
136
|
-
yield e("
|
|
136
|
+
yield e("Running end-to-end tests", yield t.testE2e());
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
-
function nn() {
|
|
139
|
+
function nn(n) {
|
|
140
140
|
return i(this, null, function* () {
|
|
141
|
-
yield e("
|
|
141
|
+
yield e("Creating MongoDB migration", yield t.mongoMigrateCreate(n));
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
function en() {
|
|
145
145
|
return i(this, null, function* () {
|
|
146
|
-
yield e("
|
|
146
|
+
yield e("Running MongoDB migrations", yield t.mongoMigrateUp());
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
149
|
function tn() {
|
|
150
150
|
return i(this, null, function* () {
|
|
151
|
-
yield e("
|
|
151
|
+
yield e("Rolling back MongoDB migration", yield t.mongoMigrateDown());
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
function on() {
|
|
155
155
|
return i(this, null, function* () {
|
|
156
|
-
yield e("
|
|
156
|
+
yield e("Starting Storybook development server", yield t.storybookDev());
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function rn() {
|
|
160
160
|
return i(this, null, function* () {
|
|
161
|
-
|
|
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");
|
|
161
|
+
yield e("Building Storybook", yield t.storybookBuild());
|
|
167
162
|
});
|
|
168
163
|
}
|
|
169
164
|
i(null, null, function* () {
|
|
170
165
|
try {
|
|
171
|
-
yield
|
|
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", {
|
|
172
167
|
describe: "Migration name",
|
|
173
168
|
type: "string"
|
|
174
169
|
}), (n) => i(null, null, function* () {
|
|
@@ -176,10 +171,10 @@ i(null, null, function* () {
|
|
|
176
171
|
a.error("Migration name is required.");
|
|
177
172
|
return;
|
|
178
173
|
}
|
|
179
|
-
yield
|
|
180
|
-
})).command("mongo:migrate:up", "Apply all MongoDB migrations",
|
|
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
|
|
181
176
|
`).parse();
|
|
182
177
|
} catch (n) {
|
|
183
|
-
|
|
178
|
+
_(n), d.exit(1);
|
|
184
179
|
}
|
|
185
180
|
});
|
package/dist/node/fs/fs.util.cjs
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("fs-extra"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("fs-extra"),m=require("node:path");var _=Object.defineProperty,c=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,l=(n,e,r)=>e in n?_(n,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[e]=r,O=(n,e)=>{for(var r in e||(e={}))f.call(e,r)&&l(n,r,e[r]);if(c)for(var r of c(e))S.call(e,r)&&l(n,r,e[r]);return n},g=(n,e)=>{var r={};for(var t in n)f.call(n,t)&&e.indexOf(t)<0&&(r[t]=n[t]);if(n!=null&&c)for(var t of c(n))e.indexOf(t)<0&&S.call(n,t)&&(r[t]=n[t]);return r};const E=i,{lstatSync:w,readdirSync:x,mkdirSync:F,readFileSync:s,unlinkSync:b,statSync:u,createWriteStream:j}=i,h=i.readJsonSync;function d(n,e,r){i.writeFileSync(n,e,r!=null?r:"utf-8")}function p(n,e,r){i.appendFileSync(n,e,r!=null?r:"utf-8")}function y(...n){return n.every(e=>i.pathExistsSync(e))}function J(...n){n.forEach(e=>{y(e)&&i.removeSync(e)})}function P(n,e,r={}){const t=r,{extensions:a}=t,v=g(t,["extensions"]);i.copySync(n,e,O({filter:o=>u(o).isDirectory()||!a||a.length===0?!0:a.includes(m.extname(o))},v))}function k(n,e){const r=`
|
|
2
|
+
${e}
|
|
3
|
+
`;y(n)?s(n,"utf-8").split(`
|
|
4
|
+
`).includes(e)||p(n,r):d(n,r)}exports.addGitIgnoreEntry=k;exports.appendFileSync=p;exports.copySync=P;exports.createWriteStream=j;exports.fs=E;exports.lstatSync=w;exports.mkdirSync=F;exports.pathExistsSync=y;exports.readFileSync=s;exports.readJsonSync=h;exports.readdirSync=x;exports.removeSync=J;exports.statSync=u;exports.unlinkSync=b;exports.writeFileSync=d;
|
|
@@ -55,3 +55,11 @@ export declare function removeSync(...paths: string[]): void;
|
|
|
55
55
|
* @param options - Optional copy configuration including extensions filter and other fs-extra options.
|
|
56
56
|
*/
|
|
57
57
|
export declare function copySync(src: string, dest: string, options?: I_CopySyncOptions): void;
|
|
58
|
+
/**
|
|
59
|
+
* Adds an entry to the .gitignore file if it doesn't already exist.
|
|
60
|
+
* Creates the .gitignore file if it doesn't exist.
|
|
61
|
+
*
|
|
62
|
+
* @param gitIgnorePath - The absolute path to the .gitignore file.
|
|
63
|
+
* @param entry - The entry name to add (e.g. '.agent', '.simple-git-hooks.json').
|
|
64
|
+
*/
|
|
65
|
+
export declare function addGitIgnoreEntry(gitIgnorePath: string, entry: string): void;
|
package/dist/node/fs/fs.util.js
CHANGED
|
@@ -1,63 +1,71 @@
|
|
|
1
1
|
import i from "fs-extra";
|
|
2
|
-
import
|
|
3
|
-
var
|
|
4
|
-
for (var e in
|
|
5
|
-
l.call(
|
|
6
|
-
if (
|
|
7
|
-
for (var e of
|
|
8
|
-
y.call(
|
|
9
|
-
return
|
|
10
|
-
}, m = (
|
|
2
|
+
import p from "node:path";
|
|
3
|
+
var S = Object.defineProperty, c = Object.getOwnPropertySymbols, l = Object.prototype.hasOwnProperty, y = Object.prototype.propertyIsEnumerable, a = (n, r, e) => r in n ? S(n, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[r] = e, d = (n, r) => {
|
|
4
|
+
for (var e in r || (r = {}))
|
|
5
|
+
l.call(r, e) && a(n, e, r[e]);
|
|
6
|
+
if (c)
|
|
7
|
+
for (var e of c(r))
|
|
8
|
+
y.call(r, e) && a(n, e, r[e]);
|
|
9
|
+
return n;
|
|
10
|
+
}, m = (n, r) => {
|
|
11
11
|
var e = {};
|
|
12
|
-
for (var t in
|
|
13
|
-
l.call(
|
|
14
|
-
if (
|
|
15
|
-
for (var t of
|
|
16
|
-
|
|
12
|
+
for (var t in n)
|
|
13
|
+
l.call(n, t) && r.indexOf(t) < 0 && (e[t] = n[t]);
|
|
14
|
+
if (n != null && c)
|
|
15
|
+
for (var t of c(n))
|
|
16
|
+
r.indexOf(t) < 0 && y.call(n, t) && (e[t] = n[t]);
|
|
17
17
|
return e;
|
|
18
18
|
};
|
|
19
|
-
const
|
|
20
|
-
lstatSync:
|
|
21
|
-
readdirSync:
|
|
22
|
-
mkdirSync:
|
|
23
|
-
readFileSync:
|
|
24
|
-
unlinkSync:
|
|
25
|
-
statSync:
|
|
26
|
-
createWriteStream:
|
|
27
|
-
} = i,
|
|
28
|
-
function
|
|
29
|
-
i.writeFileSync(
|
|
19
|
+
const g = i, {
|
|
20
|
+
lstatSync: F,
|
|
21
|
+
readdirSync: b,
|
|
22
|
+
mkdirSync: j,
|
|
23
|
+
readFileSync: _,
|
|
24
|
+
unlinkSync: h,
|
|
25
|
+
statSync: v,
|
|
26
|
+
createWriteStream: J
|
|
27
|
+
} = i, P = i.readJsonSync;
|
|
28
|
+
function O(n, r, e) {
|
|
29
|
+
i.writeFileSync(n, r, e != null ? e : "utf-8");
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
i.appendFileSync(
|
|
31
|
+
function x(n, r, e) {
|
|
32
|
+
i.appendFileSync(n, r, e != null ? e : "utf-8");
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
return
|
|
34
|
+
function s(...n) {
|
|
35
|
+
return n.every((r) => i.pathExistsSync(r));
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
function C(...n) {
|
|
38
|
+
n.forEach((r) => {
|
|
39
|
+
s(r) && i.removeSync(r);
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
function D(
|
|
43
|
-
const t = e, { extensions:
|
|
44
|
-
i.copySync(
|
|
45
|
-
filter: (f) =>
|
|
46
|
-
},
|
|
42
|
+
function D(n, r, e = {}) {
|
|
43
|
+
const t = e, { extensions: o } = t, u = m(t, ["extensions"]);
|
|
44
|
+
i.copySync(n, r, d({
|
|
45
|
+
filter: (f) => v(f).isDirectory() || !o || o.length === 0 ? !0 : o.includes(p.extname(f))
|
|
46
|
+
}, u));
|
|
47
|
+
}
|
|
48
|
+
function G(n, r) {
|
|
49
|
+
const e = `
|
|
50
|
+
${r}
|
|
51
|
+
`;
|
|
52
|
+
s(n) ? _(n, "utf-8").split(`
|
|
53
|
+
`).includes(r) || x(n, e) : O(n, e);
|
|
47
54
|
}
|
|
48
55
|
export {
|
|
49
|
-
|
|
56
|
+
G as addGitIgnoreEntry,
|
|
57
|
+
x as appendFileSync,
|
|
50
58
|
D as copySync,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
J as createWriteStream,
|
|
60
|
+
g as fs,
|
|
61
|
+
F as lstatSync,
|
|
62
|
+
j as mkdirSync,
|
|
63
|
+
s as pathExistsSync,
|
|
64
|
+
_ as readFileSync,
|
|
65
|
+
P as readJsonSync,
|
|
66
|
+
b as readdirSync,
|
|
67
|
+
C as removeSync,
|
|
68
|
+
v as statSync,
|
|
69
|
+
h as unlinkSync,
|
|
70
|
+
O as writeFileSync
|
|
63
71
|
};
|
package/dist/node/fs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./fs.util.cjs");exports.appendFileSync=e.appendFileSync;exports.copySync=e.copySync;exports.createWriteStream=e.createWriteStream;exports.fs=e.fs;exports.lstatSync=e.lstatSync;exports.mkdirSync=e.mkdirSync;exports.pathExistsSync=e.pathExistsSync;exports.readFileSync=e.readFileSync;exports.readJsonSync=e.readJsonSync;exports.readdirSync=e.readdirSync;exports.removeSync=e.removeSync;exports.statSync=e.statSync;exports.unlinkSync=e.unlinkSync;exports.writeFileSync=e.writeFileSync;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./fs.util.cjs");exports.addGitIgnoreEntry=e.addGitIgnoreEntry;exports.appendFileSync=e.appendFileSync;exports.copySync=e.copySync;exports.createWriteStream=e.createWriteStream;exports.fs=e.fs;exports.lstatSync=e.lstatSync;exports.mkdirSync=e.mkdirSync;exports.pathExistsSync=e.pathExistsSync;exports.readFileSync=e.readFileSync;exports.readJsonSync=e.readJsonSync;exports.readdirSync=e.readdirSync;exports.removeSync=e.removeSync;exports.statSync=e.statSync;exports.unlinkSync=e.unlinkSync;exports.writeFileSync=e.writeFileSync;
|
package/dist/node/fs/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { addGitIgnoreEntry as c, appendFileSync as r, copySync as y, createWriteStream as t, fs as S, lstatSync as a, mkdirSync as i, pathExistsSync as d, readFileSync as o, readJsonSync as s, readdirSync as l, removeSync as p, statSync as m, unlinkSync as F, writeFileSync as f } from "./fs.util.js";
|
|
2
2
|
export {
|
|
3
|
-
c as
|
|
3
|
+
c as addGitIgnoreEntry,
|
|
4
|
+
r as appendFileSync,
|
|
4
5
|
y as copySync,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
t as createWriteStream,
|
|
7
|
+
S as fs,
|
|
8
|
+
a as lstatSync,
|
|
9
|
+
i as mkdirSync,
|
|
10
|
+
d as pathExistsSync,
|
|
11
|
+
o as readFileSync,
|
|
11
12
|
s as readJsonSync,
|
|
12
13
|
l as readdirSync,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
p as removeSync,
|
|
15
|
+
m as statSync,
|
|
16
|
+
F as unlinkSync,
|
|
17
|
+
f as writeFileSync
|
|
17
18
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Collection as o, Db as s } from "mongodb";
|
|
2
2
|
import { Document as t, Model as l } from "mongoose";
|
|
3
|
-
class d extends
|
|
3
|
+
class d extends s {
|
|
4
4
|
}
|
|
5
5
|
class m extends t {
|
|
6
6
|
}
|
|
7
7
|
class C extends l {
|
|
8
8
|
}
|
|
9
|
-
class r extends
|
|
9
|
+
class r extends o {
|
|
10
10
|
}
|
|
11
11
|
export {
|
|
12
12
|
r as C_Collection,
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
module.exports = ${JSON.stringify(t,null,4)}
|
|
3
|
-
${w.MIGRATE_MONGO_CONFIG}
|
|
4
|
-
`;E.pathExistsSync(w.PATH.GIT_IGNORE)?E.readFileSync(w.PATH.GIT_IGNORE,"utf-8").split(`
|
|
5
|
-
`).includes(w.MIGRATE_MONGO_CONFIG)||E.appendFileSync(w.PATH.GIT_IGNORE,e):E.writeFileSync(w.PATH.GIT_IGNORE,e)}}),regexify(t,i){if(!t)return{};let e=F.deepClone(t);if(!i||i.length===0)return e;for(const o of i){const r=o.toString().split("."),n=F.getNestedValue(e,r);if(typeof n=="string"&&n.length>0){const l={$regex:`.*${B.regexSearchMapper(n)}.*`,$options:"i"};e=F.setNestedValue(e,r,l)}}return e},isDynamicVirtual(t){return!!(t&&typeof t.ref=="function")},getNewRecords(t,i,e){return R(this,null,function*(){const o=yield t.findAll({});return o.success?i.filter(n=>!o.result.some(l=>e(l,n))):i})},getExistingRecords(t,i,e){return R(this,null,function*(){const o=yield t.findAll({});return o.success?o.result.filter(n=>i.some(l=>e(n,l))):[]})}};function x(t,i,e,o,r){return R(this,null,function*(){if(!i.length||!e)return i;const n=Array.isArray(e)?e:[e];for(const l of n)typeof l=="string"?yield C(t,i,l,o,r):l&&typeof l=="object"&&(yield X(t,i,l,o,r));return i})}function C(t,i,e,o,r){return R(this,null,function*(){var n,l,y,s;const h=e.split(".");if(h.length<2){for(const m of i)yield V(t,m,e,o,void 0,r);return}const u=h[0];if(!u||u.trim()==="")return;const S=h.slice(1).join(".");for(const m of i){const N=m,O=N[u];if(O&&typeof O=="object"){let c=r;const a=c;if(r&&r.schema&&r.schema.virtuals){const f=r.schema.virtuals[u];if(f&&f.options&&f.options.ref){let g;if(typeof f.options.ref=="function"?g=f.options.ref(N):typeof f.options.ref=="string"&&(g=f.options.ref),g){const p=P(g);t.models[p]&&(c=t.models[p])}}}if(!c){const f=(l=(n=r==null?void 0:r.schema)==null?void 0:n.statics)!=null?l:{},p=((r==null?void 0:r._virtualConfigs)||f._dynamicVirtuals||[]).find(d=>d.name===u);if(p&&p.options&&p.options.ref){let d;if(typeof p.options.ref=="function"?d=p.options.ref(N):typeof p.options.ref=="string"&&(d=p.options.ref),d){const b=P(d);t.models[b]&&(c=t.models[b])}}}if(c===a){const f=(s=(y=r==null?void 0:r.schema)==null?void 0:y.statics)!=null?s:{},p=((r==null?void 0:r._virtualConfigs)||f._dynamicVirtuals||[]).find(d=>d.name===u);if(p&&p.options&&p.options.ref){let d;if(typeof p.options.ref=="function"?d=p.options.ref(N):typeof p.options.ref=="string"&&(d=p.options.ref),d){const b=P(d);t.models[b]&&(c=t.models[b])}}}if(Array.isArray(O))for(const f of O)f&&typeof f=="object"&&(yield V(t,f,S,o,u,c));else O&&typeof O=="object"&&(yield V(t,O,S,o,u,c))}}})}function X(t,i,e,o,r){return R(this,null,function*(){const{path:n,populate:l}=e;if(!n)return;if(!l){yield C(t,i,n,o,r);return}const y=n;for(const s of i){const h=s,u=h[y];let S=r;if(r&&r.schema&&r.schema.virtuals){const m=r.schema.virtuals[y];if(m&&m.options&&m.options.ref){let N;if(typeof m.options.ref=="function"?N=m.options.ref(h):typeof m.options.ref=="string"&&(N=m.options.ref),N){const O=P(N);t.models[O]&&(S=t.models[O])}}}if(!S&&typeof u=="object"&&u&&"entityType"in u){const m=P(String(u.entityType));t.models[m]&&(S=t.models[m])}if(u&&typeof u=="object")if(Array.isArray(u))for(const m of u)m&&typeof m=="object"&&(yield x(t,[m],l,o,S));else u&&typeof u=="object"&&(yield x(t,[u],l,o,S))}})}function G(t,i,e,o){if(!e||!i||!i.schema)return;const r=e.split(".");let n=i.schema;for(let l=0;l<r.length;l++){const y=r[l];if(n&&n.virtuals&&y){const s=n.virtuals[y];if(s&&s.options&&s.options.ref){let h;if(typeof s.options.ref=="function"?h=s.options.ref(o):typeof s.options.ref=="string"&&(h=s.options.ref),h&&typeof h=="string"){if(l===r.length-1)return h;const u=t.models[h];if(u&&u.schema){n=u.schema;continue}}}}if(n&&n.paths&&y){const s=n.paths[y];if(s&&s.schema){n=s.schema;continue}}return}}function Y(t,i){if(i)for(const e of Object.keys(t.models)){const o=t.models[e],r=o==null?void 0:o.schema;if(r&&(r.paths&&r.paths[i]||r.virtuals&&r.virtuals[i]))return o}}function Z(t,i){const e=(i||"").split(".")[0]||"";if(e)for(const o of Object.keys(t.models)){const r=t.models[o],n=r==null?void 0:r.schema;if(n&&(n.paths&&n.paths[e]||n.virtuals&&n.virtuals[e]))return r}}function V(t,i,e,o,r,n){return R(this,null,function*(){var l,y;let s=i.__t;if(!s){if(n){const c=r?`${r}.${e}`:e,a=(c||"").split(".")[0]||"";let f=n;if(!!!((l=f==null?void 0:f.schema)!=null&&l.paths&&f.schema.paths[a]||(y=f==null?void 0:f.schema)!=null&&y.virtuals&&f.schema.virtuals[a])){const d=Z(t,c);d&&(f=d)}const p=G(t,f,c,i);if(p)s=p;else{const d=(c.includes(".")?c.split(".").pop():c)||"";if(d){const b=Y(t,d);if(b){const j=G(t,b,c,i);j&&(s=j)}}}}if(o&&o.length>0){const c=e.split(".").pop()||"",a=o.find(f=>f.name===c);if(a&&a.options.ref){let f;typeof a.options.ref=="function"?f=a.options.ref(i):typeof a.options.ref=="string"&&(f=a.options.ref),f&&typeof f=="string"&&(s=f)}}if(!s){for(const[c,a]of Object.entries(i))if(c==="entityType"&&typeof a=="string"){s=a;break}if(s&&t.models[s]){const c=t.models[s];if(c&&c.schema){const a=c.schema,f=e.split(".").pop()||"",g=(d,b="root")=>{if(!d||!d.virtuals)return;const j=d.virtuals;for(const _ of Object.keys(j))if(_===f){const v=j[_];if(v&&v.options&&v.options.ref){let A;if(typeof v.options.ref=="function"?A=v.options.ref(i):typeof v.options.ref=="string"&&(A=v.options.ref),A&&typeof A=="string")return A}}if(d.paths)for(const _ of Object.keys(d.paths)){const v=d.paths[_];if(v&&v.schema){const A=g(v.schema,`${b}.${_}`);if(A)return A}}},p=g(a);p&&(s=p)}}}if(!s){const c=e.split(".").pop()||"";if(n&&n.schema){const a=n.schema,f=(p,d="root")=>{if(!p||!p.virtuals)return;const b=p.virtuals;for(const j of Object.keys(b))if(j===c){const _=b[j];if(_&&_.options&&_.options.ref){let v;if(typeof _.options.ref=="function"?v=_.options.ref(i):typeof _.options.ref=="string"&&(v=_.options.ref),v&&typeof v=="string")return v}}if(p.paths)for(const j of Object.keys(p.paths)){const _=p.paths[j];if(_&&_.schema){const v=f(_.schema,`${d}.${j}`);if(v)return v}}},g=f(a);g&&(s=g)}if(!s&&n){const a=G(t,n,e,i);a&&(s=a)}if(!s&&o&&o.length>0){const a=o.find(f=>f.name===c);if(a&&a.options.ref){let f;typeof a.options.ref=="function"?f=a.options.ref(i):typeof a.options.ref=="string"&&(f=a.options.ref),f&&typeof f=="string"&&(s=f)}}}if(!s){const c=e.split(".").pop()||"",a=c?c.charAt(0).toUpperCase()+c.slice(1):"";a&&t.models[a]&&(s=a)}}const h=t.models[s];if(!h)return;const u=`${e}Id`,S=`${e}Ids`,m=i[u]||i[S]||i[e];if(!m)return;const N=Array.isArray(m)?m:[m],O=yield h.find({id:{$in:N}}).lean();O.length>0&&(Array.isArray(m)?i[e]=O:i[e]=O[0])})}exports.applyNestedPopulate=x;exports.convertEnumToModelName=P;exports.mongo=I;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("migrate-mongo"),k=require("mongoose-aggregate-paginate-v2"),B=require("mongoose-paginate-v2"),q=require("node:crypto"),E=require("../../util/object/object.util.cjs"),J=require("../../util/common/common.util.cjs"),$=require("../fs/fs.util.cjs"),I=require("../path/path.constant.cjs"),H=require("../../util/validate/validate.util.cjs");var K=Object.defineProperty,L=Object.defineProperties,T=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,z=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,G=(t,e,i)=>e in t?K(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,W=(t,e)=>{for(var i in e||(e={}))z.call(e,i)&&G(t,i,e[i]);if(D)for(var i of D(e))Q.call(e,i)&&G(t,i,e[i]);return t},X=(t,e)=>L(t,T(e)),R=(t,e,i)=>new Promise((o,r)=>{var n=s=>{try{y(i.next(s))}catch(h){r(h)}},l=s=>{try{y(i.throw(s))}catch(h){r(h)}},y=s=>s.done?o(s.value):Promise.resolve(s.value).then(n,l);y((i=i.apply(t,e)).next())});function P(t){return t===t.toUpperCase()?t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():t}const A={createGenericFields(){return{id:q.randomUUID(),isDel:!1,createdAt:new Date,updatedAt:new Date}},applyPlugins(t,e){e.filter(i=>typeof i=="function").forEach(i=>t.plugin(i))},applyMiddlewares(t,e){e.forEach(({method:i,pre:o,post:r})=>{i&&o&&t.pre(i,o),i&&r&&t.post(i,r)})},createGenericSchema(t){return new t.Schema({id:{type:String,default:()=>q.randomUUID(),unique:!0},isDel:{type:Boolean,default:!1}},{timestamps:!0})},createSchema({mongoose:t,schema:e,virtuals:i=[],standalone:o=!1}){const r=new t.Schema(e,{toJSON:{virtuals:!0},toObject:{virtuals:!0}});return i.forEach(({name:n,options:l,get:y})=>{if(A.isDynamicVirtual(l)){const s=r.statics;s._dynamicVirtuals||(s._dynamicVirtuals=[]),s._dynamicVirtuals.push({name:n,options:l});const h=r.virtual(n);y?h.get(y):h.get(function(){var u;return((u=this._populated)==null?void 0:u[n])||(l!=null&&l.count?0:l!=null&&l.justOne?null:[])})}else{const s=r.virtual(n,l);y&&s.get(y)}}),o||r.add(A.createGenericSchema(t)),r},createModel({mongoose:t,name:e,schema:i,virtuals:o=[],pagination:r=!0,aggregate:n=!0,middlewares:l=[]}){if(!e)throw new Error("Model name is required.");if(t.models[e])return t.models[e];const y=A.createSchema({mongoose:t,schema:i,virtuals:o});(r||n)&&A.applyPlugins(y,[r&&B,n&&k]),A.applyMiddlewares(y,l);const s=t.model(e,y);return o.length>0&&(s._virtualConfigs=o),s},validator:{isRequired(){return function(t){return R(this,null,function*(){return!H.validate.isEmpty(t)})}},isUnique(t){return function(e){return R(this,null,function*(){if(!Array.isArray(t)||t.length===0)throw new Error("Fields must be a non-empty array of strings.");const i={$or:t.map(r=>({[r]:e}))};return!(yield this.constructor.exists(i))})}},matchesRegex(t){return e=>R(null,null,function*(){if(!Array.isArray(t)||t.some(i=>!(i instanceof RegExp)))throw new Error("regexArray must be an array of valid RegExp objects.");return t.every(i=>i.test(e))})}},migrate:X(W({},C),{setConfig:t=>{const e=`// This file is automatically generated by the Cyberskill CLI.
|
|
2
|
+
module.exports = ${JSON.stringify(t,null,4)}`;$.writeFileSync(I.PATH.MIGRATE_MONGO_CONFIG,e),$.addGitIgnoreEntry(I.PATH.GIT_IGNORE,I.MIGRATE_MONGO_CONFIG)}}),regexify(t,e){if(!t)return{};let i=E.deepClone(t);if(!e||e.length===0)return i;for(const o of e){const r=o.toString().split("."),n=E.getNestedValue(i,r);if(typeof n=="string"&&n.length>0){const l={$regex:`.*${J.regexSearchMapper(n)}.*`,$options:"i"};i=E.setNestedValue(i,r,l)}}return i},isDynamicVirtual(t){return!!(t&&typeof t.ref=="function")},getNewRecords(t,e,i){return R(this,null,function*(){const o=yield t.findAll({});return o.success?e.filter(n=>!o.result.some(l=>i(l,n))):e})},getExistingRecords(t,e,i){return R(this,null,function*(){const o=yield t.findAll({});return o.success?o.result.filter(n=>e.some(l=>i(n,l))):[]})}};function x(t,e,i,o,r){return R(this,null,function*(){if(!e.length||!i)return e;const n=Array.isArray(i)?i:[i];for(const l of n)typeof l=="string"?yield U(t,e,l,o,r):l&&typeof l=="object"&&(yield Y(t,e,l,o,r));return e})}function U(t,e,i,o,r){return R(this,null,function*(){var n,l,y,s;const h=i.split(".");if(h.length<2){for(const m of e)yield V(t,m,i,o,void 0,r);return}const u=h[0];if(!u||u.trim()==="")return;const S=h.slice(1).join(".");for(const m of e){const j=m,b=j[u];if(b&&typeof b=="object"){let c=r;const a=c;if(r&&r.schema&&r.schema.virtuals){const f=r.schema.virtuals[u];if(f&&f.options&&f.options.ref){let O;if(typeof f.options.ref=="function"?O=f.options.ref(j):typeof f.options.ref=="string"&&(O=f.options.ref),O){const p=P(O);t.models[p]&&(c=t.models[p])}}}if(!c){const f=(l=(n=r==null?void 0:r.schema)==null?void 0:n.statics)!=null?l:{},p=((r==null?void 0:r._virtualConfigs)||f._dynamicVirtuals||[]).find(d=>d.name===u);if(p&&p.options&&p.options.ref){let d;if(typeof p.options.ref=="function"?d=p.options.ref(j):typeof p.options.ref=="string"&&(d=p.options.ref),d){const g=P(d);t.models[g]&&(c=t.models[g])}}}if(c===a){const f=(s=(y=r==null?void 0:r.schema)==null?void 0:y.statics)!=null?s:{},p=((r==null?void 0:r._virtualConfigs)||f._dynamicVirtuals||[]).find(d=>d.name===u);if(p&&p.options&&p.options.ref){let d;if(typeof p.options.ref=="function"?d=p.options.ref(j):typeof p.options.ref=="string"&&(d=p.options.ref),d){const g=P(d);t.models[g]&&(c=t.models[g])}}}if(Array.isArray(b))for(const f of b)f&&typeof f=="object"&&(yield V(t,f,S,o,u,c));else b&&typeof b=="object"&&(yield V(t,b,S,o,u,c))}}})}function Y(t,e,i,o,r){return R(this,null,function*(){const{path:n,populate:l}=i;if(!n)return;if(!l){yield U(t,e,n,o,r);return}const y=n;for(const s of e){const h=s,u=h[y];let S=r;if(r&&r.schema&&r.schema.virtuals){const m=r.schema.virtuals[y];if(m&&m.options&&m.options.ref){let j;if(typeof m.options.ref=="function"?j=m.options.ref(h):typeof m.options.ref=="string"&&(j=m.options.ref),j){const b=P(j);t.models[b]&&(S=t.models[b])}}}if(!S&&typeof u=="object"&&u&&"entityType"in u){const m=P(String(u.entityType));t.models[m]&&(S=t.models[m])}if(u&&typeof u=="object")if(Array.isArray(u))for(const m of u)m&&typeof m=="object"&&(yield x(t,[m],l,o,S));else u&&typeof u=="object"&&(yield x(t,[u],l,o,S))}})}function F(t,e,i,o){if(!i||!e||!e.schema)return;const r=i.split(".");let n=e.schema;for(let l=0;l<r.length;l++){const y=r[l];if(n&&n.virtuals&&y){const s=n.virtuals[y];if(s&&s.options&&s.options.ref){let h;if(typeof s.options.ref=="function"?h=s.options.ref(o):typeof s.options.ref=="string"&&(h=s.options.ref),h&&typeof h=="string"){if(l===r.length-1)return h;const u=t.models[h];if(u&&u.schema){n=u.schema;continue}}}}if(n&&n.paths&&y){const s=n.paths[y];if(s&&s.schema){n=s.schema;continue}}return}}function Z(t,e){if(e)for(const i of Object.keys(t.models)){const o=t.models[i],r=o==null?void 0:o.schema;if(r&&(r.paths&&r.paths[e]||r.virtuals&&r.virtuals[e]))return o}}function M(t,e){const i=(e||"").split(".")[0]||"";if(i)for(const o of Object.keys(t.models)){const r=t.models[o],n=r==null?void 0:r.schema;if(n&&(n.paths&&n.paths[i]||n.virtuals&&n.virtuals[i]))return r}}function V(t,e,i,o,r,n){return R(this,null,function*(){var l,y;let s=e.__t;if(!s){if(n){const c=r?`${r}.${i}`:i,a=(c||"").split(".")[0]||"";let f=n;if(!!!((l=f==null?void 0:f.schema)!=null&&l.paths&&f.schema.paths[a]||(y=f==null?void 0:f.schema)!=null&&y.virtuals&&f.schema.virtuals[a])){const d=M(t,c);d&&(f=d)}const p=F(t,f,c,e);if(p)s=p;else{const d=(c.includes(".")?c.split(".").pop():c)||"";if(d){const g=Z(t,d);if(g){const N=F(t,g,c,e);N&&(s=N)}}}}if(o&&o.length>0){const c=i.split(".").pop()||"",a=o.find(f=>f.name===c);if(a&&a.options.ref){let f;typeof a.options.ref=="function"?f=a.options.ref(e):typeof a.options.ref=="string"&&(f=a.options.ref),f&&typeof f=="string"&&(s=f)}}if(!s){for(const[c,a]of Object.entries(e))if(c==="entityType"&&typeof a=="string"){s=a;break}if(s&&t.models[s]){const c=t.models[s];if(c&&c.schema){const a=c.schema,f=i.split(".").pop()||"",O=(d,g="root")=>{if(!d||!d.virtuals)return;const N=d.virtuals;for(const _ of Object.keys(N))if(_===f){const v=N[_];if(v&&v.options&&v.options.ref){let w;if(typeof v.options.ref=="function"?w=v.options.ref(e):typeof v.options.ref=="string"&&(w=v.options.ref),w&&typeof w=="string")return w}}if(d.paths)for(const _ of Object.keys(d.paths)){const v=d.paths[_];if(v&&v.schema){const w=O(v.schema,`${g}.${_}`);if(w)return w}}},p=O(a);p&&(s=p)}}}if(!s){const c=i.split(".").pop()||"";if(n&&n.schema){const a=n.schema,f=(p,d="root")=>{if(!p||!p.virtuals)return;const g=p.virtuals;for(const N of Object.keys(g))if(N===c){const _=g[N];if(_&&_.options&&_.options.ref){let v;if(typeof _.options.ref=="function"?v=_.options.ref(e):typeof _.options.ref=="string"&&(v=_.options.ref),v&&typeof v=="string")return v}}if(p.paths)for(const N of Object.keys(p.paths)){const _=p.paths[N];if(_&&_.schema){const v=f(_.schema,`${d}.${N}`);if(v)return v}}},O=f(a);O&&(s=O)}if(!s&&n){const a=F(t,n,i,e);a&&(s=a)}if(!s&&o&&o.length>0){const a=o.find(f=>f.name===c);if(a&&a.options.ref){let f;typeof a.options.ref=="function"?f=a.options.ref(e):typeof a.options.ref=="string"&&(f=a.options.ref),f&&typeof f=="string"&&(s=f)}}}if(!s){const c=i.split(".").pop()||"",a=c?c.charAt(0).toUpperCase()+c.slice(1):"";a&&t.models[a]&&(s=a)}}const h=t.models[s];if(!h)return;const u=`${i}Id`,S=`${i}Ids`,m=e[u]||e[S]||e[i];if(!m)return;const j=Array.isArray(m)?m:[m],b=yield h.find({id:{$in:j}}).lean();b.length>0&&(Array.isArray(m)?e[i]=b:e[i]=b[0])})}exports.applyNestedPopulate=x;exports.convertEnumToModelName=P;exports.mongo=A;
|