MCPcopy Create free account
hub / github.com/adobe/react-spectrum / addReleasedPackage

Method addReleasedPackage

scripts/bumpVersions.js:312–379  ·  view source on GitHub ↗
(pkg, bump, isDep = false)

Source from the content-addressed store, hash-verified

310 }
311
312 addReleasedPackage(pkg, bump, isDep = false) {
313 bump = this.versionBumps[pkg] || bump;
314 if (excludedPackages.has(pkg) || bump === 'unpublished' || bump === 'unchanged') {
315 return;
316 }
317
318 let p = JSON.parse(
319 fs.readFileSync(this.workspacePackages[pkg].location + '/package.json', 'utf8')
320 );
321 if (isSkipped(p)) {
322 return;
323 }
324
325 let status = bump === 'alpha' || bump === 'beta' || bump === 'rc' ? bump : 'released';
326
327 if (this.releasedPackages.has(pkg)) {
328 let cur = this.releasedPackages.get(pkg);
329 if (!isDep || levels[status] > levels[cur.status]) {
330 cur.status = status;
331 cur.bump = bump;
332 } else {
333 status = cur.status;
334 bump = cur.bump;
335 }
336 } else {
337 this.releasedPackages.set(pkg, {
338 location: this.workspacePackages[pkg].location,
339 status,
340 bump
341 });
342 }
343
344 // Bump anything that depends on this package if it's a prerelease
345 // because dependencies will be pinned rather than caret ranges.
346 // Bump anything that has this as a dep by a patch, all the way up the tree
347 for (let p in this.workspacePackages) {
348 if (this.releasedPackages.has(p)) {
349 continue;
350 }
351
352 if (this.workspacePackages[p].workspaceDependencies.includes(pkg)) {
353 let filePath = this.workspacePackages[p].location + '/package.json';
354 let pkg = JSON.parse(fs.readFileSync(filePath, 'utf8'));
355 let prerelease = semver.parse(pkg.version).prerelease;
356 let b = prerelease.length === 0 ? 'patch' : prerelease[0];
357 if (this.existingPackages.has(p) && status !== 'released') {
358 // Bump a patch version of the dependent package if it's not also a prerelease.
359 // Otherwise, bump to the next prerelease in the existing status.
360 this.addReleasedPackage(p, b, true);
361 } else if (this.existingPackages.has(p) && status === 'released') {
362 this.addReleasedPackage(p, b);
363 }
364 }
365 }
366
367 // Ensure all dependencies of this package are published and up to date
368 for (let dep of this.workspacePackages[pkg].workspaceDependencies) {
369 if (!this.existingPackages.has(dep) || this.changedPackages.has(dep)) {

Callers 1

runMethod · 0.95

Calls 4

isSkippedFunction · 0.85
hasMethod · 0.65
parseMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected