MCPcopy
hub / github.com/formatjs/formatjs / BazelNpmWorkspace

Class BazelNpmWorkspace

tools/release-please/npm-workspace-plugin.ts:106–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106export class BazelNpmWorkspace extends WorkspacePlugin {
107 constructor(github, targetBranch, repositoryConfig, options = {}) {
108 super(github, targetBranch, repositoryConfig, options)
109 this.graphPath =
110 options.graphPath ||
111 process.env.FORMATJS_RELEASE_PLEASE_NPM_WORKSPACE_GRAPH
112 this.includePeerDependencies =
113 options.includePeerDependencies === true ||
114 process.env.FORMATJS_RELEASE_PLEASE_NPM_WORKSPACE_INCLUDE_PEERS === 'true'
115 this.strategiesByPath = {}
116 this.releasesByPath = {}
117 this.candidatePaths = new Set()
118 }
119
120 async run(candidates) {
121 this.candidatePaths = new Set(candidates.map(candidate => candidate.path))
122 return super.run(candidates)
123 }
124
125 async buildAllPackages(candidates) {
126 if (!this.graphPath) {
127 throw new Error(
128 'FORMATJS_RELEASE_PLEASE_NPM_WORKSPACE_GRAPH must point to the generated workspace graph'
129 )
130 }
131
132 const configuredPaths = Object.entries(this.repositoryConfig)
133 .filter(
134 ([path, config]) =>
135 path.startsWith('packages/') && config.releaseType === 'bazel'
136 )
137 .map(([path]) => path)
138 const packagesByPath = new Map()
139
140 for (const pkg of readGraph(this.graphPath).packages) {
141 if (packagesByPath.has(pkg.path)) {
142 throw new Error(`duplicate workspace package path: ${pkg.path}`)
143 }
144 packagesByPath.set(pkg.path, pkg)
145 }
146
147 const allPackages = configuredPaths.map(path => {
148 const pkg = packagesByPath.get(path)
149 if (!pkg) {
150 throw new Error(
151 `Release Please package ${path} is missing from ${this.graphPath}`
152 )
153 }
154 return pkg
155 })
156
157 const candidatesByPath = new Map(
158 candidates.map(candidate => [candidate.path, candidate])
159 )
160 const candidatesByPackage = {}
161
162 for (const candidate of candidates) {
163 if (!this.inScope(candidate)) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected