@contrail/cli 1.0.65 → 1.0.66

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.
@@ -66,12 +66,13 @@ export async function upgradeApp() {
66
66
  type: 'list',
67
67
  name: 'appVersion',
68
68
  message: 'Which app version would you like to upgrade to?',
69
- choices: versions.reverse().map(x => {
70
- const name = x.id === appOrgToUpgrade.appVersionId ? `${x.versionNumber} (${x.createdOn}) (current)` : `${x.versionNumber} (${x.createdOn})`;
69
+ choices: versions.map(x => {
70
+ const number = x.versionNumber.toString().padStart(4, '0');
71
+ const name = x.id === appOrgToUpgrade.appVersionId ? `${number} (${x.createdOn}) (current)` : `${number} (${x.createdOn})`;
71
72
  return {
72
73
  value: x.id, name
73
74
  };
74
- })
75
+ }).sort((x, y) => { return x.name > y.name ? -1 : 1; })
75
76
  }]);
76
77
  console.log(`%s Upgrading app to version ${answers.appVersion}`, chalk.green.bold('APP INSTALLATION'));
77
78
  await upgradeAppVersion(appOrgToUpgrade, answers.appVersion);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "1.0.65",
3
+ "version": "1.0.66",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -68,12 +68,13 @@ export async function upgradeApp() {
68
68
  type: 'list',
69
69
  name: 'appVersion',
70
70
  message: 'Which app version would you like to upgrade to?',
71
- choices: versions.reverse().map(x => {
72
- const name = x.id === appOrgToUpgrade.appVersionId? `${x.versionNumber} (${x.createdOn}) (current)`: `${x.versionNumber} (${x.createdOn})`;
71
+ choices: versions.map(x => {
72
+ const number = x.versionNumber.toString().padStart(4, '0');
73
+ const name = x.id === appOrgToUpgrade.appVersionId ? `${number} (${x.createdOn}) (current)` : `${number} (${x.createdOn})`;
73
74
  return {
74
75
  value: x.id, name
75
76
  };
76
- })
77
+ }).sort((x, y) => { return x.name > y.name ? -1 : 1; })
77
78
  }]);
78
79
 
79
80
  console.log(`%s Upgrading app to version ${answers.appVersion}`, chalk.green.bold('APP INSTALLATION'));
@@ -3,13 +3,13 @@ import { Logger } from './utils/logger';
3
3
 
4
4
  export async function execute(data) {
5
5
  const logger = new Logger();
6
- logger.log(JSON.stringify(data))
7
6
  const event = (typeof data.event === 'string')
8
7
  ? JSON.parse(data.event)
9
8
  : data.event;
10
9
  data = JSON.parse(JSON.stringify(data));
11
- const config = data.config;
12
- if (!config.apiHost || !config.userName || !config.password) {
10
+ logger.log(JSON.stringify(data, null, 2));
11
+ if (!data.apiHost || !data.userName || !data.password) {
12
+ // not really. This is just to demo how to retrieve an app config
13
13
  const message = 'This action requires an api host, a username, and a password to run';
14
14
  const body = {
15
15
  message,
@@ -22,25 +22,22 @@ export async function execute(data) {
22
22
  }
23
23
 
24
24
  try {
25
- login({ apiKey: config.apiKey, orgSlug: config.orgSlug });
25
+ login({ apiKey: data.apiKey, orgSlug: data.orgSlug });
26
26
  const results = {};
27
27
 
28
28
  logger.log('Sending message: ', event);
29
- const response = await fetch(config.url, {
30
- method: 'POST',
31
- body: event,
29
+ const response = await fetch(data.apiHost, {
32
30
  headers: { 'Content-Type': 'application/json' }
33
31
  });
34
32
  if (!response.ok) {
35
33
  logger.log('Webhook event failed to publish');
36
- logger.log('Response: ', JSON.stringify(response));
37
34
  }
38
35
  else {
39
36
  logger.log('Published!');
40
37
  }
38
+ logger.log('Response: ', JSON.stringify(response));
41
39
 
42
40
  results['logs'] = logger.getEntries();
43
- results['config'] = config;
44
41
 
45
42
  logger.log('returning: ' + JSON.stringify(results));
46
43
  return {