@nestia/sdk 2.0.0-dev.20230903 → 2.0.0-dev.20230904
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/lib/INestiaConfig.d.ts +8 -23
- package/lib/NestiaSdkApplication.d.ts +6 -5
- package/lib/NestiaSdkApplication.js +27 -84
- package/lib/NestiaSdkApplication.js.map +1 -1
- package/lib/analyses/ControllerAnalyzer.js +1 -1
- package/lib/analyses/ControllerAnalyzer.js.map +1 -1
- package/lib/executable/internal/NestiaConfigLoader.d.ts +7 -0
- package/lib/executable/internal/NestiaConfigLoader.js +574 -0
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -0
- package/lib/executable/internal/NestiaProjectGetter.d.ts +3 -0
- package/lib/executable/internal/NestiaProjectGetter.js +28 -0
- package/lib/executable/internal/NestiaProjectGetter.js.map +1 -0
- package/lib/executable/internal/NestiaSdkCommand.d.ts +3 -3
- package/lib/executable/internal/NestiaSdkCommand.js +13 -104
- package/lib/executable/internal/NestiaSdkCommand.js.map +1 -1
- package/lib/executable/internal/{nestia.config.getter.js → nestia.project.getter.js} +3 -3
- package/lib/executable/internal/nestia.project.getter.js.map +1 -0
- package/lib/executable/sdk.js +3 -3
- package/lib/executable/sdk.js.map +1 -1
- package/package.json +3 -3
- package/src/INestiaConfig.ts +9 -25
- package/src/NestiaSdkApplication.ts +36 -77
- package/src/analyses/ControllerAnalyzer.ts +1 -1
- package/src/executable/internal/NestiaConfigLoader.ts +82 -0
- package/src/executable/internal/NestiaProjectGetter.ts +11 -0
- package/src/executable/internal/NestiaSdkCommand.ts +23 -146
- package/src/executable/internal/{nestia.config.getter.ts → nestia.project.getter.ts} +2 -2
- package/src/executable/sdk.ts +3 -3
- package/lib/executable/internal/NestiaConfigCompilerOptions.d.ts +0 -12
- package/lib/executable/internal/NestiaConfigCompilerOptions.js +0 -18
- package/lib/executable/internal/NestiaConfigCompilerOptions.js.map +0 -1
- package/lib/executable/internal/NestiaSdkConfig.d.ts +0 -4
- package/lib/executable/internal/NestiaSdkConfig.js +0 -1019
- package/lib/executable/internal/NestiaSdkConfig.js.map +0 -1
- package/lib/executable/internal/nestia.config.getter.js.map +0 -1
- package/src/executable/internal/NestiaConfigCompilerOptions.ts +0 -19
- package/src/executable/internal/NestiaSdkConfig.ts +0 -36
- /package/lib/executable/internal/{nestia.config.getter.d.ts → nestia.project.getter.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare namespace NestiaSdkCommand {
|
|
2
|
-
const sdk: (
|
|
3
|
-
const swagger: (
|
|
4
|
-
const e2e: (
|
|
2
|
+
const sdk: () => Promise<void>;
|
|
3
|
+
const swagger: () => Promise<void>;
|
|
4
|
+
const e2e: () => Promise<void>;
|
|
5
5
|
}
|
|
@@ -8,117 +8,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
12
|
exports.NestiaSdkCommand = void 0;
|
|
27
|
-
const cli_1 = __importDefault(require("cli"));
|
|
28
|
-
const path_1 = __importDefault(require("path"));
|
|
29
|
-
const WorkerConnector_1 = require("tgrid/protocols/workers/WorkerConnector");
|
|
30
|
-
const tsconfck_1 = require("tsconfck");
|
|
31
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
32
13
|
const NestiaSdkApplication_1 = require("../../NestiaSdkApplication");
|
|
14
|
+
const NestiaConfigLoader_1 = require("./NestiaConfigLoader");
|
|
33
15
|
var NestiaSdkCommand;
|
|
34
16
|
(function (NestiaSdkCommand) {
|
|
35
|
-
NestiaSdkCommand.sdk = (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
NestiaSdkCommand.swagger = (argv) => main({
|
|
41
|
-
assign: (config, output) => {
|
|
42
|
-
if (!config.swagger)
|
|
43
|
-
config.swagger = { output };
|
|
44
|
-
else
|
|
45
|
-
config.swagger.output = output;
|
|
46
|
-
},
|
|
47
|
-
validate: (config) => !!config.swagger && !!config.swagger.output,
|
|
48
|
-
location: (config) => config.swagger.output,
|
|
49
|
-
})(argv)((app) => app.swagger());
|
|
50
|
-
NestiaSdkCommand.e2e = (argv) => main({
|
|
51
|
-
assign: (config, output) => (config.output = output),
|
|
52
|
-
validate: (config) => !!config.output,
|
|
53
|
-
location: (config) => config.output,
|
|
54
|
-
})(argv)((app) => app.e2e());
|
|
55
|
-
const main = (props) => (argv) => (task) => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
const command = cli_1.default.parse({
|
|
57
|
-
exclude: ["e", "Something to exclude", "string", null],
|
|
58
|
-
out: ["o", "Output path of the SDK files", "string", null],
|
|
59
|
-
e2e: [
|
|
60
|
-
"e",
|
|
61
|
-
"Output path of e2e test function files",
|
|
62
|
-
"string",
|
|
63
|
-
null,
|
|
64
|
-
],
|
|
65
|
-
});
|
|
66
|
-
const inputs = [];
|
|
67
|
-
for (const r of argv) {
|
|
68
|
-
if (r[0] === "-")
|
|
69
|
-
break;
|
|
70
|
-
inputs.push(r);
|
|
71
|
-
}
|
|
72
|
-
yield generate(props)(command)(inputs)(task);
|
|
17
|
+
NestiaSdkCommand.sdk = () => main((app) => app.sdk());
|
|
18
|
+
NestiaSdkCommand.swagger = () => main((app) => app.swagger());
|
|
19
|
+
NestiaSdkCommand.e2e = () => main((app) => app.e2e());
|
|
20
|
+
const main = (task) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
yield generate(task);
|
|
73
22
|
});
|
|
74
|
-
const generate = (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const app = new NestiaSdkApplication_1.NestiaSdkApplication(config);
|
|
23
|
+
const generate = (task) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
// LOAD CONFIG INFO
|
|
25
|
+
const project = yield NestiaConfigLoader_1.NestiaConfigLoader.project();
|
|
26
|
+
const compilerOptions = yield NestiaConfigLoader_1.NestiaConfigLoader.compilerOptions(project);
|
|
27
|
+
const config = yield NestiaConfigLoader_1.NestiaConfigLoader.config(compilerOptions);
|
|
28
|
+
// GENERATE
|
|
29
|
+
const app = new NestiaSdkApplication_1.NestiaSdkApplication(config, compilerOptions);
|
|
82
30
|
yield task(app);
|
|
83
31
|
});
|
|
84
|
-
function get_typescript_options() {
|
|
85
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
const configFileName = typescript_1.default.findConfigFile(process.cwd(), typescript_1.default.sys.fileExists, "tsconfig.json");
|
|
87
|
-
if (!configFileName)
|
|
88
|
-
return null;
|
|
89
|
-
const { tsconfig } = yield (0, tsconfck_1.parseNative)(configFileName);
|
|
90
|
-
const configFileText = JSON.stringify(tsconfig);
|
|
91
|
-
const { config } = typescript_1.default.parseConfigFileTextToJson(configFileName, configFileText);
|
|
92
|
-
const configParseResult = typescript_1.default.parseJsonConfigFileContent(config, typescript_1.default.sys, path_1.default.dirname(configFileName));
|
|
93
|
-
const _a = configParseResult.raw.compilerOptions, { moduleResolution } = _a, result = __rest(_a, ["moduleResolution"]);
|
|
94
|
-
return result;
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
function get_nestia_config(validate) {
|
|
98
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
const connector = new WorkerConnector_1.WorkerConnector(null, null, "process");
|
|
100
|
-
yield connector.connect(`${__dirname}/nestia.config.getter.${__filename.substr(-2)}`);
|
|
101
|
-
const driver = yield connector.getDriver();
|
|
102
|
-
const config = yield driver.get();
|
|
103
|
-
yield connector.close();
|
|
104
|
-
if (config !== null && validate(config) === false)
|
|
105
|
-
throw new Error(`Error on NestiaCommand.main(): output path is not specified in the "nestia.config.ts".`);
|
|
106
|
-
return config;
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
const parse_cli = (props) => (command) => (include) => {
|
|
110
|
-
var _a;
|
|
111
|
-
if (command.out === null)
|
|
112
|
-
throw new Error(`Error on NestiaCommand.main(): output directory is not specified. Add the "--out <output_directory>" option.`);
|
|
113
|
-
const config = {
|
|
114
|
-
input: {
|
|
115
|
-
include,
|
|
116
|
-
exclude: command.exclude ? [command.exclude] : undefined,
|
|
117
|
-
},
|
|
118
|
-
e2e: (_a = command.e2e) !== null && _a !== void 0 ? _a : undefined,
|
|
119
|
-
};
|
|
120
|
-
props.assign(config, command.out);
|
|
121
|
-
return config;
|
|
122
|
-
};
|
|
123
32
|
})(NestiaSdkCommand || (exports.NestiaSdkCommand = NestiaSdkCommand = {}));
|
|
124
33
|
//# sourceMappingURL=NestiaSdkCommand.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaSdkCommand.js","sourceRoot":"","sources":["../../../src/executable/internal/NestiaSdkCommand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NestiaSdkCommand.js","sourceRoot":"","sources":["../../../src/executable/internal/NestiaSdkCommand.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,qEAAkE;AAClE,6DAA0D;AAE1D,IAAiB,gBAAgB,CA2BhC;AA3BD,WAAiB,gBAAgB;IAChB,oBAAG,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;IACrC,wBAAO,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7C,oBAAG,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;IAElD,MAAM,IAAI,GAAG,CAAO,IAAkD,EAAE,EAAE;QACtE,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC,CAAA,CAAC;IAEF,MAAM,QAAQ,GAAG,CACb,IAAkD,EACpD,EAAE;QACA,mBAAmB;QACnB,MAAM,OAAO,GAAW,MAAM,uCAAkB,CAAC,OAAO,EAAE,CAAC;QAC3D,MAAM,eAAe,GACjB,MAAM,uCAAkB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACtD,MAAM,MAAM,GAAkB,MAAM,uCAAkB,CAAC,MAAM,CACzD,eAAe,CAClB,CAAC;QAEF,WAAW;QACX,MAAM,GAAG,GAAyB,IAAI,2CAAoB,CACtD,MAAM,EACN,eAAe,CAClB,CAAC;QACF,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC,CAAA,CAAC;AACN,CAAC,EA3BgB,gBAAgB,gCAAhB,gBAAgB,QA2BhC"}
|
|
@@ -10,15 +10,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const WorkerServer_1 = require("tgrid/protocols/workers/WorkerServer");
|
|
13
|
-
const
|
|
13
|
+
const NestiaProjectGetter_1 = require("./NestiaProjectGetter");
|
|
14
14
|
function main() {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
const worker = new WorkerServer_1.WorkerServer();
|
|
17
|
-
yield worker.open(
|
|
17
|
+
yield worker.open(NestiaProjectGetter_1.NestiaProjectGetter);
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
main().catch((exp) => {
|
|
21
21
|
console.log(exp);
|
|
22
22
|
process.exit(-1);
|
|
23
23
|
});
|
|
24
|
-
//# sourceMappingURL=nestia.
|
|
24
|
+
//# sourceMappingURL=nestia.project.getter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestia.project.getter.js","sourceRoot":"","sources":["../../../src/executable/internal/nestia.project.getter.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uEAAoE;AAEpE,+DAA4D;AAE5D,SAAe,IAAI;;QACf,MAAM,MAAM,GAAG,IAAI,2BAAY,EAAE,CAAC;QAClC,MAAM,MAAM,CAAC,IAAI,CAAC,yCAAmB,CAAC,CAAC;IAC3C,CAAC;CAAA;AACD,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACjB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC"}
|
package/lib/executable/sdk.js
CHANGED
|
@@ -88,11 +88,11 @@ function main() {
|
|
|
88
88
|
else if (type === "init")
|
|
89
89
|
yield initialize();
|
|
90
90
|
else if (type === "sdk")
|
|
91
|
-
yield execute((c) => c.sdk(
|
|
91
|
+
yield execute((c) => c.sdk());
|
|
92
92
|
else if (type === "swagger")
|
|
93
|
-
yield execute((c) => c.swagger(
|
|
93
|
+
yield execute((c) => c.swagger());
|
|
94
94
|
else if (type === "e2e")
|
|
95
|
-
yield execute((c) => c.e2e(
|
|
95
|
+
yield execute((c) => c.e2e());
|
|
96
96
|
else
|
|
97
97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AAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACjB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzB,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/sdk",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.20230904",
|
|
4
4
|
"description": "Nestia SDK and Swagger generator",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://nestia.io",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@nestia/fetcher": "^2.0.0-dev.
|
|
38
|
+
"@nestia/fetcher": "^2.0.0-dev.20230904",
|
|
39
39
|
"cli": "^1.0.1",
|
|
40
40
|
"glob": "^7.2.0",
|
|
41
41
|
"path-to-regexp": "^6.2.1",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"typia": "^5.0.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@nestia/fetcher": ">=2.0.0-dev.
|
|
50
|
+
"@nestia/fetcher": ">=2.0.0-dev.20230904",
|
|
51
51
|
"@nestjs/common": ">=7.0.1",
|
|
52
52
|
"@nestjs/core": ">=7.0.1",
|
|
53
53
|
"reflect-metadata": ">=0.1.12",
|
package/src/INestiaConfig.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type ts from "typescript";
|
|
2
|
-
|
|
3
1
|
import type { ISwagger } from "./structures/ISwagger";
|
|
4
2
|
import { ISwaggerInfo } from "./structures/ISwaggerInfo";
|
|
5
3
|
import { ISwaggerSecurityScheme } from "./structures/ISwaggerSecurityScheme";
|
|
6
|
-
import type { StripEnums } from "./utils/StripEnums";
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* Definition for the `nestia.config.ts` file.
|
|
@@ -11,6 +8,15 @@ import type { StripEnums } from "./utils/StripEnums";
|
|
|
11
8
|
* @author Jeongho Nam - https://github.com/samchon
|
|
12
9
|
*/
|
|
13
10
|
export interface INestiaConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Location of `tsconfig.json` file.
|
|
13
|
+
*
|
|
14
|
+
* If be configured, target file will replace the `tsconfig.json` file.
|
|
15
|
+
*
|
|
16
|
+
* @default tsconfig.json
|
|
17
|
+
*/
|
|
18
|
+
project?: string;
|
|
19
|
+
|
|
14
20
|
/**
|
|
15
21
|
* Building `swagger.json` is also possible.
|
|
16
22
|
*
|
|
@@ -55,28 +61,6 @@ export interface INestiaConfig {
|
|
|
55
61
|
*/
|
|
56
62
|
e2e?: string;
|
|
57
63
|
|
|
58
|
-
/**
|
|
59
|
-
* Compiler options for the TypeScript.
|
|
60
|
-
*
|
|
61
|
-
* If you've omitted this property or the assigned property cannot fully cover the
|
|
62
|
-
* `tsconfig.json`, the properties from the `tsconfig.json` would be assigned to here.
|
|
63
|
-
* Otherwise, this property has been configured and it's detailed values are different
|
|
64
|
-
* with the `tsconfig.json`, this property values would be used instead.
|
|
65
|
-
*
|
|
66
|
-
* ```typescript
|
|
67
|
-
* import ts from "typescript";
|
|
68
|
-
*
|
|
69
|
-
* const tsconfig: ts.TsConfig;
|
|
70
|
-
* const nestiaConfig: IConfiguration;
|
|
71
|
-
*
|
|
72
|
-
* const compilerOptions: ts.CompilerOptions = {
|
|
73
|
-
* ...tsconfig.compilerOptions,
|
|
74
|
-
* ...(nestiaConfig.compilerOptions ?? {})
|
|
75
|
-
* }
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
compilerOptions?: StripEnums<ts.CompilerOptions>;
|
|
79
|
-
|
|
80
64
|
/**
|
|
81
65
|
* Whether to assert parameter types or not.
|
|
82
66
|
*
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import * as runner from "ts-node";
|
|
4
3
|
import { Pair, Singleton } from "tstl";
|
|
5
4
|
import ts from "typescript";
|
|
6
5
|
|
|
@@ -8,7 +7,6 @@ import { INestiaConfig } from "./INestiaConfig";
|
|
|
8
7
|
import { AccessorAnalyzer } from "./analyses/AccessorAnalyzer";
|
|
9
8
|
import { ControllerAnalyzer } from "./analyses/ControllerAnalyzer";
|
|
10
9
|
import { ReflectAnalyzer } from "./analyses/ReflectAnalyzer";
|
|
11
|
-
import { NestiaConfigCompilerOptions } from "./executable/internal/NestiaConfigCompilerOptions";
|
|
12
10
|
import { E2eGenerator } from "./generates/E2eGenerator";
|
|
13
11
|
import { SdkGenerator } from "./generates/SdkGenerator";
|
|
14
12
|
import { SwaggerGenerator } from "./generates/SwaggerGenerator";
|
|
@@ -19,13 +17,9 @@ import { NestiaConfigUtil } from "./utils/NestiaConfigUtil";
|
|
|
19
17
|
import { SourceFinder } from "./utils/SourceFinder";
|
|
20
18
|
|
|
21
19
|
export class NestiaSdkApplication {
|
|
22
|
-
private readonly
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
public constructor(private readonly config_: INestiaConfig) {
|
|
27
|
-
this.bundle_checker_ = new Singleton(async () => {
|
|
28
|
-
if (!this.config_.output) return () => false;
|
|
20
|
+
private readonly checker_: Singleton<Promise<(str: string) => boolean>> =
|
|
21
|
+
new Singleton(async () => {
|
|
22
|
+
if (!this.config) return () => false;
|
|
29
23
|
|
|
30
24
|
const bundles: string[] = await fs.promises.readdir(
|
|
31
25
|
SdkGenerator.BUNDLE_PATH,
|
|
@@ -34,7 +28,7 @@ export class NestiaSdkApplication {
|
|
|
34
28
|
bundles,
|
|
35
29
|
async (file) => {
|
|
36
30
|
const relative: string = path.join(
|
|
37
|
-
this.
|
|
31
|
+
this.config!.output!,
|
|
38
32
|
file,
|
|
39
33
|
);
|
|
40
34
|
const location: string = path.join(
|
|
@@ -55,14 +49,33 @@ export class NestiaSdkApplication {
|
|
|
55
49
|
return false;
|
|
56
50
|
};
|
|
57
51
|
});
|
|
52
|
+
|
|
53
|
+
public constructor(
|
|
54
|
+
private readonly config: INestiaConfig,
|
|
55
|
+
private readonly compilerOptions: ts.CompilerOptions,
|
|
56
|
+
) {}
|
|
57
|
+
|
|
58
|
+
private async is_not_excluded(file: string): Promise<boolean> {
|
|
59
|
+
if (this.config.output)
|
|
60
|
+
return (
|
|
61
|
+
file.indexOf(path.join(this.config.output, "functional")) ===
|
|
62
|
+
-1 && (await this.checker_.get())(file) === false
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const content: string = await fs.promises.readFile(file, "utf8");
|
|
66
|
+
return (
|
|
67
|
+
content.indexOf(
|
|
68
|
+
" * @nestia Generated by Nestia - https://github.com/samchon/nestia",
|
|
69
|
+
) === -1
|
|
70
|
+
);
|
|
58
71
|
}
|
|
59
72
|
|
|
60
73
|
public async e2e(): Promise<void> {
|
|
61
|
-
if (!this.
|
|
74
|
+
if (!this.config.output)
|
|
62
75
|
throw new Error(
|
|
63
76
|
"Error on NestiaApplication.e2e(): output path of SDK is not specified.",
|
|
64
77
|
);
|
|
65
|
-
else if (!this.
|
|
78
|
+
else if (!this.config.e2e)
|
|
66
79
|
throw new Error(
|
|
67
80
|
"Error on NestiaApplication.e2e(): output path of e2e test files is not specified.",
|
|
68
81
|
);
|
|
@@ -77,8 +90,8 @@ export class NestiaSdkApplication {
|
|
|
77
90
|
`Error on NestiaApplication.e2e(): output directory of ${title} does not exists.`,
|
|
78
91
|
);
|
|
79
92
|
};
|
|
80
|
-
await validate("sdk")(this.
|
|
81
|
-
await validate("e2e")(this.
|
|
93
|
+
await validate("sdk")(this.config.output);
|
|
94
|
+
await validate("e2e")(this.config.e2e);
|
|
82
95
|
|
|
83
96
|
title("Nestia E2E Generator");
|
|
84
97
|
await this.generate(
|
|
@@ -92,12 +105,12 @@ export class NestiaSdkApplication {
|
|
|
92
105
|
}
|
|
93
106
|
|
|
94
107
|
public async sdk(): Promise<void> {
|
|
95
|
-
if (!this.
|
|
108
|
+
if (!this.config.output)
|
|
96
109
|
throw new Error(
|
|
97
110
|
"Error on NestiaApplication.sdk(): output path is not specified.",
|
|
98
111
|
);
|
|
99
112
|
|
|
100
|
-
const parent: string = path.resolve(this.
|
|
113
|
+
const parent: string = path.resolve(this.config.output + "/..");
|
|
101
114
|
const stats: fs.Stats = await fs.promises.lstat(parent);
|
|
102
115
|
if (stats.isDirectory() === false)
|
|
103
116
|
throw new Error(
|
|
@@ -113,15 +126,15 @@ export class NestiaSdkApplication {
|
|
|
113
126
|
}
|
|
114
127
|
|
|
115
128
|
public async swagger(): Promise<void> {
|
|
116
|
-
if (!this.
|
|
129
|
+
if (!this.config.swagger?.output)
|
|
117
130
|
throw new Error(
|
|
118
131
|
`Error on NestiaApplication.swagger(): output path of the "swagger.json" is not specified.`,
|
|
119
132
|
);
|
|
120
133
|
|
|
121
|
-
const parsed: path.ParsedPath = path.parse(this.
|
|
134
|
+
const parsed: path.ParsedPath = path.parse(this.config.swagger.output);
|
|
122
135
|
const directory: string = !!parsed.ext
|
|
123
136
|
? path.resolve(parsed.dir)
|
|
124
|
-
: this.
|
|
137
|
+
: this.config.swagger.output;
|
|
125
138
|
const stats: fs.Stats = await fs.promises.lstat(directory);
|
|
126
139
|
if (stats.isDirectory() === false)
|
|
127
140
|
throw new Error(
|
|
@@ -143,12 +156,9 @@ export class NestiaSdkApplication {
|
|
|
143
156
|
checker: ts.TypeChecker,
|
|
144
157
|
) => (config: Config) => (routes: IRoute[]) => Promise<void>,
|
|
145
158
|
): Promise<void> {
|
|
146
|
-
// MOUNT TS-NODE
|
|
147
|
-
this.prepare(method);
|
|
148
|
-
|
|
149
159
|
// LOAD CONTROLLER FILES
|
|
150
160
|
const input: INestiaConfig.IInput = NestiaConfigUtil.input(
|
|
151
|
-
this.
|
|
161
|
+
this.config.input,
|
|
152
162
|
);
|
|
153
163
|
const fileList: string[] = await ArrayUtil.asyncFilter(
|
|
154
164
|
await SourceFinder.find({
|
|
@@ -197,7 +207,7 @@ export class NestiaSdkApplication {
|
|
|
197
207
|
console.log("Analyzing source codes");
|
|
198
208
|
const program: ts.Program = ts.createProgram(
|
|
199
209
|
controllers.map((c) => c.file),
|
|
200
|
-
this.
|
|
210
|
+
this.compilerOptions,
|
|
201
211
|
);
|
|
202
212
|
const checker: ts.TypeChecker = program.getTypeChecker();
|
|
203
213
|
|
|
@@ -224,59 +234,7 @@ export class NestiaSdkApplication {
|
|
|
224
234
|
|
|
225
235
|
// DO GENERATE
|
|
226
236
|
AccessorAnalyzer.analyze(routeList);
|
|
227
|
-
await archiver(checker)(config(this.
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
private prepare(method: string): void {
|
|
231
|
-
// CONSTRUCT OPTIONS
|
|
232
|
-
if (!this.config_.compilerOptions)
|
|
233
|
-
this.config_.compilerOptions =
|
|
234
|
-
NestiaConfigCompilerOptions.DEFAULT_OPTIONS as any;
|
|
235
|
-
const absoluted: boolean = !!this.config_.compilerOptions?.baseUrl;
|
|
236
|
-
|
|
237
|
-
// CHECK STRICT OPTION
|
|
238
|
-
const strict: boolean =
|
|
239
|
-
this.config_.compilerOptions?.strictNullChecks !== undefined
|
|
240
|
-
? !!this.config_.compilerOptions.strictNullChecks
|
|
241
|
-
: !!this.config_.compilerOptions?.strict;
|
|
242
|
-
if (strict === false)
|
|
243
|
-
throw new Error(
|
|
244
|
-
`Error on NestiaSdkApplication.${method}(): nestia requires \`compilerOptions.strictNullChecks\` to be true.`,
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
const ttsc: boolean =
|
|
248
|
-
ts.version < "5.0.0" &&
|
|
249
|
-
(() => {
|
|
250
|
-
try {
|
|
251
|
-
require.resolve("ttypescript");
|
|
252
|
-
return true;
|
|
253
|
-
} catch (e) {
|
|
254
|
-
return false;
|
|
255
|
-
}
|
|
256
|
-
})();
|
|
257
|
-
|
|
258
|
-
// MOUNT TS-NODE
|
|
259
|
-
runner.register({
|
|
260
|
-
emit: false,
|
|
261
|
-
compiler: ttsc ? "ttypescript" : undefined,
|
|
262
|
-
compilerOptions: this.config_.compilerOptions,
|
|
263
|
-
require: absoluted ? ["tsconfig-paths/register"] : undefined,
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
private async is_not_excluded(file: string): Promise<boolean> {
|
|
268
|
-
if (this.config_.output)
|
|
269
|
-
return (
|
|
270
|
-
file.indexOf(path.join(this.config_.output, "functional")) ===
|
|
271
|
-
-1 && (await this.bundle_checker_.get())(file) === false
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
const content: string = await fs.promises.readFile(file, "utf8");
|
|
275
|
-
return (
|
|
276
|
-
content.indexOf(
|
|
277
|
-
" * @nestia Generated by Nestia - https://github.com/samchon/nestia",
|
|
278
|
-
) === -1
|
|
279
|
-
);
|
|
237
|
+
await archiver(checker)(config(this.config))(routeList);
|
|
280
238
|
}
|
|
281
239
|
}
|
|
282
240
|
|
|
@@ -301,4 +259,5 @@ const is_implicit_return_typed = (route: IRoute): boolean => {
|
|
|
301
259
|
else if (VARIABLE.test(name[i])) return false;
|
|
302
260
|
return true;
|
|
303
261
|
};
|
|
262
|
+
|
|
304
263
|
const VARIABLE = /[a-zA-Z_$0-9]/;
|
|
@@ -192,7 +192,7 @@ export namespace ControllerAnalyzer {
|
|
|
192
192
|
})(),
|
|
193
193
|
description: CommentFactory.description(symbol),
|
|
194
194
|
operationId: tags
|
|
195
|
-
.find(({ name }) => name === "
|
|
195
|
+
.find(({ name }) => name === "operationId")
|
|
196
196
|
?.text!?.[0].text.split(" ")[0]
|
|
197
197
|
.trim(),
|
|
198
198
|
tags,
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { WorkerConnector } from "tgrid/protocols/workers/WorkerConnector";
|
|
4
|
+
import { register } from "ts-node";
|
|
5
|
+
import { parseNative } from "tsconfck";
|
|
6
|
+
import ts from "typescript";
|
|
7
|
+
|
|
8
|
+
import typia from "typia";
|
|
9
|
+
|
|
10
|
+
import { INestiaConfig } from "../../INestiaConfig";
|
|
11
|
+
import { NestiaProjectGetter } from "./NestiaProjectGetter";
|
|
12
|
+
|
|
13
|
+
export namespace NestiaConfigLoader {
|
|
14
|
+
export const compilerOptions = async (
|
|
15
|
+
project: string,
|
|
16
|
+
): Promise<ts.CompilerOptions> => {
|
|
17
|
+
const configFileName = ts.findConfigFile(
|
|
18
|
+
process.cwd(),
|
|
19
|
+
ts.sys.fileExists,
|
|
20
|
+
project,
|
|
21
|
+
);
|
|
22
|
+
if (!configFileName)
|
|
23
|
+
throw new Error(`unable to find "tsconfig.json" file.`);
|
|
24
|
+
|
|
25
|
+
const { tsconfig } = await parseNative(configFileName);
|
|
26
|
+
const configFileText = JSON.stringify(tsconfig);
|
|
27
|
+
const { config } = ts.parseConfigFileTextToJson(
|
|
28
|
+
configFileName,
|
|
29
|
+
configFileText,
|
|
30
|
+
);
|
|
31
|
+
const configParseResult = ts.parseJsonConfigFileContent(
|
|
32
|
+
config,
|
|
33
|
+
ts.sys,
|
|
34
|
+
path.dirname(configFileName),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const { moduleResolution, ...result } =
|
|
38
|
+
configParseResult.raw.compilerOptions;
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const config = async (
|
|
43
|
+
options: ts.CompilerOptions,
|
|
44
|
+
): Promise<INestiaConfig> => {
|
|
45
|
+
if (fs.existsSync(path.resolve("nestia.config.ts")) === false)
|
|
46
|
+
throw new Error(`unable to find "nestia.config.ts" file.`);
|
|
47
|
+
|
|
48
|
+
register({
|
|
49
|
+
emit: false,
|
|
50
|
+
compilerOptions: options,
|
|
51
|
+
require: options.baseUrl ? ["tsconfig-paths/register"] : undefined,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const loaded: INestiaConfig & { default?: INestiaConfig } =
|
|
55
|
+
await import(path.resolve("nestia.config.ts"));
|
|
56
|
+
const config: INestiaConfig =
|
|
57
|
+
typeof loaded?.default === "object" && loaded.default !== null
|
|
58
|
+
? loaded.default
|
|
59
|
+
: loaded;
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
return typia.assert(config);
|
|
63
|
+
} catch (exp) {
|
|
64
|
+
if (typia.is<typia.TypeGuardError>(exp))
|
|
65
|
+
exp.message = `invalid "nestia.config.ts" data.`;
|
|
66
|
+
throw exp;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const project = async (): Promise<string> => {
|
|
71
|
+
const connector = new WorkerConnector(null, null, "process");
|
|
72
|
+
await connector.connect(
|
|
73
|
+
`${__dirname}/nestia.project.getter.${__filename.substr(-2)}`,
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const driver = await connector.getDriver<typeof NestiaProjectGetter>();
|
|
77
|
+
const project: string = await driver.get();
|
|
78
|
+
await connector.close();
|
|
79
|
+
|
|
80
|
+
return project;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NestiaConfigLoader } from "./NestiaConfigLoader";
|
|
2
|
+
|
|
3
|
+
export namespace NestiaProjectGetter {
|
|
4
|
+
export async function get(): Promise<string> {
|
|
5
|
+
const config = await NestiaConfigLoader.config({
|
|
6
|
+
module: "CommonJS" as any,
|
|
7
|
+
noEmit: true,
|
|
8
|
+
});
|
|
9
|
+
return config.project ?? "tsconfig.json";
|
|
10
|
+
}
|
|
11
|
+
}
|