@adobe/aio-cli-plugin-api-mesh 2.2.0-beta.2 → 2.2.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.
@@ -1 +1 @@
1
- {"version":"2.2.0-beta.2","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}},"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: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"}]}}}
1
+ {"version":"2.2.1","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: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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/aio-cli-plugin-api-mesh",
3
- "version": "2.2.0-beta.2",
3
+ "version": "2.2.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -316,19 +316,14 @@ describe('create command tests', () => {
316
316
  },
317
317
  });
318
318
  const runResult = CreateCommand.run();
319
+ const expected = [expect.stringMatching(/ENOENT: no such file or directory/)];
319
320
 
320
321
  await expect(runResult).rejects.toEqual(
321
322
  new Error(
322
323
  'Unable to read the mesh configuration file provided. Please check the file and try again.',
323
324
  ),
324
325
  );
325
- expect(logSpy.mock.calls).toMatchInlineSnapshot(`
326
- [
327
- [
328
- "ENOENT: no such file or directory, open 'dummy_file_path'",
329
- ],
330
- ]
331
- `);
326
+ expect(logSpy.mock.calls[0]).toEqual(expect.arrayContaining(expected));
332
327
  expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
333
328
  [
334
329
  [
@@ -96,6 +96,13 @@ describe('get command tests', () => {
96
96
  "parse": [Function],
97
97
  "type": "boolean",
98
98
  },
99
+ "json": {
100
+ "allowNo": false,
101
+ "default": false,
102
+ "description": "Output JSON",
103
+ "parse": [Function],
104
+ "type": "boolean",
105
+ },
99
106
  }
100
107
  `);
101
108
  expect(GetCommand.aliases).toMatchInlineSnapshot(`[]`);
@@ -182,6 +189,7 @@ describe('get command tests', () => {
182
189
 
183
190
  expect(initSdk).toHaveBeenCalledWith({
184
191
  ignoreCache: true,
192
+ verbose: true,
185
193
  });
186
194
  expect(initRequestId).toHaveBeenCalled();
187
195
  expect(runResult).toEqual({ meshId: 'dummy_meshId', mesh: mockGetMeshConfig });
@@ -9,12 +9,12 @@ OF ANY KIND, either express or implied. See the License for the specific languag
9
9
  governing permissions and limitations under the License.
10
10
  */
11
11
 
12
- const { Command } = require('@oclif/command');
12
+ const { Command } = require('@oclif/core');
13
13
  const { writeFile } = require('fs/promises');
14
14
 
15
15
  const logger = require('../../classes/logger');
16
16
  const { initSdk, initRequestId } = require('../../helpers');
17
- const { ignoreCacheFlag } = require('../../utils');
17
+ const { ignoreCacheFlag, jsonFlag } = require('../../utils');
18
18
  const { getMeshId, getMesh } = require('../../lib/devConsole');
19
19
 
20
20
  require('dotenv').config();
@@ -23,8 +23,11 @@ class GetCommand extends Command {
23
23
  static args = [{ name: 'file' }];
24
24
  static flags = {
25
25
  ignoreCache: ignoreCacheFlag,
26
+ json: jsonFlag,
26
27
  };
27
28
 
29
+ static enableJsonFlag = true;
30
+
28
31
  async run() {
29
32
  await initRequestId();
30
33
 
@@ -33,9 +36,11 @@ class GetCommand extends Command {
33
36
  const { args, flags } = await this.parse(GetCommand);
34
37
 
35
38
  const ignoreCache = await flags.ignoreCache;
39
+ const json = await flags.json;
36
40
 
37
41
  const { imsOrgId, projectId, workspaceId } = await initSdk({
38
42
  ignoreCache,
43
+ verbose: !json,
39
44
  });
40
45
 
41
46
  let meshId = null;
@@ -160,7 +160,7 @@ class InitCommand extends Command {
160
160
  }
161
161
  }
162
162
 
163
- this.log('workspace setup done successfully');
163
+ this.log('Local workspace created successfully');
164
164
  }
165
165
  }
166
166
  }
@@ -122,7 +122,7 @@ describe('source:get command tests', () => {
122
122
  const version = '1.1.1';
123
123
  await GetCommand.run([`-s=${name}@${version}`]).catch(err => {
124
124
  expect(err.message).toContain(
125
- chalk.red(`The version \"1.1.1\" for source name \"test-01\" doesn't exist.`),
125
+ chalk.red(`The version "1.1.1" for source name "test-01" doesn't exist.`),
126
126
  );
127
127
  });
128
128
  });
@@ -104,9 +104,9 @@ describe('source:install command tests', () => {
104
104
  });
105
105
  test('Check executing with invalid file parameter', async () => {
106
106
  await InstallCommand.run(['test-03', '-f=notexist.json']).catch(err => {
107
- expect(err.message).toEqual(
107
+ expect(err.message).toContain(
108
108
  `Something went wrong trying to read the variables file.` +
109
- `\nENOENT: no such file or directory, open 'notexist.json'`,
109
+ `\nENOENT: no such file or directory`,
110
110
  );
111
111
  });
112
112
  });
package/src/helpers.js CHANGED
@@ -171,9 +171,10 @@ async function getDevConsoleConfig() {
171
171
  }
172
172
 
173
173
  /**
174
+ * @param options
174
175
  * @returns {string} Returns organizations the user belongs to
175
176
  */
176
- async function getAuthorizedOrganization() {
177
+ async function getAuthorizedOrganization(options = { verbose: true }) {
177
178
  logger.info(`Initializing organization selection for`);
178
179
 
179
180
  const { consoleCLI } = await getLibConsoleCLI();
@@ -203,7 +204,9 @@ async function getAuthorizedOrganization() {
203
204
  }
204
205
  } else {
205
206
  logger.debug(`Selected organization config ${objToString(consoleConfigOrg)}`);
206
- console.log(`Selected organization: ${consoleConfigOrg.name}`);
207
+ if (options.verbose) {
208
+ console.log(`Selected organization: ${consoleConfigOrg.name}`);
209
+ }
207
210
 
208
211
  return Object.assign({}, consoleConfigOrg);
209
212
  }
@@ -212,8 +215,9 @@ async function getAuthorizedOrganization() {
212
215
  /**
213
216
  * @param imsOrgId
214
217
  * @param imsOrgTitle
218
+ * @param options
215
219
  */
216
- async function getProject(imsOrgId, imsOrgTitle) {
220
+ async function getProject(imsOrgId, imsOrgTitle, options = { verbose: true }) {
217
221
  logger.info(`Initializing project selection for ${imsOrgId}`);
218
222
 
219
223
  const { consoleCLI } = await getLibConsoleCLI();
@@ -247,7 +251,9 @@ async function getProject(imsOrgId, imsOrgTitle) {
247
251
  }
248
252
  } else {
249
253
  logger.debug(`Selected project config ${objToString(consoleConfigProject)}`);
250
- console.log(`Selected project: ${consoleConfigProject.title}`);
254
+ if (options.verbose) {
255
+ console.log(`Selected project: ${consoleConfigProject.title}`);
256
+ }
251
257
 
252
258
  return consoleConfigProject;
253
259
  }
@@ -258,8 +264,15 @@ async function getProject(imsOrgId, imsOrgTitle) {
258
264
  * @param projectId
259
265
  * @param imsOrgTitle
260
266
  * @param projectTitle
267
+ * @param options
261
268
  */
262
- async function getWorkspace(orgId, projectId, imsOrgTitle, projectTitle) {
269
+ async function getWorkspace(
270
+ orgId,
271
+ projectId,
272
+ imsOrgTitle,
273
+ projectTitle,
274
+ options = { verbose: true },
275
+ ) {
263
276
  logger.info(`Initializing workspace selection for ${orgId} -> ${projectId}`);
264
277
 
265
278
  const { consoleCLI } = await getLibConsoleCLI();
@@ -292,7 +305,9 @@ async function getWorkspace(orgId, projectId, imsOrgTitle, projectTitle) {
292
305
  }
293
306
  } else {
294
307
  logger.debug(`Selected workspace config ${objToString(consoleConfigWorkspace)}`);
295
- console.log(`Select workspace: ${consoleConfigWorkspace.name}`);
308
+ if (options.verbose) {
309
+ console.log(`Select workspace: ${consoleConfigWorkspace.name}`);
310
+ }
296
311
 
297
312
  return {
298
313
  id: consoleConfigWorkspace.id,
@@ -381,16 +396,18 @@ async function getLibConsoleCLI() {
381
396
  * @returns {any} Returns an object with properties ready for consumption
382
397
  */
383
398
  async function initSdk(options) {
384
- const { ignoreCache = false } = options;
399
+ const { ignoreCache = false, verbose = true } = options;
385
400
 
386
401
  let org;
387
402
  let project;
388
403
  let workspace;
389
404
 
390
405
  if (!ignoreCache) {
391
- org = await getAuthorizedOrganization();
392
- project = await getProject(org.id, org.name);
393
- workspace = await getWorkspace(org.id, project.id, org.name, project.title);
406
+ org = await getAuthorizedOrganization({ verbose: verbose });
407
+ project = await getProject(org.id, org.name, { verbose: verbose });
408
+ workspace = await getWorkspace(org.id, project.id, org.name, project.title, {
409
+ verbose: verbose,
410
+ });
394
411
  } else {
395
412
  org = await selectAuthorizedOrganization();
396
413
  project = await selectProject(org.id, org.name);