@treeseed/sdk 0.10.25 → 0.10.27
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.
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
const EXPECTED_PORTS = ["1025->1025/tcp", "8025->8025/tcp"];
|
|
3
2
|
const KNOWN_MAILPIT_NAMES = ["treeseed_mailpit", "docs_mailpit"];
|
|
4
3
|
function runDocker(args, options = {}) {
|
|
5
4
|
return spawnSync("docker", args, {
|
|
@@ -14,9 +13,13 @@ function parseDockerPsOutput(stdout) {
|
|
|
14
13
|
});
|
|
15
14
|
}
|
|
16
15
|
function isCompatibleMailpitContainer(container) {
|
|
17
|
-
const
|
|
16
|
+
const expectedName = process.env.TREESEED_MAILPIT_CONTAINER_NAME?.trim();
|
|
17
|
+
const smtpPort = process.env.TREESEED_MAILPIT_SMTP_PORT?.trim() || "1025";
|
|
18
|
+
const uiPort = process.env.TREESEED_MAILPIT_UI_PORT?.trim() || "8025";
|
|
19
|
+
const expectedPorts = [`${smtpPort}->1025/tcp`, `${uiPort}->8025/tcp`];
|
|
20
|
+
const nameMatch = expectedName ? container.name === expectedName : KNOWN_MAILPIT_NAMES.includes(container.name);
|
|
18
21
|
const imageMatch = container.image.includes("mailpit");
|
|
19
|
-
const portsMatch =
|
|
22
|
+
const portsMatch = expectedPorts.every((port) => container.ports.includes(port));
|
|
20
23
|
return (nameMatch || imageMatch) && portsMatch;
|
|
21
24
|
}
|
|
22
25
|
function dockerIsAvailable() {
|
|
@@ -50,7 +53,7 @@ function stopKnownMailpitContainers(options = {}) {
|
|
|
50
53
|
function streamKnownMailpitLogs() {
|
|
51
54
|
const container = findRunningMailpitContainer();
|
|
52
55
|
if (!container) {
|
|
53
|
-
console.error("No running Mailpit container was found
|
|
56
|
+
console.error("No running Mailpit container was found for the configured local ports.");
|
|
54
57
|
process.exit(1);
|
|
55
58
|
}
|
|
56
59
|
const result = runDocker(["logs", "-f", container.name], { stdio: "inherit" });
|
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
2
|
import { dockerIsAvailable, findRunningMailpitContainer } from '../operations/services/mailpit-runtime.js';
|
|
3
|
-
import {
|
|
3
|
+
import { packageRoot } from '../operations/services/runtime-paths.js';
|
|
4
|
+
function mailpitConfig() {
|
|
5
|
+
return {
|
|
6
|
+
containerName: process.env.TREESEED_MAILPIT_CONTAINER_NAME?.trim() || 'treeseed_mailpit',
|
|
7
|
+
smtpPort: process.env.TREESEED_MAILPIT_SMTP_PORT?.trim() || '1025',
|
|
8
|
+
uiPort: process.env.TREESEED_MAILPIT_UI_PORT?.trim() || '8025',
|
|
9
|
+
};
|
|
10
|
+
}
|
|
4
11
|
if (!dockerIsAvailable()) {
|
|
5
12
|
console.error('Docker is required for Treeseed form email testing. Start Docker and rerun the Mailpit command.');
|
|
6
13
|
process.exit(1);
|
|
7
14
|
}
|
|
8
15
|
const existingMailpit = findRunningMailpitContainer();
|
|
16
|
+
const config = mailpitConfig();
|
|
9
17
|
if (existingMailpit) {
|
|
10
|
-
console.log(`Reusing existing Mailpit container "${existingMailpit.name}" on ports
|
|
18
|
+
console.log(`Reusing existing Mailpit container "${existingMailpit.name}" on ports ${config.smtpPort} and ${config.uiPort}.`);
|
|
11
19
|
process.exit(0);
|
|
12
20
|
}
|
|
13
|
-
|
|
21
|
+
spawnSync('docker', ['rm', '-f', config.containerName], { encoding: 'utf8', cwd: packageRoot, env: { ...process.env } });
|
|
22
|
+
const result = spawnSync('docker', [
|
|
23
|
+
'run',
|
|
24
|
+
'-d',
|
|
25
|
+
'--name',
|
|
26
|
+
config.containerName,
|
|
27
|
+
'-p',
|
|
28
|
+
`127.0.0.1:${config.smtpPort}:1025`,
|
|
29
|
+
'-p',
|
|
30
|
+
`127.0.0.1:${config.uiPort}:8025`,
|
|
31
|
+
'axllent/mailpit:latest',
|
|
32
|
+
], {
|
|
14
33
|
encoding: 'utf8',
|
|
15
34
|
cwd: packageRoot,
|
|
16
35
|
env: { ...process.env },
|
|
@@ -18,7 +37,7 @@ const result = spawnSync('docker', ['compose', '-f', mailpitComposeFile, 'up', '
|
|
|
18
37
|
if (result.status !== 0) {
|
|
19
38
|
const reusedMailpit = findRunningMailpitContainer();
|
|
20
39
|
if (reusedMailpit) {
|
|
21
|
-
console.log(`Reusing existing Mailpit container "${reusedMailpit.name}" on ports
|
|
40
|
+
console.log(`Reusing existing Mailpit container "${reusedMailpit.name}" on ports ${config.smtpPort} and ${config.uiPort}.`);
|
|
22
41
|
process.exit(0);
|
|
23
42
|
}
|
|
24
43
|
if (result.stdout)
|