@nestia/migrate 0.5.0 → 0.6.0

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.
Files changed (72) hide show
  1. package/lib/NestiaMigrateApplication.js +15 -15
  2. package/lib/NestiaMigrateApplication.js.map +1 -1
  3. package/lib/archivers/FileArchiver.js.map +1 -1
  4. package/lib/bundles/TEMPLATE.js +11 -11
  5. package/lib/bundles/TEMPLATE.js.map +1 -1
  6. package/lib/executable/bundle.js.map +1 -1
  7. package/lib/executable/migrate.js +5 -5
  8. package/lib/executable/migrate.js.map +1 -1
  9. package/lib/programmers/ControllerProgrammer.d.ts +2 -1
  10. package/lib/programmers/ControllerProgrammer.js +21 -18
  11. package/lib/programmers/ControllerProgrammer.js.map +1 -1
  12. package/lib/programmers/DtoProgrammer.d.ts +8 -4
  13. package/lib/programmers/DtoProgrammer.js +36 -77
  14. package/lib/programmers/DtoProgrammer.js.map +1 -1
  15. package/lib/programmers/ImportProgrammer.d.ts +5 -5
  16. package/lib/programmers/ImportProgrammer.js +27 -19
  17. package/lib/programmers/ImportProgrammer.js.map +1 -1
  18. package/lib/programmers/MigrateProgrammer.d.ts +1 -2
  19. package/lib/programmers/MigrateProgrammer.js +52 -36
  20. package/lib/programmers/MigrateProgrammer.js.map +1 -1
  21. package/lib/programmers/ModuleProgrammer.d.ts +5 -0
  22. package/lib/programmers/ModuleProgrammer.js +29 -0
  23. package/lib/programmers/ModuleProgrammer.js.map +1 -0
  24. package/lib/programmers/RouteProgrammer.d.ts +2 -2
  25. package/lib/programmers/RouteProgrammer.js +108 -111
  26. package/lib/programmers/RouteProgrammer.js.map +1 -1
  27. package/lib/programmers/SchemaProgrammer.d.ts +2 -1
  28. package/lib/programmers/SchemaProgrammer.js +122 -189
  29. package/lib/programmers/SchemaProgrammer.js.map +1 -1
  30. package/lib/structures/IMigrateProgram.d.ts +2 -2
  31. package/lib/structures/ISwaggerInfo.d.ts +3 -3
  32. package/lib/utils/FilePrinter.d.ts +9 -0
  33. package/lib/utils/FilePrinter.js +25 -0
  34. package/lib/utils/FilePrinter.js.map +1 -0
  35. package/lib/utils/JsonTypeChecker.d.ts +3 -1
  36. package/lib/utils/JsonTypeChecker.js +31 -18
  37. package/lib/utils/JsonTypeChecker.js.map +1 -1
  38. package/lib/utils/MapUtil.js.map +1 -1
  39. package/lib/utils/SetupWizard.js.map +1 -1
  40. package/lib/utils/StringUtil.js.map +1 -1
  41. package/package.json +11 -9
  42. package/src/NestiaMigrateApplication.ts +68 -73
  43. package/src/archivers/FileArchiver.ts +35 -38
  44. package/src/bundles/TEMPLATE.ts +11 -11
  45. package/src/executable/bundle.ts +72 -78
  46. package/src/executable/migrate.ts +59 -60
  47. package/src/index.ts +4 -4
  48. package/src/module.ts +4 -4
  49. package/src/programmers/ControllerProgrammer.ts +155 -157
  50. package/src/programmers/DtoProgrammer.ts +74 -118
  51. package/src/programmers/ImportProgrammer.ts +98 -60
  52. package/src/programmers/MigrateProgrammer.ts +75 -62
  53. package/src/programmers/ModuleProgrammer.ts +62 -0
  54. package/src/programmers/RouteProgrammer.ts +486 -466
  55. package/src/programmers/SchemaProgrammer.ts +247 -339
  56. package/src/structures/IMigrateController.ts +8 -8
  57. package/src/structures/IMigrateDto.ts +8 -8
  58. package/src/structures/IMigrateFile.ts +5 -5
  59. package/src/structures/IMigrateProgram.ts +7 -7
  60. package/src/structures/IMigrateRoute.ts +36 -36
  61. package/src/structures/IMigrateSchema.ts +4 -4
  62. package/src/structures/ISwaggeSchema.ts +82 -82
  63. package/src/structures/ISwagger.ts +20 -20
  64. package/src/structures/ISwaggerComponents.ts +7 -7
  65. package/src/structures/ISwaggerInfo.ts +57 -57
  66. package/src/structures/ISwaggerRoute.ts +52 -52
  67. package/src/structures/ISwaggerSecurity.ts +47 -47
  68. package/src/utils/FilePrinter.ts +36 -0
  69. package/src/utils/JsonTypeChecker.ts +67 -52
  70. package/src/utils/MapUtil.ts +13 -13
  71. package/src/utils/SetupWizard.ts +15 -15
  72. package/src/utils/StringUtil.ts +51 -51
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestia/migrate",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Migration program from swagger to NestJS",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "scripts": {
11
11
  "build": "rimraf lib && tsc",
12
12
  "dev": "npm run build -- --watch",
13
- "prepare": "ts-patch install && ts-node src/executable/bundle.ts",
13
+ "prepare": "ts-patch install && typia patch && ts-node src/executable/bundle.ts",
14
14
  "test": "node lib/test"
15
15
  },
16
16
  "repository": {
@@ -30,25 +30,27 @@
30
30
  },
31
31
  "homepage": "https://github.com/samchon/nestia#readme",
32
32
  "devDependencies": {
33
- "@nestia/core": "^2.3.10",
34
- "@nestia/fetcher": "^2.3.10",
35
- "@trivago/prettier-plugin-sort-imports": "^4.1.1",
33
+ "@nestia/core": "^2.4.0",
34
+ "@nestia/fetcher": "^2.4.0",
35
+ "@nestjs/common": "^10.3.1",
36
+ "@nestjs/core": "^10.3.1",
37
+ "@nestjs/platform-express": "^10.3.1",
38
+ "@nestjs/platform-fastify": "^10.3.1",
36
39
  "@types/express": "^4.17.21",
37
40
  "@types/node": "^20.3.3",
38
41
  "dotenv": "^16.3.1",
39
42
  "dotenv-expand": "^10.0.0",
40
- "prettier": "^2.8.8",
41
43
  "rimraf": "^5.0.1",
42
44
  "serialize-error": "^4.1.0",
43
45
  "source-map-support": "^0.5.21",
44
46
  "ts-node": "^10.9.1",
45
- "ts-patch": "^3.0.2",
47
+ "ts-patch": "^3.1.0",
46
48
  "tstl": "^2.5.13",
47
- "typescript": "^5.2.2",
48
49
  "typescript-transform-paths": "^3.4.6"
49
50
  },
50
51
  "dependencies": {
51
- "typia": "^5.2.6"
52
+ "typia": "^5.4.1",
53
+ "typescript": "^5.3.3"
52
54
  },
53
55
  "files": [
54
56
  "lib",
@@ -1,73 +1,68 @@
1
- import cp from "child_process";
2
-
3
- import typia from "typia";
4
-
5
- import { FileArchiver } from "./archivers/FileArchiver";
6
- import { TEMPLATE } from "./bundles/TEMPLATE";
7
- import { MigrateProgrammer } from "./programmers/MigrateProgrammer";
8
- import { IMigrateFile } from "./structures/IMigrateFile";
9
- import { IMigrateProgram } from "./structures/IMigrateProgram";
10
- import { ISwagger } from "./structures/ISwagger";
11
-
12
- export class NestiaMigrateApplication {
13
- public readonly swagger: ISwagger;
14
- private program: IMigrateProgram | null;
15
- private files: IMigrateFile[] | null;
16
-
17
- public constructor(swagger: ISwagger) {
18
- this.swagger = typia.assert(swagger);
19
- this.program = null;
20
- this.files = null;
21
- }
22
-
23
- public analyze(): IMigrateProgram {
24
- if (this.program === null)
25
- this.program = MigrateProgrammer.analyze(this.swagger);
26
- return this.program;
27
- }
28
-
29
- public write(): IMigrateFile[] {
30
- if (this.files === null) {
31
- const program: IMigrateProgram = this.analyze();
32
- this.files = MigrateProgrammer.write(this.swagger.components)(
33
- program,
34
- );
35
- }
36
- return this.files;
37
- }
38
-
39
- public generate =
40
- (archiver: NestiaMigrateApplication.IArchiver) =>
41
- (output: string): void => {
42
- const program: IMigrateProgram = this.analyze();
43
- const files: IMigrateFile[] = MigrateProgrammer.write(
44
- this.swagger.components,
45
- )(program);
46
-
47
- try {
48
- cp.execSync(
49
- `git clone https://github.com/samchon/nestia-template "${output}"`,
50
- { stdio: "ignore" },
51
- );
52
- for (const path of [
53
- "/.git",
54
- "/src/api",
55
- "/src/controllers",
56
- "/src/providers",
57
- "/test/features",
58
- ])
59
- cp.execSync(`rm -rf "${output}${path}"`, {
60
- stdio: "ignore",
61
- });
62
- } catch {
63
- FileArchiver.archive(archiver)(output)(TEMPLATE);
64
- }
65
- FileArchiver.archive(archiver)(output)(files);
66
- };
67
- }
68
- export namespace NestiaMigrateApplication {
69
- export interface IArchiver {
70
- mkdir: (path: string) => void;
71
- writeFile: (path: string, content: string) => void;
72
- }
73
- }
1
+ import cp from "child_process";
2
+ import typia from "typia";
3
+
4
+ import { FileArchiver } from "./archivers/FileArchiver";
5
+ import { TEMPLATE } from "./bundles/TEMPLATE";
6
+ import { MigrateProgrammer } from "./programmers/MigrateProgrammer";
7
+ import { IMigrateFile } from "./structures/IMigrateFile";
8
+ import { IMigrateProgram } from "./structures/IMigrateProgram";
9
+ import { ISwagger } from "./structures/ISwagger";
10
+
11
+ export class NestiaMigrateApplication {
12
+ public readonly swagger: ISwagger;
13
+ private program: IMigrateProgram | null;
14
+ private files: IMigrateFile[] | null;
15
+
16
+ public constructor(swagger: ISwagger) {
17
+ this.swagger = typia.assert(swagger);
18
+ this.program = null;
19
+ this.files = null;
20
+ }
21
+
22
+ public analyze(): IMigrateProgram {
23
+ if (this.program === null)
24
+ this.program = MigrateProgrammer.analyze(this.swagger);
25
+ return this.program;
26
+ }
27
+
28
+ public write(): IMigrateFile[] {
29
+ if (this.files === null) {
30
+ const program: IMigrateProgram = this.analyze();
31
+ this.files = MigrateProgrammer.write(program);
32
+ }
33
+ return this.files;
34
+ }
35
+
36
+ public generate =
37
+ (archiver: NestiaMigrateApplication.IArchiver) =>
38
+ (output: string): void => {
39
+ const program: IMigrateProgram = this.analyze();
40
+ const files: IMigrateFile[] = MigrateProgrammer.write(program);
41
+
42
+ try {
43
+ cp.execSync(
44
+ `git clone https://github.com/samchon/nestia-template "${output}"`,
45
+ { stdio: "ignore" },
46
+ );
47
+ for (const path of [
48
+ "/.git",
49
+ "/src/api",
50
+ "/src/controllers",
51
+ "/src/providers",
52
+ "/test/features",
53
+ ])
54
+ cp.execSync(`rm -rf "${output}${path}"`, {
55
+ stdio: "ignore",
56
+ });
57
+ } catch {
58
+ FileArchiver.archive(archiver)(output)(TEMPLATE);
59
+ }
60
+ FileArchiver.archive(archiver)(output)(files);
61
+ };
62
+ }
63
+ export namespace NestiaMigrateApplication {
64
+ export interface IArchiver {
65
+ mkdir: (path: string) => void;
66
+ writeFile: (path: string, content: string) => void;
67
+ }
68
+ }
@@ -1,38 +1,35 @@
1
- import { IMigrateFile } from "../structures/IMigrateFile";
2
-
3
- export namespace FileArchiver {
4
- export interface IOperator {
5
- mkdir(path: string): void;
6
- writeFile(path: string, content: string): void;
7
- }
8
-
9
- export const archive =
10
- (operator: IOperator) =>
11
- (output: string) =>
12
- (files: IMigrateFile[]): void => {
13
- const visited: Set<string> = new Set();
14
- for (const f of files) {
15
- mkdir(operator.mkdir)(output)(visited)(f.location);
16
- operator.writeFile(
17
- [output, f.location, f.file].join("/"),
18
- f.content,
19
- );
20
- }
21
- };
22
-
23
- const mkdir =
24
- (creator: (path: string) => void) =>
25
- (output: string) =>
26
- (visited: Set<string>) =>
27
- (path: string): void => {
28
- const sequence: string[] = path
29
- .split("/")
30
- .map((_str, i, entire) => entire.slice(0, i + 1).join("/"));
31
- for (const s of sequence)
32
- if (visited.has(s) === false)
33
- try {
34
- creator([output, s].join("/"));
35
- visited.add(s);
36
- } catch {}
37
- };
38
- }
1
+ import { IMigrateFile } from "../structures/IMigrateFile";
2
+
3
+ export namespace FileArchiver {
4
+ export interface IOperator {
5
+ mkdir(path: string): void;
6
+ writeFile(path: string, content: string): void;
7
+ }
8
+
9
+ export const archive =
10
+ (operator: IOperator) =>
11
+ (output: string) =>
12
+ (files: IMigrateFile[]): void => {
13
+ const visited: Set<string> = new Set();
14
+ for (const f of files) {
15
+ mkdir(operator.mkdir)(output)(visited)(f.location);
16
+ operator.writeFile([output, f.location, f.file].join("/"), f.content);
17
+ }
18
+ };
19
+
20
+ const mkdir =
21
+ (creator: (path: string) => void) =>
22
+ (output: string) =>
23
+ (visited: Set<string>) =>
24
+ (path: string): void => {
25
+ const sequence: string[] = path
26
+ .split("/")
27
+ .map((_str, i, entire) => entire.slice(0, i + 1).join("/"));
28
+ for (const s of sequence)
29
+ if (visited.has(s) === false)
30
+ try {
31
+ creator([output, s].join("/"));
32
+ visited.add(s);
33
+ } catch {}
34
+ };
35
+ }
@@ -7,12 +7,12 @@ export const TEMPLATE = [
7
7
  {
8
8
  "location": "",
9
9
  "file": ".eslintrc.cjs",
10
- "content": "module.exports = {\r\n root: true,\r\n plugins: [\r\n \"@typescript-eslint\",\r\n \"deprecation\",\r\n ],\r\n extends: [\r\n \"plugin:@typescript-eslint/recommended\",\r\n ],\r\n parser: \"@typescript-eslint/parser\",\r\n parserOptions: {\r\n project: [\r\n \"tsconfig.json\",\r\n \"test/tsconfig.json\",\r\n ]\r\n },\r\n overrides: [\r\n {\r\n files: [\"src/**/*.ts\", \"test/**/*.ts\"],\r\n rules: {\r\n \"@typescript-eslint/no-duplicate-imports\": \"error\",\r\n \"@typescript-eslint/no-explicit-any\": \"off\",\r\n \"@typescript-eslint/no-floating-promises\": \"error\",\r\n \"@typescript-eslint/no-inferrable-types\": \"off\",\r\n \"@typescript-eslint/no-namespace\": \"off\",\r\n \"@typescript-eslint/no-non-null-assertion\": \"off\",\r\n \"@typescript-eslint/no-var-requires\": \"off\",\r\n \"deprecation/deprecation\": \"error\",\r\n }\r\n }\r\n ]\r\n};"
10
+ "content": "module.exports = {\r\n root: true,\r\n plugins: [\"@typescript-eslint\", \"deprecation\"],\r\n extends: [\"plugin:@typescript-eslint/recommended\"],\r\n parser: \"@typescript-eslint/parser\",\r\n parserOptions: {\r\n project: [\"tsconfig.json\", \"test/tsconfig.json\"],\r\n },\r\n overrides: [\r\n {\r\n files: [\"src/**/*.ts\", \"test/**/*.ts\"],\r\n rules: {\r\n \"@typescript-eslint/no-explicit-any\": \"off\",\r\n \"@typescript-eslint/no-floating-promises\": \"error\",\r\n \"@typescript-eslint/no-inferrable-types\": \"off\",\r\n \"@typescript-eslint/no-namespace\": \"off\",\r\n \"@typescript-eslint/no-non-null-assertion\": \"off\",\r\n \"@typescript-eslint/no-var-requires\": \"off\",\r\n \"deprecation/deprecation\": \"error\",\r\n },\r\n },\r\n ],\r\n};\r\n"
11
11
  },
12
12
  {
13
13
  "location": "/.github",
14
14
  "file": "dependabot.yml",
15
- "content": "version: 2\r\nupdates:\r\n#######################################################\r\n - package-ecosystem: 'npm'\r\n directory: '/'\r\n schedule:\r\n interval: 'daily'\r\n open-pull-requests-limit: 25\r\n versioning-strategy: increase\r\n allow:\r\n - dependency-name: \"@nestia/*\"\r\n - dependency-name: \"nestia\"\r\n - dependency-name: \"tstl\"\r\n - dependency-name: \"typia\"\r\n#######################################################\r\n - package-ecosystem: 'npm'\r\n directory: '/packages/api'\r\n schedule:\r\n interval: 'daily'\r\n open-pull-requests-limit: 25\r\n versioning-strategy: increase\r\n#######################################################"
15
+ "content": "version: 2\r\nupdates:\r\n#######################################################\r\n - package-ecosystem: 'npm'\r\n directory: '/'\r\n schedule:\r\n interval: 'daily'\r\n open-pull-requests-limit: 25\r\n allow:\r\n - dependency-name: \"@nestjs/*\"\r\n - dependency-name: \"@nestia/*\"\r\n - dependency-name: \"nestia\"\r\n - dependency-name: \"tstl\"\r\n - dependency-name: \"typia\"\r\n#######################################################\r\n - package-ecosystem: 'npm'\r\n directory: '/packages/api'\r\n schedule:\r\n interval: 'daily'\r\n open-pull-requests-limit: 25\r\n#######################################################"
16
16
  },
17
17
  {
18
18
  "location": "/.github/workflows",
@@ -22,7 +22,7 @@ export const TEMPLATE = [
22
22
  {
23
23
  "location": "",
24
24
  "file": ".gitignore",
25
- "content": ".git/\r\nbin/\r\ndist/\r\nlib/\r\nnode_modules/\r\npackages/api/lib/\r\n\r\npackage-lock.json"
25
+ "content": ".git/\r\nbin/\r\ndist/\r\nlib/\r\nnode_modules/\r\npackages/api/lib/\r\n\r\npackage-lock.json\r\npnpm-lock.yaml"
26
26
  },
27
27
  {
28
28
  "location": "",
@@ -37,7 +37,7 @@ export const TEMPLATE = [
37
37
  {
38
38
  "location": "/.vscode",
39
39
  "file": "settings.json",
40
- "content": "{\r\n \"editor.tabSize\": 2,\r\n \"[typescript]\": {\r\n \"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\r\n \"editor.formatOnSave\": true,\r\n \"editor.codeActionsOnSave\": {\r\n \"source.fixAll.eslint\": true\r\n },\r\n },\r\n \"[javascript]\": {\r\n \"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\r\n \"editor.formatOnSave\": true,\r\n \"editor.codeActionsOnSave\": {\r\n \"source.fixAll.eslint\": true\r\n },\r\n }\r\n}"
40
+ "content": "{\r\n \"editor.tabSize\": 2,\r\n \"editor.formatOnSave\": true,\r\n \"[javascript][typescript]\": {\r\n \"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\r\n \"editor.codeActionsOnSave\": {\r\n \"source.fixAll.eslint\": \"explicit\"\r\n },\r\n }\r\n}"
41
41
  },
42
42
  {
43
43
  "location": "",
@@ -52,7 +52,7 @@ export const TEMPLATE = [
52
52
  {
53
53
  "location": "",
54
54
  "file": "package.json",
55
- "content": "{\r\n \"private\": true,\r\n \"name\": \"@ORGANIZATION/PROJECT\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"Starter kit of Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"scripts\": {\r\n \"test\": \"node bin/test\",\r\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\r\n \"------------------------BUILDS------------------------\": \"\",\r\n \"build\": \"npm run build:sdk && npm run build:main && npm run build:test\",\r\n \"build:api\": \"rimraf packages/api/lib && npm run build:sdk && tsc -p packages/api/tsconfig.json\",\r\n \"build:main\": \"rimraf lib && tsc\",\r\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\r\n \"build:swagger\": \"npx nestia swagger\",\r\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\r\n \"dev\": \"npm run build:test -- --watch\",\r\n \"eslint\": \"eslint src && eslint test\",\r\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\r\n \"prepare\": \"ts-patch install\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"------------------------WEBPACK------------------------\": \"\",\r\n \"webpack\": \"rimraf dist && webpack\",\r\n \"webpack:start\": \"cd dist && node dist/server\",\r\n \"------------------------DEPLOYS------------------------\": \"\",\r\n \"package:api\": \"npm run build:swagger && npm run build:api && cd packages/api && npm publish\",\r\n \"start\": \"node lib/executable/server\",\r\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\r\n },\r\n \"keywords\": [\r\n \"nestia\",\r\n \"template\",\r\n \"boilerplate\"\r\n ],\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.4.0\",\r\n \"@nestia/sdk\": \"^2.3.10\",\r\n \"@trivago/prettier-plugin-sort-imports\": \"^3.3.1\",\r\n \"@types/cli\": \"^0.11.21\",\r\n \"@types/express\": \"^4.17.21\",\r\n \"@types/inquirer\": \"^8.2.5\",\r\n \"@types/node\": \"^18.11.0\",\r\n \"@types/uuid\": \"^8.3.4\",\r\n \"@typescript-eslint/eslint-plugin\": \"^5.40.0\",\r\n \"@typescript-eslint/parser\": \"^5.40.0\",\r\n \"chalk\": \"^4.1.0\",\r\n \"cli\": \"^1.0.1\",\r\n \"copy-webpack-plugin\": \"^11.0.0\",\r\n \"eslint-plugin-deprecation\": \"^1.4.1\",\r\n \"express\": \"^4.18.2\",\r\n \"nestia\": \"^5.0.3\",\r\n \"prettier\": \"^2.7.1\",\r\n \"rimraf\": \"^3.0.2\",\r\n \"source-map-support\": \"^0.5.21\",\r\n \"swagger-ui-express\": \"^5.0.0\",\r\n \"ts-loader\": \"^9.5.1\",\r\n \"ts-node\": \"^10.9.1\",\r\n \"ts-patch\": \"^3.0.0\",\r\n \"typescript\": \"^5.2.2\",\r\n \"typescript-transform-paths\": \"^3.4.6\",\r\n \"webpack\": \"^5.89.0\",\r\n \"webpack-cli\": \"^5.1.4\",\r\n \"write-file-webpack-plugin\": \"^4.5.1\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/core\": \"^2.3.10\",\r\n \"@nestjs/common\": \"^10.2.10\",\r\n \"@nestjs/core\": \"^10.2.10\",\r\n \"@nestjs/platform-fastify\": \"^10.2.10\",\r\n \"dotenv\": \"^16.3.1\",\r\n \"dotenv-expand\": \"^10.0.0\",\r\n \"serialize-error\": \"^4.1.0\",\r\n \"tstl\": \"^2.5.13\",\r\n \"typia\": \"^5.2.6\",\r\n \"uuid\": \"^9.0.0\"\r\n },\r\n \"stackblitz\": {\r\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test\"\r\n }\r\n}\r\n"
55
+ "content": "{\r\n \"private\": true,\r\n \"name\": \"@ORGANIZATION/PROJECT\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"Starter kit of Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"scripts\": {\r\n \"test\": \"node bin/test\",\r\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\r\n \"------------------------BUILDS------------------------\": \"\",\r\n \"build\": \"npm run build:sdk && npm run build:main && npm run build:test\",\r\n \"build:api\": \"rimraf packages/api/lib && npm run build:sdk && tsc -p packages/api/tsconfig.json\",\r\n \"build:main\": \"rimraf lib && tsc\",\r\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\r\n \"build:swagger\": \"npx nestia swagger\",\r\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\r\n \"dev\": \"npm run build:test -- --watch\",\r\n \"eslint\": \"eslint src && eslint test\",\r\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\r\n \"prepare\": \"ts-patch install && typia patch\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"------------------------WEBPACK------------------------\": \"\",\r\n \"webpack\": \"rimraf dist && webpack\",\r\n \"webpack:start\": \"cd dist && node dist/server\",\r\n \"------------------------DEPLOYS------------------------\": \"\",\r\n \"package:api\": \"npm run build:swagger && npm run build:api && cd packages/api && npm publish\",\r\n \"start\": \"node lib/executable/server\",\r\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-start\"\r\n },\r\n \"keywords\": [\r\n \"nestia\",\r\n \"template\",\r\n \"boilerplate\"\r\n ],\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-start/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-start#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.4.1\",\r\n \"@nestia/sdk\": \"^2.4.5\",\r\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\r\n \"@types/cli\": \"^0.11.21\",\r\n \"@types/express\": \"^4.17.21\",\r\n \"@types/inquirer\": \"^8.2.5\",\r\n \"@types/node\": \"^18.11.0\",\r\n \"@types/uuid\": \"^8.3.4\",\r\n \"@typescript-eslint/eslint-plugin\": \"^6.19.1\",\r\n \"@typescript-eslint/parser\": \"^6.19.1\",\r\n \"chalk\": \"^4.1.0\",\r\n \"cli\": \"^1.0.1\",\r\n \"copy-webpack-plugin\": \"^11.0.0\",\r\n \"eslint-plugin-deprecation\": \"^2.0.0\",\r\n \"express\": \"^4.18.2\",\r\n \"nestia\": \"^5.1.2\",\r\n \"prettier\": \"^3.2.4\",\r\n \"prettier-plugin-prisma\": \"^5.0.0\",\r\n \"rimraf\": \"^3.0.2\",\r\n \"source-map-support\": \"^0.5.21\",\r\n \"swagger-ui-express\": \"^5.0.0\",\r\n \"ts-loader\": \"^9.5.1\",\r\n \"ts-node\": \"^10.9.1\",\r\n \"ts-patch\": \"^3.0.2\",\r\n \"typescript\": \"^5.3.2\",\r\n \"typescript-transform-paths\": \"^3.4.6\",\r\n \"webpack\": \"^5.89.0\",\r\n \"webpack-cli\": \"^5.1.4\",\r\n \"write-file-webpack-plugin\": \"^4.5.1\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/core\": \"^2.4.5\",\r\n \"@nestia/fetcher\": \"^2.4.5\",\r\n \"@nestjs/common\": \"^10.3.0\",\r\n \"@nestjs/core\": \"^10.3.0\",\r\n \"@nestjs/platform-fastify\": \"^10.3.0\",\r\n \"commander\": \"10.0.0\",\r\n \"dotenv\": \"^16.3.1\",\r\n \"dotenv-expand\": \"^10.0.0\",\r\n \"inquirer\": \"8.2.5\",\r\n \"serialize-error\": \"^4.1.0\",\r\n \"tstl\": \"^2.5.13\",\r\n \"typia\": \"^5.3.12\",\r\n \"uuid\": \"^9.0.0\"\r\n },\r\n \"stackblitz\": {\r\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test\"\r\n }\r\n}"
56
56
  },
57
57
  {
58
58
  "location": "/packages/api",
@@ -67,7 +67,7 @@ export const TEMPLATE = [
67
67
  {
68
68
  "location": "/packages/api",
69
69
  "file": "package.json",
70
- "content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"SDK library generated by Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"scripts\": {\r\n \"build\": \"npm run build:sdk && npm run compile\",\r\n \"build:sdk\": \"rimraf ../../src/api/functional && cd ../.. && npx nestia sdk && cd packages/api\",\r\n \"compile\": \"rimraf lib && tsc\",\r\n \"deploy\": \"npm run build && npm publish\",\r\n \"prepare\": \"ts-patch install\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia\"\r\n },\r\n \"author\": \"Jeongho Nam\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia/issues\"\r\n },\r\n \"homepage\": \"https://nestia.io\",\r\n \"files\": [\r\n \"lib\",\r\n \"swagger.json\",\r\n \"package.json\",\r\n \"README.md\"\r\n ],\r\n \"devDependencies\": {\r\n \"rimraf\": \"^5.0.5\",\r\n \"ts-node\": \"^10.9.1\",\r\n \"ts-patch\": \"^3.0.2\",\r\n \"typescript\": \"^5.2.2\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^2.3.10\",\r\n \"typia\": \"^5.2.6\"\r\n }\r\n}"
70
+ "content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"SDK library generated by Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"scripts\": {\r\n \"build\": \"npm run build:sdk && npm run compile\",\r\n \"build:sdk\": \"rimraf ../../src/api/functional && cd ../.. && npx nestia sdk && cd packages/api\",\r\n \"compile\": \"rimraf lib && tsc\",\r\n \"deploy\": \"npm run build && npm publish\",\r\n \"prepare\": \"ts-patch install && typia patch\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia\"\r\n },\r\n \"author\": \"Jeongho Nam\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia/issues\"\r\n },\r\n \"homepage\": \"https://nestia.io\",\r\n \"files\": [\r\n \"lib\",\r\n \"swagger.json\",\r\n \"package.json\",\r\n \"README.md\"\r\n ],\r\n \"devDependencies\": {\r\n \"rimraf\": \"^5.0.5\",\r\n \"ts-node\": \"^10.9.2\",\r\n \"ts-patch\": \"^3.1.2\",\r\n \"typescript\": \"^5.3.3\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^2.4.5\",\r\n \"typia\": \"^5.3.12\"\r\n }\r\n}"
71
71
  },
72
72
  {
73
73
  "location": "/packages/api",
@@ -82,12 +82,12 @@ export const TEMPLATE = [
82
82
  {
83
83
  "location": "",
84
84
  "file": "prettier.config.js",
85
- "content": "module.exports = {\r\n parser: \"typescript\",\r\n printWidth: 80,\r\n semi: true,\r\n tabWidth: 2,\r\n trailingComma: \"all\",\r\n importOrder: [\r\n \"<THIRD_PARTY_MODULES>\",\r\n \"^@ORGANIZATION/PROJECT-api(.*)$\",\r\n \"^[./]\",\r\n ],\r\n importOrderSeparation: true,\r\n importOrderSortSpecifiers: true,\r\n importOrderParserPlugins: [\"decorators-legacy\", \"typescript\"],\r\n};\r\n"
85
+ "content": "module.exports = {\r\n // DEFAULT CONFIGURATIONS\r\n parser: \"typescript\",\r\n printWidth: 80,\r\n semi: true,\r\n tabWidth: 2,\r\n trailingComma: \"all\",\r\n\r\n // PLUG-IN CONFIGURATIONS\r\n plugins: [\"@trivago/prettier-plugin-sort-imports\"],\r\n importOrder: [\r\n \"<THIRD_PARTY_MODULES>\",\r\n \"^@ORGANIZATION/PROJECT-api(.*)$\",\r\n \"^[./]\",\r\n ],\r\n importOrderSeparation: true,\r\n importOrderSortSpecifiers: true,\r\n importOrderParserPlugins: [\"decorators-legacy\", \"typescript\"],\r\n};\r\n"
86
86
  },
87
87
  {
88
88
  "location": "",
89
89
  "file": "README.md",
90
- "content": "# Nestia Template\r\n## Outline\r\n[![Build Status](https://github.com/samchon/nestia-template/workflows/build/badge.svg)](https://github.com/samchon/nestia-template/actions?query=workflow%3Abuild)\r\n\r\nA template repository for backend projects using [nestia](https://github.com/samchon/nestia).\r\n\r\nYou can create a new project from this boilerplate by running below command:\r\n\r\n```bash\r\nnpx nestia start <directory>\r\n```\r\n\r\nFor reference, this is a minimal boilerplate project concentrating only on [nestia](https://github.com/samchon/nestia) SDK generation. If you wanna much detailed boilerplate project even configured DB and Non-distruptive update system, visit [samchon/backend](https://github.com/samchon/backend) and create a new repository from that.\r\n\r\n\r\n\r\n\r\n## Directories and Files\r\nThis template project has categorized directories like below.\r\n\r\nAs you can see from the below, all of the Backend source files are placed into the [src](src/) directory. When you build the TypeScript source files, compiled files would be placed into the `lib` directory following the [tsconfig.json](tsconfig.json) configuration. Otherwise you build client [SDK](#32-sdk) library for npm publishing and their compiled files would be placed into the [packages](packages) directory.\r\n\r\n - [packages/api/](packages/api): SDK module built by `npm run build:api`\r\n - [src/](src): Backend source directory\r\n - [src/api/](src/api/): Client SDK that would be published to the `@ORGANIZATION/PROJECT-api`\r\n - [**src/api/functional/**](src/api/functional/): API functions generated by the [`nestia`](https://github.com/samchon/nestia)\r\n - [**src/api/structures/**](src/api/structures/): DTO structures\r\n - [src/controllers/](src/controllers/): Controller classes of the Main Program\r\n - [**test/**](test): Test Automation Program\r\n - [nestia.config.ts](nestia.config.ts): Configuration file of [`nestia`](https://github.com/samchon/nestia)\r\n - [package.json](package.json): NPM configuration\r\n - [tsconfig.json](tsconfig.json): TypeScript configuration for the main program\r\n - [tsconfig.api.json](tsconfig.api.json): TypeScript configuration for the SDK generation\r\n\r\n\r\n\r\n\r\n## NPM Run Commands\r\nList of the run commands defined in the [package.json](package.json) are like below:\r\n\r\n - `build`: Build everything\r\n - `build:api`: Build client SDK libray for the client developers\r\n - `build:main`: Build main program (`src` directory)\r\n - `build:sdk`: Build SDK into main program only\r\n - `build:swagger`: Build Swagger Documents\r\n - `build:test` Build test automation program (`test` directory)\r\n - `dev`: Incremental build for development (test program)\r\n - `eslint` & `eslint:fix` & `prettier`: Prettier and ESLint execution\r\n - `start`: Start local NestJS server\r\n - `test`: Run test automation program\r\n\r\n\r\n\r\n\r\n## Specialization\r\nTransform this template project to be yours.\r\n\r\nWhen you've created a new backend project through this template project, you can specialize it to be suitable for you by changing some words. Replace below words through IDE specific function like `Edit > Replace in Files` (*Ctrl + Shift + H*), who've been supported by the VSCode.\r\n\r\n| Before | After\r\n|-----------------|----------------------------------------\r\n| ORGANIZATION | Your account or corporation name\r\n| PROJECT | Your own project name\r\n| AUTHOR | Author name\r\n| https://github.com/samchon/nestia-template | Your repository URL\r\n\r\n\r\n\r\n\r\n## Test Driven Development\r\nWith [nestia](https://github.com/samchon/nestia) helps to accomplish TDD (Test Driven Development). \r\n\r\nJust define DTOs and API controllers' methods (only declarations) first. After the definitions, and build SDK (Software Development Kit) through [nestia](https://github.com/samchon/nestia) (`npm run build:sdk`). After buildling those SDK, develop test automation program using the SDK, following use-case scenarios in the framework of client side.\r\n\r\nDuring the test automation program development, you can find that which API is mis-designed or which requirement analysis is not exact. Development of the main program must be the last step after such validation process during TDD.\r\n\r\n> Visit the [samchon/backend](https://github.com/samchon/backend), then you may find much detailed story about this TDD.\r\n>\r\n> 1. Definitions\r\n> 2. SDK\r\n> 3. Test Automation Program\r\n> 4. Main Program\r\n\r\n```typescript\r\nimport typia from \"typia\";\r\n\r\nimport api from \"@ORGANIZATION/PROJECT-api/lib/index\";\r\nimport { IBbsArticle } from \"@ORGANIZATION/PROJECT-api/lib/structures/bbs/IBbsArticle\";\r\n\r\nimport { ArrayUtil } from \"../../../../utils/ArrayUtil\";\r\nimport { GaffComparator } from \"../../../internal/GaffComparator\";\r\nimport { RandomGenerator } from \"../../../internal/RandomGenerator\";\r\nimport { validate_index_sort } from \"../../../internal/validate_index_sort\";\r\n\r\nexport async function test_api_bbs_article_index_sort(\r\n connection: api.IConnection,\r\n): Promise<void> {\r\n // GENERATE 100 ARTICLES\r\n const section: string = \"general\";\r\n const articles: IBbsArticle[] = await ArrayUtil.asyncRepeat(100, () =>\r\n api.functional.bbs.articles.store(connection, section, {\r\n writer: RandomGenerator.name(),\r\n title: RandomGenerator.paragraph(),\r\n body: RandomGenerator.content(),\r\n format: \"txt\",\r\n files: [],\r\n password: RandomGenerator.alphabets(8),\r\n }),\r\n );\r\n typia.assertEquals(articles);\r\n\r\n // PREPARE VALIDATOR\r\n const validator = validate_index_sort(\"BbsArticleProvider.index()\")(\r\n (input: IBbsArticle.IRequest) =>\r\n api.functional.bbs.articles.index(connection, section, input),\r\n );\r\n\r\n // DO VALIDATE\r\n const components = [\r\n validator(\"created_at\")(GaffComparator.dates((x) => x.created_at)),\r\n validator(\"updated_at\")(GaffComparator.dates((x) => x.updated_at)),\r\n validator(\"title\")(GaffComparator.strings((x) => x.title)),\r\n validator(\"writer\")(GaffComparator.strings((x) => x.writer)),\r\n validator(\r\n \"writer\",\r\n \"title\",\r\n )(GaffComparator.strings((x) => [x.writer, x.title])),\r\n ];\r\n for (const comp of components) {\r\n await comp(\"+\");\r\n await comp(\"-\");\r\n }\r\n}\r\n```"
90
+ "content": "# Nestia Template\r\n## Outline\r\n[![Build Status](https://github.com/samchon/nestia-start/workflows/build/badge.svg)](https://github.com/samchon/nestia-start/actions?query=workflow%3Abuild)\r\n\r\nA template repository for backend projects using [nestia](https://github.com/samchon/nestia).\r\n\r\nYou can create a new project from this boilerplate by running below command:\r\n\r\n```bash\r\nnpx nestia start <directory>\r\n```\r\n\r\nFor reference, this is a minimal boilerplate project concentrating only on [nestia](https://github.com/samchon/nestia) SDK generation. \r\n\r\nIf you wanna much detailed boilerplate project, visit [`@samchon/backend`](https://github.com/samchon/backend).\r\n\r\n\r\n\r\n\r\n## Directories and Files\r\nThis template project has categorized directories like below.\r\n\r\nAs you can see from the below, all of the Backend source files are placed into the [src](src/) directory. When you build the TypeScript source files, compiled files would be placed into the `lib` directory following the [tsconfig.json](tsconfig.json) configuration. Otherwise you build client [SDK](#32-sdk) library for npm publishing and their compiled files would be placed into the [packages](packages) directory.\r\n\r\n - [packages/api/](packages/api): SDK module built by `npm run build:api`\r\n - [src/](src): Backend source directory\r\n - [src/api/](src/api/): Client SDK that would be published to the `@ORGANIZATION/PROJECT-api`\r\n - [**src/api/functional/**](src/api/functional/): API functions generated by the [`nestia`](https://github.com/samchon/nestia)\r\n - [**src/api/structures/**](src/api/structures/): DTO structures\r\n - [src/controllers/](src/controllers/): Controller classes of the Main Program\r\n - [**test/**](test): Test Automation Program\r\n - [nestia.config.ts](nestia.config.ts): Configuration file of [`nestia`](https://github.com/samchon/nestia)\r\n - [package.json](package.json): NPM configuration\r\n - [tsconfig.json](tsconfig.json): TypeScript configuration for the main program\r\n - [tsconfig.api.json](tsconfig.api.json): TypeScript configuration for the SDK generation\r\n\r\n\r\n\r\n\r\n## NPM Run Commands\r\nList of the run commands defined in the [package.json](package.json) are like below:\r\n\r\n - `build`: Build everything\r\n - `build:api`: Build client SDK libray for the client developers\r\n - `build:main`: Build main program (`src` directory)\r\n - `build:sdk`: Build SDK into main program only\r\n - `build:swagger`: Build Swagger Documents\r\n - `build:test` Build test automation program (`test` directory)\r\n - `dev`: Incremental build for development (test program)\r\n - `eslint` & `eslint:fix` & `prettier`: Prettier and ESLint execution\r\n - `start`: Start local NestJS server\r\n - `test`: Run test automation program\r\n\r\n\r\n\r\n\r\n## Specialization\r\nTransform this template project to be yours.\r\n\r\nWhen you've created a new backend project through this template project, you can specialize it to be suitable for you by changing some words. Replace below words through IDE specific function like `Edit > Replace in Files` (*Ctrl + Shift + H*), who've been supported by the VSCode.\r\n\r\n| Before | After\r\n|-----------------|----------------------------------------\r\n| ORGANIZATION | Your account or corporation name\r\n| PROJECT | Your own project name\r\n| AUTHOR | Author name\r\n| https://github.com/samchon/nestia-start | Your repository URL\r\n\r\n\r\n\r\n\r\n## Test Driven Development\r\nWith [nestia](https://github.com/samchon/nestia) helps to accomplish TDD (Test Driven Development). \r\n\r\nJust define DTOs and API controllers' methods (only declarations) first. After the definitions, and build SDK (Software Development Kit) through [nestia](https://github.com/samchon/nestia) (`npm run build:sdk`). After buildling those SDK, develop test automation program using the SDK, following use-case scenarios in the framework of client side.\r\n\r\nDuring the test automation program development, you can find that which API is mis-designed or which requirement analysis is not exact. Development of the main program must be the last step after such validation process during TDD.\r\n\r\n> Visit the [samchon/backend](https://github.com/samchon/backend), then you may find much detailed story about this TDD.\r\n>\r\n> 1. Definitions\r\n> 2. SDK\r\n> 3. Test Automation Program\r\n> 4. Main Program\r\n\r\n```typescript\r\nimport typia from \"typia\";\r\n\r\nimport api from \"@ORGANIZATION/PROJECT-api/lib/index\";\r\nimport { IBbsArticle } from \"@ORGANIZATION/PROJECT-api/lib/structures/bbs/IBbsArticle\";\r\n\r\nimport { ArrayUtil } from \"../../../../utils/ArrayUtil\";\r\nimport { GaffComparator } from \"../../../internal/GaffComparator\";\r\nimport { RandomGenerator } from \"../../../internal/RandomGenerator\";\r\nimport { validate_index_sort } from \"../../../internal/validate_index_sort\";\r\n\r\nexport async function test_api_bbs_article_index_sort(\r\n connection: api.IConnection,\r\n): Promise<void> {\r\n // GENERATE 100 ARTICLES\r\n const section: string = \"general\";\r\n const articles: IBbsArticle[] = await ArrayUtil.asyncRepeat(100, () =>\r\n api.functional.bbs.articles.store(connection, section, {\r\n writer: RandomGenerator.name(),\r\n title: RandomGenerator.paragraph(),\r\n body: RandomGenerator.content(),\r\n format: \"txt\",\r\n files: [],\r\n password: RandomGenerator.alphabets(8),\r\n }),\r\n );\r\n typia.assertEquals(articles);\r\n\r\n // PREPARE VALIDATOR\r\n const validator = validate_index_sort(\"BbsArticleProvider.index()\")(\r\n (input: IBbsArticle.IRequest) =>\r\n api.functional.bbs.articles.index(connection, section, input),\r\n );\r\n\r\n // DO VALIDATE\r\n const components = [\r\n validator(\"created_at\")(GaffComparator.dates((x) => x.created_at)),\r\n validator(\"updated_at\")(GaffComparator.dates((x) => x.updated_at)),\r\n validator(\"title\")(GaffComparator.strings((x) => x.title)),\r\n validator(\"writer\")(GaffComparator.strings((x) => x.writer)),\r\n validator(\r\n \"writer\",\r\n \"title\",\r\n )(GaffComparator.strings((x) => [x.writer, x.title])),\r\n ];\r\n for (const comp of components) {\r\n await comp(\"+\");\r\n await comp(\"-\");\r\n }\r\n}\r\n```"
91
91
  },
92
92
  {
93
93
  "location": "/src/executable",
@@ -107,7 +107,7 @@ export const TEMPLATE = [
107
107
  {
108
108
  "location": "/src",
109
109
  "file": "MyConfiguration.ts",
110
- "content": "import fs from \"fs\";\r\nimport path from \"path\";\r\n\r\nimport { MyGlobal } from \"./MyGlobal\";\r\n\r\nexport namespace MyConfiguration {\r\n export const API_PORT = () => Number(MyGlobal.env.PROJECT_API_PORT);\r\n\r\n export const ROOT = (() => {\r\n const splitted: string[] = __dirname.split(path.sep);\r\n return splitted.at(-1) === \"src\" && splitted.at(-2) === \"bin\"\r\n ? path.resolve(__dirname + \"/../..\")\r\n : fs.existsSync(__dirname + \"/.env\")\r\n ? __dirname\r\n : path.resolve(__dirname + \"/..\");\r\n })();\r\n}\r\n"
110
+ "content": "import fs from \"fs\";\r\nimport path from \"path\";\r\n\r\nimport { MyGlobal } from \"./MyGlobal\";\r\n\r\nexport namespace MyConfiguration {\r\n export const API_PORT = () => Number(MyGlobal.env.PROJECT_API_PORT);\r\n\r\n export const ROOT = (() => {\r\n const splitted: string[] = __dirname.split(path.sep);\r\n return splitted.at(-1) === \"src\" && splitted.at(-2) === \"bin\"\r\n ? path.resolve(__dirname + \"/../..\")\r\n : fs.existsSync(__dirname + \"/.env\")\r\n ? __dirname\r\n : path.resolve(__dirname + \"/..\");\r\n })();\r\n}\r\n"
111
111
  },
112
112
  {
113
113
  "location": "/src",
@@ -137,7 +137,7 @@ export const TEMPLATE = [
137
137
  {
138
138
  "location": "/test",
139
139
  "file": "index.ts",
140
- "content": "import { DynamicExecutor } from \"@nestia/e2e\";\r\n\r\nimport api from \"@ORGANIZATION/PROJECT-api\";\r\n\r\nimport { MyBackend } from \"../src/MyBackend\";\r\nimport { MyConfiguration } from \"../src/MyConfiguration\";\r\nimport { MyGlobal } from \"../src/MyGlobal\";\r\nimport { ArgumentParser } from \"./helpers/ArgumentParser\";\r\n\r\ninterface IOptions {\r\n include?: string[];\r\n exclude?: string[];\r\n}\r\n\r\nconst getOptions = () =>\r\n ArgumentParser.parse<IOptions>(async (command, prompt, action) => {\r\n // command.option(\"--mode <string>\", \"target mode\");\r\n // command.option(\"--reset <true|false>\", \"reset local DB or not\");\r\n command.option(\"--include <string...>\", \"include feature files\");\r\n command.option(\"--exclude <string...>\", \"exclude feature files\");\r\n\r\n prompt;\r\n\r\n return action(async (options) => {\r\n // if (typeof options.reset === \"string\")\r\n // options.reset = options.reset === \"true\";\r\n // options.mode ??= await prompt.select(\"mode\")(\"Select mode\")([\r\n // \"LOCAL\",\r\n // \"DEV\",\r\n // \"REAL\",\r\n // ]);\r\n // options.reset ??= await prompt.boolean(\"reset\")(\"Reset local DB\");\r\n return options as IOptions;\r\n });\r\n });\r\n\r\nasync function main(): Promise<void> {\r\n const options: IOptions = await getOptions();\r\n MyGlobal.testing = true;\r\n\r\n // BACKEND SERVER\r\n const backend: MyBackend = new MyBackend();\r\n await backend.open();\r\n\r\n //----\r\n // CLINET CONNECTOR\r\n //----\r\n // DO TEST\r\n const connection: api.IConnection = {\r\n host: `http://127.0.0.1:${MyConfiguration.API_PORT()}`,\r\n };\r\n const report: DynamicExecutor.IReport = await DynamicExecutor.validate({\r\n prefix: \"test\",\r\n parameters: () => [\r\n {\r\n host: connection.host,\r\n encryption: connection.encryption,\r\n },\r\n ],\r\n filter: (func) =>\r\n (!options.include?.length ||\r\n (options.include ?? []).some((str) => func.includes(str))) &&\r\n (!options.exclude?.length ||\r\n (options.exclude ?? []).every((str) => !func.includes(str))),\r\n })(__dirname + \"/features\");\r\n\r\n await backend.close();\r\n\r\n const failures: DynamicExecutor.IReport.IExecution[] =\r\n report.executions.filter((exec) => exec.error !== null);\r\n if (failures.length === 0) {\r\n console.log(\"Success\");\r\n console.log(\"Elapsed time\", report.time.toLocaleString(), `ms`);\r\n } else {\r\n for (const f of failures) console.log(f.error);\r\n process.exit(-1);\r\n }\r\n \r\n console.log([\r\n `All : ${report.executions.length}`,\r\n `Success : ${report.executions.length - failures.length}`,\r\n `Failed : ${failures.length}`,\r\n ].join(\"\\n\"));\r\n}\r\nmain().catch((exp) => {\r\n console.log(exp);\r\n process.exit(-1);\r\n});\r\n"
140
+ "content": "import { DynamicExecutor } from \"@nestia/e2e\";\r\n\r\nimport api from \"@ORGANIZATION/PROJECT-api\";\r\n\r\nimport { MyBackend } from \"../src/MyBackend\";\r\nimport { MyConfiguration } from \"../src/MyConfiguration\";\r\nimport { MyGlobal } from \"../src/MyGlobal\";\r\nimport { ArgumentParser } from \"./helpers/ArgumentParser\";\r\n\r\ninterface IOptions {\r\n include?: string[];\r\n exclude?: string[];\r\n}\r\n\r\nconst getOptions = () =>\r\n ArgumentParser.parse<IOptions>(async (command, prompt, action) => {\r\n // command.option(\"--mode <string>\", \"target mode\");\r\n // command.option(\"--reset <true|false>\", \"reset local DB or not\");\r\n command.option(\"--include <string...>\", \"include feature files\");\r\n command.option(\"--exclude <string...>\", \"exclude feature files\");\r\n\r\n prompt;\r\n\r\n return action(async (options) => {\r\n // if (typeof options.reset === \"string\")\r\n // options.reset = options.reset === \"true\";\r\n // options.mode ??= await prompt.select(\"mode\")(\"Select mode\")([\r\n // \"LOCAL\",\r\n // \"DEV\",\r\n // \"REAL\",\r\n // ]);\r\n // options.reset ??= await prompt.boolean(\"reset\")(\"Reset local DB\");\r\n return options as IOptions;\r\n });\r\n });\r\n\r\nasync function main(): Promise<void> {\r\n const options: IOptions = await getOptions();\r\n MyGlobal.testing = true;\r\n\r\n // BACKEND SERVER\r\n const backend: MyBackend = new MyBackend();\r\n await backend.open();\r\n\r\n //----\r\n // CLINET CONNECTOR\r\n //----\r\n // DO TEST\r\n const connection: api.IConnection = {\r\n host: `http://127.0.0.1:${MyConfiguration.API_PORT()}`,\r\n };\r\n const report: DynamicExecutor.IReport = await DynamicExecutor.validate({\r\n prefix: \"test\",\r\n parameters: () => [\r\n {\r\n host: connection.host,\r\n encryption: connection.encryption,\r\n },\r\n ],\r\n filter: (func) =>\r\n (!options.include?.length ||\r\n (options.include ?? []).some((str) => func.includes(str))) &&\r\n (!options.exclude?.length ||\r\n (options.exclude ?? []).every((str) => !func.includes(str))),\r\n })(__dirname + \"/features\");\r\n\r\n await backend.close();\r\n\r\n const failures: DynamicExecutor.IReport.IExecution[] =\r\n report.executions.filter((exec) => exec.error !== null);\r\n if (failures.length === 0) {\r\n console.log(\"Success\");\r\n console.log(\"Elapsed time\", report.time.toLocaleString(), `ms`);\r\n } else {\r\n for (const f of failures) console.log(f.error);\r\n process.exit(-1);\r\n }\r\n\r\n console.log(\r\n [\r\n `All: #${report.executions.length}`,\r\n `Success: #${report.executions.length - failures.length}`,\r\n `Failed: #${failures.length}`,\r\n ].join(\"\\n\"),\r\n );\r\n}\r\nmain().catch((exp) => {\r\n console.log(exp);\r\n process.exit(-1);\r\n});\r\n"
141
141
  },
142
142
  {
143
143
  "location": "/test",
@@ -157,6 +157,6 @@ export const TEMPLATE = [
157
157
  {
158
158
  "location": "",
159
159
  "file": "webpack.config.js",
160
- "content": "const path = require(\"path\");\r\n\r\nconst CopyWebpackPlugin = require(\"copy-webpack-plugin\");\r\nconst WriteFilePlugin = require(\"write-file-webpack-plugin\");\r\nconst { IgnorePlugin } = require(\"webpack\");\r\n\r\nconst lazyImports = [\r\n \"@fastify/static\",\r\n \"@fastify/view\",\r\n \"@nestjs/microservices\",\r\n \"@nestjs/websockets\",\r\n \"class-transformer\",\r\n \"class-validator\",\r\n];\r\n\r\n// @reference https://tech-blog.s-yoshiki.com/entry/297\r\nmodule.exports = {\r\n // CUSTOMIZE HERE\r\n entry: {\r\n server: \"./src/executable/server.ts\",\r\n },\r\n output: {\r\n path: path.join(__dirname, \"dist\"),\r\n filename: \"[name].js\",\r\n },\r\n optimization: {\r\n minimize: true,\r\n },\r\n\r\n // JUST KEEP THEM\r\n mode: \"production\",\r\n target: \"node\",\r\n module: {\r\n rules: [\r\n {\r\n test: /\\.ts$/,\r\n exclude: /node_modules/,\r\n loader: \"ts-loader\",\r\n },\r\n ],\r\n },\r\n resolve: {\r\n extensions: [\".tsx\", \".ts\", \".js\"],\r\n },\r\n plugins: [\r\n new CopyWebpackPlugin({\r\n patterns: [\r\n {\r\n from: \".env\",\r\n to: \"[name][ext]\",\r\n },\r\n // {\r\n // from: \"./node_modules/.prisma/client/*.node\",\r\n // to: () => Promise.resolve(\"[path][name][ext]\"),\r\n // },\r\n ],\r\n }),\r\n new WriteFilePlugin(),\r\n new IgnorePlugin({\r\n checkResource: (resource) => {\r\n if (lazyImports.some((modulo) => resource.startsWith(modulo))) {\r\n try {\r\n require.resolve(resource);\r\n } catch (err) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n },\r\n }),\r\n ],\r\n};\r\n"
160
+ "content": "const path = require(\"path\");\r\n\r\nconst CopyWebpackPlugin = require(\"copy-webpack-plugin\");\r\nconst WriteFilePlugin = require(\"write-file-webpack-plugin\");\r\nconst { IgnorePlugin } = require(\"webpack\");\r\n\r\nconst lazyImports = [\r\n \"@fastify/static\",\r\n \"@fastify/view\",\r\n \"@nestjs/microservices\",\r\n \"@nestjs/websockets\",\r\n \"class-transformer\",\r\n \"class-validator\",\r\n];\r\n\r\n// @reference https://tech-blog.s-yoshiki.com/entry/297\r\nmodule.exports = {\r\n // CUSTOMIZE HERE\r\n entry: {\r\n server: \"./src/executable/server.ts\",\r\n },\r\n output: {\r\n path: path.join(__dirname, \"dist\"),\r\n filename: \"[name].js\",\r\n },\r\n optimization: {\r\n minimize: true,\r\n },\r\n\r\n // JUST KEEP THEM\r\n mode: \"production\",\r\n target: \"node\",\r\n module: {\r\n rules: [\r\n {\r\n test: /\\.ts$/,\r\n exclude: /node_modules/,\r\n loader: \"ts-loader\",\r\n },\r\n ],\r\n },\r\n resolve: {\r\n extensions: [\".tsx\", \".ts\", \".js\"],\r\n },\r\n plugins: [\r\n new CopyWebpackPlugin({\r\n patterns: [\r\n {\r\n from: \".env\",\r\n to: \"[name][ext]\",\r\n },\r\n // {\r\n // from: \"./node_modules/.prisma/client/*.node\",\r\n // to: () => Promise.resolve(\"[path][name][ext]\"),\r\n // globOptions: {\r\n // dot: true,\r\n // },\r\n // },\r\n ],\r\n }),\r\n new WriteFilePlugin(),\r\n new IgnorePlugin({\r\n checkResource: (resource) => {\r\n if (lazyImports.some((modulo) => resource.startsWith(modulo))) {\r\n try {\r\n require.resolve(resource);\r\n } catch (err) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n },\r\n }),\r\n ],\r\n};\r\n"
161
161
  }
162
162
  ]
@@ -1,78 +1,72 @@
1
- import cp from "child_process";
2
- import fs from "fs";
3
-
4
- import { IMigrateFile } from "../structures/IMigrateFile";
5
-
6
- const ROOT = __dirname + "/../..";
7
- const ASSETS = ROOT + "/assets";
8
- const TEMPLATE = ASSETS + "/template";
9
-
10
- const clone = async (): Promise<void> => {
11
- console.log("Preparing bundles...");
12
-
13
- // CLONE REPOSITORY
14
- if (fs.existsSync(TEMPLATE))
15
- await fs.promises.rm(TEMPLATE, { recursive: true });
16
- else
17
- try {
18
- await fs.promises.mkdir(ASSETS);
19
- } catch {}
20
-
21
- cp.execSync(
22
- "git clone https://github.com/samchon/nestia-template template",
23
- {
24
- cwd: __dirname + "/../../assets",
25
- },
26
- );
27
-
28
- // REMOVE VUNLERABLE FILES
29
- for (const path of [
30
- `${TEMPLATE}/.git`,
31
- `${TEMPLATE}/src/api`,
32
- `${TEMPLATE}/src/controllers`,
33
- `${TEMPLATE}/src/providers`,
34
- `${TEMPLATE}/test/features`,
35
- ])
36
- await fs.promises.rm(path, { recursive: true });
37
- };
38
-
39
- const iterate = (collection: IMigrateFile[]) => async (location: string) => {
40
- const directory: string[] = await fs.promises.readdir(location);
41
- for (const file of directory) {
42
- const absolute: string = location + "/" + file;
43
- const stats: fs.Stats = await fs.promises.stat(absolute);
44
- if (stats.isDirectory()) await iterate(collection)(absolute);
45
- else {
46
- const content: string = await fs.promises.readFile(
47
- absolute,
48
- "utf-8",
49
- );
50
- collection.push({
51
- location: location.replace(TEMPLATE, ""),
52
- file,
53
- content,
54
- });
55
- }
56
- }
57
- };
58
-
59
- const archive = async (collection: IMigrateFile[]): Promise<void> => {
60
- const body: string = JSON.stringify(collection, null, 4);
61
- const content: string = `export const TEMPLATE = ${body}`;
62
-
63
- try {
64
- await fs.promises.mkdir(`${ROOT}/src/bundles`);
65
- } catch {}
66
- await fs.promises.writeFile(`${ROOT}/src/bundles/TEMPLATE.ts`, content);
67
- };
68
-
69
- const main = async (): Promise<void> => {
70
- const collection: IMigrateFile[] = [];
71
- await clone();
72
- await iterate(collection)(TEMPLATE);
73
- await archive(collection);
74
- };
75
- main().catch((exp) => {
76
- console.error(exp);
77
- process.exit(-1);
78
- });
1
+ import cp from "child_process";
2
+ import fs from "fs";
3
+
4
+ import { IMigrateFile } from "../structures/IMigrateFile";
5
+
6
+ const ROOT = __dirname + "/../..";
7
+ const ASSETS = ROOT + "/assets";
8
+ const TEMPLATE = ASSETS + "/template";
9
+
10
+ const clone = async (): Promise<void> => {
11
+ console.log("Preparing bundles...");
12
+
13
+ // CLONE REPOSITORY
14
+ if (fs.existsSync(TEMPLATE))
15
+ await fs.promises.rm(TEMPLATE, { recursive: true });
16
+ else
17
+ try {
18
+ await fs.promises.mkdir(ASSETS);
19
+ } catch {}
20
+
21
+ cp.execSync("git clone https://github.com/samchon/nestia-template template", {
22
+ cwd: __dirname + "/../../assets",
23
+ });
24
+
25
+ // REMOVE VUNLERABLE FILES
26
+ for (const path of [
27
+ `${TEMPLATE}/.git`,
28
+ `${TEMPLATE}/src/api`,
29
+ `${TEMPLATE}/src/controllers`,
30
+ `${TEMPLATE}/src/providers`,
31
+ `${TEMPLATE}/test/features`,
32
+ ])
33
+ await fs.promises.rm(path, { recursive: true });
34
+ };
35
+
36
+ const iterate = (collection: IMigrateFile[]) => async (location: string) => {
37
+ const directory: string[] = await fs.promises.readdir(location);
38
+ for (const file of directory) {
39
+ const absolute: string = location + "/" + file;
40
+ const stats: fs.Stats = await fs.promises.stat(absolute);
41
+ if (stats.isDirectory()) await iterate(collection)(absolute);
42
+ else {
43
+ const content: string = await fs.promises.readFile(absolute, "utf-8");
44
+ collection.push({
45
+ location: location.replace(TEMPLATE, ""),
46
+ file,
47
+ content,
48
+ });
49
+ }
50
+ }
51
+ };
52
+
53
+ const archive = async (collection: IMigrateFile[]): Promise<void> => {
54
+ const body: string = JSON.stringify(collection, null, 4);
55
+ const content: string = `export const TEMPLATE = ${body}`;
56
+
57
+ try {
58
+ await fs.promises.mkdir(`${ROOT}/src/bundles`);
59
+ } catch {}
60
+ await fs.promises.writeFile(`${ROOT}/src/bundles/TEMPLATE.ts`, content);
61
+ };
62
+
63
+ const main = async (): Promise<void> => {
64
+ const collection: IMigrateFile[] = [];
65
+ await clone();
66
+ await iterate(collection)(TEMPLATE);
67
+ await archive(collection);
68
+ };
69
+ main().catch((exp) => {
70
+ console.error(exp);
71
+ process.exit(-1);
72
+ });