@adobe/aio-cli-plugin-api-mesh 1.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/oclif.manifest.json +1 -1
- package/package.json +15 -15
- package/src/commands/api-mesh/__tests__/create.test.js +121 -139
- package/src/commands/api-mesh/__tests__/delete.test.js +40 -40
- package/src/commands/api-mesh/__tests__/describe.test.js +30 -40
- package/src/commands/api-mesh/__tests__/get.test.js +60 -69
- package/src/commands/api-mesh/__tests__/update.test.js +71 -35
- package/src/commands/api-mesh/create.js +17 -6
- package/src/commands/api-mesh/describe.js +1 -1
- package/src/commands/api-mesh/get.js +1 -1
- package/src/commands/api-mesh/source/__fixtures__/0.0.1-test-01.json +1 -1
- package/src/commands/api-mesh/source/__fixtures__/0.0.1-test-02.json +1 -1
- package/src/commands/api-mesh/source/__tests__/discover.test.js +2 -2
- package/src/commands/api-mesh/source/__tests__/get.test.js +19 -16
- package/src/commands/api-mesh/source/__tests__/install.test.js +14 -14
- package/src/commands/api-mesh/source/discover.js +24 -18
- package/src/commands/api-mesh/source/get.js +15 -11
- package/src/commands/api-mesh/source/install.js +49 -41
- package/src/commands/api-mesh/status.js +96 -0
- package/src/commands/api-mesh/update.js +12 -1
- package/src/constants.js +2 -0
- package/src/helpers.js +16 -10
- package/src/utils.js +2 -4
|
@@ -84,10 +84,10 @@ describe('update command tests', () => {
|
|
|
84
84
|
await expect(runResult).rejects.toMatchInlineSnapshot(
|
|
85
85
|
`[Error: Unable to update. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Please check the details and try again.]`,
|
|
86
86
|
);
|
|
87
|
-
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
87
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
88
88
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
[
|
|
90
|
+
[
|
|
91
91
|
"Unable to update. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Please check the details and try again.",
|
|
92
92
|
],
|
|
93
93
|
]
|
|
@@ -101,10 +101,10 @@ describe('update command tests', () => {
|
|
|
101
101
|
await expect(runResult).rejects.toMatchInlineSnapshot(
|
|
102
102
|
`[Error: Unable to get mesh ID. Please check the details and try again. RequestId: dummy_request_id]`,
|
|
103
103
|
);
|
|
104
|
-
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
104
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
105
105
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
[
|
|
107
|
+
[
|
|
108
108
|
"Unable to get mesh ID. Please check the details and try again. RequestId: dummy_request_id",
|
|
109
109
|
],
|
|
110
110
|
]
|
|
@@ -124,10 +124,10 @@ describe('update command tests', () => {
|
|
|
124
124
|
await expect(runResult).rejects.toEqual(
|
|
125
125
|
new Error('Missing required args. Run aio api-mesh update --help for more info.'),
|
|
126
126
|
);
|
|
127
|
-
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
127
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
128
128
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
[
|
|
130
|
+
[
|
|
131
131
|
"Missing required args. Run aio api-mesh update --help for more info.",
|
|
132
132
|
],
|
|
133
133
|
]
|
|
@@ -144,15 +144,15 @@ describe('update command tests', () => {
|
|
|
144
144
|
),
|
|
145
145
|
);
|
|
146
146
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
[
|
|
148
|
+
[
|
|
149
149
|
"File not found",
|
|
150
150
|
],
|
|
151
151
|
]
|
|
152
152
|
`);
|
|
153
153
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
[
|
|
155
|
+
[
|
|
156
156
|
"Unable to read the mesh configuration file provided. Please check the file and try again.",
|
|
157
157
|
],
|
|
158
158
|
]
|
|
@@ -166,13 +166,13 @@ describe('update command tests', () => {
|
|
|
166
166
|
|
|
167
167
|
expect(runResult).toMatchInlineSnapshot(`"Update cancelled"`);
|
|
168
168
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
[
|
|
170
|
+
[
|
|
171
171
|
"Update cancelled",
|
|
172
172
|
],
|
|
173
173
|
]
|
|
174
174
|
`);
|
|
175
|
-
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
175
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
176
176
|
});
|
|
177
177
|
|
|
178
178
|
test('should fail if updateMesh method failed', async () => {
|
|
@@ -186,15 +186,15 @@ describe('update command tests', () => {
|
|
|
186
186
|
),
|
|
187
187
|
);
|
|
188
188
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
[
|
|
190
|
+
[
|
|
191
191
|
"dummy_error",
|
|
192
192
|
],
|
|
193
193
|
]
|
|
194
194
|
`);
|
|
195
195
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
[
|
|
197
|
+
[
|
|
198
198
|
"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",
|
|
199
199
|
],
|
|
200
200
|
]
|
|
@@ -205,7 +205,7 @@ describe('update command tests', () => {
|
|
|
205
205
|
const runResult = await UpdateCommand.run();
|
|
206
206
|
|
|
207
207
|
expect(runResult).toMatchInlineSnapshot(`
|
|
208
|
-
|
|
208
|
+
{
|
|
209
209
|
"status": "success",
|
|
210
210
|
}
|
|
211
211
|
`);
|
|
@@ -214,14 +214,26 @@ describe('update command tests', () => {
|
|
|
214
214
|
ignoreCache: true,
|
|
215
215
|
});
|
|
216
216
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
"
|
|
217
|
+
[
|
|
218
|
+
[
|
|
219
|
+
"******************************************************************************************************",
|
|
220
|
+
],
|
|
221
|
+
[
|
|
222
|
+
"Your mesh is being provisioned. Wait a few minutes before checking the status of your mesh %s",
|
|
220
223
|
"mesh_id",
|
|
221
224
|
],
|
|
225
|
+
[
|
|
226
|
+
"To check the status of your mesh, run:",
|
|
227
|
+
],
|
|
228
|
+
[
|
|
229
|
+
"aio api-mesh:status",
|
|
230
|
+
],
|
|
231
|
+
[
|
|
232
|
+
"******************************************************************************************************",
|
|
233
|
+
],
|
|
222
234
|
]
|
|
223
235
|
`);
|
|
224
|
-
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
236
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
225
237
|
});
|
|
226
238
|
|
|
227
239
|
test('should pass with valid args and ignoreCache flag', async () => {
|
|
@@ -236,7 +248,7 @@ describe('update command tests', () => {
|
|
|
236
248
|
const runResult = await UpdateCommand.run();
|
|
237
249
|
|
|
238
250
|
expect(runResult).toMatchInlineSnapshot(`
|
|
239
|
-
|
|
251
|
+
{
|
|
240
252
|
"status": "success",
|
|
241
253
|
}
|
|
242
254
|
`);
|
|
@@ -245,14 +257,26 @@ describe('update command tests', () => {
|
|
|
245
257
|
ignoreCache: true,
|
|
246
258
|
});
|
|
247
259
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
"
|
|
260
|
+
[
|
|
261
|
+
[
|
|
262
|
+
"******************************************************************************************************",
|
|
263
|
+
],
|
|
264
|
+
[
|
|
265
|
+
"Your mesh is being provisioned. Wait a few minutes before checking the status of your mesh %s",
|
|
251
266
|
"mesh_id",
|
|
252
267
|
],
|
|
268
|
+
[
|
|
269
|
+
"To check the status of your mesh, run:",
|
|
270
|
+
],
|
|
271
|
+
[
|
|
272
|
+
"aio api-mesh:status",
|
|
273
|
+
],
|
|
274
|
+
[
|
|
275
|
+
"******************************************************************************************************",
|
|
276
|
+
],
|
|
253
277
|
]
|
|
254
278
|
`);
|
|
255
|
-
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
279
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
256
280
|
});
|
|
257
281
|
|
|
258
282
|
test('should pass with valid args if autoConfirmAction flag is set', async () => {
|
|
@@ -267,7 +291,7 @@ describe('update command tests', () => {
|
|
|
267
291
|
const runResult = await UpdateCommand.run();
|
|
268
292
|
|
|
269
293
|
expect(runResult).toMatchInlineSnapshot(`
|
|
270
|
-
|
|
294
|
+
{
|
|
271
295
|
"status": "success",
|
|
272
296
|
}
|
|
273
297
|
`);
|
|
@@ -277,13 +301,25 @@ describe('update command tests', () => {
|
|
|
277
301
|
ignoreCache: true,
|
|
278
302
|
});
|
|
279
303
|
expect(logSpy.mock.calls).toMatchInlineSnapshot(`
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
"
|
|
304
|
+
[
|
|
305
|
+
[
|
|
306
|
+
"******************************************************************************************************",
|
|
307
|
+
],
|
|
308
|
+
[
|
|
309
|
+
"Your mesh is being provisioned. Wait a few minutes before checking the status of your mesh %s",
|
|
283
310
|
"mesh_id",
|
|
284
311
|
],
|
|
312
|
+
[
|
|
313
|
+
"To check the status of your mesh, run:",
|
|
314
|
+
],
|
|
315
|
+
[
|
|
316
|
+
"aio api-mesh:status",
|
|
317
|
+
],
|
|
318
|
+
[
|
|
319
|
+
"******************************************************************************************************",
|
|
320
|
+
],
|
|
285
321
|
]
|
|
286
322
|
`);
|
|
287
|
-
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
323
|
+
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
288
324
|
});
|
|
289
325
|
});
|
|
@@ -31,10 +31,10 @@ class CreateCommand extends Command {
|
|
|
31
31
|
static flags = {
|
|
32
32
|
ignoreCache: ignoreCacheFlag,
|
|
33
33
|
autoConfirmAction: autoConfirmActionFlag,
|
|
34
|
-
json: jsonFlag
|
|
34
|
+
json: jsonFlag,
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
static enableJsonFlag = true
|
|
37
|
+
static enableJsonFlag = true;
|
|
38
38
|
|
|
39
39
|
async run() {
|
|
40
40
|
await initRequestId();
|
|
@@ -81,8 +81,19 @@ class CreateCommand extends Command {
|
|
|
81
81
|
let sdkList = [];
|
|
82
82
|
|
|
83
83
|
if (mesh) {
|
|
84
|
-
this.log(
|
|
85
|
-
|
|
84
|
+
this.log(
|
|
85
|
+
'******************************************************************************************************',
|
|
86
|
+
);
|
|
87
|
+
this.log(
|
|
88
|
+
'Your mesh is being provisioned. Wait a few minutes before checking the status of your mesh %s',
|
|
89
|
+
mesh.meshId,
|
|
90
|
+
);
|
|
91
|
+
this.log('To check the status of your mesh, run:');
|
|
92
|
+
this.log('aio api-mesh:status');
|
|
93
|
+
this.log(
|
|
94
|
+
'******************************************************************************************************',
|
|
95
|
+
);
|
|
96
|
+
|
|
86
97
|
// create API key credential
|
|
87
98
|
const adobeIdIntegrationsForWorkspace = await createAPIMeshCredentials(
|
|
88
99
|
imsOrgId,
|
|
@@ -119,12 +130,12 @@ class CreateCommand extends Command {
|
|
|
119
130
|
} else {
|
|
120
131
|
this.log('Unable to create API Key');
|
|
121
132
|
}
|
|
122
|
-
|
|
133
|
+
// Do not remove or rename return values.
|
|
123
134
|
// Template adobe/generator-app-api-mesh relies on "mesh" & "adobeIdIntegrationsForWorkspace" obj structure
|
|
124
135
|
return {
|
|
125
136
|
adobeIdIntegrationsForWorkspace,
|
|
126
137
|
sdkList,
|
|
127
|
-
mesh
|
|
138
|
+
mesh,
|
|
128
139
|
};
|
|
129
140
|
} else {
|
|
130
141
|
this.error(`Unable to create a mesh. Please try again. RequestId: ${global.requestId}`, {
|
|
@@ -37,7 +37,7 @@ describe('source:discover command tests', () => {
|
|
|
37
37
|
expect(DiscoverCommand.description).toMatchInlineSnapshot(
|
|
38
38
|
`"Return the list of avaliable sources"`,
|
|
39
39
|
);
|
|
40
|
-
expect(DiscoverCommand.aliases).toMatchInlineSnapshot(`
|
|
40
|
+
expect(DiscoverCommand.aliases).toMatchInlineSnapshot(`[]`);
|
|
41
41
|
});
|
|
42
42
|
test('Check table render is executed', async () => {
|
|
43
43
|
await DiscoverCommand.run([]);
|
|
@@ -46,7 +46,7 @@ describe('source:discover command tests', () => {
|
|
|
46
46
|
test('Check that "source:install" command is called', async () => {
|
|
47
47
|
InstallCommand.run = jest.fn().mockImplementation(() => 'source:install');
|
|
48
48
|
promptConfirm.mockResolvedValue(true);
|
|
49
|
-
promptMultiselect.mockResolvedValue([mockMetadataFixture['test-01']])
|
|
49
|
+
promptMultiselect.mockResolvedValue([mockMetadataFixture['test-01']]);
|
|
50
50
|
await DiscoverCommand.run([]);
|
|
51
51
|
expect(InstallCommand.run).toHaveBeenCalledTimes(1);
|
|
52
52
|
});
|
|
@@ -31,8 +31,11 @@ const expectedResultForSuccessScenarios = JSON.stringify(
|
|
|
31
31
|
4,
|
|
32
32
|
);
|
|
33
33
|
const normalizeAssertString = str => {
|
|
34
|
-
return str
|
|
35
|
-
|
|
34
|
+
return str
|
|
35
|
+
.replace(/[\r\t]/gm, '')
|
|
36
|
+
.replace(/[\r\n]/gm, '')
|
|
37
|
+
.replace(/ +/g, ' ');
|
|
38
|
+
};
|
|
36
39
|
mockAdapter.mockImplementation(() => ({
|
|
37
40
|
get: jest
|
|
38
41
|
.fn()
|
|
@@ -56,8 +59,8 @@ describe('source:get command tests', () => {
|
|
|
56
59
|
`"Command returns the content of a specific source."`,
|
|
57
60
|
);
|
|
58
61
|
expect(GetCommand.flags).toMatchInlineSnapshot(`
|
|
59
|
-
|
|
60
|
-
"confirm":
|
|
62
|
+
{
|
|
63
|
+
"confirm": {
|
|
61
64
|
"allowNo": false,
|
|
62
65
|
"char": "c",
|
|
63
66
|
"default": false,
|
|
@@ -65,37 +68,39 @@ describe('source:get command tests', () => {
|
|
|
65
68
|
"parse": [Function],
|
|
66
69
|
"type": "boolean",
|
|
67
70
|
},
|
|
68
|
-
"multiple":
|
|
71
|
+
"multiple": {
|
|
69
72
|
"allowNo": false,
|
|
70
73
|
"char": "m",
|
|
71
74
|
"description": "Select multiple sources",
|
|
72
|
-
"exclusive":
|
|
75
|
+
"exclusive": [
|
|
73
76
|
"name",
|
|
74
77
|
],
|
|
75
78
|
"parse": [Function],
|
|
76
79
|
"type": "boolean",
|
|
77
80
|
},
|
|
78
|
-
"source":
|
|
81
|
+
"source": {
|
|
79
82
|
"char": "s",
|
|
80
83
|
"description": "Source name",
|
|
81
|
-
"input":
|
|
84
|
+
"input": [],
|
|
82
85
|
"multiple": true,
|
|
83
86
|
"parse": [Function],
|
|
84
87
|
"type": "option",
|
|
85
88
|
},
|
|
86
89
|
}
|
|
87
90
|
`);
|
|
88
|
-
expect(GetCommand.aliases).toMatchInlineSnapshot(`
|
|
91
|
+
expect(GetCommand.aliases).toMatchInlineSnapshot(`[]`);
|
|
89
92
|
});
|
|
90
93
|
test('Check executing without parameters', async () => {
|
|
91
94
|
await GetCommand.run([]).catch(err => {
|
|
92
95
|
expect(normalizeAssertString(err.message)).toEqual(
|
|
93
|
-
normalizeAssertString(
|
|
94
|
-
`
|
|
95
|
-
|
|
96
|
+
normalizeAssertString(
|
|
97
|
+
`Something went wrong with "get" command. Please try again later.` +
|
|
98
|
+
`Error: \nThe "aio api-mesh:source:get" command requires additional parameters` +
|
|
99
|
+
`Use "aio api-mesh:source:get --help" to see parameters information.`,
|
|
100
|
+
),
|
|
96
101
|
);
|
|
97
102
|
});
|
|
98
|
-
});
|
|
103
|
+
});
|
|
99
104
|
test('Check executing success with provided name and version, copied to clipboard and logged to console', async () => {
|
|
100
105
|
await GetCommand.run(['-s=test-01@0.0.1', '-s=test-02@0.0.1']);
|
|
101
106
|
expect(ncp.readSync()).toEqual(expectedResultForSuccessScenarios);
|
|
@@ -109,9 +114,7 @@ describe('source:get command tests', () => {
|
|
|
109
114
|
test('Check executing failed due to requested source does not exist', async () => {
|
|
110
115
|
const name = 'test-99';
|
|
111
116
|
await GetCommand.run([`-s=${name}`]).catch(err => {
|
|
112
|
-
expect(err.message).toContain(
|
|
113
|
-
chalk.red(`The source with the name "test-99" doesn't exist.`),
|
|
114
|
-
);
|
|
117
|
+
expect(err.message).toContain(chalk.red(`The source with the name "test-99" doesn't exist.`));
|
|
115
118
|
});
|
|
116
119
|
});
|
|
117
120
|
test('Check executing failed due to requested version does not exist', async () => {
|
|
@@ -11,11 +11,10 @@ governing permissions and limitations under the License.
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
const mockMetadataFixture = require('../__fixtures__/connectors-metadata.json');
|
|
14
|
-
const mockSourceTest01v1Fixture = require('../__fixtures__/0.0.1-test-01.json');
|
|
15
|
-
const mockSourceTest02v1Fixture = require('../__fixtures__/0.0.1-test-02.json');
|
|
16
14
|
const mockSourceTest03v1Fixture = require('../__fixtures__/0.0.1-test-03.json');
|
|
17
15
|
const mockAdapter = require('source-registry-storage-adapter');
|
|
18
16
|
const chalk = require('chalk');
|
|
17
|
+
const path = require('path');
|
|
19
18
|
const { initSdk, initRequestId, promptInput } = require('../../../../helpers');
|
|
20
19
|
const mockSources = { '0.0.1-test-03': mockSourceTest03v1Fixture };
|
|
21
20
|
jest.mock('source-registry-storage-adapter');
|
|
@@ -50,8 +49,8 @@ describe('source:install command tests', () => {
|
|
|
50
49
|
`"Command to install the source to your API mesh."`,
|
|
51
50
|
);
|
|
52
51
|
expect(InstallCommand.flags).toMatchInlineSnapshot(`
|
|
53
|
-
|
|
54
|
-
"confirm":
|
|
52
|
+
{
|
|
53
|
+
"confirm": {
|
|
55
54
|
"allowNo": false,
|
|
56
55
|
"char": "c",
|
|
57
56
|
"default": false,
|
|
@@ -59,7 +58,7 @@ describe('source:install command tests', () => {
|
|
|
59
58
|
"parse": [Function],
|
|
60
59
|
"type": "boolean",
|
|
61
60
|
},
|
|
62
|
-
"ignoreCache":
|
|
61
|
+
"ignoreCache": {
|
|
63
62
|
"allowNo": false,
|
|
64
63
|
"char": "i",
|
|
65
64
|
"default": false,
|
|
@@ -67,33 +66,33 @@ describe('source:install command tests', () => {
|
|
|
67
66
|
"parse": [Function],
|
|
68
67
|
"type": "boolean",
|
|
69
68
|
},
|
|
70
|
-
"source":
|
|
69
|
+
"source": {
|
|
71
70
|
"char": "s",
|
|
72
71
|
"description": "Source name",
|
|
73
|
-
"input":
|
|
72
|
+
"input": [],
|
|
74
73
|
"multiple": true,
|
|
75
74
|
"parse": [Function],
|
|
76
75
|
"type": "option",
|
|
77
76
|
},
|
|
78
|
-
"variable":
|
|
77
|
+
"variable": {
|
|
79
78
|
"char": "v",
|
|
80
79
|
"description": "Variables required for the source",
|
|
81
|
-
"input":
|
|
80
|
+
"input": [],
|
|
82
81
|
"multiple": true,
|
|
83
82
|
"parse": [Function],
|
|
84
83
|
"type": "option",
|
|
85
84
|
},
|
|
86
|
-
"variable-file":
|
|
85
|
+
"variable-file": {
|
|
87
86
|
"char": "f",
|
|
88
87
|
"description": "Variables file path",
|
|
89
|
-
"input":
|
|
88
|
+
"input": [],
|
|
90
89
|
"multiple": false,
|
|
91
90
|
"parse": [Function],
|
|
92
91
|
"type": "option",
|
|
93
92
|
},
|
|
94
93
|
}
|
|
95
94
|
`);
|
|
96
|
-
expect(InstallCommand.aliases).toMatchInlineSnapshot(`
|
|
95
|
+
expect(InstallCommand.aliases).toMatchInlineSnapshot(`[]`);
|
|
97
96
|
});
|
|
98
97
|
test('Check executing without parameters', async () => {
|
|
99
98
|
await InstallCommand.run([]).catch(err => {
|
|
@@ -112,8 +111,9 @@ describe('source:install command tests', () => {
|
|
|
112
111
|
});
|
|
113
112
|
});
|
|
114
113
|
test('Check executing with invalid variable type', async () => {
|
|
115
|
-
const
|
|
116
|
-
|
|
114
|
+
const newPath = path.join(__dirname, '/../__fixtures__/variables-file-invalid.json');
|
|
115
|
+
const runPath = `-f=${newPath}`;
|
|
116
|
+
await InstallCommand.run(['test-03', runPath]).catch(err => {
|
|
117
117
|
expect(err.message).toEqual(
|
|
118
118
|
chalk.red(
|
|
119
119
|
`The next variables has invalid type.\nVariable: ENDPOINT_URL\nRequested type: string`,
|
|
@@ -10,13 +10,17 @@ governing permissions and limitations under the License.
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
const { Command, CliUx, Flags } = require('@oclif/core');
|
|
13
|
-
const {
|
|
13
|
+
const {
|
|
14
|
+
promptConfirm,
|
|
15
|
+
initRequestId,
|
|
16
|
+
promptMultiselect,
|
|
17
|
+
promptSelect,
|
|
18
|
+
} = require('../../../helpers');
|
|
14
19
|
const SourceRegistryStorage = require('source-registry-storage-adapter');
|
|
15
20
|
const config = require('@adobe/aio-lib-core-config');
|
|
16
21
|
const logger = require('../../../classes/logger');
|
|
17
22
|
const InstallCommand = require('./install');
|
|
18
23
|
|
|
19
|
-
|
|
20
24
|
class DiscoverCommand extends Command {
|
|
21
25
|
async run() {
|
|
22
26
|
try {
|
|
@@ -39,19 +43,18 @@ class DiscoverCommand extends Command {
|
|
|
39
43
|
if (flags.confirm) {
|
|
40
44
|
needInstall = true;
|
|
41
45
|
} else {
|
|
42
|
-
|
|
46
|
+
needInstall = await promptConfirm(`Do you want to install sources?`);
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
if (needInstall) {
|
|
46
|
-
const toInstall = await this.handleMultiple(list)
|
|
50
|
+
const toInstall = await this.handleMultiple(list);
|
|
47
51
|
const params = [];
|
|
48
52
|
toInstall.forEach(source => {
|
|
49
53
|
params.push('-s');
|
|
50
|
-
params.push(source)
|
|
51
|
-
})
|
|
54
|
+
params.push(source);
|
|
55
|
+
});
|
|
52
56
|
InstallCommand.run(params);
|
|
53
57
|
}
|
|
54
|
-
|
|
55
58
|
} catch (error) {
|
|
56
59
|
logger.error(error);
|
|
57
60
|
this.error(`
|
|
@@ -63,17 +66,19 @@ class DiscoverCommand extends Command {
|
|
|
63
66
|
|
|
64
67
|
async handleMultiple(data) {
|
|
65
68
|
const result = [];
|
|
66
|
-
let selectedList =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
let selectedList =
|
|
70
|
+
(await promptMultiselect(
|
|
71
|
+
'Select sources to install',
|
|
72
|
+
Object.values(data).map(elem => ({ name: elem.name, value: elem })),
|
|
73
|
+
)) || [];
|
|
74
|
+
|
|
75
|
+
if (!selectedList.length) {
|
|
72
76
|
while (!selectedList.length) {
|
|
73
|
-
selectedList =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
selectedList =
|
|
78
|
+
(await promptMultiselect(
|
|
79
|
+
'Please choose at least one source',
|
|
80
|
+
Object.values(data).map(elem => ({ name: elem.name, value: elem })),
|
|
81
|
+
)) || [];
|
|
77
82
|
}
|
|
78
83
|
}
|
|
79
84
|
|
|
@@ -113,7 +118,8 @@ class DiscoverCommand extends Command {
|
|
|
113
118
|
DiscoverCommand.flags = {
|
|
114
119
|
confirm: Flags.boolean({
|
|
115
120
|
char: 'c',
|
|
116
|
-
description:
|
|
121
|
+
description:
|
|
122
|
+
'Auto confirm install action prompt. CLI will not check ask user to install source.',
|
|
117
123
|
default: false,
|
|
118
124
|
}),
|
|
119
125
|
};
|
|
@@ -12,7 +12,12 @@ governing permissions and limitations under the License.
|
|
|
12
12
|
|
|
13
13
|
const { Command, Flags } = require('@oclif/core');
|
|
14
14
|
const SourceRegistryStorage = require('source-registry-storage-adapter');
|
|
15
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
promptMultiselect,
|
|
17
|
+
promptSelect,
|
|
18
|
+
promptConfirm,
|
|
19
|
+
initRequestId,
|
|
20
|
+
} = require('../../../helpers');
|
|
16
21
|
const ncp = require('node-clipboardy');
|
|
17
22
|
const chalk = require('chalk');
|
|
18
23
|
const config = require('@adobe/aio-lib-core-config');
|
|
@@ -31,18 +36,18 @@ class GetCommand extends Command {
|
|
|
31
36
|
await initRequestId();
|
|
32
37
|
|
|
33
38
|
logger.info(`RequestId: ${global.requestId}`);
|
|
34
|
-
let list
|
|
39
|
+
let list;
|
|
35
40
|
try {
|
|
36
41
|
list = await this.sourceRegistryStorage.getList();
|
|
37
42
|
} catch (err) {
|
|
38
|
-
this.log(err)
|
|
39
|
-
this.error(`Cannot get the list of sources: ${err}`)
|
|
43
|
+
this.log(err);
|
|
44
|
+
this.error(`Cannot get the list of sources: ${err}`);
|
|
40
45
|
}
|
|
41
46
|
const { flags } = await this.parse(GetCommand);
|
|
42
47
|
if (!flags.source && !flags.multiple) {
|
|
43
48
|
this.error(
|
|
44
49
|
`\nThe "aio api-mesh:source:get" command requires additional parameters` +
|
|
45
|
-
|
|
50
|
+
`\nUse "aio api-mesh:source:get --help" to see parameters information.`,
|
|
46
51
|
);
|
|
47
52
|
}
|
|
48
53
|
const sources = flags.multiple ? await this.handleMultiple(list) : flags.source;
|
|
@@ -54,7 +59,7 @@ class GetCommand extends Command {
|
|
|
54
59
|
this.error(
|
|
55
60
|
chalk.red(
|
|
56
61
|
`The source with the name "${name}" doesn't exist.` +
|
|
57
|
-
|
|
62
|
+
`\nUse "aio api-mesh:source:discover" command to see avaliable sources.`,
|
|
58
63
|
),
|
|
59
64
|
);
|
|
60
65
|
}
|
|
@@ -63,7 +68,7 @@ class GetCommand extends Command {
|
|
|
63
68
|
this.error(
|
|
64
69
|
chalk.red(
|
|
65
70
|
`The version "${version}" for source name "${name}" doesn't exist.` +
|
|
66
|
-
|
|
71
|
+
`\nUse "aio api-mesh:source:discover" command to see avaliable source versions.`,
|
|
67
72
|
),
|
|
68
73
|
);
|
|
69
74
|
}
|
|
@@ -84,13 +89,12 @@ class GetCommand extends Command {
|
|
|
84
89
|
}
|
|
85
90
|
} else {
|
|
86
91
|
this.log(sourceConfigsString);
|
|
87
|
-
}
|
|
92
|
+
}
|
|
88
93
|
} catch (error) {
|
|
89
94
|
logger.error(error);
|
|
90
95
|
this.error(`
|
|
91
96
|
\nSomething went wrong with "get" command. Please try again later.
|
|
92
|
-
\n${error}`
|
|
93
|
-
);
|
|
97
|
+
\n${error}`);
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
100
|
|
|
@@ -122,7 +126,7 @@ class GetCommand extends Command {
|
|
|
122
126
|
GetCommand.flags = {
|
|
123
127
|
confirm: Flags.boolean({
|
|
124
128
|
char: 'c',
|
|
125
|
-
description:'Auto confirm print action prompt. CLI will not check ask user to print source.',
|
|
129
|
+
description: 'Auto confirm print action prompt. CLI will not check ask user to print source.',
|
|
126
130
|
default: false,
|
|
127
131
|
}),
|
|
128
132
|
source: Flags.string({
|