@nestia/migrate 0.5.1 → 0.6.1
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/{NestiaMigrateApplication.d.ts → MigrateApplication.d.ts} +1 -1
- package/lib/{NestiaMigrateApplication.js → MigrateApplication.js} +38 -32
- package/lib/MigrateApplication.js.map +1 -0
- package/lib/analyzers/ControllerAnalyzer.d.ts +5 -0
- package/lib/{programmers/ControllerProgrammer.js → analyzers/ControllerAnalyzer.js} +8 -32
- package/lib/analyzers/ControllerAnalyzer.js.map +1 -0
- package/lib/analyzers/MethodAnalyzer.d.ts +9 -0
- package/lib/{programmers/RouteProgrammer.js → analyzers/MethodAnalyzer.js} +30 -134
- package/lib/analyzers/MethodAnalyzer.js.map +1 -0
- package/lib/analyzers/MigrateAnalyzer.d.ts +4 -0
- package/lib/analyzers/MigrateAnalyzer.js +12 -0
- package/lib/analyzers/MigrateAnalyzer.js.map +1 -0
- package/lib/analyzers/RouteAnalyzer.d.ts +0 -0
- package/lib/analyzers/RouteAnalyzer.js +2 -0
- package/lib/analyzers/RouteAnalyzer.js.map +1 -0
- package/lib/archivers/FileArchiver.js.map +1 -1
- package/lib/bundles/TEMPLATE.js +10 -10
- package/lib/bundles/TEMPLATE.js.map +1 -1
- package/lib/executable/bundle.js.map +1 -1
- package/lib/executable/migrate.js +7 -7
- package/lib/executable/migrate.js.map +1 -1
- package/lib/module.d.ts +1 -1
- package/lib/module.js +1 -1
- package/lib/module.js.map +1 -1
- package/lib/programmers/DtoProgrammer.d.ts +8 -4
- package/lib/programmers/DtoProgrammer.js +36 -77
- package/lib/programmers/DtoProgrammer.js.map +1 -1
- package/lib/programmers/ImportProgrammer.d.ts +5 -5
- package/lib/programmers/ImportProgrammer.js +27 -19
- package/lib/programmers/ImportProgrammer.js.map +1 -1
- package/lib/programmers/{ControllerProgrammer.d.ts → NestControllerProgrammer.d.ts} +3 -4
- package/lib/programmers/NestControllerProgrammer.js +30 -0
- package/lib/programmers/NestControllerProgrammer.js.map +1 -0
- package/lib/programmers/NestMethodProgrammer.d.ts +7 -0
- package/lib/programmers/NestMethodProgrammer.js +103 -0
- package/lib/programmers/NestMethodProgrammer.js.map +1 -0
- package/lib/programmers/NestModuleProgrammer.d.ts +5 -0
- package/lib/programmers/NestModuleProgrammer.js +29 -0
- package/lib/programmers/NestModuleProgrammer.js.map +1 -0
- package/lib/programmers/NestProgrammer.d.ts +5 -0
- package/lib/programmers/NestProgrammer.js +60 -0
- package/lib/programmers/NestProgrammer.js.map +1 -0
- package/lib/programmers/SchemaProgrammer.d.ts +2 -1
- package/lib/programmers/SchemaProgrammer.js +122 -189
- package/lib/programmers/SchemaProgrammer.js.map +1 -1
- package/lib/structures/IMigrateProgram.d.ts +2 -2
- package/lib/structures/ISwaggerInfo.d.ts +3 -3
- package/lib/utils/FilePrinter.d.ts +9 -0
- package/lib/utils/FilePrinter.js +25 -0
- package/lib/utils/FilePrinter.js.map +1 -0
- package/lib/utils/JsonTypeChecker.d.ts +3 -1
- package/lib/utils/JsonTypeChecker.js +31 -18
- package/lib/utils/JsonTypeChecker.js.map +1 -1
- package/lib/utils/MapUtil.js.map +1 -1
- package/lib/utils/SetupWizard.js.map +1 -1
- package/lib/utils/StringUtil.js.map +1 -1
- package/package.json +8 -6
- package/src/MigrateApplication.ts +73 -0
- package/src/analyzers/ControllerAnalyzer.ts +107 -0
- package/src/analyzers/MethodAnalyzer.ts +315 -0
- package/src/analyzers/MigrateAnalyzer.ts +9 -0
- package/src/analyzers/RouteAnalyzer.ts +0 -0
- package/src/archivers/FileArchiver.ts +35 -38
- package/src/bundles/TEMPLATE.ts +10 -10
- package/src/executable/bundle.ts +72 -78
- package/src/executable/migrate.ts +59 -60
- package/src/index.ts +4 -4
- package/src/module.ts +4 -4
- package/src/programmers/DtoProgrammer.ts +74 -118
- package/src/programmers/ImportProgrammer.ts +98 -60
- package/src/programmers/NestControllerProgrammer.ts +47 -0
- package/src/programmers/NestMethodProgrammer.ts +211 -0
- package/src/programmers/NestModuleProgrammer.ts +62 -0
- package/src/programmers/NestProgrammer.ts +74 -0
- package/src/programmers/SchemaProgrammer.ts +247 -339
- package/src/structures/IMigrateController.ts +8 -8
- package/src/structures/IMigrateDto.ts +8 -8
- package/src/structures/IMigrateFile.ts +5 -5
- package/src/structures/IMigrateProgram.ts +7 -7
- package/src/structures/IMigrateRoute.ts +36 -36
- package/src/structures/IMigrateSchema.ts +4 -4
- package/src/structures/ISwaggeSchema.ts +82 -82
- package/src/structures/ISwagger.ts +20 -20
- package/src/structures/ISwaggerComponents.ts +7 -7
- package/src/structures/ISwaggerInfo.ts +57 -57
- package/src/structures/ISwaggerRoute.ts +52 -52
- package/src/structures/ISwaggerSecurity.ts +47 -47
- package/src/utils/FilePrinter.ts +36 -0
- package/src/utils/JsonTypeChecker.ts +67 -52
- package/src/utils/MapUtil.ts +13 -13
- package/src/utils/SetupWizard.ts +15 -15
- package/src/utils/StringUtil.ts +51 -51
- package/lib/NestiaMigrateApplication.js.map +0 -1
- package/lib/programmers/ControllerProgrammer.js.map +0 -1
- package/lib/programmers/MigrateProgrammer.d.ts +0 -8
- package/lib/programmers/MigrateProgrammer.js +0 -48
- package/lib/programmers/MigrateProgrammer.js.map +0 -1
- package/lib/programmers/RouteProgrammer.d.ts +0 -13
- package/lib/programmers/RouteProgrammer.js.map +0 -1
- package/src/NestiaMigrateApplication.ts +0 -73
- package/src/programmers/ControllerProgrammer.ts +0 -157
- package/src/programmers/MigrateProgrammer.ts +0 -62
- package/src/programmers/RouteProgrammer.ts +0 -506
@@ -0,0 +1,47 @@
|
|
1
|
+
import ts from "typescript";
|
2
|
+
|
3
|
+
import { IMigrateController } from "../structures/IMigrateController";
|
4
|
+
import { ISwaggerComponents } from "../structures/ISwaggerComponents";
|
5
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
6
|
+
import { StringUtil } from "../utils/StringUtil";
|
7
|
+
import { ImportProgrammer } from "./ImportProgrammer";
|
8
|
+
import { NestMethodProgrammer } from "./NestMethodProgrammer";
|
9
|
+
|
10
|
+
export namespace NestControllerProgrammer {
|
11
|
+
export const write =
|
12
|
+
(components: ISwaggerComponents) =>
|
13
|
+
(controller: IMigrateController): ts.Statement[] => {
|
14
|
+
const importer: ImportProgrammer = new ImportProgrammer();
|
15
|
+
const $class = ts.factory.createClassDeclaration(
|
16
|
+
[
|
17
|
+
ts.factory.createDecorator(
|
18
|
+
ts.factory.createCallExpression(
|
19
|
+
ts.factory.createIdentifier(
|
20
|
+
importer.external({
|
21
|
+
library: "@nestjs/common",
|
22
|
+
instance: "Controller",
|
23
|
+
}),
|
24
|
+
),
|
25
|
+
[],
|
26
|
+
[ts.factory.createStringLiteral(controller.path)],
|
27
|
+
),
|
28
|
+
),
|
29
|
+
ts.factory.createToken(ts.SyntaxKind.ExportKeyword),
|
30
|
+
],
|
31
|
+
controller.name,
|
32
|
+
[],
|
33
|
+
[],
|
34
|
+
controller.routes.map(NestMethodProgrammer.write(components)(importer)),
|
35
|
+
);
|
36
|
+
return [
|
37
|
+
...importer.toStatements(
|
38
|
+
(ref) =>
|
39
|
+
`${"../".repeat(
|
40
|
+
StringUtil.splitWithNormalization(controller.location).length - 1,
|
41
|
+
)}api/structures/${ref}`,
|
42
|
+
),
|
43
|
+
...(importer.empty() ? [] : [FilePrinter.enter()]),
|
44
|
+
$class,
|
45
|
+
];
|
46
|
+
};
|
47
|
+
}
|
@@ -0,0 +1,211 @@
|
|
1
|
+
import ts from "typescript";
|
2
|
+
import { ExpressionFactory } from "typia/lib/factories/ExpressionFactory";
|
3
|
+
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
4
|
+
import { TypeFactory } from "typia/lib/factories/TypeFactory";
|
5
|
+
|
6
|
+
import { IMigrateRoute } from "../structures/IMigrateRoute";
|
7
|
+
import { ISwaggerSchema } from "../structures/ISwaggeSchema";
|
8
|
+
import { ISwaggerComponents } from "../structures/ISwaggerComponents";
|
9
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
10
|
+
import { StringUtil } from "../utils/StringUtil";
|
11
|
+
import { ImportProgrammer } from "./ImportProgrammer";
|
12
|
+
import { SchemaProgrammer } from "./SchemaProgrammer";
|
13
|
+
|
14
|
+
export namespace NestMethodProgrammer {
|
15
|
+
export const write =
|
16
|
+
(components: ISwaggerComponents) =>
|
17
|
+
(importer: ImportProgrammer) =>
|
18
|
+
(route: IMigrateRoute): ts.MethodDeclaration => {
|
19
|
+
const output: ts.TypeNode = route.success
|
20
|
+
? SchemaProgrammer.write(importer)(components)(route.success.schema)
|
21
|
+
: TypeFactory.keyword("void");
|
22
|
+
|
23
|
+
const method: ts.MethodDeclaration = ts.factory.createMethodDeclaration(
|
24
|
+
[
|
25
|
+
...writeMethodDecorators(components)(importer)(route),
|
26
|
+
ts.factory.createToken(ts.SyntaxKind.PublicKeyword),
|
27
|
+
ts.factory.createToken(ts.SyntaxKind.AsyncKeyword),
|
28
|
+
],
|
29
|
+
undefined,
|
30
|
+
route.name,
|
31
|
+
undefined,
|
32
|
+
undefined,
|
33
|
+
writeParameters(importer)(components)(route),
|
34
|
+
ts.factory.createTypeReferenceNode("Promise", [output]),
|
35
|
+
ts.factory.createBlock(
|
36
|
+
[
|
37
|
+
...[
|
38
|
+
...route.parameters.map((p) => StringUtil.normalize(p.key)),
|
39
|
+
...(route.headers ? ["headers"] : []),
|
40
|
+
...(route.query ? ["query"] : []),
|
41
|
+
...(route.body ? ["body"] : []),
|
42
|
+
].map((str) =>
|
43
|
+
ts.factory.createExpressionStatement(
|
44
|
+
ts.factory.createIdentifier(str),
|
45
|
+
),
|
46
|
+
),
|
47
|
+
ts.factory.createReturnStatement(
|
48
|
+
ts.factory.createCallExpression(
|
49
|
+
ts.factory.createIdentifier(
|
50
|
+
importer.external({
|
51
|
+
library: "typia",
|
52
|
+
instance: "random",
|
53
|
+
}),
|
54
|
+
),
|
55
|
+
[output],
|
56
|
+
undefined,
|
57
|
+
),
|
58
|
+
),
|
59
|
+
],
|
60
|
+
true,
|
61
|
+
),
|
62
|
+
);
|
63
|
+
return FilePrinter.description(method, route.description ?? "");
|
64
|
+
};
|
65
|
+
|
66
|
+
const writeMethodDecorators =
|
67
|
+
(components: ISwaggerComponents) =>
|
68
|
+
(importer: ImportProgrammer) =>
|
69
|
+
(route: IMigrateRoute): ts.Decorator[] => {
|
70
|
+
const external =
|
71
|
+
(lib: string) =>
|
72
|
+
(instance: string): ts.Identifier =>
|
73
|
+
ts.factory.createIdentifier(
|
74
|
+
importer.external({ library: lib, instance }),
|
75
|
+
);
|
76
|
+
const router = (instance: string) =>
|
77
|
+
ts.factory.createDecorator(
|
78
|
+
ts.factory.createCallExpression(
|
79
|
+
IdentifierFactory.access(external("@nestia/core")(instance))(
|
80
|
+
StringUtil.capitalize(route.method),
|
81
|
+
),
|
82
|
+
[],
|
83
|
+
[ts.factory.createStringLiteral(route.path)],
|
84
|
+
),
|
85
|
+
);
|
86
|
+
|
87
|
+
const decorators: ts.Decorator[] = [];
|
88
|
+
if (route.success?.["x-nestia-encrypted"])
|
89
|
+
decorators.push(router("EncryptedRoute"));
|
90
|
+
else if (route.success?.type === "text/plain")
|
91
|
+
decorators.push(
|
92
|
+
ts.factory.createDecorator(
|
93
|
+
ts.factory.createCallExpression(
|
94
|
+
external("@nestjs/common")(StringUtil.capitalize(route.method)),
|
95
|
+
[],
|
96
|
+
[ts.factory.createStringLiteral(route.path)],
|
97
|
+
),
|
98
|
+
),
|
99
|
+
);
|
100
|
+
else if (route.success?.type === "application/x-www-form-urlencoded")
|
101
|
+
decorators.push(router("TypedQuery"));
|
102
|
+
else if (route.success?.type === "application/json")
|
103
|
+
decorators.push(router("TypedRoute"));
|
104
|
+
else if (route.method === "head")
|
105
|
+
decorators.push(
|
106
|
+
ts.factory.createDecorator(
|
107
|
+
ts.factory.createCallExpression(
|
108
|
+
external("@nestjs/common")("Head"),
|
109
|
+
[],
|
110
|
+
[ts.factory.createStringLiteral(route.path)],
|
111
|
+
),
|
112
|
+
),
|
113
|
+
);
|
114
|
+
for (const [key, value] of Object.entries(route.exceptions ?? {}))
|
115
|
+
decorators.push(
|
116
|
+
ts.factory.createDecorator(
|
117
|
+
ts.factory.createCallExpression(
|
118
|
+
external("@nestia/core")("TypedException"),
|
119
|
+
[SchemaProgrammer.write(importer)(components)(value.schema)],
|
120
|
+
[
|
121
|
+
isNaN(Number(key))
|
122
|
+
? ts.factory.createStringLiteral(key)
|
123
|
+
: ExpressionFactory.number(Number(key)),
|
124
|
+
...(value.description?.length
|
125
|
+
? [ts.factory.createStringLiteral(value.description)]
|
126
|
+
: []),
|
127
|
+
],
|
128
|
+
),
|
129
|
+
),
|
130
|
+
);
|
131
|
+
return decorators;
|
132
|
+
};
|
133
|
+
|
134
|
+
const writeParameters =
|
135
|
+
(importer: ImportProgrammer) =>
|
136
|
+
(components: ISwaggerComponents) =>
|
137
|
+
(route: IMigrateRoute): ts.ParameterDeclaration[] => [
|
138
|
+
...route.parameters.map(({ key, schema: value }) =>
|
139
|
+
ts.factory.createParameterDeclaration(
|
140
|
+
[
|
141
|
+
ts.factory.createDecorator(
|
142
|
+
ts.factory.createCallExpression(
|
143
|
+
ts.factory.createIdentifier(
|
144
|
+
importer.external({
|
145
|
+
library: "@nestia/core",
|
146
|
+
instance: "TypedParam",
|
147
|
+
}),
|
148
|
+
),
|
149
|
+
undefined,
|
150
|
+
[ts.factory.createStringLiteral(key)],
|
151
|
+
),
|
152
|
+
),
|
153
|
+
],
|
154
|
+
undefined,
|
155
|
+
StringUtil.normalize(key),
|
156
|
+
undefined,
|
157
|
+
SchemaProgrammer.write(importer)(components)(value),
|
158
|
+
),
|
159
|
+
),
|
160
|
+
...(route.headers
|
161
|
+
? [
|
162
|
+
writeDtoParameter({ method: "TypedHeaders", variable: "headers" })(
|
163
|
+
importer,
|
164
|
+
)(components)(route.headers),
|
165
|
+
]
|
166
|
+
: []),
|
167
|
+
...(route.query
|
168
|
+
? [
|
169
|
+
writeDtoParameter({ method: "TypedQuery", variable: "query" })(
|
170
|
+
importer,
|
171
|
+
)(components)(route.query),
|
172
|
+
]
|
173
|
+
: []),
|
174
|
+
...(route.body
|
175
|
+
? [
|
176
|
+
writeDtoParameter({
|
177
|
+
method: route.body?.["x-nestia-encrypted"]
|
178
|
+
? "EncryptedBody"
|
179
|
+
: "TypedBody",
|
180
|
+
variable: "body",
|
181
|
+
})(importer)(components)(route.body.schema),
|
182
|
+
]
|
183
|
+
: []),
|
184
|
+
];
|
185
|
+
|
186
|
+
const writeDtoParameter =
|
187
|
+
(accessor: { method: string; variable: string }) =>
|
188
|
+
(importer: ImportProgrammer) =>
|
189
|
+
(components: ISwaggerComponents) =>
|
190
|
+
(schema: ISwaggerSchema): ts.ParameterDeclaration =>
|
191
|
+
ts.factory.createParameterDeclaration(
|
192
|
+
[
|
193
|
+
ts.factory.createDecorator(
|
194
|
+
ts.factory.createCallExpression(
|
195
|
+
ts.factory.createIdentifier(
|
196
|
+
importer.external({
|
197
|
+
library: "@nestia/core",
|
198
|
+
instance: accessor.method,
|
199
|
+
}),
|
200
|
+
),
|
201
|
+
undefined,
|
202
|
+
undefined,
|
203
|
+
),
|
204
|
+
),
|
205
|
+
],
|
206
|
+
undefined,
|
207
|
+
StringUtil.normalize(accessor.variable),
|
208
|
+
undefined,
|
209
|
+
SchemaProgrammer.write(importer)(components)(schema),
|
210
|
+
);
|
211
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import ts from "typescript";
|
2
|
+
|
3
|
+
import { IMigrateController } from "../structures/IMigrateController";
|
4
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
5
|
+
|
6
|
+
export namespace NestModuleProgrammer {
|
7
|
+
export const write = (controllers: IMigrateController[]): ts.Statement[] => [
|
8
|
+
$import("@nestjs/common")("Module"),
|
9
|
+
...(controllers.length ? [FilePrinter.enter()] : []),
|
10
|
+
...controllers.map((c) =>
|
11
|
+
$import(`${c.location.replace("src/", "./")}/${c.name}`)(c.name),
|
12
|
+
),
|
13
|
+
...(controllers.length ? [FilePrinter.enter()] : []),
|
14
|
+
ts.factory.createClassDeclaration(
|
15
|
+
[
|
16
|
+
ts.factory.createDecorator(
|
17
|
+
ts.factory.createCallExpression(
|
18
|
+
ts.factory.createIdentifier("Module"),
|
19
|
+
undefined,
|
20
|
+
[
|
21
|
+
ts.factory.createObjectLiteralExpression(
|
22
|
+
[
|
23
|
+
ts.factory.createPropertyAssignment(
|
24
|
+
ts.factory.createIdentifier("controllers"),
|
25
|
+
ts.factory.createArrayLiteralExpression(
|
26
|
+
controllers.map((c) =>
|
27
|
+
ts.factory.createIdentifier(c.name),
|
28
|
+
),
|
29
|
+
),
|
30
|
+
),
|
31
|
+
],
|
32
|
+
true,
|
33
|
+
),
|
34
|
+
],
|
35
|
+
),
|
36
|
+
),
|
37
|
+
ts.factory.createToken(ts.SyntaxKind.ExportKeyword),
|
38
|
+
],
|
39
|
+
"MyModule",
|
40
|
+
undefined,
|
41
|
+
undefined,
|
42
|
+
[],
|
43
|
+
),
|
44
|
+
];
|
45
|
+
}
|
46
|
+
|
47
|
+
const $import = (file: string) => (instance: string) =>
|
48
|
+
ts.factory.createImportDeclaration(
|
49
|
+
undefined,
|
50
|
+
ts.factory.createImportClause(
|
51
|
+
false,
|
52
|
+
undefined,
|
53
|
+
ts.factory.createNamedImports([
|
54
|
+
ts.factory.createImportSpecifier(
|
55
|
+
false,
|
56
|
+
undefined,
|
57
|
+
ts.factory.createIdentifier(instance),
|
58
|
+
),
|
59
|
+
]),
|
60
|
+
),
|
61
|
+
ts.factory.createStringLiteral(file),
|
62
|
+
);
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import ts from "typescript";
|
2
|
+
|
3
|
+
import { IMigrateFile } from "../structures/IMigrateFile";
|
4
|
+
import { IMigrateProgram } from "../structures/IMigrateProgram";
|
5
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
6
|
+
import { DtoProgrammer } from "./DtoProgrammer";
|
7
|
+
import { ImportProgrammer } from "./ImportProgrammer";
|
8
|
+
import { NestControllerProgrammer } from "./NestControllerProgrammer";
|
9
|
+
import { NestModuleProgrammer } from "./NestModuleProgrammer";
|
10
|
+
|
11
|
+
export namespace MigrateProgrammer {
|
12
|
+
export const write = (program: IMigrateProgram): IMigrateFile[] =>
|
13
|
+
[
|
14
|
+
{
|
15
|
+
location: "src",
|
16
|
+
file: "MyModule.ts",
|
17
|
+
statements: NestModuleProgrammer.write(program.controllers),
|
18
|
+
},
|
19
|
+
...program.controllers.map((c) => ({
|
20
|
+
location: c.location,
|
21
|
+
file: `${c.name}.ts`,
|
22
|
+
statements: NestControllerProgrammer.write(program.swagger.components)(
|
23
|
+
c,
|
24
|
+
),
|
25
|
+
})),
|
26
|
+
...[...DtoProgrammer.write(program.swagger.components).entries()].map(
|
27
|
+
([key, value]) => ({
|
28
|
+
location: "src/api/structures",
|
29
|
+
file: `${key}.ts`,
|
30
|
+
statements: writeDtoFile(key, value),
|
31
|
+
}),
|
32
|
+
),
|
33
|
+
].map((o) => ({
|
34
|
+
location: o.location,
|
35
|
+
file: o.file,
|
36
|
+
content: FilePrinter.write({ statements: o.statements }),
|
37
|
+
}));
|
38
|
+
|
39
|
+
const writeDtoFile = (
|
40
|
+
key: string,
|
41
|
+
modulo: DtoProgrammer.IModule,
|
42
|
+
): ts.Statement[] => {
|
43
|
+
const importer = new ImportProgrammer();
|
44
|
+
const statements: ts.Statement[] = iterate(importer)(modulo);
|
45
|
+
if (statements.length === 0) return [];
|
46
|
+
|
47
|
+
return [
|
48
|
+
...importer.toStatements((name) => `./${name}`, key),
|
49
|
+
...(importer.empty() ? [] : [FilePrinter.enter()]),
|
50
|
+
...statements,
|
51
|
+
];
|
52
|
+
};
|
53
|
+
|
54
|
+
const iterate =
|
55
|
+
(importer: ImportProgrammer) =>
|
56
|
+
(modulo: DtoProgrammer.IModule): ts.Statement[] => {
|
57
|
+
const output: ts.Statement[] = [];
|
58
|
+
if (modulo.programmer !== null) output.push(modulo.programmer(importer));
|
59
|
+
if (modulo.children.size) {
|
60
|
+
const internal: ts.Statement[] = [];
|
61
|
+
for (const child of modulo.children.values())
|
62
|
+
internal.push(...iterate(importer)(child));
|
63
|
+
output.push(
|
64
|
+
ts.factory.createModuleDeclaration(
|
65
|
+
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
66
|
+
ts.factory.createIdentifier(modulo.name),
|
67
|
+
ts.factory.createModuleBlock(internal),
|
68
|
+
ts.NodeFlags.Namespace,
|
69
|
+
),
|
70
|
+
);
|
71
|
+
}
|
72
|
+
return output;
|
73
|
+
};
|
74
|
+
}
|