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:
parent
b497aa8ad6
commit
7d8de8c019
2 changed files with 44 additions and 3 deletions
|
@ -7,15 +7,15 @@
|
||||||
"@logto/cli",
|
"@logto/cli",
|
||||||
"@logto/create"
|
"@logto/create"
|
||||||
], [
|
], [
|
||||||
"@logto/console",
|
|
||||||
"@logto/core",
|
"@logto/core",
|
||||||
|
"@logto/console",
|
||||||
"@logto/integration-tests",
|
"@logto/integration-tests",
|
||||||
"@logto/ui"
|
"@logto/ui"
|
||||||
]],
|
]],
|
||||||
"linked": [[
|
"linked": [[
|
||||||
|
"@logto/schemas",
|
||||||
"@logto/phrases",
|
"@logto/phrases",
|
||||||
"@logto/phrases-ui",
|
"@logto/phrases-ui"
|
||||||
"@logto/schemas"
|
|
||||||
]],
|
]],
|
||||||
"//": "END OF CAUTION",
|
"//": "END OF CAUTION",
|
||||||
"access": "restricted",
|
"access": "restricted",
|
||||||
|
|
41
.scripts/publish.js
Normal file
41
.scripts/publish.js
Normal 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');
|
Loading…
Reference in a new issue