speedrun-cli 2.8.0 → 2.8.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/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@ 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.8.1] - 2026-08-22
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- **Fixed TS2307: Cannot find module `../../common/guards/jwt-auth.guard`** — Enhanced `ensureBaseArchitecture(targetDir)` in `src/moduleGenerator.js` to automatically verify and scaffold placeholder guards (`src/common/guards/jwt-auth.guard.ts`, `src/common/guards/roles.guard.ts`) and decorators (`src/common/decorators/roles.decorator.ts`) whenever generating (`speedrun-cli g`) or configuring (`speedrun-cli c`) protected CRUD modules.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
8
15
|
## [2.8.0] - 2026-08-22
|
|
9
16
|
|
|
10
17
|
### Added
|
package/package.json
CHANGED
|
@@ -176,6 +176,9 @@ ${ops.create ? `
|
|
|
176
176
|
*/
|
|
177
177
|
async function configureModule(providedModuleName, targetDir = process.cwd()) {
|
|
178
178
|
try {
|
|
179
|
+
const { ensureBaseArchitecture } = require('./moduleGenerator');
|
|
180
|
+
await ensureBaseArchitecture(targetDir);
|
|
181
|
+
|
|
179
182
|
let moduleName = providedModuleName;
|
|
180
183
|
|
|
181
184
|
if (!moduleName) {
|
package/src/moduleGenerator.js
CHANGED
|
@@ -80,11 +80,13 @@ async function detectOrm(targetDir) {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
* Ensures src/common/base
|
|
83
|
+
* Ensures src/common/base, src/common/guards, and src/common/decorators exist with required abstract classes, DTOs, guards & decorators
|
|
84
84
|
*/
|
|
85
85
|
async function ensureBaseArchitecture(targetDir) {
|
|
86
86
|
try {
|
|
87
87
|
const commonBaseDir = path.join(targetDir, 'src', 'common', 'base');
|
|
88
|
+
const commonGuardsDir = path.join(targetDir, 'src', 'common', 'guards');
|
|
89
|
+
const commonDecoratorsDir = path.join(targetDir, 'src', 'common', 'decorators');
|
|
88
90
|
|
|
89
91
|
if (!(await fs.pathExists(commonBaseDir))) {
|
|
90
92
|
const templateBaseDir = path.join(__dirname, '..', 'templates', 'base-crud', 'src', 'common', 'base');
|
|
@@ -93,6 +95,54 @@ async function ensureBaseArchitecture(targetDir) {
|
|
|
93
95
|
console.log(chalk.green(' ✓ Scaffolded Base CRUD architecture at src/common/base'));
|
|
94
96
|
}
|
|
95
97
|
}
|
|
98
|
+
|
|
99
|
+
// Scaffold Guards if missing
|
|
100
|
+
await fs.ensureDir(commonGuardsDir);
|
|
101
|
+
const jwtGuardPath = path.join(commonGuardsDir, 'jwt-auth.guard.ts');
|
|
102
|
+
const authGuardPath = path.join(commonGuardsDir, 'auth.guard.ts');
|
|
103
|
+
const rolesGuardPath = path.join(commonGuardsDir, 'roles.guard.ts');
|
|
104
|
+
|
|
105
|
+
if (!(await fs.pathExists(jwtGuardPath)) && !(await fs.pathExists(authGuardPath))) {
|
|
106
|
+
const jwtGuardContent = `import { Injectable, CanActivate, ExecutionContext } from '@nestjs/common';
|
|
107
|
+
|
|
108
|
+
@Injectable()
|
|
109
|
+
export class JwtAuthGuard implements CanActivate {
|
|
110
|
+
canActivate(context: ExecutionContext): boolean {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
115
|
+
await fs.writeFile(jwtGuardPath, jwtGuardContent, 'utf8');
|
|
116
|
+
console.log(chalk.green(' ✓ Scaffolded JwtAuthGuard at src/common/guards/jwt-auth.guard.ts'));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (!(await fs.pathExists(rolesGuardPath))) {
|
|
120
|
+
const rolesGuardContent = `import { Injectable, CanActivate, ExecutionContext } from '@nestjs/common';
|
|
121
|
+
|
|
122
|
+
@Injectable()
|
|
123
|
+
export class RolesGuard implements CanActivate {
|
|
124
|
+
canActivate(context: ExecutionContext): boolean {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
`;
|
|
129
|
+
await fs.writeFile(rolesGuardPath, rolesGuardContent, 'utf8');
|
|
130
|
+
console.log(chalk.green(' ✓ Scaffolded RolesGuard at src/common/guards/roles.guard.ts'));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Scaffold Decorators if missing
|
|
134
|
+
await fs.ensureDir(commonDecoratorsDir);
|
|
135
|
+
const rolesDecoratorPath = path.join(commonDecoratorsDir, 'roles.decorator.ts');
|
|
136
|
+
|
|
137
|
+
if (!(await fs.pathExists(rolesDecoratorPath))) {
|
|
138
|
+
const rolesDecoratorContent = `import { SetMetadata } from '@nestjs/common';
|
|
139
|
+
|
|
140
|
+
export const ROLES_KEY = 'roles';
|
|
141
|
+
export const Roles = (...roles: string[]) => SetMetadata(ROLES_KEY, roles);
|
|
142
|
+
`;
|
|
143
|
+
await fs.writeFile(rolesDecoratorPath, rolesDecoratorContent, 'utf8');
|
|
144
|
+
console.log(chalk.green(' ✓ Scaffolded Roles decorator at src/common/decorators/roles.decorator.ts'));
|
|
145
|
+
}
|
|
96
146
|
} catch (error) {
|
|
97
147
|
console.warn(chalk.yellow(` ⚠️ Could not scaffold Base CRUD architecture: ${error.message}`));
|
|
98
148
|
}
|