-
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.
- Loading branch information
1 parent
f55c1f4
commit ce89d5f
Showing
8 changed files
with
117 additions
and
124 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
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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
const fs = require('fs'); | ||
const utils = require('../utils'); | ||
const log = require('../log'); | ||
|
||
exports.command = 'init'; | ||
exports.desc = 'Creates a statickit.json file'; | ||
exports.builder = {}; | ||
exports.handler = _args => { | ||
fs.writeFile('statickit.json', '{}', { flag: 'wx' }, function(err) { | ||
if (err) { | ||
utils.logSuccess('statickit.json already exists'); | ||
log.success('statickit.json already exists'); | ||
} else { | ||
utils.logSuccess('statickit.json created'); | ||
log.success('statickit.json created'); | ||
} | ||
}); | ||
}; |
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,64 @@ | ||
const chalk = require('chalk'); | ||
const version = require('../package.json').version; | ||
|
||
const withCaret = str => { | ||
return `${chalk.gray('>')} ${str}`; | ||
}; | ||
|
||
const withX = str => { | ||
return `${chalk.red.bold('✕')} ${str}`; | ||
}; | ||
|
||
/** | ||
* Logs a green success message to stdout. | ||
* | ||
* @param {string} msg | ||
*/ | ||
const success = msg => { | ||
console.log(withCaret(chalk.green(msg))); | ||
}; | ||
|
||
/** | ||
* Logs a progress message to stdout. | ||
* | ||
* @param {string} msg | ||
*/ | ||
const progress = msg => { | ||
console.log(withCaret(chalk.whiteBright(msg))); | ||
}; | ||
|
||
/** | ||
* Logs a subtle gray message to stdout. | ||
* | ||
* @param {string} msg | ||
*/ | ||
const meta = msg => { | ||
console.log(withCaret(chalk.gray(msg))); | ||
}; | ||
|
||
/** | ||
* Logs a red error message to stderr. | ||
* | ||
* @param {string} msg | ||
*/ | ||
const error = msg => { | ||
console.error(withX(chalk.red.bold(msg))); | ||
}; | ||
|
||
/** | ||
* Logs the CLI preamble message. | ||
*/ | ||
const preamble = () => { | ||
meta(`StaticKit CLI v${version}`); | ||
}; | ||
|
||
/** | ||
* Colorizes a variable for display. | ||
* | ||
* @param {string} val | ||
*/ | ||
const variable = val => { | ||
return chalk.cyan.bold(`\`${val}\``); | ||
}; | ||
|
||
module.exports = { success, progress, meta, error, preamble, variable }; |
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 |
---|---|---|
@@ -1,37 +1,37 @@ | ||
const chalk = require('chalk'); | ||
const utils = require('./utils'); | ||
const log = require('./log'); | ||
const { stripIndent } = require('common-tags'); | ||
|
||
// prettier-ignore | ||
const authRequired = stripIndent` | ||
Your deploy key can be found under "Settings" in the UI. | ||
There are couple ways to use your key: | ||
const authRequired = () => { | ||
log.error('Deploy key is required'); | ||
console.error(''); | ||
|
||
- Use the ${utils.colorVariable('-k')} flag, or | ||
- Set the ${utils.colorVariable('STATICKIT_DEPLOY_KEY')} env variable | ||
// prettier-ignore | ||
console.error(stripIndent` | ||
Your deploy key can be found under "Settings" in the UI. | ||
There are couple ways to use your key: | ||
${chalk.yellow.bold('-- Examples -----------------------------------------------')} | ||
- Use the ${log.variable('-k')} flag, or | ||
- Set the ${log.variable('STATICKIT_DEPLOY_KEY')} env variable | ||
The inline method looks like this: | ||
${chalk.yellow.bold('-- Examples -----------------------------------------------')} | ||
${chalk.gray('$')} statickit deploy ${chalk.cyan('-k')} c4cf8a3b6cc15b9ea0817e4fa00cb036 | ||
For convenience, you can add it to a ${utils.colorVariable('.env')} file. | ||
That way, you don't have to copy/paste it every time | ||
you run a command: | ||
The inline method looks like this: | ||
${chalk.gray('$')} echo "${chalk.gray('STATICKIT_DEPLOY_KEY=c4cf8a3b6cc...')}" >> .env | ||
${chalk.gray('$')} statickit deploy | ||
Just be sure to add ${utils.colorVariable('.env')} to your ${utils.colorVariable('.gitignore')} file, | ||
so your deploy key does not end up in version control. | ||
`; | ||
${chalk.gray('$')} statickit deploy ${chalk.cyan('-k')} c4cf8a3b6cc15b9ea0817e4fa00cb036 | ||
For convenience, you can add it to a ${log.variable('.env')} file. | ||
That way, you don't have to copy/paste it every time | ||
you run a command: | ||
${chalk.gray('$')} echo "${chalk.gray('STATICKIT_DEPLOY_KEY=c4cf8a3b6cc...')}" >> .env | ||
${chalk.gray('$')} statickit deploy | ||
Just be sure to add ${log.variable('.env')} to your ${log.variable('.gitignore')} file, | ||
so your deploy key does not end up in version control. | ||
`); | ||
|
||
const logAuthRequired = () => { | ||
utils.logError('Deploy key is required'); | ||
console.error(''); | ||
console.error(authRequired); | ||
console.error(''); | ||
}; | ||
|
||
module.exports = { authRequired, logAuthRequired }; | ||
module.exports = { authRequired }; |
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.