MCPcopy Index your code
hub / github.com/adobe/react-spectrum / addReleasedPackage

Method addReleasedPackage

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

Source from the content-addressed store, hash-verified

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