@koalarx/nest-cli 1.1.3 → 1.2.10
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 +31 -6
- package/code-base/startup-project/Dockerfile +10 -10
- package/code-base/startup-project/package.json +7 -6
- package/code-base/startup-project/prisma/generated/browser.ts +34 -0
- package/code-base/startup-project/prisma/generated/client.ts +54 -0
- package/code-base/startup-project/prisma/generated/commonInputTypes.ts +172 -0
- package/code-base/startup-project/prisma/generated/enums.ts +15 -0
- package/code-base/startup-project/prisma/generated/internal/class.ts +210 -0
- package/code-base/startup-project/prisma/generated/internal/prismaNamespace.ts +927 -0
- package/code-base/startup-project/prisma/generated/internal/prismaNamespaceBrowser.ts +116 -0
- package/code-base/startup-project/prisma/generated/models/Person.ts +1497 -0
- package/code-base/startup-project/prisma/generated/models/PersonAddress.ts +1265 -0
- package/code-base/startup-project/prisma/generated/models/PersonPhone.ts +1315 -0
- package/code-base/startup-project/prisma/generated/models.ts +14 -0
- package/code-base/startup-project/prisma/schema.prisma +3 -5
- package/code-base/startup-project/prisma.config.ts +8 -0
- package/code-base/startup-project/src/application/person/events/inactive-person/inactive-person-handler.ts +2 -2
- package/code-base/startup-project/src/application/person/events/person-event.job.ts +1 -1
- package/code-base/startup-project/src/host/controllers/person/person.controller.e2e-spec.ts +9 -5
- package/code-base/startup-project/src/host/main.ts +10 -0
- package/code-base/startup-project/src/infra/database/db-transaction-context.ts +2 -2
- package/code-base/startup-project/src/infra/database/repositories/person.repository.ts +1 -1
- package/code-base/startup-project/src/test/create-e2e-test-app.ts +10 -0
- package/code-base/startup-project/tsconfig.json +2 -1
- package/code-base/startup-project/vitest.config.e2e.mts +1 -0
- package/code-base/startup-project/vitest.config.mts +2 -1
- package/commands/new-project/index.ts +30 -0
- package/index.ts +35 -0
- package/package.json +6 -13
- package/utils/copy-folder.ts +25 -0
- package/commands/new-project/index.d.ts +0 -3
- package/commands/new-project/index.js +0 -85
- package/index.d.ts +0 -1
- package/index.js +0 -158
- package/utils/copy-folder.d.ts +0 -3
- package/utils/copy-folder.js +0 -59
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
// biome-ignore-all lint: generated file
|
|
5
|
+
// @ts-nocheck
|
|
6
|
+
/*
|
|
7
|
+
* This is a barrel export file for all models and their related types.
|
|
8
|
+
*
|
|
9
|
+
* 🟢 You can import this file directly.
|
|
10
|
+
*/
|
|
11
|
+
export type * from './models/Person'
|
|
12
|
+
export type * from './models/PersonPhone'
|
|
13
|
+
export type * from './models/PersonAddress'
|
|
14
|
+
export type * from './commonInputTypes'
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
generator client {
|
|
2
|
-
provider
|
|
3
|
-
|
|
2
|
+
provider = "prisma-client"
|
|
3
|
+
output = "generated"
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
datasource db {
|
|
7
|
-
provider
|
|
8
|
-
url = env("DATABASE_URL")
|
|
9
|
-
directUrl = env("DIRECT_URL")
|
|
7
|
+
provider = "postgresql"
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
model Person {
|
|
@@ -5,9 +5,9 @@ import { Injectable } from '@nestjs/common'
|
|
|
5
5
|
import { InactivePersonEvent } from './inactive-person-event'
|
|
6
6
|
|
|
7
7
|
@Injectable()
|
|
8
|
-
export class InactivePersonHandler extends EventHandlerBase
|
|
8
|
+
export class InactivePersonHandler extends EventHandlerBase {
|
|
9
9
|
constructor(private readonly repository: IPersonRepository) {
|
|
10
|
-
super()
|
|
10
|
+
super(InactivePersonEvent)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
async handleEvent(): Promise<void> {
|
|
@@ -5,7 +5,7 @@ import { Type } from '@nestjs/common'
|
|
|
5
5
|
import { InactivePersonHandler } from './inactive-person/inactive-person-handler'
|
|
6
6
|
|
|
7
7
|
export class PersonEventJob extends EventJob<Person> {
|
|
8
|
-
defineHandlers(): Type<EventHandlerBase
|
|
8
|
+
defineHandlers(): Type<EventHandlerBase>[] {
|
|
9
9
|
return [InactivePersonHandler]
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -6,6 +6,7 @@ import { PERSON_ROUTER_CONFIG } from './router.config'
|
|
|
6
6
|
describe(`CRUD OF PERSON`, () => {
|
|
7
7
|
let app: INestApplication
|
|
8
8
|
let personId: number
|
|
9
|
+
let addressId: number
|
|
9
10
|
|
|
10
11
|
beforeAll(async () => {
|
|
11
12
|
app = await createE2ETestApp()
|
|
@@ -35,13 +36,16 @@ describe(`CRUD OF PERSON`, () => {
|
|
|
35
36
|
`${PERSON_ROUTER_CONFIG.group}/${personId}`,
|
|
36
37
|
)
|
|
37
38
|
|
|
39
|
+
// Capturar o ID do endereço da resposta
|
|
40
|
+
addressId = response.body.address.id
|
|
41
|
+
|
|
38
42
|
expect(response.statusCode).toBe(200)
|
|
39
43
|
expect(response.body).toStrictEqual({
|
|
40
44
|
id: personId,
|
|
41
45
|
name: 'John Doe',
|
|
42
46
|
phones: [],
|
|
43
47
|
address: {
|
|
44
|
-
id:
|
|
48
|
+
id: expect.any(Number),
|
|
45
49
|
address: 'Streat 1',
|
|
46
50
|
},
|
|
47
51
|
active: true,
|
|
@@ -61,7 +65,7 @@ describe(`CRUD OF PERSON`, () => {
|
|
|
61
65
|
name: 'John Doe',
|
|
62
66
|
phones: [],
|
|
63
67
|
address: {
|
|
64
|
-
id:
|
|
68
|
+
id: addressId,
|
|
65
69
|
address: 'Streat 1',
|
|
66
70
|
},
|
|
67
71
|
active: true,
|
|
@@ -96,7 +100,7 @@ describe(`CRUD OF PERSON`, () => {
|
|
|
96
100
|
name: 'John Doe',
|
|
97
101
|
phones: [],
|
|
98
102
|
address: {
|
|
99
|
-
id:
|
|
103
|
+
id: addressId,
|
|
100
104
|
address: 'Streat 1',
|
|
101
105
|
},
|
|
102
106
|
active: true,
|
|
@@ -113,7 +117,7 @@ describe(`CRUD OF PERSON`, () => {
|
|
|
113
117
|
name: 'John Doe Updated',
|
|
114
118
|
phones: [],
|
|
115
119
|
address: {
|
|
116
|
-
id:
|
|
120
|
+
id: addressId,
|
|
117
121
|
address: 'Streat 2',
|
|
118
122
|
},
|
|
119
123
|
active: true,
|
|
@@ -130,7 +134,7 @@ describe(`CRUD OF PERSON`, () => {
|
|
|
130
134
|
name: 'John Doe Updated',
|
|
131
135
|
phones: [],
|
|
132
136
|
address: {
|
|
133
|
-
id:
|
|
137
|
+
id: addressId,
|
|
134
138
|
address: 'Streat 2',
|
|
135
139
|
},
|
|
136
140
|
active: true,
|
|
@@ -2,11 +2,21 @@ import { CreatePersonJob } from '@/application/person/create-person-job/create-p
|
|
|
2
2
|
import { DeleteInactiveJob } from '@/application/person/delete-inative-job/delete-inactive-job'
|
|
3
3
|
import { InactivePersonHandler } from '@/application/person/events/inactive-person/inactive-person-handler'
|
|
4
4
|
import { DbTransactionContext } from '@/infra/database/db-transaction-context'
|
|
5
|
+
import { setPrismaClientOptions } from '@koalarx/nest/core/database/prisma.service'
|
|
5
6
|
import { KoalaApp } from '@koalarx/nest/core/koala-app'
|
|
6
7
|
import { NestFactory } from '@nestjs/core'
|
|
8
|
+
import { PrismaPg } from '@prisma/adapter-pg'
|
|
9
|
+
import 'dotenv/config'
|
|
10
|
+
import { Pool } from 'pg'
|
|
7
11
|
import { AppModule } from './app.module'
|
|
8
12
|
|
|
9
13
|
async function bootstrap() {
|
|
14
|
+
const pool = new Pool({
|
|
15
|
+
connectionString: process.env.DATABASE_URL,
|
|
16
|
+
})
|
|
17
|
+
const adapter = new PrismaPg(pool)
|
|
18
|
+
setPrismaClientOptions({ adapter })
|
|
19
|
+
|
|
10
20
|
return NestFactory.create(AppModule).then((app) =>
|
|
11
21
|
new KoalaApp(app)
|
|
12
22
|
.useDoc({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import { PrismaClientWithCustomTransaction } from '@koalarx/nest/core/database/prisma-client-with-custom-transaction.interface'
|
|
3
3
|
import { PrismaTransactionalClient } from '@koalarx/nest/core/database/prisma-transactional-client'
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { DefaultArgs } from '@prisma/client/runtime/client'
|
|
5
|
+
import { Prisma } from 'prisma/generated/client'
|
|
6
6
|
|
|
7
7
|
export class DbTransactionContext
|
|
8
8
|
extends PrismaTransactionalClient
|
|
@@ -6,7 +6,7 @@ import { ListResponseBase } from '@koalarx/nest/core/controllers/list-response.b
|
|
|
6
6
|
import { RepositoryBase } from '@koalarx/nest/core/database/repository.base'
|
|
7
7
|
import { PRISMA_TOKEN } from '@koalarx/nest/core/koala-nest-database.module'
|
|
8
8
|
import { Inject, Injectable } from '@nestjs/common'
|
|
9
|
-
import { Prisma } from '
|
|
9
|
+
import { Prisma } from 'prisma/generated/client'
|
|
10
10
|
import { DbTransactionContext } from '../db-transaction-context'
|
|
11
11
|
|
|
12
12
|
@Injectable()
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { AppModule } from '@/host/app.module'
|
|
2
2
|
import { DbTransactionContext } from '@/infra/database/db-transaction-context'
|
|
3
|
+
import { setPrismaClientOptions } from '@koalarx/nest/core/database/prisma.service'
|
|
3
4
|
import { KoalaAppTest } from '@koalarx/nest/test/koala-app-test'
|
|
4
5
|
import { Test } from '@nestjs/testing'
|
|
6
|
+
import { PrismaPg } from '@prisma/adapter-pg'
|
|
7
|
+
import 'dotenv/config'
|
|
8
|
+
import { Pool } from 'pg'
|
|
5
9
|
|
|
6
10
|
export async function createE2ETestApp() {
|
|
11
|
+
const pool = new Pool({
|
|
12
|
+
connectionString: process.env.DATABASE_URL,
|
|
13
|
+
})
|
|
14
|
+
const adapter = new PrismaPg(pool)
|
|
15
|
+
setPrismaClientOptions({ adapter })
|
|
16
|
+
|
|
7
17
|
return Test.createTestingModule({ imports: [AppModule] })
|
|
8
18
|
.compile()
|
|
9
19
|
.then((moduleRef) => moduleRef.createNestApplication())
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { copyFolder } from '@/utils/copy-folder'
|
|
2
|
+
import chalk from 'chalk'
|
|
3
|
+
import { execSync } from 'node:child_process'
|
|
4
|
+
import { readFileSync, writeFileSync } from 'node:fs'
|
|
5
|
+
import path from 'node:path'
|
|
6
|
+
|
|
7
|
+
export function newProject(projectName: string) {
|
|
8
|
+
copyFolder(path.join(__dirname, 'code-base/startup-project'), projectName)
|
|
9
|
+
|
|
10
|
+
const packageJson = require(path.join(process.cwd(), projectName, 'package.json'))
|
|
11
|
+
packageJson.name = projectName
|
|
12
|
+
writeFileSync(path.join(process.cwd(), projectName, 'package.json'), JSON.stringify(packageJson, null, 2))
|
|
13
|
+
|
|
14
|
+
let readme = readFileSync(path.join(path.join(process.cwd(), projectName, 'README.md'))).toString()
|
|
15
|
+
readme = readme.replace('[projectName]', projectName)
|
|
16
|
+
writeFileSync(path.join(process.cwd(), projectName, 'README.md'), readme)
|
|
17
|
+
|
|
18
|
+
let env = readFileSync(path.join(path.join(__dirname, 'code-base/env', 'config.txt'))).toString()
|
|
19
|
+
env = env.replace(/\[projectName\]/g, projectName.replace(/-/g, '_'))
|
|
20
|
+
writeFileSync(path.join(process.cwd(), projectName, '.env'), env)
|
|
21
|
+
|
|
22
|
+
const gitIgnore = readFileSync(path.join(path.join(__dirname, 'code-base/gitignore', 'config.txt'))).toString()
|
|
23
|
+
writeFileSync(path.join(process.cwd(), projectName, '.gitignore'), gitIgnore)
|
|
24
|
+
|
|
25
|
+
execSync(`cd ${projectName} && npm install && npx prisma generate`, {
|
|
26
|
+
stdio: 'inherit',
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
console.log(`${chalk.green('Projeto criado com sucesso!')}`)
|
|
30
|
+
}
|
package/index.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import program from 'commander'
|
|
4
|
+
import inquirer from 'inquirer'
|
|
5
|
+
import packageJson from '../package.json'
|
|
6
|
+
import { newProject } from './commands/new-project'
|
|
7
|
+
import chalk from 'chalk'
|
|
8
|
+
import figlet from 'figlet'
|
|
9
|
+
|
|
10
|
+
program.version(packageJson.version)
|
|
11
|
+
|
|
12
|
+
console.log(chalk.cyan(figlet.textSync('Koala Nest CLI')))
|
|
13
|
+
|
|
14
|
+
program
|
|
15
|
+
.command('new [projectName]')
|
|
16
|
+
.description('Cria um novo projeto Nest com Koala Nest')
|
|
17
|
+
.action(async (projectName: string) => {
|
|
18
|
+
if (!projectName) {
|
|
19
|
+
projectName = await inquirer
|
|
20
|
+
.prompt([
|
|
21
|
+
{
|
|
22
|
+
type: 'input',
|
|
23
|
+
name: 'projectName',
|
|
24
|
+
message: 'Informe o nome do projeto',
|
|
25
|
+
validate: (value?: string) =>
|
|
26
|
+
value ? true : 'Não é permitido um nome vazio',
|
|
27
|
+
},
|
|
28
|
+
])
|
|
29
|
+
.then((answers) => answers.projectName)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
newProject(projectName)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
program.parse(process.argv)
|
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koalarx/nest-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.10",
|
|
4
4
|
"description": "Biblioteca de CLI para criação de projetos utilizando Koala Nest",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "vitest run",
|
|
7
7
|
"test:watch": "vitest",
|
|
8
8
|
"test:cov": "vitest run --coverage",
|
|
9
9
|
"test:debug": "vitest --inspect-brk --inspect --logHeapUsage --threads=false",
|
|
10
|
-
"build": "
|
|
11
|
-
"prepare": "
|
|
12
|
-
"prepublishOnly": "
|
|
10
|
+
"build": "bun .github/scripts/publish.ts",
|
|
11
|
+
"prepare": "bun run build",
|
|
12
|
+
"prepublishOnly": "bun run test",
|
|
13
13
|
"version": "git add -A src",
|
|
14
14
|
"postversion": "git push && git push --tags",
|
|
15
15
|
"deploy:hotfix": "npm version patch",
|
|
16
16
|
"deploy:feature": "npm version minor",
|
|
17
17
|
"deploy:release": "npm version major"
|
|
18
18
|
},
|
|
19
|
-
"main": "dist/index.
|
|
19
|
+
"main": "dist/index.ts",
|
|
20
20
|
"bin": {
|
|
21
|
-
"koala-nest": "index.
|
|
21
|
+
"koala-nest": "dist/commands/new-project/index.ts"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
@@ -50,13 +50,6 @@
|
|
|
50
50
|
"eslint-config-prettier": "^8.8.0",
|
|
51
51
|
"eslint-plugin-prettier": "^4.2.1",
|
|
52
52
|
"prettier": "^2.3.2",
|
|
53
|
-
"tsup": "^8.4.0",
|
|
54
53
|
"typescript": "^5.2.2"
|
|
55
|
-
},
|
|
56
|
-
"tsup": {
|
|
57
|
-
"entry": [
|
|
58
|
-
"src"
|
|
59
|
-
],
|
|
60
|
-
"dts": true
|
|
61
54
|
}
|
|
62
55
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
|
|
4
|
+
export function copyFolder(source, target) {
|
|
5
|
+
if (!fs.existsSync(target)) {
|
|
6
|
+
fs.mkdirSync(target)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const files = fs.readdirSync(source)
|
|
10
|
+
|
|
11
|
+
for (const file of files) {
|
|
12
|
+
const sourcePath = path.join(source, file)
|
|
13
|
+
const targetPath = path.join(target, file)
|
|
14
|
+
|
|
15
|
+
if (fs.statSync(sourcePath).isDirectory()) {
|
|
16
|
+
if (!fs.existsSync(target)) {
|
|
17
|
+
fs.mkdirSync(targetPath)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
copyFolder(sourcePath, targetPath)
|
|
21
|
+
} else {
|
|
22
|
+
fs.copyFileSync(sourcePath, targetPath)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/commands/new-project/index.ts
|
|
31
|
-
var new_project_exports = {};
|
|
32
|
-
__export(new_project_exports, {
|
|
33
|
-
newProject: () => newProject
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(new_project_exports);
|
|
36
|
-
|
|
37
|
-
// src/utils/copy-folder.ts
|
|
38
|
-
var import_fs = __toESM(require("fs"));
|
|
39
|
-
var import_path = __toESM(require("path"));
|
|
40
|
-
function copyFolder(source, target) {
|
|
41
|
-
if (!import_fs.default.existsSync(target)) {
|
|
42
|
-
import_fs.default.mkdirSync(target);
|
|
43
|
-
}
|
|
44
|
-
const files = import_fs.default.readdirSync(source);
|
|
45
|
-
for (const file of files) {
|
|
46
|
-
const sourcePath = import_path.default.join(source, file);
|
|
47
|
-
const targetPath = import_path.default.join(target, file);
|
|
48
|
-
if (import_fs.default.statSync(sourcePath).isDirectory()) {
|
|
49
|
-
if (!import_fs.default.existsSync(target)) {
|
|
50
|
-
import_fs.default.mkdirSync(targetPath);
|
|
51
|
-
}
|
|
52
|
-
copyFolder(sourcePath, targetPath);
|
|
53
|
-
} else {
|
|
54
|
-
import_fs.default.copyFileSync(sourcePath, targetPath);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// src/commands/new-project/index.ts
|
|
60
|
-
var import_chalk = __toESM(require("chalk"));
|
|
61
|
-
var import_node_child_process = require("child_process");
|
|
62
|
-
var import_node_fs = require("fs");
|
|
63
|
-
var import_node_path = __toESM(require("path"));
|
|
64
|
-
function newProject(projectName) {
|
|
65
|
-
copyFolder(import_node_path.default.join(__dirname, "code-base/startup-project"), projectName);
|
|
66
|
-
const packageJson = require(import_node_path.default.join(process.cwd(), projectName, "package.json"));
|
|
67
|
-
packageJson.name = projectName;
|
|
68
|
-
(0, import_node_fs.writeFileSync)(import_node_path.default.join(process.cwd(), projectName, "package.json"), JSON.stringify(packageJson, null, 2));
|
|
69
|
-
let readme = (0, import_node_fs.readFileSync)(import_node_path.default.join(import_node_path.default.join(process.cwd(), projectName, "README.md"))).toString();
|
|
70
|
-
readme = readme.replace("[projectName]", projectName);
|
|
71
|
-
(0, import_node_fs.writeFileSync)(import_node_path.default.join(process.cwd(), projectName, "README.md"), readme);
|
|
72
|
-
let env = (0, import_node_fs.readFileSync)(import_node_path.default.join(import_node_path.default.join(__dirname, "code-base/env", "config.txt"))).toString();
|
|
73
|
-
env = env.replace(/\[projectName\]/g, projectName.replace(/-/g, "_"));
|
|
74
|
-
(0, import_node_fs.writeFileSync)(import_node_path.default.join(process.cwd(), projectName, ".env"), env);
|
|
75
|
-
const gitIgnore = (0, import_node_fs.readFileSync)(import_node_path.default.join(import_node_path.default.join(__dirname, "code-base/gitignore", "config.txt"))).toString();
|
|
76
|
-
(0, import_node_fs.writeFileSync)(import_node_path.default.join(process.cwd(), projectName, ".gitignore"), gitIgnore);
|
|
77
|
-
(0, import_node_child_process.execSync)(`cd ${projectName} && npm install && npx prisma generate`, {
|
|
78
|
-
stdio: "inherit"
|
|
79
|
-
});
|
|
80
|
-
console.log(`${import_chalk.default.green("Projeto criado com sucesso!")}`);
|
|
81
|
-
}
|
|
82
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
-
0 && (module.exports = {
|
|
84
|
-
newProject
|
|
85
|
-
});
|
package/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
package/index.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
-
mod
|
|
24
|
-
));
|
|
25
|
-
|
|
26
|
-
// src/index.ts
|
|
27
|
-
var import_commander = __toESM(require("commander"));
|
|
28
|
-
var import_inquirer = __toESM(require("inquirer"));
|
|
29
|
-
|
|
30
|
-
// package.json
|
|
31
|
-
var package_default = {
|
|
32
|
-
name: "@koalarx/nest-cli",
|
|
33
|
-
version: "1.1.3",
|
|
34
|
-
description: "Biblioteca de CLI para cria\xE7\xE3o de projetos utilizando Koala Nest",
|
|
35
|
-
scripts: {
|
|
36
|
-
test: "vitest run",
|
|
37
|
-
"test:watch": "vitest",
|
|
38
|
-
"test:cov": "vitest run --coverage",
|
|
39
|
-
"test:debug": "vitest --inspect-brk --inspect --logHeapUsage --threads=false",
|
|
40
|
-
build: "node .github/scripts/publish.js",
|
|
41
|
-
prepare: "npm run build",
|
|
42
|
-
prepublishOnly: "npm test",
|
|
43
|
-
version: "git add -A src",
|
|
44
|
-
postversion: "git push && git push --tags",
|
|
45
|
-
"deploy:hotfix": "npm version patch",
|
|
46
|
-
"deploy:feature": "npm version minor",
|
|
47
|
-
"deploy:release": "npm version major"
|
|
48
|
-
},
|
|
49
|
-
main: "dist/index.js",
|
|
50
|
-
bin: {
|
|
51
|
-
"koala-nest": "index.js"
|
|
52
|
-
},
|
|
53
|
-
repository: {
|
|
54
|
-
type: "git",
|
|
55
|
-
url: "git+https://github.com/igordrangel/koala-nest-cli.git"
|
|
56
|
-
},
|
|
57
|
-
keywords: [
|
|
58
|
-
"Nest.js"
|
|
59
|
-
],
|
|
60
|
-
author: "Igor D. Rangel",
|
|
61
|
-
license: "ISC",
|
|
62
|
-
bugs: {
|
|
63
|
-
url: "https://github.com/igordrangel/koala-nest-cli/issues"
|
|
64
|
-
},
|
|
65
|
-
homepage: "https://github.com/igordrangel/koala-nest-cli#readme",
|
|
66
|
-
dependencies: {
|
|
67
|
-
chalk: "^2.4.2",
|
|
68
|
-
commander: "^2.19.0",
|
|
69
|
-
figlet: "^1.2.1",
|
|
70
|
-
inquirer: "^6.2.2",
|
|
71
|
-
shelljs: "^0.8.3"
|
|
72
|
-
},
|
|
73
|
-
devDependencies: {
|
|
74
|
-
"@rocketseat/eslint-config": "^1.2.0",
|
|
75
|
-
"@types/node": "^18.14.0",
|
|
76
|
-
"@types/node-fetch": "^2.6.4",
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
78
|
-
"@typescript-eslint/parser": "^5.0.0",
|
|
79
|
-
eslint: "^8.44.0",
|
|
80
|
-
"eslint-config-prettier": "^8.8.0",
|
|
81
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
82
|
-
prettier: "^2.3.2",
|
|
83
|
-
tsup: "^8.4.0",
|
|
84
|
-
typescript: "^5.2.2"
|
|
85
|
-
},
|
|
86
|
-
tsup: {
|
|
87
|
-
entry: [
|
|
88
|
-
"src"
|
|
89
|
-
],
|
|
90
|
-
dts: true
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// src/utils/copy-folder.ts
|
|
95
|
-
var import_fs = __toESM(require("fs"));
|
|
96
|
-
var import_path = __toESM(require("path"));
|
|
97
|
-
function copyFolder(source, target) {
|
|
98
|
-
if (!import_fs.default.existsSync(target)) {
|
|
99
|
-
import_fs.default.mkdirSync(target);
|
|
100
|
-
}
|
|
101
|
-
const files = import_fs.default.readdirSync(source);
|
|
102
|
-
for (const file of files) {
|
|
103
|
-
const sourcePath = import_path.default.join(source, file);
|
|
104
|
-
const targetPath = import_path.default.join(target, file);
|
|
105
|
-
if (import_fs.default.statSync(sourcePath).isDirectory()) {
|
|
106
|
-
if (!import_fs.default.existsSync(target)) {
|
|
107
|
-
import_fs.default.mkdirSync(targetPath);
|
|
108
|
-
}
|
|
109
|
-
copyFolder(sourcePath, targetPath);
|
|
110
|
-
} else {
|
|
111
|
-
import_fs.default.copyFileSync(sourcePath, targetPath);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// src/commands/new-project/index.ts
|
|
117
|
-
var import_chalk = __toESM(require("chalk"));
|
|
118
|
-
var import_node_child_process = require("child_process");
|
|
119
|
-
var import_node_fs = require("fs");
|
|
120
|
-
var import_node_path = __toESM(require("path"));
|
|
121
|
-
function newProject(projectName) {
|
|
122
|
-
copyFolder(import_node_path.default.join(__dirname, "code-base/startup-project"), projectName);
|
|
123
|
-
const packageJson = require(import_node_path.default.join(process.cwd(), projectName, "package.json"));
|
|
124
|
-
packageJson.name = projectName;
|
|
125
|
-
(0, import_node_fs.writeFileSync)(import_node_path.default.join(process.cwd(), projectName, "package.json"), JSON.stringify(packageJson, null, 2));
|
|
126
|
-
let readme = (0, import_node_fs.readFileSync)(import_node_path.default.join(import_node_path.default.join(process.cwd(), projectName, "README.md"))).toString();
|
|
127
|
-
readme = readme.replace("[projectName]", projectName);
|
|
128
|
-
(0, import_node_fs.writeFileSync)(import_node_path.default.join(process.cwd(), projectName, "README.md"), readme);
|
|
129
|
-
let env = (0, import_node_fs.readFileSync)(import_node_path.default.join(import_node_path.default.join(__dirname, "code-base/env", "config.txt"))).toString();
|
|
130
|
-
env = env.replace(/\[projectName\]/g, projectName.replace(/-/g, "_"));
|
|
131
|
-
(0, import_node_fs.writeFileSync)(import_node_path.default.join(process.cwd(), projectName, ".env"), env);
|
|
132
|
-
const gitIgnore = (0, import_node_fs.readFileSync)(import_node_path.default.join(import_node_path.default.join(__dirname, "code-base/gitignore", "config.txt"))).toString();
|
|
133
|
-
(0, import_node_fs.writeFileSync)(import_node_path.default.join(process.cwd(), projectName, ".gitignore"), gitIgnore);
|
|
134
|
-
(0, import_node_child_process.execSync)(`cd ${projectName} && npm install && npx prisma generate`, {
|
|
135
|
-
stdio: "inherit"
|
|
136
|
-
});
|
|
137
|
-
console.log(`${import_chalk.default.green("Projeto criado com sucesso!")}`);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// src/index.ts
|
|
141
|
-
var import_chalk2 = __toESM(require("chalk"));
|
|
142
|
-
var import_figlet = __toESM(require("figlet"));
|
|
143
|
-
import_commander.default.version(package_default.version);
|
|
144
|
-
console.log(import_chalk2.default.cyan(import_figlet.default.textSync("Koala Nest CLI")));
|
|
145
|
-
import_commander.default.command("new [projectName]").description("Cria um novo projeto Nest com Koala Nest").action(async (projectName) => {
|
|
146
|
-
if (!projectName) {
|
|
147
|
-
projectName = await import_inquirer.default.prompt([
|
|
148
|
-
{
|
|
149
|
-
type: "input",
|
|
150
|
-
name: "projectName",
|
|
151
|
-
message: "Informe o nome do projeto",
|
|
152
|
-
validate: (value) => value ? true : "N\xE3o \xE9 permitido um nome vazio"
|
|
153
|
-
}
|
|
154
|
-
]).then((answers) => answers.projectName);
|
|
155
|
-
}
|
|
156
|
-
newProject(projectName);
|
|
157
|
-
});
|
|
158
|
-
import_commander.default.parse(process.argv);
|
package/utils/copy-folder.d.ts
DELETED