nestjs-with-auth 1.0.0 → 1.0.2
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/bin/cli.js +0 -1
- package/package.json +2 -2
- package/src/index.js +1 -18
- package/src/setup.js +0 -55
- package/templates/base/{lib → src/lib}/prisma.ts +1 -1
- package/templates/base/package-lock.json +0 -12548
- package/templates/base/prisma/migrations/20260118151539_init/migration.sql +0 -12
- package/templates/base/prisma/migrations/migration_lock.toml +0 -3
package/bin/cli.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nestjs-with-auth",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "nestjs boilerplate with passport integrated",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "sangnd2x",
|
|
7
7
|
"type": "commonjs",
|
|
8
8
|
"main": "index.js",
|
|
9
9
|
"bin": {
|
|
10
|
-
"
|
|
10
|
+
"nestjs-with-auth": "./bin/cli.js"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"bin",
|
package/src/index.js
CHANGED
|
@@ -8,24 +8,7 @@ program
|
|
|
8
8
|
.action(async (projectName) => {
|
|
9
9
|
console.log(chalk.blue(`Creating ${projectName}...\n`));
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
// const choices = await getUserChoices();
|
|
13
|
-
//
|
|
14
|
-
// if (!choices.database || !choices.orm) {
|
|
15
|
-
// console.log(chalk.red('Setup cancelled'));
|
|
16
|
-
// process.exit(1);
|
|
17
|
-
// }
|
|
18
|
-
|
|
19
|
-
// Setup project
|
|
20
|
-
const projectPath = await setupProject(projectName);
|
|
21
|
-
|
|
22
|
-
// Install dependencies
|
|
23
|
-
console.log(chalk.blue('\nInstalling dependencies...'));
|
|
24
|
-
execSync('npm install', {cwd: projectPath, stdio: 'inherit'});
|
|
25
|
-
|
|
26
|
-
// Run Prisma init if needed
|
|
27
|
-
console.log(chalk.blue('\nGenerating Prisma client...'));
|
|
28
|
-
execSync('npx prisma generate', {cwd: projectPath, stdio: 'inherit'});
|
|
11
|
+
await setupProject(projectName);
|
|
29
12
|
|
|
30
13
|
console.log(chalk.green(`\n✅ Project ${projectName} created successfully!`));
|
|
31
14
|
console.log(chalk.blue(`\nNext steps:`));
|
package/src/setup.js
CHANGED
|
@@ -9,62 +9,7 @@ async function setupProject(projectName) {
|
|
|
9
9
|
console.log('Creating project...');
|
|
10
10
|
await fs.copy(templatePath, targetPath);
|
|
11
11
|
|
|
12
|
-
// Update package.json with ORM dependencies
|
|
13
|
-
const packageJsonPath = path.join(targetPath, 'package.json');
|
|
14
|
-
const packageJson = await fs.readJSON(packageJsonPath);
|
|
15
|
-
|
|
16
|
-
packageJson.name = projectName;
|
|
17
|
-
|
|
18
|
-
// Add ORM-specific dependencies
|
|
19
|
-
packageJson.dependencies['@prisma/client'] = '^5.0.0';
|
|
20
|
-
packageJson.devDependencies['prisma'] = '^5.0.0';
|
|
21
|
-
|
|
22
|
-
await fs.writeJSON(packageJsonPath, packageJson, {spaces: 2});
|
|
23
|
-
|
|
24
|
-
// Generate ORM config files
|
|
25
|
-
await generateOrmConfig(targetPath);
|
|
26
|
-
|
|
27
12
|
return targetPath;
|
|
28
13
|
}
|
|
29
14
|
|
|
30
|
-
async function generateOrmConfig(targetPath) {
|
|
31
|
-
// Create prisma schema
|
|
32
|
-
const prismaDir = path.join(targetPath, 'prisma');
|
|
33
|
-
await fs.ensureDir(prismaDir);
|
|
34
|
-
|
|
35
|
-
const schemaContent = `
|
|
36
|
-
datasource db {
|
|
37
|
-
provider = "postgresql"
|
|
38
|
-
url = env("DATABASE_URL")
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
generator client {
|
|
42
|
-
provider = "prisma-client-js"
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
model User {
|
|
46
|
-
id Int @id @default(autoincrement())
|
|
47
|
-
email String @unique
|
|
48
|
-
password String
|
|
49
|
-
}
|
|
50
|
-
`;
|
|
51
|
-
|
|
52
|
-
const prismaConfigContent = `
|
|
53
|
-
import 'dotenv/config';
|
|
54
|
-
import { defineConfig, env } from 'prisma/config';
|
|
55
|
-
|
|
56
|
-
export default defineConfig({
|
|
57
|
-
schema: 'prisma/schema.prisma',
|
|
58
|
-
migrations: {
|
|
59
|
-
path: 'prisma/migrations',
|
|
60
|
-
},
|
|
61
|
-
engine: 'classic',
|
|
62
|
-
datasource: {
|
|
63
|
-
url: env('DATABASE_URL'),
|
|
64
|
-
},
|
|
65
|
-
});`
|
|
66
|
-
await fs.writeFile(path.join(prismaDir, 'schema.prisma'), schemaContent.trim());
|
|
67
|
-
await fs.writeFile(path.join(targetPath, 'prisma.config.ts'), prismaConfigContent.trim());
|
|
68
|
-
}
|
|
69
|
-
|
|
70
15
|
module.exports = {setupProject};
|