{"version":3,"file":"index.mjs","sources":["../../src/utils/normaliseChangelog.ts","../../src/utils/versionPackage.ts","../../src/command.ts","../../src/handler.ts","../../src/utils/versionMonorepoPackages.ts"],"sourcesContent":["import { asyncExec, verboseLog } from '@repodog/cli-utils';\nimport { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\n\nexport const normaliseChangelog = async (devDependencies: Partial<Record<string, string>>): Promise<void> => {\n  const cwd = process.cwd();\n\n  if ('markdownlint-cli2' in devDependencies && existsSync(resolve(cwd, '.markdownlint.json'))) {\n    verboseLog('markdownlint dependency and config found, normalising Changelog file');\n    let changelog = readFileSync(resolve(cwd, 'CHANGELOG.md'), { encoding: 'utf8' });\n    changelog = changelog.replaceAll('#### ', '## ').replaceAll('##### ', '### ').replaceAll('# Changelog\\n\\n', '');\n    changelog = `# Changelog\\n\\n${changelog}`;\n    writeFileSync(resolve(cwd, 'CHANGELOG.md'), changelog, { encoding: 'utf8' });\n    await asyncExec(`markdownlint-cli2 ./CHANGELOG.md --config .markdownlint.json --fix`);\n  } else {\n    verboseLog('No markdownlint dependency or config found, skipping normalising Changelog file');\n  }\n};\n","import {\n  type ReleaseMeta,\n  getLatestPackageVersionOnNpm,\n  getNewVersion,\n  getPackageVersionsOnNpm,\n  verboseLog,\n} from '@repodog/cli-utils';\nimport { writeFileSync } from 'node:fs';\nimport { type PackageJson, type SetRequired } from 'type-fest';\n\nexport const versionPackage = (\n  packageJson: SetRequired<PackageJson, 'name' | 'version'>,\n  { packageJsonPath, preid, tag, type }: Pick<ReleaseMeta, 'packageJsonPath' | 'preid' | 'tag' | 'type'>,\n): void => {\n  const { name, version } = packageJson;\n  verboseLog(`Current version: ${version}`);\n  const newVersion = getNewVersion(version, type, tag, preid);\n\n  if (!newVersion) {\n    throw new Error(`The new package verison for a ${type} increment on ${version} is invalid`);\n  }\n\n  const latestNpmPackageVersion = getLatestPackageVersionOnNpm(name);\n  const packageVersionsOnNpm = getPackageVersionsOnNpm(name);\n  verboseLog(`New version: ${newVersion}`);\n  verboseLog(`Latest non-prerelease version on npm: ${latestNpmPackageVersion || 'None'}`);\n\n  if (packageVersionsOnNpm.includes(newVersion)) {\n    throw new Error(`The new ${name} package verison ${newVersion} is equal to a version on npm.`);\n  }\n\n  try {\n    verboseLog(`Outputting package.json with new version: ${newVersion}`);\n    writeFileSync(packageJsonPath, `${JSON.stringify({ ...packageJson, version: newVersion }, undefined, 2)}\\n`);\n  } catch (error: unknown) {\n    // catch arg has to be of type unknown, but in this context it will\n    // always be of type Error.\n    // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n    verboseLog(`Package.json output error: ${(error as Error).name}, ${(error as Error).message}`);\n    throw new Error(`Could not write the package.json to: ${packageJsonPath}`);\n  }\n};\n","import { type CommandBuilder } from 'yargs';\nimport { type CutHandlerArguments } from '#types.js';\n\nexport const builder: CommandBuilder<CutHandlerArguments, CutHandlerArguments> = argv =>\n  argv\n    .positional('type', {\n      demandOption: true,\n      desc: 'The release type: major | premajor | minor | preminor | patch | prepatch | prerelease | dry-run',\n      type: 'string',\n    })\n    .option('tag', {\n      desc: 'The release tag: alpha | beta | pr | unstable',\n      type: 'string',\n    })\n    .option('preid', {\n      desc: 'A unique identifier for the pre-release',\n      type: 'string',\n    })\n    .option('dry-run', {\n      desc: 'Stop job before versioning changes are committed',\n      type: 'boolean',\n    })\n    .option('filter', {\n      desc: 'A glob for filtering the packages the command is run against',\n      type: 'string',\n    })\n    .option('force', {\n      desc: 'Increment version regardless of files changed',\n      type: 'boolean',\n    })\n    .option('skip-posthook', {\n      desc: 'To skip post version lifecycle hook',\n      type: 'boolean',\n    })\n    .option('skip-prehook', {\n      desc: 'To skip pre version lifecycle hook',\n      type: 'boolean',\n    })\n    .option('skip-node-version-check', {\n      alias: 'snvc',\n      desc: 'To skip the node version check',\n      type: 'boolean',\n    })\n    .option('verbose', {\n      desc: 'Whether to output verbose logs',\n      type: 'boolean',\n    });\n\nexport const command = 'cut <type>';\nexport const desc = 'Cut release to current branch';\nexport { handler } from './handler.ts';\n","import {\n  PRE_RELEASE_TYPES,\n  type ReleaseTag,\n  VALID_RELEASE_TAGS,\n  VALID_RELEASE_TYPES,\n  addCommitPushRelease,\n  asyncExec,\n  calculateDuration,\n  clearDryRunFlag,\n  formatListLogMessage,\n  getChangedFiles,\n  getLastReleaseTag,\n  getNewVersion,\n  getPackageManager,\n  hasDryRunFlag,\n  haveFilesChanged,\n  isPreRelease,\n  isProjectMonorepo,\n  isValidReleaseTag,\n  isValidReleaseType,\n  loadPackageJson,\n  setDryRunFlag,\n  setVerbose,\n  verboseLog,\n} from '@repodog/cli-utils';\nimport colors from 'ansi-colors';\nimport { writeFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { performance } from 'node:perf_hooks';\nimport shelljs from 'shelljs';\nimport { type CutHandlerArguments } from './types.ts';\nimport { normaliseChangelog } from './utils/normaliseChangelog.ts';\nimport { versionMonorepoPackages } from './utils/versionMonorepoPackages.ts';\nimport { versionPackage } from './utils/versionPackage.ts';\n\nexport const handler = async (argv: CutHandlerArguments): Promise<void> => {\n  const startTime = performance.now();\n  const dryRun = argv['dry-run'] ?? false;\n  const filter = argv.filter;\n  const force = argv.force ?? false;\n  const skipPosthook = argv['skip-posthook'] ?? false;\n  const skipPrehook = argv['skip-prehook'] ?? false;\n  const verbose = argv.verbose ?? false;\n\n  setVerbose(verbose);\n  verboseLog('>>>> USER CONFIG START <<<<');\n  verboseLog(`dryRun: ${String(dryRun)}`);\n  verboseLog(`filter: ${filter ?? 'none'}`);\n  verboseLog(`force: ${String(force)}`);\n  verboseLog(`skipPosthook: ${String(skipPosthook)}`);\n  verboseLog(`skipPrehook: ${String(skipPrehook)}`);\n  verboseLog(`tag: ${argv.tag ?? 'undefined'}`);\n  verboseLog(`type: ${argv.type}`);\n  verboseLog('>>>> USER CONFIG END <<<<\\n');\n\n  const cwd = process.cwd();\n  verboseLog(`cwd: ${cwd}`);\n\n  try {\n    const packageJsonPath = resolve(cwd, 'package.json');\n    const packageJson = loadPackageJson(packageJsonPath);\n\n    if (hasDryRunFlag()) {\n      verboseLog('__activeDryRun flag found in .repodogrc');\n\n      if (argv.type !== 'dry-run') {\n        throw new Error(`Expected type to be dry-run as __activeDryRun is set to true in .repodogrc. Cut a release from\n          the existing dry-run output by re-running the cut command with a type of \"dry-run\" or delete the output and\n          re-run the cut command with another type\n        `);\n      }\n\n      verboseLog(`Adding, committing and pushing new version: ${packageJson.version}`);\n      clearDryRunFlag();\n      await addCommitPushRelease(packageJson.version);\n      verboseLog('>>>> PROJECT ROOT END <<<<\\n');\n      return shelljs.exit(0);\n    }\n\n    if (!isValidReleaseType(argv.type)) {\n      throw new Error(`Expected type to be a valid release type: ${VALID_RELEASE_TYPES.join(', ')}`);\n    }\n\n    if (argv.tag) {\n      if (!isValidReleaseTag(argv.tag)) {\n        throw new Error(`Expected tag to be a valid release tag: ${VALID_RELEASE_TAGS.join(', ')}`);\n      }\n\n      if (!isPreRelease(argv.type)) {\n        throw new Error(`Expected type to be pre release type: ${PRE_RELEASE_TYPES.join(', ')}`);\n      }\n    }\n\n    const preid = argv.preid;\n    // yargs types tag as a string, but it has to be a ReleaseTag or undefined.\n    // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n    const tag = argv.tag as ReleaseTag | undefined;\n    const type = argv.type;\n    const packageManager = getPackageManager();\n\n    if (!packageManager) {\n      throw new Error('Could not derive the package manager from the lock file in the current working directory');\n    }\n\n    const lastReleaseTag = getLastReleaseTag();\n    verboseLog('>>>> DERIVED VALUES START <<<<');\n    verboseLog(`Package manager: ${packageManager}`);\n    verboseLog(`Last release tag: ${lastReleaseTag}`);\n    const filesChanged = haveFilesChanged(lastReleaseTag);\n\n    if (lastReleaseTag && !force && !filesChanged) {\n      throw new Error(`No files have changed since the last release tag: ${lastReleaseTag}`);\n    }\n\n    verboseLog(`Have files changed: ${String(filesChanged)}`);\n    verboseLog('>>>> DERIVED VALUES END <<<<\\n');\n    verboseLog('>>>> PROJECT ROOT START <<<<');\n    const { devDependencies = {}, scripts = {}, version } = packageJson;\n\n    if (!skipPrehook && scripts['cut:pre-version']) {\n      verboseLog(`Running cut:pre-version script: ${scripts['cut:pre-version']}\\n`);\n      await asyncExec(`${packageManager} run cut:pre-version`);\n      shelljs.echo('\\n');\n    } else if (skipPrehook && scripts['cut:pre-version']) {\n      verboseLog(`cut:pre-version script skipped, skipPrehook set to true`);\n    } else {\n      verboseLog(`cut:pre-version script not provided`);\n    }\n\n    if (isProjectMonorepo(packageManager)) {\n      verboseLog('Project is monorepo');\n      versionMonorepoPackages({ filter, force, packageManager, preid, tag, type });\n      verboseLog('>>>> PROJECT ROOT STARTS <<<<\\n');\n    } else {\n      verboseLog('Project is standard repo structure');\n      const changedFiles = getChangedFiles(lastReleaseTag);\n      verboseLog(formatListLogMessage('Project changed files', changedFiles));\n\n      versionPackage(packageJson, {\n        packageJsonPath,\n        preid,\n        tag,\n        type,\n      });\n    }\n\n    if (!skipPosthook && scripts['cut:post-version']) {\n      verboseLog(`Running cut:post-version script: ${scripts['cut:post-version']}\\n`);\n      await asyncExec(`${packageManager} run cut:post-version`);\n      shelljs.echo('\\n');\n    } else if (skipPosthook && scripts['cut:post-version']) {\n      verboseLog(`cut:post-version skipped, skipPosthook set to true`);\n    } else {\n      verboseLog(`cut:post-version script not provided`);\n    }\n\n    const newVersion = getNewVersion(version, type, tag, preid);\n\n    if (!newVersion) {\n      throw new Error(`The new project verison for a ${type} increment on ${version} is invalid`);\n    }\n\n    verboseLog(`Release new version: ${newVersion}`);\n\n    if (isProjectMonorepo(packageManager)) {\n      try {\n        verboseLog(`Outputting project packageJson with new version: ${newVersion}`);\n        writeFileSync(packageJsonPath, JSON.stringify({ ...packageJson, version: newVersion }, undefined, 2));\n      } catch (error: unknown) {\n        // catch arg has to be of type unknown, but in this context it will\n        // always be of type Error.\n        // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n        verboseLog(`Package.json output error: ${(error as Error).name}, ${(error as Error).message}`);\n        throw new Error(`Could not write the package.json to: ${packageJsonPath}`);\n      }\n    }\n\n    if (scripts['cut:changelog']) {\n      verboseLog(`Generating changelog for ${type} release`);\n      await asyncExec(`${packageManager} run cut:changelog -- --${type} --version ${newVersion}`);\n      await normaliseChangelog(devDependencies);\n    }\n\n    if (dryRun) {\n      verboseLog('Exiting process as dry-run set to true');\n      verboseLog(`Handler duration: ${String(calculateDuration(startTime))}sec`);\n      verboseLog('>>>> PROJECT ROOT END <<<<\\n');\n      setDryRunFlag();\n      return shelljs.exit(0);\n    }\n\n    verboseLog(`Adding, committing and pushing new version: ${newVersion}`);\n    await addCommitPushRelease(newVersion);\n    verboseLog(`Handler duration: ${String(calculateDuration(startTime))}sec`);\n    verboseLog('>>>> PROJECT ROOT END <<<<\\n');\n    return shelljs.exit(0);\n  } catch (error: unknown) {\n    shelljs.echo(\n      // catch arg has to be of type unknown, but in this context it will\n      // always be of type Error.\n      // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n      `${colors.magenta('Repodog')} ${colors.dim('=>')} ${colors.red(`Error: ${(error as Error).message}`)}`,\n    );\n\n    verboseLog(`Handler duration: ${String(calculateDuration(startTime))}sec`);\n    verboseLog('>>>> PROJECT ROOT END <<<<\\n');\n    return shelljs.exit(1);\n  }\n};\n","import {\n  type ReleaseMeta,\n  formatListLogMessage,\n  getChangedFiles,\n  getInternalDependencies,\n  getLastReleaseTag,\n  getMonorepoPackageMeta,\n  loadPackageJson,\n  verboseLog,\n} from '@repodog/cli-utils';\nimport colors from 'ansi-colors';\nimport { parse, sep } from 'node:path';\nimport shelljs from 'shelljs';\nimport { versionPackage } from './versionPackage.ts';\n\nexport const versionMonorepoPackages = ({\n  filter,\n  force,\n  packageManager,\n  preid,\n  tag,\n  type,\n}: Pick<ReleaseMeta, 'filter' | 'force' | 'packageManager' | 'preid' | 'tag' | 'type'>): void => {\n  const packageMetaRecord = getMonorepoPackageMeta(packageManager, { filter });\n  const lastReleaseTag = getLastReleaseTag();\n  const changedFiles = getChangedFiles(lastReleaseTag);\n  const cwd = process.cwd();\n  verboseLog(formatListLogMessage('Project changed files', changedFiles));\n  verboseLog(`Project last release tag: ${lastReleaseTag}`);\n  verboseLog('Versioning monorepo packages');\n  verboseLog('>>>> PROJECT ROOT END <<<<\\n');\n  const packageMetaKeys = Object.keys(packageMetaRecord);\n\n  for (let index = packageMetaKeys.length - 1; index >= 0; index -= 1) {\n    verboseLog('>>>> PACKAGE START <<<<');\n    // We know packageMetaKeys[index] cannot be undefined.\n    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n    const packageMetaKey = packageMetaKeys[index]!;\n    // We know packageMetaRecord[packageMetaKey] cannot be undefined.\n    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n    const packageMeta = packageMetaRecord[packageMetaKey]!;\n\n    try {\n      const packageJson = loadPackageJson(packageMeta.path);\n      const { name } = packageJson;\n      verboseLog(`Checking package: ${name}`);\n      const internalDependencies = getInternalDependencies(packageJson, packageMetaRecord);\n\n      if (internalDependencies.some(dep => !packageMetaRecord[dep]?.checked)) {\n        verboseLog('Not all internal dependencies have been checked, pushing to back of queue\\n');\n        packageMetaKeys.unshift(name);\n        index += 1;\n        continue;\n      }\n\n      packageMeta.checked = true;\n      packageMeta.force = internalDependencies.some(dep => !!packageMetaRecord[dep]?.versioned);\n      const { dir } = parse(packageMeta.path);\n      let relativeDirectory = dir.replace(cwd, '');\n\n      if (relativeDirectory.startsWith(sep)) {\n        relativeDirectory = relativeDirectory.slice(1);\n      }\n\n      verboseLog(`Relative dir: ${relativeDirectory}`);\n\n      if (changedFiles.every(file => !file.includes(relativeDirectory))) {\n        verboseLog(`No files have changed since the last release tag: ${lastReleaseTag}`);\n\n        if (!force && !packageMeta.force) {\n          verboseLog('>>>> PACKAGE END <<<<\\n');\n          continue;\n        }\n\n        if (force) {\n          verboseLog('Force is set to true, proceeding regardless of file changes');\n        } else if (packageMeta.force) {\n          verboseLog('Package has an internal dependency with file changes');\n        }\n      }\n\n      const packageChangedFiles = changedFiles.filter(file => file.includes(relativeDirectory));\n\n      if (packageChangedFiles.length > 0) {\n        verboseLog(formatListLogMessage(`Package changed files`, packageChangedFiles));\n      }\n\n      verboseLog(`Versioning package: ${name}`);\n\n      versionPackage(packageJson, {\n        packageJsonPath: packageMeta.path,\n        preid,\n        tag,\n        type,\n      });\n\n      packageMeta.versioned = true;\n      verboseLog('>>>> PACKAGE END <<<<\\n');\n    } catch (error: unknown) {\n      shelljs.echo(\n        // catch arg has to be of type unknown, but in this context it will\n        // always be of type Error.\n        // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n        `${colors.magenta('Repodog')} ${colors.dim('=>')} ${colors.red(`Error: ${(error as Error).message}`)}`,\n      );\n\n      verboseLog('>>>> PACKAGE END <<<<\\n');\n    } finally {\n      packageMetaKeys.splice(index, 1);\n    }\n  }\n};\n"],"names":["versionPackage","packageJson","packageJsonPath","preid","tag","type","name","version","verboseLog","newVersion","getNewVersion","Error","latestNpmPackageVersion","getLatestPackageVersionOnNpm","packageVersionsOnNpm","getPackageVersionsOnNpm","includes","writeFileSync","JSON","stringify","undefined","error","message","argv","positional","demandOption","desc","option","alias","async","startTime","performance","now","dryRun","filter","force","skipPosthook","skipPrehook","verbose","setVerbose","String","cwd","process","resolve","loadPackageJson","hasDryRunFlag","clearDryRunFlag","addCommitPushRelease","shelljs","exit","isValidReleaseType","VALID_RELEASE_TYPES","join","isValidReleaseTag","VALID_RELEASE_TAGS","isPreRelease","PRE_RELEASE_TYPES","packageManager","getPackageManager","lastReleaseTag","getLastReleaseTag","filesChanged","haveFilesChanged","devDependencies","scripts","asyncExec","echo","isProjectMonorepo","packageMetaRecord","getMonorepoPackageMeta","changedFiles","getChangedFiles","formatListLogMessage","packageMetaKeys","Object","keys","index","length","packageMetaKey","packageMeta","path","internalDependencies","getInternalDependencies","some","dep","checked","unshift","versioned","dir","parse","relativeDirectory","replace","startsWith","sep","slice","every","file","packageChangedFiles","colors","magenta","dim","red","splice","versionMonorepoPackages","existsSync","changelog","readFileSync","encoding","replaceAll","normaliseChangelog","calculateDuration","setDryRunFlag"],"mappings":"g1BAIO,MCMMA,EAAiB,CAC5BC,GACEC,kBAAiBC,QAAOC,MAAKC,WAE/B,MAAMC,KAAEA,EAAIC,QAAEA,GAAYN,EAC1BO,EAAW,oBAAoBD,KAC/B,MAAME,EAAaC,EAAcH,EAASF,EAAMD,EAAKD,GAErD,IAAKM,EACH,MAAM,IAAIE,MAAM,iCAAiCN,kBAAqBE,gBAGxE,MAAMK,EAA0BC,EAA6BP,GACvDQ,EAAuBC,EAAwBT,GAIrD,GAHAE,EAAW,gBAAgBC,KAC3BD,EAAW,yCAAyCI,GAA2B,UAE3EE,EAAqBE,SAASP,GAChC,MAAM,IAAIE,MAAM,WAAWL,qBAAwBG,mCAGrD,IACED,EAAW,6CAA6CC,KACxDQ,EAAcf,EAAiB,GAAGgB,KAAKC,UAAU,IAAKlB,EAAaM,QAASE,QAAcW,EAAW,OACvG,CAAE,MAAOC,GAKP,MADAb,EAAW,8BAA+Ba,EAAgBf,SAAUe,EAAgBC,WAC9E,IAAIX,MAAM,wCAAwCT,IAC1D,+CCrC+EqB,GAC/EA,EACGC,WAAW,OAAQ,CAClBC,cAAc,EACdC,KAAM,kGACNrB,KAAM,WAEPsB,OAAO,MAAO,CACbD,KAAM,gDACNrB,KAAM,WAEPsB,OAAO,QAAS,CACfD,KAAM,0CACNrB,KAAM,WAEPsB,OAAO,UAAW,CACjBD,KAAM,mDACNrB,KAAM,YAEPsB,OAAO,SAAU,CAChBD,KAAM,+DACNrB,KAAM,WAEPsB,OAAO,QAAS,CACfD,KAAM,gDACNrB,KAAM,YAEPsB,OAAO,gBAAiB,CACvBD,KAAM,sCACNrB,KAAM,YAEPsB,OAAO,eAAgB,CACtBD,KAAM,qCACNrB,KAAM,YAEPsB,OAAO,0BAA2B,CACjCC,MAAO,OACPF,KAAM,iCACNrB,KAAM,YAEPsB,OAAO,UAAW,CACjBD,KAAM,iCACNrB,KAAM,oB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