@adobe/aio-cli-plugin-api-mesh 5.2.4-alpha.0 → 5.3.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 +13 -6
- package/src/commands/api-mesh/__tests__/cache-purge.test.js +1 -2
- package/src/commands/api-mesh/__tests__/create.test.js +19 -22
- package/src/commands/api-mesh/__tests__/delete-log-forwarding.test.js +106 -0
- package/src/commands/api-mesh/__tests__/delete.test.js +1 -2
- package/src/commands/api-mesh/__tests__/describe.test.js +1 -3
- package/src/commands/api-mesh/__tests__/get.test.js +2 -2
- package/src/commands/api-mesh/__tests__/log-get-bulk.test.js +19 -213
- package/src/commands/api-mesh/__tests__/run.test.js +191 -65
- package/src/commands/api-mesh/__tests__/update.test.js +8 -7
- package/src/commands/api-mesh/cache/purge.js +1 -3
- package/src/commands/api-mesh/config/delete/log-forwarding.js +80 -0
- package/src/commands/api-mesh/create.js +22 -6
- package/src/commands/api-mesh/delete.js +1 -3
- package/src/commands/api-mesh/describe.js +1 -3
- package/src/commands/api-mesh/get.js +1 -3
- package/src/commands/api-mesh/log-get-bulk.js +5 -26
- package/src/commands/api-mesh/log-get.js +1 -3
- package/src/commands/api-mesh/log-list.js +1 -3
- package/src/commands/api-mesh/run.js +207 -168
- package/src/commands/api-mesh/source/discover.js +2 -9
- package/src/commands/api-mesh/source/get.js +1 -8
- package/src/commands/api-mesh/source/install.js +1 -2
- package/src/commands/api-mesh/status.js +1 -2
- package/src/commands/api-mesh/update.js +21 -6
- package/src/commands/{PLUGINNAME/__tests__/index.test.js → api-mesh.js} +13 -15
- package/src/helpers.js +73 -15
- package/src/hooks/initMetadata.js +8 -0
- package/src/lib/smsClient.js +115 -1
- package/src/meshArtifact.js +231 -0
- package/src/project.js +56 -0
- package/src/server.js +74 -32
- package/src/utils.js +26 -24
- package/src/{index.js → worker.js} +9 -7
- package/src/wranglerCli.js +54 -0
- package/wrangler.toml +13 -0
- package/src/commands/PLUGINNAME/index.js +0 -32
- package/src/wranglerServer.js +0 -80
|
@@ -19,8 +19,8 @@ const {
|
|
|
19
19
|
initSdk,
|
|
20
20
|
writeSecretsFile,
|
|
21
21
|
} = require('../../../helpers');
|
|
22
|
-
const { runServer } = require('../../../server');
|
|
23
22
|
const { getMeshId, getMeshArtifact } = require('../../../lib/smsClient');
|
|
23
|
+
const { start } = require('../../../wranglerCli');
|
|
24
24
|
require('@adobe-apimesh/mesh-builder');
|
|
25
25
|
|
|
26
26
|
jest.mock('../../../helpers', () => ({
|
|
@@ -32,20 +32,25 @@ jest.mock('../../../helpers', () => ({
|
|
|
32
32
|
}),
|
|
33
33
|
initRequestId: jest.fn().mockResolvedValue({}),
|
|
34
34
|
interpolateMesh: jest.fn().mockResolvedValue({}),
|
|
35
|
-
importFiles: jest.fn().mockResolvedValue(),
|
|
35
|
+
importFiles: jest.fn().mockResolvedValue({}),
|
|
36
36
|
promptConfirm: jest.fn().mockResolvedValue(true),
|
|
37
37
|
setUpTenantFiles: jest.fn().mockResolvedValue(),
|
|
38
38
|
writeSecretsFile: jest.fn().mockResolvedValue(),
|
|
39
39
|
}));
|
|
40
40
|
|
|
41
|
-
jest.mock('../../../
|
|
42
|
-
|
|
41
|
+
jest.mock('../../../wranglerCli', () => ({
|
|
42
|
+
start: jest.fn().mockResolvedValue(),
|
|
43
43
|
}));
|
|
44
44
|
|
|
45
45
|
jest.mock('../../../lib/smsClient', () => ({
|
|
46
46
|
getMeshId: jest.fn().mockResolvedValue('mockMeshId'),
|
|
47
47
|
getMeshArtifact: jest.fn().mockResolvedValue(),
|
|
48
48
|
}));
|
|
49
|
+
|
|
50
|
+
jest.mock('../../../fixPlugins', () => ({
|
|
51
|
+
fixPlugins: jest.fn().mockResolvedValue({}),
|
|
52
|
+
}));
|
|
53
|
+
|
|
49
54
|
jest.mock('chalk', () => ({
|
|
50
55
|
red: jest.fn(text => text), // Return the input text without any color formatting
|
|
51
56
|
}));
|
|
@@ -75,7 +80,6 @@ const originalEnv = {
|
|
|
75
80
|
API_MESH_TIER: 'NON-TI',
|
|
76
81
|
};
|
|
77
82
|
|
|
78
|
-
const defaultPort = 5000;
|
|
79
83
|
const os = require('os');
|
|
80
84
|
|
|
81
85
|
describe('run command tests', () => {
|
|
@@ -94,10 +98,6 @@ describe('run command tests', () => {
|
|
|
94
98
|
platformSpy.mockRestore();
|
|
95
99
|
});
|
|
96
100
|
|
|
97
|
-
beforeAll(() => {
|
|
98
|
-
jest.spyOn(RunCommand.prototype, 'copyMeshContent').mockImplementation(() => {});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
101
|
test('snapshot run command description', () => {
|
|
102
102
|
expect(RunCommand.description).toMatchInlineSnapshot(
|
|
103
103
|
`"Run a local development server that builds and compiles a mesh locally"`,
|
|
@@ -138,8 +138,18 @@ describe('run command tests', () => {
|
|
|
138
138
|
"parse": [Function],
|
|
139
139
|
"type": "option",
|
|
140
140
|
},
|
|
141
|
+
"inspectPort": {
|
|
142
|
+
"char": "i",
|
|
143
|
+
"default": 9229,
|
|
144
|
+
"description": "Port number for the local dev server inspector",
|
|
145
|
+
"input": [],
|
|
146
|
+
"multiple": false,
|
|
147
|
+
"parse": [Function],
|
|
148
|
+
"type": "option",
|
|
149
|
+
},
|
|
141
150
|
"port": {
|
|
142
151
|
"char": "p",
|
|
152
|
+
"default": 5000,
|
|
143
153
|
"description": "Port number for the local dev server",
|
|
144
154
|
"input": [],
|
|
145
155
|
"multiple": false,
|
|
@@ -188,15 +198,23 @@ describe('run command tests', () => {
|
|
|
188
198
|
});
|
|
189
199
|
|
|
190
200
|
test('should use the port number provided in the flags for starting the server', async () => {
|
|
191
|
-
const
|
|
201
|
+
const cliInput = {
|
|
192
202
|
args: { file: 'src/commands/__fixtures__/sample_mesh.json' },
|
|
193
|
-
flags: {
|
|
203
|
+
flags: {
|
|
204
|
+
port: 6000,
|
|
205
|
+
debug: false,
|
|
206
|
+
inspectPort: 9229,
|
|
207
|
+
},
|
|
194
208
|
};
|
|
195
|
-
|
|
196
|
-
parseSpy.mockResolvedValue(parseOutput);
|
|
209
|
+
parseSpy.mockResolvedValueOnce(cliInput);
|
|
197
210
|
|
|
198
211
|
await RunCommand.run();
|
|
199
|
-
expect(
|
|
212
|
+
expect(start).toHaveBeenCalledWith(
|
|
213
|
+
expect.anything(),
|
|
214
|
+
cliInput.flags.port,
|
|
215
|
+
cliInput.flags.debug,
|
|
216
|
+
cliInput.flags.inspectPort,
|
|
217
|
+
);
|
|
200
218
|
});
|
|
201
219
|
|
|
202
220
|
test('should use the port number provided in the .env file if there is no port', async () => {
|
|
@@ -205,15 +223,23 @@ describe('run command tests', () => {
|
|
|
205
223
|
PORT: 7000,
|
|
206
224
|
};
|
|
207
225
|
|
|
208
|
-
const
|
|
226
|
+
const cliInput = {
|
|
209
227
|
args: { file: 'src/commands/__fixtures__/sample_mesh.json' },
|
|
210
|
-
flags: {
|
|
228
|
+
flags: {
|
|
229
|
+
port: 5000,
|
|
230
|
+
debug: false,
|
|
231
|
+
inspectPort: 9229,
|
|
232
|
+
},
|
|
211
233
|
};
|
|
212
|
-
|
|
213
|
-
parseSpy.mockResolvedValue(parseOutput);
|
|
234
|
+
parseSpy.mockResolvedValueOnce(cliInput);
|
|
214
235
|
|
|
215
236
|
await RunCommand.run();
|
|
216
|
-
expect(
|
|
237
|
+
expect(start).toHaveBeenCalledWith(
|
|
238
|
+
expect.anything(),
|
|
239
|
+
process.env.PORT,
|
|
240
|
+
cliInput.flags.debug,
|
|
241
|
+
cliInput.flags.inspectPort,
|
|
242
|
+
);
|
|
217
243
|
});
|
|
218
244
|
|
|
219
245
|
test('should use the default port if port number is not provided explicitly', async () => {
|
|
@@ -221,15 +247,23 @@ describe('run command tests', () => {
|
|
|
221
247
|
...originalEnv,
|
|
222
248
|
};
|
|
223
249
|
|
|
224
|
-
const
|
|
250
|
+
const cliInput = {
|
|
225
251
|
args: { file: 'src/commands/__fixtures__/sample_mesh.json' },
|
|
226
|
-
flags: {
|
|
252
|
+
flags: {
|
|
253
|
+
port: 5000,
|
|
254
|
+
debug: false,
|
|
255
|
+
inspectPort: 9229,
|
|
256
|
+
},
|
|
227
257
|
};
|
|
228
|
-
|
|
229
|
-
parseSpy.mockResolvedValue(parseOutput);
|
|
258
|
+
parseSpy.mockResolvedValueOnce(cliInput);
|
|
230
259
|
|
|
231
260
|
await RunCommand.run();
|
|
232
|
-
expect(
|
|
261
|
+
expect(start).toHaveBeenCalledWith(
|
|
262
|
+
expect.anything(),
|
|
263
|
+
cliInput.flags.port,
|
|
264
|
+
cliInput.flags.debug,
|
|
265
|
+
cliInput.flags.inspectPort,
|
|
266
|
+
);
|
|
233
267
|
});
|
|
234
268
|
|
|
235
269
|
test('should return error for run command if the mesh has placeholders and env file provided using --env flag is not found', async () => {
|
|
@@ -377,14 +411,6 @@ describe('run command tests', () => {
|
|
|
377
411
|
});
|
|
378
412
|
|
|
379
413
|
test('should successfully run the mesh if provided env file is valid, mesh interpolation is successful and interpolated mesh is a valid JSON', async () => {
|
|
380
|
-
parseSpy.mockResolvedValueOnce({
|
|
381
|
-
args: { file: 'src/commands/__fixtures__/sample_mesh_with_placeholder' },
|
|
382
|
-
flags: {
|
|
383
|
-
env: 'src/commands/__fixtures__/env_valid',
|
|
384
|
-
debug: false,
|
|
385
|
-
},
|
|
386
|
-
});
|
|
387
|
-
|
|
388
414
|
//sampleInterpolated mesh where the mesh string is a valid JSON
|
|
389
415
|
const sampleInterpolatedMesh =
|
|
390
416
|
'{"meshConfig":{"sources":[{"name":"<api-name>","handler":{"graphql":{"endpoint":"<api-url>"}}}],"responseConfig":{"includeHTTPDetails":true}}}';
|
|
@@ -395,8 +421,24 @@ describe('run command tests', () => {
|
|
|
395
421
|
interpolatedMeshData: sampleInterpolatedMesh,
|
|
396
422
|
});
|
|
397
423
|
|
|
424
|
+
const cliInput = {
|
|
425
|
+
args: { file: 'src/commands/__fixtures__/sample_mesh_with_placeholder' },
|
|
426
|
+
flags: {
|
|
427
|
+
env: 'src/commands/__fixtures__/env_valid',
|
|
428
|
+
port: 5000,
|
|
429
|
+
debug: false,
|
|
430
|
+
inspectPort: 9229,
|
|
431
|
+
},
|
|
432
|
+
};
|
|
433
|
+
parseSpy.mockResolvedValueOnce(cliInput);
|
|
434
|
+
|
|
398
435
|
await RunCommand.run();
|
|
399
|
-
expect(
|
|
436
|
+
expect(start).toHaveBeenCalledWith(
|
|
437
|
+
expect.anything(),
|
|
438
|
+
cliInput.flags.port,
|
|
439
|
+
cliInput.flags.debug,
|
|
440
|
+
cliInput.flags.inspectPort,
|
|
441
|
+
);
|
|
400
442
|
});
|
|
401
443
|
|
|
402
444
|
// file import tests
|
|
@@ -429,20 +471,30 @@ describe('run command tests', () => {
|
|
|
429
471
|
],
|
|
430
472
|
};
|
|
431
473
|
|
|
432
|
-
|
|
474
|
+
const cliInput = {
|
|
433
475
|
args: { file: 'src/commands/__fixtures__/sample_mesh_files.json' },
|
|
434
476
|
flags: {
|
|
435
477
|
autoConfirmAction: Promise.resolve(true),
|
|
478
|
+
port: 5000,
|
|
436
479
|
debug: false,
|
|
480
|
+
inspectPort: 9229,
|
|
437
481
|
},
|
|
438
|
-
}
|
|
482
|
+
};
|
|
483
|
+
parseSpy.mockResolvedValueOnce(cliInput);
|
|
439
484
|
|
|
440
485
|
importFiles.mockResolvedValueOnce({
|
|
441
|
-
|
|
486
|
+
data: {
|
|
487
|
+
meshConfig,
|
|
488
|
+
},
|
|
442
489
|
});
|
|
443
490
|
|
|
444
491
|
await RunCommand.run();
|
|
445
|
-
expect(
|
|
492
|
+
expect(start).toHaveBeenCalledWith(
|
|
493
|
+
expect.anything(),
|
|
494
|
+
cliInput.flags.port,
|
|
495
|
+
cliInput.flags.debug,
|
|
496
|
+
cliInput.flags.inspectPort,
|
|
497
|
+
);
|
|
446
498
|
});
|
|
447
499
|
|
|
448
500
|
test('should fail if the file name is more than 25 characters', async () => {
|
|
@@ -608,17 +660,29 @@ describe('run command tests', () => {
|
|
|
608
660
|
|
|
609
661
|
promptConfirm.mockResolvedValueOnce(false).mockResolvedValueOnce(true);
|
|
610
662
|
|
|
611
|
-
importFiles.mockResolvedValueOnce(
|
|
663
|
+
importFiles.mockResolvedValueOnce({
|
|
664
|
+
data: {
|
|
665
|
+
meshConfig,
|
|
666
|
+
},
|
|
667
|
+
});
|
|
612
668
|
|
|
613
|
-
|
|
669
|
+
const cliInput = {
|
|
614
670
|
args: { file: 'src/commands/__fixtures__/sample_mesh_with_files_array.json' },
|
|
615
671
|
flags: {
|
|
672
|
+
port: 5000,
|
|
616
673
|
debug: false,
|
|
674
|
+
inspectPort: 9229,
|
|
617
675
|
},
|
|
618
|
-
}
|
|
676
|
+
};
|
|
677
|
+
parseSpy.mockResolvedValueOnce(cliInput);
|
|
619
678
|
|
|
620
679
|
await RunCommand.run();
|
|
621
|
-
expect(
|
|
680
|
+
expect(start).toHaveBeenCalledWith(
|
|
681
|
+
expect.anything(),
|
|
682
|
+
cliInput.flags.port,
|
|
683
|
+
cliInput.flags.debug,
|
|
684
|
+
cliInput.flags.inspectPort,
|
|
685
|
+
);
|
|
622
686
|
});
|
|
623
687
|
|
|
624
688
|
test('should override if prompt returns Yes, if there is files array', async () => {
|
|
@@ -652,20 +716,30 @@ describe('run command tests', () => {
|
|
|
652
716
|
|
|
653
717
|
promptConfirm.mockResolvedValueOnce(true).mockResolvedValueOnce(true);
|
|
654
718
|
|
|
655
|
-
|
|
719
|
+
const cliInput = {
|
|
656
720
|
args: { file: 'src/commands/__fixtures__/sample_mesh_with_files_array.json' },
|
|
657
721
|
flags: {
|
|
722
|
+
port: 5000,
|
|
658
723
|
debug: false,
|
|
724
|
+
inspectPort: 9229,
|
|
659
725
|
},
|
|
660
|
-
}
|
|
726
|
+
};
|
|
727
|
+
parseSpy.mockResolvedValueOnce(cliInput);
|
|
661
728
|
|
|
662
729
|
importFiles.mockResolvedValueOnce({
|
|
663
|
-
|
|
730
|
+
data: {
|
|
731
|
+
meshConfig,
|
|
732
|
+
},
|
|
664
733
|
});
|
|
665
734
|
|
|
666
735
|
await RunCommand.run();
|
|
667
736
|
|
|
668
|
-
expect(
|
|
737
|
+
expect(start).toHaveBeenCalledWith(
|
|
738
|
+
expect.anything(),
|
|
739
|
+
cliInput.flags.port,
|
|
740
|
+
cliInput.flags.debug,
|
|
741
|
+
cliInput.flags.inspectPort,
|
|
742
|
+
);
|
|
669
743
|
});
|
|
670
744
|
|
|
671
745
|
test('should pass for a fully-qualified meshConfig even if the file does not exist in fileSystem', async () => {
|
|
@@ -697,22 +771,32 @@ describe('run command tests', () => {
|
|
|
697
771
|
],
|
|
698
772
|
};
|
|
699
773
|
|
|
700
|
-
|
|
774
|
+
const cliInput = {
|
|
701
775
|
args: { file: 'src/commands/__fixtures__/sample_fully_qualified_mesh.json' },
|
|
702
776
|
flags: {
|
|
703
777
|
autoConfirmAction: Promise.resolve(true),
|
|
778
|
+
port: 5000,
|
|
704
779
|
debug: false,
|
|
780
|
+
inspectPort: 9229,
|
|
705
781
|
},
|
|
706
|
-
}
|
|
782
|
+
};
|
|
783
|
+
parseSpy.mockResolvedValueOnce(cliInput);
|
|
707
784
|
|
|
708
785
|
promptConfirm.mockResolvedValueOnce(true);
|
|
709
786
|
|
|
710
787
|
importFiles.mockResolvedValueOnce({
|
|
711
|
-
|
|
788
|
+
data: {
|
|
789
|
+
meshConfig,
|
|
790
|
+
},
|
|
712
791
|
});
|
|
713
792
|
|
|
714
793
|
await RunCommand.run();
|
|
715
|
-
expect(
|
|
794
|
+
expect(start).toHaveBeenCalledWith(
|
|
795
|
+
expect.anything(),
|
|
796
|
+
cliInput.flags.port,
|
|
797
|
+
cliInput.flags.debug,
|
|
798
|
+
cliInput.flags.inspectPort,
|
|
799
|
+
);
|
|
716
800
|
});
|
|
717
801
|
|
|
718
802
|
test('should pass if the file is located in subdirectory of mesh directory', async () => {
|
|
@@ -744,21 +828,31 @@ describe('run command tests', () => {
|
|
|
744
828
|
],
|
|
745
829
|
};
|
|
746
830
|
|
|
747
|
-
|
|
831
|
+
const cliInput = {
|
|
748
832
|
args: { file: 'src/commands/__fixtures__/sample_mesh_subdirectory.json' },
|
|
749
833
|
flags: {
|
|
750
834
|
autoConfirmAction: Promise.resolve(true),
|
|
835
|
+
port: 5000,
|
|
751
836
|
debug: false,
|
|
837
|
+
inspectPort: 9229,
|
|
752
838
|
},
|
|
753
|
-
}
|
|
839
|
+
};
|
|
840
|
+
parseSpy.mockResolvedValueOnce(cliInput);
|
|
754
841
|
|
|
755
842
|
importFiles.mockResolvedValueOnce({
|
|
756
|
-
|
|
843
|
+
data: {
|
|
844
|
+
meshConfig,
|
|
845
|
+
},
|
|
757
846
|
});
|
|
758
847
|
|
|
759
848
|
await RunCommand.run();
|
|
760
849
|
|
|
761
|
-
expect(
|
|
850
|
+
expect(start).toHaveBeenCalledWith(
|
|
851
|
+
expect.anything(),
|
|
852
|
+
cliInput.flags.port,
|
|
853
|
+
cliInput.flags.debug,
|
|
854
|
+
cliInput.flags.inspectPort,
|
|
855
|
+
);
|
|
762
856
|
});
|
|
763
857
|
|
|
764
858
|
test('should fail if the file is outside the workspace directory', async () => {
|
|
@@ -919,17 +1013,25 @@ describe('run command tests', () => {
|
|
|
919
1013
|
});
|
|
920
1014
|
|
|
921
1015
|
test('should successfully run the mesh if provided secrets file is valid', async () => {
|
|
922
|
-
|
|
1016
|
+
const cliInput = {
|
|
923
1017
|
args: { file: 'src/commands/__fixtures__/sample_secrets_mesh.json' },
|
|
924
1018
|
flags: {
|
|
925
1019
|
secrets: 'src/commands/__fixtures__/secrets_valid.yaml',
|
|
1020
|
+
port: 5000,
|
|
926
1021
|
debug: false,
|
|
1022
|
+
inspectPort: 9229,
|
|
927
1023
|
},
|
|
928
|
-
}
|
|
1024
|
+
};
|
|
1025
|
+
parseSpy.mockResolvedValueOnce(cliInput);
|
|
929
1026
|
|
|
930
1027
|
await RunCommand.run();
|
|
931
1028
|
expect(writeSecretsFile).toHaveBeenCalled();
|
|
932
|
-
expect(
|
|
1029
|
+
expect(start).toHaveBeenCalledWith(
|
|
1030
|
+
expect.anything(),
|
|
1031
|
+
cliInput.flags.port,
|
|
1032
|
+
cliInput.flags.debug,
|
|
1033
|
+
cliInput.flags.inspectPort,
|
|
1034
|
+
);
|
|
933
1035
|
});
|
|
934
1036
|
|
|
935
1037
|
test('should return error if ran with secrets against windows platform with batch variables', async () => {
|
|
@@ -957,48 +1059,72 @@ describe('run command tests', () => {
|
|
|
957
1059
|
|
|
958
1060
|
test('should pass if ran with secrets against linux platform with batch variables', async () => {
|
|
959
1061
|
platformSpy.mockReturnValue('linux');
|
|
960
|
-
|
|
1062
|
+
const cliInput = {
|
|
961
1063
|
args: { file: 'src/commands/__fixtures__/sample_secrets_mesh.json' },
|
|
962
1064
|
flags: {
|
|
963
1065
|
secrets: 'src/commands/__fixtures__/secrets_with_batch_variables.yaml',
|
|
1066
|
+
port: 5000,
|
|
964
1067
|
debug: false,
|
|
1068
|
+
inspectPort: 9229,
|
|
965
1069
|
},
|
|
966
|
-
}
|
|
1070
|
+
};
|
|
1071
|
+
parseSpy.mockResolvedValueOnce(cliInput);
|
|
967
1072
|
|
|
968
1073
|
await RunCommand.run();
|
|
969
1074
|
expect(writeSecretsFile).toHaveBeenCalled();
|
|
970
|
-
expect(
|
|
1075
|
+
expect(start).toHaveBeenCalledWith(
|
|
1076
|
+
expect.anything(),
|
|
1077
|
+
cliInput.flags.port,
|
|
1078
|
+
cliInput.flags.debug,
|
|
1079
|
+
cliInput.flags.inspectPort,
|
|
1080
|
+
);
|
|
971
1081
|
});
|
|
972
1082
|
|
|
973
1083
|
test('should pass if ran with secrets against darwin(macOS) platform with batch variables', async () => {
|
|
974
1084
|
platformSpy.mockReturnValue('darwin');
|
|
975
|
-
|
|
1085
|
+
const cliInput = {
|
|
976
1086
|
args: { file: 'src/commands/__fixtures__/sample_secrets_mesh.json' },
|
|
977
1087
|
flags: {
|
|
978
1088
|
secrets: 'src/commands/__fixtures__/secrets_with_batch_variables.yaml',
|
|
1089
|
+
port: 5000,
|
|
979
1090
|
debug: false,
|
|
1091
|
+
inspectPort: 9229,
|
|
980
1092
|
},
|
|
981
|
-
}
|
|
1093
|
+
};
|
|
1094
|
+
parseSpy.mockResolvedValueOnce(cliInput);
|
|
982
1095
|
|
|
983
1096
|
await RunCommand.run();
|
|
984
1097
|
expect(writeSecretsFile).toHaveBeenCalled();
|
|
985
|
-
expect(
|
|
1098
|
+
expect(start).toHaveBeenCalledWith(
|
|
1099
|
+
expect.anything(),
|
|
1100
|
+
cliInput.flags.port,
|
|
1101
|
+
cliInput.flags.debug,
|
|
1102
|
+
cliInput.flags.inspectPort,
|
|
1103
|
+
);
|
|
986
1104
|
});
|
|
987
1105
|
|
|
988
1106
|
test('should escape variables that are preceded by backslash symbol', async () => {
|
|
989
|
-
|
|
1107
|
+
const cliInput = {
|
|
990
1108
|
args: { file: 'src/commands/__fixtures__/sample_mesh_with_escaped_secrets.json' },
|
|
991
1109
|
flags: {
|
|
992
1110
|
secrets: 'src/commands/__fixtures__/secrets_with_escaped_variables.yaml',
|
|
1111
|
+
port: 5000,
|
|
993
1112
|
debug: false,
|
|
1113
|
+
inspectPort: 9229,
|
|
994
1114
|
},
|
|
995
|
-
}
|
|
1115
|
+
};
|
|
1116
|
+
parseSpy.mockResolvedValueOnce(cliInput);
|
|
996
1117
|
|
|
997
1118
|
await RunCommand.run();
|
|
998
1119
|
expect(writeSecretsFile).toHaveBeenCalledWith(
|
|
999
1120
|
'Home: rootPath\nHomeString: $HOME\nHomeWithSlash: \\rootPath\nHomeStringWithSlash: \\$HOME\n',
|
|
1000
1121
|
expect.anything(),
|
|
1001
1122
|
);
|
|
1002
|
-
expect(
|
|
1123
|
+
expect(start).toHaveBeenCalledWith(
|
|
1124
|
+
expect.anything(),
|
|
1125
|
+
cliInput.flags.port,
|
|
1126
|
+
cliInput.flags.debug,
|
|
1127
|
+
cliInput.flags.inspectPort,
|
|
1128
|
+
);
|
|
1003
1129
|
});
|
|
1004
1130
|
});
|
|
@@ -17,7 +17,7 @@ jest.mock('../../../helpers', () => ({
|
|
|
17
17
|
initSdk: jest.fn().mockResolvedValue({}),
|
|
18
18
|
initRequestId: jest.fn().mockResolvedValue({}),
|
|
19
19
|
promptConfirm: jest.fn().mockResolvedValue(true),
|
|
20
|
-
importFiles: jest.fn().mockResolvedValue(),
|
|
20
|
+
importFiles: jest.fn().mockResolvedValue({}),
|
|
21
21
|
}));
|
|
22
22
|
jest.mock('@adobe/aio-cli-lib-console', () => ({
|
|
23
23
|
init: jest.fn().mockResolvedValue(mockConsoleCLIInstance),
|
|
@@ -35,7 +35,7 @@ const selectedWorkspace = { id: '123456789', title: 'Workspace01' };
|
|
|
35
35
|
const { readFile } = require('fs/promises');
|
|
36
36
|
|
|
37
37
|
const UpdateCommand = require('../update');
|
|
38
|
-
const { initSdk,
|
|
38
|
+
const { initSdk, promptConfirm, importFiles } = require('../../../helpers');
|
|
39
39
|
const { getMeshId, updateMesh } = require('../../../lib/smsClient');
|
|
40
40
|
|
|
41
41
|
let logSpy = null;
|
|
@@ -110,7 +110,7 @@ describe('update command tests', () => {
|
|
|
110
110
|
"status": "success",
|
|
111
111
|
}
|
|
112
112
|
`);
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
expect(initSdk).toHaveBeenCalledWith({
|
|
115
115
|
ignoreCache: true,
|
|
116
116
|
});
|
|
@@ -169,7 +169,7 @@ describe('update command tests', () => {
|
|
|
169
169
|
"status": "success",
|
|
170
170
|
}
|
|
171
171
|
`);
|
|
172
|
-
|
|
172
|
+
|
|
173
173
|
expect(initSdk).toHaveBeenCalledWith({
|
|
174
174
|
ignoreCache: true,
|
|
175
175
|
});
|
|
@@ -228,7 +228,7 @@ describe('update command tests', () => {
|
|
|
228
228
|
"status": "success",
|
|
229
229
|
}
|
|
230
230
|
`);
|
|
231
|
-
|
|
231
|
+
|
|
232
232
|
expect(promptConfirm).not.toHaveBeenCalled();
|
|
233
233
|
expect(initSdk).toHaveBeenCalledWith({
|
|
234
234
|
ignoreCache: true,
|
|
@@ -547,12 +547,13 @@ describe('update command tests', () => {
|
|
|
547
547
|
});
|
|
548
548
|
|
|
549
549
|
importFiles.mockResolvedValueOnce({
|
|
550
|
-
|
|
550
|
+
data: {
|
|
551
|
+
meshConfig,
|
|
552
|
+
},
|
|
551
553
|
});
|
|
552
554
|
|
|
553
555
|
const output = await UpdateCommand.run();
|
|
554
556
|
|
|
555
|
-
expect(initRequestId).toHaveBeenCalled();
|
|
556
557
|
expect(updateMesh.mock.calls[0]).toMatchInlineSnapshot(`
|
|
557
558
|
[
|
|
558
559
|
"CODE1234@AdobeOrg",
|
|
@@ -12,7 +12,7 @@ governing permissions and limitations under the License.
|
|
|
12
12
|
const { Command } = require('@oclif/command');
|
|
13
13
|
|
|
14
14
|
const logger = require('../../../classes/logger');
|
|
15
|
-
const { initSdk,
|
|
15
|
+
const { initSdk, promptConfirm } = require('../../../helpers');
|
|
16
16
|
const {
|
|
17
17
|
ignoreCacheFlag,
|
|
18
18
|
autoConfirmActionFlag,
|
|
@@ -30,8 +30,6 @@ class CachePurgeCommand extends Command {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
async run() {
|
|
33
|
-
await initRequestId();
|
|
34
|
-
|
|
35
33
|
logger.info(`RequestId: ${global.requestId}`);
|
|
36
34
|
|
|
37
35
|
const { flags } = await this.parse(CachePurgeCommand);
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2021 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
7
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
8
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
9
|
+
governing permissions and limitations under the License.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const { Command } = require('@oclif/core');
|
|
13
|
+
const logger = require('../../../../classes/logger');
|
|
14
|
+
const { initSdk, promptConfirm } = require('../../../../helpers');
|
|
15
|
+
const { ignoreCacheFlag, autoConfirmActionFlag } = require('../../../../utils');
|
|
16
|
+
const { deleteLogForwarding, getMeshId } = require('../../../../lib/smsClient');
|
|
17
|
+
|
|
18
|
+
class DeleteLogForwardingCommand extends Command {
|
|
19
|
+
static flags = {
|
|
20
|
+
ignoreCache: ignoreCacheFlag,
|
|
21
|
+
autoConfirmAction: autoConfirmActionFlag,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
async run() {
|
|
25
|
+
logger.info(`RequestId: ${global.requestId}`);
|
|
26
|
+
|
|
27
|
+
const { flags } = await this.parse(DeleteLogForwardingCommand);
|
|
28
|
+
|
|
29
|
+
const ignoreCache = await flags.ignoreCache;
|
|
30
|
+
const autoConfirmAction = await flags.autoConfirmAction;
|
|
31
|
+
|
|
32
|
+
const { imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({
|
|
33
|
+
ignoreCache,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
let meshId = null;
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
meshId = await getMeshId(imsOrgCode, projectId, workspaceId, workspaceName);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
this.error(
|
|
42
|
+
`Unable to get mesh ID. Please check the details and try again. RequestId: ${global.requestId}`,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// mesh could not be found
|
|
47
|
+
if (!meshId) {
|
|
48
|
+
this.error(
|
|
49
|
+
`Unable to delete log forwarding details. No mesh found for Org(${imsOrgCode}) -> Project(${projectId}) -> Workspace(${workspaceId}). Check the details and try again.`,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let shouldContinue = true;
|
|
54
|
+
|
|
55
|
+
if (!autoConfirmAction) {
|
|
56
|
+
shouldContinue = await promptConfirm(
|
|
57
|
+
`Are you sure you want to delete the log forwarding details for mesh: ${meshId}?`,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (shouldContinue) {
|
|
62
|
+
try {
|
|
63
|
+
await deleteLogForwarding(imsOrgCode, projectId, workspaceId, meshId);
|
|
64
|
+
this.log('Successfully deleted log forwarding details');
|
|
65
|
+
} catch (error) {
|
|
66
|
+
this.log(error.message);
|
|
67
|
+
this.error(
|
|
68
|
+
`Unable to delete log forwarding details. Try again. RequestId: ${global.requestId}`,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
this.log('delete log-forwarding cancelled');
|
|
73
|
+
return 'delete log-forwarding cancelled';
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
DeleteLogForwardingCommand.description = 'Delete log forwarding details for a given mesh';
|
|
79
|
+
|
|
80
|
+
module.exports = DeleteLogForwardingCommand;
|