typia 3.5.0 → 3.5.1-dev.20220216
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 +13 -21
- package/lib/executable/internal/ArgumentParser.d.ts +9 -0
- package/lib/executable/internal/ArgumentParser.js +265 -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 +141 -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 +158 -0
- package/lib/executable/internal/PluginConfigurator.js.map +1 -0
- package/lib/executable/typia.js +43 -22
- package/lib/executable/typia.js.map +1 -1
- package/lib/transform.d.ts +2 -1
- package/lib/transform.js +2 -0
- package/lib/transform.js.map +1 -1
- package/package.json +10 -5
- package/src/executable/internal/ArgumentParser.ts +143 -0
- package/src/executable/internal/CommandExecutor.ts +8 -0
- package/src/executable/internal/PackageManager.ts +99 -0
- package/src/executable/internal/PluginConfigurator.ts +96 -0
- package/src/executable/typia.ts +40 -17
- package/src/transform.ts +2 -1
- 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/TypiaSetupWizard.d.ts +0 -8
- package/lib/executable/internal/TypiaSetupWizard.js +0 -244
- package/lib/executable/internal/TypiaSetupWizard.js.map +0 -1
- package/src/executable/internal/CommandParser.ts +0 -15
- package/src/executable/internal/TypiaSetupWizard.ts +0 -182
|
@@ -0,0 +1,158 @@
|
|
|
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
|
+
silent: true,
|
|
81
|
+
});
|
|
82
|
+
return [4, (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
83
|
+
var exp_1;
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0:
|
|
87
|
+
_a.trys.push([0, 2, , 3]);
|
|
88
|
+
return [4, _Configure(pack, args)];
|
|
89
|
+
case 1:
|
|
90
|
+
_a.sent();
|
|
91
|
+
return [2, null];
|
|
92
|
+
case 2:
|
|
93
|
+
exp_1 = _a.sent();
|
|
94
|
+
return [2, exp_1];
|
|
95
|
+
case 3: return [2];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}); })()];
|
|
99
|
+
case 1:
|
|
100
|
+
error = _a.sent();
|
|
101
|
+
if (installed)
|
|
102
|
+
pack.erase({
|
|
103
|
+
modulo: "comment-json",
|
|
104
|
+
silent: true,
|
|
105
|
+
});
|
|
106
|
+
if (error !== null)
|
|
107
|
+
throw error;
|
|
108
|
+
return [2];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
PluginConfigurator.configure = configure;
|
|
114
|
+
function _Configure(pack, args) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
+
var Comment, config, _a, _b, compilerOptions, plugins, strict, oldbie;
|
|
117
|
+
return __generator(this, function (_c) {
|
|
118
|
+
var _d;
|
|
119
|
+
switch (_c.label) {
|
|
120
|
+
case 0: return [4, (_d = path_1.default.join(pack.directory, "node_modules", "comment-json"), Promise.resolve().then(function () { return __importStar(require(_d)); }))];
|
|
121
|
+
case 1:
|
|
122
|
+
Comment = _c.sent();
|
|
123
|
+
_b = (_a = Comment).parse;
|
|
124
|
+
return [4, fs_1.default.promises.readFile(args.project, "utf8")];
|
|
125
|
+
case 2:
|
|
126
|
+
config = _b.apply(_a, [_c.sent()]);
|
|
127
|
+
compilerOptions = config.compilerOptions;
|
|
128
|
+
if (compilerOptions === undefined)
|
|
129
|
+
throw new Error("".concat(args.project, " file does not have \"compilerOptions\" property."));
|
|
130
|
+
plugins = (function () {
|
|
131
|
+
var plugins = compilerOptions.plugins;
|
|
132
|
+
if (plugins === undefined)
|
|
133
|
+
return (compilerOptions.plugins = []);
|
|
134
|
+
else if (!Array.isArray(plugins))
|
|
135
|
+
throw new Error("\"plugins\" property of ".concat(args.project, " must be array type."));
|
|
136
|
+
return plugins;
|
|
137
|
+
})();
|
|
138
|
+
strict = compilerOptions.strict === true;
|
|
139
|
+
oldbie = plugins.find(function (p) {
|
|
140
|
+
return typeof p === "object" &&
|
|
141
|
+
p !== null &&
|
|
142
|
+
p.transform === "typia/lib/transform";
|
|
143
|
+
});
|
|
144
|
+
if (strict === true && oldbie !== undefined)
|
|
145
|
+
return [2];
|
|
146
|
+
compilerOptions.strict = true;
|
|
147
|
+
if (oldbie === undefined)
|
|
148
|
+
plugins.push(Comment.parse("\n {\n \"transform\": \"typia/lib/transform\"\n }"));
|
|
149
|
+
return [4, fs_1.default.promises.writeFile(args.project, Comment.stringify(config, null, 2))];
|
|
150
|
+
case 3:
|
|
151
|
+
_c.sent();
|
|
152
|
+
return [2];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
})(PluginConfigurator = exports.PluginConfigurator || (exports.PluginConfigurator = {}));
|
|
158
|
+
//# 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,CAwFlC;AAxFD,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,MAAM,EAAE,IAAI;yBACf,CAAC,CAAC;wBAGyB,WAAM,CAAC;;;;;;4CAE3B,WAAM,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,EAAA;;4CAA5B,SAA4B,CAAC;4CAC7B,WAAO,IAAI,EAAC;;;4CAEZ,WAAO,KAAY,EAAC;;;;iCAE3B,CAAC,EAAE,EAAA;;wBAPE,KAAK,GAAiB,SAOxB;wBAGJ,IAAI,SAAS;4BACT,IAAI,CAAC,KAAK,CAAC;gCACP,MAAM,EAAE,cAAc;gCACtB,MAAM,EAAE,IAAI;6BACf,CAAC,CAAC;wBACP,IAAI,KAAK,KAAK,IAAI;4BAAE,MAAM,KAAK,CAAC;;;;;KACnC;IA5BqB,4BAAS,YA4B9B,CAAA;IAED,SAAe,UAAU,CACrB,IAAoB,EACpB,IAA+B;;;;;;4BAGgB,iBAC3C,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,EAAE,cAAc,CAAC,8EAC5D;;wBAFK,OAAO,GAAkC,SAE9C;wBAEqC,KAAA,CAAA,KAAA,OAAO,CAAA,CA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AC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CACrC,EAAA;;wBAHD,SAGC,CAAC;;;;;KACL;AACL,CAAC,EAxFgB,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAwFlC"}
|
package/lib/executable/typia.js
CHANGED
|
@@ -37,39 +37,60 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
var
|
|
41
|
-
var
|
|
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");
|
|
42
44
|
var USAGE = "Wrong command has been detected. Use like below:\n\n npx typia setup \\\n --compiler (ttypescript|ts-patch) \\\n --manager (npm|pnpm|yarn) \\\n --project {tsconfig.json file path}\n\n - npx typia setup\n - npx typia setup --compiler ts-patch\n - npx typia setup --manager pnpm\n - npx typia setup --project tsconfig.test.json";
|
|
43
45
|
function halt(desc) {
|
|
44
46
|
console.error(desc);
|
|
45
47
|
process.exit(-1);
|
|
46
48
|
}
|
|
47
49
|
function setup() {
|
|
48
|
-
var _a
|
|
50
|
+
var _a;
|
|
49
51
|
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
-
var
|
|
51
|
-
return __generator(this, function (
|
|
52
|
-
switch (
|
|
52
|
+
var pack, args;
|
|
53
|
+
return __generator(this, function (_b) {
|
|
54
|
+
switch (_b.label) {
|
|
53
55
|
case 0:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (!((compiler !== "ttypescript" && compiler !== "ts-patch") ||
|
|
59
|
-
(manager !== "npm" && manager !== "pnpm" && manager !== "yarn"))) return [3, 1];
|
|
60
|
-
halt(USAGE);
|
|
61
|
-
return [3, 5];
|
|
56
|
+
console.log("----------------------------------------");
|
|
57
|
+
console.log(" Typia Setup Wizard");
|
|
58
|
+
console.log("----------------------------------------");
|
|
59
|
+
return [4, PackageManager_1.PackageManager.mount()];
|
|
62
60
|
case 1:
|
|
63
|
-
|
|
64
|
-
return [4,
|
|
61
|
+
pack = _b.sent();
|
|
62
|
+
return [4, ArgumentParser_1.ArgumentParser.parse(pack)];
|
|
65
63
|
case 2:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
args = _b.sent();
|
|
65
|
+
if (args.project === null && process.cwd() !== pack.directory)
|
|
66
|
+
throw new Error("No tsconfig.json file.");
|
|
67
|
+
pack.install({ dev: true, modulo: "typescript" });
|
|
68
|
+
(_a = args.project) !== null && _a !== void 0 ? _a : (args.project = (function () {
|
|
69
|
+
CommandExecutor_1.CommandExecutor.run("npx tsc --init", false);
|
|
70
|
+
return (args.project = "tsconfig.json");
|
|
71
|
+
})());
|
|
72
|
+
pack.install({ dev: true, modulo: "ts-node" });
|
|
73
|
+
pack.install({ dev: true, modulo: args.compiler });
|
|
74
|
+
if (!(args.compiler === "ts-patch")) return [3, 4];
|
|
75
|
+
return [4, 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;
|
|
69
88
|
case 4:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
case 5:
|
|
89
|
+
pack.install({ dev: false, modulo: "typia" });
|
|
90
|
+
return [4, PluginConfigurator_1.PluginConfigurator.configure(pack, args)];
|
|
91
|
+
case 5:
|
|
92
|
+
_b.sent();
|
|
93
|
+
return [2];
|
|
73
94
|
}
|
|
74
95
|
});
|
|
75
96
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typia.js","sourceRoot":"","sources":["../../src/executable/typia.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"typia.js","sourceRoot":"","sources":["../../src/executable/typia.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4DAA2D;AAC3D,8DAA6D;AAC7D,4DAA2D;AAC3D,oEAAmE;AAEnE,IAAM,KAAK,GAAG,qVAUmC,CAAC;AAElD,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,qBAAqB,CAAC,CAAC;oBACnC,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;oBAG3B,WAAM,+BAAc,CAAC,KAAK,EAAE,EAAA;;oBAAnD,IAAI,GAAmB,SAA4B;oBAGjB,WAAM,+BAAc,CAAC,KAAK,CAAC,IAAI,CAAC,EAAA;;oBAAlE,IAAI,GAA8B,SAAgC;oBACxE,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,KAAK,IAAI,CAAC,SAAS;wBACzD,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;oBAG9C,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;oBAClD,MAAA,IAAI,CAAC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A,IAAI,KAAK,OAAO,CAAA,EAAhB,cAAgB;oBAAE,WAAM,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"}
|
package/lib/transform.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import { ITransformOptions } from "./transformers/ITransformOptions";
|
|
3
|
-
export
|
|
3
|
+
export declare function transform(program: ts.Program, options?: ITransformOptions): ts.TransformerFactory<ts.SourceFile>;
|
|
4
|
+
export default transform;
|
package/lib/transform.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.transform = void 0;
|
|
6
7
|
var typescript_1 = __importDefault(require("typescript"));
|
|
7
8
|
var FileTransformer_1 = require("./transformers/FileTransformer");
|
|
8
9
|
function transform(program, options) {
|
|
@@ -17,5 +18,6 @@ function transform(program, options) {
|
|
|
17
18
|
return FileTransformer_1.FileTransformer.transform(project, context, file);
|
|
18
19
|
}; };
|
|
19
20
|
}
|
|
21
|
+
exports.transform = transform;
|
|
20
22
|
exports.default = transform;
|
|
21
23
|
//# sourceMappingURL=transform.js.map
|
package/lib/transform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,kEAAiE;AAIjE,SAAgB,SAAS,CACrB,OAAmB,EACnB,OAA2B;IAE3B,IAAM,OAAO,GAAa;QACtB,OAAO,SAAA;QACP,eAAe,EAAE,OAAO,CAAC,kBAAkB,EAAE;QAC7C,OAAO,EAAE,OAAO,CAAC,cAAc,EAAE;QACjC,OAAO,EAAE,oBAAE,CAAC,aAAa,EAAE;QAC3B,OAAO,EAAE,OAAO,IAAI,EAAE;KACzB,CAAC;IACF,OAAO,UAAC,OAAO,IAAK,OAAA,UAAC,IAAI;QACrB,OAAA,iCAAe,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;IAAjD,CAAiD,EADjC,CACiC,CAAC;AAC1D,CAAC;AAbD,8BAaC;AACD,kBAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typia",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.1-dev.20220216",
|
|
4
4
|
"description": "Superfast runtime validators with only one line",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"benchmark": "npm run build:benchmark && node measure/benchmark",
|
|
12
12
|
"build": "rimraf lib && ttsc --removeComments --declaration false && ttsc --emitDeclarationOnly",
|
|
13
|
-
"build:test": "rimraf bin && ttsc -p tsconfig.
|
|
14
|
-
"build:benchmark": "rimraf measure && ttsc -p tsconfig.
|
|
13
|
+
"build:test": "rimraf bin && ttsc -p test/tsconfig.json",
|
|
14
|
+
"build:benchmark": "rimraf measure && ttsc -p benchmark/tsconfig.json",
|
|
15
15
|
"build:test:prettier": "npm run build:test && prettier --write ./bin/**/*.js",
|
|
16
16
|
"dev": "rimraf lib && ttsc --watch",
|
|
17
|
-
"dev:test": "rimraf bin && ttsc -p tsconfig.
|
|
17
|
+
"dev:test": "rimraf bin && ttsc -p test/tsconfig.json --watch",
|
|
18
18
|
"eslint": "eslint ./**/*.ts",
|
|
19
19
|
"eslint:fix": "eslint ./**/*.ts --fix",
|
|
20
20
|
"issue": "node test/issue",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"package:deprecate": "npm deprecate typescript-json \"Renamed to typia\"",
|
|
24
24
|
"prettier": "prettier --write ./**/*.ts",
|
|
25
25
|
"test": "node bin/test",
|
|
26
|
-
"test:generate": "ts-node -P tsconfig.
|
|
26
|
+
"test:generate": "ts-node -P build/tsconfig.json -C ttypescript build/test.ts",
|
|
27
27
|
"test:manual": "node test/manual",
|
|
28
28
|
"test:application:replace": "node test/features/application/replace && npm run prettier"
|
|
29
29
|
},
|
|
@@ -74,8 +74,10 @@
|
|
|
74
74
|
"@types/autocannon": "^7.9.0",
|
|
75
75
|
"@types/benchmark": "^2.1.2",
|
|
76
76
|
"@types/cli": "^0.11.20",
|
|
77
|
+
"@types/commander": "^2.12.2",
|
|
77
78
|
"@types/d3": "^7.4.0",
|
|
78
79
|
"@types/express": "^4.17.14",
|
|
80
|
+
"@types/inquirer": "^8.2.5",
|
|
79
81
|
"@types/jsdom": "^20.0.0",
|
|
80
82
|
"@types/nested-error-stacks": "^2.1.0",
|
|
81
83
|
"@types/node": "^17.0.24",
|
|
@@ -89,12 +91,14 @@
|
|
|
89
91
|
"class-transformer": "^0.5.1",
|
|
90
92
|
"class-validator": "^0.13.2",
|
|
91
93
|
"cli": "^1.0.1",
|
|
94
|
+
"commander": "^10.0.0",
|
|
92
95
|
"comment-json": "^4.2.3",
|
|
93
96
|
"d3": "^5.16.0",
|
|
94
97
|
"eslint-plugin-deprecation": "^1.3.2",
|
|
95
98
|
"express": "^4.18.2",
|
|
96
99
|
"fast-json-stringify": "^5.4.0",
|
|
97
100
|
"fastify": "^4.9.2",
|
|
101
|
+
"inquirer": "^8.2.5",
|
|
98
102
|
"io-ts": "^2.2.19",
|
|
99
103
|
"jsdom": "^20.0.2",
|
|
100
104
|
"physical-cpu-count": "^2.0.0",
|
|
@@ -107,6 +111,7 @@
|
|
|
107
111
|
"ts-node": "^10.9.1",
|
|
108
112
|
"ttypescript": "^1.5.15",
|
|
109
113
|
"typescript": "^4.9.4",
|
|
114
|
+
"typescript-transform-paths": "^3.4.6",
|
|
110
115
|
"uuid": "^8.3.2",
|
|
111
116
|
"zod": "^3.19.1"
|
|
112
117
|
},
|
|
@@ -0,0 +1,143 @@
|
|
|
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
|
+
silent: true,
|
|
22
|
+
}),
|
|
23
|
+
inquirer: pack.install({
|
|
24
|
+
dev: true,
|
|
25
|
+
modulo: "inquirer",
|
|
26
|
+
version: "8.2.5",
|
|
27
|
+
silent: true,
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// TAKE OPTIONS
|
|
32
|
+
const output: IArguments | Error = await (async () => {
|
|
33
|
+
try {
|
|
34
|
+
return await _Parse(pack);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
return error as Error;
|
|
37
|
+
}
|
|
38
|
+
})();
|
|
39
|
+
|
|
40
|
+
// REMOVE TEMPORARY PACKAGES
|
|
41
|
+
if (newbie.commander) pack.erase({ modulo: "commander", silent: true });
|
|
42
|
+
if (newbie.inquirer) pack.erase({ modulo: "inquirer", silent: true });
|
|
43
|
+
|
|
44
|
+
// RETURNS
|
|
45
|
+
if (output instanceof Error) throw output;
|
|
46
|
+
return output;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function _Parse(pack: PackageManager): Promise<IArguments> {
|
|
50
|
+
// PREPARE ASSETS
|
|
51
|
+
const { createPromptModule }: typeof InquirerModule = await import(
|
|
52
|
+
path.join(pack.directory, "node_modules", "inquirer")
|
|
53
|
+
);
|
|
54
|
+
const { program }: typeof CommanderModule = await import(
|
|
55
|
+
path.join(pack.directory, "node_modules", "commander")
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
program.option("--compiler [compiler]", "compiler type");
|
|
59
|
+
program.option("--manager [manager", "package manager");
|
|
60
|
+
program.option("--project [project]", "tsconfig.json file location");
|
|
61
|
+
|
|
62
|
+
// INTERNAL PROCEDURES
|
|
63
|
+
const questioned = { value: false };
|
|
64
|
+
const action = (
|
|
65
|
+
closure: (options: Partial<IArguments>) => Promise<IArguments>,
|
|
66
|
+
) => {
|
|
67
|
+
return new Promise<IArguments>((resolve, reject) => {
|
|
68
|
+
program.action(async (options) => {
|
|
69
|
+
try {
|
|
70
|
+
resolve(await closure(options));
|
|
71
|
+
} catch (exp) {
|
|
72
|
+
reject(exp);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
program.parseAsync().catch(reject);
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const select =
|
|
79
|
+
(name: string) =>
|
|
80
|
+
(message: string) =>
|
|
81
|
+
async <Choice extends string>(
|
|
82
|
+
choices: Choice[],
|
|
83
|
+
): Promise<Choice> => {
|
|
84
|
+
questioned.value = true;
|
|
85
|
+
return (
|
|
86
|
+
await createPromptModule()({
|
|
87
|
+
type: "list",
|
|
88
|
+
name: name,
|
|
89
|
+
message: message,
|
|
90
|
+
choices: choices,
|
|
91
|
+
})
|
|
92
|
+
)[name];
|
|
93
|
+
};
|
|
94
|
+
const configure = async () => {
|
|
95
|
+
const fileList: string[] = await (
|
|
96
|
+
await fs.promises.readdir(pack.directory)
|
|
97
|
+
).filter(
|
|
98
|
+
(str) =>
|
|
99
|
+
str.substring(0, 8) === "tsconfig" &&
|
|
100
|
+
str.substring(str.length - 5) === ".json",
|
|
101
|
+
);
|
|
102
|
+
if (fileList.length === 0) {
|
|
103
|
+
if (process.cwd() !== pack.directory)
|
|
104
|
+
throw new Error("No tsconfig.json file.");
|
|
105
|
+
return null;
|
|
106
|
+
} else if (fileList.length === 1) return fileList[0];
|
|
107
|
+
return select("tsconfig")("tsconfig.json file")(fileList);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// DO CONSTRUCT
|
|
111
|
+
return action(async (options) => {
|
|
112
|
+
if (options.compiler === undefined) {
|
|
113
|
+
console.log(COMPILER_DESCRIPTION);
|
|
114
|
+
options.compiler = await select("compiler")(`Compiler`)(
|
|
115
|
+
pack.data.scripts?.build === "nest build"
|
|
116
|
+
? ["ts-patch" as const, "ttypescript" as const]
|
|
117
|
+
: ["ttypescript" as const, "ts-patch" as const],
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
options.manager ??= await select("manager")("Package Manager")([
|
|
121
|
+
"npm" as const,
|
|
122
|
+
"pnpm" as const,
|
|
123
|
+
"yarn" as const,
|
|
124
|
+
]);
|
|
125
|
+
pack.manager = options.manager;
|
|
126
|
+
options.project ??= await configure();
|
|
127
|
+
|
|
128
|
+
if (questioned.value) console.log("");
|
|
129
|
+
return options as IArguments;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const COMPILER_DESCRIPTION = [
|
|
135
|
+
`About compiler, if you adapt "ttypescript", you should use "ttsc" instead.`,
|
|
136
|
+
``,
|
|
137
|
+
`Otherwise, you choose "ts-patch", you can use the original "tsc" command.`,
|
|
138
|
+
`However, the "ts-patch" hacks "node_modules/typescript" source code.`,
|
|
139
|
+
`Also, whenever update "typescript", you've to run "npm run prepare" command.`,
|
|
140
|
+
``,
|
|
141
|
+
`By the way, when using "@nest/cli", you must just choose "ts-patch".`,
|
|
142
|
+
``,
|
|
143
|
+
].join("\n");
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
import { CommandExecutor } from "./CommandExecutor";
|
|
5
|
+
|
|
6
|
+
export class PackageManager {
|
|
7
|
+
public manager: string = "npm";
|
|
8
|
+
public get file(): string {
|
|
9
|
+
return path.join(this.directory, "package.json");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public static async mount(): Promise<PackageManager> {
|
|
13
|
+
const location: string | null = await find(process.cwd());
|
|
14
|
+
if (location === null)
|
|
15
|
+
throw new Error("Failed to find package.json file");
|
|
16
|
+
|
|
17
|
+
return new PackageManager(
|
|
18
|
+
location,
|
|
19
|
+
await this.load(path.join(location, "package.json")),
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public async save(modifier: (data: Package.Data) => void): Promise<void> {
|
|
24
|
+
const content: string = await fs.promises.readFile(this.file, "utf8");
|
|
25
|
+
this.data = JSON.parse(content);
|
|
26
|
+
modifier(this.data);
|
|
27
|
+
|
|
28
|
+
return fs.promises.writeFile(
|
|
29
|
+
this.file,
|
|
30
|
+
JSON.stringify(this.data, null, 2),
|
|
31
|
+
"utf8",
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public install(props: {
|
|
36
|
+
dev: boolean;
|
|
37
|
+
silent?: boolean;
|
|
38
|
+
modulo: string;
|
|
39
|
+
version?: string;
|
|
40
|
+
}): boolean {
|
|
41
|
+
const container = props.dev
|
|
42
|
+
? this.data.devDependencies
|
|
43
|
+
: this.data.dependencies;
|
|
44
|
+
if (
|
|
45
|
+
!!container?.[props.modulo] &&
|
|
46
|
+
fs.existsSync(
|
|
47
|
+
path.join(this.directory, "node_modules", props.modulo),
|
|
48
|
+
)
|
|
49
|
+
)
|
|
50
|
+
return false;
|
|
51
|
+
|
|
52
|
+
const middle: string =
|
|
53
|
+
this.manager === "yarn"
|
|
54
|
+
? `add${props.dev ? " -D" : ""}`
|
|
55
|
+
: `install ${props.dev ? "--save-dev" : "--save"}`;
|
|
56
|
+
CommandExecutor.run(
|
|
57
|
+
`${this.manager} ${middle} ${props.modulo}@${
|
|
58
|
+
props.version ?? "latest"
|
|
59
|
+
}`,
|
|
60
|
+
!!props.silent,
|
|
61
|
+
);
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public erase(props: { modulo: string; silent?: boolean }): void {
|
|
66
|
+
const middle: string = this.manager === "yarn" ? "remove" : "uninstall";
|
|
67
|
+
CommandExecutor.run(
|
|
68
|
+
`${this.manager} ${middle} ${props.modulo}`,
|
|
69
|
+
!!props.silent,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private constructor(
|
|
74
|
+
public readonly directory: string,
|
|
75
|
+
public data: Package.Data,
|
|
76
|
+
) {}
|
|
77
|
+
|
|
78
|
+
private static async load(file: string): Promise<Package.Data> {
|
|
79
|
+
const content: string = await fs.promises.readFile(file, "utf8");
|
|
80
|
+
return JSON.parse(content);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export namespace Package {
|
|
84
|
+
export interface Data {
|
|
85
|
+
scripts?: Record<string, string>;
|
|
86
|
+
dependencies?: Record<string, string>;
|
|
87
|
+
devDependencies?: Record<string, string>;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function find(
|
|
92
|
+
directory: string = process.cwd(),
|
|
93
|
+
depth: number = 0,
|
|
94
|
+
): Promise<string | null> {
|
|
95
|
+
const location: string = path.join(directory, "package.json");
|
|
96
|
+
if (fs.existsSync(location)) return directory;
|
|
97
|
+
else if (depth > 1) return null;
|
|
98
|
+
return find(path.join(directory, ".."), depth + 1);
|
|
99
|
+
}
|