@nestia/migrate 0.7.4 → 0.7.6
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/MigrateApplication.d.ts +9 -2
- package/lib/MigrateApplication.js +14 -8
- package/lib/MigrateApplication.js.map +1 -1
- package/lib/analyzers/MigrateAnalyzer.js +2 -2
- package/lib/analyzers/MigrateAnalyzer.js.map +1 -1
- package/lib/analyzers/{ControllerAnalyzer.d.ts → MigrateControllerAnalyzer.d.ts} +1 -1
- package/lib/analyzers/{ControllerAnalyzer.js → MigrateControllerAnalyzer.js} +11 -9
- package/lib/analyzers/MigrateControllerAnalyzer.js.map +1 -0
- package/lib/analyzers/{MethodAnalyzer.d.ts → MigrateMethodAnalyzer.d.ts} +1 -1
- package/lib/analyzers/{MethodAnalyzer.js → MigrateMethodAnalyzer.js} +26 -25
- package/lib/analyzers/MigrateMethodAnalyzer.js.map +1 -0
- package/lib/archivers/{FileArchiver.d.ts → MigrateFileArchiver.d.ts} +1 -1
- package/lib/archivers/{FileArchiver.js → MigrateFileArchiver.js} +6 -6
- package/lib/archivers/MigrateFileArchiver.js.map +1 -0
- package/lib/bundles/NEST_TEMPLATE.js +3 -3
- package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
- package/lib/bundles/SDK_TEMPLATE.js +1 -1
- package/lib/executable/bundle.js +1 -0
- package/lib/executable/bundle.js.map +1 -1
- package/lib/internal/MigrateCommander.js +3 -3
- package/lib/internal/MigrateCommander.js.map +1 -1
- package/lib/programmers/{ApiFileProgrammer.d.ts → MigrateApiFileProgrammer.d.ts} +1 -1
- package/lib/programmers/MigrateApiFileProgrammer.js +28 -0
- package/lib/programmers/MigrateApiFileProgrammer.js.map +1 -0
- package/lib/programmers/{ApiFunctionProgrammer.d.ts → MigrateApiFunctionProgrammer.d.ts} +4 -4
- package/lib/programmers/{ApiFunctionProgrammer.js → MigrateApiFunctionProgrammer.js} +10 -10
- package/lib/programmers/MigrateApiFunctionProgrammer.js.map +1 -0
- package/lib/programmers/{ApiNamespaceProgrammer.d.ts → MigrateApiNamespaceProgrammer.d.ts} +3 -3
- package/lib/programmers/{ApiNamespaceProgrammer.js → MigrateApiNamespaceProgrammer.js} +19 -19
- package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +1 -0
- package/lib/programmers/{ApiProgrammer.d.ts → MigrateApiProgrammer.d.ts} +1 -1
- package/lib/programmers/{ApiProgrammer.js → MigrateApiProgrammer.js} +25 -20
- package/lib/programmers/MigrateApiProgrammer.js.map +1 -0
- package/lib/programmers/{ApiSimulatationProgrammer.d.ts → MigrateApiSimulatationProgrammer.d.ts} +4 -4
- package/lib/programmers/{ApiSimulatationProgrammer.js → MigrateApiSimulatationProgrammer.js} +16 -16
- package/lib/programmers/MigrateApiSimulatationProgrammer.js.map +1 -0
- package/lib/programmers/{DtoProgrammer.d.ts → MigrateDtoProgrammer.d.ts} +3 -3
- package/lib/programmers/{DtoProgrammer.js → MigrateDtoProgrammer.js} +8 -8
- package/lib/programmers/MigrateDtoProgrammer.js.map +1 -0
- package/lib/programmers/{ImportProgrammer.d.ts → MigrateImportProgrammer.d.ts} +3 -3
- package/lib/programmers/{ImportProgrammer.js → MigrateImportProgrammer.js} +7 -5
- package/lib/programmers/MigrateImportProgrammer.js.map +1 -0
- package/lib/programmers/{NestControllerProgrammer.d.ts → MigrateNestControllerProgrammer.d.ts} +1 -1
- package/lib/programmers/{NestControllerProgrammer.js → MigrateNestControllerProgrammer.js} +11 -11
- package/lib/programmers/MigrateNestControllerProgrammer.js.map +1 -0
- package/lib/programmers/{NestMethodProgrammer.d.ts → MigrateNestMethodProgrammer.d.ts} +3 -3
- package/lib/programmers/{NestMethodProgrammer.js → MigrateNestMethodProgrammer.js} +13 -11
- package/lib/programmers/MigrateNestMethodProgrammer.js.map +1 -0
- package/lib/programmers/{NestModuleProgrammer.d.ts → MigrateNestModuleProgrammer.d.ts} +1 -1
- package/lib/programmers/{NestModuleProgrammer.js → MigrateNestModuleProgrammer.js} +8 -8
- package/lib/programmers/MigrateNestModuleProgrammer.js.map +1 -0
- package/lib/programmers/{NestProgrammer.d.ts → MigrateNestProgrammer.d.ts} +1 -1
- package/lib/programmers/{NestProgrammer.js → MigrateNestProgrammer.js} +17 -15
- package/lib/programmers/MigrateNestProgrammer.js.map +1 -0
- package/lib/programmers/{SchemaProgrammer.d.ts → MigrateSchemaProgrammer.d.ts} +3 -3
- package/lib/programmers/{SchemaProgrammer.js → MigrateSchemaProgrammer.js} +23 -23
- package/lib/programmers/MigrateSchemaProgrammer.js.map +1 -0
- package/lib/structures/IMigrateRoute.d.ts +1 -0
- package/lib/utils/FilePrinter.d.ts +1 -1
- package/lib/utils/FilePrinter.js +1 -1
- package/lib/utils/FilePrinter.js.map +1 -1
- package/lib/utils/{JsonTypeChecker.d.ts → SwaggerTypeChecker.d.ts} +1 -1
- package/lib/utils/SwaggerTypeChecker.js +34 -0
- package/lib/utils/SwaggerTypeChecker.js.map +1 -0
- package/package.json +68 -68
- package/src/IMigrateConfig.ts +4 -4
- package/src/MigrateApplication.ts +48 -35
- package/src/analyzers/MigrateAnalyzer.ts +13 -13
- package/src/analyzers/{ControllerAnalyzer.ts → MigrateControllerAnalyzer.ts} +122 -123
- package/src/analyzers/{MethodAnalyzer.ts → MigrateMethodAnalyzer.ts} +348 -347
- package/src/archivers/{FileArchiver.ts → MigrateFileArchiver.ts} +38 -38
- package/src/bundles/NEST_TEMPLATE.ts +3 -3
- package/src/bundles/SDK_TEMPLATE.ts +1 -1
- package/src/executable/bundle.ts +109 -108
- package/src/executable/migrate.ts +7 -7
- package/src/internal/MigrateCommander.ts +51 -52
- package/src/internal/MigrateInquirer.ts +79 -79
- package/src/module.ts +4 -4
- package/src/programmers/{ApiFileProgrammer.ts → MigrateApiFileProgrammer.ts} +53 -53
- package/src/programmers/{ApiFunctionProgrammer.ts → MigrateApiFunctionProgrammer.ts} +203 -203
- package/src/programmers/{ApiNamespaceProgrammer.ts → MigrateApiNamespaceProgrammer.ts} +430 -418
- package/src/programmers/{ApiProgrammer.ts → MigrateApiProgrammer.ts} +132 -128
- package/src/programmers/{ApiSimulatationProgrammer.ts → MigrateApiSimulatationProgrammer.ts} +328 -328
- package/src/programmers/{DtoProgrammer.ts → MigrateDtoProgrammer.ts} +78 -74
- package/src/programmers/{ImportProgrammer.ts → MigrateImportProgrammer.ts} +116 -114
- package/src/programmers/{NestControllerProgrammer.ts → MigrateNestControllerProgrammer.ts} +50 -48
- package/src/programmers/{NestMethodProgrammer.ts → MigrateNestMethodProgrammer.ts} +249 -243
- package/src/programmers/{NestModuleProgrammer.ts → MigrateNestModuleProgrammer.ts} +62 -62
- package/src/programmers/{NestProgrammer.ts → MigrateNestProgrammer.ts} +74 -74
- package/src/programmers/{SchemaProgrammer.ts → MigrateSchemaProgrammer.ts} +257 -255
- package/src/structures/IMigrateProgram.ts +9 -9
- package/src/structures/IMigrateRoute.ts +46 -45
- package/src/structures/ISwaggeSchema.ts +90 -90
- package/src/structures/ISwaggerInfo.ts +80 -80
- package/src/utils/FilePrinter.ts +36 -36
- package/src/utils/SetupWizard.ts +12 -12
- package/src/utils/StringUtil.ts +60 -60
- package/src/utils/{JsonTypeChecker.ts → SwaggerTypeChecker.ts} +67 -67
- package/lib/analyzers/ControllerAnalyzer.js.map +0 -1
- package/lib/analyzers/MethodAnalyzer.js.map +0 -1
- package/lib/archivers/FileArchiver.js.map +0 -1
- package/lib/programmers/ApiFileProgrammer.js +0 -28
- package/lib/programmers/ApiFileProgrammer.js.map +0 -1
- package/lib/programmers/ApiFunctionProgrammer.js.map +0 -1
- package/lib/programmers/ApiNamespaceProgrammer.js.map +0 -1
- package/lib/programmers/ApiProgrammer.js.map +0 -1
- package/lib/programmers/ApiSimulatationProgrammer.js.map +0 -1
- package/lib/programmers/DtoProgrammer.js.map +0 -1
- package/lib/programmers/ImportProgrammer.js.map +0 -1
- package/lib/programmers/NestControllerProgrammer.js.map +0 -1
- package/lib/programmers/NestMethodProgrammer.js.map +0 -1
- package/lib/programmers/NestModuleProgrammer.js.map +0 -1
- package/lib/programmers/NestProgrammer.js.map +0 -1
- package/lib/programmers/SchemaProgrammer.js.map +0 -1
- package/lib/utils/JsonTypeChecker.js +0 -34
- package/lib/utils/JsonTypeChecker.js.map +0 -1
@@ -1,90 +1,90 @@
|
|
1
|
-
export type ISwaggerSchema =
|
2
|
-
| ISwaggerSchema.IUnknown
|
3
|
-
| ISwaggerSchema.INullOnly
|
4
|
-
| ISwaggerSchema.IAnyOf
|
5
|
-
| ISwaggerSchema.IOneOf
|
6
|
-
| ISwaggerSchema.IBoolean
|
7
|
-
| ISwaggerSchema.IInteger
|
8
|
-
| ISwaggerSchema.INumber
|
9
|
-
| ISwaggerSchema.IString
|
10
|
-
| ISwaggerSchema.IArray
|
11
|
-
| ISwaggerSchema.IObject
|
12
|
-
| ISwaggerSchema.IReference;
|
13
|
-
export namespace ISwaggerSchema {
|
14
|
-
export interface IUnknown extends IAttribute {
|
15
|
-
type?: undefined;
|
16
|
-
}
|
17
|
-
export interface INullOnly extends IAttribute {
|
18
|
-
type: "null";
|
19
|
-
}
|
20
|
-
|
21
|
-
export interface IAnyOf extends IAttribute {
|
22
|
-
anyOf: ISwaggerSchema[];
|
23
|
-
}
|
24
|
-
export interface IOneOf extends IAttribute {
|
25
|
-
oneOf: ISwaggerSchema[];
|
26
|
-
}
|
27
|
-
|
28
|
-
export interface IBoolean extends ISignificant<"boolean"> {
|
29
|
-
default?: boolean;
|
30
|
-
enum?: boolean[];
|
31
|
-
}
|
32
|
-
export interface IInteger extends ISignificant<"integer"> {
|
33
|
-
/** @type int */ default?: number;
|
34
|
-
/** @type int */ enum?: number[];
|
35
|
-
/** @type int */ minimum?: number;
|
36
|
-
/** @type int */ maximum?: number;
|
37
|
-
/** @type int */ exclusiveMinimum?: boolean;
|
38
|
-
/** @type int */ exclusiveMaximum?: boolean;
|
39
|
-
/** @type uint */ multipleOf?: number;
|
40
|
-
}
|
41
|
-
export interface INumber extends ISignificant<"number"> {
|
42
|
-
default?: number;
|
43
|
-
enum?: number[];
|
44
|
-
minimum?: number;
|
45
|
-
maximum?: number;
|
46
|
-
exclusiveMinimum?: boolean;
|
47
|
-
exclusiveMaximum?: boolean;
|
48
|
-
multipleOf?: number;
|
49
|
-
}
|
50
|
-
export interface IString extends ISignificant<"string"> {
|
51
|
-
default?: string;
|
52
|
-
enum?: string[];
|
53
|
-
format?: string;
|
54
|
-
pattern?: string;
|
55
|
-
/** @type uint */ minLength?: number;
|
56
|
-
/** @type uint */ maxLength?: number;
|
57
|
-
}
|
58
|
-
|
59
|
-
export interface IArray extends ISignificant<"array"> {
|
60
|
-
items: ISwaggerSchema;
|
61
|
-
/** @type uint */ minItems?: number;
|
62
|
-
/** @type uint */ maxItems?: number;
|
63
|
-
"x-typia-tuple"?: ITuple;
|
64
|
-
}
|
65
|
-
export interface ITuple extends ISignificant<"array"> {
|
66
|
-
items: ISwaggerSchema[];
|
67
|
-
}
|
68
|
-
export interface IObject extends ISignificant<"object"> {
|
69
|
-
properties?: Record<string, ISwaggerSchema>;
|
70
|
-
required?: string[];
|
71
|
-
additionalProperties?: ISwaggerSchema | boolean;
|
72
|
-
"x-typia-patternProperties"?: Record<string, ISwaggerSchema>;
|
73
|
-
}
|
74
|
-
|
75
|
-
export interface IReference extends IAttribute {
|
76
|
-
$ref: string;
|
77
|
-
}
|
78
|
-
|
79
|
-
interface ISignificant<Type extends string> extends IAttribute {
|
80
|
-
type: Type;
|
81
|
-
nullable?: boolean;
|
82
|
-
}
|
83
|
-
interface IAttribute {
|
84
|
-
title?: string;
|
85
|
-
description?: string;
|
86
|
-
deprecated?: boolean;
|
87
|
-
"x-typia-optional"?: boolean;
|
88
|
-
"x-typia-rest"?: boolean;
|
89
|
-
}
|
90
|
-
}
|
1
|
+
export type ISwaggerSchema =
|
2
|
+
| ISwaggerSchema.IUnknown
|
3
|
+
| ISwaggerSchema.INullOnly
|
4
|
+
| ISwaggerSchema.IAnyOf
|
5
|
+
| ISwaggerSchema.IOneOf
|
6
|
+
| ISwaggerSchema.IBoolean
|
7
|
+
| ISwaggerSchema.IInteger
|
8
|
+
| ISwaggerSchema.INumber
|
9
|
+
| ISwaggerSchema.IString
|
10
|
+
| ISwaggerSchema.IArray
|
11
|
+
| ISwaggerSchema.IObject
|
12
|
+
| ISwaggerSchema.IReference;
|
13
|
+
export namespace ISwaggerSchema {
|
14
|
+
export interface IUnknown extends IAttribute {
|
15
|
+
type?: undefined;
|
16
|
+
}
|
17
|
+
export interface INullOnly extends IAttribute {
|
18
|
+
type: "null";
|
19
|
+
}
|
20
|
+
|
21
|
+
export interface IAnyOf extends IAttribute {
|
22
|
+
anyOf: ISwaggerSchema[];
|
23
|
+
}
|
24
|
+
export interface IOneOf extends IAttribute {
|
25
|
+
oneOf: ISwaggerSchema[];
|
26
|
+
}
|
27
|
+
|
28
|
+
export interface IBoolean extends ISignificant<"boolean"> {
|
29
|
+
default?: boolean;
|
30
|
+
enum?: boolean[];
|
31
|
+
}
|
32
|
+
export interface IInteger extends ISignificant<"integer"> {
|
33
|
+
/** @type int */ default?: number;
|
34
|
+
/** @type int */ enum?: number[];
|
35
|
+
/** @type int */ minimum?: number;
|
36
|
+
/** @type int */ maximum?: number;
|
37
|
+
/** @type int */ exclusiveMinimum?: boolean;
|
38
|
+
/** @type int */ exclusiveMaximum?: boolean;
|
39
|
+
/** @type uint */ multipleOf?: number;
|
40
|
+
}
|
41
|
+
export interface INumber extends ISignificant<"number"> {
|
42
|
+
default?: number;
|
43
|
+
enum?: number[];
|
44
|
+
minimum?: number;
|
45
|
+
maximum?: number;
|
46
|
+
exclusiveMinimum?: boolean;
|
47
|
+
exclusiveMaximum?: boolean;
|
48
|
+
multipleOf?: number;
|
49
|
+
}
|
50
|
+
export interface IString extends ISignificant<"string"> {
|
51
|
+
default?: string;
|
52
|
+
enum?: string[];
|
53
|
+
format?: string;
|
54
|
+
pattern?: string;
|
55
|
+
/** @type uint */ minLength?: number;
|
56
|
+
/** @type uint */ maxLength?: number;
|
57
|
+
}
|
58
|
+
|
59
|
+
export interface IArray extends ISignificant<"array"> {
|
60
|
+
items: ISwaggerSchema;
|
61
|
+
/** @type uint */ minItems?: number;
|
62
|
+
/** @type uint */ maxItems?: number;
|
63
|
+
"x-typia-tuple"?: ITuple;
|
64
|
+
}
|
65
|
+
export interface ITuple extends ISignificant<"array"> {
|
66
|
+
items: ISwaggerSchema[];
|
67
|
+
}
|
68
|
+
export interface IObject extends ISignificant<"object"> {
|
69
|
+
properties?: Record<string, ISwaggerSchema>;
|
70
|
+
required?: string[];
|
71
|
+
additionalProperties?: ISwaggerSchema | boolean;
|
72
|
+
"x-typia-patternProperties"?: Record<string, ISwaggerSchema>;
|
73
|
+
}
|
74
|
+
|
75
|
+
export interface IReference extends IAttribute {
|
76
|
+
$ref: string;
|
77
|
+
}
|
78
|
+
|
79
|
+
interface ISignificant<Type extends string> extends IAttribute {
|
80
|
+
type: Type;
|
81
|
+
nullable?: boolean;
|
82
|
+
}
|
83
|
+
interface IAttribute {
|
84
|
+
title?: string;
|
85
|
+
description?: string;
|
86
|
+
deprecated?: boolean;
|
87
|
+
"x-typia-optional"?: boolean;
|
88
|
+
"x-typia-rest"?: boolean;
|
89
|
+
}
|
90
|
+
}
|
@@ -1,80 +1,80 @@
|
|
1
|
-
/**
|
2
|
-
* Information about the API.
|
3
|
-
*
|
4
|
-
* @author Samchon
|
5
|
-
*/
|
6
|
-
export interface ISwaggerInfo {
|
7
|
-
/**
|
8
|
-
* The title of the API.
|
9
|
-
*/
|
10
|
-
title: string;
|
11
|
-
|
12
|
-
/**
|
13
|
-
* A short description of the API.
|
14
|
-
*/
|
15
|
-
description?: string;
|
16
|
-
|
17
|
-
/**
|
18
|
-
* A URL to the Terms of Service for the API.
|
19
|
-
*
|
20
|
-
* @format uri
|
21
|
-
*/
|
22
|
-
termsOfService?: string;
|
23
|
-
|
24
|
-
/**
|
25
|
-
* The contact information for the exposed API.
|
26
|
-
*/
|
27
|
-
contact?: ISwaggerInfo.IContact;
|
28
|
-
|
29
|
-
/**
|
30
|
-
* The license information for the exposed API.
|
31
|
-
*/
|
32
|
-
license?: ISwaggerInfo.ILicense;
|
33
|
-
|
34
|
-
/**
|
35
|
-
* Version of the API.
|
36
|
-
*/
|
37
|
-
version: string;
|
38
|
-
}
|
39
|
-
export namespace ISwaggerInfo {
|
40
|
-
/**
|
41
|
-
* Contact information for the exposed API.
|
42
|
-
*/
|
43
|
-
export interface IContact {
|
44
|
-
/**
|
45
|
-
* The identifying name of the contact person/organization.
|
46
|
-
*/
|
47
|
-
name?: string;
|
48
|
-
|
49
|
-
/**
|
50
|
-
* The URL pointing to the contact information.
|
51
|
-
*
|
52
|
-
* @format uri
|
53
|
-
*/
|
54
|
-
url?: string;
|
55
|
-
|
56
|
-
/**
|
57
|
-
* The email address of the contact person/organization.
|
58
|
-
*
|
59
|
-
* @format email
|
60
|
-
*/
|
61
|
-
email?: string;
|
62
|
-
}
|
63
|
-
|
64
|
-
/**
|
65
|
-
* License information for the exposed API.
|
66
|
-
*/
|
67
|
-
export interface ILicense {
|
68
|
-
/**
|
69
|
-
* The license name used for the API.
|
70
|
-
*/
|
71
|
-
name: string;
|
72
|
-
|
73
|
-
/**
|
74
|
-
* A URL to the license used for the API.
|
75
|
-
*
|
76
|
-
* @format uri
|
77
|
-
*/
|
78
|
-
url?: string;
|
79
|
-
}
|
80
|
-
}
|
1
|
+
/**
|
2
|
+
* Information about the API.
|
3
|
+
*
|
4
|
+
* @author Samchon
|
5
|
+
*/
|
6
|
+
export interface ISwaggerInfo {
|
7
|
+
/**
|
8
|
+
* The title of the API.
|
9
|
+
*/
|
10
|
+
title: string;
|
11
|
+
|
12
|
+
/**
|
13
|
+
* A short description of the API.
|
14
|
+
*/
|
15
|
+
description?: string;
|
16
|
+
|
17
|
+
/**
|
18
|
+
* A URL to the Terms of Service for the API.
|
19
|
+
*
|
20
|
+
* @format uri
|
21
|
+
*/
|
22
|
+
termsOfService?: string;
|
23
|
+
|
24
|
+
/**
|
25
|
+
* The contact information for the exposed API.
|
26
|
+
*/
|
27
|
+
contact?: ISwaggerInfo.IContact;
|
28
|
+
|
29
|
+
/**
|
30
|
+
* The license information for the exposed API.
|
31
|
+
*/
|
32
|
+
license?: ISwaggerInfo.ILicense;
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Version of the API.
|
36
|
+
*/
|
37
|
+
version: string;
|
38
|
+
}
|
39
|
+
export namespace ISwaggerInfo {
|
40
|
+
/**
|
41
|
+
* Contact information for the exposed API.
|
42
|
+
*/
|
43
|
+
export interface IContact {
|
44
|
+
/**
|
45
|
+
* The identifying name of the contact person/organization.
|
46
|
+
*/
|
47
|
+
name?: string;
|
48
|
+
|
49
|
+
/**
|
50
|
+
* The URL pointing to the contact information.
|
51
|
+
*
|
52
|
+
* @format uri
|
53
|
+
*/
|
54
|
+
url?: string;
|
55
|
+
|
56
|
+
/**
|
57
|
+
* The email address of the contact person/organization.
|
58
|
+
*
|
59
|
+
* @format email
|
60
|
+
*/
|
61
|
+
email?: string;
|
62
|
+
}
|
63
|
+
|
64
|
+
/**
|
65
|
+
* License information for the exposed API.
|
66
|
+
*/
|
67
|
+
export interface ILicense {
|
68
|
+
/**
|
69
|
+
* The license name used for the API.
|
70
|
+
*/
|
71
|
+
name: string;
|
72
|
+
|
73
|
+
/**
|
74
|
+
* A URL to the license used for the API.
|
75
|
+
*
|
76
|
+
* @format uri
|
77
|
+
*/
|
78
|
+
url?: string;
|
79
|
+
}
|
80
|
+
}
|
package/src/utils/FilePrinter.ts
CHANGED
@@ -1,36 +1,36 @@
|
|
1
|
-
import ts from "typescript";
|
2
|
-
|
3
|
-
export namespace FilePrinter {
|
4
|
-
export const description = <Node extends ts.Node>(
|
5
|
-
node: Node,
|
6
|
-
comment: string,
|
7
|
-
): Node => {
|
8
|
-
if (comment.length === 0) return node;
|
9
|
-
ts.addSyntheticLeadingComment(
|
10
|
-
node,
|
11
|
-
ts.SyntaxKind.MultiLineCommentTrivia,
|
12
|
-
["*", ...comment.split("\n").map((str) => ` * ${str}`), ""].join("\n"),
|
13
|
-
true,
|
14
|
-
);
|
15
|
-
return node;
|
16
|
-
};
|
17
|
-
|
18
|
-
export const
|
19
|
-
ts.factory.createExpressionStatement(ts.factory.createIdentifier("\n"));
|
20
|
-
|
21
|
-
export const write = (props: {
|
22
|
-
statements: ts.Statement[];
|
23
|
-
top?: string;
|
24
|
-
}): string => {
|
25
|
-
const script: string = ts
|
26
|
-
.createPrinter()
|
27
|
-
.printFile(
|
28
|
-
ts.factory.createSourceFile(
|
29
|
-
props.statements,
|
30
|
-
ts.factory.createToken(ts.SyntaxKind.EndOfFileToken),
|
31
|
-
ts.NodeFlags.None,
|
32
|
-
),
|
33
|
-
);
|
34
|
-
return (props.top ?? "") + script;
|
35
|
-
};
|
36
|
-
}
|
1
|
+
import ts from "typescript";
|
2
|
+
|
3
|
+
export namespace FilePrinter {
|
4
|
+
export const description = <Node extends ts.Node>(
|
5
|
+
node: Node,
|
6
|
+
comment: string,
|
7
|
+
): Node => {
|
8
|
+
if (comment.length === 0) return node;
|
9
|
+
ts.addSyntheticLeadingComment(
|
10
|
+
node,
|
11
|
+
ts.SyntaxKind.MultiLineCommentTrivia,
|
12
|
+
["*", ...comment.split("\n").map((str) => ` * ${str}`), ""].join("\n"),
|
13
|
+
true,
|
14
|
+
);
|
15
|
+
return node;
|
16
|
+
};
|
17
|
+
|
18
|
+
export const newLine = () =>
|
19
|
+
ts.factory.createExpressionStatement(ts.factory.createIdentifier("\n"));
|
20
|
+
|
21
|
+
export const write = (props: {
|
22
|
+
statements: ts.Statement[];
|
23
|
+
top?: string;
|
24
|
+
}): string => {
|
25
|
+
const script: string = ts
|
26
|
+
.createPrinter()
|
27
|
+
.printFile(
|
28
|
+
ts.factory.createSourceFile(
|
29
|
+
props.statements,
|
30
|
+
ts.factory.createToken(ts.SyntaxKind.EndOfFileToken),
|
31
|
+
ts.NodeFlags.None,
|
32
|
+
),
|
33
|
+
);
|
34
|
+
return (props.top ?? "") + script;
|
35
|
+
};
|
36
|
+
}
|
package/src/utils/SetupWizard.ts
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
import cp from "child_process";
|
2
|
-
|
3
|
-
export namespace SetupWizard {
|
4
|
-
export const setup = (output: string) => {
|
5
|
-
execute(output)("npm install");
|
6
|
-
};
|
7
|
-
|
8
|
-
const execute = (cwd: string) => (command: string, fake?: string) => {
|
9
|
-
console.log(fake ?? command);
|
10
|
-
cp.execSync(command, { cwd, stdio: "inherit" });
|
11
|
-
};
|
12
|
-
}
|
1
|
+
import cp from "child_process";
|
2
|
+
|
3
|
+
export namespace SetupWizard {
|
4
|
+
export const setup = (output: string) => {
|
5
|
+
execute(output)("npm install");
|
6
|
+
};
|
7
|
+
|
8
|
+
const execute = (cwd: string) => (command: string, fake?: string) => {
|
9
|
+
console.log(fake ?? command);
|
10
|
+
cp.execSync(command, { cwd, stdio: "inherit" });
|
11
|
+
};
|
12
|
+
}
|
package/src/utils/StringUtil.ts
CHANGED
@@ -1,60 +1,60 @@
|
|
1
|
-
import { NamingConvention } from "typia/lib/utils/NamingConvention";
|
2
|
-
|
3
|
-
export namespace StringUtil {
|
4
|
-
export const capitalize = (str: string) =>
|
5
|
-
str[0].toUpperCase() + str.slice(1).toLowerCase();
|
6
|
-
|
7
|
-
export const pascal = (path: string) =>
|
8
|
-
splitWithNormalization(path)
|
9
|
-
.filter((str) => str[0] !== "{")
|
10
|
-
.map(NamingConvention.pascal)
|
11
|
-
.join("");
|
12
|
-
|
13
|
-
export const camel = (path: string) =>
|
14
|
-
splitWithNormalization(path)
|
15
|
-
.map((str, i) =>
|
16
|
-
i === 0 ? NamingConvention.camel(str) : NamingConvention.pascal(str),
|
17
|
-
)
|
18
|
-
.join("");
|
19
|
-
|
20
|
-
export const splitWithNormalization = (path: string) =>
|
21
|
-
path
|
22
|
-
.split("/")
|
23
|
-
.map((str) => normalize(str.trim()))
|
24
|
-
.filter((str) => !!str.length);
|
25
|
-
|
26
|
-
export const reJoinWithDecimalParameters = (path: string) =>
|
27
|
-
path
|
28
|
-
.split("/")
|
29
|
-
.filter((str) => !!str.length)
|
30
|
-
.map((str) =>
|
31
|
-
str[0] === "{" && str[str.length - 1] === "}"
|
32
|
-
? `:${str.substring(1, str.length - 1)}`
|
33
|
-
: str,
|
34
|
-
)
|
35
|
-
.join("/");
|
36
|
-
|
37
|
-
export const normalize = (str: string) =>
|
38
|
-
str.split(".").join("_").split("-").join("_");
|
39
|
-
|
40
|
-
export const commonPrefix = (strs: string[]): string => {
|
41
|
-
if (strs.length === 0) return "";
|
42
|
-
|
43
|
-
let prefix = strs[0];
|
44
|
-
for (let i = 1; i < strs.length; i++) {
|
45
|
-
while (strs[i].indexOf(prefix) !== 0) {
|
46
|
-
prefix = prefix.substring(0, prefix.length - 1);
|
47
|
-
if (prefix === "") return "";
|
48
|
-
}
|
49
|
-
}
|
50
|
-
return prefix
|
51
|
-
.split("/")
|
52
|
-
.filter((str) => str[0] !== "{" || str[str.length - 1] === "}")
|
53
|
-
.join("/");
|
54
|
-
};
|
55
|
-
|
56
|
-
export const escapeDuplicate =
|
57
|
-
(keep: string[]) =>
|
58
|
-
(change: string): string =>
|
59
|
-
keep.includes(change) ? escapeDuplicate(keep)(`_${change}`) : change;
|
60
|
-
}
|
1
|
+
import { NamingConvention } from "typia/lib/utils/NamingConvention";
|
2
|
+
|
3
|
+
export namespace StringUtil {
|
4
|
+
export const capitalize = (str: string) =>
|
5
|
+
str[0].toUpperCase() + str.slice(1).toLowerCase();
|
6
|
+
|
7
|
+
export const pascal = (path: string) =>
|
8
|
+
splitWithNormalization(path)
|
9
|
+
.filter((str) => str[0] !== "{")
|
10
|
+
.map(NamingConvention.pascal)
|
11
|
+
.join("");
|
12
|
+
|
13
|
+
export const camel = (path: string) =>
|
14
|
+
splitWithNormalization(path)
|
15
|
+
.map((str, i) =>
|
16
|
+
i === 0 ? NamingConvention.camel(str) : NamingConvention.pascal(str),
|
17
|
+
)
|
18
|
+
.join("");
|
19
|
+
|
20
|
+
export const splitWithNormalization = (path: string) =>
|
21
|
+
path
|
22
|
+
.split("/")
|
23
|
+
.map((str) => normalize(str.trim()))
|
24
|
+
.filter((str) => !!str.length);
|
25
|
+
|
26
|
+
export const reJoinWithDecimalParameters = (path: string) =>
|
27
|
+
path
|
28
|
+
.split("/")
|
29
|
+
.filter((str) => !!str.length)
|
30
|
+
.map((str) =>
|
31
|
+
str[0] === "{" && str[str.length - 1] === "}"
|
32
|
+
? `:${str.substring(1, str.length - 1)}`
|
33
|
+
: str,
|
34
|
+
)
|
35
|
+
.join("/");
|
36
|
+
|
37
|
+
export const normalize = (str: string) =>
|
38
|
+
str.split(".").join("_").split("-").join("_");
|
39
|
+
|
40
|
+
export const commonPrefix = (strs: string[]): string => {
|
41
|
+
if (strs.length === 0) return "";
|
42
|
+
|
43
|
+
let prefix = strs[0];
|
44
|
+
for (let i = 1; i < strs.length; i++) {
|
45
|
+
while (strs[i].indexOf(prefix) !== 0) {
|
46
|
+
prefix = prefix.substring(0, prefix.length - 1);
|
47
|
+
if (prefix === "") return "";
|
48
|
+
}
|
49
|
+
}
|
50
|
+
return prefix
|
51
|
+
.split("/")
|
52
|
+
.filter((str) => str[0] !== "{" || str[str.length - 1] === "}")
|
53
|
+
.join("/");
|
54
|
+
};
|
55
|
+
|
56
|
+
export const escapeDuplicate =
|
57
|
+
(keep: string[]) =>
|
58
|
+
(change: string): string =>
|
59
|
+
keep.includes(change) ? escapeDuplicate(keep)(`_${change}`) : change;
|
60
|
+
}
|