yini-parser 1.0.0-alpha.1 → 1.0.0-alpha.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.
Files changed (66) hide show
  1. package/README.md +21 -10
  2. package/dist/YINI.d.ts +21 -0
  3. package/dist/{src/YINI.js → YINI.js} +7 -7
  4. package/dist/config/env.d.ts +20 -0
  5. package/dist/core/ErrorDataHandler.d.ts +60 -0
  6. package/dist/core/YINIVisitor.d.ts +149 -0
  7. package/dist/core/objectBuilder.d.ts +6 -0
  8. package/dist/core/types.d.ts +49 -0
  9. package/dist/grammar/YiniLexer.d.ts +68 -0
  10. package/dist/grammar/YiniParser.d.ts +284 -0
  11. package/dist/grammar/YiniParserVisitor.d.ts +143 -0
  12. package/dist/index.d.ts +1 -0
  13. package/dist/parseEntry.d.ts +2 -0
  14. package/dist/parsers/extractHeaderParts.d.ts +31 -0
  15. package/dist/parsers/extractSignificantYiniLine.d.ts +9 -0
  16. package/dist/parsers/parseBoolean.d.ts +5 -0
  17. package/dist/parsers/parseNull.d.ts +2 -0
  18. package/dist/parsers/parseNumber.d.ts +6 -0
  19. package/dist/parsers/parseSectionHeader.d.ts +13 -0
  20. package/dist/parsers/parseString.d.ts +2 -0
  21. package/dist/utils/pathAndFileName.d.ts +5 -0
  22. package/dist/utils/string.d.ts +42 -0
  23. package/dist/utils/system.d.ts +7 -0
  24. package/dist/yiniHelpers.d.ts +44 -0
  25. package/package.json +17 -18
  26. package/dist/tests/integration/1-core-parsing/parse-bigger-section-nesting-as-object.test.js +0 -83
  27. package/dist/tests/integration/1-core-parsing/parse-section-nesting-w-classic-markers.test.js +0 -170
  28. package/dist/tests/integration/1-core-parsing/parse-section-nesting-w-nsh-markers.test.js +0 -27
  29. package/dist/tests/integration/1-core-parsing/read some values from level 1 and 2.test.js +0 -77
  30. package/dist/tests/integration/1-core-parsing/throw on bad section heads.test.js +0 -162
  31. package/dist/tests/integration/10-special-validation-modes/validation-modes.test.js +0 -38
  32. package/dist/tests/integration/2-file-structure-and-error/able to parse mixed case filenames.test.js +0 -72
  33. package/dist/tests/integration/2-file-structure-and-error/throw error on bad file extensions.test.js +0 -36
  34. package/dist/tests/integration/2-file-structure-and-error/throw error parsing bad content.test.js +0 -80
  35. package/dist/tests/smoke/A-general-smoke.test.js +0 -259
  36. package/dist/tests/smoke/B-parse-inline-smoke.test.js +0 -270
  37. package/dist/tests/smoke/C-traverse-file-smoke.test.js +0 -141
  38. package/dist/tests/smoke/D-parse-file-smoke.test.js +0 -134
  39. package/dist/tests/unit/parsers/extractHeaderParts.unit.test.js +0 -490
  40. package/dist/tests/unit/parsers/parseSectionHeader-classic.unit.test.js +0 -421
  41. package/dist/tests/unit/parsers/parseSectionHeader-nsh.unit.test.js +0 -436
  42. package/dist/tests/unit/parsers/parseSectionHeader-throw-on-invalid.unit.test.js +0 -168
  43. package/dist/tests/unit/utils/utils-pathAndFileName.unit.test.js +0 -80
  44. package/dist/tests/unit/utils/utils-string.unit.test.js +0 -185
  45. package/dist/tests/unit/yiniHelpers.unit.test.js +0 -306
  46. /package/dist/{src/config → config}/env.js +0 -0
  47. /package/dist/{src/core → core}/ErrorDataHandler.js +0 -0
  48. /package/dist/{src/core → core}/YINIVisitor.js +0 -0
  49. /package/dist/{src/core → core}/objectBuilder.js +0 -0
  50. /package/dist/{src/core → core}/types.js +0 -0
  51. /package/dist/{src/grammar → grammar}/YiniLexer.js +0 -0
  52. /package/dist/{src/grammar → grammar}/YiniParser.js +0 -0
  53. /package/dist/{src/grammar → grammar}/YiniParserVisitor.js +0 -0
  54. /package/dist/{src/index.js → index.js} +0 -0
  55. /package/dist/{src/parseEntry.js → parseEntry.js} +0 -0
  56. /package/dist/{src/parsers → parsers}/extractHeaderParts.js +0 -0
  57. /package/dist/{src/parsers → parsers}/extractSignificantYiniLine.js +0 -0
  58. /package/dist/{src/parsers → parsers}/parseBoolean.js +0 -0
  59. /package/dist/{src/parsers → parsers}/parseNull.js +0 -0
  60. /package/dist/{src/parsers → parsers}/parseNumber.js +0 -0
  61. /package/dist/{src/parsers → parsers}/parseSectionHeader.js +0 -0
  62. /package/dist/{src/parsers → parsers}/parseString.js +0 -0
  63. /package/dist/{src/utils → utils}/pathAndFileName.js +0 -0
  64. /package/dist/{src/utils → utils}/string.js +0 -0
  65. /package/dist/{src/utils → utils}/system.js +0 -0
  66. /package/dist/{src/yiniHelpers.js → yiniHelpers.js} +0 -0
@@ -1,141 +0,0 @@
1
- "use strict";
2
- /**
3
- * 10 Traverse-File Smoke Tests
4
- *
5
- * Dry run parsing, just analyzes/validates/traverses a set of real-life
6
- * (mimiced) configuration files one might have.
7
- *
8
- * Dry-run parsing — performs only enough work to validate the input and
9
- * return success.
10
- */
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const path_1 = __importDefault(require("path"));
16
- const src_1 = __importDefault(require("../../src"));
17
- const system_1 = require("../../src/utils/system");
18
- const DIR_OF_FIXTURES = '../fixtures/smoke-fixtures';
19
- /**
20
- * Parse File Smoke Tests.
21
- */
22
- describe('Parse-File Smoke Tests:', () => {
23
- // Dir with smoke fixtures.
24
- const baseDir = path_1.default.join(__dirname, DIR_OF_FIXTURES);
25
- beforeAll(() => { });
26
- test('Parse file "1-web-server-configuration.*".', () => {
27
- // Arrange.
28
- const fileName = '1-web-server-configuration.smoke.yini';
29
- const fullPath = path_1.default.join(baseDir, fileName);
30
- // Act.
31
- const result = src_1.default.parseFile(fullPath);
32
- (0, system_1.debugPrint)('fullPath = ' + fullPath);
33
- (0, system_1.debugPrint)(result);
34
- // Assert.
35
- // NOTE: Dry run parsing - enough that something is successfully returned.
36
- expect(!!result).toEqual(true);
37
- });
38
- test('Parse file "2-user-profile-settings.*".', () => {
39
- // Arrange.
40
- const fileName = '2-user-profile-settings.smoke.yini';
41
- const fullPath = path_1.default.join(baseDir, fileName);
42
- // Act.
43
- const result = src_1.default.parseFile(fullPath);
44
- (0, system_1.debugPrint)(result);
45
- // Assert.
46
- // NOTE: Dry run parsing - enough that something is successfully returned.
47
- expect(!!result).toEqual(true);
48
- });
49
- //@todo Enable test (after can parse list (colon based)).
50
- xtest('Parse file "3-cli-application-options.*".', () => {
51
- // Arrange.
52
- const fileName = '3-cli-application-options.smoke.yini';
53
- const fullPath = path_1.default.join(baseDir, fileName);
54
- // Act.
55
- const result = src_1.default.parseFile(fullPath);
56
- (0, system_1.debugPrint)(result);
57
- // Assert.
58
- // NOTE: Dry run parsing - enough that something is successfully returned.
59
- expect(!!result).toEqual(true);
60
- });
61
- test('Parse file "4-build-project-configuration.*".', () => {
62
- // Arrange.
63
- const fileName = '4-build-project-configuration.smoke.yini';
64
- const fullPath = path_1.default.join(baseDir, fileName);
65
- // Act.
66
- const result = src_1.default.parseFile(fullPath);
67
- (0, system_1.debugPrint)(result);
68
- // Assert.
69
- // NOTE: Dry run parsing - enough that something is successfully returned.
70
- expect(!!result).toEqual(true);
71
- });
72
- test('Parse file "5-database-connection.*".', () => {
73
- // Arrange.
74
- const fileName = '5-database-connection.smoke.yini';
75
- const fullPath = path_1.default.join(baseDir, fileName);
76
- // Act.
77
- const result = src_1.default.parseFile(fullPath);
78
- (0, system_1.debugPrint)(result);
79
- // Assert.
80
- // NOTE: Dry run parsing - enough that something is successfully returned.
81
- expect(!!result).toEqual(true);
82
- });
83
- test('Parse file "6-feature-flags-example.*".', () => {
84
- // Arrange.
85
- const fileName = '6-feature-flags-example.smoke.yini';
86
- const fullPath = path_1.default.join(baseDir, fileName);
87
- // Act.
88
- const result = src_1.default.parseFile(fullPath);
89
- (0, system_1.debugPrint)(result);
90
- // Assert.
91
- // NOTE: Dry run parsing - enough that something is successfully returned.
92
- expect(!!result).toEqual(true);
93
- });
94
- test('Parse file "7-email-smtp-configuration.*".', () => {
95
- // Arrange.
96
- const fileName = '7-email-smtp-configuration.smoke.yini';
97
- const fullPath = path_1.default.join(baseDir, fileName);
98
- // Act.
99
- const result = src_1.default.parseFile(fullPath);
100
- (0, system_1.debugPrint)(result);
101
- // Assert.
102
- // NOTE: Dry run parsing - enough that something is successfully returned.
103
- expect(!!result).toEqual(true);
104
- });
105
- //@todo Enable test (after can parse colon based lists).
106
- xtest('Parse file "8-api-keys-integration.*".', () => {
107
- // Arrange.
108
- const fileName = '8-api-keys-integration.smoke.yini';
109
- const fullPath = path_1.default.join(baseDir, fileName);
110
- // Act.
111
- const result = src_1.default.parseFile(fullPath);
112
- (0, system_1.debugPrint)(result);
113
- // Assert.
114
- // NOTE: Dry run parsing - enough that something is successfully returned.
115
- expect(!!result).toEqual(true);
116
- });
117
- //@todo Enable test (after can parse with no section defined, implicit base object).
118
- xtest('Parse file "9-app-preferences.*".', () => {
119
- // Arrange.
120
- const fileName = '9-app-preferences.smoke.yini';
121
- const fullPath = path_1.default.join(baseDir, fileName);
122
- // Act.
123
- const result = src_1.default.parseFile(fullPath);
124
- (0, system_1.debugPrint)(result);
125
- // Assert.
126
- // NOTE: Dry run parsing - enough that something is successfully returned.
127
- expect(!!result).toEqual(true);
128
- });
129
- //@todo Enable test (after can parse lists)
130
- xtest('Parse file "10-logging-monitoring.*".', () => {
131
- // Arrange.
132
- const fileName = '10-logging-monitoring.smoke.yini';
133
- const fullPath = path_1.default.join(baseDir, fileName);
134
- // Act.
135
- const result = src_1.default.parseFile(fullPath);
136
- (0, system_1.debugPrint)(result);
137
- // Assert.
138
- // NOTE: Dry run parsing - enough that something is successfully returned.
139
- expect(!!result).toEqual(true);
140
- });
141
- });
@@ -1,134 +0,0 @@
1
- "use strict";
2
- /**
3
- * 10 Parse-File Smoke Tests
4
- *
5
- * To test a set of real-life (mimiced) configuration files one might have.
6
- */
7
- var __importDefault = (this && this.__importDefault) || function (mod) {
8
- return (mod && mod.__esModule) ? mod : { "default": mod };
9
- };
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- const path_1 = __importDefault(require("path"));
12
- const src_1 = __importDefault(require("../../src"));
13
- const system_1 = require("../../src/utils/system");
14
- const DIR_OF_FIXTURES = '../fixtures/smoke-fixtures';
15
- /**
16
- * Parse File Smoke Tests.
17
- */
18
- describe('Parse-File Smoke Tests:', () => {
19
- // Dir with smoke fixtures.
20
- const baseDir = path_1.default.join(__dirname, DIR_OF_FIXTURES);
21
- beforeAll(() => { });
22
- test('Parse file "1-web-server-configuration.*".', () => {
23
- // Arrange.
24
- const fileName = '1-web-server-configuration.smoke.yini';
25
- const fullPath = path_1.default.join(baseDir, fileName);
26
- // Act.
27
- const result = src_1.default.parseFile(fullPath);
28
- (0, system_1.debugPrint)('fullPath = ' + fullPath);
29
- (0, system_1.debugPrint)(result);
30
- // Assert.
31
- expect(result.Server.max_connections).toEqual(200);
32
- //@todo Add tests for the other literal as well.
33
- });
34
- test('Parse file "2-user-profile-settings.*".', () => {
35
- // Arrange.
36
- const fileName = '2-user-profile-settings.smoke.yini';
37
- const fullPath = path_1.default.join(baseDir, fileName);
38
- // Act.
39
- const result = src_1.default.parseFile(fullPath);
40
- (0, system_1.debugPrint)(result);
41
- // Assert.
42
- expect(result.profile.username).toEqual('robinkoda');
43
- //@todo Add tests for the other literal as well.
44
- });
45
- xtest('Parse file "3-cli-application-options.*".', () => {
46
- // Arrange.
47
- const fileName = '3-cli-application-options.smoke.yini';
48
- const fullPath = path_1.default.join(baseDir, fileName);
49
- // Act.
50
- const result = src_1.default.parseFile(fullPath);
51
- (0, system_1.debugPrint)(result);
52
- // Assert.
53
- expect(result.CLI.dry_run).toEqual(false);
54
- //@todo Add tests for the other literal as well.
55
- });
56
- test('Parse file "4-build-project-configuration.*".', () => {
57
- // Arrange.
58
- const fileName = '4-build-project-configuration.smoke.yini';
59
- const fullPath = path_1.default.join(baseDir, fileName);
60
- // Act.
61
- const result = src_1.default.parseFile(fullPath);
62
- (0, system_1.debugPrint)(result);
63
- // Assert.
64
- expect(result.Build.target).toEqual('ES2022');
65
- //@todo Add tests for the other literal as well.
66
- });
67
- test('Parse file "5-database-connection.*".', () => {
68
- // Arrange.
69
- const fileName = '5-database-connection.smoke.yini';
70
- const fullPath = path_1.default.join(baseDir, fileName);
71
- // Act.
72
- const result = src_1.default.parseFile(fullPath);
73
- (0, system_1.debugPrint)(result);
74
- // Assert.
75
- expect(result.Database.port).toEqual(5432);
76
- //@todo Add tests for the other literal as well.
77
- });
78
- test('Parse file "6-feature-flags-example.*".', () => {
79
- // Arrange.
80
- const fileName = '6-feature-flags-example.smoke.yini';
81
- const fullPath = path_1.default.join(baseDir, fileName);
82
- // Act.
83
- const result = src_1.default.parseFile(fullPath);
84
- (0, system_1.debugPrint)(result);
85
- // Assert.
86
- expect(result['Features'].experimental_ui).toEqual(false);
87
- expect(result.Features['Feature Toggles'].feature_x).toEqual(true);
88
- //@todo Add tests for the other literal as well.
89
- });
90
- xtest('Parse file "7-email-smtp-configuration.*".', () => {
91
- // Arrange.
92
- const fileName = '7-email-smtp-configuration.smoke.yini';
93
- const fullPath = path_1.default.join(baseDir, fileName);
94
- // Act.
95
- const result = src_1.default.parseFile(fullPath);
96
- (0, system_1.debugPrint)(result);
97
- // Assert.
98
- expect(result.SMTP.use_tls).toEqual(true);
99
- //@todo Add tests for the other literal as well.
100
- });
101
- xtest('Parse file "8-api-keys-integration.*".', () => {
102
- // Arrange.
103
- const fileName = '8-api-keys-integration.smoke.yini';
104
- const fullPath = path_1.default.join(baseDir, fileName);
105
- // Act.
106
- const result = src_1.default.parseFile(fullPath);
107
- (0, system_1.debugPrint)(result);
108
- // Assert.
109
- expect(result.Webhooks.enabled).toEqual(true);
110
- //@todo Add tests for the other literal as well.
111
- });
112
- xtest('Parse file "9-app-preferences.*".', () => {
113
- // Arrange.
114
- const fileName = '9-app-preferences.smoke.yini';
115
- const fullPath = path_1.default.join(baseDir, fileName);
116
- // Act.
117
- const result = src_1.default.parseFile(fullPath);
118
- (0, system_1.debugPrint)(result);
119
- // Assert.
120
- expect(result.base.CacheFolder).toEqual(null);
121
- //@todo Add tests for the other literal as well.
122
- });
123
- xtest('Parse file "10-logging-monitoring.*".', () => {
124
- // Arrange.
125
- const fileName = '10-logging-monitoring.smoke.yini';
126
- const fullPath = path_1.default.join(baseDir, fileName);
127
- // Act.
128
- const result = src_1.default.parseFile(fullPath);
129
- (0, system_1.debugPrint)(result);
130
- // Assert.
131
- expect(result.base.Alerts.slack_webhook).toEqual(null);
132
- //@todo Add tests for the other literal as well.
133
- });
134
- });