@nest-arch/tui 0.2.1 → 0.2.3
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 +1 -2
- package/dist/cli.js +1 -1
- package/dist/{constants-LZTzRAoQ.js → constants-DBtqeoTh.js} +1 -1
- package/dist/index.js +59 -59
- package/dist/templates/base/.env.example.hbs +1 -1
- package/dist/templates/base/.env.hbs +1 -1
- package/dist/templates/base/pnpm-workspace.yaml.hbs +3 -0
- package/dist/templates/base/src/app.module.ts.hbs +11 -5
- package/dist/templates/base/src/database/db.module.ts.hbs +2 -4
- package/dist/templates/base/src/main.ts.hbs +6 -0
- package/dist/templates/extras/swagger/create-docs.ts.hbs +13 -1
- package/dist/templates/feature/rest/todo-example/src/api/todo/todo.controller.ts.hbs +14 -189
- package/dist/templates/feature/rest/todo-example/src/api/todo/todo.module.ts.hbs +24 -0
- package/dist/templates/feature/rest/todo-example/src/api/todo/todo.router.ts.hbs +76 -0
- package/dist/templates/feature/rest/todo-example/src/api/todo/todo.service.ts.hbs +145 -0
- package/dist/templates/monorepo/apps/api-gateway/src/app.module.ts.hbs +11 -5
- package/dist/templates/monorepo/apps/api-gateway/src/main.ts.hbs +6 -0
- package/dist/templates/monorepo/root/pnpm-workspace.yaml.hbs +3 -0
- package/dist/templates/single-project/architecture/nest-api/.env.hbs +1 -1
- package/dist/templates/single-project/architecture/nest-api/pnpm-workspace.yaml.hbs +3 -0
- package/dist/templates/single-project/architecture/nest-api/src/main.ts.hbs +6 -0
- package/dist/templates/single-project/architecture/nest-gateway/src/main.ts.hbs +6 -0
- package/dist/templates/single-project/architecture/nest-microservice/src/main.ts.hbs +6 -0
- package/package.json +4 -4
- package/dist/templates/base/src/libs/trpc/scripts/fix-trpc-generated.mjs.hbs +0 -21
- package/dist/templates/base/src/libs/trpc/scripts/watch-trpc.mjs.hbs +0 -91
|
@@ -20,17 +20,17 @@ import { AuthTRPCMiddleware } from "./libs/middlewares/auth.trpc.middleware.js";
|
|
|
20
20
|
{{/if}}
|
|
21
21
|
|
|
22
22
|
import { AppController } from "./app.controller.js";
|
|
23
|
-
{{#if (and hasTodoExample hasRest)}}
|
|
24
|
-
import {
|
|
23
|
+
{{#if (and hasTodoExample (or hasRest hasTrpc))}}
|
|
24
|
+
import { TodoModule } from "./api/todo/todo.module.js";
|
|
25
|
+
{{/if}}
|
|
26
|
+
{{#if (and hasTrpc hasTodoExample hasRest)}}
|
|
27
|
+
import { TodoRouter } from "./api/todo/todo.router.js";
|
|
25
28
|
{{/if}}
|
|
26
29
|
import { AppService } from "./app.service.js";
|
|
27
30
|
|
|
28
31
|
@Module({
|
|
29
32
|
controllers: [
|
|
30
33
|
AppController,
|
|
31
|
-
{{#if (and hasTodoExample hasRest)}}
|
|
32
|
-
TodoController,
|
|
33
|
-
{{/if}}
|
|
34
34
|
],
|
|
35
35
|
imports: [
|
|
36
36
|
{{#if (or hasDatabase hasOrm)}}
|
|
@@ -53,6 +53,9 @@ import { AppService } from "./app.service.js";
|
|
|
53
53
|
onError: AppErrorHandler,
|
|
54
54
|
}),
|
|
55
55
|
{{/if}}
|
|
56
|
+
{{#if (and hasTodoExample (or hasRest hasTrpc))}}
|
|
57
|
+
TodoModule,
|
|
58
|
+
{{/if}}
|
|
56
59
|
],
|
|
57
60
|
providers: [
|
|
58
61
|
AppService,
|
|
@@ -63,6 +66,9 @@ import { AppService } from "./app.service.js";
|
|
|
63
66
|
AppContext,
|
|
64
67
|
AppErrorHandler,
|
|
65
68
|
AppRouter,
|
|
69
|
+
{{#if (and hasTrpc hasTodoExample hasRest)}}
|
|
70
|
+
TodoRouter,
|
|
71
|
+
{{/if}}
|
|
66
72
|
{{/if}}
|
|
67
73
|
],
|
|
68
74
|
})
|
|
@@ -86,6 +86,12 @@ async function bootstrap() {
|
|
|
86
86
|
}
|
|
87
87
|
{{/if}}
|
|
88
88
|
await app.listen(env.PORT ?? 3000);
|
|
89
|
+
{{#if hasRest}}
|
|
89
90
|
Logger.log(`Started backend server on http://localhost:${env.PORT ?? 3000}/api`, "Main");
|
|
91
|
+
{{else if hasTrpc}}
|
|
92
|
+
Logger.log(`Started trpc server on http://localhost:${env.PORT ?? 3000}/trpc`, "Main");
|
|
93
|
+
{{else}}
|
|
94
|
+
Logger.log(`Started server on http://localhost:${env.PORT ?? 3000}`, "Main");
|
|
95
|
+
{{/if}}
|
|
90
96
|
}
|
|
91
97
|
await bootstrap();
|
|
@@ -11,7 +11,7 @@ POSTGRES_URL=postgresql://postgres:postgres@localhost:5432/{{projectNameKebab}}_
|
|
|
11
11
|
MYSQL_URL=mysql://root:mysql@localhost:3306/{{projectNameKebab}}_db
|
|
12
12
|
{{/if}}
|
|
13
13
|
{{#if hasSqlite}}
|
|
14
|
-
SQLITE_PATH=
|
|
14
|
+
SQLITE_PATH=file:./src/database/dev.db
|
|
15
15
|
{{/if}}
|
|
16
16
|
{{#if hasMongodb}}
|
|
17
17
|
MONGODB_URL=mongodb://localhost:27017/{{projectNameKebab}}_db
|
|
@@ -92,6 +92,12 @@ async function bootstrap() {
|
|
|
92
92
|
{{/if}}
|
|
93
93
|
|
|
94
94
|
await app.listen(env.PORT ?? 3000);
|
|
95
|
+
{{#if hasRest}}
|
|
95
96
|
Logger.log(`Started backend server on http://localhost:${env.PORT ?? 3000}/api`, "Main");
|
|
97
|
+
{{else if hasTrpc}}
|
|
98
|
+
Logger.log(`Started trpc server on http://localhost:${env.PORT ?? 3000}/trpc`, "Main");
|
|
99
|
+
{{else}}
|
|
100
|
+
Logger.log(`Started server on http://localhost:${env.PORT ?? 3000}`, "Main");
|
|
101
|
+
{{/if}}
|
|
96
102
|
}
|
|
97
103
|
await bootstrap();
|
|
@@ -88,6 +88,12 @@ async function bootstrap() {
|
|
|
88
88
|
{{/if}}
|
|
89
89
|
|
|
90
90
|
await app.listen(env.PORT ?? 3000);
|
|
91
|
+
{{#if hasRest}}
|
|
91
92
|
Logger.log(`Started backend server on http://localhost:${env.PORT ?? 3000}/api`, "Main");
|
|
93
|
+
{{else if hasTrpc}}
|
|
94
|
+
Logger.log(`Started trpc server on http://localhost:${env.PORT ?? 3000}/trpc`, "Main");
|
|
95
|
+
{{else}}
|
|
96
|
+
Logger.log(`Started server on http://localhost:${env.PORT ?? 3000}`, "Main");
|
|
97
|
+
{{/if}}
|
|
92
98
|
}
|
|
93
99
|
await bootstrap();
|
|
@@ -95,6 +95,12 @@ async function bootstrap() {
|
|
|
95
95
|
|
|
96
96
|
await app.startAllMicroservices();
|
|
97
97
|
await app.listen(env.PORT ?? 3000);
|
|
98
|
+
{{#if hasRest}}
|
|
98
99
|
Logger.log(`Started backend server on http://localhost:${env.PORT ?? 3000}/api`, "Main");
|
|
100
|
+
{{else if hasTrpc}}
|
|
101
|
+
Logger.log(`Started trpc server on http://localhost:${env.PORT ?? 3000}/trpc`, "Main");
|
|
102
|
+
{{else}}
|
|
103
|
+
Logger.log(`Started server on http://localhost:${env.PORT ?? 3000}`, "Main");
|
|
104
|
+
{{/if}}
|
|
99
105
|
}
|
|
100
106
|
await bootstrap();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nest-arch/tui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Interactive terminal UI for generating NestJS projects",
|
|
6
6
|
"keywords": [
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"pkgroll": "^2.5.2",
|
|
49
49
|
"tsx": "^4.19.2",
|
|
50
50
|
"vitest": "^4.1.7",
|
|
51
|
-
"@nest-arch/core": "0.2.
|
|
52
|
-
"@nest-arch/
|
|
53
|
-
"@nest-arch/
|
|
51
|
+
"@nest-arch/core": "0.2.3",
|
|
52
|
+
"@nest-arch/shared": "0.0.0",
|
|
53
|
+
"@nest-arch/env": "0.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"typescript": "^5"
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// This script is needed because nestjs-trpc doesn't have support for NestJS 12 yet.
|
|
2
|
-
// Awaiting PR approval to support the new ESM support.
|
|
3
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
|
|
6
|
-
const generatedFile = path.join(
|
|
7
|
-
import.meta.dirname,
|
|
8
|
-
"..",
|
|
9
|
-
"@generated",
|
|
10
|
-
"server.ts"
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
let content = readFileSync(generatedFile, "utf-8");
|
|
14
|
-
|
|
15
|
-
content = content.replaceAll(
|
|
16
|
-
/(?<ext>\.router)(?<quote>")/gu,
|
|
17
|
-
"$<ext>.js$<quote>"
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
writeFileSync(generatedFile, content, "utf-8");
|
|
21
|
-
console.log("Fixed trpc generated file:", generatedFile);
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// This script is needed because nestjs-trpc doesn't have support for NestJS 12 yet.
|
|
2
|
-
// Awaiting PR approval to support the new ESM support.
|
|
3
|
-
import { spawn } from "node:child_process";
|
|
4
|
-
import { watchFile, readFileSync, writeFileSync } from "node:fs";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
|
|
7
|
-
const generatedFile = path.join(
|
|
8
|
-
import.meta.dirname,
|
|
9
|
-
"..",
|
|
10
|
-
"@generated",
|
|
11
|
-
"server.ts"
|
|
12
|
-
);
|
|
13
|
-
const REGEX_REPLACE = /(?<ext>\.router)(?<quote>")/gu;
|
|
14
|
-
|
|
15
|
-
function fixGeneratedFile() {
|
|
16
|
-
try {
|
|
17
|
-
let content = readFileSync(generatedFile, "utf-8");
|
|
18
|
-
const original = content;
|
|
19
|
-
content = content.replaceAll(REGEX_REPLACE, "$<ext>.js$<quote>");
|
|
20
|
-
if (content !== original) {
|
|
21
|
-
writeFileSync(generatedFile, content, "utf-8");
|
|
22
|
-
console.log("Fixed trpc generated file:", generatedFile);
|
|
23
|
-
}
|
|
24
|
-
} catch {
|
|
25
|
-
// file might not exist yet
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Run generate + fix upfront
|
|
30
|
-
const projectRoot = path.join(import.meta.dirname, "..", "..", "..", "..");
|
|
31
|
-
const SHELL = process.platform === "win32" ? "powershell.exe" : true;
|
|
32
|
-
{{#if isMonorepo}}
|
|
33
|
-
const genCmd =
|
|
34
|
-
"pnpm exec nestjs-trpc generate -e src/app.module.ts -o ../../packages/api/src/trpc/@generated";
|
|
35
|
-
{{else}}
|
|
36
|
-
const genCmd =
|
|
37
|
-
"pnpm exec nestjs-trpc generate -e src/app.module.ts -o src/libs/trpc/@generated";
|
|
38
|
-
{{/if}}
|
|
39
|
-
|
|
40
|
-
const spawnOpts = {
|
|
41
|
-
cwd: projectRoot,
|
|
42
|
-
shell: SHELL,
|
|
43
|
-
stdio: "inherit",
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const gen = spawn(genCmd, [], spawnOpts);
|
|
47
|
-
|
|
48
|
-
gen.on("close", (code) => {
|
|
49
|
-
if (code !== 0) {
|
|
50
|
-
process.exit(code);
|
|
51
|
-
}
|
|
52
|
-
fixGeneratedFile();
|
|
53
|
-
|
|
54
|
-
// Watch generated file for changes and re-apply fix
|
|
55
|
-
watchFile(generatedFile, { interval: 500 }, () => {
|
|
56
|
-
fixGeneratedFile();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// Start watch mode
|
|
60
|
-
{{#if isMonorepo}}
|
|
61
|
-
const watch = spawn(
|
|
62
|
-
"pnpm",
|
|
63
|
-
[
|
|
64
|
-
"exec",
|
|
65
|
-
"nestjs-trpc",
|
|
66
|
-
"watch",
|
|
67
|
-
"-e",
|
|
68
|
-
"src/app.module.ts",
|
|
69
|
-
"-o",
|
|
70
|
-
" ../../packages/api/src/trpc/@generated",
|
|
71
|
-
],
|
|
72
|
-
spawnOpts
|
|
73
|
-
);
|
|
74
|
-
{{else}}
|
|
75
|
-
const watch = spawn(
|
|
76
|
-
"pnpm",
|
|
77
|
-
[
|
|
78
|
-
"exec",
|
|
79
|
-
"nestjs-trpc",
|
|
80
|
-
"watch",
|
|
81
|
-
"-e",
|
|
82
|
-
"src/app.module.ts",
|
|
83
|
-
"-o",
|
|
84
|
-
"src/libs/trpc/@generated",
|
|
85
|
-
],
|
|
86
|
-
spawnOpts
|
|
87
|
-
);
|
|
88
|
-
{{/if}}
|
|
89
|
-
|
|
90
|
-
watch.on("close", (exitCode) => process.exit(exitCode ?? 0));
|
|
91
|
-
});
|