@fabioplunser/epd 0.5.13 → 0.5.14
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/dist/cli.js +79 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -270,7 +270,7 @@ function loadEnvironment(root, destination) {
|
|
|
270
270
|
return env;
|
|
271
271
|
}
|
|
272
272
|
function interpolateText(text, env, file) {
|
|
273
|
-
|
|
273
|
+
const substitute = (value) => value.replace(/\$(\$?)\{([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\}/g, (_m, escape, name, dflt) => {
|
|
274
274
|
if (escape)
|
|
275
275
|
return `\${${name}${dflt !== undefined ? `:-${dflt}` : ""}}`;
|
|
276
276
|
const v = env[name];
|
|
@@ -280,6 +280,83 @@ function interpolateText(text, env, file) {
|
|
|
280
280
|
return dflt;
|
|
281
281
|
throw new EpdError(`${file}: environment variable \${${name}} is not set`, `Export it, add it to .env, or write \${${name}:-fallback}.`);
|
|
282
282
|
});
|
|
283
|
+
let quote = null;
|
|
284
|
+
let flowDepth = 0;
|
|
285
|
+
let blockIndent = null;
|
|
286
|
+
let blockContentIndent = null;
|
|
287
|
+
return text.split(`
|
|
288
|
+
`).map((line) => {
|
|
289
|
+
const indent = line.match(/^ */)[0].length;
|
|
290
|
+
if (blockIndent !== null) {
|
|
291
|
+
if (!line.trim() || indent > blockIndent) {
|
|
292
|
+
blockContentIndent ??= line.trim() ? indent : null;
|
|
293
|
+
if (blockContentIndent === null || indent >= blockContentIndent)
|
|
294
|
+
return substitute(line);
|
|
295
|
+
}
|
|
296
|
+
blockIndent = blockContentIndent = null;
|
|
297
|
+
}
|
|
298
|
+
let comment = line.length;
|
|
299
|
+
let scalarStart = quote === null;
|
|
300
|
+
for (let i = 0;i < line.length; i++) {
|
|
301
|
+
const char = line[i];
|
|
302
|
+
if (quote) {
|
|
303
|
+
if (quote === '"' && char === "\\") {
|
|
304
|
+
i++;
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
if (char === quote) {
|
|
308
|
+
if (quote === "'" && line[i + 1] === "'") {
|
|
309
|
+
i++;
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
quote = null;
|
|
313
|
+
}
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
if (char === "#" && (i === 0 || /\s/.test(line[i - 1]))) {
|
|
317
|
+
comment = i;
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
if (char === "$" && /^\$\$?\{/.test(line.slice(i))) {
|
|
321
|
+
const end = line.indexOf("}", i);
|
|
322
|
+
if (end !== -1) {
|
|
323
|
+
i = end;
|
|
324
|
+
scalarStart = false;
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if (scalarStart && (char === "'" || char === '"')) {
|
|
329
|
+
quote = char;
|
|
330
|
+
scalarStart = false;
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
if (/\s/.test(char))
|
|
334
|
+
continue;
|
|
335
|
+
if (scalarStart && (char === "&" || char === "!")) {
|
|
336
|
+
while (i + 1 < line.length && !/\s/.test(line[i + 1]))
|
|
337
|
+
i++;
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
if (scalarStart && (char === "[" || char === "{")) {
|
|
341
|
+
flowDepth++;
|
|
342
|
+
} else if (flowDepth && (char === "]" || char === "}")) {
|
|
343
|
+
flowDepth--;
|
|
344
|
+
scalarStart = false;
|
|
345
|
+
} else if (flowDepth && (char === "," || char === ":") || (char === ":" || char === "-" || char === "?") && /\s/.test(line[i + 1] || " ")) {
|
|
346
|
+
scalarStart = true;
|
|
347
|
+
} else {
|
|
348
|
+
scalarStart = false;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
const content = line.slice(0, comment);
|
|
352
|
+
if (!quote && /(?:^|:\s+|-\s+)[|>](?:[1-9][+-]?|[+-][1-9]?)?\s*$/.test(content)) {
|
|
353
|
+
blockIndent = indent;
|
|
354
|
+
const explicitIndent = content.match(/[|>][+-]?([1-9])/);
|
|
355
|
+
blockContentIndent = explicitIndent ? indent + Number(explicitIndent[1]) : null;
|
|
356
|
+
}
|
|
357
|
+
return substitute(content) + line.slice(comment);
|
|
358
|
+
}).join(`
|
|
359
|
+
`);
|
|
283
360
|
}
|
|
284
361
|
function deepMerge(base, overlay) {
|
|
285
362
|
const out = Array.isArray(base) ? [...base] : { ...base };
|
|
@@ -7575,7 +7652,7 @@ var init_update = __esm(() => {
|
|
|
7575
7652
|
});
|
|
7576
7653
|
|
|
7577
7654
|
// package.json
|
|
7578
|
-
var version = "0.5.
|
|
7655
|
+
var version = "0.5.14";
|
|
7579
7656
|
var init_package = () => {};
|
|
7580
7657
|
|
|
7581
7658
|
// src/version.ts
|
package/package.json
CHANGED