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;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createCli(app, options: ApplicationOptions) {
|
export function createCli(app: Application, options: ApplicationOptions) {
|
||||||
const cli = new Command();
|
const cli = new Command();
|
||||||
|
|
||||||
cli
|
cli
|
||||||
@ -57,13 +57,28 @@ export function createCli(app, options: ApplicationOptions) {
|
|||||||
cli
|
cli
|
||||||
.command('init')
|
.command('init')
|
||||||
.option('-f, --force')
|
.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({
|
await app.db.sync({
|
||||||
force: true,
|
force: true,
|
||||||
});
|
});
|
||||||
await app.emitAsync('db.init', ...args);
|
await app.emitAsync('db.init', opts, ...args);
|
||||||
await app.destroy();
|
await app.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
cli
|
cli
|
||||||
.command('start')
|
.command('start')
|
||||||
.option('-p, --port [port]')
|
.option('-p, --port [port]')
|
||||||
|
Loading…
Reference in New Issue
Block a user