swytchcode-runtime 0.1.2 → 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 +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# swytchcode-runtime
|
|
2
2
|
|
|
3
3
|
Thin runtime wrapper around the Swytchcode CLI. Calls `swytchcode exec` for you so you can stay in TypeScript/JavaScript without shell boilerplate.
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ By default, the runtime runs Swytchcode in **JSON mode**: the CLI is invoked wit
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
npm install
|
|
12
|
+
npm install swytchcode-runtime
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Use
|
|
@@ -17,7 +17,7 @@ npm install @swytchcode/runtime
|
|
|
17
17
|
### JSON mode (default)
|
|
18
18
|
|
|
19
19
|
```ts
|
|
20
|
-
import { exec } from "
|
|
20
|
+
import { exec } from "swytchcode-runtime";
|
|
21
21
|
|
|
22
22
|
const result = await exec("api.account.create", {
|
|
23
23
|
body: { name: "my-cluster" },
|
|
@@ -50,7 +50,7 @@ await exec("api.cluster.get", {
|
|
|
50
50
|
Get stdout as a string instead of parsing JSON:
|
|
51
51
|
|
|
52
52
|
```ts
|
|
53
|
-
import { exec } from "
|
|
53
|
+
import { exec } from "swytchcode-runtime";
|
|
54
54
|
|
|
55
55
|
const output = await exec("api.report.export", { id: "123" }, { raw: true });
|
|
56
56
|
// output is the raw stdout string
|
|
@@ -83,7 +83,7 @@ Or in code: `exec("shell.integration.list", undefined, { debug: true })`.
|
|
|
83
83
|
Failures throw `SwytchcodeError` (spawn error, non-zero exit, signal, empty stdout in JSON mode, invalid JSON). Use the type guard when you need to narrow:
|
|
84
84
|
|
|
85
85
|
```ts
|
|
86
|
-
import { exec, isSwytchcodeError } from "
|
|
86
|
+
import { exec, isSwytchcodeError } from "swytchcode-runtime";
|
|
87
87
|
|
|
88
88
|
try {
|
|
89
89
|
await exec("api.account.create", { email: "test@example.com" });
|
|
@@ -121,7 +121,7 @@ Generate code that uses this runtime instead of subprocess boilerplate.
|
|
|
121
121
|
**Preferred:**
|
|
122
122
|
|
|
123
123
|
```ts
|
|
124
|
-
import { exec } from "
|
|
124
|
+
import { exec } from "swytchcode-runtime";
|
|
125
125
|
|
|
126
126
|
export async function createAccount(input: { email: string }) {
|
|
127
127
|
return exec("api.account.create", input);
|