@nestia/core 1.0.10 → 1.0.11
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 +15 -9
- package/lib/decorators/EncryptedBody.d.ts +1 -1
- package/lib/decorators/EncryptedBody.js +1 -1
- package/lib/decorators/EncryptedRoute.d.ts +4 -4
- package/lib/decorators/EncryptedRoute.js +4 -4
- package/lib/decorators/TypedRoute.d.ts +3 -2
- package/lib/decorators/TypedRoute.js +3 -2
- package/lib/decorators/TypedRoute.js.map +1 -1
- package/lib/executable/core.js +45 -23
- package/lib/executable/core.js.map +1 -1
- package/lib/executable/internal/ArgumentParser.d.ts +9 -0
- package/lib/executable/internal/ArgumentParser.js +269 -0
- package/lib/executable/internal/ArgumentParser.js.map +1 -0
- package/lib/executable/internal/CommandExecutor.d.ts +3 -0
- package/lib/executable/internal/CommandExecutor.js +17 -0
- package/lib/executable/internal/CommandExecutor.js.map +1 -0
- package/lib/executable/internal/PackageManager.d.ts +27 -0
- package/lib/executable/internal/PackageManager.js +140 -0
- package/lib/executable/internal/PackageManager.js.map +1 -0
- package/lib/executable/internal/PluginConfigurator.d.ts +5 -0
- package/lib/executable/internal/PluginConfigurator.js +168 -0
- package/lib/executable/internal/PluginConfigurator.js.map +1 -0
- package/package.json +7 -3
- package/src/decorators/EncryptedBody.ts +1 -1
- package/src/decorators/EncryptedRoute.ts +4 -4
- package/src/decorators/TypedRoute.ts +3 -2
- package/src/executable/core.ts +39 -18
- package/src/executable/internal/ArgumentParser.ts +144 -0
- package/src/executable/internal/CommandExecutor.ts +8 -0
- package/src/executable/internal/PackageManager.ts +99 -0
- package/src/executable/internal/PluginConfigurator.ts +128 -0
- package/lib/executable/internal/CommandParser.d.ts +0 -3
- package/lib/executable/internal/CommandParser.js +0 -21
- package/lib/executable/internal/CommandParser.js.map +0 -1
- package/lib/executable/internal/CoreSetupWizard.d.ts +0 -8
- package/lib/executable/internal/CoreSetupWizard.js +0 -271
- package/lib/executable/internal/CoreSetupWizard.js.map +0 -1
- package/src/executable/internal/CommandParser.ts +0 -15
- package/src/executable/internal/CoreSetupWizard.ts +0 -225
|
@@ -0,0 +1,140 @@
|
|
|
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 PackageManager = /** @class */ (function () {
|
|
47
|
+
function PackageManager(directory, data) {
|
|
48
|
+
this.directory = directory;
|
|
49
|
+
this.data = data;
|
|
50
|
+
this.manager = "npm";
|
|
51
|
+
}
|
|
52
|
+
Object.defineProperty(PackageManager.prototype, "file", {
|
|
53
|
+
get: function () {
|
|
54
|
+
return path_1.default.join(this.directory, "package.json");
|
|
55
|
+
},
|
|
56
|
+
enumerable: false,
|
|
57
|
+
configurable: true
|
|
58
|
+
});
|
|
59
|
+
PackageManager.mount = function () {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
+
var location, _a, _b;
|
|
62
|
+
return __generator(this, function (_c) {
|
|
63
|
+
switch (_c.label) {
|
|
64
|
+
case 0: return [4 /*yield*/, find(process.cwd())];
|
|
65
|
+
case 1:
|
|
66
|
+
location = _c.sent();
|
|
67
|
+
if (location === null)
|
|
68
|
+
throw new Error("Unable to find \"package.json\" file");
|
|
69
|
+
_a = PackageManager.bind;
|
|
70
|
+
_b = [void 0, location];
|
|
71
|
+
return [4 /*yield*/, this.load(path_1.default.join(location, "package.json"))];
|
|
72
|
+
case 2: return [2 /*return*/, new (_a.apply(PackageManager, _b.concat([_c.sent()])))()];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
PackageManager.prototype.save = function (modifier) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
+
var content;
|
|
80
|
+
return __generator(this, function (_a) {
|
|
81
|
+
switch (_a.label) {
|
|
82
|
+
case 0: return [4 /*yield*/, fs_1.default.promises.readFile(this.file, "utf8")];
|
|
83
|
+
case 1:
|
|
84
|
+
content = _a.sent();
|
|
85
|
+
this.data = JSON.parse(content);
|
|
86
|
+
modifier(this.data);
|
|
87
|
+
return [2 /*return*/, fs_1.default.promises.writeFile(this.file, JSON.stringify(this.data, null, 2), "utf8")];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
PackageManager.prototype.install = function (props) {
|
|
93
|
+
var container = props.dev
|
|
94
|
+
? this.data.devDependencies
|
|
95
|
+
: this.data.dependencies;
|
|
96
|
+
if (!!(container === null || container === void 0 ? void 0 : container[props.modulo]) &&
|
|
97
|
+
fs_1.default.existsSync(path_1.default.join(this.directory, "node_modules", props.modulo)))
|
|
98
|
+
return false;
|
|
99
|
+
var middle = this.manager === "yarn"
|
|
100
|
+
? "add".concat(props.dev ? " -D" : "")
|
|
101
|
+
: "install ".concat(props.dev ? "--save-dev" : "--save");
|
|
102
|
+
CommandExecutor_1.CommandExecutor.run("".concat(this.manager, " ").concat(middle, " ").concat(props.modulo).concat(props.version ? "@".concat(props.version) : ""), !!props.silent);
|
|
103
|
+
return true;
|
|
104
|
+
};
|
|
105
|
+
PackageManager.prototype.erase = function (props) {
|
|
106
|
+
var middle = this.manager === "yarn" ? "remove" : "uninstall";
|
|
107
|
+
CommandExecutor_1.CommandExecutor.run("".concat(this.manager, " ").concat(middle, " ").concat(props.modulo), !!props.silent);
|
|
108
|
+
};
|
|
109
|
+
PackageManager.load = function (file) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
+
var content;
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
switch (_a.label) {
|
|
114
|
+
case 0: return [4 /*yield*/, fs_1.default.promises.readFile(file, "utf8")];
|
|
115
|
+
case 1:
|
|
116
|
+
content = _a.sent();
|
|
117
|
+
return [2 /*return*/, JSON.parse(content)];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
return PackageManager;
|
|
123
|
+
}());
|
|
124
|
+
exports.PackageManager = PackageManager;
|
|
125
|
+
function find(directory, depth) {
|
|
126
|
+
if (directory === void 0) { directory = process.cwd(); }
|
|
127
|
+
if (depth === void 0) { depth = 0; }
|
|
128
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
+
var location;
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
location = path_1.default.join(directory, "package.json");
|
|
132
|
+
if (fs_1.default.existsSync(location))
|
|
133
|
+
return [2 /*return*/, directory];
|
|
134
|
+
else if (depth > 1)
|
|
135
|
+
return [2 /*return*/, null];
|
|
136
|
+
return [2 /*return*/, find(path_1.default.join(directory, ".."), depth + 1)];
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=PackageManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PackageManager.js","sourceRoot":"","sources":["../../../src/execut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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,AA5ED,IA4EC;AA5EY,wCAAc;AAqF3B,SAAe,IAAI,CACf,SAAiC,EACjC,KAAiB;IADjB,0BAAA,EAAA,YAAoB,OAAO,CAAC,GAAG,EAAE;IACjC,sBAAA,EAAA,SAAiB;;;;YAEX,QAAQ,GAAW,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;YAC9D,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;gBAAE,sBAAO,SAAS,EAAC;iBACzC,IAAI,KAAK,GAAG,CAAC;gBAAE,sBAAO,IAAI,EAAC;YAChC,sBAAO,IAAI,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,EAAC;;;CACtD"}
|
|
@@ -0,0 +1,168 @@
|
|
|
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.PluginConfigurator = void 0;
|
|
66
|
+
var fs_1 = __importDefault(require("fs"));
|
|
67
|
+
var path_1 = __importDefault(require("path"));
|
|
68
|
+
var PluginConfigurator;
|
|
69
|
+
(function (PluginConfigurator) {
|
|
70
|
+
function configure(pack, args) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
var installed, error;
|
|
73
|
+
var _this = this;
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
switch (_a.label) {
|
|
76
|
+
case 0:
|
|
77
|
+
installed = pack.install({
|
|
78
|
+
dev: true,
|
|
79
|
+
modulo: "comment-json",
|
|
80
|
+
version: "4.2.3",
|
|
81
|
+
silent: true,
|
|
82
|
+
});
|
|
83
|
+
return [4 /*yield*/, (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
84
|
+
var exp_1;
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
switch (_a.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
_a.trys.push([0, 2, , 3]);
|
|
89
|
+
return [4 /*yield*/, _Configure(pack, args)];
|
|
90
|
+
case 1:
|
|
91
|
+
_a.sent();
|
|
92
|
+
return [2 /*return*/, null];
|
|
93
|
+
case 2:
|
|
94
|
+
exp_1 = _a.sent();
|
|
95
|
+
return [2 /*return*/, exp_1];
|
|
96
|
+
case 3: return [2 /*return*/];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}); })()];
|
|
100
|
+
case 1:
|
|
101
|
+
error = _a.sent();
|
|
102
|
+
// REMOVE IT
|
|
103
|
+
if (installed)
|
|
104
|
+
pack.erase({
|
|
105
|
+
modulo: "comment-json",
|
|
106
|
+
silent: true,
|
|
107
|
+
});
|
|
108
|
+
if (error !== null)
|
|
109
|
+
throw error;
|
|
110
|
+
return [2 /*return*/];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
PluginConfigurator.configure = configure;
|
|
116
|
+
function _Configure(pack, args) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
+
var Comment, config, _a, _b, compilerOptions, plugins, strict, core, typia;
|
|
119
|
+
return __generator(this, function (_c) {
|
|
120
|
+
var _d;
|
|
121
|
+
switch (_c.label) {
|
|
122
|
+
case 0: return [4 /*yield*/, (_d = path_1.default.join(pack.directory, "node_modules", "comment-json"), Promise.resolve().then(function () { return __importStar(require(_d)); }))];
|
|
123
|
+
case 1:
|
|
124
|
+
Comment = _c.sent();
|
|
125
|
+
_b = (_a = Comment).parse;
|
|
126
|
+
return [4 /*yield*/, fs_1.default.promises.readFile(args.project, "utf8")];
|
|
127
|
+
case 2:
|
|
128
|
+
config = _b.apply(_a, [_c.sent()]);
|
|
129
|
+
compilerOptions = config.compilerOptions;
|
|
130
|
+
if (compilerOptions === undefined)
|
|
131
|
+
throw new Error("".concat(args.project, " file does not have \"compilerOptions\" property."));
|
|
132
|
+
plugins = (function () {
|
|
133
|
+
var plugins = compilerOptions.plugins;
|
|
134
|
+
if (plugins === undefined)
|
|
135
|
+
return (compilerOptions.plugins = []);
|
|
136
|
+
else if (!Array.isArray(plugins))
|
|
137
|
+
throw new Error("\"plugins\" property of ".concat(args.project, " must be array type."));
|
|
138
|
+
return plugins;
|
|
139
|
+
})();
|
|
140
|
+
strict = compilerOptions.strict === true;
|
|
141
|
+
core = plugins.find(function (p) {
|
|
142
|
+
return typeof p === "object" &&
|
|
143
|
+
p !== null &&
|
|
144
|
+
p.transform === "@nestia/core/lib/transform";
|
|
145
|
+
});
|
|
146
|
+
typia = plugins.find(function (p) {
|
|
147
|
+
return typeof p === "object" &&
|
|
148
|
+
p !== null &&
|
|
149
|
+
p.transform === "typia/lib/transform";
|
|
150
|
+
});
|
|
151
|
+
if (strict && !!core && !!typia)
|
|
152
|
+
return [2 /*return*/];
|
|
153
|
+
// DO CONFIGURE
|
|
154
|
+
compilerOptions.strict = true;
|
|
155
|
+
if (core === undefined)
|
|
156
|
+
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 }"));
|
|
157
|
+
if (typia === undefined)
|
|
158
|
+
plugins.push(Comment.parse("{ \"transform\": \"typia/lib/transform\" }"));
|
|
159
|
+
return [4 /*yield*/, fs_1.default.promises.writeFile(args.project, Comment.stringify(config, null, 2))];
|
|
160
|
+
case 3:
|
|
161
|
+
_c.sent();
|
|
162
|
+
return [2 /*return*/];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
})(PluginConfigurator = exports.PluginConfigurator || (exports.PluginConfigurator = {}));
|
|
168
|
+
//# sourceMappingURL=PluginConfigurator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginConfigurator.js","sourceRoot":"","sources":["../../../src/executable/internal/PluginConfigurator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0CAAoB;AACpB,8CAAwB;AAKxB,IAAiB,kBAAkB,CAwHlC;AAxHD,WAAiB,kBAAkB;IAC/B,SAAsB,SAAS,CAC3B,IAAoB,EACpB,IAA+B;;;;;;;wBAGzB,SAAS,GAAY,IAAI,CAAC,OAAO,CAAC;4BACpC,GAAG,EAAE,IAAI;4BACT,MAAM,EAAE,cAAc;4BACtB,OAAO,EAAE,OAAO;4BAChB,MAAM,EAAE,IAAI;yBACf,CAAC,CAAC;wBAGyB,qBAAM,CAAC;;;;;;4CAE3B,qBAAM,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,EAAA;;4CAA5B,SAA4B,CAAC;4CAC7B,sBAAO,IAAI,EAAC;;;4CAEZ,sBAAO,KAAY,EAAC;;;;iCAE3B,CAAC,EAAE,EAAA;;wBAPE,KAAK,GAAiB,SAOxB;wBAEJ,YAAY;wBACZ,IAAI,SAAS;4BACT,IAAI,CAAC,KAAK,CAAC;gCACP,MAAM,EAAE,cAAc;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BAA4B;wBAF5C,CAE4C,CACnD,CAAC;wBACI,KAAK,GAAsC,OAAO,CAAC,IAAI,CACzD,UAAC,CAAC;4BACE,OAAA,OAAO,CAAC,KAAK,QAAQ;gCACrB,CAAC,KAAK,IAAI;gCACV,CAAC,CAAC,SAAS,KAAK,qBAAqB;wBAFrC,CAEqC,CAC5C,CAAC;wBACF,IAAI,MAAM,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK;4BAAE,sBAAO;wBAExC,eAAe;wBACf,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC;wBAC9B,IAAI,IAAI,KAAK,SAAS;4BAClB,OAAO,CAAC,IAAI,CACR,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,EAxHgB,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAwHlC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
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.
|
|
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.
|
|
66
|
+
"typia": "^3.5.3"
|
|
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
|
|
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/
|
|
38
|
-
* up JSON string conversion speed about
|
|
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
|
|
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
|
|
33
|
-
* conversion is even type safe through
|
|
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
|
package/src/executable/core.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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> {
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type CommanderModule from "commander";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import type * as InquirerModule from "inquirer";
|
|
4
|
+
import path from "path";
|
|
5
|
+
|
|
6
|
+
import { PackageManager } from "./PackageManager";
|
|
7
|
+
|
|
8
|
+
export namespace ArgumentParser {
|
|
9
|
+
export interface IArguments {
|
|
10
|
+
compiler: "ts-patch" | "ttypescript";
|
|
11
|
+
manager: "npm" | "pnpm" | "yarn";
|
|
12
|
+
project: string | null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function parse(pack: PackageManager): Promise<IArguments> {
|
|
16
|
+
// INSTALL TEMPORARY PACKAGES
|
|
17
|
+
const newbie = {
|
|
18
|
+
commander: pack.install({
|
|
19
|
+
dev: true,
|
|
20
|
+
modulo: "commander",
|
|
21
|
+
version: "10.0.0",
|
|
22
|
+
silent: true,
|
|
23
|
+
}),
|
|
24
|
+
inquirer: pack.install({
|
|
25
|
+
dev: true,
|
|
26
|
+
modulo: "inquirer",
|
|
27
|
+
version: "8.2.5",
|
|
28
|
+
silent: true,
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// TAKE OPTIONS
|
|
33
|
+
const output: IArguments | Error = await (async () => {
|
|
34
|
+
try {
|
|
35
|
+
return await _Parse(pack);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
return error as Error;
|
|
38
|
+
}
|
|
39
|
+
})();
|
|
40
|
+
|
|
41
|
+
// REMOVE TEMPORARY PACKAGES
|
|
42
|
+
if (newbie.commander) pack.erase({ modulo: "commander", silent: true });
|
|
43
|
+
if (newbie.inquirer) pack.erase({ modulo: "inquirer", silent: true });
|
|
44
|
+
|
|
45
|
+
// RETURNS
|
|
46
|
+
if (output instanceof Error) throw output;
|
|
47
|
+
return output;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function _Parse(pack: PackageManager): Promise<IArguments> {
|
|
51
|
+
// PREPARE ASSETS
|
|
52
|
+
const { createPromptModule }: typeof InquirerModule = await import(
|
|
53
|
+
path.join(pack.directory, "node_modules", "inquirer")
|
|
54
|
+
);
|
|
55
|
+
const { program }: typeof CommanderModule = await import(
|
|
56
|
+
path.join(pack.directory, "node_modules", "commander")
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
program.option("--compiler [compiler]", "compiler type");
|
|
60
|
+
program.option("--manager [manager", "package manager");
|
|
61
|
+
program.option("--project [project]", "tsconfig.json file location");
|
|
62
|
+
|
|
63
|
+
// INTERNAL PROCEDURES
|
|
64
|
+
const questioned = { value: false };
|
|
65
|
+
const action = (
|
|
66
|
+
closure: (options: Partial<IArguments>) => Promise<IArguments>,
|
|
67
|
+
) => {
|
|
68
|
+
return new Promise<IArguments>((resolve, reject) => {
|
|
69
|
+
program.action(async (options) => {
|
|
70
|
+
try {
|
|
71
|
+
resolve(await closure(options));
|
|
72
|
+
} catch (exp) {
|
|
73
|
+
reject(exp);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
program.parseAsync().catch(reject);
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const select =
|
|
80
|
+
(name: string) =>
|
|
81
|
+
(message: string) =>
|
|
82
|
+
async <Choice extends string>(
|
|
83
|
+
choices: Choice[],
|
|
84
|
+
): Promise<Choice> => {
|
|
85
|
+
questioned.value = true;
|
|
86
|
+
return (
|
|
87
|
+
await createPromptModule()({
|
|
88
|
+
type: "list",
|
|
89
|
+
name: name,
|
|
90
|
+
message: message,
|
|
91
|
+
choices: choices,
|
|
92
|
+
})
|
|
93
|
+
)[name];
|
|
94
|
+
};
|
|
95
|
+
const configure = async () => {
|
|
96
|
+
const fileList: string[] = await (
|
|
97
|
+
await fs.promises.readdir(process.cwd())
|
|
98
|
+
).filter(
|
|
99
|
+
(str) =>
|
|
100
|
+
str.substring(0, 8) === "tsconfig" &&
|
|
101
|
+
str.substring(str.length - 5) === ".json",
|
|
102
|
+
);
|
|
103
|
+
if (fileList.length === 0) {
|
|
104
|
+
if (process.cwd() !== pack.directory)
|
|
105
|
+
throw new Error(`Unable to find "tsconfig.json" file.`);
|
|
106
|
+
return null;
|
|
107
|
+
} else if (fileList.length === 1) return fileList[0];
|
|
108
|
+
return select("tsconfig")("TS Config File")(fileList);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// DO CONSTRUCT
|
|
112
|
+
return action(async (options) => {
|
|
113
|
+
if (options.compiler === undefined) {
|
|
114
|
+
console.log(COMPILER_DESCRIPTION);
|
|
115
|
+
options.compiler = await select("compiler")(`Compiler`)(
|
|
116
|
+
pack.data.scripts?.build === "nest build"
|
|
117
|
+
? ["ts-patch" as const, "ttypescript" as const]
|
|
118
|
+
: ["ttypescript" as const, "ts-patch" as const],
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
options.manager ??= await select("manager")("Package Manager")([
|
|
122
|
+
"npm" as const,
|
|
123
|
+
"pnpm" as const,
|
|
124
|
+
"yarn" as const,
|
|
125
|
+
]);
|
|
126
|
+
pack.manager = options.manager;
|
|
127
|
+
options.project ??= await configure();
|
|
128
|
+
|
|
129
|
+
if (questioned.value) console.log("");
|
|
130
|
+
return options as IArguments;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const COMPILER_DESCRIPTION = [
|
|
136
|
+
`About compiler, if you adapt "ttypescript", you should use "ttsc" instead.`,
|
|
137
|
+
``,
|
|
138
|
+
`Otherwise, you choose "ts-patch", you can use the original "tsc" command.`,
|
|
139
|
+
`However, the "ts-patch" hacks "node_modules/typescript" source code.`,
|
|
140
|
+
`Also, whenever update "typescript", you've to run "npm run prepare" command.`,
|
|
141
|
+
``,
|
|
142
|
+
`By the way, when using "@nest/cli", you must just choose "ts-patch".`,
|
|
143
|
+
``,
|
|
144
|
+
].join("\n");
|