diff options
author | Fabio Berger <me@fabioberger.com> | 2018-07-02 22:20:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-02 22:20:34 +0800 |
commit | d247d72e3e8fb17e8147dc417637e9cc9fd9a0ba (patch) | |
tree | e6a85787f58ee1ad7e0a5e1ba5ce1c2497090bbb /packages/monorepo-scripts | |
parent | d861caca23cd87d162c0d4be62c04d9842c6b84f (diff) | |
parent | 50957e1d29674e8cb5e451ec576899ba8c15dde2 (diff) | |
download | dexon-sol-tools-d247d72e3e8fb17e8147dc417637e9cc9fd9a0ba.tar dexon-sol-tools-d247d72e3e8fb17e8147dc417637e9cc9fd9a0ba.tar.gz dexon-sol-tools-d247d72e3e8fb17e8147dc417637e9cc9fd9a0ba.tar.bz2 dexon-sol-tools-d247d72e3e8fb17e8147dc417637e9cc9fd9a0ba.tar.lz dexon-sol-tools-d247d72e3e8fb17e8147dc417637e9cc9fd9a0ba.tar.xz dexon-sol-tools-d247d72e3e8fb17e8147dc417637e9cc9fd9a0ba.tar.zst dexon-sol-tools-d247d72e3e8fb17e8147dc417637e9cc9fd9a0ba.zip |
Merge pull request #803 from 0xProject/fix/publishing/remote-tag-removal
Small publish fixes
Diffstat (limited to 'packages/monorepo-scripts')
-rw-r--r-- | packages/monorepo-scripts/CHANGELOG.json | 9 | ||||
-rw-r--r-- | packages/monorepo-scripts/src/prepublish_checks.ts | 12 | ||||
-rw-r--r-- | packages/monorepo-scripts/src/utils/utils.ts | 27 |
3 files changed, 32 insertions, 16 deletions
diff --git a/packages/monorepo-scripts/CHANGELOG.json b/packages/monorepo-scripts/CHANGELOG.json index a1dda0176..781704a8e 100644 --- a/packages/monorepo-scripts/CHANGELOG.json +++ b/packages/monorepo-scripts/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "version": "0.2.2", + "changes": [ + { + "note": "Fix git remote tag removal step & add an additional sanity assertion", + "pr": 803 + } + ] + }, + { "timestamp": 1529397769, "version": "0.2.1", "changes": [ diff --git a/packages/monorepo-scripts/src/prepublish_checks.ts b/packages/monorepo-scripts/src/prepublish_checks.ts index 1c4ee1fc6..3b4ff9082 100644 --- a/packages/monorepo-scripts/src/prepublish_checks.ts +++ b/packages/monorepo-scripts/src/prepublish_checks.ts @@ -34,17 +34,17 @@ async function checkGitTagsForNextVersionAndDeleteIfExistAsync( const packageLocation = lernaPackage.location; const nextVersion = await utils.getNextPackageVersionAsync(currentVersion, packageName, packageLocation); - const localTagVersions = localTagVersionsByPackageName[packageName]; - if (_.includes(localTagVersions, nextVersion)) { - const tagName = `${packageName}@${nextVersion}`; - await utils.removeLocalTagAsync(tagName); - } - const remoteTagVersions = remoteTagVersionsByPackageName[packageName]; if (_.includes(remoteTagVersions, nextVersion)) { const tagName = `:refs/tags/${packageName}@${nextVersion}`; await utils.removeRemoteTagAsync(tagName); } + + const localTagVersions = localTagVersionsByPackageName[packageName]; + if (_.includes(localTagVersions, nextVersion)) { + const tagName = `${packageName}@${nextVersion}`; + await utils.removeLocalTagAsync(tagName); + } } } diff --git a/packages/monorepo-scripts/src/utils/utils.ts b/packages/monorepo-scripts/src/utils/utils.ts index 20bc57bae..f819ab6f1 100644 --- a/packages/monorepo-scripts/src/utils/utils.ts +++ b/packages/monorepo-scripts/src/utils/utils.ts @@ -44,6 +44,9 @@ export const utils = { nextVersionIfValid = semver.inc(currentVersion, 'patch'); } const lastEntry = changelog[0]; + if (semver.gt(currentVersion, lastEntry.version)) { + throw new Error(`Package.json version cannot be greater then last CHANGELOG entry. Check: ${packageName}`); + } nextVersionIfValid = semver.eq(lastEntry.version, currentVersion) ? semver.inc(currentVersion, 'patch') : lastEntry.version; @@ -100,19 +103,23 @@ export const utils = { return tagVersionByPackageName; }, async removeLocalTagAsync(tagName: string): Promise<void> { - const result = await execAsync(`git tag -d ${tagName}`, { - cwd: constants.monorepoRootPath, - }); - if (!_.isEmpty(result.stderr)) { - throw new Error(`Failed to delete local git tag. Got err: ${result.stderr}`); + try { + await execAsync(`git tag -d ${tagName}`, { + cwd: constants.monorepoRootPath, + }); + } catch (err) { + throw new Error(`Failed to delete local git tag. Got err: ${err}`); } + this.log(`Removed local tag: ${tagName}`); }, async removeRemoteTagAsync(tagName: string): Promise<void> { - const result = await execAsync(`git push origin ${tagName}`, { - cwd: constants.monorepoRootPath, - }); - if (!_.isEmpty(result.stderr)) { - throw new Error(`Failed to delete remote git tag. Got err: ${result.stderr}`); + try { + await execAsync(`git push origin ${tagName}`, { + cwd: constants.monorepoRootPath, + }); + } catch (err) { + throw new Error(`Failed to delete remote git tag. Got err: ${err}`); } + this.log(`Removed remote tag: ${tagName}`); }, }; |