@adobe/aio-cli-plugin-api-mesh 1.5.0 → 2.1.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 +213 -238
- package/src/commands/api-mesh/__tests__/delete.test.js +43 -43
- 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 +166 -130
- 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
|
@@ -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({
|
|
@@ -45,7 +45,7 @@ class InstallCommand extends Command {
|
|
|
45
45
|
return obj;
|
|
46
46
|
}, {})
|
|
47
47
|
: {};
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
if (filepath) {
|
|
50
50
|
try {
|
|
51
51
|
variables = { ...variables, ...JSON.parse(await readFile(filepath, 'utf8')) };
|
|
@@ -68,7 +68,7 @@ class InstallCommand extends Command {
|
|
|
68
68
|
this.error(`Cannot get the list of sources: ${err}. RequestId: ${global.requestId}`);
|
|
69
69
|
}
|
|
70
70
|
const sources = flags.source ? flags.source : [args.source];
|
|
71
|
-
const sourceConfigs = {sources: [], files: {}};
|
|
71
|
+
const sourceConfigs = { sources: [], files: {} };
|
|
72
72
|
for (const source of sources) {
|
|
73
73
|
let [name, version] = source.split('@');
|
|
74
74
|
const normalizedName = this.normalizeName(name);
|
|
@@ -94,8 +94,13 @@ class InstallCommand extends Command {
|
|
|
94
94
|
const sourceProviderString = JSON.stringify(sourceConfig.provider);
|
|
95
95
|
const sourceVariables = jsonInterpolate.getJsonVariables(sourceProviderString);
|
|
96
96
|
const passedSourceVariables = this.getPassedSourceVariables(sourceVariables || [], variables);
|
|
97
|
-
const missedVariables = jsonInterpolate.getMissedVariables(
|
|
98
|
-
|
|
97
|
+
const missedVariables = jsonInterpolate.getMissedVariables(
|
|
98
|
+
passedSourceVariables,
|
|
99
|
+
sourceVariables,
|
|
100
|
+
);
|
|
101
|
+
for (const missedVariable of missedVariables
|
|
102
|
+
.map(item => item.name)
|
|
103
|
+
.filter((value, index, self) => self.indexOf(value) === index)) {
|
|
99
104
|
passedSourceVariables[missedVariable] = await promptInput(
|
|
100
105
|
`Enter the value for variable ${missedVariable}:`,
|
|
101
106
|
);
|
|
@@ -103,12 +108,12 @@ class InstallCommand extends Command {
|
|
|
103
108
|
|
|
104
109
|
const { error, data } = jsonInterpolate.interpolate(
|
|
105
110
|
JSON.stringify(sourceConfig.provider),
|
|
106
|
-
passedSourceVariables,
|
|
111
|
+
passedSourceVariables,
|
|
107
112
|
);
|
|
108
113
|
if (error) {
|
|
109
114
|
this.error(chalk.red(`${error.message}\n${error.list.map(err => err.message).join('\n')}`));
|
|
110
115
|
}
|
|
111
|
-
|
|
116
|
+
|
|
112
117
|
sourceConfigs.sources.push(JSON.parse(data));
|
|
113
118
|
sourceConfigs.files[sourceConfig.provider.name] = sourceConfig.files;
|
|
114
119
|
}
|
|
@@ -139,56 +144,58 @@ class InstallCommand extends Command {
|
|
|
139
144
|
const verifiedSources = this.verifySourceAlreadyExists(
|
|
140
145
|
mesh.meshConfig.sources,
|
|
141
146
|
sourceConfigs.sources,
|
|
142
|
-
);
|
|
147
|
+
);
|
|
143
148
|
|
|
144
149
|
let override = false;
|
|
145
150
|
if (verifiedSources.installed.length) {
|
|
146
|
-
override = flags.confirm
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
151
|
+
override = flags.confirm
|
|
152
|
+
? true
|
|
153
|
+
: await promptConfirm(
|
|
154
|
+
`The following sources are already installed: ${verifiedSources.installed
|
|
155
|
+
.map(source => source.name)
|
|
156
|
+
.join(', ')}.
|
|
150
157
|
Do you want to override?`,
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const uniqueFiles = this.getSourceFiles(
|
|
155
|
-
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const uniqueFiles = this.getSourceFiles(
|
|
162
|
+
verifiedSources.unique.map(source => source.name),
|
|
163
|
+
sourceConfigs.files,
|
|
164
|
+
);
|
|
165
|
+
const installedFiles = this.getSourceFiles(
|
|
166
|
+
verifiedSources.installed.map(source => source.name),
|
|
167
|
+
sourceConfigs.files,
|
|
168
|
+
);
|
|
156
169
|
let meshConfigFiles = mesh.meshConfig.files || [];
|
|
157
170
|
|
|
158
171
|
if (override) {
|
|
159
172
|
const installedMap = verifiedSources.installed.reduce((obj, source) => {
|
|
160
173
|
obj[source.name] = true;
|
|
161
|
-
return obj
|
|
174
|
+
return obj;
|
|
162
175
|
}, {});
|
|
163
|
-
|
|
176
|
+
|
|
164
177
|
mesh.meshConfig.sources = [
|
|
165
178
|
...mesh.meshConfig.sources.filter(source => !installedMap[source.name]),
|
|
166
|
-
...verifiedSources.installed
|
|
179
|
+
...verifiedSources.installed,
|
|
167
180
|
];
|
|
168
181
|
|
|
169
182
|
const installedFilesMap = installedFiles.reduce((obj, file) => {
|
|
170
183
|
obj[file.path] = true;
|
|
171
|
-
return obj
|
|
184
|
+
return obj;
|
|
172
185
|
}, {});
|
|
173
186
|
|
|
174
187
|
meshConfigFiles = [
|
|
175
188
|
...meshConfigFiles.filter(file => !installedFilesMap[file.path]),
|
|
176
|
-
...installedFiles
|
|
189
|
+
...installedFiles,
|
|
177
190
|
];
|
|
178
191
|
}
|
|
179
192
|
|
|
180
|
-
mesh.meshConfig.sources = [
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
meshConfigFiles = [
|
|
186
|
-
...meshConfigFiles,
|
|
187
|
-
...uniqueFiles
|
|
188
|
-
]
|
|
189
|
-
|
|
193
|
+
mesh.meshConfig.sources = [...mesh.meshConfig.sources, ...verifiedSources.unique];
|
|
194
|
+
|
|
195
|
+
meshConfigFiles = [...meshConfigFiles, ...uniqueFiles];
|
|
196
|
+
|
|
190
197
|
if (meshConfigFiles.length) {
|
|
191
|
-
mesh.meshConfig.files = meshConfigFiles
|
|
198
|
+
mesh.meshConfig.files = meshConfigFiles;
|
|
192
199
|
}
|
|
193
200
|
|
|
194
201
|
try {
|
|
@@ -224,17 +231,17 @@ class InstallCommand extends Command {
|
|
|
224
231
|
let result = [];
|
|
225
232
|
for (const source of sourcesList) {
|
|
226
233
|
if (Array.isArray(filesList[source])) {
|
|
227
|
-
result = [...result, ...filesList[source]]
|
|
234
|
+
result = [...result, ...filesList[source]];
|
|
228
235
|
}
|
|
229
236
|
}
|
|
230
237
|
return result;
|
|
231
238
|
}
|
|
232
239
|
|
|
233
240
|
getPassedSourceVariables(variablesInSource, passedVariables) {
|
|
234
|
-
const res = {}
|
|
241
|
+
const res = {};
|
|
235
242
|
variablesInSource.forEach(variable => {
|
|
236
243
|
if (passedVariables[variable.name]) {
|
|
237
|
-
res[variable.name] = passedVariables[variable.name]
|
|
244
|
+
res[variable.name] = passedVariables[variable.name];
|
|
238
245
|
}
|
|
239
246
|
});
|
|
240
247
|
return res;
|
|
@@ -259,17 +266,18 @@ class InstallCommand extends Command {
|
|
|
259
266
|
}
|
|
260
267
|
|
|
261
268
|
InstallCommand.flags = {
|
|
262
|
-
source: Flags.string({
|
|
269
|
+
'source': Flags.string({
|
|
263
270
|
char: 's',
|
|
264
271
|
description: 'Source name',
|
|
265
|
-
multiple: true,
|
|
272
|
+
multiple: true,
|
|
266
273
|
}),
|
|
267
|
-
confirm: Flags.boolean({
|
|
274
|
+
'confirm': Flags.boolean({
|
|
268
275
|
char: 'c',
|
|
269
|
-
description:
|
|
276
|
+
description:
|
|
277
|
+
'Auto confirm override action prompt. CLI will not check ask user to override source.',
|
|
270
278
|
default: false,
|
|
271
279
|
}),
|
|
272
|
-
variable: Flags.string({
|
|
280
|
+
'variable': Flags.string({
|
|
273
281
|
char: 'v',
|
|
274
282
|
description: 'Variables required for the source',
|
|
275
283
|
multiple: true,
|
|
@@ -278,7 +286,7 @@ InstallCommand.flags = {
|
|
|
278
286
|
char: 'f',
|
|
279
287
|
description: 'Variables file path',
|
|
280
288
|
}),
|
|
281
|
-
ignoreCache: ignoreCacheFlag,
|
|
289
|
+
'ignoreCache': ignoreCacheFlag,
|
|
282
290
|
};
|
|
283
291
|
|
|
284
292
|
InstallCommand.description = 'Command to install the source to your API mesh.';
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
const { Command } = require('@oclif/core');
|
|
2
|
+
const logger = require('../../classes/logger');
|
|
3
|
+
const { initRequestId, initSdk } = require('../../helpers');
|
|
4
|
+
const { getMeshId, getMesh } = require('../../lib/devConsole');
|
|
5
|
+
const { ignoreCacheFlag } = require('../../utils');
|
|
6
|
+
|
|
7
|
+
require('dotenv').config();
|
|
8
|
+
|
|
9
|
+
class StatusCommand extends Command {
|
|
10
|
+
static flags = {
|
|
11
|
+
ignoreCache: ignoreCacheFlag,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
async run() {
|
|
15
|
+
await initRequestId();
|
|
16
|
+
logger.info(`RequestId: ${global.requestId}`);
|
|
17
|
+
|
|
18
|
+
const { flags } = await this.parse(StatusCommand);
|
|
19
|
+
const ignoreCache = await flags.ignoreCache;
|
|
20
|
+
|
|
21
|
+
const { imsOrgId, projectId, workspaceId } = await initSdk({
|
|
22
|
+
ignoreCache,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
let meshId = null;
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
meshId = await getMeshId(imsOrgId, projectId, workspaceId);
|
|
29
|
+
} catch (err) {
|
|
30
|
+
this.log(err.message);
|
|
31
|
+
this.error(
|
|
32
|
+
`Unable to get mesh ID. Please check the details and try again. RequestId: ${global.requestId}`,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (meshId) {
|
|
37
|
+
try {
|
|
38
|
+
const mesh = await getMesh(imsOrgId, projectId, workspaceId, meshId);
|
|
39
|
+
switch (mesh.meshStatus) {
|
|
40
|
+
case 'success':
|
|
41
|
+
this.log(
|
|
42
|
+
'******************************************************************************************************',
|
|
43
|
+
);
|
|
44
|
+
this.log('Your mesh has been successfully built.');
|
|
45
|
+
this.log(
|
|
46
|
+
'******************************************************************************************************',
|
|
47
|
+
);
|
|
48
|
+
break;
|
|
49
|
+
case 'pending':
|
|
50
|
+
this.log(
|
|
51
|
+
'******************************************************************************************************',
|
|
52
|
+
);
|
|
53
|
+
this.log('Your mesh is awaiting processing.');
|
|
54
|
+
this.log(
|
|
55
|
+
'******************************************************************************************************',
|
|
56
|
+
);
|
|
57
|
+
break;
|
|
58
|
+
case 'building':
|
|
59
|
+
this.log(
|
|
60
|
+
'******************************************************************************************************',
|
|
61
|
+
);
|
|
62
|
+
this.log(
|
|
63
|
+
'Your mesh is currently being provisioned. Please wait a few minutes before checking again.',
|
|
64
|
+
);
|
|
65
|
+
this.log(
|
|
66
|
+
'******************************************************************************************************',
|
|
67
|
+
);
|
|
68
|
+
break;
|
|
69
|
+
case 'error':
|
|
70
|
+
this.log(
|
|
71
|
+
'******************************************************************************************************',
|
|
72
|
+
);
|
|
73
|
+
this.log('Your mesh errored out with the following error. ', mesh.error);
|
|
74
|
+
this.log(
|
|
75
|
+
'******************************************************************************************************',
|
|
76
|
+
);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
} catch (err) {
|
|
80
|
+
this.log(err.message);
|
|
81
|
+
|
|
82
|
+
this.error(
|
|
83
|
+
`Unable to get the mesh status. If the error persists please contact support. RequestId: ${global.requestId}`,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
this.error(
|
|
88
|
+
`Unable to get mesh status. No mesh found for Org(${imsOrgId}) -> Project(${projectId}) -> Workspace(${workspaceId}). Please check the details and try again.`,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
StatusCommand.description = 'Get a mesh status with a given meshid.';
|
|
95
|
+
|
|
96
|
+
module.exports = StatusCommand;
|
|
@@ -82,7 +82,18 @@ class UpdateCommand extends Command {
|
|
|
82
82
|
try {
|
|
83
83
|
const response = await updateMesh(imsOrgId, projectId, workspaceId, meshId, data);
|
|
84
84
|
|
|
85
|
-
this.log(
|
|
85
|
+
this.log(
|
|
86
|
+
'******************************************************************************************************',
|
|
87
|
+
);
|
|
88
|
+
this.log(
|
|
89
|
+
'Your mesh is being provisioned. Wait a few minutes before checking the status of your mesh %s',
|
|
90
|
+
meshId,
|
|
91
|
+
);
|
|
92
|
+
this.log('To check the status of your mesh, run:');
|
|
93
|
+
this.log('aio api-mesh:status');
|
|
94
|
+
this.log(
|
|
95
|
+
'******************************************************************************************************',
|
|
96
|
+
);
|
|
86
97
|
|
|
87
98
|
return response;
|
|
88
99
|
} catch (error) {
|
package/src/constants.js
CHANGED
|
@@ -8,6 +8,7 @@ const StageConstants = {
|
|
|
8
8
|
DEV_CONSOLE_API_KEY: 'adobe-api-manager-sms-stage',
|
|
9
9
|
DEV_CONSOLE_TRANSPORTER_API_KEY: 'UDPWeb1',
|
|
10
10
|
AIO_CLI_API_KEY: 'aio-cli-console-auth-stage',
|
|
11
|
+
SMS_BASE_URL: 'https://graph-stage.adobe.io/api-admin',
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
const ProdConstants = {
|
|
@@ -16,6 +17,7 @@ const ProdConstants = {
|
|
|
16
17
|
DEV_CONSOLE_API_KEY: 'adobe-graph-prod',
|
|
17
18
|
DEV_CONSOLE_TRANSPORTER_API_KEY: 'UDPWeb1',
|
|
18
19
|
AIO_CLI_API_KEY: 'aio-cli-console-auth',
|
|
20
|
+
SMS_BASE_URL: 'https://graph.adobe.io/api-admin',
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
module.exports = clientEnv === 'stage' ? StageConstants : ProdConstants;
|
package/src/helpers.js
CHANGED
|
@@ -26,6 +26,9 @@ const { objToString } = require('./utils');
|
|
|
26
26
|
|
|
27
27
|
const { DEV_CONSOLE_BASE_URL, DEV_CONSOLE_API_KEY, AIO_CLI_API_KEY } = CONSTANTS;
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* @param configFilePath
|
|
31
|
+
*/
|
|
29
32
|
async function getDevConsoleConfigFromFile(configFilePath) {
|
|
30
33
|
try {
|
|
31
34
|
if (!fs.existsSync(configFilePath)) {
|
|
@@ -47,7 +50,7 @@ async function getDevConsoleConfigFromFile(configFilePath) {
|
|
|
47
50
|
: data.baseUrl;
|
|
48
51
|
|
|
49
52
|
const config = {
|
|
50
|
-
baseUrl
|
|
53
|
+
baseUrl,
|
|
51
54
|
accessToken: (await getLibConsoleCLI()).accessToken,
|
|
52
55
|
apiKey: data.apiKey,
|
|
53
56
|
};
|
|
@@ -64,6 +67,9 @@ async function getDevConsoleConfigFromFile(configFilePath) {
|
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
69
|
|
|
70
|
+
/**
|
|
71
|
+
* @param configObject
|
|
72
|
+
*/
|
|
67
73
|
async function getDevConsoleConfigFromObject(configObject) {
|
|
68
74
|
const { baseUrl, apiKey } = configObject;
|
|
69
75
|
const config = {
|
|
@@ -325,15 +331,16 @@ async function getLibConsoleCLI() {
|
|
|
325
331
|
const accessToken = await getToken(CLI);
|
|
326
332
|
|
|
327
333
|
const consoleCLI = await libConsoleCLI.init({
|
|
328
|
-
accessToken
|
|
334
|
+
accessToken,
|
|
329
335
|
apiKey: AIO_CLI_API_KEY,
|
|
330
336
|
env: clientEnv,
|
|
331
337
|
});
|
|
332
338
|
|
|
333
|
-
return { consoleCLI
|
|
339
|
+
return { consoleCLI, accessToken };
|
|
334
340
|
}
|
|
335
341
|
|
|
336
342
|
/**
|
|
343
|
+
* @param options
|
|
337
344
|
* @returns {any} Returns an object with properties ready for consumption
|
|
338
345
|
*/
|
|
339
346
|
async function initSdk(options) {
|
|
@@ -377,7 +384,6 @@ async function initRequestId() {
|
|
|
377
384
|
* Function to run the CLI Y/N prompt to confirm the user's action
|
|
378
385
|
*
|
|
379
386
|
* @param {string} message
|
|
380
|
-
*
|
|
381
387
|
* @returns boolean
|
|
382
388
|
*/
|
|
383
389
|
async function promptConfirm(message) {
|
|
@@ -405,9 +411,9 @@ async function promptMultiselect(message, choices) {
|
|
|
405
411
|
const selected = await inquirer.prompt([
|
|
406
412
|
{
|
|
407
413
|
name: 'items',
|
|
408
|
-
message
|
|
414
|
+
message,
|
|
409
415
|
type: 'checkbox',
|
|
410
|
-
choices
|
|
416
|
+
choices,
|
|
411
417
|
},
|
|
412
418
|
]);
|
|
413
419
|
|
|
@@ -425,9 +431,9 @@ async function promptSelect(message, choices) {
|
|
|
425
431
|
const selected = await inquirer.prompt([
|
|
426
432
|
{
|
|
427
433
|
name: 'item',
|
|
428
|
-
message
|
|
434
|
+
message,
|
|
429
435
|
type: 'list',
|
|
430
|
-
choices
|
|
436
|
+
choices,
|
|
431
437
|
},
|
|
432
438
|
]);
|
|
433
439
|
|
|
@@ -441,11 +447,11 @@ async function promptSelect(message, choices) {
|
|
|
441
447
|
* @param {object[]} choices - list of options
|
|
442
448
|
* @returns {object[]} - selected options
|
|
443
449
|
*/
|
|
444
|
-
|
|
450
|
+
async function promptInput(message) {
|
|
445
451
|
const selected = await inquirer.prompt([
|
|
446
452
|
{
|
|
447
453
|
name: 'item',
|
|
448
|
-
message
|
|
454
|
+
message,
|
|
449
455
|
type: 'input',
|
|
450
456
|
},
|
|
451
457
|
]);
|
package/src/utils.js
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
* If the path evaluates to false, the default string is returned.
|
|
4
4
|
*
|
|
5
5
|
* @param {object} obj
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {Array<string>} path
|
|
7
7
|
* @param {string} defaultString
|
|
8
|
-
*
|
|
9
8
|
* @returns {string}
|
|
10
9
|
*/
|
|
11
10
|
function objToString(obj, path = [], defaultString = '') {
|
|
@@ -50,8 +49,7 @@ const autoConfirmActionFlag = Flags.boolean({
|
|
|
50
49
|
});
|
|
51
50
|
|
|
52
51
|
const jsonFlag = Flags.boolean({
|
|
53
|
-
description:
|
|
54
|
-
'Output JSON',
|
|
52
|
+
description: 'Output JSON',
|
|
55
53
|
default: false,
|
|
56
54
|
});
|
|
57
55
|
|