Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions packages/docusaurus/bin/beforeCli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,20 @@ export default async function beforeCli() {
.filter((p) => p.startsWith('@docusaurus'))
.map((p) => p.concat('@latest'))
.join(' ');
const isYarnUsed = await fs.pathExists(path.resolve('yarn.lock'));
const upgradeCommand = isYarnUsed
? `yarn upgrade ${siteDocusaurusPackagesForUpdate}`
: `npm i ${siteDocusaurusPackagesForUpdate}`;

const getUpgradeCommand = async () => {
const isYarnUsed = await fs.pathExists(path.resolve('yarn.lock'));
if (!isYarnUsed) {
return `npm i ${siteDocusaurusPackagesForUpdate}`;
}

const isYarnClassicUsed = !(await fs.pathExists(
path.resolve('.yarnrc.yml'),
));
return isYarnClassicUsed
? `yarn upgrade ${siteDocusaurusPackagesForUpdate}`
: `yarn up ${siteDocusaurusPackagesForUpdate}`;
};

/** @type {import('boxen').Options} */
const boxenOptions = {
Expand All @@ -124,7 +134,7 @@ export default async function beforeCli() {
)} → ${logger.green(`${notifier.update.latest}`)}

To upgrade Docusaurus packages with the latest version, run the following command:
${logger.code(upgradeCommand)}`,
${logger.code(await getUpgradeCommand())}`,
boxenOptions,
);

Expand Down