@happy-nut/monacori 0.1.10 → 0.1.11
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/commands.js +6 -4
- package/dist/diff.js +11 -9
- package/dist/git.d.ts +1 -0
- package/dist/git.js +9 -0
- package/dist/viewer.css +7 -1
- package/package.json +1 -1
package/dist/commands.js
CHANGED
|
@@ -124,10 +124,12 @@ function launchReviewApp(args) {
|
|
|
124
124
|
if (args.includes("--no-watch"))
|
|
125
125
|
appArgs.push("--no-watch");
|
|
126
126
|
const electronBinary = resolveElectronBinary();
|
|
127
|
-
//
|
|
128
|
-
// the installed package
|
|
129
|
-
//
|
|
130
|
-
|
|
127
|
+
// In dev only (`npm run dev` sets MONACORI_DEV=1) announce which build is launching, so a local
|
|
128
|
+
// checkout is distinguishable from the installed package. Normal `mo` runs stay silent — the shell
|
|
129
|
+
// should be clean, not littered with our internal path.
|
|
130
|
+
if (process.env.MONACORI_DEV === "1") {
|
|
131
|
+
console.error(`monacori: launching ${appMainPath()}`);
|
|
132
|
+
}
|
|
131
133
|
if (args.includes("--foreground")) {
|
|
132
134
|
const result = spawnSync(electronBinary, appArgs, { stdio: "inherit" });
|
|
133
135
|
process.exit(result.status ?? 0);
|
package/dist/diff.js
CHANGED
|
@@ -3,8 +3,9 @@ import { existsSync, readFileSync, statSync } from "node:fs";
|
|
|
3
3
|
import { basename, join } from "node:path";
|
|
4
4
|
import { FLOW_DIR, IMAGE_MAX_BYTES, SOURCE_MAX_FILE_BYTES, SOURCE_MAX_FILES, SOURCE_MAX_TOTAL_BYTES } from "./constants.js";
|
|
5
5
|
import { formatBytes, hashText, isLikelyBinary, languageForPath, stripDiffPath } from "./util.js";
|
|
6
|
-
import { git } from "./git.js";
|
|
6
|
+
import { git, repoRoot } from "./git.js";
|
|
7
7
|
export function readUnifiedDiff(options) {
|
|
8
|
+
const root = repoRoot();
|
|
8
9
|
const args = ["diff", "--no-ext-diff", "--find-renames", `--unified=${options.context}`];
|
|
9
10
|
if (options.ignoreWhitespace)
|
|
10
11
|
args.push("--ignore-all-space");
|
|
@@ -16,7 +17,7 @@ export function readUnifiedDiff(options) {
|
|
|
16
17
|
}
|
|
17
18
|
args.push("--");
|
|
18
19
|
const result = spawnSync("git", args, {
|
|
19
|
-
cwd:
|
|
20
|
+
cwd: root,
|
|
20
21
|
encoding: "utf8",
|
|
21
22
|
maxBuffer: 1024 * 1024 * 100,
|
|
22
23
|
});
|
|
@@ -25,18 +26,18 @@ export function readUnifiedDiff(options) {
|
|
|
25
26
|
}
|
|
26
27
|
const chunks = [result.stdout ?? ""];
|
|
27
28
|
if (options.includeUntracked && !options.staged) {
|
|
28
|
-
chunks.push(readUntrackedDiff(options.context));
|
|
29
|
+
chunks.push(readUntrackedDiff(options.context, root));
|
|
29
30
|
}
|
|
30
31
|
return chunks.filter(Boolean).join("\n");
|
|
31
32
|
}
|
|
32
|
-
function readUntrackedDiff(context) {
|
|
33
|
-
const files = git(
|
|
33
|
+
function readUntrackedDiff(context, root) {
|
|
34
|
+
const files = git(root, ["ls-files", "--others", "--exclude-standard"])
|
|
34
35
|
.split(/\r?\n/)
|
|
35
36
|
.map((line) => line.trim())
|
|
36
37
|
.filter((line) => line && !line.startsWith(`${FLOW_DIR}/`));
|
|
37
38
|
const chunks = [];
|
|
38
39
|
for (const file of files) {
|
|
39
|
-
const absolute = join(
|
|
40
|
+
const absolute = join(root, file);
|
|
40
41
|
if (!existsSync(absolute) || !statSync(absolute).isFile()) {
|
|
41
42
|
continue;
|
|
42
43
|
}
|
|
@@ -225,14 +226,15 @@ export function collectSourceFiles(diffFiles) {
|
|
|
225
226
|
}
|
|
226
227
|
changedLinesByPath.set(file.displayPath, nums);
|
|
227
228
|
}
|
|
228
|
-
const
|
|
229
|
+
const root = repoRoot();
|
|
230
|
+
const vcsByPath = gitStatusMap(root);
|
|
229
231
|
for (const file of diffFiles) {
|
|
230
232
|
const kind = vcsByPath.get(file.displayPath);
|
|
231
233
|
if (kind)
|
|
232
234
|
file.vcs = kind; // color the Changes list from the same status map
|
|
233
235
|
}
|
|
234
236
|
const paths = new Set();
|
|
235
|
-
const gitFiles = git(
|
|
237
|
+
const gitFiles = git(root, ["ls-files", "--cached", "--others", "--exclude-standard"]);
|
|
236
238
|
for (const file of gitFiles.split(/\r?\n/)) {
|
|
237
239
|
const path = file.trim();
|
|
238
240
|
if (path && isSourceCandidate(path)) {
|
|
@@ -248,7 +250,7 @@ export function collectSourceFiles(diffFiles) {
|
|
|
248
250
|
let embeddedFiles = 0;
|
|
249
251
|
let embeddedBytes = 0;
|
|
250
252
|
for (const path of Array.from(paths).sort((a, b) => a.localeCompare(b))) {
|
|
251
|
-
const absolute = join(
|
|
253
|
+
const absolute = join(root, path);
|
|
252
254
|
const base = {
|
|
253
255
|
path,
|
|
254
256
|
name: basename(path),
|
package/dist/git.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GitSnapshot } from "./types.js";
|
|
2
2
|
export declare function isGitRepository(root: string): boolean;
|
|
3
3
|
export declare function git(root: string, args: string[]): string;
|
|
4
|
+
export declare function repoRoot(cwd?: string): string;
|
|
4
5
|
export declare function readGitSnapshot(root: string): GitSnapshot;
|
package/dist/git.js
CHANGED
|
@@ -13,6 +13,15 @@ export function git(root, args) {
|
|
|
13
13
|
}
|
|
14
14
|
return (result.stdout ?? "").trim();
|
|
15
15
|
}
|
|
16
|
+
// Resolve the repository root. `git diff` and `git ls-files` print paths relative to it, and the
|
|
17
|
+
// desktop tree shows them as-is — so every filesystem read of those paths must resolve against the
|
|
18
|
+
// SAME root, not process.cwd(). When `mo` runs from a monorepo subdirectory (cwd != root), joining a
|
|
19
|
+
// repo-root-relative path onto cwd points at a file that doesn't exist, which surfaced as a diff with
|
|
20
|
+
// no source preview ("file is not present in the working tree"). Falls back to cwd outside a repo.
|
|
21
|
+
export function repoRoot(cwd = process.cwd()) {
|
|
22
|
+
const top = git(cwd, ["rev-parse", "--show-toplevel"]);
|
|
23
|
+
return top || cwd;
|
|
24
|
+
}
|
|
16
25
|
export function readGitSnapshot(root) {
|
|
17
26
|
return {
|
|
18
27
|
branch: git(root, ["branch", "--show-current"]),
|
package/dist/viewer.css
CHANGED
|
@@ -532,6 +532,9 @@ summary.tree-focus { background: var(--bg); }
|
|
|
532
532
|
file's diff body extends all the way down. */
|
|
533
533
|
#diff-view:not(.hidden) { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
|
|
534
534
|
#diff-view .diff2html-container { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
|
|
535
|
+
/* Source view mirrors the diff view: fill the content column so the source-body (its last child, after
|
|
536
|
+
the tabs + toolbar) reaches the bottom even for short files, instead of floating at the top. */
|
|
537
|
+
#source-viewer:not(.hidden) { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
|
|
535
538
|
.diff2html-container .d2h-wrapper { flex: 1 1 auto; display: flex; flex-direction: column; }
|
|
536
539
|
.diff2html-container .d2h-file-wrapper:last-child { flex: 1 1 auto; }
|
|
537
540
|
.diff2html-container .d2h-file-wrapper:last-child .d2h-files-diff { height: 100%; }
|
|
@@ -639,10 +642,13 @@ h1 { margin: 0; font-size: 18px; }
|
|
|
639
642
|
.source-tab-close:hover { background: var(--line); color: var(--text); }
|
|
640
643
|
.source-body {
|
|
641
644
|
border: 1px solid var(--border);
|
|
642
|
-
border-radius: 8px;
|
|
643
645
|
overflow: auto;
|
|
644
646
|
background: var(--panel);
|
|
645
647
|
user-select: text;
|
|
648
|
+
/* Square edges flush to the chrome (no rounded corners), and fill the content column so a short
|
|
649
|
+
file still reaches the bottom instead of floating at the top — IntelliJ-style. */
|
|
650
|
+
flex: 1 1 auto;
|
|
651
|
+
min-height: 0;
|
|
646
652
|
}
|
|
647
653
|
/* Extend the line-number gutter (and its divider) to the bottom of the panel so it never stops at the
|
|
648
654
|
last line with an empty strip + cut-off border below it — one continuous gutter. The .num cell is 58px
|