ci(scripts): safer package details retrieval
This commit is contained in:
@@ -19,7 +19,11 @@ export type PackageDetails = {
|
|||||||
version: string
|
version: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accepts package whitelist (directory names inside packages dir) and returns details for each package
|
||||||
|
*/
|
||||||
export const getPackageDetails = async (packages: string[]): Promise<PackageDetails[]> => {
|
export const getPackageDetails = async (packages: string[]): Promise<PackageDetails[]> => {
|
||||||
|
// Fetch all package.json files, filter out packages not in the whitelist
|
||||||
const packageJsons = await globby('packages/*/package.json', {
|
const packageJsons = await globby('packages/*/package.json', {
|
||||||
cwd: projectRoot,
|
cwd: projectRoot,
|
||||||
absolute: true,
|
absolute: true,
|
||||||
@@ -31,6 +35,9 @@ export const getPackageDetails = async (packages: string[]): Promise<PackageDeta
|
|||||||
const isPublic = packageJson.private !== true
|
const isPublic = packageJson.private !== true
|
||||||
if (!isPublic) return null
|
if (!isPublic) return null
|
||||||
|
|
||||||
|
const isInWhitelist = packages.includes(path.basename(path.dirname(packageJsonPath)))
|
||||||
|
if (!isInWhitelist) return null
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: packageJson.name as string,
|
name: packageJson.name as string,
|
||||||
packagePath: path.relative(projectRoot, dirname(packageJsonPath)),
|
packagePath: path.relative(projectRoot, dirname(packageJsonPath)),
|
||||||
|
|||||||
@@ -142,9 +142,7 @@ async function main() {
|
|||||||
console.log(chalk.bold.yellow(` Tag: ${tag}\n`))
|
console.log(chalk.bold.yellow(` Tag: ${tag}\n`))
|
||||||
console.log(chalk.bold.green(` Changes (${packageDetails.length} packages):\n`))
|
console.log(chalk.bold.green(` Changes (${packageDetails.length} packages):\n`))
|
||||||
console.log(
|
console.log(
|
||||||
`${packageDetails
|
`${packageDetails.map((p) => ` - ${p.name.padEnd(32)} ${p.version} => ${chalk.green(nextReleaseVersion)}`).join('\n')}\n`,
|
||||||
.map((p) => ` - ${p.name.padEnd(32)} ${p.version} => ${chalk.green(nextReleaseVersion)}`)
|
|
||||||
.join('\n')}\n`,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const confirmPublish = await confirm('Are you sure you want to create these versions?')
|
const confirmPublish = await confirm('Are you sure you want to create these versions?')
|
||||||
|
|||||||
Reference in New Issue
Block a user