cdk8s-plus-36 0.0.1 → 2.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/.jsii +105714 -0
- package/CODE_OF_CONDUCT.md +3 -0
- package/CONTRIBUTING.md +185 -0
- package/DCO +34 -0
- package/LICENSE +202 -0
- package/NOTICE +1 -0
- package/OWNERS.md +5 -0
- package/README.md +21 -34
- package/SECURITY.md +5 -0
- package/cdk8s.yaml +13 -0
- package/docs/java.md +156096 -0
- package/docs/plus/config-map.md +98 -0
- package/docs/plus/container.md +133 -0
- package/docs/plus/cronjob.md +67 -0
- package/docs/plus/deployment.md +232 -0
- package/docs/plus/horizontal-pod-autoscaler.md +226 -0
- package/docs/plus/ingress.md +68 -0
- package/docs/plus/job.md +48 -0
- package/docs/plus/namespace.md +58 -0
- package/docs/plus/network-policy.md +341 -0
- package/docs/plus/pod.md +455 -0
- package/docs/plus/pv.md +82 -0
- package/docs/plus/pvc.md +77 -0
- package/docs/plus/rbac.md +104 -0
- package/docs/plus/secret.md +32 -0
- package/docs/plus/service-account.md +35 -0
- package/docs/plus/service.md +41 -0
- package/docs/plus/volume.md +84 -0
- package/docs/python.md +167536 -0
- package/docs/typescript.md +145485 -0
- package/git-hooks/README.md +9 -0
- package/git-hooks/prepare-commit-msg +18 -0
- package/git-hooks/setup.sh +10 -0
- package/lib/_action.d.ts +26 -0
- package/lib/_action.js +72 -0
- package/lib/api-resource.d.ts +298 -0
- package/lib/api-resource.js +438 -0
- package/lib/base.d.ts +79 -0
- package/lib/base.js +124 -0
- package/lib/config-map.d.ts +126 -0
- package/lib/config-map.js +199 -0
- package/lib/container.d.ts +1057 -0
- package/lib/container.js +944 -0
- package/lib/cron-job.d.ts +138 -0
- package/lib/cron-job.js +170 -0
- package/lib/daemon-set.d.ts +45 -0
- package/lib/daemon-set.js +91 -0
- package/lib/deployment.d.ts +235 -0
- package/lib/deployment.js +274 -0
- package/lib/handler.d.ts +62 -0
- package/lib/handler.js +88 -0
- package/lib/horizontal-pod-autoscaler.d.ts +500 -0
- package/lib/horizontal-pod-autoscaler.js +629 -0
- package/lib/imports/k8s.d.ts +27283 -0
- package/lib/imports/k8s.js +20112 -0
- package/lib/index.d.ts +26 -0
- package/lib/index.js +66 -0
- package/lib/ingress.d.ts +230 -0
- package/lib/ingress.js +282 -0
- package/lib/job.d.ts +64 -0
- package/lib/job.js +101 -0
- package/lib/namespace.d.ts +128 -0
- package/lib/namespace.js +148 -0
- package/lib/network-policy.d.ts +311 -0
- package/lib/network-policy.js +383 -0
- package/lib/pod.d.ts +1097 -0
- package/lib/pod.js +1227 -0
- package/lib/probe.d.ts +181 -0
- package/lib/probe.js +124 -0
- package/lib/pv.d.ts +375 -0
- package/lib/pv.js +387 -0
- package/lib/pvc.d.ts +163 -0
- package/lib/pvc.js +204 -0
- package/lib/role-binding.d.ts +138 -0
- package/lib/role-binding.js +207 -0
- package/lib/role.d.ts +268 -0
- package/lib/role.js +441 -0
- package/lib/secret.d.ts +195 -0
- package/lib/secret.js +221 -0
- package/lib/service-account.d.ts +83 -0
- package/lib/service-account.js +148 -0
- package/lib/service.d.ts +289 -0
- package/lib/service.js +235 -0
- package/lib/stateful-set.d.ts +206 -0
- package/lib/stateful-set.js +291 -0
- package/lib/utils.d.ts +4 -0
- package/lib/utils.js +33 -0
- package/lib/volume.d.ts +577 -0
- package/lib/volume.js +410 -0
- package/lib/workload.d.ts +121 -0
- package/lib/workload.js +158 -0
- package/node_modules/balanced-match/.github/FUNDING.yml +2 -0
- package/node_modules/balanced-match/LICENSE.md +21 -0
- package/node_modules/balanced-match/README.md +97 -0
- package/node_modules/balanced-match/index.js +62 -0
- package/node_modules/balanced-match/package.json +48 -0
- package/node_modules/brace-expansion/.github/FUNDING.yml +2 -0
- package/node_modules/brace-expansion/LICENSE +21 -0
- package/node_modules/brace-expansion/README.md +157 -0
- package/node_modules/brace-expansion/index.js +394 -0
- package/node_modules/brace-expansion/package.json +49 -0
- package/node_modules/minimatch/LICENSE +15 -0
- package/node_modules/minimatch/README.md +491 -0
- package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts +2 -0
- package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts.map +1 -0
- package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +14 -0
- package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js.map +1 -0
- package/node_modules/minimatch/dist/commonjs/ast.d.ts +20 -0
- package/node_modules/minimatch/dist/commonjs/ast.d.ts.map +1 -0
- package/node_modules/minimatch/dist/commonjs/ast.js +747 -0
- package/node_modules/minimatch/dist/commonjs/ast.js.map +1 -0
- package/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +8 -0
- package/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts.map +1 -0
- package/node_modules/minimatch/dist/commonjs/brace-expressions.js +152 -0
- package/node_modules/minimatch/dist/commonjs/brace-expressions.js.map +1 -0
- package/node_modules/minimatch/dist/commonjs/escape.d.ts +12 -0
- package/node_modules/minimatch/dist/commonjs/escape.d.ts.map +1 -0
- package/node_modules/minimatch/dist/commonjs/escape.js +22 -0
- package/node_modules/minimatch/dist/commonjs/escape.js.map +1 -0
- package/node_modules/minimatch/dist/commonjs/index.d.ts +98 -0
- package/node_modules/minimatch/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/minimatch/dist/commonjs/index.js +1023 -0
- package/node_modules/minimatch/dist/commonjs/index.js.map +1 -0
- package/node_modules/minimatch/dist/commonjs/package.json +3 -0
- package/node_modules/minimatch/dist/commonjs/unescape.d.ts +17 -0
- package/node_modules/minimatch/dist/commonjs/unescape.d.ts.map +1 -0
- package/node_modules/minimatch/dist/commonjs/unescape.js +24 -0
- package/node_modules/minimatch/dist/commonjs/unescape.js.map +1 -0
- package/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts +2 -0
- package/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts.map +1 -0
- package/node_modules/minimatch/dist/esm/assert-valid-pattern.js +10 -0
- package/node_modules/minimatch/dist/esm/assert-valid-pattern.js.map +1 -0
- package/node_modules/minimatch/dist/esm/ast.d.ts +20 -0
- package/node_modules/minimatch/dist/esm/ast.d.ts.map +1 -0
- package/node_modules/minimatch/dist/esm/ast.js +743 -0
- package/node_modules/minimatch/dist/esm/ast.js.map +1 -0
- package/node_modules/minimatch/dist/esm/brace-expressions.d.ts +8 -0
- package/node_modules/minimatch/dist/esm/brace-expressions.d.ts.map +1 -0
- package/node_modules/minimatch/dist/esm/brace-expressions.js +148 -0
- package/node_modules/minimatch/dist/esm/brace-expressions.js.map +1 -0
- package/node_modules/minimatch/dist/esm/escape.d.ts +12 -0
- package/node_modules/minimatch/dist/esm/escape.d.ts.map +1 -0
- package/node_modules/minimatch/dist/esm/escape.js +18 -0
- package/node_modules/minimatch/dist/esm/escape.js.map +1 -0
- package/node_modules/minimatch/dist/esm/index.d.ts +98 -0
- package/node_modules/minimatch/dist/esm/index.d.ts.map +1 -0
- package/node_modules/minimatch/dist/esm/index.js +1007 -0
- package/node_modules/minimatch/dist/esm/index.js.map +1 -0
- package/node_modules/minimatch/dist/esm/package.json +3 -0
- package/node_modules/minimatch/dist/esm/unescape.d.ts +17 -0
- package/node_modules/minimatch/dist/esm/unescape.d.ts.map +1 -0
- package/node_modules/minimatch/dist/esm/unescape.js +20 -0
- package/node_modules/minimatch/dist/esm/unescape.js.map +1 -0
- package/node_modules/minimatch/package.json +82 -0
- package/package.json +172 -6
- package/rotate.md +82 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
var balanced = require('balanced-match');
|
|
2
|
+
|
|
3
|
+
module.exports = expandTop;
|
|
4
|
+
|
|
5
|
+
var escSlash = '\0SLASH'+Math.random()+'\0';
|
|
6
|
+
var escOpen = '\0OPEN'+Math.random()+'\0';
|
|
7
|
+
var escClose = '\0CLOSE'+Math.random()+'\0';
|
|
8
|
+
var escComma = '\0COMMA'+Math.random()+'\0';
|
|
9
|
+
var escPeriod = '\0PERIOD'+Math.random()+'\0';
|
|
10
|
+
|
|
11
|
+
var EXPANSION_MAX = 100000
|
|
12
|
+
|
|
13
|
+
// `EXPANSION_MAX` caps the *number* of expansions, but not their length. An
|
|
14
|
+
// input like `'{a,b}'.repeat(1500)` stays under that count - its output is
|
|
15
|
+
// truncated to 100k results - while making every result ~1500 characters
|
|
16
|
+
// long. The result set, and the intermediate arrays built while combining
|
|
17
|
+
// brace sets, then grow large enough to exhaust memory and crash the process
|
|
18
|
+
// (CVE-2026-14257). `EXPANSION_MAX_LENGTH` bounds the total number of
|
|
19
|
+
// characters the accumulator may hold at any point, so memory stays flat no
|
|
20
|
+
// matter how many brace groups are chained. The limit sits well above any
|
|
21
|
+
// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
|
|
22
|
+
// characters) so legitimate input is unaffected.
|
|
23
|
+
var EXPANSION_MAX_LENGTH = 4000000
|
|
24
|
+
|
|
25
|
+
// `expand` recurses once per level of brace *nesting* - both when expanding a
|
|
26
|
+
// set's comma members and when re-wrapping a set whose body is a single part.
|
|
27
|
+
// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one
|
|
28
|
+
// level per chained group), which left nesting depth unbounded: about 3,100
|
|
29
|
+
// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack
|
|
30
|
+
// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser
|
|
31
|
+
// will follow nesting. It sits far above any realistic pattern and well below
|
|
32
|
+
// the depth at which the stack runs out.
|
|
33
|
+
var EXPANSION_MAX_DEPTH = 1000
|
|
34
|
+
|
|
35
|
+
// Bash keeps a quirk where a brace group followed by a comma set still expands
|
|
36
|
+
// (`{a},b}`). The parser implements it by rewriting the string and restarting
|
|
37
|
+
// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n`
|
|
38
|
+
// full passes over a string that itself grows by one `escClose` sentinel each
|
|
39
|
+
// time - quadratic in `n`, with a ~26x constant from the sentinel's length.
|
|
40
|
+
// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27
|
|
41
|
+
// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many
|
|
42
|
+
// times the scan may restart. Real `{a},b}` input needs a handful.
|
|
43
|
+
var EXPANSION_MAX_REWRITES = 1000
|
|
44
|
+
|
|
45
|
+
function numeric(str) {
|
|
46
|
+
return parseInt(str, 10) == str
|
|
47
|
+
? parseInt(str, 10)
|
|
48
|
+
: str.charCodeAt(0);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function escapeBraces(str) {
|
|
52
|
+
return str.split('\\\\').join(escSlash)
|
|
53
|
+
.split('\\{').join(escOpen)
|
|
54
|
+
.split('\\}').join(escClose)
|
|
55
|
+
.split('\\,').join(escComma)
|
|
56
|
+
.split('\\.').join(escPeriod);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function unescapeBraces(str) {
|
|
60
|
+
return str.split(escSlash).join('\\')
|
|
61
|
+
.split(escOpen).join('{')
|
|
62
|
+
.split(escClose).join('}')
|
|
63
|
+
.split(escComma).join(',')
|
|
64
|
+
.split(escPeriod).join('.');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
// Like `target.push(...items)` but doesn't overflow the stack
|
|
69
|
+
function pushAll(target, items) {
|
|
70
|
+
for (var i = 0; i < items.length; i++) {
|
|
71
|
+
target.push(items[i]);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Basically just str.split(","), but handling cases
|
|
76
|
+
// where we have nested braced sections, which should be
|
|
77
|
+
// treated as individual members, like {a,{b,c},d}
|
|
78
|
+
function parseCommaParts(str) {
|
|
79
|
+
var parts = [];
|
|
80
|
+
|
|
81
|
+
// Walk the brace groups iteratively. Recursing on `post` once per group let a
|
|
82
|
+
// chain of them exhaust the stack - the parsing-side counterpart to
|
|
83
|
+
// the `expand` overflow fixed for CVE-2026-14257, and not something `max` or
|
|
84
|
+
// `maxLength` can bound, since it happens before expansion.
|
|
85
|
+
//
|
|
86
|
+
// The part the next chunk continues
|
|
87
|
+
var carry = '';
|
|
88
|
+
|
|
89
|
+
for (;;) {
|
|
90
|
+
var m = balanced('{', '}', str);
|
|
91
|
+
|
|
92
|
+
if (!m) {
|
|
93
|
+
var tail = str.split(',');
|
|
94
|
+
tail[0] = carry + tail[0];
|
|
95
|
+
pushAll(parts, tail);
|
|
96
|
+
return parts;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
var pre = m.pre;
|
|
100
|
+
var body = m.body;
|
|
101
|
+
var post = m.post;
|
|
102
|
+
var p = pre.split(',');
|
|
103
|
+
|
|
104
|
+
p[0] = carry + p[0];
|
|
105
|
+
p[p.length-1] += '{' + body + '}';
|
|
106
|
+
|
|
107
|
+
if (!post.length) {
|
|
108
|
+
pushAll(parts, p);
|
|
109
|
+
return parts;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
carry = p.pop();
|
|
113
|
+
pushAll(parts, p);
|
|
114
|
+
str = post;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function expandTop(str, options) {
|
|
119
|
+
if (!str)
|
|
120
|
+
return [];
|
|
121
|
+
|
|
122
|
+
options = options || {};
|
|
123
|
+
var max = options.max == null ? EXPANSION_MAX : options.max;
|
|
124
|
+
var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH : options.maxLength;
|
|
125
|
+
var maxDepth = options.maxDepth == null ? EXPANSION_MAX_DEPTH : options.maxDepth;
|
|
126
|
+
var maxRewrites = options.maxRewrites == null ? EXPANSION_MAX_REWRITES : options.maxRewrites;
|
|
127
|
+
|
|
128
|
+
// I don't know why Bash 4.3 does this, but it does.
|
|
129
|
+
// Anything starting with {} will have the first two bytes preserved
|
|
130
|
+
// but *only* at the top level, so {},a}b will not expand to anything,
|
|
131
|
+
// but a{},b}c will be expanded to [a}c,abc].
|
|
132
|
+
// One could argue that this is a bug in Bash, but since the goal of
|
|
133
|
+
// this module is to match Bash's rules, we escape a leading {}
|
|
134
|
+
if (str.substr(0, 2) === '{}') {
|
|
135
|
+
str = '\\{\\}' + str.substr(2);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return expand(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function embrace(str) {
|
|
142
|
+
return '{' + str + '}';
|
|
143
|
+
}
|
|
144
|
+
function isPadded(el) {
|
|
145
|
+
return /^-?0\d/.test(el);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function lte(i, y) {
|
|
149
|
+
return i <= y;
|
|
150
|
+
}
|
|
151
|
+
function gte(i, y) {
|
|
152
|
+
return i >= y;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Build `{ acc[a] + pre + values[v] }` for every combination, capping the
|
|
156
|
+
// number of results at `max` and the total number of characters at `maxLength`.
|
|
157
|
+
// This is the one place output grows, so bounding it here keeps the single
|
|
158
|
+
// accumulator - and therefore memory - flat regardless of how many brace groups
|
|
159
|
+
// are combined (CVE-2026-14257).
|
|
160
|
+
function combine(
|
|
161
|
+
acc,
|
|
162
|
+
pre,
|
|
163
|
+
values,
|
|
164
|
+
max,
|
|
165
|
+
maxLength,
|
|
166
|
+
dropEmpties
|
|
167
|
+
) {
|
|
168
|
+
var out = []
|
|
169
|
+
var length = 0
|
|
170
|
+
for (var a = 0; a < acc.length; a++) {
|
|
171
|
+
for (var v = 0; v < values.length; v++) {
|
|
172
|
+
if (out.length >= max) return out
|
|
173
|
+
var expansion = acc[a] + pre + values[v]
|
|
174
|
+
// Bash drops empty results at the top level. Skip them before they count
|
|
175
|
+
// against `max`, so `max` bounds the number of *kept* results.
|
|
176
|
+
if (dropEmpties && !expansion) continue
|
|
177
|
+
if (length + expansion.length > maxLength) return out
|
|
178
|
+
out.push(expansion)
|
|
179
|
+
length += expansion.length
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return out
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// The expansion values of a single numeric (`1..5`) or alphabetic (`a..e..2`)
|
|
186
|
+
// sequence body.
|
|
187
|
+
function expandSequence(
|
|
188
|
+
body,
|
|
189
|
+
isAlphaSequence,
|
|
190
|
+
max,
|
|
191
|
+
maxLength
|
|
192
|
+
) {
|
|
193
|
+
var n = body.split(/\.\./)
|
|
194
|
+
var N = []
|
|
195
|
+
// A sequence body always splits into two or three parts, but the compiler
|
|
196
|
+
// can't know that.
|
|
197
|
+
/* c8 ignore start */
|
|
198
|
+
if (n[0] === undefined || n[1] === undefined) {
|
|
199
|
+
return N
|
|
200
|
+
}
|
|
201
|
+
/* c8 ignore stop */
|
|
202
|
+
var x = numeric(n[0])
|
|
203
|
+
var y = numeric(n[1])
|
|
204
|
+
var width = Math.max(n[0].length, n[1].length)
|
|
205
|
+
var incr =
|
|
206
|
+
n.length === 3 && n[2] !== undefined ?
|
|
207
|
+
Math.max(Math.abs(numeric(n[2])), 1)
|
|
208
|
+
: 1
|
|
209
|
+
var test = lte
|
|
210
|
+
var reverse = y < x
|
|
211
|
+
if (reverse) {
|
|
212
|
+
incr *= -1
|
|
213
|
+
test = gte
|
|
214
|
+
}
|
|
215
|
+
var pad = n.some(isPadded)
|
|
216
|
+
|
|
217
|
+
var length = 0
|
|
218
|
+
for (var i = x; test(i, y) && N.length < max; i += incr) {
|
|
219
|
+
var c
|
|
220
|
+
if (isAlphaSequence) {
|
|
221
|
+
c = String.fromCharCode(i)
|
|
222
|
+
if (c === '\\') {
|
|
223
|
+
c = ''
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
c = String(i)
|
|
227
|
+
if (pad) {
|
|
228
|
+
var need = width - c.length
|
|
229
|
+
if (need > 0) {
|
|
230
|
+
var z = new Array(need + 1).join('0')
|
|
231
|
+
if (i < 0) {
|
|
232
|
+
c = '-' + z + c.slice(1)
|
|
233
|
+
} else {
|
|
234
|
+
c = z + c
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (length + c.length > maxLength) break
|
|
240
|
+
N.push(c)
|
|
241
|
+
length += c.length
|
|
242
|
+
}
|
|
243
|
+
return N
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function expand(
|
|
247
|
+
str,
|
|
248
|
+
max,
|
|
249
|
+
maxLength,
|
|
250
|
+
maxDepth,
|
|
251
|
+
depth,
|
|
252
|
+
maxRewrites,
|
|
253
|
+
isTop
|
|
254
|
+
) {
|
|
255
|
+
// Too deeply nested to keep following: treat the rest as literal, the same
|
|
256
|
+
// way a group that cannot expand is already handled. Truncating rather than
|
|
257
|
+
// throwing keeps expansion total, matching `max` and `maxLength`.
|
|
258
|
+
if (depth > maxDepth) {
|
|
259
|
+
return [str];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Consume the string's top-level brace groups left to right, threading a
|
|
263
|
+
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
|
264
|
+
// rather than recursing on `m.post` once per group - keeps the native stack
|
|
265
|
+
// depth constant, so deeply chained input (`'{a,b}'.repeat(3000)`) can no
|
|
266
|
+
// longer overflow the stack, and leaves a single accumulator whose size
|
|
267
|
+
// `maxLength` bounds directly (CVE-2026-14257).
|
|
268
|
+
var acc = ['']
|
|
269
|
+
|
|
270
|
+
// Bash drops empty results, but only when the *first* top-level group is a
|
|
271
|
+
// comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
|
|
272
|
+
// is on the final strings, so it is applied to whichever `combine` produces
|
|
273
|
+
// them (the one with no brace set left in the tail).
|
|
274
|
+
// How many times the `{a},b}` rewrite below has restarted the scan. Each pass
|
|
275
|
+
// re-reads the whole string, so leaving this unbounded is quadratic.
|
|
276
|
+
var rewrites = 0
|
|
277
|
+
var dropEmpties = false
|
|
278
|
+
var firstGroup = true
|
|
279
|
+
|
|
280
|
+
for (;;) {
|
|
281
|
+
const m = balanced('{', '}', str)
|
|
282
|
+
|
|
283
|
+
// No brace set left: the rest of the string is literal.
|
|
284
|
+
if (!m) {
|
|
285
|
+
return combine(acc, str, [''], max, maxLength, dropEmpties)
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
|
289
|
+
const pre = m.pre
|
|
290
|
+
|
|
291
|
+
if (/\$$/.test(pre)) {
|
|
292
|
+
acc = combine(
|
|
293
|
+
acc,
|
|
294
|
+
pre + '{' + m.body + '}',
|
|
295
|
+
[''],
|
|
296
|
+
max,
|
|
297
|
+
maxLength,
|
|
298
|
+
dropEmpties && !m.post.length
|
|
299
|
+
)
|
|
300
|
+
firstGroup = false
|
|
301
|
+
if (!m.post.length) break
|
|
302
|
+
str = m.post
|
|
303
|
+
continue
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
307
|
+
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
308
|
+
var isSequence = isNumericSequence || isAlphaSequence;
|
|
309
|
+
var isOptions = m.body.indexOf(',') >= 0;
|
|
310
|
+
if (!isSequence && !isOptions) {
|
|
311
|
+
// {a},b}
|
|
312
|
+
if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
|
|
313
|
+
rewrites++;
|
|
314
|
+
str = m.pre + '{' + m.body + escClose + m.post;
|
|
315
|
+
isTop = true;
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
// Nothing here expands, so the whole remaining string is literal.
|
|
319
|
+
return combine(
|
|
320
|
+
acc,
|
|
321
|
+
pre + '{' + m.body + '}' + m.post,
|
|
322
|
+
[''],
|
|
323
|
+
max,
|
|
324
|
+
maxLength,
|
|
325
|
+
dropEmpties
|
|
326
|
+
)
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (firstGroup) {
|
|
330
|
+
dropEmpties = isTop && !isSequence
|
|
331
|
+
firstGroup = false
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
var values;
|
|
335
|
+
if (isSequence) {
|
|
336
|
+
values = expandSequence(m.body, isAlphaSequence, max, maxLength);
|
|
337
|
+
} else {
|
|
338
|
+
var n = parseCommaParts(m.body);
|
|
339
|
+
if (n.length === 1 && n[0] !== undefined) {
|
|
340
|
+
// x{{a,b}}y ==> x{a}y x{b}y
|
|
341
|
+
n = expand(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
|
|
342
|
+
//XXX is this necessary? Can't seem to hit it in tests.
|
|
343
|
+
/* c8 ignore start */
|
|
344
|
+
if (n.length === 1) {
|
|
345
|
+
acc = combine(
|
|
346
|
+
acc,
|
|
347
|
+
pre + n[0],
|
|
348
|
+
[''],
|
|
349
|
+
max,
|
|
350
|
+
maxLength,
|
|
351
|
+
dropEmpties && !m.post.length
|
|
352
|
+
)
|
|
353
|
+
if (!m.post.length) break
|
|
354
|
+
str = m.post
|
|
355
|
+
continue
|
|
356
|
+
}
|
|
357
|
+
/* c8 ignore stop */
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// Values that `combine` is going to drop as empty produce no result, so
|
|
361
|
+
// they must not count against `max` - otherwise `{a,,b}` with `max: 2`
|
|
362
|
+
// would stop at `['a', '']` and yield one result instead of two. Skipping
|
|
363
|
+
// them outright keeps `values` bounded while leaving `max` a bound on
|
|
364
|
+
// *kept* results.
|
|
365
|
+
var dropsEmpties = dropEmpties && !m.post.length && !pre
|
|
366
|
+
for (var d = 0; dropsEmpties && d < acc.length; d++) {
|
|
367
|
+
if (acc[d]) {
|
|
368
|
+
dropsEmpties = false
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
values = []
|
|
373
|
+
var valuesLength = 0
|
|
374
|
+
outer: for (var j = 0; j < n.length; j++) {
|
|
375
|
+
var expanded = expand(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false)
|
|
376
|
+
for (var k = 0; k < expanded.length; k++) {
|
|
377
|
+
var v = expanded[k]
|
|
378
|
+
if (dropsEmpties && !v) continue
|
|
379
|
+
if (values.length >= max || valuesLength + v.length > maxLength) {
|
|
380
|
+
break outer
|
|
381
|
+
}
|
|
382
|
+
values.push(v)
|
|
383
|
+
valuesLength += v.length
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length)
|
|
389
|
+
if (!m.post.length) break
|
|
390
|
+
str = m.post
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return acc
|
|
394
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "brace-expansion",
|
|
3
|
+
"description": "Brace expansion as known from sh/bash",
|
|
4
|
+
"version": "2.1.7",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git://github.com/juliangruber/brace-expansion.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/juliangruber/brace-expansion",
|
|
10
|
+
"main": "index.js",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "tape test/*.js",
|
|
13
|
+
"gentest": "bash test/generate.sh",
|
|
14
|
+
"bench": "matcha test/perf/bench.js"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"balanced-match": "^1.0.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@c4312/matcha": "^1.3.1",
|
|
21
|
+
"tape": "^4.6.0"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [],
|
|
24
|
+
"author": {
|
|
25
|
+
"name": "Julian Gruber",
|
|
26
|
+
"email": "mail@juliangruber.com",
|
|
27
|
+
"url": "http://juliangruber.com"
|
|
28
|
+
},
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"testling": {
|
|
31
|
+
"files": "test/*.js",
|
|
32
|
+
"browsers": [
|
|
33
|
+
"ie/8..latest",
|
|
34
|
+
"firefox/20..latest",
|
|
35
|
+
"firefox/nightly",
|
|
36
|
+
"chrome/25..latest",
|
|
37
|
+
"chrome/canary",
|
|
38
|
+
"opera/12..latest",
|
|
39
|
+
"opera/next",
|
|
40
|
+
"safari/5.1..latest",
|
|
41
|
+
"ipad/6.0..latest",
|
|
42
|
+
"iphone/6.0..latest",
|
|
43
|
+
"android-browser/4.2..latest"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"tag": "2.x"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
The ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2011-2023 Isaac Z. Schlueter and Contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
15
|
+
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|