shipmail-cli 0.1.0 → 0.1.3
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 +4 -4
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +9 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Shipmail CLI
|
|
2
2
|
|
|
3
|
-
Official command line interface for the
|
|
3
|
+
Official command line interface for the Shipmail API.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npx -y shipmail-cli --help
|
|
@@ -8,7 +8,7 @@ npx -y shipmail-cli --help
|
|
|
8
8
|
|
|
9
9
|
## Authentication
|
|
10
10
|
|
|
11
|
-
Most commands require an API key. Create one in the
|
|
11
|
+
Most commands require an API key. Create one in the Shipmail dashboard and export it:
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
export SHIPMAIL_API_KEY="sm_live_..."
|
|
@@ -49,7 +49,7 @@ shipmail webhooks deliveries whk_123 --status failed
|
|
|
49
49
|
|
|
50
50
|
## Generic API Command
|
|
51
51
|
|
|
52
|
-
The `api` command reaches every
|
|
52
|
+
The `api` command reaches every Shipmail REST endpoint, including endpoints that do not have a shorthand command yet.
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
55
|
shipmail api GET /domains
|
package/dist/cli.d.ts
CHANGED
|
@@ -10,5 +10,6 @@ type RunCliOptions = {
|
|
|
10
10
|
readonly fetch?: typeof fetch | undefined;
|
|
11
11
|
};
|
|
12
12
|
declare function runCli(argv: readonly string[], options?: RunCliOptions): Promise<number>;
|
|
13
|
+
declare function isMainModule(moduleUrl?: string, argvPath?: string | undefined): boolean;
|
|
13
14
|
|
|
14
|
-
export { runCli };
|
|
15
|
+
export { isMainModule, runCli };
|
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
+
import { realpathSync } from "fs";
|
|
4
5
|
import { readFile, writeFile } from "fs/promises";
|
|
5
6
|
import { env as processEnv, exit, stderr, stdout } from "process";
|
|
6
|
-
import {
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
7
8
|
import {
|
|
8
9
|
ShipMailClient,
|
|
9
10
|
ShipMailError,
|
|
@@ -11,7 +12,7 @@ import {
|
|
|
11
12
|
} from "shipmail";
|
|
12
13
|
|
|
13
14
|
// src/version.ts
|
|
14
|
-
var VERSION = "0.1.
|
|
15
|
+
var VERSION = "0.1.3";
|
|
15
16
|
|
|
16
17
|
// src/cli.ts
|
|
17
18
|
var DEFAULT_BASE_URL = "https://shipmail.to/api/v1";
|
|
@@ -643,9 +644,14 @@ async function main() {
|
|
|
643
644
|
const code = await runCli(process.argv.slice(2));
|
|
644
645
|
exit(code);
|
|
645
646
|
}
|
|
646
|
-
|
|
647
|
+
function isMainModule(moduleUrl = import.meta.url, argvPath = process.argv[1]) {
|
|
648
|
+
if (!argvPath) return false;
|
|
649
|
+
return realpathSync(fileURLToPath(moduleUrl)) === realpathSync(argvPath);
|
|
650
|
+
}
|
|
651
|
+
if (isMainModule()) {
|
|
647
652
|
void main();
|
|
648
653
|
}
|
|
649
654
|
export {
|
|
655
|
+
isMainModule,
|
|
650
656
|
runCli
|
|
651
657
|
};
|