@rockcarver/frodo-cli 0.11.1-0 → 0.11.1-1

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 (90) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/package.json +12 -10
  3. package/src/app.js +3 -3
  4. package/.eslintrc +0 -29
  5. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -30
  6. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  7. package/.github/README.md +0 -213
  8. package/.github/workflows/pipeline.yml +0 -495
  9. package/.prettierrc +0 -6
  10. package/CODE_OF_CONDUCT.md +0 -128
  11. package/docs/BINARIES.md +0 -22
  12. package/docs/CONTRIBUTE.md +0 -96
  13. package/docs/PIPELINE.md +0 -169
  14. package/docs/images/macos_warn1.png +0 -0
  15. package/docs/images/macos_warn2.png +0 -0
  16. package/docs/images/macos_warn3.png +0 -0
  17. package/docs/images/npm_versioning_guidelines.png +0 -0
  18. package/docs/images/release_pipeline.png +0 -0
  19. package/gulpfile.js +0 -49
  20. package/jsconfig.json +0 -6
  21. package/resources/sampleEntitiesFile.json +0 -8
  22. package/resources/sampleEnvFile.env +0 -2
  23. package/src/cli/journey/journey-delete.e2e.test_.js +0 -380
  24. package/src/cli/journey/journey-list.e2e.test_.js +0 -142
  25. package/src/cli/theme/theme-delete.e2e.test_.js +0 -178
  26. package/src/cli/theme/theme-list.e2e.test_.js +0 -119
  27. package/test/client_cli/en/conn-add.test.js +0 -37
  28. package/test/client_cli/en/conn-delete.test.js +0 -37
  29. package/test/client_cli/en/conn-list.test.js +0 -37
  30. package/test/client_cli/en/conn.test.js +0 -65
  31. package/test/client_cli/en/email-template-import.test.js +0 -156
  32. package/test/client_cli/en/email-template.test.js +0 -79
  33. package/test/client_cli/en/email-templates-export.test.js +0 -208
  34. package/test/client_cli/en/email-templates-list.test.js +0 -139
  35. package/test/client_cli/en/idm-count.test.js +0 -131
  36. package/test/client_cli/en/idm-export.test.js +0 -149
  37. package/test/client_cli/en/idm-import.test_.js +0 -101
  38. package/test/client_cli/en/idm-list.test.js +0 -109
  39. package/test/client_cli/en/idm.test.js +0 -82
  40. package/test/client_cli/en/info.test.js +0 -136
  41. package/test/client_cli/en/journey-describe.test.js +0 -194
  42. package/test/client_cli/en/journey-export.test.js +0 -231
  43. package/test/client_cli/en/journey-import.test.js +0 -212
  44. package/test/client_cli/en/journey-list.test.js +0 -173
  45. package/test/client_cli/en/journey-prune.test.js +0 -159
  46. package/test/client_cli/en/journey.test.js +0 -111
  47. package/test/client_cli/en/logs-list.test.js +0 -81
  48. package/test/client_cli/en/logs-tail.test.js +0 -130
  49. package/test/client_cli/en/logs.test.js +0 -65
  50. package/test/client_cli/en/root.test.js +0 -93
  51. package/test/client_cli/en/script-export.test.js +0 -230
  52. package/test/client_cli/en/script-import.test.js +0 -176
  53. package/test/client_cli/en/script-list.test.js +0 -159
  54. package/test/client_cli/en/script.test.js +0 -79
  55. package/test/client_cli/utils/utils.js +0 -63
  56. package/test/e2e/journey/baseline/ForgottenUsername.journey.json +0 -216
  57. package/test/e2e/journey/baseline/Login.journey.json +0 -205
  58. package/test/e2e/journey/baseline/PasswordGrant.journey.json +0 -139
  59. package/test/e2e/journey/baseline/ProgressiveProfile.journey.json +0 -198
  60. package/test/e2e/journey/baseline/Registration.journey.json +0 -249
  61. package/test/e2e/journey/baseline/ResetPassword.journey.json +0 -268
  62. package/test/e2e/journey/baseline/UpdatePassword.journey.json +0 -323
  63. package/test/e2e/journey/baseline/allAlphaJourneys.journeys.json +0 -1520
  64. package/test/e2e/journey/delete/ForgottenUsername.journey.json +0 -216
  65. package/test/e2e/journey/delete/Login.journey.json +0 -205
  66. package/test/e2e/journey/delete/PasswordGrant.journey.json +0 -139
  67. package/test/e2e/journey/delete/ProgressiveProfile.journey.json +0 -198
  68. package/test/e2e/journey/delete/Registration.journey.json +0 -249
  69. package/test/e2e/journey/delete/ResetPassword.journey.json +0 -268
  70. package/test/e2e/journey/delete/UpdatePassword.journey.json +0 -323
  71. package/test/e2e/journey/delete/deleteMe.journey.json +0 -230
  72. package/test/e2e/journey/list/Disabled.journey.json +0 -43
  73. package/test/e2e/journey/list/ForgottenUsername.journey.json +0 -216
  74. package/test/e2e/journey/list/Login.journey.json +0 -205
  75. package/test/e2e/journey/list/PasswordGrant.journey.json +0 -139
  76. package/test/e2e/journey/list/ProgressiveProfile.journey.json +0 -198
  77. package/test/e2e/journey/list/Registration.journey.json +0 -249
  78. package/test/e2e/journey/list/ResetPassword.journey.json +0 -268
  79. package/test/e2e/journey/list/UpdatePassword.journey.json +0 -323
  80. package/test/e2e/theme/baseline/Contrast.theme.json +0 -95
  81. package/test/e2e/theme/baseline/Highlander.theme.json +0 -95
  82. package/test/e2e/theme/baseline/Robroy.theme.json +0 -95
  83. package/test/e2e/theme/baseline/Starter-Theme.theme.json +0 -94
  84. package/test/e2e/theme/baseline/Zardoz.theme.json +0 -95
  85. package/test/e2e/theme/import/Contrast.theme.json +0 -95
  86. package/test/e2e/theme/import/Highlander.theme.json +0 -95
  87. package/test/e2e/theme/import/Robroy.theme.json +0 -95
  88. package/test/e2e/theme/import/Starter-Theme.theme.json +0 -94
  89. package/test/e2e/theme/import/Zardoz.default.theme.json +0 -95
  90. package/test/fs_tmp/.gitkeep +0 -2
@@ -1,230 +0,0 @@
1
- import cp from 'child_process';
2
- import { promisify } from 'util';
3
- import {
4
- crudeMultilineTakeUntil,
5
- collapseWhitespace,
6
- node14Compatibility,
7
- } from '../utils/utils.js';
8
-
9
- node14Compatibility();
10
-
11
- const exec = promisify(cp.exec);
12
- const CMD = 'frodo script export --help';
13
- const { stdout } = await exec(CMD);
14
-
15
- test("CLI help interface for 'script export' Usage should be expected english", async () => {
16
- // Arrange
17
- const expected = `
18
- Usage: frodo script export [options] <host> [realm] [user] [password]
19
- `.trim();
20
- // Act
21
- const testLine = stdout
22
- .split(/\n/)
23
- .find((line) => line.trim().startsWith('Usage:'))
24
- .trim();
25
- // Assert
26
- expect(testLine).toBe(expected);
27
- });
28
-
29
- test("CLI help interface 'script export' description at line 2 should be expected english", async () => {
30
- // Arrange
31
- const expected = `
32
- Export scripts.
33
- `.trim();
34
- // Act
35
- const testLine = stdout
36
- .split(/\n/)
37
- .map((line) => line.trim())
38
- .at(2);
39
- // Assert
40
- expect(testLine).toBe(expected);
41
- });
42
-
43
- test("CLI help interface 'export argument host' description should be expected english multiline", async () => {
44
- // Arrange
45
- const expected = collapseWhitespace(`
46
- host Access Management base URL, e.g.:
47
- https://cdk.iam.example.com/am. To use a connection
48
- profile, just specify a unique substring.
49
- `);
50
- // Act
51
- const testLine = collapseWhitespace(
52
- crudeMultilineTakeUntil(
53
- stdout,
54
- ' host ',
55
- ' realm '
56
- )
57
- );
58
-
59
- // Assert
60
- expect(testLine).toBe(expected);
61
- });
62
-
63
- test("CLI help interface 'export argument realm' description should be expected english multiline", async () => {
64
- // Arrange
65
- const expected = collapseWhitespace(`
66
- realm Realm. Specify realm as '/' for the root realm or 'realm' or '/parent/child' otherwise. (default: "alpha" for Identity Cloud tenants, "/" otherwise.)
67
- `);
68
- // Act
69
- const testLine = collapseWhitespace(
70
- crudeMultilineTakeUntil(
71
- stdout,
72
- ' realm ',
73
- ' user '
74
- )
75
- );
76
-
77
- // Assert
78
- expect(testLine).toBe(expected);
79
- });
80
-
81
- test("CLI help interface 'export argument user' description should be expected english multiline", async () => {
82
- // Arrange
83
- const expected = collapseWhitespace(`
84
- user Username to login with. Must be an admin user with appropriate
85
- rights to manage authentication journeys/trees.
86
- `);
87
- // Act
88
- const testLine = collapseWhitespace(
89
- crudeMultilineTakeUntil(
90
- stdout,
91
- ' user ',
92
- ' password '
93
- )
94
- );
95
-
96
- // Assert
97
- expect(testLine).toBe(expected);
98
- });
99
-
100
- test("CLI help interface 'export argument password' description should be expected english", async () => {
101
- // Arrange
102
- const expectedDescription = `
103
- password Password.
104
- `.trim();
105
- // Act
106
- const testLine = stdout
107
- .split(/\n/)
108
- .find((line) => line.trim().startsWith('password'))
109
- .trim();
110
- // Assert
111
- expect(testLine).toBe(expectedDescription);
112
- });
113
-
114
- test("CLI help interface 'export option -m, --type <type>' description should be expected english multiline", async () => {
115
- // Arrange
116
- const expected = collapseWhitespace(`
117
- -m, --type <type> Override auto-detected deployment type. Valid values for
118
- type:
119
- classic: A classic Access Management-only deployment
120
- with custom layout and configuration.
121
- cloud: A ForgeRock Identity Cloud environment.
122
- forgeops: A ForgeOps CDK or CDM deployment.
123
- The detected or provided deployment type controls certain
124
- behavior like obtaining an Identity Management admin
125
- token or not and whether to export/import referenced
126
- email templates or how to walk through the tenant admin
127
- login flow of Identity Cloud and handle MFA (choices:
128
- "classic", "cloud", "forgeops")
129
- `);
130
- // Act
131
- const testLine = collapseWhitespace(
132
- crudeMultilineTakeUntil(
133
- stdout,
134
- ' -m, --type <type> ',
135
- ' -k, --insecure '
136
- )
137
- );
138
-
139
- // Assert
140
- expect(testLine).toBe(expected);
141
- });
142
-
143
- test("CLI help interface 'export option -k, --insecure' description should be expected english multiline", async () => {
144
- // Arrange
145
- const expected = collapseWhitespace(`
146
- -k, --insecure Allow insecure connections when using SSL/TLS. Has no effect when using a network proxy for https
147
- (HTTPS_PROXY=http://<host>:<port>), in that case the proxy must provide this capability. (default: Don't
148
- allow insecure connections)
149
- `);
150
- // Act
151
- const testLine = collapseWhitespace(
152
- crudeMultilineTakeUntil(
153
- stdout,
154
- ' -k, --insecure ',
155
- ' -n, --script-name <name> '
156
- )
157
- );
158
-
159
- // Assert
160
- expect(testLine).toBe(expected);
161
- });
162
-
163
- test("CLI help interface 'export option -s, --script <script>' description should be expected english multiline", async () => {
164
- // Arrange
165
- const expected = collapseWhitespace(`
166
- -n, --script-name <name> Name of the script. If specified, -a and -A are ignored.
167
- `);
168
- // Act
169
- const testLine = collapseWhitespace(
170
- crudeMultilineTakeUntil(
171
- stdout,
172
- ' -n, --script-name <name> ',
173
- ' -f, --file <file> '
174
- )
175
- );
176
-
177
- // Assert
178
- expect(testLine).toBe(expected);
179
- });
180
-
181
- test("CLI help interface 'export option -f, --file <file>' description should be expected english", async () => {
182
- // Arrange
183
- const expected = collapseWhitespace(`
184
- -f, --file <file> Name of the export file.
185
- `);
186
- // Act
187
- const testLine = collapseWhitespace(
188
- crudeMultilineTakeUntil(
189
- stdout,
190
- ' -f, --file <file> ',
191
- ' -a, --all '
192
- )
193
- );
194
- // Assert
195
- expect(testLine).toBe(expected);
196
- });
197
-
198
- test("CLI help interface 'export option -a, --all' description should be expected english", async () => {
199
- // Arrange
200
- const expected = collapseWhitespace(`
201
- -a, --all Export all scripts to a single file. Ignored with -i.
202
- `);
203
- // Act
204
- const testLine = collapseWhitespace(
205
- crudeMultilineTakeUntil(
206
- stdout,
207
- ' -a, --all ',
208
- ' -A, --all-separate '
209
- )
210
- );
211
- // Assert
212
- expect(testLine).toBe(expected);
213
- });
214
-
215
- test("CLI help interface 'export option -A, --all-separate' description should be expected english", async () => {
216
- // Arrange
217
- const expected = collapseWhitespace(`
218
- -A, --all-separate Export all scripts to separate files (*.script.json) in the current directory. Ignored with -i or -a.
219
- `);
220
- // Act
221
- const testLine = collapseWhitespace(
222
- crudeMultilineTakeUntil(
223
- stdout,
224
- ' -A, --all-separate ',
225
- ' -s, --script <script> '
226
- )
227
- );
228
- // Assert
229
- expect(testLine).toBe(expected);
230
- });
@@ -1,176 +0,0 @@
1
- import cp from 'child_process';
2
- import { promisify } from 'util';
3
- import {
4
- crudeMultilineTakeUntil,
5
- collapseWhitespace,
6
- node14Compatibility,
7
- } from '../utils/utils.js';
8
-
9
- node14Compatibility();
10
-
11
- const exec = promisify(cp.exec);
12
- const CMD = 'frodo script import --help';
13
- const { stdout } = await exec(CMD);
14
-
15
- test("CLI help interface for 'script import' Usage should be expected english", async () => {
16
- // Arrange
17
- const expected = `
18
- Usage: frodo script import [options] <host> [realm] [user] [password]
19
- `.trim();
20
- // Act
21
- const testLine = stdout
22
- .split(/\n/)
23
- .find((line) => line.trim().startsWith('Usage:'))
24
- .trim();
25
- // Assert
26
- expect(testLine).toBe(expected);
27
- });
28
-
29
- test("CLI help interface 'script import' description at line 2 should be expected english", async () => {
30
- // Arrange
31
- const expected = `
32
- Import scripts.
33
- `.trim();
34
- // Act
35
- const testLine = stdout
36
- .split(/\n/)
37
- .map((line) => line.trim())
38
- .at(2);
39
- // Assert
40
- expect(testLine).toBe(expected);
41
- });
42
-
43
- test("CLI help interface 'import argument host' description should be expected english multiline", async () => {
44
- // Arrange
45
- const expected = collapseWhitespace(`
46
- host Access Management base URL, e.g.:
47
- https://cdk.iam.example.com/am. To use a connection
48
- profile, just specify a unique substring.
49
- `);
50
- // Act
51
- const testLine = collapseWhitespace(
52
- crudeMultilineTakeUntil(
53
- stdout,
54
- ' host ',
55
- ' realm '
56
- )
57
- );
58
-
59
- // Assert
60
- expect(testLine).toBe(expected);
61
- });
62
-
63
- test("CLI help interface 'import argument realm' description should be expected english multiline", async () => {
64
- // Arrange
65
- const expected = collapseWhitespace(`
66
- realm Realm. Specify realm as '/' for the root realm or 'realm' or '/parent/child' otherwise. (default: "alpha" for Identity Cloud tenants, "/" otherwise.)
67
- `);
68
- // Act
69
- const testLine = collapseWhitespace(
70
- crudeMultilineTakeUntil(
71
- stdout,
72
- ' realm ',
73
- ' user '
74
- )
75
- );
76
-
77
- // Assert
78
- expect(testLine).toBe(expected);
79
- });
80
-
81
- test("CLI help interface 'import argument user' description should be expected english multiline", async () => {
82
- // Arrange
83
- const expected = collapseWhitespace(`
84
- user Username to login with. Must be an admin user with appropriate
85
- rights to manage authentication journeys/trees.
86
- `);
87
- // Act
88
- const testLine = collapseWhitespace(
89
- crudeMultilineTakeUntil(
90
- stdout,
91
- ' user ',
92
- ' password '
93
- )
94
- );
95
-
96
- // Assert
97
- expect(testLine).toBe(expected);
98
- });
99
-
100
- test("CLI help interface 'import argument password' description should be expected english", async () => {
101
- // Arrange
102
- const expectedDescription = `
103
- password Password.
104
- `.trim();
105
- // Act
106
- const testLine = stdout
107
- .split(/\n/)
108
- .find((line) => line.trim().startsWith('password'))
109
- .trim();
110
- // Assert
111
- expect(testLine).toBe(expectedDescription);
112
- });
113
-
114
- test("CLI help interface 'import option -m, --type <type>' description should be expected english multiline", async () => {
115
- // Arrange
116
- const expected = collapseWhitespace(`
117
- -m, --type <type> Override auto-detected deployment type. Valid values for
118
- type:
119
- classic: A classic Access Management-only deployment
120
- with custom layout and configuration.
121
- cloud: A ForgeRock Identity Cloud environment.
122
- forgeops: A ForgeOps CDK or CDM deployment.
123
- The detected or provided deployment type controls certain
124
- behavior like obtaining an Identity Management admin
125
- token or not and whether to export/import referenced
126
- email templates or how to walk through the tenant admin
127
- login flow of Identity Cloud and handle MFA (choices:
128
- "classic", "cloud", "forgeops")
129
- `);
130
- // Act
131
- const testLine = collapseWhitespace(
132
- crudeMultilineTakeUntil(
133
- stdout,
134
- ' -m, --type <type> ',
135
- ' -k, --insecure '
136
- )
137
- );
138
-
139
- // Assert
140
- expect(testLine).toBe(expected);
141
- });
142
-
143
- test("CLI help interface 'import option -k, --insecure' description should be expected english multiline", async () => {
144
- // Arrange
145
- const expected = collapseWhitespace(`
146
- -k, --insecure Allow insecure connections when using SSL/TLS. Has no effect when using a network proxy for https (HTTPS_PROXY=http://<host>:<port>), in that case the proxy must provide this capability. (default: Don't allow insecure connections)
147
- `);
148
- // Act
149
- const testLine = collapseWhitespace(
150
- crudeMultilineTakeUntil(
151
- stdout,
152
- ' -k, --insecure ',
153
- ' -f, --file <file> '
154
- )
155
- );
156
-
157
- // Assert
158
- expect(testLine).toBe(expected);
159
- });
160
-
161
- test("CLI help interface 'import option -f, --file <file>' description should be expected english", async () => {
162
- // Arrange
163
- const expected = collapseWhitespace(`
164
- -f, --file <file> Name of the file to import.
165
- `);
166
- // Act
167
- const testLine = collapseWhitespace(
168
- crudeMultilineTakeUntil(
169
- stdout,
170
- ' -f, --file <file> ',
171
- ' -n, --script-name <name> '
172
- )
173
- );
174
- // Assert
175
- expect(testLine).toBe(expected);
176
- });
@@ -1,159 +0,0 @@
1
- import cp from 'child_process';
2
- import { promisify } from 'util';
3
- import {
4
- crudeMultilineTakeUntil,
5
- collapseWhitespace,
6
- node14Compatibility,
7
- } from '../utils/utils.js';
8
-
9
- node14Compatibility();
10
-
11
- const exec = promisify(cp.exec);
12
- const CMD = 'frodo script list --help';
13
- const { stdout } = await exec(CMD);
14
-
15
- test("CLI help interface for 'script list' Usage should be expected english", async () => {
16
- // Arrange
17
- const expected = `
18
- Usage: frodo script list [options] <host> [realm] [user] [password]
19
- `.trim();
20
- // Act
21
- const testLine = stdout
22
- .split(/\n/)
23
- .find((line) => line.trim().startsWith('Usage:'))
24
- .trim();
25
- // Assert
26
- expect(testLine).toBe(expected);
27
- });
28
-
29
- test("CLI help interface 'script list' description at line 2 should be expected english", async () => {
30
- // Arrange
31
- const expected = `
32
- List scripts.
33
- `.trim();
34
- // Act
35
- const testLine = stdout
36
- .split(/\n/)
37
- .map((line) => line.trim())
38
- .at(2);
39
- // Assert
40
- expect(testLine).toBe(expected);
41
- });
42
-
43
- test("CLI help interface 'list argument host' description should be expected english multiline", async () => {
44
- // Arrange
45
- const expected = collapseWhitespace(`
46
- host Access Management base URL, e.g.:
47
- https://cdk.iam.example.com/am. To use a connection
48
- profile, just specify a unique substring.
49
- `);
50
- // Act
51
- const testLine = collapseWhitespace(
52
- crudeMultilineTakeUntil(
53
- stdout,
54
- ' host ',
55
- ' realm '
56
- )
57
- );
58
-
59
- // Assert
60
- expect(testLine).toBe(expected);
61
- });
62
-
63
- test("CLI help interface 'list argument realm' description should be expected english multiline", async () => {
64
- // Arrange
65
- const expected = collapseWhitespace(`
66
- realm Realm. Specify realm as '/' for the root realm or 'realm' or '/parent/child' otherwise. (default: "alpha" for Identity Cloud tenants, "/" otherwise.)
67
- `);
68
- // Act
69
- const testLine = collapseWhitespace(
70
- crudeMultilineTakeUntil(
71
- stdout,
72
- ' realm ',
73
- ' user '
74
- )
75
- );
76
-
77
- // Assert
78
- expect(testLine).toBe(expected);
79
- });
80
-
81
- test("CLI help interface 'list argument user' description should be expected english multiline", async () => {
82
- // Arrange
83
- const expected = collapseWhitespace(`
84
- user Username to login with. Must be an admin user with appropriate
85
- rights to manage authentication journeys/trees.
86
- `);
87
- // Act
88
- const testLine = collapseWhitespace(
89
- crudeMultilineTakeUntil(
90
- stdout,
91
- ' user ',
92
- ' password '
93
- )
94
- );
95
-
96
- // Assert
97
- expect(testLine).toBe(expected);
98
- });
99
-
100
- test("CLI help interface 'list argument password' description should be expected english", async () => {
101
- // Arrange
102
- const expectedDescription = `
103
- password Password.
104
- `.trim();
105
- // Act
106
- const testLine = stdout
107
- .split(/\n/)
108
- .find((line) => line.trim().startsWith('password'))
109
- .trim();
110
- // Assert
111
- expect(testLine).toBe(expectedDescription);
112
- });
113
-
114
- test("CLI help interface 'list option -m, --type <type>' description should be expected english multiline", async () => {
115
- // Arrange
116
- const expected = collapseWhitespace(`
117
- -m, --type <type> Override auto-detected deployment type. Valid values for
118
- type:
119
- classic: A classic Access Management-only deployment
120
- with custom layout and configuration.
121
- cloud: A ForgeRock Identity Cloud environment.
122
- forgeops: A ForgeOps CDK or CDM deployment.
123
- The detected or provided deployment type controls certain
124
- behavior like obtaining an Identity Management admin
125
- token or not and whether to export/import referenced
126
- email templates or how to walk through the tenant admin
127
- login flow of Identity Cloud and handle MFA (choices:
128
- "classic", "cloud", "forgeops")
129
- `);
130
- // Act
131
- const testLine = collapseWhitespace(
132
- crudeMultilineTakeUntil(
133
- stdout,
134
- ' -m, --type <type> ',
135
- ' -k, --insecure '
136
- )
137
- );
138
-
139
- // Assert
140
- expect(testLine).toBe(expected);
141
- });
142
-
143
- test("CLI help interface 'list option -k, --insecure' description should be expected english multiline", async () => {
144
- // Arrange
145
- const expected = collapseWhitespace(`
146
- -k, --insecure Allow insecure connections when using SSL/TLS. Has no effect when using a network proxy for https (HTTPS_PROXY=http://<host>:<port>), in that case the proxy must provide this capability. (default: Don't allow insecure connections) -l, --long Long with all fields. (default: false)
147
- `);
148
- // Act
149
- const testLine = collapseWhitespace(
150
- crudeMultilineTakeUntil(
151
- stdout,
152
- ' -k, --insecure ',
153
- ' -h, --help '
154
- )
155
- );
156
-
157
- // Assert
158
- expect(testLine).toBe(expected);
159
- });
@@ -1,79 +0,0 @@
1
- import cp from 'child_process';
2
- import { promisify } from 'util';
3
- import { node14Compatibility } from '../utils/utils.js';
4
-
5
- node14Compatibility();
6
-
7
- const exec = promisify(cp.exec);
8
- const CMD = 'frodo script --help';
9
- const { stdout } = await exec(CMD);
10
-
11
- test("CLI help interface for 'script' Usage should be expected english", async () => {
12
- // Arrange
13
- const expected = `
14
- Usage: frodo script [options] [command]
15
- `.trim();
16
- // Act
17
- const testLine = stdout
18
- .split(/\n/)
19
- .find((line) => line.trim().startsWith('Usage:'))
20
- .trim();
21
- // Assert
22
- expect(testLine).toBe(expected);
23
- });
24
-
25
- test("CLI help interface 'script' description at line 2 should be expected english", async () => {
26
- // Arrange
27
- const expected = `
28
- Manage scripts.
29
- `.trim();
30
- // Act
31
- const testLine = stdout
32
- .split(/\n/)
33
- .map((line) => line.trim())
34
- .at(2);
35
- // Assert
36
- expect(testLine).toBe(expected);
37
- });
38
-
39
- test("CLI help interface 'script commands list' description should be expected english", async () => {
40
- // Arrange
41
- const expected = `
42
- list List scripts.
43
- `.trim();
44
- // Act
45
- const testLine = stdout
46
- .split(/\n/)
47
- .find((line) => line.trim().startsWith('list'))
48
- .trim();
49
- // Assert
50
- expect(testLine).toBe(expected);
51
- });
52
-
53
- test("CLI help interface 'script commands export' description should be expected english", async () => {
54
- // Arrange
55
- const expected = `
56
- export Export scripts.
57
- `.trim();
58
- // Act
59
- const testLine = stdout
60
- .split(/\n/)
61
- .find((line) => line.trim().startsWith('export'))
62
- .trim();
63
- // Assert
64
- expect(testLine).toBe(expected);
65
- });
66
-
67
- test("CLI help interface 'script commands import' description should be expected english", async () => {
68
- // Arrange
69
- const expected = `
70
- import Import scripts.
71
- `.trim();
72
- // Act
73
- const testLine = stdout
74
- .split(/\n/)
75
- .find((line) => line.trim().startsWith('import'))
76
- .trim();
77
- // Assert
78
- expect(testLine).toBe(expected);
79
- });
@@ -1,63 +0,0 @@
1
- /* eslint-disable no-param-reassign */
2
- /**
3
- * @file A collection of slightly rushed functions to help test the interface
4
- */
5
-
6
- export const range = (start = 0, stop = 1, step = 1) => {
7
- const a = [start];
8
- let b = start;
9
- while (b < stop) {
10
- a.push((b += step || 1));
11
- }
12
- return a;
13
- };
14
-
15
- /**
16
- * JavaScript Regex constructor does not automatically escape special regex chars, this function fixes that
17
- */
18
- const escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string as a token
19
-
20
- /**
21
- * @param str {string} The string to parse
22
- * @param startsWith {string} The first word to encounter and start taking
23
- * @param endsAt {string} The last word to encounter and end at
24
- * A crude multiline only parser which takes from A to B, its likely to be buggy but good enough for testing
25
- */
26
- export const crudeMultilineTakeUntil = (str, startsWith, endsAt) =>
27
- str
28
- .match(
29
- new RegExp(
30
- `${escapeRegExp(startsWith)}(.*?)${escapeRegExp(endsAt)}`,
31
- 'gs'
32
- )
33
- )
34
- .join('')
35
- .replace(new RegExp(escapeRegExp(endsAt), 'g'), '');
36
-
37
- export const collapseWhitespace = (str) => str.replace(/\s+/g, ' ').trim();
38
-
39
- // node 14 compatibility
40
- function at(n) {
41
- // ToInteger() abstract op
42
- n = Math.trunc(n) || 0;
43
- // Allow negative indexing from the end
44
- if (n < 0) n += this.length;
45
- // OOB access is guaranteed to return undefined
46
- if (n < 0 || n >= this.length) return undefined;
47
- // Otherwise, this is just normal property access
48
- return this[n];
49
- }
50
-
51
- export function node14Compatibility() {
52
- if (process.version.startsWith('v14')) {
53
- const TypedArray = Reflect.getPrototypeOf(Int8Array);
54
- for (const C of [Array, String, TypedArray]) {
55
- Object.defineProperty(C.prototype, 'at', {
56
- value: at,
57
- writable: true,
58
- enumerable: false,
59
- configurable: true,
60
- });
61
- }
62
- }
63
- }