0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00
logto/.scripts/version.js
2022-12-30 13:49:00 +08:00

41 lines
1.2 KiB
JavaScript

import { exec } from 'node:child_process';
import { promisify } from 'node:util';
const execAsync = promisify(exec);
const versionGroup = process.argv[2];
if (process.argv.length > 3) {
throw new Error('Extraneous arguments found. Only one optional argument for version group name is allowed.');
}
// This is configured based on our practice. Change with care.
const allowedGroups = { core: 'core', toolkit: 'toolkit' };
if (!Object.values(allowedGroups).includes(versionGroup)) {
throw new Error('Version group is invalid. Should be one of ' + Object.values(allowedGroups).join(', ') + '.');
}
const { allPackages } = await import('./packages-meta.js');
const getIgnoreGroup = () => {
console.log(`=== Versioning ${versionGroup} group packages ===`);
return allPackages.filter(({ path }) => {
if (versionGroup === allowedGroups.toolkit) {
return !path.includes(allowedGroups.toolkit + '/');
}
return false;
});
}
const ignoreCmd = getIgnoreGroup()
.map(({ name }) => ` \\\n --ignore ${name}`)
.join('');
const cmd = ('pnpm changeset version' + ignoreCmd);
console.log(cmd);
await execAsync(cmd).catch(({ stderr, code }) => {
console.error(stderr);
process.exit(code ?? 1);
});