create-wxl 0.0.0-stage → 3.0.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/LICENSE +127 -0
- package/bin/create-wxl.mjs +153 -0
- package/dist/fork-init.mjs +1782 -0
- package/dist/source.json +6 -0
- package/package.json +20 -4
- package/src/archive-rules.mjs +148 -0
- package/src/archive.mjs +109 -0
- package/src/argv.mjs +89 -0
- package/src/fsops.mjs +205 -0
- package/src/git-env.mjs +13 -0
- package/src/git-runner.mjs +107 -0
- package/src/git-steps.mjs +148 -0
- package/src/git-version.mjs +25 -0
- package/src/language.mjs +14 -0
- package/src/messages.mjs +323 -0
- package/src/next-steps.mjs +29 -0
- package/src/node-version.mjs +17 -0
- package/src/numeric-version.mjs +16 -0
- package/src/pristine.mjs +104 -0
- package/src/publish-io.mjs +123 -0
- package/src/publish.mjs +304 -0
- package/src/questions.mjs +274 -0
- package/src/raw-tar.mjs +188 -0
- package/src/run.mjs +537 -0
- package/src/signals.mjs +88 -0
- package/src/text.mjs +80 -0
- package/README.md +0 -3
package/src/text.mjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Shared text helpers: JSON string literals for named values (every C0, DEL and C1 character
|
|
2
|
+
// escaped per traceability.md "Error and warning codes", D10), and POSIX quoting for commands
|
|
3
|
+
// printed for copying (N1, N4, N5, N7, N8, CW-E12, CW-W05).
|
|
4
|
+
|
|
5
|
+
/** S-20: the one definition of "C0, DEL or C1" (traceability.md "Error and warning codes" and
|
|
6
|
+
* AC-24's `hasControlChar`), shared with `escapeChar`'s own, wider "needs `\uXXXX`" rule below
|
|
7
|
+
* (which also covers lone surrogates, a separate reason to escape, review finding C-09 -- NOT a
|
|
8
|
+
* reason to withhold a copyable command, so `hasControlChar` does not call this with that range
|
|
9
|
+
* folded in). */
|
|
10
|
+
function isControlCodePoint(code) {
|
|
11
|
+
return code < 0x20 || (code >= 0x7f && code <= 0x9f)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function isLoneSurrogate(code) {
|
|
15
|
+
return code >= 0xd800 && code <= 0xdfff
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** D10 (the user-approved reading; stage 6/7 correction P-01/S-02/C-11): a line feed inside a
|
|
19
|
+
* value is the JSON short escape `\n` (the matrix's own value, traceability.md C60); every other
|
|
20
|
+
* C0, DEL, C1 character and lone surrogate (review finding C-09: `JSON.stringify` has written
|
|
21
|
+
* U+D800-U+DFFF as `\uXXXX` since ES2019's well-formed `JSON.stringify`) is written `\uXXXX` --
|
|
22
|
+
* `JSON.stringify`'s own short escapes for tab/CR/backspace/form-feed are NOT used for those,
|
|
23
|
+
* and DEL/C1 (review finding C-05) would otherwise pass through `JSON.stringify` unescaped at
|
|
24
|
+
* all. */
|
|
25
|
+
function escapeChar(ch) {
|
|
26
|
+
if (ch === '"') return '\\"'
|
|
27
|
+
if (ch === '\\') return '\\\\'
|
|
28
|
+
if (ch === '\n') return '\\n'
|
|
29
|
+
const code = ch.codePointAt(0)
|
|
30
|
+
if (isControlCodePoint(code) || isLoneSurrogate(code)) {
|
|
31
|
+
return `\\u${code.toString(16).padStart(4, '0')}`
|
|
32
|
+
}
|
|
33
|
+
return ch
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Prints `value` as a JSON string literal, one code point at a time through `escapeChar` (full
|
|
37
|
+
* control over which escapes it uses, D10). S-35: a non-string value is converted with
|
|
38
|
+
* `String()` first, so one escaping rule applies to every call site -- a number, boolean, etc.
|
|
39
|
+
* never carries a control character in this codebase's actual call sites, but an array or object
|
|
40
|
+
* holding one (e.g. a warning list entry) now escapes the same way a plain string does. */
|
|
41
|
+
export function jsonValue(value) {
|
|
42
|
+
const str = typeof value === 'string' ? value : String(value)
|
|
43
|
+
let out = '"'
|
|
44
|
+
for (const ch of str) out += escapeChar(ch)
|
|
45
|
+
return out + '"'
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const BARE_RE = /^[A-Za-z0-9._\-/@%+=:,]+$/
|
|
49
|
+
|
|
50
|
+
export function posixQuoteWord(word) {
|
|
51
|
+
if (BARE_RE.test(word)) return word
|
|
52
|
+
return `'${word.replace(/'/g, "'\\''")}'`
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function posixCommand(words) {
|
|
56
|
+
return words.map(posixQuoteWord).join(' ')
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A directory beginning with `-` gets the `./` prefix before it is quoted. */
|
|
60
|
+
export function formatDirectoryArg(directory) {
|
|
61
|
+
return directory.startsWith('-') ? `./${directory}` : directory
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** S-22: the one place every CW-E09 call site (fsops.mjs, pristine.mjs) tags a caught file-system
|
|
65
|
+
* error with the path `run.mjs` should report, without overwriting one an earlier catch already
|
|
66
|
+
* set (a write's own catch, re-thrown through another wrapper). */
|
|
67
|
+
export function tagReportPath(err, path) {
|
|
68
|
+
if (err && typeof err.reportPath !== 'string') err.reportPath = path
|
|
69
|
+
return err
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** traceability.md "Error and warning codes": "When a value to be placed in such a command
|
|
73
|
+
* contains a C0, DEL or C1 character, the command is not printed". True when any code point in
|
|
74
|
+
* `str` is C0 (U+0000-U+001F), DEL (U+007F) or C1 (U+0080-U+009F). */
|
|
75
|
+
export function hasControlChar(str) {
|
|
76
|
+
for (const ch of str) {
|
|
77
|
+
if (isControlCodePoint(ch.codePointAt(0))) return true
|
|
78
|
+
}
|
|
79
|
+
return false
|
|
80
|
+
}
|
package/README.md
DELETED