@nestia/core 1.0.18 → 1.0.19
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 +6 -11
- package/package.json +2 -5
- package/lib/executable/core.d.ts +0 -2
- package/lib/executable/core.js +0 -124
- package/lib/executable/core.js.map +0 -1
- package/lib/executable/internal/ArgumentParser.d.ts +0 -9
- package/lib/executable/internal/ArgumentParser.js +0 -256
- package/lib/executable/internal/ArgumentParser.js.map +0 -1
- package/lib/executable/internal/CommandExecutor.d.ts +0 -3
- package/lib/executable/internal/CommandExecutor.js +0 -17
- package/lib/executable/internal/CommandExecutor.js.map +0 -1
- package/lib/executable/internal/FileRetriever.d.ts +0 -5
- package/lib/executable/internal/FileRetriever.js +0 -109
- package/lib/executable/internal/FileRetriever.js.map +0 -1
- package/lib/executable/internal/PackageManager.d.ts +0 -27
- package/lib/executable/internal/PackageManager.js +0 -126
- package/lib/executable/internal/PackageManager.js.map +0 -1
- package/lib/executable/internal/PluginConfigurator.d.ts +0 -5
- package/lib/executable/internal/PluginConfigurator.js +0 -145
- package/lib/executable/internal/PluginConfigurator.js.map +0 -1
- package/src/executable/core.ts +0 -70
- package/src/executable/internal/ArgumentParser.ts +0 -156
- package/src/executable/internal/CommandExecutor.ts +0 -8
- package/src/executable/internal/FileRetriever.ts +0 -33
- package/src/executable/internal/PackageManager.ts +0 -92
- package/src/executable/internal/PluginConfigurator.ts +0 -130
|
@@ -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;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AY;;;;;4BACV,qBAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,EAAA;;wBAA1D,OAAO,GAAW,SAAwC;wBAChE,sBAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAC;;;;KAC9B;IACL,qBAAC;AAAD,CAAC,AA9ED,IA8EC;AA9EY,wCAAc"}
|
|
@@ -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,MAAM,EAAE,IAAI;6BACf,CAAC,CAAC;wBACP,IAAI,KAAK,KAAK,IAAI;4BAAE,MAAM,KAAK,CAAC;;;;;KAC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zD,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"}
|
package/src/executable/core.ts
DELETED
|
@@ -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");
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
export namespace FileRetriever {
|
|
5
|
-
export const directory =
|
|
6
|
-
(name: string) =>
|
|
7
|
-
(dir: string, depth: number = 0): string | null => {
|
|
8
|
-
const location: string = path.join(dir, name);
|
|
9
|
-
if (fs.existsSync(location)) return dir;
|
|
10
|
-
else if (depth > 2) return null;
|
|
11
|
-
return directory(name)(path.join(dir, ".."), depth + 1);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const file =
|
|
15
|
-
(name: string) =>
|
|
16
|
-
(directory: string, depth: number = 0): string | null => {
|
|
17
|
-
const location: string = path.join(directory, name);
|
|
18
|
-
if (fs.existsSync(location)) return location;
|
|
19
|
-
else if (depth > 2) return null;
|
|
20
|
-
return file(name)(path.join(directory, ".."), depth + 1);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const require =
|
|
24
|
-
(name: string) =>
|
|
25
|
-
async (directory: string, depth: number = 0) => {
|
|
26
|
-
const location: string | null = file(name)(directory, depth);
|
|
27
|
-
if (location === null)
|
|
28
|
-
throw new Error(
|
|
29
|
-
`Unable to find installed module. Please report to the nestia - https://github.com/samchon/nestia/issues`,
|
|
30
|
-
);
|
|
31
|
-
return import(location);
|
|
32
|
-
};
|
|
33
|
-
}
|