Skip to content

Commit

Permalink
Add special 'secret already exists' message
Browse files Browse the repository at this point in the history
  • Loading branch information
derrickreimer committed Nov 13, 2019
1 parent 28bfd05 commit 04a3a44
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/cmds/secrets_cmds/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ exports.handler = async args => {

switch (response.status) {
case 200:
log.success(`${coloredName} added to secrets`);
log.success(`Secret added`);
return;

case 401:
Expand All @@ -76,9 +76,7 @@ exports.handler = async args => {
error.field == 'key' &&
error.message == 'has already been taken'
) {
log.error(
'This secret already exists. Use `statickit secrets update` to update it.'
);
messages.secretAlreadyExists(args.name, args.value, deployKey);
} else {
log.error(`${humanizeField(error.field)} ${error.message}`);
}
Expand Down
6 changes: 5 additions & 1 deletion src/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ const withCaret = str => {
return `${chalk.gray('>')} ${str}`;
};

const withCheck = str => {
return `${chalk.green.bold('✔')} ${str}`;
};

const withX = str => {
return `${chalk.red.bold('✕')} ${str}`;
};
Expand All @@ -15,7 +19,7 @@ const withX = str => {
* @param {string} msg
*/
const success = msg => {
console.log(withCaret(chalk.green(msg)));
console.log(withCheck(chalk.green(msg)));
};

/**
Expand Down
16 changes: 15 additions & 1 deletion src/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,18 @@ const authRequired = () => {
console.error('');
};

module.exports = { authRequired };
const secretAlreadyExists = (name, value, key) => {
log.error('Secret already exists');
console.error('');

// prettier-ignore
console.error(stripIndent`
If you'd like to update it, run the following command instead:
${chalk.gray('$')} statickit secrets update ${name} ${value} -k ${key}
`);

console.error('');
};

module.exports = { authRequired, secretAlreadyExists };

0 comments on commit 04a3a44

Please sign in to comment.