@affinidi/cli 1.31.0 → 1.31.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@affinidi/cli",
3
- "version": "1.31.0",
3
+ "version": "1.31.2",
4
4
  "description": "Affinidi Elements command-line-interface",
5
5
  "author": "affinidi.com",
6
6
  "license": "Apache-2.0",
@@ -12,6 +12,7 @@
12
12
  "files": [
13
13
  "/bin",
14
14
  "/dist",
15
+ "/scripts/autocomplete.cjs",
15
16
  "/npm-shrinkwrap.json",
16
17
  "/oclif.manifest.json"
17
18
  ],
@@ -0,0 +1,34 @@
1
+ const { exec } = require('child_process')
2
+ const {CliUx} = require('@oclif/core')
3
+
4
+ exec('echo $SHELL', async (err, stdout, stderr) => {
5
+ if (err) {
6
+ // node couldn't execute the command
7
+ return
8
+ }
9
+ const answers = await CliUx.ux.prompt(`Please confirm that you want to activate autocompletion [Y/n].(it will add several lines to your ./${stdout.split('/').at(-1)}rc file`, {
10
+ default: 'n',
11
+ })
12
+ if (answers.toLowerCase() === 'y'){
13
+ if(stdout.includes('zsh')){
14
+ execEnvVarCommand('zsh')
15
+ return
16
+ }
17
+ if(stdout.includes('bash')){
18
+ execEnvVarCommand('bash')
19
+ return
20
+ }
21
+ console.log('Auto-completion supports only zsh or bash shells.') }
22
+ console.log('Auto-completion not activated. To activate in future run npm install')
23
+ })
24
+
25
+ const execEnvVarCommand = (shell) => {
26
+ exec(`printf "eval $(affinidi autocomplete:script ${shell})" >> ~/.${shell}rc; source ~/.${shell}rc`,(err, stdout, stderr) =>{
27
+ if (err){
28
+ return
29
+ }
30
+ if (stderr){
31
+ console.log("Failed to activate auto-completion")
32
+ }
33
+ return
34
+ } )}