MCPcopy
hub / github.com/prisma/prisma / publish

Function publish

scripts/ci/publish.ts:459–634  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

457
458// TODO: name this to main
459async function publish() {
460 const args = arg({
461 '--publish': Boolean,
462 '--dry-run': Boolean,
463 '--release': String, // TODO What does that do? Can we remove this? probably
464 '--test': Boolean,
465 '--custom-dist-tag': String,
466 })
467
468 if (!process.env.GITHUB_REF_NAME) {
469 throw new Error(`Missing env var GITHUB_REF_NAME`)
470 }
471
472 if (process.env.DRY_RUN === 'true') {
473 console.log(blue(bold(`\nThe DRY_RUN env var is set, so we'll do a dry run!\n`)))
474 args['--dry-run'] = true
475 }
476
477 const dryRun = args['--dry-run'] ?? false
478
479 if (args['--publish'] && process.env.RELEASE_VERSION) {
480 if (args['--release']) {
481 throw new Error(`Can't provide env var RELEASE_VERSION and --release at the same time`)
482 }
483
484 console.log(`Setting --release to RELEASE_VERSION = ${process.env.RELEASE_VERSION}`)
485 args['--release'] = process.env.RELEASE_VERSION
486 // TODO: put this into a global variable VERSION
487 // and then replace the args['--release'] with it
488 }
489
490 if (process.env.CUSTOM_DIST_TAG) {
491 args['--custom-dist-tag'] = process.env.CUSTOM_DIST_TAG
492 }
493
494 if (!args['--test'] && !args['--publish'] && !dryRun) {
495 throw new Error('Please either provide --test or --publish or --dry-run')
496 }
497
498 if (args['--release']) {
499 if (!semver.valid(args['--release'])) {
500 throw new Error(`New release version ${bold(underline(args['--release']))} is not a valid semver version.`)
501 }
502
503 // TODO: this can probably be replaced by semver lib
504 const releaseRegex = /\d{1,2}\.\d{1,2}\.\d{1,2}/
505 if (!releaseRegex.test(args['--release'])) {
506 throw new Error(
507 `New release version ${bold(underline(args['--release']))} does not follow the stable naming scheme: ${bold(
508 underline('x.y.z'),
509 )}`,
510 )
511 }
512
513 // If there is --release, it's always also --publish
514 args['--publish'] = true
515 }
516

Callers 1

publish.tsFile · 0.85

Calls 15

argFunction · 0.85
getPackagesFunction · 0.85
getPackageDependenciesFunction · 0.85
getCircularDependenciesFunction · 0.85
getPatchBranchFunction · 0.85
getPrismaBranchFunction · 0.85
getNewIntegrationVersionFunction · 0.85
getNewPatchDevVersionFunction · 0.85
getNewDevVersionFunction · 0.85
testPackagesFunction · 0.85
getPublishOrderFunction · 0.85
areEcosystemTestsPassingFunction · 0.85

Tested by

no test coverage detected