@nestia/migrate 4.6.1-dev.20250117 → 4.6.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/README.md +92 -87
- package/lib/MigrateApplication.js +3 -3
- package/lib/bundles/NEST_TEMPLATE.js +84 -64
- package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +30 -30
- package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
- package/lib/index.mjs +118 -102
- package/lib/index.mjs.map +1 -1
- package/lib/programmers/MigrateApiNamespaceProgrammer.js +6 -6
- package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +1 -1
- package/lib/programmers/{MigrateApiSimulatationProgrammer.d.ts → MigrateApiSimulationProgrammer.d.ts} +1 -1
- package/lib/programmers/{MigrateApiSimulatationProgrammer.js → MigrateApiSimulationProgrammer.js} +7 -7
- package/lib/programmers/MigrateApiSimulationProgrammer.js.map +1 -0
- package/lib/utils/openapi-down-convert/converter.js +2 -2
- package/package.json +6 -6
- package/src/MigrateApplication.ts +107 -107
- package/src/analyzers/MigrateApplicationAnalyzer.ts +18 -18
- package/src/analyzers/MigrateControllerAnalyzer.ts +51 -51
- package/src/archivers/MigrateFileArchiver.ts +38 -38
- package/src/bundles/NEST_TEMPLATE.ts +84 -64
- package/src/bundles/SDK_TEMPLATE.ts +30 -30
- package/src/executable/bundle.js +125 -125
- package/src/executable/migrate.ts +7 -7
- package/src/factories/TypeLiteralFactory.ts +57 -57
- package/src/index.ts +4 -4
- package/src/internal/MigrateCommander.ts +86 -86
- package/src/internal/MigrateInquirer.ts +89 -89
- package/src/module.ts +8 -8
- package/src/programmers/MigrateApiFileProgrammer.ts +49 -49
- package/src/programmers/MigrateApiFunctionProgrammer.ts +210 -210
- package/src/programmers/MigrateApiNamespaceProgrammer.ts +417 -417
- package/src/programmers/MigrateApiProgrammer.ts +103 -103
- package/src/programmers/{MigrateApiSimulatationProgrammer.ts → MigrateApiSimulationProgrammer.ts} +324 -324
- package/src/programmers/MigrateApiStartProgrammer.ts +194 -194
- package/src/programmers/MigrateDtoProgrammer.ts +87 -87
- package/src/programmers/MigrateE2eFileProgrammer.ts +117 -117
- package/src/programmers/MigrateE2eProgrammer.ts +34 -34
- package/src/programmers/MigrateImportProgrammer.ts +118 -118
- package/src/programmers/MigrateNestControllerProgrammer.ts +50 -50
- package/src/programmers/MigrateNestMethodProgrammer.ts +393 -393
- package/src/programmers/MigrateNestModuleProgrammer.ts +65 -65
- package/src/programmers/MigrateNestProgrammer.ts +81 -81
- package/src/programmers/MigrateSchemaProgrammer.ts +373 -373
- package/src/structures/IHttpMigrateController.ts +8 -8
- package/src/structures/IHttpMigrateDto.ts +8 -8
- package/src/structures/IHttpMigrateFile.ts +5 -5
- package/src/structures/IHttpMigrateProgram.ts +27 -27
- package/src/structures/IHttpMigrateRoute.ts +1 -1
- package/src/structures/IHttpMigrateSchema.ts +4 -4
- package/src/utils/FilePrinter.ts +36 -36
- package/src/utils/MapUtil.ts +13 -13
- package/src/utils/OpenApiTypeChecker.ts +73 -73
- package/src/utils/SetupWizard.ts +12 -12
- package/src/utils/StringUtil.ts +113 -113
- package/src/utils/openapi-down-convert/RefVisitor.ts +139 -139
- package/src/utils/openapi-down-convert/converter.ts +527 -527
- package/lib/programmers/MigrateApiSimulatationProgrammer.js.map +0 -1
@@ -1,107 +1,107 @@
|
|
1
|
-
import { OpenApi, OpenApiV3, OpenApiV3_1, SwaggerV2 } from "@samchon/openapi";
|
2
|
-
import typia, { IValidation } from "typia";
|
3
|
-
|
4
|
-
import { MigrateApplicationAnalyzer } from "./analyzers/MigrateApplicationAnalyzer";
|
5
|
-
import { NEST_TEMPLATE } from "./bundles/NEST_TEMPLATE";
|
6
|
-
import { SDK_TEMPLATE } from "./bundles/SDK_TEMPLATE";
|
7
|
-
import { MigrateApiProgrammer } from "./programmers/MigrateApiProgrammer";
|
8
|
-
import { MigrateApiStartProgrammer } from "./programmers/MigrateApiStartProgrammer";
|
9
|
-
import { MigrateE2eProgrammer } from "./programmers/MigrateE2eProgrammer";
|
10
|
-
import { MigrateNestProgrammer } from "./programmers/MigrateNestProgrammer";
|
11
|
-
import { IHttpMigrateFile } from "./structures/IHttpMigrateFile";
|
12
|
-
import { IHttpMigrateProgram } from "./structures/IHttpMigrateProgram";
|
13
|
-
|
14
|
-
export class MigrateApplication {
|
15
|
-
private constructor(public readonly document: OpenApi.IDocument) {}
|
16
|
-
|
17
|
-
public static create(
|
18
|
-
document:
|
19
|
-
| SwaggerV2.IDocument
|
20
|
-
| OpenApiV3.IDocument
|
21
|
-
| OpenApiV3_1.IDocument
|
22
|
-
| OpenApi.IDocument,
|
23
|
-
): IValidation<MigrateApplication> {
|
24
|
-
const result: IValidation<
|
25
|
-
| SwaggerV2.IDocument
|
26
|
-
| OpenApiV3.IDocument
|
27
|
-
| OpenApiV3_1.IDocument
|
28
|
-
| OpenApi.IDocument
|
29
|
-
> = typia.validate(document);
|
30
|
-
if (result.success === false) return result;
|
31
|
-
return {
|
32
|
-
success: true,
|
33
|
-
data: new MigrateApplication(OpenApi.convert(document)),
|
34
|
-
};
|
35
|
-
}
|
36
|
-
|
37
|
-
public nest(config: MigrateApplication.IConfig): MigrateApplication.IOutput {
|
38
|
-
const program: IHttpMigrateProgram = MigrateApplicationAnalyzer.analyze({
|
39
|
-
mode: "nest",
|
40
|
-
document: this.document,
|
41
|
-
simulate: config.simulate,
|
42
|
-
e2e: config.e2e,
|
43
|
-
});
|
44
|
-
const output: MigrateApplication.IOutput = {
|
45
|
-
program,
|
46
|
-
files: [
|
47
|
-
...NEST_TEMPLATE,
|
48
|
-
...MigrateNestProgrammer.write(program),
|
49
|
-
...MigrateApiProgrammer.write(program),
|
50
|
-
...(config.e2e ? MigrateE2eProgrammer.write(program) : []),
|
51
|
-
],
|
52
|
-
errors: program.errors,
|
53
|
-
};
|
54
|
-
return this.finalize(config, output);
|
55
|
-
}
|
56
|
-
|
57
|
-
public sdk(config: MigrateApplication.IConfig): MigrateApplication.IOutput {
|
58
|
-
const program: IHttpMigrateProgram = MigrateApplicationAnalyzer.analyze({
|
59
|
-
mode: "sdk",
|
60
|
-
document: this.document,
|
61
|
-
simulate: config.simulate,
|
62
|
-
e2e: config.e2e,
|
63
|
-
});
|
64
|
-
const output: MigrateApplication.IOutput = {
|
65
|
-
program,
|
66
|
-
files: [
|
67
|
-
...SDK_TEMPLATE,
|
68
|
-
...MigrateApiProgrammer.write(program),
|
69
|
-
MigrateApiStartProgrammer.write(program),
|
70
|
-
...(config.e2e ? MigrateE2eProgrammer.write(program) : []),
|
71
|
-
{
|
72
|
-
location: "",
|
73
|
-
file: "swagger.json",
|
74
|
-
content: JSON.stringify(this.document, null, 2),
|
75
|
-
},
|
76
|
-
],
|
77
|
-
errors: program.errors,
|
78
|
-
};
|
79
|
-
return this.finalize(config, output);
|
80
|
-
}
|
81
|
-
|
82
|
-
private finalize(
|
83
|
-
config: MigrateApplication.IConfig,
|
84
|
-
|
85
|
-
): MigrateApplication.IOutput {
|
86
|
-
if (config.package)
|
87
|
-
|
88
|
-
...file,
|
89
|
-
content: file.content
|
90
|
-
.split(`@ORGANIZATION/PROJECT`)
|
91
|
-
.join(config.package),
|
92
|
-
}));
|
93
|
-
return
|
94
|
-
}
|
95
|
-
}
|
96
|
-
export namespace MigrateApplication {
|
97
|
-
export interface IOutput {
|
98
|
-
program: IHttpMigrateProgram;
|
99
|
-
files: IHttpMigrateFile[];
|
100
|
-
errors: IHttpMigrateProgram.IError[];
|
101
|
-
}
|
102
|
-
export interface IConfig {
|
103
|
-
simulate: boolean;
|
104
|
-
e2e: boolean;
|
105
|
-
package?: string;
|
106
|
-
}
|
107
|
-
}
|
1
|
+
import { OpenApi, OpenApiV3, OpenApiV3_1, SwaggerV2 } from "@samchon/openapi";
|
2
|
+
import typia, { IValidation } from "typia";
|
3
|
+
|
4
|
+
import { MigrateApplicationAnalyzer } from "./analyzers/MigrateApplicationAnalyzer";
|
5
|
+
import { NEST_TEMPLATE } from "./bundles/NEST_TEMPLATE";
|
6
|
+
import { SDK_TEMPLATE } from "./bundles/SDK_TEMPLATE";
|
7
|
+
import { MigrateApiProgrammer } from "./programmers/MigrateApiProgrammer";
|
8
|
+
import { MigrateApiStartProgrammer } from "./programmers/MigrateApiStartProgrammer";
|
9
|
+
import { MigrateE2eProgrammer } from "./programmers/MigrateE2eProgrammer";
|
10
|
+
import { MigrateNestProgrammer } from "./programmers/MigrateNestProgrammer";
|
11
|
+
import { IHttpMigrateFile } from "./structures/IHttpMigrateFile";
|
12
|
+
import { IHttpMigrateProgram } from "./structures/IHttpMigrateProgram";
|
13
|
+
|
14
|
+
export class MigrateApplication {
|
15
|
+
private constructor(public readonly document: OpenApi.IDocument) {}
|
16
|
+
|
17
|
+
public static create(
|
18
|
+
document:
|
19
|
+
| SwaggerV2.IDocument
|
20
|
+
| OpenApiV3.IDocument
|
21
|
+
| OpenApiV3_1.IDocument
|
22
|
+
| OpenApi.IDocument,
|
23
|
+
): IValidation<MigrateApplication> {
|
24
|
+
const result: IValidation<
|
25
|
+
| SwaggerV2.IDocument
|
26
|
+
| OpenApiV3.IDocument
|
27
|
+
| OpenApiV3_1.IDocument
|
28
|
+
| OpenApi.IDocument
|
29
|
+
> = typia.validate(document);
|
30
|
+
if (result.success === false) return result;
|
31
|
+
return {
|
32
|
+
success: true,
|
33
|
+
data: new MigrateApplication(OpenApi.convert(document)),
|
34
|
+
};
|
35
|
+
}
|
36
|
+
|
37
|
+
public nest(config: MigrateApplication.IConfig): MigrateApplication.IOutput {
|
38
|
+
const program: IHttpMigrateProgram = MigrateApplicationAnalyzer.analyze({
|
39
|
+
mode: "nest",
|
40
|
+
document: this.document,
|
41
|
+
simulate: config.simulate,
|
42
|
+
e2e: config.e2e,
|
43
|
+
});
|
44
|
+
const output: MigrateApplication.IOutput = {
|
45
|
+
program,
|
46
|
+
files: [
|
47
|
+
...NEST_TEMPLATE,
|
48
|
+
...MigrateNestProgrammer.write(program),
|
49
|
+
...MigrateApiProgrammer.write(program),
|
50
|
+
...(config.e2e ? MigrateE2eProgrammer.write(program) : []),
|
51
|
+
],
|
52
|
+
errors: program.errors,
|
53
|
+
};
|
54
|
+
return this.finalize(config, output);
|
55
|
+
}
|
56
|
+
|
57
|
+
public sdk(config: MigrateApplication.IConfig): MigrateApplication.IOutput {
|
58
|
+
const program: IHttpMigrateProgram = MigrateApplicationAnalyzer.analyze({
|
59
|
+
mode: "sdk",
|
60
|
+
document: this.document,
|
61
|
+
simulate: config.simulate,
|
62
|
+
e2e: config.e2e,
|
63
|
+
});
|
64
|
+
const output: MigrateApplication.IOutput = {
|
65
|
+
program,
|
66
|
+
files: [
|
67
|
+
...SDK_TEMPLATE,
|
68
|
+
...MigrateApiProgrammer.write(program),
|
69
|
+
MigrateApiStartProgrammer.write(program),
|
70
|
+
...(config.e2e ? MigrateE2eProgrammer.write(program) : []),
|
71
|
+
{
|
72
|
+
location: "",
|
73
|
+
file: "swagger.json",
|
74
|
+
content: JSON.stringify(this.document, null, 2),
|
75
|
+
},
|
76
|
+
],
|
77
|
+
errors: program.errors,
|
78
|
+
};
|
79
|
+
return this.finalize(config, output);
|
80
|
+
}
|
81
|
+
|
82
|
+
private finalize(
|
83
|
+
config: MigrateApplication.IConfig,
|
84
|
+
output: MigrateApplication.IOutput,
|
85
|
+
): MigrateApplication.IOutput {
|
86
|
+
if (config.package)
|
87
|
+
output.files = output.files.map((file) => ({
|
88
|
+
...file,
|
89
|
+
content: file.content
|
90
|
+
.split(`@ORGANIZATION/PROJECT`)
|
91
|
+
.join(config.package),
|
92
|
+
}));
|
93
|
+
return output;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
export namespace MigrateApplication {
|
97
|
+
export interface IOutput {
|
98
|
+
program: IHttpMigrateProgram;
|
99
|
+
files: IHttpMigrateFile[];
|
100
|
+
errors: IHttpMigrateProgram.IError[];
|
101
|
+
}
|
102
|
+
export interface IConfig {
|
103
|
+
simulate: boolean;
|
104
|
+
e2e: boolean;
|
105
|
+
package?: string;
|
106
|
+
}
|
107
|
+
}
|
@@ -1,18 +1,18 @@
|
|
1
|
-
import { HttpMigration, IHttpMigrateApplication } from "@samchon/openapi";
|
2
|
-
|
3
|
-
import { IHttpMigrateProgram } from "../structures/IHttpMigrateProgram";
|
4
|
-
|
5
|
-
export namespace MigrateApplicationAnalyzer {
|
6
|
-
export const analyze = (
|
7
|
-
props: IHttpMigrateProgram.IProps,
|
8
|
-
): IHttpMigrateProgram => {
|
9
|
-
const application: IHttpMigrateApplication = HttpMigration.application(
|
10
|
-
props.document,
|
11
|
-
);
|
12
|
-
return {
|
13
|
-
...props,
|
14
|
-
routes: application.routes,
|
15
|
-
errors: application.errors,
|
16
|
-
};
|
17
|
-
};
|
18
|
-
}
|
1
|
+
import { HttpMigration, IHttpMigrateApplication } from "@samchon/openapi";
|
2
|
+
|
3
|
+
import { IHttpMigrateProgram } from "../structures/IHttpMigrateProgram";
|
4
|
+
|
5
|
+
export namespace MigrateApplicationAnalyzer {
|
6
|
+
export const analyze = (
|
7
|
+
props: IHttpMigrateProgram.IProps,
|
8
|
+
): IHttpMigrateProgram => {
|
9
|
+
const application: IHttpMigrateApplication = HttpMigration.application(
|
10
|
+
props.document,
|
11
|
+
);
|
12
|
+
return {
|
13
|
+
...props,
|
14
|
+
routes: application.routes,
|
15
|
+
errors: application.errors,
|
16
|
+
};
|
17
|
+
};
|
18
|
+
}
|
@@ -1,51 +1,51 @@
|
|
1
|
-
import { IHttpMigrateRoute } from "@samchon/openapi";
|
2
|
-
|
3
|
-
import { IHttpMigrateController } from "../structures/IHttpMigrateController";
|
4
|
-
import { MapUtil } from "../utils/MapUtil";
|
5
|
-
import { StringUtil } from "../utils/StringUtil";
|
6
|
-
|
7
|
-
export namespace MigrateControllerAnalyzer {
|
8
|
-
export const analyze = (props: {
|
9
|
-
routes: IHttpMigrateRoute[];
|
10
|
-
}): IHttpMigrateController[] => {
|
11
|
-
const collection: Map<string, IHttpMigrateController> = new Map();
|
12
|
-
for (const route of props.routes) {
|
13
|
-
const name: string =
|
14
|
-
route.operation()["x-samchon-controller"] ??
|
15
|
-
(route.accessor.length <= 1
|
16
|
-
? "__App"
|
17
|
-
: route.accessor.slice(0, -1).map(StringUtil.capitalize).join("")) +
|
18
|
-
"Controller";
|
19
|
-
MapUtil.take(collection)(name)(() => ({
|
20
|
-
name,
|
21
|
-
path: "@lazy",
|
22
|
-
location: "@lazy",
|
23
|
-
routes: [],
|
24
|
-
})).routes.push(route);
|
25
|
-
}
|
26
|
-
|
27
|
-
const controllers: IHttpMigrateController[] = [...collection.values()];
|
28
|
-
for (const col of controllers) {
|
29
|
-
const splitPath = (r: IHttpMigrateRoute): string[] =>
|
30
|
-
r.emendedPath.split("/");
|
31
|
-
const splitLocation = (r: IHttpMigrateRoute): string[] =>
|
32
|
-
splitPath(r).filter((s) => s[0] !== ":");
|
33
|
-
|
34
|
-
const minPath: string[] = splitPath(col.routes[0]);
|
35
|
-
const minLocation: string[] = splitLocation(col.routes[0]);
|
36
|
-
for (const r of col.routes.slice(1)) {
|
37
|
-
minPath.splice(getSplitIndex(minPath, splitPath(r)));
|
38
|
-
minLocation.splice(getSplitIndex(minLocation, splitLocation(r)));
|
39
|
-
}
|
40
|
-
col.path = minPath.join("/");
|
41
|
-
col.location = "src/controllers/" + minLocation.join("/");
|
42
|
-
}
|
43
|
-
return controllers;
|
44
|
-
};
|
45
|
-
}
|
46
|
-
|
47
|
-
const getSplitIndex = (x: string[], y: string[]) => {
|
48
|
-
const n: number = Math.min(x.length, y.length);
|
49
|
-
for (let i: number = 0; i < n; ++i) if (x[i] !== y[i]) return i;
|
50
|
-
return n;
|
51
|
-
};
|
1
|
+
import { IHttpMigrateRoute } from "@samchon/openapi";
|
2
|
+
|
3
|
+
import { IHttpMigrateController } from "../structures/IHttpMigrateController";
|
4
|
+
import { MapUtil } from "../utils/MapUtil";
|
5
|
+
import { StringUtil } from "../utils/StringUtil";
|
6
|
+
|
7
|
+
export namespace MigrateControllerAnalyzer {
|
8
|
+
export const analyze = (props: {
|
9
|
+
routes: IHttpMigrateRoute[];
|
10
|
+
}): IHttpMigrateController[] => {
|
11
|
+
const collection: Map<string, IHttpMigrateController> = new Map();
|
12
|
+
for (const route of props.routes) {
|
13
|
+
const name: string =
|
14
|
+
route.operation()["x-samchon-controller"] ??
|
15
|
+
(route.accessor.length <= 1
|
16
|
+
? "__App"
|
17
|
+
: route.accessor.slice(0, -1).map(StringUtil.capitalize).join("")) +
|
18
|
+
"Controller";
|
19
|
+
MapUtil.take(collection)(name)(() => ({
|
20
|
+
name,
|
21
|
+
path: "@lazy",
|
22
|
+
location: "@lazy",
|
23
|
+
routes: [],
|
24
|
+
})).routes.push(route);
|
25
|
+
}
|
26
|
+
|
27
|
+
const controllers: IHttpMigrateController[] = [...collection.values()];
|
28
|
+
for (const col of controllers) {
|
29
|
+
const splitPath = (r: IHttpMigrateRoute): string[] =>
|
30
|
+
r.emendedPath.split("/");
|
31
|
+
const splitLocation = (r: IHttpMigrateRoute): string[] =>
|
32
|
+
splitPath(r).filter((s) => s[0] !== ":");
|
33
|
+
|
34
|
+
const minPath: string[] = splitPath(col.routes[0]);
|
35
|
+
const minLocation: string[] = splitLocation(col.routes[0]);
|
36
|
+
for (const r of col.routes.slice(1)) {
|
37
|
+
minPath.splice(getSplitIndex(minPath, splitPath(r)));
|
38
|
+
minLocation.splice(getSplitIndex(minLocation, splitLocation(r)));
|
39
|
+
}
|
40
|
+
col.path = minPath.join("/");
|
41
|
+
col.location = "src/controllers/" + minLocation.join("/");
|
42
|
+
}
|
43
|
+
return controllers;
|
44
|
+
};
|
45
|
+
}
|
46
|
+
|
47
|
+
const getSplitIndex = (x: string[], y: string[]) => {
|
48
|
+
const n: number = Math.min(x.length, y.length);
|
49
|
+
for (let i: number = 0; i < n; ++i) if (x[i] !== y[i]) return i;
|
50
|
+
return n;
|
51
|
+
};
|
@@ -1,38 +1,38 @@
|
|
1
|
-
import { IHttpMigrateFile } from "../structures/IHttpMigrateFile";
|
2
|
-
|
3
|
-
export namespace MigrateFileArchiver {
|
4
|
-
export interface IOperator {
|
5
|
-
mkdir(path: string): Promise<void>;
|
6
|
-
writeFile(path: string, content: string): Promise<void>;
|
7
|
-
}
|
8
|
-
|
9
|
-
export const archive =
|
10
|
-
(operator: IOperator) =>
|
11
|
-
(output: string) =>
|
12
|
-
async (files: IHttpMigrateFile[]): Promise<void> => {
|
13
|
-
const visited: Set<string> = new Set();
|
14
|
-
for (const f of files) {
|
15
|
-
await mkdir(operator.mkdir)(output)(visited)(f.location);
|
16
|
-
await operator.writeFile(
|
17
|
-
[output, f.location, f.file].join("/"),
|
18
|
-
f.content,
|
19
|
-
);
|
20
|
-
}
|
21
|
-
};
|
22
|
-
|
23
|
-
const mkdir =
|
24
|
-
(creator: (path: string) => void) =>
|
25
|
-
(output: string) =>
|
26
|
-
(visited: Set<string>) =>
|
27
|
-
async (path: string): Promise<void> => {
|
28
|
-
const sequence: string[] = path
|
29
|
-
.split("/")
|
30
|
-
.map((_str, i, entire) => entire.slice(0, i + 1).join("/"));
|
31
|
-
for (const s of sequence)
|
32
|
-
if (visited.has(s) === false)
|
33
|
-
try {
|
34
|
-
await creator([output, s].join("/"));
|
35
|
-
visited.add(s);
|
36
|
-
} catch {}
|
37
|
-
};
|
38
|
-
}
|
1
|
+
import { IHttpMigrateFile } from "../structures/IHttpMigrateFile";
|
2
|
+
|
3
|
+
export namespace MigrateFileArchiver {
|
4
|
+
export interface IOperator {
|
5
|
+
mkdir(path: string): Promise<void>;
|
6
|
+
writeFile(path: string, content: string): Promise<void>;
|
7
|
+
}
|
8
|
+
|
9
|
+
export const archive =
|
10
|
+
(operator: IOperator) =>
|
11
|
+
(output: string) =>
|
12
|
+
async (files: IHttpMigrateFile[]): Promise<void> => {
|
13
|
+
const visited: Set<string> = new Set();
|
14
|
+
for (const f of files) {
|
15
|
+
await mkdir(operator.mkdir)(output)(visited)(f.location);
|
16
|
+
await operator.writeFile(
|
17
|
+
[output, f.location, f.file].join("/"),
|
18
|
+
f.content,
|
19
|
+
);
|
20
|
+
}
|
21
|
+
};
|
22
|
+
|
23
|
+
const mkdir =
|
24
|
+
(creator: (path: string) => void) =>
|
25
|
+
(output: string) =>
|
26
|
+
(visited: Set<string>) =>
|
27
|
+
async (path: string): Promise<void> => {
|
28
|
+
const sequence: string[] = path
|
29
|
+
.split("/")
|
30
|
+
.map((_str, i, entire) => entire.slice(0, i + 1).join("/"));
|
31
|
+
for (const s of sequence)
|
32
|
+
if (visited.has(s) === false)
|
33
|
+
try {
|
34
|
+
await creator([output, s].join("/"));
|
35
|
+
visited.add(s);
|
36
|
+
} catch {}
|
37
|
+
};
|
38
|
+
}
|