Home / Function/ main() — vue Function Reference

main() — vue Function Reference

Architecture documentation for the main() function in release.js from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  9a96ed4f_371f_b87a_07a5_c18292a63bd9["main()"]
  db277724_ae75_7da2_8282_8beeab456f7a["inc()"]
  9a96ed4f_371f_b87a_07a5_c18292a63bd9 -->|calls| db277724_ae75_7da2_8282_8beeab456f7a
  5a95fd30_9068_5210_3e72_0d0bdbbcd0b4["step()"]
  9a96ed4f_371f_b87a_07a5_c18292a63bd9 -->|calls| 5a95fd30_9068_5210_3e72_0d0bdbbcd0b4
  a1d42cb2_e5dc_31f1_ec75_6912d10e5a95["run()"]
  9a96ed4f_371f_b87a_07a5_c18292a63bd9 -->|calls| a1d42cb2_e5dc_31f1_ec75_6912d10e5a95
  ce1a7e5b_2ad9_7bfb_26ad_f05e14220bc6["updatePackage()"]
  9a96ed4f_371f_b87a_07a5_c18292a63bd9 -->|calls| ce1a7e5b_2ad9_7bfb_26ad_f05e14220bc6
  51ec8d40_40ae_8e0e_7094_47d79093d233["getPkgRoot()"]
  9a96ed4f_371f_b87a_07a5_c18292a63bd9 -->|calls| 51ec8d40_40ae_8e0e_7094_47d79093d233
  145c49ec_8959_074d_28c5_c1f201a6c02c["publishPackage()"]
  9a96ed4f_371f_b87a_07a5_c18292a63bd9 -->|calls| 145c49ec_8959_074d_28c5_c1f201a6c02c
  style 9a96ed4f_371f_b87a_07a5_c18292a63bd9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/release.js lines 36–132

async function main() {
  let targetVersion = args._[0]

  if (!targetVersion) {
    // no explicit version, offer suggestions
    const { release } = await prompt({
      type: 'select',
      name: 'release',
      message: 'Select release type',
      choices: versionIncrements.map(i => `${i} (${inc(i)})`).concat(['custom'])
    })

    if (release === 'custom') {
      targetVersion = (
        await prompt({
          type: 'input',
          name: 'version',
          message: 'Input custom version',
          initial: currentVersion
        })
      ).version
    } else {
      targetVersion = release.match(/\((.*)\)/)[1]
    }
  }

  if (!semver.valid(targetVersion)) {
    throw new Error(`invalid target version: ${targetVersion}`)
  }

  const { yes } = await prompt({
    type: 'confirm',
    name: 'yes',
    message: `Releasing v${targetVersion}. Confirm?`
  })

  if (!yes) {
    return
  }

  // run tests before release
  step('\nRunning tests...')
  if (!skipTests && !isDryRun) {
    await run('pnpm', ['test'])
  } else {
    console.log(`(skipped)`)
  }

  // update all package versions and inter-dependencies
  step('\nUpdating package versions...')
  packages.forEach(p => updatePackage(getPkgRoot(p), targetVersion))

  // build all packages with types
  step('\nBuilding all packages...')
  if (!skipBuild && !isDryRun) {
    await run('pnpm', ['run', 'build'])
    if (skipTests) {
      await run('pnpm', ['run', 'build:types'])
    }
  } else {
    console.log(`(skipped)`)
  }

  // generate changelog
  step('\nGenerating changelog...')
  await run(`pnpm`, ['run', 'changelog'])

  // update pnpm-lock.yaml
  step('\nUpdating lockfile...')
  await run(`pnpm`, ['install', '--prefer-offline'])

  const { stdout } = await run('git', ['diff'], { stdio: 'pipe' })
  if (stdout) {
    step('\nCommitting changes...')
    await runIfNotDry('git', ['add', '-A'])
    await runIfNotDry('git', ['commit', '-m', `release: v${targetVersion}`])
  } else {
    console.log('No changes to commit.')
  }

  // publish packages
  step('\nPublishing packages...')
  for (const pkg of packages) {
    await publishPackage(pkg, targetVersion, runIfNotDry)
  }

  // push to GitHub
  step('\nPushing to GitHub...')
  await runIfNotDry('git', ['tag', `v${targetVersion}`])
  await runIfNotDry('git', ['push', 'origin', `refs/tags/v${targetVersion}`])
  await runIfNotDry('git', ['push'])

  if (isDryRun) {
    console.log(`\nDry run finished - run git diff to see package changes.`)
  }
  console.log()
}

Domain

Subdomains

Frequently Asked Questions

What does main() do?
main() is a function in the vue codebase.
What does main() call?
main() calls 6 function(s): getPkgRoot, inc, publishPackage, run, step, updatePackage.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free