@neilbmclaughlin/github-secrets
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -35,3 +35,3 @@ #!/usr/bin/env node | ||
putSecrets(argv.a, argv.filename, argv.o, argv.r) | ||
.then(() => console.log(chalk.green('put successful'))) | ||
.then(() => console.log(chalk.green('put complete'))) | ||
.catch((err) => console.log(`${chalk.red('put failed')} (${chalk.grey(err.message)})`)) | ||
@@ -45,4 +45,4 @@ } | ||
deleteSecrets(argv.a, argv.filename, argv.o, argv.r) | ||
.then(() => console.log(chalk.green('delete successful'))) | ||
.catch((err) => console.log(`${chalk.red('delete failed')} (${chalk.grey(err.message)})`)) | ||
.then(() => console.log(chalk.green('delete complete'))) | ||
.catch((err) => console.log(`${chalk.red('delete failed')} (${chalk.grey(err.extended.message)})`)) | ||
} | ||
@@ -79,3 +79,6 @@ ) | ||
} catch (err) { | ||
throw Error(`githubRequest failed (status ${err.status}): ${restCmd} ${JSON.stringify(options)}`) | ||
err.extended = { | ||
message: `githubRequest failed (status ${err.status}): ${restCmd} ${JSON.stringify(options)}` | ||
} | ||
throw err | ||
} | ||
@@ -100,2 +103,15 @@ } | ||
async function actionSecret (accessToken, restCmd, verb, options, key) { | ||
try { | ||
await githubRequest(accessToken, restCmd, options) | ||
console.log(`${verb} secret ${key}`) | ||
} catch (err) { | ||
if (err.status && err.status === 404) { | ||
console.log(`secret ${key} does not exist`) | ||
} else { | ||
throw err | ||
} | ||
} | ||
} | ||
async function putSecrets (accessToken, filename, owner, repository) { | ||
@@ -118,3 +134,3 @@ await checkSecretsSupported(accessToken, owner, repository) | ||
const restCmd = `PUT ${path}/{secret_name}` | ||
const parameters = { | ||
const options = { | ||
secret_name: key, | ||
@@ -125,3 +141,3 @@ encrypted_value: encrypt(publicKey, value), | ||
} | ||
await githubRequest(accessToken, restCmd, parameters) | ||
await actionSecret(accessToken, restCmd, 'added', options, key) | ||
} | ||
@@ -149,4 +165,4 @@ } | ||
} | ||
await githubRequest(accessToken, restCmd, options) | ||
await actionSecret(accessToken, restCmd, 'deleted', options, key) | ||
} | ||
} |
{ | ||
"name": "@neilbmclaughlin/github-secrets", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "manage git repository secrets", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5921
143