main 98594d0

golden.mjs RawHistoryFolder

1// SPDX-License-Identifier: MIT
2//
3// Writes the golden files of TestToJSONGolden: for each input testdata/tojson/NAME.json
4// it writes NAME.golden, which is what the reference implementation
5// (@actions/expressions) prints for toJSON(fromJSON(input)), that is
6// JSON.stringify(JSON.parse(input, reviver), replacer, "  ").
7//
8//   node gen/golden.mjs /path/to/@actions/expressions/dist testdata/tojson
9//
10// New inputs are added by hand to that directory (and listed in INPUTS below
11// when they are generated rather than written out).
12
13import { pathToFileURL } from "node:url";
14import path from "node:path";
15import fs from "node:fs";
16
17const dist = path.resolve(process.argv[2]);
18const dir = process.argv[3];
19const { data } = await import(pathToFileURL(path.join(dist, "index.js")).href);
20
21const INPUTS = {
22  null: "null",
23  true: "true",
24  false: "false",
25  zero: "0",
26  negzero: "-0",
27  int: "42",
28  negative: "-17",
29  float: "1.5",
30  exp_small: "1e-7",
31  exp_large: "1e21",
32  exp_20: "1e20",
33  exp_pos: "1E2",
34  precision: "0.30000000000000004",
35  big_int: "12345678901234567890",
36  max_double: "1.7976931348623157e308",
37  min_double: "5e-324",
38  overflow: "1e999",
39  string_empty: '""',
40  string_plain: '"hello"',
41  string_escapes: '"quote \\" backslash \\\\ slash \\/ nl \\n cr \\r tab \\t bs \\b ff \\f"',
42  string_control: '"\\u0000\\u0001\\u001f\\u007f\\u0080"',
43  string_unicode: '"h\\u00e9llo \\u4e16\\u754c \\ud83d\\ude00 \\u2028\\u2029"',
44  string_lone_surrogate: '"\\ud800"',
45  array_empty: "[]",
46  array_flat: "[1,2,3]",
47  array_mixed: '[null,true,"a",1.5,[],{}]',
48  array_nested: "[[1,[2,[3,[]]]],[]]",
49  object_empty: "{}",
50  object_flat: '{"a":1,"b":"two","c":null}',
51  object_nested: '{"a":{"b":{"c":{"d":[1,{"e":2}]}}},"f":[]}',
52  object_order: '{"b":1,"a":2,"c":3}',
53  object_numeric_keys: '{"b":1,"10":2,"2":3,"a":4,"01":5,"1":6,"4294967294":7,"4294967295":8,"-1":9}',
54  object_case_dup: '{"a":1,"A":2,"b":3,"B":4}',
55  object_dup_key: '{"a":1,"b":2,"a":3}',
56  object_empty_key: '{"":1,"a":2}',
57  object_key_escapes: '{"quote\\"key":1,"new\\nline":2,"\\u00e9":3}',
58  github_event: '{"action":"opened","number":1,"pull_request":{"id":1,"draft":false,"labels":[{"name":"bug","color":"d73a4a"},{"name":"docs","color":null}],"head":{"ref":"feat/x","sha":"abc123"}},"repository":{"full_name":"octo/repo","private":true,"topics":[]}}',
59};
60
61fs.mkdirSync(dir, { recursive: true });
62for (const [name, text] of Object.entries(INPUTS)) {
63  fs.writeFileSync(path.join(dir, name + ".json"), text + "\n");
64}
65for (const f of fs.readdirSync(dir).filter(f => f.endsWith(".json")).sort()) {
66  const text = fs.readFileSync(path.join(dir, f), "utf8");
67  const value = JSON.parse(text, data.reviver);
68  fs.writeFileSync(path.join(dir, f.replace(/\.json$/, ".golden")), JSON.stringify(value, data.replacer, "  "));
69}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 3

↑↓ moveenter openesc close