@nestia/sdk 2.4.3 → 2.4.4
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 +13 -0
- package/lib/analyses/ControllerAnalyzer.js +12 -1
- package/lib/analyses/ControllerAnalyzer.js.map +1 -1
- package/lib/analyses/PathAnalyzer.d.ts +2 -2
- package/lib/analyses/PathAnalyzer.js +27 -11
- package/lib/analyses/PathAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectAnalyzer.js +11 -2
- package/lib/analyses/ReflectAnalyzer.js.map +1 -1
- package/lib/executable/internal/NestiaConfigLoader.js +5 -1
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/executable/sdk.js +11 -11
- package/lib/generates/SwaggerGenerator.js +16 -22
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/SwaggerSchemaGenerator.js +22 -15
- package/lib/generates/internal/SwaggerSchemaGenerator.js.map +1 -1
- package/lib/structures/ISwaggerComponents.d.ts +1 -1
- package/lib/structures/ISwaggerRoute.d.ts +3 -3
- package/package.json +5 -5
- package/src/INestiaConfig.ts +248 -234
- package/src/NestiaSdkApplication.ts +253 -253
- package/src/analyses/AccessorAnalyzer.ts +60 -60
- package/src/analyses/ConfigAnalyzer.ts +147 -147
- package/src/analyses/ControllerAnalyzer.ts +390 -379
- package/src/analyses/ExceptionAnalyzer.ts +115 -115
- package/src/analyses/GenericAnalyzer.ts +51 -51
- package/src/analyses/ImportAnalyzer.ts +138 -138
- package/src/analyses/PathAnalyzer.ts +110 -98
- package/src/analyses/ReflectAnalyzer.ts +11 -6
- package/src/analyses/SecurityAnalyzer.ts +20 -20
- package/src/executable/internal/CommandParser.ts +15 -15
- package/src/executable/internal/NestiaConfigLoader.ts +67 -67
- package/src/executable/internal/NestiaSdkCommand.ts +60 -60
- package/src/executable/sdk.ts +73 -73
- package/src/generates/E2eGenerator.ts +64 -64
- package/src/generates/SdkGenerator.ts +96 -96
- package/src/generates/SwaggerGenerator.ts +376 -372
- package/src/generates/internal/E2eFileProgrammer.ts +123 -123
- package/src/generates/internal/SdkDistributionComposer.ts +91 -91
- package/src/generates/internal/SdkDtoGenerator.ts +424 -424
- package/src/generates/internal/SdkFileProgrammer.ts +106 -106
- package/src/generates/internal/SdkImportWizard.ts +55 -55
- package/src/generates/internal/SdkRouteDirectory.ts +17 -17
- package/src/generates/internal/SdkSimulationProgrammer.ts +133 -133
- package/src/generates/internal/SdkTypeDefiner.ts +119 -119
- package/src/generates/internal/SwaggerSchemaGenerator.ts +18 -2
- package/src/generates/internal/SwaggerSchemaValidator.ts +198 -198
- package/src/index.ts +4 -4
- package/src/module.ts +2 -2
- package/src/structures/IErrorReport.ts +6 -6
- package/src/structures/INestiaProject.ts +13 -13
- package/src/structures/INormalizedInput.ts +20 -20
- package/src/structures/ISwagger.ts +91 -91
- package/src/structures/ISwaggerComponents.ts +29 -29
- package/src/structures/ISwaggerError.ts +8 -8
- package/src/structures/ISwaggerInfo.ts +80 -80
- package/src/structures/ISwaggerLazyProperty.ts +7 -7
- package/src/structures/ISwaggerLazySchema.ts +7 -7
- package/src/structures/ISwaggerRoute.ts +51 -51
- package/src/structures/ISwaggerSecurityScheme.ts +65 -65
- package/src/structures/ITypeTuple.ts +6 -6
- package/src/structures/MethodType.ts +5 -5
- package/src/structures/ParamCategory.ts +1 -1
- package/src/structures/TypeEntry.ts +22 -22
- package/src/utils/ArrayUtil.ts +26 -26
- package/src/utils/FileRetriever.ts +22 -22
- package/src/utils/ImportDictionary.ts +125 -125
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/PathUtil.ts +10 -10
- package/src/utils/SourceFinder.ts +66 -66
- package/src/utils/StripEnums.ts +5 -5
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
|
|
3
|
-
import { INestiaConfig } from "../../INestiaConfig";
|
|
4
|
-
import { IRoute } from "../../structures/IRoute";
|
|
5
|
-
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
6
|
-
import { SdkDtoGenerator } from "./SdkDtoGenerator";
|
|
7
|
-
import { SdkImportWizard } from "./SdkImportWizard";
|
|
8
|
-
import { SdkTypeDefiner } from "./SdkTypeDefiner";
|
|
9
|
-
|
|
10
|
-
export namespace E2eFileProgrammer {
|
|
11
|
-
export const generate =
|
|
12
|
-
(config: INestiaConfig) =>
|
|
13
|
-
(props: { api: string; current: string }) =>
|
|
14
|
-
async (route: IRoute): Promise<void> => {
|
|
15
|
-
const importer: ImportDictionary = new ImportDictionary(
|
|
16
|
-
`${props.current}/${name(route)}.ts`,
|
|
17
|
-
);
|
|
18
|
-
if (config.clone !== true)
|
|
19
|
-
for (const tuple of route.imports)
|
|
20
|
-
for (const instance of tuple[1])
|
|
21
|
-
importer.internal({
|
|
22
|
-
file: tuple[0],
|
|
23
|
-
type: true,
|
|
24
|
-
instance,
|
|
25
|
-
});
|
|
26
|
-
importer.internal({
|
|
27
|
-
type: false,
|
|
28
|
-
file: props.api,
|
|
29
|
-
instance: null,
|
|
30
|
-
name: "api",
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const body: string = arrow(config)(importer)(route);
|
|
34
|
-
const content: string = [importer.toScript(props.current), "", body].join(
|
|
35
|
-
"\n",
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
await fs.promises.writeFile(importer.file, content, "utf8");
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const arrow =
|
|
42
|
-
(config: INestiaConfig) =>
|
|
43
|
-
(importer: ImportDictionary) =>
|
|
44
|
-
(route: IRoute): string => {
|
|
45
|
-
const tab: number = 2;
|
|
46
|
-
const headers = route.parameters.find(
|
|
47
|
-
(p) => p.category === "headers" && p.field === undefined,
|
|
48
|
-
);
|
|
49
|
-
const output = [
|
|
50
|
-
`await ${accessor(route)}(`,
|
|
51
|
-
headers !== undefined
|
|
52
|
-
? [
|
|
53
|
-
"{",
|
|
54
|
-
" ...connection,",
|
|
55
|
-
" headers: {",
|
|
56
|
-
" ...(connection.headers ?? {}),",
|
|
57
|
-
` ...${SdkImportWizard.typia(
|
|
58
|
-
importer,
|
|
59
|
-
)}.random<${getTypeName(config)(importer)(headers)}>(),`,
|
|
60
|
-
" },",
|
|
61
|
-
"},",
|
|
62
|
-
]
|
|
63
|
-
.map((line) => `${" ".repeat(tab * 4)}${line}`)
|
|
64
|
-
.join("\n")
|
|
65
|
-
: `${" ".repeat(tab * 4)}connection,`,
|
|
66
|
-
...route.parameters
|
|
67
|
-
.filter((param) => param.category !== "headers")
|
|
68
|
-
.map(parameter(config)(importer)(tab)),
|
|
69
|
-
`${" ".repeat((tab - 1) * 4)});`,
|
|
70
|
-
].join("\n");
|
|
71
|
-
return [
|
|
72
|
-
`export const ${name(route)} = async (`,
|
|
73
|
-
` connection: api.IConnection`,
|
|
74
|
-
`): Promise<void> => {`,
|
|
75
|
-
...(route.output.typeName === "void"
|
|
76
|
-
? [` ${output}`]
|
|
77
|
-
: [
|
|
78
|
-
` const output: ${SdkTypeDefiner.output(config)(importer)(
|
|
79
|
-
route,
|
|
80
|
-
)} = ${output}`,
|
|
81
|
-
` ${SdkImportWizard.typia(importer)}.assert(output);`,
|
|
82
|
-
]),
|
|
83
|
-
`};`,
|
|
84
|
-
].join("\n");
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const parameter =
|
|
88
|
-
(config: INestiaConfig) =>
|
|
89
|
-
(importer: ImportDictionary) =>
|
|
90
|
-
(tab: number) =>
|
|
91
|
-
(param: IRoute.IParameter): string => {
|
|
92
|
-
const middle: string = `${SdkImportWizard.typia(importer)}.random<${wrap(
|
|
93
|
-
config,
|
|
94
|
-
)(importer)(
|
|
95
|
-
getTypeName(config)(importer)(param),
|
|
96
|
-
param.category === "body",
|
|
97
|
-
)}>()`;
|
|
98
|
-
return `${" ".repeat(4 * tab)}${middle},`;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const name = (route: IRoute): string =>
|
|
102
|
-
["test", "api", ...route.accessors].join("_");
|
|
103
|
-
|
|
104
|
-
const accessor = (route: IRoute): string =>
|
|
105
|
-
["api", "functional", ...route.accessors].join(".");
|
|
106
|
-
|
|
107
|
-
const wrap =
|
|
108
|
-
(config: INestiaConfig) =>
|
|
109
|
-
(importer: ImportDictionary) =>
|
|
110
|
-
(name: string, body: boolean): string =>
|
|
111
|
-
config.primitive === false
|
|
112
|
-
? name
|
|
113
|
-
: `${(body ? SdkImportWizard.Primitive : SdkImportWizard.Resolved)(
|
|
114
|
-
importer,
|
|
115
|
-
)}<${name}>`;
|
|
116
|
-
}
|
|
117
|
-
const getTypeName =
|
|
118
|
-
(config: INestiaConfig) =>
|
|
119
|
-
(importer: ImportDictionary) =>
|
|
120
|
-
(p: IRoute.IParameter | IRoute.IOutput) =>
|
|
121
|
-
p.metadata
|
|
122
|
-
? SdkDtoGenerator.decode(config)(importer)(p.metadata)
|
|
123
|
-
: p.typeName;
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
import { INestiaConfig } from "../../INestiaConfig";
|
|
4
|
+
import { IRoute } from "../../structures/IRoute";
|
|
5
|
+
import { ImportDictionary } from "../../utils/ImportDictionary";
|
|
6
|
+
import { SdkDtoGenerator } from "./SdkDtoGenerator";
|
|
7
|
+
import { SdkImportWizard } from "./SdkImportWizard";
|
|
8
|
+
import { SdkTypeDefiner } from "./SdkTypeDefiner";
|
|
9
|
+
|
|
10
|
+
export namespace E2eFileProgrammer {
|
|
11
|
+
export const generate =
|
|
12
|
+
(config: INestiaConfig) =>
|
|
13
|
+
(props: { api: string; current: string }) =>
|
|
14
|
+
async (route: IRoute): Promise<void> => {
|
|
15
|
+
const importer: ImportDictionary = new ImportDictionary(
|
|
16
|
+
`${props.current}/${name(route)}.ts`,
|
|
17
|
+
);
|
|
18
|
+
if (config.clone !== true)
|
|
19
|
+
for (const tuple of route.imports)
|
|
20
|
+
for (const instance of tuple[1])
|
|
21
|
+
importer.internal({
|
|
22
|
+
file: tuple[0],
|
|
23
|
+
type: true,
|
|
24
|
+
instance,
|
|
25
|
+
});
|
|
26
|
+
importer.internal({
|
|
27
|
+
type: false,
|
|
28
|
+
file: props.api,
|
|
29
|
+
instance: null,
|
|
30
|
+
name: "api",
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const body: string = arrow(config)(importer)(route);
|
|
34
|
+
const content: string = [importer.toScript(props.current), "", body].join(
|
|
35
|
+
"\n",
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
await fs.promises.writeFile(importer.file, content, "utf8");
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const arrow =
|
|
42
|
+
(config: INestiaConfig) =>
|
|
43
|
+
(importer: ImportDictionary) =>
|
|
44
|
+
(route: IRoute): string => {
|
|
45
|
+
const tab: number = 2;
|
|
46
|
+
const headers = route.parameters.find(
|
|
47
|
+
(p) => p.category === "headers" && p.field === undefined,
|
|
48
|
+
);
|
|
49
|
+
const output = [
|
|
50
|
+
`await ${accessor(route)}(`,
|
|
51
|
+
headers !== undefined
|
|
52
|
+
? [
|
|
53
|
+
"{",
|
|
54
|
+
" ...connection,",
|
|
55
|
+
" headers: {",
|
|
56
|
+
" ...(connection.headers ?? {}),",
|
|
57
|
+
` ...${SdkImportWizard.typia(
|
|
58
|
+
importer,
|
|
59
|
+
)}.random<${getTypeName(config)(importer)(headers)}>(),`,
|
|
60
|
+
" },",
|
|
61
|
+
"},",
|
|
62
|
+
]
|
|
63
|
+
.map((line) => `${" ".repeat(tab * 4)}${line}`)
|
|
64
|
+
.join("\n")
|
|
65
|
+
: `${" ".repeat(tab * 4)}connection,`,
|
|
66
|
+
...route.parameters
|
|
67
|
+
.filter((param) => param.category !== "headers")
|
|
68
|
+
.map(parameter(config)(importer)(tab)),
|
|
69
|
+
`${" ".repeat((tab - 1) * 4)});`,
|
|
70
|
+
].join("\n");
|
|
71
|
+
return [
|
|
72
|
+
`export const ${name(route)} = async (`,
|
|
73
|
+
` connection: api.IConnection`,
|
|
74
|
+
`): Promise<void> => {`,
|
|
75
|
+
...(route.output.typeName === "void"
|
|
76
|
+
? [` ${output}`]
|
|
77
|
+
: [
|
|
78
|
+
` const output: ${SdkTypeDefiner.output(config)(importer)(
|
|
79
|
+
route,
|
|
80
|
+
)} = ${output}`,
|
|
81
|
+
` ${SdkImportWizard.typia(importer)}.assert(output);`,
|
|
82
|
+
]),
|
|
83
|
+
`};`,
|
|
84
|
+
].join("\n");
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const parameter =
|
|
88
|
+
(config: INestiaConfig) =>
|
|
89
|
+
(importer: ImportDictionary) =>
|
|
90
|
+
(tab: number) =>
|
|
91
|
+
(param: IRoute.IParameter): string => {
|
|
92
|
+
const middle: string = `${SdkImportWizard.typia(importer)}.random<${wrap(
|
|
93
|
+
config,
|
|
94
|
+
)(importer)(
|
|
95
|
+
getTypeName(config)(importer)(param),
|
|
96
|
+
param.category === "body",
|
|
97
|
+
)}>()`;
|
|
98
|
+
return `${" ".repeat(4 * tab)}${middle},`;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const name = (route: IRoute): string =>
|
|
102
|
+
["test", "api", ...route.accessors].join("_");
|
|
103
|
+
|
|
104
|
+
const accessor = (route: IRoute): string =>
|
|
105
|
+
["api", "functional", ...route.accessors].join(".");
|
|
106
|
+
|
|
107
|
+
const wrap =
|
|
108
|
+
(config: INestiaConfig) =>
|
|
109
|
+
(importer: ImportDictionary) =>
|
|
110
|
+
(name: string, body: boolean): string =>
|
|
111
|
+
config.primitive === false
|
|
112
|
+
? name
|
|
113
|
+
: `${(body ? SdkImportWizard.Primitive : SdkImportWizard.Resolved)(
|
|
114
|
+
importer,
|
|
115
|
+
)}<${name}>`;
|
|
116
|
+
}
|
|
117
|
+
const getTypeName =
|
|
118
|
+
(config: INestiaConfig) =>
|
|
119
|
+
(importer: ImportDictionary) =>
|
|
120
|
+
(p: IRoute.IParameter | IRoute.IOutput) =>
|
|
121
|
+
p.metadata
|
|
122
|
+
? SdkDtoGenerator.decode(config)(importer)(p.metadata)
|
|
123
|
+
: p.typeName;
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import cp from "child_process";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
import { INestiaConfig } from "../../INestiaConfig";
|
|
6
|
-
|
|
7
|
-
export namespace SdkDistributionComposer {
|
|
8
|
-
export const compose = async (config: INestiaConfig) => {
|
|
9
|
-
if (!fs.existsSync(config.distribute!))
|
|
10
|
-
await fs.promises.mkdir(config.distribute!);
|
|
11
|
-
|
|
12
|
-
const root: string = process.cwd();
|
|
13
|
-
const output: string = path.resolve(config.output!);
|
|
14
|
-
process.chdir(config.distribute!);
|
|
15
|
-
|
|
16
|
-
const exit = () => process.chdir(root);
|
|
17
|
-
if (await configured()) return exit();
|
|
18
|
-
|
|
19
|
-
// COPY FILES
|
|
20
|
-
console.log("Composing SDK distribution environments...");
|
|
21
|
-
for (const file of await fs.promises.readdir(BUNDLE))
|
|
22
|
-
await fs.promises.copyFile(`${BUNDLE}/${file}`, file);
|
|
23
|
-
|
|
24
|
-
// CONFIGURE PATHS
|
|
25
|
-
for (const file of ["package.json", "tsconfig.json"])
|
|
26
|
-
await replace({ root, output })(file);
|
|
27
|
-
|
|
28
|
-
// INSTALL PACKAGES
|
|
29
|
-
const versions: IDependencies = await dependencies();
|
|
30
|
-
execute("npm install --save-dev rimraf");
|
|
31
|
-
execute(
|
|
32
|
-
`npm install --save @nestia/fetcher@${versions["@nestia/fetcher"]}`,
|
|
33
|
-
);
|
|
34
|
-
execute(`npm install --save typia@${versions["typia"]}`);
|
|
35
|
-
execute("npx typia setup --manager npm");
|
|
36
|
-
|
|
37
|
-
exit();
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const configured = async (): Promise<boolean> =>
|
|
41
|
-
["package.json", "tsconfig.json"].every(fs.existsSync) &&
|
|
42
|
-
(await (async () => {
|
|
43
|
-
const content = JSON.parse(
|
|
44
|
-
await fs.promises.readFile("package.json", "utf8"),
|
|
45
|
-
);
|
|
46
|
-
return !!content.dependencies?.["@nestia/fetcher"];
|
|
47
|
-
})());
|
|
48
|
-
|
|
49
|
-
const execute = (command: string) => {
|
|
50
|
-
console.log(` - ${command}`);
|
|
51
|
-
cp.execSync(command, { stdio: "ignore" });
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const replace =
|
|
55
|
-
(props: { root: string; output: string }) =>
|
|
56
|
-
async (file: string): Promise<void> => {
|
|
57
|
-
const relative = (from: string) => (to: string) =>
|
|
58
|
-
path.relative(from, to).split("\\").join("/");
|
|
59
|
-
const root: string = relative(process.cwd())(props.root);
|
|
60
|
-
const output: string = relative(process.cwd())(props.output);
|
|
61
|
-
const current: string = relative(props.root)(process.cwd());
|
|
62
|
-
|
|
63
|
-
const content: string = await fs.promises.readFile(file, "utf8");
|
|
64
|
-
await fs.promises.writeFile(
|
|
65
|
-
file,
|
|
66
|
-
content
|
|
67
|
-
.split("${root}")
|
|
68
|
-
.join(root)
|
|
69
|
-
.split("${output}")
|
|
70
|
-
.join(output)
|
|
71
|
-
.split("${current}")
|
|
72
|
-
.join(current),
|
|
73
|
-
"utf8",
|
|
74
|
-
);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const dependencies = async () => {
|
|
78
|
-
const content: string = await fs.promises.readFile(
|
|
79
|
-
__dirname + "/../../../package.json",
|
|
80
|
-
"utf8",
|
|
81
|
-
);
|
|
82
|
-
const json: { dependencies: IDependencies } = JSON.parse(content);
|
|
83
|
-
return json.dependencies;
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
interface IDependencies {
|
|
88
|
-
"@nestia/fetcher": string;
|
|
89
|
-
typia: string;
|
|
90
|
-
}
|
|
91
|
-
const BUNDLE = __dirname + "/../../../assets/bundle/distribute";
|
|
1
|
+
import cp from "child_process";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
import { INestiaConfig } from "../../INestiaConfig";
|
|
6
|
+
|
|
7
|
+
export namespace SdkDistributionComposer {
|
|
8
|
+
export const compose = async (config: INestiaConfig) => {
|
|
9
|
+
if (!fs.existsSync(config.distribute!))
|
|
10
|
+
await fs.promises.mkdir(config.distribute!);
|
|
11
|
+
|
|
12
|
+
const root: string = process.cwd();
|
|
13
|
+
const output: string = path.resolve(config.output!);
|
|
14
|
+
process.chdir(config.distribute!);
|
|
15
|
+
|
|
16
|
+
const exit = () => process.chdir(root);
|
|
17
|
+
if (await configured()) return exit();
|
|
18
|
+
|
|
19
|
+
// COPY FILES
|
|
20
|
+
console.log("Composing SDK distribution environments...");
|
|
21
|
+
for (const file of await fs.promises.readdir(BUNDLE))
|
|
22
|
+
await fs.promises.copyFile(`${BUNDLE}/${file}`, file);
|
|
23
|
+
|
|
24
|
+
// CONFIGURE PATHS
|
|
25
|
+
for (const file of ["package.json", "tsconfig.json"])
|
|
26
|
+
await replace({ root, output })(file);
|
|
27
|
+
|
|
28
|
+
// INSTALL PACKAGES
|
|
29
|
+
const versions: IDependencies = await dependencies();
|
|
30
|
+
execute("npm install --save-dev rimraf");
|
|
31
|
+
execute(
|
|
32
|
+
`npm install --save @nestia/fetcher@${versions["@nestia/fetcher"]}`,
|
|
33
|
+
);
|
|
34
|
+
execute(`npm install --save typia@${versions["typia"]}`);
|
|
35
|
+
execute("npx typia setup --manager npm");
|
|
36
|
+
|
|
37
|
+
exit();
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const configured = async (): Promise<boolean> =>
|
|
41
|
+
["package.json", "tsconfig.json"].every(fs.existsSync) &&
|
|
42
|
+
(await (async () => {
|
|
43
|
+
const content = JSON.parse(
|
|
44
|
+
await fs.promises.readFile("package.json", "utf8"),
|
|
45
|
+
);
|
|
46
|
+
return !!content.dependencies?.["@nestia/fetcher"];
|
|
47
|
+
})());
|
|
48
|
+
|
|
49
|
+
const execute = (command: string) => {
|
|
50
|
+
console.log(` - ${command}`);
|
|
51
|
+
cp.execSync(command, { stdio: "ignore" });
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const replace =
|
|
55
|
+
(props: { root: string; output: string }) =>
|
|
56
|
+
async (file: string): Promise<void> => {
|
|
57
|
+
const relative = (from: string) => (to: string) =>
|
|
58
|
+
path.relative(from, to).split("\\").join("/");
|
|
59
|
+
const root: string = relative(process.cwd())(props.root);
|
|
60
|
+
const output: string = relative(process.cwd())(props.output);
|
|
61
|
+
const current: string = relative(props.root)(process.cwd());
|
|
62
|
+
|
|
63
|
+
const content: string = await fs.promises.readFile(file, "utf8");
|
|
64
|
+
await fs.promises.writeFile(
|
|
65
|
+
file,
|
|
66
|
+
content
|
|
67
|
+
.split("${root}")
|
|
68
|
+
.join(root)
|
|
69
|
+
.split("${output}")
|
|
70
|
+
.join(output)
|
|
71
|
+
.split("${current}")
|
|
72
|
+
.join(current),
|
|
73
|
+
"utf8",
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const dependencies = async () => {
|
|
78
|
+
const content: string = await fs.promises.readFile(
|
|
79
|
+
__dirname + "/../../../package.json",
|
|
80
|
+
"utf8",
|
|
81
|
+
);
|
|
82
|
+
const json: { dependencies: IDependencies } = JSON.parse(content);
|
|
83
|
+
return json.dependencies;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface IDependencies {
|
|
88
|
+
"@nestia/fetcher": string;
|
|
89
|
+
typia: string;
|
|
90
|
+
}
|
|
91
|
+
const BUNDLE = __dirname + "/../../../assets/bundle/distribute";
|