vouchington-tooling 0.80.1 → 0.81.0
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/README.md +5 -0
- package/dist/gitleaks-workflow-helpers.d.mts +47 -0
- package/dist/gitleaks-workflow-helpers.mjs +142 -0
- package/dist/playwright/index.d.mts +1 -1
- package/dist/playwright/index.mjs +1 -1
- package/dist/playwright/storybook.d.mts +5 -0
- package/dist/playwright/storybook.mjs +18 -3
- package/package.json +1 -1
- package/scripts/__pycache__/run_bounded_process.cpython-314.pyc +0 -0
package/README.md
CHANGED
|
@@ -993,6 +993,11 @@ random suffixes, viewport sizes, a 1x1 PNG fixture, RFC 6238 TOTP codes, and a t
|
|
|
993
993
|
reporter. The reporter prints one JSON line per test with the marker `playwright-test-lifecycle`.
|
|
994
994
|
`@playwright/test` is an optional peer. TOTP setup and cleanup stay with the caller.
|
|
995
995
|
|
|
996
|
+
`storybookBundleHasStory` returns `false` for a readable index without the requested story.
|
|
997
|
+
An index request failure or non-OK HTTP response throws `StorybookIndexAccessError`, with
|
|
998
|
+
`kind` (`request` or `http`) and an HTTP `status` when available. Its diagnostic omits request
|
|
999
|
+
credentials and response bodies. Malformed JSON remains a hard failure.
|
|
1000
|
+
|
|
996
1001
|
`createBrowserErrorsFixture`, `withMonitoredPage`, and `BrowserIssueMonitor` take the narrow
|
|
997
1002
|
exported `MonitoredTestInfo` type (`attach`, `status`, `expectedStatus`, `timeout`) instead of
|
|
998
1003
|
Playwright's full `TestInfo`. A real `TestInfo` is assignable to it, so no cast is needed.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface Step {
|
|
2
|
+
id?: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
run?: string;
|
|
5
|
+
uses?: string;
|
|
6
|
+
env?: Record<string, string>;
|
|
7
|
+
with?: Record<string, unknown>;
|
|
8
|
+
if?: string;
|
|
9
|
+
'timeout-minutes'?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const source: string;
|
|
12
|
+
export declare const workflow: {
|
|
13
|
+
on: {
|
|
14
|
+
workflow_call: {
|
|
15
|
+
inputs: Record<string, {
|
|
16
|
+
default?: string;
|
|
17
|
+
}>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
jobs: {
|
|
21
|
+
gitleaks: {
|
|
22
|
+
"timeout-minutes": number;
|
|
23
|
+
steps: Step[];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const steps: Step[];
|
|
28
|
+
export declare function step(name: string): Step;
|
|
29
|
+
export declare const FAKE_TIP: string;
|
|
30
|
+
export declare const FAKE_TOP: string;
|
|
31
|
+
export declare const FAKE_BOUNDARY: string;
|
|
32
|
+
export declare function runRange(env: Record<string, string>): {
|
|
33
|
+
fetchCalls: string;
|
|
34
|
+
status: number | null;
|
|
35
|
+
stderr: string;
|
|
36
|
+
stdout: string;
|
|
37
|
+
written: string;
|
|
38
|
+
};
|
|
39
|
+
export declare function git(cwd: string, ...args: string[]): string;
|
|
40
|
+
export declare function shallowClient(remote: string, directory: string, refspec: string, ref: string): void;
|
|
41
|
+
export declare function writeGhStub(directory: string, sourceRepo: string): void;
|
|
42
|
+
export declare function runActualRange(directory: string, env: Record<string, string>): {
|
|
43
|
+
stderr: string;
|
|
44
|
+
status: number | null;
|
|
45
|
+
stdout: string;
|
|
46
|
+
written: string;
|
|
47
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync, } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { dirname, join, resolve } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { parse as load } from 'yaml';
|
|
7
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '../../..');
|
|
8
|
+
export const source = readFileSync(join(root, '.github/workflows/gitleaks.yml'), 'utf8');
|
|
9
|
+
export const workflow = load(source);
|
|
10
|
+
export const steps = workflow.jobs.gitleaks.steps;
|
|
11
|
+
export function step(name) {
|
|
12
|
+
const found = steps.find((candidate) => candidate.name === name);
|
|
13
|
+
if (!found?.run)
|
|
14
|
+
throw new Error(`missing step ${name}`);
|
|
15
|
+
return found;
|
|
16
|
+
}
|
|
17
|
+
export const FAKE_TIP = 'f'.repeat(40);
|
|
18
|
+
export const FAKE_TOP = '1'.repeat(40);
|
|
19
|
+
export const FAKE_BOUNDARY = 'e'.repeat(40);
|
|
20
|
+
export function runRange(env) {
|
|
21
|
+
const directory = mkdtempSync(join(tmpdir(), 'gitleaks-range-'));
|
|
22
|
+
const bin = join(directory, 'bin');
|
|
23
|
+
const output = join(directory, 'output');
|
|
24
|
+
const fetchLog = join(directory, 'fetch-log');
|
|
25
|
+
mkdirSync(bin);
|
|
26
|
+
writeFileSync(join(bin, 'git'), `#!/bin/bash
|
|
27
|
+
if [ "$1" = fetch ]; then printf '%s\\n' "$*" >> "$GIT_FETCH_LOG"; exit 0; fi
|
|
28
|
+
if [ "$1" = rev-list ] && [ "$2" = --no-walk ]; then [ -z "$GIT_PARENTS" ] || printf '%b\n' "$GIT_PARENTS"; exit 0; fi
|
|
29
|
+
if [ "$1" = rev-list ]; then [ -z "$GIT_RANGE" ] || printf '%b\n' "$GIT_RANGE"; exit 0; fi
|
|
30
|
+
echo "unexpected git $*" >&2
|
|
31
|
+
exit 1
|
|
32
|
+
`);
|
|
33
|
+
chmodSync(join(bin, 'git'), 0o755);
|
|
34
|
+
writeFileSync(join(bin, 'gh'), `#!/bin/bash
|
|
35
|
+
printf 'api %s\n' "$2" >> "$GIT_FETCH_LOG"
|
|
36
|
+
case "$2" in *'&page='*) printf '%b\n' "$GH_COMMITS" ;; *) printf '%s\n' "$GH_AHEAD" ;; esac
|
|
37
|
+
`);
|
|
38
|
+
chmodSync(join(bin, 'gh'), 0o755);
|
|
39
|
+
try {
|
|
40
|
+
const result = spawnSync('bash', [
|
|
41
|
+
'--noprofile',
|
|
42
|
+
'--norc',
|
|
43
|
+
'-eo',
|
|
44
|
+
'pipefail',
|
|
45
|
+
'-c',
|
|
46
|
+
step('Determine Gitleaks scan range').run ?? '',
|
|
47
|
+
], {
|
|
48
|
+
encoding: 'utf8',
|
|
49
|
+
timeout: 10_000,
|
|
50
|
+
env: {
|
|
51
|
+
...process.env,
|
|
52
|
+
PATH: `${bin}:${process.env.PATH ?? ''}`,
|
|
53
|
+
GITHUB_OUTPUT: output,
|
|
54
|
+
GIT_FETCH_LOG: fetchLog,
|
|
55
|
+
GH_TOKEN: 'test-token',
|
|
56
|
+
GITHUB_REPOSITORY: 'owner/repo',
|
|
57
|
+
GH_AHEAD: '2',
|
|
58
|
+
GH_COMMITS: `${FAKE_TIP}\n${FAKE_TOP}`,
|
|
59
|
+
GIT_PARENTS: `${FAKE_TIP} ${FAKE_BOUNDARY}\n${FAKE_TOP} ${FAKE_TIP}`,
|
|
60
|
+
GIT_RANGE: `${FAKE_TIP}\n${FAKE_TOP}`,
|
|
61
|
+
...env,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
const written = result.status === 0 ? readFileSync(output, 'utf8') : '';
|
|
65
|
+
return {
|
|
66
|
+
fetchCalls: existsSync(fetchLog) ? readFileSync(fetchLog, 'utf8') : '',
|
|
67
|
+
status: result.status,
|
|
68
|
+
stderr: result.stderr,
|
|
69
|
+
stdout: result.stdout,
|
|
70
|
+
written,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
rmSync(directory, { recursive: true, force: true });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export function git(cwd, ...args) {
|
|
78
|
+
const result = spawnSync('git', ['-C', cwd, ...args], { encoding: 'utf8', timeout: 10_000 });
|
|
79
|
+
if (result.status !== 0) {
|
|
80
|
+
throw new Error(`git ${args.join(' ')} failed: ${result.stderr}`);
|
|
81
|
+
}
|
|
82
|
+
return result.stdout.trim();
|
|
83
|
+
}
|
|
84
|
+
export function shallowClient(remote, directory, refspec, ref) {
|
|
85
|
+
mkdirSync(directory);
|
|
86
|
+
git(directory, 'init', '--quiet');
|
|
87
|
+
git(directory, 'remote', 'add', 'origin', remote);
|
|
88
|
+
git(directory, 'fetch', '--quiet', '--depth=1', 'origin', refspec);
|
|
89
|
+
git(directory, 'checkout', '--quiet', '--detach', ref);
|
|
90
|
+
}
|
|
91
|
+
let ghStubDir = '';
|
|
92
|
+
export function writeGhStub(directory, sourceRepo) {
|
|
93
|
+
ghStubDir = join(directory, 'gh-bin');
|
|
94
|
+
mkdirSync(ghStubDir);
|
|
95
|
+
writeFileSync(join(ghStubDir, 'gh'), `#!/bin/bash
|
|
96
|
+
url="$2"
|
|
97
|
+
range="\${url##*/compare/}"
|
|
98
|
+
range="\${range%%[?]*}"
|
|
99
|
+
base="\${range%%...*}"
|
|
100
|
+
head="\${range##*...}"
|
|
101
|
+
mb=$(git -C '${sourceRepo}' merge-base "$base" "$head")
|
|
102
|
+
case "$url" in
|
|
103
|
+
*'&page='*)
|
|
104
|
+
size="\${url##*per_page=}"
|
|
105
|
+
size="\${size%%&*}"
|
|
106
|
+
page="\${url##*&page=}"
|
|
107
|
+
git -C '${sourceRepo}' rev-list "$mb..$head" | sed -n "$(( (page - 1) * size + 1 )),$(( page * size ))p"
|
|
108
|
+
;;
|
|
109
|
+
*) git -C '${sourceRepo}' rev-list --count "$mb..$head" ;;
|
|
110
|
+
esac
|
|
111
|
+
`);
|
|
112
|
+
chmodSync(join(ghStubDir, 'gh'), 0o755);
|
|
113
|
+
}
|
|
114
|
+
export function runActualRange(directory, env) {
|
|
115
|
+
const output = join(directory, 'range-output');
|
|
116
|
+
const result = spawnSync('bash', [
|
|
117
|
+
'--noprofile',
|
|
118
|
+
'--norc',
|
|
119
|
+
'-eo',
|
|
120
|
+
'pipefail',
|
|
121
|
+
'-c',
|
|
122
|
+
step('Determine Gitleaks scan range').run ?? '',
|
|
123
|
+
], {
|
|
124
|
+
encoding: 'utf8',
|
|
125
|
+
cwd: directory,
|
|
126
|
+
timeout: 30_000,
|
|
127
|
+
env: {
|
|
128
|
+
...process.env,
|
|
129
|
+
GITHUB_OUTPUT: output,
|
|
130
|
+
GH_TOKEN: 'test-token',
|
|
131
|
+
GITHUB_REPOSITORY: 'owner/repo',
|
|
132
|
+
PATH: `${ghStubDir}:${process.env.PATH ?? ''}`,
|
|
133
|
+
...env,
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
return {
|
|
137
|
+
stderr: result.stderr,
|
|
138
|
+
status: result.status,
|
|
139
|
+
stdout: result.stdout,
|
|
140
|
+
written: result.status === 0 ? readFileSync(output, 'utf8') : '',
|
|
141
|
+
};
|
|
142
|
+
}
|
|
@@ -23,7 +23,7 @@ export { assertNoHorizontalScroll, getHorizontalOverflowState } from './mobile-a
|
|
|
23
23
|
export type { HorizontalOverflowState } from './mobile-assertions.mts';
|
|
24
24
|
export { openRadixDropdown } from './radix-select.mts';
|
|
25
25
|
export { randomSuffix } from './random-id.mts';
|
|
26
|
-
export { storybookBundleHasStory } from './storybook.mts';
|
|
26
|
+
export { StorybookIndexAccessError, storybookBundleHasStory } from './storybook.mts';
|
|
27
27
|
export { TEST_PNG } from './test-fixtures.mts';
|
|
28
28
|
export { TestLifecycleReporter };
|
|
29
29
|
export type { TestLifecycleReporterOptions } from './test-lifecycle-reporter.mts';
|
|
@@ -14,7 +14,7 @@ export { installImageResponseGuard } from "./expect-no-broken-images.mjs";
|
|
|
14
14
|
export { assertNoHorizontalScroll, getHorizontalOverflowState } from "./mobile-assertions.mjs";
|
|
15
15
|
export { openRadixDropdown } from "./radix-select.mjs";
|
|
16
16
|
export { randomSuffix } from "./random-id.mjs";
|
|
17
|
-
export { storybookBundleHasStory } from "./storybook.mjs";
|
|
17
|
+
export { StorybookIndexAccessError, storybookBundleHasStory } from "./storybook.mjs";
|
|
18
18
|
export { TEST_PNG } from "./test-fixtures.mjs";
|
|
19
19
|
export { TestLifecycleReporter };
|
|
20
20
|
export { generateTotpCode } from "./totp.mjs";
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { Page } from '@playwright/test';
|
|
2
|
+
export declare class StorybookIndexAccessError extends Error {
|
|
3
|
+
readonly kind: 'request' | 'http';
|
|
4
|
+
readonly status: number | undefined;
|
|
5
|
+
constructor(status?: number);
|
|
6
|
+
}
|
|
2
7
|
export declare function storybookBundleHasStory(page: Page, id: string): Promise<boolean>;
|
|
@@ -1,13 +1,28 @@
|
|
|
1
|
+
const INDEX_PATH = '/storybook/index.json';
|
|
2
|
+
const REQUEST_TIMEOUT_MS = 5000;
|
|
3
|
+
export class StorybookIndexAccessError extends Error {
|
|
4
|
+
kind;
|
|
5
|
+
status;
|
|
6
|
+
constructor(status) {
|
|
7
|
+
super(status === undefined
|
|
8
|
+
? `Storybook index ${INDEX_PATH} request failed (timeout bound: ${REQUEST_TIMEOUT_MS} ms)`
|
|
9
|
+
: `Storybook index ${INDEX_PATH} returned HTTP ${status}`);
|
|
10
|
+
this.name = 'StorybookIndexAccessError';
|
|
11
|
+
this.kind = status === undefined ? 'request' : 'http';
|
|
12
|
+
this.status = status;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
1
15
|
export async function storybookBundleHasStory(page, id) {
|
|
2
16
|
let response;
|
|
3
17
|
try {
|
|
4
|
-
response = await page.request.get(
|
|
18
|
+
response = await page.request.get(INDEX_PATH, { timeout: REQUEST_TIMEOUT_MS });
|
|
5
19
|
}
|
|
6
20
|
catch {
|
|
7
|
-
|
|
21
|
+
// Playwright transport errors can contain request URLs and headers with credentials.
|
|
22
|
+
throw new StorybookIndexAccessError();
|
|
8
23
|
}
|
|
9
24
|
if (!response.ok())
|
|
10
|
-
|
|
25
|
+
throw new StorybookIndexAccessError(response.status());
|
|
11
26
|
const storyIndex = (await response.json());
|
|
12
27
|
return id in (storyIndex.entries ?? {});
|
|
13
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vouchington-tooling",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.81.0",
|
|
4
4
|
"description": "Vouchington CLI and extractable tooling libraries.",
|
|
5
5
|
"homepage": "https://github.com/vouchington/vouchington-tooling/tree/main/packages/vouchington-tooling#readme",
|
|
6
6
|
"bugs": {
|
|
Binary file
|