@oxide/skepsis 0.2.2 → 0.2.3

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/cli.js +24 -22
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -5633,11 +5633,23 @@ function run(cmd, args) {
5633
5633
  }));
5634
5634
  });
5635
5635
  }
5636
+ const GIT_PREFIX_OVERRIDE = [
5637
+ "-c",
5638
+ "diff.mnemonicPrefix=false",
5639
+ "-c",
5640
+ "diff.noprefix=false",
5641
+ "-c",
5642
+ "diff.srcPrefix=a/",
5643
+ "-c",
5644
+ "diff.dstPrefix=b/"
5645
+ ];
5646
+ const JJ_PREFIX_OVERRIDE = ["--config", "diff.git.show-path-prefix=true"];
5636
5647
  function diffCommand(src) {
5637
5648
  const fileArgs = src.files.length > 0 ? ["--", ...src.files] : [];
5638
5649
  if (src.vcs === "jj") return {
5639
5650
  cmd: "jj",
5640
5651
  args: [
5652
+ ...JJ_PREFIX_OVERRIDE,
5641
5653
  "diff",
5642
5654
  ...src.args,
5643
5655
  "--git",
@@ -5647,6 +5659,7 @@ function diffCommand(src) {
5647
5659
  else return {
5648
5660
  cmd: "git",
5649
5661
  args: [
5662
+ ...GIT_PREFIX_OVERRIDE,
5650
5663
  "diff",
5651
5664
  ...src.args,
5652
5665
  ...fileArgs
@@ -5662,26 +5675,12 @@ async function getDiff(src) {
5662
5675
  fileHashes: extractFileHashes(stdout)
5663
5676
  };
5664
5677
  }
5665
- /** Validate diff args at startup. */
5666
- async function validateDiffArgs(src) {
5667
- const { cmd } = diffCommand(src);
5668
- const fileArgs = src.files.length > 0 ? ["--", ...src.files] : [];
5669
- const { stderr, code } = await run(cmd, src.vcs === "jj" ? [
5670
- "diff",
5671
- ...src.args,
5672
- "--stat",
5673
- ...fileArgs
5674
- ] : [
5675
- "diff",
5676
- "--stat",
5677
- ...src.args,
5678
- ...fileArgs
5679
- ]);
5680
- if (code !== 0) throw new Error(`${cmd} diff failed: ${stderr}`);
5681
- }
5682
5678
  /**
5683
5679
  * Extract newObjectId per file from the git diff's index lines.
5684
- * Format: "diff --git a/<path> b/<path>" followed by "index <old>..<new> <mode>"
5680
+ * Format: "diff --git a/<path> b/<path>" followed by "index <old>..<new> <mode>".
5681
+ * The a//b/ prefixes are guaranteed by GIT_PREFIX_OVERRIDE / JJ_PREFIX_OVERRIDE
5682
+ * regardless of the user's diff config, and must match the names @pierre/diffs
5683
+ * parses on the client so viewed-state keys line up.
5685
5684
  */
5686
5685
  function extractFileHashes(patch) {
5687
5686
  const hashes = {};
@@ -22093,7 +22092,7 @@ const fileContentsQuerySchema = object({
22093
22092
  //#region server/main.ts
22094
22093
  async function startServer(opts) {
22095
22094
  const { diffSource, port = 0, hostname = "localhost", cwd } = opts;
22096
- await validateDiffArgs(diffSource);
22095
+ await getDiff(diffSource);
22097
22096
  const app = new Hono();
22098
22097
  app.get("/api/diff", async (c) => {
22099
22098
  const { patch, fileHashes } = await getDiff(diffSource);
@@ -22150,14 +22149,17 @@ async function startServer(opts) {
22150
22149
  return c.json({ error: err.message }, 500);
22151
22150
  });
22152
22151
  return new Promise((resolve) => {
22153
- serve({
22152
+ const server = serve({
22154
22153
  fetch: app.fetch,
22155
22154
  port,
22156
22155
  hostname
22157
22156
  }, (info) => {
22158
22157
  const assignedPort = typeof info === "string" ? port : info.port;
22159
22158
  console.info(`skepsis on http://${hostname}:${assignedPort} (${displayCommand(diffSource)})`);
22160
- resolve(assignedPort);
22159
+ resolve({
22160
+ port: assignedPort,
22161
+ close: () => server.close()
22162
+ });
22161
22163
  });
22162
22164
  });
22163
22165
  }
@@ -22346,7 +22348,7 @@ function requireCheckoutRoot() {
22346
22348
  process.on("SIGINT", () => cleanup());
22347
22349
  process.on("SIGTERM", () => cleanup());
22348
22350
  const checkoutRoot = opts.dev ? requireCheckoutRoot() : void 0;
22349
- const apiPort = await startServer({
22351
+ const { port: apiPort } = await startServer({
22350
22352
  diffSource,
22351
22353
  cwd,
22352
22354
  hostname
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxide/skepsis",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "repository": "github:oxidecomputer/skepsis",
5
5
  "bin": {
6
6
  "skepsis": "dist/cli.js"