@nestia/core 1.0.10 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +15 -9
  2. package/lib/decorators/EncryptedBody.d.ts +1 -1
  3. package/lib/decorators/EncryptedBody.js +1 -1
  4. package/lib/decorators/EncryptedRoute.d.ts +4 -4
  5. package/lib/decorators/EncryptedRoute.js +4 -4
  6. package/lib/decorators/TypedRoute.d.ts +3 -2
  7. package/lib/decorators/TypedRoute.js +3 -2
  8. package/lib/decorators/TypedRoute.js.map +1 -1
  9. package/lib/executable/core.js +45 -23
  10. package/lib/executable/core.js.map +1 -1
  11. package/lib/executable/internal/ArgumentParser.d.ts +9 -0
  12. package/lib/executable/internal/ArgumentParser.js +246 -0
  13. package/lib/executable/internal/ArgumentParser.js.map +1 -0
  14. package/lib/executable/internal/CommandExecutor.d.ts +3 -0
  15. package/lib/executable/internal/CommandExecutor.js +17 -0
  16. package/lib/executable/internal/CommandExecutor.js.map +1 -0
  17. package/lib/executable/internal/FileRetriever.d.ts +5 -0
  18. package/lib/executable/internal/FileRetriever.js +109 -0
  19. package/lib/executable/internal/FileRetriever.js.map +1 -0
  20. package/lib/executable/internal/PackageManager.d.ts +27 -0
  21. package/lib/executable/internal/PackageManager.js +126 -0
  22. package/lib/executable/internal/PackageManager.js.map +1 -0
  23. package/lib/executable/internal/PluginConfigurator.d.ts +5 -0
  24. package/lib/executable/internal/PluginConfigurator.js +145 -0
  25. package/lib/executable/internal/PluginConfigurator.js.map +1 -0
  26. package/package.json +7 -3
  27. package/src/decorators/EncryptedBody.ts +1 -1
  28. package/src/decorators/EncryptedRoute.ts +4 -4
  29. package/src/decorators/TypedRoute.ts +3 -2
  30. package/src/executable/core.ts +39 -18
  31. package/src/executable/internal/ArgumentParser.ts +146 -0
  32. package/src/executable/internal/CommandExecutor.ts +8 -0
  33. package/src/executable/internal/FileRetriever.ts +33 -0
  34. package/src/executable/internal/PackageManager.ts +92 -0
  35. package/src/executable/internal/PluginConfigurator.ts +130 -0
  36. package/lib/executable/internal/CommandParser.d.ts +0 -3
  37. package/lib/executable/internal/CommandParser.js +0 -21
  38. package/lib/executable/internal/CommandParser.js.map +0 -1
  39. package/lib/executable/internal/CoreSetupWizard.d.ts +0 -8
  40. package/lib/executable/internal/CoreSetupWizard.js +0 -271
  41. package/lib/executable/internal/CoreSetupWizard.js.map +0 -1
  42. package/src/executable/internal/CommandParser.ts +0 -15
  43. package/src/executable/internal/CoreSetupWizard.ts +0 -225
@@ -0,0 +1,109 @@
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 __generator = (this && this.__generator) || function (thisArg, body) {
35
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
+ function verb(n) { return function (v) { return step([n, v]); }; }
38
+ function step(op) {
39
+ if (f) throw new TypeError("Generator is already executing.");
40
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
+ if (y = 0, t) op = [op[0] & 2, t.value];
43
+ switch (op[0]) {
44
+ case 0: case 1: t = op; break;
45
+ case 4: _.label++; return { value: op[1], done: false };
46
+ case 5: _.label++; y = op[1]; op = [0]; continue;
47
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
+ default:
49
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
+ if (t[2]) _.ops.pop();
54
+ _.trys.pop(); continue;
55
+ }
56
+ op = body.call(thisArg, _);
57
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
+ }
60
+ };
61
+ var __importDefault = (this && this.__importDefault) || function (mod) {
62
+ return (mod && mod.__esModule) ? mod : { "default": mod };
63
+ };
64
+ Object.defineProperty(exports, "__esModule", { value: true });
65
+ exports.FileRetriever = void 0;
66
+ var fs_1 = __importDefault(require("fs"));
67
+ var path_1 = __importDefault(require("path"));
68
+ var FileRetriever;
69
+ (function (FileRetriever) {
70
+ var _this = this;
71
+ FileRetriever.directory = function (name) {
72
+ return function (directory, depth) {
73
+ if (depth === void 0) { depth = 0; }
74
+ var location = path_1.default.join(directory, name);
75
+ if (fs_1.default.existsSync(location))
76
+ return directory;
77
+ else if (depth > 2)
78
+ return null;
79
+ return FileRetriever.file(name)(path_1.default.join(directory, ".."), depth + 1);
80
+ };
81
+ };
82
+ FileRetriever.file = function (name) {
83
+ return function (directory, depth) {
84
+ if (depth === void 0) { depth = 0; }
85
+ var location = path_1.default.join(directory, name);
86
+ if (fs_1.default.existsSync(location))
87
+ return location;
88
+ else if (depth > 2)
89
+ return null;
90
+ return FileRetriever.file(name)(path_1.default.join(directory, ".."), depth + 1);
91
+ };
92
+ };
93
+ FileRetriever.require = function (name) {
94
+ return function (directory, depth) {
95
+ if (depth === void 0) { depth = 0; }
96
+ return __awaiter(_this, void 0, void 0, function () {
97
+ var location;
98
+ return __generator(this, function (_a) {
99
+ var _b;
100
+ location = FileRetriever.file(name)(directory, depth);
101
+ if (location === null)
102
+ throw new Error("Unable to find installed module. Please report to the nestia - https://github.com/samchon/nestia/issues");
103
+ return [2 /*return*/, (_b = location, Promise.resolve().then(function () { return __importStar(require(_b)); }))];
104
+ });
105
+ });
106
+ };
107
+ };
108
+ })(FileRetriever = exports.FileRetriever || (exports.FileRetriever = {}));
109
+ //# sourceMappingURL=FileRetriever.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileRetriever.js","sourceRoot":"","sources":["../../../src/executable/internal/FileRetriever.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAoB;AACpB,8CAAwB;AAExB,IAAiB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yG,CAC5G,CAAC;oBACN,4BAAc,QAAQ,8EAAE;;;SAC3B;IAPD,CAOC,CAAC;AACV,CAAC,EA7BgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QA6B7B"}
@@ -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,126 @@
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 __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.PackageManager = void 0;
43
+ var fs_1 = __importDefault(require("fs"));
44
+ var path_1 = __importDefault(require("path"));
45
+ var CommandExecutor_1 = require("./CommandExecutor");
46
+ var FileRetriever_1 = require("./FileRetriever");
47
+ var PackageManager = /** @class */ (function () {
48
+ function PackageManager(directory, data) {
49
+ this.directory = directory;
50
+ this.data = data;
51
+ this.manager = "npm";
52
+ }
53
+ Object.defineProperty(PackageManager.prototype, "file", {
54
+ get: function () {
55
+ return path_1.default.join(this.directory, "package.json");
56
+ },
57
+ enumerable: false,
58
+ configurable: true
59
+ });
60
+ PackageManager.mount = function () {
61
+ return __awaiter(this, void 0, void 0, function () {
62
+ var location, _a, _b;
63
+ return __generator(this, function (_c) {
64
+ switch (_c.label) {
65
+ case 0: return [4 /*yield*/, FileRetriever_1.FileRetriever.directory("package.json")(process.cwd())];
66
+ case 1:
67
+ location = _c.sent();
68
+ if (location === null)
69
+ throw new Error("Unable to find \"package.json\" file");
70
+ _a = PackageManager.bind;
71
+ _b = [void 0, location];
72
+ return [4 /*yield*/, this.load(path_1.default.join(location, "package.json"))];
73
+ case 2: return [2 /*return*/, new (_a.apply(PackageManager, _b.concat([_c.sent()])))()];
74
+ }
75
+ });
76
+ });
77
+ };
78
+ PackageManager.prototype.save = function (modifier) {
79
+ return __awaiter(this, void 0, void 0, function () {
80
+ var content;
81
+ return __generator(this, function (_a) {
82
+ switch (_a.label) {
83
+ case 0: return [4 /*yield*/, fs_1.default.promises.readFile(this.file, "utf8")];
84
+ case 1:
85
+ content = _a.sent();
86
+ this.data = JSON.parse(content);
87
+ modifier(this.data);
88
+ return [2 /*return*/, fs_1.default.promises.writeFile(this.file, JSON.stringify(this.data, null, 2), "utf8")];
89
+ }
90
+ });
91
+ });
92
+ };
93
+ PackageManager.prototype.install = function (props) {
94
+ var container = props.dev
95
+ ? this.data.devDependencies
96
+ : this.data.dependencies;
97
+ if (!!(container === null || container === void 0 ? void 0 : container[props.modulo]) &&
98
+ FileRetriever_1.FileRetriever.file(path_1.default.join("node_modules", props.modulo))(this.directory) !== null)
99
+ return false;
100
+ var middle = this.manager === "yarn"
101
+ ? "add".concat(props.dev ? " -D" : "")
102
+ : "install ".concat(props.dev ? "--save-dev" : "--save");
103
+ CommandExecutor_1.CommandExecutor.run("".concat(this.manager, " ").concat(middle, " ").concat(props.modulo).concat(props.version ? "@".concat(props.version) : ""), !!props.silent);
104
+ return true;
105
+ };
106
+ PackageManager.prototype.erase = function (props) {
107
+ var middle = this.manager === "yarn" ? "remove" : "uninstall";
108
+ CommandExecutor_1.CommandExecutor.run("".concat(this.manager, " ").concat(middle, " ").concat(props.modulo), !!props.silent);
109
+ };
110
+ PackageManager.load = function (file) {
111
+ return __awaiter(this, void 0, void 0, function () {
112
+ var content;
113
+ return __generator(this, function (_a) {
114
+ switch (_a.label) {
115
+ case 0: return [4 /*yield*/, fs_1.default.promises.readFile(file, "utf8")];
116
+ case 1:
117
+ content = _a.sent();
118
+ return [2 /*return*/, JSON.parse(content)];
119
+ }
120
+ });
121
+ });
122
+ };
123
+ return PackageManager;
124
+ }());
125
+ exports.PackageManager = PackageManager;
126
+ //# sourceMappingURL=PackageManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackageManager.js","sourceRoot":"","sources":["../../../src/executable/internal/PackageManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAoB;AACpB,8CAAwB;AAExB,qDAAoD;AACpD,iDAAgD;AAEhD;IAqEI,wBACoB,SAAiB,EAC1B,IAAkB;QADT,cAAS,GAAT,SAAS,CAAQ;QAC1B,SAAI,GAAJ,IAAI,CAAc;QAtEtB,YAAO,GAAW,KAAK,CAAC;IAuE5B,CAAC;IAtEJ,sBAAW,gCAAI;aAAf;YACI,OAAO,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QACrD,CAAC;;;OAAA;IAEmB,oBAAK,GAAzB;;;;;4BACoC,qBAAM,6BAAa,CAAC,SAAS,CACzD,cAAc,CACjB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAA;;wBAFV,QAAQ,GAAkB,SAEhB;wBAChB,IAAI,QAAQ,KAAK,IAAI;4BACjB,MAAM,IAAI,KAAK,CAAC,sCAAoC,CAAC,CAAC;6BAE/C,cAAc;sCACrB,QAAQ;wBACR,qBAAM,IAAI,CAAC,IAAI,CAAC,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,EAAA;4BAFxD,sBAAO,cAAI,cAAc,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IAAI,CAAC,OAAO,cAAI,MAAM,cAAI,KAAK,CAAC,MAAM,SACrC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,WAAI,KAAK,CAAC,OAAO,CAAE,CAAC,CAAC,CAAC,EAAE,CAC1C,EACF,CAAC,CAAC,KAAK,CAAC,MAAM,CACjB,CAAC;QACF,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,8BAAK,GAAZ,UAAa,KAA2C;QACpD,IAAM,MAAM,GAAW,IAAI,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC;QACxE,iCAAe,CAAC,GAAG,CACf,UAAG,IAAI,CAAC,OAAO,cAAI,MAAM,cAAI,KAAK,CAAC,MAAM,CAAE,EAC3C,CAAC,CAAC,KAAK,CAAC,MAAM,CACjB,CAAC;IACN,CAAC;IAOoB,mBAAI,GAAzB,UAA0B,IAAY;;;;;4BACV,qBAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,EAAA;;wBAA1D,OAAO,GAAW,SAAwC;wBAChE,sBAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAC;;;;KAC9B;IACL,qBAAC;AAAD,CAAC,AA9ED,IA8EC;AA9EY,wCAAc"}
@@ -0,0 +1,5 @@
1
+ import { ArgumentParser } from "./ArgumentParser";
2
+ import { PackageManager } from "./PackageManager";
3
+ export declare namespace PluginConfigurator {
4
+ function configure(pack: PackageManager, args: ArgumentParser.IArguments): Promise<void>;
5
+ }
@@ -0,0 +1,145 @@
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 __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.PluginConfigurator = void 0;
43
+ var fs_1 = __importDefault(require("fs"));
44
+ var path_1 = __importDefault(require("path"));
45
+ var FileRetriever_1 = require("./FileRetriever");
46
+ var PluginConfigurator;
47
+ (function (PluginConfigurator) {
48
+ function configure(pack, args) {
49
+ return __awaiter(this, void 0, void 0, function () {
50
+ var installed, error;
51
+ var _this = this;
52
+ return __generator(this, function (_a) {
53
+ switch (_a.label) {
54
+ case 0:
55
+ installed = pack.install({
56
+ dev: true,
57
+ modulo: "comment-json",
58
+ version: "4.2.3",
59
+ silent: true,
60
+ });
61
+ return [4 /*yield*/, (function () { return __awaiter(_this, void 0, void 0, function () {
62
+ var exp_1;
63
+ return __generator(this, function (_a) {
64
+ switch (_a.label) {
65
+ case 0:
66
+ _a.trys.push([0, 2, , 3]);
67
+ return [4 /*yield*/, _Configure(pack, args)];
68
+ case 1:
69
+ _a.sent();
70
+ return [2 /*return*/, null];
71
+ case 2:
72
+ exp_1 = _a.sent();
73
+ return [2 /*return*/, exp_1];
74
+ case 3: return [2 /*return*/];
75
+ }
76
+ });
77
+ }); })()];
78
+ case 1:
79
+ error = _a.sent();
80
+ // REMOVE IT
81
+ if (installed)
82
+ pack.erase({
83
+ modulo: "comment-json",
84
+ silent: true,
85
+ });
86
+ if (error !== null)
87
+ throw error;
88
+ return [2 /*return*/];
89
+ }
90
+ });
91
+ });
92
+ }
93
+ PluginConfigurator.configure = configure;
94
+ function _Configure(pack, args) {
95
+ return __awaiter(this, void 0, void 0, function () {
96
+ var Comment, config, _a, _b, compilerOptions, plugins, strict, core, typia;
97
+ return __generator(this, function (_c) {
98
+ switch (_c.label) {
99
+ case 0: return [4 /*yield*/, FileRetriever_1.FileRetriever.require(path_1.default.join("node_modules", "comment-json"))(pack.directory)];
100
+ case 1:
101
+ Comment = _c.sent();
102
+ _b = (_a = Comment).parse;
103
+ return [4 /*yield*/, fs_1.default.promises.readFile(args.project, "utf8")];
104
+ case 2:
105
+ config = _b.apply(_a, [_c.sent()]);
106
+ compilerOptions = config.compilerOptions;
107
+ if (compilerOptions === undefined)
108
+ throw new Error("".concat(args.project, " file does not have \"compilerOptions\" property."));
109
+ plugins = (function () {
110
+ var plugins = compilerOptions.plugins;
111
+ if (plugins === undefined)
112
+ return (compilerOptions.plugins = []);
113
+ else if (!Array.isArray(plugins))
114
+ throw new Error("\"plugins\" property of ".concat(args.project, " must be array type."));
115
+ return plugins;
116
+ })();
117
+ strict = compilerOptions.strict === true;
118
+ core = plugins.find(function (p) {
119
+ return typeof p === "object" &&
120
+ p !== null &&
121
+ p.transform === "@nestia/core/lib/transform";
122
+ });
123
+ typia = plugins.find(function (p) {
124
+ return typeof p === "object" &&
125
+ p !== null &&
126
+ p.transform === "typia/lib/transform";
127
+ });
128
+ if (strict && !!core && !!typia)
129
+ return [2 /*return*/];
130
+ // DO CONFIGURE
131
+ compilerOptions.strict = true;
132
+ if (core === undefined)
133
+ plugins.push(Comment.parse("{\n \"transform\": \"@nestia/core/lib/transform\",\n /**\n * Validate request body.\n * \n * - \"assert\": Use typia.assert() function\n * - \"is\": Use typia.is() function\n * - \"validate\": Use typia.validate() function\n */\n \"validate\": \"assert\",\n\n /**\n * Validate JSON typed response body.\n * \n * - null: Just use JSON.stringify() function, without boosting\n * - \"stringify\": Use typia.stringify() function, but dangerous\n * - \"assert\": Use typia.assertStringify() function\n * - \"is\": Use typia.isStringify() function\n * - \"validate\": Use typia.validateStringify() function\n */\n \"stringify\": \"is\"\n }"));
134
+ if (typia === undefined)
135
+ plugins.push(Comment.parse("{ \"transform\": \"typia/lib/transform\" }"));
136
+ return [4 /*yield*/, fs_1.default.promises.writeFile(args.project, Comment.stringify(config, null, 2))];
137
+ case 3:
138
+ _c.sent();
139
+ return [2 /*return*/];
140
+ }
141
+ });
142
+ });
143
+ }
144
+ })(PluginConfigurator = exports.PluginConfigurator || (exports.PluginConfigurator = {}));
145
+ //# sourceMappingURL=PluginConfigurator.js.map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,OAAO,CAAC,KAAK,CAAC,y1BAqBZ,CAA0B,CAC/B,CAAC;wBACN,IAAI,KAAK,KAAK,SAAS;4BACnB,OAAO,CAAC,IAAI,CACR,OAAO,CAAC,KAAK,CACT,4CAAwC,CAClB,CAC7B,CAAC;wBACN,qBAAM,YAAE,CAAC,QAAQ,CAAC,SAAS,CACvB,IAAI,CAAC,OAAQ,EACb,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CACrC,EAAA;;wBAHD,SAGC,CAAC;;;;;KACL;AACL,CAAC,EAzHgB,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAyHlC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestia/core",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Super-fast validation decorators of NestJS",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -39,16 +39,20 @@
39
39
  "devDependencies": {
40
40
  "@trivago/prettier-plugin-sort-imports": "^4.0.0",
41
41
  "@types/express": "^4.17.15",
42
+ "@types/inquirer": "^9.0.3",
42
43
  "@typescript-eslint/eslint-plugin": "^5.46.1",
43
44
  "@typescript-eslint/parser": "^5.46.1",
45
+ "commander": "^10.0.0",
44
46
  "comment-json": "^4.2.3",
45
47
  "eslint-plugin-deprecation": "^1.3.3",
46
48
  "git-last-commit": "^1.0.1",
49
+ "inquirer": "^8.2.5",
47
50
  "rimraf": "^3.0.2",
48
51
  "ts-node": "^10.9.1",
49
52
  "tstl": "^2.5.13",
50
53
  "ttypescript": "^1.5.15",
51
- "typescript": "^4.9.4"
54
+ "typescript": "^4.9.5",
55
+ "typescript-transform-paths": "^3.4.6"
52
56
  },
53
57
  "dependencies": {
54
58
  "@nestia/fetcher": "^1.0.0",
@@ -59,7 +63,7 @@
59
63
  "raw-body": "*",
60
64
  "reflect-metadata": "*",
61
65
  "rxjs": "*",
62
- "typia": "^3.4.15"
66
+ "typia": "^3.5.5"
63
67
  },
64
68
  "peerDependencies": {
65
69
  "ttypescript": ">= 1.5.15",
@@ -26,7 +26,7 @@ import { validate_request_body } from "./internal/validate_request_body";
26
26
  *
27
27
  * For reference, when the request body data is not following the promised type `T`,
28
28
  * `BadRequestException` error (status code: 400) would be thrown. Also,
29
- * `EncryptedRoute` decrypts request body usnig those options.
29
+ * `EncryptedRoute` decrypts request body using those options.
30
30
  *
31
31
  * - AES-128/256
32
32
  * - CBC mode
@@ -34,13 +34,13 @@ import { route_error } from "./internal/route_error";
34
34
  * Encrypted router decorator functions.
35
35
  *
36
36
  * `EncryptedRoute` is a module containing router decorator functions which encrypts
37
- * response body data through AES-128/250 encryption. Furthermore, they can boost
38
- * up JSON string conversion speed about 10x times faster, even type safe through
39
- * [typia](https://github.com/samchon/typia).
37
+ * response body data through AES-128/256 encryption. Furthermore, they can boost
38
+ * up JSON string conversion speed about 50x times faster than `class-transformer`,
39
+ * even type safe through [typia](https://github.com/samchon/typia).
40
40
  *
41
41
  * For reference, router functions of `EncryptedRoute` can convert custom error classes
42
42
  * to regular {@link nest.HttpException} class automatically, through
43
- * {@link ExceptionManager}. Also, `EncryptedRoute` encrypts response body usnig those
43
+ * {@link ExceptionManager}. Also, `EncryptedRoute` encrypts response body using those
44
44
  * options.
45
45
  *
46
46
  * - AES-128/256
@@ -29,8 +29,9 @@ import { route_error } from "./internal/route_error";
29
29
  * Type safe router decorator functions.
30
30
  *
31
31
  * `TypedRoute` is a module containing router decorator functions which can boost up
32
- * JSON string conversion speed about 10x times faster. Furthermore, such JSON string
33
- * conversion is even type safe through [typia](https://github.com/samchon/typia).
32
+ * JSON string conversion speed about 50x times faster than `class-transformer`.
33
+ * Furthermore, such JSON string conversion is even type safe through
34
+ * [typia](https://github.com/samchon/typia).
34
35
  *
35
36
  * For reference, router functions of `TypedRoute` can convert custom error classes to
36
37
  * the regular {@link nest.HttpException} class automatically, through
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { CommandParser } from "./internal/CommandParser";
3
- import { CoreSetupWizard } from "./internal/CoreSetupWizard";
2
+ import { ArgumentParser } from "./internal/ArgumentParser";
3
+ import { CommandExecutor } from "./internal/CommandExecutor";
4
+ import { PackageManager } from "./internal/PackageManager";
5
+ import { PluginConfigurator } from "./internal/PluginConfigurator";
4
6
 
5
7
  const USAGE = `Wrong command has been detected. Use like below:
6
8
 
@@ -20,22 +22,41 @@ function halt(desc: string): never {
20
22
  }
21
23
 
22
24
  async function setup(): Promise<void> {
23
- const options: Record<string, string> = CommandParser.parse(
24
- process.argv.slice(3),
25
- );
26
- const manager: string = options.manager ?? "npm";
27
- const compiler: string = options.compiler ?? "ttypescript";
28
- const project: string = options.project ?? "tsconfig.json";
29
- console.log(options);
30
-
31
- if (
32
- (compiler !== "ttypescript" && compiler !== "ts-patch") ||
33
- (manager !== "npm" && manager !== "pnpm" && manager !== "yarn")
34
- )
35
- halt(USAGE);
36
- else if (compiler === "ttypescript")
37
- await CoreSetupWizard.ttypescript({ manager, project });
38
- else await CoreSetupWizard.tsPatch({ manager, project });
25
+ console.log("----------------------------------------");
26
+ console.log(" Nestia Setup Wizard");
27
+ console.log("----------------------------------------");
28
+
29
+ // LOAD PACKAGE.JSON INFO
30
+ const pack: PackageManager = await PackageManager.mount();
31
+
32
+ // TAKE ARGUMENTS
33
+ const args: ArgumentParser.IArguments = await ArgumentParser.parse(pack);
34
+
35
+ // INSTALL TYPESCRIPT
36
+ pack.install({ dev: true, modulo: "typescript" });
37
+ args.project ??= (() => {
38
+ CommandExecutor.run("npx tsc --init", false);
39
+ return (args.project = "tsconfig.json");
40
+ })();
41
+ pack.install({ dev: true, modulo: "ts-node" });
42
+
43
+ // INSTALL COMPILER
44
+ pack.install({ dev: true, modulo: args.compiler });
45
+ if (args.compiler === "ts-patch") {
46
+ await pack.save((data) => {
47
+ data.scripts ??= {};
48
+ if (typeof data.scripts.prepare === "string")
49
+ data.scripts.prepare =
50
+ "ts-patch install && " + data.scripts.prepare;
51
+ else data.scripts.prepare = "ts-patch install";
52
+ });
53
+ CommandExecutor.run("npm run prepare", false);
54
+ }
55
+
56
+ // INSTALL AND CONFIGURE TYPIA
57
+ pack.install({ dev: false, modulo: "typia" });
58
+ pack.install({ dev: false, modulo: "@nestia/core" });
59
+ await PluginConfigurator.configure(pack, args);
39
60
  }
40
61
 
41
62
  async function main(): Promise<void> {