@opensaas/stack-cli 0.1.0
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/.turbo/turbo-build.log +4 -0
- package/README.md +328 -0
- package/bin/opensaas.js +3 -0
- package/dist/commands/dev.d.ts +2 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +40 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/generate.d.ts +2 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +90 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +343 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/generator/context.d.ts +13 -0
- package/dist/generator/context.d.ts.map +1 -0
- package/dist/generator/context.js +69 -0
- package/dist/generator/context.js.map +1 -0
- package/dist/generator/index.d.ts +5 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +5 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/prisma.d.ts +10 -0
- package/dist/generator/prisma.d.ts.map +1 -0
- package/dist/generator/prisma.js +129 -0
- package/dist/generator/prisma.js.map +1 -0
- package/dist/generator/type-patcher.d.ts +13 -0
- package/dist/generator/type-patcher.d.ts.map +1 -0
- package/dist/generator/type-patcher.js +68 -0
- package/dist/generator/type-patcher.js.map +1 -0
- package/dist/generator/types.d.ts +10 -0
- package/dist/generator/types.d.ts.map +1 -0
- package/dist/generator/types.js +225 -0
- package/dist/generator/types.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
- package/src/commands/dev.ts +48 -0
- package/src/commands/generate.ts +103 -0
- package/src/commands/init.ts +367 -0
- package/src/generator/context.ts +75 -0
- package/src/generator/index.ts +4 -0
- package/src/generator/prisma.ts +157 -0
- package/src/generator/type-patcher.ts +93 -0
- package/src/generator/types.ts +263 -0
- package/src/index.ts +34 -0
- package/tsconfig.json +13 -0
- package/tsconfig.tsbuildinfo +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
# @opensaas/stack-cli
|
|
2
|
+
|
|
3
|
+
Command-line tools for OpenSaas Stack - code generation and development utilities.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add -D @opensaas/stack-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Commands
|
|
12
|
+
|
|
13
|
+
### `opensaas generate`
|
|
14
|
+
|
|
15
|
+
Generate Prisma schema and TypeScript types from your `opensaas.config.ts`.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
opensaas generate
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**What it does:**
|
|
22
|
+
|
|
23
|
+
1. Reads `opensaas.config.ts` from current directory
|
|
24
|
+
2. Generates `prisma/schema.prisma` - Prisma schema
|
|
25
|
+
3. Generates `.opensaas/types.ts` - TypeScript types
|
|
26
|
+
4. Outputs success message with next steps
|
|
27
|
+
|
|
28
|
+
**Output:**
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
š OpenSaas Generator
|
|
32
|
+
- Loading configuration...
|
|
33
|
+
ā Generation complete
|
|
34
|
+
ā
Prisma schema generated
|
|
35
|
+
ā
TypeScript types generated
|
|
36
|
+
⨠Generation complete!
|
|
37
|
+
|
|
38
|
+
Next steps:
|
|
39
|
+
1. Run: npx prisma generate
|
|
40
|
+
2. Run: npx prisma db push
|
|
41
|
+
3. Start using your generated types!
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Example package.json script:**
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"scripts": {
|
|
49
|
+
"generate": "opensaas generate"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### `opensaas dev`
|
|
55
|
+
|
|
56
|
+
Watch `opensaas.config.ts` and automatically regenerate on changes.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
opensaas dev
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**What it does:**
|
|
63
|
+
|
|
64
|
+
1. Runs initial generation
|
|
65
|
+
2. Watches `opensaas.config.ts` for changes
|
|
66
|
+
3. Automatically regenerates when file changes
|
|
67
|
+
4. Runs until you press Ctrl+C
|
|
68
|
+
|
|
69
|
+
**Output:**
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
š OpenSaas Generator
|
|
73
|
+
- Loading configuration...
|
|
74
|
+
ā Generation complete
|
|
75
|
+
ā
Prisma schema generated
|
|
76
|
+
ā
TypeScript types generated
|
|
77
|
+
|
|
78
|
+
š Watching opensaas.config.ts for changes...
|
|
79
|
+
Press Ctrl+C to stop
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
When changes detected:
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
Config changed, regenerating...
|
|
86
|
+
|
|
87
|
+
š OpenSaas Generator
|
|
88
|
+
...
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Example package.json script:**
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"scripts": {
|
|
96
|
+
"dev": "opensaas dev"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### `opensaas init` (Coming Soon)
|
|
102
|
+
|
|
103
|
+
Create a new OpenSaas project with template.
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
opensaas init my-project
|
|
107
|
+
opensaas init my-project --template blog
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Usage in Projects
|
|
111
|
+
|
|
112
|
+
### Basic Setup
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Install CLI
|
|
116
|
+
pnpm add -D @opensaas/stack-cli
|
|
117
|
+
|
|
118
|
+
# Add scripts to package.json
|
|
119
|
+
{
|
|
120
|
+
"scripts": {
|
|
121
|
+
"generate": "opensaas generate",
|
|
122
|
+
"dev": "opensaas dev"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
# Generate code
|
|
127
|
+
pnpm generate
|
|
128
|
+
|
|
129
|
+
# Or watch for changes
|
|
130
|
+
pnpm dev
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Development Workflow
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# Terminal 1: Watch config and regenerate
|
|
137
|
+
pnpm dev
|
|
138
|
+
|
|
139
|
+
# Terminal 2: Run Next.js dev server
|
|
140
|
+
pnpm next dev
|
|
141
|
+
|
|
142
|
+
# Terminal 3: Watch Prisma Studio (optional)
|
|
143
|
+
pnpm db:studio
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### CI/CD Integration
|
|
147
|
+
|
|
148
|
+
```yaml
|
|
149
|
+
# .github/workflows/test.yml
|
|
150
|
+
name: Test
|
|
151
|
+
on: [push]
|
|
152
|
+
jobs:
|
|
153
|
+
test:
|
|
154
|
+
runs-on: ubuntu-latest
|
|
155
|
+
steps:
|
|
156
|
+
- uses: actions/checkout@v3
|
|
157
|
+
- uses: pnpm/action-setup@v2
|
|
158
|
+
- run: pnpm install
|
|
159
|
+
- run: pnpm generate
|
|
160
|
+
- run: npx prisma generate
|
|
161
|
+
- run: pnpm test
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Configuration
|
|
165
|
+
|
|
166
|
+
The CLI reads `opensaas.config.ts` from the current working directory.
|
|
167
|
+
|
|
168
|
+
**Example config:**
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
// opensaas.config.ts
|
|
172
|
+
import { config, list } from '@opensaas/stack-core'
|
|
173
|
+
import { text } from '@opensaas/stack-core/fields'
|
|
174
|
+
|
|
175
|
+
export default config({
|
|
176
|
+
db: {
|
|
177
|
+
provider: 'postgresql',
|
|
178
|
+
url: process.env.DATABASE_URL,
|
|
179
|
+
},
|
|
180
|
+
lists: {
|
|
181
|
+
Post: list({
|
|
182
|
+
fields: {
|
|
183
|
+
title: text(),
|
|
184
|
+
},
|
|
185
|
+
}),
|
|
186
|
+
},
|
|
187
|
+
})
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Output Files
|
|
191
|
+
|
|
192
|
+
### Prisma Schema (`prisma/schema.prisma`)
|
|
193
|
+
|
|
194
|
+
Generated Prisma schema with:
|
|
195
|
+
|
|
196
|
+
- Database provider configuration
|
|
197
|
+
- Models for each list
|
|
198
|
+
- Field types and modifiers
|
|
199
|
+
- Indexes
|
|
200
|
+
- Relationships
|
|
201
|
+
|
|
202
|
+
**Example output:**
|
|
203
|
+
|
|
204
|
+
```prisma
|
|
205
|
+
datasource db {
|
|
206
|
+
provider = "postgresql"
|
|
207
|
+
url = env("DATABASE_URL")
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
generator client {
|
|
211
|
+
provider = "prisma-client-js"
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
model Post {
|
|
215
|
+
id String @id @default(cuid())
|
|
216
|
+
title String
|
|
217
|
+
createdAt DateTime @default(now())
|
|
218
|
+
updatedAt DateTime @updatedAt
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### TypeScript Types (`.opensaas/types.ts`)
|
|
223
|
+
|
|
224
|
+
Generated TypeScript types for:
|
|
225
|
+
|
|
226
|
+
- List items
|
|
227
|
+
- Create/update input types
|
|
228
|
+
- Context types
|
|
229
|
+
|
|
230
|
+
**Example output:**
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
export type Post = {
|
|
234
|
+
id: string
|
|
235
|
+
title: string
|
|
236
|
+
createdAt: Date
|
|
237
|
+
updatedAt: Date
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export type PostCreateInput = {
|
|
241
|
+
title: string
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export type PostUpdateInput = {
|
|
245
|
+
title?: string
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Troubleshooting
|
|
250
|
+
|
|
251
|
+
### Config not found
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
Error: Could not find opensaas.config.ts
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**Solution:** Ensure you're running the command from the directory containing `opensaas.config.ts`.
|
|
258
|
+
|
|
259
|
+
### TypeScript errors in config
|
|
260
|
+
|
|
261
|
+
```
|
|
262
|
+
Error: Failed to load configuration
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
**Solution:** Check your `opensaas.config.ts` for TypeScript errors. The CLI uses `tsx` to execute the config.
|
|
266
|
+
|
|
267
|
+
### Permission errors
|
|
268
|
+
|
|
269
|
+
```
|
|
270
|
+
Error: EACCES: permission denied
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**Solution:** Ensure you have write permissions for `prisma/` and `.opensaas/` directories.
|
|
274
|
+
|
|
275
|
+
## Examples
|
|
276
|
+
|
|
277
|
+
### Generate after config changes
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
# Edit opensaas.config.ts
|
|
281
|
+
vim opensaas.config.ts
|
|
282
|
+
|
|
283
|
+
# Regenerate
|
|
284
|
+
pnpm generate
|
|
285
|
+
|
|
286
|
+
# Update database
|
|
287
|
+
pnpm db:push
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Watch mode during development
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
# Start watch mode
|
|
294
|
+
pnpm dev
|
|
295
|
+
|
|
296
|
+
# In another terminal, edit config
|
|
297
|
+
vim opensaas.config.ts
|
|
298
|
+
|
|
299
|
+
# Generator automatically reruns!
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## Integration with Prisma
|
|
303
|
+
|
|
304
|
+
After running `opensaas generate`:
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
# Generate Prisma Client
|
|
308
|
+
npx prisma generate
|
|
309
|
+
|
|
310
|
+
# Push schema to database
|
|
311
|
+
npx prisma db push
|
|
312
|
+
|
|
313
|
+
# Create migration
|
|
314
|
+
npx prisma migrate dev --name init
|
|
315
|
+
|
|
316
|
+
# Open Prisma Studio
|
|
317
|
+
npx prisma studio
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
## Learn More
|
|
321
|
+
|
|
322
|
+
- [Core Package](../core/README.md) - Config and field types
|
|
323
|
+
- [OpenSaas Stack](../../README.md) - Stack overview
|
|
324
|
+
- [Examples](../../examples) - Working examples
|
|
325
|
+
|
|
326
|
+
## License
|
|
327
|
+
|
|
328
|
+
MIT
|
package/bin/opensaas.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAMA,wBAAsB,UAAU,kBAyC/B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import chokidar from 'chokidar';
|
|
5
|
+
import { generateCommand } from './generate.js';
|
|
6
|
+
export async function devCommand() {
|
|
7
|
+
const cwd = process.cwd();
|
|
8
|
+
const configPath = path.join(cwd, 'opensaas.config.ts');
|
|
9
|
+
// Check if config exists
|
|
10
|
+
if (!fs.existsSync(configPath)) {
|
|
11
|
+
console.error(chalk.red('Error: opensaas.config.ts not found in current directory'));
|
|
12
|
+
console.error(chalk.gray(' Please run this command from your project root'));
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
console.log(chalk.bold.cyan('\nOpenSaas Dev Mode\n'));
|
|
16
|
+
console.log(chalk.gray('Watching for changes to opensaas.config.ts...\n'));
|
|
17
|
+
// Run initial generation
|
|
18
|
+
await generateCommand();
|
|
19
|
+
// Watch for changes
|
|
20
|
+
const watcher = chokidar.watch(configPath, {
|
|
21
|
+
persistent: true,
|
|
22
|
+
ignoreInitial: true,
|
|
23
|
+
});
|
|
24
|
+
watcher.on('change', async () => {
|
|
25
|
+
console.log(chalk.yellow('\nConfig changed, regenerating...\n'));
|
|
26
|
+
await generateCommand();
|
|
27
|
+
});
|
|
28
|
+
watcher.on('error', (error) => {
|
|
29
|
+
console.error(chalk.red('\nWatcher error:'), error);
|
|
30
|
+
});
|
|
31
|
+
// Keep the process running
|
|
32
|
+
console.log(chalk.gray('Press Ctrl+C to stop watching\n'));
|
|
33
|
+
// Handle graceful shutdown
|
|
34
|
+
process.on('SIGINT', () => {
|
|
35
|
+
console.log(chalk.yellow('\n\nStopping dev mode...'));
|
|
36
|
+
watcher.close();
|
|
37
|
+
process.exit(0);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/C,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IACzB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAA;IAEvD,yBAAyB;IACzB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC,CAAA;QACpF,OAAO,CAAC,KAAK,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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAcA,wBAAsB,eAAe,kBAwFpC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import { execSync } from 'child_process';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import ora from 'ora';
|
|
6
|
+
import { createJiti } from 'jiti';
|
|
7
|
+
import { writePrismaSchema, writeTypes, writeContext, patchPrismaTypes, } from '../generator/index.js';
|
|
8
|
+
export async function generateCommand() {
|
|
9
|
+
console.log(chalk.bold('\nš OpenSaas Generator\n'));
|
|
10
|
+
const cwd = process.cwd();
|
|
11
|
+
const configPath = path.join(cwd, 'opensaas.config.ts');
|
|
12
|
+
// Check if config exists
|
|
13
|
+
if (!fs.existsSync(configPath)) {
|
|
14
|
+
console.error(chalk.red('ā Error: opensaas.config.ts not found in current directory'));
|
|
15
|
+
console.error(chalk.gray(' Please run this command from your project root'));
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
const spinner = ora('Loading configuration...').start();
|
|
19
|
+
try {
|
|
20
|
+
// Load config using jiti (supports TypeScript)
|
|
21
|
+
const jiti = createJiti(cwd, {
|
|
22
|
+
interopDefault: true,
|
|
23
|
+
});
|
|
24
|
+
const config = (await jiti.import(configPath));
|
|
25
|
+
spinner.succeed(chalk.green('Configuration loaded'));
|
|
26
|
+
// Generate Prisma schema, types, and context
|
|
27
|
+
const generatorSpinner = ora('Generating schema and types...').start();
|
|
28
|
+
try {
|
|
29
|
+
writePrismaSchema(config, path.join(cwd, 'prisma', 'schema.prisma'));
|
|
30
|
+
writeTypes(config, path.join(cwd, '.opensaas', 'types.ts'));
|
|
31
|
+
writeContext(config, path.join(cwd, '.opensaas', 'context.ts'));
|
|
32
|
+
generatorSpinner.succeed(chalk.green('Schema generation complete'));
|
|
33
|
+
console.log(chalk.green('ā
Prisma schema generated'));
|
|
34
|
+
console.log(chalk.green('ā
TypeScript types generated'));
|
|
35
|
+
console.log(chalk.green('ā
Context factory generated'));
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
generatorSpinner.fail(chalk.red('Failed to generate'));
|
|
40
|
+
console.error(chalk.red('\nā Error:'), err.message);
|
|
41
|
+
if (err.stack) {
|
|
42
|
+
console.error(chalk.gray('\n' + err.stack));
|
|
43
|
+
}
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
// Run Prisma generate to create the Prisma client
|
|
47
|
+
const prismaSpinner = ora('Generating Prisma client...').start();
|
|
48
|
+
try {
|
|
49
|
+
execSync('npx prisma generate', {
|
|
50
|
+
cwd,
|
|
51
|
+
encoding: 'utf-8',
|
|
52
|
+
stdio: 'pipe',
|
|
53
|
+
});
|
|
54
|
+
prismaSpinner.succeed(chalk.green('Prisma client generated'));
|
|
55
|
+
console.log(chalk.green('ā
Prisma client generated'));
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
prismaSpinner.fail(chalk.red('Failed to generate Prisma client'));
|
|
59
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
60
|
+
console.error(chalk.red('\nā Error:'), message);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
// Patch Prisma types with field transformations
|
|
64
|
+
const patchSpinner = ora('Patching Prisma types...').start();
|
|
65
|
+
try {
|
|
66
|
+
patchPrismaTypes(config, cwd);
|
|
67
|
+
patchSpinner.succeed(chalk.green('Type patching complete'));
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
patchSpinner.fail(chalk.red('Failed to patch types'));
|
|
71
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
72
|
+
console.error(chalk.red('\nā Error:'), message);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
console.log(chalk.bold('\n⨠Generation complete!\n'));
|
|
76
|
+
console.log(chalk.gray('Next steps:'));
|
|
77
|
+
console.log(chalk.gray(' 1. Run: npx prisma db push'));
|
|
78
|
+
console.log(chalk.gray(' 2. Start using your generated types!\n'));
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
spinner.fail(chalk.red('Generation failed'));
|
|
83
|
+
console.error(chalk.red('\nā Error:'), error.message);
|
|
84
|
+
if (error.stack) {
|
|
85
|
+
console.error(chalk.gray('\n' + error.stack));
|
|
86
|
+
}
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AACjC,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,gBAAgB,GACjB,MAAM,uBAAuB,CAAA;AAG9B,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,CAAA;IAEpD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IACzB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAA;IAEvD,yBAAyB;IACzB,IAAI,CAAC,EAAE,CAAC,UAAU,CAA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