gh-pr-attach-screenshots 0.1.0 → 0.1.2
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/package.json +1 -1
- package/dist/src/attach.d.mts +0 -5
- package/dist/src/attach.d.mts.map +0 -1
- package/dist/src/attach.mjs +0 -23
- package/dist/src/attach.mjs.map +0 -1
- package/dist/src/cli.d.mts +0 -3
- package/dist/src/cli.d.mts.map +0 -1
- package/dist/src/cli.mjs +0 -20
- package/dist/src/cli.mjs.map +0 -1
- package/dist/src/github-cli.d.mts +0 -14
- package/dist/src/github-cli.d.mts.map +0 -1
- package/dist/src/github-cli.mjs +0 -75
- package/dist/src/github-cli.mjs.map +0 -1
- package/dist/src/index.d.mts +0 -5
- package/dist/src/index.d.mts.map +0 -1
- package/dist/src/index.mjs +0 -5
- package/dist/src/index.mjs.map +0 -1
- package/dist/src/parse-args.d.mts +0 -11
- package/dist/src/parse-args.d.mts.map +0 -1
- package/dist/src/parse-args.mjs +0 -70
- package/dist/src/parse-args.mjs.map +0 -1
- package/dist/src/screenshots-section.d.mts +0 -4
- package/dist/src/screenshots-section.d.mts.map +0 -1
- package/dist/src/screenshots-section.mjs +0 -43
- package/dist/src/screenshots-section.mjs.map +0 -1
package/package.json
CHANGED
package/dist/src/attach.d.mts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type CommandRunner } from './github-cli.mts';
|
|
2
|
-
import { type AttachScreenshotOptions } from './parse-args.mts';
|
|
3
|
-
export type { AttachScreenshotOptions };
|
|
4
|
-
export declare function attachPrScreenshots(options: AttachScreenshotOptions, runner?: CommandRunner): string;
|
|
5
|
-
//# sourceMappingURL=attach.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attach.d.mts","sourceRoot":"","sources":["../../src/attach.mts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAMnB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAG/D,YAAY,EAAE,uBAAuB,EAAE,CAAA;AAEvC,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,uBAAuB,EAChC,MAAM,GAAE,aAA0B,GACjC,MAAM,CAyBR"}
|
package/dist/src/attach.mjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { editPrBody, ensureGhImageExtension, gh, runCommand, validateGh, } from './github-cli.mts';
|
|
3
|
-
import { upsertScreenshotsSection } from './screenshots-section.mts';
|
|
4
|
-
export function attachPrScreenshots(options, runner = runCommand) {
|
|
5
|
-
validateGh(runner);
|
|
6
|
-
ensureGhImageExtension(runner);
|
|
7
|
-
const repo = options.repo ??
|
|
8
|
-
gh(runner, ['repo', 'view', '--json', 'nameWithOwner', '--jq', '.nameWithOwner']);
|
|
9
|
-
const pr = options.pr ??
|
|
10
|
-
gh(runner, ['pr', 'view', '--repo', repo, '--json', 'number', '--jq', '.number']);
|
|
11
|
-
const imageMarkdown = options.images.map(image => {
|
|
12
|
-
if (!existsSync(image)) {
|
|
13
|
-
throw new Error(`Screenshot not found: ${image}`);
|
|
14
|
-
}
|
|
15
|
-
return gh(runner, ['image', image, '--repo', repo]);
|
|
16
|
-
});
|
|
17
|
-
const body = gh(runner, ['pr', 'view', pr, '--repo', repo, '--json', 'body', '--jq', '.body']);
|
|
18
|
-
const nextBody = upsertScreenshotsSection(body, imageMarkdown, { replace: options.replace });
|
|
19
|
-
editPrBody(runner, pr, repo, nextBody);
|
|
20
|
-
process.stderr.write(`Attached ${imageMarkdown.length} screenshot(s) to PR #${pr} in ${repo}\n`);
|
|
21
|
-
return nextBody;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=attach.mjs.map
|
package/dist/src/attach.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attach.mjs","sourceRoot":"","sources":["../../src/attach.mts"],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,GAAG,wBAAwB,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC5F,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;IAEtC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,aAAa,CAAC,MAAM,yBAAyB,EAAE,OAAO,IAAI,IAAI,CAAC,CAAA;IAEhG,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
package/dist/src/cli.d.mts
DELETED
package/dist/src/cli.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.mts","sourceRoot":"","sources":["../../src/cli.mts"],"names":[],"mappings":";AAIA,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAWzC"}
|
package/dist/src/cli.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { attachPrScreenshots } from './attach.mts';
|
|
3
|
-
import { HelpRequested, parseArgs } from './parse-args.mts';
|
|
4
|
-
export function main(args) {
|
|
5
|
-
try {
|
|
6
|
-
attachPrScreenshots(parseArgs(args));
|
|
7
|
-
}
|
|
8
|
-
catch (error) {
|
|
9
|
-
if (error instanceof HelpRequested) {
|
|
10
|
-
console.log(error.message);
|
|
11
|
-
process.exit(0);
|
|
12
|
-
}
|
|
13
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
14
|
-
process.exit(2);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
if (process.argv[1] === import.meta.filename) {
|
|
18
|
-
main(process.argv.slice(2));
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=cli.mjs.map
|
package/dist/src/cli.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","sourceRoot":"","sources":["../../src/cli.mts"],"names":[],"mappings":";AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE3D,MAAM,UAAU,IAAI,CAAC,IAAc;IACjC,IAAI,CAAC;QACH,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,aAAa,EAAE,CAAC;YACnC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YAC1B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;QACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC7C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AAC7B,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type CommandResult = {
|
|
2
|
-
error?: Error;
|
|
3
|
-
status: number | null;
|
|
4
|
-
stderr: string;
|
|
5
|
-
stdout: string;
|
|
6
|
-
};
|
|
7
|
-
export type CommandRunner = (command: string, args: string[]) => CommandResult;
|
|
8
|
-
export declare function runCommand(command: string, args: string[]): CommandResult;
|
|
9
|
-
export declare function formatCommandError(command: string, result: CommandResult): string;
|
|
10
|
-
export declare function gh(runner: CommandRunner, args: string[]): string;
|
|
11
|
-
export declare function validateGh(runner: CommandRunner): void;
|
|
12
|
-
export declare function ensureGhImageExtension(runner: CommandRunner): void;
|
|
13
|
-
export declare function editPrBody(runner: CommandRunner, pr: string, repo: string, body: string): void;
|
|
14
|
-
//# sourceMappingURL=github-cli.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"github-cli.d.mts","sourceRoot":"","sources":["../../src/github-cli.mts"],"names":[],"mappings":"AAOA,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,aAAa,CAAA;AAE9E,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,aAAa,CAYzE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,CAGjF;AAED,wBAAgB,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAMhE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAiBtD;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAmBlE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAS9F"}
|
package/dist/src/github-cli.mjs
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
const extensionName = 'drogers0/gh-image';
|
|
6
|
-
export function runCommand(command, args) {
|
|
7
|
-
const options = {
|
|
8
|
-
encoding: 'utf8',
|
|
9
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
10
|
-
};
|
|
11
|
-
const result = spawnSync(command, args, options);
|
|
12
|
-
return {
|
|
13
|
-
error: result.error,
|
|
14
|
-
status: result.status,
|
|
15
|
-
stderr: result.stderr ?? '',
|
|
16
|
-
stdout: result.stdout ?? '',
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export function formatCommandError(command, result) {
|
|
20
|
-
const detail = (result.error?.message ?? result.stderr.trim()) || result.stdout.trim();
|
|
21
|
-
return detail ? `${command} failed: ${detail}` : `${command} failed.`;
|
|
22
|
-
}
|
|
23
|
-
export function gh(runner, args) {
|
|
24
|
-
const result = runner('gh', args);
|
|
25
|
-
if (result.status !== 0) {
|
|
26
|
-
throw new Error(formatCommandError(`gh ${args.join(' ')}`, result));
|
|
27
|
-
}
|
|
28
|
-
return result.stdout.trim();
|
|
29
|
-
}
|
|
30
|
-
export function validateGh(runner) {
|
|
31
|
-
const result = runner('gh', ['--version']);
|
|
32
|
-
if (result.error !== undefined || result.status !== 0) {
|
|
33
|
-
throw new Error([
|
|
34
|
-
'`gh` (GitHub CLI) is not installed or not on PATH.',
|
|
35
|
-
'',
|
|
36
|
-
'Install it:',
|
|
37
|
-
' macOS: brew install gh',
|
|
38
|
-
' Linux: https://github.com/cli/cli#installation',
|
|
39
|
-
' Windows: winget install --id GitHub.cli',
|
|
40
|
-
'',
|
|
41
|
-
'Then authenticate:',
|
|
42
|
-
' gh auth login',
|
|
43
|
-
].join('\n'));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
export function ensureGhImageExtension(runner) {
|
|
47
|
-
const result = runner('gh', ['extension', 'list']);
|
|
48
|
-
if (result.status !== 0) {
|
|
49
|
-
throw new Error(formatCommandError('gh extension list', result));
|
|
50
|
-
}
|
|
51
|
-
if (result.stdout.includes(extensionName) || /^gh-image\b/m.test(result.stdout)) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
throw new Error([
|
|
55
|
-
'The `gh-image` extension is not installed.',
|
|
56
|
-
'',
|
|
57
|
-
'Install it (this may need to run outside any sandbox, as the extension',
|
|
58
|
-
'stores credentials under ~/.config/gh):',
|
|
59
|
-
' gh extension install drogers0/gh-image',
|
|
60
|
-
'',
|
|
61
|
-
'Project: https://github.com/drogers0/gh-image',
|
|
62
|
-
].join('\n'));
|
|
63
|
-
}
|
|
64
|
-
export function editPrBody(runner, pr, repo, body) {
|
|
65
|
-
const dir = mkdtempSync(join(tmpdir(), 'gh-pr-attach-screenshots-'));
|
|
66
|
-
const bodyFile = join(dir, 'body.md');
|
|
67
|
-
try {
|
|
68
|
-
writeFileSync(bodyFile, body);
|
|
69
|
-
gh(runner, ['pr', 'edit', pr, '--repo', repo, '--body-file', bodyFile]);
|
|
70
|
-
}
|
|
71
|
-
finally {
|
|
72
|
-
rmSync(dir, { force: true, recursive: true });
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=github-cli.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"github-cli.mjs","sourceRoot":"","sources":["../../src/github-cli.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA2C,MAAM,oBAAoB,CAAA;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,aAAa,GAAG,mBAAmB,CAAA;AAWzC,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,IAAc;IACxD,MAAM,OAAO,GAAuC;QAClD,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;KA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AC;YAAS,CAAC;QACT,MAAM,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC/C,CAAC;AACH,CAAC"}
|
package/dist/src/index.d.mts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { attachPrScreenshots, type AttachScreenshotOptions } from './attach.mts';
|
|
2
|
-
export { HelpRequested, parseArgs } from './parse-args.mts';
|
|
3
|
-
export { upsertScreenshotsSection } from './screenshots-section.mts';
|
|
4
|
-
export { type CommandResult, type CommandRunner, runCommand } from './github-cli.mts';
|
|
5
|
-
//# sourceMappingURL=index.d.mts.map
|
package/dist/src/index.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/index.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,KAAK,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AACpE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA"}
|
package/dist/src/index.mjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { attachPrScreenshots } from './attach.mts';
|
|
2
|
-
export { HelpRequested, parseArgs } from './parse-args.mts';
|
|
3
|
-
export { upsertScreenshotsSection } from './screenshots-section.mts';
|
|
4
|
-
export { runCommand } from './github-cli.mts';
|
|
5
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/src/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/index.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAgC,MAAM,cAAc,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AACpE,OAAO,EAA0C,UAAU,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type AttachScreenshotOptions = {
|
|
2
|
-
images: string[];
|
|
3
|
-
pr?: string;
|
|
4
|
-
repo?: string;
|
|
5
|
-
replace: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare class HelpRequested extends Error {
|
|
8
|
-
constructor();
|
|
9
|
-
}
|
|
10
|
-
export declare function parseArgs(args: string[]): AttachScreenshotOptions;
|
|
11
|
-
//# sourceMappingURL=parse-args.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-args.d.mts","sourceRoot":"","sources":["../../src/parse-args.mts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,qBAAa,aAAc,SAAQ,KAAK;;CAIvC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,uBAAuB,CAiDjE"}
|
package/dist/src/parse-args.mjs
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
export class HelpRequested extends Error {
|
|
2
|
-
constructor() {
|
|
3
|
-
super(usage());
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
export function parseArgs(args) {
|
|
7
|
-
const parsed = { images: [], replace: false };
|
|
8
|
-
for (let index = 0; index < args.length; index += 1) {
|
|
9
|
-
const arg = args[index];
|
|
10
|
-
if (arg === '--replace') {
|
|
11
|
-
parsed.replace = true;
|
|
12
|
-
continue;
|
|
13
|
-
}
|
|
14
|
-
if (arg === '--pr') {
|
|
15
|
-
parsed.pr = readOptionValue(args, index, '--pr');
|
|
16
|
-
index += 1;
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
if (arg.startsWith('--pr=')) {
|
|
20
|
-
parsed.pr = arg.slice('--pr='.length);
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
if (arg === '--repo') {
|
|
24
|
-
parsed.repo = readOptionValue(args, index, '--repo');
|
|
25
|
-
index += 1;
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
if (arg.startsWith('--repo=')) {
|
|
29
|
-
parsed.repo = arg.slice('--repo='.length);
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (arg === '--help' || arg === '-h') {
|
|
33
|
-
throw new HelpRequested();
|
|
34
|
-
}
|
|
35
|
-
if (arg.startsWith('-')) {
|
|
36
|
-
throw new Error(`Unknown option "${arg}".\n\n${usage()}`);
|
|
37
|
-
}
|
|
38
|
-
parsed.images.push(arg);
|
|
39
|
-
}
|
|
40
|
-
if (parsed.images.length === 0) {
|
|
41
|
-
throw new Error(`At least one image path is required.\n\n${usage()}`);
|
|
42
|
-
}
|
|
43
|
-
return parsed;
|
|
44
|
-
}
|
|
45
|
-
function readOptionValue(args, index, option) {
|
|
46
|
-
const value = args[index + 1];
|
|
47
|
-
if (value === undefined || value.startsWith('-')) {
|
|
48
|
-
throw new Error(`${option} requires a value.`);
|
|
49
|
-
}
|
|
50
|
-
return value;
|
|
51
|
-
}
|
|
52
|
-
function usage() {
|
|
53
|
-
return [
|
|
54
|
-
'Usage: gh-pr-attach-screenshots [--pr <number|branch|url>] [--repo owner/repo] [--replace] <image...>',
|
|
55
|
-
'',
|
|
56
|
-
'Uploads screenshots with gh-image and attaches them to the PR description.',
|
|
57
|
-
'',
|
|
58
|
-
'Options:',
|
|
59
|
-
' --pr <value> PR number, branch name, or URL (defaults to current branch PR)',
|
|
60
|
-
' --repo <value> Repository in owner/repo format (defaults to current repo)',
|
|
61
|
-
' --replace Replace existing screenshots instead of merging',
|
|
62
|
-
' --help, -h Show this help message',
|
|
63
|
-
'',
|
|
64
|
-
'Prerequisites:',
|
|
65
|
-
' - gh (GitHub CLI): brew install gh && gh auth login',
|
|
66
|
-
' - gh-image extension: gh extension install drogers0/gh-image',
|
|
67
|
-
' (may need to run outside any sandbox)',
|
|
68
|
-
].join('\n');
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=parse-args.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-args.mjs","sourceRoot":"","sources":["../../src/parse-args.mts"],"names":[],"mappings":"AAOA,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC;QACE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAA;IAChB,CAAC;CACF;AAED,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,MAAM,MAAM,GAA4B,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;IAEtE,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACpD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAE,CAAA;QAExB,IAAI,GAAG,KAAK,WAAW,EAAE,CAAC;YACxB,MAAM,CAAC,OAAO,GAAG,IAAI,CAAA;YACrB,SAAQ;QACV,CAAC;QAED,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;YACnB,MAAM,CAAC,EAAE,GAAG,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;YAChD,KAAK,IAAI,CAAC,CAAA;YACV,SAAQ;QACV,CAAC;QAED,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,MAAM,CAAC,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACrC,SAAQ;QACV,CAA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EAAE;QACF,4EAA4E;QAC5E,EAAE;QACF,UAAU;QACV,kFAAkF;QAClF,8EAA8E;QAC9E,mEAAmE;QACnE,0CAA0C;QAC1C,EAAE;QACF,gBAAgB;QAChB,uDAAuD;QACvD,gEAAgE;QAChE,2CAA2C;KAC5C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"screenshots-section.d.mts","sourceRoot":"","sources":["../../src/screenshots-section.mts"],"names":[],"mappings":"AAGA,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,EAAE,EACvB,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GAChC,MAAM,CAeR"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const sectionStart = '<!-- agent-screenshots:start -->';
|
|
2
|
-
const sectionEnd = '<!-- agent-screenshots:end -->';
|
|
3
|
-
export function upsertScreenshotsSection(body, imageMarkdown, { replace }) {
|
|
4
|
-
const existingSection = findScreenshotsSection(body);
|
|
5
|
-
const existingImages = existingSection === null || replace ? [] : screenshotLines(existingSection.content);
|
|
6
|
-
const nextImages = dedupe([
|
|
7
|
-
...existingImages,
|
|
8
|
-
...imageMarkdown.map(line => line.trim()).filter(Boolean),
|
|
9
|
-
]);
|
|
10
|
-
const nextSection = renderScreenshotsSection(nextImages);
|
|
11
|
-
if (existingSection === null) {
|
|
12
|
-
return `${body.trimEnd()}\n\n${nextSection}\n`;
|
|
13
|
-
}
|
|
14
|
-
return `${body.slice(0, existingSection.start)}${nextSection}${body.slice(existingSection.end)}`;
|
|
15
|
-
}
|
|
16
|
-
function findScreenshotsSection(body) {
|
|
17
|
-
const startMarker = body.indexOf(sectionStart);
|
|
18
|
-
const endMarker = body.indexOf(sectionEnd, startMarker + sectionStart.length);
|
|
19
|
-
if (startMarker === -1 || endMarker === -1) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
const headingStart = body.lastIndexOf('## Screenshots', startMarker);
|
|
23
|
-
const start = headingStart === -1 ? startMarker : headingStart;
|
|
24
|
-
const end = endMarker + sectionEnd.length;
|
|
25
|
-
return {
|
|
26
|
-
content: body.slice(startMarker + sectionStart.length, endMarker),
|
|
27
|
-
end,
|
|
28
|
-
start,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function screenshotLines(content) {
|
|
32
|
-
return content
|
|
33
|
-
.split('\n')
|
|
34
|
-
.map(line => line.trim())
|
|
35
|
-
.filter(line => line.startsWith(');
|
|
36
|
-
}
|
|
37
|
-
function dedupe(values) {
|
|
38
|
-
return [...new Set(values)];
|
|
39
|
-
}
|
|
40
|
-
function renderScreenshotsSection(imageMarkdown) {
|
|
41
|
-
return ['## Screenshots', sectionStart, ...imageMarkdown, sectionEnd].join('\n');
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=screenshots-section.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"screenshots-section.mjs","sourceRoot":"","sources":["../../src/screenshots-section.mts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAG,kCAAkC,CAAA;AACvD,MAAM,UAAU,GAAG,gCAAgC,CAAA;AAEnD,MAAM,UAAU,wBAAwB,CACtC,IAAY,EACZ,aAAuB,EACvB,EAAE,OAAO,EAAwB;IAEjC,MAAM,eAAe,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAA;IACpD,MAAM,cAAc,GAClB,eAAe,KAAK,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IACrF,MAAM,UAAU,GAAG,MAAM,CAAC;QACxB,GAAG,cAAc;QACjB,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,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