@exodus/stasis 1.0.0-beta.14 → 1.0.0-beta.16
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 +2 -1
- package/bin/stasis.js +99 -16
- package/package.json +22 -9
- package/src/audit-corrections.js +11 -42
- package/src/audit.js +241 -190
- package/src/babel.js +39 -122
- package/src/bundle-from-lockfile.js +9 -21
- package/src/bundle-reader.js +5 -9
- package/src/bundle.js +0 -3
- package/src/cmd/build.js +82 -174
- package/src/cmd/bundle-options.js +113 -167
- package/src/cmd/bundle.js +942 -1294
- package/src/cmd/diff.js +1 -4
- package/src/cmd/github-bundle.js +21 -26
- package/src/cmd/output.js +15 -12
- package/src/cmd/sbom.js +3 -8
- package/src/cmd/tokens.js +16 -23
- package/src/define.js +36 -94
- package/src/diff.js +72 -128
- package/src/esbuild.js +0 -4
- package/src/flow.js +18 -13
- package/src/installed.js +265 -0
- package/src/json-stream.js +4 -9
- package/src/loader-mock.js +3 -8
- package/src/loader.js +1 -5
- package/src/loaders/bash.js +41 -93
- package/src/loaders/cargo.js +298 -805
- package/src/loaders/foundry.js +109 -285
- package/src/loaders/paths.js +13 -13
- package/src/loaders/php.js +210 -489
- package/src/loaders/rust.js +507 -1430
- package/src/loaders/solidity-ownership.js +48 -128
- package/src/loaders/solidity.js +39 -122
- package/src/loaders/toml.js +7 -17
- package/src/lockfile.js +0 -3
- package/src/metro-assets.js +10 -384
- package/src/metro-resolver.js +58 -134
- package/src/metro-transformer.js +0 -5
- package/src/metro.js +0 -4
- package/src/mock.js +32 -80
- package/src/parse.js +4 -4
- package/src/prune.js +0 -3
- package/src/resolve-fields.js +137 -532
- package/src/resolve-node.js +27 -45
- package/src/resolve-typescript.js +166 -298
- package/src/rollup.js +0 -4
- package/src/run-installed.js +10 -0
- package/src/sbom.js +52 -128
- package/src/scan.js +142 -284
- package/src/sixel.js +310 -0
- package/src/table.js +63 -31
- package/src/validate-notes.d.ts +19 -0
- package/src/validate-notes.js +72 -0
- package/src/validate.d.ts +159 -0
- package/src/validate.js +596 -522
- package/src/vfs-bundle/entries.js +40 -57
- package/src/vfs-bundle/github.js +80 -122
- package/src/vfs-bundle/glob.js +4 -45
- package/src/vfs-bundle/lazy.js +27 -56
- package/src/vfs-bundle/prisma.js +235 -105
- package/src/vfs-bundle/soldeer.js +28 -49
- package/src/vfs-bundle/tree.js +295 -318
- package/src/vfs-bundle/yarnclean.js +10 -31
- package/src/vfs-bundle.js +23 -64
- package/src/webpack.js +0 -4
- package/src/why.js +78 -232
- package/src/installed-commits.js +0 -184
package/src/sixel.js
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
// Sixel logos `stasis audit` may draw beside an advisory's source: square pixels (P1 9, raster 1:1), the background
|
|
2
|
+
// left as is (P2 1), 8 colours at most, edges inside blended, and, as nothing tells what it's drawn over, an outline
|
|
3
|
+
// pixel where half is covered.
|
|
4
|
+
|
|
5
|
+
// npm's registry (upstream's `registry` source): simple-icons' npm (16.36.0, CC0-1.0), #CB3837, its
|
|
6
|
+
// knocked-out n filled white.
|
|
7
|
+
export const NPM = '\x1bP9;1q"1;1;16;16#1;2;80;22;22#2;2;100;100;100#3;2;91;66;66#4;2;94;78;77#5;2;89;56;56#6;2;92;71;71#7;2;97;88;88#8;2;85;42;42' +
|
|
8
|
+
'#1~~~!10F~~~$#2!4?!4oOOoo$#3???o$#5!4?!8G$#6!12?o$#7!8?__$#8???G!8?G-' +
|
|
9
|
+
'#1~~~!5?~~???~~~$#2!4?!4~???~$#3???~$#4!10?~$#6!12?~-' +
|
|
10
|
+
'#1NNN!5MNNMMMNNN$#3!10?@?@$#4!4?!4@$#5???@$#7!11?@' +
|
|
11
|
+
'\x1b\\'
|
|
12
|
+
|
|
13
|
+
// A GitHub repository's advisories (`repository`): simple-icons' GitHub (16.36.0, CC0-1.0), #181717, its
|
|
14
|
+
// knocked-out Octocat filled white, so that the mark shows on a dark terminal too.
|
|
15
|
+
export const GITHUB = '\x1bP9;1q"1;1;16;16#1;2;9;9;9#2;2;100;100;100#3;2;15;15;15#4;2;90;90;90#5;2;45;45;45#6;2;26;26;26#7;2;80;80;80#8;2;57;57;57' +
|
|
16
|
+
'#1_o{CEE!4NEEC{o_$#2!4?o!6_o$#3!5?G!4?G$#4!5?O?OO?O$#5???oG!6?Go$#6???G!8?G$#7!6?O??O-' +
|
|
17
|
+
'#1^~X!9?_x~^$#2???E^^^~~^^^E$#3??E!10?E$#4???H??_??_$#5??_$#6???o_!6?_O$#7!12?H$#8!5?_!4?_-' +
|
|
18
|
+
'#1?@AC!6?FFFB@$#2!4?AAMNNG$#3??@?CL!4?G$#4!6?@??F$#5???A$#6!4?@$#7???@' +
|
|
19
|
+
'\x1b\\'
|
|
20
|
+
|
|
21
|
+
// OSV (`osv`): OSV's logo as @preventive/triage draws an advisory's source (viewBox 0 75 405 400), its
|
|
22
|
+
// ring, `currentColor` there, triage's muted grey (#8b949e).
|
|
23
|
+
export const OSV = '\x1bP9;1q"1;1;16;16#1;2;55;58;62#2;2;88;13;16#3;2;98;86;86#4;2;92;43;45#5;2;94;62;63#6;2;88;17;20#7;2;96;74;75#8;2;99;95;95' +
|
|
24
|
+
'#1?o{{MM!4FEM[{o$#2!5?__OO__$#6!7?__-' +
|
|
25
|
+
'#1N~~O!8?o~~N$#2!5?^PooP^E$#3!7?IK$#4!6?I??I$#5!6?C@@C$#7!8?A$#8!7?C-' +
|
|
26
|
+
'#1???CEF!4MFFB@' +
|
|
27
|
+
'\x1b\\'
|
|
28
|
+
|
|
29
|
+
// The three at each size, made as those above are: 16 pixels for most terminals' cells, more for larger ones, as a
|
|
30
|
+
// Retina screen's are in iTerm2, two pixels a point.
|
|
31
|
+
const LOGOS = {
|
|
32
|
+
12: {
|
|
33
|
+
npm: '\x1bP9;1q"1;1;12;12#1;2;80;22;22#2;2;100;100;100#3;2;84;40;40#4;2;93;71;71#5;2;90;61;61#6;2;89;56;56#7;' +
|
|
34
|
+
'2;89;57;57#8;2;89;59;59#1~~F!3BbBBF~~$#2!3?!3wGGw$#3!3?!4CcC$#4!7?O$#5!6?O$#6??w$#8!9?w-#1~~!4o~!3o~' +
|
|
35
|
+
'~$#2!3?!3F??F$#3??G!4?N?G$#5!3?!3G??G$#7??F$#8!9?F\x1b\\',
|
|
36
|
+
github: '\x1bP9;1q"1;1;12;12#1;2;99;99;99#2;2;9;9;9#3;2;14;13;13#4;2;42;42;42#5;2;11;10;10#6;2;73;73;73#1!3?!6w$' +
|
|
37
|
+
'#2owAABEEBAAwO$#3?CC??@@??CC$#4??WC!4?CW$#5!4?C??C!3?_$#6??_!6?_-#1!3?BB^^BB$#2CB!6?WKFE$#3?CO_$#4??' +
|
|
38
|
+
'E[_??wCA$#5BG!7?OG@$#6??H?[??C?@\x1b\\',
|
|
39
|
+
osv: '\x1bP9;1q"1;1;12;12#1;2;99;89;89#2;2;55;58;62#3;2;54;58;62#4;2;94;54;55#5;2;88;18;20#2??G?@?@??O$#3o{EE' +
|
|
40
|
+
'ABABEM{o$#4!5?__$#5!3?_oWWo_-#1!5?@@$#2!4?_??_?A?@$#3BFEOOooWW[NA$#4!6?A$#5!3?@BECB@\x1b\\',
|
|
41
|
+
},
|
|
42
|
+
14: {
|
|
43
|
+
npm: '\x1bP9;1q"1;1;14;14#1;2;80;22;22#2;2;100;100;100#3;2;84;38;37#4;2;80;25;24#5;2;80;23;23#6;2;79;22;21#1}' +
|
|
44
|
+
'~~!9F~}$#2!3?!4wWWww$#3!7?__$#4!11?w$#6@!12?@-#1~~@!4?_~??_~~$#2!3?!4^??^^$#3!3?!4_??__$#4!11?^$#5??' +
|
|
45
|
+
']!4?^$#6??_-#1!13B@$#6!13?A\x1b\\',
|
|
46
|
+
github: '\x1bP9;1q"1;1;14;14#1;2;10;9;9#2;2;99;99;99#3;2;9;9;9#4;2;20;20;20#5;2;45;45;45#6;2;77;77;77#1_w[C!6EC[' +
|
|
47
|
+
'w$#2!3?_!6o_$#3!3?A??@@??A??_$#4??_!8?_$#5!5?!4G$#6!3?WG!4?GW-#1B^g?O!4?oowNB$#2!3?FNn~~NNF$#3K_!10?' +
|
|
48
|
+
'oK$#4??C!8?C$#5??RW!4?O?GB$#6!3?__O??_-#1!9?@@$#2!6?@@$#3??@@A!4?A?@$#4!4?@$#6!5?@??@\x1b\\',
|
|
49
|
+
osv: '\x1bP9;1q"1;1;14;14#1;2;99;91;91#2;2;54;58;62#3;2;88;12;16#4;2;95;62;63#5;2;55;58;62#6;2;90;31;34#2?GcG' +
|
|
50
|
+
'D@@?@?A_G_$#3!4?_oOOo_$#4!6?__$#5_oWE!3ABEEK[o-#1!6?AA$#2@?A?!4_!3?DOE$#3!4?F!4GF$#4!6?DD$#5E^L!5?__' +
|
|
51
|
+
'oyN@$#6!5?F??F-#2!5?!4A?@$#5!3?!7@\x1b\\',
|
|
52
|
+
},
|
|
53
|
+
16: { npm: NPM, github: GITHUB, osv: OSV },
|
|
54
|
+
20: {
|
|
55
|
+
npm: '\x1bP9;1q"1;1;20;20#1;2;80;22;22#2;2;100;100;100#3;2;89;58;58#4;2;80;22;21#5;2;95;79;79#6;2;80;24;24#7;' +
|
|
56
|
+
'2;82;31;31#8;2;96;84;84#1|!3~!12N!4~$#2!5?!10_$#3!4?!12O$#4A$#5!4?_$#8!15?_-#1!4~!7?{!4?!4~$#2!5?!5~' +
|
|
57
|
+
'!3@~~$#3!12?A$#5!4?~$#6!10?{$#7!10?AA{$#8!15?~-#1!4~!7o~!4o!4~$#2!5?!5N!3?NN$#5!4?N$#6!10?N$#7!12?N$' +
|
|
58
|
+
'#8!15?N-#1?@!16B@@$#4@A!16?A\x1b\\',
|
|
59
|
+
github: '\x1bP9;1q"1;1;20;20#1;2;18;18;18#2;2;100;100;100#3;2;9;9;9#4;2;33;33;33#5;2;52;52;52#6;2;74;73;73#2!5?_' +
|
|
60
|
+
'_?!4_?__$#3?_owKMM]!4^]MMKwo_$#4!4?O?O!6?O?O$#5!4?_!10?_$#6!5?O?_!4?_?O-#1!3?c!12?c$#2!4?{!10~{$#3}~' +
|
|
61
|
+
'~B!12?B~~}$#4!3?W!12?W$#5!4?@!10?@$#6!4?A!10?A-#1??C?EG!9?A$#2!5?PBR!4~BB@$#3@FZr_CG!6?w{{~^F@$#4!3?' +
|
|
62
|
+
'G??CG!4?GC$#5!3?C?_?C!4?s$#6!4?XAo_!6?A@-#2!8?!4@$#3!4?@@B!6?B@$#4!12?@$#5!7?@\x1b\\',
|
|
63
|
+
osv: '\x1bP9;1q"1;1;20;20#1;2;54;58;62#2;2;88;14;17#3;2;97;76;77#4;2;91;38;41#5;2;55;58;62#1?_OC?A?@H@!3H?Q??' +
|
|
64
|
+
'W_$#2!9?!3_$#5??_w{[]MEM!3EMK{w_-#1C??{@!11?U??[$#2!6?}nF@@FN}G$#3!8?o{{w$#4!7?OGAA?o$#5w~~B!12?h~~_' +
|
|
65
|
+
'-#1?EG?AOG!4?O?GCa?G$#2!6?@BBAABB@$#4!9?@@$#5?@FF__!5o_oow[^FF-#1!4?!3@??A?A?@@$#5!7?@B@B@@\x1b\\',
|
|
66
|
+
},
|
|
67
|
+
24: {
|
|
68
|
+
npm: '\x1bP9;1q"1;1;24;24#1;2;80;22;22#2;2;100;100;100#3;2;93;73;73#4;2;84;40;40#5;2;79;22;22#6;2;99;96;96#7;' +
|
|
69
|
+
'2;98;91;91#8;2;99;97;97#1}!4~!14^!3~}{$#3!5?!14_$#5!22?@A-#1!5~!7?!3w!4?!5~$#2!6?!6~!4B~~$#3!12?!3Cw' +
|
|
70
|
+
'$#7!5?~!9?C$#8!18?~-#1!5~!7?!3~!4?!5~$#2!6?!6~!4?~~$#3!15?~$#6!18?~$#7!5?~-#1^!4~!7{!3~!4{!3~^N$#2!6' +
|
|
71
|
+
'?!6@!4?@@$#3!15?@$#4!5?!7A!3?!4A$#5!22?_O$#6!18?@$#7!5?@\x1b\\',
|
|
72
|
+
github: '\x1bP9;1q"1;1;24;24#1;2;10;9;9#2;2;100;100;100#3;2;9;9;9#4;2;73;73;73#5;2;55;55;55#6;2;30;29;29#1??_ooW' +
|
|
73
|
+
'[[!8}][Ww__$#3!4?GC?A??!4@!4?C?O$#4!6?_!10?_$#5!16?_$#6!5?_?_!10?_-#1G}~~N!14?N~~}$#2!5?w~~}}!4~}}~~' +
|
|
74
|
+
'w$#3o@!21?w$#4!4?_B??@@!4?@@$#5!4?OC!12?Fo-#1@^~^Wo_!10?_o{~~^D$#2!5?FN!3^!4~!3^NF$#3M_!20?_A$#4!4?_' +
|
|
75
|
+
'?O??_!4?_$#5!3?_BG??_!6?_?OGB$#6!4?C??_!8?_-#1!3?BEGHPX!6?^^NNFB@$#2!5?A!3CM!4^M$#3??@CG?O?_!6?_?O?G' +
|
|
76
|
+
'C$#4!4?@@A??@!4?@$#5!7?AA$#6!5?C?G\x1b\\',
|
|
77
|
+
osv: '\x1bP9;1q"1;1;24;24#1;2;98;87;88#2;2;88;13;16#3;2;89;24;27#4;2;54;58;62#5;2;55;58;62#6;2;93;50;52#4!4?G' +
|
|
78
|
+
'C?a?!6@OaAC??_$#5??_oow}[]!7M[{wwo-#1!10?_gg_$#2!7?w{]ABFA]}w$#3!10?[C?[$#4o!3?O!13?AK??AO$#5?}~~NB@' +
|
|
79
|
+
'!11?@B~~{g$#6!9?_?OO?_-#1!10?BFFB$#2!7?FN!6WNF$#4?W_?aO!11?_OC??OD$#5@F^~[!13?_w~~NA$#6!9?FC??CF-#4?' +
|
|
80
|
+
'?@@GCA@?AA?__??@?GCA@$#5!5?GK]][{{[[!3]NFB@\x1b\\',
|
|
81
|
+
},
|
|
82
|
+
28: {
|
|
83
|
+
npm: '\x1bP9;1q"1;1;28;28#1;2;80;22;22#2;2;100;100;100#3;2;95;80;80#4;2;85;41;41#5;2;80;25;25#6;2;80;25;24#7;' +
|
|
84
|
+
'2;82;31;30#8;2;80;24;23#1}!26~}-#1!5~!10?!3_!5?!5~$#2!6?!8}!4M!4}$#3!6?!16@$#4!14?!4O$#5!14?_$#7!22?' +
|
|
85
|
+
'~$#8!5?~-#1!5~!10?!3~!5?!5~$#2!6?!8~!4?!4~$#5!14?~$#6!5?{$#7!22?~$#8!5?B-#1!5~o!8_o!3~!5_!5~$#2!6?!8' +
|
|
86
|
+
'N!4?!4N$#4!6?!8O!4?!4O$#5!5?K!8?@$#6!5?B!8?M$#7!22?N$#8!22?O-#1F!26NF\x1b\\',
|
|
87
|
+
github: '\x1bP9;1q"1;1;28;28#1;2;43;43;43#2;2;100;100;100#3;2;9;9;9#4;2;20;20;20#5;2;9;8;8#6;2;67;66;66#7;2;82;8' +
|
|
88
|
+
'1;81#3!3?_oww{!4}!4~!4}{wwo_$#5!11?@!4?@-#1!6?@!14?@_$#2!6?o~}}{{!4}{{}}~o$#3_{!3~N!4?!8@!4?N!3~{_$#' +
|
|
89
|
+
'4!5?O!3?@!8?@!3?O$#6!5?_G?@?A!6?A?@?M$#7!6?E!4?A!4?A-#1!5?O!16?O$#2!5?A!16~$#3!5~!17?_!5~$#4!5?_$#6!' +
|
|
90
|
+
'22?G$#7!5?L!16?F-#1!5?O@?OOC!6?s$#2!6?O``bbz!4~zBB@@$#3?BN~pbEKKG!8?!3{}~~^NB$#4!4?I??A?CG!6?G??A@$#' +
|
|
91
|
+
'5?C!24?C$#6!6?gO??O!8?A$#7!4?CK??A??C!4?C-#1!7?@??A!6?B$#2!11?B!4FB$#3!4?@@BEEM!8?!3FB@@$#4!10?C!6?C' +
|
|
92
|
+
'$#6!8?@@$#7!10?@\x1b\\',
|
|
93
|
+
osv: '\x1bP9;1q"1;1;28;28#1;2;93;52;53#2;2;88;15;18#3;2;54;58;62#4;2;99;89;89#5;2;55;58;62#3!3?_oww{!3}!6^~}{' +
|
|
94
|
+
'{woo_$#5!19?A?CG-#1!12?OO?O$#2!8?_w{{kM[k{{w_$#3?w}~~^FB@!10?@BB^!3~{_$#4!13?__$#5!21?C-#1!11?M?``@]' +
|
|
95
|
+
'G$#2!8?^~~``??_`v~^$#3A!4~_!16?_!4~B$#4!11?O!4]$#5!5?O!21?K-#2!10?@!6B@@$#3?@BNFB?_!4o!5_ooww{~~^FA$' +
|
|
96
|
+
'#5??C!17?CA!4?@-#3!5?A!3B!4F!3N!4FBB@$#5!12?G!3?G\x1b\\',
|
|
97
|
+
},
|
|
98
|
+
32: {
|
|
99
|
+
npm: '\x1bP9;1q"1;1;32;32#1;2;80;22;22#2;2;100;100;100#3;2;91;65;65#4;2;81;26;26#5;2;85;44;43#6;2;83;34;34#7;' +
|
|
100
|
+
'2;86;48;48#8;2;83;36;35#1}!30~}-#1!6~!20@!6~$#2!7?!9}!4]!5}$#3!16?!4_$#5!25?}$#6!6?]$#8!6?_-#1!6~!11' +
|
|
101
|
+
'?!3~!6?!6~$#2!7?!9~!5?!4~$#4!16?~$#5!25?~$#7!20?~$#8!6?~-#1!6~!11?!3~!6?!6~$#2!7?!9~!5?!4~$#4!16?~$#' +
|
|
102
|
+
'5!25?~$#7!20?~$#8!6?~-#1!6~!10{}!3~!6{!6~$#2!7?!9@!5?!4@$#3!7?!9A!5?!4A$#4!6?A!9?@$#5!25?@$#6!25?A$#' +
|
|
103
|
+
'7!20?@$#8!6?@!13?A-#1@!30B@\x1b\\',
|
|
104
|
+
github: '\x1bP9;1q"1;1;32;32#1;2;30;30;30#2;2;100;100;100#3;2;9;9;9#4;2;10;9;9#5;2;92;92;92#6;2;57;56;56#7;2;77;' +
|
|
105
|
+
'77;77#3!4?_?OGC?AA!8?A??C?O$#4!5?__ow!3{!8}!3{ww__-#1!10?A?C!6?C?A$#2!8?}{{!10w{{}$#3?OCA!24?ACO$#4?' +
|
|
106
|
+
'_w{!3~!4@!10B!4@!3~{w_$#5!7?G$#6!7?A!3?C?CC??CC?C!3?A$#7!7?s?A!5?CC!5?A?{-#1!5?[!19?@G$#2!6?{!18~{$#' +
|
|
107
|
+
'3U!30?e$#4g!4~b!20?v!4~W$#5!6?A$#6!6?@$#7!25?A-#1!4?o!4?O?_!10?O??A$#2!7?BFNN^^!6~^^NNFB$#3AO!28?O$#' +
|
|
108
|
+
'4@N~~N^[wo__!9?!3_ow{!4~NB$#5!5?_$#6!6?A!5?_!6?_$#7!6?`CG?O!10?O?GC@-#1!5?@CG?OOQ$#2!6?@EC!3K{!6~$#3' +
|
|
109
|
+
'!5?O!18?_!3?A$#4??@BNMWopbb`!8?!4~^^NF@@$#5!8?G!3?A!6?{$#6!6?A@A!3?@!6?@$#7!19?A-#2!14?!4@$#3!8?@@$#' +
|
|
110
|
+
'4!10?@@!8?!4@\x1b\\',
|
|
111
|
+
osv: '\x1bP9;1q"1;1;32;32#1;2;99;92;92#2;2;92;42;44#3;2;88;13;16#4;2;95;64;66#5;2;54;58;62#5!4?_oww{{}}!8~}}{' +
|
|
112
|
+
'{wwo_-#2!14?_??_$#3!10?_owwW{wWwwo_$#5?o{}!3~NFB@@!8?@@BFN!4~{o-#1!14?wyAwG$#2!12?W?B?@??W$#3!9?}~~F' +
|
|
113
|
+
'F!4?FF~~}$#4!12?_wCD{Fo_$#5?!5~!20?!5~}-#1!13?@@BB@@$#2!12?B!6?B$#3!9?@FNK]!4[]KNF@$#4!14?A??A$#5?F!' +
|
|
114
|
+
'4~]!16?_w{!4~N-#5!3?@@_ow{}~}!8{}}~~^NNF@-#5!10?!4@!5B!3@\x1b\\',
|
|
115
|
+
},
|
|
116
|
+
40: {
|
|
117
|
+
npm: '\x1bP9;1q"1;1;40;40#1;2;80;22;22#2;2;100;100;100#3;2;83;35;35#4;2;95;81;81#5;2;92;69;69#6;2;89;58;58#7;' +
|
|
118
|
+
'2;79;22;21#8;2;92;68;68#1w}}!34~}}{$#7E@@!34?@@A-#1!8~!15B!9F!8~$#2!9?!22w$#3!8?!15C$#5!31?w$#6!8?w-' +
|
|
119
|
+
'#1!8~!12?!5w!7?!8~$#2!9?!11~!6B!5~$#3!25?w$#4!20?!6C$#5!31?~$#6!8?~-#1!8~!12?!5~!7?!8~$#2!9?!11~!6?!' +
|
|
120
|
+
'5~$#3!25?~$#5!31?F$#6!8?~$#8!31?w-#1!8~!12?!5~!7?!8~$#2!9?!11~!6?!5~$#3!25?~$#6!8?~$#8!31?~-#1!8~!12' +
|
|
121
|
+
'{!5~!7{!8~$#2!9?!11B!6?!5B$#3!25?B$#6!8?B$#8!31?B-#1@FF!34NFF@$#7EGG!34?G?E\x1b\\',
|
|
122
|
+
github: '\x1bP9;1q"1;1;40;40#1;2;9;9;9#2;2;100;100;100#3;2;51;51;51#4;2;27;26;26#5;2;73;73;73#1!7?_oow!3{!4}!4~!' +
|
|
123
|
+
'4}!3{woo_-#1??_w{}!3~BBFF!13N!3FBB!3~}{w_$#2!9?owwoo!12_oowwo$#3!14?O?OO!4?OO?O$#4!9?CC!4?O!8?O?G??C' +
|
|
124
|
+
'C$#5!9?G??G!5?!4O!5?G??G-#1o}!5~NB!22?BN!5~}_$#2!8?o!21~|o$#3!7?_!24?_$#4!7?OC!22?CO$#5!8?G!21?AG-#1' +
|
|
125
|
+
'!7~!25?_!7~$#2!8?!24~$#3!7?O!24?W$#4!7?_$#5!7?N!24?F-#1@N!3~!3N[woo__!11?!3_oow{!6~N@$#2!7?_?BFNN!3^' +
|
|
126
|
+
'!8~^^!3NFB$#3!5?O!3?CG?O!14?O?GC$#4!5?_?OA!5?__!8?_!6?A$#5!6?o?`!17?O!4?@-#1!3?BFN^{o_`!4B!10?!8~^NF' +
|
|
127
|
+
'B$#2!8?BM[!4W{!8~{$#3!9?@A?C??@!8?@$#4!7?AGO?!4_$#5!7?@C??C?CCA!8?A-#1!8?@BB!4F!10?!4FB@@$#2!15?@!8B' +
|
|
128
|
+
'@\x1b\\',
|
|
129
|
+
osv: '\x1bP9;1q"1;1;40;40#1;2;55;58;62#2;2;91;33;35#3;2;88;13;16#4;2;99;93;94#5;2;94;57;58#6;2;54;58;62#1!8?o' +
|
|
130
|
+
'!3w{!5}!3~!6}{w{wo__$#6!7?_!3?C!4?@@!3?!3@!4?C!3?O-#1!3?_w{!4~^NNFB!3@!3?!5@BFF^^!3~}{o$#3!16?!8_$#6' +
|
|
131
|
+
'!3?OCA!9?A??!3@!3?AA??G?_!3?@?G_-#1?c}!4~NB@!21?@N!5~w$#2!18?CGGCK$#3!11?_w{}!3~BFFBr!3~}{o$#4!19?OO' +
|
|
132
|
+
'G$#5!18?w__o$#6?W@!4?o!23?A!6?E_-#1?^!5~g!25?!6~$#2!15?i?@!5?S$#3!11?N!3~@T!6?@@!3~^$#4!16?i}~~_~}i$' +
|
|
133
|
+
'#5!15?S!4?^?@?}$#6?_!5?O!24?_!6?N-#1?@F!4~^K!20?_ow!5~N@$#2!17?@??A?@$#3!12?@BFMN!3][]]NMFB@$#4!18?!' +
|
|
134
|
+
'4@$#5!15?@!8?@$#6??G!4?_Q!19?_?GE!5?OE-#1!5?@!3?_o{}!3{!8w{{}}!4~NNB@@$#6!4?@?@?_OG??AA?CC!5?C!3?@!4' +
|
|
135
|
+
'?O?CA-#1!8?!4@!4B!9FBB!3@$#6!7?@!6?CC!4?GG!3?C?AA\x1b\\',
|
|
136
|
+
},
|
|
137
|
+
48: {
|
|
138
|
+
npm: '\x1bP9;1q"1;1;48;48#1;2;80;22;22#2;2;100;100;100#3;2;85;41;41#4;2;95;82;82#5;2;90;61;61#6;2;79;22;21#7;' +
|
|
139
|
+
'2;81;29;28#8;2;81;28;28#1w}!43~}}w$#6C!44?@?C-#1!10~!28N!10~$#2!11?!27_$#3!10?!28O$#4!10?_-#1!10~!28' +
|
|
140
|
+
'?!10~$#2!11?!13~!7^!7~$#4!10?~$#5!24?!7_-#1!10~!15?!6~!7?!10~$#2!11?!13~!7?!7~$#4!10?~$#7!24?~-#1!10' +
|
|
141
|
+
'~!15?!6~!7?!10~$#2!11?!13~!7?!7~$#4!10?~$#7!24?N$#8!24?o-#1!10~!15?!6~!7?!10~$#2!11?!13~!7?!7~$#4!10' +
|
|
142
|
+
'?~$#8!24?~-#1!10~!14w{!6~!7w!10~$#2!11?!13B!7?!7B$#3!10?!14C!7?!7C$#4!10?B$#8!24?B-#1N^^!42~^^F$#6??' +
|
|
143
|
+
'_!42?_?G\x1b\\',
|
|
144
|
+
github: '\x1bP9;1q"1;1;48;48#1;2;27;26;26#2;2;100;100;100#3;2;9;9;9#4;2;67;67;67#5;2;45;44;44#6;2;86;86;86#3!9?_' +
|
|
145
|
+
'_ooww{{!5}!4~!5}{{wwoo__-#1!13?O!20?O$#2!12?__!20?__$#3!4?ow{}!3~!3N^^!16~^^!3N!3~}{w_$#5!11?OO??_!1' +
|
|
146
|
+
'6?_??OO$#6!11?_??_!18?_??_-#1!10?j!6?@?@!8?@!8?m$#2!11?!5~!16}!4~n$#3?o{!7~O!7?@!10?@!7?P!7~{o$#4!21' +
|
|
147
|
+
'?!6@$#5!10?C!9?@!6?@??@$#6!16?@!14?@!4?O-#1!8?W!30?o$#2!9?w!27~}w$#3}!7~F@!28?@N!7~{$#4!9?A$#5!8?_!2' +
|
|
148
|
+
'9?A$#6!9?C!27?@C-#1!8?B_!29?@$#2!9?F!28~F$#3^!7~{!29?_}!7~^$#4!38?G$#5!9?O!28?O$#6!9?G-#1!9?O!5?O!16' +
|
|
149
|
+
'?O?G$#2!7?O__?@BFF!3N^^!8~^^!3NFFB@$#3?F^!3~n!3N]{woo!4_!10?!4_oow{}!7~^F$#4!6?O_O?@?C!4?O!10?_?O??G' +
|
|
150
|
+
'?CA$#5!10?_??G??O!14?O!5?@$#6!11?A??G!4?_-#1!10?O`!5?C!11?@$#2!9?@F[W!5w{!10~$#3!3?@FN^~}w_?BB!3FB!1' +
|
|
151
|
+
'2?!11~^NB@$#4!8?@!9?A!10?A$#5!9?C!3?C!4?@$#6!9?AGAc!16?{-#1!13?@$#2!18?FF!8NF$#3!8?@BBFFMM!3]!12?!3^' +
|
|
152
|
+
'NNFFB@@$#5!14?!4@$#6!29?F\x1b\\',
|
|
153
|
+
osv: '\x1bP9;1q"1;1;48;48#1;2;55;58;62#2;2;90;32;34#3;2;88;13;16#4;2;99;93;93#5;2;54;58;62#6;2;94;59;60#1!9?!' +
|
|
154
|
+
'3_!3w{!4}!5~}}~!3}{{!3woo$#5!11?O??C!10?@@?@??A?CC!3?_-#1!4?_o{}!7~^N!3F!7B!3F!3N!6~}}wo_$#5!17?G??C' +
|
|
155
|
+
'!11?O!6?@?CGO-#1??w{!6~^F@!22?@FN^!6~w$#2!22?_$#3!15?_ow{{}]]!3}]}{{wo_$#5!3?A!8?A@!21?A??_!6?C_$#6!' +
|
|
156
|
+
'21?_!4?_-#1?}!7~!30?J!6~}O$#2!18?_OOK?@??GOO$#3!13?o!4~^NNA??@?ANN^!4~w$#4!19?__otyA~o_$#5?@!7?@!29?' +
|
|
157
|
+
'S!6?@_$#6!21?@IC{?D?__-#1?V!7~_!29?}!7~B$#2!18?G`?_!4?_?KI$#3!13?@^!3~A?_!6?_`?!3~^F$#4!19?QI^~~o~^N' +
|
|
158
|
+
'AC$#5?G!7?O!28?_@$#6!18?tKT!3?N??OOp-#1??@V^!3~^NM!24?ow}!6~^F@$#2!23?@@$#3!15?@BFF!3N^]]^^!3NFB@$#5' +
|
|
159
|
+
'??AG_!3?_O!24?_-#1!5?BB@??__o{{}!3{!3woowooww{{!3}!5~^NFB$#5!11?OG?A?A!5?GG?GG!6?@!6?O??@-#1!9?!4BFF' +
|
|
160
|
+
'NN^N!10^!3N!3FB@$#5!8?!5C!5?O!10?O??G!3?A@\x1b\\',
|
|
161
|
+
},
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const SIZES = Object.keys(LOGOS).map(Number)
|
|
165
|
+
|
|
166
|
+
// Each pixel's register (0 for none): sixel data draws in bands of six rows, a character's bits a column, top first.
|
|
167
|
+
function decode(image) {
|
|
168
|
+
const header = image.slice(0, image.indexOf('#'))
|
|
169
|
+
const [width, height] = header.split(';').slice(-2).map(Number)
|
|
170
|
+
const colours = new Map()
|
|
171
|
+
const pixels = new Uint8Array(width * height)
|
|
172
|
+
let register = 0
|
|
173
|
+
let x = 0
|
|
174
|
+
let y = 0
|
|
175
|
+
for (const [, at, rgb, count = '1', sixel, control] of image.slice(header.length, -2).matchAll(/#(\d+)(?:;2;([\d;]+))?|(?:!(\d+))?([?-~])|([$-])/gu)) {
|
|
176
|
+
if (at !== undefined) {
|
|
177
|
+
register = Number(at)
|
|
178
|
+
if (rgb !== undefined) colours.set(register, rgb)
|
|
179
|
+
} else if (control !== undefined) {
|
|
180
|
+
x = 0
|
|
181
|
+
if (control === '-') y += 6
|
|
182
|
+
} else {
|
|
183
|
+
const bits = sixel.charCodeAt(0) - 0x3f
|
|
184
|
+
for (let n = 0; n < Number(count); n++, x++) {
|
|
185
|
+
for (let bit = 0; bit < 6; bit++) if (bits & (1 << bit)) pixels[(y + bit) * width + x] = register
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return { width, height, colours, pixels }
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// As the logos above are written: a band's registers each a line, runs of three or more counted.
|
|
193
|
+
function encode({ width, height, colours, pixels }) {
|
|
194
|
+
const bands = []
|
|
195
|
+
for (let y = 0; y < height; y += 6) {
|
|
196
|
+
const lines = []
|
|
197
|
+
for (const register of colours.keys()) {
|
|
198
|
+
let line = ''
|
|
199
|
+
for (let x = 0; x < width; x++) {
|
|
200
|
+
let bits = 0
|
|
201
|
+
for (let bit = 0; bit < 6 && y + bit < height; bit++) if (pixels[(y + bit) * width + x] === register) bits |= 1 << bit
|
|
202
|
+
line += String.fromCharCode(0x3f + bits)
|
|
203
|
+
}
|
|
204
|
+
line = line.replace(/\?+$/u, '')
|
|
205
|
+
if (line !== '') lines.push(`#${register}${line.replaceAll(/(.)\1{2,}/gu, (run, sixel) => `!${run.length}${sixel}`)}`)
|
|
206
|
+
}
|
|
207
|
+
bands.push(lines.join('$'))
|
|
208
|
+
}
|
|
209
|
+
const defined = [...colours].map(([register, rgb]) => `#${register};2;${rgb}`).join('')
|
|
210
|
+
return `\x1bP9;1q"1;1;${width};${height}${defined}${bands.join('-')}\x1b\\`
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// `image` lowered by `top` pixels, the rows above it left as the terminal has them.
|
|
214
|
+
function lowered(image, top) {
|
|
215
|
+
const { width, height, colours, pixels } = decode(image)
|
|
216
|
+
const below = new Uint8Array(width * (height + top))
|
|
217
|
+
below.set(pixels, width * top)
|
|
218
|
+
return encode({ width, height: height + top, colours, pixels: below })
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// A register above the logos' own (8 at most), for the terminal's background: iTerm2 draws what a sixel image
|
|
222
|
+
// leaves undrawn in the highest register drawn with (libsixel's index for none, 255, cut to the highest),
|
|
223
|
+
// where other terminals leave it as it is; so it is drawn with, a blank character, which draws nothing.
|
|
224
|
+
const BACKGROUND = 9
|
|
225
|
+
|
|
226
|
+
// The logos for two cells of `cell`'s size (capabilities()'s): the largest leaving an eighth of a row (two pixels at
|
|
227
|
+
// least), lowered to sit mid-row, else the smallest. `background` (`r;g;b` in percent) fills what they leave, for iTerm2.
|
|
228
|
+
export function logos(cell, background) {
|
|
229
|
+
let size = 16
|
|
230
|
+
let top = 0
|
|
231
|
+
if (cell) {
|
|
232
|
+
const room = cell.height - Math.max(2, Math.ceil(cell.height / 8))
|
|
233
|
+
size = SIZES.findLast((each) => each <= room && each <= 2 * cell.width) ?? SIZES[0]
|
|
234
|
+
top = Math.floor((cell.height - size) / 2)
|
|
235
|
+
}
|
|
236
|
+
const fitted = (image) => {
|
|
237
|
+
const placed = top > 0 ? lowered(image, top) : image
|
|
238
|
+
return background ? `${placed.slice(0, -2)}$#${BACKGROUND};2;${background}?\x1b\\` : placed
|
|
239
|
+
}
|
|
240
|
+
return Object.fromEntries(Object.entries(LOGOS[size]).map(([name, image]) => [name, fitted(image)]))
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Primary Device Attributes, answered `CSI ? 62 ; 4 ; 22 c`, say: its class, then what it has, 4 sixel graphics. Every
|
|
244
|
+
// terminal answers it, so it is asked last, its answer telling the others have come, or won't.
|
|
245
|
+
const DA1 = '\x1b[c'
|
|
246
|
+
const SIXEL = '4'
|
|
247
|
+
|
|
248
|
+
// iTerm2's report of its cells' size, answered `OSC 1337 ; ReportCellSize=height;width;scale ST`: in points,
|
|
249
|
+
// `scale` the screen's pixels to a point, which it draws a sixel image's pixels as (two on a Retina screen).
|
|
250
|
+
const REPORT_CELL_SIZE = '\x1b]1337;ReportCellSize\x1b\\'
|
|
251
|
+
// A cell's size in pixels (XTWINOPS 16), answered `CSI 6 ; height ; width t`: as xterm.js draws sixel images,
|
|
252
|
+
// in CSS pixels; but iTerm2's in points, which it doesn't draw them in.
|
|
253
|
+
const CELL_SIZE = '\x1b[16t'
|
|
254
|
+
// OSC 11, answered `OSC 11 ; rgb:RRRR/GGGG/BBBB ST`, each of 1 to 4 hex digits.
|
|
255
|
+
const BACKGROUND_COLOUR = '\x1b]11;?\x1b\\'
|
|
256
|
+
|
|
257
|
+
// The first reply in `read` that `pattern` matches after an ESC: text like a reply, without its ESC, is not one.
|
|
258
|
+
const reply = (read, pattern) => [...read.matchAll(pattern)].find(({ index }) => read[index - 1] === '\x1b')
|
|
259
|
+
|
|
260
|
+
const sixelIn = (read) => reply(read, /\[\?([\d;]*)c/gu)?.[1].split(';').slice(1).includes(SIXEL) ?? false
|
|
261
|
+
|
|
262
|
+
// In the pixels the terminal draws sixel images in: iTerm2's points by its scale, else XTWINOPS 16's.
|
|
263
|
+
function cellIn(read) {
|
|
264
|
+
const iterm2 = reply(read, /\]1337;ReportCellSize=([\d.]+);([\d.]+)(?:;([\d.]+))?/gu)
|
|
265
|
+
if (iterm2) return { height: iterm2[1] * (iterm2[3] ?? 1), width: iterm2[2] * (iterm2[3] ?? 1) }
|
|
266
|
+
const xtwinops = reply(read, /\[6;(\d+);(\d+)t/gu)
|
|
267
|
+
return xtwinops ? { height: Number(xtwinops[1]), width: Number(xtwinops[2]) } : null
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// The terminal's answer to `question` (DA1 last), up to DA1's; null, asking nothing, where a stream is no terminal or
|
|
271
|
+
// a dumb one (Emacs' shell), or after `timeout` ms. A key pressed meanwhile is read with the answer and dropped.
|
|
272
|
+
function ask(question, { input = process.stdin, output = process.stdout, env = process.env, timeout = 1000 } = {}) {
|
|
273
|
+
if (!input?.isTTY || !output?.isTTY || env.TERM === 'dumb') return Promise.resolve(null)
|
|
274
|
+
const { promise, resolve } = Promise.withResolvers()
|
|
275
|
+
const raw = input.isRaw
|
|
276
|
+
const flowing = input.readableFlowing === true
|
|
277
|
+
let read = ''
|
|
278
|
+
const finish = (answer) => {
|
|
279
|
+
clearTimeout(timer)
|
|
280
|
+
input.off('data', onData)
|
|
281
|
+
input.setRawMode(raw)
|
|
282
|
+
if (!flowing) input.pause()
|
|
283
|
+
resolve(answer)
|
|
284
|
+
}
|
|
285
|
+
// DA1's answer, `CSI ? Ps ; ... c`, may come in pieces, and after a key or another report.
|
|
286
|
+
const onData = (chunk) => {
|
|
287
|
+
read += chunk.toString('latin1')
|
|
288
|
+
if (reply(read, /\[\?[\d;]*c/gu)) finish(read)
|
|
289
|
+
}
|
|
290
|
+
const timer = setTimeout(finish, timeout, null)
|
|
291
|
+
input.setRawMode(true)
|
|
292
|
+
input.on('data', onData)
|
|
293
|
+
input.resume()
|
|
294
|
+
output.write(question)
|
|
295
|
+
return promise
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export const supported = async (options) => sixelIn((await ask(DA1, options)) ?? '')
|
|
299
|
+
|
|
300
|
+
// `r;g;b` in percent, as a sixel image's colours are.
|
|
301
|
+
function backgroundIn(read) {
|
|
302
|
+
const colour = reply(read, /\]11;rgb:([\da-f]{1,4})\/([\da-f]{1,4})\/([\da-f]{1,4})/giu)
|
|
303
|
+
return colour ? colour.slice(1).map((hex) => Math.round((Number.parseInt(hex, 16) / (16 ** hex.length - 1)) * 100)).join(';') : null
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// In one round trip: `sixel` (as supported()), `cell` (`{ width, height }`) and `background`, each null where untold.
|
|
307
|
+
export async function capabilities(options) {
|
|
308
|
+
const read = (await ask(REPORT_CELL_SIZE + CELL_SIZE + BACKGROUND_COLOUR + DA1, options)) ?? ''
|
|
309
|
+
return { sixel: sixelIn(read), cell: cellIn(read), background: backgroundIn(read) }
|
|
310
|
+
}
|
package/src/table.js
CHANGED
|
@@ -1,54 +1,87 @@
|
|
|
1
|
-
// A report's tables, as `stasis audit` and `stasis validate` print them, and their colours where the
|
|
2
|
-
// stream they go to takes colours.
|
|
3
1
|
import { styleText } from 'node:util'
|
|
4
2
|
|
|
5
|
-
//
|
|
6
|
-
// break the box layout.
|
|
3
|
+
// Line breaks (LF/CR/CRLF, U+2028/U+2029) in a cell (an advisory's title, say) would break the box layout.
|
|
7
4
|
const cell = (v) => String(v ?? '').replace(/[\r\n\u2028\u2029]+/gu, ' ')
|
|
8
5
|
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
// `multiline` (the `--why` reason column) keeps intentional `\n` breaks -- one
|
|
12
|
-
// physical line per entry -- while still flattening stray CR/separators in each.
|
|
13
|
-
const cellLines = (v, multiline) =>
|
|
14
|
-
multiline ? String(v ?? '').split('\n').map((s) => cell(s)) : [cell(v)]
|
|
6
|
+
// The physical lines a cell occupies: one, but a `multiline` column's (`--why`'s reason) one per `\n`-separated entry.
|
|
7
|
+
const cellLines = (v, multiline) => (multiline ? String(v ?? '').split('\n').map((s) => cell(s)) : [cell(v)])
|
|
15
8
|
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
// A fold, not Math.max(...): a column (a --why cell of 2000 chains, say) may hold more items than a call takes arguments.
|
|
10
|
+
const longest = (items, lengthOf = (item) => item.length) => items.reduce((max, item) => Math.max(max, lengthOf(item)), 0)
|
|
11
|
+
|
|
12
|
+
// A wrapping column narrows no further than its header, and its longest word up to this: only a longer word is cut.
|
|
13
|
+
const MAX_WHOLE_WORD = 20
|
|
14
|
+
|
|
15
|
+
const INDENT = ' '
|
|
16
|
+
|
|
17
|
+
// `text` cut into lines of at most `width`, at spaces where it has them; each after the first starts with `indent`.
|
|
18
|
+
function wrapLine(text, width, indent = '') {
|
|
19
|
+
const lines = []
|
|
20
|
+
let rest = text
|
|
21
|
+
let prefix = ''
|
|
22
|
+
while (prefix.length + rest.length > width) {
|
|
23
|
+
const room = width - prefix.length
|
|
24
|
+
const space = rest.lastIndexOf(' ', room)
|
|
25
|
+
const at = space > 0 ? space : room
|
|
26
|
+
lines.push(prefix + rest.slice(0, at).trimEnd())
|
|
27
|
+
rest = rest.slice(at).trimStart()
|
|
28
|
+
prefix = indent
|
|
29
|
+
}
|
|
30
|
+
if (rest !== '' || lines.length === 0) lines.push(prefix + rest)
|
|
31
|
+
return lines
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// `rows` as a boxed table of `columns`, `paint(text, column, row)` styling a cell's text (not its padding). Wider than
|
|
35
|
+
// `width`, its `wrap` columns narrow, the widest first, as far as MAX_WHOLE_WORD lets them.
|
|
36
|
+
export function formatTable(rows, columns, { multiline = [], paint, paintHeader, paintFrame, width, wrap = [] } = {}) {
|
|
19
37
|
if (rows.length === 0) return ''
|
|
20
38
|
const ml = new Set(multiline)
|
|
21
39
|
const linesOf = (obj) => columns.map((c) => cellLines(obj[c], ml.has(c)))
|
|
22
40
|
const header = columns.map((c) => [c])
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
41
|
+
let body = rows.map(linesOf)
|
|
42
|
+
const measure = () => columns.map((c, i) => Math.max(c.length, longest(body, (cells) => longest(cells[i]))))
|
|
43
|
+
let widths = measure()
|
|
44
|
+
// Each column's text, a space either side, and a border after it; one more border before the first.
|
|
45
|
+
const total = () => widths.reduce((sum, w) => sum + w + 3, 1)
|
|
46
|
+
const wrapping = columns.flatMap((c, i) => (wrap.includes(c) ? [i] : []))
|
|
47
|
+
if (width !== undefined && wrapping.length > 0 && total() > width) {
|
|
48
|
+
const indent = (i) => (ml.has(columns[i]) ? INDENT : '')
|
|
49
|
+
const longestWord = (i) => longest(body, (cells) => longest(cells[i], (line) => longest(line.split(' '))))
|
|
50
|
+
const floors = new Map(wrapping.map((i) => [i, Math.max(columns[i].length, indent(i).length + Math.min(MAX_WHOLE_WORD, longestWord(i)))]))
|
|
51
|
+
while (total() > width) {
|
|
52
|
+
const widest = wrapping.filter((i) => widths[i] > floors.get(i)).toSorted((a, b) => widths[b] - widths[a])[0]
|
|
53
|
+
if (widest === undefined) break
|
|
54
|
+
widths[widest]--
|
|
55
|
+
}
|
|
56
|
+
body = body.map((cells) => cells.map((lines, i) =>
|
|
57
|
+
wrapping.includes(i) ? lines.flatMap((l) => wrapLine(l, widths[i], indent(i))) : lines))
|
|
58
|
+
widths = measure()
|
|
59
|
+
}
|
|
60
|
+
const frame = (text) => (paintFrame ? paintFrame(text) : text)
|
|
61
|
+
const bar = frame('│')
|
|
62
|
+
const line = (l, m, r, fill) => frame(l + widths.map((w) => fill.repeat(w + 2)).join(m) + r)
|
|
63
|
+
// A row spans as many physical lines as its tallest cell.
|
|
64
|
+
const render = (cells, style) => {
|
|
65
|
+
const height = longest(cells)
|
|
32
66
|
const out = []
|
|
33
67
|
for (let i = 0; i < height; i++) {
|
|
34
|
-
out.push(
|
|
68
|
+
out.push(`${bar} ${cells.map((c, j) => {
|
|
35
69
|
const text = c[i] ?? ''
|
|
36
|
-
return (
|
|
37
|
-
}).join(
|
|
70
|
+
return (style && text !== '' ? style(text, columns[j]) : text) + ' '.repeat(widths[j] - text.length)
|
|
71
|
+
}).join(` ${bar} `)} ${bar}`)
|
|
38
72
|
}
|
|
39
73
|
return out.join('\n')
|
|
40
74
|
}
|
|
41
75
|
return [
|
|
42
76
|
line('┌', '┬', '┐', '─'),
|
|
43
|
-
render(header),
|
|
77
|
+
render(header, paintHeader),
|
|
44
78
|
line('├', '┼', '┤', '─'),
|
|
45
|
-
...body.map((cells, at) => render(cells, rows[at])),
|
|
79
|
+
...body.map((cells, at) => render(cells, paint && ((text, column) => paint(text, column, rows[at])))),
|
|
46
80
|
line('└', '┴', '┘', '─'),
|
|
47
81
|
].join('\n')
|
|
48
82
|
}
|
|
49
83
|
|
|
50
|
-
//
|
|
51
|
-
// terminal that has them does (a TTY's hasColors); a pipe, or a file, doesn't.
|
|
84
|
+
// As @exodus/test tells it: CI's logs take colours, though no terminal, as does a TTY that has them.
|
|
52
85
|
export function takesColors(stream) {
|
|
53
86
|
return Boolean(process.env.CI) || Boolean(stream?.hasColors?.())
|
|
54
87
|
}
|
|
@@ -56,8 +89,7 @@ export function takesColors(stream) {
|
|
|
56
89
|
// Dimmed text's format: CI's logs show gray, not faint.
|
|
57
90
|
export const DIM = process.env.CI ? 'gray' : 'dim'
|
|
58
91
|
|
|
59
|
-
// `paint(format, text)`: `text` in
|
|
60
|
-
// where `colors` (else as `stream` takes them, takesColors), else as it is.
|
|
92
|
+
// `paint(format, text)`: `text` in util.styleText's `format` where `colors`, else as it is.
|
|
61
93
|
export function painter(stream, colors = takesColors(stream)) {
|
|
62
94
|
return (format, text) => (colors && format && text !== '' ? styleText(format, text, { validateStream: false }) : text)
|
|
63
95
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Types of `@exodus/stasis/validate-notes` (validate-notes.js).
|
|
2
|
+
|
|
3
|
+
export const OWN_REASONS: Readonly<Record<string, string>>
|
|
4
|
+
export const PACKAGE_REASONS: Readonly<Record<string, string>>
|
|
5
|
+
export const PATCH_ERRORS: Readonly<Record<string, string>>
|
|
6
|
+
export const FILE_REASONS: Readonly<Record<string, string>>
|
|
7
|
+
export const LOCKFILE_ERRORS: Readonly<Record<string, string>>
|
|
8
|
+
export function generatedBy(client: { schema: string; generator: string; prisma: string }): string
|
|
9
|
+
|
|
10
|
+
// A package as a report tells it, as much as its note reads.
|
|
11
|
+
export interface NotedPackage {
|
|
12
|
+
reason?: string
|
|
13
|
+
at?: string
|
|
14
|
+
directory?: string
|
|
15
|
+
patch?: { path?: string; from?: string; error?: string; verified?: boolean; applied?: boolean; recorded?: true }
|
|
16
|
+
}
|
|
17
|
+
export type NotePart = string | { path: string }
|
|
18
|
+
export function noteOf(pkg: NotedPackage): NotePart[]
|
|
19
|
+
export function noteText(pkg: NotedPackage): string
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// A validation report in words, as printValidationReport tells it. Of no module, for a browser too.
|
|
2
|
+
export const OWN_REASONS = {
|
|
3
|
+
skipped: 'skipped (--only-deps): its dependencies alone validated',
|
|
4
|
+
'no-repository': 'no repository to read it of',
|
|
5
|
+
'no-commit': 'no commit to read it at',
|
|
6
|
+
'commit-not-in-history': 'its commit is in the history of no branch or tag of its repository (a fork\'s, say)',
|
|
7
|
+
'history-unread': 'its commit is at no tag or branch head, nor in its default branch\'s history, and not every other branch was compared',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// A package's reason: unverified, or, from `misplaced` on, failing its lockfile or what it records.
|
|
11
|
+
export const PACKAGE_REASONS = {
|
|
12
|
+
local: 'installed from a directory of the repository, which isn\'t read',
|
|
13
|
+
'patch-unverified': 'as patched by the bundle\'s patch, which isn\'t verified against the repository',
|
|
14
|
+
git: 'locked from git, not a registry',
|
|
15
|
+
'not-a-submodule': 'no submodule of its repository\'s tree at its path',
|
|
16
|
+
'git-built': 'locked from git: of the files its repository hasn\'t at the commit, which its install may build, none verified',
|
|
17
|
+
'not-registry': 'locked from elsewhere than its registry',
|
|
18
|
+
'no-integrity': 'locked with no sha512 to hold its tarball to',
|
|
19
|
+
unsupported: 'no upstream package for its ecosystem',
|
|
20
|
+
unnamed: 'no name or version recorded',
|
|
21
|
+
'not-published': 'not published',
|
|
22
|
+
unreadable: 'its registry refused it',
|
|
23
|
+
timeout: 'not reached in time',
|
|
24
|
+
failed: 'could not be fetched',
|
|
25
|
+
'alias-unverified': 'installed under another name, an alias no lockfile read tells of',
|
|
26
|
+
misplaced: 'installed where its path or its lockfile names another package or version',
|
|
27
|
+
'not-locked': 'not locked by the lockfile',
|
|
28
|
+
'integrity-mismatch': 'its registry\'s tarball is not the one it is locked or recorded with',
|
|
29
|
+
'integrity-conflict': 'locked or recorded with two integrities',
|
|
30
|
+
'integrity-not-locked': 'records an integrity its lockfile doesn\'t lock it with',
|
|
31
|
+
'commit-not-locked': 'records another commit than its repository\'s tree pins it at',
|
|
32
|
+
'patch-not-locked': 'records a patch its lockfile doesn\'t patch it with',
|
|
33
|
+
'patch-not-recorded': 'records an integrity and no patch, where its lockfile patches it',
|
|
34
|
+
'patch-conflict': 'its copies record different patches, or one of them none, where pnpm patches every copy with one',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Why a patch wasn't applied, told after `its patch` and its path.
|
|
38
|
+
export const PATCH_ERRORS = {
|
|
39
|
+
'patch-not-in-repository': 'is the bundle\'s, not the repository\'s',
|
|
40
|
+
'patch-not-found': 'is in no file of its hash (the bundle\'s, or the patches directory\'s)',
|
|
41
|
+
'patch-mismatch': 'is not of the hash its lockfile locks',
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const FILE_REASONS = {
|
|
45
|
+
symlink: 'a symlink in the repository',
|
|
46
|
+
submodule: 'in a submodule',
|
|
47
|
+
'tree-cut': 'the repository\'s tree was too large to list whole',
|
|
48
|
+
generated: 'not as the repository\'s Prisma schema generates it',
|
|
49
|
+
'not-generated': 'in a Prisma Client\'s output, which generates no such file',
|
|
50
|
+
listed: 'the repository\'s tree was listed, not read, and a lockfile records its integrity alone',
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const generatedBy = (client) => `${client.schema}'s ${client.generator} (Prisma ${client.prisma})`
|
|
54
|
+
|
|
55
|
+
export const LOCKFILE_ERRORS = {
|
|
56
|
+
'no-lockfile': 'no lockfile of its repository locks them',
|
|
57
|
+
'lockfile-ambiguous': 'more than one package manager\'s lockfile installs it',
|
|
58
|
+
'lockfile-unreadable': 'its lockfile couldn\'t be read',
|
|
59
|
+
'lockfile-unsupported': 'its lockfile is of a kind validate doesn\'t read',
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// The paths in it as `{ path }`, for a caller to set apart.
|
|
63
|
+
export function noteOf(pkg) {
|
|
64
|
+
const { patch } = pkg
|
|
65
|
+
if (pkg.reason) return [PACKAGE_REASONS[pkg.reason] ?? pkg.reason, ...(pkg.at ? [': ', { path: pkg.at }] : [])]
|
|
66
|
+
if (patch?.error) return ['its patch', ...(patch.path ? [' ', { path: patch.path }] : []), ` ${PATCH_ERRORS[patch.error] ?? `could not be applied (${patch.error})`}`]
|
|
67
|
+
if (!patch) return pkg.directory ? ['held to ', { path: pkg.directory }, ' of the repository'] : []
|
|
68
|
+
const whose = patch.from !== 'bundle' ? [] : [patch.verified ? ' (the bundle\'s, as the repository has it)' : ' (the bundle\'s, not verified against the repository)']
|
|
69
|
+
return [patch.applied === false ? 'bundled as published, not patched' : 'patched', ...(patch.path ? [' by ', { path: patch.path }, ...whose] : []), ...(patch.recorded ? [', as recorded'] : [])]
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const noteText = (pkg) => noteOf(pkg).map((part) => (typeof part === 'string' ? part : part.path)).join('')
|