better documentation
This commit is contained in:
@@ -19,7 +19,7 @@ function notEmpty (value) {
|
||||
return value.length>0
|
||||
}
|
||||
|
||||
async function setupQuestionnaire(is_docker) {
|
||||
async function setupQuestionnaire(is_docker, db) {
|
||||
|
||||
const questions = []
|
||||
questions.push({
|
||||
@@ -53,6 +53,7 @@ async function setupQuestionnaire(is_docker) {
|
||||
name: 'db.dialect',
|
||||
message: 'DB dialect',
|
||||
type: 'list',
|
||||
when: answers => !db,
|
||||
choices: ['sqlite', 'postgres']
|
||||
})
|
||||
|
||||
@@ -61,7 +62,7 @@ async function setupQuestionnaire(is_docker) {
|
||||
message: 'sqlite db path',
|
||||
default: is_docker ? '/opt/gancio/db.sqlite' : './db.sqlite',
|
||||
filter: p => path.resolve(cwd, p),
|
||||
when: answers => answers.db.dialect === 'sqlite',
|
||||
when: answers => (db && db==='sqlite') || (answers.db && answers.db.dialect === 'sqlite'),
|
||||
validate: db_path => db_path.length>0 && fs.existsSync(path.dirname(db_path))
|
||||
})
|
||||
|
||||
@@ -69,7 +70,7 @@ async function setupQuestionnaire(is_docker) {
|
||||
name: 'db.host',
|
||||
message: 'Postgres host',
|
||||
default: is_docker ? 'db' : 'localhost',
|
||||
when: answers => answers.db.dialect === 'postgres',
|
||||
when: answers => (db && db==='postgresql') || (answers.db && answers.db.dialect === 'postgres'),
|
||||
validate: notEmpty
|
||||
})
|
||||
|
||||
@@ -77,7 +78,7 @@ async function setupQuestionnaire(is_docker) {
|
||||
name: 'db.database',
|
||||
message: 'DB name',
|
||||
default: 'gancio',
|
||||
when: answers => answers.db.dialect === 'postgres',
|
||||
when: answers => (db && db==='postgresql') || (answers.db && answers.db.dialect === 'postgres'),
|
||||
validate: notEmpty
|
||||
})
|
||||
|
||||
@@ -85,7 +86,7 @@ async function setupQuestionnaire(is_docker) {
|
||||
name: 'db.username',
|
||||
message: 'DB user',
|
||||
default: 'gancio',
|
||||
when: answers => answers.db.dialect === 'postgres',
|
||||
when: answers => (db && db==='postgresql') || (answers.db && answers.db.dialect === 'postgres'),
|
||||
validate: notEmpty
|
||||
})
|
||||
|
||||
@@ -94,7 +95,7 @@ async function setupQuestionnaire(is_docker) {
|
||||
type: 'password',
|
||||
message: 'DB password',
|
||||
default: 'gancio',
|
||||
when: answers => answers.db.dialect === 'postgres',
|
||||
when: answers => (db && db==='postgresql') || (answers.db && answers.db.dialect === 'postgres'),
|
||||
validate: async (password, options) => {
|
||||
try {
|
||||
const db = new sequelize({ ...options.db, dialect: 'postgres' , password, logging: false })
|
||||
@@ -112,7 +113,8 @@ async function setupQuestionnaire(is_docker) {
|
||||
questions.push({
|
||||
name: 'upload_path',
|
||||
message: 'Where gancio has to store media?',
|
||||
default: '/opt/gancio/uploads',
|
||||
default: is_docker ? '/opt/gancio/uploads' : './uploads',
|
||||
when: answers => !is_docker,
|
||||
filter: p => path.resolve(cwd, p),
|
||||
validate: async p => {
|
||||
let exists = fs.existsSync(p)
|
||||
@@ -182,9 +184,6 @@ async function upgrade (options) {
|
||||
}
|
||||
})
|
||||
const migrations = await umzug.up()
|
||||
if (migrations.length) {
|
||||
consola.info('Migrations executed: ', migrations.map(m => m.file))
|
||||
}
|
||||
db.close()
|
||||
}
|
||||
|
||||
@@ -205,10 +204,10 @@ If this is your first run use 'gancio setup --config <CONFIG_FILE.json>' `)
|
||||
}
|
||||
|
||||
async function setup (options) {
|
||||
consola.info('DOCKER ', options.docker)
|
||||
consola.info(`You're going to setup gancio on this machine.`)
|
||||
const config = await setupQuestionnaire(options.docker)
|
||||
await firstrun.setup(config, options.config)
|
||||
const config = await setupQuestionnaire(options.docker, options.db)
|
||||
const ret = await firstrun.setup(config, options.config)
|
||||
if (!ret) process.exit(-1)
|
||||
if (options.docker) {
|
||||
consola.info(`You can edit ./config.json to modify your configuration.`)
|
||||
consola.info(`Start the server with "docker-compose up"`)
|
||||
@@ -229,6 +228,9 @@ require('yargs')
|
||||
default: false,
|
||||
type: 'boolean'
|
||||
})
|
||||
.option('db', {
|
||||
describe: 'Specify db type',
|
||||
})
|
||||
.option('config', {
|
||||
alias: 'c',
|
||||
describe: 'Configuration file',
|
||||
|
||||
Reference in New Issue
Block a user