clodable 0.2.1 → 0.2.2

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/dist/.version CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
package/dist/clodable.mjs CHANGED
@@ -23407,6 +23407,9 @@ var CLODABLE_FILES = [
23407
23407
  ".mcp.json",
23408
23408
  WORKFLOW_PATH
23409
23409
  ];
23410
+ function clodableFile(path2) {
23411
+ return CLODABLE_FILES.some((own2) => path2 === own2 || path2.startsWith(`${own2}/`));
23412
+ }
23410
23413
  async function keepIgnored(root) {
23411
23414
  await applyKit(root, [await gitignorePlan(root)]);
23412
23415
  }
@@ -23826,7 +23829,19 @@ async function liveBase(ws) {
23826
23829
  return await ws.git.revParse(ws.liveBranch) ? ws.liveBranch : void 0;
23827
23830
  }
23828
23831
  async function countUnpublished(ws) {
23829
- return (await unpublishedSaves(ws, { buildersOnly: true })).length;
23832
+ return (await waitingSaves(ws)).length;
23833
+ }
23834
+ async function waitingSaves(ws) {
23835
+ const saves = await unpublishedSaves(ws, { buildersOnly: true });
23836
+ return saves.length > 0 && await sameAsLive(ws) ? [] : saves;
23837
+ }
23838
+ async function sameAsLive(ws, options = {}) {
23839
+ const live = await liveBase(ws);
23840
+ if (!live) return false;
23841
+ const diff = await ws.git.run(["diff", "--name-only", `${live}...HEAD`]);
23842
+ if (diff.exitCode !== 0) return false;
23843
+ const changed = diff.stdout.split("\n").filter(Boolean);
23844
+ return options.clodablesToo ? changed.length === 0 : changed.every(clodableFile);
23830
23845
  }
23831
23846
  async function unpublishedSaves(ws, options = {}) {
23832
23847
  const live = await liveBase(ws);
@@ -23838,7 +23853,7 @@ async function unpublishedSaves(ws, options = {}) {
23838
23853
  return saves.filter((c2) => c2.kind !== "setup" && !onlyClodables(files.get(c2.sha) ?? []));
23839
23854
  }
23840
23855
  function onlyClodables(paths) {
23841
- return paths.length > 0 && paths.every((path2) => CLODABLE_FILES.some((own2) => path2 === own2 || path2.startsWith(`${own2}/`)));
23856
+ return paths.length > 0 && paths.every(clodableFile);
23842
23857
  }
23843
23858
  async function ensurePullRequest(ws, branch) {
23844
23859
  const saves = await unpublishedSaves(ws);
@@ -23882,7 +23897,7 @@ async function status(ws, options = {}) {
23882
23897
  ws.state()
23883
23898
  ]);
23884
23899
  const hasLive = Boolean(await ws.git.revParse(ws.liveRef));
23885
- const unpublished = branch === ws.liveBranch ? [] : await unpublishedSaves(ws, { buildersOnly: true });
23900
+ const unpublished = branch === ws.liveBranch ? [] : await waitingSaves(ws);
23886
23901
  const behindLive = hasLive ? await ws.git.count(`HEAD..${ws.liveRef}`, { noMerges: true }) : 0;
23887
23902
  return {
23888
23903
  project: {
@@ -23914,7 +23929,7 @@ async function history(ws, options = {}) {
23914
23929
  unpublishedSaves(ws, { buildersOnly: true }),
23915
23930
  ws.git.log(live, { firstParent: true, limit: options.limit ?? 30 })
23916
23931
  ]);
23917
- return { draft, published };
23932
+ return { draft, sameAsLive: draft.length > 0 && await sameAsLive(ws), published };
23918
23933
  }
23919
23934
  var BEFORE_RESTORE = "Saved changes before restoring";
23920
23935
  async function restore(ws, sha) {
@@ -24234,6 +24249,18 @@ ${kindTrailer(options.kind)}`
24234
24249
  ...keep.map((path2) => `:(top,exclude)${path2}`)
24235
24250
  ]);
24236
24251
  }
24252
+ /** Put these paths (files, from the top) back as they are in `sha`, staged and in the files. */
24253
+ async restorePaths(sha, paths) {
24254
+ if (paths.length === 0) return;
24255
+ await this.ok([
24256
+ "restore",
24257
+ `--source=${sha}`,
24258
+ "--staged",
24259
+ "--worktree",
24260
+ "--",
24261
+ ...paths.map((path2) => `:(top,literal)${path2}`)
24262
+ ]);
24263
+ }
24237
24264
  async stageAll() {
24238
24265
  await this.ok(["add", "--all"]);
24239
24266
  }
@@ -28090,7 +28117,7 @@ async function* publish(ws, options = {}) {
28090
28117
  yield step("sync", "done", "Already up to date with your live site");
28091
28118
  }
28092
28119
  const saves = await ws.git.log(`${ws.liveRef}..HEAD`, { noMerges: true, limit: 200 });
28093
- if (saves.length === 0) {
28120
+ if (saves.length === 0 || await sameAsLive(ws, { clodablesToo: true })) {
28094
28121
  throw new ClodableError({
28095
28122
  code: "nothing-to-publish",
28096
28123
  message: "There's nothing new to publish. Your live site already has everything."
@@ -28195,6 +28222,9 @@ async function* undoPublish(ws, options = {}) {
28195
28222
  hint: "Ask Claude to undo it by hand. It can see exactly what changed."
28196
28223
  });
28197
28224
  }
28225
+ const undone = await side.run(["diff", "--cached", "--name-only", "HEAD"]);
28226
+ await side.restorePaths("HEAD", undone.stdout.split("\n").filter(clodableFile));
28227
+ await keepIgnored(dir);
28198
28228
  const undoTitle = `Undo: ${target.subject}`;
28199
28229
  const identity = await ws.git.identity() ?? void 0;
28200
28230
  await side.commitAll(undoTitle, {
@@ -48854,6 +48884,7 @@ async function historyCommand(ctx2, options) {
48854
48884
  out.header("history");
48855
48885
  out.line(import_picocolors5.default.bold("Your draft"));
48856
48886
  if (h2.draft.length === 0) out.line(ash(" Nothing waiting to go live."));
48887
+ else if (h2.sameAsLive) out.line(ash(" Same as your live site: nothing to publish."));
48857
48888
  for (const c2 of h2.draft) {
48858
48889
  out.line(
48859
48890
  ` ${clay("\u25CF")} ${c2.subject} ${ash(`\xB7 ${formatRelative(c2.date)} \xB7 ${c2.sha.slice(0, 7)}`)}`
@@ -48878,6 +48909,10 @@ async function restoreCommand(ctx2, sha) {
48878
48909
  ctx2,
48879
48910
  async () => restore(await ctx2.workspace(), sha),
48880
48911
  (result) => {
48912
+ if (!result.saved) {
48913
+ ctx2.out.line(`${celadon("\u2713")} Your app already looks like this version: nothing changed`);
48914
+ return;
48915
+ }
48881
48916
  ctx2.out.line(
48882
48917
  `${celadon("\u2713")} Restored ${ash(`\xB7 saved as a new version, nothing was erased`)}`
48883
48918
  );
@@ -48903,7 +48938,7 @@ async function inboxCommand(ctx2, options) {
48903
48938
  }
48904
48939
 
48905
48940
  // src/index.ts
48906
- var version2 = true ? "0.2.1" : "0.1.0-dev";
48941
+ var version2 = true ? "0.2.2" : "0.1.0-dev";
48907
48942
  var cli = cac("clodable");
48908
48943
  cli.option("--json", "Print one JSON event per line (for programs)");
48909
48944
  cli.option("--cwd <dir>", "Run in another folder");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clodable",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "The AI app builder you own. The Clodable command line: save, publish, undo, preview.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/bworlds-co/clodable#readme",