@fungi.computer/oyster 0.57.7 → 0.57.8

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.
@@ -3,9 +3,15 @@ import { Cli } from "@fungi.computer/lantern";
3
3
  import { installStandaloneAppSet } from "./app-set.js";
4
4
  /**
5
5
  * The commit a checkout installs from. A checkout with uncommitted edits is
6
- * the owner's own, so it is recorded as a commit holding those edits (made
7
- * with `git stash create`, which leaves the stash and the tree alone), never
8
- * as the release tag's commit it started from.
6
+ * the owner's own, so it is recorded as a commit holding those edits (the
7
+ * tracked files as they are on disk, plus anything staged), never as the
8
+ * release tag's commit it started from.
9
+ *
10
+ * The edits are captured through a private copy of the index. The command
11
+ * `git stash create` rewrites the checkout's own index, and when another git
12
+ * process (an editor, a file watcher, a second command) holds `index.lock` it
13
+ * exits 1 with no message, which would fail the install for a reason the
14
+ * owner cannot see.
9
15
  */
10
16
  export declare function checkoutRevision(directory: string): string;
11
17
  export declare function installApps(args: readonly string[], install?: typeof installStandaloneAppSet, ui?: Cli): Promise<void>;
@@ -8,6 +8,7 @@
8
8
  // [--repositories <base URL>] [--ref <branch or tag>]
9
9
  // [--from <checkout directory>] [--concurrency 1-3] [--timings <file>] [--only <app>[,<app>]]
10
10
  import { execFileSync } from "node:child_process";
11
+ import { copyFileSync, existsSync, mkdtempSync, rmSync } from "node:fs";
11
12
  import { mkdtemp, rm, writeFile } from "node:fs/promises";
12
13
  import { tmpdir } from "node:os";
13
14
  import { join, resolve } from "node:path";
@@ -46,13 +47,41 @@ Options:
46
47
  `;
47
48
  /**
48
49
  * The commit a checkout installs from. A checkout with uncommitted edits is
49
- * the owner's own, so it is recorded as a commit holding those edits (made
50
- * with `git stash create`, which leaves the stash and the tree alone), never
51
- * as the release tag's commit it started from.
50
+ * the owner's own, so it is recorded as a commit holding those edits (the
51
+ * tracked files as they are on disk, plus anything staged), never as the
52
+ * release tag's commit it started from.
53
+ *
54
+ * The edits are captured through a private copy of the index. The command
55
+ * `git stash create` rewrites the checkout's own index, and when another git
56
+ * process (an editor, a file watcher, a second command) holds `index.lock` it
57
+ * exits 1 with no message, which would fail the install for a reason the
58
+ * owner cannot see.
52
59
  */
53
60
  export function checkoutRevision(directory) {
54
- const git = (...args) => execFileSync("git", args, { cwd: directory, encoding: "utf8" }).trim();
55
- return git("stash", "create") || git("rev-parse", "HEAD");
61
+ const git = (env, ...args) => execFileSync("git", args, {
62
+ cwd: directory,
63
+ encoding: "utf8",
64
+ env: { ...process.env, ...env },
65
+ }).trim();
66
+ const head = git({}, "rev-parse", "HEAD");
67
+ const scratch = mkdtempSync(join(tmpdir(), "oyster-checkout-index-"));
68
+ try {
69
+ const index = join(scratch, "index");
70
+ const realIndex = resolve(directory, git({}, "rev-parse", "--git-path", "index"));
71
+ if (existsSync(realIndex))
72
+ copyFileSync(realIndex, index);
73
+ const env = { GIT_INDEX_FILE: index };
74
+ if (!existsSync(index))
75
+ git(env, "read-tree", "HEAD");
76
+ git(env, "add", "--update");
77
+ const tree = git(env, "write-tree");
78
+ if (tree === git({}, "rev-parse", "HEAD^{tree}"))
79
+ return head;
80
+ return git(env, "commit-tree", tree, "-p", head, "-m", "On HEAD: install-apps checkout");
81
+ }
82
+ finally {
83
+ rmSync(scratch, { recursive: true, force: true });
84
+ }
56
85
  }
57
86
  function missingVariableMessage(url, key) {
58
87
  const lines = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/oyster",
3
- "version": "0.57.7",
3
+ "version": "0.57.8",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Oyster by Fungi: open-source Apps for people and AI agents. Try with one command or run on your own Cloudflare account.",
6
6
  "homepage": "https://docs.fungi.computer/oyster",