@biffo/cli 0.384.0 → 0.385.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +32 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -731,7 +731,8 @@ function checkCoreOwnership({
731
731
  commitMessage = "",
732
732
  warnOnly = [],
733
733
  templateShippedPaths = null,
734
- upgradeCommitFiles = null
734
+ upgradeCommitFiles = null,
735
+ firstCommitIsUpgrade = false
735
736
  }) {
736
737
  const empty = {
737
738
  blocked: [],
@@ -742,7 +743,7 @@ function checkCoreOwnership({
742
743
  };
743
744
  if (!isInstance) return { skipped: "template", ...empty };
744
745
  let effectiveChangedFiles = changedFiles;
745
- if (branch.startsWith(UPGRADE_BRANCH_PREFIX)) {
746
+ if (branch.startsWith(UPGRADE_BRANCH_PREFIX) || firstCommitIsUpgrade) {
746
747
  const exempt = new Set(upgradeCommitFiles ?? []);
747
748
  effectiveChangedFiles = changedFiles.filter((f) => !exempt.has(f));
748
749
  if (effectiveChangedFiles.length === 0) return { skipped: "upgrade-branch", ...empty };
@@ -4056,7 +4057,10 @@ var coreUpgradeCommand = new Command3("upgrade").description("Three-way-merge te
4056
4057
  ).option(
4057
4058
  "--allow-dirty",
4058
4059
  "Compute the plan even with uncommitted changes in the instance tree (they become part of the merge)"
4059
- ).option("--base <branch>", "Base branch for the PR (defaults to the repo\u2019s default branch)").option("--remote <name>", "Git remote to push to and open the PR on (default: origin)").option(
4060
+ ).option("--base <branch>", "Base branch for the PR (defaults to the repo\u2019s default branch)").option(
4061
+ "--no-push",
4062
+ "With --apply, stop after the local commit and dependency install: no push, no PR, no GitHub token needed"
4063
+ ).option("--remote <name>", "Git remote to push to and open the PR on (default: origin)").option(
4060
4064
  "--reap",
4061
4065
  "Delete local branches previous upgrade runs left behind, once their PR has merged (#758)"
4062
4066
  ).action(
@@ -4077,6 +4081,7 @@ var coreUpgradeCommand = new Command3("upgrade").description("Three-way-merge te
4077
4081
  if (options.toTemplate) runOptions.theirsDir = resolve4(options.toTemplate);
4078
4082
  if (options.base) runOptions.base = options.base;
4079
4083
  if (options.remote) runOptions.remote = options.remote;
4084
+ if (options.push === false) runOptions.noPush = true;
4080
4085
  if (options.reap) runOptions.reap = true;
4081
4086
  await runCoreUpgrade(runOptions);
4082
4087
  } catch (err) {
@@ -4322,7 +4327,7 @@ async function applyAndOpenPr(options, deps, plan, migrations, fromVersion, toVe
4322
4327
  );
4323
4328
  }
4324
4329
  const { git } = deps;
4325
- const token = deps.resolveToken();
4330
+ const token = options.noPush ? "" : deps.resolveToken();
4326
4331
  if (!await git.isGitRepo(options.cwd)) {
4327
4332
  throw new Error(`${options.cwd} is not a git repository.`);
4328
4333
  }
@@ -4414,6 +4419,12 @@ async function buildCommitAndOpenPr(options, deps, plan, migrations, fromVersion
4414
4419
  const installOutcomes = await installInstanceDependencies(options.cwd, run);
4415
4420
  const installFailures = describeInstallFailures(installOutcomes);
4416
4421
  for (const message of installFailures) log.warn(message);
4422
+ if (options.noPush) {
4423
+ log.success(
4424
+ `Committed the upgrade on ${branch}; --no-push, so nothing was pushed and no PR was opened.`
4425
+ );
4426
+ return;
4427
+ }
4417
4428
  log.step(3, 4, `Pushing ${branch}`);
4418
4429
  const pushOpts = { token };
4419
4430
  if (options.remote) pushOpts.remote = options.remote;
@@ -14659,6 +14670,20 @@ async function resolveUpgradeCommitFiles(repoRoot, base, opts = {}, runner = def
14659
14670
  if (diff.exitCode !== 0) return null;
14660
14671
  return splitLines(diff.stdout);
14661
14672
  }
14673
+ var UPGRADE_COMMIT_SUBJECT = /^chore\(core\): upgrade template core \d+\.\d+\.\d+ -> \d+\.\d+\.\d+$/;
14674
+ async function firstCommitIsCliUpgrade(repoRoot, base, runner = defaultRunner2) {
14675
+ try {
14676
+ const rev = await runner(["rev-list", "--reverse", `${base}..HEAD`], repoRoot);
14677
+ if (rev.exitCode !== 0) return false;
14678
+ const first = splitLines(rev.stdout)[0];
14679
+ if (!first) return false;
14680
+ const msg = await runner(["log", "-1", "--format=%s", first], repoRoot);
14681
+ if (msg.exitCode !== 0) return false;
14682
+ return UPGRADE_COMMIT_SUBJECT.test(msg.stdout.trim());
14683
+ } catch {
14684
+ return false;
14685
+ }
14686
+ }
14662
14687
 
14663
14688
  // src/scripts/check-core-ownership.ts
14664
14689
  var LOCAL_UPGRADE_BASE = "origin/dev";
@@ -14718,7 +14743,8 @@ async function runOwnershipCheck(argv) {
14718
14743
  reject: false
14719
14744
  });
14720
14745
  const branch = resolveBranch(process.env, gitBranch);
14721
- const upgradeCommitFiles = branch.startsWith(UPGRADE_BRANCH_PREFIX) ? await resolveUpgradeCommitFiles(
14746
+ const firstCommitIsUpgrade = !staged && !branch.startsWith(UPGRADE_BRANCH_PREFIX) && ciBase !== null ? await firstCommitIsCliUpgrade(root, ciBase) : false;
14747
+ const upgradeCommitFiles = branch.startsWith(UPGRADE_BRANCH_PREFIX) || firstCommitIsUpgrade ? await resolveUpgradeCommitFiles(
14722
14748
  root,
14723
14749
  ciBase ?? LOCAL_UPGRADE_BASE,
14724
14750
  staged ? { stagedFallbackFiles: changedFiles } : {}
@@ -14737,6 +14763,7 @@ async function runOwnershipCheck(argv) {
14737
14763
  commitMessage,
14738
14764
  warnOnly: readDivergenceConfig(root).warnOnly,
14739
14765
  upgradeCommitFiles,
14766
+ firstCommitIsUpgrade,
14740
14767
  templateShippedPaths
14741
14768
  });
14742
14769
  if (result.knownOrphans.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biffo/cli",
3
- "version": "0.384.0",
3
+ "version": "0.385.0",
4
4
  "description": "Biffo project scaffolding CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",