nestia 4.0.4 → 4.0.6
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 +109 -137
- package/bin/NestiaSetupWizard.d.ts +1 -6
- package/bin/NestiaSetupWizard.js +41 -72
- package/bin/NestiaSetupWizard.js.map +1 -1
- package/bin/index.js +2 -19
- package/bin/index.js.map +1 -1
- package/bin/internal/ArgumentParser.d.ts +9 -0
- package/bin/internal/ArgumentParser.js +159 -0
- package/bin/internal/ArgumentParser.js.map +1 -0
- package/bin/internal/CommandExecutor.d.ts +3 -0
- package/bin/internal/CommandExecutor.js +17 -0
- package/bin/internal/CommandExecutor.js.map +1 -0
- package/bin/internal/PackageManager.d.ts +27 -0
- package/bin/internal/PackageManager.js +79 -0
- package/bin/internal/PackageManager.js.map +1 -0
- package/bin/internal/PluginConfigurator.d.ts +5 -0
- package/bin/internal/PluginConfigurator.js +132 -0
- package/bin/internal/PluginConfigurator.js.map +1 -0
- package/package.json +5 -1
- package/bin/CommandParser.d.ts +0 -3
- package/bin/CommandParser.js +0 -21
- package/bin/CommandParser.js.map +0 -1
package/README.md
CHANGED
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
Nestia is a set of helper libraries for NestJS, supporting below features:
|
|
7
7
|
|
|
8
|
-
- [`@nestia/core`](#nestiacore): **15,000x times faster** validation
|
|
9
|
-
- [`@nestia/sdk`](#nestiasdk): evolved **SDK** and **Swagger**
|
|
8
|
+
- [`@nestia/core`](#nestiacore): **15,000x times faster** validation decorators
|
|
9
|
+
- [`@nestia/sdk`](#nestiasdk): evolved **SDK** and **Swagger** generators
|
|
10
|
+
- SDK (Software Development Kit)
|
|
11
|
+
- interaction library for client developers
|
|
12
|
+
- almost same with [tRPC](https://github.com/trpc/trpc)
|
|
10
13
|
- `nestia`: just CLI (command line interface) tool
|
|
11
14
|
|
|
12
|
-
%20Core(TM)%20i5-1135G7%20%40%202.40GHz#is)
|
|
15
|
+

|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
|
|
@@ -29,33 +30,34 @@ Just run above command, then boilerplate project would be constructed.
|
|
|
29
30
|
npx nestia setup
|
|
30
31
|
```
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
All installation and configuration processes would be automatically done.
|
|
33
|
+
Just type `npx nestia setup`, that's all.
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
If you've installed [ttypescript](https://github.com/cevek/ttypescript) during setup, you should compile `@nestia/core` utilization code through `ttsc` command, instead of `tsc`.
|
|
37
36
|
|
|
38
37
|
```bash
|
|
39
|
-
|
|
40
|
-
npx
|
|
41
|
-
npx nestia setup --manager yarn
|
|
38
|
+
# COMPILE THROUGH TTYPESCRIPT
|
|
39
|
+
npx ttsc
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
npx
|
|
41
|
+
# RUN TS-NODE WITH TTYPESCRIPT
|
|
42
|
+
npx ts-node -C ttypescript src/index.ts
|
|
45
43
|
```
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
Otherwise, you've chosen [ts-patch](https://github.com/nonara/ts-patch), you can use original `tsc` command. However, [ts-patch](https://github.com/nonara/ts-patch) hacks `node_modules/typescript` source code. Also, whenever update `typescript` version, you've to run `npm run prepare` command repeatedly.
|
|
46
|
+
|
|
47
|
+
By the way, when using `@nest/cli`, you must just choose [ts-patch](https://github.com/nonara/ts-patch).
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
|
-
#
|
|
51
|
-
|
|
50
|
+
# USE ORIGINAL TSC COMMAND
|
|
51
|
+
tsc
|
|
52
|
+
npx ts-node src/index.ts
|
|
52
53
|
|
|
53
|
-
#
|
|
54
|
-
|
|
54
|
+
# WHENVER UPDATE
|
|
55
|
+
npm install --save-dev typescript@latest
|
|
56
|
+
npm run prepare
|
|
55
57
|
```
|
|
56
58
|
|
|
57
59
|
### Manual Setup
|
|
58
|
-
If you want to install and configure `nestia` manually, read [Guide Documents
|
|
60
|
+
If you want to install and configure `nestia` manually, read [Guide Documents -> Setup](https://github.com/samchon/nestia/wiki/Setup).
|
|
59
61
|
|
|
60
62
|
|
|
61
63
|
|
|
@@ -88,7 +90,7 @@ export class BbsArticlesController {
|
|
|
88
90
|
* @param inupt Content to store
|
|
89
91
|
* @returns Newly archived article
|
|
90
92
|
*/
|
|
91
|
-
@TypedRoute.Post() //
|
|
93
|
+
@TypedRoute.Post() // 50x faster and safer JSON.stringify()
|
|
92
94
|
public async store(
|
|
93
95
|
@TypedBody() input: IBbsArticle.IStore // super-fast validator
|
|
94
96
|
): Promise<IBbsArticle>;
|
|
@@ -97,65 +99,20 @@ export class BbsArticlesController {
|
|
|
97
99
|
}
|
|
98
100
|
```
|
|
99
101
|
|
|
100
|
-
|
|
101
|
-
`TypedBody()` is a decorator function of `application/json` typed request body.
|
|
102
|
-
|
|
103
|
-
Also, it supports super-fast validation pipe, which is maximum **15,000x times faster** then `nest.Body()` function using `class-validator`.
|
|
104
|
-
|
|
105
|
-
### TypedRoute
|
|
106
|
-
`TypedRoute` is a set of decorator functions for `application/json` typed response body.
|
|
107
|
-
|
|
108
|
-
Also, it supports safe and fast JSON stringify function pipe, which is maximum 10x times faster than native `JSON.stringify()` function. Furthermore, it is **type safe** through validation.
|
|
109
|
-
|
|
110
|
-
- `TypedRoute.Get()`
|
|
111
|
-
- `TypedRoute.Post()`
|
|
112
|
-
- `TypedRoute.Put()`
|
|
113
|
-
- `TypedRoute.Patch()`
|
|
114
|
-
- `TypedRoute.Delete()`
|
|
102
|
+
If you want to know more about this core library, visit [Guide Documents](https://github.com/samchon/nestia/wiki).
|
|
115
103
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
writer: IBbsArticle.IWriter;
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* @minItems 1
|
|
132
|
-
*/
|
|
133
|
-
contents: IBbsArticle.IContent[];
|
|
134
|
-
}
|
|
135
|
-
export namespace IBbsArticle {
|
|
136
|
-
export interface IWriter {
|
|
137
|
-
/**
|
|
138
|
-
* @minLength 3
|
|
139
|
-
*/
|
|
140
|
-
name: string;
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* @format email
|
|
144
|
-
*/
|
|
145
|
-
email: string;
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* @pattern ^0[0-9]{7,16}
|
|
149
|
-
*/
|
|
150
|
-
mobile: string;
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* @minimum 18
|
|
154
|
-
*/
|
|
155
|
-
age: number;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
```
|
|
104
|
+
- Decorators
|
|
105
|
+
- [TypedRoute](https://github.com/samchon/nestia/wiki/Core-Library#typedroute)
|
|
106
|
+
- [TypedBody](https://github.com/samchon/nestia/wiki/Core-Library#typedbody)
|
|
107
|
+
- [TypedQuery](https://github.com/samchon/nestia/wiki/Core-Library#typedquery)
|
|
108
|
+
- [TypedParam](https://github.com/samchon/nestia/wiki/Core-Library#typedparam)
|
|
109
|
+
- Enhancements
|
|
110
|
+
- [Comment Tags](https://github.com/samchon/nestia/wiki/Core-Library#comment-tags)
|
|
111
|
+
- [Configuration](https://github.com/samchon/nestia/wiki/Core-Library#configuration)
|
|
112
|
+
- Advanced Usage
|
|
113
|
+
- [DynamicModule](https://github.com/samchon/nestia/wiki/Core-Library#dynamicmodule)
|
|
114
|
+
- [Encryption](https://github.com/samchon/nestia/wiki/Core-Library#encryption)
|
|
115
|
+
- [Inheritance](https://github.com/samchon/nestia/wiki/Core-Library#inheritance)
|
|
159
116
|
|
|
160
117
|
|
|
161
118
|
|
|
@@ -168,7 +125,7 @@ Automatic *SDK* and *Swagger* generator for [@nestia/core](#nestiacore).
|
|
|
168
125
|
|
|
169
126
|
With [@nestia/core](#nestiacore), you can boost up validation speed maximum **15,000x times faster**. However, as `@nestjs/swagger` does not support [@nestia/core](#nestiacore), you can't generate swagger documents from `@nestjs/swagger` more.
|
|
170
127
|
|
|
171
|
-
Instead, I provide you `@nestia/sdk` module, which can generate not only swagger documents, but also SDK (Software Development Kit) library.
|
|
128
|
+
Instead, I provide you `@nestia/sdk` module, which can generate not only swagger documents, but also SDK (Software Development Kit) library. The SDK library can be utilized by client developers and it is almost same with `tRPC`.
|
|
172
129
|
|
|
173
130
|
### Usage
|
|
174
131
|
```bash
|
|
@@ -180,71 +137,31 @@ npx nestia <sdk|swagger> <source_directories_or_patterns> \
|
|
|
180
137
|
# EXAMPLES
|
|
181
138
|
npx nestia sdk "src/**/*.controller.ts" --out "src/api"
|
|
182
139
|
npx nestia swagger "src/controllers" --out "dist/swagger.json"
|
|
183
|
-
```
|
|
184
140
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
If you've configured `nestia.config.ts` file, you can omit all options like below. About the `nestia.config.ts` file, read [Guide Documents - Configuration](https://github.com/samchon/nestia/wiki/Configuration)
|
|
188
|
-
|
|
189
|
-
```bash
|
|
141
|
+
# ONLY WHEN "nestia.config.ts" FILE EXISTS
|
|
190
142
|
npx nestia sdk
|
|
191
143
|
npx nestia swagger
|
|
192
144
|
```
|
|
193
145
|
|
|
194
|
-
|
|
195
|
-
When you generate SDK library through `npx nestia sdk` command, `@nestia/sdk` will generate below code, by analyzing your backend source code in the compilation level.
|
|
196
|
-
|
|
197
|
-
```typescript
|
|
198
|
-
import { Fetcher, IConnection } from "@nestia/fetcher";
|
|
199
|
-
import { IBbsArticle } from "../../../structures/IBbsArticle";
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Store a new content.
|
|
203
|
-
*
|
|
204
|
-
* @param input Content to store
|
|
205
|
-
* @returns Newly archived article
|
|
206
|
-
*/
|
|
207
|
-
export function store(
|
|
208
|
-
connection: api.IConnection,
|
|
209
|
-
input: IBbsArticle.IStore
|
|
210
|
-
): Promise<IBbsArticle> {
|
|
211
|
-
return Fetcher.fetch(
|
|
212
|
-
connection,
|
|
213
|
-
store.ENCRYPTED,
|
|
214
|
-
store.METHOD,
|
|
215
|
-
store.path(),
|
|
216
|
-
input
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
export namespace store {
|
|
220
|
-
export const METHOD = "POST" as const;
|
|
221
|
-
export function path(): string {
|
|
222
|
-
return "/bbs/articles";
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
```
|
|
146
|
+
You can generate sdk or swagger documents by above commands.
|
|
226
147
|
|
|
227
|
-
|
|
148
|
+
If you want to know more, visit [Guide Documents](https://github.com/samchon/nestia/wiki).
|
|
228
149
|
|
|
229
|
-
|
|
150
|
+
- Generators
|
|
151
|
+
- [Swagger Documents](https://github.com/samchon/nestia/wiki/SDK-Generator#swagger-documents)
|
|
152
|
+
- [SDK Library](https://github.com/samchon/nestia/wiki/SDK-Generator#sdk-library)
|
|
153
|
+
- Advanced Usage
|
|
154
|
+
- [Comment Tags](https://github.com/samchon/nestia/wiki/SDK-Generator#comment-tags)
|
|
155
|
+
- [Configuration](https://github.com/samchon/nestia/wiki/SDK-Generator#configuration)
|
|
230
156
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
import typia from "typia";
|
|
157
|
+
### Demonstration
|
|
158
|
+
Here is example projects building Swagger Documents and SDK Library with `npx nestia swagger` and `npx nestia sdk` comands. `@nestia/sdk` generates those documents and libraries by analyzing your NestJS backend server code in the compilation level.
|
|
234
159
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
title: "some title",
|
|
241
|
-
content: "some content",
|
|
242
|
-
}
|
|
243
|
-
);
|
|
244
|
-
typia.assert(article);
|
|
245
|
-
console.log(article);
|
|
246
|
-
}
|
|
247
|
-
```
|
|
160
|
+
Project | Controller | SDK | Swagger
|
|
161
|
+
--------|------------|-----|---------
|
|
162
|
+
`npx nestia start` | [`BbsArticlesController`](https://github.com/samchon/nestia-template/blob/master/src/controllers/BbsArticlesController.ts) | [Functions](https://github.com/samchon/nestia-template/blob/master/src/api/functional/bbs/articles/index.ts) | [Editor](https://editor.swagger.io/?url=https%3A%2F%2Fraw.githubusercontent.com%2Fsamchon%2Fnestia-template%2Fmaster%2Fdist%2Fswagger.json)
|
|
163
|
+
[fake-iamport](https://github.com/samchon/fake-iamport-server) | [`IamportCertificationsController`](https://github.com/samchon/fake-iamport-server/blob/master/src/controllers/FakeIamportCertificationsController.ts) | [Functions](https://github.com/samchon/fake-iamport-server/blob/master/src/api/functional/certifications/index.ts) | [Editor](https://editor.swagger.io/?url=https%3A%2F%2Fraw.githubusercontent.com%2Fsamchon%2Ffake-iamport-server%2Fmaster%2Fdist%2Fswagger.json)
|
|
164
|
+
[fake-toss-payments](https://github.com/samchon/fake-toss-payments-server) | [`TossPaymentsController`](https://github.com/samchon/fake-toss-payments-server/blob/master/src/controllers/FakeTossPaymentsController.ts) | [Functions](https://github.com/samchon/fake-toss-payments-server/blob/master/src/api/functional/v1/payments/index.ts) | [Editor](https://editor.swagger.io/?url=https%3A%2F%2Fraw.githubusercontent.com%2Fsamchon%2Ffake-toss-payments-server%2Fmaster%2Fdist%2Fswagger.json)
|
|
248
165
|
|
|
249
166
|
|
|
250
167
|
|
|
@@ -288,4 +205,59 @@ export function assertStringify<T>(input: T): string; // safe and faster
|
|
|
288
205
|
|
|
289
206
|
All functions in `typia` require **only one line**. You don't need any extra dedication like JSON schema definitions or decorator function calls. Just call `typia` function with only one line like `typia.assert<T>(input)`.
|
|
290
207
|
|
|
291
|
-
Also, as `typia` performs AOT (Ahead of Time) compilation skill, its performance is much faster than other competitive libaries. For an example, when comparing validate function `is()` with other competitive libraries, `typia` is maximum **15,000x times faster** than `class-validator`.
|
|
208
|
+
Also, as `typia` performs AOT (Ahead of Time) compilation skill, its performance is much faster than other competitive libaries. For an example, when comparing validate function `is()` with other competitive libraries, `typia` is maximum **15,000x times faster** than `class-validator`.
|
|
209
|
+
|
|
210
|
+
### Reactia
|
|
211
|
+
> https://github.com/samchon/reactia
|
|
212
|
+
>
|
|
213
|
+
> Not published yet, but soon
|
|
214
|
+
|
|
215
|
+
[](https://github.com/samchon/reactia/blob/master/LICENSE)
|
|
216
|
+
[](https://github.com/samchon/reactia/actions?query=workflow%3Abuild)
|
|
217
|
+
[](https://github.com/samchon/reactia/wiki)
|
|
218
|
+
|
|
219
|
+
Reactia is an automatic React components generator, just by analyzing TypeScript type.
|
|
220
|
+
|
|
221
|
+
- `@reactia/core`: Core Library analyzing TypeScript type
|
|
222
|
+
- `@reactia/mui`: Material UI Theme for `core` and `nest`
|
|
223
|
+
- `@reactia/nest`: Automatic Frontend Application Builder for `NestJS`
|
|
224
|
+
<!-- - `reactia`: Just CLI tool -->
|
|
225
|
+
|
|
226
|
+

|
|
227
|
+
|
|
228
|
+
When you want to automate an individual component, just use `@reactia/core`.
|
|
229
|
+
|
|
230
|
+
```tsx
|
|
231
|
+
import ReactDOM from "react-dom";
|
|
232
|
+
|
|
233
|
+
import typia from "typia";
|
|
234
|
+
import { ReactiaComponent } from "@reactia/core";
|
|
235
|
+
import { MuiInputTheme } from "@reactia/mui";
|
|
236
|
+
|
|
237
|
+
const RequestInput = ReactiaComponent<IRequestDto>(MuiInputTheme());
|
|
238
|
+
const input: IRequestDto = { ... };
|
|
239
|
+
|
|
240
|
+
ReactDOM.render(
|
|
241
|
+
<RequestInput input={input} />,
|
|
242
|
+
document.body
|
|
243
|
+
);
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Otherwise, you can fully automate frontend application development through `@reactia/nest`.
|
|
247
|
+
|
|
248
|
+
```tsx
|
|
249
|
+
import React from "react";
|
|
250
|
+
import ReactDOM from "react-dom";
|
|
251
|
+
|
|
252
|
+
import { ISwagger } "@nestia/swagger";
|
|
253
|
+
import { MuiApplicationTheme } from "@reactia/mui";
|
|
254
|
+
import { ReactiaApplication } from "@reactia/nest";
|
|
255
|
+
|
|
256
|
+
const swagger: ISwagger = await import("./swagger.json");
|
|
257
|
+
const App: React.FC = ReactiaApplication(MuiApplicationTheme())(swagger);
|
|
258
|
+
|
|
259
|
+
ReactDOM.render(
|
|
260
|
+
<App />,
|
|
261
|
+
document.body
|
|
262
|
+
);
|
|
263
|
+
```
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
export declare namespace NestiaSetupWizard {
|
|
2
|
-
|
|
3
|
-
manager: "npm" | "pnpm" | "yarn";
|
|
4
|
-
project: string;
|
|
5
|
-
}
|
|
6
|
-
function ttypescript(args: IArguments): Promise<void>;
|
|
7
|
-
function tsPatch(args: IArguments): Promise<void>;
|
|
2
|
+
function setup(): Promise<void>;
|
|
8
3
|
}
|
package/bin/NestiaSetupWizard.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -31,61 +8,53 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
9
|
});
|
|
33
10
|
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
12
|
exports.NestiaSetupWizard = void 0;
|
|
39
|
-
const
|
|
40
|
-
const
|
|
13
|
+
const ArgumentParser_1 = require("./internal/ArgumentParser");
|
|
14
|
+
const CommandExecutor_1 = require("./internal/CommandExecutor");
|
|
15
|
+
const PackageManager_1 = require("./internal/PackageManager");
|
|
16
|
+
const PluginConfigurator_1 = require("./internal/PluginConfigurator");
|
|
41
17
|
var NestiaSetupWizard;
|
|
42
18
|
(function (NestiaSetupWizard) {
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
const wizard = yield prepare(args);
|
|
46
|
-
yield wizard.ttypescript(args);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
NestiaSetupWizard.ttypescript = ttypescript;
|
|
50
|
-
function tsPatch(args) {
|
|
19
|
+
function setup() {
|
|
20
|
+
var _a;
|
|
51
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
22
|
+
console.log("----------------------------------------");
|
|
23
|
+
console.log(" Nestia Setup Wizard");
|
|
24
|
+
console.log("----------------------------------------");
|
|
25
|
+
// LOAD PACKAGE.JSON INFO
|
|
26
|
+
const pack = yield PackageManager_1.PackageManager.mount();
|
|
27
|
+
// TAKE ARGUMENTS
|
|
28
|
+
const args = yield ArgumentParser_1.ArgumentParser.parse(pack);
|
|
29
|
+
// INSTALL TYPESCRIPT
|
|
30
|
+
pack.install({ dev: true, modulo: "typescript" });
|
|
31
|
+
(_a = args.project) !== null && _a !== void 0 ? _a : (args.project = (() => {
|
|
32
|
+
CommandExecutor_1.CommandExecutor.run("npx tsc --init", false);
|
|
33
|
+
return (args.project = "tsconfig.json");
|
|
34
|
+
})());
|
|
35
|
+
pack.install({ dev: true, modulo: "ts-node" });
|
|
36
|
+
// INSTALL COMPILER
|
|
37
|
+
pack.install({ dev: true, modulo: args.compiler });
|
|
38
|
+
if (args.compiler === "ts-patch") {
|
|
39
|
+
yield pack.save((data) => {
|
|
40
|
+
var _a;
|
|
41
|
+
(_a = data.scripts) !== null && _a !== void 0 ? _a : (data.scripts = {});
|
|
42
|
+
if (typeof data.scripts.prepare === "string")
|
|
43
|
+
data.scripts.prepare =
|
|
44
|
+
"ts-patch install && " + data.scripts.prepare;
|
|
45
|
+
else
|
|
46
|
+
data.scripts.prepare = "ts-patch install";
|
|
47
|
+
});
|
|
48
|
+
CommandExecutor_1.CommandExecutor.run("npm run prepare", false);
|
|
49
|
+
}
|
|
50
|
+
// INSTALL AND CONFIGURE TYPIA
|
|
51
|
+
pack.install({ dev: false, modulo: "typia" });
|
|
52
|
+
pack.install({ dev: false, modulo: "@nestia/core" });
|
|
53
|
+
pack.install({ dev: true, modulo: "@nestia/sdk" });
|
|
54
|
+
pack.install({ dev: true, modulo: "nestia" });
|
|
55
|
+
yield PluginConfigurator_1.PluginConfigurator.configure(pack, args);
|
|
68
56
|
});
|
|
69
57
|
}
|
|
58
|
+
NestiaSetupWizard.setup = setup;
|
|
70
59
|
})(NestiaSetupWizard = exports.NestiaSetupWizard || (exports.NestiaSetupWizard = {}));
|
|
71
|
-
const add = (manager) => (pack) => (modulo, devOnly) => {
|
|
72
|
-
const exists = (devOnly === false
|
|
73
|
-
? !!pack.dependencies && !!pack.dependencies[modulo]
|
|
74
|
-
: !!pack.devDependencies && !!pack.devDependencies[modulo]) &&
|
|
75
|
-
fs_1.default.existsSync("node_modules/" + modulo);
|
|
76
|
-
const middle = manager === "yarn"
|
|
77
|
-
? `add${devOnly ? " -D" : ""}`
|
|
78
|
-
: `install ${devOnly ? "--save-dev" : "--save"}`;
|
|
79
|
-
if (exists === false)
|
|
80
|
-
execute(`${manager} ${middle} ${modulo}`);
|
|
81
|
-
};
|
|
82
|
-
const halt = (closer) => (desc) => {
|
|
83
|
-
closer();
|
|
84
|
-
console.error(desc);
|
|
85
|
-
process.exit(-1);
|
|
86
|
-
};
|
|
87
|
-
function execute(command) {
|
|
88
|
-
console.log(command);
|
|
89
|
-
child_process_1.default.execSync(command, { stdio: "inherit" });
|
|
90
|
-
}
|
|
91
60
|
//# sourceMappingURL=NestiaSetupWizard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaSetupWizard.js","sourceRoot":"","sources":["../src/NestiaSetupWizard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NestiaSetupWizard.js","sourceRoot":"","sources":["../src/NestiaSetupWizard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8DAA2D;AAC3D,gEAA6D;AAC7D,8DAA2D;AAC3D,sEAAmE;AAEnE,IAAiB,iBAAiB,CA0CjC;AA1CD,WAAiB,iBAAiB;IAC9B,SAAsB,KAAK;;;YACvB,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;YACxD,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;YACpC,OAAO,CAAC,GAAG,CAAC,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E,KAAK,CAAC,CAAC;aACjD;YAED,8BAA8B;YAC9B,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;YAC9C,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;YACrD,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;YACnD,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC9C,MAAM,uCAAkB,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;;KAClD;IAxCqB,uBAAK,QAwC1B,CAAA;AACL,CAAC,EA1CgB,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QA0CjC"}
|
package/bin/index.js
CHANGED
|
@@ -33,14 +33,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const CommandParser_1 = require("./CommandParser");
|
|
37
36
|
const NestiaSetupWizard_1 = require("./NestiaSetupWizard");
|
|
38
37
|
const NestiaStarter_1 = require("./NestiaStarter");
|
|
39
38
|
const USAGE = `Wrong command has been detected. Use like below:
|
|
40
39
|
|
|
41
40
|
npx nestia [command] [options?]
|
|
42
41
|
|
|
43
|
-
1. npx nestia start <directory>
|
|
42
|
+
1. npx nestia start <directory> --manager (npm|pnpm|yarn)
|
|
44
43
|
- npx nestia start project
|
|
45
44
|
- npx nestia start project --manager pnpm
|
|
46
45
|
2. npx nestia setup \\
|
|
@@ -68,22 +67,6 @@ function halt(desc) {
|
|
|
68
67
|
console.error(desc);
|
|
69
68
|
process.exit(-1);
|
|
70
69
|
}
|
|
71
|
-
function setup() {
|
|
72
|
-
var _a, _b, _c;
|
|
73
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
const options = CommandParser_1.CommandParser.parse(process.argv.slice(3));
|
|
75
|
-
const manager = (_a = options.manager) !== null && _a !== void 0 ? _a : "npm";
|
|
76
|
-
const compiler = (_b = options.compiler) !== null && _b !== void 0 ? _b : "ttypescript";
|
|
77
|
-
const project = (_c = options.project) !== null && _c !== void 0 ? _c : "tsconfig.json";
|
|
78
|
-
if ((compiler !== "ttypescript" && compiler !== "ts-patch") ||
|
|
79
|
-
(manager !== "npm" && manager !== "pnpm" && manager !== "yarn"))
|
|
80
|
-
halt(USAGE);
|
|
81
|
-
else if (compiler === "ttypescript")
|
|
82
|
-
yield NestiaSetupWizard_1.NestiaSetupWizard.ttypescript({ manager, project });
|
|
83
|
-
else
|
|
84
|
-
yield NestiaSetupWizard_1.NestiaSetupWizard.tsPatch({ manager, project });
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
70
|
function main() {
|
|
88
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
72
|
var _a, _b;
|
|
@@ -92,7 +75,7 @@ function main() {
|
|
|
92
75
|
if (type === "start")
|
|
93
76
|
yield NestiaStarter_1.NestiaStarter.start((msg) => halt(msg !== null && msg !== void 0 ? msg : USAGE))(argv);
|
|
94
77
|
else if (type === "setup")
|
|
95
|
-
yield setup();
|
|
78
|
+
yield NestiaSetupWizard_1.NestiaSetupWizard.setup();
|
|
96
79
|
else if (type === "dependencies" ||
|
|
97
80
|
type === "init" ||
|
|
98
81
|
type === "sdk" ||
|
package/bin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;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C,CAAC;AACrB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PackageManager } from "./PackageManager";
|
|
2
|
+
export declare namespace ArgumentParser {
|
|
3
|
+
interface IArguments {
|
|
4
|
+
compiler: "ts-patch" | "ttypescript";
|
|
5
|
+
manager: "npm" | "pnpm" | "yarn";
|
|
6
|
+
project: string | null;
|
|
7
|
+
}
|
|
8
|
+
function parse(pack: PackageManager): Promise<IArguments>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.ArgumentParser = void 0;
|
|
39
|
+
const fs_1 = __importDefault(require("fs"));
|
|
40
|
+
const path_1 = __importDefault(require("path"));
|
|
41
|
+
var ArgumentParser;
|
|
42
|
+
(function (ArgumentParser) {
|
|
43
|
+
function parse(pack) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
// INSTALL TEMPORARY PACKAGES
|
|
46
|
+
const newbie = {
|
|
47
|
+
commander: pack.install({
|
|
48
|
+
dev: true,
|
|
49
|
+
modulo: "commander",
|
|
50
|
+
version: "10.0.0",
|
|
51
|
+
silent: true,
|
|
52
|
+
}),
|
|
53
|
+
inquirer: pack.install({
|
|
54
|
+
dev: true,
|
|
55
|
+
modulo: "inquirer",
|
|
56
|
+
version: "8.2.5",
|
|
57
|
+
silent: true,
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
60
|
+
// TAKE OPTIONS
|
|
61
|
+
const output = yield (() => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
try {
|
|
63
|
+
return yield _Parse(pack);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
return error;
|
|
67
|
+
}
|
|
68
|
+
}))();
|
|
69
|
+
// REMOVE TEMPORARY PACKAGES
|
|
70
|
+
if (newbie.commander)
|
|
71
|
+
pack.erase({ modulo: "commander", silent: true });
|
|
72
|
+
if (newbie.inquirer)
|
|
73
|
+
pack.erase({ modulo: "inquirer", silent: true });
|
|
74
|
+
// RETURNS
|
|
75
|
+
if (output instanceof Error)
|
|
76
|
+
throw output;
|
|
77
|
+
return output;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
ArgumentParser.parse = parse;
|
|
81
|
+
function _Parse(pack) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
var _a, _b;
|
|
84
|
+
// PREPARE ASSETS
|
|
85
|
+
const { createPromptModule } = yield (_a = path_1.default.join(pack.directory, "node_modules", "inquirer"), Promise.resolve().then(() => __importStar(require(_a))));
|
|
86
|
+
const { program } = yield (_b = path_1.default.join(pack.directory, "node_modules", "commander"), Promise.resolve().then(() => __importStar(require(_b))));
|
|
87
|
+
program.option("--compiler [compiler]", "compiler type");
|
|
88
|
+
program.option("--manager [manager", "package manager");
|
|
89
|
+
program.option("--project [project]", "tsconfig.json file location");
|
|
90
|
+
// INTERNAL PROCEDURES
|
|
91
|
+
const questioned = { value: false };
|
|
92
|
+
const action = (closure) => {
|
|
93
|
+
return new Promise((resolve, reject) => {
|
|
94
|
+
program.action((options) => __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
try {
|
|
96
|
+
resolve(yield closure(options));
|
|
97
|
+
}
|
|
98
|
+
catch (exp) {
|
|
99
|
+
reject(exp);
|
|
100
|
+
}
|
|
101
|
+
}));
|
|
102
|
+
program.parseAsync().catch(reject);
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
const select = (name) => (message) => (choices) => __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
questioned.value = true;
|
|
107
|
+
return (yield createPromptModule()({
|
|
108
|
+
type: "list",
|
|
109
|
+
name: name,
|
|
110
|
+
message: message,
|
|
111
|
+
choices: choices,
|
|
112
|
+
}))[name];
|
|
113
|
+
});
|
|
114
|
+
const configure = () => __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
const fileList = yield (yield fs_1.default.promises.readdir(process.cwd())).filter((str) => str.substring(0, 8) === "tsconfig" &&
|
|
116
|
+
str.substring(str.length - 5) === ".json");
|
|
117
|
+
if (fileList.length === 0) {
|
|
118
|
+
if (process.cwd() !== pack.directory)
|
|
119
|
+
throw new Error(`Unable to find "tsconfig.json" file.`);
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
else if (fileList.length === 1)
|
|
123
|
+
return fileList[0];
|
|
124
|
+
return select("tsconfig")("TS Config File")(fileList);
|
|
125
|
+
});
|
|
126
|
+
// DO CONSTRUCT
|
|
127
|
+
return action((options) => __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
var _c, _d, _e;
|
|
129
|
+
if (options.compiler === undefined) {
|
|
130
|
+
console.log(COMPILER_DESCRIPTION);
|
|
131
|
+
options.compiler = yield select("compiler")(`Compiler`)(((_c = pack.data.scripts) === null || _c === void 0 ? void 0 : _c.build) === "nest build"
|
|
132
|
+
? ["ts-patch", "ttypescript"]
|
|
133
|
+
: ["ttypescript", "ts-patch"]);
|
|
134
|
+
}
|
|
135
|
+
(_d = options.manager) !== null && _d !== void 0 ? _d : (options.manager = yield select("manager")("Package Manager")([
|
|
136
|
+
"npm",
|
|
137
|
+
"pnpm",
|
|
138
|
+
"yarn",
|
|
139
|
+
]));
|
|
140
|
+
pack.manager = options.manager;
|
|
141
|
+
(_e = options.project) !== null && _e !== void 0 ? _e : (options.project = yield configure());
|
|
142
|
+
if (questioned.value)
|
|
143
|
+
console.log("");
|
|
144
|
+
return options;
|
|
145
|
+
}));
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
})(ArgumentParser = exports.ArgumentParser || (exports.ArgumentParser = {}));
|
|
149
|
+
const COMPILER_DESCRIPTION = [
|
|
150
|
+
`About compiler, if you adapt "ttypescript", you should use "ttsc" instead.`,
|
|
151
|
+
``,
|
|
152
|
+
`Otherwise, you choose "ts-patch", you can use the original "tsc" command.`,
|
|
153
|
+
`However, the "ts-patch" hacks "node_modules/typescript" source code.`,
|
|
154
|
+
`Also, whenever update "typescript", you've to run "npm run prepare" command.`,
|
|
155
|
+
``,
|
|
156
|
+
`By the way, when using "@nest/cli", you must just choose "ts-patch".`,
|
|
157
|
+
``,
|
|
158
|
+
].join("\n");
|
|
159
|
+
//# sourceMappingURL=ArgumentParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArgumentParser.js","sourceRoot":"","sources":["../../src/internal/ArgumentParser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4CAAoB;AAEpB,gDAAwB;AAIxB,IAAiB,cAAc,CA6H9B;AA7HD,WAAiB,cAAc;IAO3B,SAAsB,KAAK,CAAC,IAAoB;;YAC5C,6BAA6B;YAC7B,MAAM,MAAM,GAAG;gBACX,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC;oBACpB,GAAG,EAAE,IAAI;oBACT,MAAM,EAAE,WAAW;oBACnB,OAAO,EAAE,QAAQ;oBACjB,MAAM,EAAE,IAAI;iBACf,CAAC;gBACF,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC;oBACnB,GAAG,EAAE,IAAI;oBACT,MAAM,EAAE,UAAU;oBAClB,OAAO,EAAE,OAAO;oBAChB,MAAM,EAAE,IAAI;iBACf,CAAC;aACL,CAAC;YAEF,eAAe;YACf,MAAM,MAAM,GAAuB,MAAM,CAAC,GAAS,EAAE;gBACjD,IAAI;oBACA,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;iBAC7B;gBAAC,OAAO,KAAK,EAAE;oBACZ,OAAO,KAAc,CAAC;iBACzB;YACL,CAAC,CAAA,CAAC,EAAE,CAAC;YAEL,4BAA4B;YAC5B,IAAI,MAAM,CAAC,SAAS;gBAAE,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,WAA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3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CommandExecutor = void 0;
|
|
7
|
+
const child_process_1 = __importDefault(require("child_process"));
|
|
8
|
+
var CommandExecutor;
|
|
9
|
+
(function (CommandExecutor) {
|
|
10
|
+
function run(str, silent) {
|
|
11
|
+
if (silent === false)
|
|
12
|
+
console.log(str);
|
|
13
|
+
child_process_1.default.execSync(str, { stdio: "ignore" });
|
|
14
|
+
}
|
|
15
|
+
CommandExecutor.run = run;
|
|
16
|
+
})(CommandExecutor = exports.CommandExecutor || (exports.CommandExecutor = {}));
|
|
17
|
+
//# sourceMappingURL=CommandExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../src/internal/CommandExecutor.ts"],"names":[],"mappings":";;;;;;AAAA,kEAA+B;AAE/B,IAAiB,eAAe,CAK/B;AALD,WAAiB,eAAe;IAC5B,SAAgB,GAAG,CAAC,GAAW,EAAE,MAAe;QAC5C,IAAI,MAAM,KAAK,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvC,uBAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC1C,CAAC;IAHe,mBAAG,MAGlB,CAAA;AACL,CAAC,EALgB,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAK/B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare class PackageManager {
|
|
2
|
+
readonly directory: string;
|
|
3
|
+
data: Package.Data;
|
|
4
|
+
manager: string;
|
|
5
|
+
get file(): string;
|
|
6
|
+
static mount(): Promise<PackageManager>;
|
|
7
|
+
save(modifier: (data: Package.Data) => void): Promise<void>;
|
|
8
|
+
install(props: {
|
|
9
|
+
dev: boolean;
|
|
10
|
+
silent?: boolean;
|
|
11
|
+
modulo: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
}): boolean;
|
|
14
|
+
erase(props: {
|
|
15
|
+
modulo: string;
|
|
16
|
+
silent?: boolean;
|
|
17
|
+
}): void;
|
|
18
|
+
private constructor();
|
|
19
|
+
private static load;
|
|
20
|
+
}
|
|
21
|
+
export declare namespace Package {
|
|
22
|
+
interface Data {
|
|
23
|
+
scripts?: Record<string, string>;
|
|
24
|
+
dependencies?: Record<string, string>;
|
|
25
|
+
devDependencies?: Record<string, string>;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PackageManager = void 0;
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const CommandExecutor_1 = require("./CommandExecutor");
|
|
19
|
+
class PackageManager {
|
|
20
|
+
get file() {
|
|
21
|
+
return path_1.default.join(this.directory, "package.json");
|
|
22
|
+
}
|
|
23
|
+
static mount() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const location = yield find(process.cwd());
|
|
26
|
+
if (location === null)
|
|
27
|
+
throw new Error(`Unable to find "package.json" file`);
|
|
28
|
+
return new PackageManager(location, yield this.load(path_1.default.join(location, "package.json")));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
save(modifier) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const content = yield fs_1.default.promises.readFile(this.file, "utf8");
|
|
34
|
+
this.data = JSON.parse(content);
|
|
35
|
+
modifier(this.data);
|
|
36
|
+
return fs_1.default.promises.writeFile(this.file, JSON.stringify(this.data, null, 2), "utf8");
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
install(props) {
|
|
40
|
+
const container = props.dev
|
|
41
|
+
? this.data.devDependencies
|
|
42
|
+
: this.data.dependencies;
|
|
43
|
+
if (!!(container === null || container === void 0 ? void 0 : container[props.modulo]) &&
|
|
44
|
+
fs_1.default.existsSync(path_1.default.join(this.directory, "node_modules", props.modulo)))
|
|
45
|
+
return false;
|
|
46
|
+
const middle = this.manager === "yarn"
|
|
47
|
+
? `add${props.dev ? " -D" : ""}`
|
|
48
|
+
: `install ${props.dev ? "--save-dev" : "--save"}`;
|
|
49
|
+
CommandExecutor_1.CommandExecutor.run(`${this.manager} ${middle} ${props.modulo}${props.version ? `@${props.version}` : ""}`, !!props.silent);
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
erase(props) {
|
|
53
|
+
const middle = this.manager === "yarn" ? "remove" : "uninstall";
|
|
54
|
+
CommandExecutor_1.CommandExecutor.run(`${this.manager} ${middle} ${props.modulo}`, !!props.silent);
|
|
55
|
+
}
|
|
56
|
+
constructor(directory, data) {
|
|
57
|
+
this.directory = directory;
|
|
58
|
+
this.data = data;
|
|
59
|
+
this.manager = "npm";
|
|
60
|
+
}
|
|
61
|
+
static load(file) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const content = yield fs_1.default.promises.readFile(file, "utf8");
|
|
64
|
+
return JSON.parse(content);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.PackageManager = PackageManager;
|
|
69
|
+
function find(directory = process.cwd(), depth = 0) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
const location = path_1.default.join(directory, "package.json");
|
|
72
|
+
if (fs_1.default.existsSync(location))
|
|
73
|
+
return directory;
|
|
74
|
+
else if (depth > 1)
|
|
75
|
+
return null;
|
|
76
|
+
return find(path_1.default.join(directory, ".."), depth + 1);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=PackageManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PackageManager.js","sourceRoot":"","sources":["../../src/internal/PackageManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,uDAAoD;AAEpD,MAAa,cAAc;IAEvB,IAAW,IAAI;QACX,OAAO,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IACrD,CAAC;IAEM,MAAM,CAAO,KAAK;;YACrB,MAAM,QAAQ,GAAkB,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;YAC1D,IAAI,QAAQ,KAAK,IAAI;gBACjB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;YAE1D,OAAO,IAAI,cAAc,CACrB,QAAQ,EACR,MAAM,IAAI,CAAC,IAAI,CAAC,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CACvD,CAAC;QACN,CAAC;KAAA;IAEY,IAAI,CAAC,QAAsC;;YACpD,MAAM,OAAO,GAAW,MAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACtE,IAAI,CAAC,IAAI,GAAG,IA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,KAA2C;QACpD,MAAM,MAAM,GAAW,IAAI,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC;QACxE,iCAAe,CAAC,GAAG,CACf,GAAG,IAAI,CAAC,OAAO,IAAI,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE,EAC3C,CAAC,CAAC,KAAK,CAAC,MAAM,CACjB,CAAC;IACN,CAAC;IAED,YACoB,SAAiB,EAC1B,IAAkB;QADT,cAAS,GAAT,SAAS,CAAQ;QAC1B,SAAI,GAAJ,IAAI,CAAc;QApEtB,YAAO,GAAW,KAAK,CAAC;IAqE5B,CAAC;IAEI,MAAM,CAAO,IAAI,CAAC,IAAY;;YAClC,MAAM,OAAO,GAAW,MAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACjE,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;KAAA;CACJ;AA5ED,wCA4EC;AASD,SAAe,IAAI,CACf,YAAoB,OAAO,CAAC,GAAG,EAAE,EACjC,QAAgB,CAAC;;QAEjB,MAAM,QAAQ,GAAW,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QAC9D,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,OAAO,SAAS,CAAC;aACzC,IAAI,KAAK,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QAChC,OAAO,IAAI,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IACvD,CAAC;CAAA"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.PluginConfigurator = void 0;
|
|
39
|
+
const fs_1 = __importDefault(require("fs"));
|
|
40
|
+
const path_1 = __importDefault(require("path"));
|
|
41
|
+
var PluginConfigurator;
|
|
42
|
+
(function (PluginConfigurator) {
|
|
43
|
+
function configure(pack, args) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
// INSTALL COMMENT-JSON
|
|
46
|
+
const installed = pack.install({
|
|
47
|
+
dev: true,
|
|
48
|
+
modulo: "comment-json",
|
|
49
|
+
version: "4.2.3",
|
|
50
|
+
silent: true,
|
|
51
|
+
});
|
|
52
|
+
// DO CONFIGURE
|
|
53
|
+
const error = yield (() => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
try {
|
|
55
|
+
yield _Configure(pack, args);
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
catch (exp) {
|
|
59
|
+
return exp;
|
|
60
|
+
}
|
|
61
|
+
}))();
|
|
62
|
+
// REMOVE IT
|
|
63
|
+
if (installed)
|
|
64
|
+
pack.erase({
|
|
65
|
+
modulo: "comment-json",
|
|
66
|
+
silent: true,
|
|
67
|
+
});
|
|
68
|
+
if (error !== null)
|
|
69
|
+
throw error;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
PluginConfigurator.configure = configure;
|
|
73
|
+
function _Configure(pack, args) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
var _a;
|
|
76
|
+
// GET COMPILER-OPTIONS
|
|
77
|
+
const Comment = yield (_a = path_1.default.join(pack.directory, "node_modules", "comment-json"), Promise.resolve().then(() => __importStar(require(_a))));
|
|
78
|
+
const config = Comment.parse(yield fs_1.default.promises.readFile(args.project, "utf8"));
|
|
79
|
+
const compilerOptions = config.compilerOptions;
|
|
80
|
+
if (compilerOptions === undefined)
|
|
81
|
+
throw new Error(`${args.project} file does not have "compilerOptions" property.`);
|
|
82
|
+
// PREPARE PLUGINS
|
|
83
|
+
const plugins = (() => {
|
|
84
|
+
const plugins = compilerOptions.plugins;
|
|
85
|
+
if (plugins === undefined)
|
|
86
|
+
return (compilerOptions.plugins = []);
|
|
87
|
+
else if (!Array.isArray(plugins))
|
|
88
|
+
throw new Error(`"plugins" property of ${args.project} must be array type.`);
|
|
89
|
+
return plugins;
|
|
90
|
+
})();
|
|
91
|
+
// CHECK WHETHER CONFIGURED
|
|
92
|
+
const strict = compilerOptions.strict === true;
|
|
93
|
+
const core = plugins.find((p) => typeof p === "object" &&
|
|
94
|
+
p !== null &&
|
|
95
|
+
p.transform === "@nestia/core/lib/transform");
|
|
96
|
+
const typia = plugins.find((p) => typeof p === "object" &&
|
|
97
|
+
p !== null &&
|
|
98
|
+
p.transform === "typia/lib/transform");
|
|
99
|
+
if (strict && !!core && !!typia)
|
|
100
|
+
return;
|
|
101
|
+
// DO CONFIGURE
|
|
102
|
+
compilerOptions.strict = true;
|
|
103
|
+
if (core === undefined)
|
|
104
|
+
plugins.push(Comment.parse(`{
|
|
105
|
+
"transform": "@nestia/core/lib/transform",
|
|
106
|
+
/**
|
|
107
|
+
* Validate request body.
|
|
108
|
+
*
|
|
109
|
+
* - "assert": Use typia.assert() function
|
|
110
|
+
* - "is": Use typia.is() function
|
|
111
|
+
* - "validate": Use typia.validate() function
|
|
112
|
+
*/
|
|
113
|
+
"validate": "assert",
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Validate JSON typed response body.
|
|
117
|
+
*
|
|
118
|
+
* - null: Just use JSON.stringify() function, without boosting
|
|
119
|
+
* - "stringify": Use typia.stringify() function, but dangerous
|
|
120
|
+
* - "assert": Use typia.assertStringify() function
|
|
121
|
+
* - "is": Use typia.isStringify() function
|
|
122
|
+
* - "validate": Use typia.validateStringify() function
|
|
123
|
+
*/
|
|
124
|
+
"stringify": "is"
|
|
125
|
+
}`));
|
|
126
|
+
if (typia === undefined)
|
|
127
|
+
plugins.push(Comment.parse(`{ "transform": "typia/lib/transform" }`));
|
|
128
|
+
yield fs_1.default.promises.writeFile(args.project, Comment.stringify(config, null, 2));
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
})(PluginConfigurator = exports.PluginConfigurator || (exports.PluginConfigurator = {}));
|
|
132
|
+
//# sourceMappingURL=PluginConfigurator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginConfigurator.js","sourceRoot":"","sources":["../../src/internal/PluginConfigurator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4CAAoB;AACpB,gDAAwB;AAKxB,IAAiB,kBAAkB,CAwHlC;AAxHD,WAAiB,kBAAkB;IAC/B,SAAsB,SAAS,CAC3B,IAAoB,EACpB,IAA+B;;YAE/B,uBAAuB;YACvB,MAAM,SAAS,GAAY,IAAI,CAAC,OAAO,CAAC;gBACpC,GAAG,EAAE,IAAI;gBACT,MAAM,EAAE,cAAc;gBACtB,OAAO,EAAE,OAAO;gBAChB,MAAM,EAAE,IAAI;aACf,CAAC,CAAC;YAEH,eAAe;YACf,MAAM,KAAK,GAAiB,MAAM,CAAC,GAAS,EAAE;gBAC1C,IAAI;oBACA,MAAM,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;oBAC7B,OAAO,IAAI,CAAC;iBACf;gBAAC,OAAO,GAAG,EAAE;oBACV,OAAO,GAAY,CAAC;iBACvB;YACL,CAAC,CAAA,CAAC,EAAE,CAAC;YAEL,YAAY;YACZ,IAAI,SAAS;gBACT,IAAI,CAAC,KAAK,CAAC;oBACP,MAAM,EAAE,cAAc;oBACtB,MAAM,EAAE,IAAI;iBACf,CAAC,CAAC;YACP,IAAI,KAAK,KAAK,IAAI;gBAAE,MAAM,KAAK,CAAC;QACpC,CAAC;KAAA;IA7BqB,4BAAS,YA6B9B,CAAA;IAED,SAAe,UAAU,CACrB,IAAoB,EACpB,IAA+B;;;YAE/B,uBAAuB;YACvB,MAAM,OAAO,GAAkC,YAC3C,cAAI,CAAC,IAAI,CAAC,IAA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I,CAAC,CAAC,KAAK;gBAAE,OAAO;YAExC,eAAe;YACf,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC;YAC9B,IAAI,IAAI,KAAK,SAAS;gBAClB,OAAO,CAAC,IAAI,CACR,OAAO,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;kBAqBZ,CAA0B,CAC/B,CAAC;YACN,IAAI,KAAK,KAAK,SAAS;gBACnB,OAAO,CAAC,IAAI,CACR,OAAO,CAAC,KAAK,CACT,wCAAwC,CAClB,CAC7B,CAAC;YACN,MAAM,YAAE,CAAC,QAAQ,CAAC,SAAS,CACvB,IAAI,CAAC,OAAQ,EACb,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CACrC,CAAC;QACN,CAAC;KAAA;AACL,CAAC,EAxHgB,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAwHlC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nestia",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.6",
|
|
4
4
|
"description": "Nestia CLI",
|
|
5
5
|
"main": "bin/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -31,7 +31,11 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@nestia/core": "^1.0.6",
|
|
33
33
|
"@nestia/sdk": "^1.0.1",
|
|
34
|
+
"@types/inquirer": "^9.0.3",
|
|
34
35
|
"@types/node": "^18.11.16",
|
|
36
|
+
"commander": "^10.0.0",
|
|
37
|
+
"comment-json": "^4.2.3",
|
|
38
|
+
"inquirer": "^8.2.5",
|
|
35
39
|
"rimraf": "^3.0.2",
|
|
36
40
|
"typescript": "^4.9.4"
|
|
37
41
|
},
|
package/bin/CommandParser.d.ts
DELETED
package/bin/CommandParser.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommandParser = void 0;
|
|
4
|
-
var CommandParser;
|
|
5
|
-
(function (CommandParser) {
|
|
6
|
-
function parse(argList) {
|
|
7
|
-
const output = {};
|
|
8
|
-
argList.forEach((arg, i) => {
|
|
9
|
-
if (arg.startsWith("--") === false)
|
|
10
|
-
return;
|
|
11
|
-
const key = arg.slice(2);
|
|
12
|
-
const value = argList[i + 1];
|
|
13
|
-
if (value === undefined || value.startsWith("--"))
|
|
14
|
-
return;
|
|
15
|
-
output[key] = value;
|
|
16
|
-
});
|
|
17
|
-
return output;
|
|
18
|
-
}
|
|
19
|
-
CommandParser.parse = parse;
|
|
20
|
-
})(CommandParser = exports.CommandParser || (exports.CommandParser = {}));
|
|
21
|
-
//# sourceMappingURL=CommandParser.js.map
|
package/bin/CommandParser.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CommandParser.js","sourceRoot":"","sources":["../src/CommandParser.ts"],"names":[],"mappings":";;;AAAA,IAAiB,aAAa,CAc7B;AAdD,WAAiB,aAAa;IAC1B,SAAgB,KAAK,CAAC,OAAiB;QACnC,MAAM,MAAM,GAA2B,EAAE,CAAC;QAC1C,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;YACvB,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,KAAK;gBAAE,OAAO;YAE3C,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACzB,MAAM,KAAK,GAAuB,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACjD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;gBAAE,OAAO;YAE1D,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACxB,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAClB,CAAC;IAZe,mBAAK,QAYpB,CAAA;AACL,CAAC,EAdgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAc7B"}
|