contensis-cli 1.3.1-beta.1 → 1.3.1-beta.3

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/src/shell.ts CHANGED
@@ -14,6 +14,7 @@ import { LIB_VERSION } from './version';
14
14
  class ContensisShell {
15
15
  private currentEnvironment!: string;
16
16
  private emptyInputCounter: number = 0;
17
+ private cache!: SessionCache;
17
18
  private env!: EnvironmentCache;
18
19
  private firstStart = true;
19
20
  private userId: string = '';
@@ -22,12 +23,12 @@ class ContensisShell {
22
23
 
23
24
  private refreshEnvironment = () => {
24
25
  // Reload any persisted changes from the disk cache
25
- const {
26
- cache: { currentEnvironment = '', environments = {} },
27
- } = new ContensisCli([]);
26
+ const { cache } = new ContensisCli([]);
27
+ this.cache = cache; // read the cache to pre-load suggestions
28
28
  // console.log(`refreshing env w/${currentEnvironment}`);
29
- this.currentEnvironment = currentEnvironment;
30
- this.env = environments[currentEnvironment];
29
+ this.currentEnvironment = cache.currentEnvironment || '';
30
+ const environments = cache.environments || {};
31
+ this.env = environments[this.currentEnvironment];
31
32
 
32
33
  // Reload logging here to support changing language
33
34
  Logging('en-GB').then(({ messages, Log }) => {
@@ -128,12 +129,20 @@ class ContensisShell {
128
129
  },
129
130
  },
130
131
  'connect',
132
+ ...Object.keys(this.cache.environments || {}).map(
133
+ alias => `connect ${alias}`
134
+ ),
131
135
  'list envs',
132
136
  'quit',
133
137
  ];
134
138
 
135
139
  if (currentEnvironment)
136
- availableCommands.push('login', 'list projects', 'set project');
140
+ availableCommands.push(
141
+ 'login',
142
+ 'list projects',
143
+ 'set project',
144
+ ...(this.env.projects || []).map(project => `set project ${project}`)
145
+ );
137
146
  if (userId)
138
147
  availableCommands.push(
139
148
  'copy field',
@@ -243,9 +252,8 @@ class ContensisShell {
243
252
  : JSON.stringify(ex, null, 2)
244
253
  }`
245
254
  );
246
- } finally {
247
- return this.contensisPrompt();
248
255
  }
256
+ return this.contensisPrompt();
249
257
  }
250
258
  })
251
259
  .catch((err: Error) => {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "1.3.1-beta.1";
1
+ export const LIB_VERSION = "1.3.1-beta.3";