feat(tree-wide): init

This commit is contained in:
Saahil 2024-09-25 00:22:35 +00:00 committed by GitHub
parent 8b80a47543
commit 7849690f59
10 changed files with 1245 additions and 0 deletions

View file

@ -0,0 +1,38 @@
fs = require 'fs'
path = require 'path'
prompt = (question, callback) ->
return new Promise (resolve, reject) ->
process.stdout.write question
process.stdin.resume()
process.stdin.once 'data', (data) ->
data = data.toString().trim()
resolve data
callback? data
process.stdin.once 'error', (err) ->
reject err
callback? err
keys = {
IMAP_USER: 'IMAP username',
IMAP_PASSWORD: 'IMAP password',
IMAP_HOST: 'IMAP host',
IMAP_PORT: 'IMAP port',
PORT: 'Port',
USE_CLIPBOARD: 'Use clipboard? (y/n)',
USE_SERVER: 'Use server? (y/n)'
}
env = {}
for key, question of keys
if process.env[key]?
console.log "Skipping #{key}"
else
await prompt question + ': ', (data) ->
env[key] = data
fs.writeFileSync path.join(__dirname, '..', '.env'),
(key + '=' + value for key, value of env).join('\n')
console.log 'Wrote .env file'
process.exit 0