@cplieger/deadset-ts 8.0.0-dev.11 → 8.0.0-dev.13

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.
Files changed (73) hide show
  1. package/README.md +2 -0
  2. package/THIRD_PARTY_NOTICES.md +27 -0
  3. package/dist/src/build-scripts.js +6 -13
  4. package/dist/src/commands/read.js +156 -0
  5. package/dist/src/commands/shell.js +75 -0
  6. package/dist/src/commands/tools.js +460 -0
  7. package/dist/src/configuration-files.js +11 -25
  8. package/dist/src/conformance-record.js +1 -1
  9. package/dist/src/dependencies.js +67 -115
  10. package/dist/src/load/synthesize.js +12 -5
  11. package/dist/src/manifest.js +27 -14
  12. package/dist/src/roots.js +18 -11
  13. package/dist/src/text/named-files.js +24 -3
  14. package/dist/src/text/yaml.js +464 -173
  15. package/dist/src/vendor/unbash/ansi-c.js +132 -0
  16. package/dist/src/vendor/unbash/arithmetic-parts.js +37 -0
  17. package/dist/src/vendor/unbash/arithmetic.js +591 -0
  18. package/dist/src/vendor/unbash/assignment.js +131 -0
  19. package/dist/src/vendor/unbash/chars.js +48 -0
  20. package/dist/src/vendor/unbash/command.js +41 -0
  21. package/dist/src/vendor/unbash/expansion.js +80 -0
  22. package/dist/src/vendor/unbash/glob.js +268 -0
  23. package/dist/src/vendor/unbash/heredoc.js +27 -0
  24. package/dist/src/vendor/unbash/internal-types.js +1 -0
  25. package/dist/src/vendor/unbash/lexer.js +4274 -0
  26. package/dist/src/vendor/unbash/limits.js +3 -0
  27. package/dist/src/vendor/unbash/parser.js +1366 -0
  28. package/dist/src/vendor/unbash/parts.js +57 -0
  29. package/dist/src/vendor/unbash/substitution-context.js +8 -0
  30. package/dist/src/vendor/unbash/traversal.js +212 -0
  31. package/dist/src/vendor/unbash/types.js +1 -0
  32. package/dist/src/vendor/unbash/word-value.js +61 -0
  33. package/dist/src/vendor/unbash/word.js +40 -0
  34. package/dist/src/workflow-steps.js +111 -133
  35. package/jsr.json +2 -1
  36. package/package.json +9 -7
  37. package/src/build-scripts.ts +6 -13
  38. package/src/commands/read.ts +230 -0
  39. package/src/commands/shell.ts +126 -0
  40. package/src/commands/tools.ts +618 -0
  41. package/src/configuration-files.ts +10 -26
  42. package/src/conformance-record.ts +1 -1
  43. package/src/dependencies.ts +99 -123
  44. package/src/load/synthesize.ts +18 -5
  45. package/src/manifest.ts +43 -25
  46. package/src/roots.ts +20 -13
  47. package/src/text/named-files.ts +26 -3
  48. package/src/text/yaml.ts +503 -179
  49. package/src/vendor/unbash/LICENSE +15 -0
  50. package/src/vendor/unbash/VENDORED.md +16 -0
  51. package/src/vendor/unbash/ansi-c.ts +132 -0
  52. package/src/vendor/unbash/arithmetic-parts.ts +53 -0
  53. package/src/vendor/unbash/arithmetic.ts +641 -0
  54. package/src/vendor/unbash/assignment.ts +163 -0
  55. package/src/vendor/unbash/chars.ts +48 -0
  56. package/src/vendor/unbash/command.ts +47 -0
  57. package/src/vendor/unbash/expansion.ts +144 -0
  58. package/src/vendor/unbash/glob.ts +284 -0
  59. package/src/vendor/unbash/heredoc.ts +34 -0
  60. package/src/vendor/unbash/internal-types.ts +94 -0
  61. package/src/vendor/unbash/lexer.ts +4352 -0
  62. package/src/vendor/unbash/limits.ts +3 -0
  63. package/src/vendor/unbash/parser.ts +1612 -0
  64. package/src/vendor/unbash/parts.ts +96 -0
  65. package/src/vendor/unbash/substitution-context.ts +20 -0
  66. package/src/vendor/unbash/traversal.ts +182 -0
  67. package/src/vendor/unbash/types.ts +660 -0
  68. package/src/vendor/unbash/word-value.ts +64 -0
  69. package/src/vendor/unbash/word.ts +50 -0
  70. package/src/workflow-steps.ts +153 -154
  71. package/dist/src/text/shell.js +0 -159
  72. package/src/text/named-files.inputs.json +0 -1522
  73. package/src/text/shell.ts +0 -161
package/src/text/shell.ts DELETED
@@ -1,161 +0,0 @@
1
- /**
2
- * Shell command lines read as text, never run: the commands a line runs, the tokens the
3
- * Contract splits a command into, and the words POSIX token recognition reads.
4
- */
5
-
6
- /**
7
- * The shell's list and pipeline operators, each of which ends one command. An `&` beside a
8
- * redirection's `<` or `>` (`2>&1`, and bash's `&>log`) is part of the redirection.
9
- */
10
- const COMMAND_OPERATORS = /&&|\|\||;|\||(?<![<>])&(?!>)/u;
11
-
12
- /** Where a command splits into tokens: white space and the operators the Contract names. */
13
- const TOKEN_SEPARATORS = /\s+|&&|\|\||;|\|/u;
14
-
15
- /** A text written inside one pair of quotes. */
16
- const QUOTED = /^(["'])(.*)\1$/su;
17
-
18
- /** The commands one line runs, the text between two of the shell's list and pipeline operators. */
19
- export function commandsOf(line: string): readonly string[] {
20
- return line.split(COMMAND_OPERATORS);
21
- }
22
-
23
- /** One text with one pair of enclosing quotes removed. */
24
- export function unquoted(text: string): string {
25
- return text.replace(QUOTED, "$2");
26
- }
27
-
28
- /**
29
- * Every token one script's command line holds, each with one pair of enclosing quotes
30
- * removed. A token holding a wildcard is a pattern rather than a path, and names no
31
- * entry point.
32
- */
33
- export function scriptTokens(command: string): readonly string[] {
34
- return command
35
- .split(TOKEN_SEPARATORS)
36
- .map(unquoted)
37
- .filter((token) => token !== "" && !token.includes("*"));
38
- }
39
-
40
- /** One shell line up to its comment: a `#` that starts a word outside quotes. */
41
- export function withoutComment(line: string): string {
42
- let quote = "";
43
- for (let at = 0; at < line.length; at += 1) {
44
- const char = line[at];
45
- if (quote !== "") {
46
- if (char === quote) {
47
- quote = "";
48
- } else if (char === "\\" && quote === '"') {
49
- at += 1;
50
- }
51
- } else if (char === "'" || char === '"') {
52
- quote = char;
53
- } else if (char === "\\") {
54
- at += 1;
55
- } else if (char === "#" && (at === 0 || /\s/u.test(line[at - 1] ?? ""))) {
56
- return line.slice(0, at);
57
- }
58
- }
59
- return line;
60
- }
61
-
62
- /** The characters that end a word outside quotes and separate nothing: blanks. */
63
- // Stryker disable next-line Regex: its \v to \V mutant is no valid escape under the u flag, so the whole module fails to parse
64
- const BLANK = /[ \t\r\f\v]/u;
65
-
66
- /** The characters that end a word outside quotes and begin an operator: newline included. */
67
- const OPERATOR = /[\n;&|()<>]/u;
68
-
69
- /** The characters a backslash escapes inside double quotes; before any other it stands for itself. */
70
- const DOUBLE_QUOTE_ESCAPES = new Set(["$", "`", '"', "\\"]);
71
-
72
- /**
73
- * The words of one command line, as POSIX token recognition reads quotes, backslashes,
74
- * line continuations, comments and operators. A word an expansion may change (an unquoted
75
- * `$`, backquote, glob character or leading `~`, or a `$` or backquote in double quotes)
76
- * is computed, and so is the rest of a line whose quote is never closed. A computed word
77
- * and each operator are undefined, so a flag's file is never read across them.
78
- */
79
- export function shellWords(command: string): readonly (string | undefined)[] {
80
- const words: (string | undefined)[] = [];
81
- let word: string | undefined;
82
- let computed = false;
83
- const end = (): void => {
84
- if (word !== undefined) {
85
- words.push(computed ? undefined : word);
86
- }
87
- word = undefined;
88
- computed = false;
89
- };
90
- for (let at = 0; at < command.length; at += 1) {
91
- const char = command.charAt(at);
92
- if (char === "\\" && command.charAt(at + 1) === "\n") {
93
- at += 1;
94
- } else if (BLANK.test(char)) {
95
- end();
96
- } else if (OPERATOR.test(char)) {
97
- end();
98
- words.push(undefined);
99
- } else if (char === "#" && word === undefined) {
100
- const newline = command.indexOf("\n", at);
101
- at = newline < 0 ? command.length : newline - 1;
102
- } else if (char === "\\") {
103
- at += 1;
104
- word = (word ?? "") + command.charAt(at);
105
- } else if (char === "'" || char === '"') {
106
- const close = closingQuote(command, at);
107
- if (close < 0) {
108
- word ??= "";
109
- computed = true;
110
- break;
111
- }
112
- const quoted =
113
- char === "'"
114
- ? { text: command.slice(at + 1, close), computed: false }
115
- : doubleQuoted(command.slice(at + 1, close));
116
- word = (word ?? "") + quoted.text;
117
- computed ||= quoted.computed;
118
- at = close;
119
- } else {
120
- computed ||= /[$`*?[]/u.test(char) || (char === "~" && word === undefined);
121
- word = (word ?? "") + char;
122
- }
123
- }
124
- end();
125
- return words;
126
- }
127
-
128
- /** The text between one pair of double quotes, unescaped, and whether an expansion may change it. */
129
- function doubleQuoted(inner: string): { readonly text: string; readonly computed: boolean } {
130
- let text = "";
131
- let computed = false;
132
- for (let at = 0; at < inner.length; at += 1) {
133
- const char = inner.charAt(at);
134
- const next = inner.charAt(at + 1);
135
- if (char === "\\" && next === "\n") {
136
- at += 1;
137
- } else if (char === "\\" && DOUBLE_QUOTE_ESCAPES.has(next)) {
138
- text += next;
139
- at += 1;
140
- } else {
141
- computed ||= char === "$" || char === "`";
142
- text += char;
143
- }
144
- }
145
- return { text, computed };
146
- }
147
-
148
- /** The index of the quote that closes the one at `open`, or -1 where none does. */
149
- function closingQuote(command: string, open: number): number {
150
- const quote = command.charAt(open);
151
- for (let at = open + 1; at < command.length; at += 1) {
152
- const char = command.charAt(at);
153
- if (char === quote) {
154
- return at;
155
- }
156
- if (quote === '"' && char === "\\") {
157
- at += 1;
158
- }
159
- }
160
- return -1;
161
- }