create-arkos 1.5.9-canary.1 → 1.6.0-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/README.md +59 -156
- package/dist/utils/project-config-inquirer.js +69 -75
- package/dist/utils/project-config-inquirer.js.map +1 -1
- package/dist/utils/template-compiler.js +11 -7
- package/dist/utils/template-compiler.js.map +1 -1
- package/package.json +3 -3
- package/templates/basic/.env.hbs +2 -2
- package/templates/basic/README.md.hbs +1 -1
- package/templates/basic/arkos.config.ts.hbs +6 -11
- package/templates/basic/jsconfig.json.hbs +14 -5
- package/templates/basic/package.json.hbs +2 -4
- package/templates/basic/prisma/schema/__tests__/user-role.prisma.hbs.test.ts +1 -1
- package/templates/basic/prisma/schema/__tests__/user.prisma.hbs.test.ts +2 -2
- package/templates/basic/prisma/schema/user.prisma.hbs +1 -1
- package/templates/basic/src/app.ts.hbs +5 -3
- package/templates/basic/src/modules/auth-permission/auth-permission.policy.ts.hbs +33 -0
- package/templates/basic/src/modules/auth-permission/auth-permission.router.ts.hbs +14 -0
- package/templates/basic/src/modules/auth-role/auth-role.policy.ts.hbs +33 -0
- package/templates/basic/src/modules/auth-role/auth-role.router.ts.hbs +14 -0
- package/templates/basic/src/modules/auth-role/schemas/create-auth-role.schema.ts.hbs +1 -5
- package/templates/basic/src/modules/auth-role/schemas/update-auth-role.schema.ts.hbs +1 -5
- package/templates/basic/src/modules/file-upload/file-upload.policy.ts.hbs +33 -0
- package/templates/basic/src/modules/file-upload/file-upload.router.ts.hbs +13 -0
- package/templates/basic/src/modules/user/dtos/update-user.dto.ts.hbs +1 -5
- package/templates/basic/src/modules/user/schemas/update-user.schema.ts.hbs +1 -5
- package/templates/basic/src/modules/user/user.interceptors.ts.hbs +0 -50
- package/templates/basic/src/modules/user/user.policy.ts.hbs +33 -0
- package/templates/basic/src/modules/user/user.router.ts.hbs +14 -0
- package/templates/basic/src/utils/validation/api-actions.ts.hbs +1 -1
- package/templates/basic/tsconfig.json.hbs +13 -9
- package/templates/basic/src/modules/auth-permission/auth-permission.auth.ts.hbs +0 -75
- package/templates/basic/src/modules/auth-role/auth-role.auth.ts.hbs +0 -75
- package/templates/basic/src/modules/file-upload/file-upload.auth.ts.hbs +0 -83
- package/templates/basic/src/modules/user/user.auth.ts.hbs +0 -75
package/README.md
CHANGED
|
@@ -1,94 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
+
[](https://badge.socket.dev/npm/package/create-arkos)
|
|
5
6
|

|
|
6
7
|

|
|
7
8
|

|
|
9
|
+

|
|
8
10
|
|
|
9
11
|
</div>
|
|
10
12
|
|
|
11
13
|
<div align="center">
|
|
12
|
-
<h2>Scaffold
|
|
13
|
-
<p>The official CLI tool for Arkos.js
|
|
14
|
+
<h2>Scaffold Your Arkos Project in Seconds</h2>
|
|
15
|
+
<p>The official CLI scaffolding tool for Arkos.js</p>
|
|
14
16
|
</div>
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
## Why create-arkos?
|
|
19
|
-
|
|
20
|
-
Skip the hours of boilerplate setup. Get a production-ready API with authentication, validation, and auto-generated docs in **under 5 minutes**.
|
|
18
|
+
<div align="center">
|
|
21
19
|
|
|
22
|
-
**
|
|
20
|
+
**[Installation](https://www.arkosjs.com/docs/getting-started/installation)** •
|
|
21
|
+
**[Documentation](https://arkosjs.com/docs)** •
|
|
22
|
+
**[Website](https://arkosjs.com)** •
|
|
23
|
+
**[Tutorial](https://arkosjs.com/learn)** •
|
|
24
|
+
**[GitHub](https://github.com/uanela/arkos)** •
|
|
25
|
+
**[Blog](https://www.arkosjs.com/blog)** •
|
|
26
|
+
**[Npm](https://www.npmjs.com/package/create-arkos)**
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
- Prototyping APIs that need to scale later
|
|
26
|
-
- Teams who want consistent project structure from day one
|
|
28
|
+
</div>
|
|
27
29
|
|
|
28
30
|
## Quick Start
|
|
29
31
|
|
|
30
32
|
```bash
|
|
31
|
-
# Using pnpm (recommended)
|
|
32
33
|
pnpm create arkos@latest my-project
|
|
33
|
-
|
|
34
|
-
# Using npm
|
|
35
|
-
npm create arkos@latest my-project
|
|
36
|
-
|
|
37
|
-
# Using yarn
|
|
38
|
-
yarn create arkos@latest my-project
|
|
39
34
|
```
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
## What You Get
|
|
44
|
-
|
|
45
|
-
✅ **Production-ready REST API** with Express.js
|
|
46
|
-
✅ **JWT authentication** configured and ready
|
|
47
|
-
✅ **Auto-generated Swagger docs** at `/api/docs`
|
|
48
|
-
✅ **Database setup** with Prisma ORM
|
|
49
|
-
✅ **Input validation** (Zod or class-validator)
|
|
50
|
-
✅ **TypeScript support** (optional)
|
|
51
|
-
✅ **Best practices** and security middleware
|
|
36
|
+
Follow the interactive prompts. Your project comes with JWT auth, customizable CRUD routes, Swagger docs at `/api/docs`, file uploads, validation, and a full security middleware stack. Understand the generated [Project Structure](https://www.arkosjs.com/docs/getting-started/project-structure).
|
|
52
37
|
|
|
53
|
-
## Interactive Setup
|
|
54
|
-
|
|
55
|
-
The CLI guides you through a friendly setup process:
|
|
38
|
+
## Interactive Setup
|
|
56
39
|
|
|
57
40
|
```bash
|
|
58
|
-
? What is the name of your project? my-
|
|
41
|
+
? What is the name of your project? my-project
|
|
59
42
|
? Would you like to use TypeScript? Yes
|
|
60
|
-
? What db provider will be used for Prisma?
|
|
61
|
-
?
|
|
62
|
-
?
|
|
63
|
-
?
|
|
64
|
-
?
|
|
65
|
-
? Would you like to use authentication with Multiple Roles? Yes
|
|
66
|
-
? Choose default username field for login: email
|
|
43
|
+
? What db provider will be used for Prisma? postgresql
|
|
44
|
+
? Which Validation library would you like to use? zod
|
|
45
|
+
? Which Authentication mode would you like to use? static
|
|
46
|
+
? Enter the Prisma field name to use as the login username: email
|
|
47
|
+
? Would you like to use Strict Routing? No
|
|
67
48
|
```
|
|
68
49
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
**Database Providers:**
|
|
72
|
-
|
|
73
|
-
- PostgreSQL (recommended for production)
|
|
74
|
-
- MongoDB
|
|
75
|
-
- MySQL
|
|
76
|
-
- SQLite (great for prototyping)
|
|
77
|
-
- SQL Server
|
|
78
|
-
- CockroachDB
|
|
79
|
-
|
|
80
|
-
**Validation Libraries:**
|
|
81
|
-
|
|
82
|
-
- **Zod** - TypeScript-first schema validation
|
|
83
|
-
- **class-validator** - Decorator-based validation
|
|
84
|
-
|
|
85
|
-
**Authentication Types:**
|
|
86
|
-
|
|
87
|
-
- **Dynamic** - Database-level auth with roles and permissions tables
|
|
88
|
-
- **Static** - File-based configuration for simpler projects
|
|
89
|
-
- **Define Later** - Skip for now, add when ready
|
|
90
|
-
|
|
91
|
-
## From Scaffold to Running API
|
|
50
|
+
## From Zero to Running API
|
|
92
51
|
|
|
93
52
|
```bash
|
|
94
53
|
# 1. Create your project
|
|
@@ -100,101 +59,49 @@ cd my-project
|
|
|
100
59
|
# 3. Configure your database
|
|
101
60
|
# Edit .env with your DATABASE_URL
|
|
102
61
|
|
|
103
|
-
# 4.
|
|
62
|
+
# 4. Push the schema
|
|
104
63
|
npx prisma db push
|
|
105
64
|
|
|
106
65
|
# 5. Start building
|
|
107
66
|
npm run dev
|
|
108
67
|
```
|
|
109
68
|
|
|
110
|
-
|
|
69
|
+
Your API is now running at `http://localhost:8000` — OpenAPI at `/api/docs`.
|
|
70
|
+
|
|
71
|
+
## Configuration Options
|
|
72
|
+
|
|
73
|
+
**Database providers:** PostgreSQL · MongoDB · MySQL · SQLite · SQL Server · CockroachDB
|
|
111
74
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
75
|
+
**Validation:** Zod · class-validator
|
|
76
|
+
|
|
77
|
+
**Authentication types:**
|
|
78
|
+
|
|
79
|
+
- **Static** — file-based, roles defined in code via `ArkosPolicy`
|
|
80
|
+
- **Dynamic** — database-level, roles and permissions stored in tables
|
|
81
|
+
- **None** — skip for now, add when ready
|
|
115
82
|
|
|
116
83
|
## Generated Project Structure
|
|
117
84
|
|
|
118
85
|
```
|
|
119
|
-
my-
|
|
86
|
+
my-project/
|
|
120
87
|
├── prisma/
|
|
121
|
-
│ └── schema.prisma
|
|
88
|
+
│ └── schema.prisma
|
|
122
89
|
├── src/
|
|
90
|
+
│ ├── modules
|
|
123
91
|
│ ├── utils/
|
|
124
92
|
│ │ └── prisma/
|
|
125
|
-
│ │ └── index.ts
|
|
126
|
-
│
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
├── .env # Environment variables
|
|
130
|
-
├── .gitignore
|
|
93
|
+
│ │ └── index.ts
|
|
94
|
+
│ └── app.ts
|
|
95
|
+
├── .env
|
|
96
|
+
├── arkos.config.ts
|
|
131
97
|
├── package.json
|
|
132
|
-
└── tsconfig.json
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## Environment Setup
|
|
136
|
-
|
|
137
|
-
Example `.env` configurations for different databases:
|
|
138
|
-
|
|
139
|
-
```env
|
|
140
|
-
# PostgreSQL (recommended for production)
|
|
141
|
-
DATABASE_URL="postgresql://username:password@localhost:5432/mydb"
|
|
142
|
-
|
|
143
|
-
# MongoDB
|
|
144
|
-
DATABASE_URL="mongodb://localhost:27017/mydb"
|
|
145
|
-
|
|
146
|
-
# MySQL
|
|
147
|
-
DATABASE_URL="mysql://username:password@localhost:3306/mydb"
|
|
148
|
-
|
|
149
|
-
# SQLite (great for local development)
|
|
150
|
-
DATABASE_URL="file:./dev.db"
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
## Authentication Out of the Box
|
|
154
|
-
|
|
155
|
-
### Dynamic Authentication (Recommended)
|
|
156
|
-
|
|
157
|
-
Perfect for apps that need user management and role-based access:
|
|
158
|
-
|
|
159
|
-
- `auth-role` table for managing roles
|
|
160
|
-
- `auth-permission` table for granular permissions
|
|
161
|
-
- Multi-role support
|
|
162
|
-
- Database-level flexibility
|
|
163
|
-
|
|
164
|
-
### Static Authentication
|
|
165
|
-
|
|
166
|
-
Great for simpler projects or when roles are predefined:
|
|
167
|
-
|
|
168
|
-
- Configuration file-based
|
|
169
|
-
- Faster setup
|
|
170
|
-
- Easy to understand and modify
|
|
171
|
-
|
|
172
|
-
## Next Steps
|
|
173
|
-
|
|
174
|
-
Once your project is created:
|
|
175
|
-
|
|
176
|
-
1. **Define your data models** in `prisma/schema.prisma`
|
|
177
|
-
2. **Run migrations** with `npx prisma db push`
|
|
178
|
-
3. **Start coding** - Arkos handles the CRUD operations automatically
|
|
179
|
-
4. **Add custom logic** with interceptors when needed
|
|
180
|
-
|
|
181
|
-
```bash
|
|
182
|
-
# Generate CRUD for a new model
|
|
183
|
-
arkos generate posts -m Post
|
|
184
|
-
|
|
185
|
-
# Start development
|
|
186
|
-
npm run dev
|
|
187
|
-
|
|
188
|
-
# Build for production
|
|
189
|
-
npm run build
|
|
98
|
+
└── tsconfig.json
|
|
190
99
|
```
|
|
191
100
|
|
|
192
|
-
##
|
|
193
|
-
|
|
194
|
-
Try our canary releases for the latest features:
|
|
101
|
+
## Getting Nightly Updates
|
|
195
102
|
|
|
196
103
|
```bash
|
|
197
|
-
pnpm create arkos@
|
|
104
|
+
pnpm create arkos@next my-project
|
|
198
105
|
```
|
|
199
106
|
|
|
200
107
|
## Requirements
|
|
@@ -202,36 +109,32 @@ pnpm create arkos@canary my-project
|
|
|
202
109
|
- Node.js 20 or higher
|
|
203
110
|
- npm, yarn, or pnpm
|
|
204
111
|
|
|
205
|
-
##
|
|
206
|
-
|
|
207
|
-
- **Documentation:** [arkosjs.com/docs](https://arkosjs.com/docs/intro)
|
|
208
|
-
- **Main Framework:** [github.com/uanela/arkos](https://github.com/uanela/arkos)
|
|
209
|
-
- **Community:** [Join our WhatsApp group](https://chat.whatsapp.com/EJ8cjb9hxau0EcOnI4fdpD)
|
|
210
|
-
- **Examples:** [arkosjs.com/docs/examples](https://arkosjs.com/docs/examples)
|
|
211
|
-
|
|
212
|
-
## Support
|
|
112
|
+
## Support & Contributing
|
|
213
113
|
|
|
114
|
+
- **Documentation:** [arkosjs.com/docs](https://arkosjs.com/docs)
|
|
214
115
|
- **Bug Reports:** [GitHub Issues](https://github.com/uanela/arkos/issues)
|
|
215
116
|
- **Feature Requests:** Open a GitHub issue
|
|
216
|
-
- **
|
|
117
|
+
- **Contact:** [uanelaluiswayne@gmail.com](mailto:uanelaluiswayne@gmail.com)
|
|
217
118
|
|
|
218
|
-
|
|
119
|
+
Contributions are welcome! We appreciate all contributions, from bug fixes to new features.
|
|
219
120
|
|
|
220
|
-
|
|
121
|
+
## License
|
|
221
122
|
|
|
222
|
-
|
|
123
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
223
124
|
|
|
224
125
|
<div align="center">
|
|
225
126
|
|
|
226
|
-
**[
|
|
127
|
+
**[Installation](https://www.arkosjs.com/docs/getting-started/installation)** •
|
|
128
|
+
**[Documentation](https://arkosjs.com/docs)** •
|
|
227
129
|
**[Website](https://arkosjs.com)** •
|
|
130
|
+
**[Tutorial](https://arkosjs.com/learn)** •
|
|
228
131
|
**[GitHub](https://github.com/uanela/arkos)** •
|
|
229
|
-
**[
|
|
132
|
+
**[Blog](https://www.arkosjs.com/blog)** •
|
|
133
|
+
**[Npm](https://www.npmjs.com/package/create-arkos)**
|
|
230
134
|
|
|
231
135
|
Built with ❤️ by [Uanela Como](https://github.com/uanela) and contributors
|
|
232
136
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
_From the Greek "ἀρχή" (Arkhē) - meaning "beginning" - your foundation for Express and Prisma backend development_
|
|
137
|
+
_The name "Arkos" comes from the Greek word "ἀρχή" (Arkhē), meaning "beginning" or "foundation", reflecting our goal of providing a solid foundation for backend development._
|
|
236
138
|
|
|
237
139
|
</div>
|
|
140
|
+
```
|
|
@@ -21,6 +21,9 @@ class ProjectConfigInquirer {
|
|
|
21
21
|
this.config.projectPath = path.resolve(process.cwd(), this.config.projectName);
|
|
22
22
|
if (process?.argv?.includes?.("--advanced"))
|
|
23
23
|
this.config.advanced = true;
|
|
24
|
+
if (this.config.prisma.defaultDatabaseUrl)
|
|
25
|
+
this.config.prisma.defaultDatabaseUrl =
|
|
26
|
+
this.config.prisma.defaultDatabaseUrl.replaceAll("{{projectName}}", this.config.projectName);
|
|
24
27
|
return this.config;
|
|
25
28
|
}
|
|
26
29
|
async promptProjectName() {
|
|
@@ -77,7 +80,7 @@ class ProjectConfigInquirer {
|
|
|
77
80
|
type: "confirm",
|
|
78
81
|
name: "typescript",
|
|
79
82
|
message: `Would you like to use ${chalk.cyan("TypeScript")}?`,
|
|
80
|
-
default:
|
|
83
|
+
default: true,
|
|
81
84
|
},
|
|
82
85
|
]);
|
|
83
86
|
this.config.typescript = typescript;
|
|
@@ -100,124 +103,115 @@ class ProjectConfigInquirer {
|
|
|
100
103
|
},
|
|
101
104
|
]);
|
|
102
105
|
let idDatabaseType;
|
|
103
|
-
let
|
|
106
|
+
let defaultDatabaseUrl;
|
|
104
107
|
switch (prismaProvider) {
|
|
105
108
|
case "mongodb":
|
|
106
109
|
idDatabaseType = '@id @default(auto()) @map("_id") @db.ObjectId';
|
|
107
|
-
|
|
110
|
+
defaultDatabaseUrl = `mongodb://localhost:27017/{{projectName}}`;
|
|
108
111
|
break;
|
|
109
112
|
case "sqlite":
|
|
110
113
|
idDatabaseType = "@id @default(cuid())";
|
|
111
|
-
|
|
114
|
+
defaultDatabaseUrl = "file:../../file.db";
|
|
112
115
|
break;
|
|
113
116
|
case "mysql":
|
|
114
117
|
idDatabaseType = "@id @default(uuid())";
|
|
115
|
-
|
|
118
|
+
defaultDatabaseUrl = `mysql://username:password@localhost:3306/{{projectName}}`;
|
|
116
119
|
break;
|
|
117
120
|
case "postgresql":
|
|
118
121
|
idDatabaseType = "@id @default(uuid())";
|
|
119
|
-
|
|
122
|
+
defaultDatabaseUrl = `postgresql://username:password@localhost:5432/{{projectName}}`;
|
|
120
123
|
break;
|
|
121
124
|
case "sqlserver":
|
|
122
125
|
idDatabaseType = "@id @default(uuid())";
|
|
123
|
-
|
|
126
|
+
defaultDatabaseUrl = `sqlserver://localhost:1433;database={{projectName}};username=sa;password=password;encrypt=DANGER_PLAINTEXT`;
|
|
124
127
|
break;
|
|
125
128
|
case "cockroachdb":
|
|
126
129
|
idDatabaseType = "@id @default(uuid())";
|
|
127
|
-
|
|
130
|
+
defaultDatabaseUrl = `postgresql://username:password@localhost:26257/{{projectName}}?sslmode=require`;
|
|
128
131
|
break;
|
|
129
132
|
default:
|
|
130
133
|
idDatabaseType = "@id @default(uuid())";
|
|
131
|
-
|
|
134
|
+
defaultDatabaseUrl = `postgresql://username:password@localhost:5432/{{projectName}}`;
|
|
132
135
|
}
|
|
133
136
|
this.config.prisma = {
|
|
134
137
|
provider: prismaProvider,
|
|
135
|
-
idDatabaseType
|
|
136
|
-
|
|
138
|
+
idDatabaseType,
|
|
139
|
+
defaultDatabaseUrl,
|
|
137
140
|
};
|
|
138
141
|
}
|
|
139
142
|
async promptValidation() {
|
|
140
|
-
const
|
|
143
|
+
const choices = this.config.typescript
|
|
144
|
+
? ["zod", "class-validator", "none"]
|
|
145
|
+
: ["zod", "none"];
|
|
146
|
+
const { validationType } = await inquirer.prompt([
|
|
141
147
|
{
|
|
142
|
-
type: "
|
|
143
|
-
name: "
|
|
144
|
-
message: `
|
|
145
|
-
|
|
148
|
+
type: "list",
|
|
149
|
+
name: "validationType",
|
|
150
|
+
message: `Which ${chalk.cyan("Validation")} library would you like to use?`,
|
|
151
|
+
choices,
|
|
152
|
+
default: "zod",
|
|
146
153
|
},
|
|
147
154
|
]);
|
|
148
|
-
if (
|
|
149
|
-
let validationTypeResponse = { validationType: "zod" };
|
|
150
|
-
if (this.config.typescript)
|
|
151
|
-
validationTypeResponse = await inquirer.prompt([
|
|
152
|
-
{
|
|
153
|
-
type: "list",
|
|
154
|
-
name: "validationType",
|
|
155
|
-
message: "Choose validation library:",
|
|
156
|
-
choices: ["zod", "class-validator"],
|
|
157
|
-
},
|
|
158
|
-
]);
|
|
159
|
-
else {
|
|
160
|
-
console.info(chalk.bold(`${chalk.greenBright("?")} Validation library set to zod (class-validator is not supported on JavaScript):`), chalk.cyan("zod"));
|
|
161
|
-
}
|
|
155
|
+
if (validationType !== "none") {
|
|
162
156
|
this.config.validation = {
|
|
163
|
-
type:
|
|
157
|
+
type: validationType,
|
|
164
158
|
};
|
|
165
159
|
}
|
|
166
|
-
else if (!this.config.typescript) {
|
|
167
|
-
}
|
|
168
160
|
}
|
|
169
161
|
async promptAuthentication() {
|
|
170
|
-
if (this.config.prisma.provider === "none")
|
|
171
|
-
|
|
172
|
-
|
|
162
|
+
if (this.config.prisma.provider === "none") {
|
|
163
|
+
console.info(`Skipping authentication setup as it requires prisma.`);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const { authenticationType } = await inquirer.prompt([
|
|
173
167
|
{
|
|
174
|
-
type: "
|
|
175
|
-
name: "
|
|
176
|
-
message: `
|
|
177
|
-
|
|
168
|
+
type: "list",
|
|
169
|
+
name: "authenticationType",
|
|
170
|
+
message: `Which ${chalk.cyan("Authentication")} mode would you like to use?`,
|
|
171
|
+
choices: ["static", "dynamic", "none"],
|
|
172
|
+
default: "static",
|
|
178
173
|
},
|
|
179
174
|
]);
|
|
180
|
-
if (
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
175
|
+
if (authenticationType === "none") {
|
|
176
|
+
this.config.authentication = { type: "none", multipleRoles: false };
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const { usernameField } = await inquirer.prompt([
|
|
180
|
+
{
|
|
181
|
+
type: "input",
|
|
182
|
+
name: "usernameField",
|
|
183
|
+
message: "Enter the Prisma field name to use as the login username:",
|
|
184
|
+
default: "email",
|
|
185
|
+
validate: (input) => {
|
|
186
|
+
if (!input || input.length === 0)
|
|
187
|
+
return "Field name cannot be empty";
|
|
188
|
+
if (!/^[a-z][a-zA-Z0-9]*$/.test(input))
|
|
189
|
+
return "Must be a valid Prisma field name (camelCase, starts with lowercase, letters and numbers only)";
|
|
190
|
+
return true;
|
|
187
191
|
},
|
|
188
|
-
|
|
189
|
-
|
|
192
|
+
},
|
|
193
|
+
]);
|
|
194
|
+
this.config.authentication = {
|
|
195
|
+
type: authenticationType,
|
|
196
|
+
usernameField,
|
|
197
|
+
multipleRoles: false,
|
|
198
|
+
};
|
|
199
|
+
if (authenticationType !== "static" &&
|
|
200
|
+
this.config.prisma.provider !== "sqlite") {
|
|
201
|
+
const { multipleRoles } = await inquirer.prompt([
|
|
190
202
|
{
|
|
191
|
-
type: "
|
|
192
|
-
name: "
|
|
193
|
-
|
|
194
|
-
|
|
203
|
+
type: "confirm",
|
|
204
|
+
name: "multipleRoles",
|
|
205
|
+
default: true,
|
|
206
|
+
message: `Would you like to use authentication with ${chalk.cyan("Multiple Roles")}?`,
|
|
195
207
|
},
|
|
196
208
|
]);
|
|
197
209
|
this.config.authentication = {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
multipleRoles: false,
|
|
210
|
+
...this.config.authentication,
|
|
211
|
+
multipleRoles,
|
|
201
212
|
};
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
authenticationType !== "static") {
|
|
205
|
-
const { multipleRoles } = await inquirer.prompt([
|
|
206
|
-
{
|
|
207
|
-
type: "confirm",
|
|
208
|
-
name: "multipleRoles",
|
|
209
|
-
default: true,
|
|
210
|
-
message: `Would you like to use authentication with ${chalk.cyan("Multiple Roles")}?`,
|
|
211
|
-
},
|
|
212
|
-
]);
|
|
213
|
-
this.config.authentication = {
|
|
214
|
-
...this.config.authentication,
|
|
215
|
-
multipleRoles,
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
else if (this.config.prisma.provider === "sqlite") {
|
|
219
|
-
console.info(`Skipping multiple roles option because it is not supported with sqlite prisma provider and static authentication mode.`);
|
|
220
|
-
}
|
|
213
|
+
}
|
|
214
|
+
else if (this.config.prisma.provider === "sqlite") {
|
|
221
215
|
}
|
|
222
216
|
}
|
|
223
217
|
async promptStrictRouting() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-config-inquirer.js","sourceRoot":"","sources":["../../src/utils/project-config-inquirer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAiC1B,MAAM,qBAAqB;IACjB,MAAM,CAAgB;IAE9B;QACE,IAAI,CAAC,MAAM,GAAG,EAAmB,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC/B,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9B,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAClC,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9B,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAClC,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAEjC,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,KAAK,GAAG,EAAE;YACnC,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;YACvD,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;SACvD;;YACC,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CACpC,OAAO,CAAC,GAAG,EAAE,EACb,IAAI,CAAC,MAAM,CAAC,WAAW,CACxB,CAAC;QAEJ,IAAI,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,YAAY,CAAC;YAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;QAEzE,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,CAAC,MAAM,CAAC;YAC9C;gBACE,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,yBAAyB,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG;gBACjE,OAAO,EAAE,KAAK;aACf;SACF,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG;YACpB,MAAM,EAAE,aAAa;SACtB,CAAC;IACJ,CAAC;CACF;AAED,MAAM,qBAAqB,GAAG,IAAI,qBAAqB,EAAE,CAAC;AAE1D,eAAe,qBAAqB,CAAC","sourcesContent":["import path from \"path\";\nimport inquirer from \"inquirer\";\nimport chalk from \"chalk\";\n\nexport interface ProjectConfig {\n projectName: string;\n argProjectName?: 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 | \"none\";\n idDatabaseType: string;\n defaultDBurl: string;\n };\n projectPath: string;\n routing?: {\n strict?: boolean;\n };\n advanced?: boolean;\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 await this.promptStrictRouting();\n\n if (this.config.projectName === \".\") {\n this.config.projectName = path.basename(process.cwd());\n this.config.projectPath = path.resolve(process.cwd());\n } else\n this.config.projectPath = path.resolve(\n process.cwd(),\n this.config.projectName\n );\n\n if (process?.argv?.includes?.(\"--advanced\")) this.config.advanced = true;\n\n return this.config;\n }\n\n private async promptProjectName() {\n let projectName = process?.argv?.[2];\n this.config.argProjectName = 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: 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(`\\nError: ${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 === \".\") return true;\n\n if (!input || input.length === 0) {\n return \"Project name cannot be empty\";\n }\n\n if (!/^[a-zA-Z0-9_-]+$/.test(input)) {\n return \"Project name can only contain letters, numbers, hyphens, and underscores\";\n }\n\n if (!/^[a-zA-Z0-9]/.test(input)) {\n return \"Project name must start with a letter or number\";\n }\n\n if (!/[a-zA-Z0-9]$/.test(input)) {\n return \"Project name must end with a letter or number\";\n }\n\n if (input.length > 50) {\n return \"Project name must be 50 characters or less\";\n }\n\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 \"none\",\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 let validationTypeResponse: {\n validationType: \"zod\" | \"class-validator\";\n } = { validationType: \"zod\" };\n\n if (this.config.typescript)\n validationTypeResponse = await inquirer.prompt([\n {\n type: \"list\",\n name: \"validationType\",\n message: \"Choose validation library:\",\n choices: [\"zod\", \"class-validator\"],\n },\n ]);\n else {\n console.info(\n chalk.bold(\n `${chalk.greenBright(\"?\")} Validation library set to zod (class-validator is not supported on JavaScript):`\n ),\n chalk.cyan(\"zod\")\n );\n }\n this.config.validation = {\n type: validationTypeResponse.validationType,\n };\n } else if (!this.config.typescript) {\n }\n }\n\n private async promptAuthentication() {\n if (this.config.prisma.provider === \"none\")\n return console.info(\n `Skipping authentication setup as it requires prisma.`\n );\n\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\"],\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: false,\n };\n\n if (\n authenticationType !== \"define later\" &&\n this.config.prisma.provider !== \"sqlite\" &&\n authenticationType !== \"static\"\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 this.config.authentication = {\n ...this.config.authentication,\n multipleRoles,\n };\n } else if (this.config.prisma.provider === \"sqlite\") {\n console.info(\n `Skipping multiple roles option because it is not supported with sqlite prisma provider and static authentication mode.`\n );\n }\n }\n }\n\n private async promptStrictRouting() {\n const { strictRouting } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"strictRouting\",\n message: `Would you like to use ${chalk.cyan(\"Strict Routing\")}?`,\n default: false,\n },\n ]);\n this.config.routing = {\n strict: strictRouting,\n };\n }\n}\n\nconst projectConfigInquirer = new ProjectConfigInquirer();\n\nexport default projectConfigInquirer;\n"]}
|
|
1
|
+
{"version":3,"file":"project-config-inquirer.js","sourceRoot":"","sources":["../../src/utils/project-config-inquirer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAiC1B,MAAM,qBAAqB;IACj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AM,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,EACxC;YACA,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;gBAC9C;oBACE,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,eAAe;oBACrB,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE,6CAA6C,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG;iBACtF;aACF,CAAC,CAAC;YAEH,IAAI,CAAC,MAAM,CAAC,cAAc,GAAG;gBAC3B,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc;gBAC7B,aAAa;aACd,CAAC;SACH;aAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE;SAIpD;IACH,CAAC;IAEO,KAAK,CAAC,mBAAmB;QAC/B,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;YAC9C;gBACE,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,yBAAyB,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG;gBACjE,OAAO,EAAE,KAAK;aACf;SACF,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG;YACpB,MAAM,EAAE,aAAa;SACtB,CAAC;IACJ,CAAC;CACF;AAED,MAAM,qBAAqB,GAAG,IAAI,qBAAqB,EAAE,CAAC;AAE1D,eAAe,qBAAqB,CAAC","sourcesContent":["import path from \"path\";\nimport inquirer from \"inquirer\";\nimport chalk from \"chalk\";\n\nexport interface ProjectConfig {\n projectName: string;\n argProjectName?: string;\n typescript: boolean;\n validation?: {\n type?: \"zod\" | \"class-validator\";\n };\n authentication?: {\n type?: \"static\" | \"dynamic\" | \"none\";\n usernameField?: string;\n multipleRoles: boolean;\n };\n prisma: {\n provider:\n | \"postgresql\"\n | \"mysql\"\n | \"sqlite\"\n | \"sqlserver\"\n | \"cockroachdb\"\n | \"mongodb\"\n | \"none\";\n idDatabaseType: string;\n defaultDatabaseUrl: string;\n };\n projectPath: string;\n routing?: {\n strict?: boolean;\n };\n advanced?: boolean;\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 await this.promptStrictRouting();\n\n if (this.config.projectName === \".\") {\n this.config.projectName = path.basename(process.cwd());\n this.config.projectPath = path.resolve(process.cwd());\n } else\n this.config.projectPath = path.resolve(\n process.cwd(),\n this.config.projectName\n );\n\n if (process?.argv?.includes?.(\"--advanced\")) this.config.advanced = true;\n if (this.config.prisma.defaultDatabaseUrl)\n this.config.prisma.defaultDatabaseUrl =\n this.config.prisma.defaultDatabaseUrl.replaceAll(\n \"{{projectName}}\",\n this.config.projectName\n );\n\n return this.config;\n }\n\n private async promptProjectName() {\n let projectName = process?.argv?.[2];\n this.config.argProjectName = 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: this.validateProjectName,\n },\n ]);\n projectName = result.projectName;\n } else {\n const validation = this.validateProjectName(projectName);\n if (validation !== true) {\n console.error(chalk.red(`\\nError: ${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 === \".\") return true;\n\n if (!input || input.length === 0) {\n return \"Project name cannot be empty\";\n }\n\n if (!/^[a-zA-Z0-9_-]+$/.test(input)) {\n return \"Project name can only contain letters, numbers, hyphens, and underscores\";\n }\n\n if (!/^[a-zA-Z0-9]/.test(input)) {\n return \"Project name must start with a letter or number\";\n }\n\n if (!/[a-zA-Z0-9]$/.test(input)) {\n return \"Project name must end with a letter or number\";\n }\n\n if (input.length > 50) {\n return \"Project name must be 50 characters or less\";\n }\n\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: true,\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 \"none\",\n ],\n },\n ]);\n\n let idDatabaseType: string;\n let defaultDatabaseUrl: string;\n\n switch (prismaProvider) {\n case \"mongodb\":\n idDatabaseType = '@id @default(auto()) @map(\"_id\") @db.ObjectId';\n defaultDatabaseUrl = `mongodb://localhost:27017/{{projectName}}`;\n break;\n case \"sqlite\":\n idDatabaseType = \"@id @default(cuid())\";\n defaultDatabaseUrl = \"file:../../file.db\";\n break;\n case \"mysql\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDatabaseUrl = `mysql://username:password@localhost:3306/{{projectName}}`;\n break;\n case \"postgresql\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDatabaseUrl = `postgresql://username:password@localhost:5432/{{projectName}}`;\n break;\n case \"sqlserver\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDatabaseUrl = `sqlserver://localhost:1433;database={{projectName}};username=sa;password=password;encrypt=DANGER_PLAINTEXT`;\n break;\n case \"cockroachdb\":\n idDatabaseType = \"@id @default(uuid())\";\n defaultDatabaseUrl = `postgresql://username:password@localhost:26257/{{projectName}}?sslmode=require`;\n break;\n default:\n idDatabaseType = \"@id @default(uuid())\";\n defaultDatabaseUrl = `postgresql://username:password@localhost:5432/{{projectName}}`;\n }\n\n this.config.prisma = {\n provider: prismaProvider,\n idDatabaseType,\n defaultDatabaseUrl,\n };\n }\n\n private async promptValidation() {\n // For JS projects, class-validator is not supported — skip the choice\n const choices = this.config.typescript\n ? [\"zod\", \"class-validator\", \"none\"]\n : [\"zod\", \"none\"];\n\n const { validationType } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"validationType\",\n message: `Which ${chalk.cyan(\"Validation\")} library would you like to use?`,\n choices,\n default: \"zod\",\n },\n ]);\n\n if (validationType !== \"none\") {\n this.config.validation = {\n type: validationType as \"zod\" | \"class-validator\",\n };\n }\n // validation stays undefined when \"none\" is chosen — matches original behaviour\n }\n\n private async promptAuthentication() {\n if (this.config.prisma.provider === \"none\") {\n console.info(`Skipping authentication setup as it requires prisma.`);\n return;\n }\n\n const { authenticationType } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"authenticationType\",\n message: `Which ${chalk.cyan(\"Authentication\")} mode would you like to use?`,\n choices: [\"static\", \"dynamic\", \"none\"],\n default: \"static\",\n },\n ]);\n\n if (authenticationType === \"none\") {\n this.config.authentication = { type: \"none\", multipleRoles: false };\n return;\n }\n\n const { usernameField } = await inquirer.prompt([\n {\n type: \"input\",\n name: \"usernameField\",\n message: \"Enter the Prisma field name to use as the login username:\",\n default: \"email\",\n validate: (input: string) => {\n if (!input || input.length === 0) return \"Field name cannot be empty\";\n if (!/^[a-z][a-zA-Z0-9]*$/.test(input))\n return \"Must be a valid Prisma field name (camelCase, starts with lowercase, letters and numbers only)\";\n return true;\n },\n },\n ]);\n\n this.config.authentication = {\n type: authenticationType as \"static\" | \"dynamic\",\n usernameField,\n multipleRoles: false,\n };\n\n if (\n authenticationType !== \"static\" &&\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 this.config.authentication = {\n ...this.config.authentication,\n multipleRoles,\n };\n } else if (this.config.prisma.provider === \"sqlite\") {\n // console.info(\n // `Skipping multiple roles option because it is not supported with sqlite prisma provider and static authentication mode.`\n // );\n }\n }\n\n private async promptStrictRouting() {\n const { strictRouting } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"strictRouting\",\n message: `Would you like to use ${chalk.cyan(\"Strict Routing\")}?`,\n default: false,\n },\n ]);\n this.config.routing = {\n strict: strictRouting,\n };\n }\n}\n\nconst projectConfigInquirer = new ProjectConfigInquirer();\n\nexport default projectConfigInquirer;\n"]}
|
|
@@ -50,12 +50,16 @@ class TemplateCompiler {
|
|
|
50
50
|
"auth.query.ts.hbs",
|
|
51
51
|
];
|
|
52
52
|
const authPermissionModuleComponents = [
|
|
53
|
-
"auth-permission.
|
|
53
|
+
"auth-permission.router.ts.hbs",
|
|
54
|
+
"auth-permission.policy.ts.hbs",
|
|
55
|
+
"auth-permission.query.ts.hbs",
|
|
54
56
|
"auth-permission.query.ts.hbs",
|
|
55
57
|
"auth-permission.service.ts.hbs",
|
|
56
58
|
];
|
|
57
59
|
const authRoleModuleComponents = [
|
|
58
|
-
"auth-role.
|
|
60
|
+
"auth-role.router.ts.hbs",
|
|
61
|
+
"auth-role.policy.ts.hbs",
|
|
62
|
+
"auth-role.query.ts.hbs",
|
|
59
63
|
"auth-role.query.ts.hbs",
|
|
60
64
|
"auth-role.service.ts.hbs",
|
|
61
65
|
];
|
|
@@ -63,17 +67,17 @@ class TemplateCompiler {
|
|
|
63
67
|
"user.interceptors.ts.hbs",
|
|
64
68
|
"user.query.ts.hbs",
|
|
65
69
|
"user.service.ts.hbs",
|
|
66
|
-
"user.
|
|
70
|
+
"user.router.ts.hbs",
|
|
71
|
+
"user.policy.ts.hbs",
|
|
67
72
|
];
|
|
68
73
|
if (config.prisma?.provider === "none")
|
|
69
74
|
files.push(...authSharedPrismaFiles, ...dynamicAuthPrismaFiles, "schema.prisma.hbs", ...sharedAuthZodSchemaFiles, ...dynamicAuthZodSchemaFiles, ...sharedAuthClassValidatorDtoFiles, ...dynamicAuthClassValidatorDtoFiles, ...userModuleComponents, ...authModuleComponents, ...authPermissionModuleComponents, ...authRoleModuleComponents, ...userZodSchemaFiles, ...userClassValidatorDtoFiles, "file-upload.auth.ts.hbs", "index.ts.hbs");
|
|
70
|
-
if (!config.authentication?.type ||
|
|
71
|
-
|
|
72
|
-
files.push(...authSharedPrismaFiles, ...dynamicAuthPrismaFiles, ...sharedAuthZodSchemaFiles, ...dynamicAuthZodSchemaFiles, ...sharedAuthClassValidatorDtoFiles, ...dynamicAuthClassValidatorDtoFiles, ...userModuleComponents, ...authModuleComponents, ...authPermissionModuleComponents, ...authRoleModuleComponents, ...userZodSchemaFiles, ...userClassValidatorDtoFiles, "file-upload.auth.ts.hbs");
|
|
75
|
+
if (!config.authentication?.type || config.authentication?.type === "none")
|
|
76
|
+
files.push(...authSharedPrismaFiles, ...dynamicAuthPrismaFiles, ...sharedAuthZodSchemaFiles, ...dynamicAuthZodSchemaFiles, ...sharedAuthClassValidatorDtoFiles, ...dynamicAuthClassValidatorDtoFiles, ...userModuleComponents, ...authModuleComponents, ...authPermissionModuleComponents, ...authRoleModuleComponents, ...userZodSchemaFiles, ...userClassValidatorDtoFiles, "file-upload.router.ts.hbs", "file-upload.policy.ts.hbs");
|
|
73
77
|
if (config.authentication?.type === "static")
|
|
74
78
|
files.push(...dynamicAuthPrismaFiles, ...dynamicAuthZodSchemaFiles, ...dynamicAuthClassValidatorDtoFiles, ...authPermissionModuleComponents, ...authRoleModuleComponents);
|
|
75
79
|
if (config.validation?.type !== "zod")
|
|
76
|
-
files.push(...sharedAuthZodSchemaFiles, ...dynamicAuthZodSchemaFiles, ...userZodSchemaFiles);
|
|
80
|
+
files.push(...sharedAuthZodSchemaFiles, ...dynamicAuthZodSchemaFiles, ...userZodSchemaFiles, "api-actions.hbs.ts");
|
|
77
81
|
if (config.validation?.type !== "class-validator")
|
|
78
82
|
files.push(...sharedAuthClassValidatorDtoFiles, ...dynamicAuthClassValidatorDtoFiles, ...userClassValidatorDtoFiles);
|
|
79
83
|
if (!config.typescript)
|