Skip to content

Commit

Permalink
feat(packages/sui-mono): update cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrés Alvarez authored and Andrés Alvarez committed Dec 19, 2023
1 parent df6d0ba commit fabea43
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions packages/sui-mono/bin/sui-mono-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,22 @@ const releasesByPackages = ({status}) => {
.map(scope => scopeMapper({scope, status}))
}

const bump = async ({pkg, code} = {}) => {
const getCwd = ({pkg}) => {
const isMonoPackage = checkIsMonoPackage()
const cwd = isMonoPackage ? BASE_DIR : path.join(process.cwd(), pkg)
await exec(`npm --no-git-tag-version version ${RELEASE_CODES[code]}`, {cwd})
return isMonoPackage ? BASE_DIR : path.join(process.cwd(), pkg)
}

const commit = async ({pkg, skipCi} = {}) => {
const bump = ({pkg, code}) => {
const cwd = getCwd({pkg})
return exec(`npm --no-git-tag-version version ${RELEASE_CODES[code]}`, {cwd})
}

const commit = async ({pkg, skipCi}) => {
const isMonoPackage = checkIsMonoPackage()
const tagPrefix = isMonoPackage ? '' : `${pkg}-`
const packageScope = isMonoPackage ? 'Root' : pkg.replace(path.sep, '/')

const cwd = isMonoPackage ? BASE_DIR : path.join(process.cwd(), pkg)
const cwd = getCwd({pkg})

await exec(`git add ${path.join(cwd, 'package.json')}`, {cwd})

Expand All @@ -94,10 +98,8 @@ const commit = async ({pkg, skipCi} = {}) => {
await exec(`git tag -a ${tagPrefix}${version} -m "v${version}"`, {cwd})
}

const publish = async ({pkg} = {}) => {
const isMonoPackage = checkIsMonoPackage()

const cwd = isMonoPackage ? BASE_DIR : path.join(process.cwd(), pkg)
const publish = async ({pkg}) => {
const cwd = getCwd({pkg})
const {private: isPrivatePackage, config: localPackageConfig} = getPackageJson(cwd, true)

if (!isPrivatePackage) {
Expand Down Expand Up @@ -164,13 +166,13 @@ checkShouldRelease()

const packagesToRelease = releasesByPackages({status}).filter(({code}) => code !== 0)

await Promise.all(packagesToRelease.map(pkg => bump({...pkg, skipCi})))
await Promise.all(packagesToRelease.map(pkg => bump(pkg)))

for (const pkg of packagesToRelease) {
await commit({...pkg, skipCi})
}

await Promise.all(packagesToRelease.map(pkg => publish({...pkg, skipCi})))
await Promise.all(packagesToRelease.map(pkg => publish(pkg)))

if (packagesToRelease.length > 0) {
if (lock) {
Expand Down

0 comments on commit fabea43

Please sign in to comment.