feat(cli): quickstart (#1204)
This commit is contained in:
parent
e5f5a2a0c5
commit
b96cdea2fc
@ -13,10 +13,7 @@ if [ ! -f "/app/nocobase/package.json" ]; then
|
||||
tar -zxf /app/nocobase.tar.gz --absolute-names -C /app/nocobase
|
||||
fi
|
||||
|
||||
cd /app/nocobase && yarn nocobase db:auth --retry=30
|
||||
cd /app/nocobase && yarn nocobase install -s
|
||||
cd /app/nocobase && yarn nocobase upgrade -S
|
||||
cd /app/nocobase && yarn start
|
||||
cd /app/nocobase && yarn start --quickstart
|
||||
|
||||
# Run command with node if the first argument contains a "-" or is not a system command. The last
|
||||
# part inside the "{}" is a workaround for the following bug in ash/dash:
|
||||
|
@ -15,6 +15,7 @@ module.exports = (cli) => {
|
||||
.option('-p, --port [port]')
|
||||
.option('-d, --daemon')
|
||||
.option('--db-sync')
|
||||
.option('--quickstart')
|
||||
.allowUnknownOption()
|
||||
.action(async (opts) => {
|
||||
if (opts.port) {
|
||||
@ -40,6 +41,10 @@ module.exports = (cli) => {
|
||||
return;
|
||||
}
|
||||
await postCheck(opts);
|
||||
if (opts.quickstart) {
|
||||
await run('node', [`./packages/${APP_PACKAGE_ROOT}/server/lib/index.js`, 'install', '--ignore-installed']);
|
||||
await run('node', [`./packages/${APP_PACKAGE_ROOT}/server/lib/index.js`, 'upgrade']);
|
||||
}
|
||||
if (opts.dbSync) {
|
||||
await run('node', [`./packages/${APP_PACKAGE_ROOT}/server/lib/index.js`, 'db:sync']);
|
||||
}
|
||||
|
@ -478,6 +478,12 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
|
||||
return true;
|
||||
}
|
||||
|
||||
async isInstalled() {
|
||||
return (
|
||||
(await this.db.collectionExistsInDb('applicationVersion')) || (await this.db.collectionExistsInDb('collections'))
|
||||
);
|
||||
}
|
||||
|
||||
async install(options: InstallOptions = {}) {
|
||||
console.log('Database dialect: ' + this.db.sequelize.getDialect());
|
||||
|
||||
|
@ -8,26 +8,20 @@ export default (app: Application) => {
|
||||
.option('-c, --clean')
|
||||
.option('-s, --silent')
|
||||
.option('-r, --retry [retry]')
|
||||
.option('-I, --ignore-installed')
|
||||
.action(async (...cliArgs) => {
|
||||
let installed = false;
|
||||
const [opts] = cliArgs;
|
||||
|
||||
try {
|
||||
await app.db.auth({ retry: opts.retry || 1 });
|
||||
} catch (error) {
|
||||
console.log(
|
||||
chalk.red(
|
||||
'Unable to connect to the database. Please check the database environment variables in the .env file.',
|
||||
),
|
||||
);
|
||||
if (opts.ignoreInstalled) {
|
||||
if (await app.isInstalled()) {
|
||||
console.log('Application installed');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!opts?.clean && !opts?.force) {
|
||||
if (
|
||||
(await app.db.collectionExistsInDb('applicationVersion')) ||
|
||||
(await app.db.collectionExistsInDb('collections'))
|
||||
) {
|
||||
if (await app.isInstalled()) {
|
||||
installed = true;
|
||||
if (!opts.silent) {
|
||||
console.log('NocoBase is already installed. To reinstall, please execute:');
|
||||
|
Loading…
Reference in New Issue
Block a user