@waffle-os/git 0.0.25 → 0.0.26

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/package.json +7 -7
  2. package/src/program.ts +7 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waffle-os/git",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
4
  "description": "Local Git commands for Waffle runtimes, backed by isomorphic-git",
5
5
  "license": "Apache-2.0 AND BSD-3-Clause AND ISC AND MIT AND Zlib",
6
6
  "repository": {
@@ -40,14 +40,14 @@
40
40
  "esbuild"
41
41
  ],
42
42
  "waffleHostInterface": 4,
43
- "gitHead": "6b27558d10a1870b9ae76fad99dbafd69222c62b",
43
+ "gitHead": "e7d4379f5c16b6c9d1d15a0aa1a01e576b315cfc",
44
44
  "waffleCorrespondingSource": {
45
45
  "schema": "waffle-corresponding-source/1",
46
- "filename": "waffle-os-git-source-0c5c2ef0b89d767fc2a7c060c06dde7ae9e4ec682fa73194a2f092fcf79a3899.tar.gz",
47
- "url": "https://github.com/ShaulLavo/waffle/releases/download/programs-v0.0.25/waffle-os-git-source-0c5c2ef0b89d767fc2a7c060c06dde7ae9e4ec682fa73194a2f092fcf79a3899.tar.gz",
48
- "bytes": 2292285,
49
- "sha256": "0c5c2ef0b89d767fc2a7c060c06dde7ae9e4ec682fa73194a2f092fcf79a3899",
50
- "manifestSha256": "5afd17aedf2bc2e690834d8e3cafdb70329d472cfb6423f0264f93a649d7d8ea"
46
+ "filename": "waffle-os-git-source-516e3d2ed5374160921f7f9d54e22380e41c6fef9b993e4616aeaa52f0562526.tar.gz",
47
+ "url": "https://github.com/ShaulLavo/waffle/releases/download/programs-v0.0.26/waffle-os-git-source-516e3d2ed5374160921f7f9d54e22380e41c6fef9b993e4616aeaa52f0562526.tar.gz",
48
+ "bytes": 2292323,
49
+ "sha256": "516e3d2ed5374160921f7f9d54e22380e41c6fef9b993e4616aeaa52f0562526",
50
+ "manifestSha256": "ec386483026f5dbd51466c7e57a19c452b452d8b14a268bf6b06dc56ee24346d"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public",
package/src/program.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { defineProgramPackage } from "@waffle-os/runtime/programs";
2
2
  import type { Runtime } from "@waffle-os/runtime";
3
- import { FilesystemClient } from "@waffle-os/runtime/adapter/worker";
4
3
  import { FilesystemError } from "@waffle-os/runtime/adapter/worker";
5
4
 
6
5
  /** Bundler-visible URL for the prepared CLI script. */
@@ -57,17 +56,10 @@ export async function installGitProgram(
57
56
  throw new TypeError(`Path must be absolute and canonical: ${name}`);
58
57
  }
59
58
  const bytes = new TextEncoder().encode(`#!${interpreter}\n${options.source}`);
60
- // Order after queued page writes, then use a private connection for exclusive creation.
61
- await runtime.filesystem.resolvePath("/");
62
- const filesystem = new FilesystemClient(runtime.filesystem.fork());
59
+ const filesystem = runtime.filesystem;
63
60
  let owned: number | undefined;
64
- try {
65
- await filesystem.asyncCall("mkdirp", [path.slice(0, path.lastIndexOf("/")) || "/"]);
66
- if (await createScript(filesystem, path, bytes))
67
- owned = (await filesystem.asyncCall("lookup", [path]))?.ino;
68
- } finally {
69
- filesystem.dispose();
70
- }
61
+ await filesystem.mkdirp(path.slice(0, path.lastIndexOf("/")) || "/");
62
+ if (await createScript(filesystem, path, bytes)) owned = (await filesystem.lookup(path))?.ino;
71
63
  let disposal: Promise<void> | undefined;
72
64
  return {
73
65
  path,
@@ -79,15 +71,15 @@ export async function installGitProgram(
79
71
  };
80
72
  }
81
73
 
82
- async function createScript(filesystem: FilesystemClient, path: string, bytes: Uint8Array) {
74
+ async function createScript(filesystem: Runtime["filesystem"], path: string, bytes: Uint8Array) {
83
75
  try {
84
- await filesystem.asyncCall("writeFile", [path, false, true], bytes);
76
+ await filesystem.writeFile(path, bytes, "exclusive");
85
77
  return true;
86
78
  } catch (error) {
87
79
  if (!(error instanceof FilesystemError) || error.errno !== 20) throw error;
88
80
  // An identical script from an earlier install may be reused, but is not owned for deletion.
89
- const entry = await filesystem.asyncCall("lookup", [path]);
90
- if (entry?.kind !== "file" || !sameBytes(await filesystem.asyncCall("readFile", [path]), bytes))
81
+ const entry = await filesystem.lookup(path);
82
+ if (entry?.kind !== "file" || !sameBytes(await filesystem.readFile(path), bytes))
91
83
  throw new GitProgramConflictError(path);
92
84
  return false;
93
85
  }