diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-04-15 11:57:33 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-04-15 11:57:33 +0900 |
| commit | 69c452a9809d0af933b3137651b9a18327d3e8a7 (patch) | |
| tree | f8e91109f95c91d3609cd6ef32c99d9cc31a0831 /cli | |
| parent | i18n (diff) | |
| download | misskey-69c452a9809d0af933b3137651b9a18327d3e8a7.tar.gz misskey-69c452a9809d0af933b3137651b9a18327d3e8a7.tar.bz2 misskey-69c452a9809d0af933b3137651b9a18327d3e8a7.zip | |
:pizza:
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/del-usr.js | 13 | ||||
| -rw-r--r-- | cli/init.js | 162 |
2 files changed, 175 insertions, 0 deletions
diff --git a/cli/del-usr.js b/cli/del-usr.js new file mode 100644 index 0000000000..08e97845ec --- /dev/null +++ b/cli/del-usr.js @@ -0,0 +1,13 @@ +const deleteUser = require('../built/models/user').deleteUser; + +const args = process.argv.slice(2); + +const userId = args[0]; + +console.log(`deleting ${userId}...`); + +deleteUser(userId).then(() => { + console.log('done'); +}, e => { + console.error(e); +}); diff --git a/cli/init.js b/cli/init.js new file mode 100644 index 0000000000..7a3e7d1b51 --- /dev/null +++ b/cli/init.js @@ -0,0 +1,162 @@ +const fs = require('fs'); +const path = require('path'); +const yaml = require('js-yaml'); +const inquirer = require('inquirer'); +const chalk = require('chalk'); + +const configDirPath = `${__dirname}/../.config`; +const configPath = `${configDirPath}/default.yml`; + +const form = [{ + type: 'input', + name: 'maintainerName', + message: 'Your name:' +}, { + type: 'input', + name: 'maintainerUrl', + message: 'Your home page URL or your mailto URL:' +}, { + type: 'input', + name: 'url', + message: 'URL you want to run Misskey:' +}, { + type: 'input', + name: 'port', + message: 'Listen port (e.g. 443):' +}, { + type: 'confirm', + name: 'https', + message: 'Use TLS?', + default: false +}, { + type: 'input', + name: 'https_key', + message: 'Path of tls key:', + when: ctx => ctx.https +}, { + type: 'input', + name: 'https_cert', + message: 'Path of tls cert:', + when: ctx => ctx.https +}, { + type: 'input', + name: 'https_ca', + message: 'Path of tls ca:', + when: ctx => ctx.https +}, { + type: 'input', + name: 'mongo_host', + message: 'MongoDB\'s host:', + default: 'localhost' +}, { + type: 'input', + name: 'mongo_port', + message: 'MongoDB\'s port:', + default: '27017' +}, { + type: 'input', + name: 'mongo_db', + message: 'MongoDB\'s db:', + default: 'misskey' +}, { + type: 'input', + name: 'mongo_user', + message: 'MongoDB\'s user:' +}, { + type: 'password', + name: 'mongo_pass', + message: 'MongoDB\'s password:' +}, { + type: 'input', + name: 'redis_host', + message: 'Redis\'s host:', + default: 'localhost' +}, { + type: 'input', + name: 'redis_port', + message: 'Redis\'s port:', + default: '6379' +}, { + type: 'password', + name: 'redis_pass', + message: 'Redis\'s password:' +}, { + type: 'confirm', + name: 'elasticsearch', + message: 'Use Elasticsearch?', + default: false +}, { + type: 'input', + name: 'es_host', + message: 'Elasticsearch\'s host:', + default: 'localhost', + when: ctx => ctx.elasticsearch +}, { + type: 'input', + name: 'es_port', + message: 'Elasticsearch\'s port:', + default: '9200', + when: ctx => ctx.elasticsearch +}, { + type: 'password', + name: 'es_pass', + message: 'Elasticsearch\'s password:', + when: ctx => ctx.elasticsearch +}, { + type: 'input', + name: 'recaptcha_site', + message: 'reCAPTCHA\'s site key:' +}, { + type: 'input', + name: 'recaptcha_secret', + message: 'reCAPTCHA\'s secret key:' +}]; + +inquirer.prompt(form).then(as => { + // Mapping answers + const conf = { + maintainer: { + name: as['maintainerName'], + url: as['maintainerUrl'] + }, + url: as['url'], + port: parseInt(as['port'], 10), + https: { + enable: as['https'], + key: as['https_key'] || null, + cert: as['https_cert'] || null, + ca: as['https_ca'] || null + }, + mongodb: { + host: as['mongo_host'], + port: parseInt(as['mongo_port'], 10), + db: as['mongo_db'], + user: as['mongo_user'], + pass: as['mongo_pass'] + }, + redis: { + host: as['redis_host'], + port: parseInt(as['redis_port'], 10), + pass: as['redis_pass'] + }, + elasticsearch: { + enable: as['elasticsearch'], + host: as['es_host'] || null, + port: parseInt(as['es_port'], 10) || null, + pass: as['es_pass'] || null + }, + recaptcha: { + siteKey: as['recaptcha_site'], + secretKey: as['recaptcha_secret'] + } + }; + + console.log(`Thanks. Writing the configuration to ${chalk.bold(path.resolve(configPath))}`); + + try { + fs.writeFileSync(configPath, yaml.dump(conf)); + console.log(chalk.green('Well done.')); + } catch (e) { + console.error(e); + } +}); |