-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setConfigSecrets command integrated and create command optimized
- Loading branch information
Showing
5 changed files
with
165 additions
and
31 deletions.
There are no files selected for viewing
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
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,41 @@ | ||
import { GluegunCommand } from 'gluegun'; | ||
|
||
import { ExtendedGluegunToolbox } from '../../interfaces/extended-gluegun-toolbox'; | ||
|
||
/** | ||
* Set secrets for the server configuration | ||
*/ | ||
const NewCommand: GluegunCommand = { | ||
alias: ['scs'], | ||
description: 'Set secrets for the server configuration', | ||
hidden: false, | ||
name: 'setConfigSecrets', | ||
run: async (toolbox: ExtendedGluegunToolbox) => { | ||
// Retrieve the tools we need | ||
const { | ||
filesystem, | ||
parameters, | ||
patching, | ||
print: { error, info, spin }, | ||
server, | ||
} = toolbox; | ||
|
||
// Check if file exists | ||
const filePath = parameters.first || 'src/config.env.ts'; | ||
if (!filesystem.exists(filePath)) { | ||
info(''); | ||
error(`There's no file named "${filePath}"`); | ||
return undefined; | ||
} | ||
|
||
// Set secrets | ||
const prepareSpinner = spin(`Setting secrets in server configuration: ${filePath}`); | ||
await patching.update(filePath, content => server.replaceSecretOrPrivateKeys(content)); | ||
prepareSpinner.succeed(`Secrets set in server configuration ${filePath}`); | ||
|
||
// For tests | ||
return 'secrets in server configuration set'; | ||
}, | ||
}; | ||
|
||
export default NewCommand; |
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