From c460d556b6d56cd62d436d75eb588bdd302040c5 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Mon, 15 Jan 2024 14:59:33 -0800 Subject: [PATCH] No prompting in CI --- README.md | 29 +++++++++++++++++++++++++++++ bin.js | 10 ++++++++++ 2 files changed, 39 insertions(+) diff --git a/README.md b/README.md index 059f022..aa16141 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,35 @@ deploySite.then(info => { console.log('done deploying site!') }) .catch(e => { throw e }) ``` +## Bin + +`async-neocities` ships a bin that lets you deploy to neocities locally or in CI. + +It's interactive and will help you set up your config and keys. + + +```console +Usage: async-neocities [options] + + Example: async-neocities --src public + + --help, -h print help text + --src, -s The directory to deploy to neocities (default: "public") + --cleanup, -c Destructively clean up orphaned files on neocities + --protect, -p String to minimatch files which will never be cleaned up + --status Print auth status of current working directory + --print-key Print api-key status of current working directory + --clear-key Remove the currently assoicated API key + --force-auth Force re-authorization of current working directory + +async-neocities (v2.1.6) +``` + +You can set the flags with ENV vars + +- `ASYNC_NEOCITIES_API_KEY` or `NEOCITIES_API_TOKEN`: the API token matching the site name. +- `ASYNC_NEOCITIES_SITE_NAME`: the name of the site to deploy to. + ## API ### `import { NeocitiesAPIClient } from 'async-neocities'` diff --git a/bin.js b/bin.js index d93beda..8794506 100755 --- a/bin.js +++ b/bin.js @@ -66,6 +66,8 @@ const cfg = createApplicationConfig(pkg.name) const args = parseArgs({ options }) +const isCI = process.env['CI'] + if (args.values['version']) { console.log(pkg.version) process.exit(0) @@ -174,6 +176,10 @@ async function main () { } else { // Config file not found or siteName is missing console.log('deploy-to-neocities.json not found or siteName is missing.') + if (isCI) { + console.log('Running in CI, skipping prompts') + process.exit(1) + } console.log('Please enter siteName:') // Setup readline interface @@ -210,6 +216,10 @@ async function main () { // Ask user for Neocities password // Ask user for password + if (isCI) { + console.log('Running in CI, skipping prompts') + process.exit(1) + } const password = await passwordPrompt('Enter Neocities password: ') if (!password) {