arkos 1.2.11-test → 1.2.12-beta
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/README.md +22 -14
- package/cli.js +2 -11
- package/dist/cjs/app.js +1 -1
- package/dist/cjs/app.js.map +1 -1
- package/dist/cjs/modules/auth/auth.service.js +0 -7
- package/dist/cjs/modules/auth/auth.service.js.map +1 -1
- package/dist/cjs/modules/base/base.controller.js +11 -12
- package/dist/cjs/modules/base/base.controller.js.map +1 -1
- package/dist/cjs/modules/base/base.router.js.map +1 -1
- package/dist/cjs/modules/base/base.service.js.map +1 -1
- package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +41 -27
- package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
- package/dist/cjs/modules/error-handler/error-handler.controller.js.map +1 -1
- package/dist/cjs/modules/error-handler/utils/catch-async.js +1 -1
- package/dist/cjs/modules/error-handler/utils/catch-async.js.map +1 -1
- package/dist/cjs/modules/swagger/swagger.router.js +14 -56
- package/dist/cjs/modules/swagger/swagger.router.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +250 -0
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/get-system-json-schema-paths.js +66 -0
- package/dist/cjs/modules/swagger/utils/helpers/get-system-json-schema-paths.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +41 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +22 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js +30 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js +442 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js +165 -0
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js +93 -0
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -0
- package/dist/cjs/server.js +2 -2
- package/dist/cjs/server.js.map +1 -1
- package/dist/cjs/types/arkos-config.js.map +1 -1
- package/dist/cjs/utils/cli/build.js +2 -19
- package/dist/cjs/utils/cli/build.js.map +1 -1
- package/dist/cjs/utils/cli/dev.js +16 -26
- package/dist/cjs/utils/cli/dev.js.map +1 -1
- package/dist/cjs/utils/cli/generate.js +6 -6
- package/dist/cjs/utils/cli/generate.js.map +1 -1
- package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -3
- package/dist/cjs/utils/cli/utils/cli.helpers.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-middlewares.js +33 -66
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-middlewares.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +16 -10
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-router-template.js +5 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-router-template.js.map +1 -1
- package/dist/cjs/utils/helpers/fs.helpers.js +12 -5
- package/dist/cjs/utils/helpers/fs.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/global.helpers.js +69 -2
- package/dist/cjs/utils/helpers/global.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/models.helpers.js +20 -44
- package/dist/cjs/utils/helpers/models.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/prisma.helpers.js +7 -4
- package/dist/cjs/utils/helpers/prisma.helpers.js.map +1 -1
- package/dist/cjs/utils/sheu.js +143 -0
- package/dist/cjs/utils/sheu.js.map +1 -0
- package/dist/esm/app.js +1 -0
- package/dist/esm/app.js.map +1 -0
- package/dist/{es2020 → esm}/exports/auth/index.js +1 -1
- package/dist/{es2020 → esm}/exports/controllers/index.js +2 -2
- package/dist/{es2020 → esm}/exports/error-handler/index.js +2 -2
- package/dist/{es2020 → esm}/exports/index.js +2 -2
- package/dist/{es2020 → esm}/exports/middlewares/index.js +1 -1
- package/dist/esm/exports/prisma/index.js +3 -0
- package/dist/{es2020 → esm}/exports/services/index.js +4 -4
- package/dist/esm/exports/utils/index.js +4 -0
- package/dist/esm/exports/validation/index.js +4 -0
- package/dist/{es2020 → esm}/modules/auth/auth.controller.js +7 -7
- package/dist/{es2020 → esm}/modules/auth/auth.router.js +6 -6
- package/dist/{es2020 → esm}/modules/auth/auth.service.js +6 -13
- package/dist/esm/modules/auth/auth.service.js.map +1 -0
- package/dist/{es2020 → esm}/modules/auth/utils/helpers/auth.controller.helpers.js +2 -2
- package/dist/{es2020 → esm}/modules/base/base.controller.js +18 -19
- package/dist/esm/modules/base/base.controller.js.map +1 -0
- package/dist/{es2020 → esm}/modules/base/base.middlewares.js +6 -6
- package/dist/{es2020 → esm}/modules/base/base.router.js +4 -4
- package/dist/esm/modules/base/base.router.js.map +1 -0
- package/dist/{es2020 → esm}/modules/base/base.service.js +6 -6
- package/dist/{es2020 → esm}/modules/base/base.service.js.map +1 -1
- package/dist/{es2020 → esm}/modules/base/utils/helpers/base.controller.helpers.js +1 -1
- package/dist/{es2020 → esm}/modules/base/utils/helpers/base.middlewares.helpers.js +1 -1
- package/dist/{es2020 → esm}/modules/base/utils/helpers/base.router.helpers.js +45 -33
- package/dist/esm/modules/base/utils/helpers/base.router.helpers.js.map +1 -0
- package/dist/{es2020 → esm}/modules/base/utils/helpers/base.service.helpers.js +1 -1
- package/dist/{es2020 → esm}/modules/email/email.service.js +2 -2
- package/dist/{es2020 → esm}/modules/error-handler/error-handler.controller.js +3 -3
- package/dist/{es2020 → esm}/modules/error-handler/error-handler.controller.js.map +1 -1
- package/dist/{es2020 → esm}/modules/error-handler/utils/catch-async.js +1 -1
- package/dist/esm/modules/error-handler/utils/catch-async.js.map +1 -0
- package/dist/{es2020 → esm}/modules/error-handler/utils/error-handler.helpers.js +1 -1
- package/dist/{es2020 → esm}/modules/file-upload/file-upload.controller.js +7 -7
- package/dist/{es2020 → esm}/modules/file-upload/file-upload.router.js +5 -5
- package/dist/{es2020 → esm}/modules/file-upload/file-upload.service.js +5 -5
- package/dist/{es2020 → esm}/modules/file-upload/utils/helpers/file-upload.helpers.js +2 -2
- package/dist/{es2020 → esm}/modules/swagger/swagger.router.js +15 -57
- package/dist/esm/modules/swagger/swagger.router.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +247 -0
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/get-system-json-schema-paths.js +63 -0
- package/dist/esm/modules/swagger/utils/helpers/get-system-json-schema-paths.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +38 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +19 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js +24 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js +436 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js +159 -0
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js +83 -0
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -0
- package/dist/esm/server.js +3 -0
- package/dist/esm/server.js.map +1 -0
- package/dist/esm/types/arkos-config.js.map +1 -0
- package/dist/{es2020 → esm}/utils/cli/build.js +4 -21
- package/dist/esm/utils/cli/build.js.map +1 -0
- package/dist/{es2020 → esm}/utils/cli/dev.js +20 -30
- package/dist/esm/utils/cli/dev.js.map +1 -0
- package/dist/{es2020 → esm}/utils/cli/generate.js +10 -10
- package/dist/{es2020 → esm}/utils/cli/generate.js.map +1 -1
- package/dist/{es2020 → esm}/utils/cli/index.js +5 -5
- package/dist/{es2020 → esm}/utils/cli/start.js +4 -4
- package/dist/esm/utils/cli/utils/cli.helpers.js +16 -0
- package/dist/esm/utils/cli/utils/cli.helpers.js.map +1 -0
- package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js +1 -1
- package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-middlewares.js +34 -67
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-middlewares.js.map +1 -0
- package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +18 -12
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +1 -0
- package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-router-template.js +6 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-router-template.js.map +1 -0
- package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-service-template.js +2 -2
- package/dist/{es2020 → esm}/utils/cli/utils/template-generators.js +6 -6
- package/dist/{es2020 → esm}/utils/features/api.features.js +4 -4
- package/dist/{es2020 → esm}/utils/features/change-case.features.js +1 -1
- package/dist/{es2020 → esm}/utils/helpers/fs.helpers.js +12 -5
- package/dist/esm/utils/helpers/fs.helpers.js.map +1 -0
- package/dist/esm/utils/helpers/global.helpers.js +65 -0
- package/dist/esm/utils/helpers/global.helpers.js.map +1 -0
- package/dist/{es2020 → esm}/utils/helpers/models.helpers.js +21 -12
- package/dist/esm/utils/helpers/models.helpers.js.map +1 -0
- package/dist/{es2020 → esm}/utils/helpers/prisma.helpers.js +11 -8
- package/dist/esm/utils/helpers/prisma.helpers.js.map +1 -0
- package/dist/esm/utils/sheu.js +141 -0
- package/dist/esm/utils/sheu.js.map +1 -0
- package/dist/{es2020 → esm}/utils/validate-dto.js +1 -1
- package/dist/{es2020 → esm}/utils/validate-schema.js +1 -1
- package/dist/types/modules/base/base.service.d.ts +1 -1
- package/dist/types/modules/base/utils/helpers/base.router.helpers.d.ts +4 -1
- package/dist/types/modules/swagger/swagger.router.d.ts +1 -1
- package/dist/types/modules/swagger/utils/helpers/get-authentication-json-schema-paths.d.ts +2 -0
- package/dist/types/modules/swagger/utils/helpers/get-system-json-schema-paths.d.ts +2 -0
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.d.ts +1 -0
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.d.ts +1 -0
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.d.ts +1 -0
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.d.ts +2 -0
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.d.ts +2 -0
- package/dist/types/modules/swagger/utils/helpers/swagger.router.helpers.d.ts +7 -0
- package/dist/types/types/arkos-config.d.ts +7 -4
- package/dist/types/utils/cli/utils/cli.helpers.d.ts +1 -1
- package/dist/types/utils/helpers/global.helpers.d.ts +6 -1
- package/dist/types/utils/helpers/models.helpers.d.ts +10 -1
- package/dist/types/utils/sheu.d.ts +25 -0
- package/package.json +23 -29
- package/dist/es2020/app.js +0 -1
- package/dist/es2020/app.js.map +0 -1
- package/dist/es2020/exports/prisma/index.js +0 -3
- package/dist/es2020/exports/utils/index.js +0 -4
- package/dist/es2020/exports/validation/index.js +0 -4
- package/dist/es2020/modules/auth/auth.service.js.map +0 -1
- package/dist/es2020/modules/base/base.controller.js.map +0 -1
- package/dist/es2020/modules/base/base.router.js.map +0 -1
- package/dist/es2020/modules/base/utils/helpers/base.router.helpers.js.map +0 -1
- package/dist/es2020/modules/error-handler/utils/catch-async.js.map +0 -1
- package/dist/es2020/modules/swagger/swagger.router.js.map +0 -1
- package/dist/es2020/server.js +0 -3
- package/dist/es2020/server.js.map +0 -1
- package/dist/es2020/types/arkos-config.js.map +0 -1
- package/dist/es2020/utils/cli/build.js.map +0 -1
- package/dist/es2020/utils/cli/dev.js.map +0 -1
- package/dist/es2020/utils/cli/utils/cli.helpers.js +0 -18
- package/dist/es2020/utils/cli/utils/cli.helpers.js.map +0 -1
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-middlewares.js.map +0 -1
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +0 -1
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-router-template.js.map +0 -1
- package/dist/es2020/utils/helpers/fs.helpers.js.map +0 -1
- package/dist/es2020/utils/helpers/global.helpers.js +0 -4
- package/dist/es2020/utils/helpers/global.helpers.js.map +0 -1
- package/dist/es2020/utils/helpers/models.helpers.js.map +0 -1
- package/dist/es2020/utils/helpers/prisma.helpers.js.map +0 -1
- /package/dist/{es2020 → esm}/exports/auth/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/controllers/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/error-handler/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/middlewares/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/prisma/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/services/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/utils/index.js.map +0 -0
- /package/dist/{es2020 → esm}/exports/validation/index.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/auth/auth.controller.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/auth/auth.router.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/auth/utils/helpers/auth.controller.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/base/base.middlewares.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/base/utils/helpers/base.controller.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/base/utils/helpers/base.middlewares.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/base/utils/helpers/base.service.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/email/email.service.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/error-handler/utils/app-error.js +0 -0
- /package/dist/{es2020 → esm}/modules/error-handler/utils/app-error.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/error-handler/utils/error-handler.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/file-upload/file-upload.controller.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/file-upload/file-upload.router.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/file-upload/file-upload.service.js.map +0 -0
- /package/dist/{es2020 → esm}/modules/file-upload/utils/helpers/file-upload.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/paths.js +0 -0
- /package/dist/{es2020 → esm}/paths.js.map +0 -0
- /package/dist/{es2020 → esm}/types/arkos-config.js +0 -0
- /package/dist/{es2020 → esm}/types/auth.js +0 -0
- /package/dist/{es2020 → esm}/types/auth.js.map +0 -0
- /package/dist/{es2020 → esm}/types/index.js +0 -0
- /package/dist/{es2020 → esm}/types/index.js.map +0 -0
- /package/dist/{es2020 → esm}/types/router-config.js +0 -0
- /package/dist/{es2020 → esm}/types/router-config.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/arkos-env.js +0 -0
- /package/dist/{es2020 → esm}/utils/arkos-env.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/index.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/start.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-controller-template.js +0 -0
- /package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-controller-template.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-service-template.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/cli/utils/template-generators.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/dotenv.helpers.js +0 -0
- /package/dist/{es2020 → esm}/utils/dotenv.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/features/api.features.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/features/change-case.features.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/api.features.helpers.js +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/api.features.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/change-case.helpers.js +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/change-case.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/deepmerge.helper.js +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/deepmerge.helper.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/query-parser.helpers.js +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/query-parser.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/text.helpers.js +0 -0
- /package/dist/{es2020 → esm}/utils/helpers/text.helpers.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/validate-dto.js.map +0 -0
- /package/dist/{es2020 → esm}/utils/validate-schema.js.map +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { killDevelopmentServerChildProcess } from "../dev.js";
|
|
3
|
+
import { killProductionServerChildProcess } from "../start.js";
|
|
4
|
+
export function ensureDirectoryExists(dirPath) {
|
|
5
|
+
if (!fs.existsSync(dirPath)) {
|
|
6
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function killServerChildProcess() {
|
|
10
|
+
killDevelopmentServerChildProcess();
|
|
11
|
+
killProductionServerChildProcess();
|
|
12
|
+
}
|
|
13
|
+
export function getVersion() {
|
|
14
|
+
return "1.2.12-beta";
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=cli.helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.helpers.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/cli.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,iCAAiC,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAE5D,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,iCAAiC,EAAE,CAAC;IACpC,gCAAgC,EAAE,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import fs from \"fs\";\nimport { killDevelopmentServerChildProcess } from \"../dev\";\nimport { killProductionServerChildProcess } from \"../start\";\n\nexport function ensureDirectoryExists(dirPath: string): void {\n if (!fs.existsSync(dirPath)) {\n fs.mkdirSync(dirPath, { recursive: true });\n }\n}\n\nexport function killServerChildProcess() {\n killDevelopmentServerChildProcess();\n killProductionServerChildProcess();\n}\n\nexport function getVersion() {\n return \"{{version}}\";\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getUserFileExtension } from "../../../../helpers/fs.helpers";
|
|
1
|
+
import { getUserFileExtension } from "../../../../helpers/fs.helpers.js";
|
|
2
2
|
export function generateAuthConfigsTemplate(options) {
|
|
3
3
|
const { modelName } = options;
|
|
4
4
|
const ext = getUserFileExtension();
|
package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-middlewares.js
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getUserFileExtension } from "../../../../helpers/fs.helpers";
|
|
1
|
+
import { getUserFileExtension } from "../../../../helpers/fs.helpers.js";
|
|
2
2
|
export function generateMiddlewaresTemplate(options) {
|
|
3
3
|
const { modelName } = options;
|
|
4
4
|
const ext = getUserFileExtension();
|
|
@@ -20,246 +20,213 @@ import { catchAsync } from "arkos/error-handler";`
|
|
|
20
20
|
if (isAuth) {
|
|
21
21
|
return `${baseImports}
|
|
22
22
|
|
|
23
|
-
// export const beforeGetMe =
|
|
23
|
+
// export const beforeGetMe =
|
|
24
24
|
// async (${functionParams}) => {
|
|
25
25
|
// // Your logic here
|
|
26
26
|
// next();
|
|
27
27
|
// }
|
|
28
|
-
// );
|
|
29
28
|
|
|
30
|
-
// export const afterGetMe =
|
|
29
|
+
// export const afterGetMe =
|
|
31
30
|
// async (${functionParams}) => {
|
|
32
31
|
// // Your logic here
|
|
33
32
|
// next();
|
|
34
33
|
// }
|
|
35
|
-
// );
|
|
36
34
|
|
|
37
|
-
// export const beforeLogin =
|
|
35
|
+
// export const beforeLogin =
|
|
38
36
|
// async (${functionParams}) => {
|
|
39
37
|
// // Your logic here
|
|
40
38
|
// next();
|
|
41
39
|
// }
|
|
42
|
-
// );
|
|
43
40
|
|
|
44
|
-
// export const afterLogin =
|
|
41
|
+
// export const afterLogin =
|
|
45
42
|
// async (${functionParams}) => {
|
|
46
43
|
// // Your logic here
|
|
47
44
|
// next();
|
|
48
45
|
// }
|
|
49
|
-
// );
|
|
50
46
|
|
|
51
|
-
// export const beforeLogout =
|
|
47
|
+
// export const beforeLogout =
|
|
52
48
|
// async (${functionParams}) => {
|
|
53
49
|
// // Your logic here
|
|
54
50
|
// next();
|
|
55
51
|
// }
|
|
56
|
-
// );
|
|
57
52
|
|
|
58
|
-
// export const afterLogout =
|
|
53
|
+
// export const afterLogout =
|
|
59
54
|
// async (${functionParams}) => {
|
|
60
55
|
// // Your logic here
|
|
61
56
|
// next();
|
|
62
57
|
// }
|
|
63
|
-
// );
|
|
64
58
|
|
|
65
|
-
// export const beforeSignup =
|
|
59
|
+
// export const beforeSignup =
|
|
66
60
|
// async (${functionParams}) => {
|
|
67
61
|
// // Your logic here
|
|
68
62
|
// next();
|
|
69
63
|
// }
|
|
70
|
-
// );
|
|
71
64
|
|
|
72
|
-
// export const afterSignup =
|
|
65
|
+
// export const afterSignup =
|
|
73
66
|
// async (${functionParams}) => {
|
|
74
67
|
// // Your logic here
|
|
75
68
|
// next();
|
|
76
69
|
// }
|
|
77
|
-
// );
|
|
78
70
|
|
|
79
|
-
// export const beforeUpdatePassword =
|
|
71
|
+
// export const beforeUpdatePassword =
|
|
80
72
|
// async (${functionParams}) => {
|
|
81
73
|
// // Your logic here
|
|
82
74
|
// next();
|
|
83
75
|
// }
|
|
84
|
-
// );
|
|
85
76
|
|
|
86
|
-
// export const afterUpdatePassword =
|
|
77
|
+
// export const afterUpdatePassword =
|
|
87
78
|
// async (${functionParams}) => {
|
|
88
79
|
// // Your logic here
|
|
89
80
|
// next();
|
|
90
81
|
// }
|
|
91
|
-
// );
|
|
92
82
|
`;
|
|
93
83
|
}
|
|
94
84
|
if (isFileUpload) {
|
|
95
85
|
return `${baseImports}
|
|
96
86
|
|
|
97
87
|
|
|
98
|
-
// export const beforeFindFile =
|
|
88
|
+
// export const beforeFindFile =
|
|
99
89
|
// async (${functionParams}) => {
|
|
100
90
|
// // Your logic here
|
|
101
91
|
// next();
|
|
102
92
|
// }
|
|
103
|
-
// );
|
|
104
93
|
|
|
105
94
|
// There is not afterFindFile: because the main handler is handleded by express.static()
|
|
106
95
|
|
|
107
|
-
// export const beforeUploadFile =
|
|
96
|
+
// export const beforeUploadFile =
|
|
108
97
|
// async (${functionParams}) => {
|
|
109
98
|
// // Your logic here
|
|
110
99
|
// next();
|
|
111
100
|
// }
|
|
112
|
-
// );
|
|
113
101
|
|
|
114
|
-
// export const afterUploadFile =
|
|
102
|
+
// export const afterUploadFile =
|
|
115
103
|
// async (${functionParams}) => {
|
|
116
104
|
// // Your logic here
|
|
117
105
|
// next();
|
|
118
106
|
// }
|
|
119
|
-
// );
|
|
120
107
|
|
|
121
|
-
// export const beforeUpdateFile =
|
|
108
|
+
// export const beforeUpdateFile =
|
|
122
109
|
// async (${functionParams}) => {
|
|
123
110
|
// // Your logic here
|
|
124
111
|
// next();
|
|
125
112
|
// }
|
|
126
|
-
// );
|
|
127
113
|
|
|
128
|
-
// export const afterUpdateFile =
|
|
114
|
+
// export const afterUpdateFile =
|
|
129
115
|
// async (${functionParams}) => {
|
|
130
116
|
// // Your logic here
|
|
131
117
|
// next();
|
|
132
118
|
// }
|
|
133
|
-
// );
|
|
134
119
|
|
|
135
|
-
// export const beforeDeleteFile =
|
|
120
|
+
// export const beforeDeleteFile =
|
|
136
121
|
// async (${functionParams}) => {
|
|
137
122
|
// // Your logic here
|
|
138
123
|
// next();
|
|
139
124
|
// }
|
|
140
|
-
// );
|
|
141
125
|
|
|
142
|
-
// export const afterDeleteFile =
|
|
126
|
+
// export const afterDeleteFile =
|
|
143
127
|
// async (${functionParams}) => {
|
|
144
128
|
// // Your logic here
|
|
145
129
|
// next();
|
|
146
130
|
// }
|
|
147
|
-
// );
|
|
148
131
|
`;
|
|
149
132
|
}
|
|
150
133
|
return `${baseImports}
|
|
151
134
|
|
|
152
|
-
// export const beforeCreateOne =
|
|
135
|
+
// export const beforeCreateOne =
|
|
153
136
|
// async (${functionParams}) => {
|
|
154
137
|
// // Your logic here
|
|
155
138
|
// next();
|
|
156
139
|
// }
|
|
157
|
-
// );
|
|
158
140
|
|
|
159
|
-
// export const afterCreateOne =
|
|
141
|
+
// export const afterCreateOne =
|
|
160
142
|
// async (${functionParams}) => {
|
|
161
143
|
// // Your logic here
|
|
162
144
|
// next();
|
|
163
145
|
// }
|
|
164
|
-
// );
|
|
165
146
|
|
|
166
|
-
// export const beforeFindOne =
|
|
147
|
+
// export const beforeFindOne =
|
|
167
148
|
// async (${functionParams}) => {
|
|
168
149
|
// // Your logic here
|
|
169
150
|
// next();
|
|
170
151
|
// }
|
|
171
|
-
// );
|
|
172
152
|
|
|
173
|
-
// export const afterFindOne =
|
|
153
|
+
// export const afterFindOne =
|
|
174
154
|
// async (${functionParams}) => {
|
|
175
155
|
// // Your logic here
|
|
176
156
|
// next();
|
|
177
157
|
// }
|
|
178
|
-
// );
|
|
179
158
|
|
|
180
|
-
// export const beforeFindMany =
|
|
159
|
+
// export const beforeFindMany =
|
|
181
160
|
// async (${functionParams}) => {
|
|
182
161
|
// // Your logic here
|
|
183
162
|
// next();
|
|
184
163
|
// }
|
|
185
|
-
// );
|
|
186
164
|
|
|
187
|
-
// export const afterFindMany =
|
|
165
|
+
// export const afterFindMany =
|
|
188
166
|
// async (${functionParams}) => {
|
|
189
167
|
// // Your logic here
|
|
190
168
|
// next();
|
|
191
169
|
// }
|
|
192
|
-
// );
|
|
193
170
|
|
|
194
|
-
// export const beforeUpdateOne =
|
|
171
|
+
// export const beforeUpdateOne =
|
|
195
172
|
// async (${functionParams}) => {
|
|
196
173
|
// // Your logic here
|
|
197
174
|
// next();
|
|
198
175
|
// }
|
|
199
|
-
// );
|
|
200
176
|
|
|
201
|
-
// export const afterUpdateOne =
|
|
177
|
+
// export const afterUpdateOne =
|
|
202
178
|
// async (${functionParams}) => {
|
|
203
179
|
// // Your logic here
|
|
204
180
|
// next();
|
|
205
181
|
// }
|
|
206
|
-
// );
|
|
207
182
|
|
|
208
|
-
// export const beforeDeleteOne =
|
|
183
|
+
// export const beforeDeleteOne =
|
|
209
184
|
// async (${functionParams}) => {
|
|
210
185
|
// // Your logic here
|
|
211
186
|
// next();
|
|
212
187
|
// }
|
|
213
|
-
// );
|
|
214
188
|
|
|
215
|
-
// export const afterDeleteOne =
|
|
189
|
+
// export const afterDeleteOne =
|
|
216
190
|
// async (${functionParams}) => {
|
|
217
191
|
// // Your logic here
|
|
218
192
|
// next();
|
|
219
193
|
// }
|
|
220
|
-
// );
|
|
221
194
|
|
|
222
|
-
// export const beforeCreateMany =
|
|
195
|
+
// export const beforeCreateMany =
|
|
223
196
|
// async (${functionParams}) => {
|
|
224
197
|
// // Your logic here
|
|
225
198
|
// next();
|
|
226
199
|
// }
|
|
227
|
-
// );
|
|
228
200
|
|
|
229
|
-
// export const afterCreateMany =
|
|
201
|
+
// export const afterCreateMany =
|
|
230
202
|
// async (${functionParams}) => {
|
|
231
203
|
// // Your logic here
|
|
232
204
|
// next();
|
|
233
205
|
// }
|
|
234
|
-
// );
|
|
235
206
|
|
|
236
|
-
// export const beforeUpdateMany =
|
|
207
|
+
// export const beforeUpdateMany =
|
|
237
208
|
// async (${functionParams}) => {
|
|
238
209
|
// // Your logic here
|
|
239
210
|
// next();
|
|
240
211
|
// }
|
|
241
|
-
// );
|
|
242
212
|
|
|
243
|
-
// export const afterUpdateMany =
|
|
213
|
+
// export const afterUpdateMany =
|
|
244
214
|
// async (${functionParams}) => {
|
|
245
215
|
// // Your logic here
|
|
246
216
|
// next();
|
|
247
217
|
// }
|
|
248
|
-
// );
|
|
249
218
|
|
|
250
|
-
// export const beforeDeleteMany =
|
|
219
|
+
// export const beforeDeleteMany =
|
|
251
220
|
// async (${functionParams}) => {
|
|
252
221
|
// // Your logic here
|
|
253
222
|
// next();
|
|
254
223
|
// }
|
|
255
|
-
// );
|
|
256
224
|
|
|
257
|
-
// export const afterDeleteMany =
|
|
225
|
+
// export const afterDeleteMany =
|
|
258
226
|
// async (${functionParams}) => {
|
|
259
227
|
// // Your logic here
|
|
260
228
|
// next();
|
|
261
229
|
// }
|
|
262
|
-
// );
|
|
263
230
|
`;
|
|
264
231
|
}
|
|
265
232
|
//# sourceMappingURL=generate-middlewares.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-middlewares.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-middlewares.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAGtE,MAAM,UAAU,2BAA2B,CAAC,OAAwB;IAClE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAEpE,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,KAAK,MAAM,CAAC;IAC1C,MAAM,YAAY,GAChB,SAAS,CAAC,KAAK,KAAK,YAAY,IAAI,SAAS,CAAC,KAAK,KAAK,aAAa,CAAC;IAGxE,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1D,MAAM,YAAY,GAAG,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5D,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC;IAE7D,MAAM,WAAW,GAAG,YAAY;QAC9B,CAAC,CAAC;kDAC4C;QAC9C,CAAC,CAAC,mDAAmD,CAAC;IAExD,MAAM,cAAc,GAAG,YAAY;QACjC,CAAC,CAAC,QAAQ,WAAW,UAAU,YAAY,WAAW,QAAQ,EAAE;QAChE,CAAC,CAAC,gBAAgB,CAAC;IAErB,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,GAAG,WAAW;;;cAGX,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;CAI3B,CAAC;IACA,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,GAAG,WAAW;;;;cAIX,cAAc;;;;;;;;cAQd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;CAI3B,CAAC;IACA,CAAC;IAGD,OAAO,GAAG,WAAW;;;cAGT,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;CAI3B,CAAC;AACF,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateMiddlewaresTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Model name is required for middleware template\");\n\n const isAuth = modelName.camel === \"auth\";\n const isFileUpload =\n modelName.camel === \"fileUpload\" || modelName.camel === \"file-upload\";\n\n // Generate imports based on TypeScript/JavaScript\n const requestType = isTypeScript ? \"ArkosRequest\" : \"req\";\n const responseType = isTypeScript ? \"ArkosResponse\" : \"res\";\n const nextType = isTypeScript ? \"ArkosNextFunction\" : \"next\";\n\n const baseImports = isTypeScript\n ? `import { ArkosRequest, ArkosResponse, ArkosNextFunction } from \"arkos\";\nimport { catchAsync } from \"arkos/error-handler\";`\n : `import { catchAsync } from \"arkos/error-handler\";`;\n\n const functionParams = isTypeScript\n ? `req: ${requestType}, res: ${responseType}, next: ${nextType}`\n : `req, res, next`;\n\n if (isAuth) {\n return `${baseImports}\n\n// export const beforeGetMe = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterGetMe = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeLogin = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterLogin = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeLogout = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterLogout = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeSignup = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterSignup = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeUpdatePassword = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterUpdatePassword = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n`;\n }\n\n if (isFileUpload) {\n return `${baseImports}\n\n\n// export const beforeFindFile = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// There is not afterFindFile: because the main handler is handleded by express.static()\n\n// export const beforeUploadFile = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterUploadFile = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeUpdateFile = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterUpdateFile = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeDeleteFile = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterDeleteFile = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n`;\n }\n\n // Regular model middlewares\n return `${baseImports}\n\n// export const beforeCreateOne = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterCreateOne = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeFindOne = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterFindOne = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeFindMany = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterFindMany = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeUpdateOne = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterUpdateOne = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeDeleteOne = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterDeleteOne = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeCreateMany = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterCreateMany = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeUpdateMany = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterUpdateMany = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeDeleteMany = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterDeleteMany = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n`;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getUserFileExtension } from "../../../../helpers/fs.helpers";
|
|
1
|
+
import { getUserFileExtension } from "../../../../helpers/fs.helpers.js";
|
|
2
2
|
export function generateQueryOptionsTemplate(options) {
|
|
3
3
|
const { modelName } = options;
|
|
4
4
|
const isAuth = modelName?.camel === "auth";
|
|
@@ -15,7 +15,7 @@ export function generateQueryOptionsTemplate(options) {
|
|
|
15
15
|
: `: PrismaQueryOptions<typeof prisma.${modelName.camel}>`
|
|
16
16
|
: "";
|
|
17
17
|
const prismaImport = isTypeScript
|
|
18
|
-
? `import { prisma } from "../../utils/prisma";\n`
|
|
18
|
+
? `import { prisma } from "../../utils/prisma.js";\n`
|
|
19
19
|
: "";
|
|
20
20
|
if (isAuth) {
|
|
21
21
|
return `${prismaImport}${imports};
|
|
@@ -36,16 +36,22 @@ export default ${modelName.camel}QueryOptions;
|
|
|
36
36
|
return `${prismaImport}${imports};
|
|
37
37
|
|
|
38
38
|
const ${modelName.camel}QueryOptions${typeAnnotation} = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
global: {},
|
|
40
|
+
find: {},
|
|
41
|
+
findOne: {},
|
|
42
|
+
findMany: {},
|
|
43
|
+
udpate: {},
|
|
44
|
+
updateMany: {},
|
|
45
|
+
updateOne: {},
|
|
46
|
+
create: {},
|
|
47
|
+
createMany: {},
|
|
48
|
+
createOne: {},
|
|
49
|
+
save: {},
|
|
50
|
+
saveMany: {},
|
|
51
|
+
saveOne: {},
|
|
52
|
+
delete: {},
|
|
53
|
+
deleteMany: {},
|
|
54
|
+
deleteOne: {},
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
export default ${modelName.camel}QueryOptions;
|
package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-prisma-query-options.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-prisma-query-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAGtE,MAAM,UAAU,4BAA4B,CAAC,OAAwB;IACnE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,MAAM,GAAG,SAAS,EAAE,KAAK,KAAK,MAAM,CAAC;IAC3C,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAGtE,MAAM,OAAO,GAAG,MAAM;QACpB,CAAC,CAAC,uDAAuD;QACzD,CAAC,CAAC,mDAAmD,CAAC;IAGxD,MAAM,cAAc,GAAG,YAAY;QACjC,CAAC,CAAC,MAAM;YACN,CAAC,CAAC,0CAA0C,SAAS,CAAC,KAAK,GAAG;YAC9D,CAAC,CAAC,sCAAsC,SAAS,CAAC,KAAK,GAAG;QAC5D,CAAC,CAAC,EAAE,CAAC;IAGP,MAAM,YAAY,GAAG,YAAY;QAC/B,CAAC,CAAC,gDAAgD;QAClD,CAAC,CAAC,EAAE,CAAC;IAEP,IAAI,MAAM,EAAE,CAAC;QAEX,OAAO,GAAG,YAAY,GAAG,OAAO;;QAE5B,SAAS,CAAC,KAAK,eAAe,cAAc;;;;;;;;;iBASnC,SAAS,CAAC,KAAK;CAC/B,CAAC;IACA,CAAC;SAAM,CAAC;QAEN,OAAO,GAAG,YAAY,GAAG,OAAO;;QAE5B,SAAS,CAAC,KAAK,eAAe,cAAc;;;;;;;;;;;;;;;;;;;iBAmBnC,SAAS,CAAC,KAAK;CAC/B,CAAC;IACA,CAAC;AACH,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateQueryOptionsTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n const isAuth = modelName?.camel === \"auth\";\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Model name is required for query config template\");\n\n // Generate imports\n const imports = isAuth\n ? `import { AuthPrismaQueryOptions } from 'arkos/prisma'`\n : `import { PrismaQueryOptions } from 'arkos/prisma'`;\n\n // Generate type annotation for TypeScript\n const typeAnnotation = isTypeScript\n ? isAuth\n ? `: AuthPrismaQueryOptions<typeof prisma.${modelName.camel}>`\n : `: PrismaQueryOptions<typeof prisma.${modelName.camel}>`\n : \"\";\n\n // Generate prisma import if TypeScript\n const prismaImport = isTypeScript\n ? `import { prisma } from \"../../utils/prisma\";\\n`\n : \"\";\n\n if (isAuth) {\n // Auth template\n return `${prismaImport}${imports};\n\nconst ${modelName.camel}QueryOptions${typeAnnotation} = {\n getMe: {},\n updateMe: {},\n deleteMe: {},\n login: {},\n signup: {},\n updatePassword: {},\n}\n\nexport default ${modelName.camel}QueryOptions;\n`;\n } else {\n // Regular template\n return `${prismaImport}${imports};\n\nconst ${modelName.camel}QueryOptions${typeAnnotation} = {\n global: {},\n find: {},\n findOne: {},\n findMany: {},\n udpate: {},\n updateMany: {},\n updateOne: {},\n create: {},\n createMany: {},\n createOne: {},\n save: {},\n saveMany: {},\n saveOne: {},\n delete: {},\n deleteMany: {},\n deleteOne: {},\n}\n\nexport default ${modelName.camel}QueryOptions;\n`;\n }\n}\n"]}
|
package/dist/{es2020 → esm}/utils/cli/utils/template-generator/templates/generate-router-template.js
RENAMED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import pluralize from "pluralize";
|
|
2
|
-
import { checkFileExists, getUserFileExtension, } from "../../../../helpers/fs.helpers";
|
|
2
|
+
import { checkFileExists, getUserFileExtension, } from "../../../../helpers/fs.helpers.js";
|
|
3
3
|
export function generateRouterTemplate(options) {
|
|
4
4
|
const { modelName, imports } = options;
|
|
5
5
|
if (!modelName)
|
|
6
6
|
throw new Error("Model name is required for router template");
|
|
7
7
|
const ext = getUserFileExtension();
|
|
8
8
|
const controllerPath = imports?.controller || `./${modelName.kebab}.controller.${ext}`;
|
|
9
|
+
const routerConfigTsType = ext === "ts" ? ": RouterConfig" : "";
|
|
10
|
+
const routerConfigTsTypeImport = ext === "ts" ? "import { RouterConfig } from 'arkos'" : "";
|
|
9
11
|
const controllerExists = checkFileExists(controllerPath);
|
|
10
12
|
const controllerImportLine = controllerExists
|
|
11
13
|
? `import ${modelName.camel}Controller from "${imports?.controller || `./${modelName.kebab}.controller`}"`
|
|
@@ -16,6 +18,9 @@ export function generateRouterTemplate(options) {
|
|
|
16
18
|
return `import { Router } from 'express'
|
|
17
19
|
import { authService } from 'arkos/services'
|
|
18
20
|
${controllerImportLine}
|
|
21
|
+
${routerConfigTsTypeImport}
|
|
22
|
+
|
|
23
|
+
export const config${routerConfigTsType} = { }
|
|
19
24
|
|
|
20
25
|
const ${modelName.camel}Router = Router()
|
|
21
26
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-router-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-router-template.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,eAAe,EACf,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AAGxC,MAAM,UAAU,sBAAsB,CAAC,OAAwB;IAC7D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAG9E,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,cAAc,GAClB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,eAAe,GAAG,EAAE,CAAC;IAElE,MAAM,kBAAkB,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,MAAM,wBAAwB,GAC5B,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE7D,MAAM,gBAAgB,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;IAEzD,MAAM,oBAAoB,GAAG,gBAAgB;QAC3C,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,aAC7C,GAAG;QACL,CAAC,CAAC,aAAa,SAAS,CAAC,KAAK,oBAC1B,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,aAC7C,GAAG,CAAC;IAER,MAAM,qBAAqB,GAAG,gBAAgB;QAC5C,CAAC,CAAC,KAAK,SAAS,CAAC,KAAK,wBAAwB;QAC9C,CAAC,CAAC,QAAQ,SAAS,CAAC,KAAK,wBAAwB,CAAC;IAEpD,OAAO;;EAEP,oBAAoB;EACpB,wBAAwB;;qBAEL,kBAAkB;;QAE/B,SAAS,CAAC,KAAK;;EAErB,SAAS,CAAC,KAAK;4CAC2B,SAAS,CACjD,SAAS,CAAC,KAAK,CAChB;;qDAEkD,SAAS,CAAC,KAAK;EAClE,qBAAqB;;;iBAGN,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import pluralize from \"pluralize\";\nimport {\n checkFileExists,\n getUserFileExtension,\n} from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateRouterTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName) throw new Error(\"Model name is required for router template\");\n\n // Check if controller file exists\n const ext = getUserFileExtension();\n const controllerPath =\n imports?.controller || `./${modelName.kebab}.controller.${ext}`;\n\n const routerConfigTsType = ext === \"ts\" ? \": RouterConfig\" : \"\";\n const routerConfigTsTypeImport =\n ext === \"ts\" ? \"import { RouterConfig } from 'arkos'\" : \"\";\n\n const controllerExists = checkFileExists(controllerPath);\n\n const controllerImportLine = controllerExists\n ? `import ${modelName.camel}Controller from \"${\n imports?.controller || `./${modelName.kebab}.controller`\n }\"`\n : `// import ${modelName.camel}Controller from \"${\n imports?.controller || `./${modelName.kebab}.controller`\n }\"`;\n\n const controllerHandlerLine = controllerExists\n ? ` ${modelName.camel}Controller.someHandler`\n : ` // ${modelName.camel}Controller.someHandler`;\n\n return `import { Router } from 'express'\nimport { authService } from 'arkos/services'\n${controllerImportLine}\n${routerConfigTsTypeImport}\n\nexport const config${routerConfigTsType} = { }\n\nconst ${modelName.camel}Router = Router()\n\n${modelName.camel}Router.post(\n '/custom-endpoint', // resolves to /api/${pluralize(\n modelName.kebab\n )}/custom-endpoint\n authService.authenticate,\n authService.handleAccessControl('CustomAction', '${modelName.kebab}'),\n${controllerHandlerLine}\n)\n\nexport default ${modelName.camel}Router\n`;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getUserFileExtension } from "../../../../helpers/fs.helpers";
|
|
1
|
+
import { getUserFileExtension } from "../../../../helpers/fs.helpers.js";
|
|
2
2
|
export function generateServiceTemplate(options) {
|
|
3
3
|
const { modelName, imports } = options;
|
|
4
4
|
const ext = getUserFileExtension();
|
|
@@ -6,7 +6,7 @@ export function generateServiceTemplate(options) {
|
|
|
6
6
|
if (!modelName)
|
|
7
7
|
throw new Error("Model name is required for service template");
|
|
8
8
|
const prismaImport = isTypeScript
|
|
9
|
-
? `import { prisma } from "../../utils/prisma";\n`
|
|
9
|
+
? `import { prisma } from "../../utils/prisma.js";\n`
|
|
10
10
|
: "";
|
|
11
11
|
const baseServiceImport = isTypeScript
|
|
12
12
|
? `import { BaseService } from "${imports?.baseService || "arkos/services"}";`
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { generateControllerTemplate } from "./template-generator/templates/generate-controller-template";
|
|
2
|
-
import { generateAuthConfigsTemplate } from "./template-generator/templates/generate-auth-configs-template";
|
|
3
|
-
import { generateMiddlewaresTemplate } from "./template-generator/templates/generate-middlewares";
|
|
4
|
-
import { generateQueryOptionsTemplate } from "./template-generator/templates/generate-prisma-query-options";
|
|
5
|
-
import { generateRouterTemplate } from "./template-generator/templates/generate-router-template";
|
|
6
|
-
import { generateServiceTemplate } from "./template-generator/templates/generate-service-template";
|
|
1
|
+
import { generateControllerTemplate } from "./template-generator/templates/generate-controller-template.js";
|
|
2
|
+
import { generateAuthConfigsTemplate } from "./template-generator/templates/generate-auth-configs-template.js";
|
|
3
|
+
import { generateMiddlewaresTemplate } from "./template-generator/templates/generate-middlewares.js";
|
|
4
|
+
import { generateQueryOptionsTemplate } from "./template-generator/templates/generate-prisma-query-options.js";
|
|
5
|
+
import { generateRouterTemplate } from "./template-generator/templates/generate-router-template.js";
|
|
6
|
+
import { generateServiceTemplate } from "./template-generator/templates/generate-service-template.js";
|
|
7
7
|
export function generateTemplate(type, options) {
|
|
8
8
|
switch (type) {
|
|
9
9
|
case "controller":
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import deepmerge from "../helpers/deepmerge.helper";
|
|
2
|
-
import { parseQueryParamsWithModifiers } from "../helpers/api.features.helpers";
|
|
3
|
-
import AppError from "../../modules/error-handler/utils/app-error";
|
|
4
|
-
import { getPrismaInstance } from "../helpers/prisma.helpers";
|
|
1
|
+
import deepmerge from "../helpers/deepmerge.helper.js";
|
|
2
|
+
import { parseQueryParamsWithModifiers } from "../helpers/api.features.helpers.js";
|
|
3
|
+
import AppError from "../../modules/error-handler/utils/app-error.js";
|
|
4
|
+
import { getPrismaInstance } from "../helpers/prisma.helpers.js";
|
|
5
5
|
export default class APIFeatures {
|
|
6
6
|
constructor(req, modelName) {
|
|
7
7
|
this.filters = {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as changeCase from "../helpers/change-case.helpers";
|
|
1
|
+
import * as changeCase from "../helpers/change-case.helpers.js";
|
|
2
2
|
const isObject = (object) => object !== null && typeof object === "object";
|
|
3
3
|
function changeKeysFactory(changeCase) {
|
|
4
4
|
return function changeKeys(object, depth = 1, options) {
|
|
@@ -11,7 +11,8 @@ export function fullCleanCwd(path) {
|
|
|
11
11
|
if (typeof path !== "string")
|
|
12
12
|
throw new Error("Path must be a string");
|
|
13
13
|
const cwd = process.cwd().replace(/\/+$/, "");
|
|
14
|
-
|
|
14
|
+
const escapedCwd = cwd.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
15
|
+
return path.replace(new RegExp(`${escapedCwd}/?`, "g"), "");
|
|
15
16
|
}
|
|
16
17
|
export let userFileExtension;
|
|
17
18
|
export const getUserFileExtension = () => {
|
|
@@ -20,13 +21,19 @@ export const getUserFileExtension = () => {
|
|
|
20
21
|
try {
|
|
21
22
|
const currentDir = process.cwd();
|
|
22
23
|
const hasTsConfig = fs.existsSync(path.join(currentDir, "tsconfig.json"));
|
|
24
|
+
const hasAppTs = fs.existsSync(path.join(currentDir, "src", "app.ts"));
|
|
25
|
+
const hasAppJs = fs.existsSync(path.join(currentDir, "src", "app.js"));
|
|
23
26
|
const isBuildMode = process.env.ARKOS_BUILD === "true";
|
|
24
|
-
if (
|
|
27
|
+
if (isBuildMode)
|
|
28
|
+
userFileExtension = "js";
|
|
29
|
+
else if (hasTsConfig)
|
|
30
|
+
userFileExtension = "ts";
|
|
31
|
+
else if (hasAppTs && !hasAppJs)
|
|
25
32
|
userFileExtension = "ts";
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
else if (hasAppJs)
|
|
34
|
+
userFileExtension = "js";
|
|
35
|
+
else
|
|
28
36
|
userFileExtension = "js";
|
|
29
|
-
}
|
|
30
37
|
return userFileExtension;
|
|
31
38
|
}
|
|
32
39
|
catch (e) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/fs.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;AAChD,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AAE9C,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,EAAE,CACtB,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM;IAChC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,UAAU;IAC5B,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;AAQpB,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAEvE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC9C,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAE9D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,UAAU,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,CAAC,IAAI,iBAA0C,CAAC;AAOtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAgB,EAAE;IACpD,IAAI,iBAAiB;QAAE,OAAO,iBAAiB,CAAC;IAEhD,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAGjC,MAAM,WAAW,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;QAG1E,MAAM,QAAQ,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;QACvE,MAAM,QAAQ,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;QAGvE,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM,CAAC;QAGvD,IAAI,WAAW;YAAE,iBAAiB,GAAG,IAAI,CAAC;aACrC,IAAI,WAAW;YAAE,iBAAiB,GAAG,IAAI,CAAC;aAC1C,IAAI,QAAQ,IAAI,CAAC,QAAQ;YAAE,iBAAiB,GAAG,IAAI,CAAC;aACpD,IAAI,QAAQ;YAAE,iBAAiB,GAAG,IAAI,CAAC;;YACvC,iBAAiB,GAAG,IAAI,CAAC;QAE9B,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QAEX,iBAAiB,GAAG,IAAI,CAAC;QACzB,OAAO,iBAAiB,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC;AAgBF,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { promisify } from \"util\";\nimport fs from \"fs\";\nimport path from \"path\";\n\nexport const statAsync = promisify(fs.stat);\nexport const accessAsync = promisify(fs.access);\nexport const mkdirAsync = promisify(fs.mkdir);\n\nexport const crd = () =>\n process.env.ARKOS_BUILD === \"true\"\n ? process.cwd() + \"/.build/\"\n : process.cwd();\n\n/**\n * Removes the current working directory prefix from the given path.\n * Handles cases with or without a trailing slash in cwd.\n * @param path - The path to clean\n * @returns The path without the cwd prefix\n */\nexport function fullCleanCwd(path: string): string {\n if (typeof path !== \"string\") throw new Error(\"Path must be a string\");\n\n const cwd = process.cwd().replace(/\\/+$/, \"\"); // remove trailing slashes\n const escapedCwd = cwd.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"); // escape regex special chars\n\n return path.replace(new RegExp(`${escapedCwd}/?`, \"g\"), \"\"); // remove cwd + optional slash\n}\n\nexport let userFileExtension: \"ts\" | \"js\" | undefined;\n\n/**\n * Detects the file extension that should be used in the current execution context\n * Returns 'ts' when TypeScript config exists and not in build mode, otherwise 'js'\n * @returns 'ts' | 'js'\n */\nexport const getUserFileExtension = (): \"ts\" | \"js\" => {\n if (userFileExtension) return userFileExtension;\n\n try {\n const currentDir = process.cwd();\n\n // Check for tsconfig.json in current directory\n const hasTsConfig = fs.existsSync(path.join(currentDir, \"tsconfig.json\"));\n\n // Check for main app files\n const hasAppTs = fs.existsSync(path.join(currentDir, \"src\", \"app.ts\"));\n const hasAppJs = fs.existsSync(path.join(currentDir, \"src\", \"app.js\"));\n\n // Check environment variable for build mode\n const isBuildMode = process.env.ARKOS_BUILD === \"true\";\n\n // Decision logic (prioritized)\n if (isBuildMode) userFileExtension = \"js\";\n else if (hasTsConfig) userFileExtension = \"ts\";\n else if (hasAppTs && !hasAppJs) userFileExtension = \"ts\";\n else if (hasAppJs) userFileExtension = \"js\";\n else userFileExtension = \"js\";\n\n return userFileExtension;\n } catch (e) {\n // Default to js if anything goes wrong\n userFileExtension = \"js\";\n return userFileExtension;\n }\n};\n\n/**\n * Checks if a file exists at the specified file path.\n *\n * @param filePath - The path to the file to check\n * @returns {boolean} True if the file exists, false otherwise or if there's an error\n *\n * @example\n * ```ts\n * const exists = checkFileExists('./path/to/file.txt');\n * if (exists) {\n * console.info('File exists!');\n * }\n * ```\n */\nexport function checkFileExists(filePath: string): boolean {\n try {\n return fs.existsSync(path.resolve(filePath));\n } catch (error) {\n return false;\n }\n}\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { createRequire } from "module";
|
|
4
|
+
import { pathToFileURL } from "url";
|
|
5
|
+
import { getUserFileExtension } from "./fs.helpers.js";
|
|
6
|
+
export function getPackageJson() {
|
|
7
|
+
try {
|
|
8
|
+
const pkgPath = path.join(process.cwd(), "package.json");
|
|
9
|
+
if (fs.existsSync(pkgPath)) {
|
|
10
|
+
return JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
console.error("Error checking package.json:", err);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function isEsm() {
|
|
18
|
+
const pkg = getPackageJson();
|
|
19
|
+
return pkg.type === "module";
|
|
20
|
+
}
|
|
21
|
+
export async function importModule(modulePath, options = { fixExtension: true }) {
|
|
22
|
+
let correctedPath = modulePath;
|
|
23
|
+
if (!options.fixExtension ||
|
|
24
|
+
modulePath.endsWith(".ts") ||
|
|
25
|
+
getUserFileExtension() === "ts")
|
|
26
|
+
return await import(modulePath);
|
|
27
|
+
if (options?.fixExtension &&
|
|
28
|
+
isEsm() &&
|
|
29
|
+
modulePath.startsWith(".") &&
|
|
30
|
+
!modulePath.endsWith(".js")) {
|
|
31
|
+
const fullImportPath = path.resolve(process.cwd(), modulePath);
|
|
32
|
+
const indexPath = fullImportPath + "/index.js";
|
|
33
|
+
if (fs.existsSync(indexPath)) {
|
|
34
|
+
correctedPath = modulePath + "/index.js";
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
correctedPath = modulePath + ".js";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const userRequire = createRequire(pathToFileURL(process.cwd() + "/package.json"));
|
|
41
|
+
const resolved = userRequire.resolve(modulePath);
|
|
42
|
+
return await import(pathToFileURL(resolved));
|
|
43
|
+
return await import(correctedPath);
|
|
44
|
+
}
|
|
45
|
+
export function detectPackageManagerFromUserAgent() {
|
|
46
|
+
const userAgent = process.env.npm_config_user_agent || "";
|
|
47
|
+
if (!userAgent)
|
|
48
|
+
return "npm";
|
|
49
|
+
if (userAgent.includes("pnpm"))
|
|
50
|
+
return "pnpm";
|
|
51
|
+
if (userAgent.includes("yarn"))
|
|
52
|
+
return "yarn";
|
|
53
|
+
if (userAgent.includes("npm"))
|
|
54
|
+
return "npm";
|
|
55
|
+
if (userAgent.includes("bun"))
|
|
56
|
+
return "bun";
|
|
57
|
+
if (userAgent.includes("cnpm"))
|
|
58
|
+
return "cnpm";
|
|
59
|
+
if (userAgent.includes("corepack"))
|
|
60
|
+
return "corepack";
|
|
61
|
+
if (userAgent.includes("deno"))
|
|
62
|
+
return "deno";
|
|
63
|
+
return "npm";
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=global.helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/global.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;QACzD,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAC;IACrD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,KAAK;IACnB,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;IAC7B,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC/B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,UAAkB,EAClB,UAAqC,EAAE,YAAY,EAAE,IAAI,EAAE;IAG3D,IAAI,aAAa,GAAG,UAAU,CAAC;IAE/B,IACE,CAAC,OAAO,CAAC,YAAY;QACrB,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC1B,oBAAoB,EAAE,KAAK,IAAI;QAE/B,OAAO,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;IAElC,IACE,OAAO,EAAE,YAAY;QACrB,KAAK,EAAE;QACP,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC;QAC1B,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAC3B,CAAC;QACD,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;QAC/D,MAAM,SAAS,GAAG,cAAc,GAAG,WAAW,CAAC;QAG/C,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7B,aAAa,GAAG,UAAU,GAAG,WAAW,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,aAAa,GAAG,UAAU,GAAG,KAAK,CAAC;QACrC,CAAC;IACH,CAAC;IAGD,MAAM,WAAW,GAAG,aAAa,CAC/B,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,eAAe,CAAC,CAC/C,CAAC;IACF,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACjD,OAAO,MAAM,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAQ,CAAC,CAAC;IAEpD,OAAO,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;AACrC,CAAC;AAQD,MAAM,UAAU,iCAAiC;IAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC;IAE1D,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7B,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IACtD,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAE9C,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { createRequire } from \"module\";\nimport { pathToFileURL } from \"url\";\nimport { getUserFileExtension } from \"./fs.helpers\";\n\nexport function getPackageJson() {\n try {\n const pkgPath = path.join(process.cwd(), \"package.json\");\n if (fs.existsSync(pkgPath)) {\n return JSON.parse(fs.readFileSync(pkgPath, \"utf8\"));\n }\n } catch (err) {\n console.error(\"Error checking package.json:\", err);\n }\n}\n\nexport function isEsm() {\n const pkg = getPackageJson();\n return pkg.type === \"module\";\n}\n\nexport async function importModule(\n modulePath: string,\n options: { fixExtension: boolean } = { fixExtension: true }\n) {\n // Add .js extension if it's a relative path without extension\n let correctedPath = modulePath;\n\n if (\n !options.fixExtension ||\n modulePath.endsWith(\".ts\") ||\n getUserFileExtension() === \"ts\"\n )\n return await import(modulePath);\n\n if (\n options?.fixExtension &&\n isEsm() &&\n modulePath.startsWith(\".\") &&\n !modulePath.endsWith(\".js\")\n ) {\n const fullImportPath = path.resolve(process.cwd(), modulePath);\n const indexPath = fullImportPath + \"/index.js\";\n\n // Check if it's a directory with index.js or a direct file\n if (fs.existsSync(indexPath)) {\n correctedPath = modulePath + \"/index.js\";\n } else {\n correctedPath = modulePath + \".js\";\n }\n }\n\n // When importing user modules:\n const userRequire = createRequire(\n pathToFileURL(process.cwd() + \"/package.json\")\n );\n const resolved = userRequire.resolve(modulePath);\n return await import(pathToFileURL(resolved) as any);\n\n return await import(correctedPath);\n}\n\n/**\n * Helps getting the current package manager from user agent\n *\n * @returns {string} the package manager\n * @default \"npm\"\n */\nexport function detectPackageManagerFromUserAgent(): string {\n const userAgent = process.env.npm_config_user_agent || \"\";\n\n if (!userAgent) return \"npm\";\n if (userAgent.includes(\"pnpm\")) return \"pnpm\";\n if (userAgent.includes(\"yarn\")) return \"yarn\";\n if (userAgent.includes(\"npm\")) return \"npm\";\n if (userAgent.includes(\"bun\")) return \"bun\";\n if (userAgent.includes(\"cnpm\")) return \"cnpm\";\n if (userAgent.includes(\"corepack\")) return \"corepack\";\n if (userAgent.includes(\"deno\")) return \"deno\";\n\n return \"npm\";\n}\n"]}
|