nestia 4.0.10 → 4.0.11-dev.20230410-2
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 +11 -65
- package/bin/NestiaSetupWizard.js +1 -1
- package/bin/NestiaSetupWizard.js.map +1 -1
- package/bin/index.d.ts +3 -1
- package/bin/index.js +20 -16
- package/bin/index.js.map +1 -1
- package/bin/internal/ArgumentParser.js +9 -48
- package/bin/internal/ArgumentParser.js.map +1 -1
- package/bin/internal/FileRetriever.d.ts +0 -1
- package/bin/internal/FileRetriever.js +0 -39
- package/bin/internal/FileRetriever.js.map +1 -1
- package/bin/internal/PackageManager.d.ts +0 -5
- package/bin/internal/PackageManager.js +1 -11
- package/bin/internal/PackageManager.js.map +1 -1
- package/bin/internal/PluginConfigurator.d.ts +1 -2
- package/bin/internal/PluginConfigurator.js +7 -38
- package/bin/internal/PluginConfigurator.js.map +1 -1
- package/package.json +9 -6
- package/src/NestiaSetupWizard.ts +48 -0
- package/src/NestiaStarter.ts +44 -0
- package/src/index.ts +74 -0
- package/src/internal/ArgumentParser.ts +114 -0
- package/src/internal/CommandExecutor.ts +8 -0
- package/src/internal/FileRetriever.ts +22 -0
- package/src/internal/PackageManager.ts +72 -0
- package/src/internal/PluginConfigurator.ts +89 -0
package/README.md
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
Nestia is a set of helper libraries for NestJS, supporting below features:
|
|
7
7
|
|
|
8
|
-
- [`@nestia/core`](#nestiacore):
|
|
8
|
+
- [`@nestia/core`](#nestiacore): super-fast decorators
|
|
9
|
+
- **20,000x faster** validation
|
|
10
|
+
- **200x faster** JSON serialization
|
|
9
11
|
- [`@nestia/sdk`](#nestiasdk): evolved **SDK** and **Swagger** generators
|
|
10
12
|
- SDK (Software Development Kit)
|
|
11
13
|
- interaction library for client developers
|
|
@@ -37,11 +39,10 @@ Just run above command, then boilerplate project would be constructed.
|
|
|
37
39
|
|
|
38
40
|
### Setup Wizard
|
|
39
41
|
```bash
|
|
42
|
+
npm install --save-dev nestia
|
|
40
43
|
npx nestia setup
|
|
41
44
|
```
|
|
42
45
|
|
|
43
|
-
Just type `npx nestia setup`, that's all.
|
|
44
|
-
|
|
45
46
|
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`.
|
|
46
47
|
|
|
47
48
|
```bash
|
|
@@ -79,7 +80,7 @@ If you want to install and configure `nestia` manually, read [Guide Documents ->
|
|
|
79
80
|
Super-fast validation decorators for NestJS.
|
|
80
81
|
|
|
81
82
|
- 15,000x faster request body validation
|
|
82
|
-
-
|
|
83
|
+
- 100x faster JSON response, even type safe
|
|
83
84
|
- Do not need DTO class definition, just fine with interface
|
|
84
85
|
|
|
85
86
|
`@nestia/core` is a transformer library of NestJS, supporting super-fast validation decorators, by wrapping [typia](https://github.com/samchon/typia). Comparing validation speed with `class-validator`, [typia](https://github.com/samchon/typia) is maximum **15,000x times faster** and it is even much safer.
|
|
@@ -193,11 +194,7 @@ Project | Controller | SDK | Swagger
|
|
|
193
194
|
export function is<T>(input: unknown | T): input is T; // returns boolean
|
|
194
195
|
export function assert<T>(input: unknown | T): T; // throws TypeGuardError
|
|
195
196
|
export function validate<T>(input: unknown | T): IValidation<T>; // detailed
|
|
196
|
-
|
|
197
|
-
// STRICT VALIDATORS
|
|
198
|
-
export function equals<T>(input: unknown | T): input is T;
|
|
199
|
-
export function assertEquals<T>(input: unknown | T): T;
|
|
200
|
-
export function validateEquals<T>(input: unknown | T): IValidation<T>;
|
|
197
|
+
export const customValidators: CustomValidatorMap; // can add custom validators
|
|
201
198
|
|
|
202
199
|
// JSON
|
|
203
200
|
export function application<T>(): IJsonApplication; // JSON schema
|
|
@@ -205,6 +202,9 @@ export function assertParse<T>(input: string): T; // type safe parser
|
|
|
205
202
|
export function assertStringify<T>(input: T): string; // safe and faster
|
|
206
203
|
// +) isParse, validateParse
|
|
207
204
|
// +) stringify, isStringify, validateStringify
|
|
205
|
+
|
|
206
|
+
// RANDOM
|
|
207
|
+
export function random<T>(g?: Partial<IRandomGenerator>): Primitive<T>;
|
|
208
208
|
```
|
|
209
209
|
|
|
210
210
|
`typia` is a transformer library of TypeScript, supporting below features:
|
|
@@ -212,62 +212,8 @@ export function assertStringify<T>(input: T): string; // safe and faster
|
|
|
212
212
|
- Super-fast Runtime Validators
|
|
213
213
|
- Safe JSON parse and fast stringify functions
|
|
214
214
|
- JSON schema generator
|
|
215
|
+
- Random data generation
|
|
215
216
|
|
|
216
217
|
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)`.
|
|
217
218
|
|
|
218
|
-
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 **
|
|
219
|
-
|
|
220
|
-
### Reactia
|
|
221
|
-
> https://github.com/samchon/reactia
|
|
222
|
-
>
|
|
223
|
-
> Not published yet, but soon
|
|
224
|
-
|
|
225
|
-
[](https://github.com/samchon/reactia/blob/master/LICENSE)
|
|
226
|
-
[](https://github.com/samchon/reactia/actions?query=workflow%3Abuild)
|
|
227
|
-
[](https://github.com/samchon/reactia/wiki)
|
|
228
|
-
|
|
229
|
-
Reactia is an automatic React components generator, just by analyzing TypeScript type.
|
|
230
|
-
|
|
231
|
-
- `@reactia/core`: Core Library analyzing TypeScript type
|
|
232
|
-
- `@reactia/mui`: Material UI Theme for `core` and `nest`
|
|
233
|
-
- `@reactia/nest`: Automatic Frontend Application Builder for `NestJS`
|
|
234
|
-
<!-- - `reactia`: Just CLI tool -->
|
|
235
|
-
|
|
236
|
-

|
|
237
|
-
|
|
238
|
-
When you want to automate an individual component, just use `@reactia/core`.
|
|
239
|
-
|
|
240
|
-
```tsx
|
|
241
|
-
import ReactDOM from "react-dom";
|
|
242
|
-
|
|
243
|
-
import typia from "typia";
|
|
244
|
-
import { ReactiaComponent } from "@reactia/core";
|
|
245
|
-
import { MuiInputTheme } from "@reactia/mui";
|
|
246
|
-
|
|
247
|
-
const RequestInput = ReactiaComponent<IRequestDto>(MuiInputTheme());
|
|
248
|
-
const input: IRequestDto = { ... };
|
|
249
|
-
|
|
250
|
-
ReactDOM.render(
|
|
251
|
-
<RequestInput input={input} />,
|
|
252
|
-
document.body
|
|
253
|
-
);
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
Otherwise, you can fully automate frontend application development through `@reactia/nest`.
|
|
257
|
-
|
|
258
|
-
```tsx
|
|
259
|
-
import React from "react";
|
|
260
|
-
import ReactDOM from "react-dom";
|
|
261
|
-
|
|
262
|
-
import { ISwagger } "@nestia/swagger";
|
|
263
|
-
import { MuiApplicationTheme } from "@reactia/mui";
|
|
264
|
-
import { ReactiaApplication } from "@reactia/nest";
|
|
265
|
-
|
|
266
|
-
const swagger: ISwagger = await import("./swagger.json");
|
|
267
|
-
const App: React.FC = ReactiaApplication(MuiApplicationTheme())(swagger);
|
|
268
|
-
|
|
269
|
-
ReactDOM.render(
|
|
270
|
-
<App />,
|
|
271
|
-
document.body
|
|
272
|
-
);
|
|
273
|
-
```
|
|
219
|
+
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 **20,000x times faster** than `class-validator`.
|
package/bin/NestiaSetupWizard.js
CHANGED
|
@@ -52,7 +52,7 @@ var NestiaSetupWizard;
|
|
|
52
52
|
pack.install({ dev: false, modulo: "@nestia/core" });
|
|
53
53
|
pack.install({ dev: true, modulo: "@nestia/sdk" });
|
|
54
54
|
pack.install({ dev: true, modulo: "nestia" });
|
|
55
|
-
yield PluginConfigurator_1.PluginConfigurator.configure(
|
|
55
|
+
yield PluginConfigurator_1.PluginConfigurator.configure(args);
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
NestiaSetupWizard.setup = setup;
|
|
@@ -1 +1 @@
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H,iCAAe,CAAC,GAAG,CAAC,iBAAiB,EAAE,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,CAAC,CAAC;;KAC5C;IAxCqB,uBAAK,QAwC1B,CAAA;AACL,CAAC,EA1CgB,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QA0CjC"}
|
package/bin/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
declare const USAGE = "Wrong command has been detected. Use like below:\n\nnpx nestia [command] [options?]\n\n 1. npx nestia start <directory> --manager (npm|pnpm|yarn)\n - npx nestia start project\n - npx nestia start project --manager pnpm\n 2. npx nestia setup \\\n --compiler (ttypescript|ts-patch) \\\n --manager (npm|pnpm|yarn) \\\n --project {tsconfig.json file path}\n - npx nestia setup\n - npx nestia setup --compiler ttypescript\n - npx nestia setup --compiler ts-patch\n - npx nestia setup --manager pnpm\n 3. npx nestia dependencies --manager (npm|pnpm|yarn)\n - npx nestia dependencies\n - npx nestia dependencies --manager yarn\n 4. npx nestia init\n 5. npx nestia sdk <input> --out <output>\n - npx nestia sdk # when \"nestia.config.ts\" be configured\n - npx nestia sdk src/controllers --out src/api\n - npx nestia sdk src/**/*.controller.ts --out src/api\n 6. npx nestia swagger <input> --out <output>\n - npx nestia swagger # when \"nestia.config.ts\" be configured\n - npx nestia swagger src/controllers --out src/api\n - npx nestia swagger src/**/*.controller.ts --out src/api \n";
|
|
3
|
+
declare function halt(desc: string): never;
|
|
4
|
+
declare function main(): Promise<void>;
|
package/bin/index.js
CHANGED
|
@@ -32,14 +32,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const path_1 = __importDefault(require("path"));
|
|
40
|
-
const FileRetriever_1 = require("./internal/FileRetriever");
|
|
41
|
-
const NestiaSetupWizard_1 = require("./NestiaSetupWizard");
|
|
42
|
-
const NestiaStarter_1 = require("./NestiaStarter");
|
|
43
35
|
const USAGE = `Wrong command has been detected. Use like below:
|
|
44
36
|
|
|
45
37
|
npx nestia [command] [options?]
|
|
@@ -74,21 +66,33 @@ function halt(desc) {
|
|
|
74
66
|
}
|
|
75
67
|
function main() {
|
|
76
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
var _a;
|
|
78
69
|
const type = process.argv[2];
|
|
79
70
|
const argv = process.argv.slice(3);
|
|
80
|
-
if (type === "start")
|
|
81
|
-
yield
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
if (type === "start") {
|
|
72
|
+
yield (yield Promise.resolve().then(() => __importStar(require("./NestiaStarter")))).NestiaStarter.start((msg) => halt(msg !== null && msg !== void 0 ? msg : USAGE))(argv);
|
|
73
|
+
}
|
|
74
|
+
else if (type === "setup") {
|
|
75
|
+
try {
|
|
76
|
+
yield Promise.resolve().then(() => __importStar(require("comment-json")));
|
|
77
|
+
yield Promise.resolve().then(() => __importStar(require("inquirer")));
|
|
78
|
+
yield Promise.resolve().then(() => __importStar(require("commander")));
|
|
79
|
+
}
|
|
80
|
+
catch (_a) {
|
|
81
|
+
halt(`nestia has not been installed. Run "npm i -D nestia" before.`);
|
|
82
|
+
}
|
|
83
|
+
yield (yield Promise.resolve().then(() => __importStar(require("./NestiaSetupWizard")))).NestiaSetupWizard.setup();
|
|
84
|
+
}
|
|
84
85
|
else if (type === "dependencies" ||
|
|
85
86
|
type === "init" ||
|
|
86
87
|
type === "sdk" ||
|
|
87
88
|
type === "swagger") {
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
try {
|
|
90
|
+
require.resolve("@nestia/sdk/lib/executable/sdk");
|
|
91
|
+
}
|
|
92
|
+
catch (_b) {
|
|
90
93
|
halt(`@nestia/sdk has not been installed. Run "npx nestia setup" before.`);
|
|
91
|
-
|
|
94
|
+
}
|
|
95
|
+
yield Promise.resolve().then(() => __importStar(require("@nestia/sdk/lib/executable/sdk")));
|
|
92
96
|
}
|
|
93
97
|
else
|
|
94
98
|
halt(USAGE);
|
package/bin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Bb,CAAC;AAEF,SAAS,IAAI,CAAC,IAAY;IACtB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC;AAED,SAAe,IAAI;;QACf,MAAM,IAAI,GAAuB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjD,MAAM,IAAI,GAAa,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAE7C,IAAI,IAAI,KAAK,OAAO,EAAE;YAClB,MAAM,CACF,wDAAa,iBAAiB,GAAC,CAClC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SAC5D;aAAM,IAAI,IAAI,KAAK,OAAO,EAAE;YACzB,IAAI;gBACA,wDAAa,cAAc,GAAC,CAAC;gBAC7B,wDAAa,UAAU,GAAC,CAAC;gBACzB,wDAAa,WAAW,GAAC,CAAC;aAC7B;YAAC,WAAM;gBACJ,IAAI,CACA,8DAA8D,CACjE,CAAC;aACL;YACD,MAAM,CAAC,wDAAa,qBAAqB,GAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;SACzE;aAAM,IACH,IAAI,KAAK,cAAc;YACvB,IAAI,KAAK,MAAM;YACf,IAAI,KAAK,KAAK;YACd,IAAI,KAAK,SAAS,EACpB;YACE,IAAI;gBACA,OAAO,CAAC,OAAO,CAAC,gCAAgC,CAAC,CAAC;aACrD;YAAC,WAAM;gBACJ,IAAI,CACA,oEAAoE,CACvE,CAAC;aACL;YACD,wDAAa,gCAAgC,GAAC,CAAC;SAClD;;YAAM,IAAI,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;CAAA;AACD,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACjB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC"}
|
|
@@ -13,62 +13,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ArgumentParser = void 0;
|
|
16
|
+
const commander_1 = __importDefault(require("commander"));
|
|
16
17
|
const fs_1 = __importDefault(require("fs"));
|
|
17
|
-
const
|
|
18
|
-
const FileRetriever_1 = require("./FileRetriever");
|
|
18
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
19
19
|
var ArgumentParser;
|
|
20
20
|
(function (ArgumentParser) {
|
|
21
21
|
function parse(pack) {
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
// INSTALL TEMPORARY PACKAGES
|
|
24
|
-
const newbie = {
|
|
25
|
-
commander: pack.install({
|
|
26
|
-
dev: true,
|
|
27
|
-
modulo: "commander",
|
|
28
|
-
version: "10.0.0",
|
|
29
|
-
silent: true,
|
|
30
|
-
}),
|
|
31
|
-
inquirer: pack.install({
|
|
32
|
-
dev: true,
|
|
33
|
-
modulo: "inquirer",
|
|
34
|
-
version: "8.2.5",
|
|
35
|
-
silent: true,
|
|
36
|
-
}),
|
|
37
|
-
};
|
|
38
|
-
// TAKE OPTIONS
|
|
39
|
-
const output = yield (() => __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
try {
|
|
41
|
-
return yield _Parse(pack);
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
return error;
|
|
45
|
-
}
|
|
46
|
-
}))();
|
|
47
|
-
// REMOVE TEMPORARY PACKAGES
|
|
48
|
-
if (newbie.commander)
|
|
49
|
-
pack.erase({ modulo: "commander", silent: true });
|
|
50
|
-
if (newbie.inquirer)
|
|
51
|
-
pack.erase({ modulo: "inquirer", silent: true });
|
|
52
|
-
// RETURNS
|
|
53
|
-
if (output instanceof Error)
|
|
54
|
-
throw output;
|
|
55
|
-
return output;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
ArgumentParser.parse = parse;
|
|
59
|
-
function _Parse(pack) {
|
|
60
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
23
|
// PREPARE ASSETS
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
program.option("--
|
|
65
|
-
program.option("--manager [manager", "package manager");
|
|
66
|
-
program.option("--project [project]", "tsconfig.json file location");
|
|
24
|
+
commander_1.default.program.option("--compiler [compiler]", "compiler type");
|
|
25
|
+
commander_1.default.program.option("--manager [manager", "package manager");
|
|
26
|
+
commander_1.default.program.option("--project [project]", "tsconfig.json file location");
|
|
67
27
|
// INTERNAL PROCEDURES
|
|
68
28
|
const questioned = { value: false };
|
|
69
29
|
const action = (closure) => {
|
|
70
30
|
return new Promise((resolve, reject) => {
|
|
71
|
-
program.action((options) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
commander_1.default.program.action((options) => __awaiter(this, void 0, void 0, function* () {
|
|
72
32
|
try {
|
|
73
33
|
resolve(yield closure(options));
|
|
74
34
|
}
|
|
@@ -76,12 +36,12 @@ var ArgumentParser;
|
|
|
76
36
|
reject(exp);
|
|
77
37
|
}
|
|
78
38
|
}));
|
|
79
|
-
program.parseAsync().catch(reject);
|
|
39
|
+
commander_1.default.program.parseAsync().catch(reject);
|
|
80
40
|
});
|
|
81
41
|
};
|
|
82
42
|
const select = (name) => (message) => (choices) => __awaiter(this, void 0, void 0, function* () {
|
|
83
43
|
questioned.value = true;
|
|
84
|
-
return (yield createPromptModule()({
|
|
44
|
+
return (yield inquirer_1.default.createPromptModule()({
|
|
85
45
|
type: "list",
|
|
86
46
|
name: name,
|
|
87
47
|
message: message,
|
|
@@ -130,6 +90,7 @@ var ArgumentParser;
|
|
|
130
90
|
}));
|
|
131
91
|
});
|
|
132
92
|
}
|
|
93
|
+
ArgumentParser.parse = parse;
|
|
133
94
|
})(ArgumentParser = exports.ArgumentParser || (exports.ArgumentParser = {}));
|
|
134
95
|
const COMPILER_DESCRIPTION = [
|
|
135
96
|
`About compiler, if you adapt "ttypescript", you should use "ttsc" instead.`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArgumentParser.js","sourceRoot":"","sources":["../../src/internal/ArgumentParser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
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string | null;
|
|
3
3
|
const file: (name: string) => (directory: string, depth?: number) => string | null;
|
|
4
|
-
const require: (name: string) => (directory: string, depth?: number) => Promise<any>;
|
|
5
4
|
}
|
|
@@ -1,36 +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
|
-
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
4
|
};
|
|
@@ -56,12 +24,5 @@ var FileRetriever;
|
|
|
56
24
|
return null;
|
|
57
25
|
return FileRetriever.file(name)(path_1.default.join(directory, ".."), depth + 1);
|
|
58
26
|
};
|
|
59
|
-
FileRetriever.require = (name) => (directory, depth = 0) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
var _a;
|
|
61
|
-
const location = FileRetriever.file(name)(directory, depth);
|
|
62
|
-
if (location === null)
|
|
63
|
-
throw new Error(`Unable to find installed module. Please report to the nestia - https://github.com/samchon/nestia/issues`);
|
|
64
|
-
return _a = location, Promise.resolve().then(() => __importStar(require(_a)));
|
|
65
|
-
});
|
|
66
27
|
})(FileRetriever = exports.FileRetriever || (exports.FileRetriever = {}));
|
|
67
28
|
//# sourceMappingURL=FileRetriever.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileRetriever.js","sourceRoot":"","sources":["../../src/internal/FileRetriever.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileRetriever.js","sourceRoot":"","sources":["../../src/internal/FileRetriever.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,IAAiB,aAAa,CAkB7B;AAlBD,WAAiB,aAAa;IACb,uBAAS,GAClB,CAAC,IAAY,EAAE,EAAE,CACjB,CAAC,GAAW,EAAE,QAAgB,CAAC,EAAiB,EAAE;QAC9C,MAAM,QAAQ,GAAW,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC9C,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,OAAO,GAAG,CAAC;aACnC,IAAI,KAAK,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QAChC,OAAO,cAAA,SAAS,CAAC,IAAI,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC;IAEO,kBAAI,GACb,CAAC,IAAY,EAAE,EAAE,CACjB,CAAC,SAAiB,EAAE,QAAgB,CAAC,EAAiB,EAAE;QACpD,MAAM,QAAQ,GAAW,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,OAAO,QAAQ,CAAC;aACxC,IAAI,KAAK,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QAChC,OAAO,cAAA,IAAI,CAAC,IAAI,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IAC7D,CAAC,CAAC;AACV,CAAC,EAlBgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAkB7B"}
|
|
@@ -7,14 +7,9 @@ export declare class PackageManager {
|
|
|
7
7
|
save(modifier: (data: Package.Data) => void): Promise<void>;
|
|
8
8
|
install(props: {
|
|
9
9
|
dev: boolean;
|
|
10
|
-
silent?: boolean;
|
|
11
10
|
modulo: string;
|
|
12
11
|
version?: string;
|
|
13
12
|
}): boolean;
|
|
14
|
-
erase(props: {
|
|
15
|
-
modulo: string;
|
|
16
|
-
silent?: boolean;
|
|
17
|
-
}): void;
|
|
18
13
|
private constructor();
|
|
19
14
|
private static load;
|
|
20
15
|
}
|
|
@@ -38,22 +38,12 @@ class PackageManager {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
install(props) {
|
|
41
|
-
const container = props.dev
|
|
42
|
-
? this.data.devDependencies
|
|
43
|
-
: this.data.dependencies;
|
|
44
|
-
if (!!(container === null || container === void 0 ? void 0 : container[props.modulo]) &&
|
|
45
|
-
FileRetriever_1.FileRetriever.file(path_1.default.join("node_modules", props.modulo))(this.directory) !== null)
|
|
46
|
-
return false;
|
|
47
41
|
const middle = this.manager === "yarn"
|
|
48
42
|
? `add${props.dev ? " -D" : ""}`
|
|
49
43
|
: `install ${props.dev ? "--save-dev" : "--save"}`;
|
|
50
|
-
CommandExecutor_1.CommandExecutor.run(`${this.manager} ${middle} ${props.modulo}${props.version ? `@${props.version}` : ""}`,
|
|
44
|
+
CommandExecutor_1.CommandExecutor.run(`${this.manager} ${middle} ${props.modulo}${props.version ? `@${props.version}` : ""}`, true);
|
|
51
45
|
return true;
|
|
52
46
|
}
|
|
53
|
-
erase(props) {
|
|
54
|
-
const middle = this.manager === "yarn" ? "remove" : "uninstall";
|
|
55
|
-
CommandExecutor_1.CommandExecutor.run(`${this.manager} ${middle} ${props.modulo}`, !!props.silent);
|
|
56
|
-
}
|
|
57
47
|
constructor(directory, data) {
|
|
58
48
|
this.directory = directory;
|
|
59
49
|
this.data = data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageManager.js","sourceRoot":"","sources":["../../src/internal/PackageManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,uDAAoD;AACpD,mDAAgD;AAEhD,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,6BAAa,CAAC,SAAS,CACzD,cAAc,CACjB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;YACjB,IAAI,QAAQ,KAAK,IAAI;gBACjB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;YAE1D,OAAO,IAAI,cAAc,CACr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,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACjE,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;KAAA;CACJ;AA1DD,wCA0DC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ArgumentParser } from "./ArgumentParser";
|
|
2
|
-
import { PackageManager } from "./PackageManager";
|
|
3
2
|
export declare namespace PluginConfigurator {
|
|
4
|
-
function configure(
|
|
3
|
+
function configure(args: ArgumentParser.IArguments): Promise<void>;
|
|
5
4
|
}
|
|
@@ -13,46 +13,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.PluginConfigurator = void 0;
|
|
16
|
+
const comment_json_1 = __importDefault(require("comment-json"));
|
|
16
17
|
const fs_1 = __importDefault(require("fs"));
|
|
17
|
-
const path_1 = __importDefault(require("path"));
|
|
18
|
-
const FileRetriever_1 = require("./FileRetriever");
|
|
19
18
|
var PluginConfigurator;
|
|
20
19
|
(function (PluginConfigurator) {
|
|
21
|
-
function configure(
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
// INSTALL COMMENT-JSON
|
|
24
|
-
const installed = pack.install({
|
|
25
|
-
dev: true,
|
|
26
|
-
modulo: "comment-json",
|
|
27
|
-
version: "4.2.3",
|
|
28
|
-
silent: true,
|
|
29
|
-
});
|
|
30
|
-
// DO CONFIGURE
|
|
31
|
-
const error = yield (() => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
try {
|
|
33
|
-
yield _Configure(pack, args);
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
catch (exp) {
|
|
37
|
-
return exp;
|
|
38
|
-
}
|
|
39
|
-
}))();
|
|
40
|
-
// REMOVE IT
|
|
41
|
-
if (installed)
|
|
42
|
-
pack.erase({
|
|
43
|
-
modulo: "comment-json",
|
|
44
|
-
silent: true,
|
|
45
|
-
});
|
|
46
|
-
if (error !== null)
|
|
47
|
-
throw error;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
PluginConfigurator.configure = configure;
|
|
51
|
-
function _Configure(pack, args) {
|
|
20
|
+
function configure(args) {
|
|
52
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
22
|
// GET COMPILER-OPTIONS
|
|
54
|
-
const
|
|
55
|
-
const config = Comment.parse(yield fs_1.default.promises.readFile(args.project, "utf8"));
|
|
23
|
+
const config = comment_json_1.default.parse(yield fs_1.default.promises.readFile(args.project, "utf8"));
|
|
56
24
|
const compilerOptions = config.compilerOptions;
|
|
57
25
|
if (compilerOptions === undefined)
|
|
58
26
|
throw new Error(`${args.project} file does not have "compilerOptions" property.`);
|
|
@@ -78,7 +46,7 @@ var PluginConfigurator;
|
|
|
78
46
|
// DO CONFIGURE
|
|
79
47
|
compilerOptions.strict = true;
|
|
80
48
|
if (core === undefined)
|
|
81
|
-
plugins.push(
|
|
49
|
+
plugins.push(comment_json_1.default.parse(`{
|
|
82
50
|
"transform": "@nestia/core/lib/transform",
|
|
83
51
|
/**
|
|
84
52
|
* Validate request body.
|
|
@@ -101,9 +69,10 @@ var PluginConfigurator;
|
|
|
101
69
|
"stringify": "assert"
|
|
102
70
|
}`));
|
|
103
71
|
if (typia === undefined)
|
|
104
|
-
plugins.push(
|
|
105
|
-
yield fs_1.default.promises.writeFile(args.project,
|
|
72
|
+
plugins.push(comment_json_1.default.parse(`{ "transform": "typia/lib/transform" }`));
|
|
73
|
+
yield fs_1.default.promises.writeFile(args.project, comment_json_1.default.stringify(config, null, 2));
|
|
106
74
|
});
|
|
107
75
|
}
|
|
76
|
+
PluginConfigurator.configure = configure;
|
|
108
77
|
})(PluginConfigurator = exports.PluginConfigurator || (exports.PluginConfigurator = {}));
|
|
109
78
|
//# sourceMappingURL=PluginConfigurator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginConfigurator.js","sourceRoot":"","sources":["../../src/internal/PluginConfigurator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"PluginConfigurator.js","sourceRoot":"","sources":["../../src/internal/PluginConfigurator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gEAAoC;AACpC,4CAAoB;AAIpB,IAAiB,kBAAkB,CAmFlC;AAnFD,WAAiB,kBAAkB;IAC/B,SAAsB,SAAS,CAC3B,IAA+B;;YAE/B,uBAAuB;YACvB,MAAM,MAAM,GAA2B,sBAAQ,CAAC,KAAK,CACjD,MAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAQ,EAAE,MAAM,CAAC,CAC1B,CAAC;YAC5B,MAAM,eAAe,GACjB,MAAM,CAAC,eAAqD,CAAC;YACjE,IAAI,eAAe,KAAK,SAAS;gBAC7B,MAAM,IAAI,KAAK,CACX,GAAG,IAAI,CAAC,OAAO,iDAAiD,CACnE,CAAC;YAEN,kBAAkB;YAClB,MAAM,OAAO,GAAkD,CAAC,GAAG,EAAE;gBACjE,MAAM,OAAO,GAAG,eAAe,CAAC,OAEjB,CAAC;gBAChB,IAAI,OAAO,KAAK,SAAS;oBACrB,OAAO,CAAC,eAAe,CAAC,OAAO,GAAG,EAAS,CAAC,CAAC;qBAC5C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;oBAC5B,MAAM,IAAI,KAAK,CACX,yBAAyB,IAAI,CAAC,OAAO,sBAAsB,CAC9D,CAAC;gBACN,OAAO,OAAO,CAAC;YACnB,CAAC,CAAC,EAAE,CAAC;YAEL,2BAA2B;YAC3B,MAAM,MAAM,GAAY,eAAe,CAAC,MAAM,KAAK,IAAI,CAAC;YACxD,MAAM,IAAI,GAAuC,OAAO,CAAC,IAAI,CACzD,CAAC,CAAC,EAAE,EAAE,CACF,OAAO,CAAC,KAAK,QAAQ;gBACrB,CAAC,KAAK,IAAI;gBACV,CAAC,CAAC,SAAS,KAAK,4BAA4B,CACnD,CAAC;YACF,MAAM,KAAK,GAAuC,OAAO,CAAC,IAAI,CAC1D,CAAC,CAAC,EAAE,EAAE,CACF,OAAO,CAAC,KAAK,QAAQ;gBACrB,CAAC,KAAK,IAAI;gBACV,CAAC,CAAC,SAAS,KAAK,qBAAqB,CAC5C,CAAC;YACF,IAAI,MAAM,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK;gBAAE,OAAO;YAExC,eAAe;YACf,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC;YAC9B,IAAI,IAAI,KAAK,SAAS;gBAClB,OAAO,CAAC,IAAI,CACR,sBAAQ,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;kBAqBb,CAA2B,CAChC,CAAC;YACN,IAAI,KAAK,KAAK,SAAS;gBACnB,OAAO,CAAC,IAAI,CACR,sBAAQ,CAAC,KAAK,CACV,wCAAwC,CACjB,CAC9B,CAAC;YACN,MAAM,YAAE,CAAC,QAAQ,CAAC,SAAS,CACvB,IAAI,CAAC,OAAQ,EACb,sBAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CACtC,CAAC;QACN,CAAC;KAAA;IAjFqB,4BAAS,YAiF9B,CAAA;AACL,CAAC,EAnFgB,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAmFlC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nestia",
|
|
3
|
-
"version": "4.0.
|
|
4
|
-
"description": "Nestia CLI",
|
|
3
|
+
"version": "4.0.11-dev.20230410-2",
|
|
4
|
+
"description": "Nestia CLI tool",
|
|
5
5
|
"main": "bin/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"nestia": "bin/index.js"
|
|
@@ -28,21 +28,24 @@
|
|
|
28
28
|
"url": "https://github.com/samchon/nestia/issues"
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/samchon/nestia",
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"commander": "^10.0.0",
|
|
33
|
+
"comment-json": "^4.2.3",
|
|
34
|
+
"inquirer": "^8.2.5"
|
|
35
|
+
},
|
|
31
36
|
"devDependencies": {
|
|
32
37
|
"@nestia/core": "^1.0.17",
|
|
33
38
|
"@nestia/sdk": "^1.0.16",
|
|
34
39
|
"@types/inquirer": "^9.0.3",
|
|
35
40
|
"@types/node": "^18.11.16",
|
|
36
|
-
"commander": "^10.0.0",
|
|
37
|
-
"comment-json": "^4.2.3",
|
|
38
|
-
"inquirer": "^8.2.5",
|
|
39
41
|
"rimraf": "^3.0.2",
|
|
40
42
|
"typescript": "^4.9.5"
|
|
41
43
|
},
|
|
42
44
|
"files": [
|
|
43
45
|
"bin",
|
|
46
|
+
"src",
|
|
44
47
|
"README.md",
|
|
45
48
|
"LICENSE",
|
|
46
|
-
"package
|
|
49
|
+
"package.json"
|
|
47
50
|
]
|
|
48
51
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ArgumentParser } from "./internal/ArgumentParser";
|
|
2
|
+
import { CommandExecutor } from "./internal/CommandExecutor";
|
|
3
|
+
import { PackageManager } from "./internal/PackageManager";
|
|
4
|
+
import { PluginConfigurator } from "./internal/PluginConfigurator";
|
|
5
|
+
|
|
6
|
+
export namespace NestiaSetupWizard {
|
|
7
|
+
export async function setup(): Promise<void> {
|
|
8
|
+
console.log("----------------------------------------");
|
|
9
|
+
console.log(" Nestia Setup Wizard");
|
|
10
|
+
console.log("----------------------------------------");
|
|
11
|
+
|
|
12
|
+
// LOAD PACKAGE.JSON INFO
|
|
13
|
+
const pack: PackageManager = await PackageManager.mount();
|
|
14
|
+
|
|
15
|
+
// TAKE ARGUMENTS
|
|
16
|
+
const args: ArgumentParser.IArguments = await ArgumentParser.parse(
|
|
17
|
+
pack,
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
// INSTALL TYPESCRIPT
|
|
21
|
+
pack.install({ dev: true, modulo: "typescript", version: "4.9.5" });
|
|
22
|
+
args.project ??= (() => {
|
|
23
|
+
CommandExecutor.run("npx tsc --init", false);
|
|
24
|
+
return (args.project = "tsconfig.json");
|
|
25
|
+
})();
|
|
26
|
+
pack.install({ dev: true, modulo: "ts-node" });
|
|
27
|
+
|
|
28
|
+
// INSTALL COMPILER
|
|
29
|
+
pack.install({ dev: true, modulo: args.compiler });
|
|
30
|
+
if (args.compiler === "ts-patch") {
|
|
31
|
+
await pack.save((data) => {
|
|
32
|
+
data.scripts ??= {};
|
|
33
|
+
if (typeof data.scripts.prepare === "string")
|
|
34
|
+
data.scripts.prepare =
|
|
35
|
+
"ts-patch install && " + data.scripts.prepare;
|
|
36
|
+
else data.scripts.prepare = "ts-patch install";
|
|
37
|
+
});
|
|
38
|
+
CommandExecutor.run("npm run prepare", false);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// INSTALL AND CONFIGURE TYPIA
|
|
42
|
+
pack.install({ dev: false, modulo: "typia" });
|
|
43
|
+
pack.install({ dev: false, modulo: "@nestia/core" });
|
|
44
|
+
pack.install({ dev: true, modulo: "@nestia/sdk" });
|
|
45
|
+
pack.install({ dev: true, modulo: "nestia" });
|
|
46
|
+
await PluginConfigurator.configure(args);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import cp from "child_process";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
|
|
4
|
+
export namespace NestiaStarter {
|
|
5
|
+
export const start =
|
|
6
|
+
(halter: (msg?: string) => never) =>
|
|
7
|
+
async (argv: string[]): Promise<void> => {
|
|
8
|
+
// VALIDATION
|
|
9
|
+
const dest: string | undefined = argv[0];
|
|
10
|
+
const manager: string = argv[1] ?? "npm";
|
|
11
|
+
|
|
12
|
+
if (dest === undefined) halter();
|
|
13
|
+
else if (fs.existsSync(dest) === true)
|
|
14
|
+
halter("The target directory already exists.");
|
|
15
|
+
|
|
16
|
+
console.log("-----------------------------------------");
|
|
17
|
+
console.log(" Nestia Starter Kit");
|
|
18
|
+
console.log("-----------------------------------------");
|
|
19
|
+
|
|
20
|
+
// COPY PROJECTS
|
|
21
|
+
execute(
|
|
22
|
+
`git clone https://github.com/samchon/nestia-template ${dest}`,
|
|
23
|
+
);
|
|
24
|
+
console.log(`cd "${dest}"`);
|
|
25
|
+
process.chdir(dest);
|
|
26
|
+
|
|
27
|
+
// INSTALL DEPENDENCIES
|
|
28
|
+
execute(`${manager} install`);
|
|
29
|
+
|
|
30
|
+
// BUILD TYPESCRIPT
|
|
31
|
+
execute("npm run build");
|
|
32
|
+
|
|
33
|
+
// DO TEST
|
|
34
|
+
execute("npm run test");
|
|
35
|
+
|
|
36
|
+
// REMOVE .GIT DIRECTORY
|
|
37
|
+
cp.execSync("npx rimraf .git");
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
function execute(command: string): void {
|
|
41
|
+
console.log(command);
|
|
42
|
+
cp.execSync(command, { stdio: "inherit" });
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const USAGE = `Wrong command has been detected. Use like below:
|
|
3
|
+
|
|
4
|
+
npx nestia [command] [options?]
|
|
5
|
+
|
|
6
|
+
1. npx nestia start <directory> --manager (npm|pnpm|yarn)
|
|
7
|
+
- npx nestia start project
|
|
8
|
+
- npx nestia start project --manager pnpm
|
|
9
|
+
2. npx nestia setup \\
|
|
10
|
+
--compiler (ttypescript|ts-patch) \\
|
|
11
|
+
--manager (npm|pnpm|yarn) \\
|
|
12
|
+
--project {tsconfig.json file path}
|
|
13
|
+
- npx nestia setup
|
|
14
|
+
- npx nestia setup --compiler ttypescript
|
|
15
|
+
- npx nestia setup --compiler ts-patch
|
|
16
|
+
- npx nestia setup --manager pnpm
|
|
17
|
+
3. npx nestia dependencies --manager (npm|pnpm|yarn)
|
|
18
|
+
- npx nestia dependencies
|
|
19
|
+
- npx nestia dependencies --manager yarn
|
|
20
|
+
4. npx nestia init
|
|
21
|
+
5. npx nestia sdk <input> --out <output>
|
|
22
|
+
- npx nestia sdk # when "nestia.config.ts" be configured
|
|
23
|
+
- npx nestia sdk src/controllers --out src/api
|
|
24
|
+
- npx nestia sdk src/**/*.controller.ts --out src/api
|
|
25
|
+
6. npx nestia swagger <input> --out <output>
|
|
26
|
+
- npx nestia swagger # when "nestia.config.ts" be configured
|
|
27
|
+
- npx nestia swagger src/controllers --out src/api
|
|
28
|
+
- npx nestia swagger src/**/*.controller.ts --out src/api
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
function halt(desc: string): never {
|
|
32
|
+
console.error(desc);
|
|
33
|
+
process.exit(-1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function main(): Promise<void> {
|
|
37
|
+
const type: string | undefined = process.argv[2];
|
|
38
|
+
const argv: string[] = process.argv.slice(3);
|
|
39
|
+
|
|
40
|
+
if (type === "start") {
|
|
41
|
+
await (
|
|
42
|
+
await import("./NestiaStarter")
|
|
43
|
+
).NestiaStarter.start((msg) => halt(msg ?? USAGE))(argv);
|
|
44
|
+
} else if (type === "setup") {
|
|
45
|
+
try {
|
|
46
|
+
await import("comment-json");
|
|
47
|
+
await import("inquirer");
|
|
48
|
+
await import("commander");
|
|
49
|
+
} catch {
|
|
50
|
+
halt(
|
|
51
|
+
`nestia has not been installed. Run "npm i -D nestia" before.`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
await (await import("./NestiaSetupWizard")).NestiaSetupWizard.setup();
|
|
55
|
+
} else if (
|
|
56
|
+
type === "dependencies" ||
|
|
57
|
+
type === "init" ||
|
|
58
|
+
type === "sdk" ||
|
|
59
|
+
type === "swagger"
|
|
60
|
+
) {
|
|
61
|
+
try {
|
|
62
|
+
require.resolve("@nestia/sdk/lib/executable/sdk");
|
|
63
|
+
} catch {
|
|
64
|
+
halt(
|
|
65
|
+
`@nestia/sdk has not been installed. Run "npx nestia setup" before.`,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
await import("@nestia/sdk/lib/executable/sdk");
|
|
69
|
+
} else halt(USAGE);
|
|
70
|
+
}
|
|
71
|
+
main().catch((exp) => {
|
|
72
|
+
console.log(exp.message);
|
|
73
|
+
process.exit(-1);
|
|
74
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import commander from "commander";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import inquirer from "inquirer";
|
|
4
|
+
|
|
5
|
+
import { PackageManager } from "./PackageManager";
|
|
6
|
+
|
|
7
|
+
export namespace ArgumentParser {
|
|
8
|
+
export interface IArguments {
|
|
9
|
+
compiler: "ts-patch" | "ttypescript";
|
|
10
|
+
manager: "npm" | "pnpm" | "yarn";
|
|
11
|
+
project: string | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function parse(pack: PackageManager): Promise<IArguments> {
|
|
15
|
+
// PREPARE ASSETS
|
|
16
|
+
commander.program.option("--compiler [compiler]", "compiler type");
|
|
17
|
+
commander.program.option("--manager [manager", "package manager");
|
|
18
|
+
commander.program.option(
|
|
19
|
+
"--project [project]",
|
|
20
|
+
"tsconfig.json file location",
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
// INTERNAL PROCEDURES
|
|
24
|
+
const questioned = { value: false };
|
|
25
|
+
const action = (
|
|
26
|
+
closure: (options: Partial<IArguments>) => Promise<IArguments>,
|
|
27
|
+
) => {
|
|
28
|
+
return new Promise<IArguments>((resolve, reject) => {
|
|
29
|
+
commander.program.action(async (options) => {
|
|
30
|
+
try {
|
|
31
|
+
resolve(await closure(options));
|
|
32
|
+
} catch (exp) {
|
|
33
|
+
reject(exp);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
commander.program.parseAsync().catch(reject);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
const select =
|
|
40
|
+
(name: string) =>
|
|
41
|
+
(message: string) =>
|
|
42
|
+
async <Choice extends string>(
|
|
43
|
+
choices: Choice[],
|
|
44
|
+
): Promise<Choice> => {
|
|
45
|
+
questioned.value = true;
|
|
46
|
+
return (
|
|
47
|
+
await inquirer.createPromptModule()({
|
|
48
|
+
type: "list",
|
|
49
|
+
name: name,
|
|
50
|
+
message: message,
|
|
51
|
+
choices: choices,
|
|
52
|
+
})
|
|
53
|
+
)[name];
|
|
54
|
+
};
|
|
55
|
+
const configure = async () => {
|
|
56
|
+
const fileList: string[] = await (
|
|
57
|
+
await fs.promises.readdir(process.cwd())
|
|
58
|
+
)
|
|
59
|
+
.filter(
|
|
60
|
+
(str) =>
|
|
61
|
+
str.substring(0, 8) === "tsconfig" &&
|
|
62
|
+
str.substring(str.length - 5) === ".json",
|
|
63
|
+
)
|
|
64
|
+
.sort((x, y) =>
|
|
65
|
+
x === "tsconfig.json"
|
|
66
|
+
? -1
|
|
67
|
+
: y === "tsconfig.json"
|
|
68
|
+
? 1
|
|
69
|
+
: x < y
|
|
70
|
+
? -1
|
|
71
|
+
: 1,
|
|
72
|
+
);
|
|
73
|
+
if (fileList.length === 0) {
|
|
74
|
+
if (process.cwd() !== pack.directory)
|
|
75
|
+
throw new Error(`Unable to find "tsconfig.json" file.`);
|
|
76
|
+
return null;
|
|
77
|
+
} else if (fileList.length === 1) return fileList[0];
|
|
78
|
+
return select("tsconfig")("TS Config File")(fileList);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// DO CONSTRUCT
|
|
82
|
+
return action(async (options) => {
|
|
83
|
+
if (options.compiler === undefined) {
|
|
84
|
+
console.log(COMPILER_DESCRIPTION);
|
|
85
|
+
options.compiler = await select("compiler")(`Compiler`)(
|
|
86
|
+
pack.data.scripts?.build === "nest build"
|
|
87
|
+
? ["ts-patch" as const, "ttypescript" as const]
|
|
88
|
+
: ["ttypescript" as const, "ts-patch" as const],
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
options.manager ??= await select("manager")("Package Manager")([
|
|
92
|
+
"npm" as const,
|
|
93
|
+
"pnpm" as const,
|
|
94
|
+
"yarn" as const,
|
|
95
|
+
]);
|
|
96
|
+
pack.manager = options.manager;
|
|
97
|
+
options.project ??= await configure();
|
|
98
|
+
|
|
99
|
+
if (questioned.value) console.log("");
|
|
100
|
+
return options as IArguments;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const COMPILER_DESCRIPTION = [
|
|
106
|
+
`About compiler, if you adapt "ttypescript", you should use "ttsc" instead.`,
|
|
107
|
+
``,
|
|
108
|
+
`Otherwise, you choose "ts-patch", you can use the original "tsc" command.`,
|
|
109
|
+
`However, the "ts-patch" hacks "node_modules/typescript" source code.`,
|
|
110
|
+
`Also, whenever update "typescript", you've to run "npm run prepare" command.`,
|
|
111
|
+
``,
|
|
112
|
+
`By the way, when using "@nest/cli", you must just choose "ts-patch".`,
|
|
113
|
+
``,
|
|
114
|
+
].join("\n");
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
export namespace FileRetriever {
|
|
5
|
+
export const directory =
|
|
6
|
+
(name: string) =>
|
|
7
|
+
(dir: string, depth: number = 0): string | null => {
|
|
8
|
+
const location: string = path.join(dir, name);
|
|
9
|
+
if (fs.existsSync(location)) return dir;
|
|
10
|
+
else if (depth > 2) return null;
|
|
11
|
+
return directory(name)(path.join(dir, ".."), depth + 1);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const file =
|
|
15
|
+
(name: string) =>
|
|
16
|
+
(directory: string, depth: number = 0): string | null => {
|
|
17
|
+
const location: string = path.join(directory, name);
|
|
18
|
+
if (fs.existsSync(location)) return location;
|
|
19
|
+
else if (depth > 2) return null;
|
|
20
|
+
return file(name)(path.join(directory, ".."), depth + 1);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
import { CommandExecutor } from "./CommandExecutor";
|
|
5
|
+
import { FileRetriever } from "./FileRetriever";
|
|
6
|
+
|
|
7
|
+
export class PackageManager {
|
|
8
|
+
public manager: string = "npm";
|
|
9
|
+
public get file(): string {
|
|
10
|
+
return path.join(this.directory, "package.json");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public static async mount(): Promise<PackageManager> {
|
|
14
|
+
const location: string | null = await FileRetriever.directory(
|
|
15
|
+
"package.json",
|
|
16
|
+
)(process.cwd());
|
|
17
|
+
if (location === null)
|
|
18
|
+
throw new Error(`Unable to find "package.json" file`);
|
|
19
|
+
|
|
20
|
+
return new PackageManager(
|
|
21
|
+
location,
|
|
22
|
+
await this.load(path.join(location, "package.json")),
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public async save(modifier: (data: Package.Data) => void): Promise<void> {
|
|
27
|
+
const content: string = await fs.promises.readFile(this.file, "utf8");
|
|
28
|
+
this.data = JSON.parse(content);
|
|
29
|
+
modifier(this.data);
|
|
30
|
+
|
|
31
|
+
return fs.promises.writeFile(
|
|
32
|
+
this.file,
|
|
33
|
+
JSON.stringify(this.data, null, 2),
|
|
34
|
+
"utf8",
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public install(props: {
|
|
39
|
+
dev: boolean;
|
|
40
|
+
modulo: string;
|
|
41
|
+
version?: string;
|
|
42
|
+
}): boolean {
|
|
43
|
+
const middle: string =
|
|
44
|
+
this.manager === "yarn"
|
|
45
|
+
? `add${props.dev ? " -D" : ""}`
|
|
46
|
+
: `install ${props.dev ? "--save-dev" : "--save"}`;
|
|
47
|
+
CommandExecutor.run(
|
|
48
|
+
`${this.manager} ${middle} ${props.modulo}${
|
|
49
|
+
props.version ? `@${props.version}` : ""
|
|
50
|
+
}`,
|
|
51
|
+
true,
|
|
52
|
+
);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private constructor(
|
|
57
|
+
public readonly directory: string,
|
|
58
|
+
public data: Package.Data,
|
|
59
|
+
) {}
|
|
60
|
+
|
|
61
|
+
private static async load(file: string): Promise<Package.Data> {
|
|
62
|
+
const content: string = await fs.promises.readFile(file, "utf8");
|
|
63
|
+
return JSON.parse(content);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export namespace Package {
|
|
67
|
+
export interface Data {
|
|
68
|
+
scripts?: Record<string, string>;
|
|
69
|
+
dependencies?: Record<string, string>;
|
|
70
|
+
devDependencies?: Record<string, string>;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import comments from "comment-json";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
|
|
4
|
+
import { ArgumentParser } from "./ArgumentParser";
|
|
5
|
+
|
|
6
|
+
export namespace PluginConfigurator {
|
|
7
|
+
export async function configure(
|
|
8
|
+
args: ArgumentParser.IArguments,
|
|
9
|
+
): Promise<void> {
|
|
10
|
+
// GET COMPILER-OPTIONS
|
|
11
|
+
const config: comments.CommentObject = comments.parse(
|
|
12
|
+
await fs.promises.readFile(args.project!, "utf8"),
|
|
13
|
+
) as comments.CommentObject;
|
|
14
|
+
const compilerOptions: comments.CommentObject | undefined =
|
|
15
|
+
config.compilerOptions as comments.CommentObject | undefined;
|
|
16
|
+
if (compilerOptions === undefined)
|
|
17
|
+
throw new Error(
|
|
18
|
+
`${args.project} file does not have "compilerOptions" property.`,
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
// PREPARE PLUGINS
|
|
22
|
+
const plugins: comments.CommentArray<comments.CommentObject> = (() => {
|
|
23
|
+
const plugins = compilerOptions.plugins as
|
|
24
|
+
| comments.CommentArray<comments.CommentObject>
|
|
25
|
+
| undefined;
|
|
26
|
+
if (plugins === undefined)
|
|
27
|
+
return (compilerOptions.plugins = [] as any);
|
|
28
|
+
else if (!Array.isArray(plugins))
|
|
29
|
+
throw new Error(
|
|
30
|
+
`"plugins" property of ${args.project} must be array type.`,
|
|
31
|
+
);
|
|
32
|
+
return plugins;
|
|
33
|
+
})();
|
|
34
|
+
|
|
35
|
+
// CHECK WHETHER CONFIGURED
|
|
36
|
+
const strict: boolean = compilerOptions.strict === true;
|
|
37
|
+
const core: comments.CommentObject | undefined = plugins.find(
|
|
38
|
+
(p) =>
|
|
39
|
+
typeof p === "object" &&
|
|
40
|
+
p !== null &&
|
|
41
|
+
p.transform === "@nestia/core/lib/transform",
|
|
42
|
+
);
|
|
43
|
+
const typia: comments.CommentObject | undefined = plugins.find(
|
|
44
|
+
(p) =>
|
|
45
|
+
typeof p === "object" &&
|
|
46
|
+
p !== null &&
|
|
47
|
+
p.transform === "typia/lib/transform",
|
|
48
|
+
);
|
|
49
|
+
if (strict && !!core && !!typia) return;
|
|
50
|
+
|
|
51
|
+
// DO CONFIGURE
|
|
52
|
+
compilerOptions.strict = true;
|
|
53
|
+
if (core === undefined)
|
|
54
|
+
plugins.push(
|
|
55
|
+
comments.parse(`{
|
|
56
|
+
"transform": "@nestia/core/lib/transform",
|
|
57
|
+
/**
|
|
58
|
+
* Validate request body.
|
|
59
|
+
*
|
|
60
|
+
* - "assert": Use typia.assert() function
|
|
61
|
+
* - "is": Use typia.is() function
|
|
62
|
+
* - "validate": Use typia.validate() function
|
|
63
|
+
*/
|
|
64
|
+
"validate": "assert",
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Validate JSON typed response body.
|
|
68
|
+
*
|
|
69
|
+
* - "assert": Use typia.assertStringify() function
|
|
70
|
+
* - "is": Use typia.isStringify() function
|
|
71
|
+
* - "validate": Use typia.validateStringify() function
|
|
72
|
+
* - "stringify": Use typia.stringify() function, but dangerous
|
|
73
|
+
* - null: Just use JSON.stringify() function, without boosting
|
|
74
|
+
*/
|
|
75
|
+
"stringify": "assert"
|
|
76
|
+
}`) as comments.CommentObject,
|
|
77
|
+
);
|
|
78
|
+
if (typia === undefined)
|
|
79
|
+
plugins.push(
|
|
80
|
+
comments.parse(
|
|
81
|
+
`{ "transform": "typia/lib/transform" }`,
|
|
82
|
+
) as comments.CommentObject,
|
|
83
|
+
);
|
|
84
|
+
await fs.promises.writeFile(
|
|
85
|
+
args.project!,
|
|
86
|
+
comments.stringify(config, null, 2),
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|