diffing 0.2.0 → 0.2.1

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 (92) hide show
  1. package/README.md +28 -4
  2. package/dist/cli-agent-BLPX3oOP.mjs +443 -0
  3. package/dist/cli-agent-BNwY5lZE.mjs +446 -0
  4. package/dist/cli-agent-CbzXDSSF.mjs +446 -0
  5. package/dist/cli-agent-DsqbS3n7.mjs +443 -0
  6. package/dist/cli-agent-ZAkixf4c.mjs +446 -0
  7. package/dist/cli.mjs +539 -33
  8. package/dist/client/assets/{angular-html-fdYbuxHF.js → angular-html-DsssUIMZ.js} +1 -1
  9. package/dist/client/assets/{angular-ts-D3iFqR-R.js → angular-ts-dTg-sJ77.js} +1 -1
  10. package/dist/client/assets/{apl-MnBV-iQN.js → apl-C1yUKbqz.js} +1 -1
  11. package/dist/client/assets/{astro-BrpK01E7.js → astro-BI07ha2y.js} +1 -1
  12. package/dist/client/assets/{blade-CGmyBuwD.js → blade-DkzUGffS.js} +1 -1
  13. package/dist/client/assets/{c-xQnwtG9Y.js → c-KkuqqOvW.js} +1 -1
  14. package/dist/client/assets/{cobol-ypVzOIQu.js → cobol-DRh7-jLi.js} +1 -1
  15. package/dist/client/assets/{coffee-CrtE1uj2.js → coffee-wR_ZAh9a.js} +1 -1
  16. package/dist/client/assets/{cpp-DLd4XEKA.js → cpp-OD_qyywn.js} +1 -1
  17. package/dist/client/assets/{crystal-CJYvpLt_.js → crystal-E4ahAddE.js} +1 -1
  18. package/dist/client/assets/{css-DrX2B9os.js → css-2NgE_uxz.js} +1 -1
  19. package/dist/client/assets/{edge-BsQYk9OW.js → edge-8mbscxxD.js} +1 -1
  20. package/dist/client/assets/{elixir-DU_VfGYR.js → elixir-CJv1b3Q6.js} +1 -1
  21. package/dist/client/assets/{elm-W4eOLEDv.js → elm-DUPzqZ9H.js} +1 -1
  22. package/dist/client/assets/{erb-D9FdIJ2e.js → erb-ssvEF26z.js} +1 -1
  23. package/dist/client/assets/{git-rebase-BtPCXjbS.js → git-rebase-DiWIK1Oa.js} +1 -1
  24. package/dist/client/assets/{glimmer-js-BVfUGMUb.js → glimmer-js-DrHg6AuA.js} +1 -1
  25. package/dist/client/assets/{glimmer-ts-BZEaHDZL.js → glimmer-ts-wQSGOa8A.js} +1 -1
  26. package/dist/client/assets/{glsl-CSiNDuwt.js → glsl-OY27QGY0.js} +1 -1
  27. package/dist/client/assets/{graphql-Crf08Rhb.js → graphql-CSWSqe6f.js} +1 -1
  28. package/dist/client/assets/{hack-DUiQuO20.js → hack-Bi1v624Q.js} +1 -1
  29. package/dist/client/assets/{haml-BtvVTDRG.js → haml-CX94zV9m.js} +1 -1
  30. package/dist/client/assets/{handlebars-Bu_cdZA_.js → handlebars-C1j6wnjG.js} +1 -1
  31. package/dist/client/assets/{html-C4cun3zD.js → html-BcAjMlB7.js} +1 -1
  32. package/dist/client/assets/{html-derivative-CQnD80KV.js → html-derivative-DcEpOzdx.js} +1 -1
  33. package/dist/client/assets/{http-DuOJF9Kg.js → http-BBxxSc6S.js} +1 -1
  34. package/dist/client/assets/{hurl-DgrdYsYh.js → hurl-CpKRNTz4.js} +1 -1
  35. package/dist/client/assets/{index-CZZd7iTh.js → index-Bwv7BWUp.js} +156 -84
  36. package/dist/client/assets/index-CoZyJYkw.css +1 -0
  37. package/dist/client/assets/{java-D-vtFiv8.js → java-CFUlLvAA.js} +1 -1
  38. package/dist/client/assets/{javascript-CFYFXvdN.js → javascript-C-HnT3sE.js} +1 -1
  39. package/dist/client/assets/{jinja-fZvIg2_s.js → jinja-CPU8RwNP.js} +1 -1
  40. package/dist/client/assets/{jison-DEzxLq5g.js → jison-CW0TBQOs.js} +1 -1
  41. package/dist/client/assets/{json-QM4VBqMC.js → json-qUjlNuEJ.js} +1 -1
  42. package/dist/client/assets/{jsx-DLzUM_cC.js → jsx-KWeo60kf.js} +1 -1
  43. package/dist/client/assets/{julia-Dwt1SIpn.js → julia-CnJB8y2e.js} +1 -1
  44. package/dist/client/assets/{just-Dwp-hLcL.js → just-Do22d9PP.js} +1 -1
  45. package/dist/client/assets/{latex-CMF1JViz.js → latex-CCPgzvKn.js} +1 -1
  46. package/dist/client/assets/{liquid-czkpOZWY.js → liquid-B9btdZoI.js} +1 -1
  47. package/dist/client/assets/{lua-DE5PD0Vh.js → lua-IFRifurW.js} +1 -1
  48. package/dist/client/assets/{marko-DHeEvZiW.js → marko-CCaVBFq1.js} +1 -1
  49. package/dist/client/assets/{mdc-B941liUQ.js → mdc-BtbnOLUc.js} +1 -1
  50. package/dist/client/assets/{nginx-Pb9t8c-r.js → nginx-BkbFZHVt.js} +1 -1
  51. package/dist/client/assets/{nim-MMUvW_R1.js → nim-2uCd5j65.js} +1 -1
  52. package/dist/client/assets/{perl-DXwXRmuC.js → perl-C4ixqSNT.js} +1 -1
  53. package/dist/client/assets/{php-D42kv59r.js → php-DJ8WOtcI.js} +1 -1
  54. package/dist/client/assets/{pug-v0iesski.js → pug-BOaafhT5.js} +1 -1
  55. package/dist/client/assets/{qml-spxQQ-ei.js → qml-CURE-1y4.js} +1 -1
  56. package/dist/client/assets/{r-CobWTBG9.js → r-CPWmgzo3.js} +1 -1
  57. package/dist/client/assets/{razor-B-_Ww3MB.js → razor-DH83VP_d.js} +1 -1
  58. package/dist/client/assets/{regexp-BJMVs8R0.js → regexp-BXVWi-t_.js} +1 -1
  59. package/dist/client/assets/{rst-BHcaWsY0.js → rst-Bbxxs6E2.js} +1 -1
  60. package/dist/client/assets/{ruby-BCMT6kog.js → ruby-C-TuWES4.js} +1 -1
  61. package/dist/client/assets/{sas-DHfZnd3R.js → sas-njzNYNOq.js} +1 -1
  62. package/dist/client/assets/{scss-DjDsJvDO.js → scss-D2i6rHB8.js} +1 -1
  63. package/dist/client/assets/{shellscript-B6qaIiU-.js → shellscript-D6Bxi40C.js} +1 -1
  64. package/dist/client/assets/{shellsession-ByCeir2b.js → shellsession-Defxq-I6.js} +1 -1
  65. package/dist/client/assets/{soy-C6WpnMSF.js → soy-D0GKXrtT.js} +1 -1
  66. package/dist/client/assets/{sql-BIvSNLV_.js → sql-BRW_ADkU.js} +1 -1
  67. package/dist/client/assets/{stata-PG9iZ--I.js → stata-w7w59F48.js} +1 -1
  68. package/dist/client/assets/{surrealql-CmvCzG09.js → surrealql-O-lLuqz7.js} +1 -1
  69. package/dist/client/assets/{svelte-ChumG88s.js → svelte-DN3DR5-t.js} +1 -1
  70. package/dist/client/assets/{templ-CmzuRY_a.js → templ-CJ2JFoia.js} +1 -1
  71. package/dist/client/assets/{tex-DL8t-_eJ.js → tex-CpWrf5g9.js} +1 -1
  72. package/dist/client/assets/{ts-tags-BFfE0Egm.js → ts-tags-CZ6Af6Pe.js} +1 -1
  73. package/dist/client/assets/{tsx-C1bFyHcE.js → tsx-gIUSpRih.js} +1 -1
  74. package/dist/client/assets/{twig-DkIluZEQ.js → twig-DwZINhmw.js} +1 -1
  75. package/dist/client/assets/{typescript-Gc86Bc3j.js → typescript-Dj2aMECR.js} +1 -1
  76. package/dist/client/assets/{vue-C88JmL53.js → vue-B5K0aWrP.js} +1 -1
  77. package/dist/client/assets/{vue-html-Cry4aksC.js → vue-html-DKGgrypd.js} +1 -1
  78. package/dist/client/assets/{vue-vine-zlDkA3Ui.js → vue-vine-B5iDYTCh.js} +1 -1
  79. package/dist/client/assets/{xml-NvwpIFDy.js → xml-CbTzxfc-.js} +1 -1
  80. package/dist/client/assets/{xsl-CDjXvY9w.js → xsl-Dj-Be6nx.js} +1 -1
  81. package/dist/client/assets/{yaml-Bh-LPjcH.js → yaml-rTK8uEjh.js} +1 -1
  82. package/dist/client/index.html +2 -5
  83. package/dist/mcp-CE77qfjx.mjs +254 -0
  84. package/dist/mcp-CFeE13n-.mjs +254 -0
  85. package/dist/mcp-SGCrfYGo.mjs +254 -0
  86. package/dist/server-lock-B4crz9-_.mjs +708 -0
  87. package/dist/server-lock-DpCrvL-Z.mjs +714 -0
  88. package/dist/update-check-DJuFE9w6.mjs +128 -0
  89. package/dist/update-check-DSC02MWQ.mjs +129 -0
  90. package/dist/update-check-KL-2sGxE.mjs +129 -0
  91. package/package.json +12 -14
  92. package/dist/client/assets/index-CkC-EvWo.css +0 -1
@@ -0,0 +1,128 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { dirname, resolve } from "node:path";
3
+ import { readFileSync } from "node:fs";
4
+ import { spawn } from "node:child_process";
5
+ //#region src/lib/update-check.ts
6
+ /**
7
+ * Strips ANSI escape sequences from a string to compute its visible/display length.
8
+ */
9
+ function stripAnsi(str) {
10
+ return str.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "");
11
+ }
12
+ /**
13
+ * Compare two semver version strings to see if the latest version is newer.
14
+ */
15
+ function isNewerVersion(current, latest) {
16
+ const clean = (v) => v.replace(/^v/, "");
17
+ const cParts = clean(current).split(".").map(Number);
18
+ const lParts = clean(latest).split(".").map(Number);
19
+ for (let i = 0; i < 3; i++) {
20
+ const cVal = cParts[i] ?? 0;
21
+ const lVal = lParts[i] ?? 0;
22
+ if (Number.isNaN(cVal) || Number.isNaN(lVal)) continue;
23
+ if (lVal > cVal) return true;
24
+ if (lVal < cVal) return false;
25
+ }
26
+ return false;
27
+ }
28
+ /**
29
+ * Queries the npm registry asynchronously with a 1-second timeout.
30
+ */
31
+ async function checkForUpdates(currentVersion) {
32
+ try {
33
+ const controller = new AbortController();
34
+ const id = setTimeout(() => controller.abort(), 1e3);
35
+ const res = await fetch("https://registry.npmjs.org/diffing/latest", { signal: controller.signal });
36
+ clearTimeout(id);
37
+ if (!res.ok) return null;
38
+ const data = await res.json();
39
+ if (!data.version) return null;
40
+ return {
41
+ hasUpdate: isNewerVersion(currentVersion, data.version),
42
+ latestVersion: data.version
43
+ };
44
+ } catch {
45
+ return null;
46
+ }
47
+ }
48
+ /**
49
+ * Prints a beautifully styled console box letting the user know a new version is available.
50
+ */
51
+ function printUpdateDisclaimer(current, latest) {
52
+ const borderCol = "\x1B[38;5;220m";
53
+ const bold = "\x1B[1m";
54
+ const reset = "\x1B[0m";
55
+ const boxWidth = 58;
56
+ const top = borderCol + "╭" + "─".repeat(boxWidth) + "╮\x1B[0m";
57
+ const bottom = borderCol + "╰" + "─".repeat(boxWidth) + "╯\x1B[0m";
58
+ const side = borderCol + "│\x1B[0m";
59
+ const l1 = `🚀 ${bold}Update available!${reset} v${current} → \x1b[38;5;82mv${latest}${reset}`;
60
+ const l2 = `Run ${bold}diffing update${reset} to easily upgrade to the latest version.`;
61
+ const printRow = (content) => {
62
+ const displayLength = stripAnsi(content).length + (content.includes("🚀") ? 1 : 0);
63
+ const totalPadding = boxWidth - 4 - displayLength;
64
+ const pad = " ".repeat(Math.max(0, totalPadding));
65
+ console.log(`${side} ${content}${pad} ${side}`);
66
+ };
67
+ console.log();
68
+ console.log(top);
69
+ printRow("");
70
+ printRow(l1);
71
+ printRow(l2);
72
+ printRow("");
73
+ console.log(bottom);
74
+ console.log();
75
+ }
76
+ /**
77
+ * Executes the update command process.
78
+ */
79
+ async function runUpdateCommand() {
80
+ const pkgPath = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "package.json");
81
+ const currentVersion = JSON.parse(readFileSync(pkgPath, "utf-8")).version;
82
+ console.log("Checking for updates...");
83
+ const updateInfo = await checkForUpdates(currentVersion);
84
+ if (!updateInfo || !updateInfo.hasUpdate) {
85
+ console.log(`\x1b[38;5;82mYou are already on the latest version of diffing (v${currentVersion})!\x1b[0m`);
86
+ return 0;
87
+ }
88
+ const latest = updateInfo.latestVersion;
89
+ console.log(`\n\x1b[38;5;75mUpdating diffing: v${currentVersion} → v${latest}...\x1b[0m\n`);
90
+ let cmd = "npm";
91
+ let args = [
92
+ "install",
93
+ "-g",
94
+ "diffing@latest"
95
+ ];
96
+ try {
97
+ const { execSync } = await import("node:child_process");
98
+ execSync("pnpm --version", { stdio: "ignore" });
99
+ cmd = "pnpm";
100
+ args = [
101
+ "add",
102
+ "-g",
103
+ "diffing@latest"
104
+ ];
105
+ } catch {}
106
+ console.log(`Running: ${cmd} ${args.join(" ")}\n`);
107
+ const exitCode = await new Promise((res) => {
108
+ const child = spawn(cmd, args, {
109
+ stdio: "inherit",
110
+ shell: true
111
+ });
112
+ child.on("close", (code) => {
113
+ res(code ?? 0);
114
+ });
115
+ child.on("error", (err) => {
116
+ console.error(`Failed to start update process: ${err.message}`);
117
+ res(1);
118
+ });
119
+ });
120
+ if (exitCode === 0) console.log(`\n\x1b[38;5;82mSuccessfully updated diffing to v${latest}!\x1b[0m\n`);
121
+ else {
122
+ console.error(`\n\x1b[38;5;196mFailed to update diffing. Please try running the command manually with sudo if required:\x1b[0m`);
123
+ console.error(` sudo ${cmd} ${args.join(" ")}\n`);
124
+ }
125
+ return exitCode;
126
+ }
127
+ //#endregion
128
+ export { checkForUpdates, printUpdateDisclaimer, runUpdateCommand };
@@ -0,0 +1,129 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { dirname, resolve } from "node:path";
3
+ import { existsSync, readFileSync } from "node:fs";
4
+ import { spawn } from "node:child_process";
5
+ //#region src/lib/update-check.ts
6
+ /**
7
+ * Strips ANSI escape sequences from a string to compute its visible/display length.
8
+ */
9
+ function stripAnsi(str) {
10
+ return str.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "");
11
+ }
12
+ /**
13
+ * Compare two semver version strings to see if the latest version is newer.
14
+ */
15
+ function isNewerVersion(current, latest) {
16
+ const clean = (v) => v.replace(/^v/, "");
17
+ const cParts = clean(current).split(".").map(Number);
18
+ const lParts = clean(latest).split(".").map(Number);
19
+ for (let i = 0; i < 3; i++) {
20
+ const cVal = cParts[i] ?? 0;
21
+ const lVal = lParts[i] ?? 0;
22
+ if (Number.isNaN(cVal) || Number.isNaN(lVal)) continue;
23
+ if (lVal > cVal) return true;
24
+ if (lVal < cVal) return false;
25
+ }
26
+ return false;
27
+ }
28
+ /**
29
+ * Queries the npm registry asynchronously with a 1-second timeout.
30
+ */
31
+ async function checkForUpdates(currentVersion) {
32
+ try {
33
+ const controller = new AbortController();
34
+ const id = setTimeout(() => controller.abort(), 1e3);
35
+ const res = await fetch("https://registry.npmjs.org/diffing/latest", { signal: controller.signal });
36
+ clearTimeout(id);
37
+ if (!res.ok) return null;
38
+ const data = await res.json();
39
+ if (!data.version) return null;
40
+ return {
41
+ hasUpdate: isNewerVersion(currentVersion, data.version),
42
+ latestVersion: data.version
43
+ };
44
+ } catch {
45
+ return null;
46
+ }
47
+ }
48
+ /**
49
+ * Prints a beautifully styled console box letting the user know a new version is available.
50
+ */
51
+ function printUpdateDisclaimer(current, latest) {
52
+ const borderCol = "\x1B[38;5;220m";
53
+ const bold = "\x1B[1m";
54
+ const reset = "\x1B[0m";
55
+ const boxWidth = 58;
56
+ const top = borderCol + "╭" + "─".repeat(boxWidth) + "╮\x1B[0m";
57
+ const bottom = borderCol + "╰" + "─".repeat(boxWidth) + "╯\x1B[0m";
58
+ const side = borderCol + "│\x1B[0m";
59
+ const l1 = `🚀 ${bold}Update available!${reset} v${current} → \x1b[38;5;82mv${latest}${reset}`;
60
+ const l2 = `Run ${bold}diffing update${reset} to easily upgrade to the latest version.`;
61
+ const printRow = (content) => {
62
+ const displayLength = stripAnsi(content).length + (content.includes("🚀") ? 1 : 0);
63
+ const totalPadding = boxWidth - 4 - displayLength;
64
+ const pad = " ".repeat(Math.max(0, totalPadding));
65
+ console.log(`${side} ${content}${pad} ${side}`);
66
+ };
67
+ console.log();
68
+ console.log(top);
69
+ printRow("");
70
+ printRow(l1);
71
+ printRow(l2);
72
+ printRow("");
73
+ console.log(bottom);
74
+ console.log();
75
+ }
76
+ /**
77
+ * Executes the update command process.
78
+ */
79
+ async function runUpdateCommand() {
80
+ const __dirname = dirname(fileURLToPath(import.meta.url));
81
+ const pkgPath = existsSync(resolve(__dirname, "..", "package.json")) ? resolve(__dirname, "..", "package.json") : resolve(__dirname, "..", "..", "package.json");
82
+ const currentVersion = JSON.parse(readFileSync(pkgPath, "utf-8")).version;
83
+ console.log("Checking for updates...");
84
+ const updateInfo = await checkForUpdates(currentVersion);
85
+ if (!updateInfo || !updateInfo.hasUpdate) {
86
+ console.log(`\x1b[38;5;82mYou are already on the latest version of diffing (v${currentVersion})!\x1b[0m`);
87
+ return 0;
88
+ }
89
+ const latest = updateInfo.latestVersion;
90
+ console.log(`\n\x1b[38;5;75mUpdating diffing: v${currentVersion} → v${latest}...\x1b[0m\n`);
91
+ let cmd = "npm";
92
+ let args = [
93
+ "install",
94
+ "-g",
95
+ "diffing@latest"
96
+ ];
97
+ try {
98
+ const { execSync } = await import("node:child_process");
99
+ execSync("pnpm --version", { stdio: "ignore" });
100
+ cmd = "pnpm";
101
+ args = [
102
+ "add",
103
+ "-g",
104
+ "diffing@latest"
105
+ ];
106
+ } catch {}
107
+ console.log(`Running: ${cmd} ${args.join(" ")}\n`);
108
+ const exitCode = await new Promise((res) => {
109
+ const child = spawn(cmd, args, {
110
+ stdio: "inherit",
111
+ shell: true
112
+ });
113
+ child.on("close", (code) => {
114
+ res(code ?? 0);
115
+ });
116
+ child.on("error", (err) => {
117
+ console.error(`Failed to start update process: ${err.message}`);
118
+ res(1);
119
+ });
120
+ });
121
+ if (exitCode === 0) console.log(`\n\x1b[38;5;82mSuccessfully updated diffing to v${latest}!\x1b[0m\n`);
122
+ else {
123
+ console.error(`\n\x1b[38;5;196mFailed to update diffing. Please try running the command manually with sudo if required:\x1b[0m`);
124
+ console.error(` sudo ${cmd} ${args.join(" ")}\n`);
125
+ }
126
+ return exitCode;
127
+ }
128
+ //#endregion
129
+ export { checkForUpdates, printUpdateDisclaimer, runUpdateCommand };
@@ -0,0 +1,129 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { dirname, resolve } from "node:path";
3
+ import { existsSync, readFileSync } from "node:fs";
4
+ import { spawn } from "node:child_process";
5
+ //#region src/lib/update-check.ts
6
+ /**
7
+ * Strips ANSI escape sequences from a string to compute its visible/display length.
8
+ */
9
+ function stripAnsi(str) {
10
+ return str.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "");
11
+ }
12
+ /**
13
+ * Compare two semver version strings to see if the latest version is newer.
14
+ */
15
+ function isNewerVersion(current, latest) {
16
+ const clean = (v) => v.replace(/^v/, "");
17
+ const cParts = clean(current).split(".").map(Number);
18
+ const lParts = clean(latest).split(".").map(Number);
19
+ for (let i = 0; i < 3; i++) {
20
+ const cVal = cParts[i] ?? 0;
21
+ const lVal = lParts[i] ?? 0;
22
+ if (Number.isNaN(cVal) || Number.isNaN(lVal)) continue;
23
+ if (lVal > cVal) return true;
24
+ if (lVal < cVal) return false;
25
+ }
26
+ return false;
27
+ }
28
+ /**
29
+ * Queries the npm registry asynchronously with a 1-second timeout.
30
+ */
31
+ async function checkForUpdates(currentVersion) {
32
+ try {
33
+ const controller = new AbortController();
34
+ const id = setTimeout(() => controller.abort(), 1e3);
35
+ const res = await fetch("https://registry.npmjs.org/diffing/latest", { signal: controller.signal });
36
+ clearTimeout(id);
37
+ if (!res.ok) return null;
38
+ const data = await res.json();
39
+ if (!data.version) return null;
40
+ return {
41
+ hasUpdate: isNewerVersion(currentVersion, data.version),
42
+ latestVersion: data.version
43
+ };
44
+ } catch {
45
+ return null;
46
+ }
47
+ }
48
+ /**
49
+ * Prints a beautifully styled console box letting the user know a new version is available.
50
+ */
51
+ function printUpdateDisclaimer(current, latest) {
52
+ const borderCol = "\x1B[38;5;220m";
53
+ const bold = "\x1B[1m";
54
+ const reset = "\x1B[0m";
55
+ const boxWidth = 66;
56
+ const top = borderCol + "╭" + "─".repeat(boxWidth) + "╮\x1B[0m";
57
+ const bottom = borderCol + "╰" + "─".repeat(boxWidth) + "╯\x1B[0m";
58
+ const side = borderCol + "│\x1B[0m";
59
+ const l1 = `🚀 ${bold}Update available!${reset} v${current} → \x1b[38;5;82mv${latest}${reset}`;
60
+ const l2 = `Run ${bold}diffing update${reset} to easily upgrade to the latest version.`;
61
+ const printRow = (content) => {
62
+ const displayLength = stripAnsi(content).length + (content.includes("🚀") ? 1 : 0);
63
+ const totalPadding = boxWidth - 4 - displayLength;
64
+ const pad = " ".repeat(Math.max(0, totalPadding));
65
+ console.log(`${side} ${content}${pad} ${side}`);
66
+ };
67
+ console.log();
68
+ console.log(top);
69
+ printRow("");
70
+ printRow(l1);
71
+ printRow(l2);
72
+ printRow("");
73
+ console.log(bottom);
74
+ console.log();
75
+ }
76
+ /**
77
+ * Executes the update command process.
78
+ */
79
+ async function runUpdateCommand() {
80
+ const __dirname = dirname(fileURLToPath(import.meta.url));
81
+ const pkgPath = existsSync(resolve(__dirname, "..", "package.json")) ? resolve(__dirname, "..", "package.json") : resolve(__dirname, "..", "..", "package.json");
82
+ const currentVersion = JSON.parse(readFileSync(pkgPath, "utf-8")).version;
83
+ console.log("Checking for updates...");
84
+ const updateInfo = await checkForUpdates(currentVersion);
85
+ if (!updateInfo || !updateInfo.hasUpdate) {
86
+ console.log(`\x1b[38;5;82mYou are already on the latest version of diffing (v${currentVersion})!\x1b[0m`);
87
+ return 0;
88
+ }
89
+ const latest = updateInfo.latestVersion;
90
+ console.log(`\n\x1b[38;5;75mUpdating diffing: v${currentVersion} → v${latest}...\x1b[0m\n`);
91
+ let cmd = "npm";
92
+ let args = [
93
+ "install",
94
+ "-g",
95
+ "diffing@latest"
96
+ ];
97
+ try {
98
+ const { execSync } = await import("node:child_process");
99
+ execSync("pnpm --version", { stdio: "ignore" });
100
+ cmd = "pnpm";
101
+ args = [
102
+ "add",
103
+ "-g",
104
+ "diffing@latest"
105
+ ];
106
+ } catch {}
107
+ console.log(`Running: ${cmd} ${args.join(" ")}\n`);
108
+ const exitCode = await new Promise((res) => {
109
+ const child = spawn(cmd, args, {
110
+ stdio: "inherit",
111
+ shell: true
112
+ });
113
+ child.on("close", (code) => {
114
+ res(code ?? 0);
115
+ });
116
+ child.on("error", (err) => {
117
+ console.error(`Failed to start update process: ${err.message}`);
118
+ res(1);
119
+ });
120
+ });
121
+ if (exitCode === 0) console.log(`\n\x1b[38;5;82mSuccessfully updated diffing to v${latest}!\x1b[0m\n`);
122
+ else {
123
+ console.error(`\n\x1b[38;5;196mFailed to update diffing. Please try running the command manually with sudo if required:\x1b[0m`);
124
+ console.error(` sudo ${cmd} ${args.join(" ")}\n`);
125
+ }
126
+ return exitCode;
127
+ }
128
+ //#endregion
129
+ export { checkForUpdates, printUpdateDisclaimer, runUpdateCommand };
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "diffing",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "local-first CLI for reviewing, navigating, and discussing git diffs with AI",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "packageManager": "pnpm@10.32.1",
8
7
  "homepage": "https://github.com/ahmedragab20/diffing",
9
8
  "repository": {
10
9
  "type": "git",
@@ -25,17 +24,6 @@
25
24
  "files": [
26
25
  "dist"
27
26
  ],
28
- "scripts": {
29
- "build": "vite build && tsdown",
30
- "changeset": "changeset",
31
- "dev:client": "vite",
32
- "dev:server": "tsx src/cli.ts --no-open --port 3433",
33
- "test": "vitest run",
34
- "test:watch": "vitest",
35
- "prepublishOnly": "pnpm run build",
36
- "release": "pnpm run build && changeset publish",
37
- "version-packages": "changeset version"
38
- },
39
27
  "dependencies": {
40
28
  "@base-ui-components/react": "1.0.0-rc.0",
41
29
  "@ff-labs/fff-node": "^0.8.4",
@@ -74,5 +62,15 @@
74
62
  "typescript": "^6.0.2",
75
63
  "vite": "^8.0.3",
76
64
  "vitest": "^4.1.7"
65
+ },
66
+ "scripts": {
67
+ "build": "vite build && tsdown",
68
+ "changeset": "changeset",
69
+ "dev:client": "vite",
70
+ "dev:server": "tsx src/cli.ts --no-open --port 3433",
71
+ "test": "vitest run",
72
+ "test:watch": "vitest",
73
+ "release": "pnpm run build && changeset publish",
74
+ "version-packages": "changeset version"
77
75
  }
78
- }
76
+ }