sendmock 0.0.0-stage → 0.1.0-beta.4

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/README.md CHANGED
@@ -1,3 +1,21 @@
1
- # Temporary Holding Version
1
+ # sendmock
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [SendMock](https://shibbirweb.github.io/sendmock/) catches the email, SMS, payments and webhooks your app sends, on your machine, so nothing reaches real people.
4
+
5
+ This package runs the SendMock binary for your computer (macOS, Linux and Windows, x64 and arm64), which your package manager installs as one of the `@sendmock/*` packages.
6
+
7
+ 1. Install it in your project:
8
+
9
+ ```bash
10
+ npm install --save-dev sendmock
11
+ ```
12
+
13
+ 2. Start it:
14
+
15
+ ```bash
16
+ npx sendmock
17
+ ```
18
+
19
+ 3. Open http://127.0.0.1:8025 and point your app's SMTP settings at `127.0.0.1:1025`.
20
+
21
+ The beta is the `beta` tag: `npm install --save-dev sendmock@beta`. See the [install guide](https://shibbirweb.github.io/sendmock/docs/install/) for every other way to install it.
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawn } = require("node:child_process");
5
+
6
+ const { buildBinaryEnvironment, locateBinary } = require("../lib/launcher.js");
7
+
8
+ const located = locateBinary(process.platform, process.arch, require.resolve);
9
+ if (located.errorMessage) {
10
+ console.error(`sendmock: ${located.errorMessage}`);
11
+ process.exit(1);
12
+ }
13
+
14
+ const child = spawn(located.binaryPath, process.argv.slice(2), {
15
+ stdio: "inherit",
16
+ env: buildBinaryEnvironment(process.env),
17
+ });
18
+ // Ctrl+C and stop requests reach SendMock, which shuts down cleanly and exits on its own.
19
+ for (const signalName of ["SIGINT", "SIGTERM", "SIGHUP"]) {
20
+ process.on(signalName, () => {
21
+ child.kill(signalName);
22
+ });
23
+ }
24
+ child.on("error", (spawnError) => {
25
+ console.error(
26
+ `sendmock: could not start ${located.binaryPath}: ${spawnError.message}`,
27
+ );
28
+ process.exit(1);
29
+ });
30
+ child.on("exit", (exitCode, exitSignal) => {
31
+ if (exitSignal) {
32
+ process.kill(process.pid, exitSignal);
33
+ return;
34
+ }
35
+ process.exit(exitCode ?? 1);
36
+ });
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Finds the SendMock binary that the package manager installed for this computer. Each
5
+ * platform's binary is its own package listed in `optionalDependencies` with `os` and `cpu`
6
+ * set, so npm, pnpm, Yarn and Bun install only the one that fits and no install script runs.
7
+ */
8
+
9
+ const path = require("node:path");
10
+
11
+ /** `process.platform-process.arch` to the platform package and the binary inside it. */
12
+ const platformPackages = {
13
+ "darwin-arm64": "@sendmock/darwin-arm64",
14
+ "darwin-x64": "@sendmock/darwin-x64",
15
+ "linux-arm64": "@sendmock/linux-arm64",
16
+ "linux-x64": "@sendmock/linux-x64",
17
+ "win32-arm64": "@sendmock/win32-arm64",
18
+ "win32-x64": "@sendmock/win32-x64",
19
+ };
20
+
21
+ function findPlatformPackage(platform, cpu) {
22
+ return platformPackages[`${platform}-${cpu}`] ?? null;
23
+ }
24
+
25
+ function readBinaryName(platform) {
26
+ return platform === "win32" ? "sendmock.exe" : "sendmock";
27
+ }
28
+
29
+ /**
30
+ * The binary's path, or an error message saying what is missing. `resolvePackageJson` is
31
+ * `require.resolve`, passed in so tests can give their own.
32
+ */
33
+ function locateBinary(platform, cpu, resolvePackageJson) {
34
+ const platformPackage = findPlatformPackage(platform, cpu);
35
+ if (platformPackage === null) {
36
+ return {
37
+ errorMessage: `SendMock has no build for ${platform} on ${cpu}. Builds exist for ${Object.keys(platformPackages).join(", ")}.`,
38
+ };
39
+ }
40
+ try {
41
+ const packageJsonPath = resolvePackageJson(
42
+ `${platformPackage}/package.json`,
43
+ );
44
+ return {
45
+ binaryPath: path.join(
46
+ path.dirname(packageJsonPath),
47
+ readBinaryName(platform),
48
+ ),
49
+ };
50
+ } catch {
51
+ return {
52
+ errorMessage: `The ${platformPackage} package is missing. Install sendmock again without --no-optional (or --omit=optional), so the package manager adds the binary for this computer.`,
53
+ };
54
+ }
55
+ }
56
+
57
+ /**
58
+ * The binary's environment: this one, plus a mark that npm started it, so
59
+ * `npx sendmock ai install` writes agent configurations that also start SendMock through npx.
60
+ */
61
+ function buildBinaryEnvironment(parentEnvironment) {
62
+ return { ...parentEnvironment, SENDMOCK_LAUNCHER: "npm" };
63
+ }
64
+
65
+ module.exports = {
66
+ buildBinaryEnvironment,
67
+ findPlatformPackage,
68
+ locateBinary,
69
+ platformPackages,
70
+ };
package/package.json CHANGED
@@ -1,6 +1,31 @@
1
1
  {
2
2
  "name": "sendmock",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-beta.4",
4
+ "description": "Catch email, SMS, payments and webhooks from any app on your machine.",
5
+ "homepage": "https://shibbirweb.github.io/sendmock/",
6
+ "license": "MIT OR Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/shibbirweb/sendmock.git"
10
+ },
11
+ "bin": {
12
+ "sendmock": "bin/sendmock.js"
13
+ },
14
+ "files": [
15
+ "bin",
16
+ "lib",
17
+ "README.md"
18
+ ],
19
+ "engines": {
20
+ "node": ">=18"
21
+ },
22
+ "mcpName": "io.github.shibbirweb/sendmock",
23
+ "optionalDependencies": {
24
+ "@sendmock/darwin-arm64": "0.1.0-beta.4",
25
+ "@sendmock/darwin-x64": "0.1.0-beta.4",
26
+ "@sendmock/linux-arm64": "0.1.0-beta.4",
27
+ "@sendmock/linux-x64": "0.1.0-beta.4",
28
+ "@sendmock/win32-arm64": "0.1.0-beta.4",
29
+ "@sendmock/win32-x64": "0.1.0-beta.4"
30
+ }
31
+ }