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
  9797ceff_6b01_5793_df1c_703211bf1f43["main()"]
  f4fd1db5_c19d_9eca_26c6_3ec2e8727f78["inc()"]
  9797ceff_6b01_5793_df1c_703211bf1f43 -->|calls| f4fd1db5_c19d_9eca_26c6_3ec2e8727f78
  3ec13699_f292_f51d_de06_ed5cc90ff63e["step()"]
  9797ceff_6b01_5793_df1c_703211bf1f43 -->|calls| 3ec13699_f292_f51d_de06_ed5cc90ff63e
  2217cdcb_cc5b_fb20_aad5_9b0de4e45d66["run()"]
  9797ceff_6b01_5793_df1c_703211bf1f43 -->|calls| 2217cdcb_cc5b_fb20_aad5_9b0de4e45d66
  c2535345_4cee_9ec9_4e5e_3a09ff161cac["updatePackage()"]
  9797ceff_6b01_5793_df1c_703211bf1f43 -->|calls| c2535345_4cee_9ec9_4e5e_3a09ff161cac
  56a36a8e_348d_8a6c_fe22_109141d8b264["getPkgRoot()"]
  9797ceff_6b01_5793_df1c_703211bf1f43 -->|calls| 56a36a8e_348d_8a6c_fe22_109141d8b264
  4966327d_52f6_e756_ab8d_6813a6a45a44["publishPackage()"]
  9797ceff_6b01_5793_df1c_703211bf1f43 -->|calls| 4966327d_52f6_e756_ab8d_6813a6a45a44
  style 9797ceff_6b01_5793_df1c_703211bf1f43 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