0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

chore: add pubilsh script

This commit is contained in:
Gao Sun 2022-11-11 14:04:31 +08:00
parent b497aa8ad6
commit 7d8de8c019
No known key found for this signature in database
GPG key ID: 13EBE123E4773688
2 changed files with 44 additions and 3 deletions

View file

@ -7,15 +7,15 @@
"@logto/cli",
"@logto/create"
], [
"@logto/console",
"@logto/core",
"@logto/console",
"@logto/integration-tests",
"@logto/ui"
]],
"linked": [[
"@logto/schemas",
"@logto/phrases",
"@logto/phrases-ui",
"@logto/schemas"
"@logto/phrases-ui"
]],
"//": "END OF CAUTION",
"access": "restricted",

41
.scripts/publish.js Normal file
View file

@ -0,0 +1,41 @@
const { execSync } = require('child_process');
const changesetConfig = require('../.changeset/config.json');
/** @type {Array<{ name: string; version?: string; path: string; private: boolean; }>} */
const allPackages = JSON.parse(execSync('pnpm recursive list --depth=-1 --json', { encoding: 'utf8' }));
const mainPackages = [...changesetConfig.fixed, ...changesetConfig.linked].map(([first]) => first);
const taggedPackages = mainPackages
.map((packageName) => {
const packageInfo = allPackages.find(({ name }) => name === packageName);
if (!packageInfo) {
throw new Error(`Package ${packageName} not found`);
}
const { name, version } = packageInfo;
if (!version) {
throw new Error(`No version found in package ${packageName}`);
}
const tag = name + '@' + version;
const hasTag = Boolean(execSync(`git tag -l ${tag}`, { encoding: 'utf8' }));
if (hasTag) {
console.log(`Tag ${tag} exists, skipping`);
return;
}
execSync(`git tag -a ${tag} -m'${tag}'`);
console.log(`Tag ${tag} added`);
return packageName;
})
.filter((value) => !!value);
if (taggedPackages.length === 0) {
console.log('No package tagged, exiting');
process.exit(0);
}
execSync('pnpm -r publish');
execSync('git push --tags');