mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-01 11:47:51 +08:00
fix: If it is already installed, skip the installation process
This commit is contained in:
parent
aff76b2d85
commit
ca2bee7d9a
@ -31,7 +31,7 @@ export function createI18n(options: ApplicationOptions) {
|
||||
return instance;
|
||||
}
|
||||
|
||||
export function createCli(app, options: ApplicationOptions) {
|
||||
export function createCli(app: Application, options: ApplicationOptions) {
|
||||
const cli = new Command();
|
||||
|
||||
cli
|
||||
@ -57,13 +57,28 @@ export function createCli(app, options: ApplicationOptions) {
|
||||
cli
|
||||
.command('init')
|
||||
.option('-f, --force')
|
||||
.action(async (...args) => {
|
||||
.action(async (opts, ...args) => {
|
||||
if (!opts?.force) {
|
||||
const tables = await app.db.sequelize.getQueryInterface().showAllTables();
|
||||
if (tables.includes('collections')) {
|
||||
console.log('NocoBase is already installed. To reinstall, please execute:');
|
||||
console.log();
|
||||
let command = 'yarn nocobase init --force'
|
||||
for (const [key, value] of Object.entries(opts||{})) {
|
||||
command += value === true ? ` --${key}` : ` --${key}=${value}`;
|
||||
}
|
||||
console.log(command);
|
||||
console.log();
|
||||
return;
|
||||
}
|
||||
}
|
||||
await app.db.sync({
|
||||
force: true,
|
||||
});
|
||||
await app.emitAsync('db.init', ...args);
|
||||
await app.emitAsync('db.init', opts, ...args);
|
||||
await app.destroy();
|
||||
});
|
||||
|
||||
cli
|
||||
.command('start')
|
||||
.option('-p, --port [port]')
|
||||
|
Loading…
Reference in New Issue
Block a user