@adobe/aio-cli-plugin-api-mesh 4.1.0-alpha → 4.1.0-beta.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.
- package/oclif.manifest.json +1 -1
- package/package.json +8 -4
- package/src/commands/api-mesh/__tests__/create.test.js +293 -217
- package/src/commands/api-mesh/__tests__/delete.test.js +6 -6
- package/src/commands/api-mesh/__tests__/describe.test.js +17 -2
- package/src/commands/api-mesh/__tests__/get.test.js +78 -9
- package/src/commands/api-mesh/__tests__/run.test.js +25 -22
- package/src/commands/api-mesh/__tests__/status.test.js +1 -1
- package/src/commands/api-mesh/__tests__/update.test.js +9 -8
- package/src/commands/api-mesh/create.js +9 -6
- package/src/commands/api-mesh/delete.js +5 -5
- package/src/commands/api-mesh/describe.js +3 -3
- package/src/commands/api-mesh/get.js +11 -8
- package/src/commands/api-mesh/run.js +35 -10
- package/src/commands/api-mesh/status.js +4 -4
- package/src/commands/api-mesh/update.js +9 -7
- package/src/constants.js +0 -2
- package/src/cors.js +28 -0
- package/src/fixPlugins.js +28 -0
- package/src/index.js +44 -0
- package/src/lib/devConsole.js +32 -38
- package/src/plugins/complianceHeaders/complianceHeaders.js +55 -0
- package/src/plugins/complianceHeaders/index.js +2 -0
- package/src/plugins/httpDetailsExtensions/LICENSE +21 -0
- package/src/plugins/httpDetailsExtensions/index.js +81 -0
- package/src/secrets.js +34 -0
- package/src/served.js +22 -0
- package/src/server.js +30 -198
- package/src/serverUtils.js +3 -3
- package/src/wranglerServer.js +75 -0
|
@@ -53,7 +53,7 @@ const mockAutoApproveAction = Promise.resolve(false);
|
|
|
53
53
|
describe('delete command tests', () => {
|
|
54
54
|
beforeEach(() => {
|
|
55
55
|
initSdk.mockResolvedValue({
|
|
56
|
-
|
|
56
|
+
imsOrgId: selectedOrg.id,
|
|
57
57
|
projectId: selectedProject.id,
|
|
58
58
|
workspaceId: selectedWorkspace.id,
|
|
59
59
|
});
|
|
@@ -117,13 +117,13 @@ describe('delete command tests', () => {
|
|
|
117
117
|
|
|
118
118
|
return runResult.catch(err => {
|
|
119
119
|
expect(err.message).toMatchInlineSnapshot(
|
|
120
|
-
`"Unable to delete
|
|
120
|
+
`"Unable to delete. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Please check the details and try again."`,
|
|
121
121
|
);
|
|
122
122
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
123
123
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
124
124
|
[
|
|
125
125
|
[
|
|
126
|
-
"Unable to delete
|
|
126
|
+
"Unable to delete. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Please check the details and try again.",
|
|
127
127
|
],
|
|
128
128
|
]
|
|
129
129
|
`);
|
|
@@ -181,7 +181,7 @@ describe('delete command tests', () => {
|
|
|
181
181
|
|
|
182
182
|
await expect(runResult).rejects.toEqual(
|
|
183
183
|
new Error(
|
|
184
|
-
'Unable to delete mesh.
|
|
184
|
+
'Unable to delete mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id',
|
|
185
185
|
),
|
|
186
186
|
);
|
|
187
187
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
@@ -194,7 +194,7 @@ describe('delete command tests', () => {
|
|
|
194
194
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
195
195
|
[
|
|
196
196
|
[
|
|
197
|
-
"Unable to delete mesh.
|
|
197
|
+
"Unable to delete mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id",
|
|
198
198
|
],
|
|
199
199
|
]
|
|
200
200
|
`);
|
|
@@ -212,7 +212,7 @@ describe('delete command tests', () => {
|
|
|
212
212
|
expect(deleteMesh.mock.calls).toMatchInlineSnapshot(`
|
|
213
213
|
[
|
|
214
214
|
[
|
|
215
|
-
"
|
|
215
|
+
"1234",
|
|
216
216
|
"5678",
|
|
217
217
|
"123456789",
|
|
218
218
|
"mesh_id",
|
|
@@ -160,7 +160,12 @@ describe('describe command tests', () => {
|
|
|
160
160
|
|
|
161
161
|
expect(runResult).toMatchInlineSnapshot(`
|
|
162
162
|
{
|
|
163
|
+
"imsOrgId": "1234",
|
|
163
164
|
"meshId": "dummy_meshId",
|
|
165
|
+
"meshUrl": "https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql",
|
|
166
|
+
"projectId": "5678",
|
|
167
|
+
"workspaceId": "123456789",
|
|
168
|
+
"workspaceName": "Workspace01",
|
|
164
169
|
}
|
|
165
170
|
`);
|
|
166
171
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
@@ -199,7 +204,7 @@ describe('describe command tests', () => {
|
|
|
199
204
|
|
|
200
205
|
expect(initRequestId).toHaveBeenCalled();
|
|
201
206
|
expect(describeMesh).toHaveBeenCalledWith(
|
|
202
|
-
selectedOrg.
|
|
207
|
+
selectedOrg.id,
|
|
203
208
|
selectedProject.id,
|
|
204
209
|
selectedWorkspace.id,
|
|
205
210
|
selectedWorkspace.title,
|
|
@@ -207,7 +212,12 @@ describe('describe command tests', () => {
|
|
|
207
212
|
expect(runResult).toMatchInlineSnapshot(`
|
|
208
213
|
{
|
|
209
214
|
"apiKey": "dummy_apiKey",
|
|
215
|
+
"imsOrgId": "1234",
|
|
210
216
|
"meshId": "dummy_meshId",
|
|
217
|
+
"meshUrl": "https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql",
|
|
218
|
+
"projectId": "5678",
|
|
219
|
+
"workspaceId": "123456789",
|
|
220
|
+
"workspaceName": "Workspace01",
|
|
211
221
|
}
|
|
212
222
|
`);
|
|
213
223
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
@@ -250,7 +260,7 @@ describe('describe command tests', () => {
|
|
|
250
260
|
|
|
251
261
|
expect(initRequestId).toHaveBeenCalled();
|
|
252
262
|
expect(describeMesh).toHaveBeenCalledWith(
|
|
253
|
-
selectedOrg.
|
|
263
|
+
selectedOrg.id,
|
|
254
264
|
selectedProject.id,
|
|
255
265
|
selectedWorkspace.id,
|
|
256
266
|
selectedWorkspace.title,
|
|
@@ -258,7 +268,12 @@ describe('describe command tests', () => {
|
|
|
258
268
|
expect(runResult).toMatchInlineSnapshot(`
|
|
259
269
|
{
|
|
260
270
|
"apiKey": "dummy_apiKey",
|
|
271
|
+
"imsOrgId": "1234",
|
|
261
272
|
"meshId": "dummy_meshId",
|
|
273
|
+
"meshUrl": "https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql",
|
|
274
|
+
"projectId": "5678",
|
|
275
|
+
"workspaceId": "123456789",
|
|
276
|
+
"workspaceName": "Workspace01",
|
|
262
277
|
}
|
|
263
278
|
`);
|
|
264
279
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
@@ -115,13 +115,13 @@ describe('get command tests', () => {
|
|
|
115
115
|
|
|
116
116
|
return runResult.catch(err => {
|
|
117
117
|
expect(err.message).toMatchInlineSnapshot(
|
|
118
|
-
`"Unable to get mesh config. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789).
|
|
118
|
+
`"Unable to get mesh config. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Please check the details and try again."`,
|
|
119
119
|
);
|
|
120
120
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
121
121
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
122
122
|
[
|
|
123
123
|
[
|
|
124
|
-
"Unable to get mesh config. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789).
|
|
124
|
+
"Unable to get mesh config. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Please check the details and try again.",
|
|
125
125
|
],
|
|
126
126
|
]
|
|
127
127
|
`);
|
|
@@ -134,13 +134,13 @@ describe('get command tests', () => {
|
|
|
134
134
|
|
|
135
135
|
return runResult.catch(err => {
|
|
136
136
|
expect(err.message).toMatchInlineSnapshot(
|
|
137
|
-
`"Unable to get mesh ID.
|
|
137
|
+
`"Unable to get mesh ID. Please check the details and try again. RequestId: dummy_request_id"`,
|
|
138
138
|
);
|
|
139
139
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
140
140
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
141
141
|
[
|
|
142
142
|
[
|
|
143
|
-
"Unable to get mesh ID.
|
|
143
|
+
"Unable to get mesh ID. Please check the details and try again. RequestId: dummy_request_id",
|
|
144
144
|
],
|
|
145
145
|
]
|
|
146
146
|
`);
|
|
@@ -164,7 +164,7 @@ describe('get command tests', () => {
|
|
|
164
164
|
|
|
165
165
|
await expect(runResult).rejects.toEqual(
|
|
166
166
|
new Error(
|
|
167
|
-
'Unable to get mesh.
|
|
167
|
+
'Unable to get mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id',
|
|
168
168
|
),
|
|
169
169
|
);
|
|
170
170
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
@@ -177,7 +177,7 @@ describe('get command tests', () => {
|
|
|
177
177
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
178
178
|
[
|
|
179
179
|
[
|
|
180
|
-
"Unable to get mesh.
|
|
180
|
+
"Unable to get mesh. Please check the details and try again. If the error persists please contact support. RequestId: dummy_request_id",
|
|
181
181
|
],
|
|
182
182
|
]
|
|
183
183
|
`);
|
|
@@ -193,7 +193,30 @@ describe('get command tests', () => {
|
|
|
193
193
|
verbose: true,
|
|
194
194
|
});
|
|
195
195
|
expect(initRequestId).toHaveBeenCalled();
|
|
196
|
-
expect(runResult).
|
|
196
|
+
expect(runResult).toMatchInlineSnapshot(`
|
|
197
|
+
{
|
|
198
|
+
"imsOrgId": "1234",
|
|
199
|
+
"mesh": {
|
|
200
|
+
"meshConfig": {
|
|
201
|
+
"sources": [
|
|
202
|
+
{
|
|
203
|
+
"handler": {
|
|
204
|
+
"graphql": {
|
|
205
|
+
"endpoint": "<gql_endpoint>",
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
"name": "<api_name>",
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
"meshId": "dummy_meshId",
|
|
214
|
+
"meshUrl": "https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql",
|
|
215
|
+
"projectId": "5678",
|
|
216
|
+
"workspaceId": "123456789",
|
|
217
|
+
"workspaceName": "Workspace01",
|
|
218
|
+
}
|
|
219
|
+
`);
|
|
197
220
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
198
221
|
[
|
|
199
222
|
[
|
|
@@ -240,7 +263,30 @@ describe('get command tests', () => {
|
|
|
240
263
|
|
|
241
264
|
const runResult = await GetCommand.run();
|
|
242
265
|
|
|
243
|
-
expect(runResult).
|
|
266
|
+
expect(runResult).toMatchInlineSnapshot(`
|
|
267
|
+
{
|
|
268
|
+
"imsOrgId": "1234",
|
|
269
|
+
"mesh": {
|
|
270
|
+
"meshConfig": {
|
|
271
|
+
"sources": [
|
|
272
|
+
{
|
|
273
|
+
"handler": {
|
|
274
|
+
"graphql": {
|
|
275
|
+
"endpoint": "<gql_endpoint>",
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
"name": "<api_name>",
|
|
279
|
+
},
|
|
280
|
+
],
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
"meshId": "dummy_meshId",
|
|
284
|
+
"meshUrl": "https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql",
|
|
285
|
+
"projectId": "5678",
|
|
286
|
+
"workspaceId": "123456789",
|
|
287
|
+
"workspaceName": "Workspace01",
|
|
288
|
+
}
|
|
289
|
+
`);
|
|
244
290
|
expect(writeFile.mock.calls).toMatchInlineSnapshot(`
|
|
245
291
|
[
|
|
246
292
|
[
|
|
@@ -294,7 +340,30 @@ describe('get command tests', () => {
|
|
|
294
340
|
});
|
|
295
341
|
const runResult = await GetCommand.run();
|
|
296
342
|
|
|
297
|
-
expect(runResult).
|
|
343
|
+
expect(runResult).toMatchInlineSnapshot(`
|
|
344
|
+
{
|
|
345
|
+
"imsOrgId": "1234",
|
|
346
|
+
"mesh": {
|
|
347
|
+
"meshConfig": {
|
|
348
|
+
"sources": [
|
|
349
|
+
{
|
|
350
|
+
"handler": {
|
|
351
|
+
"graphql": {
|
|
352
|
+
"endpoint": "<gql_endpoint>",
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
"name": "<api_name>",
|
|
356
|
+
},
|
|
357
|
+
],
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
"meshId": "dummy_meshId",
|
|
361
|
+
"meshUrl": "https://edge-sandbox-graph.adobe.io/api/dummy_meshId/graphql",
|
|
362
|
+
"projectId": "5678",
|
|
363
|
+
"workspaceId": "123456789",
|
|
364
|
+
"workspaceName": "Workspace01",
|
|
365
|
+
}
|
|
366
|
+
`);
|
|
298
367
|
expect(writeFile.mock.calls).toMatchInlineSnapshot(`
|
|
299
368
|
[
|
|
300
369
|
[
|
|
@@ -12,7 +12,6 @@ governing permissions and limitations under the License.
|
|
|
12
12
|
|
|
13
13
|
const RunCommand = require('../run');
|
|
14
14
|
const {
|
|
15
|
-
startGraphqlServer,
|
|
16
15
|
interpolateMesh,
|
|
17
16
|
importFiles,
|
|
18
17
|
promptConfirm,
|
|
@@ -20,18 +19,18 @@ const {
|
|
|
20
19
|
initSdk,
|
|
21
20
|
writeSecretsFile,
|
|
22
21
|
} = require('../../../helpers');
|
|
22
|
+
const { runServer } = require('../../../server');
|
|
23
23
|
const { getMeshId, getMeshArtifact } = require('../../../lib/devConsole');
|
|
24
24
|
require('@adobe-apimesh/mesh-builder');
|
|
25
25
|
|
|
26
26
|
jest.mock('../../../helpers', () => ({
|
|
27
27
|
initSdk: jest.fn().mockResolvedValue({
|
|
28
|
-
|
|
28
|
+
imsOrgId: 'mockOrgId',
|
|
29
29
|
projectId: 'mockProjectId',
|
|
30
30
|
workspaceId: 'mockWorkspaceId',
|
|
31
31
|
workspaceName: 'mockWorkspaceTitle',
|
|
32
32
|
}),
|
|
33
33
|
initRequestId: jest.fn().mockResolvedValue({}),
|
|
34
|
-
startGraphqlServer: jest.fn().mockResolvedValue({}),
|
|
35
34
|
interpolateMesh: jest.fn().mockResolvedValue({}),
|
|
36
35
|
importFiles: jest.fn().mockResolvedValue(),
|
|
37
36
|
promptConfirm: jest.fn().mockResolvedValue(true),
|
|
@@ -39,6 +38,10 @@ jest.mock('../../../helpers', () => ({
|
|
|
39
38
|
writeSecretsFile: jest.fn().mockResolvedValue(),
|
|
40
39
|
}));
|
|
41
40
|
|
|
41
|
+
jest.mock('../../../server', () => ({
|
|
42
|
+
runServer: jest.fn().mockResolvedValue(),
|
|
43
|
+
}));
|
|
44
|
+
|
|
42
45
|
jest.mock('../../../lib/devConsole', () => ({
|
|
43
46
|
getMeshId: jest.fn().mockResolvedValue('mockMeshId'),
|
|
44
47
|
getMeshArtifact: jest.fn().mockResolvedValue(),
|
|
@@ -91,6 +94,10 @@ describe('run command tests', () => {
|
|
|
91
94
|
platformSpy.mockRestore();
|
|
92
95
|
});
|
|
93
96
|
|
|
97
|
+
beforeAll(() => {
|
|
98
|
+
jest.spyOn(RunCommand.prototype, 'copyMeshContent').mockImplementation(() => {});
|
|
99
|
+
});
|
|
100
|
+
|
|
94
101
|
test('snapshot run command description', () => {
|
|
95
102
|
expect(RunCommand.description).toMatchInlineSnapshot(
|
|
96
103
|
`"Run a local development server that builds and compiles a mesh locally"`,
|
|
@@ -189,11 +196,7 @@ describe('run command tests', () => {
|
|
|
189
196
|
parseSpy.mockResolvedValue(parseOutput);
|
|
190
197
|
|
|
191
198
|
await RunCommand.run();
|
|
192
|
-
expect(
|
|
193
|
-
expect.anything(),
|
|
194
|
-
parseOutput.flags.port,
|
|
195
|
-
false,
|
|
196
|
-
);
|
|
199
|
+
expect(runServer).toHaveBeenCalledWith(expect.anything(), parseOutput.flags.port);
|
|
197
200
|
});
|
|
198
201
|
|
|
199
202
|
test('should use the port number provided in the .env file if there is no port', async () => {
|
|
@@ -210,7 +213,7 @@ describe('run command tests', () => {
|
|
|
210
213
|
parseSpy.mockResolvedValue(parseOutput);
|
|
211
214
|
|
|
212
215
|
await RunCommand.run();
|
|
213
|
-
expect(
|
|
216
|
+
expect(runServer).toHaveBeenCalledWith(expect.anything(), process.env.PORT);
|
|
214
217
|
});
|
|
215
218
|
|
|
216
219
|
test('should use the default port if port number is not provided explicitly', async () => {
|
|
@@ -226,7 +229,7 @@ describe('run command tests', () => {
|
|
|
226
229
|
parseSpy.mockResolvedValue(parseOutput);
|
|
227
230
|
|
|
228
231
|
await RunCommand.run();
|
|
229
|
-
expect(
|
|
232
|
+
expect(runServer).toHaveBeenCalledWith(expect.anything(), defaultPort);
|
|
230
233
|
});
|
|
231
234
|
|
|
232
235
|
test('should return error for run command if the mesh has placeholders and env file provided using --env flag is not found', async () => {
|
|
@@ -393,7 +396,7 @@ describe('run command tests', () => {
|
|
|
393
396
|
});
|
|
394
397
|
|
|
395
398
|
await RunCommand.run();
|
|
396
|
-
expect(
|
|
399
|
+
expect(runServer).toHaveBeenCalledWith(expect.anything(), defaultPort);
|
|
397
400
|
});
|
|
398
401
|
|
|
399
402
|
// file import tests
|
|
@@ -439,7 +442,7 @@ describe('run command tests', () => {
|
|
|
439
442
|
});
|
|
440
443
|
|
|
441
444
|
await RunCommand.run();
|
|
442
|
-
expect(
|
|
445
|
+
expect(runServer).toHaveBeenCalledWith(expect.anything(), defaultPort);
|
|
443
446
|
});
|
|
444
447
|
|
|
445
448
|
test('should fail if the file name is more than 25 characters', async () => {
|
|
@@ -615,7 +618,7 @@ describe('run command tests', () => {
|
|
|
615
618
|
});
|
|
616
619
|
|
|
617
620
|
await RunCommand.run();
|
|
618
|
-
expect(
|
|
621
|
+
expect(runServer).toHaveBeenCalledWith(expect.anything(), defaultPort);
|
|
619
622
|
});
|
|
620
623
|
|
|
621
624
|
test('should override if prompt returns Yes, if there is files array', async () => {
|
|
@@ -662,7 +665,7 @@ describe('run command tests', () => {
|
|
|
662
665
|
|
|
663
666
|
await RunCommand.run();
|
|
664
667
|
|
|
665
|
-
expect(
|
|
668
|
+
expect(runServer).toHaveBeenCalledWith(expect.anything(), defaultPort);
|
|
666
669
|
});
|
|
667
670
|
|
|
668
671
|
test('should pass for a fully-qualified meshConfig even if the file does not exist in fileSystem', async () => {
|
|
@@ -709,7 +712,7 @@ describe('run command tests', () => {
|
|
|
709
712
|
});
|
|
710
713
|
|
|
711
714
|
await RunCommand.run();
|
|
712
|
-
expect(
|
|
715
|
+
expect(runServer).toHaveBeenCalledWith(expect.anything(), defaultPort);
|
|
713
716
|
});
|
|
714
717
|
|
|
715
718
|
test('should pass if the file is located in subdirectory of mesh directory', async () => {
|
|
@@ -755,7 +758,7 @@ describe('run command tests', () => {
|
|
|
755
758
|
|
|
756
759
|
await RunCommand.run();
|
|
757
760
|
|
|
758
|
-
expect(
|
|
761
|
+
expect(runServer).toHaveBeenCalledWith(expect.anything(), defaultPort);
|
|
759
762
|
});
|
|
760
763
|
|
|
761
764
|
test('should fail if the file is outside the workspace directory', async () => {
|
|
@@ -862,13 +865,13 @@ describe('run command tests', () => {
|
|
|
862
865
|
|
|
863
866
|
expect(initSdk).toHaveBeenCalled();
|
|
864
867
|
expect(getMeshId).toHaveBeenCalledWith(
|
|
865
|
-
'
|
|
868
|
+
'mockOrgId',
|
|
866
869
|
'mockProjectId',
|
|
867
870
|
'mockWorkspaceId',
|
|
868
871
|
'mockWorkspaceTitle',
|
|
869
872
|
);
|
|
870
873
|
expect(getMeshArtifact).toHaveBeenCalledWith(
|
|
871
|
-
'
|
|
874
|
+
'mockOrgId',
|
|
872
875
|
'mockProjectId',
|
|
873
876
|
'mockWorkspaceId',
|
|
874
877
|
'mockWorkspaceTitle',
|
|
@@ -926,7 +929,7 @@ describe('run command tests', () => {
|
|
|
926
929
|
|
|
927
930
|
await RunCommand.run();
|
|
928
931
|
expect(writeSecretsFile).toHaveBeenCalled();
|
|
929
|
-
expect(
|
|
932
|
+
expect(runServer).toHaveBeenCalledWith(expect.anything(), defaultPort);
|
|
930
933
|
});
|
|
931
934
|
|
|
932
935
|
test('should return error if ran with secrets against windows platform with batch variables', async () => {
|
|
@@ -964,7 +967,7 @@ describe('run command tests', () => {
|
|
|
964
967
|
|
|
965
968
|
await RunCommand.run();
|
|
966
969
|
expect(writeSecretsFile).toHaveBeenCalled();
|
|
967
|
-
expect(
|
|
970
|
+
expect(runServer).toHaveBeenCalledWith(expect.anything(), defaultPort);
|
|
968
971
|
});
|
|
969
972
|
|
|
970
973
|
test('should pass if ran with secrets against darwin(macOS) platform with batch variables', async () => {
|
|
@@ -979,7 +982,7 @@ describe('run command tests', () => {
|
|
|
979
982
|
|
|
980
983
|
await RunCommand.run();
|
|
981
984
|
expect(writeSecretsFile).toHaveBeenCalled();
|
|
982
|
-
expect(
|
|
985
|
+
expect(runServer).toHaveBeenCalledWith(expect.anything(), defaultPort);
|
|
983
986
|
});
|
|
984
987
|
|
|
985
988
|
test('should escape variables that are preceded by backslash symbol', async () => {
|
|
@@ -996,6 +999,6 @@ describe('run command tests', () => {
|
|
|
996
999
|
'Home: rootPath\nHomeString: $HOME\nHomeWithSlash: \\rootPath\nHomeStringWithSlash: \\$HOME\n',
|
|
997
1000
|
expect.anything(),
|
|
998
1001
|
);
|
|
999
|
-
expect(
|
|
1002
|
+
expect(runServer).toHaveBeenCalledWith(expect.anything(), defaultPort);
|
|
1000
1003
|
});
|
|
1001
1004
|
});
|
|
@@ -88,7 +88,7 @@ describe('status command tests', () => {
|
|
|
88
88
|
describe('unexpected error', () => {
|
|
89
89
|
test('should output mesh not found error when mesh does not exist', async () => {
|
|
90
90
|
getMeshId.mockResolvedValue(null);
|
|
91
|
-
const expectedMessage = `Unable to get mesh status. No mesh found for Org(${mockOrg.
|
|
91
|
+
const expectedMessage = `Unable to get mesh status. No mesh found for Org(${mockOrg.id}) -> Project(${mockProject.id}) -> Workspace(${mockWorkspace.id}). Please check the details and try again.`;
|
|
92
92
|
const runResult = StatusCommand.run();
|
|
93
93
|
await expect(runResult).rejects.toEqual(new Error(expectedMessage));
|
|
94
94
|
expect(errorLogSpy).toHaveBeenCalledWith(expectedMessage);
|
|
@@ -50,7 +50,6 @@ describe('update command tests', () => {
|
|
|
50
50
|
beforeEach(() => {
|
|
51
51
|
initSdk.mockResolvedValue({
|
|
52
52
|
imsOrgId: selectedOrg.id,
|
|
53
|
-
imsOrgCode: selectedOrg.code,
|
|
54
53
|
projectId: selectedProject.id,
|
|
55
54
|
workspaceId: selectedWorkspace.id,
|
|
56
55
|
workspaceName: selectedWorkspace.title,
|
|
@@ -326,13 +325,13 @@ describe('update command tests', () => {
|
|
|
326
325
|
const runResult = UpdateCommand.run();
|
|
327
326
|
|
|
328
327
|
await expect(runResult).rejects.toMatchInlineSnapshot(
|
|
329
|
-
`[Error: Unable to get mesh ID.
|
|
328
|
+
`[Error: Unable to get mesh ID. Please check the details and try again. RequestId: dummy_request_id]`,
|
|
330
329
|
);
|
|
331
330
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
332
331
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
333
332
|
[
|
|
334
333
|
[
|
|
335
|
-
"Unable to get mesh ID.
|
|
334
|
+
"Unable to get mesh ID. Please check the details and try again. RequestId: dummy_request_id",
|
|
336
335
|
],
|
|
337
336
|
]
|
|
338
337
|
`);
|
|
@@ -374,7 +373,7 @@ describe('update command tests', () => {
|
|
|
374
373
|
// );
|
|
375
374
|
|
|
376
375
|
await expect(runResult).rejects.toMatchInlineSnapshot(
|
|
377
|
-
`[Error: Unable to update the mesh.
|
|
376
|
+
`[Error: Unable to update the mesh. Please check the mesh configuration file and try again. If the error persists please contact support. RequestId: dummy_request_id]`,
|
|
378
377
|
);
|
|
379
378
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
380
379
|
[
|
|
@@ -386,7 +385,7 @@ describe('update command tests', () => {
|
|
|
386
385
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
387
386
|
[
|
|
388
387
|
[
|
|
389
|
-
"Unable to update the mesh.
|
|
388
|
+
"Unable to update the mesh. Please check the mesh configuration file and try again. If the error persists please contact support. RequestId: dummy_request_id",
|
|
390
389
|
],
|
|
391
390
|
]
|
|
392
391
|
`);
|
|
@@ -555,7 +554,7 @@ describe('update command tests', () => {
|
|
|
555
554
|
expect(initRequestId).toHaveBeenCalled();
|
|
556
555
|
expect(updateMesh.mock.calls[0]).toMatchInlineSnapshot(`
|
|
557
556
|
[
|
|
558
|
-
"
|
|
557
|
+
"1234",
|
|
559
558
|
"5678",
|
|
560
559
|
"123456789",
|
|
561
560
|
"Workspace01",
|
|
@@ -723,7 +722,9 @@ describe('update command tests', () => {
|
|
|
723
722
|
|
|
724
723
|
const output = UpdateCommand.run();
|
|
725
724
|
await expect(output).rejects.toEqual(
|
|
726
|
-
new Error(
|
|
725
|
+
new Error(
|
|
726
|
+
'Unable to import the files in the mesh config. Please check the file and try again.',
|
|
727
|
+
),
|
|
727
728
|
);
|
|
728
729
|
|
|
729
730
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
@@ -737,7 +738,7 @@ describe('update command tests', () => {
|
|
|
737
738
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
738
739
|
[
|
|
739
740
|
[
|
|
740
|
-
"Unable to import the files in the mesh config.
|
|
741
|
+
"Unable to import the files in the mesh config. Please check the file and try again.",
|
|
741
742
|
],
|
|
742
743
|
]
|
|
743
744
|
`);
|
|
@@ -59,6 +59,7 @@ class CreateCommand extends Command {
|
|
|
59
59
|
const envFilePath = await flags.env;
|
|
60
60
|
const secretsFilePath = await flags.secrets;
|
|
61
61
|
const {
|
|
62
|
+
imsOrgId,
|
|
62
63
|
imsOrgCode,
|
|
63
64
|
projectId,
|
|
64
65
|
workspaceId,
|
|
@@ -82,7 +83,7 @@ class CreateCommand extends Command {
|
|
|
82
83
|
data = JSON.parse(inputMeshData);
|
|
83
84
|
} catch (err) {
|
|
84
85
|
this.log(err.message);
|
|
85
|
-
this.error('Input mesh file is not a valid JSON.
|
|
86
|
+
this.error('Input mesh file is not a valid JSON. Please check the file provided.');
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
|
|
@@ -101,7 +102,9 @@ class CreateCommand extends Command {
|
|
|
101
102
|
data = await importFiles(data, filesList, args.file, flags.autoConfirmAction);
|
|
102
103
|
} catch (err) {
|
|
103
104
|
this.log(err.message);
|
|
104
|
-
this.error(
|
|
105
|
+
this.error(
|
|
106
|
+
'Unable to import the files in the mesh config. Please check the file and try again.',
|
|
107
|
+
);
|
|
105
108
|
}
|
|
106
109
|
}
|
|
107
110
|
|
|
@@ -115,7 +118,7 @@ class CreateCommand extends Command {
|
|
|
115
118
|
data.secrets = encryptedSecrets;
|
|
116
119
|
} catch (err) {
|
|
117
120
|
this.log(err.message);
|
|
118
|
-
this.error('Unable to import secrets.
|
|
121
|
+
this.error('Unable to import secrets. Please check the file and try again.');
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
|
|
@@ -128,7 +131,7 @@ class CreateCommand extends Command {
|
|
|
128
131
|
if (shouldContinue) {
|
|
129
132
|
try {
|
|
130
133
|
const { mesh } = await createMesh(
|
|
131
|
-
|
|
134
|
+
imsOrgId,
|
|
132
135
|
projectId,
|
|
133
136
|
workspaceId,
|
|
134
137
|
workspaceName,
|
|
@@ -156,7 +159,7 @@ class CreateCommand extends Command {
|
|
|
156
159
|
|
|
157
160
|
// When renaming the return values, make sure to make necessary changes to
|
|
158
161
|
// template adobe/generator-app-api-mesh since it relies on "mesh"
|
|
159
|
-
return { mesh };
|
|
162
|
+
return { ...mesh, meshUrl, imsOrgId, projectId, workspaceId, workspaceName };
|
|
160
163
|
} else {
|
|
161
164
|
this.error(`Unable to create a mesh. Please try again. RequestId: ${global.requestId}`, {
|
|
162
165
|
exit: false,
|
|
@@ -166,7 +169,7 @@ class CreateCommand extends Command {
|
|
|
166
169
|
this.log(error.message);
|
|
167
170
|
|
|
168
171
|
this.error(
|
|
169
|
-
`Unable to create a mesh.
|
|
172
|
+
`Unable to create a mesh. Please check the mesh configuration file and try again. If the error persists please contact support. RequestId: ${global.requestId}`,
|
|
170
173
|
);
|
|
171
174
|
}
|
|
172
175
|
} else {
|
|
@@ -34,14 +34,14 @@ class DeleteCommand extends Command {
|
|
|
34
34
|
const ignoreCache = await flags.ignoreCache;
|
|
35
35
|
const autoConfirmAction = await flags.autoConfirmAction;
|
|
36
36
|
|
|
37
|
-
const {
|
|
37
|
+
const { imsOrgId, projectId, workspaceId } = await initSdk({
|
|
38
38
|
ignoreCache,
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
let meshId = null;
|
|
42
42
|
|
|
43
43
|
try {
|
|
44
|
-
meshId = await getMeshId(
|
|
44
|
+
meshId = await getMeshId(imsOrgId, projectId, workspaceId);
|
|
45
45
|
} catch (err) {
|
|
46
46
|
this.error(
|
|
47
47
|
`Unable to get mesh ID. Please check the details and try again. RequestId: ${global.requestId}`,
|
|
@@ -59,7 +59,7 @@ class DeleteCommand extends Command {
|
|
|
59
59
|
|
|
60
60
|
if (shouldContinue) {
|
|
61
61
|
try {
|
|
62
|
-
const deleteMeshResponse = await deleteMesh(
|
|
62
|
+
const deleteMeshResponse = await deleteMesh(imsOrgId, projectId, workspaceId, meshId);
|
|
63
63
|
|
|
64
64
|
if (deleteMeshResponse) {
|
|
65
65
|
this.log('Successfully deleted mesh %s', meshId);
|
|
@@ -72,7 +72,7 @@ class DeleteCommand extends Command {
|
|
|
72
72
|
this.log(error.message);
|
|
73
73
|
|
|
74
74
|
this.error(
|
|
75
|
-
`Unable to delete mesh.
|
|
75
|
+
`Unable to delete mesh. Please check the details and try again. If the error persists please contact support. RequestId: ${global.requestId}`,
|
|
76
76
|
);
|
|
77
77
|
}
|
|
78
78
|
} else {
|
|
@@ -82,7 +82,7 @@ class DeleteCommand extends Command {
|
|
|
82
82
|
}
|
|
83
83
|
} else {
|
|
84
84
|
this.error(
|
|
85
|
-
`Unable to delete
|
|
85
|
+
`Unable to delete. No mesh found for Org(${imsOrgId}) -> Project(${projectId}) -> Workspace(${workspaceId}). Please check the details and try again.`,
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
@@ -30,12 +30,12 @@ class DescribeCommand extends Command {
|
|
|
30
30
|
|
|
31
31
|
const { flags } = await this.parse(DescribeCommand);
|
|
32
32
|
const ignoreCache = await flags.ignoreCache;
|
|
33
|
-
const {
|
|
33
|
+
const { imsOrgId, projectId, workspaceId, workspaceName } = await initSdk({
|
|
34
34
|
ignoreCache,
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
try {
|
|
38
|
-
const meshDetails = await describeMesh(
|
|
38
|
+
const meshDetails = await describeMesh(imsOrgId, projectId, workspaceId, workspaceName);
|
|
39
39
|
|
|
40
40
|
if (meshDetails) {
|
|
41
41
|
const { meshId } = meshDetails;
|
|
@@ -49,7 +49,7 @@ class DescribeCommand extends Command {
|
|
|
49
49
|
this.log('Mesh ID: %s', meshId);
|
|
50
50
|
this.log('Mesh Endpoint: %s', meshUrl);
|
|
51
51
|
|
|
52
|
-
return meshDetails;
|
|
52
|
+
return { ...meshDetails, meshUrl, imsOrgId, projectId, workspaceId, workspaceName };
|
|
53
53
|
} else {
|
|
54
54
|
logger.error(
|
|
55
55
|
`Unable to get mesh details. Please check the details and try again. RequestId: ${global.requestId}`,
|