arkos 1.4.0-canary.2 → 1.4.0-canary.4

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 (28) hide show
  1. package/README.md +3 -1
  2. package/dist/cjs/modules/file-upload/utils/helpers/file-upload.helpers.js +10 -14
  3. package/dist/cjs/modules/file-upload/utils/helpers/file-upload.helpers.js.map +1 -1
  4. package/dist/cjs/utils/cli/build.js +1 -1
  5. package/dist/cjs/utils/cli/build.js.map +1 -1
  6. package/dist/cjs/utils/cli/generate.js +7 -6
  7. package/dist/cjs/utils/cli/generate.js.map +1 -1
  8. package/dist/cjs/utils/cli/index.js +12 -12
  9. package/dist/cjs/utils/cli/index.js.map +1 -1
  10. package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
  11. package/dist/cjs/utils/cli/utils/template-generators.js +1 -1
  12. package/dist/cjs/utils/cli/utils/template-generators.js.map +1 -1
  13. package/dist/cjs/utils/helpers/fs.helpers.js +9 -3
  14. package/dist/cjs/utils/helpers/fs.helpers.js.map +1 -1
  15. package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js +10 -14
  16. package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js.map +1 -1
  17. package/dist/esm/utils/cli/build.js +1 -1
  18. package/dist/esm/utils/cli/build.js.map +1 -1
  19. package/dist/esm/utils/cli/generate.js +7 -6
  20. package/dist/esm/utils/cli/generate.js.map +1 -1
  21. package/dist/esm/utils/cli/index.js +12 -12
  22. package/dist/esm/utils/cli/index.js.map +1 -1
  23. package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
  24. package/dist/esm/utils/cli/utils/template-generators.js +1 -1
  25. package/dist/esm/utils/cli/utils/template-generators.js.map +1 -1
  26. package/dist/esm/utils/helpers/fs.helpers.js +9 -3
  27. package/dist/esm/utils/helpers/fs.helpers.js.map +1 -1
  28. package/package.json +3 -3
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  ![Header Image](https://www.arkosjs.com/img/arkos-readme-header.webp?v=2)
2
2
 
3
- ## The Express And Prisma RESTful Framework
3
+ <div align="center">
4
+ <h2>The Express And Prisma RESTful Framework</h2>
5
+ </div>
4
6
 
5
7
  Arkos.js simplifies the development of secure and scalable RESTful APIs with minimal configuration, allowing developers to focus on what really matters for their business logic.
6
8
 
@@ -21,7 +21,9 @@ function adjustRequestUrl(req, _, next) {
21
21
  }
22
22
  function extractRequestInfo(req) {
23
23
  const { fileUpload } = (0, server_1.getArkosConfig)();
24
- const protocol = req.headers["x-forwarded-proto"] === "https" ? "https" : "http";
24
+ const protocol = req.secure || req.headers["x-forwarded-proto"] === "https"
25
+ ? "https"
26
+ : "http";
25
27
  const baseURL = `${protocol}://${req.get?.("host")}`;
26
28
  const baseRoute = fileUpload?.baseRoute || "/api/uploads";
27
29
  return { baseURL, baseRoute };
@@ -42,19 +44,16 @@ const generateRelativePath = (filePath, fileType) => {
42
44
  };
43
45
  const processFile = async (req, filePath) => {
44
46
  const { baseURL, baseRoute } = extractRequestInfo(req);
45
- const relativePath = generateRelativePath(filePath, req.params.fileType);
46
- return `${baseURL}${baseRoute === "/" ? "" : baseRoute}/${relativePath}`;
47
+ const relativePath = generateRelativePath(filePath, req.params.fileType).replace(/\\/g, "/");
48
+ return `${baseURL}${baseRoute === "/" ? "" : baseRoute}${relativePath.startsWith("/") ? relativePath : `/${relativePath}`}`;
47
49
  };
48
50
  exports.processFile = processFile;
49
51
  const processImage = async (req, filePath, options) => {
50
- const { baseURL, baseRoute } = extractRequestInfo(req);
51
52
  const ext = path_1.default.extname(filePath).toLowerCase();
52
53
  const originalFormat = ext.replace(".", "");
53
54
  const outputFormat = options.format || originalFormat;
54
- if (!mimetype_1.default.lookup(ext)?.includes?.("image")) {
55
- const relativePath = generateRelativePath(filePath, req.params.fileType);
56
- return `${baseURL}${baseRoute}/${relativePath}`;
57
- }
55
+ if (!mimetype_1.default.lookup(ext)?.includes?.("image"))
56
+ return (0, exports.processFile)(req, filePath);
58
57
  const tempName = `${path_1.default.basename(filePath, ext)}_${Date.now()}${ext}`;
59
58
  const tempPath = path_1.default.join(path_1.default.dirname(filePath), tempName);
60
59
  try {
@@ -72,16 +71,13 @@ const processImage = async (req, filePath, options) => {
72
71
  fit: "inside",
73
72
  });
74
73
  }
75
- if (outputFormat === "webp") {
74
+ if (outputFormat === "webp")
76
75
  transformer = transformer.toFormat("webp");
77
- }
78
- else if (outputFormat === "jpeg" || outputFormat === "jpg") {
76
+ else if (outputFormat === "jpeg" || outputFormat === "jpg")
79
77
  transformer = transformer.toFormat("jpeg");
80
- }
81
78
  await transformer.toFile(tempPath);
82
79
  await (0, util_1.promisify)(fs_1.default.rename)(tempPath, filePath);
83
- const relativePath = generateRelativePath(filePath, req?.params.fileType);
84
- return `${baseURL}${baseRoute}/${relativePath}`;
80
+ return (0, exports.processFile)(req, filePath);
85
81
  }
86
82
  catch (error) {
87
83
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"file-upload.helpers.js","sourceRoot":"","sources":["../../../../../../src/modules/file-upload/utils/helpers/file-upload.helpers.ts"],"names":[],"mappings":";;;;;;AAaA,4CAYC;AAED,gDASC;AApCD,4CAAoB;AACpB,gDAAwB;AACxB,kDAA0B;AAC1B,+BAAiC;AACjC,+CAAoD;AACpD,wDAAgC;AAMhC,qEAAoE;AAEpE,SAAgB,gBAAgB,CAC9B,GAAiB,EACjB,CAAgB,EAChB,IAAuB;IAEvB,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,uBAAc,GAAE,CAAC;IACxC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CACvB,UAAU,EAAE,SAAS,GAAG,GAAG,IAAI,eAAe,EAC9C,GAAG,CACJ,CAAC;IACF,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,SAAS,IAAI,eAAe,EAAE,GAAG,CAAC,CAAC;IACzE,IAAI,EAAE,CAAC;AACT,CAAC;A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YAAE,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAG/C,MAAM,YAAY,GAAG,oBAAoB,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAO,CAAC,QAAQ,CAAC,CAAC;QAE3E,OAAO,GAAG,OAAO,GAAG,SAAS,IAAI,YAAY,EAAE,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAEf,IAAI,CAAC;YACH,MAAM,IAAA,gBAAS,EAAC,YAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC;YACnC,MAAM,IAAA,gBAAS,EAAC,YAAE,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;QAEf,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AArEW,QAAA,YAAY,gBAqEvB","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport sharp from \"sharp\";\nimport { promisify } from \"util\";\nimport { getArkosConfig } from \"../../../../server\";\nimport mimetype from \"mimetype\";\nimport {\n ArkosNextFunction,\n ArkosRequest,\n ArkosResponse,\n} from \"../../../../types\";\nimport { fullCleanCwd } from \"../../../../utils/helpers/fs.helpers\";\n\nexport function adjustRequestUrl(\n req: ArkosRequest,\n _: ArkosResponse,\n next: ArkosNextFunction\n) {\n const { fileUpload } = getArkosConfig();\n req.url = req.url.replace(\n fileUpload?.baseRoute + \"/\" || \"/api/uploads/\",\n \"/\"\n );\n req.url = req.url.replace(fileUpload?.baseRoute || \"/api/uploads/\", \"/\");\n next();\n}\n\nexport function extractRequestInfo(req: ArkosRequest) {\n const { fileUpload } = getArkosConfig();\n\n // Determine the base URL for file access\n const protocol =\n req.headers[\"x-forwarded-proto\"] === \"https\" ? \"https\" : \"http\";\n const baseURL = `${protocol}://${req.get?.(\"host\")}`;\n const baseRoute = fileUpload?.baseRoute || \"/api/uploads\";\n return { baseURL, baseRoute };\n}\n\n/**\n * Generates the correct relative path regardless of upload directory location\n */\nconst generateRelativePath = (filePath: string, fileType: string) => {\n const { fileUpload } = getArkosConfig();\n\n const baseUploadDir = fileUpload?.baseUploadDir || \"/uploads\";\n if (baseUploadDir.startsWith(\"..\")) {\n // For paths outside project directory\n return path.join(fileType, path.basename(filePath));\n } else {\n // For paths within project\n return fullCleanCwd(\n filePath\n .replace(`${baseUploadDir}/`, \"\")\n .replace(`/${baseUploadDir}/`, \"\")\n .replace(`/${baseUploadDir}`, \"\")\n .replace(`${baseUploadDir}`, \"\")\n );\n }\n};\n\n/**\n * Handles basic file processing for non-image files\n */\nexport const processFile = async (\n req: ArkosRequest,\n filePath: string\n): Promise<string> => {\n const { baseURL, baseRoute } = extractRequestInfo(req);\n\n const relativePath = generateRelativePath(filePath, req.params!.fileType);\n return `${baseURL}${baseRoute === \"/\" ? \"\" : baseRoute}/${relativePath}`;\n};\n\n/**\n * Processes image files using Sharp for resizing and format conversion\n */\nexport const processImage = async (\n req: ArkosRequest,\n filePath: string,\n options: Record<string, any>\n): Promise<string | null> => {\n const { baseURL, baseRoute } = extractRequestInfo(req);\n\n const ext = path.extname(filePath).toLowerCase();\n const originalFormat = ext.replace(\".\", \"\");\n const outputFormat = options.format || originalFormat;\n\n if (!mimetype.lookup(ext)?.includes?.(\"image\")) {\n const relativePath = generateRelativePath(filePath, req.params!.fileType);\n return `${baseURL}${baseRoute}/${relativePath}`;\n }\n\n // Create a temp filename with original name + random string\n const tempName = `${path.basename(filePath, ext)}_${Date.now()}${ext}`;\n const tempPath = path.join(path.dirname(filePath), tempName);\n\n try {\n let transformer = sharp(filePath);\n const metadata = await transformer.metadata();\n\n // Apply resize transformations if requested\n if (options.resizeTo && metadata.width && metadata.height) {\n const targetSize = options.resizeTo;\n const scaleFactor =\n targetSize / Math.min(metadata.width, metadata.height);\n const newWidth = Math.round(metadata.width * scaleFactor);\n const newHeight = Math.round(metadata.height * scaleFactor);\n transformer = transformer.resize(newWidth, newHeight);\n } else if (options.width || options.height) {\n transformer = transformer.resize(\n options.width || null,\n options.height || null,\n {\n fit: \"inside\",\n }\n );\n }\n\n // Apply format transformations if requested\n if (outputFormat === \"webp\") {\n transformer = transformer.toFormat(\"webp\");\n } else if (outputFormat === \"jpeg\" || outputFormat === \"jpg\") {\n transformer = transformer.toFormat(\"jpeg\");\n }\n\n // Save to temp file first\n await transformer.toFile(tempPath);\n\n // Rename temp file to original filename\n await promisify(fs.rename)(tempPath, filePath);\n\n // Return the public URL for the file\n const relativePath = generateRelativePath(filePath, req?.params!.fileType);\n\n return `${baseURL}${baseRoute}/${relativePath}`;\n } catch (error) {\n // Clean up temp file if it exists\n try {\n await promisify(fs.stat)(tempPath);\n await promisify(fs.unlink)(tempPath);\n } catch (err) {\n // If temp file doesn't exist, no need to clean up\n }\n throw error;\n }\n};\n"]}
1
+ {"version":3,"file":"file-upload.helpers.js","sourceRoot":"","sources":["../../../../../../src/modules/file-upload/utils/helpers/file-upload.helpers.ts"],"names":[],"mappings":";;;;;;AAaA,4CAYC;AAED,gDAWC;AAtCD,4CAAoB;AACpB,gDAAwB;AACxB,kDAA0B;AAC1B,+BAAiC;AACjC,+CAAoD;AACpD,wDAAgC;AAMhC,qEAAoE;AAEpE,SAAgB,gBAAgB,CAC9B,GAAiB,EACjB,CAAgB,EAChB,IAAuB;IAEvB,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,uBAAc,GAAE,CAAC;IACxC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CACvB,UAAU,EAAE,SAAS,GAAG,GAAG,IAAI,eAAe,EAC9C,GAAG,CACJ,CAAC;IACF,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,SAAS,IAAI,eAAe,EAAE,GAAG,CAAC,CAAC;IACzE,IAAI,EAAE,CAAC;AACT,CAAC;AAED,SAAgB,kBAAkB,CAAC,GAAiB;IAClD,MAAM,EAAE,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,EAAE,CAAC;QACf,IAAI,CAAC;YACH,MAAM,IAAA,gBAAS,EAAC,YAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC;YACnC,MAAM,IAAA,gBAAS,EAAC,YAAE,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;QAEf,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAtDW,QAAA,YAAY,gBAsDvB","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport sharp from \"sharp\";\nimport { promisify } from \"util\";\nimport { getArkosConfig } from \"../../../../server\";\nimport mimetype from \"mimetype\";\nimport {\n ArkosNextFunction,\n ArkosRequest,\n ArkosResponse,\n} from \"../../../../types\";\nimport { fullCleanCwd } from \"../../../../utils/helpers/fs.helpers\";\n\nexport function adjustRequestUrl(\n req: ArkosRequest,\n _: ArkosResponse,\n next: ArkosNextFunction\n) {\n const { fileUpload } = getArkosConfig();\n req.url = req.url.replace(\n fileUpload?.baseRoute + \"/\" || \"/api/uploads/\",\n \"/\"\n );\n req.url = req.url.replace(fileUpload?.baseRoute || \"/api/uploads/\", \"/\");\n next();\n}\n\nexport function extractRequestInfo(req: ArkosRequest) {\n const { fileUpload } = getArkosConfig();\n\n // Determine the base URL for file access\n const protocol =\n req.secure || req.headers[\"x-forwarded-proto\"] === \"https\"\n ? \"https\"\n : \"http\";\n const baseURL = `${protocol}://${req.get?.(\"host\")}`;\n const baseRoute = fileUpload?.baseRoute || \"/api/uploads\";\n return { baseURL, baseRoute };\n}\n\n/**\n * Generates the correct relative path regardless of upload directory location\n */\nconst generateRelativePath = (filePath: string, fileType: string) => {\n const { fileUpload } = getArkosConfig();\n\n const baseUploadDir = fileUpload?.baseUploadDir || \"/uploads\";\n if (baseUploadDir.startsWith(\"..\")) {\n return path.join(fileType, path.basename(filePath));\n } else {\n return fullCleanCwd(\n filePath\n .replace(`${baseUploadDir}/`, \"\")\n .replace(`/${baseUploadDir}/`, \"\")\n .replace(`/${baseUploadDir}`, \"\")\n .replace(`${baseUploadDir}`, \"\")\n );\n }\n};\n\n/**\n * Handles basic file processing for non-image files\n */\nexport const processFile = async (\n req: ArkosRequest,\n filePath: string\n): Promise<string> => {\n const { baseURL, baseRoute } = extractRequestInfo(req);\n\n const relativePath = generateRelativePath(\n filePath,\n req.params!.fileType\n ).replace(/\\\\/g, \"/\");\n\n return `${baseURL}${baseRoute === \"/\" ? \"\" : baseRoute}${\n relativePath.startsWith(\"/\") ? relativePath : `/${relativePath}`\n }`;\n};\n\n/**\n * Processes image files using Sharp for resizing and format conversion\n */\nexport const processImage = async (\n req: ArkosRequest,\n filePath: string,\n options: Record<string, any>\n): Promise<string | null> => {\n const ext = path.extname(filePath).toLowerCase();\n const originalFormat = ext.replace(\".\", \"\");\n const outputFormat = options.format || originalFormat;\n\n if (!mimetype.lookup(ext)?.includes?.(\"image\"))\n return processFile(req, filePath);\n\n const tempName = `${path.basename(filePath, ext)}_${Date.now()}${ext}`;\n const tempPath = path.join(path.dirname(filePath), tempName);\n\n try {\n let transformer = sharp(filePath);\n const metadata = await transformer.metadata();\n\n if (options.resizeTo && metadata.width && metadata.height) {\n const targetSize = options.resizeTo;\n const scaleFactor =\n targetSize / Math.min(metadata.width, metadata.height);\n const newWidth = Math.round(metadata.width * scaleFactor);\n const newHeight = Math.round(metadata.height * scaleFactor);\n transformer = transformer.resize(newWidth, newHeight);\n } else if (options.width || options.height) {\n transformer = transformer.resize(\n options.width || null,\n options.height || null,\n {\n fit: \"inside\",\n }\n );\n }\n\n if (outputFormat === \"webp\") transformer = transformer.toFormat(\"webp\");\n else if (outputFormat === \"jpeg\" || outputFormat === \"jpg\")\n transformer = transformer.toFormat(\"jpeg\");\n\n await transformer.toFile(tempPath);\n\n await promisify(fs.rename)(tempPath, filePath);\n\n return processFile(req, filePath);\n } catch (error) {\n try {\n await promisify(fs.stat)(tempPath);\n await promisify(fs.unlink)(tempPath);\n } catch (err) {\n // If temp file doesn't exist, no need to clean up\n }\n throw error;\n }\n};\n"]}
@@ -92,7 +92,7 @@ function buildTypeScriptProject(options, moduleType) {
92
92
  const tempTsconfigPath = path_1.default.join(process.cwd(), `tsconfig.arkos-build.json`);
93
93
  fs_1.default.writeFileSync(tempTsconfigPath, JSON.stringify(tempTsconfig, null, 2));
94
94
  try {
95
- (0, child_process_1.execSync)(`npx rimraf ${BUILD_DIR} && npx tsc -p ${tempTsconfigPath}`, {
95
+ (0, child_process_1.execSync)(`npx trash ${BUILD_DIR} && npx tsc -p ${tempTsconfigPath}`, {
96
96
  stdio: "inherit",
97
97
  cwd: process.cwd(),
98
98
  });
@@ -1 +1 @@
1
- {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../src/utils/cli/build.ts"],"names":[],"mappings":";;;;;AAsBA,oCAyCC;AA/DD,gDAAwB;AACxB,4CAAoB;AACpB,iDAAyC;AACzC,sDAA2E;AAC3E,sDAA6D;AAC7D,qDAAiD;AACjD,8DAA8E;AAC9E,mDAA2B;AAG3B,MAAM,SAAS,GAAG,QAAQ,CAAC;AAC3B,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,KAAK,CAAU,CAAC;AAW7C,SAAgB,YAAY,CAAC,UAAwB,EAAE;IACrD,MAAM,OAAO,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACvC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,MAAM,CAAC;IAE9B,MAAM,QAAQ,GAAG,IAAA,yCAAwB,GAAE,CAAC;IAC5C,MAAM,UAAU,GAAG,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtD,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,+BAA+B,IAAA,wBAAU,GAAE,SAAS,CAAC,CAAC;QACnE,OAAO,CAAC,IAAI,CACV,qBAAqB,IAAA,yBAAY,EAAC,QA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AC,UAAU,CAAC,UAAU,CAAC;YAAE,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC3D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,8CAA8C,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;AACH,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { execSync } from \"child_process\";\nimport { fullCleanCwd, getUserFileExtension } from \"../helpers/fs.helpers\";\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { getVersion } from \"./utils/cli.helpers\";\nimport { detectPackageManagerFromUserAgent } from \"../helpers/global.helpers\";\nimport sheu from \"../sheu\";\n\n// Constants\nconst BUILD_DIR = \".build\";\nconst MODULE_TYPES = [\"cjs\", \"esm\"] as const;\ntype ModuleType = (typeof MODULE_TYPES)[number];\n\ninterface BuildOptions {\n config?: string;\n module?: string;\n}\n\n/**\n * Main build function for the arkos CLI\n */\nexport function buildCommand(options: BuildOptions = {}) {\n const fileExt = getUserFileExtension();\n process.env.NODE_ENV = \"production\";\n process.env.NODE_ENV = \"true\";\n\n const envFiles = loadEnvironmentVariables();\n const moduleType = validateModuleType(options.module);\n\n try {\n console.info(` \\x1b[1m\\x1b[36m Arkos.js ${getVersion()}\\x1b[0m`);\n console.info(\n ` - Environments: ${fullCleanCwd(envFiles?.join(\", \") || \"\")\n .replaceAll(`${process.cwd()}/`, \"\")\n .replaceAll(\"/\", \"\")}`\n );\n\n console.info(`\\n Creating an optimized production build...`);\n\n ensureBuildDir();\n\n // Detect project type\n\n if (fileExt === \"ts\") {\n buildTypeScriptProject(options, moduleType);\n } else {\n buildJavaScriptProject(options, moduleType);\n }\n\n const packageManger = detectPackageManagerFromUserAgent();\n\n console.info(`\\n\\x1b[1m\\x1b[32m Build complete!\\x1b[0m\\n`);\n console.info(` \\x1b[1mNext step:\\x1b[0m`);\n console.info(\n ` Run it using \\x1b[1m\\x1b[36m${packageManger} run start\\x1b[0m\\n`\n );\n } catch (err: any) {\n console.info(\"\");\n sheu.error(`Build failed: ${err?.message}`);\n console.error(err);\n process.exit(1);\n }\n}\n\n/**\n * Validates and normalizes module type option\n */\nfunction validateModuleType(moduleType?: string): ModuleType {\n if (!moduleType) return \"cjs\";\n\n const normalizedType = moduleType.toLowerCase();\n\n // Map common terms to our module types\n if (normalizedType === \"cjs\" || normalizedType === \"commonjs\") {\n return \"cjs\";\n } else if (\n [\"esm\", \"es\", \"es2020\", \"esnext\", \"module\"].includes(normalizedType)\n ) {\n return \"esm\";\n }\n\n // Default to CJS if unrecognized\n console.warn(\n `⚠️ Unrecognized module type \"${moduleType}\", defaulting to \"cjs\"`\n );\n return \"cjs\";\n}\n\n/**\n * Ensure the build directory exists\n */\nfunction ensureBuildDir() {\n if (!fs.existsSync(BUILD_DIR)) {\n fs.mkdirSync(BUILD_DIR, { recursive: true });\n }\n\n // Create module-specific subdirectories\n for (const moduleType of MODULE_TYPES) {\n const moduleDir = path.join(BUILD_DIR, moduleType);\n if (!fs.existsSync(moduleDir)) {\n fs.mkdirSync(moduleDir, { recursive: true });\n }\n }\n}\n\n/**\n * Build a TypeScript project\n */\nfunction buildTypeScriptProject(options: BuildOptions, moduleType: ModuleType) {\n // Read the user's tsconfig.json\n const tsconfigPath = path.join(\n process.cwd(),\n options.config || \"tsconfig.json\"\n );\n let tsconfig: any = {};\n\n try {\n if (fs.existsSync(tsconfigPath)) {\n const tsconfigContent = fs.readFileSync(tsconfigPath, \"utf8\");\n tsconfig = JSON.parse(tsconfigContent);\n }\n } catch (error) {\n console.error(\"❌ Error reading tsconfig.json:\", error);\n // Continue with default config\n }\n\n // Create a custom tsconfig that outputs to our build directory with the correct module type\n const tempTsconfig = {\n ...tsconfig,\n compilerOptions: {\n ...(tsconfig.compilerOptions || {}),\n rootDir: \".\",\n outDir: path.join(`./${BUILD_DIR}`),\n // module: moduleType === \"esm\" ? \"ESNext\" : \"CommonJS\",\n },\n };\n\n const tempTsconfigPath = path.join(\n process.cwd(),\n `tsconfig.arkos-build.json`\n );\n fs.writeFileSync(tempTsconfigPath, JSON.stringify(tempTsconfig, null, 2));\n\n try {\n // Run TypeScript compiler\n execSync(`npx rimraf ${BUILD_DIR} && npx tsc -p ${tempTsconfigPath}`, {\n stdio: \"inherit\",\n cwd: process.cwd(),\n });\n\n // Copy non-TypeScript files\n\n copyAllNonSourceFiles(moduleType, [\".ts\", \".tsx\"]);\n\n // Clean up temp config\n cleanupTempConfig(tempTsconfigPath);\n } catch (error) {\n cleanupTempConfig(tempTsconfigPath);\n throw error;\n }\n}\n\n/**\n * Build a JavaScript project\n */\nfunction buildJavaScriptProject(_: BuildOptions, moduleType: ModuleType) {\n // Target directory\n const targetDir = path.join(BUILD_DIR);\n\n try {\n // Copy JavaScript files based on module type\n if (moduleType === \"esm\") {\n // Copy JS files for ESM (skip .cjs files as they are CommonJS)\n\n execSync(\n `npx copyfiles -u 0 \"src/**/*.js\" \"src/**/*.jsx\" \"src/**/*.mjs\" ${targetDir}`,\n {\n stdio: \"inherit\",\n cwd: process.cwd(),\n }\n );\n\n // Note about CommonJS files\n console.info(\"Note: .cjs files are skipped in ESM build\");\n } else {\n // Copy all JS files for CommonJS\n\n execSync(\n `npx copyfiles -u 0 \"src/**/*.js\" \"src/**/*.jsx\" \"src/**/*.cjs\" \"src/**/*.mjs\" ${targetDir}`,\n {\n stdio: \"inherit\",\n cwd: process.cwd(),\n }\n );\n }\n\n // Copy all non-JS files\n copyAllNonSourceFiles(moduleType, [\n \".js\",\n \".jsx\",\n \".mjs\",\n \".cjs\",\n \".ts\",\n \".tsx\",\n ]);\n\n // Create appropriate package.json in the build directory\n createModulePackageJson(moduleType);\n } catch (error) {\n console.error(\"❌ Error building JavaScript project:\", error);\n throw error;\n }\n}\n\n/**\n * Copy all non-source code files to the build directory\n * This function will copy everything except the specified source file extensions\n */\nfunction copyAllNonSourceFiles(_: ModuleType, skipExtensions: string[]) {\n const targetDir = path.join(BUILD_DIR);\n const sourceDir = \"src\";\n\n try {\n // Recursive function to copy files\n function copyDirRecursive(dir: string) {\n if (!fs.existsSync(dir)) return;\n\n const items = fs.readdirSync(dir);\n\n for (const item of items) {\n const sourcePath = path.join(dir, item);\n const targetPath = path.join(\n targetDir,\n dir.replace(sourceDir, \"\"),\n item\n );\n\n // Get file stats\n const stats = fs.statSync(sourcePath);\n\n if (stats.isDirectory()) {\n // Ensure target directory exists\n if (!fs.existsSync(targetPath)) {\n fs.mkdirSync(targetPath, { recursive: true });\n }\n // Recurse into subdirectory\n copyDirRecursive(sourcePath);\n } else if (stats.isFile()) {\n // Check if this is a file we should skip\n const ext = path.extname(item).toLowerCase();\n if (!skipExtensions.includes(ext)) {\n // Ensure the target directory exists\n const targetDir = path.dirname(targetPath);\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true });\n }\n // Copy the file\n fs.copyFileSync(sourcePath, targetPath);\n }\n }\n }\n }\n\n // Start copying from src directory\n copyDirRecursive(sourceDir);\n\n // Copy project root files if needed\n const rootFilesToCopy = [\"README.md\", \"LICENSE\"];\n\n for (const file of rootFilesToCopy) {\n if (fs.existsSync(path.join(process.cwd(), file))) {\n fs.copyFileSync(\n path.join(process.cwd(), file),\n path.join(targetDir, file)\n );\n }\n }\n\n // console.info(`Copied all non-source files to ${targetDir}`);\n } catch (error) {\n console.warn(\"Warning: Error copying project files:\", error);\n console.error(error);\n }\n}\n\n/**\n * Create appropriate package.json in the build directory\n */\nfunction createModulePackageJson(moduleType: ModuleType) {\n const packageJsonPath = path.join(process.cwd(), \"package.json\");\n\n if (!fs.existsSync(packageJsonPath)) {\n return;\n }\n\n try {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf8\"));\n const buildPackageJson: any = {\n name: packageJson.name,\n version: packageJson.version,\n description: packageJson.description,\n main: \"index.js\",\n dependencies: packageJson.dependencies,\n };\n\n // Set appropriate type field for ESM\n if (moduleType === \"esm\") {\n buildPackageJson.type = \"module\";\n }\n\n const targetDir = path.join(BUILD_DIR, moduleType);\n fs.writeFileSync(\n path.join(targetDir, \"package.json\"),\n JSON.stringify(buildPackageJson, null, 2)\n );\n } catch (error) {\n console.warn(\n \"Warning: Failed to create module-specific package.json\",\n error\n );\n }\n}\n\n/**\n * Clean up temporary tsconfig\n */\nfunction cleanupTempConfig(configPath: string) {\n try {\n if (fs.existsSync(configPath)) fs.unlinkSync(configPath);\n } catch (error) {\n console.warn(\"Warning: Error cleaning up temporary config:\", error);\n }\n}\n"]}
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../src/utils/cli/build.ts"],"names":[],"mappings":";;;;;AAsBA,oCAyCC;AA/DD,gDAAwB;AACxB,4CAAoB;AACpB,iDAAyC;AACzC,sDAA2E;AAC3E,sDAA6D;AAC7D,qDAAiD;AACjD,8DAA8E;AAC9E,mDAA2B;AAG3B,MAAM,SAAS,GAAG,QAAQ,CAAC;AAC3B,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,KAAK,CAAU,CAAC;AAW7C,SAAgB,YAAY,CAAC,UAAwB,EAAE;IACrD,MAAM,OAAO,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACvC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,MAAM,CAAC;IAE9B,MAAM,QAAQ,GAAG,IAAA,yCAAwB,GAAE,CAAC;IAC5C,MAAM,UAAU,GAAG,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtD,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,+BAA+B,IAAA,wBAAU,GAAE,SAAS,CAAC,CAAC;QACnE,OAAO,CAAC,IAAI,CACV,qBAAqB,IAAA,yBAAY,EAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;aAC1D,UAAU,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC;aACnC,U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I,CAAC,8CAA8C,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;AACH,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { execSync } from \"child_process\";\nimport { fullCleanCwd, getUserFileExtension } from \"../helpers/fs.helpers\";\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { getVersion } from \"./utils/cli.helpers\";\nimport { detectPackageManagerFromUserAgent } from \"../helpers/global.helpers\";\nimport sheu from \"../sheu\";\n\n// Constants\nconst BUILD_DIR = \".build\";\nconst MODULE_TYPES = [\"cjs\", \"esm\"] as const;\ntype ModuleType = (typeof MODULE_TYPES)[number];\n\ninterface BuildOptions {\n config?: string;\n module?: string;\n}\n\n/**\n * Main build function for the arkos CLI\n */\nexport function buildCommand(options: BuildOptions = {}) {\n const fileExt = getUserFileExtension();\n process.env.NODE_ENV = \"production\";\n process.env.NODE_ENV = \"true\";\n\n const envFiles = loadEnvironmentVariables();\n const moduleType = validateModuleType(options.module);\n\n try {\n console.info(` \\x1b[1m\\x1b[36m Arkos.js ${getVersion()}\\x1b[0m`);\n console.info(\n ` - Environments: ${fullCleanCwd(envFiles?.join(\", \") || \"\")\n .replaceAll(`${process.cwd()}/`, \"\")\n .replaceAll(\"/\", \"\")}`\n );\n\n console.info(`\\n Creating an optimized production build...`);\n\n ensureBuildDir();\n\n // Detect project type\n\n if (fileExt === \"ts\") {\n buildTypeScriptProject(options, moduleType);\n } else {\n buildJavaScriptProject(options, moduleType);\n }\n\n const packageManger = detectPackageManagerFromUserAgent();\n\n console.info(`\\n\\x1b[1m\\x1b[32m Build complete!\\x1b[0m\\n`);\n console.info(` \\x1b[1mNext step:\\x1b[0m`);\n console.info(\n ` Run it using \\x1b[1m\\x1b[36m${packageManger} run start\\x1b[0m\\n`\n );\n } catch (err: any) {\n console.info(\"\");\n sheu.error(`Build failed: ${err?.message}`);\n console.error(err);\n process.exit(1);\n }\n}\n\n/**\n * Validates and normalizes module type option\n */\nfunction validateModuleType(moduleType?: string): ModuleType {\n if (!moduleType) return \"cjs\";\n\n const normalizedType = moduleType.toLowerCase();\n\n // Map common terms to our module types\n if (normalizedType === \"cjs\" || normalizedType === \"commonjs\") {\n return \"cjs\";\n } else if (\n [\"esm\", \"es\", \"es2020\", \"esnext\", \"module\"].includes(normalizedType)\n ) {\n return \"esm\";\n }\n\n // Default to CJS if unrecognized\n console.warn(\n `⚠️ Unrecognized module type \"${moduleType}\", defaulting to \"cjs\"`\n );\n return \"cjs\";\n}\n\n/**\n * Ensure the build directory exists\n */\nfunction ensureBuildDir() {\n if (!fs.existsSync(BUILD_DIR)) {\n fs.mkdirSync(BUILD_DIR, { recursive: true });\n }\n\n // Create module-specific subdirectories\n for (const moduleType of MODULE_TYPES) {\n const moduleDir = path.join(BUILD_DIR, moduleType);\n if (!fs.existsSync(moduleDir)) {\n fs.mkdirSync(moduleDir, { recursive: true });\n }\n }\n}\n\n/**\n * Build a TypeScript project\n */\nfunction buildTypeScriptProject(options: BuildOptions, moduleType: ModuleType) {\n // Read the user's tsconfig.json\n const tsconfigPath = path.join(\n process.cwd(),\n options.config || \"tsconfig.json\"\n );\n let tsconfig: any = {};\n\n try {\n if (fs.existsSync(tsconfigPath)) {\n const tsconfigContent = fs.readFileSync(tsconfigPath, \"utf8\");\n tsconfig = JSON.parse(tsconfigContent);\n }\n } catch (error) {\n console.error(\"❌ Error reading tsconfig.json:\", error);\n // Continue with default config\n }\n\n // Create a custom tsconfig that outputs to our build directory with the correct module type\n const tempTsconfig = {\n ...tsconfig,\n compilerOptions: {\n ...(tsconfig.compilerOptions || {}),\n rootDir: \".\",\n outDir: path.join(`./${BUILD_DIR}`),\n // module: moduleType === \"esm\" ? \"ESNext\" : \"CommonJS\",\n },\n };\n\n const tempTsconfigPath = path.join(\n process.cwd(),\n `tsconfig.arkos-build.json`\n );\n fs.writeFileSync(tempTsconfigPath, JSON.stringify(tempTsconfig, null, 2));\n\n try {\n execSync(`npx trash ${BUILD_DIR} && npx tsc -p ${tempTsconfigPath}`, {\n stdio: \"inherit\",\n cwd: process.cwd(),\n });\n\n copyAllNonSourceFiles(moduleType, [\".ts\", \".tsx\"]);\n\n // Clean up temp config\n cleanupTempConfig(tempTsconfigPath);\n } catch (error) {\n cleanupTempConfig(tempTsconfigPath);\n throw error;\n }\n}\n\n/**\n * Build a JavaScript project\n */\nfunction buildJavaScriptProject(_: BuildOptions, moduleType: ModuleType) {\n const targetDir = path.join(BUILD_DIR);\n\n try {\n if (moduleType === \"esm\") {\n execSync(\n `npx copyfiles -u 0 \"src/**/*.js\" \"src/**/*.jsx\" \"src/**/*.mjs\" ${targetDir}`,\n {\n stdio: \"inherit\",\n cwd: process.cwd(),\n }\n );\n\n console.info(\"Note: .cjs files are skipped in ESM build\");\n } else {\n execSync(\n `npx copyfiles -u 0 \"src/**/*.js\" \"src/**/*.jsx\" \"src/**/*.cjs\" \"src/**/*.mjs\" ${targetDir}`,\n {\n stdio: \"inherit\",\n cwd: process.cwd(),\n }\n );\n }\n\n copyAllNonSourceFiles(moduleType, [\n \".js\",\n \".jsx\",\n \".mjs\",\n \".cjs\",\n \".ts\",\n \".tsx\",\n ]);\n\n // Create appropriate package.json in the build directory\n createModulePackageJson(moduleType);\n } catch (error) {\n console.error(\"❌ Error building JavaScript project:\", error);\n throw error;\n }\n}\n\n/**\n * Copy all non-source code files to the build directory\n * This function will copy everything except the specified source file extensions\n */\nfunction copyAllNonSourceFiles(_: ModuleType, skipExtensions: string[]) {\n const targetDir = path.join(BUILD_DIR);\n const sourceDir = \"src\";\n\n try {\n // Recursive function to copy files\n function copyDirRecursive(dir: string) {\n if (!fs.existsSync(dir)) return;\n\n const items = fs.readdirSync(dir);\n\n for (const item of items) {\n const sourcePath = path.join(dir, item);\n const targetPath = path.join(\n targetDir,\n dir.replace(sourceDir, \"\"),\n item\n );\n\n // Get file stats\n const stats = fs.statSync(sourcePath);\n\n if (stats.isDirectory()) {\n // Ensure target directory exists\n if (!fs.existsSync(targetPath)) {\n fs.mkdirSync(targetPath, { recursive: true });\n }\n // Recurse into subdirectory\n copyDirRecursive(sourcePath);\n } else if (stats.isFile()) {\n // Check if this is a file we should skip\n const ext = path.extname(item).toLowerCase();\n if (!skipExtensions.includes(ext)) {\n // Ensure the target directory exists\n const targetDir = path.dirname(targetPath);\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true });\n }\n // Copy the file\n fs.copyFileSync(sourcePath, targetPath);\n }\n }\n }\n }\n\n // Start copying from src directory\n copyDirRecursive(sourceDir);\n\n // Copy project root files if needed\n const rootFilesToCopy = [\"README.md\", \"LICENSE\"];\n\n for (const file of rootFilesToCopy) {\n if (fs.existsSync(path.join(process.cwd(), file))) {\n fs.copyFileSync(\n path.join(process.cwd(), file),\n path.join(targetDir, file)\n );\n }\n }\n\n // console.info(`Copied all non-source files to ${targetDir}`);\n } catch (error) {\n console.warn(\"Warning: Error copying project files:\", error);\n console.error(error);\n }\n}\n\n/**\n * Create appropriate package.json in the build directory\n */\nfunction createModulePackageJson(moduleType: ModuleType) {\n const packageJsonPath = path.join(process.cwd(), \"package.json\");\n\n if (!fs.existsSync(packageJsonPath)) {\n return;\n }\n\n try {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf8\"));\n const buildPackageJson: any = {\n name: packageJson.name,\n version: packageJson.version,\n description: packageJson.description,\n main: \"index.js\",\n dependencies: packageJson.dependencies,\n };\n\n // Set appropriate type field for ESM\n if (moduleType === \"esm\") {\n buildPackageJson.type = \"module\";\n }\n\n const targetDir = path.join(BUILD_DIR, moduleType);\n fs.writeFileSync(\n path.join(targetDir, \"package.json\"),\n JSON.stringify(buildPackageJson, null, 2)\n );\n } catch (error) {\n console.warn(\n \"Warning: Failed to create module-specific package.json\",\n error\n );\n }\n}\n\n/**\n * Clean up temporary tsconfig\n */\nfunction cleanupTempConfig(configPath: string) {\n try {\n if (fs.existsSync(configPath)) fs.unlinkSync(configPath);\n } catch (error) {\n console.warn(\"Warning: Error cleaning up temporary config:\", error);\n }\n}\n"]}
@@ -28,9 +28,10 @@ const generateFile = async (options, config) => {
28
28
  };
29
29
  const ext = (0, fs_helpers_1.getUserFileExtension)();
30
30
  const resolvedPath = (config.customPath || customPath).replaceAll("{{module-name}}", names.kebab);
31
+ console.log(resolvedPath);
31
32
  const modulePath = path_1.default.join(process.cwd(), resolvedPath);
32
- const fileName = config.useCreatePrefix
33
- ? `create-${names.kebab}.${config.fileSuffix}.${ext}`
33
+ const fileName = config.prefix
34
+ ? `${config.prefix}${names.kebab}.${config.fileSuffix}.${ext}`
34
35
  : `${names.kebab}.${config.fileSuffix}.${ext}`;
35
36
  const filePath = path_1.default.join(modulePath, fileName);
36
37
  const humamReadableTemplateName = config.templateName.charAt(0).toUpperCase() +
@@ -107,7 +108,7 @@ exports.generateCommand = {
107
108
  templateName: "create-schema",
108
109
  fileSuffix: "schema",
109
110
  customPath: "src/modules/{{module-name}}/schemas",
110
- useCreatePrefix: true,
111
+ prefix: "create-",
111
112
  });
112
113
  },
113
114
  updateSchema: async (options) => {
@@ -115,7 +116,7 @@ exports.generateCommand = {
115
116
  templateName: "update-schema",
116
117
  fileSuffix: "schema",
117
118
  customPath: "src/modules/{{module-name}}/schemas",
118
- useCreatePrefix: true,
119
+ prefix: "update-",
119
120
  });
120
121
  },
121
122
  createDto: async (options) => {
@@ -123,7 +124,7 @@ exports.generateCommand = {
123
124
  templateName: "create-dto",
124
125
  fileSuffix: "dto",
125
126
  customPath: "src/modules/{{module-name}}/dtos",
126
- useCreatePrefix: true,
127
+ prefix: "create-",
127
128
  });
128
129
  },
129
130
  updateDto: async (options) => {
@@ -131,7 +132,7 @@ exports.generateCommand = {
131
132
  templateName: "update-dto",
132
133
  fileSuffix: "dto",
133
134
  customPath: "src/modules/{{module-name}}/dtos",
134
- useCreatePrefix: true,
135
+ prefix: "update-",
135
136
  });
136
137
  },
137
138
  queryOptions: async (options) => {
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../../src/utils/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AAkC;YAC9C,eAAe,EAAE,IAAI;SACtB,CAAC,CAAC;IACL,CAAC;IAED,YAAY,EAAE,KAAK,EAAE,OAAwB,EAAE,EAAE;QAC/C,MAAM,YAAY,CAAC,OAAO,EAAE;YAC1B,YAAY,EAAE,eAAe;YAC7B,UAAU,EAAE,OAAO;YACnB,gBAAgB,EAAE,CAAC,SAAS,EAAE,EAAE;gBAC9B,IAAI,SAAS,KAAK,aAAa,EAAE,CAAC;oBAChC,cAAI,CAAC,KAAK,CACR,gEAAgE,CACjE,CAAC;oBACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { generateTemplate } from \"./utils/template-generators\";\nimport { ensureDirectoryExists } from \"./utils/cli.helpers\";\nimport {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../helpers/change-case.helpers\";\nimport { fullCleanCwd, getUserFileExtension } from \"../helpers/fs.helpers\";\nimport sheu from \"../sheu\";\nimport { capitalize } from \"../helpers/text.helpers\";\n\ninterface GenerateOptions {\n path?: string;\n model: string;\n}\n\ninterface GenerateConfig {\n templateName: string;\n fileSuffix: string;\n customValidation?: (modelName: string) => void;\n customImports?: (names: any) => any;\n customPath?: string;\n useCreatePrefix?: boolean;\n}\n\nconst generateFile = async (\n options: GenerateOptions,\n config: GenerateConfig\n) => {\n const modelName = options.model;\n\n if (!modelName) {\n sheu.error(\"Module name is required!\");\n process.exit(1);\n }\n\n if (config.customValidation) config.customValidation(modelName);\n\n const { path: customPath = \"src/modules/{{module-name}}\" } = options;\n\n const names = {\n pascal: pascalCase(modelName),\n camel: camelCase(modelName),\n kebab: kebabCase(modelName),\n };\n\n const ext = getUserFileExtension();\n\n // Replace {{module-name}} placeholder with actual kebab-cased module name\n const resolvedPath = (config.customPath || customPath).replaceAll(\n \"{{module-name}}\",\n names.kebab\n );\n\n const modulePath = path.join(process.cwd(), resolvedPath);\n\n // Determine file name based on whether it needs \"create-\" prefix\n const fileName = config.useCreatePrefix\n ? `create-${names.kebab}.${config.fileSuffix}.${ext}`\n : `${names.kebab}.${config.fileSuffix}.${ext}`;\n\n const filePath = path.join(modulePath, fileName);\n\n const humamReadableTemplateName =\n config.templateName.charAt(0).toUpperCase() +\n config.templateName.slice(1).replaceAll(\"-\", \" \");\n\n try {\n ensureDirectoryExists(modulePath);\n\n const templateData = {\n modelName: names,\n ...(config.customImports && { imports: config.customImports(names) }),\n };\n\n const content = generateTemplate(config.templateName, templateData);\n if (fs.existsSync(filePath))\n throw new Error(\n `${capitalize(humamReadableTemplateName.toLowerCase())} for ${options.model} already exists.`\n );\n fs.writeFileSync(filePath, content);\n\n console.info(\"\");\n sheu.done(\n `${humamReadableTemplateName} for ${options.model} generated under ${fullCleanCwd(filePath)}`\n );\n } catch (err: any) {\n console.info(\"\");\n sheu.error(\n `${`Failed to generate ${humamReadableTemplateName.toLowerCase()}`} for ${options.model} ${filePath ? \"under \" + fullCleanCwd(filePath) + \".\" : \".\"}`\n );\n console.info(`${sheu.bold(\"Reason: \")}${err?.message || \"unknown\"}`);\n process.exit(1);\n }\n};\n\nexport const generateCommand = {\n controller: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"controller\",\n fileSuffix: \"controller\",\n customImports: () => ({\n baseController: \"arkos/controllers\",\n }),\n });\n },\n\n service: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"service\",\n fileSuffix: \"service\",\n customImports: () => ({\n baseService: \"arkos/services\",\n }),\n });\n },\n\n router: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"router\",\n fileSuffix: \"router\",\n customImports: (names) => ({\n baseRouter: \"arkos\",\n controller: `./${names.kebab}.controller`,\n }),\n });\n },\n\n interceptors: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"interceptors\",\n fileSuffix: \"interceptors\",\n });\n },\n\n authConfigs: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"auth-configs\",\n fileSuffix: \"auth\",\n });\n },\n\n hooks: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"hooks\",\n fileSuffix: \"hooks\",\n });\n },\n\n createSchema: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"create-schema\",\n fileSuffix: \"schema\",\n customPath: \"src/modules/{{module-name}}/schemas\",\n useCreatePrefix: true,\n });\n },\n\n updateSchema: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"update-schema\",\n fileSuffix: \"schema\",\n customPath: \"src/modules/{{module-name}}/schemas\",\n useCreatePrefix: true,\n });\n },\n\n createDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"create-dto\",\n fileSuffix: \"dto\",\n customPath: \"src/modules/{{module-name}}/dtos\",\n useCreatePrefix: true,\n });\n },\n\n updateDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"update-dto\",\n fileSuffix: \"dto\",\n customPath: \"src/modules/{{module-name}}/dtos\",\n useCreatePrefix: true,\n });\n },\n\n queryOptions: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"query-options\",\n fileSuffix: \"query\",\n customValidation: (modelName) => {\n if (modelName === \"file-upload\") {\n sheu.error(\n \"Prisma query options are not available to file-upload resource\"\n );\n process.exit(1);\n }\n },\n });\n },\n};\n"]}
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../../src/utils/cli/generate.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,qEAA+D;AAC/D,qDAA4D;AAC5D,wEAIwC;AACxC,sDAA2E;AAC3E,mDAA2B;AAC3B,0DAAqD;AAgBrD,MAAM,YAAY,GAAG,KAAK,EACxB,OAAwB,EACxB,MAAsB,EACtB,EAAE;IACF,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC;IAEhC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,cAAI,CAAC,KAAK,CAAC,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KAAK,aAAa,EAAE,CAAC;oBAChC,cAAI,CAAC,KAAK,CACR,gEAAgE,CACjE,CAAC;oBACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { generateTemplate } from \"./utils/template-generators\";\nimport { ensureDirectoryExists } from \"./utils/cli.helpers\";\nimport {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../helpers/change-case.helpers\";\nimport { fullCleanCwd, getUserFileExtension } from \"../helpers/fs.helpers\";\nimport sheu from \"../sheu\";\nimport { capitalize } from \"../helpers/text.helpers\";\n\ninterface GenerateOptions {\n path?: string;\n model: string;\n}\n\ninterface GenerateConfig {\n templateName: string;\n fileSuffix: string;\n customValidation?: (modelName: string) => void;\n customImports?: (names: any) => any;\n customPath?: string;\n prefix?: string;\n}\n\nconst generateFile = async (\n options: GenerateOptions,\n config: GenerateConfig\n) => {\n const modelName = options.model;\n\n if (!modelName) {\n sheu.error(\"Module name is required!\");\n process.exit(1);\n }\n\n if (config.customValidation) config.customValidation(modelName);\n\n const { path: customPath = \"src/modules/{{module-name}}\" } = options;\n\n const names = {\n pascal: pascalCase(modelName),\n camel: camelCase(modelName),\n kebab: kebabCase(modelName),\n };\n\n const ext = getUserFileExtension();\n\n const resolvedPath = (config.customPath || customPath).replaceAll(\n \"{{module-name}}\",\n names.kebab\n );\n console.log(resolvedPath);\n\n const modulePath = path.join(process.cwd(), resolvedPath);\n\n const fileName = config.prefix\n ? `${config.prefix}${names.kebab}.${config.fileSuffix}.${ext}`\n : `${names.kebab}.${config.fileSuffix}.${ext}`;\n\n const filePath = path.join(modulePath, fileName);\n\n const humamReadableTemplateName =\n config.templateName.charAt(0).toUpperCase() +\n config.templateName.slice(1).replaceAll(\"-\", \" \");\n\n try {\n ensureDirectoryExists(modulePath);\n\n const templateData = {\n modelName: names,\n ...(config.customImports && { imports: config.customImports(names) }),\n };\n\n const content = generateTemplate(config.templateName, templateData);\n if (fs.existsSync(filePath))\n throw new Error(\n `${capitalize(humamReadableTemplateName.toLowerCase())} for ${options.model} already exists.`\n );\n fs.writeFileSync(filePath, content);\n\n console.info(\"\");\n sheu.done(\n `${humamReadableTemplateName} for ${options.model} generated under ${fullCleanCwd(filePath)}`\n );\n } catch (err: any) {\n console.info(\"\");\n sheu.error(\n `${`Failed to generate ${humamReadableTemplateName.toLowerCase()}`} for ${options.model} ${filePath ? \"under \" + fullCleanCwd(filePath) + \".\" : \".\"}`\n );\n console.info(`${sheu.bold(\"Reason: \")}${err?.message || \"unknown\"}`);\n process.exit(1);\n }\n};\n\nexport const generateCommand = {\n controller: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"controller\",\n fileSuffix: \"controller\",\n customImports: () => ({\n baseController: \"arkos/controllers\",\n }),\n });\n },\n\n service: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"service\",\n fileSuffix: \"service\",\n customImports: () => ({\n baseService: \"arkos/services\",\n }),\n });\n },\n\n router: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"router\",\n fileSuffix: \"router\",\n customImports: (names) => ({\n baseRouter: \"arkos\",\n controller: `./${names.kebab}.controller`,\n }),\n });\n },\n\n interceptors: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"interceptors\",\n fileSuffix: \"interceptors\",\n });\n },\n\n authConfigs: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"auth-configs\",\n fileSuffix: \"auth\",\n });\n },\n\n hooks: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"hooks\",\n fileSuffix: \"hooks\",\n });\n },\n\n createSchema: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"create-schema\",\n fileSuffix: \"schema\",\n customPath: \"src/modules/{{module-name}}/schemas\",\n prefix: \"create-\",\n });\n },\n\n updateSchema: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"update-schema\",\n fileSuffix: \"schema\",\n customPath: \"src/modules/{{module-name}}/schemas\",\n prefix: \"update-\",\n });\n },\n\n createDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"create-dto\",\n fileSuffix: \"dto\",\n customPath: \"src/modules/{{module-name}}/dtos\",\n prefix: \"create-\",\n });\n },\n\n updateDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"update-dto\",\n fileSuffix: \"dto\",\n customPath: \"src/modules/{{module-name}}/dtos\",\n prefix: \"update-\",\n });\n },\n\n queryOptions: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"query-options\",\n fileSuffix: \"query\",\n customValidation: (modelName) => {\n if (modelName === \"file-upload\") {\n sheu.error(\n \"Prisma query options are not available to file-upload resource\"\n );\n process.exit(1);\n }\n },\n });\n },\n};\n"]}
@@ -44,84 +44,84 @@ generate
44
44
  .alias("c")
45
45
  .description("Generate a new controller")
46
46
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
47
- .option("-p, --path <path>", "Custom path for the controller", "src/modules")
47
+ .option("-p, --path <path>", "Custom path for the controller", "src/modules/{{module-name}}")
48
48
  .action(generate_1.generateCommand.controller);
49
49
  generate
50
50
  .command("service")
51
51
  .alias("s")
52
52
  .description("Generate a new service")
53
53
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
54
- .option("-p, --path <path>", "Custom path for the service", "src/modules")
54
+ .option("-p, --path <path>", "Custom path for the service", "src/modules/{{module-name}}")
55
55
  .action(generate_1.generateCommand.service);
56
56
  generate
57
57
  .command("router")
58
58
  .alias("r")
59
59
  .description("Generate a new router")
60
60
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
61
- .option("-p, --path <path>", "Custom path for the router", "src/modules")
61
+ .option("-p, --path <path>", "Custom path for the router", "src/modules/{{module-name}}")
62
62
  .action(generate_1.generateCommand.router);
63
63
  generate
64
64
  .command("auth-configs")
65
65
  .alias("a")
66
66
  .description("Generate auth configuration")
67
67
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
68
- .option("-p, --path <path>", "Custom path for the router", "src/modules")
68
+ .option("-p, --path <path>", "Custom path for the router", "src/modules/{{module-name}}")
69
69
  .action(generate_1.generateCommand.authConfigs);
70
70
  generate
71
71
  .command("query-options")
72
72
  .alias("q")
73
73
  .description("Generate prisma query options")
74
74
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
75
- .option("-p, --path <path>", "Custom path for query options", "src/modules")
75
+ .option("-p, --path <path>", "Custom path for query options", "src/modules/{{module-name}}")
76
76
  .action(generate_1.generateCommand.queryOptions);
77
77
  generate
78
78
  .command("middlewares")
79
79
  .alias("m")
80
80
  .description("Generate a new interceptors file")
81
81
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
82
- .option("-p, --path <path>", "Custom path for middleware", "src/modules")
82
+ .option("-p, --path <path>", "Custom path for middleware", "src/modules/{{module-name}}")
83
83
  .action(generate_1.generateCommand.interceptors);
84
84
  generate
85
85
  .command("interceptors")
86
86
  .alias("i")
87
87
  .description("Generate a new interceptors file")
88
88
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
89
- .option("-p, --path <path>", "Custom path for interceptors", "src/modules")
89
+ .option("-p, --path <path>", "Custom path for interceptors", "src/modules/{{module-name}}")
90
90
  .action(generate_1.generateCommand.interceptors);
91
91
  generate
92
92
  .command("hooks")
93
93
  .alias("h")
94
94
  .description("Generate a new service hooks file")
95
95
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
96
- .option("-p, --path <path>", "Custom path for hooks", "src/modules")
96
+ .option("-p, --path <path>", "Custom path for hooks", "src/modules/{{module-name}}")
97
97
  .action(generate_1.generateCommand.hooks);
98
98
  generate
99
99
  .command("create-schema")
100
100
  .alias("cs")
101
101
  .description("Generate a new zod create schema file for a prisma model")
102
102
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
103
- .option("-p, --path <path>", "Custom path for hooks", "src/modules")
103
+ .option("-p, --path <path>", "Custom path for hooks", "src/modules/{{module-name}}")
104
104
  .action(generate_1.generateCommand.createSchema);
105
105
  generate
106
106
  .command("update-schema")
107
107
  .alias("us")
108
108
  .description("Generate a new zod update schema file for a prisma model")
109
109
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
110
- .option("-p, --path <path>", "Custom path for hooks", "src/modules")
110
+ .option("-p, --path <path>", "Custom path for hooks", "src/modules/{{module-name}}")
111
111
  .action(generate_1.generateCommand.updateSchema);
112
112
  generate
113
113
  .command("create-dto")
114
114
  .alias("cd")
115
115
  .description("Generate a new class-validator create dto file for a prisma model")
116
116
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
117
- .option("-p, --path <path>", "Custom path for hooks", "src/modules")
117
+ .option("-p, --path <path>", "Custom path for hooks", "src/modules/{{module-name}}")
118
118
  .action(generate_1.generateCommand.createDto);
119
119
  generate
120
120
  .command("update-dto")
121
121
  .alias("ud")
122
122
  .description("Generate a new class-validator update dto file for a prisma model")
123
123
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
124
- .option("-p, --path <path>", "Custom path for hooks", "src/modules")
124
+ .option("-p, --path <path>", "Custom path for hooks", "src/modules/{{module-name}}")
125
125
  .action(generate_1.generateCommand.updateDto);
126
126
  program
127
127
  .command("prisma")
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/cli/index.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAoC;AACpC,mCAAuC;AAgJrB,6FAhJT,oBAAY,OAgJS;AA/I9B,+BAAmC;AA+IH,2FA/IvB,gBAAU,OA+IuB;AA9I1C,mCAAuC;AA8IK,6FA9InC,oBAAY,OA8ImC;AA7IxD,yCAA6C;AA6Ia,gGA7IjD,0BAAe,OA6IiD;AA5IzE,qDAAiD;AACjD,wEAAsD;AAEtD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAyIrB,0BAAO;AAvIhB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,O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c,CAAC,qCAAqC,EAAE,aAAa,CAAC;KACpE,MAAM,CAAC,mBAAmB,EAAE,uBAAuB,EAAE,aAAa,CAAC;KACnE,MAAM,CAAC,0BAAe,CAAC,SAAS,CAAC,CAAC;AAErC,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,OAAO,CAAC,UAAU,CAAC;KACnB,WAAW,CAAC,0DAA0D,CAAC;KACvE,MAAM,CAAC,yBAAqB,CAAC,CAAC;AAEjC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import { Command } from \"commander\";\nimport { buildCommand } from \"./build\";\nimport { devCommand } from \"./dev\";\nimport { startCommand } from \"./start\";\nimport { generateCommand } from \"./generate\";\nimport { getVersion } from \"./utils/cli.helpers\";\nimport prismaGenerateCommand from \"./prisma-generate\";\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\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>, --module <name>\", \"Module 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>, --module <name>\", \"Module 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>, --module <name>\", \"Module 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 .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\"-p, --path <path>\", \"Custom path for the router\", \"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>, --module <name>\", \"Module 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 interceptors file\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\"-p, --path <path>\", \"Custom path for middleware\", \"src/modules\")\n .action(generateCommand.interceptors);\n\ngenerate\n .command(\"interceptors\")\n .alias(\"i\")\n .description(\"Generate a new interceptors file\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\"-p, --path <path>\", \"Custom path for interceptors\", \"src/modules\")\n .action(generateCommand.interceptors);\n\ngenerate\n .command(\"hooks\")\n .alias(\"h\")\n .description(\"Generate a new service hooks file\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\"-p, --path <path>\", \"Custom path for hooks\", \"src/modules\")\n .action(generateCommand.hooks);\n\ngenerate\n .command(\"create-schema\")\n .alias(\"cs\")\n .description(\"Generate a new zod create schema file for a prisma model\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\"-p, --path <path>\", \"Custom path for hooks\", \"src/modules\")\n .action(generateCommand.createSchema);\n\ngenerate\n .command(\"update-schema\")\n .alias(\"us\")\n .description(\"Generate a new zod update schema file for a prisma model\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\"-p, --path <path>\", \"Custom path for hooks\", \"src/modules\")\n .action(generateCommand.updateSchema);\n\ngenerate\n .command(\"create-dto\")\n .alias(\"cd\")\n .description(\n \"Generate a new class-validator create dto file for a prisma model\"\n )\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\"-p, --path <path>\", \"Custom path for hooks\", \"src/modules\")\n .action(generateCommand.createDto);\n\ngenerate\n .command(\"update-dto\")\n .alias(\"ud\")\n .description(\n \"Generate a new class-validator update dto file for a prisma model\"\n )\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\"-p, --path <path>\", \"Custom path for hooks\", \"src/modules\")\n .action(generateCommand.updateDto);\n\nprogram\n .command(\"prisma\")\n .command(\"generate\")\n .description(\"Generate your @prisma/client and BaseService class types\")\n .action(prismaGenerateCommand);\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":";;;;;;AAAA,yCAAoC;AACpC,mCAAuC;AAgMrB,6FAhMT,oBAAY,OAgMS;AA/L9B,+BAAmC;AA+LH,2FA/LvB,gBAAU,OA+LuB;AA9L1C,mCAAuC;AA8LK,6FA9LnC,oBAAY,OA8LmC;AA7LxD,yCAA6C;AA6La,gGA7LjD,0BAAe,OA6LiD;AA5LzE,qDAAiD;AACjD,wEAAsD;AAEtD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAyLrB,0BAAO;AAvLhB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,IAAA,wBAAU,GAAE,CAAC,CAAC;AAExE,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,0BAA0B,CAA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ACA,MAAM,CAAC,0BAAe,CAAC,SAAS,CAAC,CAAC;AAErC,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,OAAO,CAAC,UAAU,CAAC;KACnB,WAAW,CAAC,0DAA0D,CAAC;KACvE,MAAM,CAAC,yBAAqB,CAAC,CAAC;AAEjC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import { Command } from \"commander\";\nimport { buildCommand } from \"./build\";\nimport { devCommand } from \"./dev\";\nimport { startCommand } from \"./start\";\nimport { generateCommand } from \"./generate\";\nimport { getVersion } from \"./utils/cli.helpers\";\nimport prismaGenerateCommand from \"./prisma-generate\";\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\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>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for the controller\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.controller);\n\ngenerate\n .command(\"service\")\n .alias(\"s\")\n .description(\"Generate a new service\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for the service\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.service);\n\ngenerate\n .command(\"router\")\n .alias(\"r\")\n .description(\"Generate a new router\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for the router\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.router);\n\ngenerate\n .command(\"auth-configs\")\n .alias(\"a\")\n .description(\"Generate auth configuration\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for the router\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.authConfigs);\n\ngenerate\n .command(\"query-options\")\n .alias(\"q\")\n .description(\"Generate prisma query options\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for query options\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.queryOptions);\n\ngenerate\n .command(\"middlewares\")\n .alias(\"m\")\n .description(\"Generate a new interceptors file\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for middleware\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.interceptors);\n\ngenerate\n .command(\"interceptors\")\n .alias(\"i\")\n .description(\"Generate a new interceptors file\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for interceptors\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.interceptors);\n\ngenerate\n .command(\"hooks\")\n .alias(\"h\")\n .description(\"Generate a new service hooks file\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for hooks\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.hooks);\n\ngenerate\n .command(\"create-schema\")\n .alias(\"cs\")\n .description(\"Generate a new zod create schema file for a prisma model\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for hooks\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.createSchema);\n\ngenerate\n .command(\"update-schema\")\n .alias(\"us\")\n .description(\"Generate a new zod update schema file for a prisma model\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for hooks\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.updateSchema);\n\ngenerate\n .command(\"create-dto\")\n .alias(\"cd\")\n .description(\n \"Generate a new class-validator create dto file for a prisma model\"\n )\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for hooks\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.createDto);\n\ngenerate\n .command(\"update-dto\")\n .alias(\"ud\")\n .description(\n \"Generate a new class-validator update dto file for a prisma model\"\n )\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for hooks\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.updateDto);\n\nprogram\n .command(\"prisma\")\n .command(\"generate\")\n .description(\"Generate your @prisma/client and BaseService class types\")\n .action(prismaGenerateCommand);\n\nprogram.parse(process.argv);\n\nexport { program, buildCommand, devCommand, startCommand, generateCommand };\n"]}
@@ -19,6 +19,6 @@ function killServerChildProcess() {
19
19
  (0, start_1.killProductionServerChildProcess)();
20
20
  }
21
21
  function getVersion() {
22
- return "1.4.0-canary.2";
22
+ return "1.4.0-canary.4";
23
23
  }
24
24
  //# sourceMappingURL=cli.helpers.js.map
@@ -40,7 +40,7 @@ function generateTemplate(type, options) {
40
40
  case "update-dto":
41
41
  return (0, update_dto_template_1.generateUpdateDtoTemplate)(options);
42
42
  default:
43
- throw new Error(`\nUnknown template type: ${type}`);
43
+ throw new Error(`Unknown template type: ${type}`);
44
44
  }
45
45
  }
46
46
  //# sourceMappingURL=template-generators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"template-generators.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/template-generators.ts"],"names":[],"mappings":";;;;;AA8BA,4CA8BC;AA5DD,4FAAgG;AAChG,gGAAmG;AACnG,8FAAkG;AAClG,kGAAqG;AACrG,oFAAwF;AACxF,sFAA0F;AAC1F,mGAAkF;AAClF,sGAAyG;AACzG,sGAAyG;AACzG,4GAA+G;AAC/G,4GAA+G;AAoB/G,SAAgB,gBAAgB,CAC9B,IAAY,EACZ,OAAwB;IAExB,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,YAAY;YACf,OAAO,IAAA,gDAA0B,EAAC,OAAO,CAAC,CAAC;QAC7C,KAAK,SAAS;YACZ,OAAO,IAAA,0CAAuB,EAAC,OAAO,CAAC,CAAC;QAC1C,KAAK,QAAQ;YACX,OAAO,IAAA,wCAAsB,EAAC,OAAO,CAAC,CAAC;QACzC,KAAK,cAAc;YACjB,OAAO,IAAA,mDAA2B,EAAC,OAAO,CAAC,CAAC;QAC9C,KAAK,eAAe;YAClB,OAAO,IAAA,qDAA4B,EAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,cAAc;YACjB,OAAO,IAAA,kDAA2B,EAAC,OAAO,CAAC,CAAC;QAC9C,KAAK,OAAO;YACV,OAAO,IAAA,wBAAqB,EAAC,OAAO,CAAC,CAAC;QACxC,KAAK,eAAe;YAClB,OAAO,IAAA,qDAA4B,EAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,eAAe;YAClB,OAAO,IAAA,qDAA4B,EAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,YAAY;YACf,OAAO,IAAA,+CAAyB,EAAC,OAAO,CAAC,CAAC;QAC5C,KAAK,YAAY;YACf,OAAO,IAAA,+CAAyB,EAAC,OAAO,CAAC,CAAC;QAC5C;YACE,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC;AACH,CAAC","sourcesContent":["import { generateControllerTemplate } from \"./template-generator/templates/controller-template\";\nimport { generateAuthConfigsTemplate } from \"./template-generator/templates/auth-configs-template\";\nimport { generateMiddlewaresTemplate } from \"./template-generator/templates/middlewares-template\";\nimport { generateQueryOptionsTemplate } from \"./template-generator/templates/query-options-template\";\nimport { generateRouterTemplate } from \"./template-generator/templates/router-template\";\nimport { generateServiceTemplate } from \"./template-generator/templates/service-template\";\nimport generateHooksTemplate from \"./template-generator/templates/hooks-template\";\nimport { generateCreateSchemaTemplate } from \"./template-generator/templates/zod/create-schema-template\";\nimport { generateUpdateSchemaTemplate } from \"./template-generator/templates/zod/update-schema-template\";\nimport { generateUpdateDtoTemplate } from \"./template-generator/templates/class-validator/update-dto-template\";\nimport { generateCreateDtoTemplate } from \"./template-generator/templates/class-validator/create-dto-template\";\n\ninterface ModelName {\n pascal: string;\n camel: string;\n kebab: string;\n}\n\ninterface MiddlewareName {\n pascal: string;\n camel: string;\n kebab: string;\n}\n\nexport interface TemplateOptions {\n modelName: ModelName;\n middlewareName?: MiddlewareName;\n imports?: Record<string, string>;\n}\n\nexport function generateTemplate(\n type: string,\n options: TemplateOptions\n): string {\n switch (type) {\n case \"controller\":\n return generateControllerTemplate(options);\n case \"service\":\n return generateServiceTemplate(options);\n case \"router\":\n return generateRouterTemplate(options);\n case \"auth-configs\":\n return generateAuthConfigsTemplate(options);\n case \"query-options\":\n return generateQueryOptionsTemplate(options);\n case \"interceptors\":\n return generateMiddlewaresTemplate(options);\n case \"hooks\":\n return generateHooksTemplate(options);\n case \"create-schema\":\n return generateCreateSchemaTemplate(options);\n case \"update-schema\":\n return generateUpdateSchemaTemplate(options);\n case \"create-dto\":\n return generateCreateDtoTemplate(options);\n case \"update-dto\":\n return generateUpdateDtoTemplate(options);\n default:\n throw new Error(`\\nUnknown template type: ${type}`);\n }\n}\n"]}
1
+ {"version":3,"file":"template-generators.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/template-generators.ts"],"names":[],"mappings":";;;;;AA8BA,4CA8BC;AA5DD,4FAAgG;AAChG,gGAAmG;AACnG,8FAAkG;AAClG,kGAAqG;AACrG,oFAAwF;AACxF,sFAA0F;AAC1F,mGAAkF;AAClF,sGAAyG;AACzG,sGAAyG;AACzG,4GAA+G;AAC/G,4GAA+G;AAoB/G,SAAgB,gBAAgB,CAC9B,IAAY,EACZ,OAAwB;IAExB,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,YAAY;YACf,OAAO,IAAA,gDAA0B,EAAC,OAAO,CAAC,CAAC;QAC7C,KAAK,SAAS;YACZ,OAAO,IAAA,0CAAuB,EAAC,OAAO,CAAC,CAAC;QAC1C,KAAK,QAAQ;YACX,OAAO,IAAA,wCAAsB,EAAC,OAAO,CAAC,CAAC;QACzC,KAAK,cAAc;YACjB,OAAO,IAAA,mDAA2B,EAAC,OAAO,CAAC,CAAC;QAC9C,KAAK,eAAe;YAClB,OAAO,IAAA,qDAA4B,EAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,cAAc;YACjB,OAAO,IAAA,kDAA2B,EAAC,OAAO,CAAC,CAAC;QAC9C,KAAK,OAAO;YACV,OAAO,IAAA,wBAAqB,EAAC,OAAO,CAAC,CAAC;QACxC,KAAK,eAAe;YAClB,OAAO,IAAA,qDAA4B,EAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,eAAe;YAClB,OAAO,IAAA,qDAA4B,EAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,YAAY;YACf,OAAO,IAAA,+CAAyB,EAAC,OAAO,CAAC,CAAC;QAC5C,KAAK,YAAY;YACf,OAAO,IAAA,+CAAyB,EAAC,OAAO,CAAC,CAAC;QAC5C;YACE,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC;AACH,CAAC","sourcesContent":["import { generateControllerTemplate } from \"./template-generator/templates/controller-template\";\nimport { generateAuthConfigsTemplate } from \"./template-generator/templates/auth-configs-template\";\nimport { generateMiddlewaresTemplate } from \"./template-generator/templates/middlewares-template\";\nimport { generateQueryOptionsTemplate } from \"./template-generator/templates/query-options-template\";\nimport { generateRouterTemplate } from \"./template-generator/templates/router-template\";\nimport { generateServiceTemplate } from \"./template-generator/templates/service-template\";\nimport generateHooksTemplate from \"./template-generator/templates/hooks-template\";\nimport { generateCreateSchemaTemplate } from \"./template-generator/templates/zod/create-schema-template\";\nimport { generateUpdateSchemaTemplate } from \"./template-generator/templates/zod/update-schema-template\";\nimport { generateUpdateDtoTemplate } from \"./template-generator/templates/class-validator/update-dto-template\";\nimport { generateCreateDtoTemplate } from \"./template-generator/templates/class-validator/create-dto-template\";\n\ninterface ModelName {\n pascal: string;\n camel: string;\n kebab: string;\n}\n\ninterface MiddlewareName {\n pascal: string;\n camel: string;\n kebab: string;\n}\n\nexport interface TemplateOptions {\n modelName: ModelName;\n middlewareName?: MiddlewareName;\n imports?: Record<string, string>;\n}\n\nexport function generateTemplate(\n type: string,\n options: TemplateOptions\n): string {\n switch (type) {\n case \"controller\":\n return generateControllerTemplate(options);\n case \"service\":\n return generateServiceTemplate(options);\n case \"router\":\n return generateRouterTemplate(options);\n case \"auth-configs\":\n return generateAuthConfigsTemplate(options);\n case \"query-options\":\n return generateQueryOptionsTemplate(options);\n case \"interceptors\":\n return generateMiddlewaresTemplate(options);\n case \"hooks\":\n return generateHooksTemplate(options);\n case \"create-schema\":\n return generateCreateSchemaTemplate(options);\n case \"update-schema\":\n return generateUpdateSchemaTemplate(options);\n case \"create-dto\":\n return generateCreateDtoTemplate(options);\n case \"update-dto\":\n return generateUpdateDtoTemplate(options);\n default:\n throw new Error(`Unknown template type: ${type}`);\n }\n}\n"]}
@@ -15,9 +15,15 @@ exports.crd = crd;
15
15
  function fullCleanCwd(path) {
16
16
  if (typeof path !== "string")
17
17
  throw new Error("Path must be a string");
18
- const cwd = process.cwd().replace(/\/+$/, "");
19
- const escapedCwd = cwd.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
20
- return path.replace(new RegExp(`${escapedCwd}/?`, "g"), "");
18
+ if (path.startsWith(`/${process.cwd()}`) ||
19
+ path.startsWith(`${process.cwd()}`) ||
20
+ path.startsWith(`${process.cwd()}/`))
21
+ return path
22
+ .replace(process.cwd(), "")
23
+ .replace(/^\/+/g, "")
24
+ .replace("\\", "");
25
+ else
26
+ return path;
21
27
  }
22
28
  const getUserFileExtension = () => {
23
29
  if (exports.userFileExtension)
@@ -1 +1 @@
1
- {"version":3,"file":"fs.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/fs.helpers.ts"],"names":[],"mappings":";;;;;;AAcA,oCAOC;AAsDD,0CAMC;AAjFD,4CAAoB;AACpB,gDAAwB;AAEjB,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;AAQpB,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,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;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,QAAQ,GAAG,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;QACvE,MAAM,QAAQ,GAAG,YAAE,CAAC,UAAU,CAAC,cAAI,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,yBAAiB,GAAG,IAAI,CAAC;aACrC,IAAI,WAAW,IAAI,QAAQ;YAAE,yBAAiB,GAAG,IAAI,CAAC;aACtD,IAAI,QAAQ,IAAI,CAAC,QAAQ;YAAE,yBAAiB,GAAG,IAAI,CAAC;aACpD,IAAI,QAAQ;YAAE,yBAAiB,GAAG,IAAI,CAAC;;YACvC,yBAAiB,GAAG,IAAI,CAAC;QAE9B,OAAO,yBAAiB,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QAEX,yBAAiB,GAAG,IAAI,CAAC;QACzB,OAAO,yBAAiB,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC;AA7BW,QAAA,oBAAoB,wBA6B/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 fs from \"fs\";\nimport path from \"path\";\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 && hasAppTs) 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"]}
1
+ {"version":3,"file":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CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;QACvE,MAAM,QAAQ,GAAG,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;QAEvE,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM,CAAC;QAEvD,IAAI,WAAW;YAAE,yBAAiB,GAAG,IAAI,CAAC;aACrC,IAAI,WAAW,IAAI,QAAQ;YAAE,yBAAiB,GAAG,IAAI,CAAC;aACtD,IAAI,QAAQ,IAAI,CAAC,QAAQ;YAAE,yBAAiB,GAAG,IAAI,CAAC;aACpD,IAAI,QAAQ;YAAE,yBAAiB,GAAG,IAAI,CAAC;;YACvC,yBAAiB,GAAG,IAAI,CAAC;QAE9B,OAAO,yBAAiB,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,yBAAiB,GAAG,IAAI,CAAC;QACzB,OAAO,yBAAiB,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC;AAxBW,QAAA,oBAAoB,wBAwB/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 fs from \"fs\";\nimport path from \"path\";\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 if (\n path.startsWith(`/${process.cwd()}`) ||\n path.startsWith(`${process.cwd()}`) ||\n path.startsWith(`${process.cwd()}/`)\n )\n return path\n .replace(process.cwd(), \"\")\n .replace(/^\\/+/g, \"\")\n .replace(\"\\\\\", \"\");\n else return path;\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 const hasTsConfig = fs.existsSync(path.join(currentDir, \"tsconfig.json\"));\n\n const hasAppTs = fs.existsSync(path.join(currentDir, \"src\", \"app.ts\"));\n const hasAppJs = fs.existsSync(path.join(currentDir, \"src\", \"app.js\"));\n\n const isBuildMode = process.env.ARKOS_BUILD === \"true\";\n\n if (isBuildMode) userFileExtension = \"js\";\n else if (hasTsConfig && hasAppTs) 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 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"]}
@@ -13,7 +13,9 @@ export function adjustRequestUrl(req, _, next) {
13
13
  }
14
14
  export function extractRequestInfo(req) {
15
15
  const { fileUpload } = getArkosConfig();
16
- const protocol = req.headers["x-forwarded-proto"] === "https" ? "https" : "http";
16
+ const protocol = req.secure || req.headers["x-forwarded-proto"] === "https"
17
+ ? "https"
18
+ : "http";
17
19
  const baseURL = `${protocol}://${req.get?.("host")}`;
18
20
  const baseRoute = fileUpload?.baseRoute || "/api/uploads";
19
21
  return { baseURL, baseRoute };
@@ -34,18 +36,15 @@ const generateRelativePath = (filePath, fileType) => {
34
36
  };
35
37
  export const processFile = async (req, filePath) => {
36
38
  const { baseURL, baseRoute } = extractRequestInfo(req);
37
- const relativePath = generateRelativePath(filePath, req.params.fileType);
38
- return `${baseURL}${baseRoute === "/" ? "" : baseRoute}/${relativePath}`;
39
+ const relativePath = generateRelativePath(filePath, req.params.fileType).replace(/\\/g, "/");
40
+ return `${baseURL}${baseRoute === "/" ? "" : baseRoute}${relativePath.startsWith("/") ? relativePath : `/${relativePath}`}`;
39
41
  };
40
42
  export const processImage = async (req, filePath, options) => {
41
- const { baseURL, baseRoute } = extractRequestInfo(req);
42
43
  const ext = path.extname(filePath).toLowerCase();
43
44
  const originalFormat = ext.replace(".", "");
44
45
  const outputFormat = options.format || originalFormat;
45
- if (!mimetype.lookup(ext)?.includes?.("image")) {
46
- const relativePath = generateRelativePath(filePath, req.params.fileType);
47
- return `${baseURL}${baseRoute}/${relativePath}`;
48
- }
46
+ if (!mimetype.lookup(ext)?.includes?.("image"))
47
+ return processFile(req, filePath);
49
48
  const tempName = `${path.basename(filePath, ext)}_${Date.now()}${ext}`;
50
49
  const tempPath = path.join(path.dirname(filePath), tempName);
51
50
  try {
@@ -63,16 +62,13 @@ export const processImage = async (req, filePath, options) => {
63
62
  fit: "inside",
64
63
  });
65
64
  }
66
- if (outputFormat === "webp") {
65
+ if (outputFormat === "webp")
67
66
  transformer = transformer.toFormat("webp");
68
- }
69
- else if (outputFormat === "jpeg" || outputFormat === "jpg") {
67
+ else if (outputFormat === "jpeg" || outputFormat === "jpg")
70
68
  transformer = transformer.toFormat("jpeg");
71
- }
72
69
  await transformer.toFile(tempPath);
73
70
  await promisify(fs.rename)(tempPath, filePath);
74
- const relativePath = generateRelativePath(filePath, req?.params.fileType);
75
- return `${baseURL}${baseRoute}/${relativePath}`;
71
+ return processFile(req, filePath);
76
72
  }
77
73
  catch (error) {
78
74
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"file-upload.helpers.js","sourceRoot":"","sources":["../../../../../../src/modules/file-upload/utils/helpers/file-upload.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,QAAQ,MAAM,UAAU,CAAC;AAMhC,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEpE,MAAM,UAAU,gBAAgB,CAC9B,GAAiB,EACjB,CAAgB,EAChB,IAAuB;IAEvB,MAAM,EAAE,UAAU,EAAE,GAAG,cAAc,EAAE,CAAC;IACxC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CACvB,UAAU,EAAE,SAAS,GAAG,GAAG,IAAI,eAAe,EAC9C,GAAG,CACJ,CAAC;IACF,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,SAAS,IAAI,eAAe,EAAE,GAAG,CAAC,CAAC;IACzE,IAAI,EAAE,CAAC;AACT,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAiB;IAClD,MAAM,EAAE,UAAU,EAAE,GAAG,cAAc,EAAE,CAAC;IAGxC,MAAM,QAAQ,GACZ,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IAClE,MAAM,OAAO,GAAG,GAAG,QAAQ,MAAM,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;IACrD,MAAM,SA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AAS,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;QAEf,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport sharp from \"sharp\";\nimport { promisify } from \"util\";\nimport { getArkosConfig } from \"../../../../server\";\nimport mimetype from \"mimetype\";\nimport {\n ArkosNextFunction,\n ArkosRequest,\n ArkosResponse,\n} from \"../../../../types\";\nimport { fullCleanCwd } from \"../../../../utils/helpers/fs.helpers\";\n\nexport function adjustRequestUrl(\n req: ArkosRequest,\n _: ArkosResponse,\n next: ArkosNextFunction\n) {\n const { fileUpload } = getArkosConfig();\n req.url = req.url.replace(\n fileUpload?.baseRoute + \"/\" || \"/api/uploads/\",\n \"/\"\n );\n req.url = req.url.replace(fileUpload?.baseRoute || \"/api/uploads/\", \"/\");\n next();\n}\n\nexport function extractRequestInfo(req: ArkosRequest) {\n const { fileUpload } = getArkosConfig();\n\n // Determine the base URL for file access\n const protocol =\n req.headers[\"x-forwarded-proto\"] === \"https\" ? \"https\" : \"http\";\n const baseURL = `${protocol}://${req.get?.(\"host\")}`;\n const baseRoute = fileUpload?.baseRoute || \"/api/uploads\";\n return { baseURL, baseRoute };\n}\n\n/**\n * Generates the correct relative path regardless of upload directory location\n */\nconst generateRelativePath = (filePath: string, fileType: string) => {\n const { fileUpload } = getArkosConfig();\n\n const baseUploadDir = fileUpload?.baseUploadDir || \"/uploads\";\n if (baseUploadDir.startsWith(\"..\")) {\n // For paths outside project directory\n return path.join(fileType, path.basename(filePath));\n } else {\n // For paths within project\n return fullCleanCwd(\n filePath\n .replace(`${baseUploadDir}/`, \"\")\n .replace(`/${baseUploadDir}/`, \"\")\n .replace(`/${baseUploadDir}`, \"\")\n .replace(`${baseUploadDir}`, \"\")\n );\n }\n};\n\n/**\n * Handles basic file processing for non-image files\n */\nexport const processFile = async (\n req: ArkosRequest,\n filePath: string\n): Promise<string> => {\n const { baseURL, baseRoute } = extractRequestInfo(req);\n\n const relativePath = generateRelativePath(filePath, req.params!.fileType);\n return `${baseURL}${baseRoute === \"/\" ? \"\" : baseRoute}/${relativePath}`;\n};\n\n/**\n * Processes image files using Sharp for resizing and format conversion\n */\nexport const processImage = async (\n req: ArkosRequest,\n filePath: string,\n options: Record<string, any>\n): Promise<string | null> => {\n const { baseURL, baseRoute } = extractRequestInfo(req);\n\n const ext = path.extname(filePath).toLowerCase();\n const originalFormat = ext.replace(\".\", \"\");\n const outputFormat = options.format || originalFormat;\n\n if (!mimetype.lookup(ext)?.includes?.(\"image\")) {\n const relativePath = generateRelativePath(filePath, req.params!.fileType);\n return `${baseURL}${baseRoute}/${relativePath}`;\n }\n\n // Create a temp filename with original name + random string\n const tempName = `${path.basename(filePath, ext)}_${Date.now()}${ext}`;\n const tempPath = path.join(path.dirname(filePath), tempName);\n\n try {\n let transformer = sharp(filePath);\n const metadata = await transformer.metadata();\n\n // Apply resize transformations if requested\n if (options.resizeTo && metadata.width && metadata.height) {\n const targetSize = options.resizeTo;\n const scaleFactor =\n targetSize / Math.min(metadata.width, metadata.height);\n const newWidth = Math.round(metadata.width * scaleFactor);\n const newHeight = Math.round(metadata.height * scaleFactor);\n transformer = transformer.resize(newWidth, newHeight);\n } else if (options.width || options.height) {\n transformer = transformer.resize(\n options.width || null,\n options.height || null,\n {\n fit: \"inside\",\n }\n );\n }\n\n // Apply format transformations if requested\n if (outputFormat === \"webp\") {\n transformer = transformer.toFormat(\"webp\");\n } else if (outputFormat === \"jpeg\" || outputFormat === \"jpg\") {\n transformer = transformer.toFormat(\"jpeg\");\n }\n\n // Save to temp file first\n await transformer.toFile(tempPath);\n\n // Rename temp file to original filename\n await promisify(fs.rename)(tempPath, filePath);\n\n // Return the public URL for the file\n const relativePath = generateRelativePath(filePath, req?.params!.fileType);\n\n return `${baseURL}${baseRoute}/${relativePath}`;\n } catch (error) {\n // Clean up temp file if it exists\n try {\n await promisify(fs.stat)(tempPath);\n await promisify(fs.unlink)(tempPath);\n } catch (err) {\n // If temp file doesn't exist, no need to clean up\n }\n throw error;\n }\n};\n"]}
1
+ {"version":3,"file":"file-upload.helpers.js","sourceRoot":"","sources":["../../../../../../src/modules/file-upload/utils/helpers/file-upload.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,QAAQ,MAAM,UAAU,CAAC;AAMhC,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEpE,MAAM,UAAU,gBAAgB,CAC9B,GAAiB,EACjB,CAAgB,EAChB,IAAuB;IAEvB,MAAM,EAAE,UAAU,EAAE,GAAG,cAAc,EAAE,CAAC;IACxC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CACvB,UAAU,EAAE,SAAS,GAAG,GAAG,IAAI,eAAe,EAC9C,GAAG,CACJ,CAAC;IACF,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,SAAS,IAAI,eAAe,EAAE,GAAG,CAAC,CAAC;IACzE,IAAI,EAAE,CAAC;AACT,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAiB;IAClD,MAAM,EAAE,UAAU,EAAE,GAAG,cAAc,EAAE,CAAC;IAGxC,MAAM,QAAQ,GACZ,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,OAAO;QACxD,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,MAAM,CAAC;IACb,MAAM,OAAO,GAAG,GAAG,QAAQ,MAAM,GAAG,CAAC,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from \"fs\";\nimport path from \"path\";\nimport sharp from \"sharp\";\nimport { promisify } from \"util\";\nimport { getArkosConfig } from \"../../../../server\";\nimport mimetype from \"mimetype\";\nimport {\n ArkosNextFunction,\n ArkosRequest,\n ArkosResponse,\n} from \"../../../../types\";\nimport { fullCleanCwd } from \"../../../../utils/helpers/fs.helpers\";\n\nexport function adjustRequestUrl(\n req: ArkosRequest,\n _: ArkosResponse,\n next: ArkosNextFunction\n) {\n const { fileUpload } = getArkosConfig();\n req.url = req.url.replace(\n fileUpload?.baseRoute + \"/\" || \"/api/uploads/\",\n \"/\"\n );\n req.url = req.url.replace(fileUpload?.baseRoute || \"/api/uploads/\", \"/\");\n next();\n}\n\nexport function extractRequestInfo(req: ArkosRequest) {\n const { fileUpload } = getArkosConfig();\n\n // Determine the base URL for file access\n const protocol =\n req.secure || req.headers[\"x-forwarded-proto\"] === \"https\"\n ? \"https\"\n : \"http\";\n const baseURL = `${protocol}://${req.get?.(\"host\")}`;\n const baseRoute = fileUpload?.baseRoute || \"/api/uploads\";\n return { baseURL, baseRoute };\n}\n\n/**\n * Generates the correct relative path regardless of upload directory location\n */\nconst generateRelativePath = (filePath: string, fileType: string) => {\n const { fileUpload } = getArkosConfig();\n\n const baseUploadDir = fileUpload?.baseUploadDir || \"/uploads\";\n if (baseUploadDir.startsWith(\"..\")) {\n return path.join(fileType, path.basename(filePath));\n } else {\n return fullCleanCwd(\n filePath\n .replace(`${baseUploadDir}/`, \"\")\n .replace(`/${baseUploadDir}/`, \"\")\n .replace(`/${baseUploadDir}`, \"\")\n .replace(`${baseUploadDir}`, \"\")\n );\n }\n};\n\n/**\n * Handles basic file processing for non-image files\n */\nexport const processFile = async (\n req: ArkosRequest,\n filePath: string\n): Promise<string> => {\n const { baseURL, baseRoute } = extractRequestInfo(req);\n\n const relativePath = generateRelativePath(\n filePath,\n req.params!.fileType\n ).replace(/\\\\/g, \"/\");\n\n return `${baseURL}${baseRoute === \"/\" ? \"\" : baseRoute}${\n relativePath.startsWith(\"/\") ? relativePath : `/${relativePath}`\n }`;\n};\n\n/**\n * Processes image files using Sharp for resizing and format conversion\n */\nexport const processImage = async (\n req: ArkosRequest,\n filePath: string,\n options: Record<string, any>\n): Promise<string | null> => {\n const ext = path.extname(filePath).toLowerCase();\n const originalFormat = ext.replace(\".\", \"\");\n const outputFormat = options.format || originalFormat;\n\n if (!mimetype.lookup(ext)?.includes?.(\"image\"))\n return processFile(req, filePath);\n\n const tempName = `${path.basename(filePath, ext)}_${Date.now()}${ext}`;\n const tempPath = path.join(path.dirname(filePath), tempName);\n\n try {\n let transformer = sharp(filePath);\n const metadata = await transformer.metadata();\n\n if (options.resizeTo && metadata.width && metadata.height) {\n const targetSize = options.resizeTo;\n const scaleFactor =\n targetSize / Math.min(metadata.width, metadata.height);\n const newWidth = Math.round(metadata.width * scaleFactor);\n const newHeight = Math.round(metadata.height * scaleFactor);\n transformer = transformer.resize(newWidth, newHeight);\n } else if (options.width || options.height) {\n transformer = transformer.resize(\n options.width || null,\n options.height || null,\n {\n fit: \"inside\",\n }\n );\n }\n\n if (outputFormat === \"webp\") transformer = transformer.toFormat(\"webp\");\n else if (outputFormat === \"jpeg\" || outputFormat === \"jpg\")\n transformer = transformer.toFormat(\"jpeg\");\n\n await transformer.toFile(tempPath);\n\n await promisify(fs.rename)(tempPath, filePath);\n\n return processFile(req, filePath);\n } catch (error) {\n try {\n await promisify(fs.stat)(tempPath);\n await promisify(fs.unlink)(tempPath);\n } catch (err) {\n // If temp file doesn't exist, no need to clean up\n }\n throw error;\n }\n};\n"]}
@@ -86,7 +86,7 @@ function buildTypeScriptProject(options, moduleType) {
86
86
  const tempTsconfigPath = path.join(process.cwd(), `tsconfig.arkos-build.json`);
87
87
  fs.writeFileSync(tempTsconfigPath, JSON.stringify(tempTsconfig, null, 2));
88
88
  try {
89
- execSync(`npx rimraf ${BUILD_DIR} && npx tsc -p ${tempTsconfigPath}`, {
89
+ execSync(`npx trash ${BUILD_DIR} && npx tsc -p ${tempTs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C;IACtE,CAAC;AACH,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { execSync } from \"child_process\";\nimport { fullCleanCwd, getUserFileExtension } from \"../helpers/fs.helpers\";\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { getVersion } from \"./utils/cli.helpers\";\nimport { detectPackageManagerFromUserAgent } from \"../helpers/global.helpers\";\nimport sheu from \"../sheu\";\n\n// Constants\nconst BUILD_DIR = \".build\";\nconst MODULE_TYPES = [\"cjs\", \"esm\"] as const;\ntype ModuleType = (typeof MODULE_TYPES)[number];\n\ninterface BuildOptions {\n config?: string;\n module?: string;\n}\n\n/**\n * Main build function for the arkos CLI\n */\nexport function buildCommand(options: BuildOptions = {}) {\n const fileExt = getUserFileExtension();\n process.env.NODE_ENV = \"production\";\n process.env.NODE_ENV = \"true\";\n\n const envFiles = loadEnvironmentVariables();\n const moduleType = validateModuleType(options.module);\n\n try {\n console.info(` \\x1b[1m\\x1b[36m Arkos.js ${getVersion()}\\x1b[0m`);\n console.info(\n ` - Environments: ${fullCleanCwd(envFiles?.join(\", \") || \"\")\n .replaceAll(`${process.cwd()}/`, \"\")\n .replaceAll(\"/\", \"\")}`\n );\n\n console.info(`\\n Creating an optimized production build...`);\n\n ensureBuildDir();\n\n // Detect project type\n\n if (fileExt === \"ts\") {\n buildTypeScriptProject(options, moduleType);\n } else {\n buildJavaScriptProject(options, moduleType);\n }\n\n const packageManger = detectPackageManagerFromUserAgent();\n\n console.info(`\\n\\x1b[1m\\x1b[32m Build complete!\\x1b[0m\\n`);\n console.info(` \\x1b[1mNext step:\\x1b[0m`);\n console.info(\n ` Run it using \\x1b[1m\\x1b[36m${packageManger} run start\\x1b[0m\\n`\n );\n } catch (err: any) {\n console.info(\"\");\n sheu.error(`Build failed: ${err?.message}`);\n console.error(err);\n process.exit(1);\n }\n}\n\n/**\n * Validates and normalizes module type option\n */\nfunction validateModuleType(moduleType?: string): ModuleType {\n if (!moduleType) return \"cjs\";\n\n const normalizedType = moduleType.toLowerCase();\n\n // Map common terms to our module types\n if (normalizedType === \"cjs\" || normalizedType === \"commonjs\") {\n return \"cjs\";\n } else if (\n [\"esm\", \"es\", \"es2020\", \"esnext\", \"module\"].includes(normalizedType)\n ) {\n return \"esm\";\n }\n\n // Default to CJS if unrecognized\n console.warn(\n `⚠️ Unrecognized module type \"${moduleType}\", defaulting to \"cjs\"`\n );\n return \"cjs\";\n}\n\n/**\n * Ensure the build directory exists\n */\nfunction ensureBuildDir() {\n if (!fs.existsSync(BUILD_DIR)) {\n fs.mkdirSync(BUILD_DIR, { recursive: true });\n }\n\n // Create module-specific subdirectories\n for (const moduleType of MODULE_TYPES) {\n const moduleDir = path.join(BUILD_DIR, moduleType);\n if (!fs.existsSync(moduleDir)) {\n fs.mkdirSync(moduleDir, { recursive: true });\n }\n }\n}\n\n/**\n * Build a TypeScript project\n */\nfunction buildTypeScriptProject(options: BuildOptions, moduleType: ModuleType) {\n // Read the user's tsconfig.json\n const tsconfigPath = path.join(\n process.cwd(),\n options.config || \"tsconfig.json\"\n );\n let tsconfig: any = {};\n\n try {\n if (fs.existsSync(tsconfigPath)) {\n const tsconfigContent = fs.readFileSync(tsconfigPath, \"utf8\");\n tsconfig = JSON.parse(tsconfigContent);\n }\n } catch (error) {\n console.error(\"❌ Error reading tsconfig.json:\", error);\n // Continue with default config\n }\n\n // Create a custom tsconfig that outputs to our build directory with the correct module type\n const tempTsconfig = {\n ...tsconfig,\n compilerOptions: {\n ...(tsconfig.compilerOptions || {}),\n rootDir: \".\",\n outDir: path.join(`./${BUILD_DIR}`),\n // module: moduleType === \"esm\" ? \"ESNext\" : \"CommonJS\",\n },\n };\n\n const tempTsconfigPath = path.join(\n process.cwd(),\n `tsconfig.arkos-build.json`\n );\n fs.writeFileSync(tempTsconfigPath, JSON.stringify(tempTsconfig, null, 2));\n\n try {\n // Run TypeScript compiler\n execSync(`npx rimraf ${BUILD_DIR} && npx tsc -p ${tempTsconfigPath}`, {\n stdio: \"inherit\",\n cwd: process.cwd(),\n });\n\n // Copy non-TypeScript files\n\n copyAllNonSourceFiles(moduleType, [\".ts\", \".tsx\"]);\n\n // Clean up temp config\n cleanupTempConfig(tempTsconfigPath);\n } catch (error) {\n cleanupTempConfig(tempTsconfigPath);\n throw error;\n }\n}\n\n/**\n * Build a JavaScript project\n */\nfunction buildJavaScriptProject(_: BuildOptions, moduleType: ModuleType) {\n // Target directory\n const targetDir = path.join(BUILD_DIR);\n\n try {\n // Copy JavaScript files based on module type\n if (moduleType === \"esm\") {\n // Copy JS files for ESM (skip .cjs files as they are CommonJS)\n\n execSync(\n `npx copyfiles -u 0 \"src/**/*.js\" \"src/**/*.jsx\" \"src/**/*.mjs\" ${targetDir}`,\n {\n stdio: \"inherit\",\n cwd: process.cwd(),\n }\n );\n\n // Note about CommonJS files\n console.info(\"Note: .cjs files are skipped in ESM build\");\n } else {\n // Copy all JS files for CommonJS\n\n execSync(\n `npx copyfiles -u 0 \"src/**/*.js\" \"src/**/*.jsx\" \"src/**/*.cjs\" \"src/**/*.mjs\" ${targetDir}`,\n {\n stdio: \"inherit\",\n cwd: process.cwd(),\n }\n );\n }\n\n // Copy all non-JS files\n copyAllNonSourceFiles(moduleType, [\n \".js\",\n \".jsx\",\n \".mjs\",\n \".cjs\",\n \".ts\",\n \".tsx\",\n ]);\n\n // Create appropriate package.json in the build directory\n createModulePackageJson(moduleType);\n } catch (error) {\n console.error(\"❌ Error building JavaScript project:\", error);\n throw error;\n }\n}\n\n/**\n * Copy all non-source code files to the build directory\n * This function will copy everything except the specified source file extensions\n */\nfunction copyAllNonSourceFiles(_: ModuleType, skipExtensions: string[]) {\n const targetDir = path.join(BUILD_DIR);\n const sourceDir = \"src\";\n\n try {\n // Recursive function to copy files\n function copyDirRecursive(dir: string) {\n if (!fs.existsSync(dir)) return;\n\n const items = fs.readdirSync(dir);\n\n for (const item of items) {\n const sourcePath = path.join(dir, item);\n const targetPath = path.join(\n targetDir,\n dir.replace(sourceDir, \"\"),\n item\n );\n\n // Get file stats\n const stats = fs.statSync(sourcePath);\n\n if (stats.isDirectory()) {\n // Ensure target directory exists\n if (!fs.existsSync(targetPath)) {\n fs.mkdirSync(targetPath, { recursive: true });\n }\n // Recurse into subdirectory\n copyDirRecursive(sourcePath);\n } else if (stats.isFile()) {\n // Check if this is a file we should skip\n const ext = path.extname(item).toLowerCase();\n if (!skipExtensions.includes(ext)) {\n // Ensure the target directory exists\n const targetDir = path.dirname(targetPath);\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true });\n }\n // Copy the file\n fs.copyFileSync(sourcePath, targetPath);\n }\n }\n }\n }\n\n // Start copying from src directory\n copyDirRecursive(sourceDir);\n\n // Copy project root files if needed\n const rootFilesToCopy = [\"README.md\", \"LICENSE\"];\n\n for (const file of rootFilesToCopy) {\n if (fs.existsSync(path.join(process.cwd(), file))) {\n fs.copyFileSync(\n path.join(process.cwd(), file),\n path.join(targetDir, file)\n );\n }\n }\n\n // console.info(`Copied all non-source files to ${targetDir}`);\n } catch (error) {\n console.warn(\"Warning: Error copying project files:\", error);\n console.error(error);\n }\n}\n\n/**\n * Create appropriate package.json in the build directory\n */\nfunction createModulePackageJson(moduleType: ModuleType) {\n const packageJsonPath = path.join(process.cwd(), \"package.json\");\n\n if (!fs.existsSync(packageJsonPath)) {\n return;\n }\n\n try {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf8\"));\n const buildPackageJson: any = {\n name: packageJson.name,\n version: packageJson.version,\n description: packageJson.description,\n main: \"index.js\",\n dependencies: packageJson.dependencies,\n };\n\n // Set appropriate type field for ESM\n if (moduleType === \"esm\") {\n buildPackageJson.type = \"module\";\n }\n\n const targetDir = path.join(BUILD_DIR, moduleType);\n fs.writeFileSync(\n path.join(targetDir, \"package.json\"),\n JSON.stringify(buildPackageJson, null, 2)\n );\n } catch (error) {\n console.warn(\n \"Warning: Failed to create module-specific package.json\",\n error\n );\n }\n}\n\n/**\n * Clean up temporary tsconfig\n */\nfunction cleanupTempConfig(configPath: string) {\n try {\n if (fs.existsSync(configPath)) fs.unlinkSync(configPath);\n } catch (error) {\n console.warn(\"Warning: Error cleaning up temporary config:\", error);\n }\n}\n"]}
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../src/utils/cli/build.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,IAAI,MAAM,SAAS,CAAC;AAG3B,MAAM,SAAS,GAAG,QAAQ,CAAC;AAC3B,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,KAAK,CAAU,CAAC;AAW7C,MAAM,UAAU,YAAY,CAAC,UAAwB,EAAE;IACrD,MAAM,OAAO,GAAG,oBAAoB,EAAE,CAAC;IACvC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,MAAM,CAAC;IAE9B,MAAM,QAAQ,GAAG,wBAAwB,EAAE,CAAC;IAC5C,MAAM,UAAU,GAAG,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtD,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,+BAA+B,UAAU,EAAE,SAAS,CAAC,CAAC;QACnE,OAAO,CAAC,IAAI,CACV,qBAAqB,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;aAC1D,UAAU,CAAC,GAAG,OAAO,CAAC,G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AAO,CAAC,IAAI,CAAC,8CAA8C,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;AACH,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { execSync } from \"child_process\";\nimport { fullCleanCwd, getUserFileExtension } from \"../helpers/fs.helpers\";\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { getVersion } from \"./utils/cli.helpers\";\nimport { detectPackageManagerFromUserAgent } from \"../helpers/global.helpers\";\nimport sheu from \"../sheu\";\n\n// Constants\nconst BUILD_DIR = \".build\";\nconst MODULE_TYPES = [\"cjs\", \"esm\"] as const;\ntype ModuleType = (typeof MODULE_TYPES)[number];\n\ninterface BuildOptions {\n config?: string;\n module?: string;\n}\n\n/**\n * Main build function for the arkos CLI\n */\nexport function buildCommand(options: BuildOptions = {}) {\n const fileExt = getUserFileExtension();\n process.env.NODE_ENV = \"production\";\n process.env.NODE_ENV = \"true\";\n\n const envFiles = loadEnvironmentVariables();\n const moduleType = validateModuleType(options.module);\n\n try {\n console.info(` \\x1b[1m\\x1b[36m Arkos.js ${getVersion()}\\x1b[0m`);\n console.info(\n ` - Environments: ${fullCleanCwd(envFiles?.join(\", \") || \"\")\n .replaceAll(`${process.cwd()}/`, \"\")\n .replaceAll(\"/\", \"\")}`\n );\n\n console.info(`\\n Creating an optimized production build...`);\n\n ensureBuildDir();\n\n // Detect project type\n\n if (fileExt === \"ts\") {\n buildTypeScriptProject(options, moduleType);\n } else {\n buildJavaScriptProject(options, moduleType);\n }\n\n const packageManger = detectPackageManagerFromUserAgent();\n\n console.info(`\\n\\x1b[1m\\x1b[32m Build complete!\\x1b[0m\\n`);\n console.info(` \\x1b[1mNext step:\\x1b[0m`);\n console.info(\n ` Run it using \\x1b[1m\\x1b[36m${packageManger} run start\\x1b[0m\\n`\n );\n } catch (err: any) {\n console.info(\"\");\n sheu.error(`Build failed: ${err?.message}`);\n console.error(err);\n process.exit(1);\n }\n}\n\n/**\n * Validates and normalizes module type option\n */\nfunction validateModuleType(moduleType?: string): ModuleType {\n if (!moduleType) return \"cjs\";\n\n const normalizedType = moduleType.toLowerCase();\n\n // Map common terms to our module types\n if (normalizedType === \"cjs\" || normalizedType === \"commonjs\") {\n return \"cjs\";\n } else if (\n [\"esm\", \"es\", \"es2020\", \"esnext\", \"module\"].includes(normalizedType)\n ) {\n return \"esm\";\n }\n\n // Default to CJS if unrecognized\n console.warn(\n `⚠️ Unrecognized module type \"${moduleType}\", defaulting to \"cjs\"`\n );\n return \"cjs\";\n}\n\n/**\n * Ensure the build directory exists\n */\nfunction ensureBuildDir() {\n if (!fs.existsSync(BUILD_DIR)) {\n fs.mkdirSync(BUILD_DIR, { recursive: true });\n }\n\n // Create module-specific subdirectories\n for (const moduleType of MODULE_TYPES) {\n const moduleDir = path.join(BUILD_DIR, moduleType);\n if (!fs.existsSync(moduleDir)) {\n fs.mkdirSync(moduleDir, { recursive: true });\n }\n }\n}\n\n/**\n * Build a TypeScript project\n */\nfunction buildTypeScriptProject(options: BuildOptions, moduleType: ModuleType) {\n // Read the user's tsconfig.json\n const tsconfigPath = path.join(\n process.cwd(),\n options.config || \"tsconfig.json\"\n );\n let tsconfig: any = {};\n\n try {\n if (fs.existsSync(tsconfigPath)) {\n const tsconfigContent = fs.readFileSync(tsconfigPath, \"utf8\");\n tsconfig = JSON.parse(tsconfigContent);\n }\n } catch (error) {\n console.error(\"❌ Error reading tsconfig.json:\", error);\n // Continue with default config\n }\n\n // Create a custom tsconfig that outputs to our build directory with the correct module type\n const tempTsconfig = {\n ...tsconfig,\n compilerOptions: {\n ...(tsconfig.compilerOptions || {}),\n rootDir: \".\",\n outDir: path.join(`./${BUILD_DIR}`),\n // module: moduleType === \"esm\" ? \"ESNext\" : \"CommonJS\",\n },\n };\n\n const tempTsconfigPath = path.join(\n process.cwd(),\n `tsconfig.arkos-build.json`\n );\n fs.writeFileSync(tempTsconfigPath, JSON.stringify(tempTsconfig, null, 2));\n\n try {\n execSync(`npx trash ${BUILD_DIR} && npx tsc -p ${tempTsconfigPath}`, {\n stdio: \"inherit\",\n cwd: process.cwd(),\n });\n\n copyAllNonSourceFiles(moduleType, [\".ts\", \".tsx\"]);\n\n // Clean up temp config\n cleanupTempConfig(tempTsconfigPath);\n } catch (error) {\n cleanupTempConfig(tempTsconfigPath);\n throw error;\n }\n}\n\n/**\n * Build a JavaScript project\n */\nfunction buildJavaScriptProject(_: BuildOptions, moduleType: ModuleType) {\n const targetDir = path.join(BUILD_DIR);\n\n try {\n if (moduleType === \"esm\") {\n execSync(\n `npx copyfiles -u 0 \"src/**/*.js\" \"src/**/*.jsx\" \"src/**/*.mjs\" ${targetDir}`,\n {\n stdio: \"inherit\",\n cwd: process.cwd(),\n }\n );\n\n console.info(\"Note: .cjs files are skipped in ESM build\");\n } else {\n execSync(\n `npx copyfiles -u 0 \"src/**/*.js\" \"src/**/*.jsx\" \"src/**/*.cjs\" \"src/**/*.mjs\" ${targetDir}`,\n {\n stdio: \"inherit\",\n cwd: process.cwd(),\n }\n );\n }\n\n copyAllNonSourceFiles(moduleType, [\n \".js\",\n \".jsx\",\n \".mjs\",\n \".cjs\",\n \".ts\",\n \".tsx\",\n ]);\n\n // Create appropriate package.json in the build directory\n createModulePackageJson(moduleType);\n } catch (error) {\n console.error(\"❌ Error building JavaScript project:\", error);\n throw error;\n }\n}\n\n/**\n * Copy all non-source code files to the build directory\n * This function will copy everything except the specified source file extensions\n */\nfunction copyAllNonSourceFiles(_: ModuleType, skipExtensions: string[]) {\n const targetDir = path.join(BUILD_DIR);\n const sourceDir = \"src\";\n\n try {\n // Recursive function to copy files\n function copyDirRecursive(dir: string) {\n if (!fs.existsSync(dir)) return;\n\n const items = fs.readdirSync(dir);\n\n for (const item of items) {\n const sourcePath = path.join(dir, item);\n const targetPath = path.join(\n targetDir,\n dir.replace(sourceDir, \"\"),\n item\n );\n\n // Get file stats\n const stats = fs.statSync(sourcePath);\n\n if (stats.isDirectory()) {\n // Ensure target directory exists\n if (!fs.existsSync(targetPath)) {\n fs.mkdirSync(targetPath, { recursive: true });\n }\n // Recurse into subdirectory\n copyDirRecursive(sourcePath);\n } else if (stats.isFile()) {\n // Check if this is a file we should skip\n const ext = path.extname(item).toLowerCase();\n if (!skipExtensions.includes(ext)) {\n // Ensure the target directory exists\n const targetDir = path.dirname(targetPath);\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true });\n }\n // Copy the file\n fs.copyFileSync(sourcePath, targetPath);\n }\n }\n }\n }\n\n // Start copying from src directory\n copyDirRecursive(sourceDir);\n\n // Copy project root files if needed\n const rootFilesToCopy = [\"README.md\", \"LICENSE\"];\n\n for (const file of rootFilesToCopy) {\n if (fs.existsSync(path.join(process.cwd(), file))) {\n fs.copyFileSync(\n path.join(process.cwd(), file),\n path.join(targetDir, file)\n );\n }\n }\n\n // console.info(`Copied all non-source files to ${targetDir}`);\n } catch (error) {\n console.warn(\"Warning: Error copying project files:\", error);\n console.error(error);\n }\n}\n\n/**\n * Create appropriate package.json in the build directory\n */\nfunction createModulePackageJson(moduleType: ModuleType) {\n const packageJsonPath = path.join(process.cwd(), \"package.json\");\n\n if (!fs.existsSync(packageJsonPath)) {\n return;\n }\n\n try {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf8\"));\n const buildPackageJson: any = {\n name: packageJson.name,\n version: packageJson.version,\n description: packageJson.description,\n main: \"index.js\",\n dependencies: packageJson.dependencies,\n };\n\n // Set appropriate type field for ESM\n if (moduleType === \"esm\") {\n buildPackageJson.type = \"module\";\n }\n\n const targetDir = path.join(BUILD_DIR, moduleType);\n fs.writeFileSync(\n path.join(targetDir, \"package.json\"),\n JSON.stringify(buildPackageJson, null, 2)\n );\n } catch (error) {\n console.warn(\n \"Warning: Failed to create module-specific package.json\",\n error\n );\n }\n}\n\n/**\n * Clean up temporary tsconfig\n */\nfunction cleanupTempConfig(configPath: string) {\n try {\n if (fs.existsSync(configPath)) fs.unlinkSync(configPath);\n } catch (error) {\n console.warn(\"Warning: Error cleaning up temporary config:\", error);\n }\n}\n"]}
@@ -22,9 +22,10 @@ const generateFile = async (options, config) => {
22
22
  };
23
23
  const ext = getUserFileExtension();
24
24
  const resolvedPath = (config.customPath || customPath).replaceAll("{{module-name}}", names.kebab);
25
+ console.log(resolvedPath);
25
26
  const modulePath = path.join(process.cwd(), resolvedPath);
26
- const fileName = config.useCreatePrefix
27
- ? `create-${names.kebab}.${config.fileSuffix}.${ext}`
27
+ const fileName = config.prefix
28
+ ? `${config.prefix}${names.kebab}.${config.fileSuffix}.${ext}`
28
29
  : `${names.kebab}.${config.fileSuffix}.${ext}`;
29
30
  const filePath = path.join(modulePath, fileName);
30
31
  const humamReadableTemplateName = config.templateName.charAt(0).toUpperCase() +
@@ -101,7 +102,7 @@ export const generateCommand = {
101
102
  templateName: "create-schema",
102
103
  fileSuffix: "schema",
103
104
  customPath: "src/modules/{{module-name}}/schemas",
104
- useCreatePrefix: true,
105
+ prefix: "create-",
105
106
  });
106
107
  },
107
108
  updateSchema: async (options) => {
@@ -109,7 +110,7 @@ export const generateCommand = {
109
110
  templateName: "update-schema",
110
111
  fileSuffix: "schema",
111
112
  customPath: "src/modules/{{module-name}}/schemas",
112
- useCreatePrefix: true,
113
+ prefix: "update-",
113
114
  });
114
115
  },
115
116
  createDto: async (options) => {
@@ -117,7 +118,7 @@ export const generateCommand = {
117
118
  templateName: "create-dto",
118
119
  fileSuffix: "dto",
119
120
  customPath: "src/modules/{{module-name}}/dtos",
120
- useCreatePrefix: true,
121
+ prefix: "create-",
121
122
  });
122
123
  },
123
124
  updateDto: async (options) => {
@@ -125,7 +126,7 @@ export const generateCommand = {
125
126
  templateName: "update-dto",
126
127
  fileSuffix: "dto",
127
128
  customPath: "src/modules/{{module-name}}/dtos",
128
- useCreatePrefix: true,
129
+ prefix: "update-",
129
130
  });
130
131
  },
131
132
  queryOptions: async (options) => {
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../../src/utils/cli/generate.ts"],"names":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C;YAC9C,eAAe,EAAE,IAAI;SACtB,CAAC,CAAC;IACL,CAAC;IAED,SAAS,EAAE,KAAK,EAAE,OAAwB,EAAE,EAAE;QAC5C,MAAM,YAAY,CAAC,OAAO,EAAE;YAC1B,YAAY,EAAE,YAAY;YAC1B,UAAU,EAAE,KAAK;YACjB,UAAU,EAAE,kCAAkC;YAC9C,eAAe,EAAE,IAAI;SACtB,CAAC,CAAC;IACL,CAAC;IAED,YAAY,EAAE,KAAK,EAAE,OAAwB,EAAE,EAAE;QAC/C,MAAM,YAAY,CAAC,OAAO,EAAE;YAC1B,YAAY,EAAE,eAAe;YAC7B,UAAU,EAAE,OAAO;YACnB,gBAAgB,EAAE,CAAC,SAAS,EAAE,EAAE;gBAC9B,IAAI,SAAS,KAAK,aAAa,EAAE,CAAC;oBAChC,IAAI,CAAC,KAAK,CACR,gEAAgE,CACjE,CAAC;oBACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { generateTemplate } from \"./utils/template-generators\";\nimport { ensureDirectoryExists } from \"./utils/cli.helpers\";\nimport {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../helpers/change-case.helpers\";\nimport { fullCleanCwd, getUserFileExtension } from \"../helpers/fs.helpers\";\nimport sheu from \"../sheu\";\nimport { capitalize } from \"../helpers/text.helpers\";\n\ninterface GenerateOptions {\n path?: string;\n model: string;\n}\n\ninterface GenerateConfig {\n templateName: string;\n fileSuffix: string;\n customValidation?: (modelName: string) => void;\n customImports?: (names: any) => any;\n customPath?: string;\n useCreatePrefix?: boolean;\n}\n\nconst generateFile = async (\n options: GenerateOptions,\n config: GenerateConfig\n) => {\n const modelName = options.model;\n\n if (!modelName) {\n sheu.error(\"Module name is required!\");\n process.exit(1);\n }\n\n if (config.customValidation) config.customValidation(modelName);\n\n const { path: customPath = \"src/modules/{{module-name}}\" } = options;\n\n const names = {\n pascal: pascalCase(modelName),\n camel: camelCase(modelName),\n kebab: kebabCase(modelName),\n };\n\n const ext = getUserFileExtension();\n\n // Replace {{module-name}} placeholder with actual kebab-cased module name\n const resolvedPath = (config.customPath || customPath).replaceAll(\n \"{{module-name}}\",\n names.kebab\n );\n\n const modulePath = path.join(process.cwd(), resolvedPath);\n\n // Determine file name based on whether it needs \"create-\" prefix\n const fileName = config.useCreatePrefix\n ? `create-${names.kebab}.${config.fileSuffix}.${ext}`\n : `${names.kebab}.${config.fileSuffix}.${ext}`;\n\n const filePath = path.join(modulePath, fileName);\n\n const humamReadableTemplateName =\n config.templateName.charAt(0).toUpperCase() +\n config.templateName.slice(1).replaceAll(\"-\", \" \");\n\n try {\n ensureDirectoryExists(modulePath);\n\n const templateData = {\n modelName: names,\n ...(config.customImports && { imports: config.customImports(names) }),\n };\n\n const content = generateTemplate(config.templateName, templateData);\n if (fs.existsSync(filePath))\n throw new Error(\n `${capitalize(humamReadableTemplateName.toLowerCase())} for ${options.model} already exists.`\n );\n fs.writeFileSync(filePath, content);\n\n console.info(\"\");\n sheu.done(\n `${humamReadableTemplateName} for ${options.model} generated under ${fullCleanCwd(filePath)}`\n );\n } catch (err: any) {\n console.info(\"\");\n sheu.error(\n `${`Failed to generate ${humamReadableTemplateName.toLowerCase()}`} for ${options.model} ${filePath ? \"under \" + fullCleanCwd(filePath) + \".\" : \".\"}`\n );\n console.info(`${sheu.bold(\"Reason: \")}${err?.message || \"unknown\"}`);\n process.exit(1);\n }\n};\n\nexport const generateCommand = {\n controller: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"controller\",\n fileSuffix: \"controller\",\n customImports: () => ({\n baseController: \"arkos/controllers\",\n }),\n });\n },\n\n service: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"service\",\n fileSuffix: \"service\",\n customImports: () => ({\n baseService: \"arkos/services\",\n }),\n });\n },\n\n router: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"router\",\n fileSuffix: \"router\",\n customImports: (names) => ({\n baseRouter: \"arkos\",\n controller: `./${names.kebab}.controller`,\n }),\n });\n },\n\n interceptors: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"interceptors\",\n fileSuffix: \"interceptors\",\n });\n },\n\n authConfigs: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"auth-configs\",\n fileSuffix: \"auth\",\n });\n },\n\n hooks: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"hooks\",\n fileSuffix: \"hooks\",\n });\n },\n\n createSchema: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"create-schema\",\n fileSuffix: \"schema\",\n customPath: \"src/modules/{{module-name}}/schemas\",\n useCreatePrefix: true,\n });\n },\n\n updateSchema: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"update-schema\",\n fileSuffix: \"schema\",\n customPath: \"src/modules/{{module-name}}/schemas\",\n useCreatePrefix: true,\n });\n },\n\n createDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"create-dto\",\n fileSuffix: \"dto\",\n customPath: \"src/modules/{{module-name}}/dtos\",\n useCreatePrefix: true,\n });\n },\n\n updateDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"update-dto\",\n fileSuffix: \"dto\",\n customPath: \"src/modules/{{module-name}}/dtos\",\n useCreatePrefix: true,\n });\n },\n\n queryOptions: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"query-options\",\n fileSuffix: \"query\",\n customValidation: (modelName) => {\n if (modelName === \"file-upload\") {\n sheu.error(\n \"Prisma query options are not available to file-upload resource\"\n );\n process.exit(1);\n }\n },\n });\n },\n};\n"]}
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../../src/utils/cli/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,gBAAgB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,CAAC,CAAC;IACL,CAAC;IAED,SAAS,EAAE,KAAK,EAAE,OAAwB,EAAE,EAAE;QAC5C,MAAM,YAAY,CAAC,OAAO,EAAE;YAC1B,YAAY,EAAE,YAAY;YAC1B,UAAU,EAAE,KAAK;YACjB,UAAU,EAAE,kCAAkC;YAC9C,MAAM,EAAE,SAAS;SAClB,CAAC,CAAC;IACL,CAAC;IAED,YAAY,EAAE,KAAK,EAAE,OAAwB,EAAE,EAAE;QAC/C,MAAM,YAAY,CAAC,OAAO,EAAE;YAC1B,YAAY,EAAE,eAAe;YAC7B,UAAU,EAAE,OAAO;YACnB,gBAAgB,EAAE,CAAC,SAAS,EAAE,EAAE;gBAC9B,IAAI,SAAS,KAAK,aAAa,EAAE,CAAC;oBAChC,IAAI,CAAC,KAAK,CACR,gEAAgE,CACjE,CAAC;oBACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { generateTemplate } from \"./utils/template-generators\";\nimport { ensureDirectoryExists } from \"./utils/cli.helpers\";\nimport {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../helpers/change-case.helpers\";\nimport { fullCleanCwd, getUserFileExtension } from \"../helpers/fs.helpers\";\nimport sheu from \"../sheu\";\nimport { capitalize } from \"../helpers/text.helpers\";\n\ninterface GenerateOptions {\n path?: string;\n model: string;\n}\n\ninterface GenerateConfig {\n templateName: string;\n fileSuffix: string;\n customValidation?: (modelName: string) => void;\n customImports?: (names: any) => any;\n customPath?: string;\n prefix?: string;\n}\n\nconst generateFile = async (\n options: GenerateOptions,\n config: GenerateConfig\n) => {\n const modelName = options.model;\n\n if (!modelName) {\n sheu.error(\"Module name is required!\");\n process.exit(1);\n }\n\n if (config.customValidation) config.customValidation(modelName);\n\n const { path: customPath = \"src/modules/{{module-name}}\" } = options;\n\n const names = {\n pascal: pascalCase(modelName),\n camel: camelCase(modelName),\n kebab: kebabCase(modelName),\n };\n\n const ext = getUserFileExtension();\n\n const resolvedPath = (config.customPath || customPath).replaceAll(\n \"{{module-name}}\",\n names.kebab\n );\n console.log(resolvedPath);\n\n const modulePath = path.join(process.cwd(), resolvedPath);\n\n const fileName = config.prefix\n ? `${config.prefix}${names.kebab}.${config.fileSuffix}.${ext}`\n : `${names.kebab}.${config.fileSuffix}.${ext}`;\n\n const filePath = path.join(modulePath, fileName);\n\n const humamReadableTemplateName =\n config.templateName.charAt(0).toUpperCase() +\n config.templateName.slice(1).replaceAll(\"-\", \" \");\n\n try {\n ensureDirectoryExists(modulePath);\n\n const templateData = {\n modelName: names,\n ...(config.customImports && { imports: config.customImports(names) }),\n };\n\n const content = generateTemplate(config.templateName, templateData);\n if (fs.existsSync(filePath))\n throw new Error(\n `${capitalize(humamReadableTemplateName.toLowerCase())} for ${options.model} already exists.`\n );\n fs.writeFileSync(filePath, content);\n\n console.info(\"\");\n sheu.done(\n `${humamReadableTemplateName} for ${options.model} generated under ${fullCleanCwd(filePath)}`\n );\n } catch (err: any) {\n console.info(\"\");\n sheu.error(\n `${`Failed to generate ${humamReadableTemplateName.toLowerCase()}`} for ${options.model} ${filePath ? \"under \" + fullCleanCwd(filePath) + \".\" : \".\"}`\n );\n console.info(`${sheu.bold(\"Reason: \")}${err?.message || \"unknown\"}`);\n process.exit(1);\n }\n};\n\nexport const generateCommand = {\n controller: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"controller\",\n fileSuffix: \"controller\",\n customImports: () => ({\n baseController: \"arkos/controllers\",\n }),\n });\n },\n\n service: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"service\",\n fileSuffix: \"service\",\n customImports: () => ({\n baseService: \"arkos/services\",\n }),\n });\n },\n\n router: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"router\",\n fileSuffix: \"router\",\n customImports: (names) => ({\n baseRouter: \"arkos\",\n controller: `./${names.kebab}.controller`,\n }),\n });\n },\n\n interceptors: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"interceptors\",\n fileSuffix: \"interceptors\",\n });\n },\n\n authConfigs: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"auth-configs\",\n fileSuffix: \"auth\",\n });\n },\n\n hooks: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"hooks\",\n fileSuffix: \"hooks\",\n });\n },\n\n createSchema: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"create-schema\",\n fileSuffix: \"schema\",\n customPath: \"src/modules/{{module-name}}/schemas\",\n prefix: \"create-\",\n });\n },\n\n updateSchema: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"update-schema\",\n fileSuffix: \"schema\",\n customPath: \"src/modules/{{module-name}}/schemas\",\n prefix: \"update-\",\n });\n },\n\n createDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"create-dto\",\n fileSuffix: \"dto\",\n customPath: \"src/modules/{{module-name}}/dtos\",\n prefix: \"create-\",\n });\n },\n\n updateDto: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"update-dto\",\n fileSuffix: \"dto\",\n customPath: \"src/modules/{{module-name}}/dtos\",\n prefix: \"update-\",\n });\n },\n\n queryOptions: async (options: GenerateOptions) => {\n await generateFile(options, {\n templateName: \"query-options\",\n fileSuffix: \"query\",\n customValidation: (modelName) => {\n if (modelName === \"file-upload\") {\n sheu.error(\n \"Prisma query options are not available to file-upload resource\"\n );\n process.exit(1);\n }\n },\n });\n },\n};\n"]}
@@ -33,84 +33,84 @@ generate
33
33
  .alias("c")
34
34
  .description("Generate a new controller")
35
35
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
36
- .option("-p, --path <path>", "Custom path for the controller", "src/modules")
36
+ .option("-p, --path <path>", "Custom path for the controller", "src/modules/{{module-name}}")
37
37
  .action(generateCommand.controller);
38
38
  generate
39
39
  .command("service")
40
40
  .alias("s")
41
41
  .description("Generate a new service")
42
42
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
43
- .option("-p, --path <path>", "Custom path for the service", "src/modules")
43
+ .option("-p, --path <path>", "Custom path for the service", "src/modules/{{module-name}}")
44
44
  .action(generateCommand.service);
45
45
  generate
46
46
  .command("router")
47
47
  .alias("r")
48
48
  .description("Generate a new router")
49
49
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
50
- .option("-p, --path <path>", "Custom path for the router", "src/modules")
50
+ .option("-p, --path <path>", "Custom path for the router", "src/modules/{{module-name}}")
51
51
  .action(generateCommand.router);
52
52
  generate
53
53
  .command("auth-configs")
54
54
  .alias("a")
55
55
  .description("Generate auth configuration")
56
56
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
57
- .option("-p, --path <path>", "Custom path for the router", "src/modules")
57
+ .option("-p, --path <path>", "Custom path for the router", "src/modules/{{module-name}}")
58
58
  .action(generateCommand.authConfigs);
59
59
  generate
60
60
  .command("query-options")
61
61
  .alias("q")
62
62
  .description("Generate prisma query options")
63
63
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
64
- .option("-p, --path <path>", "Custom path for query options", "src/modules")
64
+ .option("-p, --path <path>", "Custom path for query options", "src/modules/{{module-name}}")
65
65
  .action(generateCommand.queryOptions);
66
66
  generate
67
67
  .command("middlewares")
68
68
  .alias("m")
69
69
  .description("Generate a new interceptors file")
70
70
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
71
- .option("-p, --path <path>", "Custom path for middleware", "src/modules")
71
+ .option("-p, --path <path>", "Custom path for middleware", "src/modules/{{module-name}}")
72
72
  .action(generateCommand.interceptors);
73
73
  generate
74
74
  .command("interceptors")
75
75
  .alias("i")
76
76
  .description("Generate a new interceptors file")
77
77
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
78
- .option("-p, --path <path>", "Custom path for interceptors", "src/modules")
78
+ .option("-p, --path <path>", "Custom path for interceptors", "src/modules/{{module-name}}")
79
79
  .action(generateCommand.interceptors);
80
80
  generate
81
81
  .command("hooks")
82
82
  .alias("h")
83
83
  .description("Generate a new service hooks file")
84
84
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
85
- .option("-p, --path <path>", "Custom path for hooks", "src/modules")
85
+ .option("-p, --path <path>", "Custom path for hooks", "src/modules/{{module-name}}")
86
86
  .action(generateCommand.hooks);
87
87
  generate
88
88
  .command("create-schema")
89
89
  .alias("cs")
90
90
  .description("Generate a new zod create schema file for a prisma model")
91
91
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
92
- .option("-p, --path <path>", "Custom path for hooks", "src/modules")
92
+ .option("-p, --path <path>", "Custom path for hooks", "src/modules/{{module-name}}")
93
93
  .action(generateCommand.createSchema);
94
94
  generate
95
95
  .command("update-schema")
96
96
  .alias("us")
97
97
  .description("Generate a new zod update schema file for a prisma model")
98
98
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
99
- .option("-p, --path <path>", "Custom path for hooks", "src/modules")
99
+ .option("-p, --path <path>", "Custom path for hooks", "src/modules/{{module-name}}")
100
100
  .action(generateCommand.updateSchema);
101
101
  generate
102
102
  .command("create-dto")
103
103
  .alias("cd")
104
104
  .description("Generate a new class-validator create dto file for a prisma model")
105
105
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
106
- .option("-p, --path <path>", "Custom path for hooks", "src/modules")
106
+ .option("-p, --path <path>", "Custom path for hooks", "src/modules/{{module-name}}")
107
107
  .action(generateCommand.createDto);
108
108
  generate
109
109
  .command("update-dto")
110
110
  .alias("ud")
111
111
  .description("Generate a new class-validator update dto file for a prisma model")
112
112
  .requiredOption("-m, --model <name>, --module <name>", "Module name")
113
- .option("-p, --path <path>", "Custom path for hooks", "src/modules")
113
+ .option("-p, --path <path>", "Custom path for hooks", "src/modules/{{module-name}}")
114
114
  .action(generateCommand.updateDto);
115
115
  program
116
116
  .command("prisma")
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,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AC;KACnE,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;AAExC,QAAQ;KACL,OAAO,CAAC,YAAY,CAAC;KACrB,KAAK,CAAC,IAAI,CAAC;KACX,WAAW,CACV,mEAAmE,CACpE;KACA,cAAc,CAAC,qCAAqC,EAAE,aAAa,CAAC;KACpE,MAAM,CAAC,mBAAmB,EAAE,uBAAuB,EAAE,aAAa,CAAC;KACnE,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;AAErC,QAAQ;KACL,OAAO,CAAC,YAAY,CAAC;KACrB,KAAK,CAAC,IAAI,CAAC;KACX,WAAW,CACV,mEAAmE,CACpE;KACA,cAAc,CAAC,qCAAqC,EAAE,aAAa,CAAC;KACpE,MAAM,CAAC,mBAAmB,EAAE,uBAAuB,EAAE,aAAa,CAAC;KACnE,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;AAErC,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,OAAO,CAAC,UAAU,CAAC;KACnB,WAAW,CAAC,0DAA0D,CAAC;KACvE,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAEjC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { Command } from \"commander\";\nimport { buildCommand } from \"./build\";\nimport { devCommand } from \"./dev\";\nimport { startCommand } from \"./start\";\nimport { generateCommand } from \"./generate\";\nimport { getVersion } from \"./utils/cli.helpers\";\nimport prismaGenerateCommand from \"./prisma-generate\";\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\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>, --module <name>\", \"Module 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>, --module <name>\", \"Module 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>, --module <name>\", \"Module 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 .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\"-p, --path <path>\", \"Custom path for the router\", \"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>, --module <name>\", \"Module 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 interceptors file\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\"-p, --path <path>\", \"Custom path for middleware\", \"src/modules\")\n .action(generateCommand.interceptors);\n\ngenerate\n .command(\"interceptors\")\n .alias(\"i\")\n .description(\"Generate a new interceptors file\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\"-p, --path <path>\", \"Custom path for interceptors\", \"src/modules\")\n .action(generateCommand.interceptors);\n\ngenerate\n .command(\"hooks\")\n .alias(\"h\")\n .description(\"Generate a new service hooks file\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\"-p, --path <path>\", \"Custom path for hooks\", \"src/modules\")\n .action(generateCommand.hooks);\n\ngenerate\n .command(\"create-schema\")\n .alias(\"cs\")\n .description(\"Generate a new zod create schema file for a prisma model\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\"-p, --path <path>\", \"Custom path for hooks\", \"src/modules\")\n .action(generateCommand.createSchema);\n\ngenerate\n .command(\"update-schema\")\n .alias(\"us\")\n .description(\"Generate a new zod update schema file for a prisma model\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\"-p, --path <path>\", \"Custom path for hooks\", \"src/modules\")\n .action(generateCommand.updateSchema);\n\ngenerate\n .command(\"create-dto\")\n .alias(\"cd\")\n .description(\n \"Generate a new class-validator create dto file for a prisma model\"\n )\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\"-p, --path <path>\", \"Custom path for hooks\", \"src/modules\")\n .action(generateCommand.createDto);\n\ngenerate\n .command(\"update-dto\")\n .alias(\"ud\")\n .description(\n \"Generate a new class-validator update dto file for a prisma model\"\n )\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\"-p, --path <path>\", \"Custom path for hooks\", \"src/modules\")\n .action(generateCommand.updateDto);\n\nprogram\n .command(\"prisma\")\n .command(\"generate\")\n .description(\"Generate your @prisma/client and BaseService class types\")\n .action(prismaGenerateCommand);\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":"AAAA,O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,EACnB,uBAAuB,EACvB,6BAA6B,CAC9B;KACA,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;AAExC,QAAQ;KACL,OAAO,CAAC,YAAY,CAAC;KACrB,KAAK,CAAC,IAAI,CAAC;KACX,WAAW,CACV,mEAAmE,CACpE;KACA,cAAc,CAAC,qCAAqC,EAAE,aAAa,CAAC;KACpE,MAAM,CACL,mBAAmB,EACnB,uBAAuB,EACvB,6BAA6B,CAC9B;KACA,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;AAErC,QAAQ;KACL,OAAO,CAAC,YAAY,CAAC;KACrB,KAAK,CAAC,IAAI,CAAC;KACX,WAAW,CACV,mEAAmE,CACpE;KACA,cAAc,CAAC,qCAAqC,EAAE,aAAa,CAAC;KACpE,MAAM,CACL,mBAAmB,EACnB,uBAAuB,EACvB,6BAA6B,CAC9B;KACA,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;AAErC,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,OAAO,CAAC,UAAU,CAAC;KACnB,WAAW,CAAC,0DAA0D,CAAC;KACvE,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAEjC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { Command } from \"commander\";\nimport { buildCommand } from \"./build\";\nimport { devCommand } from \"./dev\";\nimport { startCommand } from \"./start\";\nimport { generateCommand } from \"./generate\";\nimport { getVersion } from \"./utils/cli.helpers\";\nimport prismaGenerateCommand from \"./prisma-generate\";\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\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>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for the controller\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.controller);\n\ngenerate\n .command(\"service\")\n .alias(\"s\")\n .description(\"Generate a new service\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for the service\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.service);\n\ngenerate\n .command(\"router\")\n .alias(\"r\")\n .description(\"Generate a new router\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for the router\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.router);\n\ngenerate\n .command(\"auth-configs\")\n .alias(\"a\")\n .description(\"Generate auth configuration\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for the router\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.authConfigs);\n\ngenerate\n .command(\"query-options\")\n .alias(\"q\")\n .description(\"Generate prisma query options\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for query options\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.queryOptions);\n\ngenerate\n .command(\"middlewares\")\n .alias(\"m\")\n .description(\"Generate a new interceptors file\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for middleware\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.interceptors);\n\ngenerate\n .command(\"interceptors\")\n .alias(\"i\")\n .description(\"Generate a new interceptors file\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for interceptors\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.interceptors);\n\ngenerate\n .command(\"hooks\")\n .alias(\"h\")\n .description(\"Generate a new service hooks file\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for hooks\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.hooks);\n\ngenerate\n .command(\"create-schema\")\n .alias(\"cs\")\n .description(\"Generate a new zod create schema file for a prisma model\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for hooks\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.createSchema);\n\ngenerate\n .command(\"update-schema\")\n .alias(\"us\")\n .description(\"Generate a new zod update schema file for a prisma model\")\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for hooks\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.updateSchema);\n\ngenerate\n .command(\"create-dto\")\n .alias(\"cd\")\n .description(\n \"Generate a new class-validator create dto file for a prisma model\"\n )\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for hooks\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.createDto);\n\ngenerate\n .command(\"update-dto\")\n .alias(\"ud\")\n .description(\n \"Generate a new class-validator update dto file for a prisma model\"\n )\n .requiredOption(\"-m, --model <name>, --module <name>\", \"Module name\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for hooks\",\n \"src/modules/{{module-name}}\"\n )\n .action(generateCommand.updateDto);\n\nprogram\n .command(\"prisma\")\n .command(\"generate\")\n .description(\"Generate your @prisma/client and BaseService class types\")\n .action(prismaGenerateCommand);\n\nprogram.parse(process.argv);\n\nexport { program, buildCommand, devCommand, startCommand, generateCommand };\n"]}
@@ -11,6 +11,6 @@ export function killServerChildProcess() {
11
11
  killProductionServerChildProcess();
12
12
  }
13
13
  export function getVersion() {
14
- return "1.4.0-canary.2";
14
+ return "1.4.0-canary.4";
15
15
  }
16
16
  //# sourceMappingURL=cli.helpers.js.map
@@ -34,7 +34,7 @@ export function generateTemplate(type, options) {
34
34
  case "update-dto":
35
35
  return generateUpdateDtoTemplate(options);
36
36
  default:
37
- throw new Error(`\nUnknown template type: ${type}`);
37
+ throw new Error(`Unknown template type: ${type}`);
38
38
  }
39
39
  }
40
40
  //# sourceMappingURL=template-generators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"template-generators.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/template-generators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,oDAAoD,CAAC;AAChG,OAAO,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAC;AACnG,OAAO,EAAE,2BAA2B,EAAE,MAAM,qDAAqD,CAAC;AAClG,OAAO,EAAE,4BAA4B,EAAE,MAAM,uDAAuD,CAAC;AACrG,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC;AAC1F,OAAO,qBAAqB,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,4BAA4B,EAAE,MAAM,2DAA2D,CAAC;AACzG,OAAO,EAAE,4BAA4B,EAAE,MAAM,2DAA2D,CAAC;AACzG,OAAO,EAAE,yBAAyB,EAAE,MAAM,oEAAoE,CAAC;AAC/G,OAAO,EAAE,yBAAyB,EAAE,MAAM,oEAAoE,CAAC;AAoB/G,MAAM,UAAU,gBAAgB,CAC9B,IAAY,EACZ,OAAwB;IAExB,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,YAAY;YACf,OAAO,0BAA0B,CAAC,OAAO,CAAC,CAAC;QAC7C,KAAK,SAAS;YACZ,OAAO,uBAAuB,CAAC,OAAO,CAAC,CAAC;QAC1C,KAAK,QAAQ;YACX,OAAO,sBAAsB,CAAC,OAAO,CAAC,CAAC;QACzC,KAAK,cAAc;YACjB,OAAO,2BAA2B,CAAC,OAAO,CAAC,CAAC;QAC9C,KAAK,eAAe;YAClB,OAAO,4BAA4B,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,cAAc;YACjB,OAAO,2BAA2B,CAAC,OAAO,CAAC,CAAC;QAC9C,KAAK,OAAO;YACV,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACxC,KAAK,eAAe;YAClB,OAAO,4BAA4B,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,eAAe;YAClB,OAAO,4BAA4B,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,YAAY;YACf,OAAO,yBAAyB,CAAC,OAAO,CAAC,CAAC;QAC5C,KAAK,YAAY;YACf,OAAO,yBAAyB,CAAC,OAAO,CAAC,CAAC;QAC5C;YACE,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC;AACH,CAAC","sourcesContent":["import { generateControllerTemplate } from \"./template-generator/templates/controller-template\";\nimport { generateAuthConfigsTemplate } from \"./template-generator/templates/auth-configs-template\";\nimport { generateMiddlewaresTemplate } from \"./template-generator/templates/middlewares-template\";\nimport { generateQueryOptionsTemplate } from \"./template-generator/templates/query-options-template\";\nimport { generateRouterTemplate } from \"./template-generator/templates/router-template\";\nimport { generateServiceTemplate } from \"./template-generator/templates/service-template\";\nimport generateHooksTemplate from \"./template-generator/templates/hooks-template\";\nimport { generateCreateSchemaTemplate } from \"./template-generator/templates/zod/create-schema-template\";\nimport { generateUpdateSchemaTemplate } from \"./template-generator/templates/zod/update-schema-template\";\nimport { generateUpdateDtoTemplate } from \"./template-generator/templates/class-validator/update-dto-template\";\nimport { generateCreateDtoTemplate } from \"./template-generator/templates/class-validator/create-dto-template\";\n\ninterface ModelName {\n pascal: string;\n camel: string;\n kebab: string;\n}\n\ninterface MiddlewareName {\n pascal: string;\n camel: string;\n kebab: string;\n}\n\nexport interface TemplateOptions {\n modelName: ModelName;\n middlewareName?: MiddlewareName;\n imports?: Record<string, string>;\n}\n\nexport function generateTemplate(\n type: string,\n options: TemplateOptions\n): string {\n switch (type) {\n case \"controller\":\n return generateControllerTemplate(options);\n case \"service\":\n return generateServiceTemplate(options);\n case \"router\":\n return generateRouterTemplate(options);\n case \"auth-configs\":\n return generateAuthConfigsTemplate(options);\n case \"query-options\":\n return generateQueryOptionsTemplate(options);\n case \"interceptors\":\n return generateMiddlewaresTemplate(options);\n case \"hooks\":\n return generateHooksTemplate(options);\n case \"create-schema\":\n return generateCreateSchemaTemplate(options);\n case \"update-schema\":\n return generateUpdateSchemaTemplate(options);\n case \"create-dto\":\n return generateCreateDtoTemplate(options);\n case \"update-dto\":\n return generateUpdateDtoTemplate(options);\n default:\n throw new Error(`\\nUnknown template type: ${type}`);\n }\n}\n"]}
1
+ {"version":3,"file":"template-generators.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/template-generators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,oDAAoD,CAAC;AAChG,OAAO,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAC;AACnG,OAAO,EAAE,2BAA2B,EAAE,MAAM,qDAAqD,CAAC;AAClG,OAAO,EAAE,4BAA4B,EAAE,MAAM,uDAAuD,CAAC;AACrG,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC;AAC1F,OAAO,qBAAqB,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,4BAA4B,EAAE,MAAM,2DAA2D,CAAC;AACzG,OAAO,EAAE,4BAA4B,EAAE,MAAM,2DAA2D,CAAC;AACzG,OAAO,EAAE,yBAAyB,EAAE,MAAM,oEAAoE,CAAC;AAC/G,OAAO,EAAE,yBAAyB,EAAE,MAAM,oEAAoE,CAAC;AAoB/G,MAAM,UAAU,gBAAgB,CAC9B,IAAY,EACZ,OAAwB;IAExB,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,YAAY;YACf,OAAO,0BAA0B,CAAC,OAAO,CAAC,CAAC;QAC7C,KAAK,SAAS;YACZ,OAAO,uBAAuB,CAAC,OAAO,CAAC,CAAC;QAC1C,KAAK,QAAQ;YACX,OAAO,sBAAsB,CAAC,OAAO,CAAC,CAAC;QACzC,KAAK,cAAc;YACjB,OAAO,2BAA2B,CAAC,OAAO,CAAC,CAAC;QAC9C,KAAK,eAAe;YAClB,OAAO,4BAA4B,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,cAAc;YACjB,OAAO,2BAA2B,CAAC,OAAO,CAAC,CAAC;QAC9C,KAAK,OAAO;YACV,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACxC,KAAK,eAAe;YAClB,OAAO,4BAA4B,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,eAAe;YAClB,OAAO,4BAA4B,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,YAAY;YACf,OAAO,yBAAyB,CAAC,OAAO,CAAC,CAAC;QAC5C,KAAK,YAAY;YACf,OAAO,yBAAyB,CAAC,OAAO,CAAC,CAAC;QAC5C;YACE,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC;AACH,CAAC","sourcesContent":["import { generateControllerTemplate } from \"./template-generator/templates/controller-template\";\nimport { generateAuthConfigsTemplate } from \"./template-generator/templates/auth-configs-template\";\nimport { generateMiddlewaresTemplate } from \"./template-generator/templates/middlewares-template\";\nimport { generateQueryOptionsTemplate } from \"./template-generator/templates/query-options-template\";\nimport { generateRouterTemplate } from \"./template-generator/templates/router-template\";\nimport { generateServiceTemplate } from \"./template-generator/templates/service-template\";\nimport generateHooksTemplate from \"./template-generator/templates/hooks-template\";\nimport { generateCreateSchemaTemplate } from \"./template-generator/templates/zod/create-schema-template\";\nimport { generateUpdateSchemaTemplate } from \"./template-generator/templates/zod/update-schema-template\";\nimport { generateUpdateDtoTemplate } from \"./template-generator/templates/class-validator/update-dto-template\";\nimport { generateCreateDtoTemplate } from \"./template-generator/templates/class-validator/create-dto-template\";\n\ninterface ModelName {\n pascal: string;\n camel: string;\n kebab: string;\n}\n\ninterface MiddlewareName {\n pascal: string;\n camel: string;\n kebab: string;\n}\n\nexport interface TemplateOptions {\n modelName: ModelName;\n middlewareName?: MiddlewareName;\n imports?: Record<string, string>;\n}\n\nexport function generateTemplate(\n type: string,\n options: TemplateOptions\n): string {\n switch (type) {\n case \"controller\":\n return generateControllerTemplate(options);\n case \"service\":\n return generateServiceTemplate(options);\n case \"router\":\n return generateRouterTemplate(options);\n case \"auth-configs\":\n return generateAuthConfigsTemplate(options);\n case \"query-options\":\n return generateQueryOptionsTemplate(options);\n case \"interceptors\":\n return generateMiddlewaresTemplate(options);\n case \"hooks\":\n return generateHooksTemplate(options);\n case \"create-schema\":\n return generateCreateSchemaTemplate(options);\n case \"update-schema\":\n return generateUpdateSchemaTemplate(options);\n case \"create-dto\":\n return generateCreateDtoTemplate(options);\n case \"update-dto\":\n return generateUpdateDtoTemplate(options);\n default:\n throw new Error(`Unknown template type: ${type}`);\n }\n}\n"]}
@@ -6,9 +6,15 @@ export const crd = () => process.env.ARKOS_BUILD === "true"
6
6
  export function fullCleanCwd(path) {
7
7
  if (typeof path !== "string")
8
8
  throw new Error("Path must be a string");
9
- const cwd = process.cwd().replace(/\/+$/, "");
10
- const escapedCwd = cwd.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
11
- return path.replace(new RegExp(`${escapedCwd}/?`, "g"), "");
9
+ if (path.startsWith(`/${process.cwd()}`) ||
10
+ path.startsWith(`${process.cwd()}`) ||
11
+ path.startsWith(`${process.cwd()}/`))
12
+ return path
13
+ .replace(process.cwd(), "")
14
+ .replace(/^\/+/g, "")
15
+ .replace("\\", "");
16
+ else
17
+ return path;
12
18
  }
13
19
  export let userFileExtension;
14
20
  export const getUserFileExtension = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"fs.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/fs.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,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,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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 && hasAppTs) 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"]}
1
+ {"version":3,"file":"fs.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/fs.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,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,IACE,IAAI,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;QACpC,IAAI,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;QACnC,IAAI,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;QAEpC,OAAO,IAAI;aACR,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC;aAC1B,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;aACpB,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;;QAClB,OAAO,IAAI,CAAC;AACnB,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;QAEjC,MAAM,WAAW,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;QAE1E,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;QAEvE,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM,CAAC;QAEvD,IAAI,WAAW;YAAE,iBAAiB,GAAG,IAAI,CAAC;aACrC,IAAI,WAAW,IAAI,QAAQ;YAAE,iBAAiB,GAAG,IAAI,CAAC;aACtD,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;QACX,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 fs from \"fs\";\nimport path from \"path\";\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 if (\n path.startsWith(`/${process.cwd()}`) ||\n path.startsWith(`${process.cwd()}`) ||\n path.startsWith(`${process.cwd()}/`)\n )\n return path\n .replace(process.cwd(), \"\")\n .replace(/^\\/+/g, \"\")\n .replace(\"\\\\\", \"\");\n else return path;\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 const hasTsConfig = fs.existsSync(path.join(currentDir, \"tsconfig.json\"));\n\n const hasAppTs = fs.existsSync(path.join(currentDir, \"src\", \"app.ts\"));\n const hasAppJs = fs.existsSync(path.join(currentDir, \"src\", \"app.js\"));\n\n const isBuildMode = process.env.ARKOS_BUILD === \"true\";\n\n if (isBuildMode) userFileExtension = \"js\";\n else if (hasTsConfig && hasAppTs) 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 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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkos",
3
- "version": "1.4.0-canary.2",
3
+ "version": "1.4.0-canary.4",
4
4
  "description": "The Express & Prisma RESTful Framework",
5
5
  "main": "dist/cjs/exports/index.js",
6
6
  "module": "dist/esm/exports/index.js",
@@ -85,11 +85,10 @@
85
85
  "build:esm": "tsc -p tsconfig.esm.json && npx tsx scripts/fix-esm-imports.ts",
86
86
  "build:types": "tsc -p tsconfig.types.json",
87
87
  "build:cjs": "tsc -p tsconfig.cjs.json",
88
- "build": "npx rimraf dist && pnpm run build:cjs && pnpm run build:esm && pnpm run build:types && tsx scripts/post-build-scripts.ts",
88
+ "build": "npx trash dist && pnpm run build:cjs && pnpm run build:esm && pnpm run build:types && tsx scripts/post-build-scripts.ts",
89
89
  "buildTsup": "tsup && tsx scripts/post-build-scripts.ts",
90
90
  "minifyOld": "esbuild dist/cjs/**/*.js --minify --outdir=dist --allow-overwrite --log-limit=0 --define:process.env.NODE_ENV=process.env.NODE_ENV",
91
91
  "minify": "esbuild $(find dist -type f -name '*.js') --minify --outdir=dist --allow-overwrite --log-limit=0 --define:process.env.NODE_ENV=process.env.NODE_ENV",
92
- "minifyOld2": "",
93
92
  "clean": "rm -r dist",
94
93
  "dev": "tsx --watch",
95
94
  "lint": "eslint src --ext .ts",
@@ -193,6 +192,7 @@
193
192
  "sharp": "^0.33.5",
194
193
  "swagger-jsdoc": "^6.2.8",
195
194
  "swagger-ui-express": "^5.0.1",
195
+ "trash-cli": "6.0.0",
196
196
  "zod": "^3.24.2",
197
197
  "zod-to-json-schema": "^3.24.6"
198
198
  },