@koalarx/nest-cli 1.1.4 → 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/code-base/startup-project/Dockerfile +10 -10
- package/code-base/startup-project/package.json +4 -4
- 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 +2 -2
- package/code-base/startup-project/src/host/main.ts +3 -4
- 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 +3 -4
- 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,17 +1,16 @@
|
|
|
1
|
-
import 'dotenv/config'
|
|
2
1
|
import { CreatePersonJob } from '@/application/person/create-person-job/create-person-job'
|
|
3
2
|
import { DeleteInactiveJob } from '@/application/person/delete-inative-job/delete-inactive-job'
|
|
4
3
|
import { InactivePersonHandler } from '@/application/person/events/inactive-person/inactive-person-handler'
|
|
5
4
|
import { DbTransactionContext } from '@/infra/database/db-transaction-context'
|
|
6
|
-
import { KoalaApp } from '@koalarx/nest/core/koala-app'
|
|
7
5
|
import { setPrismaClientOptions } from '@koalarx/nest/core/database/prisma.service'
|
|
6
|
+
import { KoalaApp } from '@koalarx/nest/core/koala-app'
|
|
7
|
+
import { NestFactory } from '@nestjs/core'
|
|
8
8
|
import { PrismaPg } from '@prisma/adapter-pg'
|
|
9
|
+
import 'dotenv/config'
|
|
9
10
|
import { Pool } from 'pg'
|
|
10
|
-
import { NestFactory } from '@nestjs/core'
|
|
11
11
|
import { AppModule } from './app.module'
|
|
12
12
|
|
|
13
13
|
async function bootstrap() {
|
|
14
|
-
// Configurar o adapter PostgreSQL antes de inicializar a aplicação
|
|
15
14
|
const pool = new Pool({
|
|
16
15
|
connectionString: process.env.DATABASE_URL,
|
|
17
16
|
})
|
|
@@ -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,14 +1,13 @@
|
|
|
1
|
-
import 'dotenv/config'
|
|
2
1
|
import { AppModule } from '@/host/app.module'
|
|
3
2
|
import { DbTransactionContext } from '@/infra/database/db-transaction-context'
|
|
4
|
-
import { KoalaAppTest } from '@koalarx/nest/test/koala-app-test'
|
|
5
3
|
import { setPrismaClientOptions } from '@koalarx/nest/core/database/prisma.service'
|
|
4
|
+
import { KoalaAppTest } from '@koalarx/nest/test/koala-app-test'
|
|
5
|
+
import { Test } from '@nestjs/testing'
|
|
6
6
|
import { PrismaPg } from '@prisma/adapter-pg'
|
|
7
|
+
import 'dotenv/config'
|
|
7
8
|
import { Pool } from 'pg'
|
|
8
|
-
import { Test } from '@nestjs/testing'
|
|
9
9
|
|
|
10
10
|
export async function createE2ETestApp() {
|
|
11
|
-
// Configurar o adapter PostgreSQL antes de criar o módulo de teste
|
|
12
11
|
const pool = new Pool({
|
|
13
12
|
connectionString: process.env.DATABASE_URL,
|
|
14
13
|
})
|
|
@@ -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.4",
|
|
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
package/utils/copy-folder.js
DELETED
|
@@ -1,59 +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/utils/copy-folder.ts
|
|
31
|
-
var copy_folder_exports = {};
|
|
32
|
-
__export(copy_folder_exports, {
|
|
33
|
-
copyFolder: () => copyFolder
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(copy_folder_exports);
|
|
36
|
-
var import_fs = __toESM(require("fs"));
|
|
37
|
-
var import_path = __toESM(require("path"));
|
|
38
|
-
function copyFolder(source, target) {
|
|
39
|
-
if (!import_fs.default.existsSync(target)) {
|
|
40
|
-
import_fs.default.mkdirSync(target);
|
|
41
|
-
}
|
|
42
|
-
const files = import_fs.default.readdirSync(source);
|
|
43
|
-
for (const file of files) {
|
|
44
|
-
const sourcePath = import_path.default.join(source, file);
|
|
45
|
-
const targetPath = import_path.default.join(target, file);
|
|
46
|
-
if (import_fs.default.statSync(sourcePath).isDirectory()) {
|
|
47
|
-
if (!import_fs.default.existsSync(target)) {
|
|
48
|
-
import_fs.default.mkdirSync(targetPath);
|
|
49
|
-
}
|
|
50
|
-
copyFolder(sourcePath, targetPath);
|
|
51
|
-
} else {
|
|
52
|
-
import_fs.default.copyFileSync(sourcePath, targetPath);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
-
0 && (module.exports = {
|
|
58
|
-
copyFolder
|
|
59
|
-
});
|