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