Skip to content

Commit

Permalink
fix: remove custom node-workspace plugin
Browse files Browse the repository at this point in the history
release-please now has all the fixes we need and we can
use the upstream plugin
  • Loading branch information
lukekarrys committed May 3, 2024
1 parent dff1b5b commit 8b2e738
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 118 deletions.
37 changes: 25 additions & 12 deletions lib/release/node-workspace-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ const { ManifestPlugin } = require('release-please/build/src/plugin.js')
const { addPath } = require('release-please/build/src/plugins/workspace.js')
const { TagName } = require('release-please/build/src/util/tag-name.js')
const { ROOT_PROJECT_PATH } = require('release-please/build/src/manifest.js')
const { DEPS, link, wrapSpecs } = require('./util.js')
const { DEPS, link, wrapSpecs, list } = require('./util.js')

/* istanbul ignore next: TODO fix flaky tests and enable coverage */
module.exports = class extends ManifestPlugin {
static WORKSPACE_MESSAGE = (name, version) => `${DEPS}(workspace): ${name}@${version}`

#releasesByPackage = new Map()
#pathsByComponent = new Map()
#WORKSPACE_SCOPE = /(?<scope>workspace): `?(?<name>\S+?)[@\s](?<version>\S+?)`?$/gm

async preconfigure (strategiesByPath) {
// First build a list of all releases that will happen based on
Expand All @@ -32,6 +31,16 @@ module.exports = class extends ManifestPlugin {
return candidates
}

#replaceWorkspace ({ name, versionRange }) {
const version = versionRange.replace(/^[\^~]/, '')
const { path, component } = this.#releasesByPackage.get(name)
const { tagSeparator, includeVInTag } = this.repositoryConfig[path]
const { repository: { owner, repo } } = this.github
const tag = new TagName(version, component, tagSeparator, includeVInTag).toString()
const url = `https://github.com/${owner}/${repo}/releases/tag/${tag}`
return list(`${link('workspace', url)}: ${wrapSpecs(`${name}@${version}`)}`)
}

// I don't like how release-please formats workspace changelog entries
// so this rewrites them to look like the rest of our changelog. This can't
// be part of the changelog plugin since they are written after that by the
Expand All @@ -42,16 +51,20 @@ module.exports = class extends ManifestPlugin {
for (const release of candidate.pullRequest.body.releaseData) {
// Update notes with a link to each workspaces release notes
// now that we have all of the releases in a single pull request
release.notes =
release.notes.replace(this.#WORKSPACE_SCOPE, (...args) => {
const { scope, name, version } = args.pop()
const { path, component } = this.#releasesByPackage.get(name)
const { tagSeparator, includeVInTag } = this.repositoryConfig[path]
const { repository: { owner, repo } } = this.github
const tag = new TagName(version, component, tagSeparator, includeVInTag).toString()
const url = `https://github.com/${owner}/${repo}/releases/tag/${tag}`
return `${link(scope, url)}: ${wrapSpecs(`${name}@${version}`)}`
})
release.notes = release.notes
.replace(/^\* The following workspace dependencies were updated\n/gm, '')
.replace(/^\s{2}\* dependencies\n/gm, '')
.replace(/^\s{2}\* devDependencies\n/gm, '')
.replace(/^\s{2}\* peerDependencies\n/gm, '')
.replace(/^\s{2}\* optionalDependencies\n/gm, '')
.replace(
/^\s{4}\* (?<name>[^\s]+) bumped to (?<versionRange>[^\s]+)/gm,
(...args) => this.#replaceWorkspace(args.at(-1))
)
.replace(
/^\s{4}\* (?<name>[^\s]+) bumped from (?:[^\s]+) to (?<versionRange>[^\s]+)/gm,
(...args) => this.#replaceWorkspace(args.at(-1))
)

// Find the associated changelog and update that too
const path = this.#pathsByComponent.get(release.component)
Expand Down
103 changes: 0 additions & 103 deletions lib/release/node-workspace.js

This file was deleted.

3 changes: 0 additions & 3 deletions lib/release/release-please.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const assert = require('assert')
const core = require('@actions/core')
const omit = require('just-omit')
const ChangelogNotes = require('./changelog.js')
const NodeWorkspace = require('./node-workspace.js')
const NodeWorkspaceFormat = require('./node-workspace-format.js')
const { getPublishTag, noop } = require('./util.js')

Expand Down Expand Up @@ -69,8 +68,6 @@ class ReleasePlease {
new ChangelogNotes(github, o))
RP.registerVersioningStrategy('default', (o) =>
o.prerelease ? new PrereleaseVersioningStrategy(o) : new DefaultVersioningStrategy(o))
RP.registerPlugin('node-workspace', ({ github, targetBranch, repositoryConfig, ...o }) =>
new NodeWorkspace(github, targetBranch, repositoryConfig, o))
RP.registerPlugin('node-workspace-format', ({ github, targetBranch, repositoryConfig, ...o }) =>
new NodeWorkspaceFormat(github, targetBranch, repositoryConfig, o))

Expand Down

0 comments on commit 8b2e738

Please sign in to comment.