dokku-compose 0.6.12 → 0.7.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/dist/index.js +37 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -129,10 +129,13 @@ function createRunner(opts = {}) {
|
|
|
129
129
|
const log = [];
|
|
130
130
|
const controlPath = opts.host ? path.join(os.tmpdir(), `dc-${createHash("sha1").update(opts.host).digest("hex").slice(0, 16)}.sock`) : null;
|
|
131
131
|
const sshControlFlags = controlPath ? ["-o", "ControlMaster=auto", "-o", `ControlPath=${controlPath}`, "-o", "ControlPersist=60"] : [];
|
|
132
|
+
function shellQuote(arg) {
|
|
133
|
+
return `'${arg.replace(/'/g, "'\\''")}'`;
|
|
134
|
+
}
|
|
132
135
|
async function execDokku(args) {
|
|
133
136
|
if (opts.host) {
|
|
134
137
|
try {
|
|
135
|
-
const result = await execa("ssh", [...sshControlFlags, `dokku@${opts.host}`, ...args]);
|
|
138
|
+
const result = await execa("ssh", [...sshControlFlags, `dokku@${opts.host}`, "--", ...args.map(shellQuote)]);
|
|
136
139
|
return { stdout: result.stdout, ok: true };
|
|
137
140
|
} catch (e) {
|
|
138
141
|
return { stdout: e.stdout ?? "", ok: false };
|
|
@@ -150,7 +153,7 @@ function createRunner(opts = {}) {
|
|
|
150
153
|
dryRunLog: log,
|
|
151
154
|
async run(...args) {
|
|
152
155
|
if (opts.dryRun) {
|
|
153
|
-
log.push(args.join(" "));
|
|
156
|
+
log.push(args.map((a) => a.includes(" ") ? shellQuote(a) : a).join(" "));
|
|
154
157
|
return;
|
|
155
158
|
}
|
|
156
159
|
await execDokku(args);
|
|
@@ -890,8 +893,38 @@ async function destroyServices(ctx, services) {
|
|
|
890
893
|
logDone();
|
|
891
894
|
}
|
|
892
895
|
}
|
|
893
|
-
|
|
894
|
-
|
|
896
|
+
var SERVICE_PLUGINS = ["postgres", "redis"];
|
|
897
|
+
async function exportServices(ctx) {
|
|
898
|
+
const services = {};
|
|
899
|
+
const pluginOutput = await ctx.query("plugin:list");
|
|
900
|
+
const installedPlugins = new Set(
|
|
901
|
+
pluginOutput.split("\n").map((line) => line.trim().split(/\s+/)[0]).filter(Boolean)
|
|
902
|
+
);
|
|
903
|
+
for (const plugin of SERVICE_PLUGINS) {
|
|
904
|
+
if (!installedPlugins.has(plugin)) continue;
|
|
905
|
+
const listOutput = await ctx.query(`${plugin}:list`);
|
|
906
|
+
const lines = listOutput.split("\n").slice(1);
|
|
907
|
+
for (const line of lines) {
|
|
908
|
+
const name = line.trim().split(/\s+/)[0];
|
|
909
|
+
if (!name) continue;
|
|
910
|
+
const infoOutput = await ctx.query(`${plugin}:info`, name);
|
|
911
|
+
const versionMatch = infoOutput.match(/Version:\s+(\S+)/);
|
|
912
|
+
if (!versionMatch) continue;
|
|
913
|
+
const versionField = versionMatch[1];
|
|
914
|
+
const colonIdx = versionField.lastIndexOf(":");
|
|
915
|
+
const config = { plugin };
|
|
916
|
+
if (colonIdx > 0) {
|
|
917
|
+
const image = versionField.slice(0, colonIdx);
|
|
918
|
+
const version2 = versionField.slice(colonIdx + 1);
|
|
919
|
+
if (image !== plugin) config.image = image;
|
|
920
|
+
if (version2) config.version = version2;
|
|
921
|
+
} else {
|
|
922
|
+
config.version = versionField;
|
|
923
|
+
}
|
|
924
|
+
services[name] = config;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
return services;
|
|
895
928
|
}
|
|
896
929
|
async function exportAppLinks(ctx, app, services) {
|
|
897
930
|
const linked = [];
|