MCPcopy
hub / github.com/vuejs/core / publishPackage

Function publishPackage

scripts/release.js:439–489  ·  view source on GitHub ↗

* @param {string} pkgName * @param {string} version * @param {ReadonlyArray<string>} additionalFlags

(pkgName, version, additionalFlags)

Source from the content-addressed store, hash-verified

437 * @param {ReadonlyArray<string>} additionalFlags
438 */
439async function publishPackage(pkgName, version, additionalFlags) {
440 const packageName = getPkgManifest(pkgName).name
441
442 let releaseTag = null
443 if (args.tag) {
444 releaseTag = args.tag
445 } else if (version.includes('alpha')) {
446 releaseTag = 'alpha'
447 } else if (version.includes('beta')) {
448 releaseTag = 'beta'
449 } else if (version.includes('rc')) {
450 releaseTag = 'rc'
451 }
452
453 if (!isDryRun && (await isPackagePublished(packageName, version))) {
454 const pkgVersion = `${packageName}@${version}`
455 console.log(pico.yellow(`Skipping already published: ${pkgVersion}`))
456 alreadyPublishedPackages.push(pkgVersion)
457 return
458 }
459
460 step(`Publishing ${packageName}...`)
461 try {
462 // Don't change the package manager here as we rely on pnpm to handle
463 // workspace:* deps
464 await run(
465 'pnpm',
466 [
467 'publish',
468 ...(releaseTag ? ['--tag', releaseTag] : []),
469 '--access',
470 'public',
471 ...(args.registry ? ['--registry', args.registry] : []),
472 ...additionalFlags,
473 ],
474 {
475 cwd: getPkgRoot(pkgName),
476 stdio: 'pipe',
477 },
478 )
479 console.log(pico.green(`Successfully published ${packageName}@${version}`))
480 } catch (/** @type {any} */ e) {
481 if (e.message?.match(/previously published/)) {
482 const pkgVersion = `${packageName}@${version}`
483 console.log(pico.red(`Skipping already published: ${pkgVersion}`))
484 alreadyPublishedPackages.push(pkgVersion)
485 } else {
486 throw e
487 }
488 }
489}
490
491async function isPackagePublished(
492 /** @type {string} */ packageName,

Callers 1

publishPackagesFunction · 0.85

Calls 6

getPkgManifestFunction · 0.85
isPackagePublishedFunction · 0.85
stepFunction · 0.85
getPkgRootFunction · 0.85
runFunction · 0.70
pushMethod · 0.65

Tested by

no test coverage detected