create-arkos 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,192 @@
1
+ # create-arkos
2
+
3
+ The official CLI tool to quickly scaffold new Arkos.js API projects with interactive setup and best practices out of the box.
4
+
5
+ ## Overview
6
+
7
+ `create-arkos` is the scaffolding tool for the Arkos.js framework (v1.2.3-beta). It provides an interactive setup experience to generate a complete, production-ready RESTful API project with automatic CRUD operations, authentication, validation, and more - all built on top of Express.js and Prisma.
8
+
9
+ ## Requirements
10
+
11
+ - Node.js 20 or higher
12
+ - npm, yarn, or pnpm
13
+
14
+ ## Quick Start
15
+
16
+ ```bash
17
+ # Using npm
18
+ npm create arkos@latest
19
+
20
+ # Using yarn
21
+ yarn create arkos
22
+
23
+ # Using pnpm
24
+ pnpm create arkos
25
+ ```
26
+
27
+ ## Interactive Setup
28
+
29
+ The CLI will guide you through an interactive setup process:
30
+
31
+ ```bash
32
+ > create-arkos@1.0 dev
33
+
34
+ ? What is the name of your project? my-arkos-project
35
+ ? Would you like to use TypeScript? Yes
36
+ ? What db provider will be used for Prisma? mongodb
37
+ ? Would you like to set up Validation? Yes
38
+ ? Choose validation library: class-validator
39
+ ? Would you like to set up Authentication? Yes
40
+ ? Choose authentication type: dynamic
41
+ ? Would you like to use authentication with Multiple Roles? Yes
42
+ ? Choose default username field for login: email
43
+ ```
44
+
45
+ ## Configuration Options
46
+
47
+ ### Database Providers
48
+
49
+ - **PostgreSQL** - Production-ready relational database
50
+ - **MongoDB** - NoSQL document database
51
+ - **MySQL** - Popular relational database
52
+ - **SQLite** - Lightweight file-based database
53
+ - **SQL Server** - Microsoft's enterprise database
54
+ - **CockroachDB** - Distributed SQL database
55
+
56
+ ### Validation Libraries
57
+
58
+ - **class-validator** - Decorator-based validation
59
+ - **zod** - TypeScript-first schema validation
60
+
61
+ ### Authentication Types
62
+
63
+ - **Static** - Uses configuration files for roles and permissions
64
+ - **Dynamic** - Database-level authentication with `auth-role` and `auth-permission` tables
65
+ - **Define Later** - Skip authentication setup for now
66
+
67
+ ### Username Field Options
68
+
69
+ - **Email** - Use email as login identifier
70
+ - **Username** - Use username as login identifier
71
+ - **Define Later** - Configure custom field later
72
+
73
+ ## Generated Project Structure
74
+
75
+ ```
76
+ my-arkos-project/
77
+ ├── prisma/
78
+ │ └── schema.prisma # Database schema with auth tables (if dynamic)
79
+ ├── src/
80
+ │ ├── utils/
81
+ │ │ └── prisma/
82
+ │ │ └── index.ts # Prisma client configuration
83
+ │ ├── app.ts # Main application file
84
+ │ ├── arkos.config.ts # Arkos framework configuration
85
+ │ └── package.json # Dependencies and scripts
86
+ ├── .env # Environment variables
87
+ ├── .gitignore # Git ignore rules
88
+ ├── package.json # Project configuration
89
+ ├── pnpm-lock.yaml # Lock file
90
+ └── tsconfig.json # TypeScript configuration
91
+ ```
92
+
93
+ ## Getting Started After Creation
94
+
95
+ 1. **Navigate to your project**:
96
+
97
+ ```bash
98
+ cd my-arkos-project
99
+ ```
100
+
101
+ 2. **Set up your database**:
102
+
103
+ ```bash
104
+ # Edit .env file with your DATABASE_URL
105
+ # Example: DATABASE_URL="mongodb://localhost:27017/my-arkos-project"
106
+ ```
107
+
108
+ 3. **Set up Prisma**:
109
+
110
+ ```bash
111
+ npx prisma db push
112
+ npx prisma generate
113
+ ```
114
+
115
+ 4. **Start development**:
116
+ ```bash
117
+ npm run dev
118
+ ```
119
+
120
+ ## Environment Variables
121
+
122
+ The generated project requires these environment variables in `.env`:
123
+
124
+ ```env
125
+ DATABASE_URL="your-database-connection-string"
126
+ ```
127
+
128
+ Example for different databases:
129
+
130
+ ```env
131
+ # PostgreSQL
132
+ DATABASE_URL="postgresql://username:password@localhost:5432/mydb"
133
+
134
+ # MongoDB
135
+ DATABASE_URL="mongodb://localhost:27017/mydb"
136
+
137
+ # MySQL
138
+ DATABASE_URL="mysql://username:password@localhost:3306/mydb"
139
+
140
+ # SQLite
141
+ DATABASE_URL="file:./dev.db"
142
+ ```
143
+
144
+ ## Authentication Setup
145
+
146
+ ### Dynamic Authentication
147
+
148
+ When you choose "dynamic" authentication, the CLI generates:
149
+
150
+ - `auth-role` table for role management
151
+ - `auth-permission` table for permission management
152
+ - Database-level authentication system
153
+ - Multiple roles support
154
+
155
+ ### Static Authentication
156
+
157
+ When you choose "static" authentication:
158
+
159
+ - Uses configuration files for roles and permissions
160
+ - Simpler setup for smaller projects
161
+ - File-based permission management
162
+
163
+ ## Available Framework Commands
164
+
165
+ Once your project is created, you can use these Arkos.js commands:
166
+
167
+ ```bash
168
+ arkos dev # Start development server
169
+ arkos start # Start production server
170
+ arkos build # Build for production
171
+ arkos generate component-name -m model-name # generate components like controller, routers, services
172
+ ```
173
+
174
+ ## Support & Community
175
+
176
+ - **Documentation**: [www.arkosjs.com](https://www.arkosjs.com)
177
+ - **GitHub**: [uanela/arkos](https://github.com/uanela/arkos)
178
+ - **WhatsApp Community**: [Join our WhatsApp group](https://chat.whatsapp.com/EJ8cjb9hxau0EcOnI4fdpD)
179
+
180
+ ## Version
181
+
182
+ Current version: 1.2.3-beta
183
+
184
+ ## License
185
+
186
+ MIT License
187
+
188
+ ---
189
+
190
+ **Built with ❤️ by the Arkos.js Team**
191
+
192
+ _From the Greek "ἀρχή" (Arkhē) - your foundation for backend development_
package/cli.js ADDED
File without changes
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ const fs_extra_1 = __importDefault(require("fs-extra"));
17
+ const path_1 = __importDefault(require("path"));
18
+ const chalk_1 = __importDefault(require("chalk"));
19
+ const child_process_1 = require("child_process");
20
+ const project_config_inquirer_1 = __importDefault(require("./utils/project-config-inquirer"));
21
+ const template_compiler_1 = __importDefault(require("./utils/template-compiler"));
22
+ const handlebars_1 = __importDefault(require("handlebars"));
23
+ handlebars_1.default.registerHelper("eq", (a, b) => a === b);
24
+ handlebars_1.default.registerHelper("neq", (a, b) => a !== b);
25
+ function main() {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const config = yield project_config_inquirer_1.default.run();
28
+ const projectPath = config.projectPath;
29
+ fs_extra_1.default.mkdirSync(projectPath, { recursive: true });
30
+ console.info(`\nCreating a new ${chalk_1.default.bold(chalk_1.default.cyan("Arkos.js"))} project in ${chalk_1.default.green(`./${config.projectName}`)}`);
31
+ const templatesDir = path_1.default.resolve(`./src/utils/templates/basic`);
32
+ yield template_compiler_1.default.compile(templatesDir, config);
33
+ process.chdir(projectPath);
34
+ console.info("\nInstalling dependencies...");
35
+ console.info("\nUsing npm.\n");
36
+ (0, child_process_1.execSync)("npm install", { stdio: "inherit" });
37
+ console.info(`
38
+ ${chalk_1.default.bold(chalk_1.default.cyan("Arkos.js"))} project created successfully!
39
+
40
+ Next steps:
41
+ 1. cd ${config.projectName}
42
+ 2. setup your ${chalk_1.default.cyan("DATABASE_URL")} under .env
43
+ 3. npx prisma db push
44
+ 4. npx prisma generate
45
+ 5. npm run dev
46
+ `);
47
+ });
48
+ }
49
+ main().catch(console.error);
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,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,WAAW;kBACV,eAAK,CAAC,IAAI,CAAC,cAAc,CAAC;;;;KAIvC,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-extra\";\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\";\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 in ${chalk.green(`./${config.projectName}`)}`\n );\n\n const templatesDir = path.resolve(`./src/utils/templates/basic`);\n await templateCompiler.compile(templatesDir, config);\n\n process.chdir(projectPath);\n\n console.info(\"\\nInstalling dependencies...\");\n console.info(\"\\nUsing npm.\\n\");\n\n execSync(\"npm install\", { 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. npx prisma generate\n 5. npm run dev\n `);\n}\n\nmain().catch(console.error);\n"]}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const fs_extra_1 = __importDefault(require("fs-extra"));
16
+ const path_1 = __importDefault(require("path"));
17
+ const handlebars_1 = __importDefault(require("handlebars"));
18
+ handlebars_1.default.registerHelper("eq", (a, b) => a === b);
19
+ handlebars_1.default.registerHelper("neq", (a, b) => a !== b);
20
+ (() => {
21
+ const templatesDir = `${process.cwd()}/cache/handlebars/templates`;
22
+ const outputDir = `${process.cwd()}/cache/handlebars/output`;
23
+ const config = {
24
+ projectName: "arkos-project",
25
+ typescript: true,
26
+ validation: {
27
+ type: "zod",
28
+ },
29
+ authentication: {
30
+ type: "dynamic",
31
+ usernameField: "email",
32
+ multipleRoles: true,
33
+ },
34
+ prisma: {
35
+ provider: "mongodb",
36
+ idDatabaseType: "@db @default(uuid())",
37
+ },
38
+ projectPath: outputDir,
39
+ };
40
+ function processTemplates(dir, relativeDir = "") {
41
+ fs_extra_1.default.readdirSync(dir, { withFileTypes: true }).forEach((dirent) => __awaiter(this, void 0, void 0, function* () {
42
+ const fullPath = path_1.default.join(dir, dirent.name);
43
+ const relativePath = path_1.default.join(relativeDir, dirent.name);
44
+ if (dirent.isDirectory()) {
45
+ processTemplates(fullPath, relativePath);
46
+ }
47
+ else if (dirent.name.endsWith(".hbs")) {
48
+ const templatePath = fullPath;
49
+ const template = handlebars_1.default.compile(fs_extra_1.default.readFileSync(templatePath, "utf8"));
50
+ const content = template(config);
51
+ const ext = config.typescript ? ".ts" : ".js";
52
+ let outputPath = path_1.default.join(outputDir, relativePath.replace(".hbs", ""));
53
+ if (dirent.name.endsWith(".ts.hbs"))
54
+ outputPath = path_1.default.join(outputDir, relativePath.replace(".ts.hbs", ext));
55
+ fs_extra_1.default.mkdirSync(path_1.default.dirname(outputPath), { recursive: true });
56
+ fs_extra_1.default.writeFileSync(outputPath, content);
57
+ }
58
+ }));
59
+ }
60
+ processTemplates(templatesDir);
61
+ })();
62
+ //# sourceMappingURL=hbs-tester.helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hbs-tester.helpers.js","sourceRoot":"","sources":["../../../src/utils/helpers/hbs-tester.helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,wDAA0B;AAC1B,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,EAAE,IAAI;SACpB;QACD,MAAM,EAAE;YACN,QAAQ,EAAE,SAAS;YACnB,cAAc,EAAE,sBAAsB;SACvC;QACD,WAAW,EAAE,SAAS;KACvB,CAAC;IAEF,SAAS,gBAAgB,CAAC,GAAW,EAAE,WAAW,GAAG,EAAE;QACrD,kBAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAO,MAAM,EAAE,EAA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C,CAAC,CAAC,EAAE,CAAC","sourcesContent":["import fs from \"fs-extra\";\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 },\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,23 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getLatestVersion = void 0;
13
+ function getLatestVersion(packageName) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ const res = yield fetch(`https://registry.npmjs.org/${packageName}`);
16
+ if (!res.ok)
17
+ throw new Error(`Failed to fetch: ${res.status}`);
18
+ const data = yield res.json();
19
+ return data["dist-tags"].latest;
20
+ });
21
+ }
22
+ exports.getLatestVersion = getLatestVersion;
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,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","sourcesContent":["export 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"]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=template-processor.js.map
@@ -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,161 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const path_1 = __importDefault(require("path"));
16
+ const inquirer_1 = __importDefault(require("inquirer"));
17
+ const chalk_1 = __importDefault(require("chalk"));
18
+ class ProjectConfigInquirer {
19
+ constructor() {
20
+ this.config = {};
21
+ }
22
+ run() {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ yield this.promptProjectName();
25
+ yield this.promptTypescript();
26
+ yield this.promptPrismaProvider();
27
+ yield this.promptValidation();
28
+ yield this.promptAuthentication();
29
+ const projectPath = path_1.default.resolve(process.cwd(), this.config.projectName);
30
+ this.config.projectPath = projectPath;
31
+ return this.config;
32
+ });
33
+ }
34
+ promptProjectName() {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ let projectName = process.argv[2];
37
+ if (!projectName) {
38
+ const result = yield inquirer_1.default.prompt([
39
+ {
40
+ type: "input",
41
+ name: "projectName",
42
+ message: "What is the name of your project?",
43
+ default: "my-arkos-project",
44
+ validate: (input) => input.length > 0 ? true : "Project name cannot be empty",
45
+ },
46
+ ]);
47
+ projectName = result.projectName;
48
+ }
49
+ this.config.projectName = projectName;
50
+ });
51
+ }
52
+ promptTypescript() {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ const { typescript } = yield inquirer_1.default.prompt([
55
+ {
56
+ type: "confirm",
57
+ name: "typescript",
58
+ message: `Would you like to use ${chalk_1.default.cyan("TypeScript")}?`,
59
+ default: false,
60
+ },
61
+ ]);
62
+ this.config.typescript = typescript;
63
+ });
64
+ }
65
+ promptPrismaProvider() {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ const { prismaProvider } = yield inquirer_1.default.prompt([
68
+ {
69
+ type: "list",
70
+ name: "prismaProvider",
71
+ message: `What db provider will be used for ${chalk_1.default.cyan("Prisma")}?`,
72
+ choices: [
73
+ "postgresql",
74
+ "mongodb",
75
+ "mysql",
76
+ "sqlite",
77
+ "sqlserver",
78
+ "cockroachdb",
79
+ ],
80
+ },
81
+ ]);
82
+ this.config.prisma = {
83
+ provider: prismaProvider,
84
+ idDatabaseType: "@id @default(uuid())",
85
+ };
86
+ });
87
+ }
88
+ promptValidation() {
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ const { useValidation } = yield inquirer_1.default.prompt([
91
+ {
92
+ type: "confirm",
93
+ name: "useValidation",
94
+ message: `Would you like to set up ${chalk_1.default.cyan("Validation")}?`,
95
+ default: true,
96
+ },
97
+ ]);
98
+ if (useValidation) {
99
+ const { validationType } = yield inquirer_1.default.prompt([
100
+ {
101
+ type: "list",
102
+ name: "validationType",
103
+ message: "Choose validation library:",
104
+ choices: ["zod", "class-validator"],
105
+ },
106
+ ]);
107
+ this.config.validation = {
108
+ type: validationType,
109
+ };
110
+ }
111
+ });
112
+ }
113
+ promptAuthentication() {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ const { useAuthentication } = yield inquirer_1.default.prompt([
116
+ {
117
+ type: "confirm",
118
+ name: "useAuthentication",
119
+ message: `Would you like to set up ${chalk_1.default.cyan("Authentication")}?`,
120
+ default: true,
121
+ },
122
+ ]);
123
+ if (useAuthentication) {
124
+ const { authenticationType } = yield inquirer_1.default.prompt([
125
+ {
126
+ type: "list",
127
+ name: "authenticationType",
128
+ message: "Choose authentication type:",
129
+ choices: ["static", "dynamic", "define later"],
130
+ },
131
+ ]);
132
+ if (authenticationType !== "define later") {
133
+ const { multipleRoles } = yield inquirer_1.default.prompt([
134
+ {
135
+ type: "confirm",
136
+ name: "multipleRoles",
137
+ default: true,
138
+ message: `Would you like to use authentication with ${chalk_1.default.cyan("Multiple Roles")}?`,
139
+ },
140
+ ]);
141
+ const { usernameField } = yield inquirer_1.default.prompt([
142
+ {
143
+ type: "list",
144
+ name: "usernameField",
145
+ message: "Choose default username field for login:",
146
+ choices: ["email", "username", "define later"],
147
+ },
148
+ ]);
149
+ this.config.authentication = {
150
+ type: authenticationType,
151
+ usernameField: usernameField === "define later" ? "custom" : usernameField,
152
+ multipleRoles,
153
+ };
154
+ }
155
+ }
156
+ });
157
+ }
158
+ }
159
+ const projectConfigInquirer = new ProjectConfigInquirer();
160
+ exports.default = projectConfigInquirer;
161
+ //# sourceMappingURL=project-config-inquirer.js.map
@@ -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;AA0B1B,MAAM,qBAAqB;IAG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AC,QAAQ,CAAC,CAAC,CAAC,aAAa;wBAC7D,aAAa;qBACd,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 };\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 (!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: (input) =>\n input.length > 0 ? true : \"Project name cannot be empty\",\n },\n ]);\n projectName = result.projectName;\n }\n this.config.projectName = projectName;\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 this.config.prisma = {\n provider: prismaProvider,\n idDatabaseType: \"@id @default(uuid())\",\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 (authenticationType !== \"define later\") {\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 }\n }\n }\n}\n\nconst projectConfigInquirer = new ProjectConfigInquirer();\n\nexport default projectConfigInquirer;\n"]}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const path_1 = __importDefault(require("path"));
16
+ const fs_extra_1 = __importDefault(require("fs-extra"));
17
+ const handlebars_1 = __importDefault(require("handlebars"));
18
+ class TemplateCompiler {
19
+ canCompileAuthenticationTemplates(config) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ return !!config.authentication;
22
+ });
23
+ }
24
+ filesToBeSkipped(config) {
25
+ var _a;
26
+ const files = [];
27
+ if (config.authentication.type !== "define later") {
28
+ files.concat(["user.prisma.hbs"]);
29
+ }
30
+ if (((_a = config.authentication) === null || _a === void 0 ? void 0 : _a.type) === "static") {
31
+ files.concat(["auth-role.prisma.hbs", "auth-permission.prisma.hbs"]);
32
+ }
33
+ return files;
34
+ }
35
+ compile(templatesDir, config) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const outputDir = config.projectPath;
38
+ const isTypescript = config.typescript;
39
+ const filesToBeSkipped = this.filesToBeSkipped(config);
40
+ function processTemplates(dir, relativeDir = "") {
41
+ fs_extra_1.default.readdirSync(dir, { withFileTypes: true }).forEach((dirent) => __awaiter(this, void 0, void 0, function* () {
42
+ if (filesToBeSkipped.includes(dirent.name))
43
+ return;
44
+ const fullPath = path_1.default.join(dir, dirent.name);
45
+ const relativePath = path_1.default.join(relativeDir, dirent.name);
46
+ if (dirent.isDirectory()) {
47
+ processTemplates(fullPath, relativePath);
48
+ }
49
+ else if (dirent.name.endsWith(".hbs")) {
50
+ const templatePath = fullPath;
51
+ const template = handlebars_1.default.compile(fs_extra_1.default.readFileSync(templatePath, "utf8"));
52
+ let arkosLatestVersion = "1.0.0";
53
+ const content = template(Object.assign(Object.assign({}, config), { arkosLatestVersion }));
54
+ const ext = isTypescript ? ".ts" : ".js";
55
+ let outputPath = path_1.default.join(outputDir, relativePath.replace(".hbs", ""));
56
+ if (dirent.name.endsWith(".ts.hbs"))
57
+ outputPath = path_1.default.join(outputDir, relativePath.replace(".ts.hbs", ext));
58
+ fs_extra_1.default.mkdirSync(path_1.default.dirname(outputPath), { recursive: true });
59
+ fs_extra_1.default.writeFileSync(outputPath, content);
60
+ }
61
+ }));
62
+ }
63
+ processTemplates(templatesDir);
64
+ });
65
+ }
66
+ }
67
+ const templateCompiler = new TemplateCompiler();
68
+ exports.default = templateCompiler;
69
+ //# sourceMappingURL=template-compiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-compiler.js","sourceRoot":"","sources":["../../src/utils/template-compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,gDAAwB;AACxB,wDAA0B;AAC1B,4DAAoC;AAGpC,MAAM,gBAAgB;IACd,iCAAiC,CAAC,MAAqB;;YAC3D,OAAO,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;QACjC,CAAC;KAAA;IAED,gBAAgB,CAAC,MAAqB;;QACpC,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,IAAI,MAAM,CAAC,cAAc,CAAC,IAAI,KAAK,cAAc,EAAE;YACjD,KAAK,CAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;SACnC;QAED,IAAI,CAAA,MAAA,MAAM,CAAC,cAAc,0CAAE,IAAI,MAAK,QAAQ,EAAE;YAC5C,KAAK,CAAC,MAAM,CAAC,CAAC,sBAAsB,EAAE,4BAA4B,CAAC,CAAC,CAAC;SACtE;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IA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,EACT,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CACjC,CAAC;wBACF,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;4BACjC,UAAU,GAAG,cAAI,CAAC,IAAI,CACpB,SAAS,EACT,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CACrC,CAAC;wBAEJ,kBAAE,CAAC,SAAS,CAAC,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;wBAC5D,kBAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;qBACvC;gBACH,CAAC,CAAA,CAAC,CAAC;YACL,CAAC;YAED,gBAAgB,CAAC,YAAY,CAAC,CAAC;QACjC,CAAC;KAAA;CACF;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-extra\";\nimport handlebars from \"handlebars\";\n// import { getLatestVersion } from \"./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.concat([\"user.prisma.hbs\"]);\n }\n\n if (config.authentication?.type === \"static\") {\n files.concat([\"auth-role.prisma.hbs\", \"auth-permission.prisma.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 arkosLatestVersion = \"1.0.0\";\n\n const content = template({ ...config, arkosLatestVersion });\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 ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "create-arkos",
3
+ "version": "0.0.1",
4
+ "description": "CLI for creating Arkos.js projects, see docs at www.arkosjs.com/docs",
5
+ "bin": {
6
+ "create-arkos": "./dist/index.js"
7
+ },
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "dev": "ts-node src/index.ts",
11
+ "test:hbs": "ts-node src/utils/helpers/hbs-tester.helpers.ts",
12
+ "prepublishOnly": "pnpm run build"
13
+ },
14
+ "author": "Uanela Como",
15
+ "license": "MIT",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/uanela/arkos.git"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/uanela/arkos/issues"
22
+ },
23
+ "homepage": "https://www.arkosjs.com",
24
+ "files": ["dist", "cli.js", "README.md"],
25
+ "devDependencies": {
26
+ "@types/fs-extra": "^11.0.4",
27
+ "@types/inquirer": "^8.1.0",
28
+ "@types/node": "^16.18.126",
29
+ "fs-extra": "^10.1.0",
30
+ "inquirer": "^8.2.6",
31
+ "ts-node": "^10.9.2",
32
+ "typescript": "^4.9.5"
33
+ },
34
+ "dependencies": {
35
+ "@clack/prompts": "^0.11.0",
36
+ "@inquirer/prompts": "^7.6.0",
37
+ "chalk": "^5.4.1",
38
+ "handlebars": "^4.7.8"
39
+ }
40
+ }