nestia 7.1.0 → 7.1.1

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Jeongho Nam
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Jeongho Nam
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,92 +1,93 @@
1
- # Nestia
2
- ![Nestia Logo](https://nestia.io/logo.png)
3
-
4
- [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/nestia/blob/master/LICENSE)
5
- [![npm version](https://img.shields.io/npm/v/@nestia/fetcher.svg)](https://www.npmjs.com/package/@nestia/fetcher)
6
- [![Downloads](https://img.shields.io/npm/dm/@nestia/fetcher.svg)](https://www.npmjs.com/package/@nestia/fetcher)
7
- [![Build Status](https://github.com/samchon/nestia/workflows/build/badge.svg)](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)
8
- [![Guide Documents](https://img.shields.io/badge/Guide-Documents-forestgreen)](https://nestia.io/docs/)
9
- [![Gurubase](https://img.shields.io/badge/Gurubase-Document%20Chatbot-006BFF)](https://gurubase.io/g/nestia)
10
- [![Discord Badge](https://img.shields.io/badge/discord-samchon-d91965?style=flat&labelColor=5866f2&logo=discord&logoColor=white&link=https://discord.gg/E94XhzrUCZ)](https://discord.gg/E94XhzrUCZ)
11
-
12
- Nestia is a set of helper libraries for NestJS, supporting below features:
13
-
14
- - `@nestia/core`:
15
- - Super-fast/easy decorators
16
- - Advanced WebSocket routes
17
- - `@nestia/sdk`:
18
- - Swagger generator, more evolved than ever
19
- - SDK library generator for clients
20
- - Mockup Simulator for client applications
21
- - Automatic E2E test functions generator
22
- - `@nestia/e2e`: Test program utilizing e2e test functions
23
- - `@nestia/benchmark`: Benchmark program using e2e test functions
24
- - `@nestia/editor`: Swagger-UI with Online TypeScript Editor
25
- - `@agentica`: Agentic AI library specialized in LLM function calling
26
- - `nestia`: Just CLI (command line interface) tool
27
-
28
- > [!NOTE]
29
- >
30
- > - **Only one line** required, with pure TypeScript type
31
- > - Enhance performance **30x** up
32
- > - Runtime validator is **20,000x faster** than `class-validator`
33
- > - JSON serialization is **200x faster** than `class-transformer`
34
- > - Software Development Kit
35
- > - Collection of typed `fetch` functions with DTO structures like [tRPC](https://trpc.io/)
36
- > - Mockup simulator means embedded backend simulator in the SDK
37
- > - similar with [msw](https://mswjs.io/), but fully automated
38
-
39
- ![nestia-sdk-demo](https://user-images.githubusercontent.com/13158709/215004990-368c589d-7101-404e-b81b-fbc936382f05.gif)
40
-
41
- > Left is NestJS server code, and right is client (frontend) code utilizing SDK
42
-
43
-
44
-
45
-
46
- ## Sponsors and Backers
47
- Thanks for your support.
48
-
49
- Your donation would encourage `nestia` development.
50
-
51
- [![Backers](https://opencollective.com/nestia/backers.svg?avatarHeight=75&width=600)](https://opencollective.com/nestia)
52
-
53
-
54
-
55
-
56
- ## Guide Documents
57
- Check out the document in the [website](https://nestia.io/docs/):
58
-
59
- ### 🏠 Home
60
- - [Introduction](https://nestia.io/docs/)
61
- - [Setup](https://nestia.io/docs/setup/)
62
- - [Pure TypeScript](https://nestia.io/docs/pure)
63
-
64
- ### 📖 Features
65
- - Core Library
66
- - [`@WebSocketRoute`](https://nestia.io/docs/core/WebSocketRoute)
67
- - [`@TypedRoute`](https://nestia.io/docs/core/TypedRoute/)
68
- - [**`@TypedBody`**](https://nestia.io/docs/core/TypedBody/)
69
- - [`@TypedParam`](https://nestia.io/docs/core/TypedParam/)
70
- - [`@TypedQuery`](https://nestia.io/docs/core/TypedQuery/)
71
- - [`@TypedFormData`](https://nestia.io/docs/core/TypedFormData/)
72
- - [`@TypedHeaders`](https://nestia.io/docs/core/TypedHeaders/)
73
- - [`@TypedException`](https://nestia.io/docs/core/TypedException/)
74
- - Software Development Kit
75
- - [SDK Builder](https://nestia.io/docs/sdk/)
76
- - [Mockup Simulator](https://nestia.io/docs/sdk/simulate/)
77
- - [E2E Test Functions](https://nestia.io/docs/sdk/e2e/)
78
- - [Distribution](https://nestia.io/docs/sdk/distribute/)
79
- - Swagger Document
80
- - [Swagger Builder](https://nestia.io/docs/swagger/)
81
- - [**AI Chatbot Development**](https://nestia.io/docs/swagger/chat/)
82
- - [Cloud Swagger Editor](https://nestia.io/docs/swagger/editor/)
83
- - [Documentation Strategy](https://nestia.io/docs/swagger/strategy/)
84
- - E2E Testing
85
- - [Why E2E Test?](https://nestia.io/docs/e2e/why/)
86
- - [Test Program Development](https://nestia.io/docs/e2e/development/)
87
- - [Performance Benchmark](https://nestia.io/docs/e2e/benchmark/)
88
-
89
- ### 🔗 Appendix
90
- - [API Documents](https://nestia.io/api)
91
- - [ Benchmark Result](https://github.com/samchon/nestia/tree/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz)
92
- - [⇲ `dev.to` Articles](https://dev.to/samchon/series/22751)
1
+ # Nestia
2
+ ![Nestia Logo](https://nestia.io/logo.png)
3
+
4
+ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/nestia/blob/master/LICENSE)
5
+ [![npm version](https://img.shields.io/npm/v/@nestia/fetcher.svg)](https://www.npmjs.com/package/@nestia/fetcher)
6
+ [![Downloads](https://img.shields.io/npm/dm/@nestia/fetcher.svg)](https://www.npmjs.com/package/@nestia/fetcher)
7
+ [![Build Status](https://github.com/samchon/nestia/workflows/build/badge.svg)](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)
8
+ [![Guide Documents](https://img.shields.io/badge/Guide-Documents-forestgreen)](https://nestia.io/docs/)
9
+ [![Gurubase](https://img.shields.io/badge/Gurubase-Document%20Chatbot-006BFF)](https://gurubase.io/g/nestia)
10
+ [![Discord Badge](https://img.shields.io/badge/discord-samchon-d91965?style=flat&labelColor=5866f2&logo=discord&logoColor=white&link=https://discord.gg/E94XhzrUCZ)](https://discord.gg/E94XhzrUCZ)
11
+
12
+ Nestia is a set of helper libraries for NestJS, supporting below features:
13
+
14
+ - `@nestia/core`:
15
+ - Super-fast/easy decorators
16
+ - Advanced WebSocket routes
17
+ - `@nestia/sdk`:
18
+ - Swagger generator, more evolved than ever
19
+ - SDK library generator for clients
20
+ - Mockup Simulator for client applications
21
+ - Automatic E2E test functions generator
22
+ - `@nestia/e2e`: Test program utilizing e2e test functions
23
+ - `@nestia/benchmark`: Benchmark program using e2e test functions
24
+ - `@nestia/editor`: Swagger-UI with Online TypeScript Editor
25
+ - [`@agentica`](https://github.com/wrtnlabs/agentica): Agentic AI library specialized in LLM function calling
26
+ - [`@autobe`](https://github.com/wrtnlabs/autobe): Vibe coding agent generating NestJS application
27
+ - `nestia`: Just CLI (command line interface) tool
28
+
29
+ > [!NOTE]
30
+ >
31
+ > - **Only one line** required, with pure TypeScript type
32
+ > - Enhance performance **30x** up
33
+ > - Runtime validator is **20,000x faster** than `class-validator`
34
+ > - JSON serialization is **200x faster** than `class-transformer`
35
+ > - Software Development Kit
36
+ > - Collection of typed `fetch` functions with DTO structures like [tRPC](https://trpc.io/)
37
+ > - Mockup simulator means embedded backend simulator in the SDK
38
+ > - similar with [msw](https://mswjs.io/), but fully automated
39
+
40
+ ![nestia-sdk-demo](https://user-images.githubusercontent.com/13158709/215004990-368c589d-7101-404e-b81b-fbc936382f05.gif)
41
+
42
+ > Left is NestJS server code, and right is client (frontend) code utilizing SDK
43
+
44
+
45
+
46
+
47
+ ## Sponsors and Backers
48
+ Thanks for your support.
49
+
50
+ Your donation would encourage `nestia` development.
51
+
52
+ [![Backers](https://opencollective.com/nestia/backers.svg?avatarHeight=75&width=600)](https://opencollective.com/nestia)
53
+
54
+
55
+
56
+
57
+ ## Guide Documents
58
+ Check out the document in the [website](https://nestia.io/docs/):
59
+
60
+ ### 🏠 Home
61
+ - [Introduction](https://nestia.io/docs/)
62
+ - [Setup](https://nestia.io/docs/setup/)
63
+ - [Pure TypeScript](https://nestia.io/docs/pure)
64
+
65
+ ### 📖 Features
66
+ - Core Library
67
+ - [`@WebSocketRoute`](https://nestia.io/docs/core/WebSocketRoute)
68
+ - [`@TypedRoute`](https://nestia.io/docs/core/TypedRoute/)
69
+ - [**`@TypedBody`**](https://nestia.io/docs/core/TypedBody/)
70
+ - [`@TypedParam`](https://nestia.io/docs/core/TypedParam/)
71
+ - [`@TypedQuery`](https://nestia.io/docs/core/TypedQuery/)
72
+ - [`@TypedFormData`](https://nestia.io/docs/core/TypedFormData/)
73
+ - [`@TypedHeaders`](https://nestia.io/docs/core/TypedHeaders/)
74
+ - [`@TypedException`](https://nestia.io/docs/core/TypedException/)
75
+ - Software Development Kit
76
+ - [SDK Builder](https://nestia.io/docs/sdk/)
77
+ - [Mockup Simulator](https://nestia.io/docs/sdk/simulate/)
78
+ - [E2E Test Functions](https://nestia.io/docs/sdk/e2e/)
79
+ - [Distribution](https://nestia.io/docs/sdk/distribute/)
80
+ - Swagger Document
81
+ - [Swagger Builder](https://nestia.io/docs/swagger/)
82
+ - [**AI Chatbot Development**](https://nestia.io/docs/swagger/chat/)
83
+ - [Cloud Swagger Editor](https://nestia.io/docs/swagger/editor/)
84
+ - [Documentation Strategy](https://nestia.io/docs/swagger/strategy/)
85
+ - E2E Testing
86
+ - [Why E2E Test?](https://nestia.io/docs/e2e/why/)
87
+ - [Test Program Development](https://nestia.io/docs/e2e/development/)
88
+ - [Performance Benchmark](https://nestia.io/docs/e2e/benchmark/)
89
+
90
+ ### 🔗 Appendix
91
+ - [API Documents](https://nestia.io/api)
92
+ - [⇲ Benchmark Result](https://github.com/samchon/nestia/tree/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz)
93
+ - [⇲ `dev.to` Articles](https://dev.to/samchon/series/22751)
package/bin/index.js CHANGED
@@ -42,19 +42,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
42
42
  step((generator = generator.apply(thisArg, _arguments || [])).next());
43
43
  });
44
44
  };
45
- const USAGE = `Wrong command has been detected. Use like below:
46
-
47
- npx nestia [command] [options?]
48
-
49
- 1. npx nestia start <directory>
50
- 2. npx nestia template <directory>
51
- 3. npx nestia setup
52
- 4. npx nestia dependencies
53
- 5. npx nestia init
54
- 6. npx nestia sdk
55
- 7. npx nestia swagger
56
- 9. npx nestia e2e
57
- 10. npx nestia all
45
+ const USAGE = `Wrong command has been detected. Use like below:
46
+
47
+ npx nestia [command] [options?]
48
+
49
+ 1. npx nestia start <directory>
50
+ 2. npx nestia template <directory>
51
+ 3. npx nestia setup
52
+ 4. npx nestia dependencies
53
+ 5. npx nestia init
54
+ 6. npx nestia sdk
55
+ 7. npx nestia swagger
56
+ 9. npx nestia e2e
57
+ 10. npx nestia all
58
58
  `;
59
59
  function halt(desc) {
60
60
  console.error(desc);
@@ -61,31 +61,31 @@ var PluginConfigurator;
61
61
  compilerOptions.experimentalDecorators = true;
62
62
  compilerOptions.emitDecoratorMetadata = true;
63
63
  if (core === undefined)
64
- plugins.push(comment_json_1.default.parse(`{
65
- "transform": "@nestia/core/lib/transform",
66
- /**
67
- * Validate request body.
68
- *
69
- * - "assert": Use typia.assert() function
70
- * - "is": Use typia.is() function
71
- * - "validate": Use typia.validate() function
72
- * - "assertEquals": Use typia.assertEquals() function
73
- * - "equals": Use typia.equals() function
74
- * - "validateEquals": Use typia.validateEquals() function
75
- */
76
- "validate": "validate",
77
-
78
- /**
79
- * Validate JSON typed response body.
80
- *
81
- * - "assert": Use typia.assertStringify() function
82
- * - "is": Use typia.isStringify() function
83
- * - "validate": Use typia.validateStringify() function
84
- * - "validate.log": typia.validateStringify(), but do not throw and just log it
85
- * - "stringify": Use typia.stringify() function, but dangerous
86
- * - null: Just use JSON.stringify() function, without boosting
87
- */
88
- "stringify": "assert"
64
+ plugins.push(comment_json_1.default.parse(`{
65
+ "transform": "@nestia/core/lib/transform",
66
+ /**
67
+ * Validate request body.
68
+ *
69
+ * - "assert": Use typia.assert() function
70
+ * - "is": Use typia.is() function
71
+ * - "validate": Use typia.validate() function
72
+ * - "assertEquals": Use typia.assertEquals() function
73
+ * - "equals": Use typia.equals() function
74
+ * - "validateEquals": Use typia.validateEquals() function
75
+ */
76
+ "validate": "validate",
77
+
78
+ /**
79
+ * Validate JSON typed response body.
80
+ *
81
+ * - "assert": Use typia.assertStringify() function
82
+ * - "is": Use typia.isStringify() function
83
+ * - "validate": Use typia.validateStringify() function
84
+ * - "validate.log": typia.validateStringify(), but do not throw and just log it
85
+ * - "stringify": Use typia.stringify() function, but dangerous
86
+ * - null: Just use JSON.stringify() function, without boosting
87
+ */
88
+ "stringify": "assert"
89
89
  }`));
90
90
  if (swagger === undefined && args.runtime === true)
91
91
  plugins.push(comment_json_1.default.parse(`{ "transform": "@nestia/sdk/lib/transform" }`));
package/package.json CHANGED
@@ -1,54 +1,54 @@
1
- {
2
- "name": "nestia",
3
- "version": "7.1.0",
4
- "description": "Nestia CLI tool",
5
- "main": "bin/index.js",
6
- "bin": {
7
- "nestia": "bin/index.js"
8
- },
9
- "scripts": {
10
- "build": "rimraf bin && tsc",
11
- "package:latest": "npm run build && npm publish --access public --tag latest",
12
- "package:next": "npm run build && npm publish --access public --tag next"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "https://github.com/samchon/nestia"
17
- },
18
- "keywords": [
19
- "nestia",
20
- "cli",
21
- "sdk",
22
- "swagger",
23
- "generator",
24
- "nestjs",
25
- "typia"
26
- ],
27
- "author": "Jeongho Nam",
28
- "license": "MIT",
29
- "bugs": {
30
- "url": "https://github.com/samchon/nestia/issues"
31
- },
32
- "homepage": "https://nestia.io",
33
- "dependencies": {
34
- "commander": "^10.0.0",
35
- "comment-json": "^4.2.3",
36
- "inquirer": "^8.2.5",
37
- "package-manager-detector": "^0.2.0"
38
- },
39
- "devDependencies": {
40
- "@nestia/core": "workspace:^",
41
- "@nestia/sdk": "workspace:^",
42
- "@types/inquirer": "^9.0.3",
43
- "@types/node": "^18.11.16",
44
- "rimraf": "^6.0.1",
45
- "typescript": "~5.8.3"
46
- },
47
- "files": [
48
- "bin",
49
- "src",
50
- "README.md",
51
- "LICENSE",
52
- "package.json"
53
- ]
54
- }
1
+ {
2
+ "name": "nestia",
3
+ "version": "7.1.1",
4
+ "description": "Nestia CLI tool",
5
+ "main": "bin/index.js",
6
+ "bin": {
7
+ "nestia": "bin/index.js"
8
+ },
9
+ "scripts": {
10
+ "build": "rimraf bin && tsc",
11
+ "package:latest": "npm run build && npm publish --access public --tag latest",
12
+ "package:next": "npm run build && npm publish --access public --tag next"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/samchon/nestia"
17
+ },
18
+ "keywords": [
19
+ "nestia",
20
+ "cli",
21
+ "sdk",
22
+ "swagger",
23
+ "generator",
24
+ "nestjs",
25
+ "typia"
26
+ ],
27
+ "author": "Jeongho Nam",
28
+ "license": "MIT",
29
+ "bugs": {
30
+ "url": "https://github.com/samchon/nestia/issues"
31
+ },
32
+ "homepage": "https://nestia.io",
33
+ "dependencies": {
34
+ "commander": "^10.0.0",
35
+ "comment-json": "^4.2.3",
36
+ "inquirer": "^8.2.5",
37
+ "package-manager-detector": "^0.2.0"
38
+ },
39
+ "devDependencies": {
40
+ "@nestia/core": "^7.1.1",
41
+ "@nestia/sdk": "^7.1.1",
42
+ "@types/inquirer": "^9.0.3",
43
+ "@types/node": "^18.11.16",
44
+ "rimraf": "^6.0.1",
45
+ "typescript": "~5.8.3"
46
+ },
47
+ "files": [
48
+ "bin",
49
+ "src",
50
+ "README.md",
51
+ "LICENSE",
52
+ "package.json"
53
+ ]
54
+ }
@@ -1,90 +1,90 @@
1
- import fs from "fs";
2
-
3
- import { ArgumentParser } from "./internal/ArgumentParser";
4
- import { CommandExecutor } from "./internal/CommandExecutor";
5
- import { PackageManager } from "./internal/PackageManager";
6
- import { PluginConfigurator } from "./internal/PluginConfigurator";
7
-
8
- export namespace NestiaSetupWizard {
9
- export async function setup(): Promise<void> {
10
- console.log("----------------------------------------");
11
- console.log(" Nestia Setup Wizard");
12
- console.log("----------------------------------------");
13
-
14
- // PREPARE ASSETS
15
- const pack: PackageManager = await PackageManager.mount();
16
- const args: ArgumentParser.IArguments = await ArgumentParser.parse(pack);
17
-
18
- // INSTALL NESTIA
19
- pack.install({ dev: false, modulo: "@nestia/core", version: "latest" });
20
- pack.install({ dev: false, modulo: "@nestia/e2e", version: "latest" });
21
- pack.install({ dev: false, modulo: "@nestia/fetcher", version: "latest" });
22
- pack.install({
23
- dev: args.runtime === false,
24
- modulo: "@nestia/sdk",
25
- version: "latest",
26
- });
27
- pack.install({ dev: true, modulo: "@nestia/benchmark", version: "latest" });
28
- pack.install({ dev: true, modulo: "nestia", version: "latest" });
29
- pack.install({ dev: false, modulo: "typia", version: "latest" });
30
-
31
- // INSTALL TYPESCRIPT COMPILERS
32
- pack.install({ dev: true, modulo: "ts-patch", version: "latest" });
33
- pack.install({ dev: true, modulo: "ts-node", version: "latest" });
34
- pack.install({
35
- dev: true,
36
- modulo: "typescript",
37
- version: await getTypeScriptVersion(),
38
- });
39
- args.project ??= (() => {
40
- const runner: string = pack.manager === "npm" ? "npx" : pack.manager;
41
- CommandExecutor.run(`${runner} tsc --init`);
42
- return (args.project = "tsconfig.json");
43
- })();
44
-
45
- // SETUP TRANSFORMER
46
- await pack.save((data) => {
47
- // COMPOSE PREPARE COMMAND
48
- data.scripts ??= {};
49
- if (
50
- typeof data.scripts.prepare === "string" &&
51
- data.scripts.prepare.trim().length !== 0
52
- ) {
53
- if (data.scripts.prepare.includes("ts-patch install") === false)
54
- data.scripts.prepare = "ts-patch install && " + data.scripts.prepare;
55
- } else data.scripts.prepare = "ts-patch install";
56
-
57
- // NO MORE "typia patch" REQUIRED
58
- data.scripts.prepare = data.scripts.prepare
59
- .split("&&")
60
- .map((str) => str.trim())
61
- .filter((str) => str !== "typia patch")
62
- .join(" && ");
63
-
64
- // FOR OLDER VERSIONS
65
- if (typeof data.scripts.postinstall === "string") {
66
- data.scripts.postinstall = data.scripts.postinstall
67
- .split("&&")
68
- .map((str) => str.trim())
69
- .filter((str) => str.indexOf("ts-patch install") === -1)
70
- .join(" && ");
71
- if (data.scripts.postinstall.length === 0)
72
- delete data.scripts.postinstall;
73
- }
74
- });
75
- CommandExecutor.run(`${pack.manager} run prepare`);
76
-
77
- // CONFIGURE PLUGIN
78
- await PluginConfigurator.configure(args);
79
- }
80
-
81
- const getTypeScriptVersion = async (): Promise<string> => {
82
- const content: string = await fs.promises.readFile(
83
- `${__dirname}/../package.json`,
84
- "utf-8",
85
- );
86
- const json: { devDependencies: { typescript: string } } =
87
- JSON.parse(content);
88
- return json.devDependencies.typescript;
89
- };
90
- }
1
+ import fs from "fs";
2
+
3
+ import { ArgumentParser } from "./internal/ArgumentParser";
4
+ import { CommandExecutor } from "./internal/CommandExecutor";
5
+ import { PackageManager } from "./internal/PackageManager";
6
+ import { PluginConfigurator } from "./internal/PluginConfigurator";
7
+
8
+ export namespace NestiaSetupWizard {
9
+ export async function setup(): Promise<void> {
10
+ console.log("----------------------------------------");
11
+ console.log(" Nestia Setup Wizard");
12
+ console.log("----------------------------------------");
13
+
14
+ // PREPARE ASSETS
15
+ const pack: PackageManager = await PackageManager.mount();
16
+ const args: ArgumentParser.IArguments = await ArgumentParser.parse(pack);
17
+
18
+ // INSTALL NESTIA
19
+ pack.install({ dev: false, modulo: "@nestia/core", version: "latest" });
20
+ pack.install({ dev: false, modulo: "@nestia/e2e", version: "latest" });
21
+ pack.install({ dev: false, modulo: "@nestia/fetcher", version: "latest" });
22
+ pack.install({
23
+ dev: args.runtime === false,
24
+ modulo: "@nestia/sdk",
25
+ version: "latest",
26
+ });
27
+ pack.install({ dev: true, modulo: "@nestia/benchmark", version: "latest" });
28
+ pack.install({ dev: true, modulo: "nestia", version: "latest" });
29
+ pack.install({ dev: false, modulo: "typia", version: "latest" });
30
+
31
+ // INSTALL TYPESCRIPT COMPILERS
32
+ pack.install({ dev: true, modulo: "ts-patch", version: "latest" });
33
+ pack.install({ dev: true, modulo: "ts-node", version: "latest" });
34
+ pack.install({
35
+ dev: true,
36
+ modulo: "typescript",
37
+ version: await getTypeScriptVersion(),
38
+ });
39
+ args.project ??= (() => {
40
+ const runner: string = pack.manager === "npm" ? "npx" : pack.manager;
41
+ CommandExecutor.run(`${runner} tsc --init`);
42
+ return (args.project = "tsconfig.json");
43
+ })();
44
+
45
+ // SETUP TRANSFORMER
46
+ await pack.save((data) => {
47
+ // COMPOSE PREPARE COMMAND
48
+ data.scripts ??= {};
49
+ if (
50
+ typeof data.scripts.prepare === "string" &&
51
+ data.scripts.prepare.trim().length !== 0
52
+ ) {
53
+ if (data.scripts.prepare.includes("ts-patch install") === false)
54
+ data.scripts.prepare = "ts-patch install && " + data.scripts.prepare;
55
+ } else data.scripts.prepare = "ts-patch install";
56
+
57
+ // NO MORE "typia patch" REQUIRED
58
+ data.scripts.prepare = data.scripts.prepare
59
+ .split("&&")
60
+ .map((str) => str.trim())
61
+ .filter((str) => str !== "typia patch")
62
+ .join(" && ");
63
+
64
+ // FOR OLDER VERSIONS
65
+ if (typeof data.scripts.postinstall === "string") {
66
+ data.scripts.postinstall = data.scripts.postinstall
67
+ .split("&&")
68
+ .map((str) => str.trim())
69
+ .filter((str) => str.indexOf("ts-patch install") === -1)
70
+ .join(" && ");
71
+ if (data.scripts.postinstall.length === 0)
72
+ delete data.scripts.postinstall;
73
+ }
74
+ });
75
+ CommandExecutor.run(`${pack.manager} run prepare`);
76
+
77
+ // CONFIGURE PLUGIN
78
+ await PluginConfigurator.configure(args);
79
+ }
80
+
81
+ const getTypeScriptVersion = async (): Promise<string> => {
82
+ const content: string = await fs.promises.readFile(
83
+ `${__dirname}/../package.json`,
84
+ "utf-8",
85
+ );
86
+ const json: { devDependencies: { typescript: string } } =
87
+ JSON.parse(content);
88
+ return json.devDependencies.typescript;
89
+ };
90
+ }