Comparing version 1.0.9 to 1.0.10
{ | ||
"name": "@env0/cli", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "env0 CLI", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -30,5 +30,6 @@ | ||
### `env0 configure` | ||
### `env0 configure <arguments>` | ||
Displays a set of prompts that will help you configure the CLI options. | ||
Sets configurable options for the CLI. | ||
If no arguments are given, displays a set of prompts that will help you configure the CLI options. | ||
@@ -35,0 +36,0 @@ ### `env0 deploy <arguments>` |
const inquirer = require('inquirer'); | ||
const configManager = require('../lib/config-manager'); | ||
const { argumentsMap } = require('../config/arguments'); | ||
const logger = require('../lib/logger'); | ||
const _ = require('lodash'); | ||
@@ -22,12 +23,24 @@ | ||
const configure = async () => { | ||
const configuration = { ...emptyConfig, ...configManager.read() }; | ||
const isInteractiveConfigure = options => _.isEmpty(options); | ||
const questions = getQuestions(configuration); | ||
const configure = async options => { | ||
let newConfiguration; | ||
if (isInteractiveConfigure(options)) { | ||
const configuration = { ...emptyConfig, ...configManager.read() }; | ||
const answers = await inquirer.prompt(questions); | ||
const questions = getQuestions(configuration); | ||
configManager.write(removeEmptyAnswers(answers)); | ||
const answers = await inquirer.prompt(questions); | ||
newConfiguration = removeEmptyAnswers(answers); | ||
} else { | ||
newConfiguration = configManager.read(options); | ||
Object.keys(options).forEach(opt => logger.info(`Setting ${opt}: ${options[opt]}`)); | ||
} | ||
configManager.write(newConfiguration); | ||
logger.info('Done configuring CLI options!'); | ||
}; | ||
module.exports = configure; |
@@ -6,2 +6,3 @@ const commandLineUsage = require('command-line-usage'); | ||
const { repository } = require('../../package.json'); | ||
const { flatMap } = require('lodash'); | ||
@@ -28,3 +29,3 @@ const header = ` | ||
})), | ||
group: [ command ] | ||
group: [command] | ||
})); | ||
@@ -47,6 +48,3 @@ | ||
header: 'Examples', | ||
content: Object.keys(commands).map(command => ({ | ||
desc: commands[command].description, | ||
example: commands[command].example, | ||
})) | ||
content: flatMap(Object.keys(commands), command => commands[command].help) | ||
}, | ||
@@ -53,0 +51,0 @@ { |
@@ -40,4 +40,2 @@ const DeployUtils = require('../lib/deploy-utils'); | ||
configManager.write(options); | ||
logger.setSecrets(options); | ||
@@ -44,0 +42,0 @@ |
@@ -26,3 +26,3 @@ const { options } = require('./constants'); | ||
secret: true, | ||
group: ['deploy', 'destroy', 'approve', 'cancel'] | ||
group: ['deploy', 'destroy', 'approve', 'cancel', 'configure'] | ||
}, | ||
@@ -36,3 +36,3 @@ [API_SECRET]: { | ||
secret: true, | ||
group: ['deploy', 'destroy', 'approve', 'cancel'] | ||
group: ['deploy', 'destroy', 'approve', 'cancel', 'configure'] | ||
}, | ||
@@ -45,3 +45,3 @@ [ORGANIZATION_ID]: { | ||
prompt: 'Organization ID', | ||
group: ['deploy', 'destroy', 'approve', 'cancel'] | ||
group: ['deploy', 'destroy', 'approve', 'cancel', 'configure'] | ||
}, | ||
@@ -54,3 +54,3 @@ [PROJECT_ID]: { | ||
prompt: 'Project ID', | ||
group: ['deploy', 'destroy', 'approve', 'cancel'] | ||
group: ['deploy', 'destroy', 'approve', 'cancel', 'configure'] | ||
}, | ||
@@ -70,3 +70,3 @@ [WORKSPACE_NAME]: { | ||
prompt: 'Environment Name', | ||
group: ['deploy', 'destroy', 'approve', 'cancel'] | ||
group: ['deploy', 'destroy', 'approve', 'cancel', 'configure'] | ||
}, | ||
@@ -79,3 +79,3 @@ [BLUEPRINT_ID]: { | ||
prompt: 'Blueprint ID', | ||
group: ['deploy'] | ||
group: ['deploy', 'configure'] | ||
}, | ||
@@ -82,0 +82,0 @@ [REQUIRES_APPROVAL]: { |
@@ -9,34 +9,64 @@ const { argumentsMap, allArguments, baseArguments } = require('./arguments'); | ||
options: allArguments, | ||
description: 'Deploys an environment', | ||
example: `$ env0 deploy -k <${API_KEY}> -s <${API_SECRET}> -o <${ORGANIZATION_ID}> -p <${PROJECT_ID}> -b <${BLUEPRINT_ID}> -e <${ENVIRONMENT_NAME}> -r [revision] -v [stage=dev]` | ||
help: [ | ||
{ | ||
desc: 'Deploys an environment', | ||
example: `$ env0 deploy -k <${API_KEY}> -s <${API_SECRET}> -o <${ORGANIZATION_ID}> -p <${PROJECT_ID}> -b <${BLUEPRINT_ID}> -e <${ENVIRONMENT_NAME}> -r [revision] -v [stage=dev]` | ||
} | ||
] | ||
}, | ||
destroy: { | ||
options: [ | ||
...baseArguments, | ||
argumentsMap[REQUIRES_APPROVAL] | ||
], | ||
description: 'Destroys an environment', | ||
example: `$ env0 destroy -k <${API_KEY}> -s <${API_SECRET}> -o <${ORGANIZATION_ID}> -p <${PROJECT_ID}> -e <${ENVIRONMENT_NAME}>\n` | ||
options: [...baseArguments, argumentsMap[REQUIRES_APPROVAL]], | ||
help: [ | ||
{ | ||
desc: 'Destroys an environment', | ||
example: `$ env0 destroy -k <${API_KEY}> -s <${API_SECRET}> -o <${ORGANIZATION_ID}> -p <${PROJECT_ID}> -e <${ENVIRONMENT_NAME}>\n` | ||
} | ||
] | ||
}, | ||
approve: { | ||
options: baseArguments, | ||
description: 'Accepts a deployment that is pending approval', | ||
example: `$ env0 approve -k <${API_KEY}> -s <${API_SECRET}> -o <${ORGANIZATION_ID}> -p <${PROJECT_ID}> -e <${ENVIRONMENT_NAME}>\n` | ||
help: [ | ||
{ | ||
desc: 'Accepts a deployment that is pending approval', | ||
example: `$ env0 approve -k <${API_KEY}> -s <${API_SECRET}> -o <${ORGANIZATION_ID}> -p <${PROJECT_ID}> -e <${ENVIRONMENT_NAME}>\n` | ||
} | ||
] | ||
}, | ||
cancel: { | ||
options: baseArguments, | ||
description: 'Cancels a deployment that is pending approval', | ||
example: `$ env0 cancel -k <${API_KEY}> -s <${API_SECRET}> -o <${ORGANIZATION_ID}> -p <${PROJECT_ID}> -e <${ENVIRONMENT_NAME}>\n` | ||
help: [ | ||
{ | ||
desc: 'Cancels a deployment that is pending approval', | ||
example: `$ env0 cancel -k <${API_KEY}> -s <${API_SECRET}> -o <${ORGANIZATION_ID}> -p <${PROJECT_ID}> -e <${ENVIRONMENT_NAME}>\n` | ||
} | ||
] | ||
}, | ||
configure: { | ||
description: 'Configures env0 CLI options', | ||
example: `$ env0 configure`, | ||
options: [...baseArguments, argumentsMap[BLUEPRINT_ID]], | ||
help: [ | ||
{ | ||
desc: 'Configures env0 CLI options', | ||
example: `$ env0 configure -k <${API_KEY}> -s <${API_SECRET}> -o <${ORGANIZATION_ID}> -p <${PROJECT_ID}> -e <${ENVIRONMENT_NAME}> -b <${BLUEPRINT_ID}>` | ||
}, | ||
{ | ||
desc: 'Interactively configures env0 CLI options\n', | ||
example: `$ env0 configure` | ||
} | ||
] | ||
}, | ||
version: { | ||
description: 'Shows the CLI version', | ||
example: `$ env0 version` | ||
help: [ | ||
{ | ||
desc: 'Shows the CLI version', | ||
example: `$ env0 version` | ||
} | ||
] | ||
}, | ||
help: { | ||
description: 'Shows this help message', | ||
example: `$ env0 help` | ||
help: [ | ||
{ | ||
desc: 'Shows this help message', | ||
example: `$ env0 help` | ||
} | ||
] | ||
} | ||
@@ -43,0 +73,0 @@ }; |
@@ -48,3 +48,4 @@ const Env0ApiClient = require('./api-client'); | ||
}, | ||
configurationChanges | ||
configurationChanges, | ||
requiresApproval: convertStringToBoolean(options[REQUIRES_APPROVAL]) | ||
}); | ||
@@ -51,0 +52,0 @@ |
@@ -38,3 +38,4 @@ const commandLineArgs = require('command-line-args'); | ||
if (command === 'configure') { | ||
await configure(); | ||
const options = getCommandOptions(command, args); | ||
await configure(options); | ||
isInternalCmd = true; | ||
@@ -59,7 +60,4 @@ } | ||
const commandDefinitions = commands[command].options; | ||
const commandsOptions = commandLineArgs(commandDefinitions, { argv }); | ||
const currentCommandOptions = getCommandOptions(command, argv); | ||
const currentCommandOptions = commandsOptions[command]; | ||
const environmentVariables = getEnvironmentVariablesOptions( | ||
@@ -83,2 +81,9 @@ currentCommandOptions[ENVIRONMENT_VARIABLES], | ||
const getCommandOptions = (command, argv) => { | ||
const commandDefinitions = commands[command].options; | ||
const commandsOptions = commandLineArgs(commandDefinitions, { argv }); | ||
return commandsOptions[command]; | ||
}; | ||
const parseEnvironmentVariables = (environmentVariables, sensitive) => { | ||
@@ -85,0 +90,0 @@ const result = []; |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
33627
780
144
1