dokku-compose 0.6.0 → 0.6.2
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/index.js +43 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -302,14 +302,16 @@ function parseReport(raw, namespace) {
|
|
|
302
302
|
}
|
|
303
303
|
return result;
|
|
304
304
|
}
|
|
305
|
-
function parseBulkReport(raw, namespace) {
|
|
305
|
+
function parseBulkReport(raw, namespace, headerNamespace) {
|
|
306
306
|
const result = /* @__PURE__ */ new Map();
|
|
307
307
|
const sections = raw.split(/(?=^=====> )/m).filter((s) => s.trim());
|
|
308
|
+
const nsPattern = (headerNamespace ?? namespace).replace(/-/g, "[\\s-]");
|
|
309
|
+
const headerRe = new RegExp(`^=====> (.+?)\\s+${nsPattern}\\s+information`, "i");
|
|
308
310
|
for (const section of sections) {
|
|
309
311
|
const headerEnd = section.indexOf("\n");
|
|
310
312
|
if (headerEnd === -1) continue;
|
|
311
313
|
const header = section.slice(0, headerEnd);
|
|
312
|
-
const match = header.match(
|
|
314
|
+
const match = header.match(headerRe);
|
|
313
315
|
if (!match) continue;
|
|
314
316
|
const app = match[1];
|
|
315
317
|
result.set(app, parseReport(section, namespace));
|
|
@@ -606,17 +608,47 @@ var Builder = {
|
|
|
606
608
|
};
|
|
607
609
|
|
|
608
610
|
// src/resources/docker-options.ts
|
|
611
|
+
var PHASES = ["build", "deploy", "run"];
|
|
612
|
+
function filterManagedOpts(opts) {
|
|
613
|
+
return opts.filter((o) => !o.startsWith("--link ") && !o.startsWith("--build-arg "));
|
|
614
|
+
}
|
|
615
|
+
function parsePhaseOpts(raw) {
|
|
616
|
+
if (!raw) return [];
|
|
617
|
+
const opts = raw.match(/--\S+(?:\s+(?!--)\S+)*/g) ?? [];
|
|
618
|
+
return filterManagedOpts(opts);
|
|
619
|
+
}
|
|
620
|
+
function dockerOptsFromReport(report) {
|
|
621
|
+
const result = {};
|
|
622
|
+
for (const phase of PHASES) {
|
|
623
|
+
const opts = parsePhaseOpts(report[phase] ?? "");
|
|
624
|
+
if (opts.length > 0) result[phase] = opts;
|
|
625
|
+
}
|
|
626
|
+
return result;
|
|
627
|
+
}
|
|
609
628
|
var DockerOptions = {
|
|
610
629
|
key: "docker_options",
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
630
|
+
async read(ctx, target) {
|
|
631
|
+
const raw = await ctx.query("docker-options:report", target);
|
|
632
|
+
return dockerOptsFromReport(parseReport(raw, "docker-options"));
|
|
633
|
+
},
|
|
634
|
+
async readAll(ctx) {
|
|
635
|
+
const raw = await ctx.query("docker-options:report");
|
|
636
|
+
const bulk = parseBulkReport(raw, "docker-options");
|
|
637
|
+
const result = /* @__PURE__ */ new Map();
|
|
638
|
+
for (const [app, report] of bulk) {
|
|
639
|
+
result.set(app, dockerOptsFromReport(report));
|
|
640
|
+
}
|
|
641
|
+
return result;
|
|
642
|
+
},
|
|
643
|
+
async onChange(ctx, target, { before, after }) {
|
|
644
|
+
for (const phase of PHASES) {
|
|
645
|
+
const prev = new Set(before[phase] ?? []);
|
|
646
|
+
const desired = new Set(after[phase] ?? []);
|
|
647
|
+
for (const opt of desired) {
|
|
648
|
+
if (!prev.has(opt)) await ctx.run("docker-options:add", target, phase, opt);
|
|
649
|
+
}
|
|
650
|
+
for (const opt of prev) {
|
|
651
|
+
if (!desired.has(opt)) await ctx.run("docker-options:remove", target, phase, opt);
|
|
620
652
|
}
|
|
621
653
|
}
|
|
622
654
|
}
|