From e6c782c61718249e7a3dee90f2aee65e528e715b Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Jan 2017 11:05:21 +0900 Subject: Refactor --- init.js | 182 -------------------------------------------------------- package.json | 3 +- tools/init.js | 182 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/update.sh | 4 ++ update.sh | 4 -- 5 files changed, 188 insertions(+), 187 deletions(-) delete mode 100644 init.js create mode 100644 tools/init.js create mode 100644 tools/update.sh delete mode 100644 update.sh diff --git a/init.js b/init.js deleted file mode 100644 index 424b17b55d..0000000000 --- a/init.js +++ /dev/null @@ -1,182 +0,0 @@ -const fs = require('fs'); -const yaml = require('js-yaml'); -const inquirer = require('inquirer'); - -const configDirPath = `${__dirname}/.config`; -const configPath = `${configDirPath}/config.yml`; - -const form = [ - { - type: 'input', - name: 'maintainer', - message: 'Maintainer name(and email address):' - }, - { - type: 'input', - name: 'url', - message: 'PRIMARY URL:' - }, - { - type: 'input', - name: 'secondary_url', - message: 'SECONDARY URL:' - }, - { - type: 'input', - name: 'port', - message: 'Listen port:' - }, - { - 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: as['maintainer'], - url: as['url'], - secondary_url: as['secondary_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 ${configPath}`); - - try { - fs.mkdirSync(configDirPath); - fs.writeFileSync(configPath, yaml.dump(conf)); - console.log('Well done.'); - } catch (e) { - console.error(e); - } -}); diff --git a/package.json b/package.json index 237fdbffac..01cf838374 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,9 @@ "bugs": "https://github.com/syuilo/misskey/issues", "main": "./built/index.js", "scripts": { - "config": "node ./init.js", + "config": "node ./tools/init.js", "start": "node ./built/index.js", + "update": "./tools/update.sh", "swagger": "node ./swagger.js", "build": "gulp build", "rebuild": "gulp rebuild", diff --git a/tools/init.js b/tools/init.js new file mode 100644 index 0000000000..1c012ea0d9 --- /dev/null +++ b/tools/init.js @@ -0,0 +1,182 @@ +const fs = require('fs'); +const yaml = require('js-yaml'); +const inquirer = require('inquirer'); + +const configDirPath = `${__dirname}/../.config`; +const configPath = `${configDirPath}/config.yml`; + +const form = [ + { + type: 'input', + name: 'maintainer', + message: 'Maintainer name(and email address):' + }, + { + type: 'input', + name: 'url', + message: 'PRIMARY URL:' + }, + { + type: 'input', + name: 'secondary_url', + message: 'SECONDARY URL:' + }, + { + type: 'input', + name: 'port', + message: 'Listen port:' + }, + { + 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: as['maintainer'], + url: as['url'], + secondary_url: as['secondary_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 ${configPath}`); + + try { + fs.mkdirSync(configDirPath); + fs.writeFileSync(configPath, yaml.dump(conf)); + console.log('Well done.'); + } catch (e) { + console.error(e); + } +}); diff --git a/tools/update.sh b/tools/update.sh new file mode 100644 index 0000000000..c48d20de68 --- /dev/null +++ b/tools/update.sh @@ -0,0 +1,4 @@ +#!/bin/sh +git pull +npm install +npm run build diff --git a/update.sh b/update.sh deleted file mode 100644 index c48d20de68..0000000000 --- a/update.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -git pull -npm install -npm run build -- cgit v1.2.3-freya