arkos 1.1.96-test → 1.1.98-test

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/cjs/modules/auth/auth.controller.js +0 -5
  2. package/dist/cjs/modules/auth/auth.controller.js.map +1 -1
  3. package/dist/cjs/modules/auth/auth.router.js +82 -35
  4. package/dist/cjs/modules/auth/auth.router.js.map +1 -1
  5. package/dist/cjs/modules/auth/auth.service.js +5 -5
  6. package/dist/cjs/modules/auth/auth.service.js.map +1 -1
  7. package/dist/cjs/modules/base/base.middlewares.js +7 -14
  8. package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
  9. package/dist/cjs/modules/base/base.service.js +21 -12
  10. package/dist/cjs/modules/base/base.service.js.map +1 -1
  11. package/dist/cjs/modules/base/utils/helpers/base.middlewares.helpers.js +50 -0
  12. package/dist/cjs/modules/base/utils/helpers/base.middlewares.helpers.js.map +1 -0
  13. package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +93 -40
  14. package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
  15. package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
  16. package/dist/cjs/server.js +3 -2
  17. package/dist/cjs/server.js.map +1 -1
  18. package/dist/cjs/types/index.js.map +1 -1
  19. package/dist/cjs/utils/cli/dev.js +176 -26
  20. package/dist/cjs/utils/cli/dev.js.map +1 -1
  21. package/dist/cjs/utils/cli/index.js +3 -2
  22. package/dist/cjs/utils/cli/index.js.map +1 -1
  23. package/dist/cjs/utils/cli/start.js +12 -8
  24. package/dist/cjs/utils/cli/start.js.map +1 -1
  25. package/dist/cjs/utils/cli/utils/cli.helpers.js +7 -0
  26. package/dist/cjs/utils/cli/utils/cli.helpers.js.map +1 -1
  27. package/dist/cjs/utils/helpers/fs.helpers.js +1 -1
  28. package/dist/cjs/utils/helpers/fs.helpers.js.map +1 -1
  29. package/dist/cjs/utils/helpers/models.helpers.js +7 -0
  30. package/dist/cjs/utils/helpers/models.helpers.js.map +1 -1
  31. package/dist/es2020/modules/auth/auth.controller.js +0 -5
  32. package/dist/es2020/modules/auth/auth.controller.js.map +1 -1
  33. package/dist/es2020/modules/auth/auth.router.js +82 -35
  34. package/dist/es2020/modules/auth/auth.router.js.map +1 -1
  35. package/dist/es2020/modules/auth/auth.service.js +5 -5
  36. package/dist/es2020/modules/auth/auth.service.js.map +1 -1
  37. package/dist/es2020/modules/base/base.middlewares.js +7 -14
  38. package/dist/es2020/modules/base/base.middlewares.js.map +1 -1
  39. package/dist/es2020/modules/base/base.service.js +21 -12
  40. package/dist/es2020/modules/base/base.service.js.map +1 -1
  41. package/dist/es2020/modules/base/utils/helpers/base.middlewares.helpers.js +44 -0
  42. package/dist/es2020/modules/base/utils/helpers/base.middlewares.helpers.js.map +1 -0
  43. package/dist/es2020/modules/base/utils/helpers/base.router.helpers.js +93 -40
  44. package/dist/es2020/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
  45. package/dist/es2020/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
  46. package/dist/es2020/server.js +3 -2
  47. package/dist/es2020/server.js.map +1 -1
  48. package/dist/es2020/types/index.js.map +1 -1
  49. package/dist/es2020/utils/cli/dev.js +173 -27
  50. package/dist/es2020/utils/cli/dev.js.map +1 -1
  51. package/dist/es2020/utils/cli/index.js +3 -2
  52. package/dist/es2020/utils/cli/index.js.map +1 -1
  53. package/dist/es2020/utils/cli/start.js +11 -8
  54. package/dist/es2020/utils/cli/start.js.map +1 -1
  55. package/dist/es2020/utils/cli/utils/cli.helpers.js +6 -0
  56. package/dist/es2020/utils/cli/utils/cli.helpers.js.map +1 -1
  57. package/dist/es2020/utils/helpers/fs.helpers.js +1 -1
  58. package/dist/es2020/utils/helpers/fs.helpers.js.map +1 -1
  59. package/dist/es2020/utils/helpers/models.helpers.js +7 -0
  60. package/dist/es2020/utils/helpers/models.helpers.js.map +1 -1
  61. package/dist/types/modules/base/base.middlewares.d.ts +2 -2
  62. package/dist/types/modules/base/base.service.d.ts +2 -2
  63. package/dist/types/modules/base/utils/helpers/base.middlewares.helpers.d.ts +3 -0
  64. package/dist/types/server.d.ts +1 -0
  65. package/dist/types/types/index.d.ts +11 -3
  66. package/dist/types/utils/cli/dev.d.ts +1 -0
  67. package/dist/types/utils/cli/start.d.ts +1 -0
  68. package/dist/types/utils/cli/utils/cli.helpers.d.ts +1 -0
  69. package/package.json +3 -2
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;AAwEA,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,yCAAiB,CAAA;IACjB,qCAAa,CAAA;IACb,yCAAiB,CAAA;IACjB,yCAAiB,CAAA;AACnB,CAAC,EALW,oBAAoB,oCAApB,oBAAoB,QAK/B","sourcesContent":["import { NextFunction, Request, RequestHandler, Response } from \"express\";\n\nexport type PrismaOperations = \"findMany\";\n\nexport type PrismaQueryOptions<T extends Record<string, any>> = {\n queryOptions?: Partial<Parameters<T[\"findMany\"]>[0]>;\n findOne?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n findMany?: Partial<Parameters<T[\"findMany\"]>[0]>;\n deleteMany?: Partial<Parameters<T[\"deleteMany\"]>[0]>;\n updateMany?: Partial<Parameters<T[\"updateMany\"]>[0]>;\n createMany?: Partial<Parameters<T[\"createMany\"]>[0]>;\n createOne?: Partial<Parameters<T[\"create\"]>[0]>;\n updateOne?: Partial<Parameters<T[\"update\"]>[0]>;\n deleteOne?: Partial<Parameters<T[\"delete\"]>[0]>;\n};\n\nexport type AuthPrismaQueryOptions<T extends Record<string, any>> = {\n // User profile endpoints\n getMe?: Partial<Parameters<T[\"findUnique\"]>[0]>;\n updateMe?: Partial<Parameters<T[\"update\"]>[0]>;\n deleteMe?: Partial<Parameters<T[\"update\"]>[0]>;\n\n // Authentication endpoints\n login?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n signup?: Partial<Parameters<T[\"create\"]>[0]>;\n updatePassword?: Partial<Parameters<T[\"update\"]>[0]>;\n};\n\n/**\n * Interface defining the minimum structure required for Prisma model delegates\n * This allows us to constraint TModel without requiring Prisma imports\n */\nexport type PrismaModelDelegate = {\n create: (args: { data: never; [key: string]: never }) => Promise<any>;\n createMany: (args: { data: never; [key: string]: never }) => Promise<any>;\n findMany: (args: { [key: string]: never }) => Promise<any[]>;\n findFirst: (args: { where: never; [key: string]: never }) => Promise<any>;\n findUnique: (args: { where: never; [key: string]: never }) => Promise<any>;\n update: (args: {\n where: never;\n data: never;\n [key: string]: never;\n }) => Promise<any>;\n updateMany: (args: {\n where: never;\n data: never;\n [key: string]: never;\n }) => Promise<any>;\n delete: (args: { where: never; [key: string]: never }) => Promise<any>;\n deleteMany: (args: { where: never; [key: string]: never }) => Promise<any>;\n count: (args: { where: never; [key: string]: never }) => Promise<number>;\n};\n\nexport interface UserRole {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n roleId: string;\n role: AuthRole;\n user: User;\n userId: string;\n}\n\nexport interface AuthRole {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n name: string;\n permissions: AuthPermission[];\n userRoles: UserRole[];\n}\n\nexport enum AuthPermissionAction {\n Create = \"Create\",\n View = \"View\",\n Update = \"Update\",\n Delete = \"Delete\",\n}\n\nexport interface AuthPermission {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n resource: string;\n action: AuthPermissionAction;\n roleId: string;\n role: AuthRole;\n}\n\nexport interface User {\n id: string;\n isStaff: boolean;\n isSuperUser: boolean;\n password: string;\n passwordChangedAt?: Date;\n deletedSelfAccountAt: Date;\n isActive: boolean;\n roles?: UserRole[] | any[];\n role?: UserRole | any;\n}\n\nexport interface ArkosRequest<Body = any, Query = any> extends Request {\n user?: User & Record<string, any>;\n relationFields?: Record<string, boolean>;\n include?: Record<string, any>;\n responseData?: Record<string, any> | null | undefined;\n additionalData?: Record<string, any> | null | undefined;\n responseStatus?: number | string | null | undefined;\n body: Body;\n prismaQueryOptions?: Record<string, any>;\n // query: Query extends Request['ParsedQs'];\n}\n\nexport interface ArkosResponse extends Response {}\nexport interface ArkosNextFunction extends NextFunction {}\nexport interface ArkosRequestHandler extends RequestHandler {}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;AAwLA,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,yCAAiB,CAAA;IACjB,qCAAa,CAAA;IACb,yCAAiB,CAAA;IACjB,yCAAiB,CAAA;AACnB,CAAC,EALW,oBAAoB,oCAApB,oBAAoB,QAK/B","sourcesContent":["import { NextFunction, Request, RequestHandler, Response } from \"express\";\n\nexport type PrismaOperations = \"findMany\";\n\n/**\n * Type definition for Prisma query operations with flexible options\n * @template T - The Prisma model delegate type\n */\nexport type PrismaQueryOptions<T extends Record<string, any>> = {\n /**\n * @deprecated Use `global` instead for general query options\n */\n queryOptions?: Partial<Parameters<T[\"findMany\"]>[0]>;\n\n /**\n * Global query options that can be used for all operations\n * Replaces the deprecated queryOptions\n */\n global?: Partial<Parameters<T[\"findMany\"]>[0]>;\n\n /**\n * General find options for findMany and findOne operations\n */\n find?: Partial<Parameters<T[\"findMany\"]>[0]>;\n\n /**\n * General create options for createOne and createMany operations\n */\n create?: Partial<Parameters<T[\"create\"]>[0]>;\n\n /**\n * General update options for updateOne and updateMany operations\n */\n update?: Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * General delete options for deleteOne and deleteMany operations\n */\n delete?: Partial<Parameters<T[\"delete\"]>[0]>;\n\n /**\n * General save options for createOne, createMany, updateOne, updateMany operations\n */\n save?:\n | Partial<Parameters<T[\"create\"]>[0]>\n | Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * Save options for single record operations (createOne, updateOne)\n */\n saveOne?:\n | Partial<Parameters<T[\"create\"]>[0]>\n | Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * Save options for multiple record operations (createMany, updateMany)\n */\n saveMany?:\n | Partial<Parameters<T[\"createMany\"]>[0]>\n | Partial<Parameters<T[\"updateMany\"]>[0]>;\n\n /**\n * Options for finding a single record (first match)\n */\n findOne?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n\n /**\n * Options for finding multiple records\n */\n findMany?: Partial<Parameters<T[\"findMany\"]>[0]>;\n\n /**\n * Options for creating a single record\n */\n createOne?: Partial<Parameters<T[\"create\"]>[0]>;\n\n /**\n * Options for creating multiple records\n */\n createMany?: Partial<Parameters<T[\"createMany\"]>[0]>;\n\n /**\n * Options for updating a single record\n */\n updateOne?: Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * Options for updating multiple records\n */\n updateMany?: Partial<Parameters<T[\"updateMany\"]>[0]>;\n\n /**\n * Options for deleting a single record\n */\n deleteOne?: Partial<Parameters<T[\"delete\"]>[0]>;\n\n /**\n * Options for deleting multiple records\n */\n deleteMany?: Partial<Parameters<T[\"deleteMany\"]>[0]>;\n};\n\n/**\n * Type definition for authentication-related Prisma query operations\n * @template T - The Prisma model delegate type\n */\nexport type AuthPrismaQueryOptions<T extends Record<string, any>> = {\n // User profile endpoints\n /**\n * Options for retrieving the current authenticated user's profile\n */\n getMe?: Partial<Parameters<T[\"findUnique\"]>[0]>;\n\n /**\n * Options for updating the current authenticated user's profile\n */\n updateMe?: Partial<Parameters<T[\"update\"]>[0]>;\n\n /**\n * Options for soft deleting or deactivating the current authenticated user's account\n */\n deleteMe?: Partial<Parameters<T[\"update\"]>[0]>;\n\n // Authentication endpoints\n /**\n * Options for user login authentication queries\n */\n login?: Partial<Parameters<T[\"findFirst\"]>[0]>;\n\n /**\n * Options for user registration and account creation\n */\n signup?: Partial<Parameters<T[\"create\"]>[0]>;\n\n /**\n * Options for updating the current authenticated user's password\n */\n updatePassword?: Partial<Parameters<T[\"update\"]>[0]>;\n};\n\n/**\n * Interface defining the minimum structure required for Prisma model delegates\n * This allows us to constraint TModel without requiring Prisma imports\n */\nexport type PrismaModelDelegate = {\n create: (args: { data: never; [key: string]: never }) => Promise<any>;\n createMany: (args: { data: never; [key: string]: never }) => Promise<any>;\n findMany: (args: { [key: string]: never }) => Promise<any[]>;\n findFirst: (args: { where: never; [key: string]: never }) => Promise<any>;\n findUnique: (args: { where: never; [key: string]: never }) => Promise<any>;\n update: (args: {\n where: never;\n data: never;\n [key: string]: never;\n }) => Promise<any>;\n updateMany: (args: {\n where: never;\n data: never;\n [key: string]: never;\n }) => Promise<any>;\n delete: (args: { where: never; [key: string]: never }) => Promise<any>;\n deleteMany: (args: { where: never; [key: string]: never }) => Promise<any>;\n count: (args: { where: never; [key: string]: never }) => Promise<number>;\n};\n\nexport interface UserRole {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n roleId: string;\n role: AuthRole;\n user: User;\n userId: string;\n}\n\nexport interface AuthRole {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n name: string;\n permissions: AuthPermission[];\n userRoles: UserRole[];\n}\n\nexport enum AuthPermissionAction {\n Create = \"Create\",\n View = \"View\",\n Update = \"Update\",\n Delete = \"Delete\",\n}\n\nexport interface AuthPermission {\n id: string;\n createdAt: Date;\n deletedAt?: Date;\n resource: string;\n action: AuthPermissionAction;\n roleId: string;\n role: AuthRole;\n}\n\nexport interface User {\n id: string;\n isStaff: boolean;\n isSuperUser: boolean;\n password: string;\n passwordChangedAt?: Date;\n deletedSelfAccountAt: Date;\n isActive: boolean;\n roles?: UserRole[] | any[];\n role?: UserRole | any;\n}\n\nexport interface ArkosRequest<Body = any, Query = any> extends Request {\n user?: User & Record<string, any>;\n relationFields?: Record<string, boolean>;\n include?: Record<string, any>;\n responseData?: Record<string, any> | null | undefined;\n additionalData?: Record<string, any> | null | undefined;\n responseStatus?: number | string | null | undefined;\n body: Body;\n prismaQueryOptions?: Record<string, any>;\n // query: Query extends Request['ParsedQs'];\n}\n\nexport interface ArkosResponse extends Response {}\nexport interface ArkosNextFunction extends NextFunction {}\nexport interface ArkosRequestHandler extends RequestHandler {}\n"]}
@@ -1,54 +1,176 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.devCommand = devCommand;
7
+ exports.killDevelopmentServerChildProcess = killDevelopmentServerChildProcess;
4
8
  const child_process_1 = require("child_process");
9
+ const chokidar_1 = require("chokidar");
5
10
  const fs_helpers_1 = require("../helpers/fs.helpers");
6
11
  const _1 = require(".");
7
12
  const dotenv_helpers_1 = require("../dotenv.helpers");
8
13
  const global_helpers_1 = require("../helpers/global.helpers");
14
+ const fs_1 = __importDefault(require("fs"));
15
+ let child = null;
16
+ let envFiles;
9
17
  async function devCommand(options = {}) {
10
18
  process.env.NODE_ENV = "development";
11
- const envFiles = (0, dotenv_helpers_1.loadEnvironmentVariables)();
19
+ envFiles = (0, dotenv_helpers_1.loadEnvironmentVariables)();
20
+ child = null;
21
+ let restartTimeout = null;
12
22
  try {
13
23
  const { port, host } = options;
14
24
  const fileExt = (0, fs_helpers_1.getUserFileExtension)();
15
25
  const entryPoint = `src/app.${fileExt}`;
16
- if (!entryPoint) {
17
- console.error("Could not find application entry point.");
26
+ if (!fs_1.default.existsSync(entryPoint)) {
27
+ console.error("Could not find application entry point.");
18
28
  process.exit(1);
19
29
  }
20
- const env = {
30
+ const getEnv = () => ({
21
31
  NODE_ENV: "development",
22
32
  ...process.env,
23
33
  ...(port && { CLI_PORT: port }),
24
34
  ...(host && { CLI_HOST: host }),
35
+ });
36
+ const startServer = () => {
37
+ if (child) {
38
+ child.kill();
39
+ child = null;
40
+ }
41
+ const env = getEnv();
42
+ if (fileExt === "ts") {
43
+ child = (0, child_process_1.spawn)("npx", [
44
+ "ts-node-dev",
45
+ "--respawn",
46
+ "--notify=false",
47
+ "--ignore-watch",
48
+ "node_modules",
49
+ "--ignore-watch",
50
+ "dist",
51
+ "--ignore-watch",
52
+ "build",
53
+ "--ignore-watch",
54
+ ".dist",
55
+ "--ignore-watch",
56
+ ".build",
57
+ "--watch",
58
+ "src",
59
+ entryPoint,
60
+ ], {
61
+ stdio: "inherit",
62
+ env,
63
+ shell: true,
64
+ });
65
+ }
66
+ else {
67
+ child = (0, child_process_1.spawn)("npx", [
68
+ "nodemon",
69
+ "--watch",
70
+ "src",
71
+ "--ext",
72
+ "js,json",
73
+ "--ignore",
74
+ "node_modules/",
75
+ "--ignore",
76
+ "dist/",
77
+ "--ignore",
78
+ "build/",
79
+ "--ignore",
80
+ ".dist/",
81
+ "--ignore",
82
+ ".build/",
83
+ "--delay",
84
+ "1000ms",
85
+ entryPoint,
86
+ ], {
87
+ stdio: "inherit",
88
+ env,
89
+ shell: true,
90
+ });
91
+ }
92
+ if (child) {
93
+ child.on("error", (error) => {
94
+ console.error("Failed to start server:", error);
95
+ });
96
+ child.on("exit", (code, signal) => {
97
+ if (signal !== "SIGTERM" && signal !== "SIGINT") {
98
+ console.info(`Server exited with code ${code}, restarting...`);
99
+ setTimeout(startServer, 1000);
100
+ }
101
+ });
102
+ }
103
+ };
104
+ const scheduleRestart = (reason) => {
105
+ if (restartTimeout)
106
+ clearTimeout(restartTimeout);
107
+ console.info(`\n${reason} `);
108
+ console.info("Restarting server...");
109
+ restartTimeout = setTimeout(() => {
110
+ startServer();
111
+ restartTimeout = null;
112
+ }, 1000);
25
113
  };
26
- let child;
27
- if (fileExt === "ts") {
28
- child = (0, child_process_1.spawn)("npx", ["ts-node-dev", "--respawn", entryPoint], {
29
- stdio: "inherit",
30
- env,
31
- shell: true,
114
+ const setupEnvWatcher = () => {
115
+ const envWatcher = (0, chokidar_1.watch)((0, fs_helpers_1.fullCleanCwd)(envFiles?.join(",") || "")
116
+ .replaceAll("/", "")
117
+ .split(",") || [], {
118
+ ignoreInitial: true,
119
+ persistent: true,
32
120
  });
33
- }
34
- else {
35
- child = (0, child_process_1.spawn)("npx", ["nodemon", entryPoint], {
36
- stdio: "inherit",
37
- env,
38
- shell: true,
121
+ envWatcher.on("all", (event, filePath) => {
122
+ try {
123
+ envFiles = (0, dotenv_helpers_1.loadEnvironmentVariables)();
124
+ scheduleRestart("Environment file changed");
125
+ }
126
+ catch (error) {
127
+ console.error(`Error reloading ${filePath}:`, error);
128
+ }
39
129
  });
40
- }
130
+ return envWatcher;
131
+ };
132
+ const setupAdditionalWatcher = () => {
133
+ const additionalWatcher = (0, chokidar_1.watch)([
134
+ "src",
135
+ "package.json",
136
+ "tsconfig.json",
137
+ "arkos.config.ts",
138
+ "arkos.config.js",
139
+ ], {
140
+ ignoreInitial: true,
141
+ ignored: [
142
+ /node_modules/,
143
+ /\.git/,
144
+ /\.dist/,
145
+ /\.build/,
146
+ /dist/,
147
+ /build/,
148
+ /\.env.*/,
149
+ ],
150
+ });
151
+ additionalWatcher.on("add", (filePath) => {
152
+ scheduleRestart(`New file detected: ${(0, fs_helpers_1.fullCleanCwd)(filePath)}`);
153
+ });
154
+ additionalWatcher.on("unlink", (filePath) => {
155
+ scheduleRestart(`File deleted: ${(0, fs_helpers_1.fullCleanCwd)(filePath)}`);
156
+ });
157
+ return additionalWatcher;
158
+ };
159
+ startServer();
160
+ const envWatcher = setupEnvWatcher();
161
+ const additionalWatcher = setupAdditionalWatcher();
41
162
  const checkConfig = async () => {
42
163
  try {
43
164
  const { getArkosConfig } = await (0, global_helpers_1.importModule)("../../server");
44
165
  const config = getArkosConfig();
45
166
  if (config && config.available) {
167
+ const env = getEnv();
46
168
  console.info("\n");
47
169
  console.info(` \x1b[1m\x1b[36m Arkos.js ${(0, _1.getVersion)()}\x1b[0m`);
48
170
  console.info(` - Local: http://${env.CLI_HOST || config.host || env.HOST || "localhost"}:${env.CLI_PORT || config.port || env.PORT || "8000"}`);
49
- console.info(` - Environments: ${envFiles
50
- ?.join(", ")
51
- .replaceAll(`${process.cwd()}/`, "")}\n`);
171
+ console.info(` - Environments: ${(0, fs_helpers_1.fullCleanCwd)(envFiles?.join(", ") || "")
172
+ .replaceAll(`${process.cwd()}/`, "")
173
+ .replaceAll("/", "")}`);
52
174
  return true;
53
175
  }
54
176
  return false;
@@ -68,25 +190,53 @@ async function devCommand(options = {}) {
68
190
  attempts++;
69
191
  }
70
192
  if (attempts >= maxAttempts) {
193
+ const env = getEnv();
71
194
  console.info("\n");
72
195
  console.info(` \x1b[1m\x1b[36m Arkos.js ${(0, _1.getVersion)()}\x1b[0m`);
73
196
  console.info(` - Local: http://${env.CLI_HOST || env.HOST || "localhost"}:${env.CLI_PORT || env.PORT || "8000"}`);
74
- console.info(` - Environments: ${envFiles
75
- ?.join(", ")
76
- .replaceAll(`${process.cwd()}/`, "")}\n`);
197
+ console.info(` - Environments: ${(0, fs_helpers_1.fullCleanCwd)(envFiles?.join(", ") || "")
198
+ .replaceAll(`${process.cwd()}/`, "")
199
+ .replaceAll("/", "")}`);
77
200
  }
78
201
  };
79
202
  waitForConfig();
80
- process.on("SIGINT", () => {
203
+ const cleanup = () => {
204
+ console.info("\nShutting down development server...");
205
+ if (restartTimeout) {
206
+ clearTimeout(restartTimeout);
207
+ }
208
+ if (envWatcher)
209
+ envWatcher.close();
210
+ if (additionalWatcher)
211
+ additionalWatcher.close();
81
212
  if (child) {
82
- child.kill();
213
+ child.kill("SIGTERM");
214
+ setTimeout(() => {
215
+ if (child && !child.killed) {
216
+ child.kill("SIGKILL");
217
+ }
218
+ }, 5000);
83
219
  }
84
220
  process.exit(0);
221
+ };
222
+ process.on("SIGINT", cleanup);
223
+ process.on("SIGTERM", cleanup);
224
+ process.on("uncaughtException", (error) => {
225
+ console.error("Uncaught Exception:", error);
226
+ cleanup();
85
227
  });
86
228
  }
87
229
  catch (error) {
88
- console.error("Development server failed to start:", error);
230
+ console.error("Development server failed to start:", error);
231
+ if (child) {
232
+ child?.kill?.();
233
+ child = null;
234
+ }
89
235
  process.exit(1);
90
236
  }
91
237
  }
238
+ function killDevelopmentServerChildProcess() {
239
+ child?.kill?.();
240
+ child = null;
241
+ }
92
242
  //# sourceMappingURL=dev.js.map
@@ -1 +1 @@
1
- {"version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MAAM;gBAEjB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;gBACzD,QAAQ,EAAE,CAAC;YACb,CAAC;YAGD,IAAI,QAAQ,IAAI,WAAW,EAAE,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACnB,OAAO,CAAC,IAAI,CAAC,+BAA+B,IAAA,aAAU,GAAE,SAAS,CAAC,CAAC;gBACnE,OAAO,CAAC,IAAI,CACV,4BACE,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI,IAAI,WAC9B,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI,IAAI,MAAM,EAAE,CACzC,CAAC;gBACF,OAAO,CAAC,IAAI,CACV,qBAAqB,QAAQ;oBAC3B,EAAE,IAAI,CAAC,IAAI,CAAC;qBACX,UAAU,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,CAC3C,CAAC;YACJ,CAAC;QACH,CAAC,CAAC;QAEF,aAAa,EAAE,CAAC;QAahB,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACxB,IAAI,KAAK,EAAE,CAAC;gBACV,KAAK,CAAC,IAAI,EAAE,CAAC;YACf,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;QAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC","sourcesContent":["// src/utils/cli/dev.ts\nimport { spawn } from \"child_process\";\nimport { getUserFileExtension } from \"../helpers/fs.helpers\";\nimport { getVersion } from \".\";\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { importModule } from \"../helpers/global.helpers\";\n\ninterface DevOptions {\n port?: string;\n host?: string;\n}\n\n/**\n * Dev server command for the arkos CLI\n */\nexport async function devCommand(options: DevOptions = {}) {\n process.env.NODE_ENV = \"development\";\n\n const envFiles = loadEnvironmentVariables();\n\n try {\n const { port, host } = options;\n\n // Detect if project uses TypeScript or JavaScript\n const fileExt = getUserFileExtension();\n\n // Find the application entry point\n const entryPoint = `src/app.${fileExt}`;\n\n if (!entryPoint) {\n console.error(\"❌ Could not find application entry point.\");\n process.exit(1);\n }\n\n // Set environment variables\n const env: { [x: string]: string } = {\n NODE_ENV: \"development\",\n ...process.env,\n ...(port && { CLI_PORT: port }),\n ...(host && { CLI_HOST: host }),\n };\n\n // Start the application with the appropriate runner\n let child;\n\n // Setup file watching if enabled\n if (fileExt === \"ts\") {\n child = spawn(\"npx\", [\"ts-node-dev\", \"--respawn\", entryPoint], {\n stdio: \"inherit\",\n env,\n shell: true,\n });\n } else {\n child = spawn(\"npx\", [\"nodemon\", entryPoint], {\n stdio: \"inherit\",\n env,\n shell: true,\n });\n }\n\n const checkConfig = async () => {\n try {\n // Import the config getter\n\n const { getArkosConfig } = await importModule(\"../../server\");\n\n const config = getArkosConfig();\n\n if (config && config.available) {\n // Config is ready, display the info with actual values\n console.info(\"\\n\");\n console.info(` \\x1b[1m\\x1b[36m Arkos.js ${getVersion()}\\x1b[0m`);\n console.info(\n ` - Local: http://${\n env.CLI_HOST || config.host || env.HOST || \"localhost\"\n }:${env.CLI_PORT || config.port || env.PORT || \"8000\"}`\n );\n console.info(\n ` - Environments: ${envFiles\n ?.join(\", \")\n .replaceAll(`${process.cwd()}/`, \"\")}\\n`\n );\n return true;\n }\n return false;\n } catch (error) {\n return false;\n }\n };\n\n // Try to get config periodically\n const waitForConfig = async () => {\n let attempts = 0;\n const maxAttempts = 15;\n\n while (attempts < maxAttempts) {\n const ready = await checkConfig();\n if (ready) break;\n\n await new Promise((resolve) => setTimeout(resolve, 300));\n attempts++;\n }\n\n // Fall back to defaults if config never became available\n if (attempts >= maxAttempts) {\n console.info(\"\\n\");\n console.info(` \\x1b[1m\\x1b[36m Arkos.js ${getVersion()}\\x1b[0m`);\n console.info(\n ` - Local: http://${\n env.CLI_HOST || env.HOST || \"localhost\"\n }:${env.CLI_PORT || env.PORT || \"8000\"}`\n );\n console.info(\n ` - Environments: ${envFiles\n ?.join(\", \")\n .replaceAll(`${process.cwd()}/`, \"\")}\\n`\n );\n }\n };\n\n waitForConfig();\n\n // console.info(` \\x1b[1m\\x1b[36m Arkos.js ${getVersion()}\\x1b[0m`);\n // console.info(\n // ` - Local: http://${env.HOST || host}:${env.PORT || port}`\n // );\n // console.info(\n // ` - Environments: ${envFiles\n // ?.join(\", \")\n // .replaceAll(`${process.cwd()}/`, \"\")}\\n`\n // );\n\n // Handle process exit\n process.on(\"SIGINT\", () => {\n if (child) {\n child.kill();\n }\n process.exit(0);\n });\n } catch (error) {\n console.error(\"❌ Development server failed to start:\", error);\n process.exit(1);\n }\n}\n"]}
1
+ {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../../../src/utils/cli/dev.ts"],"names":[],"mappings":";;;;;AAmBA,gCAySC;AAKD,8EAGC;AApUD,iDAAoD;AACpD,uCAAiC;AACjC,sDAA2E;AAC3E,wBAA+B;AAC/B,sDAA6D;AAC7D,8DAAyD;AACzD,4CAAoB;AAOpB,IAAI,KAAK,GAAwB,IAAI,CAAC;AACtC,IAAI,QAA8B,CAAC;AAK5B,KAAK,UAAU,UAAU,CAAC,UAAsB,EAAE;IACvD,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,aAAa,CAAC;IACrC,QAAQ,GAAG,IAAA,yCAAwB,GAAE,CAAC;IACtC,KAAK,GAAG,IAAI,CAAC;IACb,IAAI,cAAc,GAA0B,IAAI,CAAC;IAEjD,IAAI,CAAC;QACH,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QAG/B,MAAM,OAAO,GAAG,I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leanCwd, getUserFileExtension } from \"../helpers/fs.helpers\";\nimport { getVersion } from \".\";\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { importModule } from \"../helpers/global.helpers\";\nimport fs from \"fs\";\n\ninterface DevOptions {\n port?: string;\n host?: string;\n}\n\nlet child: ChildProcess | null = null;\nlet envFiles: string[] | undefined;\n\n/**\n * Dev server command for the arkos CLI\n */\nexport async function devCommand(options: DevOptions = {}) {\n process.env.NODE_ENV = \"development\";\n envFiles = loadEnvironmentVariables();\n child = null;\n let restartTimeout: NodeJS.Timeout | null = null;\n\n try {\n const { port, host } = options;\n\n // Detect if project uses TypeScript or JavaScript\n const fileExt = getUserFileExtension();\n\n // Find the application entry point\n const entryPoint = `src/app.${fileExt}`;\n\n if (!fs.existsSync(entryPoint)) {\n console.error(\"Could not find application entry point.\");\n process.exit(1);\n }\n\n // Set environment variables\n const getEnv = () =>\n ({\n NODE_ENV: \"development\",\n ...process.env,\n ...(port && { CLI_PORT: port }),\n ...(host && { CLI_HOST: host }),\n }) as { [x: string]: string };\n\n // Function to start the child process\n const startServer = () => {\n if (child) {\n child.kill();\n child = null;\n }\n\n const env = getEnv();\n\n if (fileExt === \"ts\") {\n // Enhanced ts-node-dev configuration\n child = spawn(\n \"npx\",\n [\n \"ts-node-dev\",\n \"--respawn\",\n \"--notify=false\", // Disable desktop notifications\n \"--ignore-watch\",\n \"node_modules\",\n \"--ignore-watch\",\n \"dist\",\n \"--ignore-watch\",\n \"build\",\n \"--ignore-watch\",\n \".dist\",\n \"--ignore-watch\",\n \".build\",\n \"--watch\",\n \"src\", // Explicitly watch src directory\n entryPoint,\n ],\n {\n stdio: \"inherit\",\n env,\n shell: true,\n }\n );\n } else {\n // Enhanced nodemon configuration\n child = spawn(\n \"npx\",\n [\n \"nodemon\",\n \"--watch\",\n \"src\",\n \"--ext\",\n \"js,json\",\n \"--ignore\",\n \"node_modules/\",\n \"--ignore\",\n \"dist/\",\n \"--ignore\",\n \"build/\",\n \"--ignore\",\n \".dist/\",\n \"--ignore\",\n \".build/\",\n \"--delay\",\n \"1000ms\",\n entryPoint,\n ],\n {\n stdio: \"inherit\",\n env,\n shell: true,\n }\n );\n }\n\n if (child) {\n child.on(\"error\", (error) => {\n console.error(\"Failed to start server:\", error);\n });\n\n child.on(\"exit\", (code, signal) => {\n if (signal !== \"SIGTERM\" && signal !== \"SIGINT\") {\n console.info(`Server exited with code ${code}, restarting...`);\n setTimeout(startServer, 1000);\n }\n });\n }\n };\n\n // Function to handle server restart with debouncing\n const scheduleRestart = (reason: string) => {\n if (restartTimeout) clearTimeout(restartTimeout);\n\n console.info(`\\n${reason} `);\n console.info(\"Restarting server...\");\n\n restartTimeout = setTimeout(() => {\n startServer();\n restartTimeout = null;\n }, 1000);\n };\n\n // Setup environment file watching\n const setupEnvWatcher = () => {\n const envWatcher = watch(\n fullCleanCwd(envFiles?.join(\",\") || \"\")\n .replaceAll(\"/\", \"\")\n .split(\",\") || [],\n {\n ignoreInitial: true,\n persistent: true,\n }\n );\n\n envWatcher.on(\"all\", (event, filePath) => {\n try {\n envFiles = loadEnvironmentVariables();\n\n // Restart server to pick up new env vars\n scheduleRestart(\"Environment file changed\");\n } catch (error) {\n console.error(`Error reloading ${filePath}:`, error);\n }\n });\n\n return envWatcher;\n };\n\n // Setup additional file watching for better new file detection\n const setupAdditionalWatcher = () => {\n const additionalWatcher = watch(\n [\n \"src\",\n \"package.json\",\n \"tsconfig.json\",\n \"arkos.config.ts\",\n \"arkos.config.js\",\n ],\n {\n ignoreInitial: true,\n ignored: [\n /node_modules/,\n /\\.git/,\n /\\.dist/,\n /\\.build/,\n /dist/,\n /build/,\n /\\.env.*/,\n ],\n }\n );\n\n additionalWatcher.on(\"add\", (filePath) => {\n scheduleRestart(`New file detected: ${fullCleanCwd(filePath)}`);\n });\n\n additionalWatcher.on(\"unlink\", (filePath) => {\n scheduleRestart(`File deleted: ${fullCleanCwd(filePath)}`);\n });\n\n return additionalWatcher;\n };\n\n // Start the server\n startServer();\n\n // Setup watchers if enabled\n const envWatcher = setupEnvWatcher();\n const additionalWatcher = setupAdditionalWatcher();\n\n const checkConfig = async () => {\n try {\n // Import the config getter\n const { getArkosConfig } = await importModule(\"../../server\");\n const config = getArkosConfig();\n if (config && config.available) {\n // Config is ready, display the info with actual values\n const env = getEnv();\n console.info(\"\\n\");\n console.info(` \\x1b[1m\\x1b[36m Arkos.js ${getVersion()}\\x1b[0m`);\n console.info(\n ` - Local: http://${\n env.CLI_HOST || config.host || env.HOST || \"localhost\"\n }:${env.CLI_PORT || config.port || env.PORT || \"8000\"}`\n );\n console.info(\n ` - Environments: ${fullCleanCwd(envFiles?.join(\", \") || \"\")\n .replaceAll(`${process.cwd()}/`, \"\")\n .replaceAll(\"/\", \"\")}`\n );\n return true;\n }\n return false;\n } catch (error) {\n return false;\n }\n };\n\n // Try to get config periodically\n const waitForConfig = async () => {\n let attempts = 0;\n const maxAttempts = 15;\n while (attempts < maxAttempts) {\n const ready = await checkConfig();\n if (ready) break;\n await new Promise((resolve) => setTimeout(resolve, 300));\n attempts++;\n }\n\n // Fall back to defaults if config never became available\n if (attempts >= maxAttempts) {\n const env = getEnv();\n console.info(\"\\n\");\n console.info(` \\x1b[1m\\x1b[36m Arkos.js ${getVersion()}\\x1b[0m`);\n console.info(\n ` - Local: http://${\n env.CLI_HOST || env.HOST || \"localhost\"\n }:${env.CLI_PORT || env.PORT || \"8000\"}`\n );\n console.info(\n ` - Environments: ${fullCleanCwd(envFiles?.join(\", \") || \"\")\n .replaceAll(`${process.cwd()}/`, \"\")\n .replaceAll(\"/\", \"\")}`\n );\n }\n };\n\n waitForConfig();\n\n // Enhanced cleanup function\n const cleanup = () => {\n console.info(\"\\nShutting down development server...\");\n\n if (restartTimeout) {\n clearTimeout(restartTimeout);\n }\n\n if (envWatcher) envWatcher.close();\n\n if (additionalWatcher) additionalWatcher.close();\n\n if (child) {\n child.kill(\"SIGTERM\");\n\n // Force kill after 5 seconds if still running\n setTimeout(() => {\n if (child && !child.killed) {\n child.kill(\"SIGKILL\");\n }\n }, 5000);\n }\n\n process.exit(0);\n };\n\n // Handle process exit\n process.on(\"SIGINT\", cleanup);\n process.on(\"SIGTERM\", cleanup);\n\n // Handle uncaught exceptions\n process.on(\"uncaughtException\", (error) => {\n console.error(\"Uncaught Exception:\", error);\n cleanup();\n });\n } catch (error) {\n console.error(\"Development server failed to start:\", error);\n\n if (child) {\n (child as ChildProcess)?.kill?.();\n child = null;\n }\n\n process.exit(1);\n }\n}\n\n/**\n * Help function to help other processes to terminate the development server child process\n */\nexport function killDevelopmentServerChildProcess() {\n (child as ChildProcess)?.kill?.();\n child = null;\n}\n"]}
@@ -17,8 +17,9 @@ Object.defineProperty(exports, "startCommand", { enumerable: true, get: function
17
17
  const generate_1 = require("./generate");
18
18
  Object.defineProperty(exports, "generateCommand", { enumerable: true, get: function () { return generate_1.generateCommand; } });
19
19
  function getVersion() {
20
- const packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, "../../../../package.json"), "utf8"));
21
- return packageJson.version || "1.0.0";
20
+ const packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, "../../../../package.json"), "utf8") ||
21
+ "{}");
22
+ return packageJson?.version || "1.0.0";
22
23
  }
23
24
  const program = new commander_1.Command();
24
25
  exports.program = program;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/cli/index.ts"],"names":[],"mappings":";;;;;;AASA,gCAMC;AAdD,yCAAoC;AACpC,mCAAuC;AA8FrB,6FA9FT,oBAAY,OA8FS;AA7F9B,gDAAwB;AACxB,4CAAoB;AACpB,+BAAmC;AA2FH,2FA3FvB,gBAAU,OA2FuB;AA1F1C,mCAAuC;AA0FK,6FA1FnC,oBAAY,OA0FmC;AAzFxD,yCAA6C;AAyFa,gGAzFjD,0BAAe,OAyFiD;AAvFzE,SAAgB,UAAU;IACxB,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC5B,YAAE,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AC,mBAAmB,EAAE,4BAA4B,EAAE,aAAa,CAAC;KACxE,MAAM,CAAC,0BAAe,CAAC,WAAW,CAAC,CAAC;AAEvC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC","sourcesContent":["// src/utils/cli/index.ts\nimport { Command } from \"commander\";\nimport { buildCommand } from \"./build\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport { devCommand } from \"./dev\";\nimport { startCommand } from \"./start\";\nimport { generateCommand } from \"./generate\";\n\nexport function getVersion() {\n const packageJson = JSON.parse(\n fs.readFileSync(path.join(__dirname, \"../../../../package.json\"), \"utf8\")\n );\n\n return packageJson.version || \"1.0.0\";\n}\n\nconst program = new Command();\n\nprogram.name(\"arkos\").description(\"Arkos.js CLI\").version(getVersion());\n\nprogram\n .command(\"build\")\n .description(\"Build your Arkos project\")\n .option(\"-m, --module <type>\", \"Module type (cjs or esm)\", \"cjs\")\n .action(buildCommand);\n\nprogram\n .command(\"dev\")\n .description(\"Run development server\")\n .option(\"-p, --port <number>\", \"Port number\")\n .option(\"-h, --host <host>\", \"Host to bind to\")\n .action(devCommand);\n\nprogram\n .command(\"start\")\n .description(\"Run production server\")\n .option(\"-p, --port <number>\", \"Port number\")\n .option(\"-h, --host <host>\", \"Host to bind to\")\n .action(startCommand);\n\n// Generate command with alias 'g'\nconst generate = program\n .command(\"generate\")\n .alias(\"g\")\n .description(\"Generate arkos components\");\n\ngenerate\n .command(\"controller\")\n .alias(\"c\")\n .description(\"Generate a new controller\")\n .requiredOption(\"-m, --model <name>\", \"Model name\")\n .option(\"-p, --path <path>\", \"Custom path for the controller\", \"src/modules\")\n .action(generateCommand.controller);\n\ngenerate\n .command(\"service\")\n .alias(\"s\")\n .description(\"Generate a new service\")\n .requiredOption(\"-m, --model <name>\", \"Model name\")\n .option(\"-p, --path <path>\", \"Custom path for the service\", \"src/modules\")\n .action(generateCommand.service);\n\ngenerate\n .command(\"router\")\n .alias(\"r\")\n .description(\"Generate a new router\")\n .requiredOption(\"-m, --model <name>\", \"Model name\")\n .option(\"-p, --path <path>\", \"Custom path for the router\", \"src/modules\")\n .action(generateCommand.router);\n\ngenerate\n .command(\"auth-configs\")\n .alias(\"a\")\n .description(\"Generate auth configuration\")\n .option(\"--path <path>\", \"Custom path for auth config\", \"src/modules\")\n .action(generateCommand.authConfigs);\n\ngenerate\n .command(\"query-options\")\n .alias(\"q\")\n .description(\"Generate prisma query options\")\n .requiredOption(\"-m, --model <name>\", \"Model name\")\n .option(\"-p, --path <path>\", \"Custom path for query options\", \"src/modules\")\n .action(generateCommand.queryOptions);\n\ngenerate\n .command(\"middlewares\")\n .alias(\"m\")\n .description(\"Generate a new middleware file\")\n .requiredOption(\"-m, --model <name>\", \"Middleware name\")\n .option(\"-p, --path <path>\", \"Custom path for middleware\", \"src/modules\")\n .action(generateCommand.middlewares);\n\nprogram.parse(process.argv);\n\nexport { program, buildCommand, devCommand, startCommand, generateCommand };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/cli/index.ts"],"names":[],"mappings":";;;;;;AASA,gCAOC;AAfD,yCAAoC;AACpC,mCAAuC;AA+FrB,6FA/FT,oBAAY,OA+FS;AA9F9B,gDAAwB;AACxB,4CAAoB;AACpB,+BAAmC;AA4FH,2FA5FvB,gBAAU,OA4FuB;AA3F1C,mCAAuC;AA2FK,6FA3FnC,oBAAY,OA2FmC;AA1FxD,yCAA6C;AA0Fa,gGA1FjD,0BAAe,OA0FiD;AAxFzE,SAAgB,UAAU;IACxB,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC5B,YAAE,CAAC,YAAY,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,0BAA0B,CAAC,EAAE,MAAM,CAAC;QACvE,IAAI,CACP,CAAC;IAEF,OAAO,WAAW,EAAE,OAAO,IAAI,OAAO,CAAC;AACzC,CAAC;AAED,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AA+ErB,0BAAO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import path from \"path\";\nimport fs from \"fs\";\nimport { devCommand } from \"./dev\";\nimport { startCommand } from \"./start\";\nimport { generateCommand } from \"./generate\";\n\nexport function getVersion() {\n const packageJson = JSON.parse(\n fs.readFileSync(path.join(__dirname, \"../../../../package.json\"), \"utf8\") ||\n \"{}\"\n );\n\n return packageJson?.version || \"1.0.0\";\n}\n\nconst program = new Command();\n\nprogram.name(\"arkos\").description(\"Arkos.js CLI\").version(getVersion());\n\nprogram\n .command(\"build\")\n .description(\"Build your Arkos project\")\n .option(\"-m, --module <type>\", \"Module type (cjs or esm)\", \"cjs\")\n .action(buildCommand);\n\nprogram\n .command(\"dev\")\n .description(\"Run development server\")\n .option(\"-p, --port <number>\", \"Port number\")\n .option(\"-h, --host <host>\", \"Host to bind to\")\n .action(devCommand);\n\nprogram\n .command(\"start\")\n .description(\"Run production server\")\n .option(\"-p, --port <number>\", \"Port number\")\n .option(\"-h, --host <host>\", \"Host to bind to\")\n .action(startCommand);\n\n// Generate command with alias 'g'\nconst generate = program\n .command(\"generate\")\n .alias(\"g\")\n .description(\"Generate arkos components\");\n\ngenerate\n .command(\"controller\")\n .alias(\"c\")\n .description(\"Generate a new controller\")\n .requiredOption(\"-m, --model <name>\", \"Model name\")\n .option(\"-p, --path <path>\", \"Custom path for the controller\", \"src/modules\")\n .action(generateCommand.controller);\n\ngenerate\n .command(\"service\")\n .alias(\"s\")\n .description(\"Generate a new service\")\n .requiredOption(\"-m, --model <name>\", \"Model name\")\n .option(\"-p, --path <path>\", \"Custom path for the service\", \"src/modules\")\n .action(generateCommand.service);\n\ngenerate\n .command(\"router\")\n .alias(\"r\")\n .description(\"Generate a new router\")\n .requiredOption(\"-m, --model <name>\", \"Model name\")\n .option(\"-p, --path <path>\", \"Custom path for the router\", \"src/modules\")\n .action(generateCommand.router);\n\ngenerate\n .command(\"auth-configs\")\n .alias(\"a\")\n .description(\"Generate auth configuration\")\n .option(\"--path <path>\", \"Custom path for auth config\", \"src/modules\")\n .action(generateCommand.authConfigs);\n\ngenerate\n .command(\"query-options\")\n .alias(\"q\")\n .description(\"Generate prisma query options\")\n .requiredOption(\"-m, --model <name>\", \"Model name\")\n .option(\"-p, --path <path>\", \"Custom path for query options\", \"src/modules\")\n .action(generateCommand.queryOptions);\n\ngenerate\n .command(\"middlewares\")\n .alias(\"m\")\n .description(\"Generate a new middleware file\")\n .requiredOption(\"-m, --model <name>\", \"Middleware name\")\n .option(\"-p, --path <path>\", \"Custom path for middleware\", \"src/modules\")\n .action(generateCommand.middlewares);\n\nprogram.parse(process.argv);\n\nexport { program, buildCommand, devCommand, startCommand, generateCommand };\n"]}
@@ -4,15 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.startCommand = startCommand;
7
+ exports.killProductionServerChildProcess = killProductionServerChildProcess;
7
8
  const path_1 = __importDefault(require("path"));
8
9
  const fs_1 = __importDefault(require("fs"));
9
10
  const child_process_1 = require("child_process");
10
11
  const _1 = require(".");
11
12
  const dotenv_helpers_1 = require("../dotenv.helpers");
12
13
  const global_helpers_1 = require("../helpers/global.helpers");
14
+ const fs_helpers_1 = require("../helpers/fs.helpers");
15
+ let child = null;
16
+ let envFiles;
13
17
  async function startCommand(options = {}) {
14
18
  process.env.NODE_ENV = "production";
15
- const envFiles = (0, dotenv_helpers_1.loadEnvironmentVariables)();
19
+ envFiles = (0, dotenv_helpers_1.loadEnvironmentVariables)();
16
20
  try {
17
21
  const { port, host } = options;
18
22
  const entryPoint = path_1.default.join(".build", "src", "app.js");
@@ -27,7 +31,7 @@ async function startCommand(options = {}) {
27
31
  ...(host && { CLI_HOST: host }),
28
32
  ARKOS_BUILD: "true",
29
33
  };
30
- const child = (0, child_process_1.spawn)("node", [entryPoint], {
34
+ child = (0, child_process_1.spawn)("node", [entryPoint], {
31
35
  stdio: "inherit",
32
36
  env,
33
37
  shell: true,
@@ -38,6 +42,7 @@ async function startCommand(options = {}) {
38
42
  }
39
43
  process.exit(0);
40
44
  });
45
+ console.log(envFiles);
41
46
  const checkConfig = async () => {
42
47
  try {
43
48
  const { getArkosConfig } = await (0, global_helpers_1.importModule)("../../server");
@@ -46,12 +51,7 @@ async function startCommand(options = {}) {
46
51
  console.info("\n");
47
52
  console.info(` \x1b[1m\x1b[36m Arkos.js ${(0, _1.getVersion)()}\x1b[0m`);
48
53
  console.info(` - Local: http://${env.CLI_HOST || config.host || env.HOST || "localhost"}:${env.CLI_PORT || config.port || env.PORT || "8000"}`);
49
- console.info(` - Environments: ${envFiles
50
- ?.join(", ")
51
- .replaceAll(`${process.cwd()}/`, "")
52
- .replaceAll(`/${process.cwd()}`, "")
53
- .replaceAll(`/${process.cwd()}/`, "")
54
- .replaceAll(`${process.cwd()}`, "")}\n`);
54
+ console.info(` - Environments: ${(0, fs_helpers_1.fullCleanCwd)(envFiles?.join(", ") || "").replaceAll("/", "")}\n`);
55
55
  return true;
56
56
  }
57
57
  return false;
@@ -87,4 +87,8 @@ async function startCommand(options = {}) {
87
87
  process.exit(1);
88
88
  }
89
89
  }
90
+ function killProductionServerChildProcess() {
91
+ child?.kill?.();
92
+ child = null;
93
+ }
90
94
  //# sourceMappingURL=start.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"start.js","sourceRoot":"","sources":["../../../../src/utils/cli/start.ts"],"names":[],"mappings":";;;;;AAiBA,oCA4GC;AA5HD,gDAAwB;AACxB,4CAAoB;AACpB,iDAAsC;AAEtC,wBAA+B;AAC/B,sDAA6D;AAC7D,8DAAyD;AAUlD,KAAK,UAAU,YAAY,CAAC,UAAwB,EAAE;IAC3D,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;IACpC,MAAM,QAAQ,GAAG,IAAA,yCAAwB,GAAE,CAAC;IAE5C,IAAI,CAAC;QACH,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QAG/B,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,QA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AC;YACb,CAAC;YAGD,IAAI,QAAQ,IAAI,WAAW,EAAE,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACnB,OAAO,CAAC,IAAI,CAAC,+BAA+B,IAAA,aAAU,GAAE,SAAS,CAAC,CAAC;gBACnE,OAAO,CAAC,IAAI,CACV,4BACE,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI,IAAI,WAC9B,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI,IAAI,MAAM,EAAE,CACzC,CAAC;gBACF,OAAO,CAAC,IAAI,CACV,qBAAqB,QAAQ;oBAC3B,EAAE,IAAI,CAAC,IAAI,CAAC;qBACX,UAAU,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,CAC3C,CAAC;YACJ,CAAC;QACH,CAAC,CAAC;QAEF,aAAa,EAAE,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;QAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC","sourcesContent":["// src/utils/cli/start.ts\nimport path from \"path\";\nimport fs from \"fs\";\nimport { spawn } from \"child_process\";\nimport { getArkosConfig } from \"../../server\";\nimport { getVersion } from \".\";\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { importModule } from \"../helpers/global.helpers\";\n\ninterface StartOptions {\n port?: string;\n host?: string;\n}\n\n/**\n * Production start command for the arkos CLI\n */\nexport async function startCommand(options: StartOptions = {}) {\n process.env.NODE_ENV = \"production\";\n const envFiles = loadEnvironmentVariables();\n\n try {\n const { port, host } = options;\n\n // Check for built app file\n const entryPoint = path.join(\".build\", \"src\", \"app.js\");\n\n if (!fs.existsSync(path.join(process.cwd(), entryPoint))) {\n console.error(\n `❌ Could not find built application entry point at ${entryPoint}`\n );\n process.exit(1);\n }\n\n // Set environment variables\n const env: { [x: string]: string } = {\n ...process.env,\n NODE_ENV: \"production\",\n ...(port && { CLI_PORT: port }),\n ...(host && { CLI_HOST: host }),\n ARKOS_BUILD: \"true\",\n };\n\n // Start the application\n const child = spawn(\"node\", [entryPoint], {\n stdio: \"inherit\",\n env,\n shell: true,\n });\n\n // Handle process exit\n process.on(\"SIGINT\", () => {\n if (child) {\n child.kill();\n }\n process.exit(0);\n });\n\n const checkConfig = async () => {\n try {\n const { getArkosConfig } = await importModule(\"../../server\");\n\n const config = getArkosConfig();\n\n if (config && config.available) {\n // Config is ready, display the info with actual values\n console.info(\"\\n\");\n console.info(` \\x1b[1m\\x1b[36m Arkos.js ${getVersion()}\\x1b[0m`);\n console.info(\n ` - Local: http://${\n env.CLI_HOST || config.host || env.HOST || \"localhost\"\n }:${env.CLI_PORT || config.port || env.PORT || \"8000\"}`\n );\n console.info(\n ` - Environments: ${envFiles\n ?.join(\", \")\n .replaceAll(`${process.cwd()}/`, \"\")\n .replaceAll(`/${process.cwd()}`, \"\")\n .replaceAll(`/${process.cwd()}/`, \"\")\n .replaceAll(`${process.cwd()}`, \"\")}\\n`\n );\n return true;\n }\n return false;\n } catch (error) {\n console.info(error);\n return false;\n }\n };\n\n // Try to get config periodically\n const waitForConfig = async () => {\n let attempts = 0;\n const maxAttempts = 15;\n\n while (attempts < maxAttempts) {\n const ready = await checkConfig();\n if (ready) break;\n\n await new Promise((resolve) => setTimeout(resolve, 300));\n attempts++;\n }\n\n // Fall back to defaults if config never became available\n if (attempts >= maxAttempts) {\n console.info(\"\\n\");\n console.info(` \\x1b[1m\\x1b[36m Arkos.js ${getVersion()}\\x1b[0m`);\n console.info(\n ` - Local: http://${\n env.CLI_HOST || env.HOST || \"localhost\"\n }:${env.CLI_PORT || env.PORT || \"8000\"}`\n );\n console.info(\n ` - Environments: ${envFiles\n ?.join(\", \")\n .replaceAll(`${process.cwd()}/`, \"\")}\\n`\n );\n }\n };\n\n waitForConfig();\n } catch (error) {\n console.error(\"❌ Production server failed to start:\", error);\n process.exit(1);\n }\n}\n"]}
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../../../src/utils/cli/start.ts"],"names":[],"mappings":";;;;;AAoBA,oCAyGC;AAKD,4EAGC;AApID,gDAAwB;AACxB,4CAAoB;AACpB,iDAAoD;AACpD,wBAA+B;AAC/B,sDAA6D;AAC7D,8DAAyD;AACzD,sDAAqD;AAOrD,IAAI,KAAK,GAAwB,IAAI,CAAC;AACtC,IAAI,QAA8B,CAAC;AAK5B,KAAK,UAAU,YAAY,CAAC,UAAwB,EAAE;IAC3D,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;IACpC,QAAQ,GAAG,IAAA,yCAAwB,GAAE,CAAC;IAEtC,IAAI,CAAC;QACH,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QAG/B,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAExD,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC;YACzD,OAAO,CAAC,KAAK,CACX,qDAAqD,UAAU,EAAE,CAClE,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAGD,MAAM,GAAG,GAA4B;YACnC,GAAG,OAAO,CAAC,GAAG;YACd,QAAQ,EAAE,YAAY;YACtB,GAAG,CAAC,IAAI,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YAC/B,GAAG,CAAC,IAAI,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YAC/B,WAAW,EAAE,MAAM;SACpB,CAAC;QAGF,KAAK,GAAG,IAAA,qBAAK,EAAC,MAAM,EAAE,CAAC,UAAU,CAAC,EAAE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sB,EAAE,IAAI,EAAE,EAAE,CAAC;IAClC,KAAK,GAAG,IAAI,CAAC;AACf,CAAC","sourcesContent":["// src/utils/cli/start.ts\nimport path from \"path\";\nimport fs from \"fs\";\nimport { ChildProcess, spawn } from \"child_process\";\nimport { getVersion } from \".\";\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { importModule } from \"../helpers/global.helpers\";\nimport { fullCleanCwd } from \"../helpers/fs.helpers\";\n\ninterface StartOptions {\n port?: string;\n host?: string;\n}\n\nlet child: ChildProcess | null = null;\nlet envFiles: string[] | undefined;\n\n/**\n * Production start command for the arkos CLI\n */\nexport async function startCommand(options: StartOptions = {}) {\n process.env.NODE_ENV = \"production\";\n envFiles = loadEnvironmentVariables();\n\n try {\n const { port, host } = options;\n\n // Check for built app file\n const entryPoint = path.join(\".build\", \"src\", \"app.js\");\n\n if (!fs.existsSync(path.join(process.cwd(), entryPoint))) {\n console.error(\n `❌ Could not find built application entry point at ${entryPoint}`\n );\n process.exit(1);\n }\n\n // Set environment variables\n const env: { [x: string]: string } = {\n ...process.env,\n NODE_ENV: \"production\",\n ...(port && { CLI_PORT: port }),\n ...(host && { CLI_HOST: host }),\n ARKOS_BUILD: \"true\",\n };\n\n // Start the application\n child = spawn(\"node\", [entryPoint], {\n stdio: \"inherit\",\n env,\n shell: true,\n });\n\n // Handle process exit\n process.on(\"SIGINT\", () => {\n if (child) {\n child.kill();\n }\n process.exit(0);\n });\n\n console.log(envFiles);\n\n const checkConfig = async () => {\n try {\n const { getArkosConfig } = await importModule(\"../../server\");\n\n const config = getArkosConfig();\n\n if (config && config.available) {\n // Config is ready, display the info with actual values\n console.info(\"\\n\");\n console.info(` \\x1b[1m\\x1b[36m Arkos.js ${getVersion()}\\x1b[0m`);\n console.info(\n ` - Local: http://${\n env.CLI_HOST || config.host || env.HOST || \"localhost\"\n }:${env.CLI_PORT || config.port || env.PORT || \"8000\"}`\n );\n console.info(\n ` - Environments: ${fullCleanCwd(envFiles?.join(\", \") || \"\").replaceAll(\"/\", \"\")}\\n`\n );\n return true;\n }\n return false;\n } catch (error) {\n console.info(error);\n return false;\n }\n };\n\n // Try to get config periodically\n const waitForConfig = async () => {\n let attempts = 0;\n const maxAttempts = 15;\n\n while (attempts < maxAttempts) {\n const ready = await checkConfig();\n if (ready) break;\n\n await new Promise((resolve) => setTimeout(resolve, 300));\n attempts++;\n }\n\n // Fall back to defaults if config never became available\n if (attempts >= maxAttempts) {\n console.info(\"\\n\");\n console.info(` \\x1b[1m\\x1b[36m Arkos.js ${getVersion()}\\x1b[0m`);\n console.info(\n ` - Local: http://${\n env.CLI_HOST || env.HOST || \"localhost\"\n }:${env.CLI_PORT || env.PORT || \"8000\"}`\n );\n console.info(\n ` - Environments: ${envFiles\n ?.join(\", \")\n .replaceAll(`${process.cwd()}/`, \"\")}\\n`\n );\n }\n };\n\n waitForConfig();\n } catch (error) {\n console.error(\"❌ Production server failed to start:\", error);\n process.exit(1);\n }\n}\n\n/**\n * Help function to help other processes to terminate the production server child process\n */\nexport function killProductionServerChildProcess() {\n (child as ChildProcess)?.kill?.();\n child = null;\n}\n"]}
@@ -4,10 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ensureDirectoryExists = ensureDirectoryExists;
7
+ exports.killServerChildProcess = killServerChildProcess;
7
8
  const fs_1 = __importDefault(require("fs"));
9
+ const dev_1 = require("../dev");
10
+ const start_1 = require("../start");
8
11
  function ensureDirectoryExists(dirPath) {
9
12
  if (!fs_1.default.existsSync(dirPath)) {
10
13
  fs_1.default.mkdirSync(dirPath, { recursive: true });
11
14
  }
12
15
  }
16
+ function killServerChildProcess() {
17
+ (0, dev_1.killDevelopmentServerChildProcess)();
18
+ (0, start_1.killProductionServerChildProcess)();
19
+ }
13
20
  //# sourceMappingURL=cli.helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.helpers.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/cli.helpers.ts"],"names":[],"mappings":";;;;;AAEA,sDAIC;AAND,4CAAoB;AAEpB,SAAgB,qBAAqB,CAAC,OAAe;IACnD,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,YAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC","sourcesContent":["import fs from \"fs\";\n\nexport function ensureDirectoryExists(dirPath: string): void {\n if (!fs.existsSync(dirPath)) {\n fs.mkdirSync(dirPath, { recursive: true });\n }\n}\n"]}
1
+ {"version":3,"file":"cli.helpers.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/cli.helpers.ts"],"names":[],"mappings":";;;;;AAIA,sDAIC;AAED,wDAGC;AAbD,4CAAoB;AACpB,gCAA2D;AAC3D,oCAA4D;AAE5D,SAAgB,qBAAqB,CAAC,OAAe;IACnD,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,YAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,SAAgB,sBAAsB;IACpC,IAAA,uCAAiC,GAAE,CAAC;IACpC,IAAA,wCAAgC,GAAE,CAAC;AACrC,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"]}
@@ -20,7 +20,7 @@ function fullCleanCwd(path) {
20
20
  if (typeof path !== "string")
21
21
  throw new Error("Path must be a string");
22
22
  const cwd = process.cwd().replace(/\/+$/, "");
23
- return path.replace(new RegExp(`^${cwd}/?`), "");
23
+ return path.replace(new RegExp(`${cwd}/?`, "g"), "");
24
24
  }
25
25
  const getUserFileExtension = () => {
26
26
  if (exports.userFileExtension)
@@ -1 +1 @@
1
- {"version":3,"file":"fs.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/fs.helpers.ts"],"names":[],"mappings":";;;;;;AAoBA,oCAKC;AAkDD,0CAMC;AAjFD,+BAAiC;AACjC,4CAAoB;AACpB,gDAAwB;AAEX,QAAA,SAAS,GAAG,IAAA,gBAAS,EAAC,YAAE,CAAC,IAAI,CAAC,CAAC;AAC/B,QAAA,WAAW,GAAG,IAAA,gBAAS,EAAC,YAAE,CAAC,MAAM,CAAC,CAAC;AACnC,QAAA,UAAU,GAAG,IAAA,gBAAS,EAAC,YAAE,CAAC,KAAK,CAAC,CAAC;AAEvC,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;AAHP,QAAA,GAAG,OAGI;AASpB,SAAgB,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,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC;AASM,MAAM,oBAAoB,GAAG,GAAgB,EAAE;IACpD,IAAI,yBAAiB;QAAE,OAAO,yBAAiB,CAAC;IAEhD,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAGjC,MAAM,WAAW,GAAG,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;QAG1E,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM,CAAC;QAGvD,IAAI,WAAW,IAAI,CAAC,WAAW,EAAE,CAAC;YAChC,yBAAiB,GAAG,IAAI,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,yBAAiB,GAAG,IAAI,CAAC;QAC3B,CAAC;QAED,OAAO,yBAAiB,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QAEX,yBAAiB,GAAG,IAAI,CAAC;QACzB,OAAO,yBAAiB,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC;AAzBW,QAAA,oBAAoB,wBAyB/B;AAgBF,SAAgB,eAAe,CAAC,QAAgB;IAC9C,IAAI,CAAC;QACH,OAAO,YAAE,CAAC,UAAU,CAAC,cAAI,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 *\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 return path.replace(new RegExp(`^${cwd}/?`), \"\"); // 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 environment variable for build mode\n const isBuildMode = process.env.ARKOS_BUILD === \"true\";\n\n // If tsconfig exists and not in build mode, use TypeScript\n if (hasTsConfig && !isBuildMode) {\n userFileExtension = \"ts\";\n } else {\n userFileExtension = \"js\";\n }\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.log('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"]}
1
+ {"version":3,"file":"fs.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/fs.helpers.ts"],"names":[],"mappings":";;;;;;AAoBA,oCAKC;AAkDD,0CAMC;AAjFD,+BAAiC;AACjC,4CAAoB;AACpB,gDAAwB;AAEX,QAAA,SAAS,GAAG,IAAA,gBAAS,EAAC,YAAE,CAAC,IAAI,CAAC,CAAC;AAC/B,QAAA,WAAW,GAAG,IAAA,gBAAS,EAAC,YAAE,CAAC,MAAM,CAAC,CAAC;AACnC,QAAA,UAAU,GAAG,IAAA,gBAAS,EAAC,YAAE,CAAC,KAAK,CAAC,CAAC;AAEvC,MAAM,GAAG,GAAG,GAAG,EAAE,CACtB,OAAO,CAAC,GAAG,CAAC,WAAW,KAA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AAC,UAAU,CAAC,cAAI,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 *\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 return path.replace(new RegExp(`${cwd}/?`, \"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 environment variable for build mode\n const isBuildMode = process.env.ARKOS_BUILD === \"true\";\n\n // If tsconfig exists and not in build mode, use TypeScript\n if (hasTsConfig && !isBuildMode) {\n userFileExtension = \"ts\";\n } else {\n userFileExtension = \"js\";\n }\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.log('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"]}
@@ -53,6 +53,7 @@ const fs_1 = __importDefault(require("fs"));
53
53
  const change_case_helpers_1 = require("../../utils/helpers/change-case.helpers");
54
54
  const fs_helpers_1 = require("./fs.helpers");
55
55
  const global_helpers_1 = require("./global.helpers");
56
+ const cli_helpers_1 = require("../cli/utils/cli.helpers");
56
57
  exports.prismaModelsModules = {};
57
58
  function getModelModules(modelName) {
58
59
  return exports.prismaModelsModules[(0, change_case_helpers_1.kebabCase)(modelName)];
@@ -144,21 +145,25 @@ async function processSubdir(modelName, type, result) {
144
145
  function validateNamingConventions(key, fileName, result) {
145
146
  if (key === "prismaQueryOptions") {
146
147
  if (result.prismaQueryOptions) {
148
+ (0, cli_helpers_1.killServerChildProcess)();
147
149
  throw new Error(`\n Cannot use both ${fileName} and ${fileName.replace("prisma-query-options", "query")} at once, please choose only one name convention. \n`);
148
150
  }
149
151
  }
150
152
  else if (key === "prismaQueryOptionsNew") {
151
153
  if (result.prismaQueryOptions) {
154
+ (0, cli_helpers_1.killServerChildProcess)();
152
155
  throw new Error(`\n Cannot use both ${fileName} and ${fileName.replace("query", "prisma-query-options")} at once, please choose only one name convention. \n`);
153
156
  }
154
157
  }
155
158
  else if (key === "authConfigs") {
156
159
  if (result.authConfigs) {
160
+ (0, cli_helpers_1.killServerChildProcess)();
157
161
  throw new Error(`\n Cannot use both ${fileName} and ${fileName.replace("auth-configs", "auth")} at once, please choose only one name convention. \n`);
158
162
  }
159
163
  }
160
164
  else if (key === "authConfigsNew") {
161
165
  if (result.authConfigs) {
166
+ (0, cli_helpers_1.killServerChildProcess)();
162
167
  throw new Error(`\n Cannot use both ${fileName} and ${fileName.replace("auth", "auth-configs")} at once, please choose only one name convention. \n`);
163
168
  }
164
169
  }
@@ -191,6 +196,7 @@ async function importPrismaModelModules(modelName) {
191
196
  if (!err.message.includes("Cannot find module")) {
192
197
  console.error(`Failed to import ${fileName}: \n`);
193
198
  console.error(err);
199
+ (0, cli_helpers_1.killServerChildProcess)();
194
200
  process.exit(1);
195
201
  }
196
202
  });
@@ -203,6 +209,7 @@ async function importPrismaModelModules(modelName) {
203
209
  if (err.message.includes("Cannot use both"))
204
210
  throw err;
205
211
  console.error(err);
212
+ (0, cli_helpers_1.killServerChildProcess)();
206
213
  }
207
214
  }));
208
215
  await Promise.all([