@nestia/core 1.0.18 → 1.1.0-dev.20230413

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 (107) hide show
  1. package/README.md +7 -34
  2. package/lib/decorators/DynamicModule.d.ts +23 -23
  3. package/lib/decorators/DynamicModule.js +103 -103
  4. package/lib/decorators/EncryptedBody.d.ts +23 -23
  5. package/lib/decorators/EncryptedBody.js +125 -125
  6. package/lib/decorators/EncryptedController.d.ts +31 -31
  7. package/lib/decorators/EncryptedController.js +41 -41
  8. package/lib/decorators/EncryptedModule.d.ts +49 -49
  9. package/lib/decorators/EncryptedModule.js +161 -161
  10. package/lib/decorators/EncryptedRoute.d.ts +78 -78
  11. package/lib/decorators/EncryptedRoute.js +216 -216
  12. package/lib/decorators/PlainBody.d.ts +22 -22
  13. package/lib/decorators/PlainBody.js +82 -82
  14. package/lib/decorators/TypedBody.d.ts +16 -16
  15. package/lib/decorators/TypedBody.js +94 -94
  16. package/lib/decorators/TypedParam.d.ts +25 -25
  17. package/lib/decorators/TypedParam.js +61 -61
  18. package/lib/decorators/TypedQuery.d.ts +14 -14
  19. package/lib/decorators/TypedQuery.js +99 -99
  20. package/lib/decorators/TypedQuery.js.map +1 -1
  21. package/lib/decorators/TypedRoute.d.ts +72 -72
  22. package/lib/decorators/TypedRoute.js +185 -185
  23. package/lib/decorators/internal/EncryptedConstant.d.ts +1 -1
  24. package/lib/decorators/internal/EncryptedConstant.js +7 -7
  25. package/lib/decorators/internal/TransformError.d.ts +1 -1
  26. package/lib/decorators/internal/TransformError.js +10 -10
  27. package/lib/decorators/internal/get_path_and_stringify.d.ts +1 -1
  28. package/lib/decorators/internal/get_path_and_stringify.js +78 -78
  29. package/lib/decorators/internal/headers_to_object.d.ts +3 -3
  30. package/lib/decorators/internal/headers_to_object.js +49 -49
  31. package/lib/decorators/internal/load_controller.d.ts +2 -2
  32. package/lib/decorators/internal/load_controller.js +151 -152
  33. package/lib/decorators/internal/load_controller.js.map +1 -1
  34. package/lib/decorators/internal/route_error.d.ts +3 -3
  35. package/lib/decorators/internal/route_error.js +86 -86
  36. package/lib/decorators/internal/validate_request_body.d.ts +2 -2
  37. package/lib/decorators/internal/validate_request_body.js +57 -57
  38. package/lib/index.d.ts +3 -3
  39. package/lib/index.js +31 -31
  40. package/lib/module.d.ts +12 -12
  41. package/lib/module.js +28 -28
  42. package/lib/options/INestiaTransformOptions.d.ts +4 -4
  43. package/lib/options/INestiaTransformOptions.js +2 -2
  44. package/lib/options/INestiaTransformProject.d.ts +5 -5
  45. package/lib/options/INestiaTransformProject.js +2 -2
  46. package/lib/options/IRequestBodyValidator.d.ts +16 -16
  47. package/lib/options/IRequestBodyValidator.js +2 -2
  48. package/lib/options/IResponseBodyStringifier.d.ts +20 -20
  49. package/lib/options/IResponseBodyStringifier.js +2 -2
  50. package/lib/programmers/TypedBodyProgrammer.d.ts +5 -5
  51. package/lib/programmers/TypedBodyProgrammer.js +45 -45
  52. package/lib/programmers/TypedQueryProgrammer.d.ts +5 -5
  53. package/lib/programmers/TypedQueryProgrammer.js +260 -165
  54. package/lib/programmers/TypedQueryProgrammer.js.map +1 -1
  55. package/lib/programmers/TypedRouteProgrammer.d.ts +5 -5
  56. package/lib/programmers/TypedRouteProgrammer.js +47 -47
  57. package/lib/transform.d.ts +3 -3
  58. package/lib/transform.js +20 -20
  59. package/lib/transformers/FileTransformer.d.ts +5 -5
  60. package/lib/transformers/FileTransformer.js +32 -32
  61. package/lib/transformers/MethodDecoratorTransformer.d.ts +5 -5
  62. package/lib/transformers/MethodDecoratorTransformer.js +87 -87
  63. package/lib/transformers/MethodTransformer.d.ts +5 -5
  64. package/lib/transformers/MethodTransformer.js +54 -54
  65. package/lib/transformers/MethodTransformer.js.map +1 -1
  66. package/lib/transformers/NodeTransformer.d.ts +5 -5
  67. package/lib/transformers/NodeTransformer.js +20 -20
  68. package/lib/transformers/ParameterDecoratorTransformer.d.ts +5 -5
  69. package/lib/transformers/ParameterDecoratorTransformer.js +53 -53
  70. package/lib/transformers/ParameterTransformer.d.ts +5 -5
  71. package/lib/transformers/ParameterTransformer.js +33 -33
  72. package/lib/transformers/ParameterTransformer.js.map +1 -1
  73. package/lib/typings/Creator.d.ts +3 -3
  74. package/lib/typings/Creator.js +2 -2
  75. package/lib/utils/ExceptionManager.d.ts +64 -64
  76. package/lib/utils/ExceptionManager.js +112 -112
  77. package/lib/utils/Singleton.d.ts +1 -1
  78. package/lib/utils/Singleton.js +23 -23
  79. package/package.json +8 -9
  80. package/src/decorators/TypedQuery.ts +10 -8
  81. package/src/programmers/TypedQueryProgrammer.ts +104 -33
  82. package/src/transformers/MethodTransformer.ts +1 -1
  83. package/src/transformers/ParameterTransformer.ts +1 -1
  84. package/lib/executable/core.d.ts +0 -2
  85. package/lib/executable/core.js +0 -124
  86. package/lib/executable/core.js.map +0 -1
  87. package/lib/executable/internal/ArgumentParser.d.ts +0 -9
  88. package/lib/executable/internal/ArgumentParser.js +0 -256
  89. package/lib/executable/internal/ArgumentParser.js.map +0 -1
  90. package/lib/executable/internal/CommandExecutor.d.ts +0 -3
  91. package/lib/executable/internal/CommandExecutor.js +0 -17
  92. package/lib/executable/internal/CommandExecutor.js.map +0 -1
  93. package/lib/executable/internal/FileRetriever.d.ts +0 -5
  94. package/lib/executable/internal/FileRetriever.js +0 -109
  95. package/lib/executable/internal/FileRetriever.js.map +0 -1
  96. package/lib/executable/internal/PackageManager.d.ts +0 -27
  97. package/lib/executable/internal/PackageManager.js +0 -126
  98. package/lib/executable/internal/PackageManager.js.map +0 -1
  99. package/lib/executable/internal/PluginConfigurator.d.ts +0 -5
  100. package/lib/executable/internal/PluginConfigurator.js +0 -145
  101. package/lib/executable/internal/PluginConfigurator.js.map +0 -1
  102. package/src/executable/core.ts +0 -70
  103. package/src/executable/internal/ArgumentParser.ts +0 -156
  104. package/src/executable/internal/CommandExecutor.ts +0 -8
  105. package/src/executable/internal/FileRetriever.ts +0 -33
  106. package/src/executable/internal/PackageManager.ts +0 -92
  107. package/src/executable/internal/PluginConfigurator.ts +0 -130
@@ -1,109 +0,0 @@
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 (dir, depth) {
73
- if (depth === void 0) { depth = 0; }
74
- var location = path_1.default.join(dir, name);
75
- if (fs_1.default.existsSync(location))
76
- return dir;
77
- else if (depth > 2)
78
- return null;
79
- return FileRetriever.directory(name)(path_1.default.join(dir, ".."), 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
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileRetriever.js","sourceRoot":"","sources":["../../../src/executable/internal/FileRetriever.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAoB;AACpB,8CAAwB;AAExB,IAAiB,aAAa,CA6B7B;AA7BD,WAAiB,aAAa;;IACb,uBAAS,GAClB,UAAC,IAAY;QACb,OAAA,UAAC,GAAW,EAAE,KAAiB;YAAjB,sBAAA,EAAA,SAAiB;YAC3B,IAAM,QAAQ,GAAW,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAC9C,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;gBAAE,OAAO,GAAG,CAAC;iBACnC,IAAI,KAAK,GAAG,CAAC;gBAAE,OAAO,IAAI,CAAC;YAChC,OAAO,cAAA,SAAS,CAAC,IAAI,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;QAC5D,CAAC;IALD,CAKC,CAAC;IAEO,kBAAI,GACb,UAAC,IAAY;QACb,OAAA,UAAC,SAAiB,EAAE,KAAiB;YAAjB,sBAAA,EAAA,SAAiB;YACjC,IAAM,QAAQ,GAAW,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YACpD,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;gBAAE,OAAO,QAAQ,CAAC;iBACxC,IAAI,KAAK,GAAG,CAAC;gBAAE,OAAO,IAAI,CAAC;YAChC,OAAO,cAAA,IAAI,CAAC,IAAI,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;QAC7D,CAAC;IALD,CAKC,CAAC;IAEO,qBAAO,GAChB,UAAC,IAAY;QACb,OAAA,UAAO,SAAiB,EAAE,KAAiB;YAAjB,sBAAA,EAAA,SAAiB;;;;;oBACjC,QAAQ,GAAkB,cAAA,IAAI,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;oBAC7D,IAAI,QAAQ,KAAK,IAAI;wBACjB,MAAM,IAAI,KAAK,CACX,yGAAyG,CAC5G,CAAC;oBACN,4BAAc,QAAQ,8EAAE;;;SAC3B;IAPD,CAOC,CAAC;AACV,CAAC,EA7BgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QA6B7B"}
@@ -1,27 +0,0 @@
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
- }
@@ -1,126 +0,0 @@
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
@@ -1 +0,0 @@
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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,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"}
@@ -1,5 +0,0 @@
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
- }
@@ -1,145 +0,0 @@
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 * - \"assert\": Use typia.assertStringify() function\n * - \"is\": Use typia.isStringify() function\n * - \"validate\": Use typia.validateStringify() function\n * - \"stringify\": Use typia.stringify() function, but dangerous\n * - null: Just use JSON.stringify() function, without boosting\n */\n \"stringify\": \"assert\"\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
@@ -1 +0,0 @@
1
- {"version":3,"file":"PluginConfigurator.js","sourceRoot":"","sources":["../../../src/executable/internal/PluginConfigurator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0CAAoB;AACpB,8CAAwB;AAGxB,iDAAgD;AAGhD,IAAiB,kBAAkB,CAyHlC;AAzHD,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;gCACtB,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AAC,CAAC,SAAS,KAAK,4BAA4B;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,61BAqBZ,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"}
@@ -1,70 +0,0 @@
1
- #!/usr/bin/env node
2
- import { ArgumentParser } from "./internal/ArgumentParser";
3
- import { CommandExecutor } from "./internal/CommandExecutor";
4
- import { PackageManager } from "./internal/PackageManager";
5
- import { PluginConfigurator } from "./internal/PluginConfigurator";
6
-
7
- const USAGE = `Wrong command has been detected. Use like below:
8
-
9
- npx @nestia/core setup \\
10
- --compiler (ttypescript|ts-patch) \\
11
- --manager (npm|pnpm|yarn) \\
12
- --project {tsconfig.json file path}
13
-
14
- - npx @nestia/core setup
15
- - npx @nestia/core setup --compiler ts-patch
16
- - npx @nestia/core setup --manager pnpm
17
- - npx @nestia/core setup --project tsconfig.test.json`;
18
-
19
- function halt(desc: string): never {
20
- console.error(desc);
21
- process.exit(-1);
22
- }
23
-
24
- async function setup(): Promise<void> {
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", version: "4.9.5" });
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);
60
- }
61
-
62
- async function main(): Promise<void> {
63
- const type: string | undefined = process.argv[2];
64
- if (type === "setup") await setup();
65
- else halt(USAGE);
66
- }
67
- main().catch((exp) => {
68
- console.error(exp);
69
- process.exit(-1);
70
- });
@@ -1,156 +0,0 @@
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 { FileRetriever } from "./FileRetriever";
7
- import { PackageManager } from "./PackageManager";
8
-
9
- export namespace ArgumentParser {
10
- export interface IArguments {
11
- compiler: "ts-patch" | "ttypescript";
12
- manager: "npm" | "pnpm" | "yarn";
13
- project: string | null;
14
- }
15
-
16
- export async function parse(pack: PackageManager): Promise<IArguments> {
17
- // INSTALL TEMPORARY PACKAGES
18
- const newbie = {
19
- commander: pack.install({
20
- dev: true,
21
- modulo: "commander",
22
- version: "10.0.0",
23
- silent: true,
24
- }),
25
- inquirer: pack.install({
26
- dev: true,
27
- modulo: "inquirer",
28
- version: "8.2.5",
29
- silent: true,
30
- }),
31
- };
32
-
33
- // TAKE OPTIONS
34
- const output: IArguments | Error = await (async () => {
35
- try {
36
- return await _Parse(pack);
37
- } catch (error) {
38
- return error as Error;
39
- }
40
- })();
41
-
42
- // REMOVE TEMPORARY PACKAGES
43
- if (newbie.commander) pack.erase({ modulo: "commander", silent: true });
44
- if (newbie.inquirer) pack.erase({ modulo: "inquirer", silent: true });
45
-
46
- // RETURNS
47
- if (output instanceof Error) throw output;
48
- return output;
49
- }
50
-
51
- async function _Parse(pack: PackageManager): Promise<IArguments> {
52
- // PREPARE ASSETS
53
- const { createPromptModule }: typeof InquirerModule =
54
- await FileRetriever.require(path.join("node_modules", "inquirer"))(
55
- pack.directory,
56
- );
57
- const { program }: typeof CommanderModule = await FileRetriever.require(
58
- path.join("node_modules", "commander"),
59
- )(pack.directory);
60
-
61
- program.option("--compiler [compiler]", "compiler type");
62
- program.option("--manager [manager", "package manager");
63
- program.option("--project [project]", "tsconfig.json file location");
64
-
65
- // INTERNAL PROCEDURES
66
- const questioned = { value: false };
67
- const action = (
68
- closure: (options: Partial<IArguments>) => Promise<IArguments>,
69
- ) => {
70
- return new Promise<IArguments>((resolve, reject) => {
71
- program.action(async (options) => {
72
- try {
73
- resolve(await closure(options));
74
- } catch (exp) {
75
- reject(exp);
76
- }
77
- });
78
- program.parseAsync().catch(reject);
79
- });
80
- };
81
- const select =
82
- (name: string) =>
83
- (message: string) =>
84
- async <Choice extends string>(
85
- choices: Choice[],
86
- ): Promise<Choice> => {
87
- questioned.value = true;
88
- return (
89
- await createPromptModule()({
90
- type: "list",
91
- name: name,
92
- message: message,
93
- choices: choices,
94
- })
95
- )[name];
96
- };
97
- const configure = async () => {
98
- const fileList: string[] = await (
99
- await fs.promises.readdir(process.cwd())
100
- )
101
- .filter(
102
- (str) =>
103
- str.substring(0, 8) === "tsconfig" &&
104
- str.substring(str.length - 5) === ".json",
105
- )
106
- .sort((x, y) =>
107
- x === "tsconfig.json"
108
- ? -1
109
- : y === "tsconfig.json"
110
- ? 1
111
- : x < y
112
- ? -1
113
- : 1,
114
- );
115
- if (fileList.length === 0) {
116
- if (process.cwd() !== pack.directory)
117
- throw new Error(`Unable to find "tsconfig.json" file.`);
118
- return null;
119
- } else if (fileList.length === 1) return fileList[0];
120
- return select("tsconfig")("TS Config File")(fileList);
121
- };
122
-
123
- // DO CONSTRUCT
124
- return action(async (options) => {
125
- if (options.compiler === undefined) {
126
- console.log(COMPILER_DESCRIPTION);
127
- options.compiler = await select("compiler")(`Compiler`)(
128
- pack.data.scripts?.build === "nest build"
129
- ? ["ts-patch" as const, "ttypescript" as const]
130
- : ["ttypescript" as const, "ts-patch" as const],
131
- );
132
- }
133
- options.manager ??= await select("manager")("Package Manager")([
134
- "npm" as const,
135
- "pnpm" as const,
136
- "yarn" as const,
137
- ]);
138
- pack.manager = options.manager;
139
- options.project ??= await configure();
140
-
141
- if (questioned.value) console.log("");
142
- return options as IArguments;
143
- });
144
- }
145
- }
146
-
147
- const COMPILER_DESCRIPTION = [
148
- `About compiler, if you adapt "ttypescript", you should use "ttsc" instead.`,
149
- ``,
150
- `Otherwise, you choose "ts-patch", you can use the original "tsc" command.`,
151
- `However, the "ts-patch" hacks "node_modules/typescript" source code.`,
152
- `Also, whenever update "typescript", you've to run "npm run prepare" command.`,
153
- ``,
154
- `By the way, when using "@nest/cli", you must just choose "ts-patch".`,
155
- ``,
156
- ].join("\n");