@adobe/aio-cli-plugin-api-mesh 3.3.0-alpha.1 → 3.3.0-beta
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 +1 -1
- package/src/commands/api-mesh/__tests__/update.test.js +6 -0
- package/src/commands/api-mesh/source/__tests__/install.test.js +4 -0
- package/src/commands/api-mesh/source/install.js +20 -4
- package/src/commands/api-mesh/status.js +59 -76
- package/src/commands/api-mesh/update.js +15 -4
- package/src/lib/devConsole.js +26 -2
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"3.3.0-
|
|
1
|
+
{"version":"3.3.0-beta","commands":{"PLUGINNAME":{"id":"PLUGINNAME","description":"Your description here","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":["$ aio PLUGINNAME:some_command"],"flags":{"someflag":{"name":"someflag","type":"option","char":"f","description":"this is some flag"}},"args":[]},"api-mesh:create":{"id":"api-mesh:create","description":"Create a mesh with the given config.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"json":{"name":"json","type":"boolean","description":"Output JSON","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"}},"args":[{"name":"file"}]},"api-mesh:delete":{"id":"api-mesh:delete","description":"Delete the config of a given mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false}},"args":[]},"api-mesh:describe":{"id":"api-mesh:describe","description":"Get details of a mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[]},"api-mesh:get":{"id":"api-mesh:get","description":"Get the config of a given mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"json":{"name":"json","type":"boolean","description":"Output JSON","allowNo":false}},"args":[{"name":"file"}]},"api-mesh:init":{"id":"api-mesh:init","description":"This command will create a workspace where you can organise your API mesh configuration and other files","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":[{"description":"API mesh workspace init","command":"aio api-mesh init commerce-mesh"},{"description":"API mesh workspace init with flags","command":"aio api-mesh init commerce-mesh --path ./mesh_projects/test_mesh --git y --packageManager yarn"}],"flags":{"path":{"name":"path","type":"option","char":"p","default":"."},"packageManager":{"name":"packageManager","type":"option","char":"m","options":["npm","yarn"]},"git":{"name":"git","type":"option","char":"g","options":["y","n"]}},"args":[{"name":"projectName","description":"Project name","required":true}]},"api-mesh:run":{"id":"api-mesh:run","description":"Run a local development server that builds and compiles a mesh locally","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":[],"flags":{"port":{"name":"port","type":"option","char":"p","description":"Port number for the local dev server"},"debug":{"name":"debug","type":"boolean","description":"Enable debugging mode","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"select":{"name":"select","type":"boolean","description":"Retrieve existing artifacts from the mesh","allowNo":false}},"args":[{"name":"file","description":"Mesh File"}]},"api-mesh:status":{"id":"api-mesh:status","description":"Get a mesh status with a given meshid.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[]},"api-mesh:update":{"id":"api-mesh:update","description":"Update a mesh with the given config.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"}},"args":[{"name":"file"}]},"api-mesh:source:discover":{"id":"api-mesh:source:discover","description":"Return the list of avaliable sources","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm install action prompt. CLI will not check ask user to install source.","allowNo":false}},"args":[]},"api-mesh:source:get":{"id":"api-mesh:source:get","description":"Command returns the content of a specific source.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":["$ aio api-mesh:source:get -s=<version>@<source_name>","$ aio api-mesh:source:get -s<source_name>","$ aio api-mesh:source:get -m"],"flags":{"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm print action prompt. CLI will not check ask user to print source.","allowNo":false},"source":{"name":"source","type":"option","char":"s","description":"Source name"},"multiple":{"name":"multiple","type":"boolean","char":"m","description":"Select multiple sources","allowNo":false}},"args":[]},"api-mesh:source:install":{"id":"api-mesh:source:install","description":"Command to install the source to your API mesh.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":["$ aio api-mesh:source:install <version>@<source_name>","$ aio api-mesh:source:install <source_name> -v <variable_name>=<variable_value>","$ aio api-mesh:source:install <source_name> -f <path_to_variables_file>"],"flags":{"source":{"name":"source","type":"option","char":"s","description":"Source name"},"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm override action prompt. CLI will not check ask user to override source.","allowNo":false},"variable":{"name":"variable","type":"option","char":"v","description":"Variables required for the source"},"variable-file":{"name":"variable-file","type":"option","char":"f","description":"Variables file path"},"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[{"name":"source"}]}}}
|
package/package.json
CHANGED
|
@@ -52,6 +52,9 @@ describe('update command tests', () => {
|
|
|
52
52
|
imsOrgId: selectedOrg.id,
|
|
53
53
|
projectId: selectedProject.id,
|
|
54
54
|
workspaceId: selectedWorkspace.id,
|
|
55
|
+
workspaceName: selectedWorkspace.title,
|
|
56
|
+
orgName: selectedOrg.name,
|
|
57
|
+
projectName: selectedProject.title,
|
|
55
58
|
});
|
|
56
59
|
|
|
57
60
|
global.requestId = 'dummy_request_id';
|
|
@@ -554,6 +557,9 @@ describe('update command tests', () => {
|
|
|
554
557
|
"1234",
|
|
555
558
|
"5678",
|
|
556
559
|
"123456789",
|
|
560
|
+
"Workspace01",
|
|
561
|
+
"ORG01",
|
|
562
|
+
"Project01",
|
|
557
563
|
"mesh_id",
|
|
558
564
|
{
|
|
559
565
|
"meshConfig": {
|
|
@@ -40,6 +40,8 @@ initSdk.mockResolvedValue({
|
|
|
40
40
|
projectId: selectedProject.id,
|
|
41
41
|
workspaceId: selectedWorkspace.id,
|
|
42
42
|
workspaceName: selectedWorkspace.title,
|
|
43
|
+
organizationName: selectedOrg.name,
|
|
44
|
+
projectName: selectedProject.title,
|
|
43
45
|
});
|
|
44
46
|
initRequestId.mockResolvedValue({});
|
|
45
47
|
promptInput.mockResolvedValueOnce('test-03');
|
|
@@ -148,6 +150,8 @@ describe('source:install command tests', () => {
|
|
|
148
150
|
selectedProject.id,
|
|
149
151
|
selectedWorkspace.id,
|
|
150
152
|
selectedWorkspace.title,
|
|
153
|
+
selectedOrg.name,
|
|
154
|
+
selectedProject.title,
|
|
151
155
|
'dummy_meshId',
|
|
152
156
|
res,
|
|
153
157
|
);
|
|
@@ -36,7 +36,14 @@ class InstallCommand extends Command {
|
|
|
36
36
|
await initRequestId();
|
|
37
37
|
logger.info(`RequestId: ${global.requestId}`);
|
|
38
38
|
const ignoreCache = await flags.ignoreCache;
|
|
39
|
-
const {
|
|
39
|
+
const {
|
|
40
|
+
imsOrgId,
|
|
41
|
+
projectId,
|
|
42
|
+
workspaceId,
|
|
43
|
+
organizationName,
|
|
44
|
+
projectName,
|
|
45
|
+
workspaceName,
|
|
46
|
+
} = await initSdk({ ignoreCache });
|
|
40
47
|
const filepath = flags['variable-file'];
|
|
41
48
|
let variables = flags.variable
|
|
42
49
|
? flags.variable.reduce((obj, val) => {
|
|
@@ -199,9 +206,18 @@ class InstallCommand extends Command {
|
|
|
199
206
|
}
|
|
200
207
|
|
|
201
208
|
try {
|
|
202
|
-
const response = await updateMesh(
|
|
203
|
-
|
|
204
|
-
|
|
209
|
+
const response = await updateMesh(
|
|
210
|
+
imsOrgId,
|
|
211
|
+
projectId,
|
|
212
|
+
workspaceId,
|
|
213
|
+
workspaceName,
|
|
214
|
+
organizationName,
|
|
215
|
+
projectName,
|
|
216
|
+
meshId,
|
|
217
|
+
{
|
|
218
|
+
meshConfig: mesh.meshConfig,
|
|
219
|
+
},
|
|
220
|
+
);
|
|
205
221
|
|
|
206
222
|
this.log('Successfully updated the mesh with the id: %s', meshId);
|
|
207
223
|
|
|
@@ -44,94 +44,77 @@ class StatusCommand extends Command {
|
|
|
44
44
|
try {
|
|
45
45
|
const { showCloudflareURL: showEdgeMeshUrl } = await getTenantFeatures(imsOrgCode);
|
|
46
46
|
const mesh = await getMesh(imsOrgId, projectId, workspaceId, workspaceName, meshId);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
projectId,
|
|
51
|
-
workspaceId,
|
|
52
|
-
meshId,
|
|
53
|
-
);
|
|
54
|
-
this.log(chalk.blackBright('Edge Mesh Status:'));
|
|
55
|
-
switch (String(meshDeployments.status).toLowerCase()) {
|
|
56
|
-
case 'success':
|
|
57
|
-
this.log(
|
|
58
|
-
'******************************************************************************************************',
|
|
59
|
-
);
|
|
60
|
-
this.log('Your mesh was successfully built.');
|
|
61
|
-
this.log(
|
|
62
|
-
'******************************************************************************************************',
|
|
63
|
-
);
|
|
64
|
-
break;
|
|
65
|
-
case 'provisioning':
|
|
66
|
-
this.log(
|
|
67
|
-
'******************************************************************************************************',
|
|
68
|
-
);
|
|
69
|
-
this.log('Your mesh is provisioning.');
|
|
70
|
-
this.log(
|
|
71
|
-
'******************************************************************************************************',
|
|
72
|
-
);
|
|
73
|
-
break;
|
|
74
|
-
case 'error':
|
|
75
|
-
this.log(
|
|
76
|
-
'******************************************************************************************************',
|
|
77
|
-
);
|
|
78
|
-
this.log('Your mesh encountered the following error: ', meshDeployments.error);
|
|
79
|
-
this.log(
|
|
80
|
-
'******************************************************************************************************',
|
|
81
|
-
);
|
|
82
|
-
break;
|
|
83
|
-
default:
|
|
84
|
-
//Case when deployments table has no status and only initial metadata
|
|
85
|
-
this.log(
|
|
86
|
-
'******************************************************************************************************',
|
|
87
|
-
);
|
|
88
|
-
this.log('Your mesh status is not available. Please wait for a while and try again.');
|
|
89
|
-
this.log(
|
|
90
|
-
'******************************************************************************************************',
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
this.log(chalk.blackBright('Legacy Mesh Status:'));
|
|
94
|
-
}
|
|
47
|
+
this.log(
|
|
48
|
+
'******************************************************************************************************',
|
|
49
|
+
);
|
|
95
50
|
switch (mesh.meshStatus) {
|
|
96
51
|
case 'success':
|
|
97
|
-
this.log(
|
|
98
|
-
'******************************************************************************************************',
|
|
99
|
-
);
|
|
100
|
-
this.log('Your mesh has been successfully built.');
|
|
101
|
-
this.log(
|
|
102
|
-
'******************************************************************************************************',
|
|
103
|
-
);
|
|
52
|
+
this.log(`${chalk.bold(`Legacy Mesh:`)} has been successfully built.`);
|
|
104
53
|
break;
|
|
105
54
|
case 'pending':
|
|
106
|
-
this.log(
|
|
107
|
-
'******************************************************************************************************',
|
|
108
|
-
);
|
|
109
|
-
this.log('Your mesh is awaiting processing.');
|
|
110
|
-
this.log(
|
|
111
|
-
'******************************************************************************************************',
|
|
112
|
-
);
|
|
55
|
+
this.log(`${chalk.bold(`Legacy Mesh:`)} is awaiting processing.`);
|
|
113
56
|
break;
|
|
114
57
|
case 'building':
|
|
115
58
|
this.log(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
'Your mesh is currently being provisioned. Please wait a few minutes before checking again.',
|
|
120
|
-
);
|
|
121
|
-
this.log(
|
|
122
|
-
'******************************************************************************************************',
|
|
59
|
+
`${chalk.bold(
|
|
60
|
+
`Legacy Mesh:`,
|
|
61
|
+
)} is currently being provisioned. Please wait a few minutes before checking again.`,
|
|
123
62
|
);
|
|
124
63
|
break;
|
|
125
64
|
case 'error':
|
|
126
|
-
this.log(
|
|
127
|
-
|
|
128
|
-
);
|
|
129
|
-
this.log('Your mesh errored out with the following error. ', mesh.error);
|
|
130
|
-
this.log(
|
|
131
|
-
'******************************************************************************************************',
|
|
132
|
-
);
|
|
65
|
+
this.log(`${chalk.bold(`Legacy Mesh:`)} build has errors.`);
|
|
66
|
+
this.log(mesh.error);
|
|
133
67
|
break;
|
|
134
68
|
}
|
|
69
|
+
if (showEdgeMeshUrl) {
|
|
70
|
+
if (mesh.meshStatus == 'error') {
|
|
71
|
+
this.log(`${chalk.bold(`Edge Mesh:`)} build has errors.`);
|
|
72
|
+
this.log(mesh.error);
|
|
73
|
+
} else {
|
|
74
|
+
const meshDeployments = await getMeshDeployments(
|
|
75
|
+
imsOrgCode,
|
|
76
|
+
projectId,
|
|
77
|
+
workspaceId,
|
|
78
|
+
meshId,
|
|
79
|
+
);
|
|
80
|
+
switch (String(meshDeployments.status).toLowerCase()) {
|
|
81
|
+
case 'success':
|
|
82
|
+
this.log(`${chalk.bold(`Edge Mesh:`)} has been successfully built.`);
|
|
83
|
+
break;
|
|
84
|
+
case 'provisioning':
|
|
85
|
+
this.log(
|
|
86
|
+
`${chalk.bold(
|
|
87
|
+
`Edge Mesh:`,
|
|
88
|
+
)} is currently being provisioned. Please wait a few minutes before checking again.`,
|
|
89
|
+
);
|
|
90
|
+
break;
|
|
91
|
+
case 'de-provisioning':
|
|
92
|
+
this.log(
|
|
93
|
+
`${chalk.bold(
|
|
94
|
+
`Edge Mesh:`,
|
|
95
|
+
)} is currently being de-provisioned. Please wait a few minutes before checking again.`,
|
|
96
|
+
);
|
|
97
|
+
break;
|
|
98
|
+
case 'error':
|
|
99
|
+
if (meshDeployments.error.includes(`Mesh status is not available`))
|
|
100
|
+
this.log(`${chalk.bold(`Edge Mesh:`)} ${meshDeployments.error}`);
|
|
101
|
+
else {
|
|
102
|
+
this.log(`${chalk.bold(`Edge Mesh:`)} build has errors.`);
|
|
103
|
+
this.log(meshDeployments.error);
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
this.log(
|
|
108
|
+
`${chalk.bold(
|
|
109
|
+
`Edge Mesh:`,
|
|
110
|
+
)} Mesh status is not available. Please wait for a while and try again.`,
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
this.log(
|
|
116
|
+
'******************************************************************************************************',
|
|
117
|
+
);
|
|
135
118
|
} catch (err) {
|
|
136
119
|
this.log(err.message);
|
|
137
120
|
|
|
@@ -49,9 +49,11 @@ class UpdateCommand extends Command {
|
|
|
49
49
|
const autoConfirmAction = await flags.autoConfirmAction;
|
|
50
50
|
const envFilePath = await flags.env;
|
|
51
51
|
|
|
52
|
-
const { imsOrgId, projectId, workspaceId } = await initSdk(
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
const { imsOrgId, projectId, workspaceId, orgName, projectName, workspaceName } = await initSdk(
|
|
53
|
+
{
|
|
54
|
+
ignoreCache,
|
|
55
|
+
},
|
|
56
|
+
);
|
|
55
57
|
|
|
56
58
|
//Input the mesh data from the input file
|
|
57
59
|
let inputMeshData = await readFileContents(args.file, this, 'mesh');
|
|
@@ -112,7 +114,16 @@ class UpdateCommand extends Command {
|
|
|
112
114
|
|
|
113
115
|
if (shouldContinue) {
|
|
114
116
|
try {
|
|
115
|
-
const response = await updateMesh(
|
|
117
|
+
const response = await updateMesh(
|
|
118
|
+
imsOrgId,
|
|
119
|
+
projectId,
|
|
120
|
+
workspaceId,
|
|
121
|
+
workspaceName,
|
|
122
|
+
orgName,
|
|
123
|
+
projectName,
|
|
124
|
+
meshId,
|
|
125
|
+
data,
|
|
126
|
+
);
|
|
116
127
|
|
|
117
128
|
this.log(
|
|
118
129
|
'******************************************************************************************************',
|
package/src/lib/devConsole.js
CHANGED
|
@@ -325,7 +325,28 @@ const createMesh = async (
|
|
|
325
325
|
}
|
|
326
326
|
};
|
|
327
327
|
|
|
328
|
-
|
|
328
|
+
/**
|
|
329
|
+
* Update an API Mesh.
|
|
330
|
+
* @param {string} organizationId Organization identifier.
|
|
331
|
+
* @param {string} projectId Project identifier.
|
|
332
|
+
* @param {string} workspaceId Workspace identifier.
|
|
333
|
+
* @param {string} workspaceName Workspace Name.
|
|
334
|
+
* @param {string} orgName Organization name.
|
|
335
|
+
* @param {string} projectName Project name.
|
|
336
|
+
* @param {string} meshId Mesh identifier.
|
|
337
|
+
* @param {unknown} data Mesh configuration data.
|
|
338
|
+
* @returns {Promise<any>}
|
|
339
|
+
*/
|
|
340
|
+
const updateMesh = async (
|
|
341
|
+
organizationId,
|
|
342
|
+
projectId,
|
|
343
|
+
workspaceId,
|
|
344
|
+
workspaceName,
|
|
345
|
+
orgName,
|
|
346
|
+
projectName,
|
|
347
|
+
meshId,
|
|
348
|
+
data,
|
|
349
|
+
) => {
|
|
329
350
|
const { baseUrl: devConsoleUrl, accessToken, apiKey } = await getDevConsoleConfig();
|
|
330
351
|
const config = {
|
|
331
352
|
method: 'put',
|
|
@@ -334,6 +355,9 @@ const updateMesh = async (organizationId, projectId, workspaceId, meshId, data)
|
|
|
334
355
|
'Authorization': `Bearer ${accessToken}`,
|
|
335
356
|
'Content-Type': 'application/json',
|
|
336
357
|
'x-request-id': global.requestId,
|
|
358
|
+
'workspaceName': workspaceName,
|
|
359
|
+
'orgName': orgName,
|
|
360
|
+
'projectName': projectName,
|
|
337
361
|
},
|
|
338
362
|
data: JSON.stringify(data),
|
|
339
363
|
};
|
|
@@ -939,7 +963,7 @@ const getMeshDeployments = async (organizationCode, projectId, workspaceId, mesh
|
|
|
939
963
|
return {
|
|
940
964
|
status: 'ERROR',
|
|
941
965
|
meshId: meshId,
|
|
942
|
-
error: '
|
|
966
|
+
error: 'Mesh status is not available.',
|
|
943
967
|
};
|
|
944
968
|
}
|
|
945
969
|
};
|