@ahoo-wang/fetcher-generator 2.2.0 → 2.2.2
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/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +100 -96
- package/dist/index.js.map +1 -1
- package/dist/model/modelGenerator.d.ts +2 -0
- package/dist/model/modelGenerator.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -2,14 +2,14 @@ import { VariableDeclarationKind as O, Scope as L } from "ts-morph";
|
|
|
2
2
|
import { parse as Q } from "yaml";
|
|
3
3
|
import * as v from "fs";
|
|
4
4
|
import { readFile as k } from "fs";
|
|
5
|
-
import { ContentTypeValues as
|
|
5
|
+
import { ContentTypeValues as S, combineURLs as q } from "@ahoo-wang/fetcher";
|
|
6
6
|
import * as K from "path";
|
|
7
7
|
import { join as U, relative as J } from "path";
|
|
8
8
|
import { ResourceAttributionPathSpec as R } from "@ahoo-wang/fetcher-wow";
|
|
9
9
|
function f(n) {
|
|
10
10
|
return n.$ref.split("/").pop();
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function I(n, e) {
|
|
13
13
|
const t = f(n);
|
|
14
14
|
return e.schemas?.[t];
|
|
15
15
|
}
|
|
@@ -24,7 +24,7 @@ function H(n, e) {
|
|
|
24
24
|
function C(n, e) {
|
|
25
25
|
return {
|
|
26
26
|
key: f(n),
|
|
27
|
-
schema:
|
|
27
|
+
schema: I(n, e)
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
const b = /[-_\s.]+|(?=[A-Z])/;
|
|
@@ -84,7 +84,7 @@ function g(n) {
|
|
|
84
84
|
return !!(n && typeof n == "object" && "$ref" in n);
|
|
85
85
|
}
|
|
86
86
|
function oe(n) {
|
|
87
|
-
return !n || g(n) || !n.content ? void 0 : n.content[
|
|
87
|
+
return !n || g(n) || !n.content ? void 0 : n.content[S.APPLICATION_JSON]?.schema;
|
|
88
88
|
}
|
|
89
89
|
function ne(n) {
|
|
90
90
|
return [
|
|
@@ -124,17 +124,17 @@ function ae(n) {
|
|
|
124
124
|
function F(n) {
|
|
125
125
|
return Array.isArray(n.anyOf) && n.anyOf.length > 0;
|
|
126
126
|
}
|
|
127
|
-
function
|
|
127
|
+
function W(n) {
|
|
128
128
|
return Array.isArray(n.oneOf) && n.oneOf.length > 0;
|
|
129
129
|
}
|
|
130
130
|
function ce(n) {
|
|
131
|
-
return F(n) ||
|
|
131
|
+
return F(n) || W(n);
|
|
132
132
|
}
|
|
133
133
|
function ge(n) {
|
|
134
134
|
return Array.isArray(n.allOf) && n.allOf.length > 0;
|
|
135
135
|
}
|
|
136
136
|
function j(n) {
|
|
137
|
-
return F(n) ||
|
|
137
|
+
return F(n) || W(n) || ge(n);
|
|
138
138
|
}
|
|
139
139
|
function le(n) {
|
|
140
140
|
return n.includes("|") || n.includes("&") ? `(${n})[]` : `${n}[]`;
|
|
@@ -156,9 +156,9 @@ function N(n) {
|
|
|
156
156
|
return "any";
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
const
|
|
159
|
+
const _ = "types.ts", pe = "@";
|
|
160
160
|
function me(n) {
|
|
161
|
-
return q(n.path,
|
|
161
|
+
return q(n.path, _);
|
|
162
162
|
}
|
|
163
163
|
function D(n, e, t) {
|
|
164
164
|
const o = q(e, t), r = n.getSourceFile(o);
|
|
@@ -174,7 +174,7 @@ function $(n, e, t) {
|
|
|
174
174
|
moduleSpecifier: e
|
|
175
175
|
})), t.forEach((r) => {
|
|
176
176
|
o.getNamedImports().some(
|
|
177
|
-
(
|
|
177
|
+
(a) => a.getName() === r
|
|
178
178
|
) || o.addNamedImport(r);
|
|
179
179
|
});
|
|
180
180
|
}
|
|
@@ -183,7 +183,7 @@ function y(n, e, t) {
|
|
|
183
183
|
$(n, t.path, [t.name]);
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
|
-
const o = n.getDirectoryPath(), r = U(e, t.path,
|
|
186
|
+
const o = n.getDirectoryPath(), r = U(e, t.path, _);
|
|
187
187
|
let s = J(o, r);
|
|
188
188
|
s = s.replace(/\.ts$/, ""), s.startsWith(".") || (s = "./" + s), $(n, s, [t.name]);
|
|
189
189
|
}
|
|
@@ -285,7 +285,7 @@ class Pe {
|
|
|
285
285
|
const s = G(o);
|
|
286
286
|
if (!s || !g(s) || s.$ref !== Ae || !o.requestBody)
|
|
287
287
|
return;
|
|
288
|
-
const
|
|
288
|
+
const a = o.parameters ?? [], c = a.filter((d) => g(d) && d.$ref === Ce).at(0), i = a.filter(
|
|
289
289
|
(d) => !g(d) && d.in === "path"
|
|
290
290
|
);
|
|
291
291
|
if (c) {
|
|
@@ -293,9 +293,9 @@ class Pe {
|
|
|
293
293
|
c,
|
|
294
294
|
this.openAPI.components
|
|
295
295
|
);
|
|
296
|
-
|
|
296
|
+
i.push(d);
|
|
297
297
|
}
|
|
298
|
-
const m = o.requestBody.content[
|
|
298
|
+
const m = o.requestBody.content[S.APPLICATION_JSON].schema, l = C(
|
|
299
299
|
m,
|
|
300
300
|
this.openAPI.components
|
|
301
301
|
);
|
|
@@ -304,7 +304,7 @@ class Pe {
|
|
|
304
304
|
name: r,
|
|
305
305
|
method: t.method,
|
|
306
306
|
path: e,
|
|
307
|
-
pathParameters:
|
|
307
|
+
pathParameters: i,
|
|
308
308
|
summary: o.summary,
|
|
309
309
|
description: o.description,
|
|
310
310
|
schema: l,
|
|
@@ -347,24 +347,24 @@ class Pe {
|
|
|
347
347
|
const o = t?.items;
|
|
348
348
|
if (!g(o))
|
|
349
349
|
return;
|
|
350
|
-
const s =
|
|
350
|
+
const s = I(
|
|
351
351
|
o,
|
|
352
352
|
this.openAPI.components
|
|
353
|
-
).properties.body.items.anyOf.map((
|
|
354
|
-
const c =
|
|
353
|
+
).properties.body.items.anyOf.map((a) => {
|
|
354
|
+
const c = a.title, i = a.properties.name.const, p = a.properties.body, m = C(
|
|
355
355
|
p,
|
|
356
356
|
this.openAPI.components
|
|
357
357
|
);
|
|
358
|
-
return m.schema.title = m.schema.title ||
|
|
358
|
+
return m.schema.title = m.schema.title || a.title, {
|
|
359
359
|
title: c,
|
|
360
|
-
name:
|
|
360
|
+
name: i,
|
|
361
361
|
schema: m
|
|
362
362
|
};
|
|
363
363
|
});
|
|
364
|
-
e.tags?.forEach((
|
|
365
|
-
const c = this.aggregates.get(
|
|
366
|
-
c && s.forEach((
|
|
367
|
-
c.events.set(
|
|
364
|
+
e.tags?.forEach((a) => {
|
|
365
|
+
const c = this.aggregates.get(a);
|
|
366
|
+
c && s.forEach((i) => {
|
|
367
|
+
c.events.set(i.name, i);
|
|
368
368
|
});
|
|
369
369
|
});
|
|
370
370
|
}
|
|
@@ -378,13 +378,13 @@ class Pe {
|
|
|
378
378
|
const o = V(
|
|
379
379
|
e.requestBody,
|
|
380
380
|
this.openAPI.components
|
|
381
|
-
).content[
|
|
381
|
+
).content[S.APPLICATION_JSON].schema, s = I(
|
|
382
382
|
o,
|
|
383
383
|
this.openAPI.components
|
|
384
|
-
).properties?.field,
|
|
384
|
+
).properties?.field, a = C(s, this.openAPI.components);
|
|
385
385
|
e.tags?.forEach((c) => {
|
|
386
|
-
const
|
|
387
|
-
|
|
386
|
+
const i = this.aggregates.get(c);
|
|
387
|
+
i && (i.fields = a);
|
|
388
388
|
});
|
|
389
389
|
}
|
|
390
390
|
}
|
|
@@ -425,15 +425,15 @@ function u(n) {
|
|
|
425
425
|
return { name: e, path: A };
|
|
426
426
|
const t = n.split(".");
|
|
427
427
|
let o = -1;
|
|
428
|
-
for (let
|
|
429
|
-
if (t[
|
|
430
|
-
o =
|
|
428
|
+
for (let i = 0; i < t.length; i++)
|
|
429
|
+
if (t[i] && /^[A-Z]/.test(t[i])) {
|
|
430
|
+
o = i;
|
|
431
431
|
break;
|
|
432
432
|
}
|
|
433
433
|
if (o === -1)
|
|
434
434
|
return { name: n, path: "/" };
|
|
435
|
-
const r = t.slice(0, o), s = r.length > 0 ? `/${r.join("/")}` : "/",
|
|
436
|
-
return { name: w(
|
|
435
|
+
const r = t.slice(0, o), s = r.length > 0 ? `/${r.join("/")}` : "/", a = t.slice(o);
|
|
436
|
+
return { name: w(a), path: s };
|
|
437
437
|
}
|
|
438
438
|
class x {
|
|
439
439
|
/** The ts-morph project instance used for code generation */
|
|
@@ -476,25 +476,29 @@ class we extends x {
|
|
|
476
476
|
this.logger.info("No schemas found in OpenAPI specification");
|
|
477
477
|
return;
|
|
478
478
|
}
|
|
479
|
-
const t =
|
|
480
|
-
([o]) => !o.startsWith("wow.")
|
|
481
|
-
);
|
|
479
|
+
const t = this.filterSchemas(e);
|
|
482
480
|
this.logger.progress(
|
|
483
481
|
`Generating models for ${t.length} schemas`
|
|
484
|
-
), t.forEach((
|
|
482
|
+
), t.forEach((o, r) => {
|
|
485
483
|
this.logger.progressWithCount(
|
|
486
|
-
|
|
484
|
+
r + 1,
|
|
487
485
|
t.length,
|
|
488
|
-
`Processing schema: ${o}`,
|
|
486
|
+
`Processing schema: ${o.key}`,
|
|
489
487
|
2
|
|
490
|
-
);
|
|
491
|
-
const i = {
|
|
492
|
-
key: o,
|
|
493
|
-
schema: r
|
|
494
|
-
};
|
|
495
|
-
this.generateKeyedSchema(i);
|
|
488
|
+
), this.generateKeyedSchema(o);
|
|
496
489
|
}), this.logger.success("Model generation completed");
|
|
497
490
|
}
|
|
491
|
+
filterSchemas(e) {
|
|
492
|
+
return Object.entries(e).map(
|
|
493
|
+
([t, o]) => ({
|
|
494
|
+
key: t,
|
|
495
|
+
schema: o
|
|
496
|
+
})
|
|
497
|
+
).filter((t) => !this.isWowSchema(t.key));
|
|
498
|
+
}
|
|
499
|
+
isWowSchema(e) {
|
|
500
|
+
return e.startsWith("wow.");
|
|
501
|
+
}
|
|
498
502
|
/**
|
|
499
503
|
* Generates a model for a specific schema key.
|
|
500
504
|
* Processes enums, objects, unions, and type aliases in order.
|
|
@@ -532,10 +536,10 @@ class we extends x {
|
|
|
532
536
|
e,
|
|
533
537
|
o,
|
|
534
538
|
r
|
|
535
|
-
) : (j(o) && (o.anyOf || o.oneOf || o.allOf).forEach((
|
|
536
|
-
if (g(
|
|
539
|
+
) : (j(o) && (o.anyOf || o.oneOf || o.allOf).forEach((a) => {
|
|
540
|
+
if (g(a)) {
|
|
537
541
|
const c = u(
|
|
538
|
-
f(
|
|
542
|
+
f(a)
|
|
539
543
|
);
|
|
540
544
|
E(
|
|
541
545
|
e,
|
|
@@ -548,7 +552,7 @@ class we extends x {
|
|
|
548
552
|
this.processInterface(
|
|
549
553
|
t,
|
|
550
554
|
e,
|
|
551
|
-
|
|
555
|
+
a,
|
|
552
556
|
r
|
|
553
557
|
);
|
|
554
558
|
}), r);
|
|
@@ -566,18 +570,18 @@ class we extends x {
|
|
|
566
570
|
);
|
|
567
571
|
}
|
|
568
572
|
processInterface(e, t, o, r) {
|
|
569
|
-
for (const [s,
|
|
573
|
+
for (const [s, a] of Object.entries(o.properties)) {
|
|
570
574
|
const c = this.resolvePropertyType(
|
|
571
575
|
t,
|
|
572
576
|
e,
|
|
573
577
|
s,
|
|
574
|
-
|
|
578
|
+
a
|
|
575
579
|
);
|
|
576
|
-
let
|
|
577
|
-
|
|
580
|
+
let i = r.getProperty(s);
|
|
581
|
+
i ? i.setType(c) : i = r.addProperty({
|
|
578
582
|
name: s,
|
|
579
583
|
type: c
|
|
580
|
-
}), g(
|
|
584
|
+
}), g(a) || P(i, a.title, a.description);
|
|
581
585
|
}
|
|
582
586
|
return r;
|
|
583
587
|
}
|
|
@@ -614,12 +618,12 @@ class we extends x {
|
|
|
614
618
|
const s = {
|
|
615
619
|
path: e.path,
|
|
616
620
|
name: `${e.name}${w(o)}`
|
|
617
|
-
},
|
|
621
|
+
}, a = this.processObject(
|
|
618
622
|
t,
|
|
619
623
|
s,
|
|
620
624
|
r
|
|
621
625
|
);
|
|
622
|
-
return P(
|
|
626
|
+
return P(a, r.title, r.description), s.name;
|
|
623
627
|
}
|
|
624
628
|
return "any";
|
|
625
629
|
}
|
|
@@ -627,21 +631,21 @@ class we extends x {
|
|
|
627
631
|
const r = o.anyOf || o.oneOf || o.allOf, s = /* @__PURE__ */ new Set();
|
|
628
632
|
r.forEach((c) => {
|
|
629
633
|
if (g(c)) {
|
|
630
|
-
const
|
|
634
|
+
const i = u(
|
|
631
635
|
f(c)
|
|
632
636
|
);
|
|
633
637
|
E(
|
|
634
638
|
e,
|
|
635
639
|
t,
|
|
636
640
|
this.outputDir,
|
|
637
|
-
|
|
638
|
-
), s.add(
|
|
641
|
+
i
|
|
642
|
+
), s.add(i.name);
|
|
639
643
|
return;
|
|
640
644
|
}
|
|
641
645
|
s.add(N(c.type ?? "string"));
|
|
642
646
|
});
|
|
643
|
-
const
|
|
644
|
-
return Array.from(s).join(
|
|
647
|
+
const a = ce(o) ? "|" : "&";
|
|
648
|
+
return Array.from(s).join(a);
|
|
645
649
|
}
|
|
646
650
|
}
|
|
647
651
|
function xe(n) {
|
|
@@ -750,24 +754,24 @@ class Oe extends x {
|
|
|
750
754
|
`Adding import for event model: ${l.name} from path: ${l.path}`
|
|
751
755
|
), y(t, this.outputDir, l), r.push(l);
|
|
752
756
|
}
|
|
753
|
-
const s = "DOMAIN_EVENT_TYPES",
|
|
757
|
+
const s = "DOMAIN_EVENT_TYPES", a = r.map((m) => m.name).join(" | ");
|
|
754
758
|
this.logger.info(
|
|
755
|
-
`Creating domain event types union: ${s} = ${
|
|
759
|
+
`Creating domain event types union: ${s} = ${a}`
|
|
756
760
|
), t.addTypeAlias({
|
|
757
761
|
name: s,
|
|
758
|
-
type:
|
|
762
|
+
type: a
|
|
759
763
|
});
|
|
760
|
-
const c = `${h(e.aggregate.aggregateName)}QueryClientFactory`,
|
|
764
|
+
const c = `${h(e.aggregate.aggregateName)}QueryClientFactory`, i = u(e.state.key), p = u(e.fields.key);
|
|
761
765
|
this.logger.info(
|
|
762
|
-
`Adding import for state model: ${
|
|
763
|
-
), y(t, this.outputDir,
|
|
766
|
+
`Adding import for state model: ${i.name} from path: ${i.path}`
|
|
767
|
+
), y(t, this.outputDir, i), this.logger.info(
|
|
764
768
|
`Adding import for fields model: ${p.name} from path: ${p.path}`
|
|
765
769
|
), y(t, this.outputDir, p), this.logger.info(`Creating query client factory: ${c}`), t.addVariableStatement({
|
|
766
770
|
declarationKind: O.Const,
|
|
767
771
|
declarations: [
|
|
768
772
|
{
|
|
769
773
|
name: c,
|
|
770
|
-
initializer: `new QueryClientFactory<${
|
|
774
|
+
initializer: `new QueryClientFactory<${i.name}, ${p.name} | string, ${s}>(${o})`
|
|
771
775
|
}
|
|
772
776
|
],
|
|
773
777
|
isExported: !0
|
|
@@ -776,7 +780,7 @@ class Oe extends x {
|
|
|
776
780
|
);
|
|
777
781
|
}
|
|
778
782
|
}
|
|
779
|
-
class
|
|
783
|
+
class Se extends x {
|
|
780
784
|
commandEndpointPathsName = "COMMAND_ENDPOINT_PATHS";
|
|
781
785
|
defaultCommandClientOptionsName = "DEFAULT_COMMAND_CLIENT_OPTIONS";
|
|
782
786
|
/**
|
|
@@ -900,7 +904,7 @@ class Ie extends x {
|
|
|
900
904
|
let r = "CommandClient", s = {
|
|
901
905
|
name: "api",
|
|
902
906
|
arguments: []
|
|
903
|
-
},
|
|
907
|
+
}, a = "Promise<CommandResult>";
|
|
904
908
|
o && (r = "Stream" + r, s = {
|
|
905
909
|
name: "api",
|
|
906
910
|
arguments: [
|
|
@@ -910,17 +914,17 @@ class Ie extends x {
|
|
|
910
914
|
resultExtractor: JsonEventStreamResultExtractor,
|
|
911
915
|
}`
|
|
912
916
|
]
|
|
913
|
-
},
|
|
917
|
+
}, a = "Promise<CommandResultEventStream>");
|
|
914
918
|
const c = Ee(
|
|
915
919
|
t.aggregate,
|
|
916
920
|
r
|
|
917
|
-
),
|
|
921
|
+
), i = e.addClass({
|
|
918
922
|
name: c,
|
|
919
923
|
isExported: !0,
|
|
920
924
|
decorators: [s],
|
|
921
925
|
implements: ["ApiMetadataCapable"]
|
|
922
926
|
});
|
|
923
|
-
|
|
927
|
+
i.addConstructor({
|
|
924
928
|
parameters: [
|
|
925
929
|
{
|
|
926
930
|
name: "apiMetadata",
|
|
@@ -931,7 +935,7 @@ class Ie extends x {
|
|
|
931
935
|
}
|
|
932
936
|
]
|
|
933
937
|
}), t.commands.forEach((p) => {
|
|
934
|
-
this.processCommandMethod(e,
|
|
938
|
+
this.processCommandMethod(e, i, p, a);
|
|
935
939
|
});
|
|
936
940
|
}
|
|
937
941
|
methodToDecorator(e) {
|
|
@@ -952,21 +956,21 @@ class Ie extends x {
|
|
|
952
956
|
), this.logger.info(
|
|
953
957
|
`Command method details: HTTP ${o.method}, path: ${o.path}, return type: ${r}`
|
|
954
958
|
);
|
|
955
|
-
const
|
|
956
|
-
`Adding path parameter: ${
|
|
959
|
+
const a = o.pathParameters.map((i) => (this.logger.info(
|
|
960
|
+
`Adding path parameter: ${i.name} (type: string)`
|
|
957
961
|
), {
|
|
958
|
-
name:
|
|
962
|
+
name: i.name,
|
|
959
963
|
type: "string",
|
|
960
964
|
decorators: [
|
|
961
965
|
{
|
|
962
966
|
name: "path",
|
|
963
|
-
arguments: [`'${
|
|
967
|
+
arguments: [`'${i.name}'`]
|
|
964
968
|
}
|
|
965
969
|
]
|
|
966
970
|
}));
|
|
967
971
|
this.logger.info(
|
|
968
972
|
`Adding command request parameter: commandRequest (type: CommandRequest<${s.name}>)`
|
|
969
|
-
),
|
|
973
|
+
), a.push({
|
|
970
974
|
name: "commandRequest",
|
|
971
975
|
type: `CommandRequest<${s.name}>`,
|
|
972
976
|
decorators: [
|
|
@@ -977,7 +981,7 @@ class Ie extends x {
|
|
|
977
981
|
]
|
|
978
982
|
}), this.logger.info(
|
|
979
983
|
"Adding attributes parameter: attributes (type: Record<string, any>)"
|
|
980
|
-
),
|
|
984
|
+
), a.push({
|
|
981
985
|
name: "attributes",
|
|
982
986
|
type: "Record<string, any>",
|
|
983
987
|
decorators: [
|
|
@@ -995,10 +999,10 @@ class Ie extends x {
|
|
|
995
999
|
arguments: [`${this.getEndpointPath(o)}`]
|
|
996
1000
|
}
|
|
997
1001
|
],
|
|
998
|
-
parameters:
|
|
1002
|
+
parameters: a,
|
|
999
1003
|
returnType: r,
|
|
1000
1004
|
statements: [
|
|
1001
|
-
`throw autoGeneratedError(${
|
|
1005
|
+
`throw autoGeneratedError(${a.map((i) => i.name).join(",")});`
|
|
1002
1006
|
]
|
|
1003
1007
|
});
|
|
1004
1008
|
(o.summary || o.description) && this.logger.info(
|
|
@@ -1008,7 +1012,7 @@ class Ie extends x {
|
|
|
1008
1012
|
);
|
|
1009
1013
|
}
|
|
1010
1014
|
}
|
|
1011
|
-
class
|
|
1015
|
+
class Ie extends x {
|
|
1012
1016
|
queryClientGenerator;
|
|
1013
1017
|
commandClientGenerator;
|
|
1014
1018
|
/**
|
|
@@ -1016,7 +1020,7 @@ class Se extends x {
|
|
|
1016
1020
|
* @param context - The generation context containing OpenAPI spec and project details
|
|
1017
1021
|
*/
|
|
1018
1022
|
constructor(e) {
|
|
1019
|
-
super(e), this.queryClientGenerator = new Oe(e), this.commandClientGenerator = new
|
|
1023
|
+
super(e), this.queryClientGenerator = new Oe(e), this.commandClientGenerator = new Se(e);
|
|
1020
1024
|
}
|
|
1021
1025
|
/**
|
|
1022
1026
|
* Generates client classes for all aggregates.
|
|
@@ -1083,7 +1087,7 @@ class Me {
|
|
|
1083
1087
|
contextAggregates: o,
|
|
1084
1088
|
logger: this.options.logger
|
|
1085
1089
|
};
|
|
1086
|
-
this.options.logger.info("Generating models"), new we(r).generate(), this.options.logger.info("Models generated successfully"), this.options.logger.info("Generating clients"), new
|
|
1090
|
+
this.options.logger.info("Generating models"), new we(r).generate(), this.options.logger.info("Models generated successfully"), this.options.logger.info("Generating clients"), new Ie(r).generate(), this.options.logger.info("Clients generated successfully"), this.options.logger.info("Generating index files"), this.generateIndex(), this.options.logger.info("Index files generated successfully"), this.options.logger.info("Optimizing source files"), this.optimizeSourceFiles(), this.options.logger.info("Source files optimized successfully"), this.options.logger.info("Saving project to disk"), await this.project.save(), this.options.logger.info("Code generation completed successfully");
|
|
1087
1091
|
}
|
|
1088
1092
|
/**
|
|
1089
1093
|
* Generates index.ts files for all subdirectories in the output directory.
|
|
@@ -1122,8 +1126,8 @@ class Me {
|
|
|
1122
1126
|
let r = [];
|
|
1123
1127
|
try {
|
|
1124
1128
|
r = v.readdirSync(t).filter((c) => {
|
|
1125
|
-
const
|
|
1126
|
-
return v.statSync(
|
|
1129
|
+
const i = K.join(t, c);
|
|
1130
|
+
return v.statSync(i).isDirectory();
|
|
1127
1131
|
});
|
|
1128
1132
|
} catch (c) {
|
|
1129
1133
|
this.options.logger.error(
|
|
@@ -1140,22 +1144,22 @@ class Me {
|
|
|
1140
1144
|
}
|
|
1141
1145
|
const s = `${t}/index.ts`;
|
|
1142
1146
|
this.options.logger.info(`Creating/updating index file: ${s}`);
|
|
1143
|
-
const
|
|
1144
|
-
|
|
1147
|
+
const a = this.project.getSourceFile(s) || this.project.createSourceFile(s, "", { overwrite: !0 });
|
|
1148
|
+
a.removeText();
|
|
1145
1149
|
for (const c of o) {
|
|
1146
|
-
const
|
|
1147
|
-
this.options.logger.info(`Adding export for file: ${
|
|
1148
|
-
moduleSpecifier:
|
|
1150
|
+
const i = `./${c.getBaseNameWithoutExtension()}`;
|
|
1151
|
+
this.options.logger.info(`Adding export for file: ${i}`), a.addExportDeclaration({
|
|
1152
|
+
moduleSpecifier: i,
|
|
1149
1153
|
isTypeOnly: !1,
|
|
1150
1154
|
namedExports: []
|
|
1151
1155
|
});
|
|
1152
1156
|
}
|
|
1153
1157
|
for (const c of r) {
|
|
1154
|
-
const
|
|
1158
|
+
const i = `./${c}`;
|
|
1155
1159
|
this.options.logger.info(
|
|
1156
|
-
`Adding export for subdirectory: ${
|
|
1157
|
-
),
|
|
1158
|
-
moduleSpecifier:
|
|
1160
|
+
`Adding export for subdirectory: ${i}`
|
|
1161
|
+
), a.addExportDeclaration({
|
|
1162
|
+
moduleSpecifier: i,
|
|
1159
1163
|
isTypeOnly: !1,
|
|
1160
1164
|
namedExports: []
|
|
1161
1165
|
});
|