speedrun-cli 2.6.8 → 2.6.9
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/CHANGELOG.md +59 -0
- package/package.json +1 -1
- package/templates/orm/prisma/package.json +0 -3
- package/templates/base-crud/src/modules/products/dto/create-product.dto.ts +0 -44
- package/templates/base-crud/src/modules/products/dto/product.dto.ts +0 -38
- package/templates/base-crud/src/modules/products/dto/update-product.dto.ts +0 -12
- package/templates/base-crud/src/modules/products/products.controller.ts +0 -94
package/CHANGELOG.md
CHANGED
|
@@ -5,8 +5,64 @@ All notable changes to create-nestjs-auth will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.6.9] - 2026-08-21
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- **Products module no longer shipped by default** — `src/modules/products/` was incorrectly included in the `base-crud` shared template and therefore copied into every project where `--base-crud` was enabled, even before the user ran `speedrun-cli generate`. The products example files have been moved exclusively into the ORM-specific overlay templates (`base-crud-{orm}`), which are only written during the guided CRUD setup step. The `base-crud` shared layer now only contains the abstract classes (`src/common/base/`) and `CRUD_README.md`.
|
|
12
|
+
- **Seed runs twice on Prisma** — removed the `"prisma": { "seed": "ts-node prisma/seed.ts" }` field from `templates/orm/prisma/package.json`. This field caused Prisma to automatically invoke the seed at the end of every `prisma migrate dev`, while `postSetup.js` also called `npm run prisma:seed` explicitly — resulting in the seed being executed twice and credentials being printed double.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## [2.6.8] - 2026-08-21
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- **Guided CRUD setup step** — `? Do you want to generate your first CRUD module now?` is now part of the main setup flow, positioned after Database (Schema/Migration → Seed) and before Dev server start
|
|
20
|
+
- **`promptCrudGeneration()`** in `postSetup.js` — reusable function that calls `generateModule` with the selected ORM token, and auto-registers the generated module in `src/app.module.ts`
|
|
21
|
+
- **Manual instructions** now include a CRUD generation step (`speedrun-cli generate <name>`) when interactive setup is skipped
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- Setup prompt message updated: `"Would you like to complete the setup now? (JWT secrets, database, CRUD)"` to accurately reflect full scope
|
|
25
|
+
- CRUD generation is now **always offered** during guided setup (previously only shown when `--base-crud` flag was set, and appeared _after_ the dev server prompt)
|
|
26
|
+
- Guided setup flow order: **JWT → Database → CRUD → Dev server**
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
- **Duplicate CRUD prompt** — removed orphaned CRUD prompt block from `bin/cli.js`; single source of truth is now `postSetup.js`
|
|
30
|
+
- **`registerInAppModule` false positive** — overly broad `includes(${Name}Module)` check replaced with regex word-boundary `\b${Name}Module\b` to prevent partial-name collisions
|
|
31
|
+
- **Drizzle inject token mismatch** — `@Inject('DB_CONNECTION')` corrected to `@Inject('DRIZZLE')` to match the exported token in `database.module.ts`
|
|
32
|
+
- **TypeORM `@InjectRepository(Object)`** — added inline comment guiding users to replace `Object` with their actual entity class
|
|
33
|
+
- Ctrl+C during dev server no longer silently drops the CRUD prompt (prompt now runs _before_ the dev server)
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## [2.6.0] - 2026-08-18
|
|
38
|
+
|
|
39
|
+
### Added
|
|
40
|
+
- **Base CRUD Architecture** (`--base-crud` flag) — generates abstract `BaseService<T>` and `BaseController<T>` in `src/common/base/` with full Swagger integration
|
|
41
|
+
- **`BaseService<T>`** — generic CRUD abstraction with `create`, `findAll` (paginated), `findOne`, `update`, `remove` (soft-delete) and automatic `NotFoundException` throwing
|
|
42
|
+
- **`BaseController<T>`** — generic REST controller wiring `BaseService` methods to NestJS route decorators with full `@nestjs/swagger` decorators
|
|
43
|
+
- **Swagger DTO helpers** — `ApiResponseDto<T>`, `PaginatedResponseDto<T>`, `ApiResponseSchema()`, `PaginatedResponseSchema()` utility functions
|
|
44
|
+
- **ORM-specific ProductModule examples** — concrete `ProductsService` + `ProductsModule` templates for all four ORMs (`base-crud-{prisma,typeorm,drizzle,mongoose}`)
|
|
45
|
+
- **`ProductEntity` alias pattern** — each ORM service exports `export type ProductEntity = <OrmType>` so the shared controller imports from a single uniform name
|
|
46
|
+
- **`CRUD_README.md`** — full guide and cheatsheet copied into generated projects when `--base-crud` is enabled
|
|
47
|
+
- **`speedrun-cli generate [module-name]`** (`g` alias) — interactive CRUD module generator:
|
|
48
|
+
- Full CRUD or Custom Selection (checkbox) for individual operations
|
|
49
|
+
- ORM auto-detection from `package.json` dependencies
|
|
50
|
+
- Generates `service`, `controller`, `module`, and `dto/` files
|
|
51
|
+
- Auto-registers generated module in `src/app.module.ts`
|
|
52
|
+
|
|
53
|
+
### Changed
|
|
54
|
+
- Generator step 6 split into **6a (shared base-crud)** + **6b (ORM-specific overlay)** for correct template composition
|
|
55
|
+
- `printSuccessHeader` now displays Base CRUD status in success output
|
|
56
|
+
|
|
57
|
+
### Fixed
|
|
58
|
+
- Prisma template import paths corrected (`../../database/` → `../../prisma/`) to resolve `TS2307` errors
|
|
59
|
+
- Removed direct `@prisma/client` model imports in templates; replaced with local interface stubs to decouple from user schema (`TS2305` fix)
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
8
63
|
## [2.0.8] - 2025-12-05
|
|
9
64
|
|
|
65
|
+
|
|
10
66
|
### Fixed
|
|
11
67
|
- Fixed template copy failure when CLI is installed globally or via npx (node_modules path check issue)
|
|
12
68
|
- Fixed .gitignore not being included in generated projects (renamed to gitignore for npm compatibility)
|
|
@@ -91,6 +147,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
91
147
|
|
|
92
148
|
| Version | Date | Description |
|
|
93
149
|
|---------|------|-------------|
|
|
150
|
+
| 2.6.8 | 2026-08-21 | CRUD generation integrated into guided setup flow + bug fixes |
|
|
151
|
+
| 2.6.0 | 2026-08-18 | Base CRUD Architecture, ORM-specific templates, `generate` command |
|
|
152
|
+
| 2.0.8 | 2025-12-05 | Template copy & Prisma migration prompt fixes |
|
|
94
153
|
| 2.0.0 | 2025-12-04 | Multi-ORM and multi-database support |
|
|
95
154
|
| 1.1.0 | 2025-11-17 | Interactive mode and post-setup automation |
|
|
96
155
|
| 1.0.0 | 2025-11-16 | Initial release with Prisma + PostgreSQL |
|
package/package.json
CHANGED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
-
import {
|
|
3
|
-
IsString, IsNotEmpty, IsNumber, IsPositive, IsOptional,
|
|
4
|
-
IsEnum, MinLength, MaxLength, Min, IsInt, Matches,
|
|
5
|
-
} from 'class-validator';
|
|
6
|
-
import { Type } from 'class-transformer';
|
|
7
|
-
|
|
8
|
-
export enum ProductStatus {
|
|
9
|
-
ACTIVE = 'ACTIVE',
|
|
10
|
-
INACTIVE = 'INACTIVE',
|
|
11
|
-
OUT_OF_STOCK = 'OUT_OF_STOCK',
|
|
12
|
-
DISCONTINUED = 'DISCONTINUED',
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class CreateProductDto {
|
|
16
|
-
@ApiProperty({ description: 'Product name', example: 'Wireless Mechanical Keyboard', minLength: 3, maxLength: 150 })
|
|
17
|
-
@IsString() @IsNotEmpty() @MinLength(3) @MaxLength(150)
|
|
18
|
-
name: string;
|
|
19
|
-
|
|
20
|
-
@ApiPropertyOptional({ description: 'Product description', example: 'Compact TKL layout with RGB', maxLength: 1000 })
|
|
21
|
-
@IsOptional() @IsString() @MaxLength(1000)
|
|
22
|
-
description?: string;
|
|
23
|
-
|
|
24
|
-
@ApiProperty({ description: 'Unique SKU (uppercase, numbers, hyphens)', example: 'KB-WL-MEC-001', pattern: '^[A-Z0-9-]+$' })
|
|
25
|
-
@IsString() @IsNotEmpty()
|
|
26
|
-
@Matches(/^[A-Z0-9-]+$/, { message: 'sku must contain only uppercase letters, numbers, and hyphens' })
|
|
27
|
-
sku: string;
|
|
28
|
-
|
|
29
|
-
@ApiProperty({ description: 'Price in smallest currency unit (cents)', example: 149999, minimum: 0 })
|
|
30
|
-
@Type(() => Number) @IsNumber() @IsPositive()
|
|
31
|
-
price: number;
|
|
32
|
-
|
|
33
|
-
@ApiProperty({ description: 'Available stock quantity', example: 250, minimum: 0 })
|
|
34
|
-
@Type(() => Number) @IsInt() @Min(0)
|
|
35
|
-
stock: number;
|
|
36
|
-
|
|
37
|
-
@ApiPropertyOptional({ description: 'Product category', example: 'Peripherals', maxLength: 100 })
|
|
38
|
-
@IsOptional() @IsString() @MaxLength(100)
|
|
39
|
-
category?: string;
|
|
40
|
-
|
|
41
|
-
@ApiPropertyOptional({ enum: ProductStatus, default: ProductStatus.ACTIVE, example: ProductStatus.ACTIVE })
|
|
42
|
-
@IsOptional() @IsEnum(ProductStatus)
|
|
43
|
-
status?: ProductStatus = ProductStatus.ACTIVE;
|
|
44
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
-
import { ProductStatus } from './create-product.dto';
|
|
3
|
-
|
|
4
|
-
/** Product response DTO — shape returned from the API, used by Swagger @ApiExtraModels */
|
|
5
|
-
export class ProductDto {
|
|
6
|
-
@ApiProperty({ description: 'Product UUID v4', example: '123e4567-e89b-12d3-a456-426614174000', format: 'uuid' })
|
|
7
|
-
id: string;
|
|
8
|
-
|
|
9
|
-
@ApiProperty({ example: 'Wireless Mechanical Keyboard' })
|
|
10
|
-
name: string;
|
|
11
|
-
|
|
12
|
-
@ApiPropertyOptional({ example: 'Compact TKL layout with RGB' })
|
|
13
|
-
description?: string;
|
|
14
|
-
|
|
15
|
-
@ApiProperty({ example: 'KB-WL-MEC-001' })
|
|
16
|
-
sku: string;
|
|
17
|
-
|
|
18
|
-
@ApiProperty({ description: 'Price in cents', example: 149999 })
|
|
19
|
-
price: number;
|
|
20
|
-
|
|
21
|
-
@ApiProperty({ example: 250 })
|
|
22
|
-
stock: number;
|
|
23
|
-
|
|
24
|
-
@ApiPropertyOptional({ example: 'Peripherals' })
|
|
25
|
-
category?: string;
|
|
26
|
-
|
|
27
|
-
@ApiProperty({ enum: ProductStatus, example: ProductStatus.ACTIVE })
|
|
28
|
-
status: ProductStatus;
|
|
29
|
-
|
|
30
|
-
@ApiProperty({ example: '2025-01-01T00:00:00.000Z' })
|
|
31
|
-
createdAt: Date;
|
|
32
|
-
|
|
33
|
-
@ApiProperty({ example: '2025-01-15T08:30:00.000Z' })
|
|
34
|
-
updatedAt: Date;
|
|
35
|
-
|
|
36
|
-
@ApiPropertyOptional({ nullable: true, example: null })
|
|
37
|
-
deletedAt?: Date | null;
|
|
38
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { PartialType } from '@nestjs/swagger';
|
|
2
|
-
import { CreateProductDto } from './create-product.dto';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Update Product DTO
|
|
6
|
-
*
|
|
7
|
-
* Uses PartialType from @nestjs/swagger (NOT @nestjs/mapped-types) to:
|
|
8
|
-
* 1. Make all fields optional (PATCH semantics)
|
|
9
|
-
* 2. Preserve @ApiProperty decorators for Swagger schema rendering
|
|
10
|
-
* 3. Keep all class-validator rules active on provided fields
|
|
11
|
-
*/
|
|
12
|
-
export class UpdateProductDto extends PartialType(CreateProductDto) {}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Controller,
|
|
3
|
-
Get,
|
|
4
|
-
Param,
|
|
5
|
-
Query,
|
|
6
|
-
ParseUUIDPipe,
|
|
7
|
-
HttpStatus,
|
|
8
|
-
Type,
|
|
9
|
-
} from '@nestjs/common';
|
|
10
|
-
import {
|
|
11
|
-
ApiTags,
|
|
12
|
-
ApiOperation,
|
|
13
|
-
ApiResponse,
|
|
14
|
-
ApiBearerAuth,
|
|
15
|
-
ApiExtraModels,
|
|
16
|
-
ApiParam,
|
|
17
|
-
} from '@nestjs/swagger';
|
|
18
|
-
import { BaseController } from '../../common/base/base.controller';
|
|
19
|
-
import {
|
|
20
|
-
ApiResponseDto,
|
|
21
|
-
ApiResponseSchema,
|
|
22
|
-
PaginatedResponseDto,
|
|
23
|
-
PaginatedResponseSchema,
|
|
24
|
-
PaginationQueryDto,
|
|
25
|
-
} from '../../common/base';
|
|
26
|
-
import { ProductsService, ProductEntity } from './products.service';
|
|
27
|
-
import { CreateProductDto } from './dto/create-product.dto';
|
|
28
|
-
import { UpdateProductDto } from './dto/update-product.dto';
|
|
29
|
-
import { ProductDto } from './dto/product.dto';
|
|
30
|
-
|
|
31
|
-
// ─────────────────────────────────────────────────────────────
|
|
32
|
-
// Products Controller
|
|
33
|
-
//
|
|
34
|
-
// Extends BaseController which provides (via ORM-specific service):
|
|
35
|
-
// POST /products → create()
|
|
36
|
-
// GET /products → findAll()
|
|
37
|
-
// GET /products/:id → findOne()
|
|
38
|
-
// PUT /products/:id → update()
|
|
39
|
-
// DELETE /products/:id → remove()
|
|
40
|
-
//
|
|
41
|
-
// @ApiExtraModels registers DTOs so Swagger renders
|
|
42
|
-
// generic ApiResponseDto<ProductDto> and PaginatedResponseDto<ProductDto>.
|
|
43
|
-
// ─────────────────────────────────────────────────────────────
|
|
44
|
-
@ApiTags('Products')
|
|
45
|
-
@ApiBearerAuth('bearer')
|
|
46
|
-
@ApiExtraModels(ApiResponseDto, PaginatedResponseDto, ProductDto)
|
|
47
|
-
@Controller('products')
|
|
48
|
-
export class ProductsController extends BaseController<
|
|
49
|
-
ProductEntity,
|
|
50
|
-
CreateProductDto,
|
|
51
|
-
UpdateProductDto
|
|
52
|
-
> {
|
|
53
|
-
constructor(private readonly productsService: ProductsService) {
|
|
54
|
-
super(productsService);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
protected getDtoClass(): Type<ProductEntity> {
|
|
58
|
-
return ProductDto as unknown as Type<ProductEntity>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// ── Overrides to inject Swagger response schemas ────────────
|
|
62
|
-
|
|
63
|
-
@Get()
|
|
64
|
-
@ApiOperation({ summary: 'Get all products (paginated)' })
|
|
65
|
-
@ApiResponse({ status: HttpStatus.OK, description: 'Paginated products', schema: PaginatedResponseSchema(ProductDto) })
|
|
66
|
-
@ApiResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized' })
|
|
67
|
-
override async findAll(@Query() pagination: PaginationQueryDto): Promise<PaginatedResponseDto<ProductEntity>> {
|
|
68
|
-
return super.findAll(pagination);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
@Get('by-sku/:sku')
|
|
72
|
-
@ApiOperation({ summary: 'Get a product by SKU' })
|
|
73
|
-
@ApiParam({ name: 'sku', example: 'KB-WL-MEC-001', description: 'Unique Stock Keeping Unit' })
|
|
74
|
-
@ApiResponse({ status: HttpStatus.OK, description: 'Product found by SKU', schema: ApiResponseSchema(ProductDto) })
|
|
75
|
-
@ApiResponse({ status: HttpStatus.NOT_FOUND, description: 'Product not found' })
|
|
76
|
-
@ApiResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized' })
|
|
77
|
-
async findBySku(@Param('sku') sku: string): Promise<ApiResponseDto<ProductEntity>> {
|
|
78
|
-
const data = await this.productsService.findBySku(sku);
|
|
79
|
-
return { success: true, data, meta: { correlationId: '', timestamp: new Date().toISOString() } };
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
@Get(':id')
|
|
83
|
-
@ApiOperation({ summary: 'Get a product by UUID' })
|
|
84
|
-
@ApiParam({ name: 'id', format: 'uuid', example: '123e4567-e89b-12d3-a456-426614174000' })
|
|
85
|
-
@ApiResponse({ status: HttpStatus.OK, description: 'Product found', schema: ApiResponseSchema(ProductDto) })
|
|
86
|
-
@ApiResponse({ status: HttpStatus.NOT_FOUND, description: 'Product not found' })
|
|
87
|
-
@ApiResponse({ status: HttpStatus.BAD_REQUEST, description: 'Invalid UUID format' })
|
|
88
|
-
@ApiResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized' })
|
|
89
|
-
override async findOne(
|
|
90
|
-
@Param('id', new ParseUUIDPipe({ version: '4', errorHttpStatusCode: HttpStatus.BAD_REQUEST })) id: string,
|
|
91
|
-
): Promise<ApiResponseDto<ProductEntity>> {
|
|
92
|
-
return super.findOne(id);
|
|
93
|
-
}
|
|
94
|
-
}
|