@cellajs/cli 0.1.0 → 0.2.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.
package/README.md CHANGED
@@ -79,16 +79,18 @@ pnpm cella sync --track branch # follow the tip once, without editing config
79
79
  main ──▶ cella/sync/<stamp> ──(3-way merge)──▶ PR ──(squash)──▶ main
80
80
  ```
81
81
 
82
- It runs a real git 3-way merge and leaves the result **staged** — it never auto-commits on the
83
- first pass. `sync` is **idempotent and two-phase**:
84
-
85
- 1. **First run** cuts the branch and stages the merge, then stops so you can review (and resolve
86
- any conflicts in your IDE — `git add` the resolved files).
87
- 2. **Re-run `pnpm cella sync`** on the same branch to finish: it reconciles dependencies
88
- (`pnpm install` + `pnpm check`), stages everything, commits the delta, pushes to `origin`,
82
+ It runs a real git 3-way merge. `sync` is **idempotent and staged**: each run advances the sync
83
+ one stage, and the run that commits never ships — the pause on the committed branch is where
84
+ drift triage (`pnpm cella analyze` diffs committed HEAD) and follow-up commits happen.
85
+
86
+ 1. **First run** cuts the branch and merges. A clean merge is committed right away: dependencies
87
+ are reconciled (`pnpm install` + `pnpm check`), everything is staged, and the delta is
88
+ committed — then the run stops on the branch. A conflicted merge stops earlier so you can
89
+ resolve in your IDE (`git add` the resolved files) and re-run to commit.
90
+ 2. **Final re-run `pnpm cella sync`** on the committed branch ships it: pushes to `origin`,
89
91
  opens a PR into `main` (via `gh`), and switches you back to `main`.
90
92
 
91
- When you commit, the in-progress merge state (`MERGE_HEAD`) is discarded, so the staged delta
93
+ When the commit stage runs, the in-progress merge state (`MERGE_HEAD`) is discarded, so the staged delta
92
94
  collapses into a **single-parent commit** (`chore: sync upstream cella <sha>`). This keeps the PR
93
95
  to one clean commit with the incremental diff — a two-parent merge commit would instead list the
94
96
  upstream branch's entire history, because the fork doesn't share pushed ancestry with upstream
package/dist/index.js CHANGED
@@ -97,11 +97,16 @@ var cellaConfigSchema = z.object({
97
97
 
98
98
  // src/utils/managed-files.ts
99
99
  var CONFIG_FILE = "cella/cella.config.ts";
100
+ var LEGACY_CONFIG_FILE = "cella.config.ts";
101
+ var CONFIG_FILE_PATHS = [CONFIG_FILE, LEGACY_CONFIG_FILE];
102
+ function isConfigFile(filePath) {
103
+ return CONFIG_FILE_PATHS.includes(filePath);
104
+ }
100
105
  function isPackageJson(filePath) {
101
106
  return filePath === "package.json" || filePath.endsWith("/package.json");
102
107
  }
103
108
  function isManagedFile(filePath) {
104
- return isPackageJson(filePath) || filePath === "pnpm-lock.yaml" || filePath === CONFIG_FILE;
109
+ return isPackageJson(filePath) || filePath === "pnpm-lock.yaml" || isConfigFile(filePath);
105
110
  }
106
111
 
107
112
  // src/utils/module-territory.ts
@@ -210,7 +215,7 @@ import process4 from "process";
210
215
  // package.json
211
216
  var package_default = {
212
217
  name: "@cellajs/cli",
213
- version: "0.1.0",
218
+ version: "0.2.0",
214
219
  private: false,
215
220
  license: "MIT",
216
221
  description: "CLI for managing your monorepo and syncing with upstream Cella.",
@@ -641,9 +646,7 @@ function printSyncComplete(result, options = {}) {
641
646
  if (options.stagedBranch) {
642
647
  console.info(`${colors_default.green("\u2713")} Sync merge staged on '${options.stagedBranch}'`);
643
648
  console.info(
644
- colors_default.dim(
645
- ` ${updated} files updated, ${merged} auto-merged, ${conflicts} conflicts. Review, then rerun \`pnpm cella sync\` to finish.`
646
- )
649
+ colors_default.dim(` ${updated} files updated, ${merged} auto-merged, ${conflicts} conflicts. Committing next...`)
647
650
  );
648
651
  } else {
649
652
  console.info(`${colors_default.green("\u2713")} sync complete`);
@@ -651,6 +654,30 @@ function printSyncComplete(result, options = {}) {
651
654
  }
652
655
  console.info();
653
656
  }
657
+ function findMaskingPins(files) {
658
+ return files.filter(
659
+ (file) => file.isPinned && file.status === "behind" && file.existsInFork && file.existsInUpstream
660
+ );
661
+ }
662
+ function printMaskingPinWarning(files) {
663
+ const masking = findMaskingPins(files);
664
+ if (masking.length === 0) return;
665
+ const many = masking.length > 1;
666
+ console.info();
667
+ console.info(
668
+ `${warningMark} ${colors_default.yellow(
669
+ `${masking.length} pinned ${many ? "files match" : "file matches"} the previous upstream but changed upstream \u2014`
670
+ )}`
671
+ );
672
+ console.info(colors_default.yellow(" the pin keeps the old fork copy and silently drops those upstream changes:"));
673
+ for (const file of masking) {
674
+ console.info(colors_default.dim(` \u2A00 ${file.path}`));
675
+ }
676
+ console.info(
677
+ colors_default.yellow(" If the fork never customized these, unpin them in cella/cella.config.ts to take upstream.")
678
+ );
679
+ console.info();
680
+ }
654
681
  function printFlagWarnings(options) {
655
682
  const { hard, unpinned } = options;
656
683
  if (!hard && !unpinned) return;
@@ -2294,6 +2321,7 @@ async function runAnalyze(config) {
2294
2321
  };
2295
2322
  printAnalysisFileGroups(result.files, linkOptions);
2296
2323
  printSummary(result.summary, "analysis summary");
2324
+ printMaskingPinWarning(result.files);
2297
2325
  if (config.logFile) {
2298
2326
  const logPath = writeLogFile(config.forkPath, result.files);
2299
2327
  console.info();
@@ -3908,6 +3936,7 @@ async function runSync(config, options) {
3908
3936
  spinnerFail("sync completed with conflicts");
3909
3937
  }
3910
3938
  printSummary(result.summary, "merge summary");
3939
+ printMaskingPinWarning(result.files);
3911
3940
  if (config.logFile) {
3912
3941
  const logPath = writeLogFile(config.forkPath, result.files);
3913
3942
  console.info();
@@ -4083,7 +4112,7 @@ async function runSyncCycle(config) {
4083
4112
  }
4084
4113
  return { status: "staged", branch };
4085
4114
  }
4086
- async function resumeSyncMerge(config, branch) {
4115
+ async function commitSyncMerge(config, branch) {
4087
4116
  const { forkPath } = config;
4088
4117
  const conflicts = await getConflictedFiles(forkPath);
4089
4118
  console.info();
@@ -4106,7 +4135,12 @@ async function resumeSyncMerge(config, branch) {
4106
4135
  await commitSquash(forkPath, message);
4107
4136
  console.info();
4108
4137
  console.info(colors_default.green(`committed the sync on '${branch}' as '${message}'.`));
4109
- await shipSyncBranch(config, branch);
4138
+ printTriageSteps(branch);
4139
+ }
4140
+ function printTriageSteps(branch) {
4141
+ console.info(colors_default.dim(`staying on '${branch}' without pushing.`));
4142
+ console.info(colors_default.dim(" run drift triage (`pnpm cella analyze`), commit any follow-ups, then:"));
4143
+ console.info(colors_default.dim(" pnpm cella sync (pushes the branch and opens the PR)"));
4110
4144
  }
4111
4145
  async function mergeOpenSyncPrs(config, open) {
4112
4146
  const { forkPath, settings } = config;
@@ -4171,7 +4205,7 @@ async function runSyncCommand(config) {
4171
4205
  const currentBranch = await getCurrentBranch(forkPath);
4172
4206
  const onSyncBranch = isTemporarySyncBranch(currentBranch);
4173
4207
  if (onSyncBranch && mergeInProgress(forkPath)) {
4174
- await resumeSyncMerge(config, currentBranch);
4208
+ await commitSyncMerge(config, currentBranch);
4175
4209
  return;
4176
4210
  }
4177
4211
  if (onSyncBranch) {
@@ -4200,9 +4234,11 @@ commit them first (\`git commit --amend --no-edit\` or a new commit).`
4200
4234
  if (outcome.status === "conflicts") {
4201
4235
  console.info(`${warningMark} ${colors_default.yellow(`conflicts on '${temporaryBranch}'. Resolve and stage them, then:`)}`);
4202
4236
  printFinishSteps();
4203
- console.info(colors_default.dim(" rerun commits the sync, pushes the branch, and opens a PR."));
4237
+ console.info(colors_default.dim(" rerun commits the sync and stops for drift triage; a further rerun ships (push + PR)."));
4204
4238
  console.info(colors_default.dim(" let the rerun commit \u2014 a manual `git commit` records a merge commit that bloats the PR."));
4239
+ return;
4205
4240
  }
4241
+ await commitSyncMerge(config, temporaryBranch);
4206
4242
  }
4207
4243
 
4208
4244
  // src/services/forks.ts