create-arkos 0.0.16 → 0.0.18
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/{create-arkos/src/index.js → index.js} +2 -2
- package/dist/index.js.map +1 -0
- package/dist/utils/helpers/hbs-tester.helpers.js.map +1 -0
- package/dist/utils/helpers/index.js.map +1 -0
- package/dist/{shared/src/utils/helpers/user-agent.helpers.js → utils/helpers/npm.helpers.js} +8 -2
- package/dist/utils/helpers/npm.helpers.js.map +1 -0
- package/dist/utils/helpers/template-processor.js.map +1 -0
- package/dist/utils/project-config-inquirer.js.map +1 -0
- package/dist/utils/template-compiler.js.map +1 -0
- package/package.json +3 -5
- package/dist/create-arkos/src/index.js.map +0 -1
- package/dist/create-arkos/src/utils/helpers/hbs-tester.helpers.js.map +0 -1
- package/dist/create-arkos/src/utils/helpers/index.js.map +0 -1
- package/dist/create-arkos/src/utils/helpers/npm.helpers.js +0 -10
- package/dist/create-arkos/src/utils/helpers/npm.helpers.js.map +0 -1
- package/dist/create-arkos/src/utils/helpers/template-processor.js.map +0 -1
- package/dist/create-arkos/src/utils/project-config-inquirer.js.map +0 -1
- package/dist/create-arkos/src/utils/template-compiler.js.map +0 -1
- package/dist/shared/src/index.js +0 -18
- package/dist/shared/src/index.js.map +0 -1
- package/dist/shared/src/utils/helpers/user-agent.helpers.js.map +0 -1
- /package/dist/{create-arkos/src/utils → utils}/helpers/hbs-tester.helpers.js +0 -0
- /package/dist/{create-arkos/src/utils → utils}/helpers/index.js +0 -0
- /package/dist/{create-arkos/src/utils → utils}/helpers/template-processor.js +0 -0
- /package/dist/{create-arkos/src/utils → utils}/project-config-inquirer.js +0 -0
- /package/dist/{create-arkos/src/utils → utils}/template-compiler.js +0 -0
|
@@ -20,8 +20,8 @@ const child_process_1 = require("child_process");
|
|
|
20
20
|
const project_config_inquirer_1 = __importDefault(require("./utils/project-config-inquirer"));
|
|
21
21
|
const template_compiler_1 = __importDefault(require("./utils/template-compiler"));
|
|
22
22
|
const handlebars_1 = __importDefault(require("handlebars"));
|
|
23
|
-
const shared_1 = require("@arkos/shared");
|
|
24
23
|
const helpers_1 = require("./utils/helpers");
|
|
24
|
+
const npm_helpers_1 = require("./utils/helpers/npm.helpers");
|
|
25
25
|
handlebars_1.default.registerHelper("eq", (a, b) => a === b);
|
|
26
26
|
handlebars_1.default.registerHelper("neq", (a, b) => a !== b);
|
|
27
27
|
function main() {
|
|
@@ -33,7 +33,7 @@ function main() {
|
|
|
33
33
|
const templatesDir = path_1.default.join(__dirname, `../templates/basic`);
|
|
34
34
|
yield template_compiler_1.default.compile(templatesDir, config);
|
|
35
35
|
process.chdir(projectPath);
|
|
36
|
-
const packageManager = (0,
|
|
36
|
+
const packageManager = (0, npm_helpers_1.detectPackageManagerFromUserAgent)();
|
|
37
37
|
const { dependencies, devDependencies } = (0, helpers_1.getProcjetPackageJsonDependecies)(projectPath);
|
|
38
38
|
console.info(chalk_1.default.bold("\ndependencies:"));
|
|
39
39
|
dependencies.forEach((dependency) => console.info(`- ${dependency}`));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,4CAAoB;AACpB,gDAAwB;AACxB,kDAA0B;AAC1B,iDAAyC;AACzC,8FAAoE;AACpE,kFAAyD;AACzD,4DAAoC;AACpC,6CAAmE;AACnE,6DAAgF;AAEhF,oBAAU,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AACnD,oBAAU,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAEpD,SAAe,IAAI;;QACjB,MAAM,MAAM,GAAG,MAAM,iCAAqB,CAAC,GAAG,EAAE,CAAC;QAEjD,MAAM,WAAW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,SAAS,EAAE,CAAC,CAAC;QAE5D,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC3B,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;QACjD,IAAA,wBAAQ,EAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAEtD,OAAO,CAAC,IAAI,CAAC;IACX,eAAK,CAAC,IAAI,CAAC,eAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;;;UAG5B,MAAM,CAAC,WAAW;kBACV,eAAK,CAAC,IAAI,CAAC,cAAc,CAAC;;OAErC,cAAc;KAChB,CAAC,CAAC;IACP,CAAC;CAAA;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport fs from \"fs\";\nimport path from \"path\";\nimport chalk from \"chalk\";\nimport { execSync } from \"child_process\";\nimport projectConfigInquirer from \"./utils/project-config-inquirer\";\nimport templateCompiler from \"./utils/template-compiler\";\nimport Handlebars from \"handlebars\";\nimport { getProcjetPackageJsonDependecies } from \"./utils/helpers\";\nimport { detectPackageManagerFromUserAgent } from \"./utils/helpers/npm.helpers\";\n\nHandlebars.registerHelper(\"eq\", (a, b) => a === b);\nHandlebars.registerHelper(\"neq\", (a, b) => a !== b);\n\nasync function main() {\n const config = await projectConfigInquirer.run();\n\n const projectPath = config.projectPath;\n\n fs.mkdirSync(projectPath, { recursive: true });\n\n console.info(\n `\\nCreating a new ${chalk.bold(chalk.cyan(\"Arkos.js\"))} project under ${chalk.green(`./${config.projectName}`)}`\n );\n\n const templatesDir = path.join(__dirname, `../templates/basic`);\n await templateCompiler.compile(templatesDir, config);\n\n process.chdir(projectPath);\n\n const packageManager = detectPackageManagerFromUserAgent();\n const { dependencies, devDependencies } =\n getProcjetPackageJsonDependecies(projectPath);\n\n console.info(chalk.bold(\"\\ndependencies:\"));\n dependencies.forEach((dependency) => console.info(`- ${dependency}`));\n\n console.info(chalk.bold(\"\\ndevDependencies:\"));\n devDependencies.forEach((devDependency) =>\n console.info(`- ${devDependency}`)\n );\n\n console.info(\"\\nInstalling dependencies...\");\n console.info(`Using ${packageManager}.\\n`);\n\n execSync(`${packageManager} install`, { stdio: \"inherit\" });\n\n process.chdir(projectPath);\n console.info(\"\\nRunning npx prisma generate...\");\n execSync(`npx prisma generate`, { stdio: \"inherit\" });\n\n console.info(`\n ${chalk.bold(chalk.cyan(\"Arkos.js\"))} project created successfully!\n\n Next steps:\n 1. cd ${config.projectName}\n 2. setup your ${chalk.cyan(\"DATABASE_URL\")} under .env\n 3. npx prisma db push\n 4. ${packageManager} run dev\n `);\n}\n\nmain().catch(console.error);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hbs-tester.helpers.js","sourceRoot":"","sources":["../../../src/utils/helpers/hbs-tester.helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,4DAAoC;AAEpC,oBAAU,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AACnD,oBAAU,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAEpD,CAAC,GAAG,EAAE;IACJ,MAAM,YAAY,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,6BAA6B,CAAC;IACnE,MAAM,SAAS,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,0BAA0B,CAAC;IAC7D,MAAM,MAAM,GAAkB;QAC5B,WAAW,EAAE,eAAe;QAC5B,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE;YACV,IAAI,EAAE,KAAK;SACZ;QACD,cAAc,EAAE;YACd,IAAI,EAAE,SAAS;YACf,aAAa,EAAE,OAAO;YACtB,aAAa,EAA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CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CACrC,CAAC;gBAEJ,YAAE,CAAC,SAAS,CAAC,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC5D,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;aACvC;QACH,CAAC,CAAA,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACjC,CAAC,CAAC,EAAE,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport handlebars from \"handlebars\";\nimport { ProjectConfig } from \"../project-config-inquirer\";\nhandlebars.registerHelper(\"eq\", (a, b) => a === b);\nhandlebars.registerHelper(\"neq\", (a, b) => a !== b);\n\n(() => {\n const templatesDir = `${process.cwd()}/cache/handlebars/templates`;\n const outputDir = `${process.cwd()}/cache/handlebars/output`;\n const config: ProjectConfig = {\n projectName: \"arkos-project\",\n typescript: true,\n validation: {\n type: \"zod\",\n },\n authentication: {\n type: \"dynamic\",\n usernameField: \"email\",\n multipleRoles: true,\n },\n prisma: {\n provider: \"mongodb\",\n idDatabaseType: \"@db @default(uuid())\",\n defaultDBurl: \"@db @default(uuid())\",\n },\n projectPath: outputDir,\n };\n\n function processTemplates(dir: string, relativeDir = \"\") {\n fs.readdirSync(dir, { withFileTypes: true }).forEach(async (dirent) => {\n const fullPath = path.join(dir, dirent.name);\n const relativePath = path.join(relativeDir, dirent.name);\n\n if (dirent.isDirectory()) {\n processTemplates(fullPath, relativePath);\n } else if (dirent.name.endsWith(\".hbs\")) {\n const templatePath = fullPath;\n const template = handlebars.compile(\n fs.readFileSync(templatePath, \"utf8\")\n );\n\n const content = template(config);\n const ext = config.typescript ? \".ts\" : \".js\";\n\n let outputPath = path.join(outputDir, relativePath.replace(\".hbs\", \"\"));\n if (dirent.name.endsWith(\".ts.hbs\"))\n outputPath = path.join(\n outputDir,\n relativePath.replace(\".ts.hbs\", ext)\n );\n\n fs.mkdirSync(path.dirname(outputPath), { recursive: true });\n fs.writeFileSync(outputPath, content);\n }\n });\n }\n\n processTemplates(templatesDir);\n})();\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAoB;AAEpB,SAAsB,gBAAgB,CAAC,WAAmB;;QACxD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,8BAA8B,WAAW,EAAE,CAAC,CAAC;QACrE,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QAE/D,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;IAClC,CAAC;CAAA;AAND,4CAMC;AAED,SAAgB,gCAAgC,CAAC,WAAmB;IAIlE,MAAM,OAAO,GAAG,YAAE,CAAC,YAAY,CAAC,GAAG,WAAW,eAAe,EAAE;QAC7D,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,MAAM,WAAW,GAGb,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACxB,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAC3D,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAEjE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC;AAC3C,CAAC;AAhBD,4EAgBC","sourcesContent":["import fs from \"fs\";\n\nexport async function getLatestVersion(packageName: string) {\n const res = await fetch(`https://registry.npmjs.org/${packageName}`);\n if (!res.ok) throw new Error(`Failed to fetch: ${res.status}`);\n\n const data = await res.json();\n return data[\"dist-tags\"].latest;\n}\n\nexport function getProcjetPackageJsonDependecies(projectPath: string): {\n dependencies: string[];\n devDependencies: string[];\n} {\n const content = fs.readFileSync(`${projectPath}/package.json`, {\n encoding: \"utf8\",\n });\n\n const packageJson: {\n dependencies: Record<string, string>;\n devDependencies: Record<string, string>;\n } = JSON.parse(content);\n const dependencies = Object.keys(packageJson.dependencies);\n const devDependencies = Object.keys(packageJson.devDependencies);\n\n return { dependencies, devDependencies };\n}\n"]}
|
package/dist/{shared/src/utils/helpers/user-agent.helpers.js → utils/helpers/npm.helpers.js}
RENAMED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.detectPackageManagerFromUserAgent = void 0;
|
|
3
|
+
exports.detectPackageManagerFromUserAgent = exports.getNpmPackageVersion = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
function getNpmPackageVersion(name = "arkos") {
|
|
6
|
+
const version = (0, child_process_1.execSync)(`npm view ${name} version`).toString().trim();
|
|
7
|
+
return version;
|
|
8
|
+
}
|
|
9
|
+
exports.getNpmPackageVersion = getNpmPackageVersion;
|
|
4
10
|
function detectPackageManagerFromUserAgent() {
|
|
5
11
|
const userAgent = process.env.npm_config_user_agent || "";
|
|
6
12
|
if (!userAgent)
|
|
@@ -22,4 +28,4 @@ function detectPackageManagerFromUserAgent() {
|
|
|
22
28
|
return "npm";
|
|
23
29
|
}
|
|
24
30
|
exports.detectPackageManagerFromUserAgent = detectPackageManagerFromUserAgent;
|
|
25
|
-
//# sourceMappingURL=
|
|
31
|
+
//# sourceMappingURL=npm.helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm.helpers.js","sourceRoot":"","sources":["../../../src/utils/helpers/npm.helpers.ts"],"names":[],"mappings":";;;AAAA,iDAAyC;AAQzC,SAAgB,oBAAoB,CAAC,OAAe,OAAO;IACzD,MAAM,OAAO,GAAG,IAAA,wBAAQ,EAAC,YAAY,IAAI,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;IACvE,OAAO,OAAO,CAAC;AACjB,CAAC;AAHD,oDAGC;AAQD,SAAgB,iCAAiC;IAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC;IAE1D,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7B,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IACtD,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAE9C,OAAO,KAAK,CAAC;AACf,CAAC;AAbD,8EAaC","sourcesContent":["import { execSync } from \"child_process\";\n\n/**\n * Helps getting npm packages latest version\n *\n * @param {striong} name - name of the npm package (defaults: arkos)\n * @returns {string} version - the package latest version\n * */\nexport function getNpmPackageVersion(name: string = \"arkos\"): string {\n const version = execSync(`npm view ${name} version`).toString().trim();\n return version;\n}\n\n/**\n * Helps getting the current package manager from user agent\n *\n * @returns {string} the package manager\n * @default \"npm\"\n */\nexport function detectPackageManagerFromUserAgent(): string {\n const userAgent = process.env.npm_config_user_agent || \"\";\n\n if (!userAgent) return \"npm\";\n if (userAgent.includes(\"pnpm\")) return \"pnpm\";\n if (userAgent.includes(\"yarn\")) return \"yarn\";\n if (userAgent.includes(\"npm\")) return \"npm\";\n if (userAgent.includes(\"bun\")) return \"bun\";\n if (userAgent.includes(\"cnpm\")) return \"cnpm\";\n if (userAgent.includes(\"corepack\")) return \"corepack\";\n if (userAgent.includes(\"deno\")) return \"deno\";\n\n return \"npm\";\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-processor.js","sourceRoot":"","sources":["../../../src/utils/helpers/template-processor.ts"],"names":[],"mappings":"","sourcesContent":["// import Handlebars from \"handlebars\";\n// import fs from \"fs\";\n// import { ProjectConfig } from \"../project-config-inquirer\";\n\n// async function processTemplate(templatePath: string, config: ProjectConfig) {\n// const files = await this.getAllFiles(templatePath);\n\n// for (const file of files) {\n// const content = fs.readFileSync(file, \"utf-8\");\n\n// // Compile template\n// const template = Handlebars.compile(content);\n\n// // Replace with config values\n// const processed = template({\n// PROJECT_NAME: config.projectName,\n// AUTH_ENABLED: config.authentication.enabled,\n// AUTH_TYPE: config.authentication.type,\n// VALIDATION_ENABLED: config.validation.enabled,\n// VALIDATION_TYPE: config.validation.type,\n// PRISMA_DATABASE_PROVIDER: config.prismaProvideer,\n// });\n\n// fs.writeFileSync(file, processed);\n// }\n// }\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-config-inquirer.js","sourceRoot":"","sources":["../../src/utils/project-config-inquirer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,wDAAgC;AAChC,kDAA0B;AA2B1B,MAAM,qBAAqB;IAGzB;QACE,IAAI,CAAC,MAAM,GAAG,EAAmB,CAAC;IACpC,CAAC;IAEK,GAAG;;YACP,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC/B,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC9B,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAClC,MAAM,IAAI,CAAC,gBAAgB,EA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,CAAC,MAAM,CAAC;wBAC9C;4BACE,IAAI,EAAE,SAAS;4BACf,IAAI,EAAE,eAAe;4BACrB,OAAO,EAAE,IAAI;4BACb,OAAO,EAAE,6CAA6C,eAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG;yBACtF;qBACF,CAAC,CAAC;oBAEH,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,kBAAQ,CAAC,MAAM,CAAC;wBAC9C;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,eAAe;4BACrB,OAAO,EAAE,0CAA0C;4BACnD,OAAO,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,cAAc,CAAC;yBAC/C;qBACF,CAAC,CAAC;oBAEH,IAAI,CAAC,MAAM,CAAC,cAAc,GAAG;wBAC3B,IAAI,EAAE,kBAAkB;wBACxB,aAAa,EACX,aAAa,KAAK,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa;wBAC7D,aAAa;qBACd,CAAC;iBACH;qBAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE;oBACnD,OAAO,CAAC,IAAI,CACV,+DAA+D,CAChE,CAAC;iBACH;aACF;QACH,CAAC;KAAA;CACF;AAED,MAAM,qBAAqB,GAAG,IAAI,qBAAqB,EAAE,CAAC;AAE1D,kBAAe,qBAAqB,CAAC","sourcesContent":["import path from \"path\";\nimport inquirer from \"inquirer\";\nimport chalk from \"chalk\";\n\nexport interface ProjectConfig {\n projectName: string;\n typescript: boolean;\n validation: {\n type?: \"zod\" | \"class-validator\";\n };\n authentication: {\n type?: \"static\" | \"dynamic\" | \"define later\";\n usernameField?: \"username\" | \"email\" | \"custom\";\n multipleRoles: boolean;\n };\n prisma: {\n provider:\n | \"postgresql\"\n | \"mysql\"\n | \"sqlite\"\n | \"sqlserver\"\n | \"cockroachdb\"\n | \"mongodb\";\n idDatabaseType: string;\n defaultDBurl: string;\n };\n projectPath: string;\n}\n\nclass ProjectConfigInquirer {\n private config: ProjectConfig;\n\n constructor() {\n this.config = {} as ProjectConfig;\n }\n\n async run() {\n await this.promptProjectName();\n await this.promptTypescript();\n await this.promptPrismaProvider();\n await this.promptValidation();\n await this.promptAuthentication();\n\n const projectPath = path.resolve(process.cwd(), this.config.projectName);\n this.config.projectPath = projectPath;\n\n return this.config;\n }\n\n private async promptProjectName() {\n let projectName = process.argv[2];\n\n // If user passed \".\", use current directory name\n if (projectName === \".\") {\n projectName = path.basename(process.cwd());\n }\n\n if (!projectName) {\n const result = await inquirer.prompt([\n {\n type: \"input\",\n name: \"projectName\",\n message: \"What is the name of your project?\",\n default: \"my-arkos-project\",\n validate: this.validateProjectName,\n },\n ]);\n projectName = result.projectName;\n } else {\n // Validate the project name from command line args\n const validation = this.validateProjectName(projectName);\n if (validation !== true) {\n console.error(chalk.red(`Error: ${validation}`));\n process.exit(1);\n }\n }\n\n this.config.projectName = projectName;\n }\n\n private validateProjectName(input: string): boolean | string {\n if (!input || input.length === 0) {\n return \"Project name cannot be empty\";\n }\n\n // Check for valid characters (letters, numbers, hyphens, underscores)\n if (!/^[a-zA-Z0-9_-]+$/.test(input)) {\n return \"Project name can only contain letters, numbers, hyphens, and underscores\";\n }\n\n // Check if it starts with a letter or number (not hyphen or underscore)\n if (!/^[a-zA-Z0-9]/.test(input)) {\n return \"Project name must start with a letter or number\";\n }\n\n // Check if it ends with a letter or number (not hyphen or underscore)\n if (!/[a-zA-Z0-9]$/.test(input)) {\n return \"Project name must end with a letter or number\";\n }\n\n // Check length (reasonable limits)\n if (input.length > 50) {\n return \"Project name must be 50 characters or less\";\n }\n\n // Check for reserved names\n const reservedNames = [\"node_modules\"];\n if (reservedNames.includes(input.toLowerCase())) {\n return \"Project name cannot be a reserved name\";\n }\n\n return true;\n }\n\n private async promptTypescript() {\n const { typescript } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"typescript\",\n message: `Would you like to use ${chalk.cyan(\"TypeScript\")}?`,\n default: false,\n },\n ]);\n this.config.typescript = typescript;\n }\n\n private async promptPrismaProvider() {\n const { prismaProvider } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"prismaProvider\",\n message: `What db provider will be used for ${chalk.cyan(\"Prisma\")}?`,\n choices: [\n \"postgresql\",\n \"mongodb\",\n \"mysql\",\n \"sqlite\",\n \"sqlserver\",\n \"cockroachdb\",\n ],\n },\n ]);\n\n // Set the correct idDatabaseType based on provider\n let idDatabaseType: string;\n let defaultDBurl: string;\n\n switch (prismaProvider) {\n case \"mongodb\":\n idDatabaseType = '@id @default(auto()) @map(\"_id\") @db.ObjectId';\n defaultDBurl = `mongodb://localhost:27017/${this.config.projectName}`;\n break;\n case \"sqlite\":\n idDatabaseType = \"@id @default(cuid())\";\n defaultDBurl = \"file:../file.db\";\n break;\n case \"mysql\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `mysql://username:password@localhost:3306/${this.config.projectName}`;\n break;\n case \"postgresql\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `postgresql://username:password@localhost:5432/${this.config.projectName}`;\n break;\n case \"sqlserver\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `sqlserver://localhost:1433;database=${this.config.projectName};username=sa;password=password;encrypt=DANGER_PLAINTEXT`;\n break;\n case \"cockroachdb\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `postgresql://username:password@localhost:26257/${this.config.projectName}?sslmode=require`;\n break;\n default:\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `postgresql://username:password@localhost:5432/${this.config.projectName}`;\n }\n\n this.config.prisma = {\n provider: prismaProvider,\n idDatabaseType: idDatabaseType,\n defaultDBurl: defaultDBurl,\n };\n }\n\n private async promptValidation() {\n const { useValidation } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"useValidation\",\n message: `Would you like to set up ${chalk.cyan(\"Validation\")}?`,\n default: true,\n },\n ]);\n\n if (useValidation) {\n const { validationType } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"validationType\",\n message: \"Choose validation library:\",\n choices: [\"zod\", \"class-validator\"],\n },\n ]);\n this.config.validation = {\n type: validationType,\n };\n }\n }\n\n private async promptAuthentication() {\n const { useAuthentication } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"useAuthentication\",\n message: `Would you like to set up ${chalk.cyan(\"Authentication\")}?`,\n default: true,\n },\n ]);\n\n if (useAuthentication) {\n const { authenticationType } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"authenticationType\",\n message: \"Choose authentication type:\",\n choices: [\"static\", \"dynamic\", \"define later\"],\n },\n ]);\n\n if (\n authenticationType !== \"define later\" &&\n this.config.prisma.provider !== \"sqlite\"\n ) {\n const { multipleRoles } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"multipleRoles\",\n default: true,\n message: `Would you like to use authentication with ${chalk.cyan(\"Multiple Roles\")}?`,\n },\n ]);\n\n const { usernameField } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"usernameField\",\n message: \"Choose default username field for login:\",\n choices: [\"email\", \"username\", \"define later\"],\n },\n ]);\n\n this.config.authentication = {\n type: authenticationType,\n usernameField:\n usernameField === \"define later\" ? \"custom\" : usernameField,\n multipleRoles,\n };\n } else if (this.config.prisma.provider === \"sqlite\") {\n console.info(\n `Skipping multiple roles options because provider is sqlite...`\n );\n }\n }\n }\n}\n\nconst projectConfigInquirer = new ProjectConfigInquirer();\n\nexport default projectConfigInquirer;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-compiler.js","sourceRoot":"","sources":["../../src/utils/template-compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,gDAAwB;AACxB,4CAAoB;AACpB,4DAAoC;AACpC,uDAA6D;AAE7D,MAAM,gBAAgB;IACd,iCAAiC,CAAC,MAAqB;;YAC3D,OAAO,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;QACjC,CAAC;KAAA;IAED,gBAAgB,CAAC,MAA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e,gBAAgB,CAAC","sourcesContent":["import { ProjectConfig } from \"./project-config-inquirer\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport handlebars from \"handlebars\";\nimport { getNpmPackageVersion } from \"./helpers/npm.helpers\";\n\nclass TemplateCompiler {\n async canCompileAuthenticationTemplates(config: ProjectConfig) {\n return !!config.authentication;\n }\n\n filesToBeSkipped(config: ProjectConfig) {\n const files: string[] = [];\n\n if (config.authentication?.type === \"define later\")\n files.push(...[\"user.prisma.hbs\"]);\n\n if (config.authentication?.type === \"static\")\n files.push(\n ...[\n \"auth-role.prisma.hbs\",\n \"auth-permission.prisma.hbs\",\n \"user-role.prisma.hbs\",\n ]\n );\n\n if (!config.typescript) files.push(...[\"tsconfig.json.hbs\"]);\n\n if (config?.typescript) files.push(...[\"jsconfig.json.hbs\"]);\n\n return files;\n }\n /**\n * Compiles the Arkos.js project with handlebars templates\n *\n * @param templatesDir {string} templates location\n * @param config {ProjectConfig} the project configuration\n * @returns void\n * */\n async compile(templatesDir: string, config: ProjectConfig) {\n const outputDir = config.projectPath;\n const isTypescript = config.typescript;\n const filesToBeSkipped = this.filesToBeSkipped(config);\n\n function processTemplates(dir: string, relativeDir = \"\") {\n fs.readdirSync(dir, { withFileTypes: true }).forEach(async (dirent) => {\n if (filesToBeSkipped.includes(dirent.name)) return;\n\n const fullPath = path.join(dir, dirent.name);\n const relativePath = path.join(relativeDir, dirent.name);\n\n if (dirent.isDirectory()) {\n processTemplates(fullPath, relativePath);\n } else if (dirent.name.endsWith(\".hbs\")) {\n const templatePath = fullPath;\n const template = handlebars.compile(\n fs.readFileSync(templatePath, \"utf8\")\n );\n\n let arkosCurrentVersion = getNpmPackageVersion(\"arkos\");\n\n const content = template({ ...config, arkosCurrentVersion });\n const ext = isTypescript ? \".ts\" : \".js\";\n\n let outputPath = path.join(\n outputDir,\n relativePath.replace(\".hbs\", \"\")\n );\n if (dirent.name.endsWith(\".ts.hbs\"))\n outputPath = path.join(\n outputDir,\n relativePath.replace(\".ts.hbs\", ext)\n );\n\n fs.mkdirSync(path.dirname(outputPath), { recursive: true });\n fs.writeFileSync(outputPath, content);\n }\n });\n }\n\n processTemplates(templatesDir);\n }\n}\n\nconst templateCompiler = new TemplateCompiler();\n\nexport default templateCompiler;\n"]}
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-arkos",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "CLI for creating Arkos.js projects, see docs at www.arkosjs.com",
|
|
5
5
|
"bin": {
|
|
6
|
-
"create-arkos": "./dist/index.js"
|
|
6
|
+
"create-arkos": "./dist/create-arkos/src/index.js"
|
|
7
7
|
},
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "rimraf dist && tsc",
|
|
10
10
|
"dev": "ts-node src/index.ts",
|
|
11
11
|
"test:hbs": "ts-node src/utils/helpers/hbs-tester.helpers.ts",
|
|
12
|
-
"prebuild": "pnpm --filter @arkos/shared build",
|
|
13
12
|
"prepublishOnly": "pnpm build"
|
|
14
13
|
},
|
|
15
14
|
"author": "Uanela Como",
|
|
@@ -28,8 +27,7 @@
|
|
|
28
27
|
"@types/node": "^16.18.126",
|
|
29
28
|
"ts-node": "^10.9.2",
|
|
30
29
|
"tsup": "^8.5.0",
|
|
31
|
-
"typescript": "^4.9.5"
|
|
32
|
-
"@arkos/shared": "workspace:*"
|
|
30
|
+
"typescript": "^4.9.5"
|
|
33
31
|
},
|
|
34
32
|
"dependencies": {
|
|
35
33
|
"@clack/prompts": "^0.11.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,4CAAoB;AACpB,gDAAwB;AACxB,kDAA0B;AAC1B,iDAAyC;AACzC,8FAAoE;AACpE,kFAAyD;AACzD,4DAAoC;AACpC,0CAAkE;AAClE,6CAAmE;AA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C,oBAAoB,CAAC,CAAC,CAAC;QAC/C,eAAe,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE,CACxC,OAAO,CAAC,IAAI,CAAC,KAAK,aAAa,EAAE,CAAC,CACnC,CAAC;QAEF,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QAC7C,OAAO,CAAC,IAAI,CAAC,SAAS,cAAc,KAAK,CAAC,CAAC;QAE3C,IAAA,wBAAQ,EAAC,GAAG,cAAc,UAAU,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAE5D,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC3B,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;QACjD,IAAA,wBAAQ,EAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAEtD,OAAO,CAAC,IAAI,CAAC;IACX,eAAK,CAAC,IAAI,CAAC,eAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;;;UAG5B,MAAM,CAAC,WAAW;kBACV,eAAK,CAAC,IAAI,CAAC,cAAc,CAAC;;OAErC,cAAc;KAChB,CAAC,CAAC;IACP,CAAC;CAAA;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport fs from \"fs\";\nimport path from \"path\";\nimport chalk from \"chalk\";\nimport { execSync } from \"child_process\";\nimport projectConfigInquirer from \"./utils/project-config-inquirer\";\nimport templateCompiler from \"./utils/template-compiler\";\nimport Handlebars from \"handlebars\";\nimport { detectPackageManagerFromUserAgent } from \"@arkos/shared\";\nimport { getProcjetPackageJsonDependecies } from \"./utils/helpers\";\n\nHandlebars.registerHelper(\"eq\", (a, b) => a === b);\nHandlebars.registerHelper(\"neq\", (a, b) => a !== b);\n\nasync function main() {\n const config = await projectConfigInquirer.run();\n\n const projectPath = config.projectPath;\n\n fs.mkdirSync(projectPath, { recursive: true });\n\n console.info(\n `\\nCreating a new ${chalk.bold(chalk.cyan(\"Arkos.js\"))} project under ${chalk.green(`./${config.projectName}`)}`\n );\n\n const templatesDir = path.join(__dirname, `../templates/basic`);\n await templateCompiler.compile(templatesDir, config);\n\n process.chdir(projectPath);\n\n const packageManager = detectPackageManagerFromUserAgent();\n const { dependencies, devDependencies } =\n getProcjetPackageJsonDependecies(projectPath);\n\n console.info(chalk.bold(\"\\ndependencies:\"));\n dependencies.forEach((dependency) => console.info(`- ${dependency}`));\n\n console.info(chalk.bold(\"\\ndevDependencies:\"));\n devDependencies.forEach((devDependency) =>\n console.info(`- ${devDependency}`)\n );\n\n console.info(\"\\nInstalling dependencies...\");\n console.info(`Using ${packageManager}.\\n`);\n\n execSync(`${packageManager} install`, { stdio: \"inherit\" });\n\n process.chdir(projectPath);\n console.info(\"\\nRunning npx prisma generate...\");\n execSync(`npx prisma generate`, { stdio: \"inherit\" });\n\n console.info(`\n ${chalk.bold(chalk.cyan(\"Arkos.js\"))} project created successfully!\n\n Next steps:\n 1. cd ${config.projectName}\n 2. setup your ${chalk.cyan(\"DATABASE_URL\")} under .env\n 3. npx prisma db push\n 4. ${packageManager} run dev\n `);\n}\n\nmain().catch(console.error);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hbs-tester.helpers.js","sourceRoot":"","sources":["../../../../../src/utils/helpers/hbs-tester.helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,4DAAoC;AAEpC,oBAAU,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AACnD,oBAAU,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAEpD,CAAC,GAAG,EAAE;IACJ,MAAM,YA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,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;gBAE9C,IAAI,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;gBACxE,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;oBACjC,UAAU,GAAG,cAAI,CAAC,IAAI,CACpB,SAAS,EACT,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CACrC,CAAC;gBAEJ,YAAE,CAAC,SAAS,CAAC,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC5D,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;aACvC;QACH,CAAC,CAAA,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACjC,CAAC,CAAC,EAAE,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport handlebars from \"handlebars\";\nimport { ProjectConfig } from \"../project-config-inquirer\";\nhandlebars.registerHelper(\"eq\", (a, b) => a === b);\nhandlebars.registerHelper(\"neq\", (a, b) => a !== b);\n\n(() => {\n const templatesDir = `${process.cwd()}/cache/handlebars/templates`;\n const outputDir = `${process.cwd()}/cache/handlebars/output`;\n const config: ProjectConfig = {\n projectName: \"arkos-project\",\n typescript: true,\n validation: {\n type: \"zod\",\n },\n authentication: {\n type: \"dynamic\",\n usernameField: \"email\",\n multipleRoles: true,\n },\n prisma: {\n provider: \"mongodb\",\n idDatabaseType: \"@db @default(uuid())\",\n defaultDBurl: \"@db @default(uuid())\",\n },\n projectPath: outputDir,\n };\n\n function processTemplates(dir: string, relativeDir = \"\") {\n fs.readdirSync(dir, { withFileTypes: true }).forEach(async (dirent) => {\n const fullPath = path.join(dir, dirent.name);\n const relativePath = path.join(relativeDir, dirent.name);\n\n if (dirent.isDirectory()) {\n processTemplates(fullPath, relativePath);\n } else if (dirent.name.endsWith(\".hbs\")) {\n const templatePath = fullPath;\n const template = handlebars.compile(\n fs.readFileSync(templatePath, \"utf8\")\n );\n\n const content = template(config);\n const ext = config.typescript ? \".ts\" : \".js\";\n\n let outputPath = path.join(outputDir, relativePath.replace(\".hbs\", \"\"));\n if (dirent.name.endsWith(\".ts.hbs\"))\n outputPath = path.join(\n outputDir,\n relativePath.replace(\".ts.hbs\", ext)\n );\n\n fs.mkdirSync(path.dirname(outputPath), { recursive: true });\n fs.writeFileSync(outputPath, content);\n }\n });\n }\n\n processTemplates(templatesDir);\n})();\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/utils/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAoB;AAEpB,SAAsB,gBAAgB,CAAC,WAAmB;;QACxD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,8BAA8B,WAAW,EAAE,CAAC,CAAC;QACrE,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QAE/D,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;IAClC,CAAC;CAAA;AAND,4CAMC;AAED,SAAgB,gCAAgC,CAAC,WAAmB;IAIlE,MAAM,OAAO,GAAG,YAAE,CAAC,YAAY,CAAC,GAAG,WAAW,eAAe,EAAE;QAC7D,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,MAAM,WAAW,GAGb,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACxB,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAC3D,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAEjE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC;AAC3C,CAAC;AAhBD,4EAgBC","sourcesContent":["import fs from \"fs\";\n\nexport async function getLatestVersion(packageName: string) {\n const res = await fetch(`https://registry.npmjs.org/${packageName}`);\n if (!res.ok) throw new Error(`Failed to fetch: ${res.status}`);\n\n const data = await res.json();\n return data[\"dist-tags\"].latest;\n}\n\nexport function getProcjetPackageJsonDependecies(projectPath: string): {\n dependencies: string[];\n devDependencies: string[];\n} {\n const content = fs.readFileSync(`${projectPath}/package.json`, {\n encoding: \"utf8\",\n });\n\n const packageJson: {\n dependencies: Record<string, string>;\n devDependencies: Record<string, string>;\n } = JSON.parse(content);\n const dependencies = Object.keys(packageJson.dependencies);\n const devDependencies = Object.keys(packageJson.devDependencies);\n\n return { dependencies, devDependencies };\n}\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNpmPackageVersion = void 0;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
function getNpmPackageVersion(name = "arkos") {
|
|
6
|
-
const version = (0, child_process_1.execSync)(`npm view ${name} version`).toString().trim();
|
|
7
|
-
return version;
|
|
8
|
-
}
|
|
9
|
-
exports.getNpmPackageVersion = getNpmPackageVersion;
|
|
10
|
-
//# sourceMappingURL=npm.helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"npm.helpers.js","sourceRoot":"","sources":["../../../../../src/utils/helpers/npm.helpers.ts"],"names":[],"mappings":";;;AAAA,iDAAyC;AAQzC,SAAgB,oBAAoB,CAAC,OAAe,OAAO;IACzD,MAAM,OAAO,GAAG,IAAA,wBAAQ,EAAC,YAAY,IAAI,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;IACvE,OAAO,OAAO,CAAC;AACjB,CAAC;AAHD,oDAGC","sourcesContent":["import { execSync } from \"child_process\";\n\n/**\n * Helps getting npm packages latest version\n *\n * @param {striong} name - name of the npm package (defaults: arkos)\n * @returns {string} version - the package latest version\n * */\nexport function getNpmPackageVersion(name: string = \"arkos\"): string {\n const version = execSync(`npm view ${name} version`).toString().trim();\n return version;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template-processor.js","sourceRoot":"","sources":["../../../../../src/utils/helpers/template-processor.ts"],"names":[],"mappings":"","sourcesContent":["// import Handlebars from \"handlebars\";\n// import fs from \"fs\";\n// import { ProjectConfig } from \"../project-config-inquirer\";\n\n// async function processTemplate(templatePath: string, config: ProjectConfig) {\n// const files = await this.getAllFiles(templatePath);\n\n// for (const file of files) {\n// const content = fs.readFileSync(file, \"utf-8\");\n\n// // Compile template\n// const template = Handlebars.compile(content);\n\n// // Replace with config values\n// const processed = template({\n// PROJECT_NAME: config.projectName,\n// AUTH_ENABLED: config.authentication.enabled,\n// AUTH_TYPE: config.authentication.type,\n// VALIDATION_ENABLED: config.validation.enabled,\n// VALIDATION_TYPE: config.validation.type,\n// PRISMA_DATABASE_PROVIDER: config.prismaProvideer,\n// });\n\n// fs.writeFileSync(file, processed);\n// }\n// }\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-config-inquirer.js","sourceRoot":"","sources":["../../../../src/utils/project-config-inquirer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,wDAAgC;AAChC,kDAA0B;AA2B1B,MAAM,qBAAqB;IAGzB;QACE,IAAI,CAAC,MAAM,GAAG,EAAmB,CAAC;IACpC,CAAC;IAEK,GAAG;;YACP,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC/B,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC9B,MAAM,IAA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,QAAQ,EACxC;oBACA,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,kBAAQ,CAAC,MAAM,CAAC;wBAC9C;4BACE,IAAI,EAAE,SAAS;4BACf,IAAI,EAAE,eAAe;4BACrB,OAAO,EAAE,IAAI;4BACb,OAAO,EAAE,6CAA6C,eAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG;yBACtF;qBACF,CAAC,CAAC;oBAEH,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,kBAAQ,CAAC,MAAM,CAAC;wBAC9C;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,eAAe;4BACrB,OAAO,EAAE,0CAA0C;4BACnD,OAAO,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,cAAc,CAAC;yBAC/C;qBACF,CAAC,CAAC;oBAEH,IAAI,CAAC,MAAM,CAAC,cAAc,GAAG;wBAC3B,IAAI,EAAE,kBAAkB;wBACxB,aAAa,EACX,aAAa,KAAK,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa;wBAC7D,aAAa;qBACd,CAAC;iBACH;qBAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE;oBACnD,OAAO,CAAC,IAAI,CACV,+DAA+D,CAChE,CAAC;iBACH;aACF;QACH,CAAC;KAAA;CACF;AAED,MAAM,qBAAqB,GAAG,IAAI,qBAAqB,EAAE,CAAC;AAE1D,kBAAe,qBAAqB,CAAC","sourcesContent":["import path from \"path\";\nimport inquirer from \"inquirer\";\nimport chalk from \"chalk\";\n\nexport interface ProjectConfig {\n projectName: string;\n typescript: boolean;\n validation: {\n type?: \"zod\" | \"class-validator\";\n };\n authentication: {\n type?: \"static\" | \"dynamic\" | \"define later\";\n usernameField?: \"username\" | \"email\" | \"custom\";\n multipleRoles: boolean;\n };\n prisma: {\n provider:\n | \"postgresql\"\n | \"mysql\"\n | \"sqlite\"\n | \"sqlserver\"\n | \"cockroachdb\"\n | \"mongodb\";\n idDatabaseType: string;\n defaultDBurl: string;\n };\n projectPath: string;\n}\n\nclass ProjectConfigInquirer {\n private config: ProjectConfig;\n\n constructor() {\n this.config = {} as ProjectConfig;\n }\n\n async run() {\n await this.promptProjectName();\n await this.promptTypescript();\n await this.promptPrismaProvider();\n await this.promptValidation();\n await this.promptAuthentication();\n\n const projectPath = path.resolve(process.cwd(), this.config.projectName);\n this.config.projectPath = projectPath;\n\n return this.config;\n }\n\n private async promptProjectName() {\n let projectName = process.argv[2];\n\n // If user passed \".\", use current directory name\n if (projectName === \".\") {\n projectName = path.basename(process.cwd());\n }\n\n if (!projectName) {\n const result = await inquirer.prompt([\n {\n type: \"input\",\n name: \"projectName\",\n message: \"What is the name of your project?\",\n default: \"my-arkos-project\",\n validate: this.validateProjectName,\n },\n ]);\n projectName = result.projectName;\n } else {\n // Validate the project name from command line args\n const validation = this.validateProjectName(projectName);\n if (validation !== true) {\n console.error(chalk.red(`Error: ${validation}`));\n process.exit(1);\n }\n }\n\n this.config.projectName = projectName;\n }\n\n private validateProjectName(input: string): boolean | string {\n if (!input || input.length === 0) {\n return \"Project name cannot be empty\";\n }\n\n // Check for valid characters (letters, numbers, hyphens, underscores)\n if (!/^[a-zA-Z0-9_-]+$/.test(input)) {\n return \"Project name can only contain letters, numbers, hyphens, and underscores\";\n }\n\n // Check if it starts with a letter or number (not hyphen or underscore)\n if (!/^[a-zA-Z0-9]/.test(input)) {\n return \"Project name must start with a letter or number\";\n }\n\n // Check if it ends with a letter or number (not hyphen or underscore)\n if (!/[a-zA-Z0-9]$/.test(input)) {\n return \"Project name must end with a letter or number\";\n }\n\n // Check length (reasonable limits)\n if (input.length > 50) {\n return \"Project name must be 50 characters or less\";\n }\n\n // Check for reserved names\n const reservedNames = [\"node_modules\"];\n if (reservedNames.includes(input.toLowerCase())) {\n return \"Project name cannot be a reserved name\";\n }\n\n return true;\n }\n\n private async promptTypescript() {\n const { typescript } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"typescript\",\n message: `Would you like to use ${chalk.cyan(\"TypeScript\")}?`,\n default: false,\n },\n ]);\n this.config.typescript = typescript;\n }\n\n private async promptPrismaProvider() {\n const { prismaProvider } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"prismaProvider\",\n message: `What db provider will be used for ${chalk.cyan(\"Prisma\")}?`,\n choices: [\n \"postgresql\",\n \"mongodb\",\n \"mysql\",\n \"sqlite\",\n \"sqlserver\",\n \"cockroachdb\",\n ],\n },\n ]);\n\n // Set the correct idDatabaseType based on provider\n let idDatabaseType: string;\n let defaultDBurl: string;\n\n switch (prismaProvider) {\n case \"mongodb\":\n idDatabaseType = '@id @default(auto()) @map(\"_id\") @db.ObjectId';\n defaultDBurl = `mongodb://localhost:27017/${this.config.projectName}`;\n break;\n case \"sqlite\":\n idDatabaseType = \"@id @default(cuid())\";\n defaultDBurl = \"file:../file.db\";\n break;\n case \"mysql\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `mysql://username:password@localhost:3306/${this.config.projectName}`;\n break;\n case \"postgresql\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `postgresql://username:password@localhost:5432/${this.config.projectName}`;\n break;\n case \"sqlserver\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `sqlserver://localhost:1433;database=${this.config.projectName};username=sa;password=password;encrypt=DANGER_PLAINTEXT`;\n break;\n case \"cockroachdb\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `postgresql://username:password@localhost:26257/${this.config.projectName}?sslmode=require`;\n break;\n default:\n idDatabaseType = \"@id @default(uuid())\";\n defaultDBurl = `postgresql://username:password@localhost:5432/${this.config.projectName}`;\n }\n\n this.config.prisma = {\n provider: prismaProvider,\n idDatabaseType: idDatabaseType,\n defaultDBurl: defaultDBurl,\n };\n }\n\n private async promptValidation() {\n const { useValidation } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"useValidation\",\n message: `Would you like to set up ${chalk.cyan(\"Validation\")}?`,\n default: true,\n },\n ]);\n\n if (useValidation) {\n const { validationType } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"validationType\",\n message: \"Choose validation library:\",\n choices: [\"zod\", \"class-validator\"],\n },\n ]);\n this.config.validation = {\n type: validationType,\n };\n }\n }\n\n private async promptAuthentication() {\n const { useAuthentication } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"useAuthentication\",\n message: `Would you like to set up ${chalk.cyan(\"Authentication\")}?`,\n default: true,\n },\n ]);\n\n if (useAuthentication) {\n const { authenticationType } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"authenticationType\",\n message: \"Choose authentication type:\",\n choices: [\"static\", \"dynamic\", \"define later\"],\n },\n ]);\n\n if (\n authenticationType !== \"define later\" &&\n this.config.prisma.provider !== \"sqlite\"\n ) {\n const { multipleRoles } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"multipleRoles\",\n default: true,\n message: `Would you like to use authentication with ${chalk.cyan(\"Multiple Roles\")}?`,\n },\n ]);\n\n const { usernameField } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"usernameField\",\n message: \"Choose default username field for login:\",\n choices: [\"email\", \"username\", \"define later\"],\n },\n ]);\n\n this.config.authentication = {\n type: authenticationType,\n usernameField:\n usernameField === \"define later\" ? \"custom\" : usernameField,\n multipleRoles,\n };\n } else if (this.config.prisma.provider === \"sqlite\") {\n console.info(\n `Skipping multiple roles options because provider is sqlite...`\n );\n }\n }\n }\n}\n\nconst projectConfigInquirer = new ProjectConfigInquirer();\n\nexport default projectConfigInquirer;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template-compiler.js","sourceRoot":"","sources":["../../../../src/utils/template-compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,gDAAwB;AACxB,4CAAoB;AACpB,4DAAoC;AACpC,uDAA6D;AAE7D,MAAM,gBAAgB;IACd,iCAAiC,CAAC,MAAqB;;YAC3D,OAAO,CAAC,CAAC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F;AAED,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC;AAEhD,kBAAe,gBAAgB,CAAC","sourcesContent":["import { ProjectConfig } from \"./project-config-inquirer\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport handlebars from \"handlebars\";\nimport { getNpmPackageVersion } from \"./helpers/npm.helpers\";\n\nclass TemplateCompiler {\n async canCompileAuthenticationTemplates(config: ProjectConfig) {\n return !!config.authentication;\n }\n\n filesToBeSkipped(config: ProjectConfig) {\n const files: string[] = [];\n\n if (config.authentication?.type === \"define later\")\n files.push(...[\"user.prisma.hbs\"]);\n\n if (config.authentication?.type === \"static\")\n files.push(\n ...[\n \"auth-role.prisma.hbs\",\n \"auth-permission.prisma.hbs\",\n \"user-role.prisma.hbs\",\n ]\n );\n\n if (!config.typescript) files.push(...[\"tsconfig.json.hbs\"]);\n\n if (config?.typescript) files.push(...[\"jsconfig.json.hbs\"]);\n\n return files;\n }\n /**\n * Compiles the Arkos.js project with handlebars templates\n *\n * @param templatesDir {string} templates location\n * @param config {ProjectConfig} the project configuration\n * @returns void\n * */\n async compile(templatesDir: string, config: ProjectConfig) {\n const outputDir = config.projectPath;\n const isTypescript = config.typescript;\n const filesToBeSkipped = this.filesToBeSkipped(config);\n\n function processTemplates(dir: string, relativeDir = \"\") {\n fs.readdirSync(dir, { withFileTypes: true }).forEach(async (dirent) => {\n if (filesToBeSkipped.includes(dirent.name)) return;\n\n const fullPath = path.join(dir, dirent.name);\n const relativePath = path.join(relativeDir, dirent.name);\n\n if (dirent.isDirectory()) {\n processTemplates(fullPath, relativePath);\n } else if (dirent.name.endsWith(\".hbs\")) {\n const templatePath = fullPath;\n const template = handlebars.compile(\n fs.readFileSync(templatePath, \"utf8\")\n );\n\n let arkosCurrentVersion = getNpmPackageVersion(\"arkos\");\n\n const content = template({ ...config, arkosCurrentVersion });\n const ext = isTypescript ? \".ts\" : \".js\";\n\n let outputPath = path.join(\n outputDir,\n relativePath.replace(\".hbs\", \"\")\n );\n if (dirent.name.endsWith(\".ts.hbs\"))\n outputPath = path.join(\n outputDir,\n relativePath.replace(\".ts.hbs\", ext)\n );\n\n fs.mkdirSync(path.dirname(outputPath), { recursive: true });\n fs.writeFileSync(outputPath, content);\n }\n });\n }\n\n processTemplates(templatesDir);\n }\n}\n\nconst templateCompiler = new TemplateCompiler();\n\nexport default templateCompiler;\n"]}
|
package/dist/shared/src/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./utils/helpers/user-agent.helpers"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../shared/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qEAAmD","sourcesContent":["export * from \"./utils/helpers/user-agent.helpers\";\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"user-agent.helpers.js","sourceRoot":"","sources":["../../../../../../shared/src/utils/helpers/user-agent.helpers.ts"],"names":[],"mappings":";;;AAMA,SAAgB,iCAAiC;IAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC;IAE1D,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7B,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IACtD,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAE9C,OAAO,KAAK,CAAC;AACf,CAAC;AAbD,8EAaC","sourcesContent":["/**\n * Helps getting the current package manager from user agent\n *\n * @returns {string} the package manager\n * @default \"npm\"\n */\nexport function detectPackageManagerFromUserAgent(): string {\n const userAgent = process.env.npm_config_user_agent || \"\";\n\n if (!userAgent) return \"npm\";\n if (userAgent.includes(\"pnpm\")) return \"pnpm\";\n if (userAgent.includes(\"yarn\")) return \"yarn\";\n if (userAgent.includes(\"npm\")) return \"npm\";\n if (userAgent.includes(\"bun\")) return \"bun\";\n if (userAgent.includes(\"cnpm\")) return \"cnpm\";\n if (userAgent.includes(\"corepack\")) return \"corepack\";\n if (userAgent.includes(\"deno\")) return \"deno\";\n\n return \"npm\";\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|