arkos 1.6.2-beta → 1.6.3-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/app.js.map +1 -1
- package/dist/cjs/components/arkos-policy/index.js.map +1 -1
- package/dist/cjs/modules/auth/auth.service.js +6 -4
- package/dist/cjs/modules/auth/auth.service.js.map +1 -1
- package/dist/cjs/modules/auth/utils/services/auth-action.service.js +5 -3
- package/dist/cjs/modules/auth/utils/services/auth-action.service.js.map +1 -1
- package/dist/cjs/modules/email/email.service.js +1 -0
- package/dist/cjs/modules/email/email.service.js.map +1 -1
- package/dist/cjs/modules/file-upload/file-upload.controller.js +7 -4
- package/dist/cjs/modules/file-upload/file-upload.controller.js.map +1 -1
- package/dist/cjs/modules/swagger/swagger.router.js +4 -1
- package/dist/cjs/modules/swagger/swagger.router.js.map +1 -1
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/types/validation/validator.js +3 -0
- package/dist/cjs/types/validation/validator.js.map +1 -0
- package/dist/cjs/utils/arkos-router/types/index.js.map +1 -1
- package/dist/cjs/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js.map +1 -1
- package/dist/cjs/utils/cli/build.js +12 -3
- package/dist/cjs/utils/cli/build.js.map +1 -1
- package/dist/cjs/utils/cli/index.js.map +1 -1
- package/dist/cjs/utils/cli/start.js +11 -10
- package/dist/cjs/utils/cli/start.js.map +1 -1
- package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/esm/app.js.map +1 -1
- package/dist/esm/components/arkos-policy/index.js.map +1 -1
- package/dist/esm/modules/auth/auth.service.js +6 -4
- package/dist/esm/modules/auth/auth.service.js.map +1 -1
- package/dist/esm/modules/auth/utils/services/auth-action.service.js +6 -4
- package/dist/esm/modules/auth/utils/services/auth-action.service.js.map +1 -1
- package/dist/esm/modules/email/email.service.js +1 -0
- package/dist/esm/modules/email/email.service.js.map +1 -1
- package/dist/esm/modules/file-upload/file-upload.controller.js +7 -4
- package/dist/esm/modules/file-upload/file-upload.controller.js.map +1 -1
- package/dist/esm/modules/swagger/swagger.router.js +4 -1
- package/dist/esm/modules/swagger/swagger.router.js.map +1 -1
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/validation/validator.js +2 -0
- package/dist/esm/types/validation/validator.js.map +1 -0
- package/dist/esm/utils/arkos-router/types/index.js.map +1 -1
- package/dist/esm/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js.map +1 -1
- package/dist/esm/utils/cli/build.js +13 -4
- package/dist/esm/utils/cli/build.js.map +1 -1
- package/dist/esm/utils/cli/index.js.map +1 -1
- package/dist/esm/utils/cli/start.js +11 -10
- package/dist/esm/utils/cli/start.js.map +1 -1
- package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/types/modules/auth/utils/services/auth-action.service.d.ts +1 -1
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/validation/validator.d.ts +2 -0
- package/dist/types/utils/arkos-router/types/index.d.ts +9 -9
- package/dist/types/utils/cli/build.d.ts +1 -1
- package/dist/types/utils/cli/start.d.ts +4 -1
- package/package.json +4 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
|
-
import { execSync } from "child_process";
|
|
3
|
+
import { execFileSync, execSync } from "child_process";
|
|
4
4
|
import { getUserFileExtension } from "../helpers/fs.helpers.js";
|
|
5
5
|
import { loadEnvironmentVariables } from "../dotenv.helpers.js";
|
|
6
6
|
import { detectPackageManagerFromUserAgent } from "../helpers/global.helpers.js";
|
|
@@ -8,12 +8,14 @@ import sheu from "../sheu.js";
|
|
|
8
8
|
import watermarkStamper from "./utils/watermark-stamper.js";
|
|
9
9
|
import { removeDir } from "../remove-dir.js";
|
|
10
10
|
import { bundler } from "../bundler.js";
|
|
11
|
+
import portAndHostAllocator from "../features/port-and-host-allocator.js";
|
|
12
|
+
import { startCommand } from "./start.js";
|
|
11
13
|
const BUILD_DIR = ".build";
|
|
12
14
|
const MODULE_TYPES = ["cjs", "esm"];
|
|
13
|
-
export function buildCommand(options = {}) {
|
|
15
|
+
export async function buildCommand(options = {}) {
|
|
14
16
|
process.env.NO_CLI = "true";
|
|
15
17
|
const fileExt = getUserFileExtension();
|
|
16
|
-
if (
|
|
18
|
+
if (!process.env.NODE_ENV)
|
|
17
19
|
process.env.NODE_ENV = "production";
|
|
18
20
|
process.env.ARKOS_BUILD = "true";
|
|
19
21
|
const envFiles = loadEnvironmentVariables();
|
|
@@ -29,6 +31,13 @@ export function buildCommand(options = {}) {
|
|
|
29
31
|
else
|
|
30
32
|
buildJavaScriptProject(options, moduleType);
|
|
31
33
|
const packageManger = detectPackageManagerFromUserAgent();
|
|
34
|
+
const hostAndPort = await portAndHostAllocator.getHostAndAvailablePort(process.env);
|
|
35
|
+
const child = startCommand({
|
|
36
|
+
...hostAndPort,
|
|
37
|
+
stamp: false,
|
|
38
|
+
shouldThrow: true,
|
|
39
|
+
});
|
|
40
|
+
child.kill();
|
|
32
41
|
console.info(`\n\x1b[1m\x1b[32m Build complete!\x1b[0m\n`);
|
|
33
42
|
console.info(` \x1b[1mNext step:\x1b[0m`);
|
|
34
43
|
console.info(` Run it using \x1b[1m\x1b[36m${packageManger} run start\x1b[0m\n`);
|
|
@@ -84,7 +93,7 @@ function buildTypeScriptProject(options, moduleType) {
|
|
|
84
93
|
fs.writeFileSync(tempTsconfigPath, JSON.stringify(tempTsconfig, null, 2));
|
|
85
94
|
try {
|
|
86
95
|
removeDir(BUILD_DIR);
|
|
87
|
-
|
|
96
|
+
execFileSync("tsc", ["-p", tempTsconfigPath], {
|
|
88
97
|
stdio: "inherit",
|
|
89
98
|
cwd: process.cwd(),
|
|
90
99
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../src/utils/cli/build.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,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C,CAAC;IACvB,CAAC;AACH,CAAC;AAKD,SAAS,iBAAiB,CAAC,UAAkB;IAC3C,IAAI,CAAC;QACH,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;YAAE,EAAE,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 { getUserFileExtension } from \"../helpers/fs.helpers\";\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { detectPackageManagerFromUserAgent } from \"../helpers/global.helpers\";\nimport sheu from \"../sheu\";\nimport watermarkStamper from \"./utils/watermark-stamper\";\nimport { removeDir } from \"../remove-dir\";\nimport { bundler } from \"../bundler\";\n\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 process.env.NO_CLI = \"true\";\n const fileExt = getUserFileExtension();\n if (process.env.NODE_ENV === \"test\" || !process.env.NODE_ENV)\n process.env.NODE_ENV = \"production\";\n process.env.ARKOS_BUILD = \"true\";\n\n const envFiles = loadEnvironmentVariables();\n const moduleType = validateModuleType(options.module);\n\n try {\n watermarkStamper.stamp({\n envFiles,\n });\n\n console.info(`\\n Creating an optimized production build...`);\n\n ensureBuildDir();\n\n if (fileExt === \"ts\") buildTypeScriptProject(options, moduleType);\n else buildJavaScriptProject(options, moduleType);\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 if (normalizedType === \"cjs\" || normalizedType === \"commonjs\") return \"cjs\";\n else if ([\"esm\", \"es\", \"es2020\", \"esnext\", \"module\"].includes(normalizedType))\n return \"esm\";\n\n sheu.warn(`Unrecognized module type \"${moduleType}\", defaulting to \"cjs\"`);\n return \"cjs\";\n}\n\n/**\n * Ensure the build directory exists\n */\nfunction ensureBuildDir() {\n if (!fs.existsSync(BUILD_DIR)) fs.mkdirSync(BUILD_DIR, { recursive: true });\n\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 const tsconfigPath = path.join(\n process.cwd(),\n options.config || \"tsconfig.json\"\n );\n let tsconfig: any = {};\n try {\n if (fs.existsSync(tsconfigPath)) {\n tsconfig = bundler.readJsonWithComments(tsconfigPath);\n }\n } catch (error) {\n console.error(\"❌ Error reading tsconfig.json:\", error);\n }\n\n const tempTsconfig = {\n ...tsconfig,\n compilerOptions: {\n ...(tsconfig.compilerOptions || {}),\n rootDir: \".\",\n outDir: path.join(`./${BUILD_DIR}`),\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 removeDir(BUILD_DIR);\n execSync(`tsc -p ${tempTsconfigPath}`, {\n stdio: \"inherit\",\n cwd: process.cwd(),\n });\n\n copyAllNonSourceFiles(moduleType, [\".ts\", \".tsx\"]);\n bundler.bundle({\n ext: \".js\",\n outDir: path.join(process.cwd(), BUILD_DIR),\n rootDir: process.cwd(),\n configPath: tempTsconfigPath,\n });\n\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 bundler.bundle({\n ext: \".js\",\n outDir: path.join(process.cwd(), BUILD_DIR),\n rootDir: process.cwd(),\n });\n // createModulePackageJson(moduleType);\n } catch (error: any) {\n console.info(error.stack);\n console.error(\"❌ Error building JavaScript project:\", error.stack);\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 = [\"arkos.config.js\"];\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 * 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,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,IA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AAuC,EAAE,KAAK,CAAC,CAAC;QAC7D,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAKD,SAAS,iBAAiB,CAAC,UAAkB;IAC3C,IAAI,CAAC;QACH,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;YAAE,EAAE,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 { execFileSync, execSync } from \"child_process\";\nimport { getUserFileExtension } from \"../helpers/fs.helpers\";\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { detectPackageManagerFromUserAgent } from \"../helpers/global.helpers\";\nimport sheu from \"../sheu\";\nimport watermarkStamper from \"./utils/watermark-stamper\";\nimport { removeDir } from \"../remove-dir\";\nimport { bundler } from \"../bundler\";\nimport portAndHostAllocator from \"../features/port-and-host-allocator\";\nimport { startCommand } from \"./start\";\n\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 async function buildCommand(options: BuildOptions = {}) {\n process.env.NO_CLI = \"true\";\n const fileExt = getUserFileExtension();\n if (!process.env.NODE_ENV) process.env.NODE_ENV = \"production\";\n process.env.ARKOS_BUILD = \"true\";\n\n const envFiles = loadEnvironmentVariables();\n const moduleType = validateModuleType(options.module);\n\n try {\n watermarkStamper.stamp({\n envFiles,\n });\n\n console.info(`\\n Creating an optimized production build...`);\n\n ensureBuildDir();\n\n if (fileExt === \"ts\") buildTypeScriptProject(options, moduleType);\n else buildJavaScriptProject(options, moduleType);\n\n const packageManger = detectPackageManagerFromUserAgent();\n\n const hostAndPort = await portAndHostAllocator.getHostAndAvailablePort(\n process.env\n );\n\n const child = startCommand({\n ...hostAndPort,\n stamp: false,\n shouldThrow: true,\n });\n child.kill();\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 if (normalizedType === \"cjs\" || normalizedType === \"commonjs\") return \"cjs\";\n else if ([\"esm\", \"es\", \"es2020\", \"esnext\", \"module\"].includes(normalizedType))\n return \"esm\";\n\n sheu.warn(`Unrecognized module type \"${moduleType}\", defaulting to \"cjs\"`);\n return \"cjs\";\n}\n\n/**\n * Ensure the build directory exists\n */\nfunction ensureBuildDir() {\n if (!fs.existsSync(BUILD_DIR)) fs.mkdirSync(BUILD_DIR, { recursive: true });\n\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 const tsconfigPath = path.join(\n process.cwd(),\n options.config || \"tsconfig.json\"\n );\n let tsconfig: any = {};\n try {\n if (fs.existsSync(tsconfigPath)) {\n tsconfig = bundler.readJsonWithComments(tsconfigPath);\n }\n } catch (error) {\n console.error(\"❌ Error reading tsconfig.json:\", error);\n }\n\n const tempTsconfig = {\n ...tsconfig,\n compilerOptions: {\n ...(tsconfig.compilerOptions || {}),\n rootDir: \".\",\n outDir: path.join(`./${BUILD_DIR}`),\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 removeDir(BUILD_DIR);\n execFileSync(\"tsc\", [\"-p\", tempTsconfigPath], {\n stdio: \"inherit\",\n cwd: process.cwd(),\n });\n\n copyAllNonSourceFiles(moduleType, [\".ts\", \".tsx\"]);\n bundler.bundle({\n ext: \".js\",\n outDir: path.join(process.cwd(), BUILD_DIR),\n rootDir: process.cwd(),\n configPath: tempTsconfigPath,\n });\n\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 bundler.bundle({\n ext: \".js\",\n outDir: path.join(process.cwd(), BUILD_DIR),\n rootDir: process.cwd(),\n });\n // createModulePackageJson(moduleType);\n } catch (error: any) {\n console.info(error.stack);\n console.error(\"❌ Error building JavaScript project:\", error.stack);\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 = [\"arkos.config.js\"];\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 * 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,O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KACtB,WAAW,CAAC,uDAAuD,CAAC;KACpE,MAAM,CAAC,iBAAiB,EAAE,0CAA0C,CAAC;KACrE,MAAM,CACL,mBAAmB,EACnB,8BAA8B,EAC9B,wBAAwB,CACzB;KACA,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAGnC,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,EAAE;IACxC,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1D,MAAM,eAAe,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,eAAe,CAAC,kBAAkB,CAAC;YACjC,GAAG,eAAe;YAClB,KAAK,EAAE,UAAU;SAClB,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,oBAAoB,UAAU,EAAE,CAAC,CAAC;QAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,QAAQ;KACL,OAAO,CAAC,KAAK,CAAC;KACd,WAAW,CAAC,sCAAsC,CAAC;KACnD,MAAM,CAAC,GAAG,EAAE;IACX,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC7B,eAAe,CAAC,kBAAkB,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC;AAEL,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\";\nimport exportAuthActionCommand from \"./export-auth-action\";\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 .option(\n \"-m, --module <name>\",\n \"Module name (comma-separated for bulk: post,user,auth)\"\n )\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\"-p, --path <path>\", \"Custom path for the component\")\n .option(\"-o, --overwrite\", \"Overwrites all the content on the existing file\");\n\ngenerate\n .command(\"controller\")\n .alias(\"c\")\n .description(\"Generate a new controller\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.controller({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"service\")\n .alias(\"s\")\n .description(\"Generate a new service\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.service({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"router\")\n .alias(\"r\")\n .description(\"Generate a new router\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.router({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"auth-configs\")\n .alias(\"a\")\n .description(\"Generate auth configuration\")\n .option(\"-a, --advanced\", \"Advanced code structure\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.authConfigs({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"query-options\")\n .alias(\"q\")\n .description(\"Generate prisma query options\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.queryOptions({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"interceptors\")\n .alias(\"i\")\n .description(\"Generate a new interceptors file\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.interceptors({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"hooks\")\n .alias(\"h\")\n .description(\"Generate a new service hooks file\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.hooks({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"create-schema\")\n .alias(\"cs\")\n .description(\"Generate a new zod create schema file for a prisma model\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.createSchema({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"update-schema\")\n .alias(\"us\")\n .description(\"Generate a new zod update schema file for a prisma model\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.updateSchema({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"schema\")\n .alias(\"sc\")\n .description(\"Generate a new zod create schema file for a prisma model\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.baseSchema({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"query-schema\")\n .alias(\"qs\")\n .description(\"Generate a new zod update schema file for a prisma model\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.querySchema({ ...generateOptions, ...options });\n });\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 .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.createDto({ ...generateOptions, ...options });\n });\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 .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.updateDto({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"dto\")\n .alias(\"d\")\n .description(\n \"Generate a new class-validator base dto file for a prisma model\"\n )\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.baseDto({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"query-dto\")\n .alias(\"qd\")\n .description(\n \"Generate a new class-validator base dto file for a prisma model\"\n )\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.queryDto({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"model\")\n .alias(\"m\")\n .description(\"Generate a new prisma model\")\n .option(\"-p, --path <path>\", \"Custom path for prisma model\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.prismaModel({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"policy\")\n .alias(\"p\")\n .description(\"Generate a new policy\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.policy({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"login-schema\")\n .alias(\"ls\")\n .description(\"Generate zod login schema for auth module\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.loginSchema({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"signup-schema\")\n .alias(\"ss\")\n .description(\"Generate zod signup schema for auth module\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.signupSchema({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"update-me-schema\")\n .alias(\"ums\")\n .description(\"Generate zod update-me schema for auth module\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.updateMeSchema({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"update-password-schema\")\n .alias(\"ups\")\n .description(\"Generate zod update-password schema for auth module\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.updatePasswordSchema({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"login-dto\")\n .alias(\"ld\")\n .description(\"Generate class-validator login dto for auth module\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.loginDto({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"signup-dto\")\n .alias(\"sd\")\n .description(\"Generate class-validator signup dto for auth module\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.signupDto({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"update-me-dto\")\n .alias(\"umd\")\n .description(\"Generate class-validator update-me dto for auth module\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.updateMeDto({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"update-password-dto\")\n .alias(\"upd\")\n .description(\"Generate class-validator update-password dto for auth module\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.updatePasswordDto({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"components\")\n .alias(\"co\")\n .description(\n \"Generate multiple components for one or more modules. Use -m post,user,auth for multiple modules\"\n )\n .option(\"-a, --all\", \"Generate all components\")\n .option(\n \"-n, --names <names>\",\n \"Comma-separated list of components (e.g., s,sc,m or service,schema,model)\"\n )\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.multipleComponents({ ...generateOptions, ...options });\n });\n\nprogram\n .command(\"prisma\")\n .command(\"generate\")\n .description(\"Generate your @prisma/client and BaseService class types\")\n .action(prismaGenerateCommand);\n\nprogram\n .command(\"export\")\n .command(\"auth-action\")\n .description(\"Export file with an array containing all auth-actions\")\n .option(\"-o, --overwrite\", \"Overwrites all the changes on the object\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for auth-actions\",\n \"src/modules/auth/utils\"\n )\n .action(exportAuthActionCommand);\n\n// To resolve arkos g r,c,service -m post\ngenerate.on(\"command:*\", ([unknownCmd]) => {\n if (unknownCmd.includes(\",\") && !unknownCmd.includes(\" \")) {\n const generateOptions = generate.opts();\n generateCommand.multipleComponents({\n ...generateOptions,\n names: unknownCmd,\n });\n } else {\n console.error(`Unknown command: ${unknownCmd}`);\n process.exit(1);\n }\n});\n\ngenerate\n .command(\"all\")\n .description(\"Generate all components for a module\")\n .action(() => {\n const opts = generate.opts();\n generateCommand.multipleComponents({ ...opts, all: true });\n });\n\nprogram.parse(process.argv);\n\nexport { program, buildCommand, devCommand, startCommand, generateCommand };\n"]}
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,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\";\nimport exportAuthActionCommand from \"./export-auth-action\";\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 as any);\n\nconst generate = program\n .command(\"generate\")\n .alias(\"g\")\n .description(\"Generate arkos components\")\n .option(\n \"-m, --module <name>\",\n \"Module name (comma-separated for bulk: post,user,auth)\"\n )\n .option(\"--model <name>\", \"Module name (alias for --module)\")\n .option(\"-p, --path <path>\", \"Custom path for the component\")\n .option(\"-o, --overwrite\", \"Overwrites all the content on the existing file\");\n\ngenerate\n .command(\"controller\")\n .alias(\"c\")\n .description(\"Generate a new controller\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.controller({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"service\")\n .alias(\"s\")\n .description(\"Generate a new service\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.service({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"router\")\n .alias(\"r\")\n .description(\"Generate a new router\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.router({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"auth-configs\")\n .alias(\"a\")\n .description(\"Generate auth configuration\")\n .option(\"-a, --advanced\", \"Advanced code structure\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.authConfigs({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"query-options\")\n .alias(\"q\")\n .description(\"Generate prisma query options\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.queryOptions({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"interceptors\")\n .alias(\"i\")\n .description(\"Generate a new interceptors file\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.interceptors({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"hooks\")\n .alias(\"h\")\n .description(\"Generate a new service hooks file\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.hooks({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"create-schema\")\n .alias(\"cs\")\n .description(\"Generate a new zod create schema file for a prisma model\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.createSchema({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"update-schema\")\n .alias(\"us\")\n .description(\"Generate a new zod update schema file for a prisma model\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.updateSchema({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"schema\")\n .alias(\"sc\")\n .description(\"Generate a new zod create schema file for a prisma model\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.baseSchema({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"query-schema\")\n .alias(\"qs\")\n .description(\"Generate a new zod update schema file for a prisma model\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.querySchema({ ...generateOptions, ...options });\n });\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 .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.createDto({ ...generateOptions, ...options });\n });\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 .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.updateDto({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"dto\")\n .alias(\"d\")\n .description(\n \"Generate a new class-validator base dto file for a prisma model\"\n )\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.baseDto({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"query-dto\")\n .alias(\"qd\")\n .description(\n \"Generate a new class-validator base dto file for a prisma model\"\n )\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.queryDto({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"model\")\n .alias(\"m\")\n .description(\"Generate a new prisma model\")\n .option(\"-p, --path <path>\", \"Custom path for prisma model\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.prismaModel({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"policy\")\n .alias(\"p\")\n .description(\"Generate a new policy\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.policy({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"login-schema\")\n .alias(\"ls\")\n .description(\"Generate zod login schema for auth module\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.loginSchema({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"signup-schema\")\n .alias(\"ss\")\n .description(\"Generate zod signup schema for auth module\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.signupSchema({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"update-me-schema\")\n .alias(\"ums\")\n .description(\"Generate zod update-me schema for auth module\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.updateMeSchema({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"update-password-schema\")\n .alias(\"ups\")\n .description(\"Generate zod update-password schema for auth module\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.updatePasswordSchema({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"login-dto\")\n .alias(\"ld\")\n .description(\"Generate class-validator login dto for auth module\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.loginDto({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"signup-dto\")\n .alias(\"sd\")\n .description(\"Generate class-validator signup dto for auth module\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.signupDto({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"update-me-dto\")\n .alias(\"umd\")\n .description(\"Generate class-validator update-me dto for auth module\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.updateMeDto({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"update-password-dto\")\n .alias(\"upd\")\n .description(\"Generate class-validator update-password dto for auth module\")\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.updatePasswordDto({ ...generateOptions, ...options });\n });\n\ngenerate\n .command(\"components\")\n .alias(\"co\")\n .description(\n \"Generate multiple components for one or more modules. Use -m post,user,auth for multiple modules\"\n )\n .option(\"-a, --all\", \"Generate all components\")\n .option(\n \"-n, --names <names>\",\n \"Comma-separated list of components (e.g., s,sc,m or service,schema,model)\"\n )\n .action((options) => {\n const generateOptions = generate.opts();\n generateCommand.multipleComponents({ ...generateOptions, ...options });\n });\n\nprogram\n .command(\"prisma\")\n .command(\"generate\")\n .description(\"Generate your @prisma/client and BaseService class types\")\n .action(prismaGenerateCommand);\n\nprogram\n .command(\"export\")\n .command(\"auth-action\")\n .description(\"Export file with an array containing all auth-actions\")\n .option(\"-o, --overwrite\", \"Overwrites all the changes on the object\")\n .option(\n \"-p, --path <path>\",\n \"Custom path for auth-actions\",\n \"src/modules/auth/utils\"\n )\n .action(exportAuthActionCommand);\n\n// To resolve arkos g r,c,service -m post\ngenerate.on(\"command:*\", ([unknownCmd]) => {\n if (unknownCmd.includes(\",\") && !unknownCmd.includes(\" \")) {\n const generateOptions = generate.opts();\n generateCommand.multipleComponents({\n ...generateOptions,\n names: unknownCmd,\n });\n } else {\n console.error(`Unknown command: ${unknownCmd}`);\n process.exit(1);\n }\n});\n\ngenerate\n .command(\"all\")\n .description(\"Generate all components for a module\")\n .action(() => {\n const opts = generate.opts();\n generateCommand.multipleComponents({ ...opts, all: true });\n });\n\nprogram.parse(process.argv);\n\nexport { program, buildCommand, devCommand, startCommand, generateCommand };\n"]}
|
|
@@ -8,7 +8,7 @@ import sheu from "../sheu.js";
|
|
|
8
8
|
import { getArkosConfig } from "../helpers/arkos-config.helpers.js";
|
|
9
9
|
let child = null;
|
|
10
10
|
let envFiles;
|
|
11
|
-
export
|
|
11
|
+
export function startCommand(options = {}) {
|
|
12
12
|
process.env.NO_CLI = "true";
|
|
13
13
|
if (!process.env.NODE_ENV)
|
|
14
14
|
process.env.NODE_ENV = "production";
|
|
@@ -34,15 +34,13 @@ export async function startCommand(options = {}) {
|
|
|
34
34
|
env?.CLI_HOST ||
|
|
35
35
|
env?.HOST ||
|
|
36
36
|
(env.ARKOS_BUILD !== "true" ? "0.0.0.0" : "127.0.0.1");
|
|
37
|
-
env.__PORT =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
host: env.__HOST,
|
|
45
|
-
});
|
|
37
|
+
env.__PORT = env?.CLI_PORT || env?.PORT || "8000";
|
|
38
|
+
if (options.stamp !== false)
|
|
39
|
+
watermarkStamper.stamp({
|
|
40
|
+
envFiles,
|
|
41
|
+
port: env.__PORT,
|
|
42
|
+
host: env.__HOST,
|
|
43
|
+
});
|
|
46
44
|
child = spawn("node", [entryPoint], {
|
|
47
45
|
stdio: "inherit",
|
|
48
46
|
env,
|
|
@@ -53,8 +51,11 @@ export async function startCommand(options = {}) {
|
|
|
53
51
|
child.kill();
|
|
54
52
|
process.exit(0);
|
|
55
53
|
});
|
|
54
|
+
return child;
|
|
56
55
|
}
|
|
57
56
|
catch (error) {
|
|
57
|
+
if (options.shouldThrow)
|
|
58
|
+
throw error;
|
|
58
59
|
sheu.error("Production server failed to start:");
|
|
59
60
|
console.error(error);
|
|
60
61
|
process.exit(1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../../src/utils/cli/start.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAgB,KAAK,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,gBAAgB,MAAM,2BAA2B,CAAC;AACzD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../../src/utils/cli/start.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAgB,KAAK,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,gBAAgB,MAAM,2BAA2B,CAAC;AACzD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AASjE,IAAI,KAAK,GAAwB,IAAI,CAAC;AACtC,IAAI,QAA8B,CAAC;AAKnC,MAAM,UAAU,YAAY,CAAC,UAAwB,EAAE;IACrD,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;IAE5B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ;QAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;IAC/D,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,MAAM,CAAC;IAEjC,QAAQ,GAAG,wBAAwB,E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E,GAAG,CAAC,MAAM;gBAChB,IAAI,EAAE,GAAG,CAAC,MAAM;aACjB,CAAC,CAAC;QAEL,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,EAAE;YAClC,KAAK,EAAE,SAAS;YAChB,GAAG;YACH,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC;QAEH,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACxB,IAAI,KAAK;gBAAE,KAAK,CAAC,IAAI,EAAE,CAAC;YAExB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,OAAO,CAAC,WAAW;YAAE,MAAM,KAAK,CAAC;QACrC,IAAI,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACjD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAKD,MAAM,UAAU,gCAAgC;IAC7C,KAAsB,EAAE,IAAI,EAAE,EAAE,CAAC;IAClC,KAAK,GAAG,IAAI,CAAC;AACf,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { ChildProcess, spawn } from \"child_process\";\nimport { loadEnvironmentVariables } from \"../dotenv.helpers\";\nimport { fullCleanCwd } from \"../helpers/fs.helpers\";\nimport watermarkStamper from \"./utils/watermark-stamper\";\nimport sheu from \"../sheu\";\nimport { getArkosConfig } from \"../helpers/arkos-config.helpers\";\n\ninterface StartOptions {\n port?: string;\n host?: string;\n stamp?: false;\n shouldThrow?: true;\n}\n\nlet child: ChildProcess | null = null;\nlet envFiles: string[] | undefined;\n\n/**\n * Production start command for the arkos CLI\n */\nexport function startCommand(options: StartOptions = {}) {\n process.env.NO_CLI = \"true\";\n\n if (!process.env.NODE_ENV) process.env.NODE_ENV = \"production\";\n process.env.ARKOS_BUILD = \"true\";\n\n envFiles = loadEnvironmentVariables();\n\n try {\n const { port, host } = options;\n\n const config = getArkosConfig();\n\n const entryPoint = path.join(\n process.cwd(),\n \".build\",\n config.source?.entryPoint!.replace(\".ts\", \".js\")!\n );\n\n if (!fs.existsSync(path.join(entryPoint))) {\n sheu.error(\n `Could not find built application entry point at ${fullCleanCwd(entryPoint).replaceAll(/^\\/+/g, \"\")}`\n );\n process.exit(1);\n }\n\n const env: { [x: string]: string } = {\n NODE_ENV: \"production\",\n ...process.env,\n ...(port && { CLI_PORT: port }),\n ...(host && { CLI_HOST: host }),\n ARKOS_BUILD: \"true\",\n CLI: \"false\",\n };\n\n env.__HOST =\n env?.CLI_HOST ||\n env?.HOST ||\n (env.ARKOS_BUILD !== \"true\" ? \"0.0.0.0\" : \"127.0.0.1\");\n\n env.__PORT = env?.CLI_PORT || env?.PORT || \"8000\";\n\n if (options.stamp !== false)\n watermarkStamper.stamp({\n envFiles,\n port: env.__PORT,\n host: env.__HOST,\n });\n\n child = spawn(\"node\", [entryPoint], {\n stdio: \"inherit\",\n env,\n shell: true,\n });\n\n process.on(\"SIGINT\", () => {\n if (child) child.kill();\n\n process.exit(0);\n });\n\n return child;\n } catch (error) {\n if (options.shouldThrow) throw error;\n sheu.error(\"Production server failed to start:\");\n console.error(error);\n process.exit(1);\n }\n}\n\n/**\n * Help function to help other processes to terminate the production server child process\n */\nexport function killProductionServerChildProcess() {\n (child as ChildProcess)?.kill?.();\n child = null;\n}\n"]}
|
|
@@ -9,7 +9,7 @@ interface AuthAction {
|
|
|
9
9
|
}
|
|
10
10
|
declare class AuthActionService {
|
|
11
11
|
authActions: AuthAction[];
|
|
12
|
-
add(action: string, resource: string, accessControl?: AccessControlConfig):
|
|
12
|
+
add(action: string, resource: string, accessControl?: AccessControlConfig): Required<AuthAction>;
|
|
13
13
|
remove(action: string, resource: string): void;
|
|
14
14
|
getAll(): AuthAction[];
|
|
15
15
|
getOne(action: string, resource: string): AuthAction | undefined;
|
|
@@ -235,4 +235,5 @@ export interface ArkosNextFunction extends NextFunction {
|
|
|
235
235
|
}
|
|
236
236
|
export type ArkosRequestHandler<P extends Record<string, any> = any, ResBody = any, ReqBody = any, ReqQuery extends Record<string, any> = any, Locals extends Record<string, any> = Record<string, any>> = (req: ArkosRequest<P, ResBody, ReqBody, ReqQuery>, res: ArkosResponse<ResBody, Locals>, next: ArkosNextFunction) => void | Promise<void>;
|
|
237
237
|
export type ArkosErrorRequestHandler<P extends Record<string, any> = any, ResBody = any, ReqBody = any, ReqQuery extends Record<string, any> = any, Locals extends Record<string, any> = Record<string, any>> = (err: any, req: ArkosRequest<P, ResBody, ReqBody, ReqQuery>, res: ArkosResponse<ResBody, Locals>, next: ArkosNextFunction) => void | Promise<void>;
|
|
238
|
+
export type ArkosAnyRequestHandler<P extends Record<string, any> = any, ResBody = any, ReqBody = any, ReqQuery extends Record<string, any> = any, Locals extends Record<string, any> = Record<string, any>> = ArkosRequestHandler<P, ResBody, ReqBody, ReqQuery, Locals> | ArkosErrorRequestHandler<P, ResBody, ReqBody, ReqQuery, Locals> | Array<ArkosRequestHandler<P, ResBody, ReqBody, ReqQuery, Locals> | ArkosErrorRequestHandler<P, ResBody, ReqBody, ReqQuery, Locals>>;
|
|
238
239
|
export {};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { IRoute, IRouter, IRouterHandler, IRouterMatcher, Locals } from "express";
|
|
1
|
+
import { Application, IRoute, IRouter, IRouterHandler, IRouterMatcher, Locals } from "express";
|
|
2
2
|
import { z, ZodSchema } from "zod";
|
|
3
3
|
import { Options as RateLimitOptions } from "express-rate-limit";
|
|
4
4
|
import { Options as QueryParserOptions } from "../../../utils/helpers/query-parser.helpers";
|
|
5
5
|
import { DetailedAccessControlRule } from "../../../types/auth";
|
|
6
|
-
import { ArkosErrorRequestHandler, ArkosRequestHandler } from "../../../types";
|
|
6
|
+
import { ArkosAnyRequestHandler, ArkosErrorRequestHandler, ArkosRequestHandler } from "../../../types";
|
|
7
7
|
import compression from "compression";
|
|
8
8
|
import { OpenApiConfig } from "./openapi-config";
|
|
9
9
|
import { UploadConfig } from "./upload-config";
|
|
10
10
|
import { BodyParserConfig } from "./body-parser-config";
|
|
11
11
|
import { ArkosRouterOptions } from "..";
|
|
12
|
+
import { Validator } from "../../../types/validation/validator";
|
|
12
13
|
export type ArkosUseConfig = Pick<ArkosRouteConfig, "authentication" | "rateLimit" | "compression" | "queryParser" | "bodyParser" | "disabled"> & {
|
|
13
14
|
path?: PathParams;
|
|
14
15
|
};
|
|
@@ -24,7 +25,6 @@ export type InternalIArkosRouter = IArkosRouter & {
|
|
|
24
25
|
}>;
|
|
25
26
|
};
|
|
26
27
|
};
|
|
27
|
-
export type ArkosAnyRequestHandler = ArkosRequestHandler | ArkosErrorRequestHandler | Array<ArkosRequestHandler | ArkosErrorRequestHandler>;
|
|
28
28
|
/**
|
|
29
29
|
* Handler function for HTTP methods that accepts route configuration and request handlers.
|
|
30
30
|
*
|
|
@@ -33,14 +33,14 @@ export type ArkosAnyRequestHandler = ArkosRequestHandler | ArkosErrorRequestHand
|
|
|
33
33
|
* @returns {IRouter} The Express router instance.
|
|
34
34
|
*/
|
|
35
35
|
type RouterMethodHandler<T> = IRouterHandler<T> & IRouterMatcher<T> & {
|
|
36
|
-
(config:
|
|
37
|
-
<TQuery extends
|
|
38
|
-
<TQuery extends
|
|
36
|
+
<TQuery extends Validator = any, TBody extends Validator = any, TParams extends Validator = any>(config: ArkosRouteConfig<TQuery, TBody, TParams>, ...handlers: Array<ArkosRequestHandler<InferValidationType<TParams, Record<string, string>>, any, InferValidationType<TBody, any>, InferValidationType<TQuery, qs.ParsedQs>, any> | Array<ArkosRequestHandler<InferValidationType<TParams, Record<string, string>>, any, InferValidationType<TBody, any>, InferValidationType<TQuery, qs.ParsedQs>, any>>>): T;
|
|
37
|
+
<TQuery extends Validator = any, TBody extends Validator = any, TParams extends Validator = any>(config: ArkosRouteConfig<TQuery, TBody, TParams>, ...handlers: Array<ArkosErrorRequestHandler<InferValidationType<TParams, Record<string, string>>, any, InferValidationType<TBody, any>, InferValidationType<TQuery, qs.ParsedQs>, any> | Array<ArkosErrorRequestHandler<InferValidationType<TParams, Record<string, string>>, any, InferValidationType<TBody, any>, InferValidationType<TQuery, qs.ParsedQs>, any>>>): T;
|
|
38
|
+
<TQuery extends Validator = any, TBody extends Validator = any, TParams extends Validator = any>(config: ArkosRouteConfig<TQuery, TBody, TParams>, subApplication: Application): T;
|
|
39
39
|
};
|
|
40
40
|
export type ArkosRouteMethodHandler<T> = {
|
|
41
41
|
(config: ArkosAnyRequestHandler | Omit<ArkosRouteConfig, "path">, ...handlers: Array<ArkosRequestHandler | ArkosErrorRequestHandler | Array<ArkosRequestHandler | ArkosErrorRequestHandler>>): T;
|
|
42
|
-
<TQuery extends
|
|
43
|
-
<TQuery extends
|
|
42
|
+
<TQuery extends Validator = any, TBody extends Validator = any, TParams extends Validator = any>(config: Omit<ArkosRouteConfig<TQuery, TBody, TParams>, "path">, ...handlers: Array<ArkosAnyRequestHandler<InferValidationType<TParams, Record<string, string>>, any, InferValidationType<TBody, any>, InferValidationType<TQuery, qs.ParsedQs>, Locals> | Array<ArkosRequestHandler<InferValidationType<TParams, Record<string, string>>, any, InferValidationType<TBody, any>, InferValidationType<TQuery, qs.ParsedQs>, Locals>>>): T;
|
|
43
|
+
<TQuery extends Validator = any, TBody extends Validator = any, TParams extends Validator = any>(config: Omit<ArkosRouteConfig<TQuery, TBody, TParams>, "path">, ...handlers: Array<ArkosErrorRequestHandler<InferValidationType<TParams, Record<string, string>>, any, InferValidationType<TBody, any>, InferValidationType<TQuery, qs.ParsedQs>, Locals> | Array<ArkosErrorRequestHandler<InferValidationType<TParams, Record<string, string>>, any, InferValidationType<TBody, any>, InferValidationType<TQuery, qs.ParsedQs>, Locals>>>): T;
|
|
44
44
|
};
|
|
45
45
|
/**
|
|
46
46
|
* Handler function for `use` that accepts route configuration and middleware handlers.
|
|
@@ -122,7 +122,7 @@ export interface IArkosRouter extends IRouter {
|
|
|
122
122
|
/**
|
|
123
123
|
* Configuration object for defining routes in Arkos.js.
|
|
124
124
|
*/
|
|
125
|
-
export type ArkosRouteConfig<TQuery extends
|
|
125
|
+
export type ArkosRouteConfig<TQuery extends Validator = any, TBody extends Validator = any, TParams extends Validator = any> = {
|
|
126
126
|
/**
|
|
127
127
|
* Disables the route by not mounting it internally.
|
|
128
128
|
*/
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { ChildProcess } from "child_process";
|
|
1
2
|
interface StartOptions {
|
|
2
3
|
port?: string;
|
|
3
4
|
host?: string;
|
|
5
|
+
stamp?: false;
|
|
6
|
+
shouldThrow?: true;
|
|
4
7
|
}
|
|
5
8
|
/**
|
|
6
9
|
* Production start command for the arkos CLI
|
|
7
10
|
*/
|
|
8
|
-
export declare function startCommand(options?: StartOptions):
|
|
11
|
+
export declare function startCommand(options?: StartOptions): ChildProcess;
|
|
9
12
|
/**
|
|
10
13
|
* Help function to help other processes to terminate the production server child process
|
|
11
14
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkos",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3-beta",
|
|
4
4
|
"description": "The Express & Prisma RESTful Framework",
|
|
5
5
|
"main": "dist/cjs/exports/index.js",
|
|
6
6
|
"module": "dist/esm/exports/index.js",
|
|
@@ -97,7 +97,6 @@
|
|
|
97
97
|
"test": "jest",
|
|
98
98
|
"test:watch": "jest --watch",
|
|
99
99
|
"test:coverage": "jest --coverage",
|
|
100
|
-
"test:ui": "vitest --ui",
|
|
101
100
|
"test:create": "tsx src/scripts/create-test.ts",
|
|
102
101
|
"publish:test": "npm publish --tag test",
|
|
103
102
|
"publish:beta": "npm publish --tag beta",
|
|
@@ -147,7 +146,7 @@
|
|
|
147
146
|
"@types/jsonwebtoken": "9.0.9",
|
|
148
147
|
"@types/multer": "2.0.0",
|
|
149
148
|
"@types/node": "22.13.13",
|
|
150
|
-
"@types/nodemailer": "
|
|
149
|
+
"@types/nodemailer": "8.0.0",
|
|
151
150
|
"@types/pluralize": "0.0.33",
|
|
152
151
|
"@types/swagger-jsdoc": "6.0.4",
|
|
153
152
|
"@typescript-eslint/eslint-plugin": "6.0.0",
|
|
@@ -164,8 +163,7 @@
|
|
|
164
163
|
"ts-prune": "0.10.3",
|
|
165
164
|
"tsx": "4.20.3",
|
|
166
165
|
"type-fest": "4.41.0",
|
|
167
|
-
"typescript": "5.8.2"
|
|
168
|
-
"vitest": "3.2.4"
|
|
166
|
+
"typescript": "5.8.2"
|
|
169
167
|
},
|
|
170
168
|
"dependencies": {
|
|
171
169
|
"chokidar": "4.0.3",
|
|
@@ -190,9 +188,9 @@
|
|
|
190
188
|
"html-to-text": "9.0.5",
|
|
191
189
|
"jsonwebtoken": "9.0.3",
|
|
192
190
|
"mimetype": "0.0.8",
|
|
193
|
-
"multer": "2.0.2",
|
|
194
191
|
"nodemailer": "8.0.7",
|
|
195
192
|
"sharp": "0.34.5",
|
|
193
|
+
"multer": "2.1.1",
|
|
196
194
|
"swagger-jsdoc": "6.2.8",
|
|
197
195
|
"zod": "3.24.2",
|
|
198
196
|
"zod-to-json-schema": "3.24.6"
|