@odata2ts/odata2ts 0.23.1 → 0.25.0

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.
Files changed (78) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/lib/FactoryFunctionModel.d.ts +13 -13
  3. package/lib/FactoryFunctionModel.js +2 -2
  4. package/lib/FactoryFunctionModel.js.map +1 -1
  5. package/lib/NamingModel.d.ts +182 -182
  6. package/lib/NamingModel.js +11 -11
  7. package/lib/NamingModel.js.map +1 -1
  8. package/lib/OptionModel.d.ts +228 -223
  9. package/lib/OptionModel.js +23 -23
  10. package/lib/OptionModel.js.map +1 -1
  11. package/lib/app.d.ts +8 -8
  12. package/lib/app.js +67 -63
  13. package/lib/app.js.map +1 -1
  14. package/lib/cli.d.ts +3 -3
  15. package/lib/cli.js +153 -153
  16. package/lib/data-model/DataModel.d.ts +88 -85
  17. package/lib/data-model/DataModel.js +141 -134
  18. package/lib/data-model/DataModel.js.map +1 -1
  19. package/lib/data-model/DataModelDigestion.d.ts +48 -44
  20. package/lib/data-model/DataModelDigestion.js +299 -274
  21. package/lib/data-model/DataModelDigestion.js.map +1 -1
  22. package/lib/data-model/DataModelDigestionV2.d.ts +10 -10
  23. package/lib/data-model/DataModelDigestionV2.js +210 -200
  24. package/lib/data-model/DataModelDigestionV2.js.map +1 -1
  25. package/lib/data-model/DataModelDigestionV4.d.ts +3 -3
  26. package/lib/data-model/DataModelDigestionV4.js +197 -195
  27. package/lib/data-model/DataModelDigestionV4.js.map +1 -1
  28. package/lib/data-model/DataTypeModel.d.ts +102 -102
  29. package/lib/data-model/DataTypeModel.js +8 -8
  30. package/lib/data-model/DataTypeModel.js.map +1 -1
  31. package/lib/data-model/NamingHelper.d.ts +57 -55
  32. package/lib/data-model/NamingHelper.js +231 -214
  33. package/lib/data-model/NamingHelper.js.map +1 -1
  34. package/lib/data-model/ServiceConfigHelper.d.ts +21 -21
  35. package/lib/data-model/ServiceConfigHelper.js +113 -113
  36. package/lib/data-model/edmx/ODataEdmxModelBase.d.ts +92 -80
  37. package/lib/data-model/edmx/ODataEdmxModelBase.js +2 -2
  38. package/lib/data-model/edmx/ODataEdmxModelBase.js.map +1 -1
  39. package/lib/data-model/edmx/ODataEdmxModelV3.d.ts +63 -63
  40. package/lib/data-model/edmx/ODataEdmxModelV3.js +2 -2
  41. package/lib/data-model/edmx/ODataEdmxModelV4.d.ts +67 -67
  42. package/lib/data-model/edmx/ODataEdmxModelV4.js +2 -2
  43. package/lib/defaultConfig.d.ts +9 -9
  44. package/lib/defaultConfig.js +165 -164
  45. package/lib/defaultConfig.js.map +1 -1
  46. package/lib/evaluateConfig.d.ts +25 -25
  47. package/lib/evaluateConfig.js +82 -82
  48. package/lib/generator/ImportContainer.d.ts +16 -16
  49. package/lib/generator/ImportContainer.js +91 -91
  50. package/lib/generator/ModelGenerator.d.ts +2 -2
  51. package/lib/generator/ModelGenerator.js +211 -183
  52. package/lib/generator/ModelGenerator.js.map +1 -1
  53. package/lib/generator/QueryObjectGenerator.d.ts +2 -2
  54. package/lib/generator/QueryObjectGenerator.js +239 -239
  55. package/lib/generator/ServiceGenerator.d.ts +8 -8
  56. package/lib/generator/ServiceGenerator.js +422 -422
  57. package/lib/generator/index.d.ts +3 -3
  58. package/lib/generator/index.js +9 -9
  59. package/lib/index.d.ts +3 -3
  60. package/lib/index.js +6 -6
  61. package/lib/project/ProjectManager.d.ts +30 -30
  62. package/lib/project/ProjectManager.js +177 -175
  63. package/lib/project/ProjectManager.js.map +1 -1
  64. package/lib/project/formatter/BaseFormatter.d.ts +49 -49
  65. package/lib/project/formatter/BaseFormatter.js +30 -30
  66. package/lib/project/formatter/FileFormatter.d.ts +16 -16
  67. package/lib/project/formatter/FileFormatter.js +2 -2
  68. package/lib/project/formatter/NoopFormatter.d.ts +29 -29
  69. package/lib/project/formatter/NoopFormatter.js +42 -42
  70. package/lib/project/formatter/PrettierFormatter.d.ts +46 -46
  71. package/lib/project/formatter/PrettierFormatter.js +92 -92
  72. package/lib/project/formatter/index.d.ts +2 -2
  73. package/lib/project/formatter/index.js +14 -14
  74. package/lib/project/logger/logFilePath.d.ts +1 -1
  75. package/lib/project/logger/logFilePath.js +12 -12
  76. package/lib/run-cli.d.ts +2 -2
  77. package/lib/run-cli.js +6 -6
  78. package/package.json +27 -28
@@ -1,49 +1,49 @@
1
- import { ManipulationSettings } from "ts-morph";
2
- import { FileFormatter } from "./FileFormatter";
3
- /**
4
- * Abstract formatter.
5
- *
6
- * @export
7
- * @abstract
8
- * @class Formatter
9
- */
10
- export declare abstract class BaseFormatter implements FileFormatter {
11
- /**
12
- * Path of the output file.
13
- *
14
- * @protected
15
- * @type {string}
16
- * @memberof Formatter
17
- */
18
- protected output: string;
19
- /**
20
- * Initialized ts-morph manipulation settings for project creation.
21
- *
22
- * @protected
23
- * @type {Partial<ManipulationSettings>}
24
- * @memberof Formatter
25
- */
26
- protected settings: Partial<ManipulationSettings>;
27
- /**
28
- * Default constructor
29
- * @param {string} output Path of the output file
30
- * @memberof Formatter
31
- */
32
- constructor(output: string);
33
- /**
34
- * Initializes the formatter.
35
- *
36
- * @abstract
37
- * @returns {Promise<BaseFormatter>} Initialized formatter
38
- * @memberof Formatter
39
- */
40
- abstract init(): Promise<BaseFormatter>;
41
- /**
42
- * Returns initialized ts-morph manipuation settings.
43
- *
44
- * @returns {Promise<Partial<ManipulationSettings>>} ts-morph manipulation settings
45
- * @memberof Formatter
46
- */
47
- getSettings(): Partial<ManipulationSettings>;
48
- abstract format(source: string): Promise<string>;
49
- }
1
+ import { ManipulationSettings } from "ts-morph";
2
+ import { FileFormatter } from "./FileFormatter";
3
+ /**
4
+ * Abstract formatter.
5
+ *
6
+ * @export
7
+ * @abstract
8
+ * @class Formatter
9
+ */
10
+ export declare abstract class BaseFormatter implements FileFormatter {
11
+ /**
12
+ * Path of the output file.
13
+ *
14
+ * @protected
15
+ * @type {string}
16
+ * @memberof Formatter
17
+ */
18
+ protected output: string;
19
+ /**
20
+ * Initialized ts-morph manipulation settings for project creation.
21
+ *
22
+ * @protected
23
+ * @type {Partial<ManipulationSettings>}
24
+ * @memberof Formatter
25
+ */
26
+ protected settings: Partial<ManipulationSettings>;
27
+ /**
28
+ * Default constructor
29
+ * @param {string} output Path of the output file
30
+ * @memberof Formatter
31
+ */
32
+ constructor(output: string);
33
+ /**
34
+ * Initializes the formatter.
35
+ *
36
+ * @abstract
37
+ * @returns {Promise<BaseFormatter>} Initialized formatter
38
+ * @memberof Formatter
39
+ */
40
+ abstract init(): Promise<BaseFormatter>;
41
+ /**
42
+ * Returns initialized ts-morph manipuation settings.
43
+ *
44
+ * @returns {Promise<Partial<ManipulationSettings>>} ts-morph manipulation settings
45
+ * @memberof Formatter
46
+ */
47
+ getSettings(): Partial<ManipulationSettings>;
48
+ abstract format(source: string): Promise<string>;
49
+ }
@@ -1,31 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseFormatter = void 0;
4
- /**
5
- * Abstract formatter.
6
- *
7
- * @export
8
- * @abstract
9
- * @class Formatter
10
- */
11
- class BaseFormatter {
12
- /**
13
- * Default constructor
14
- * @param {string} output Path of the output file
15
- * @memberof Formatter
16
- */
17
- constructor(output) {
18
- this.output = output;
19
- }
20
- /**
21
- * Returns initialized ts-morph manipuation settings.
22
- *
23
- * @returns {Promise<Partial<ManipulationSettings>>} ts-morph manipulation settings
24
- * @memberof Formatter
25
- */
26
- getSettings() {
27
- return this.settings;
28
- }
29
- }
30
- exports.BaseFormatter = BaseFormatter;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseFormatter = void 0;
4
+ /**
5
+ * Abstract formatter.
6
+ *
7
+ * @export
8
+ * @abstract
9
+ * @class Formatter
10
+ */
11
+ class BaseFormatter {
12
+ /**
13
+ * Default constructor
14
+ * @param {string} output Path of the output file
15
+ * @memberof Formatter
16
+ */
17
+ constructor(output) {
18
+ this.output = output;
19
+ }
20
+ /**
21
+ * Returns initialized ts-morph manipuation settings.
22
+ *
23
+ * @returns {Promise<Partial<ManipulationSettings>>} ts-morph manipulation settings
24
+ * @memberof Formatter
25
+ */
26
+ getSettings() {
27
+ return this.settings;
28
+ }
29
+ }
30
+ exports.BaseFormatter = BaseFormatter;
31
31
  //# sourceMappingURL=BaseFormatter.js.map
@@ -1,16 +1,16 @@
1
- import { ManipulationSettings } from "ts-morph";
2
- export interface FileFormatter {
3
- /**
4
- * Returns initialized ts-morph manipulation settings.
5
- *
6
- * @returns {Partial<ManipulationSettings>} ts-morph manipulation settings
7
- */
8
- getSettings(): Partial<ManipulationSettings>;
9
- /**
10
- * Formats a given source code.
11
- *
12
- * @param {string} source Source code to format
13
- * @returns {string} Formatted source code
14
- */
15
- format(source: string): Promise<string>;
16
- }
1
+ import { ManipulationSettings } from "ts-morph";
2
+ export interface FileFormatter {
3
+ /**
4
+ * Returns initialized ts-morph manipulation settings.
5
+ *
6
+ * @returns {Partial<ManipulationSettings>} ts-morph manipulation settings
7
+ */
8
+ getSettings(): Partial<ManipulationSettings>;
9
+ /**
10
+ * Formats a given source code.
11
+ *
12
+ * @param {string} source Source code to format
13
+ * @returns {string} Formatted source code
14
+ */
15
+ format(source: string): Promise<string>;
16
+ }
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=FileFormatter.js.map
@@ -1,29 +1,29 @@
1
- import { BaseFormatter } from "./BaseFormatter";
2
- /**
3
- * Prettier formatter.
4
- *
5
- * NOTE: Should be created like this => const formatter = await new NoopFormatter("./test.ts").init();
6
- *
7
- * @export
8
- * @class NoopFormatter
9
- * @extends {Formatter}
10
- */
11
- export declare class NoopFormatter extends BaseFormatter {
12
- /**
13
- * Initializes the formatter.
14
- *
15
- * @abstract
16
- * @returns {Promise<Formatter>} Initialized formatter
17
- * @memberof Formatter
18
- */
19
- init(): Promise<BaseFormatter>;
20
- /**
21
- * Formats a given source code.
22
- *
23
- * @abstract
24
- * @param {string} source Source code to format
25
- * @returns {string} Formatted source code
26
- * @memberof Formatter
27
- */
28
- format(source: string): Promise<string>;
29
- }
1
+ import { BaseFormatter } from "./BaseFormatter";
2
+ /**
3
+ * Prettier formatter.
4
+ *
5
+ * NOTE: Should be created like this => const formatter = await new NoopFormatter("./test.ts").init();
6
+ *
7
+ * @export
8
+ * @class NoopFormatter
9
+ * @extends {Formatter}
10
+ */
11
+ export declare class NoopFormatter extends BaseFormatter {
12
+ /**
13
+ * Initializes the formatter.
14
+ *
15
+ * @abstract
16
+ * @returns {Promise<Formatter>} Initialized formatter
17
+ * @memberof Formatter
18
+ */
19
+ init(): Promise<BaseFormatter>;
20
+ /**
21
+ * Formats a given source code.
22
+ *
23
+ * @abstract
24
+ * @param {string} source Source code to format
25
+ * @returns {string} Formatted source code
26
+ * @memberof Formatter
27
+ */
28
+ format(source: string): Promise<string>;
29
+ }
@@ -1,43 +1,43 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NoopFormatter = void 0;
4
- const tslib_1 = require("tslib");
5
- const BaseFormatter_1 = require("./BaseFormatter");
6
- /**
7
- * Prettier formatter.
8
- *
9
- * NOTE: Should be created like this => const formatter = await new NoopFormatter("./test.ts").init();
10
- *
11
- * @export
12
- * @class NoopFormatter
13
- * @extends {Formatter}
14
- */
15
- class NoopFormatter extends BaseFormatter_1.BaseFormatter {
16
- /**
17
- * Initializes the formatter.
18
- *
19
- * @abstract
20
- * @returns {Promise<Formatter>} Initialized formatter
21
- * @memberof Formatter
22
- */
23
- init() {
24
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
25
- return this;
26
- });
27
- }
28
- /**
29
- * Formats a given source code.
30
- *
31
- * @abstract
32
- * @param {string} source Source code to format
33
- * @returns {string} Formatted source code
34
- * @memberof Formatter
35
- */
36
- format(source) {
37
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
38
- return source;
39
- });
40
- }
41
- }
42
- exports.NoopFormatter = NoopFormatter;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoopFormatter = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const BaseFormatter_1 = require("./BaseFormatter");
6
+ /**
7
+ * Prettier formatter.
8
+ *
9
+ * NOTE: Should be created like this => const formatter = await new NoopFormatter("./test.ts").init();
10
+ *
11
+ * @export
12
+ * @class NoopFormatter
13
+ * @extends {Formatter}
14
+ */
15
+ class NoopFormatter extends BaseFormatter_1.BaseFormatter {
16
+ /**
17
+ * Initializes the formatter.
18
+ *
19
+ * @abstract
20
+ * @returns {Promise<Formatter>} Initialized formatter
21
+ * @memberof Formatter
22
+ */
23
+ init() {
24
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
25
+ return this;
26
+ });
27
+ }
28
+ /**
29
+ * Formats a given source code.
30
+ *
31
+ * @abstract
32
+ * @param {string} source Source code to format
33
+ * @returns {string} Formatted source code
34
+ * @memberof Formatter
35
+ */
36
+ format(source) {
37
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
38
+ return source;
39
+ });
40
+ }
41
+ }
42
+ exports.NoopFormatter = NoopFormatter;
43
43
  //# sourceMappingURL=NoopFormatter.js.map
@@ -1,46 +1,46 @@
1
- import { BaseFormatter } from "./BaseFormatter";
2
- export declare class PrettierFormatter extends BaseFormatter {
3
- /**
4
- * Prettier options found in the project.
5
- *
6
- * @private
7
- * @type {prettier.Options}
8
- * @memberof PrettierFormatter
9
- */
10
- private options;
11
- /**
12
- * Initializes the formatter.
13
- *
14
- * @returns {Promise<PrettierFormatter>} Initialized formatter
15
- * @memberof PrettierFormatter
16
- */
17
- init(): Promise<PrettierFormatter>;
18
- /**
19
- * Formats a given source code.
20
- *
21
- * @abstract
22
- * @param {string} source Source code to format
23
- * @returns {string} Formatted source code
24
- * @memberof Formatter
25
- */
26
- format(source: string): Promise<string>;
27
- /**
28
- * Converts prettier indentation config to ts-morph settings.
29
- *
30
- * @private
31
- * @param {boolean | undefined} useTabs Flag, whether to use tabs or not
32
- * @param {number | undefined} tabWidth Width of a simulated tab, each number represents a space
33
- * @returns {IndentationText} Converted indentation text
34
- * @memberof PrettierFormatter
35
- */
36
- private convertIndentation;
37
- /**
38
- * Converts prettier newline config to ts-morph settings.
39
- *
40
- * @private
41
- * @param {string | undefined} eol prettier end-of-line config
42
- * @returns {NewLineKind | undefined} Converted new line kind
43
- * @memberof PrettierFormatter
44
- */
45
- private convertNewline;
46
- }
1
+ import { BaseFormatter } from "./BaseFormatter";
2
+ export declare class PrettierFormatter extends BaseFormatter {
3
+ /**
4
+ * Prettier options found in the project.
5
+ *
6
+ * @private
7
+ * @type {prettier.Options}
8
+ * @memberof PrettierFormatter
9
+ */
10
+ private options;
11
+ /**
12
+ * Initializes the formatter.
13
+ *
14
+ * @returns {Promise<PrettierFormatter>} Initialized formatter
15
+ * @memberof PrettierFormatter
16
+ */
17
+ init(): Promise<PrettierFormatter>;
18
+ /**
19
+ * Formats a given source code.
20
+ *
21
+ * @abstract
22
+ * @param {string} source Source code to format
23
+ * @returns {string} Formatted source code
24
+ * @memberof Formatter
25
+ */
26
+ format(source: string): Promise<string>;
27
+ /**
28
+ * Converts prettier indentation config to ts-morph settings.
29
+ *
30
+ * @private
31
+ * @param {boolean | undefined} useTabs Flag, whether to use tabs or not
32
+ * @param {number | undefined} tabWidth Width of a simulated tab, each number represents a space
33
+ * @returns {IndentationText} Converted indentation text
34
+ * @memberof PrettierFormatter
35
+ */
36
+ private convertIndentation;
37
+ /**
38
+ * Converts prettier newline config to ts-morph settings.
39
+ *
40
+ * @private
41
+ * @param {string | undefined} eol prettier end-of-line config
42
+ * @returns {NewLineKind | undefined} Converted new line kind
43
+ * @memberof PrettierFormatter
44
+ */
45
+ private convertNewline;
46
+ }
@@ -1,93 +1,93 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PrettierFormatter = void 0;
4
- const tslib_1 = require("tslib");
5
- const prettier_1 = tslib_1.__importDefault(require("prettier"));
6
- const ts_morph_1 = require("ts-morph");
7
- const BaseFormatter_1 = require("./BaseFormatter");
8
- class PrettierFormatter extends BaseFormatter_1.BaseFormatter {
9
- /**
10
- * Initializes the formatter.
11
- *
12
- * @returns {Promise<PrettierFormatter>} Initialized formatter
13
- * @memberof PrettierFormatter
14
- */
15
- init() {
16
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
- const options = yield prettier_1.default.resolveConfig(this.output);
18
- if (options) {
19
- this.options = options;
20
- this.settings = {
21
- indentationText: this.convertIndentation(this.options.useTabs, this.options.tabWidth),
22
- insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: this.options.bracketSpacing !== undefined ? this.options.bracketSpacing : true,
23
- newLineKind: this.convertNewline(this.options.endOfLine),
24
- quoteKind: this.options.singleQuote ? ts_morph_1.QuoteKind.Single : ts_morph_1.QuoteKind.Double,
25
- useTrailingCommas: this.options.trailingComma === "none" ? false : true,
26
- };
27
- }
28
- else
29
- this.settings = {};
30
- return this;
31
- });
32
- }
33
- /**
34
- * Formats a given source code.
35
- *
36
- * @abstract
37
- * @param {string} source Source code to format
38
- * @returns {string} Formatted source code
39
- * @memberof Formatter
40
- */
41
- format(source) {
42
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
43
- return prettier_1.default.format(source, Object.assign({ parser: "typescript" }, this.options));
44
- });
45
- }
46
- /**
47
- * Converts prettier indentation config to ts-morph settings.
48
- *
49
- * @private
50
- * @param {boolean | undefined} useTabs Flag, whether to use tabs or not
51
- * @param {number | undefined} tabWidth Width of a simulated tab, each number represents a space
52
- * @returns {IndentationText} Converted indentation text
53
- * @memberof PrettierFormatter
54
- */
55
- convertIndentation(useTabs, tabWidth) {
56
- if (useTabs)
57
- return ts_morph_1.IndentationText.Tab;
58
- switch (tabWidth) {
59
- case 2:
60
- return ts_morph_1.IndentationText.TwoSpaces;
61
- case 4:
62
- return ts_morph_1.IndentationText.FourSpaces;
63
- case 8:
64
- return ts_morph_1.IndentationText.EightSpaces;
65
- default:
66
- return ts_morph_1.IndentationText.TwoSpaces;
67
- }
68
- }
69
- /**
70
- * Converts prettier newline config to ts-morph settings.
71
- *
72
- * @private
73
- * @param {string | undefined} eol prettier end-of-line config
74
- * @returns {NewLineKind | undefined} Converted new line kind
75
- * @memberof PrettierFormatter
76
- */
77
- convertNewline(eol) {
78
- switch (eol) {
79
- case "lf":
80
- return ts_morph_1.NewLineKind.LineFeed;
81
- case "crlf":
82
- return ts_morph_1.NewLineKind.CarriageReturnLineFeed;
83
- case "cr":
84
- return ts_morph_1.NewLineKind.CarriageReturnLineFeed;
85
- case "auto":
86
- return ts_morph_1.NewLineKind.LineFeed;
87
- default:
88
- return ts_morph_1.NewLineKind.LineFeed;
89
- }
90
- }
91
- }
92
- exports.PrettierFormatter = PrettierFormatter;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrettierFormatter = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const prettier_1 = tslib_1.__importDefault(require("prettier"));
6
+ const ts_morph_1 = require("ts-morph");
7
+ const BaseFormatter_1 = require("./BaseFormatter");
8
+ class PrettierFormatter extends BaseFormatter_1.BaseFormatter {
9
+ /**
10
+ * Initializes the formatter.
11
+ *
12
+ * @returns {Promise<PrettierFormatter>} Initialized formatter
13
+ * @memberof PrettierFormatter
14
+ */
15
+ init() {
16
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
+ const options = yield prettier_1.default.resolveConfig(this.output);
18
+ if (options) {
19
+ this.options = options;
20
+ this.settings = {
21
+ indentationText: this.convertIndentation(this.options.useTabs, this.options.tabWidth),
22
+ insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: this.options.bracketSpacing !== undefined ? this.options.bracketSpacing : true,
23
+ newLineKind: this.convertNewline(this.options.endOfLine),
24
+ quoteKind: this.options.singleQuote ? ts_morph_1.QuoteKind.Single : ts_morph_1.QuoteKind.Double,
25
+ useTrailingCommas: this.options.trailingComma === "none" ? false : true,
26
+ };
27
+ }
28
+ else
29
+ this.settings = {};
30
+ return this;
31
+ });
32
+ }
33
+ /**
34
+ * Formats a given source code.
35
+ *
36
+ * @abstract
37
+ * @param {string} source Source code to format
38
+ * @returns {string} Formatted source code
39
+ * @memberof Formatter
40
+ */
41
+ format(source) {
42
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
43
+ return prettier_1.default.format(source, Object.assign({ parser: "typescript" }, this.options));
44
+ });
45
+ }
46
+ /**
47
+ * Converts prettier indentation config to ts-morph settings.
48
+ *
49
+ * @private
50
+ * @param {boolean | undefined} useTabs Flag, whether to use tabs or not
51
+ * @param {number | undefined} tabWidth Width of a simulated tab, each number represents a space
52
+ * @returns {IndentationText} Converted indentation text
53
+ * @memberof PrettierFormatter
54
+ */
55
+ convertIndentation(useTabs, tabWidth) {
56
+ if (useTabs)
57
+ return ts_morph_1.IndentationText.Tab;
58
+ switch (tabWidth) {
59
+ case 2:
60
+ return ts_morph_1.IndentationText.TwoSpaces;
61
+ case 4:
62
+ return ts_morph_1.IndentationText.FourSpaces;
63
+ case 8:
64
+ return ts_morph_1.IndentationText.EightSpaces;
65
+ default:
66
+ return ts_morph_1.IndentationText.TwoSpaces;
67
+ }
68
+ }
69
+ /**
70
+ * Converts prettier newline config to ts-morph settings.
71
+ *
72
+ * @private
73
+ * @param {string | undefined} eol prettier end-of-line config
74
+ * @returns {NewLineKind | undefined} Converted new line kind
75
+ * @memberof PrettierFormatter
76
+ */
77
+ convertNewline(eol) {
78
+ switch (eol) {
79
+ case "lf":
80
+ return ts_morph_1.NewLineKind.LineFeed;
81
+ case "crlf":
82
+ return ts_morph_1.NewLineKind.CarriageReturnLineFeed;
83
+ case "cr":
84
+ return ts_morph_1.NewLineKind.CarriageReturnLineFeed;
85
+ case "auto":
86
+ return ts_morph_1.NewLineKind.LineFeed;
87
+ default:
88
+ return ts_morph_1.NewLineKind.LineFeed;
89
+ }
90
+ }
91
+ }
92
+ exports.PrettierFormatter = PrettierFormatter;
93
93
  //# sourceMappingURL=PrettierFormatter.js.map
@@ -1,2 +1,2 @@
1
- import type { FileFormatter } from "./FileFormatter";
2
- export declare function createFormatter(outputDir: string, usePrettier: boolean): Promise<FileFormatter>;
1
+ import type { FileFormatter } from "./FileFormatter";
2
+ export declare function createFormatter(outputDir: string, usePrettier: boolean): Promise<FileFormatter>;
@@ -1,15 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createFormatter = void 0;
4
- const tslib_1 = require("tslib");
5
- const PrettierFormatter_1 = require("./PrettierFormatter");
6
- const NoopFormatter_1 = require("./NoopFormatter");
7
- function createFormatter(outputDir, usePrettier) {
8
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
- const formatter = usePrettier ? new PrettierFormatter_1.PrettierFormatter(outputDir) : new NoopFormatter_1.NoopFormatter(outputDir);
10
- yield formatter.init();
11
- return formatter;
12
- });
13
- }
14
- exports.createFormatter = createFormatter;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createFormatter = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const PrettierFormatter_1 = require("./PrettierFormatter");
6
+ const NoopFormatter_1 = require("./NoopFormatter");
7
+ function createFormatter(outputDir, usePrettier) {
8
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
+ const formatter = usePrettier ? new PrettierFormatter_1.PrettierFormatter(outputDir) : new NoopFormatter_1.NoopFormatter(outputDir);
10
+ yield formatter.init();
11
+ return formatter;
12
+ });
13
+ }
14
+ exports.createFormatter = createFormatter;
15
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- export declare function logFilePath(filePath: string): string;
1
+ export declare function logFilePath(filePath: string): string;