mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 03:46:08 +00:00
fix(cli): support upgrade to next (#5130)
This commit is contained in:
parent
eaf23766c7
commit
da966813ee
@ -23,6 +23,7 @@ module.exports = (cli) => {
|
||||
.command('upgrade')
|
||||
.allowUnknownOption()
|
||||
.option('--raw')
|
||||
.option('--next')
|
||||
.option('-S|--skip-code-update')
|
||||
.action(async (options) => {
|
||||
if (hasTsNode()) promptForTs();
|
||||
@ -40,26 +41,32 @@ module.exports = (cli) => {
|
||||
await runAppCommand('upgrade');
|
||||
return;
|
||||
}
|
||||
// If ts-node is not installed, do not do the following
|
||||
const appDevDir = resolve(process.cwd(), './storage/.app-dev');
|
||||
if (existsSync(appDevDir)) {
|
||||
rmSync(appDevDir, { recursive: true, force: true });
|
||||
}
|
||||
const rmAppDir = () => {
|
||||
// If ts-node is not installed, do not do the following
|
||||
const appDevDir = resolve(process.cwd(), './storage/.app-dev');
|
||||
if (existsSync(appDevDir)) {
|
||||
rmSync(appDevDir, { recursive: true, force: true });
|
||||
}
|
||||
};
|
||||
const pkg = require('../../package.json');
|
||||
// get latest version
|
||||
const { stdout } = await run('npm', ['info', '@nocobase/cli', 'version'], { stdio: 'pipe' });
|
||||
const { stdout } = await run('npm', ['info', options.next ? '@nocobase/cli@next' : '@nocobase/cli', 'version'], {
|
||||
stdio: 'pipe',
|
||||
});
|
||||
if (pkg.version === stdout) {
|
||||
await runAppCommand('upgrade');
|
||||
rmAppDir();
|
||||
return;
|
||||
}
|
||||
const currentY = 1 * pkg.version.split('.')[1];
|
||||
const latestY = 1 * stdout.split('.')[1];
|
||||
if (currentY > latestY) {
|
||||
if (options.next || currentY > latestY) {
|
||||
await run('yarn', ['add', '@nocobase/cli@next', '@nocobase/devtools@next', '-W']);
|
||||
} else {
|
||||
await run('yarn', ['add', '@nocobase/cli', '@nocobase/devtools', '-W']);
|
||||
}
|
||||
await run('yarn', ['install']);
|
||||
await runAppCommand('upgrade');
|
||||
rmAppDir();
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user