-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
255 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { Command } from 'commander'; | ||
import Configstore, { CONFIG_KEYS } from '../../lib/Config'; | ||
import fs from 'fs-extra'; | ||
import chalk from 'chalk'; | ||
|
||
export default function extensionCommandBuilder() { | ||
const configCommander = new Command('config').description( | ||
'Config Commands', | ||
); | ||
const setCommander = new Command('set').description( | ||
'set config items', | ||
); | ||
|
||
setCommander | ||
.command('cafile <ca-file-path>') | ||
.description('To set CA file') | ||
.action((caFilePath: string) => { | ||
if (fs.existsSync(caFilePath)) { | ||
Configstore.set(CONFIG_KEYS.CA_FILE, caFilePath); | ||
} else { | ||
console.log(chalk.red("Provided file path does not exist.")); | ||
} | ||
}) | ||
|
||
setCommander | ||
.command('strict-ssl <boolean>') | ||
.description('To set CA file') | ||
.action((value: string) => { | ||
const ACCEPTED_VALUES = ['false', 'true'] | ||
if (ACCEPTED_VALUES.includes(value)) { | ||
Configstore.set(CONFIG_KEYS.STRICT_SSL, value); | ||
} else { | ||
console.log(chalk.red("Entered value is not valid.")); | ||
} | ||
}) | ||
|
||
configCommander.addCommand(setCommander); | ||
|
||
const getCommander = new Command('get').description( | ||
'set config items', | ||
); | ||
|
||
getCommander | ||
.command('cafile') | ||
.description('To set CA file') | ||
.action(() => { | ||
console.log(Configstore.get(CONFIG_KEYS.CA_FILE) || ""); | ||
}) | ||
|
||
getCommander | ||
.command('strict-ssl') | ||
.description('To set strict-ssl') | ||
.action(() => { | ||
console.log(Configstore.get(CONFIG_KEYS.STRICT_SSL) || ""); | ||
}) | ||
|
||
configCommander.addCommand(getCommander); | ||
|
||
const deleteCommander = new Command('delete').alias('rm').description( | ||
'delete config items', | ||
); | ||
|
||
deleteCommander | ||
.command('cafile') | ||
.description('To delete CA file') | ||
.action(() => { | ||
Configstore.delete(CONFIG_KEYS.CA_FILE) | ||
}) | ||
|
||
deleteCommander | ||
.command('strict-ssl') | ||
.description('To reset strict-ssl') | ||
.action(() => { | ||
Configstore.delete(CONFIG_KEYS.STRICT_SSL) | ||
}) | ||
|
||
configCommander.addCommand(deleteCommander); | ||
|
||
return configCommander; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Command } from 'commander'; | ||
|
||
import configCommandBuilder from './config-builder'; | ||
export default function env(program: Command) { | ||
program.addCommand(configCommandBuilder()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.