@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
@@ -57,32 +57,73 @@ export namespace TypedQueryProgrammer {
57
57
  for (const property of object.properties) {
58
58
  const key: Metadata = property.key;
59
59
  const value: Metadata = property.value;
60
+ validate(object)(key)(value, 0);
61
+ }
62
+ return object;
63
+ };
60
64
 
61
- if (
62
- (value.atomics.length ? 1 : 0) +
63
- (value.constants.length ? 1 : 0) +
64
- (value.templates.length ? 1 : 0) !==
65
- value.bucket()
66
- )
67
- throw new Error(
68
- ErrorMessages.property(object)(key)(
69
- "only atomic typed propertie are allowed.",
70
- ),
71
- );
72
- else if (value.atomics.length > 1 || value.constants.length > 1)
73
- throw new Error(
74
- ErrorMessages.property(object)(key)(
75
- "union type is not allowed.",
76
- ),
77
- );
78
- else if (value.nullable === true)
65
+ const validate =
66
+ (obj: MetadataObject) =>
67
+ (key: Metadata) =>
68
+ (value: Metadata, depth: number): string[] => {
69
+ if (value.nullable)
70
+ throw new Error(
71
+ ErrorMessages.property(obj)(key)(
72
+ "nullable type is not allowed. Use undefindable type instead.",
73
+ ),
74
+ );
75
+ else if (depth === 1 && value.required === false)
76
+ throw new Error(
77
+ ErrorMessages.property(obj)(key)(
78
+ "optional type is not allowed in array.",
79
+ ),
80
+ );
81
+ else if (
82
+ value.maps.length ||
83
+ value.sets.length ||
84
+ value.objects.length
85
+ )
86
+ throw new Error(
87
+ ErrorMessages.property(obj)(key)(
88
+ "object type is not allowed",
89
+ ),
90
+ );
91
+
92
+ const atom: string[] = [];
93
+ for (const type of value.atomics) atom.push(type);
94
+ for (const { type } of value.constants) atom.push(type);
95
+
96
+ if (depth === 0) {
97
+ if (atom.length && (value.arrays.length || value.arrays.length))
79
98
  throw new Error(
80
- ErrorMessages.property(object)(key)(
81
- "property type cannot be null. Use undefined instead.",
99
+ ErrorMessages.property(obj)(key)(
100
+ "union type is not allowed",
82
101
  ),
83
102
  );
84
- }
85
- return object;
103
+ for (const elem of value.arrays)
104
+ atom.push(...validate(obj)(key)(elem, depth + 1));
105
+ for (const tuple of value.tuples)
106
+ for (const elem of tuple)
107
+ atom.push(...validate(obj)(key)(elem, depth + 1));
108
+ } else if (value.arrays.length || value.tuples.length)
109
+ throw new Error(
110
+ ErrorMessages.property(obj)(key)(
111
+ "double-array type is not allowed",
112
+ ),
113
+ );
114
+
115
+ const size: number = new Set(atom).size;
116
+ if (size === 0)
117
+ throw new Error(
118
+ ErrorMessages.property(obj)(key)("unknown type"),
119
+ );
120
+ else if (size > 1)
121
+ throw new Error(
122
+ ErrorMessages.property(obj)(key)(
123
+ "union type is not allowed",
124
+ ),
125
+ );
126
+ return atom;
86
127
  };
87
128
 
88
129
  const decode =
@@ -143,20 +184,50 @@ export namespace TypedQueryProgrammer {
143
184
  const key: string = property.key.constants[0]!.values[0] as string;
144
185
  const value: Metadata = property.value;
145
186
 
146
- const type: Atomic.Literal = value.atomics.length
147
- ? value.atomics[0]!
187
+ const [type, isArray]: [Atomic.Literal, boolean] = value.atomics
188
+ .length
189
+ ? [value.atomics[0], false]
148
190
  : value.constants.length
149
- ? value.constants[0]!.type
150
- : "string";
191
+ ? [value.constants[0]!.type, false]
192
+ : (() => {
193
+ const meta = value.arrays[0] ?? value.tuples[0][0];
194
+ return meta.atomics.length
195
+ ? [meta.atomics[0], true]
196
+ : [meta.constants[0]!.type, true];
197
+ })();
151
198
  return ts.factory.createPropertyAssignment(
152
199
  key,
153
- decode_value(importer)(type)(
154
- ts.factory.createCallExpression(
155
- ts.factory.createIdentifier("input.get"),
156
- undefined,
157
- [ts.factory.createStringLiteral(key)],
158
- ),
159
- ),
200
+ isArray
201
+ ? ts.factory.createCallExpression(
202
+ IdentifierFactory.join(
203
+ ts.factory.createCallExpression(
204
+ ts.factory.createIdentifier("input.getAll"),
205
+ undefined,
206
+ [ts.factory.createStringLiteral(key)],
207
+ ),
208
+ "map",
209
+ ),
210
+ undefined,
211
+ [
212
+ ts.factory.createArrowFunction(
213
+ undefined,
214
+ undefined,
215
+ [IdentifierFactory.parameter("elem")],
216
+ undefined,
217
+ undefined,
218
+ decode_value(importer)(type)(
219
+ ts.factory.createIdentifier("elem"),
220
+ ),
221
+ ),
222
+ ],
223
+ )
224
+ : decode_value(importer)(type)(
225
+ ts.factory.createCallExpression(
226
+ ts.factory.createIdentifier("input.get"),
227
+ undefined,
228
+ [ts.factory.createStringLiteral(key)],
229
+ ),
230
+ ),
160
231
  );
161
232
  };
162
233
 
@@ -43,7 +43,7 @@ export namespace MethodTransformer {
43
43
  method.body,
44
44
  );
45
45
  // eslint-disable-next-line
46
- return ts.factory.updateMethodDeclaration(
46
+ return (ts.factory.updateMethodDeclaration as any)(
47
47
  method,
48
48
  decorators.map((deco) =>
49
49
  MethodDecoratorTransformer.transform(project, escaped, deco),
@@ -37,7 +37,7 @@ export namespace ParameterTransformer {
37
37
  param.initializer,
38
38
  );
39
39
  // eslint-disable-next-line
40
- return ts.factory.updateParameterDeclaration(
40
+ return (ts.factory.updateParameterDeclaration as any)(
41
41
  param,
42
42
  decorators.map((deco) =>
43
43
  ParameterDecoratorTransformer.transform(project, type, deco),
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,124 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- var __generator = (this && this.__generator) || function (thisArg, body) {
13
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
- function verb(n) { return function (v) { return step([n, v]); }; }
16
- function step(op) {
17
- if (f) throw new TypeError("Generator is already executing.");
18
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
19
- 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;
20
- if (y = 0, t) op = [op[0] & 2, t.value];
21
- switch (op[0]) {
22
- case 0: case 1: t = op; break;
23
- case 4: _.label++; return { value: op[1], done: false };
24
- case 5: _.label++; y = op[1]; op = [0]; continue;
25
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
- default:
27
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
- if (t[2]) _.ops.pop();
32
- _.trys.pop(); continue;
33
- }
34
- op = body.call(thisArg, _);
35
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
- }
38
- };
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- var ArgumentParser_1 = require("./internal/ArgumentParser");
41
- var CommandExecutor_1 = require("./internal/CommandExecutor");
42
- var PackageManager_1 = require("./internal/PackageManager");
43
- var PluginConfigurator_1 = require("./internal/PluginConfigurator");
44
- var USAGE = "Wrong command has been detected. Use like below:\n\n npx @nestia/core setup \\\n --compiler (ttypescript|ts-patch) \\\n --manager (npm|pnpm|yarn) \\\n --project {tsconfig.json file path}\n\n - npx @nestia/core setup\n - npx @nestia/core setup --compiler ts-patch\n - npx @nestia/core setup --manager pnpm\n - npx @nestia/core setup --project tsconfig.test.json";
45
- function halt(desc) {
46
- console.error(desc);
47
- process.exit(-1);
48
- }
49
- function setup() {
50
- var _a;
51
- return __awaiter(this, void 0, void 0, function () {
52
- var pack, args;
53
- return __generator(this, function (_b) {
54
- switch (_b.label) {
55
- case 0:
56
- console.log("----------------------------------------");
57
- console.log(" Nestia Setup Wizard");
58
- console.log("----------------------------------------");
59
- return [4 /*yield*/, PackageManager_1.PackageManager.mount()];
60
- case 1:
61
- pack = _b.sent();
62
- return [4 /*yield*/, ArgumentParser_1.ArgumentParser.parse(pack)];
63
- case 2:
64
- args = _b.sent();
65
- // INSTALL TYPESCRIPT
66
- pack.install({ dev: true, modulo: "typescript", version: "4.9.5" });
67
- (_a = args.project) !== null && _a !== void 0 ? _a : (args.project = (function () {
68
- CommandExecutor_1.CommandExecutor.run("npx tsc --init", false);
69
- return (args.project = "tsconfig.json");
70
- })());
71
- pack.install({ dev: true, modulo: "ts-node" });
72
- // INSTALL COMPILER
73
- pack.install({ dev: true, modulo: args.compiler });
74
- if (!(args.compiler === "ts-patch")) return [3 /*break*/, 4];
75
- return [4 /*yield*/, pack.save(function (data) {
76
- var _a;
77
- (_a = data.scripts) !== null && _a !== void 0 ? _a : (data.scripts = {});
78
- if (typeof data.scripts.prepare === "string")
79
- data.scripts.prepare =
80
- "ts-patch install && " + data.scripts.prepare;
81
- else
82
- data.scripts.prepare = "ts-patch install";
83
- })];
84
- case 3:
85
- _b.sent();
86
- CommandExecutor_1.CommandExecutor.run("npm run prepare", false);
87
- _b.label = 4;
88
- case 4:
89
- // INSTALL AND CONFIGURE TYPIA
90
- pack.install({ dev: false, modulo: "typia" });
91
- pack.install({ dev: false, modulo: "@nestia/core" });
92
- return [4 /*yield*/, PluginConfigurator_1.PluginConfigurator.configure(pack, args)];
93
- case 5:
94
- _b.sent();
95
- return [2 /*return*/];
96
- }
97
- });
98
- });
99
- }
100
- function main() {
101
- return __awaiter(this, void 0, void 0, function () {
102
- var type;
103
- return __generator(this, function (_a) {
104
- switch (_a.label) {
105
- case 0:
106
- type = process.argv[2];
107
- if (!(type === "setup")) return [3 /*break*/, 2];
108
- return [4 /*yield*/, setup()];
109
- case 1:
110
- _a.sent();
111
- return [3 /*break*/, 3];
112
- case 2:
113
- halt(USAGE);
114
- _a.label = 3;
115
- case 3: return [2 /*return*/];
116
- }
117
- });
118
- });
119
- }
120
- main().catch(function (exp) {
121
- console.error(exp);
122
- process.exit(-1);
123
- });
124
- //# sourceMappingURL=core.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/executable/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4DAA2D;AAC3D,8DAA6D;AAC7D,4DAA2D;AAC3D,oEAAmE;AAEnE,IAAM,KAAK,GAAG,wXAU0C,CAAC;AAEzD,SAAS,IAAI,CAAC,IAAY;IACtB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC;AAED,SAAe,KAAK;;;;;;;oBAChB,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;oBACxD,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;oBACpC,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;oBAG3B,qBAAM,+BAAc,CAAC,KAAK,EAAE,EAAA;;oBAAnD,IAAI,GAAmB,SAA4B;oBAGjB,qBAAM,+BAAc,CAAC,KAAK,CAAC,IAAI,CAAC,EAAA;;oBAAlE,IAAI,GAA8B,SAAgC;oBAExE,qBAAqB;oBACrB,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;oBACpE,MAAA,IAAI,CAAC,OAAO,oCAAZ,IAAI,C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AC;;;;;CAClD;AAED,SAAe,IAAI;;;;;;oBACT,IAAI,GAAuB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;yBAC7C,CAAA,IAAI,KAAK,OAAO,CAAA,EAAhB,wBAAgB;oBAAE,qBAAM,KAAK,EAAE,EAAA;;oBAAb,SAAa,CAAC;;;oBAC/B,IAAI,CAAC,KAAK,CAAC,CAAC;;;;;;CACpB;AACD,IAAI,EAAE,CAAC,KAAK,CAAC,UAAC,GAAG;IACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC"}
@@ -1,9 +0,0 @@
1
- import { PackageManager } from "./PackageManager";
2
- export declare namespace ArgumentParser {
3
- interface IArguments {
4
- compiler: "ts-patch" | "ttypescript";
5
- manager: "npm" | "pnpm" | "yarn";
6
- project: string | null;
7
- }
8
- function parse(pack: PackageManager): Promise<IArguments>;
9
- }
@@ -1,256 +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.ArgumentParser = void 0;
43
- var fs_1 = __importDefault(require("fs"));
44
- var path_1 = __importDefault(require("path"));
45
- var FileRetriever_1 = require("./FileRetriever");
46
- var ArgumentParser;
47
- (function (ArgumentParser) {
48
- function parse(pack) {
49
- return __awaiter(this, void 0, void 0, function () {
50
- var newbie, output;
51
- var _this = this;
52
- return __generator(this, function (_a) {
53
- switch (_a.label) {
54
- case 0:
55
- newbie = {
56
- commander: pack.install({
57
- dev: true,
58
- modulo: "commander",
59
- version: "10.0.0",
60
- silent: true,
61
- }),
62
- inquirer: pack.install({
63
- dev: true,
64
- modulo: "inquirer",
65
- version: "8.2.5",
66
- silent: true,
67
- }),
68
- };
69
- return [4 /*yield*/, (function () { return __awaiter(_this, void 0, void 0, function () {
70
- var error_1;
71
- return __generator(this, function (_a) {
72
- switch (_a.label) {
73
- case 0:
74
- _a.trys.push([0, 2, , 3]);
75
- return [4 /*yield*/, _Parse(pack)];
76
- case 1: return [2 /*return*/, _a.sent()];
77
- case 2:
78
- error_1 = _a.sent();
79
- return [2 /*return*/, error_1];
80
- case 3: return [2 /*return*/];
81
- }
82
- });
83
- }); })()];
84
- case 1:
85
- output = _a.sent();
86
- // REMOVE TEMPORARY PACKAGES
87
- if (newbie.commander)
88
- pack.erase({ modulo: "commander", silent: true });
89
- if (newbie.inquirer)
90
- pack.erase({ modulo: "inquirer", silent: true });
91
- // RETURNS
92
- if (output instanceof Error)
93
- throw output;
94
- return [2 /*return*/, output];
95
- }
96
- });
97
- });
98
- }
99
- ArgumentParser.parse = parse;
100
- function _Parse(pack) {
101
- return __awaiter(this, void 0, void 0, function () {
102
- var createPromptModule, program, questioned, action, select, configure;
103
- var _this = this;
104
- return __generator(this, function (_a) {
105
- switch (_a.label) {
106
- case 0: return [4 /*yield*/, FileRetriever_1.FileRetriever.require(path_1.default.join("node_modules", "inquirer"))(pack.directory)];
107
- case 1:
108
- createPromptModule = (_a.sent()).createPromptModule;
109
- return [4 /*yield*/, FileRetriever_1.FileRetriever.require(path_1.default.join("node_modules", "commander"))(pack.directory)];
110
- case 2:
111
- program = (_a.sent()).program;
112
- program.option("--compiler [compiler]", "compiler type");
113
- program.option("--manager [manager", "package manager");
114
- program.option("--project [project]", "tsconfig.json file location");
115
- questioned = { value: false };
116
- action = function (closure) {
117
- return new Promise(function (resolve, reject) {
118
- program.action(function (options) { return __awaiter(_this, void 0, void 0, function () {
119
- var _a, exp_1;
120
- return __generator(this, function (_b) {
121
- switch (_b.label) {
122
- case 0:
123
- _b.trys.push([0, 2, , 3]);
124
- _a = resolve;
125
- return [4 /*yield*/, closure(options)];
126
- case 1:
127
- _a.apply(void 0, [_b.sent()]);
128
- return [3 /*break*/, 3];
129
- case 2:
130
- exp_1 = _b.sent();
131
- reject(exp_1);
132
- return [3 /*break*/, 3];
133
- case 3: return [2 /*return*/];
134
- }
135
- });
136
- }); });
137
- program.parseAsync().catch(reject);
138
- });
139
- };
140
- select = function (name) {
141
- return function (message) {
142
- return function (choices) { return __awaiter(_this, void 0, void 0, function () {
143
- return __generator(this, function (_a) {
144
- switch (_a.label) {
145
- case 0:
146
- questioned.value = true;
147
- return [4 /*yield*/, createPromptModule()({
148
- type: "list",
149
- name: name,
150
- message: message,
151
- choices: choices,
152
- })];
153
- case 1: return [2 /*return*/, (_a.sent())[name]];
154
- }
155
- });
156
- }); };
157
- };
158
- };
159
- configure = function () { return __awaiter(_this, void 0, void 0, function () {
160
- var fileList;
161
- return __generator(this, function (_a) {
162
- switch (_a.label) {
163
- case 0: return [4 /*yield*/, fs_1.default.promises.readdir(process.cwd())];
164
- case 1: return [4 /*yield*/, (_a.sent())
165
- .filter(function (str) {
166
- return str.substring(0, 8) === "tsconfig" &&
167
- str.substring(str.length - 5) === ".json";
168
- })
169
- .sort(function (x, y) {
170
- return x === "tsconfig.json"
171
- ? -1
172
- : y === "tsconfig.json"
173
- ? 1
174
- : x < y
175
- ? -1
176
- : 1;
177
- })];
178
- case 2:
179
- fileList = _a.sent();
180
- if (fileList.length === 0) {
181
- if (process.cwd() !== pack.directory)
182
- throw new Error("Unable to find \"tsconfig.json\" file.");
183
- return [2 /*return*/, null];
184
- }
185
- else if (fileList.length === 1)
186
- return [2 /*return*/, fileList[0]];
187
- return [2 /*return*/, select("tsconfig")("TS Config File")(fileList)];
188
- }
189
- });
190
- }); };
191
- // DO CONSTRUCT
192
- return [2 /*return*/, action(function (options) { return __awaiter(_this, void 0, void 0, function () {
193
- var _a, _b, _c, _d, _e;
194
- var _f, _g, _h;
195
- return __generator(this, function (_j) {
196
- switch (_j.label) {
197
- case 0:
198
- if (!(options.compiler === undefined)) return [3 /*break*/, 2];
199
- console.log(COMPILER_DESCRIPTION);
200
- _a = options;
201
- return [4 /*yield*/, select("compiler")("Compiler")(((_f = pack.data.scripts) === null || _f === void 0 ? void 0 : _f.build) === "nest build"
202
- ? ["ts-patch", "ttypescript"]
203
- : ["ttypescript", "ts-patch"])];
204
- case 1:
205
- _a.compiler = _j.sent();
206
- _j.label = 2;
207
- case 2:
208
- if (!((_g = options.manager) !== null && _g !== void 0)) return [3 /*break*/, 3];
209
- _b = _g;
210
- return [3 /*break*/, 5];
211
- case 3:
212
- _c = options;
213
- return [4 /*yield*/, select("manager")("Package Manager")([
214
- "npm",
215
- "pnpm",
216
- "yarn",
217
- ])];
218
- case 4:
219
- _b = (_c.manager = _j.sent());
220
- _j.label = 5;
221
- case 5:
222
- _b;
223
- pack.manager = options.manager;
224
- if (!((_h = options.project) !== null && _h !== void 0)) return [3 /*break*/, 6];
225
- _d = _h;
226
- return [3 /*break*/, 8];
227
- case 6:
228
- _e = options;
229
- return [4 /*yield*/, configure()];
230
- case 7:
231
- _d = (_e.project = _j.sent());
232
- _j.label = 8;
233
- case 8:
234
- _d;
235
- if (questioned.value)
236
- console.log("");
237
- return [2 /*return*/, options];
238
- }
239
- });
240
- }); })];
241
- }
242
- });
243
- });
244
- }
245
- })(ArgumentParser = exports.ArgumentParser || (exports.ArgumentParser = {}));
246
- var COMPILER_DESCRIPTION = [
247
- "About compiler, if you adapt \"ttypescript\", you should use \"ttsc\" instead.",
248
- "",
249
- "Otherwise, you choose \"ts-patch\", you can use the original \"tsc\" command.",
250
- "However, the \"ts-patch\" hacks \"node_modules/typescript\" source code.",
251
- "Also, whenever update \"typescript\", you've to run \"npm run prepare\" command.",
252
- "",
253
- "By the way, when using \"@nest/cli\", you must just choose \"ts-patch\".",
254
- "",
255
- ].join("\n");
256
- //# sourceMappingURL=ArgumentParser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ArgumentParser.js","sourceRoot":"","sources":["../../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AAC"}
@@ -1,3 +0,0 @@
1
- export declare namespace CommandExecutor {
2
- function run(str: string, silent: boolean): void;
3
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CommandExecutor = void 0;
7
- var child_process_1 = __importDefault(require("child_process"));
8
- var CommandExecutor;
9
- (function (CommandExecutor) {
10
- function run(str, silent) {
11
- if (silent === false)
12
- console.log(str);
13
- child_process_1.default.execSync(str, { stdio: "ignore" });
14
- }
15
- CommandExecutor.run = run;
16
- })(CommandExecutor = exports.CommandExecutor || (exports.CommandExecutor = {}));
17
- //# sourceMappingURL=CommandExecutor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../../src/executable/internal/CommandExecutor.ts"],"names":[],"mappings":";;;;;;AAAA,gEAA+B;AAE/B,IAAiB,eAAe,CAK/B;AALD,WAAiB,eAAe;IAC5B,SAAgB,GAAG,CAAC,GAAW,EAAE,MAAe;QAC5C,IAAI,MAAM,KAAK,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvC,uBAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC1C,CAAC;IAHe,mBAAG,MAGlB,CAAA;AACL,CAAC,EALgB,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAK/B"}
@@ -1,5 +0,0 @@
1
- export declare namespace FileRetriever {
2
- const directory: (name: string) => (dir: string, depth?: number) => string | null;
3
- const file: (name: string) => (directory: string, depth?: number) => string | null;
4
- const require: (name: string) => (directory: string, depth?: number) => Promise<any>;
5
- }