@cyberskill/shared 3.0.0 → 3.2.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/commitlint/index.js +1 -0
- package/dist/config/commitlint/index.js.map +1 -0
- package/dist/config/config.type.js +1 -0
- package/dist/config/config.type.js.map +1 -0
- package/dist/config/config.util.js +4 -2
- package/dist/config/config.util.js.map +1 -0
- package/dist/config/env/env.constant.js +1 -0
- package/dist/config/env/env.constant.js.map +1 -0
- package/dist/config/env/env.util.js +1 -0
- package/dist/config/env/env.util.js.map +1 -0
- package/dist/config/env/index.js +1 -0
- package/dist/config/env/index.js.map +1 -0
- package/dist/config/eslint/index.js +1 -0
- package/dist/config/eslint/index.js.map +1 -0
- package/dist/config/graphql-codegen/graphql-codegen.util.js +1 -0
- package/dist/config/graphql-codegen/graphql-codegen.util.js.map +1 -0
- package/dist/config/graphql-codegen/index.js +1 -0
- package/dist/config/graphql-codegen/index.js.map +1 -0
- package/dist/config/index.js +1 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/lint-staged/index.js +1 -0
- package/dist/config/lint-staged/index.js.map +1 -0
- package/dist/config/storybook/index.js +1 -0
- package/dist/config/storybook/index.js.map +1 -0
- package/dist/config/storybook/storybook.main.js +1 -0
- package/dist/config/storybook/storybook.main.js.map +1 -0
- package/dist/config/storybook/storybook.preview.d.ts +1 -1
- package/dist/config/storybook/storybook.preview.js +6 -4
- package/dist/config/storybook/storybook.preview.js.map +1 -0
- package/dist/config/vitest/index.js +1 -0
- package/dist/config/vitest/index.js.map +1 -0
- package/dist/config/vitest/vitest.e2e.d.ts +2 -0
- package/dist/config/vitest/vitest.e2e.js +12 -18
- package/dist/config/vitest/vitest.e2e.js.map +1 -0
- package/dist/config/vitest/vitest.unit.d.ts +2 -0
- package/dist/config/vitest/vitest.unit.js +8 -5
- package/dist/config/vitest/vitest.unit.js.map +1 -0
- package/dist/constant/common.js +1 -0
- package/dist/constant/common.js.map +1 -0
- package/dist/constant/index.js +1 -0
- package/dist/constant/index.js.map +1 -0
- package/dist/constant/response-status.js +1 -0
- package/dist/constant/response-status.js.map +1 -0
- package/dist/node/apollo-server/apollo-server.util.js +1 -0
- package/dist/node/apollo-server/apollo-server.util.js.map +1 -0
- package/dist/node/apollo-server/index.js +1 -0
- package/dist/node/apollo-server/index.js.map +1 -0
- package/dist/node/cli/index.js +56 -45
- package/dist/node/cli/index.js.map +1 -0
- package/dist/node/command/command.type.js +1 -0
- package/dist/node/command/command.type.js.map +1 -0
- package/dist/node/command/command.util.js +107 -99
- package/dist/node/command/command.util.js.map +1 -0
- package/dist/node/command/index.js +1 -0
- package/dist/node/command/index.js.map +1 -0
- package/dist/node/express/express.type.d.ts +4 -0
- package/dist/node/express/express.util.js +49 -31
- package/dist/node/express/express.util.js.map +1 -0
- package/dist/node/express/index.js +1 -0
- package/dist/node/express/index.js.map +1 -0
- package/dist/node/fs/fs.util.js +1 -0
- package/dist/node/fs/fs.util.js.map +1 -0
- package/dist/node/fs/index.js +1 -0
- package/dist/node/fs/index.js.map +1 -0
- package/dist/node/log/index.js +1 -0
- package/dist/node/log/index.js.map +1 -0
- package/dist/node/log/log.type.js +1 -0
- package/dist/node/log/log.type.js.map +1 -0
- package/dist/node/log/log.util.js +1 -0
- package/dist/node/log/log.util.js.map +1 -0
- package/dist/node/mongo/index.d.ts +2 -0
- package/dist/node/mongo/index.js +21 -12
- package/dist/node/mongo/index.js.map +1 -0
- package/dist/node/mongo/mongo.constant.js +1 -0
- package/dist/node/mongo/mongo.constant.js.map +1 -0
- package/dist/node/mongo/mongo.controller.d.ts +5 -315
- package/dist/node/mongo/mongo.controller.mongoose.d.ts +234 -0
- package/dist/node/mongo/mongo.controller.mongoose.js +468 -0
- package/dist/node/mongo/mongo.controller.mongoose.js.map +1 -0
- package/dist/node/mongo/mongo.controller.native.d.ts +84 -0
- package/dist/node/mongo/mongo.controller.native.js +214 -0
- package/dist/node/mongo/mongo.controller.native.js.map +1 -0
- package/dist/node/mongo/mongo.dynamic-populate.d.ts +61 -0
- package/dist/node/mongo/mongo.dynamic-populate.js +197 -0
- package/dist/node/mongo/mongo.dynamic-populate.js.map +1 -0
- package/dist/node/mongo/mongo.populate.d.ts +15 -0
- package/dist/node/mongo/mongo.populate.js +269 -0
- package/dist/node/mongo/mongo.populate.js.map +1 -0
- package/dist/node/mongo/mongo.type.js +1 -0
- package/dist/node/mongo/mongo.type.js.map +1 -0
- package/dist/node/mongo/mongo.util.d.ts +52 -0
- package/dist/node/mongo/mongo.util.js +106 -363
- package/dist/node/mongo/mongo.util.js.map +1 -0
- package/dist/node/package/index.js +1 -0
- package/dist/node/package/index.js.map +1 -0
- package/dist/node/package/package.type.js +1 -0
- package/dist/node/package/package.type.js.map +1 -0
- package/dist/node/package/package.util.js +20 -20
- package/dist/node/package/package.util.js.map +1 -0
- package/dist/node/path/index.js +1 -0
- package/dist/node/path/index.js.map +1 -0
- package/dist/node/path/path.constant.js +10 -9
- package/dist/node/path/path.constant.js.map +1 -0
- package/dist/node/path/path.util.js +1 -0
- package/dist/node/path/path.util.js.map +1 -0
- package/dist/node/storage/index.js +1 -0
- package/dist/node/storage/index.js.map +1 -0
- package/dist/node/storage/storage.constant.js +1 -0
- package/dist/node/storage/storage.constant.js.map +1 -0
- package/dist/node/storage/storage.util.js +1 -0
- package/dist/node/storage/storage.util.js.map +1 -0
- package/dist/node/upload/index.js +1 -0
- package/dist/node/upload/index.js.map +1 -0
- package/dist/node/upload/upload.constant.js +1 -0
- package/dist/node/upload/upload.constant.js.map +1 -0
- package/dist/node/upload/upload.type.js +1 -0
- package/dist/node/upload/upload.type.js.map +1 -0
- package/dist/node/upload/upload.util.js +1 -0
- package/dist/node/upload/upload.util.js.map +1 -0
- package/dist/node/ws/index.d.ts +1 -1
- package/dist/node/ws/index.js +2 -1
- package/dist/node/ws/index.js.map +1 -0
- package/dist/node/ws/{ts.util.js → ws.util.js} +1 -0
- package/dist/node/ws/ws.util.js.map +1 -0
- package/dist/node_modules/.pnpm/{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 → vitest@4.0.18_@types_node@25.3.5_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 +1 -0
- package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.5_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.map +1 -0
- package/dist/react/apollo-client/apollo-client.component.js +1 -0
- package/dist/react/apollo-client/apollo-client.component.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.constant.js +1 -0
- package/dist/react/apollo-client/apollo-client.constant.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.context.js +1 -0
- package/dist/react/apollo-client/apollo-client.context.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.module.scss.js +1 -0
- package/dist/react/apollo-client/apollo-client.module.scss.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.util.js +14 -13
- package/dist/react/apollo-client/apollo-client.util.js.map +1 -0
- package/dist/react/apollo-client/index.js +1 -0
- package/dist/react/apollo-client/index.js.map +1 -0
- package/dist/react/apollo-client/links/index.js +1 -0
- package/dist/react/apollo-client/links/index.js.map +1 -0
- package/dist/react/apollo-client/links/upload.js +1 -0
- package/dist/react/apollo-client/links/upload.js.map +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js.map +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js.map +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +1 -0
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js.map +1 -0
- package/dist/react/apollo-client-nextjs/index.js +1 -0
- package/dist/react/apollo-client-nextjs/index.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.component.js +23 -21
- package/dist/react/apollo-error/apollo-error.component.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.context.js +1 -0
- package/dist/react/apollo-error/apollo-error.context.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.hook.js +1 -0
- package/dist/react/apollo-error/apollo-error.hook.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.module.scss.js +1 -0
- package/dist/react/apollo-error/apollo-error.module.scss.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.provider.js +1 -0
- package/dist/react/apollo-error/apollo-error.provider.js.map +1 -0
- package/dist/react/apollo-error/apollo-error.util.js +1 -0
- package/dist/react/apollo-error/apollo-error.util.js.map +1 -0
- package/dist/react/apollo-error/index.js +1 -0
- package/dist/react/apollo-error/index.js.map +1 -0
- package/dist/react/i18next/i18next.hook.js +1 -0
- package/dist/react/i18next/i18next.hook.js.map +1 -0
- package/dist/react/i18next/i18next.util.js +1 -0
- package/dist/react/i18next/i18next.util.js.map +1 -0
- package/dist/react/i18next/index.js +1 -0
- package/dist/react/i18next/index.js.map +1 -0
- package/dist/react/loading/index.js +1 -0
- package/dist/react/loading/index.js.map +1 -0
- package/dist/react/loading/loading.component.js +1 -0
- package/dist/react/loading/loading.component.js.map +1 -0
- package/dist/react/loading/loading.context.js +1 -0
- package/dist/react/loading/loading.context.js.map +1 -0
- package/dist/react/loading/loading.hook.js +1 -0
- package/dist/react/loading/loading.hook.js.map +1 -0
- package/dist/react/loading/loading.module.scss.js +1 -0
- package/dist/react/loading/loading.module.scss.js.map +1 -0
- package/dist/react/loading/loading.provider.js +1 -0
- package/dist/react/loading/loading.provider.js.map +1 -0
- package/dist/react/log/index.js +1 -0
- package/dist/react/log/index.js.map +1 -0
- package/dist/react/log/log.util.js +1 -0
- package/dist/react/log/log.util.js.map +1 -0
- package/dist/react/next-intl/index.js +1 -0
- package/dist/react/next-intl/index.js.map +1 -0
- package/dist/react/next-intl/next-intl.constant.js +1 -0
- package/dist/react/next-intl/next-intl.constant.js.map +1 -0
- package/dist/react/next-intl/next-intl.context.js +1 -0
- package/dist/react/next-intl/next-intl.context.js.map +1 -0
- package/dist/react/next-intl/next-intl.hoc.js +1 -0
- package/dist/react/next-intl/next-intl.hoc.js.map +1 -0
- package/dist/react/next-intl/next-intl.hook.js +1 -0
- package/dist/react/next-intl/next-intl.hook.js.map +1 -0
- package/dist/react/next-intl/next-intl.provider.js +1 -0
- package/dist/react/next-intl/next-intl.provider.js.map +1 -0
- package/dist/react/storage/index.js +1 -0
- package/dist/react/storage/index.js.map +1 -0
- package/dist/react/storage/storage.hook.js +1 -0
- package/dist/react/storage/storage.hook.js.map +1 -0
- package/dist/react/storage/storage.util.js +1 -0
- package/dist/react/storage/storage.util.js.map +1 -0
- package/dist/react/toast/index.js +1 -0
- package/dist/react/toast/index.js.map +1 -0
- package/dist/react/userback/index.js +1 -0
- package/dist/react/userback/index.js.map +1 -0
- package/dist/react/userback/userback.component.js +1 -0
- package/dist/react/userback/userback.component.js.map +1 -0
- package/dist/typescript/common.type.js +1 -0
- package/dist/typescript/common.type.js.map +1 -0
- package/dist/typescript/index.js +1 -0
- package/dist/typescript/index.js.map +1 -0
- package/dist/util/common/common.util.js +27 -25
- package/dist/util/common/common.util.js.map +1 -0
- package/dist/util/common/index.js +1 -0
- package/dist/util/common/index.js.map +1 -0
- package/dist/util/index.js +1 -0
- package/dist/util/index.js.map +1 -0
- package/dist/util/object/index.js +1 -0
- package/dist/util/object/index.js.map +1 -0
- package/dist/util/object/object.util.js +50 -49
- package/dist/util/object/object.util.js.map +1 -0
- package/dist/util/serializer/index.js +1 -0
- package/dist/util/serializer/index.js.map +1 -0
- package/dist/util/serializer/serializer.util.js +13 -12
- package/dist/util/serializer/serializer.util.js.map +1 -0
- package/dist/util/string/index.js +1 -0
- package/dist/util/string/index.js.map +1 -0
- package/dist/util/string/string.util.js +30 -28
- package/dist/util/string/string.util.js.map +1 -0
- package/dist/util/validate/index.js +1 -0
- package/dist/util/validate/index.js.map +1 -0
- package/dist/util/validate/validate.util.d.ts +0 -4
- package/dist/util/validate/validate.util.js +4 -3
- package/dist/util/validate/validate.util.js.map +1 -0
- package/package.json +68 -95
- package/public/tsconfig.base.json +1 -1
- package/dist/config/commitlint/index.cjs +0 -1
- package/dist/config/config.type.cjs +0 -1
- package/dist/config/config.util.cjs +0 -1
- package/dist/config/env/env.constant.cjs +0 -1
- package/dist/config/env/env.util.cjs +0 -1
- package/dist/config/env/index.cjs +0 -1
- package/dist/config/eslint/index.cjs +0 -1
- package/dist/config/graphql-codegen/graphql-codegen.util.cjs +0 -1
- package/dist/config/graphql-codegen/index.cjs +0 -1
- package/dist/config/index.cjs +0 -1
- package/dist/config/lint-staged/index.cjs +0 -1
- package/dist/config/storybook/index.cjs +0 -1
- package/dist/config/storybook/storybook.main.cjs +0 -1
- package/dist/config/storybook/storybook.preview.cjs +0 -1
- package/dist/config/vitest/index.cjs +0 -1
- package/dist/config/vitest/vitest.e2e.cjs +0 -1
- package/dist/config/vitest/vitest.unit.cjs +0 -1
- package/dist/constant/common.cjs +0 -1
- package/dist/constant/index.cjs +0 -1
- package/dist/constant/response-status.cjs +0 -1
- package/dist/node/apollo-server/apollo-server.util.cjs +0 -1
- package/dist/node/apollo-server/index.cjs +0 -1
- package/dist/node/cli/index.cjs +0 -3
- package/dist/node/command/command.type.cjs +0 -1
- package/dist/node/command/command.util.cjs +0 -2
- package/dist/node/command/index.cjs +0 -1
- package/dist/node/express/express.util.cjs +0 -1
- package/dist/node/express/index.cjs +0 -1
- package/dist/node/fs/fs.util.cjs +0 -4
- package/dist/node/fs/index.cjs +0 -1
- package/dist/node/log/index.cjs +0 -1
- package/dist/node/log/log.type.cjs +0 -1
- package/dist/node/log/log.util.cjs +0 -1
- package/dist/node/mongo/index.cjs +0 -1
- package/dist/node/mongo/mongo.constant.cjs +0 -1
- package/dist/node/mongo/mongo.controller.cjs +0 -1
- package/dist/node/mongo/mongo.controller.js +0 -858
- package/dist/node/mongo/mongo.controller.test.unit.d.ts +0 -1
- package/dist/node/mongo/mongo.type.cjs +0 -1
- package/dist/node/mongo/mongo.util.cjs +0 -2
- package/dist/node/mongo/mongo.util.test.unit.d.ts +0 -1
- package/dist/node/package/index.cjs +0 -1
- package/dist/node/package/package.type.cjs +0 -1
- package/dist/node/package/package.util.cjs +0 -1
- package/dist/node/path/index.cjs +0 -1
- package/dist/node/path/path.constant.cjs +0 -1
- package/dist/node/path/path.test.unit.d.ts +0 -1
- package/dist/node/path/path.util.cjs +0 -1
- package/dist/node/storage/index.cjs +0 -1
- package/dist/node/storage/storage.constant.cjs +0 -1
- package/dist/node/storage/storage.util.cjs +0 -1
- package/dist/node/upload/index.cjs +0 -1
- package/dist/node/upload/upload.constant.cjs +0 -1
- package/dist/node/upload/upload.type.cjs +0 -1
- package/dist/node/upload/upload.util.cjs +0 -1
- package/dist/node/ws/index.cjs +0 -1
- package/dist/node/ws/ts.util.cjs +0 -1
- package/dist/node_modules/.pnpm/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 -1
- package/dist/react/apollo-client/apollo-client.component.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.constant.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.context.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.module.scss.cjs +0 -1
- package/dist/react/apollo-client/apollo-client.util.cjs +0 -1
- package/dist/react/apollo-client/index.cjs +0 -1
- package/dist/react/apollo-client/links/index.cjs +0 -1
- package/dist/react/apollo-client/links/upload.cjs +0 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.cjs +0 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.cjs +0 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.cjs +0 -1
- package/dist/react/apollo-client-nextjs/index.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.component.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.context.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.hook.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.module.scss.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.provider.cjs +0 -1
- package/dist/react/apollo-error/apollo-error.test.unit.d.ts +0 -1
- package/dist/react/apollo-error/apollo-error.util.cjs +0 -1
- package/dist/react/apollo-error/index.cjs +0 -1
- package/dist/react/i18next/i18next.hook.cjs +0 -1
- package/dist/react/i18next/i18next.util.cjs +0 -1
- package/dist/react/i18next/index.cjs +0 -1
- package/dist/react/loading/index.cjs +0 -1
- package/dist/react/loading/loading.component.cjs +0 -6
- package/dist/react/loading/loading.context.cjs +0 -1
- package/dist/react/loading/loading.hook.cjs +0 -1
- package/dist/react/loading/loading.module.scss.cjs +0 -1
- package/dist/react/loading/loading.provider.cjs +0 -1
- package/dist/react/loading/loading.test.unit.d.ts +0 -1
- package/dist/react/log/index.cjs +0 -1
- package/dist/react/log/log.util.cjs +0 -1
- package/dist/react/next-intl/index.cjs +0 -1
- package/dist/react/next-intl/next-intl.constant.cjs +0 -1
- package/dist/react/next-intl/next-intl.context.cjs +0 -1
- package/dist/react/next-intl/next-intl.hoc.cjs +0 -1
- package/dist/react/next-intl/next-intl.hook.cjs +0 -1
- package/dist/react/next-intl/next-intl.provider.cjs +0 -1
- package/dist/react/storage/index.cjs +0 -1
- package/dist/react/storage/storage.hook.cjs +0 -1
- package/dist/react/storage/storage.util.cjs +0 -1
- package/dist/react/toast/index.cjs +0 -1
- package/dist/react/userback/index.cjs +0 -1
- package/dist/react/userback/userback.component.cjs +0 -1
- package/dist/typescript/common.type.cjs +0 -1
- package/dist/typescript/index.cjs +0 -1
- package/dist/util/common/common.test.unit.d.ts +0 -1
- package/dist/util/common/common.util.cjs +0 -1
- package/dist/util/common/index.cjs +0 -1
- package/dist/util/index.cjs +0 -1
- package/dist/util/object/index.cjs +0 -1
- package/dist/util/object/object.test.unit.d.ts +0 -1
- package/dist/util/object/object.util.cjs +0 -1
- package/dist/util/serializer/index.cjs +0 -1
- package/dist/util/serializer/serializer.test.unit.d.ts +0 -1
- package/dist/util/serializer/serializer.util.cjs +0 -1
- package/dist/util/string/index.cjs +0 -1
- package/dist/util/string/string.test.unit.d.ts +0 -1
- package/dist/util/string/string.util.cjs +0 -1
- package/dist/util/validate/index.cjs +0 -1
- package/dist/util/validate/validate.test.unit.d.ts +0 -1
- package/dist/util/validate/validate.util.cjs +0 -1
- /package/dist/node/ws/{ts.util.d.ts → ws.util.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/node/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport process from 'node:process';\nimport { hideBin } from 'yargs/helpers';\nimport yargs from 'yargs/yargs';\n\nimport type { I_IssueEntry } from '../log/index.js';\n\nimport { clearAllErrorLists, getStoredErrorLists, resolveCommands, runCommand } from '../command/index.js';\nimport { addGitIgnoreEntry, pathExistsSync, readFileSync, removeSync, writeFileSync } from '../fs/index.js';\nimport { catchError, E_IssueType, log } from '../log/index.js';\nimport { getPackage, installDependencies } from '../package/index.js';\nimport { AG_KIT_PACKAGE_NAME, command, createGitHooksConfig, CYBERSKILL_CLI, CYBERSKILL_PACKAGE_NAME, DOT_AGENT, PATH, resolve, SIMPLE_GIT_HOOK_JSON } from '../path/index.js';\n\n/**\n * Retrieves the version from the package.json file.\n * This function reads the package.json file and extracts the version number.\n * If the file cannot be read or parsed, it returns a default version of '1.0.0'.\n *\n * @returns The version string from package.json or '1.0.0' as fallback.\n */\nfunction getVersion(): string {\n try {\n const pkg = JSON.parse(\n readFileSync(resolve(__dirname, '../../../package.json'), 'utf-8'),\n );\n return pkg.version;\n }\n catch {\n return '1.0.0';\n }\n}\n\n/**\n * Performs TypeScript validation if a TypeScript configuration file exists.\n * This function checks for the presence of a TypeScript configuration file\n * and runs TypeScript validation if found. If no configuration is found,\n * it logs a warning and skips the type check.\n *\n * @returns A promise that resolves when the TypeScript validation is complete.\n */\nasync function checkTypescript() {\n if (pathExistsSync(PATH.TS_CONFIG)) {\n await runCommand('Performing TypeScript validation', await command.typescriptCheck());\n }\n else {\n log.warn('No TypeScript configuration found. Skipping type check.');\n }\n}\n\n/**\n * Performs ESLint checking with optional auto-fix functionality.\n * This function runs ESLint checks on the codebase and optionally applies\n * automatic fixes to resolve linting issues.\n *\n * @param fix - Whether to apply automatic fixes to linting issues (default: false).\n * @returns A promise that resolves when the ESLint check is complete.\n */\nasync function checkEslint(fix = false) {\n const commandToRun = fix ? await command.eslintFix() : await command.eslintCheck();\n const label = fix ? 'Running ESLint with auto-fix' : 'Running ESLint check';\n\n try {\n await runCommand(label, commandToRun, { timeout: 60000, throwOnError: true });\n }\n catch (error: any) {\n if (error.code === 'ETIMEDOUT' || error.killed || error.signal === 'SIGTERM') {\n log.warn('Lint check timed out. Retrying with debug mode enabled...');\n process.env['DEBUG'] = 'true';\n await runCommand(`${label} (Debug Mode)`, commandToRun);\n }\n else {\n catchError(error);\n }\n }\n}\n\n/**\n * Prints a formatted list of issues (errors or warnings) to the console.\n * This function displays issues in a boxed format with appropriate color coding\n * based on the issue type. It only displays issues if the list is not empty.\n *\n * @param type - The type of issues to display ('Errors' or 'Warnings').\n * @param list - An array of issue entries to display.\n */\nfunction printIssues(type: 'Errors' | 'Warnings', list: I_IssueEntry[]) {\n if (!list.length) {\n return;\n }\n\n const color = type === 'Errors' ? 'red' : 'yellow';\n log.printBoxedLog(type === 'Errors' ? '✖ Errors' : '⚠ Warnings', list, color);\n}\n\n/**\n * Displays the final check results after all validation processes.\n * This function retrieves stored error lists and displays them in a formatted manner.\n * If no errors or warnings are found, it displays a success message. If errors are found,\n * it exits the process with code 1 to indicate failure.\n *\n * @returns A promise that resolves when the results are displayed.\n */\nasync function showCheckResult() {\n setTimeout(async () => {\n const allResults = (await getStoredErrorLists()) || [];\n const errors = allResults.filter(e => e.type === E_IssueType.Error);\n const warnings = allResults.filter(e => e.type === E_IssueType.Warning);\n\n if (!errors.length && !warnings.length) {\n log.printBoxedLog('✔ NO ISSUES FOUND', [], 'green');\n }\n else {\n printIssues('Warnings', warnings);\n printIssues('Errors', errors);\n\n if (errors.length > 0) {\n process.exit(1);\n }\n }\n }, 0);\n}\n\n/**\n * Executes lint-staged to check only staged files.\n * This function runs lint-staged which executes linting tools only on files\n * that are staged for commit. It includes building the package if it's the current project\n * and displays the results after completion.\n *\n * @returns A promise that resolves when lint-staged execution is complete.\n */\nasync function lintStaged() {\n await clearAllErrorLists();\n const packageData = await getPackage({ name: CYBERSKILL_PACKAGE_NAME });\n\n if (!packageData.success) {\n log.error('Failed to retrieve package information. Aborting lint-staged.');\n return;\n }\n\n if (packageData.result.isCurrentProject) {\n await runCommand(`Building package: ${CYBERSKILL_PACKAGE_NAME}`, await command.build());\n }\n\n await runCommand('Executing lint-staged', await command.lintStaged());\n showCheckResult();\n}\n\n/**\n * Inspects the ESLint configuration to show active rules and settings.\n * This function runs ESLint inspection to display the current configuration,\n * including which rules are active and their settings.\n *\n * @returns A promise that resolves when the ESLint inspection is complete.\n */\nasync function inspectLint() {\n await runCommand('Inspecting ESLint configuration', await command.eslintInspect());\n}\n\n/**\n * Performs comprehensive linting checks including TypeScript and ESLint.\n * This function runs both TypeScript validation and ESLint checks in parallel,\n * then displays the combined results.\n *\n * @returns A promise that resolves when all linting checks are complete.\n */\nasync function lintCheck() {\n await clearAllErrorLists();\n await checkTypescript();\n await checkEslint();\n showCheckResult();\n}\n\n/**\n * Performs comprehensive linting checks with automatic fixes.\n * This function runs both TypeScript validation and ESLint checks with auto-fix\n * in parallel, then displays the combined results.\n *\n * @returns A promise that resolves when all linting checks with fixes are complete.\n */\nasync function lintFix() {\n await clearAllErrorLists();\n await checkTypescript();\n await checkEslint(true);\n showCheckResult();\n}\n\n/**\n * Validates commit message format using commitlint.\n * This function runs commitlint to check if the current commit message\n * follows the conventional commit format and displays the results.\n *\n * @returns A promise that resolves when commit message validation is complete.\n */\nasync function commitLint() {\n await clearAllErrorLists();\n await runCommand('Validating commit message', await command.commitLint());\n showCheckResult();\n}\n\n/**\n * Sets up Git hooks for automated code quality checks.\n * This function configures Git hooks using simple-git-hooks, creates the necessary\n * configuration files, and updates .gitignore to exclude hook configuration files.\n * It also sets up the hooks to run linting and commit validation automatically.\n *\n * @returns A promise that resolves when Git hook setup is complete.\n */\nasync function gitHookSetup() {\n await runCommand('Configuring Git hooks', await command.configureGitHook());\n\n removeSync(PATH.GIT_HOOK);\n\n const hooks = await resolveCommands(createGitHooksConfig);\n\n writeFileSync(PATH.SIMPLE_GIT_HOOKS_JSON, JSON.stringify(hooks, null, 4));\n\n addGitIgnoreEntry(PATH.GIT_IGNORE, SIMPLE_GIT_HOOK_JSON);\n\n await runCommand('Setting up simple-git-hooks', await command.simpleGitHooks());\n}\n\n/**\n * Sets up the AI agent environment.\n * This function ensures the ag-kit package is installed globally, initializes\n * or updates the AI agent configuration, and adds the agent directory\n * to .gitignore to exclude it from version control.\n *\n * @returns A promise that resolves when the AI agent setup is complete.\n */\nasync function aiSetup() {\n try {\n await runCommand(`Checking for ${AG_KIT_PACKAGE_NAME}`, `pnpm list -g ${AG_KIT_PACKAGE_NAME}`);\n }\n catch {\n await runCommand(`Installing ${AG_KIT_PACKAGE_NAME} globally`, `pnpm i -g ${AG_KIT_PACKAGE_NAME}`);\n }\n\n if (pathExistsSync(PATH.DOT_AGENT)) {\n await runCommand('Updating AI agent', 'echo y | ag-kit update');\n }\n else {\n await runCommand('Initializing AI agent', 'ag-kit init');\n }\n\n addGitIgnoreEntry(PATH.GIT_EXCLUDE, DOT_AGENT);\n}\n\n/**\n * Initializes the project with dependencies and Git hooks.\n * This function installs project dependencies and sets up Git hooks for\n * automated code quality checks. It's typically run when setting up a new project.\n *\n * @returns A promise that resolves when project initialization is complete.\n */\nasync function ready() {\n await installDependencies();\n await gitHookSetup();\n}\n\n/**\n * Resets the project by removing dependencies and reinstalling them.\n * This function removes node_modules and lock files, cleans the package manager cache,\n * reinstalls dependencies, and sets up Git hooks. It's useful for resolving\n * dependency-related issues.\n *\n * @returns A promise that resolves when project reset is complete.\n */\nasync function reset() {\n removeSync(PATH.NODE_MODULES, PATH.PNPM_LOCK_YAML);\n await runCommand('Pruning pnpm store', await command.pnpmPruneStore());\n await runCommand('Clearing pnpm cache', await command.pnpmCleanCache());\n await installDependencies();\n await gitHookSetup();\n await aiSetup();\n}\n\n/**\n * Inspects project dependencies to analyze their status.\n * This function runs dependency inspection to check for outdated packages,\n * security vulnerabilities, and other dependency-related issues.\n *\n * @returns A promise that resolves when dependency inspection is complete.\n */\nasync function inspect() {\n await runCommand('Inspecting project dependencies', await command.nodeModulesInspect());\n}\n\n/**\n * Runs the unit test suite.\n * This function executes unit tests using the configured test runner\n * and displays the test results.\n *\n * @returns A promise that resolves when unit tests are complete.\n */\nasync function testUnit() {\n try {\n const packageData = await getPackage({ name: CYBERSKILL_PACKAGE_NAME });\n const cmd = packageData.success && packageData.result.isCurrentProject\n ? `pnpm exec vitest run`\n : await command.testUnit();\n\n await runCommand('Running unit tests', cmd, { throwOnError: true });\n }\n catch {\n process.exit(1);\n }\n}\n\n/**\n * Runs the end-to-end test suite.\n * This function executes end-to-end tests using the configured test runner\n * and displays the test results.\n *\n * @returns A promise that resolves when end-to-end tests are complete.\n */\nasync function testE2E() {\n try {\n const packageData = await getPackage({ name: CYBERSKILL_PACKAGE_NAME });\n const cmd = packageData.success && packageData.result.isCurrentProject\n ? `pnpm exec vitest run --passWithNoTests --config src/config/vitest/vitest.e2e.ts`\n : await command.testE2e();\n\n await runCommand('Running end-to-end tests', cmd, { throwOnError: true });\n }\n catch {\n process.exit(1);\n }\n}\n\n/**\n * Creates a new MongoDB migration file.\n * This function creates a new migration file with the specified name\n * for database schema changes.\n *\n * @param migrationName - The name for the new migration file.\n * @returns A promise that resolves when the migration file is created.\n */\nasync function mongoMigrateCreate(migrationName: string) {\n await runCommand('Creating MongoDB migration', await command.mongoMigrateCreate(migrationName));\n}\n\n/**\n * Applies all pending MongoDB migrations.\n * This function runs all pending database migrations to update the database schema\n * to the latest version.\n *\n * @returns A promise that resolves when all migrations are applied.\n */\nasync function mongoMigrateUp() {\n await runCommand('Running MongoDB migrations', await command.mongoMigrateUp());\n}\n\n/**\n * Rolls back the last applied MongoDB migration.\n * This function reverts the most recent database migration, undoing\n * the last schema change.\n *\n * @returns A promise that resolves when the migration is rolled back.\n */\nasync function mongoMigrateDown() {\n await runCommand('Rolling back MongoDB migration', await command.mongoMigrateDown());\n}\n\n/**\n * Starts the Storybook development server.\n * This function runs Storybook in development mode, allowing you to\n * view and interact with your component stories in a browser.\n *\n * @returns A promise that resolves when the Storybook dev server is started.\n */\nasync function storybookDev() {\n await runCommand('Starting Storybook development server', await command.storybookDev());\n}\n\n/**\n * Builds Storybook for production deployment.\n * This function creates a static build of Storybook that can be\n * deployed to a web server or hosting service.\n *\n * @returns A promise that resolves when the Storybook build is complete.\n */\nasync function storybookBuild() {\n await runCommand('Building Storybook', await command.storybookBuild());\n}\n\n(async () => {\n try {\n await yargs(hideBin(process.argv))\n .scriptName(CYBERSKILL_CLI)\n .usage('$0 <command> [options]')\n .command('ai:setup', 'Setup AI agent environment', aiSetup)\n .command('lint', 'Check code for linting issues', lintCheck)\n .command('lint:fix', 'Fix linting issues automatically', lintFix)\n .command('lint:inspect', 'View active ESLint configuration', inspectLint)\n .command('lint-staged', 'Run lint checks on staged files', lintStaged)\n .command('commitlint', 'Validate commit message format', commitLint)\n .command('ready', 'Initialize project and dependencies', ready)\n .command('reset', 'Reset the project and reinstall dependencies', reset)\n .command('inspect', 'Analyze installed project dependencies', inspect)\n .command('test:unit', 'Run unit test suite', testUnit)\n .command('test:e2e', 'Run end-to-end test suite', testE2E)\n .command('mongo:migrate:create <name>', 'Create a MongoDB migration', y =>\n y.positional('name', {\n describe: 'Migration name',\n type: 'string',\n }), async (argv) => {\n if (!argv.name) {\n log.error('Migration name is required.');\n\n return;\n }\n\n await mongoMigrateCreate(argv.name);\n })\n .command('mongo:migrate:up', 'Apply all MongoDB migrations', mongoMigrateUp)\n .command('mongo:migrate:down', 'Rollback last MongoDB migration', mongoMigrateDown)\n .command('storybook:dev', 'Start Storybook development server', storybookDev)\n .command('storybook:build', 'Build Storybook for production', storybookBuild)\n .demandCommand(1, 'Please specify a valid command.')\n .strict()\n .help()\n .alias('h', 'help')\n .alias('v', 'version')\n .version(getVersion())\n .epilog('💡 Tip: Use \"--help\" with any command to see options\\n')\n .parse();\n }\n catch (error) {\n catchError(error);\n process.exit(1);\n }\n})();\n"],"names":["process","hideBin","yargs","runCommand","clearAllErrorLists","getStoredErrorLists","resolveCommands","getPackage","installDependencies","pathExistsSync","addGitIgnoreEntry","removeSync","readFileSync","writeFileSync","resolve","CYBERSKILL_CLI","command","CYBERSKILL_PACKAGE_NAME","PATH","SIMPLE_GIT_HOOK_JSON","createGitHooksConfig","AG_KIT_PACKAGE_NAME","DOT_AGENT","log","catchError","E_IssueType","getVersion","checkTypescript","checkEslint","fix","commandToRun","label","error","printIssues","type","list","color","showCheckResult","allResults","errors","warnings","lintStaged","packageData","inspectLint","lintCheck","lintFix","commitLint","gitHookSetup","hooks","aiSetup","ready","reset","inspect","testUnit","cmd","testE2E","mongoMigrateCreate","migrationName","mongoMigrateUp","mongoMigrateDown","storybookDev","storybookBuild","y","argv"],"mappings":";AAoBA,OAAAA,OAAA;AAAA,SAAA,WAAAC,SAAA;AAAA,OAAAC,OAAA;AAAA,SAAA,cAAAC,GAAA,sBAAAC,GAAA,uBAAAC,GAAA,mBAAAC,SAAA;AAAA,SAAA,cAAAC,GAAA,uBAAAC,SAAA;AAAA,SAAA,kBAAAC,GAAA,qBAAAC,GAAA,cAAAC,GAAA,gBAAAC,GAAA,iBAAAC,SAAA;AAAA,SAAA,WAAAC,SAAA;AAAA,SAAA,kBAAA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AAI,MAAM,6BAA6B;AAEvC;AAAA,MACJ;AAEA,YAAMiC,EAAmBO,EAAK,IAAI;AAAA,IACtC,CAAC,EACA,QAAQ,oBAAoB,gCAAgCL,CAAc,EAC1E,QAAQ,sBAAsB,mCAAmCC,CAAgB,EACjF,QAAQ,iBAAiB,sCAAsCC,CAAY,EAC3E,QAAQ,mBAAmB,kCAAkCC,CAAc,EAC3E,cAAc,GAAG,iCAAiC,EAClD,OAAA,EACA,OACA,MAAM,KAAK,MAAM,EACjB,MAAM,KAAK,SAAS,EACpB,QAAQnC,EAAA,CAAY,EACpB,OAAO;AAAA,CAAwD,EAC/D,MAAA;AAAA,EACT,SACOM,GAAO;AACV,IAAAR,EAAWQ,CAAK,GAChBhC,EAAQ,KAAK,CAAC;AAAA,EAClB;AACJ,GAAA;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.type.js","sources":["../../../src/node/command/command.type.ts"],"sourcesContent":["/**\n * Interface representing an ESLint error structure.\n */\nexport interface I_EslintError {\n filePath: string;\n messages: Array<{\n ruleId: string;\n severity: number;\n message: string;\n line: number;\n column: number;\n }>;\n}\n\n/**\n * Interface representing the command execution context.\n */\nexport interface I_CommandContext {\n isCurrentProject: boolean;\n}\n\n/**\n * Interface representing a command with raw flag and command string.\n */\nexport interface I_Command { raw: boolean; cmd: string }\n\n/**\n * Type for a function that generates a command string based on context.\n */\nexport type T_CommandFunction = (context?: I_CommandContext) => string;\n\n/**\n * Type for a command, which can be a string, function that returns a string, or a raw command object.\n */\nexport type T_Command = string | T_CommandFunction | I_Command;\n\n/**\n * Type for a command map input, which can be a record or a function returning a record.\n */\nexport type T_CommandMapInput = Record<string, T_Command> | ((context: I_CommandContext) => Record<string, T_Command>);\n\n/**\n * Enum for command types: CLI, STRING, or FUNCTION.\n */\nexport enum E_CommandType {\n CLI = 'CLI',\n STRING = 'STRING',\n FUNCTION = 'FUNCTION',\n}\n"],"names":["E_CommandType"],"mappings":"AA4CO,IAAKA,sBAAAA,OACRA,EAAA,MAAM,OACNA,EAAA,SAAS,UACTA,EAAA,WAAW,YAHHA,IAAAA,KAAA,CAAA,CAAA;"}
|
|
@@ -1,153 +1,161 @@
|
|
|
1
|
-
import { exec as x } from "node:child_process";
|
|
2
|
-
import
|
|
3
|
-
import * as
|
|
1
|
+
import { exec as x, execFile as I } from "node:child_process";
|
|
2
|
+
import m from "node:process";
|
|
3
|
+
import * as C from "node:util";
|
|
4
4
|
import { storage as g } from "../storage/storage.util.js";
|
|
5
5
|
import { getPackage as $ } from "../package/package.util.js";
|
|
6
|
-
import { CYBERSKILL_PACKAGE_NAME as
|
|
6
|
+
import { CYBERSKILL_PACKAGE_NAME as d, PNPM_EXEC_CLI as w, TSX_CLI as P, CYBERSKILL_CLI_PATH as S, CYBERSKILL_CLI as T } from "../path/path.constant.js";
|
|
7
7
|
import { E_IssueType as f } from "../log/log.type.js";
|
|
8
|
-
import { log as
|
|
9
|
-
import { getEnv as
|
|
10
|
-
const
|
|
11
|
-
async function
|
|
12
|
-
const
|
|
13
|
-
return
|
|
8
|
+
import { log as u, catchError as E } from "../log/log.util.js";
|
|
9
|
+
import { getEnv as _ } from "../../config/env/env.util.js";
|
|
10
|
+
const O = C.promisify(x), A = C.promisify(I), N = /[|&;<>`$(){}[\]!#~*?]/, M = /^\s*(\d+):(\d+)\s+(error|warning)\s+(.+)\s+(\S+)$/, k = /^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:\s+(\S.+)$/, B = /^✖\s+(.+)\s+\[([^\]]*)\]$/, v = /\s+/;
|
|
11
|
+
async function h() {
|
|
12
|
+
const t = await $();
|
|
13
|
+
return t.success ? t.result.name : Date.now().toString();
|
|
14
14
|
}
|
|
15
|
-
async function
|
|
16
|
-
if (
|
|
15
|
+
async function L(t) {
|
|
16
|
+
if (t.length === 0)
|
|
17
17
|
return;
|
|
18
|
-
const
|
|
18
|
+
const r = await h();
|
|
19
19
|
try {
|
|
20
|
-
const o = [...await
|
|
21
|
-
await g.set(
|
|
22
|
-
const
|
|
23
|
-
|
|
20
|
+
const o = [...await j(), ...t];
|
|
21
|
+
await g.set(r, o), setTimeout(async () => {
|
|
22
|
+
const e = await g.getLogLink(r);
|
|
23
|
+
e && u.info(`📂 Open the error list manually: ${e}`);
|
|
24
24
|
}, 0);
|
|
25
|
-
} catch (
|
|
26
|
-
|
|
25
|
+
} catch (s) {
|
|
26
|
+
E(s);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
async function
|
|
29
|
+
async function j() {
|
|
30
30
|
try {
|
|
31
|
-
const
|
|
32
|
-
return await g.get(
|
|
33
|
-
} catch (
|
|
34
|
-
return
|
|
31
|
+
const t = await h();
|
|
32
|
+
return await g.get(t) ?? [];
|
|
33
|
+
} catch (t) {
|
|
34
|
+
return E(t, {
|
|
35
35
|
returnValue: []
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
async function
|
|
39
|
+
async function V() {
|
|
40
40
|
try {
|
|
41
|
-
const
|
|
42
|
-
await g.remove(
|
|
43
|
-
} catch (
|
|
44
|
-
|
|
41
|
+
const t = await h();
|
|
42
|
+
await g.remove(t);
|
|
43
|
+
} catch (t) {
|
|
44
|
+
E(t);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
async function
|
|
48
|
-
const
|
|
47
|
+
async function D(t) {
|
|
48
|
+
const r = [], s = [];
|
|
49
49
|
let o = "";
|
|
50
|
-
const
|
|
51
|
-
|
|
50
|
+
const e = M, i = k, n = B;
|
|
51
|
+
t.split(`
|
|
52
52
|
`).forEach((a) => {
|
|
53
53
|
if (a.startsWith("/"))
|
|
54
54
|
o = a.trim();
|
|
55
55
|
else {
|
|
56
|
-
const
|
|
57
|
-
|
|
56
|
+
const c = e.exec(a) || [], l = i.exec(a) || [], p = n.exec(a) || [];
|
|
57
|
+
c.length && o ? r.push({
|
|
58
58
|
file: o,
|
|
59
|
-
position: `${
|
|
60
|
-
type:
|
|
61
|
-
message:
|
|
62
|
-
rule:
|
|
63
|
-
}) :
|
|
64
|
-
file:
|
|
65
|
-
position: `${
|
|
66
|
-
type:
|
|
67
|
-
message:
|
|
68
|
-
}) :
|
|
59
|
+
position: `${c[1]}:${c[2]}`,
|
|
60
|
+
type: c[3] === f.Error ? f.Error : f.Warning,
|
|
61
|
+
message: c?.[4]?.trim() ?? "",
|
|
62
|
+
rule: c?.[5]?.trim() ?? ""
|
|
63
|
+
}) : l.length ? r.push({
|
|
64
|
+
file: l?.[1] ?? "",
|
|
65
|
+
position: `${l[2]}:${l[3]}`,
|
|
66
|
+
type: l[4] === f.Error ? f.Error : f.Warning,
|
|
67
|
+
message: l?.[5]?.trim() ?? ""
|
|
68
|
+
}) : p.length ? r.push({
|
|
69
69
|
file: "commitlint",
|
|
70
70
|
type: f.Error,
|
|
71
|
-
message:
|
|
72
|
-
rule:
|
|
73
|
-
}) :
|
|
71
|
+
message: p?.[1]?.trim() ?? "",
|
|
72
|
+
rule: p?.[2]?.trim() ?? ""
|
|
73
|
+
}) : s.push(a.trim());
|
|
74
74
|
}
|
|
75
|
-
}),
|
|
75
|
+
}), r.length && await L(r), s.length && (u.warn("Unmatched lines:"), s.forEach((a) => u.info(` ${a}`)));
|
|
76
76
|
}
|
|
77
|
-
async function
|
|
77
|
+
async function R(t) {
|
|
78
78
|
try {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
type:
|
|
79
|
+
const r = JSON.parse(t), s = [];
|
|
80
|
+
r.forEach(({ filePath: o, messages: e }) => {
|
|
81
|
+
e.forEach(({ severity: i, line: n, column: a, ruleId: c, message: l }) => {
|
|
82
|
+
s.push({
|
|
83
|
+
type: i === 2 ? f.Error : f.Warning,
|
|
84
84
|
file: o,
|
|
85
|
-
position: `${
|
|
86
|
-
rule:
|
|
87
|
-
message:
|
|
85
|
+
position: `${n}:${a}`,
|
|
86
|
+
rule: c,
|
|
87
|
+
message: l
|
|
88
88
|
});
|
|
89
89
|
});
|
|
90
|
-
}),
|
|
90
|
+
}), s.length && await L(s);
|
|
91
91
|
} catch {
|
|
92
|
-
await
|
|
92
|
+
await D(t);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
async function
|
|
95
|
+
async function K(t, r = R, s = {}) {
|
|
96
96
|
const o = new AbortController();
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
m.on("SIGINT", () => {
|
|
98
|
+
u.warn("Process interrupted. Terminating..."), o.abort(), m.exit();
|
|
99
99
|
});
|
|
100
100
|
try {
|
|
101
|
-
if (typeof
|
|
102
|
-
const
|
|
103
|
-
maxBuffer:
|
|
101
|
+
if (typeof t == "string") {
|
|
102
|
+
const e = {
|
|
103
|
+
maxBuffer: 10485760,
|
|
104
104
|
signal: o.signal,
|
|
105
|
-
timeout:
|
|
106
|
-
}
|
|
107
|
-
|
|
105
|
+
timeout: s.timeout
|
|
106
|
+
};
|
|
107
|
+
let i;
|
|
108
|
+
if (N.test(t))
|
|
109
|
+
i = await O(t, e);
|
|
110
|
+
else {
|
|
111
|
+
const n = t.split(v).filter(Boolean);
|
|
112
|
+
i = await A(n[0], n.slice(1), e);
|
|
113
|
+
}
|
|
114
|
+
await Promise.all([i.stdout, i.stderr].map((n) => n && r(n)));
|
|
108
115
|
}
|
|
109
|
-
} catch (
|
|
110
|
-
const { stdout:
|
|
111
|
-
await Promise.all([
|
|
116
|
+
} catch (e) {
|
|
117
|
+
const { stdout: i, stderr: n, message: a } = e;
|
|
118
|
+
throw await Promise.all([i, n].map((c) => c && r(c))), !n && !i && u.error(`Command failed: ${a}`), e;
|
|
112
119
|
}
|
|
113
120
|
}
|
|
114
|
-
function
|
|
115
|
-
return { raw: !0, cmd:
|
|
121
|
+
function q(t) {
|
|
122
|
+
return { raw: !0, cmd: t };
|
|
116
123
|
}
|
|
117
|
-
function y(
|
|
118
|
-
return
|
|
124
|
+
function y(t, r) {
|
|
125
|
+
return r?.isCurrentProject ? `${w} ${P} ${S} ${t}` : `${w} ${T} ${t}`;
|
|
119
126
|
}
|
|
120
|
-
function
|
|
121
|
-
return typeof
|
|
127
|
+
function W(t, r) {
|
|
128
|
+
return typeof t == "function" ? y(t(r), r) : typeof t == "object" && t?.raw === !0 ? t.cmd : typeof t == "string" ? y(t, r) : t;
|
|
122
129
|
}
|
|
123
|
-
async function
|
|
124
|
-
const
|
|
125
|
-
if (
|
|
126
|
-
const
|
|
130
|
+
async function z(t) {
|
|
131
|
+
const r = await $({ name: d });
|
|
132
|
+
if (r.success) {
|
|
133
|
+
const s = { isCurrentProject: r.result.isCurrentProject }, o = typeof t == "function" ? t(s) : t;
|
|
127
134
|
return Object.fromEntries(
|
|
128
|
-
Object.entries(o).map(([
|
|
135
|
+
Object.entries(o).map(([e, i]) => [e, W(i, s)])
|
|
129
136
|
);
|
|
130
137
|
}
|
|
131
138
|
}
|
|
132
|
-
async function
|
|
139
|
+
async function Q(t, r, s = {}) {
|
|
133
140
|
let o;
|
|
134
141
|
try {
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
}, 100), await
|
|
140
|
-
} catch (
|
|
141
|
-
if (o && (clearInterval(o),
|
|
142
|
-
throw
|
|
143
|
-
|
|
142
|
+
const e = Date.now();
|
|
143
|
+
u.start(`${t}`), _().DEBUG ? u.info(`→ ${r}`) : o = setInterval(() => {
|
|
144
|
+
const i = Math.floor((Date.now() - e) / 1e3);
|
|
145
|
+
i > 0 && m.stdout.write(`\r⏳ ${t}... ${i}s`);
|
|
146
|
+
}, 100), await K(r, R, s), o && (clearInterval(o), m.stdout.write("\r\x1B[K")), u.success(`${t} done.`);
|
|
147
|
+
} catch (e) {
|
|
148
|
+
if (o && (clearInterval(o), m.stdout.write("\r\x1B[K")), s.throwOnError)
|
|
149
|
+
throw e;
|
|
150
|
+
E(e);
|
|
144
151
|
}
|
|
145
152
|
}
|
|
146
153
|
export {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
154
|
+
V as clearAllErrorLists,
|
|
155
|
+
W as formatCommand,
|
|
156
|
+
j as getStoredErrorLists,
|
|
157
|
+
q as rawCommand,
|
|
158
|
+
z as resolveCommands,
|
|
159
|
+
Q as runCommand
|
|
153
160
|
};
|
|
161
|
+
//# sourceMappingURL=command.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.util.js","sources":["../../../src/node/command/command.util.ts"],"sourcesContent":["import { exec, execFile } from 'node:child_process';\nimport process from 'node:process';\nimport * as util from 'node:util';\n\nimport { getEnv } from '#config/env/index.js';\n\nimport type { I_IssueEntry } from '../log/index.js';\nimport type { I_CommandContext, I_EslintError, T_Command, T_CommandMapInput } from './command.type.js';\n\nimport { catchError, E_IssueType, log } from '../log/index.js';\nimport { getPackage } from '../package/index.js';\nimport { CYBERSKILL_CLI, CYBERSKILL_CLI_PATH, CYBERSKILL_PACKAGE_NAME, PNPM_EXEC_CLI, TSX_CLI } from '../path/index.js';\nimport { storage } from '../storage/index.js';\n\nconst execPromise = util.promisify(exec);\nconst execFilePromise = util.promisify(execFile);\nconst SHELL_METACHARACTERS = /[|&;<>`$(){}[\\]!#~*?]/;\n// eslint-disable-next-line regexp/no-super-linear-backtracking, regexp/no-misleading-capturing-group\nconst RE_ESLINT_ERROR = /^\\s*(\\d+):(\\d+)\\s+(error|warning)\\s+(.+)\\s+(\\S+)$/;\nconst RE_TS_ERROR = /^(.+?)\\((\\d+),(\\d+)\\):\\s+(error|warning)\\s+TS\\d+:\\s+(\\S.+)$/;\n// eslint-disable-next-line regexp/no-super-linear-backtracking, regexp/no-misleading-capturing-group\nconst RE_COMMITLINT_ERROR = /^✖\\s+(.+)\\s+\\[([^\\]]*)\\]$/;\nconst RE_WHITESPACE = /\\s+/;\n\n/**\n * Retrieves the package name for the current project.\n * This function attempts to get the package name from the current project's package.json.\n * If the package information cannot be retrieved, it returns a timestamp as a fallback.\n *\n * @returns A promise that resolves to the package name or a timestamp string.\n */\nasync function getPackageName() {\n const pkg = await getPackage();\n\n if (!pkg.success) {\n return Date.now().toString();\n }\n\n return pkg.result.name;\n}\n\n/**\n * Saves a list of error entries to persistent storage.\n * This function stores error information with the package name as the key,\n * and provides a log link for manual inspection of the stored errors.\n *\n * @param errorList - An array of error entries to be stored.\n * @returns A promise that resolves when the storage operation is complete.\n */\nasync function saveErrorListToStorage(errorList: I_IssueEntry[]): Promise<void> {\n if (errorList.length === 0) {\n return;\n }\n\n const packageName = await getPackageName();\n\n try {\n const existingErrors = await getStoredErrorLists();\n const mergedErrors = [...existingErrors, ...errorList];\n\n await storage.set(packageName, mergedErrors);\n\n setTimeout(async () => {\n const logPath = await storage.getLogLink(packageName);\n\n if (logPath) {\n log.info(`📂 Open the error list manually: ${logPath}`);\n }\n }, 0);\n }\n catch (error) {\n catchError(error);\n }\n}\n\n/**\n * Retrieves all stored error lists from persistent storage.\n * This function fetches error entries that were previously saved using the package name as the key.\n *\n * @returns A promise that resolves to an array of error entries, or an empty array if none are found.\n */\nexport async function getStoredErrorLists(): Promise<I_IssueEntry[]> {\n try {\n const packageName = await getPackageName();\n const allErrors = await storage.get<I_IssueEntry[]>(packageName);\n\n return allErrors ?? [];\n }\n catch (error) {\n return catchError<I_IssueEntry[]>(error, {\n returnValue: [],\n });\n }\n}\n\n/**\n * Clears all stored error lists from persistent storage.\n * This function removes all error entries associated with the current package name.\n *\n * @returns A promise that resolves when the clearing operation is complete.\n */\nexport async function clearAllErrorLists(): Promise<void> {\n try {\n const packageName = await getPackageName();\n await storage.remove(packageName);\n }\n catch (error) {\n catchError(error);\n }\n}\n\n/**\n * Parses text-based error output and converts it to structured error entries.\n * This function processes command output that contains error information in text format,\n * extracting file paths, line numbers, error types, messages, and rule violations.\n * It handles multiple error formats including ESLint, TypeScript, and commitlint errors.\n *\n * @param output - The raw text output from a command execution containing error information.\n */\nasync function parseTextErrors(output: string): Promise<void> {\n const errorList: I_IssueEntry[] = [];\n const unmatchedLines: string[] = [];\n let lastFilePath = '';\n const eslintErrorDetailsRegex = RE_ESLINT_ERROR;\n const tsRegex = RE_TS_ERROR;\n const commitlintRegex = RE_COMMITLINT_ERROR;\n\n output.split('\\n').forEach((line) => {\n if (line.startsWith('/')) {\n lastFilePath = line.trim();\n }\n else {\n const eslintMatch = eslintErrorDetailsRegex.exec(line) || [];\n const tsMatch = tsRegex.exec(line) || [];\n const commitlintMatch = commitlintRegex.exec(line) || [];\n\n if (eslintMatch.length && lastFilePath) {\n errorList.push({\n file: lastFilePath,\n position: `${eslintMatch[1]}:${eslintMatch[2]}`,\n type: eslintMatch[3] === E_IssueType.Error ? E_IssueType.Error : E_IssueType.Warning,\n message: eslintMatch?.[4]?.trim() ?? '',\n rule: eslintMatch?.[5]?.trim() ?? '',\n });\n }\n else if (tsMatch.length) {\n errorList.push({\n file: tsMatch?.[1] ?? '',\n position: `${tsMatch[2]}:${tsMatch[3]}`,\n type: tsMatch[4] === E_IssueType.Error ? E_IssueType.Error : E_IssueType.Warning,\n message: tsMatch?.[5]?.trim() ?? '',\n });\n }\n else if (commitlintMatch.length) {\n errorList.push({\n file: 'commitlint',\n type: E_IssueType.Error,\n message: commitlintMatch?.[1]?.trim() ?? '',\n rule: commitlintMatch?.[2]?.trim() ?? '',\n });\n }\n else {\n unmatchedLines.push(line.trim());\n }\n }\n });\n\n if (errorList.length) {\n await saveErrorListToStorage(errorList);\n }\n\n if (unmatchedLines.length) {\n log.warn(`Unmatched lines:`);\n unmatchedLines.forEach(line => log.info(` ${line}`));\n }\n}\n\n/**\n * Parses command output that contains structured error information.\n * This function attempts to parse JSON-formatted error output (typically from ESLint)\n * and converts it to structured error entries. If JSON parsing fails, it falls back\n * to text-based parsing.\n *\n * @param output - The command output to parse, expected to be JSON-formatted error data.\n */\nasync function parseCommandOutput(output: string): Promise<void> {\n try {\n const results: I_EslintError[] = JSON.parse(output);\n const errorList: I_IssueEntry[] = [];\n\n results.forEach(({ filePath, messages }) => {\n messages.forEach(({ severity, line, column, ruleId, message }) => {\n errorList.push({\n type: severity === 2 ? E_IssueType.Error : E_IssueType.Warning,\n file: filePath,\n position: `${line}:${column}`,\n rule: ruleId,\n message,\n });\n });\n });\n\n if (errorList.length) {\n await saveErrorListToStorage(errorList);\n }\n }\n catch {\n await parseTextErrors(output);\n }\n}\n\n/**\n * Executes a command and processes its output for errors.\n * This function runs a command with proper signal handling for graceful termination,\n * processes both stdout and stderr for error information, and handles command failures.\n *\n * @param command - The command string to execute, or undefined if no command should be run.\n * @param parser - The function to use for parsing command output (defaults to parseCommandOutput).\n * @returns A promise that resolves when the command execution is complete.\n */\nasync function executeCommand(command: string | void, parser = parseCommandOutput, options: { timeout?: number } = {}): Promise<void> {\n const controller = new AbortController();\n\n process.on('SIGINT', () => {\n log.warn('Process interrupted. Terminating...');\n controller.abort();\n process.exit();\n });\n\n try {\n if (typeof command === 'string') {\n const execOptions = {\n maxBuffer: 10 * 1024 * 1024,\n signal: controller.signal,\n timeout: options.timeout,\n };\n\n let result: { stdout: string; stderr: string };\n\n if (SHELL_METACHARACTERS.test(command)) {\n result = await execPromise(command, execOptions);\n }\n else {\n const parts = command.split(RE_WHITESPACE).filter(Boolean);\n result = await execFilePromise(parts[0]!, parts.slice(1), execOptions);\n }\n\n await Promise.all([result.stdout, result.stderr].map(output => output && parser(output)));\n }\n }\n catch (error) {\n const { stdout, stderr, message } = error as {\n stdout?: string;\n stderr?: string;\n message: string;\n };\n\n await Promise.all([stdout, stderr].map(output => output && parser(output)));\n\n if (!stderr && !stdout) {\n log.error(`Command failed: ${message}`);\n }\n\n throw error;\n }\n}\n\n/**\n * Creates a raw command object that bypasses CLI formatting.\n * This function wraps a command string in an object that indicates it should be executed\n * as-is without any additional CLI formatting or path resolution.\n *\n * @param cmd - The raw command string to be executed directly.\n * @returns An object containing the raw command with a flag indicating it should not be formatted.\n */\nexport function rawCommand(cmd: string) {\n return { raw: true, cmd };\n}\n\n/**\n * Formats a command for CLI execution based on the current project context.\n * This function determines whether to use the current project's CLI path or the global CLI,\n * and formats the command accordingly with the appropriate executable paths.\n *\n * @param command - The command string to format.\n * @param context - Optional context information about the current project.\n * @returns The formatted command string ready for execution.\n */\nfunction formatCLI(command: string, context?: I_CommandContext) {\n if (context?.isCurrentProject) {\n return `${PNPM_EXEC_CLI} ${TSX_CLI} ${CYBERSKILL_CLI_PATH} ${command}`;\n }\n\n return `${PNPM_EXEC_CLI} ${CYBERSKILL_CLI} ${command}`;\n}\n\n/**\n * Formats a command based on its type and context.\n * This function handles different command types:\n * - Function commands: Executes the function with context and formats the result\n * - Raw commands: Returns the command as-is without formatting\n * - String commands: Formats them as CLI commands\n *\n * @param command - The command to format, which can be a string, function, or raw command object.\n * @param context - Optional context information for command execution.\n * @returns The formatted command string ready for execution.\n */\nexport function formatCommand(command: T_Command, context?: I_CommandContext) {\n if (typeof command === 'function') {\n return formatCLI(command(context), context);\n }\n\n if (typeof command === 'object' && command?.raw === true) {\n return command.cmd;\n }\n\n if (typeof command === 'string') {\n return formatCLI(command, context);\n }\n\n return command;\n}\n\n/**\n * Resolves a map of commands by formatting them based on the current project context.\n * This function takes a command map (either static or dynamic) and formats all commands\n * using the appropriate CLI paths based on whether the current project is the Cyberskill package.\n *\n * @param input - The command map to resolve, which can be static or a function that returns a map.\n * @returns A promise that resolves to an object with formatted command strings, or undefined if package info cannot be retrieved.\n */\nexport async function resolveCommands(input: T_CommandMapInput) {\n const packageData = await getPackage({ name: CYBERSKILL_PACKAGE_NAME });\n\n if (packageData.success) {\n const ctx: I_CommandContext = { isCurrentProject: packageData.result.isCurrentProject };\n const commands = typeof input === 'function' ? input(ctx) : input;\n\n return Object.fromEntries(\n Object.entries(commands).map(([key, cmd]) => [key, formatCommand(cmd, ctx)]),\n );\n }\n}\n\n/**\n * Executes a command with proper logging and error handling.\n * This function provides a standardized way to run commands with:\n * - Progress logging with start and success messages\n * - Debug logging of the actual command when DEBUG mode is enabled\n * - Error handling and reporting\n *\n * @param label - A human-readable label describing what the command does.\n * @param command - The command string to execute, or undefined if no command should be run.\n * @returns A promise that resolves when the command execution is complete.\n */\nexport async function runCommand(label: string, command: string | void, options: { timeout?: number; throwOnError?: boolean } = {}) {\n let timer: NodeJS.Timeout | undefined;\n\n try {\n const startTime = Date.now();\n log.start(`${label}`);\n\n if (getEnv().DEBUG) {\n log.info(`→ ${command}`);\n }\n else {\n timer = setInterval(() => {\n const elapsed = Math.floor((Date.now() - startTime) / 1000);\n\n if (elapsed > 0) {\n process.stdout.write(`\\r⏳ ${label}... ${elapsed}s`);\n }\n }, 100);\n }\n\n await executeCommand(command, parseCommandOutput, options);\n\n if (timer) {\n clearInterval(timer);\n process.stdout.write(`\\r\\x1B[K`);\n }\n\n log.success(`${label} done.`);\n }\n catch (error) {\n if (timer) {\n clearInterval(timer);\n process.stdout.write(`\\r\\x1B[K`);\n }\n\n if (options.throwOnError) {\n throw error;\n }\n catchError(error);\n }\n}\n"],"names":["exec","execFile","process","util","storage","getPackage","CYBERSKILL_PACKAGE_NAME","PNPM_EXEC_CLI","TSX_CLI","CYBERSKILL_CLI_PATH","CYBERSKILL_CLI","E_IssueType","log","catchError","getEnv","execPromise","execFilePromise","SHELL_METACHARACTERS","RE_ESLINT_ERROR","RE_TS_ERROR","RE_COMMITLINT_ERROR","RE_WHITESPACE","getPackageName","pkg","saveErrorListToStorage","errorList","packageName","mergedErrors","getStoredErrorLists","logPath","error","clearAllErrorLists","parseTextErrors","output","unmatchedLines","lastFilePath","eslintErrorDetailsRegex","tsRegex","commitlintRegex","line","eslintMatch","tsMatch","commitlintMatch","parseCommandOutput","results","filePath","messages","severity","column","ruleId","message","executeCommand","command","parser","options","controller","execOptions","result","parts","stdout","stderr","rawCommand","cmd","formatCLI","context","formatCommand","resolveCommands","input","packageData","ctx","commands","key","runCommand","label","timer","startTime","elapsed"],"mappings":"AAcA,SAAA,QAAAA,GAAA,YAAAC,SAAA;AAAA,OAAAC,OAAA;AAAA,YAAAC,OAAA;AAAA,SAAA,WAAAC,SAAA;AAAA,SA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+6,9 @@ export { Router } from 'express';
|
|
|
6
6
|
export interface I_ExpressOptions {
|
|
7
7
|
isDev?: boolean;
|
|
8
8
|
static?: string | string[];
|
|
9
|
+
maxFileSize?: number;
|
|
10
|
+
maxFiles?: number;
|
|
11
|
+
jsonLimit?: string;
|
|
9
12
|
}
|
|
10
13
|
export interface I_NestOptions {
|
|
11
14
|
module: Type<object>;
|
|
@@ -13,6 +16,7 @@ export interface I_NestOptions {
|
|
|
13
16
|
static?: string | string[];
|
|
14
17
|
filters?: ExceptionFilter[];
|
|
15
18
|
pipes?: ValidationPipe[];
|
|
19
|
+
jsonLimit?: string;
|
|
16
20
|
}
|
|
17
21
|
export type T_CorsType = 'node' | 'nest';
|
|
18
22
|
interface I_BaseCorsOptions {
|
|
@@ -1,54 +1,72 @@
|
|
|
1
1
|
import { NestFactory as u } from "@nestjs/core";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import n from "compression";
|
|
3
|
+
import l from "cookie-parser";
|
|
4
4
|
import m from "cors";
|
|
5
|
-
import
|
|
6
|
-
import { default as
|
|
7
|
-
import
|
|
8
|
-
import { express as
|
|
9
|
-
import
|
|
5
|
+
import i from "express";
|
|
6
|
+
import { default as G } from "express";
|
|
7
|
+
import f from "express-session";
|
|
8
|
+
import { express as d } from "express-useragent";
|
|
9
|
+
import p from "graphql-upload/graphqlUploadExpress.mjs";
|
|
10
10
|
import x from "helmet";
|
|
11
|
-
|
|
11
|
+
import y from "node:process";
|
|
12
|
+
function E({ isDev: e, whiteList: r, ...t }) {
|
|
12
13
|
return {
|
|
13
|
-
origin: (
|
|
14
|
-
e || !
|
|
14
|
+
origin: (s, o) => {
|
|
15
|
+
e || !s || r?.includes(s ?? "") ? o(null, !0) : o(new Error("Not allowed by CORS"), !1);
|
|
15
16
|
},
|
|
16
17
|
credentials: !0,
|
|
17
|
-
...
|
|
18
|
+
...t
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
-
return m(
|
|
21
|
+
function F(e) {
|
|
22
|
+
return m(E(e));
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
24
|
+
function P(e) {
|
|
25
|
+
const r = {
|
|
26
|
+
resave: !1,
|
|
27
|
+
saveUninitialized: !1,
|
|
28
|
+
cookie: {
|
|
29
|
+
httpOnly: !0,
|
|
30
|
+
sameSite: "lax",
|
|
31
|
+
secure: y.env.NODE_ENV === "production"
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return f({
|
|
35
|
+
...r,
|
|
36
|
+
...e,
|
|
37
|
+
cookie: { ...r.cookie, ...e.cookie }
|
|
38
|
+
});
|
|
25
39
|
}
|
|
26
|
-
function c(e, r = !1) {
|
|
40
|
+
function c(e, r = !1, t = "1mb") {
|
|
27
41
|
e.set("trust proxy", 1), e.use(
|
|
28
42
|
x({
|
|
29
43
|
crossOriginEmbedderPolicy: r ? !1 : void 0,
|
|
30
44
|
contentSecurityPolicy: r ? !1 : void 0
|
|
31
45
|
})
|
|
32
|
-
), e.use(
|
|
46
|
+
), e.use(l()), e.use(i.json({ limit: t })), e.use(i.urlencoded({ extended: !0, limit: t })), e.use(n()), e.use(d());
|
|
33
47
|
}
|
|
34
|
-
function
|
|
35
|
-
r && (Array.isArray(r) ? r : [r]).forEach((
|
|
36
|
-
e.use(`/${
|
|
48
|
+
function a(e, r) {
|
|
49
|
+
r && (Array.isArray(r) ? r : [r]).forEach((s) => {
|
|
50
|
+
e.use(`/${s}`, i.static(s));
|
|
37
51
|
});
|
|
38
52
|
}
|
|
39
|
-
function
|
|
40
|
-
const r =
|
|
41
|
-
return c(r, e?.isDev),
|
|
53
|
+
function z(e) {
|
|
54
|
+
const r = i();
|
|
55
|
+
return c(r, e?.isDev, e?.jsonLimit), a(r, e?.static), r.use(p({
|
|
56
|
+
maxFileSize: e?.maxFileSize ?? 1e7,
|
|
57
|
+
maxFiles: e?.maxFiles ?? 10
|
|
58
|
+
})), r;
|
|
42
59
|
}
|
|
43
|
-
async function
|
|
60
|
+
async function C(e) {
|
|
44
61
|
const r = await u.create(e.module);
|
|
45
|
-
return c(r.getHttpAdapter().getInstance(), e.isDev),
|
|
62
|
+
return c(r.getHttpAdapter().getInstance(), e.isDev, e.jsonLimit), a(r.getHttpAdapter().getInstance(), e.static), e.filters && r.useGlobalFilters(...e.filters), e.pipes && r.useGlobalPipes(...e.pipes), r;
|
|
46
63
|
}
|
|
47
64
|
export {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
65
|
+
F as createCors,
|
|
66
|
+
E as createCorsOptions,
|
|
67
|
+
z as createExpress,
|
|
68
|
+
C as createNest,
|
|
69
|
+
P as createSession,
|
|
70
|
+
G as express
|
|
54
71
|
};
|
|
72
|
+
//# sourceMappingURL=express.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"express.util.js","sources":["../../../src/node/express/express.util.ts"],"sourcesContent":["import type { INestApplication } from '@nestjs/common';\nimport type { Application, RequestHandler } from 'express';\nimport type { SessionOptions } from 'express-session';\n\nimport { NestFactory } from '@nestjs/core';\nimport bodyParser from 'body-parser';\nimport compression from 'compression';\nimport cookieParser from 'cookie-parser';\nimport cors from 'cors';\nimport express from 'express';\nimport session from 'express-session';\nimport { express as useragent } from 'express-useragent';\nimport graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.mjs';\nimport helmet from 'helmet';\nimport process from 'node:process';\n\nimport type { I_ExpressOptions, I_NestOptions, T_CorsOptions, T_CorsType } from './express.type.js';\n\n/**\n * Creates CORS options with environment-specific configuration.\n * This function generates CORS options based on the development environment,\n * including whitelist configuration for allowed origins.\n *\n * @param options - CORS configuration options.\n * @param options.isDev - Whether the application is running in development mode.\n * @param options.whiteList - Array of allowed origins for CORS requests.\n * @returns CORS options object configured for the specified environment.\n */\nexport function createCorsOptions<T extends T_CorsType>({ isDev, whiteList, ...rest }: T_CorsOptions<T>) {\n return {\n origin: (origin: string | undefined, callback: (err: Error | null, allow?: boolean) => void) => {\n if (isDev || !origin || whiteList?.includes(origin ?? '')) {\n callback(null, true);\n }\n else {\n callback(new Error('Not allowed by CORS'), false);\n }\n },\n credentials: true,\n ...rest,\n };\n}\n\n/**\n * Creates a CORS middleware function with the specified configuration.\n * This function creates a CORS middleware that can be used with both Express and NestJS applications,\n * applying the configured CORS options for origin validation and credential handling.\n *\n * @param options - CORS configuration options to apply to the middleware.\n * @returns A CORS middleware function ready to be used in Express or NestJS applications.\n */\nexport function createCors<T extends T_CorsType>(options: T_CorsOptions<T>) {\n return cors<cors.CorsRequest>(createCorsOptions(options));\n}\n\n/**\n * Creates a session middleware function with the specified configuration.\n * This function creates an Express session middleware that can be used to handle user sessions\n * with the provided session options including secret, cookie settings, and storage configuration.\n *\n * @param options - Session configuration options including secret, cookie settings, and storage.\n * @returns A session middleware function ready to be used in Express applications.\n */\nexport function createSession(options: SessionOptions): RequestHandler {\n const secureDefaults: Partial<SessionOptions> = {\n resave: false,\n saveUninitialized: false,\n cookie: {\n httpOnly: true,\n sameSite: 'lax',\n secure: process.env['NODE_ENV'] === 'production',\n },\n };\n\n return session({\n ...secureDefaults,\n ...options,\n cookie: { ...secureDefaults.cookie, ...options.cookie },\n });\n}\n\n/**\n * Sets up common middleware for Express applications.\n * This function configures essential middleware including:\n * - Trust proxy settings for proper IP handling\n * - Cookie parsing for request cookies\n * - URL-encoded body parsing for form data\n * - Compression for response optimization\n * - User agent parsing for device/browser detection\n *\n * @param app - The Express application instance to configure with middleware.\n */\nfunction setupMiddleware(app: Application, isDev = false, jsonLimit = '1mb') {\n app.set('trust proxy', 1);\n app.use(\n helmet({\n crossOriginEmbedderPolicy: isDev ? false : undefined,\n contentSecurityPolicy: isDev ? false : undefined,\n }),\n );\n app.use(cookieParser());\n app.use(express.json({ limit: jsonLimit }));\n app.use(express.urlencoded({ extended: true, limit: jsonLimit }));\n app.use(compression());\n app.use(useragent());\n}\n\n/**\n * Sets up static file serving for Express applications.\n * This function configures static file serving for the specified folders,\n * making files in those directories accessible via HTTP requests.\n *\n * @param app - The Express application instance to configure with static file serving.\n * @param staticFolders - A string or array of strings representing the paths to serve statically.\n */\nfunction setupStaticFolders(app: Application, staticFolders?: string | string[]) {\n if (staticFolders) {\n const statics = Array.isArray(staticFolders) ? staticFolders : [staticFolders];\n statics.forEach((folder) => {\n app.use(`/${folder}`, express.static(folder));\n });\n }\n}\n\n/**\n * Creates and configures an Express application with common middleware and settings.\n * This function sets up a complete Express application with:\n * - Essential middleware (cookies, body parsing, compression, user agent)\n * - Static file serving for specified folders\n * - GraphQL upload support for file uploads\n *\n * @param options - Optional configuration for the Express application including static folder paths.\n * @returns A configured Express application instance ready for use.\n */\nexport function createExpress(options?: I_ExpressOptions): Application {\n const app = express();\n\n setupMiddleware(app, options?.isDev, options?.jsonLimit);\n setupStaticFolders(app, options?.static);\n app.use(graphqlUploadExpress({\n maxFileSize: options?.maxFileSize ?? 10_000_000,\n maxFiles: options?.maxFiles ?? 10,\n }));\n\n return app;\n}\n\n/**\n * Creates and configures a NestJS application with Express integration.\n * This function sets up a NestJS application with:\n * - Express HTTP adapter configuration\n * - Common middleware (cookies, body parsing, compression, user agent)\n * - Static file serving for specified folders\n * - Global filters and pipes if provided\n *\n * @param options - Configuration options for the NestJS application including module, static folders, filters, and pipes.\n * @returns A promise that resolves to a configured NestJS application instance.\n */\nexport async function createNest(options: I_NestOptions): Promise<INestApplication> {\n const app = await NestFactory.create(options.module);\n\n setupMiddleware(app.getHttpAdapter().getInstance(), options.isDev, options.jsonLimit);\n setupStaticFolders(app.getHttpAdapter().getInstance(), options.static);\n\n if (options.filters) {\n app.useGlobalFilters(...options.filters);\n }\n\n if (options.pipes) {\n app.useGlobalPipes(...options.pipes);\n }\n\n return app;\n}\n\nexport { bodyParser, express };\n"],"names":["createCorsOptions","isDev","whiteList","rest","origin","callback","createCors","options","cors","createSession","secureDefaults","process","session","setupMiddleware","app","jsonLimit","helmet","cookieParser","express","compression","useragent","setupSt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ACrBL,EAAI,IAAIM,GAAW;AACvB;AAUA,SAASC,EAAmBP,GAAkBQ,GAAmC;AAC7E,EAAIA,MACgB,MAAM,QAAQA,CAAa,IAAIA,IAAgB,CAACA,CAAa,GACrE,QAAQ,CAACC,MAAW;AACxB,IAAAT,EAAI,IAAI,IAAIS,CAAM,IAAIL,EAAQ,OAAOK,CAAM,CAAC;AAAA,EAChD,CAAC;AAET;AAYO,SAASC,EAAcjB,GAAyC;AACnE,QAAMO,IAAMI,EAAA;AAEZ,SAAAL,EAAgBC,GAAKP,GAAS,OAAOA,GAAS,SAAS,GACvDc,EAAmBP,GAAKP,GAAS,MAAM,GACvCO,EAAI,IAAIW,EAAqB;AAAA,IACzB,aAAalB,GAAS,eAAe;AAAA,IACrC,UAAUA,GAAS,YAAY;AAAA,EAAA,CAClC,CAAC,GAEKO;AACX;AAaA,eAAsBY,EAAWnB,GAAmD;AAChF,QAAMO,IAAM,MAAMa,EAAY,OAAOpB,EAAQ,MAAM;AAEnD,SAAAM,EAAgBC,EAAI,iBAAiB,YAAA,GAAeP,EAAQ,OAAOA,EAAQ,SAAS,GACpFc,EAAmBP,EAAI,eAAA,EAAiB,YAAA,GAAeP,EAAQ,MAAM,GAEjEA,EAAQ,WACRO,EAAI,iBAAiB,GAAGP,EAAQ,OAAO,GAGvCA,EAAQ,SACRO,EAAI,eAAe,GAAGP,EAAQ,KAAK,GAGhCO;AACX;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
package/dist/node/fs/fs.util.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.util.js","sources":["../../../src/node/fs/fs.util.ts"],"sourcesContent":["import fsExtra from 'fs-extra';\nimport path from 'node:path';\n\nimport type { I_CopySyncOptions } from './fs.type.js';\n\n/**\n * Re-export of the fs-extra module for file system operations.\n */\nexport const fs = fsExtra;\n\nexport const {\n lstatSync,\n readdirSync,\n mkdirSync,\n readFileSync,\n unlinkSync,\n statSync,\n createWriteStream,\n} = fsExtra;\n\nexport const readJsonSync: typeof fsExtra.readJsonSync = fsExtra.readJsonSync;\n\n/**\n * Writes data to a file synchronously with UTF-8 encoding as default.\n * This function provides a simplified interface for writing files with automatic UTF-8 encoding\n * when no specific options are provided.\n *\n * @param file - The file path or file descriptor to write to.\n * @param data - The data to write to the file (string or Uint8Array).\n * @param options - Optional write file options (defaults to UTF-8 encoding).\n */\nexport function writeFileSync(file: fsExtra.PathOrFileDescriptor, data: string | Uint8Array, options?: fsExtra.WriteFileOptions): void {\n fsExtra.writeFileSync(file, data, options ?? 'utf-8');\n}\n\n/**\n * Appends data to a file synchronously with UTF-8 encoding as default.\n * This function provides a simplified interface for appending to files with automatic UTF-8 encoding\n * when no specific options are provided.\n *\n * @param path - The file path or file descriptor to append to.\n * @param data - The data to append to the file (string or Uint8Array).\n * @param options - Optional write file options (defaults to UTF-8 encoding).\n */\nexport function appendFileSync(path: fsExtra.PathOrFileDescriptor, data: string | Uint8Array, options?: fsExtra.WriteFileOptions): void {\n fsExtra.appendFileSync(path, data, options ?? 'utf-8');\n}\n\n/**\n * Checks if all specified paths exist synchronously.\n * This function verifies that every path in the provided array exists in the file system.\n * Returns true only if all paths exist, false if any path is missing.\n *\n * @param paths - An array of file or directory paths to check for existence.\n * @returns True if all paths exist, false if any path is missing.\n */\nexport function pathExistsSync(...paths: string[]) {\n return paths.every(path => fsExtra.pathExistsSync(path));\n}\n\n/**\n * Removes files or directories synchronously if they exist.\n * This function safely removes multiple files or directories by checking for existence\n * before attempting removal, preventing errors for non-existent paths.\n *\n * @param paths - An array of file or directory paths to remove.\n */\nexport function removeSync(...paths: string[]) {\n paths.forEach((filePath) => {\n if (pathExistsSync(filePath)) {\n fsExtra.removeSync(filePath);\n }\n });\n}\n\n/**\n * Copies files and directories synchronously with optional filtering.\n * This function copies files from source to destination with support for:\n * - Extension-based filtering (only copy files with specified extensions)\n * - Directory preservation (always copy directories regardless of extension filter)\n * - Additional copy options from fs-extra\n *\n * @param src - The source path to copy from.\n * @param dest - The destination path to copy to.\n * @param options - Optional copy configuration including extensions filter and other fs-extra options.\n */\nexport function copySync(src: string, dest: string, options: I_CopySyncOptions = {}): void {\n const { extensions, ...rest } = options;\n\n fsExtra.copySync(src, dest, {\n filter: (srcPath: string) => {\n if (statSync(srcPath).isDirectory()) {\n return true;\n }\n\n if (!extensions || extensions.length === 0) {\n return true;\n }\n\n return extensions.includes(path.extname(srcPath));\n },\n ...rest,\n });\n}\n\n/**\n * Adds an entry to the .gitignore file if it doesn't already exist.\n * Creates the .gitignore file if it doesn't exist.\n *\n * @param gitIgnorePath - The absolute path to the .gitignore file.\n * @param entry - The entry name to add (e.g. '.agent', '.simple-git-hooks.json').\n */\nexport function addGitIgnoreEntry(gitIgnorePath: string, entry: string): void {\n const gitIgnoreContent = `\\n${entry}\\n`;\n\n if (pathExistsSync(gitIgnorePath)) {\n const gitignore = readFileSync(gitIgnorePath, 'utf-8').split('\\n');\n\n if (!gitignore.includes(entry)) {\n appendFileSync(gitIgnorePath, gitIgnoreContent);\n }\n }\n else {\n writeFileSync(gitIgnorePath, gitIgnoreContent);\n }\n}\n"],"names":["fsExtra","path","fs","lstatSync","readdirSync","mkdirSync","readFileSync","unlinkSync","statSync","createWriteStream","readJsonSync","writeFileSync","file","data","options","appendFileSync","pathExistsSync","paths","removeSync","filePath","copySync","src","dest","extensions","rest","srcPath","addGitIgnoreEntry","gitIgnorePath","entry","gitIgnoreContent"],"mappings":"AAQO,OAAAA,OAAA;AAAA,OAAAC,OAAA;AAAA,MAAMC,IAAKF,GAEL;AAAA,EACT,WAAAG;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,mBAAAC;AACJ,IAAIT,GAESU,IAA4CV,EAAQ;AAW1D,SAASW,EAAcC,GAAoCC,GAA2BC,GAA0C;AACnI,EAAAd,EAAQ,cAAcY,GAAMC,GAAMC,KAAW,OAAO;AACxD;AAWO,SAASC,EAAed,GAAoCY,GAA2BC,GAA0C;AACpI,EAAAd,EAAQ,eAAeC,GAAMY,GAAMC,KAAW,OAAO;AACzD;AAUO,SAASE,KAAkBC,GAAiB;AAC/C,SAAOA,EAAM,MAAM,CAAAhB,MAAQD,EAAQ,eAAeC,CAAI,CAAC;AAC3D;AASO,SAASiB,KAAcD,GAAiB;AAC3C,EAAAA,EAAM,QAAQ,CAACE,MAAa;AACxB,IAAIH,EAAeG,CAAQ,KACvBnB,EAAQ,WAAWmB,CAAQ;AAAA,EAEnC,CAAC;AACL;AAaO,SAASC,EAASC,GAAaC,GAAcR,IAA6B,CAAA,GAAU;AACvF,QAAM,EAAE,YAAAS,GAAY,GAAGC,EAAA,IAASV;AAEhC,EAAAd,EAAQ,SAASqB,GAAKC,GAAM;AAAA,IACxB,QAAQ,CAACG,MACDjB,EAASiB,CAAO,EAAE,iBAIlB,CAACF,KAAcA,EAAW,WAAW,IAC9B,KAGJA,EAAW,SAAStB,EAAK,QAAQwB,CAAO,CAAC;AAAA,IAEpD,GAAGD;AAAA,EAAA,CACN;AACL;AASO,SAASE,EAAkBC,GAAuBC,GAAqB;AAC1E,QAAMC,IAAmB;AAAA,EAAKD,CAAK;AAAA;AAEnC,EAAIZ,EAAeW,CAAa,IACVrB,EAAaqB,GAAe,OAAO,EAAE,MAAM;AAAA,CAAI,EAElD,SAASC,CAAK,KACzBb,EAAeY,GAAeE,CAAgB,IAIlDlB,EAAcgB,GAAeE,CAAgB;AAErD;"}
|
package/dist/node/fs/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/node/log/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.type.js","sources":["../../../src/node/log/log.type.ts"],"sourcesContent":["import type { I_Log as I_LogCommon } from '#typescript/index.js';\n\n/**\n * Enum representing the type of issues for logging and error handling.\n * - Error: Represents an error issue.\n * - Warning: Represents a warning issue.\n */\nexport enum E_IssueType {\n Error = 'error',\n Warning = 'warning',\n}\n\nexport interface I_IssueEntry {\n type: E_IssueType;\n file: string;\n message: string;\n position?: string;\n rule?: string;\n}\n\nexport interface I_ThrowError {\n message?: string;\n status?: {\n CODE: string | number;\n MESSAGE: string;\n };\n type?: 'graphql' | 'rest';\n}\n\nexport interface I_Log extends I_LogCommon {\n printBoxedLog: (\n title: string,\n issues: I_IssueEntry[],\n color?: string,\n ) => void;\n}\n\nexport interface I_CatchErrorOptions {\n shouldLog?: boolean;\n returnValue?: unknown;\n callback?: (error: Error) => void;\n}\n"],"names":["E_IssueType"],"mappings":"AAOO,IAAKA,sBAAAA,OACRA,EAAA,QAAQ,SACRA,EAAA,UAAU,WAFFA,IAAAA,KAAA,CAAA,CAAA;"}
|