loaner-sdk 0.4.0 → 0.5.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/README.md +32 -0
- package/dist/cli/bin.js +17 -0
- package/dist/cli/commands.json +2746 -0
- package/dist/cli/engine/args.js +175 -0
- package/dist/cli/engine/auth.js +243 -0
- package/dist/cli/engine/commands.js +266 -0
- package/dist/cli/engine/help.js +155 -0
- package/dist/cli/engine/index.js +879 -0
- package/dist/cli/engine/job.js +20 -0
- package/dist/cli/engine/mcp.js +125 -0
- package/dist/cli/jobs/deploy.js +97 -0
- package/dist/cli/jobs/index.js +4 -0
- package/dist/cli/jobs/logs.js +66 -0
- package/dist/cli/jobs/open.js +23 -0
- package/dist/http.d.ts +6 -2
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +16 -8
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +101 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +111 -44
- package/dist/index.js.map +1 -1
- package/dist/pack.d.ts +7 -0
- package/dist/pack.d.ts.map +1 -0
- package/dist/pack.js +124 -0
- package/dist/pack.js.map +1 -0
- package/dist/src/pack.js +123 -0
- package/package.json +15 -5
package/README.md
CHANGED
|
@@ -25,6 +25,38 @@ const copies = await machine.fork({ commands: ['pytest -k fix_a', 'pytest -k fix
|
|
|
25
25
|
await machine.delete()
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
## Deploy an app
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
const { url } = await machines.deployments.deploy('./site', { name: 'docs-site', env: { API_URL: 'https://…' } })
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`deploy` packs the folder (inside a git repository what git keeps; never `node_modules`, `.git` or `.env` files),
|
|
35
|
+
uploads it, and waits until it is served at `url`, a URL of its name that stays the same when you deploy again. A
|
|
36
|
+
failed build throws `DeploymentFailed`, whose `card` has the `step` and the `error`. Next.js, Astro, Vite and any app
|
|
37
|
+
with a `start` script need nothing else. `deployments.logs(name, { of: 'app' })` reads what the running app prints;
|
|
38
|
+
`kind: 'app'` keeps it running until `deployments.delete(name)`. `deployments.create` deploys a git repository or a
|
|
39
|
+
folder on a machine instead.
|
|
40
|
+
|
|
41
|
+
## The `loaner` command
|
|
42
|
+
|
|
43
|
+
The package's bin: every MCP tool as `loaner <noun> <verb>`, and three jobs for what tools can't carry.
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
npx loaner-sdk auth login https://loaner.example.com # in your browser; --device: a code to approve anywhere
|
|
47
|
+
npx loaner-sdk deploy ./site --env-file .env.production # packs, uploads, builds; prints its URL
|
|
48
|
+
npx loaner-sdk logs site --of build # why a build failed; --follow watches the app
|
|
49
|
+
npx loaner-sdk open site # its URL, in your browser
|
|
50
|
+
npx loaner-sdk machine create --template node # any tool: `loaner` alone lists them
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`deploy` keeps the app running until `loaner deployment delete`; `--preview` stops it after 2 idle hours. Its name
|
|
54
|
+
comes from package.json (or `--name`) and is in its URL, which stays the same when you deploy again. In CI,
|
|
55
|
+
`LOANER_URL` and `LOANER_API_KEY` sign in without a browser. `--json` answers JSON, and exit codes are stable:
|
|
56
|
+
`loaner help agents` lists them. It needs Node 20.10 or later.
|
|
57
|
+
|
|
58
|
+
## Notes
|
|
59
|
+
|
|
28
60
|
- `run` follows a command however long it takes (the API's 202s and waits are handled), and returns every byte it
|
|
29
61
|
printed with its `exitCode`. `start` answers at once for servers and watchers (`wait`, `kill`, `send`).
|
|
30
62
|
- A refused call throws `LoanerError` with the API's `status`, `code` and `detail` (which says what to change).
|
package/dist/cli/bin.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* The `loaner` command: every MCP tool of Loaner as `loaner <noun> <verb>`, plus the jobs in `jobs/`. The engine
|
|
4
|
+
* in `engine/` is the kit's; this file, `jobs/` and `commands.json` (written by `pnpm sdk:types`) are the app's.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* npx loaner-sdk auth login https://api.example.com
|
|
8
|
+
* npx loaner-sdk help
|
|
9
|
+
*/
|
|
10
|
+
import { readFileSync } from 'node:fs';
|
|
11
|
+
import snapshot from './commands.json' with { type: 'json' };
|
|
12
|
+
import { createCli } from './engine/index.js';
|
|
13
|
+
import { jobs } from './jobs/index.js';
|
|
14
|
+
// The package's own version, read where it is installed (dist/cli/bin.js → package.json)
|
|
15
|
+
const { version } = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
|
|
16
|
+
const cli = createCli({ name: 'loaner', envPrefix: 'LOANER', version, snapshot, jobs });
|
|
17
|
+
process.exitCode = await cli.run(process.argv.slice(2));
|