Merge branch 'main' into next

This commit is contained in:
GitHub Actions Bot 2024-08-26 07:51:36 +00:00
commit 22ad2b4a91

View File

@ -23,6 +23,7 @@ module.exports = (cli) => {
.command('upgrade') .command('upgrade')
.allowUnknownOption() .allowUnknownOption()
.option('--raw') .option('--raw')
.option('--next')
.option('-S|--skip-code-update') .option('-S|--skip-code-update')
.action(async (options) => { .action(async (options) => {
if (hasTsNode()) promptForTs(); if (hasTsNode()) promptForTs();
@ -40,26 +41,32 @@ module.exports = (cli) => {
await runAppCommand('upgrade'); await runAppCommand('upgrade');
return; return;
} }
// If ts-node is not installed, do not do the following const rmAppDir = () => {
const appDevDir = resolve(process.cwd(), './storage/.app-dev'); // If ts-node is not installed, do not do the following
if (existsSync(appDevDir)) { const appDevDir = resolve(process.cwd(), './storage/.app-dev');
rmSync(appDevDir, { recursive: true, force: true }); if (existsSync(appDevDir)) {
} rmSync(appDevDir, { recursive: true, force: true });
}
};
const pkg = require('../../package.json'); const pkg = require('../../package.json');
// get latest version // 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) { if (pkg.version === stdout) {
await runAppCommand('upgrade'); await runAppCommand('upgrade');
rmAppDir();
return; return;
} }
const currentY = 1 * pkg.version.split('.')[1]; const currentY = 1 * pkg.version.split('.')[1];
const latestY = 1 * stdout.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']); await run('yarn', ['add', '@nocobase/cli@next', '@nocobase/devtools@next', '-W']);
} else { } else {
await run('yarn', ['add', '@nocobase/cli', '@nocobase/devtools', '-W']); await run('yarn', ['add', '@nocobase/cli', '@nocobase/devtools', '-W']);
} }
await run('yarn', ['install']); await run('yarn', ['install']);
await runAppCommand('upgrade'); await runAppCommand('upgrade');
rmAppDir();
}); });
}; };