@visulima/fs 5.1.0 → 6.0.1
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/CHANGELOG.md +10 -0
- package/LICENSE.md +159 -19
- package/README.md +6 -6
- package/dist/eol.js +3 -3
- package/dist/glob-parent.js +1 -1
- package/dist/glob.d.ts +54 -2
- package/dist/glob.js +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/ini.d.ts +2 -2
- package/dist/ini.js +1 -1
- package/dist/is-glob.js +1 -1
- package/dist/json5.d.ts +2 -2
- package/dist/json5.js +1 -1
- package/dist/jsonc.d.ts +2 -2
- package/dist/jsonc.js +1 -1
- package/dist/match.js +1 -1
- package/dist/packem_shared/FIND_UP_STOP-pQqZdUPw.js +1 -0
- package/dist/packem_shared/_commonjsHelpers-CqkleIqs.js +1 -0
- package/dist/packem_shared/assertValidFileOrDirectoryPath-CAHgg-jK.js +1 -0
- package/dist/packem_shared/build-rm-options-_U1T9rOz.js +1 -0
- package/dist/packem_shared/collect-DXVMgRiZ.js +1 -0
- package/dist/packem_shared/collectSync-jjcJdHox.js +1 -0
- package/dist/packem_shared/copy-Cv8Vvdrc.js +1 -0
- package/dist/packem_shared/copySync-JIxmcGrd.js +1 -0
- package/dist/packem_shared/emptyDir-DQ1LfO2i.js +1 -0
- package/dist/packem_shared/emptyDirSync-BXDqirP1.js +1 -0
- package/dist/packem_shared/ensureDir-qy_X-WeG.js +1 -0
- package/dist/packem_shared/{ensureDirSync-B0w9WMwE.js → ensureDirSync-ONFJBCbg.js} +1 -1
- package/dist/packem_shared/{ensureFile-waD4hDO8.js → ensureFile-q1ozF6q5.js} +1 -1
- package/dist/packem_shared/ensureFileSync-B6eR38N_.js +1 -0
- package/dist/packem_shared/ensureLink-BpsTVGAm.js +1 -0
- package/dist/packem_shared/ensureLinkSync-B5moWvh3.js +1 -0
- package/dist/packem_shared/ensureSymlink-BF0BwVPy.js +1 -0
- package/dist/packem_shared/ensureSymlinkSync-D-JzDuD7.js +1 -0
- package/dist/packem_shared/findUp-BlQ1EUhu.js +1 -0
- package/dist/packem_shared/findUpSync-CF1OXVQw.js +1 -0
- package/dist/packem_shared/glob-Cyk1H9ZL.js +1 -0
- package/dist/packem_shared/globSync-Cm0u7eCn.js +1 -0
- package/dist/packem_shared/index-CBWLeiRp.js +1 -0
- package/dist/packem_shared/index-DDkv7LRn.js +1 -0
- package/dist/packem_shared/index-DGueExxA.js +1 -0
- package/dist/packem_shared/index-ovH_d7Hf.js +11 -0
- package/dist/packem_shared/indexToLineColumn-BHKDfaPx-DS9KxkE-.js +6 -0
- package/dist/packem_shared/ini-preserve-D3Z1KcgN.js +4 -0
- package/dist/packem_shared/is-stats-identical-DOh8_0KH.js +1 -0
- package/dist/packem_shared/isAccessible-CqNOFdZu.js +1 -0
- package/dist/packem_shared/isAccessibleSync-DYKTrrvc.js +1 -0
- package/dist/packem_shared/json-value.d-DZqAihX4.d.ts +29 -0
- package/dist/packem_shared/jsonc-merge-BGm21l00.js +2 -0
- package/dist/packem_shared/map-read-error-8dAe6Qhr.js +1 -0
- package/dist/packem_shared/move-DG3P4i6Y.js +1 -0
- package/dist/packem_shared/parseJson-gfl5PTTo.js +1 -0
- package/dist/packem_shared/readFile-DbKGLwIK.js +1 -0
- package/dist/packem_shared/readFileSync-CTTHkZ_p.js +1 -0
- package/dist/packem_shared/readIni-C9VUitQm.js +1 -0
- package/dist/packem_shared/readIniSync-DhMbhDPx.js +1 -0
- package/dist/packem_shared/readJson-CClJlGok.js +1 -0
- package/dist/packem_shared/readJson5-D33tgtEU.js +1 -0
- package/dist/packem_shared/readJson5Sync-DEd-ejtp.js +1 -0
- package/dist/packem_shared/readJsonSync-CbryXYxN.js +1 -0
- package/dist/packem_shared/readJsonc-Cp1KzmVx.js +1 -0
- package/dist/packem_shared/readJsoncSync-sE30rJ5W.js +1 -0
- package/dist/packem_shared/readToml-jD08lZRN.js +1 -0
- package/dist/packem_shared/readTomlSync-0J8gIalg.js +1 -0
- package/dist/packem_shared/readYaml-C63_W9Qg.js +1 -0
- package/dist/packem_shared/readYamlSync-CuyDW6xR.js +1 -0
- package/dist/packem_shared/remove-4ofpEuH1.js +1 -0
- package/dist/packem_shared/removeSync-g1D5kONg.js +1 -0
- package/dist/packem_shared/resolve-symlink-target-D4Pb9Fjw.js +1 -0
- package/dist/packem_shared/sanitize-B1LHjdjC.js +1 -0
- package/dist/packem_shared/stripJsonComments-Do7s7No5.js +1 -0
- package/dist/packem_shared/to-uint-8-array-DlTu4L-l.js +1 -0
- package/dist/packem_shared/types.d-B-T1rDxl.d.ts +958 -0
- package/dist/packem_shared/walk-Brue5N30.js +1 -0
- package/dist/packem_shared/walk-include-aizKyl9e.js +1 -0
- package/dist/packem_shared/walkSync-BWGgTwUy.js +1 -0
- package/dist/packem_shared/writeFile-BIBP7wbK.js +1 -0
- package/dist/packem_shared/writeFileSync-DJoHk3Ks.js +1 -0
- package/dist/packem_shared/writeIni--gog68qN.js +4 -0
- package/dist/packem_shared/writeIniSync-BL_z8aMQ.js +4 -0
- package/dist/packem_shared/writeJson-DmN1UqZc.js +4 -0
- package/dist/packem_shared/writeJson5-CPRmF2K7.js +4 -0
- package/dist/packem_shared/writeJson5Sync-BiUfm-cZ.js +4 -0
- package/dist/packem_shared/writeJsonSync-BiFyXQ5h.js +4 -0
- package/dist/packem_shared/writeJsonc-B4ahk9a2.js +4 -0
- package/dist/packem_shared/writeJsoncSync-lBv1IFDo.js +4 -0
- package/dist/packem_shared/writeToml-Frvwh0Kn.js +1 -0
- package/dist/packem_shared/writeTomlSync-BvKdlKvE.js +1 -0
- package/dist/packem_shared/writeYaml-C4IGXTOo.js +1 -0
- package/dist/packem_shared/writeYamlSync-BAbWtkvq.js +1 -0
- package/dist/size.js +1 -1
- package/dist/toml.d.ts +1 -1
- package/dist/toml.js +1 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +1 -1
- package/dist/yaml.d.ts +2 -2
- package/dist/yaml.js +1 -1
- package/package.json +28 -28
- package/dist/packem_shared/FIND_UP_STOP-CAwY1qU7.js +0 -1
- package/dist/packem_shared/_commonjsHelpers-CWAkuNXM.js +0 -1
- package/dist/packem_shared/assertValidFileOrDirectoryPath-BTlt945W.js +0 -1
- package/dist/packem_shared/build-rm-options-avnusYx-.js +0 -1
- package/dist/packem_shared/collect-Dbo3K4iq.js +0 -1
- package/dist/packem_shared/collectSync-BLLtRqQ4.js +0 -1
- package/dist/packem_shared/copy-DiR5_5iA.js +0 -1
- package/dist/packem_shared/copySync-DffsYlhb.js +0 -1
- package/dist/packem_shared/emptyDir-BlBeczk0.js +0 -1
- package/dist/packem_shared/emptyDirSync-DfUZ9Ejz.js +0 -1
- package/dist/packem_shared/ensureDir-BEiomfxz.js +0 -1
- package/dist/packem_shared/ensureFileSync-CG07zjV7.js +0 -1
- package/dist/packem_shared/ensureLink-Dz-PDWa5.js +0 -1
- package/dist/packem_shared/ensureLinkSync-BZH7TaSQ.js +0 -1
- package/dist/packem_shared/ensureSymlink-Byi6ajoE.js +0 -1
- package/dist/packem_shared/ensureSymlinkSync-D7OCsAd8.js +0 -1
- package/dist/packem_shared/findUp-BHCEMf5y.js +0 -1
- package/dist/packem_shared/findUpSync-BKJsHMQN.js +0 -1
- package/dist/packem_shared/glob-BUjyjdE8.js +0 -1
- package/dist/packem_shared/glob-sync.d-0UK6O_wZ.d.ts +0 -54
- package/dist/packem_shared/globSync-Bk9TUV7x.js +0 -1
- package/dist/packem_shared/index-B2MhYg3r.js +0 -1
- package/dist/packem_shared/index-BHy3Kcr7.js +0 -11
- package/dist/packem_shared/index-CPZbuHkp.js +0 -1
- package/dist/packem_shared/index-LUKYN3u3.js +0 -1
- package/dist/packem_shared/indexToLineColumn-BfkIsWHQ-DQJmePiQ.js +0 -6
- package/dist/packem_shared/ini-preserve-D1DopDLd.js +0 -4
- package/dist/packem_shared/is-stats-identical-l1GRN4Qu.js +0 -1
- package/dist/packem_shared/isAccessible-B7guOm3k.js +0 -1
- package/dist/packem_shared/isAccessibleSync-XH4YleJW.js +0 -1
- package/dist/packem_shared/jsonc-merge-Bkw73TLW.js +0 -2
- package/dist/packem_shared/map-read-error-CR3rQUxx.js +0 -1
- package/dist/packem_shared/move-KhPRvsRd.js +0 -1
- package/dist/packem_shared/parseJson-lm3MUNdf.js +0 -1
- package/dist/packem_shared/readFile-VgxUDrNH.js +0 -1
- package/dist/packem_shared/readFileSync-CloFeQw8.js +0 -1
- package/dist/packem_shared/readIni-CEXHWn92.js +0 -1
- package/dist/packem_shared/readIniSync-DsxVHypc.js +0 -1
- package/dist/packem_shared/readJson-DV2KxaEJ.js +0 -1
- package/dist/packem_shared/readJson5-S68aVros.js +0 -1
- package/dist/packem_shared/readJson5Sync-Bi9Rv46R.js +0 -1
- package/dist/packem_shared/readJsonSync-DweZd5ZA.js +0 -1
- package/dist/packem_shared/readJsonc-Dqh-elUt.js +0 -1
- package/dist/packem_shared/readJsoncSync-Dy2PZG5g.js +0 -1
- package/dist/packem_shared/readToml-CN_xnICv.js +0 -1
- package/dist/packem_shared/readTomlSync-B9TVGzen.js +0 -1
- package/dist/packem_shared/readYaml-DcpUq11D.js +0 -1
- package/dist/packem_shared/readYamlSync-D5RVZwco.js +0 -1
- package/dist/packem_shared/remove-D_CUIlBL.js +0 -1
- package/dist/packem_shared/removeSync-F4nKiwrU.js +0 -1
- package/dist/packem_shared/resolve-symlink-target-CWrn0v4P.js +0 -1
- package/dist/packem_shared/sanitize-aEqeyx4d.js +0 -1
- package/dist/packem_shared/stripJsonComments-Bfcn2PKv.js +0 -1
- package/dist/packem_shared/to-uint-8-array-7sXMoZwU.js +0 -1
- package/dist/packem_shared/types.d-C-RhhzcS.d.ts +0 -1753
- package/dist/packem_shared/walk-B211aFS7.js +0 -1
- package/dist/packem_shared/walk-include-2NQzWTCI.js +0 -1
- package/dist/packem_shared/walkSync-VeMvHYLk.js +0 -1
- package/dist/packem_shared/writeFile-Dnba9aVe.js +0 -1
- package/dist/packem_shared/writeFileSync-pW8o2DG1.js +0 -1
- package/dist/packem_shared/writeIni-DgZ-0EUD.js +0 -4
- package/dist/packem_shared/writeIniSync-Buz4Cove.js +0 -4
- package/dist/packem_shared/writeJson-vexC7dw2.js +0 -4
- package/dist/packem_shared/writeJson5-DeW_smOs.js +0 -4
- package/dist/packem_shared/writeJson5Sync-Cz5pwaPh.js +0 -4
- package/dist/packem_shared/writeJsonSync-DJLfN5iT.js +0 -4
- package/dist/packem_shared/writeJsonc-BqJQS0Mk.js +0 -4
- package/dist/packem_shared/writeJsoncSync-CchlR2KW.js +0 -4
- package/dist/packem_shared/writeToml-Bn-wQdaM.js +0 -1
- package/dist/packem_shared/writeTomlSync-CTv4RXkJ.js +0 -1
- package/dist/packem_shared/writeYaml-BbiKaW3J.js +0 -1
- package/dist/packem_shared/writeYamlSync-dI80QfIA.js +0 -1
|
@@ -0,0 +1,958 @@
|
|
|
1
|
+
import { PathLike, Dirent } from 'node:fs';
|
|
2
|
+
import { FSLike } from 'fdir';
|
|
3
|
+
/**
|
|
4
|
+
* Positional information for a YAML error, pointing at the offending
|
|
5
|
+
* character in the source string.
|
|
6
|
+
*/
|
|
7
|
+
interface Mark {
|
|
8
|
+
/** Zero-based column (characters into the current line). */
|
|
9
|
+
column: number;
|
|
10
|
+
/** Zero-based line number. */
|
|
11
|
+
line: number;
|
|
12
|
+
/** Zero-based absolute offset into the source string. */
|
|
13
|
+
position: number;
|
|
14
|
+
/** A short excerpt of the source around the error, if available. */
|
|
15
|
+
snippet?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Base class for all errors raised by `@visulima/yaml`.
|
|
19
|
+
*/
|
|
20
|
+
declare class YAMLError extends Error {
|
|
21
|
+
readonly mark?: Mark;
|
|
22
|
+
constructor(message: string, mark?: Mark, source?: string);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A non-fatal notice (e.g. a duplicate mapping key) collected during parsing.
|
|
26
|
+
*/
|
|
27
|
+
declare class YAMLWarning extends YAMLError {
|
|
28
|
+
constructor(message: string, mark?: Mark, source?: string);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Maps a source offset to a line and column.
|
|
32
|
+
*
|
|
33
|
+
* Errors already carry a resolved position, so this exists for callers that
|
|
34
|
+
* hold offsets of their own — an editor mapping a node's span to a cursor
|
|
35
|
+
* position, or a linter reporting against its own ranges. The parser fills it
|
|
36
|
+
* in as it scans, which costs one array push per line and only when a counter
|
|
37
|
+
* was supplied.
|
|
38
|
+
*/
|
|
39
|
+
declare class LineCounter {
|
|
40
|
+
/** Offset at which each line begins. Line 1 always starts at 0. */
|
|
41
|
+
lineStarts: number[];
|
|
42
|
+
/**
|
|
43
|
+
* Record the start of a new line.
|
|
44
|
+
*
|
|
45
|
+
* The parser re-scans on a speculative parse or a rewind, so the same break
|
|
46
|
+
* can arrive more than once. Line starts are strictly increasing, so an
|
|
47
|
+
* offset that is not past the last one has already been seen.
|
|
48
|
+
*/
|
|
49
|
+
addNewLine(offset: number): void;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve an offset to a 1-indexed line and column.
|
|
52
|
+
*
|
|
53
|
+
* Binary search rather than a scan, so a lookup stays cheap on a large
|
|
54
|
+
* document even when a caller resolves many offsets.
|
|
55
|
+
*/
|
|
56
|
+
linePos(offset: number): {
|
|
57
|
+
col: number;
|
|
58
|
+
line: number;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** Which scalar-resolution rules to apply. */
|
|
62
|
+
type SchemaName = "core" | "failsafe" | "json" | "yaml-1.1";
|
|
63
|
+
/** One custom scalar type. */
|
|
64
|
+
interface ScalarTag {
|
|
65
|
+
/**
|
|
66
|
+
* Participate in *implicit* resolution — an untagged scalar matching
|
|
67
|
+
* {@link ScalarTag.test} resolves through this tag. Without it the tag only
|
|
68
|
+
* applies when written explicitly (`!!name value`).
|
|
69
|
+
* @default false
|
|
70
|
+
*/
|
|
71
|
+
default?: boolean;
|
|
72
|
+
/** Recognise a JS value as belonging to this tag, used when serializing. */
|
|
73
|
+
identify?: (value: unknown) => boolean;
|
|
74
|
+
/** Turn the scalar's raw text into a value. */
|
|
75
|
+
resolve: (raw: string) => unknown;
|
|
76
|
+
/** Render a value back to scalar text. Defaults to `String(value)`. */
|
|
77
|
+
stringify?: (value: unknown) => string;
|
|
78
|
+
/**
|
|
79
|
+
* The tag name. Either a local `!name` / `!!name`, or a fully qualified
|
|
80
|
+
* `tag:domain,date:name`.
|
|
81
|
+
*/
|
|
82
|
+
tag: string;
|
|
83
|
+
/** Pattern an untagged scalar must match for implicit resolution. */
|
|
84
|
+
test?: RegExp;
|
|
85
|
+
}
|
|
86
|
+
/** What the `customTags` option accepts. */
|
|
87
|
+
type CustomTags = ScalarTag[] | ((tags: ScalarTag[]) => ScalarTag[]);
|
|
88
|
+
/**
|
|
89
|
+
* How duplicate keys in a mapping are handled.
|
|
90
|
+
*
|
|
91
|
+
* - `error` (default): throw a `YAMLParseError`.
|
|
92
|
+
* - `overwrite`: keep the last value.
|
|
93
|
+
* - `ignore`: keep the first value.
|
|
94
|
+
*/
|
|
95
|
+
type DuplicateKeyBehavior = "error" | "ignore" | "overwrite";
|
|
96
|
+
/** Options accepted by `parse`. */
|
|
97
|
+
interface ParseOptions {
|
|
98
|
+
/**
|
|
99
|
+
* Extra scalar types. Each tag says how to recognise, resolve and render
|
|
100
|
+
* one type; set `default` with a `test` pattern to have it participate in
|
|
101
|
+
* implicit resolution as well as explicit `!!tag` use.
|
|
102
|
+
*/
|
|
103
|
+
customTags?: CustomTags;
|
|
104
|
+
/**
|
|
105
|
+
* How to treat repeated keys inside a single mapping.
|
|
106
|
+
* @default "error"
|
|
107
|
+
*/
|
|
108
|
+
duplicateKeys?: DuplicateKeyBehavior;
|
|
109
|
+
/**
|
|
110
|
+
* Resolve integers to `BigInt` instead of `number`, so values beyond
|
|
111
|
+
* `Number.MAX_SAFE_INTEGER` survive. Floats are unaffected.
|
|
112
|
+
* @default false
|
|
113
|
+
*/
|
|
114
|
+
intAsBigInt?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Collects the offset of every line break as the document is scanned, so
|
|
117
|
+
* `lineCounter.linePos(offset)` can resolve any offset afterwards.
|
|
118
|
+
*/
|
|
119
|
+
lineCounter?: LineCounter;
|
|
120
|
+
/**
|
|
121
|
+
* Build mappings as `Map` rather than plain objects, which keeps complex
|
|
122
|
+
* keys (sequences, mappings) as their native values instead of flattening
|
|
123
|
+
* them to strings.
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
mapAsMap?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Maximum number of alias nodes that may be resolved. Guards against
|
|
129
|
+
* "billion laughs" style alias-expansion attacks.
|
|
130
|
+
* @default 100
|
|
131
|
+
*/
|
|
132
|
+
maxAliasCount?: number;
|
|
133
|
+
/**
|
|
134
|
+
* Maximum nesting depth of collections. Guards against a deeply nested
|
|
135
|
+
* document (`[[[[…`) exhausting the call stack with a `RangeError` that
|
|
136
|
+
* escapes the `YAMLError` hierarchy.
|
|
137
|
+
* @default 1000
|
|
138
|
+
*/
|
|
139
|
+
maxDepth?: number;
|
|
140
|
+
/**
|
|
141
|
+
* Resolve `<<` merge keys. Disable to treat `<<` as an ordinary key.
|
|
142
|
+
* @default true
|
|
143
|
+
*/
|
|
144
|
+
merge?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Optional callback invoked for every non-fatal `YAMLWarning`. When
|
|
147
|
+
* omitted, warnings are silently ignored.
|
|
148
|
+
*/
|
|
149
|
+
onWarning?: (warning: YAMLWarning) => void;
|
|
150
|
+
/**
|
|
151
|
+
* When `true`, a `__proto__` mapping key becomes an own data property
|
|
152
|
+
* instead of being assigned through the inherited setter, so a document can
|
|
153
|
+
* never reach the prototype chain. Merge keys (`<<`) honour this too.
|
|
154
|
+
* @default true
|
|
155
|
+
*/
|
|
156
|
+
preventProtoPollution?: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Applied to every key/value pair after parsing, like the `JSON.parse`
|
|
159
|
+
* reviver. Returning `undefined` drops the entry.
|
|
160
|
+
*/
|
|
161
|
+
reviver?: (key: unknown, value: unknown) => unknown;
|
|
162
|
+
/**
|
|
163
|
+
* Which scalar-resolution rules to apply.
|
|
164
|
+
*
|
|
165
|
+
* `core` (default) is YAML 1.2 core: `~`/`null`, `true`/`false`, decimal,
|
|
166
|
+
* hex and octal ints, floats, `.inf`/`.nan`.
|
|
167
|
+
* `failsafe` resolves nothing; every scalar stays a string.
|
|
168
|
+
* `json` resolves only the JSON grammar; any other unquoted scalar is a
|
|
169
|
+
* document error.
|
|
170
|
+
* `yaml-1.1` is the older, wider set: `yes`/`no`/`on`/`off` as booleans,
|
|
171
|
+
* `010` as octal, `0b` binaries, `1_000` underscores, sexagesimals, and
|
|
172
|
+
* timestamps as `Date`.
|
|
173
|
+
*
|
|
174
|
+
* Defaults to `yaml-1.1` when {@link ParseOptions.version} is `"1.1"`.
|
|
175
|
+
* @default "core"
|
|
176
|
+
*/
|
|
177
|
+
schema?: SchemaName;
|
|
178
|
+
/**
|
|
179
|
+
* Full YAML 1.2 strictness, on by default. The parser always rejects the
|
|
180
|
+
* unambiguous spec violations (tabs as indentation, malformed directives,
|
|
181
|
+
* deficient indentation, comments not separated by white space). With
|
|
182
|
+
* `strict` it additionally rejects the corner cases that both `yaml` and
|
|
183
|
+
* `js-yaml` accept but the spec forbids: a node property (anchor or tag)
|
|
184
|
+
* carried onto a new line yet indented no deeper than its parent key; a
|
|
185
|
+
* block mapping or sequence whose first entry sits on the document-start
|
|
186
|
+
* line; two anchors or two tags on one node; and a block scalar whose
|
|
187
|
+
* leading empty lines out-indent its content or that uses a tab for
|
|
188
|
+
* indentation. Set `strict: false` to relax exactly those checks (closer to
|
|
189
|
+
* `js-yaml`); it never changes the value of an accepted document, only
|
|
190
|
+
* whether these malformed inputs throw.
|
|
191
|
+
* @default true
|
|
192
|
+
*/
|
|
193
|
+
strict?: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Keep every mapping key a string, skipping scalar resolution for keys.
|
|
196
|
+
* @default false
|
|
197
|
+
*/
|
|
198
|
+
stringKeys?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* YAML version to assume when the document carries no `%YAML` directive.
|
|
201
|
+
* `"1.1"` selects the `yaml-1.1` schema unless {@link ParseOptions.schema}
|
|
202
|
+
* says otherwise.
|
|
203
|
+
* @default "1.2"
|
|
204
|
+
*/
|
|
205
|
+
version?: "1.1" | "1.2";
|
|
206
|
+
}
|
|
207
|
+
/** Options accepted by `stringify`. */
|
|
208
|
+
interface StringifyOptions {
|
|
209
|
+
/**
|
|
210
|
+
* How to render a multi-line string: `literal` (`|`), `folded` (`>`), or
|
|
211
|
+
* `false` to always use a quoted style.
|
|
212
|
+
* @default true
|
|
213
|
+
*/
|
|
214
|
+
blockQuote?: "folded" | "literal" | boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Force every collection to one style, overriding {@link StringifyOptions.flowLevel}.
|
|
217
|
+
* @default "any"
|
|
218
|
+
*/
|
|
219
|
+
collectionStyle?: "any" | "block" | "flow";
|
|
220
|
+
/**
|
|
221
|
+
* Extra scalar types used when serializing: a value claimed by a tag's
|
|
222
|
+
* `identify` is written with that tag.
|
|
223
|
+
*/
|
|
224
|
+
customTags?: CustomTags;
|
|
225
|
+
/**
|
|
226
|
+
* Emit an explicit document-start marker (`---`) before the document.
|
|
227
|
+
* @default false
|
|
228
|
+
*/
|
|
229
|
+
directives?: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* String written for `false`.
|
|
232
|
+
* @default "false"
|
|
233
|
+
*/
|
|
234
|
+
falseStr?: string;
|
|
235
|
+
/**
|
|
236
|
+
* Pad the inside of flow collections: `{ a: 1 }` rather than `{a: 1}`.
|
|
237
|
+
* @default true
|
|
238
|
+
*/
|
|
239
|
+
flowCollectionPadding?: boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Force flow style (`{a: 1, b: [2, 3]}`) for collections nested deeper than
|
|
242
|
+
* this level. `-1` disables flow style entirely (everything is block
|
|
243
|
+
* style). `0` makes the whole document flow style.
|
|
244
|
+
* @default -1
|
|
245
|
+
*/
|
|
246
|
+
flowLevel?: number;
|
|
247
|
+
/**
|
|
248
|
+
* When `true`, non-ASCII characters are escaped in double-quoted scalars.
|
|
249
|
+
* @default false
|
|
250
|
+
*/
|
|
251
|
+
forceQuotes?: boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Number of spaces used for each indentation level.
|
|
254
|
+
* @default 2
|
|
255
|
+
*/
|
|
256
|
+
indent?: number;
|
|
257
|
+
/**
|
|
258
|
+
* Indent block sequences inside a mapping under their key.
|
|
259
|
+
* @default true
|
|
260
|
+
*/
|
|
261
|
+
indentSeq?: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Keep `undefined` values instead of dropping them, writing them as `null`.
|
|
264
|
+
* @default false
|
|
265
|
+
*/
|
|
266
|
+
keepUndefined?: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Preferred maximum line width for folded scalars. `0` disables folding.
|
|
269
|
+
* @default 80
|
|
270
|
+
*/
|
|
271
|
+
lineWidth?: number;
|
|
272
|
+
/**
|
|
273
|
+
* String written for `null`.
|
|
274
|
+
* @default "null"
|
|
275
|
+
*/
|
|
276
|
+
nullStr?: string;
|
|
277
|
+
/**
|
|
278
|
+
* A `JSON.stringify`-style replacer applied to every value before it is
|
|
279
|
+
* serialized. Return `undefined` to omit the value.
|
|
280
|
+
*/
|
|
281
|
+
replacer?: (key: string, value: unknown) => unknown;
|
|
282
|
+
/**
|
|
283
|
+
* Prefer single quotes over double quotes when a string must be quoted.
|
|
284
|
+
* @default false
|
|
285
|
+
*/
|
|
286
|
+
singleQuote?: boolean;
|
|
287
|
+
/**
|
|
288
|
+
* When `true`, keys with `undefined` values (and `undefined` array members)
|
|
289
|
+
* are skipped instead of being written as `null`.
|
|
290
|
+
* @default false
|
|
291
|
+
*/
|
|
292
|
+
skipInvalid?: boolean;
|
|
293
|
+
/**
|
|
294
|
+
* When `true`, object keys are emitted in sorted order. A comparator can be
|
|
295
|
+
* supplied for custom ordering.
|
|
296
|
+
* @default false
|
|
297
|
+
*/
|
|
298
|
+
sortKeys?: boolean | ((a: string, b: string) => number);
|
|
299
|
+
/**
|
|
300
|
+
* String written for `true`.
|
|
301
|
+
* @default "true"
|
|
302
|
+
*/
|
|
303
|
+
trueStr?: string;
|
|
304
|
+
}
|
|
305
|
+
//#region src/types.d.ts
|
|
306
|
+
type FileSystemAdapter = Partial<FSLike>;
|
|
307
|
+
interface GlobOptions$1 {
|
|
308
|
+
/**
|
|
309
|
+
* Whether to return absolute paths. Disable to have relative paths.
|
|
310
|
+
* @default false
|
|
311
|
+
*/
|
|
312
|
+
absolute?: boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Enables support for brace expansion syntax, like `{a,b}` or `{1..9}`.
|
|
315
|
+
* @default true
|
|
316
|
+
*/
|
|
317
|
+
braceExpansion?: boolean;
|
|
318
|
+
/**
|
|
319
|
+
* Whether to match in case-sensitive mode.
|
|
320
|
+
* @default true
|
|
321
|
+
*/
|
|
322
|
+
caseSensitiveMatch?: boolean;
|
|
323
|
+
/**
|
|
324
|
+
* The working directory in which to search. Results will be returned relative to this directory, unless
|
|
325
|
+
* {@link absolute} is set.
|
|
326
|
+
*
|
|
327
|
+
* It is important to avoid globbing outside this directory when possible, even with absolute paths enabled,
|
|
328
|
+
* as doing so can harm performance due to having to recalculate relative paths.
|
|
329
|
+
* @default process.cwd()
|
|
330
|
+
*/
|
|
331
|
+
cwd?: string | URL;
|
|
332
|
+
/**
|
|
333
|
+
* Logs useful debug information. Meant for development purposes. Logs can change at any time.
|
|
334
|
+
* @default false
|
|
335
|
+
*/
|
|
336
|
+
debug?: boolean;
|
|
337
|
+
/**
|
|
338
|
+
* Maximum directory depth to crawl.
|
|
339
|
+
* @default Infinity
|
|
340
|
+
*/
|
|
341
|
+
deep?: number;
|
|
342
|
+
/**
|
|
343
|
+
* Whether to return entries that start with a dot, like `.gitignore` or `.prettierrc`.
|
|
344
|
+
* @default false
|
|
345
|
+
*/
|
|
346
|
+
dot?: boolean;
|
|
347
|
+
/**
|
|
348
|
+
* Whether to automatically expand directory patterns.
|
|
349
|
+
*
|
|
350
|
+
* Important to disable if migrating from [`fast-glob`](https://github.com/mrmlnc/fast-glob).
|
|
351
|
+
* @default true
|
|
352
|
+
*/
|
|
353
|
+
expandDirectories?: boolean;
|
|
354
|
+
/**
|
|
355
|
+
* Enables support for extglobs, like `+(pattern)`.
|
|
356
|
+
* @default true
|
|
357
|
+
*/
|
|
358
|
+
extglob?: boolean;
|
|
359
|
+
/**
|
|
360
|
+
* Whether to traverse and include symbolic links. Can slightly affect performance.
|
|
361
|
+
* @default true
|
|
362
|
+
*/
|
|
363
|
+
followSymbolicLinks?: boolean;
|
|
364
|
+
/**
|
|
365
|
+
* An object that overrides `node:fs` functions.
|
|
366
|
+
* @default import('node:fs')
|
|
367
|
+
*/
|
|
368
|
+
fs?: FileSystemAdapter;
|
|
369
|
+
/**
|
|
370
|
+
* Enables support for matching nested directories with globstars (`**`).
|
|
371
|
+
* If `false`, `**` behaves exactly like `*`.
|
|
372
|
+
* @default true
|
|
373
|
+
*/
|
|
374
|
+
globstar?: boolean;
|
|
375
|
+
/**
|
|
376
|
+
* Glob patterns to exclude from the results.
|
|
377
|
+
* @default []
|
|
378
|
+
*/
|
|
379
|
+
ignore?: string | readonly string[];
|
|
380
|
+
/**
|
|
381
|
+
* Enable to only return directories.
|
|
382
|
+
* If `true`, disables {@link onlyFiles}.
|
|
383
|
+
* @default false
|
|
384
|
+
*/
|
|
385
|
+
onlyDirectories?: boolean;
|
|
386
|
+
/**
|
|
387
|
+
* Enable to only return files.
|
|
388
|
+
* @default true
|
|
389
|
+
*/
|
|
390
|
+
onlyFiles?: boolean;
|
|
391
|
+
/**
|
|
392
|
+
* @deprecated Provide patterns as the first argument instead.
|
|
393
|
+
*/
|
|
394
|
+
patterns?: string | readonly string[];
|
|
395
|
+
/**
|
|
396
|
+
* An `AbortSignal` to abort crawling the file system.
|
|
397
|
+
* @default undefined
|
|
398
|
+
*/
|
|
399
|
+
signal?: AbortSignal;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Constant to check if the path is visible to the calling process.
|
|
403
|
+
* Corresponds to `node:fs.constants.F_OK`.
|
|
404
|
+
*/
|
|
405
|
+
declare const F_OK: number;
|
|
406
|
+
/**
|
|
407
|
+
* Constant to check if the path is readable to the calling process.
|
|
408
|
+
* Corresponds to `node:fs.constants.R_OK`.
|
|
409
|
+
*/
|
|
410
|
+
declare const R_OK: number;
|
|
411
|
+
/**
|
|
412
|
+
* Constant to check if the path is writable to the calling process.
|
|
413
|
+
* Corresponds to `node:fs.constants.W_OK`.
|
|
414
|
+
*/
|
|
415
|
+
declare const W_OK: number;
|
|
416
|
+
/**
|
|
417
|
+
* Constant to check if the path is executable by the calling process.
|
|
418
|
+
* Corresponds to `node:fs.constants.X_OK`.
|
|
419
|
+
*/
|
|
420
|
+
declare const X_OK: number;
|
|
421
|
+
/**
|
|
422
|
+
* A special symbol that can be returned by the matcher function in `findUp` or `findUpSync`
|
|
423
|
+
* to stop the search process prematurely.
|
|
424
|
+
*/
|
|
425
|
+
declare const FIND_UP_STOP: symbol;
|
|
426
|
+
type ColorizeMethod = (value: string) => string;
|
|
427
|
+
/**
|
|
428
|
+
* Options accepted by `jsonc-parser`'s `parse` function.
|
|
429
|
+
*/
|
|
430
|
+
type JsoncParseOptions = {
|
|
431
|
+
/**
|
|
432
|
+
* Allow empty content as a valid input. Defaults to `false`.
|
|
433
|
+
*/
|
|
434
|
+
allowEmptyContent?: boolean;
|
|
435
|
+
/**
|
|
436
|
+
* Allow trailing commas in arrays and objects. Defaults to `false`.
|
|
437
|
+
*/
|
|
438
|
+
allowTrailingComma?: boolean;
|
|
439
|
+
/**
|
|
440
|
+
* Disallow JavaScript-style comments in the input. Defaults to `false` (comments allowed).
|
|
441
|
+
*/
|
|
442
|
+
disallowComments?: boolean;
|
|
443
|
+
};
|
|
444
|
+
/**
|
|
445
|
+
* Formatting options for `jsonc-parser` edits.
|
|
446
|
+
*/
|
|
447
|
+
type JsoncFormattingOptions = {
|
|
448
|
+
/**
|
|
449
|
+
* The line ending to use in the output.
|
|
450
|
+
*/
|
|
451
|
+
eol?: string;
|
|
452
|
+
/**
|
|
453
|
+
* When `true`, insert a final newline when the output does not end with one.
|
|
454
|
+
*/
|
|
455
|
+
insertFinalNewline?: boolean;
|
|
456
|
+
/**
|
|
457
|
+
* Indent with spaces (`true`) or tabs (`false`). Defaults to `true`.
|
|
458
|
+
*/
|
|
459
|
+
insertSpaces?: boolean;
|
|
460
|
+
/**
|
|
461
|
+
* When `true`, attempt to keep the original line structure when applying edits.
|
|
462
|
+
*/
|
|
463
|
+
keepLines?: boolean;
|
|
464
|
+
/**
|
|
465
|
+
* Indent size when {@link JsoncFormattingOptions.insertSpaces | insertSpaces} is `true`.
|
|
466
|
+
*/
|
|
467
|
+
tabSize?: number;
|
|
468
|
+
};
|
|
469
|
+
/**
|
|
470
|
+
* Options accepted by the `ini` library's `stringify` / `encode` functions.
|
|
471
|
+
* Kept as a local definition so the types compile without the optional peer installed.
|
|
472
|
+
*/
|
|
473
|
+
type IniEncodeOptions = {
|
|
474
|
+
/**
|
|
475
|
+
* Align `=` signs across the output.
|
|
476
|
+
*/
|
|
477
|
+
align?: boolean;
|
|
478
|
+
/**
|
|
479
|
+
* Serialize array values using the `key[]` convention. Defaults to `true`.
|
|
480
|
+
*/
|
|
481
|
+
bracketedArray?: boolean;
|
|
482
|
+
/**
|
|
483
|
+
* Append a trailing newline to every section.
|
|
484
|
+
*/
|
|
485
|
+
newline?: boolean;
|
|
486
|
+
/**
|
|
487
|
+
* Target platform for section/key escaping. Defaults to the current platform.
|
|
488
|
+
*/
|
|
489
|
+
platform?: string;
|
|
490
|
+
/**
|
|
491
|
+
* Name of the top-level section.
|
|
492
|
+
*/
|
|
493
|
+
section?: string;
|
|
494
|
+
/**
|
|
495
|
+
* Sort keys alphabetically within sections.
|
|
496
|
+
*/
|
|
497
|
+
sort?: boolean;
|
|
498
|
+
/**
|
|
499
|
+
* Write `key = value` with spaces around `=`. Defaults to `false`.
|
|
500
|
+
*/
|
|
501
|
+
whitespace?: boolean;
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* Replacer accepted by `JSON5.stringify()`.
|
|
505
|
+
*/
|
|
506
|
+
type Json5Replacer = (number | string)[] | ((this: unknown, key: string, value: unknown) => unknown) | null;
|
|
507
|
+
/**
|
|
508
|
+
* Options for the `glob` and `globSync` functions.
|
|
509
|
+
*
|
|
510
|
+
* Re-exported from [`tinyglobby`](https://github.com/SuperchupuDev/tinyglobby) (which is bundled into the built
|
|
511
|
+
* output, with a local patch adding negated-ignore support). The `ignore` option accepts leading-`!` patterns to
|
|
512
|
+
* _un-ignore_ entries — for example `ignore: ["dist/**", "!dist/index.d.ts"]` drops the `dist/` tree except for
|
|
513
|
+
* its type entry point.
|
|
514
|
+
*/
|
|
515
|
+
type GlobOptions = Omit<GlobOptions$1, "patterns">;
|
|
516
|
+
/**
|
|
517
|
+
* Options for the `walk` and `walkSync` functions.
|
|
518
|
+
*/
|
|
519
|
+
interface WalkOptions {
|
|
520
|
+
/**
|
|
521
|
+
* List of file extensions used to filter entries.
|
|
522
|
+
* If specified, entries without the file extension specified by this option are excluded.
|
|
523
|
+
* @default {undefined}
|
|
524
|
+
*/
|
|
525
|
+
extensions?: string[];
|
|
526
|
+
/**
|
|
527
|
+
* Indicates whether symlinks should be resolved or not.
|
|
528
|
+
* @default {false}
|
|
529
|
+
*/
|
|
530
|
+
followSymlinks?: boolean;
|
|
531
|
+
/**
|
|
532
|
+
* Indicates whether directory entries should be included or not.
|
|
533
|
+
* @default {true}
|
|
534
|
+
*/
|
|
535
|
+
includeDirs?: boolean;
|
|
536
|
+
/**
|
|
537
|
+
* Indicates whether file entries should be included or not.
|
|
538
|
+
* @default {true}
|
|
539
|
+
*/
|
|
540
|
+
includeFiles?: boolean;
|
|
541
|
+
/**
|
|
542
|
+
* Indicates whether symlink entries should be included or not.
|
|
543
|
+
* This option is meaningful only if `followSymlinks` is set to `false`.
|
|
544
|
+
* @default {true}
|
|
545
|
+
*/
|
|
546
|
+
includeSymlinks?: boolean;
|
|
547
|
+
/**
|
|
548
|
+
* List of regular expression or glob patterns used to filter entries.
|
|
549
|
+
* If specified, entries that do not match the patterns specified by this option are excluded.
|
|
550
|
+
* @default {undefined}
|
|
551
|
+
*/
|
|
552
|
+
match?: (RegExp | string)[];
|
|
553
|
+
/**
|
|
554
|
+
* The maximum depth of the file tree to be walked recursively.
|
|
555
|
+
* @default {Infinity}
|
|
556
|
+
*/
|
|
557
|
+
maxDepth?: number;
|
|
558
|
+
/**
|
|
559
|
+
* List of regular expression or glob patterns used to filter entries.
|
|
560
|
+
* If specified, entries matching the patterns specified by this option are excluded.
|
|
561
|
+
* @default {undefined}
|
|
562
|
+
*/
|
|
563
|
+
skip?: (RegExp | string)[];
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Represents an entry found by `walk` or `walkSync`.
|
|
567
|
+
*/
|
|
568
|
+
interface WalkEntry extends Pick<Dirent, "isDirectory" | "isFile" | "isSymbolicLink" | "name"> {
|
|
569
|
+
/** The full path to the entry. */
|
|
570
|
+
path: string;
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Supported compression types for file operations.
|
|
574
|
+
*/
|
|
575
|
+
type CompressionType = "brotli" | "gzip" | "none";
|
|
576
|
+
/**
|
|
577
|
+
* Supported file encodings for reading files.
|
|
578
|
+
*/
|
|
579
|
+
type ReadFileEncoding = "ascii" | "base64" | "base64url" | "hex" | "latin1" | "ucs-2" | "ucs2" | "utf-8" | "utf-16le" | "utf8" | "utf16le";
|
|
580
|
+
/**
|
|
581
|
+
* Options for reading files.
|
|
582
|
+
*/
|
|
583
|
+
type ReadFileOptions<C> = {
|
|
584
|
+
/**
|
|
585
|
+
* Return content as a Buffer. Default: `false`
|
|
586
|
+
*/
|
|
587
|
+
buffer?: boolean;
|
|
588
|
+
/**
|
|
589
|
+
* Compression method to decompress the file against. Default: `none`
|
|
590
|
+
*/
|
|
591
|
+
compression?: C;
|
|
592
|
+
/**
|
|
593
|
+
* The encoding to use. Default: `utf8`
|
|
594
|
+
* @see https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
|
|
595
|
+
*/
|
|
596
|
+
encoding?: ReadFileEncoding;
|
|
597
|
+
/**
|
|
598
|
+
* The flag used to open the file. Default: `r`
|
|
599
|
+
*/
|
|
600
|
+
flag?: number | string;
|
|
601
|
+
};
|
|
602
|
+
/**
|
|
603
|
+
* Represents the content type of a read file, which can be a Buffer or a string based on options.
|
|
604
|
+
* @template O - The ReadFileOptions type.
|
|
605
|
+
*/
|
|
606
|
+
type ContentType<O = undefined> = O extends {
|
|
607
|
+
buffer: true;
|
|
608
|
+
} ? Buffer : string;
|
|
609
|
+
/**
|
|
610
|
+
* Type for the `reviver` parameter of `JSON.parse()`.
|
|
611
|
+
* A function that transforms the results. This function is called for each member of the object.
|
|
612
|
+
* If a member contains nested objects, the nested objects are transformed before the parent object is.
|
|
613
|
+
*/
|
|
614
|
+
type JsonReviver = Parameters<(typeof JSON)["parse"]>["1"];
|
|
615
|
+
/**
|
|
616
|
+
* Specifies a location (line and column) in a file for code frame generation.
|
|
617
|
+
*/
|
|
618
|
+
type CodeFrameLocation = {
|
|
619
|
+
/** The column number. */
|
|
620
|
+
column?: number;
|
|
621
|
+
/** The line number. */
|
|
622
|
+
line: number;
|
|
623
|
+
};
|
|
624
|
+
/**
|
|
625
|
+
* Options for customizing the appearance of code frames.
|
|
626
|
+
*/
|
|
627
|
+
type CodeFrameOptions = {
|
|
628
|
+
/** Colorization methods for different parts of the code frame. */
|
|
629
|
+
color?: {
|
|
630
|
+
/** Color for the gutter (line numbers). */
|
|
631
|
+
gutter?: ColorizeMethod;
|
|
632
|
+
/** Color for the marker (pointing to the error). */
|
|
633
|
+
marker?: ColorizeMethod;
|
|
634
|
+
/** Color for the message. */
|
|
635
|
+
message?: ColorizeMethod;
|
|
636
|
+
};
|
|
637
|
+
};
|
|
638
|
+
/**
|
|
639
|
+
* Options for reading and parsing JSON files.
|
|
640
|
+
* Extends {@link CodeFrameOptions}.
|
|
641
|
+
*/
|
|
642
|
+
type ReadJsonOptions = CodeFrameOptions & {
|
|
643
|
+
/**
|
|
644
|
+
* A function to transform the string content before parsing.
|
|
645
|
+
* @param source The raw string content of the file.
|
|
646
|
+
* @returns The transformed string content.
|
|
647
|
+
*/
|
|
648
|
+
beforeParse?: (source: string) => string;
|
|
649
|
+
};
|
|
650
|
+
/**
|
|
651
|
+
* Options for writing files.
|
|
652
|
+
*/
|
|
653
|
+
type WriteFileOptions = {
|
|
654
|
+
/**
|
|
655
|
+
* When `true` and the target file already exists, the previous contents are
|
|
656
|
+
* preserved by renaming the existing file to `${path}.bak` before the new
|
|
657
|
+
* contents are written. This is independent of {@link WriteFileOptions.overwrite}.
|
|
658
|
+
*
|
|
659
|
+
* Default: `false`
|
|
660
|
+
*/
|
|
661
|
+
backup?: boolean;
|
|
662
|
+
/**
|
|
663
|
+
* The group and user ID used to set the file ownership. Default: `undefined`
|
|
664
|
+
*/
|
|
665
|
+
chown?: {
|
|
666
|
+
gid: number;
|
|
667
|
+
uid: number;
|
|
668
|
+
};
|
|
669
|
+
/**
|
|
670
|
+
* The encoding to use. Default: `utf8`
|
|
671
|
+
*/
|
|
672
|
+
encoding?: BufferEncoding | null;
|
|
673
|
+
/**
|
|
674
|
+
* The flag used to write the file. Append flags (containing `a`) concatenate
|
|
675
|
+
* the new contents onto the existing file; exclusive flags (containing `x`)
|
|
676
|
+
* throw an `AlreadyExistsError` when the file already exists. Default: `w`
|
|
677
|
+
*/
|
|
678
|
+
flag?: string;
|
|
679
|
+
/**
|
|
680
|
+
* The file mode (permission and sticky bits). Default: `0o666`
|
|
681
|
+
*/
|
|
682
|
+
mode?: number;
|
|
683
|
+
/**
|
|
684
|
+
* Indicates whether the file should be overwritten if it already exists.
|
|
685
|
+
* When `false` and the target already exists, an `AlreadyExistsError` is thrown.
|
|
686
|
+
*
|
|
687
|
+
* Default: `true`
|
|
688
|
+
*/
|
|
689
|
+
overwrite?: boolean;
|
|
690
|
+
/**
|
|
691
|
+
* Recursively create parent directories if needed. Default: `true`
|
|
692
|
+
*/
|
|
693
|
+
recursive?: boolean;
|
|
694
|
+
};
|
|
695
|
+
/**
|
|
696
|
+
* Type for the `replacer` parameter of `JSON.stringify()`.
|
|
697
|
+
* Can be a function that alters the behavior of the stringification process,
|
|
698
|
+
* or an array of strings and numbers that acts as a whitelist for selecting
|
|
699
|
+
* the properties of the value object to be included in the JSON string.
|
|
700
|
+
* If this value is null or not provided, all properties of the object are included in the resulting JSON string.
|
|
701
|
+
*/
|
|
702
|
+
type JsonReplacer = (number | string)[] | ((this: unknown, key: string, value: unknown) => unknown) | null;
|
|
703
|
+
/**
|
|
704
|
+
* Type for the `replacer` parameter used in YAML serialization, similar to `JSON.stringify`'s replacer.
|
|
705
|
+
* @deprecated Use {@link JsonReplacer} directly instead.
|
|
706
|
+
*/
|
|
707
|
+
type YamlReplacer = JsonReplacer;
|
|
708
|
+
/**
|
|
709
|
+
* Options for writing JSON files.
|
|
710
|
+
* Extends {@link WriteFileOptions}.
|
|
711
|
+
*/
|
|
712
|
+
type WriteJsonOptions = WriteFileOptions & {
|
|
713
|
+
/**
|
|
714
|
+
* Detect indentation automatically if the file exists. Default: `false`
|
|
715
|
+
*/
|
|
716
|
+
detectIndent?: boolean;
|
|
717
|
+
/**
|
|
718
|
+
* The space used for pretty-printing.
|
|
719
|
+
*
|
|
720
|
+
* Pass in `undefined` for no formatting.
|
|
721
|
+
*/
|
|
722
|
+
indent?: number | string;
|
|
723
|
+
/**
|
|
724
|
+
* Passed into `JSON.stringify`.
|
|
725
|
+
*/
|
|
726
|
+
replacer?: JsonReplacer;
|
|
727
|
+
/**
|
|
728
|
+
* Override the default `JSON.stringify` method.
|
|
729
|
+
*/
|
|
730
|
+
stringify?: (data: unknown, replacer: JsonReplacer, space: number | string | undefined) => string;
|
|
731
|
+
};
|
|
732
|
+
/**
|
|
733
|
+
* Options for the `findUp` and `findUpSync` functions.
|
|
734
|
+
*/
|
|
735
|
+
type FindUpOptions = {
|
|
736
|
+
/**
|
|
737
|
+
* Whether to follow symbolic links.
|
|
738
|
+
* @default undefined (behaves like `true` for `findUp`, `false` for `findUpSync` due to `fs.stat` vs `fs.lstat`)
|
|
739
|
+
*/
|
|
740
|
+
allowSymlinks?: boolean;
|
|
741
|
+
/**
|
|
742
|
+
* The current working directory.
|
|
743
|
+
* @default process.cwd()
|
|
744
|
+
*/
|
|
745
|
+
cwd?: URL | string;
|
|
746
|
+
/**
|
|
747
|
+
* The directory to stop searching at.
|
|
748
|
+
* @default path.parse(cwd).root
|
|
749
|
+
*/
|
|
750
|
+
stopAt?: URL | string;
|
|
751
|
+
/**
|
|
752
|
+
* The type of path to find.
|
|
753
|
+
* @default "file"
|
|
754
|
+
*/
|
|
755
|
+
type?: "directory" | "file";
|
|
756
|
+
};
|
|
757
|
+
/**
|
|
758
|
+
* The result type for the name matcher function used in `findUp`.
|
|
759
|
+
* It can be a `PathLike` (string, Buffer, or URL), a Promise resolving to `PathLike` or `FIND_UP_STOP`,
|
|
760
|
+
* `FIND_UP_STOP` to stop the search, or `undefined` to continue.
|
|
761
|
+
*/
|
|
762
|
+
type FindUpNameFnResult = PathLike | Promise<PathLike | typeof FIND_UP_STOP> | typeof FIND_UP_STOP | undefined;
|
|
763
|
+
/**
|
|
764
|
+
* Specifies the name(s) of the file or directory to search for in `findUp`.
|
|
765
|
+
* Can be a single name, an array of names, or a function that returns a name or `FIND_UP_STOP`.
|
|
766
|
+
*/
|
|
767
|
+
type FindUpName = string[] | string | ((directory: string) => FindUpNameFnResult);
|
|
768
|
+
/**
|
|
769
|
+
* The result type for the name matcher function used in `findUpSync`.
|
|
770
|
+
* It can be a `PathLike` (string, Buffer, or URL), `FIND_UP_STOP` to stop the search,
|
|
771
|
+
* or `undefined` to continue.
|
|
772
|
+
*/
|
|
773
|
+
type FindUpNameSyncFnResult = PathLike | typeof FIND_UP_STOP | undefined;
|
|
774
|
+
/**
|
|
775
|
+
* Specifies the name(s) of the file or directory to search for in `findUpSync`.
|
|
776
|
+
* Can be a single name, an array of names, or a function that returns a name or `FIND_UP_STOP`.
|
|
777
|
+
*/
|
|
778
|
+
type FindUpNameSync = string[] | string | ((directory: string) => FindUpNameSyncFnResult);
|
|
779
|
+
/**
|
|
780
|
+
* Options for operations that might require retries, like `emptyDir` or `remove`.
|
|
781
|
+
*/
|
|
782
|
+
type RetryOptions = {
|
|
783
|
+
/**
|
|
784
|
+
* If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
|
|
785
|
+
* `EPERM` error is encountered, Node.js will retry the operation with a linear
|
|
786
|
+
* backoff wait of `retryDelay` ms longer on each try. This option represents the
|
|
787
|
+
* number of retries. This option is ignored if the `recursive` option is not
|
|
788
|
+
* `true` for operations that support it (like `rm`).
|
|
789
|
+
* @default 0
|
|
790
|
+
*/
|
|
791
|
+
maxRetries?: number;
|
|
792
|
+
/**
|
|
793
|
+
* The amount of time in milliseconds to wait between retries.
|
|
794
|
+
* This option is ignored if the `recursive` option is not `true` for operations that support it.
|
|
795
|
+
* @default 100
|
|
796
|
+
*/
|
|
797
|
+
retryDelay?: number;
|
|
798
|
+
};
|
|
799
|
+
/**
|
|
800
|
+
* Options for reading YAML files.
|
|
801
|
+
* Combines options from `yaml` library (DocumentOptions, ParseOptions, SchemaOptions, ToJSOptions)
|
|
802
|
+
* and custom {@link ReadFileOptions}.
|
|
803
|
+
*/
|
|
804
|
+
type ReadYamlOptions<C> = ReadFileOptions<C> & ParseOptions;
|
|
805
|
+
/**
|
|
806
|
+
* Type for the `reviver` parameter used in YAML deserialization, similar to `JSON.parse`'s reviver.
|
|
807
|
+
* A function that transforms the results. This function is called for each member of the object.
|
|
808
|
+
* If a member contains nested objects, the nested objects are transformed before the parent object is.
|
|
809
|
+
*/
|
|
810
|
+
type YamlReviver = (key: unknown, value: unknown) => unknown;
|
|
811
|
+
/**
|
|
812
|
+
* Options for writing YAML files.
|
|
813
|
+
* Extends {@link WriteFileOptions} and includes options from the `yaml` library for stringification.
|
|
814
|
+
*/
|
|
815
|
+
type WriteYamlExtras = {
|
|
816
|
+
/**
|
|
817
|
+
* Passed into `yaml.stringify` as the replacer argument.
|
|
818
|
+
*/
|
|
819
|
+
replacer?: JsonReplacer;
|
|
820
|
+
/**
|
|
821
|
+
* Passed into `yaml.stringify` as the space argument for indentation.
|
|
822
|
+
* Can be a number of spaces or a string (e.g., a tab character).
|
|
823
|
+
*/
|
|
824
|
+
space?: number | string;
|
|
825
|
+
};
|
|
826
|
+
type WriteYamlOptions = WriteFileOptions & WriteYamlExtras & StringifyOptions;
|
|
827
|
+
/**
|
|
828
|
+
* Options for reading TOML files.
|
|
829
|
+
* Uses `smol-toml`, which does not expose additional parse options.
|
|
830
|
+
*/
|
|
831
|
+
type ReadTomlOptions<C> = ReadFileOptions<C>;
|
|
832
|
+
/**
|
|
833
|
+
* Options for writing TOML files.
|
|
834
|
+
* Extends {@link WriteFileOptions}. `smol-toml` does not expose additional stringify options.
|
|
835
|
+
*/
|
|
836
|
+
type WriteTomlOptions = WriteFileOptions;
|
|
837
|
+
/**
|
|
838
|
+
* Extra options for JSONC parsing on top of file-reading and code-frame options.
|
|
839
|
+
*/
|
|
840
|
+
type ReadJsoncExtras = {
|
|
841
|
+
/**
|
|
842
|
+
* A function to transform the string content before parsing.
|
|
843
|
+
* @param source The raw string content of the file.
|
|
844
|
+
* @returns The transformed string content.
|
|
845
|
+
*/
|
|
846
|
+
beforeParse?: (source: string) => string;
|
|
847
|
+
};
|
|
848
|
+
/**
|
|
849
|
+
* Options for reading JSONC (JSON with comments) files.
|
|
850
|
+
* Combines options from `jsonc-parser` and custom {@link ReadFileOptions} and {@link CodeFrameOptions}.
|
|
851
|
+
*/
|
|
852
|
+
type ReadJsoncOptions<C> = CodeFrameOptions & JsoncParseOptions & ReadFileOptions<C> & ReadJsoncExtras;
|
|
853
|
+
/**
|
|
854
|
+
* Options for writing JSONC files with optional comment preservation.
|
|
855
|
+
* Extends {@link WriteFileOptions}.
|
|
856
|
+
*/
|
|
857
|
+
type WriteJsoncOptions = WriteFileOptions & {
|
|
858
|
+
/**
|
|
859
|
+
* Detect indentation automatically if the file exists. Default: `false`.
|
|
860
|
+
*/
|
|
861
|
+
detectIndent?: boolean;
|
|
862
|
+
/**
|
|
863
|
+
* Formatting options forwarded to `jsonc-parser` when modifying existing files.
|
|
864
|
+
*/
|
|
865
|
+
formattingOptions?: JsoncFormattingOptions;
|
|
866
|
+
/**
|
|
867
|
+
* Indentation used when writing a fresh file (no existing file to preserve).
|
|
868
|
+
* Default: `"\t"`.
|
|
869
|
+
*/
|
|
870
|
+
indent?: number | string;
|
|
871
|
+
/**
|
|
872
|
+
* When `true` and the file already exists, preserve existing comments and formatting
|
|
873
|
+
* by computing a minimal diff against the new data via `jsonc-parser`'s `modify` API. Default: `true`.
|
|
874
|
+
*/
|
|
875
|
+
preserveComments?: boolean;
|
|
876
|
+
/**
|
|
877
|
+
* Passed into `JSON.stringify` when writing a fresh file.
|
|
878
|
+
*/
|
|
879
|
+
replacer?: JsonReplacer;
|
|
880
|
+
};
|
|
881
|
+
/**
|
|
882
|
+
* Type for the `reviver` parameter of `JSON5.parse()`.
|
|
883
|
+
*/
|
|
884
|
+
type Json5Reviver = (this: unknown, key: string, value: unknown) => unknown;
|
|
885
|
+
/**
|
|
886
|
+
* Extra options for JSON5 parsing on top of file-reading and code-frame options.
|
|
887
|
+
*/
|
|
888
|
+
type ReadJson5Extras = {
|
|
889
|
+
/**
|
|
890
|
+
* A function to transform the string content before parsing.
|
|
891
|
+
*/
|
|
892
|
+
beforeParse?: (source: string) => string;
|
|
893
|
+
};
|
|
894
|
+
/**
|
|
895
|
+
* Options for reading JSON5 files.
|
|
896
|
+
*/
|
|
897
|
+
type ReadJson5Options<C> = CodeFrameOptions & ReadFileOptions<C> & ReadJson5Extras;
|
|
898
|
+
/**
|
|
899
|
+
* Options for writing JSON5 files.
|
|
900
|
+
* Extends {@link WriteFileOptions}.
|
|
901
|
+
*/
|
|
902
|
+
type WriteJson5Options = WriteFileOptions & {
|
|
903
|
+
/**
|
|
904
|
+
* Detect indentation automatically if the file exists. Default: `false`.
|
|
905
|
+
*/
|
|
906
|
+
detectIndent?: boolean;
|
|
907
|
+
/**
|
|
908
|
+
* Indentation for pretty-printing.
|
|
909
|
+
*/
|
|
910
|
+
indent?: number | string;
|
|
911
|
+
/**
|
|
912
|
+
* Override the quote character used for strings. See `JSON5.stringify`.
|
|
913
|
+
*/
|
|
914
|
+
quote?: string;
|
|
915
|
+
/**
|
|
916
|
+
* Passed into `JSON5.stringify`.
|
|
917
|
+
*/
|
|
918
|
+
replacer?: Json5Replacer;
|
|
919
|
+
};
|
|
920
|
+
/**
|
|
921
|
+
* Options for reading INI files.
|
|
922
|
+
*/
|
|
923
|
+
type ReadIniOptions<C> = ReadFileOptions<C> & {
|
|
924
|
+
/**
|
|
925
|
+
* Parse array values (keys ending with `[]`) into native arrays. Default: `true`.
|
|
926
|
+
*/
|
|
927
|
+
bracketedArray?: boolean;
|
|
928
|
+
};
|
|
929
|
+
/**
|
|
930
|
+
* Supported INI line-ending values.
|
|
931
|
+
*/
|
|
932
|
+
type IniLineEnding = "\n" | "\r\n";
|
|
933
|
+
/**
|
|
934
|
+
* Extra options for INI writing on top of the `ini` encoder options and file-writing options.
|
|
935
|
+
*/
|
|
936
|
+
type WriteIniExtras = {
|
|
937
|
+
/**
|
|
938
|
+
* Line ending to write. When omitted and {@link WriteIniOptions.preserveStyle | preserveStyle} is `true`,
|
|
939
|
+
* the line ending is auto-detected from the existing file. Falls back to `"\n"` otherwise.
|
|
940
|
+
*/
|
|
941
|
+
eol?: IniLineEnding;
|
|
942
|
+
/**
|
|
943
|
+
* When `true` and the file already exists, auto-detect and preserve styling described on this type.
|
|
944
|
+
* Defaults to `true`. Explicit `whitespace` / `eol` values always win over detection.
|
|
945
|
+
*/
|
|
946
|
+
preserveStyle?: boolean;
|
|
947
|
+
};
|
|
948
|
+
/**
|
|
949
|
+
* Options for writing INI files.
|
|
950
|
+
*
|
|
951
|
+
* Extends {@link WriteFileOptions} and `ini`'s {@link IniEncodeOptions}. When an existing file is present and
|
|
952
|
+
* {@link WriteIniOptions.preserveStyle | preserveStyle} is `true` (the default), the following styling is
|
|
953
|
+
* detected from that file and applied unless overridden: space around `=` (via {@link IniEncodeOptions.whitespace | whitespace}),
|
|
954
|
+
* line ending (via {@link WriteIniOptions.eol | eol}), and per-key original lines (including trailing
|
|
955
|
+
* whitespace and inline `;` / `#` comments) for unchanged values.
|
|
956
|
+
*/
|
|
957
|
+
type WriteIniOptions = IniEncodeOptions & WriteFileOptions & WriteIniExtras;
|
|
958
|
+
export { CodeFrameLocation as A, FIND_UP_STOP as B, CompressionType as C, F_OK as D, FindUpNameFnResult as E, FindUpName as F, FindUpNameSyncFnResult as G, GlobOptions as H, IniEncodeOptions as I, Json5Reviver as J, R_OK as K, ReadFileEncoding as L, W_OK as M, ReadIniOptions as R, WriteIniOptions as W, X_OK as X, YamlReviver as Y, IniLineEnding as a, ReadJson5Options as b, WriteJson5Options as c, Json5Replacer as d, ReadJsoncOptions as e, WriteJsoncOptions as f, JsoncFormattingOptions as g, JsoncParseOptions as h, ReadTomlOptions as i, WriteTomlOptions as j, CodeFrameOptions as k, JsonReviver as l, ReadYamlOptions as m, WriteYamlOptions as n, JsonReplacer as o, YamlReplacer as p, WalkOptions as q, FindUpOptions as r, FindUpNameSync as s, WalkEntry as t, ReadFileOptions as u, ContentType as v, ReadJsonOptions as w, RetryOptions as x, WriteFileOptions as y, WriteJsonOptions as z };
|