disk 0.8.0 → 0.8.8
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/{LICENSE.md → LICENSE} +10 -9
- package/README.md +111 -78
- package/dist/cli.js +573 -0
- package/dist/index.cjs +421 -0
- package/dist/index.d.cts +1144 -0
- package/dist/index.d.ts +1144 -0
- package/dist/index.js +372 -0
- package/package.json +39 -32
- package/lib/disk.js +0 -381
- package/lib/partition.js +0 -117
package/{LICENSE.md → LICENSE}
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Archil, Inc.
|
|
3
4
|
|
|
4
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -11,10 +12,10 @@ furnished to do so, subject to the following conditions:
|
|
|
11
12
|
The above copyright notice and this permission notice shall be included in all
|
|
12
13
|
copies or substantial portions of the Software.
|
|
13
14
|
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,119 +1,152 @@
|
|
|
1
|
-
#
|
|
2
|
-
[](https://npmjs.com/package/disk)
|
|
3
|
-
[](https://npmjs.com/package/disk)
|
|
4
|
-
[](https://npmjs.com/package/disk)
|
|
5
|
-
[](https://travis-ci.org/jhermsmeier/node-disk)
|
|
6
|
-
[](https://nodejs.org/api/documentation.html#documentation_stability_index)
|
|
1
|
+
# disk
|
|
7
2
|
|
|
8
|
-
|
|
3
|
+
Node.js client and CLI for [Archil](https://archil.com) disks. Create disks, list and inspect them, manage who can mount them, and run commands against them — all from scripts, CI, or an interactive terminal.
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
$ npm install --save disk
|
|
12
|
-
```
|
|
5
|
+
`disk` talks to the Archil control plane over HTTPS and has no native dependencies. If you also want to mount a disk's data plane from Node (rare — most users want `disk exec` or the `archil` CLI), install [`@archildata/native`](https://www.npmjs.com/package/@archildata/native) alongside `disk`.
|
|
13
6
|
|
|
14
|
-
##
|
|
7
|
+
## Install
|
|
15
8
|
|
|
16
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npm install disk
|
|
11
|
+
```
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
- [GPT](https://github.com/jhermsmeier/node-gpt) – GUID Partition Table
|
|
20
|
-
- [CHS](https://github.com/jhermsmeier/node-chs) – Cylinder-Head-Sector Addressing
|
|
21
|
-
- [apple-partition-map](https://github.com/jhermsmeier/node-apple-partition-map) – Apple Partition Map
|
|
22
|
-
- [BlockDevice](https://github.com/jhermsmeier/node-blockdevice) – Block device handling
|
|
23
|
-
- [RamDisk](https://github.com/jhermsmeier/node-ramdisk) – In-memory block device
|
|
13
|
+
## CLI
|
|
24
14
|
|
|
25
|
-
|
|
15
|
+
```bash
|
|
16
|
+
# Authenticate
|
|
17
|
+
export ARCHIL_API_KEY=key-...
|
|
18
|
+
export ARCHIL_REGION=aws-us-east-1
|
|
26
19
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
- [UDF](https://github.com/jhermsmeier/node-udf) – OSTA Universal Disk Format
|
|
20
|
+
# Create a disk — the response includes a one-time disk token you'll need to mount it
|
|
21
|
+
npx disk create my-disk
|
|
30
22
|
|
|
31
|
-
|
|
23
|
+
# List and inspect
|
|
24
|
+
npx disk list
|
|
25
|
+
npx disk get dsk-abc123
|
|
32
26
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
- [NTFS](https://github.com/jhermsmeier/node-ntfs) – NTFS file system driver
|
|
27
|
+
# Run a command against the disk's contents — Archil spins up a container with the disk
|
|
28
|
+
# mounted, runs the command, and returns stdout/stderr/exit code.
|
|
29
|
+
npx disk dsk-abc123 exec "ls -la /mnt"
|
|
37
30
|
|
|
38
|
-
|
|
31
|
+
# Delete
|
|
32
|
+
npx disk delete dsk-abc123
|
|
39
33
|
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
# Manage account-level API keys
|
|
35
|
+
npx disk api-keys list
|
|
36
|
+
npx disk api-keys create ci-bot
|
|
37
|
+
npx disk api-keys delete key-abc123
|
|
42
38
|
```
|
|
43
39
|
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
`list` and `get` pretty-print tables by default; pass `-o json` to pipe into `jq`. Credentials come from `ARCHIL_API_KEY` / `ARCHIL_REGION`, or `--api-key` / `--region` / `--base-url` flags.
|
|
41
|
+
|
|
42
|
+
## Library
|
|
43
|
+
|
|
44
|
+
The recommended pattern is a module-namespace import:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import * as archil from "disk";
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
// Configure once per process — falls back to ARCHIL_API_KEY / ARCHIL_REGION env vars.
|
|
50
|
+
archil.configure({ apiKey: process.env.ARCHIL_API_KEY, region: "aws-us-east-1" });
|
|
51
|
+
|
|
52
|
+
// Create a disk. `token` here is the disk token — the one-time credential for mounting.
|
|
53
|
+
const { disk, token } = await archil.createDisk({ name: "my-disk" });
|
|
54
|
+
console.log(`Created ${disk.id}, disk token: ${token}`);
|
|
55
|
+
|
|
56
|
+
// List and look up disks
|
|
57
|
+
const all = await archil.listDisks();
|
|
58
|
+
const d = await archil.getDisk(disk.id);
|
|
51
59
|
```
|
|
52
60
|
|
|
53
|
-
|
|
61
|
+
Per-disk operations are methods on the `Disk` object itself, not top-level functions:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
const d = await archil.getDisk("dsk-abc123");
|
|
65
|
+
|
|
66
|
+
// Run a command in a container with the disk mounted
|
|
67
|
+
const { stdout, stderr, exitCode } = await d.exec("ls -la /mnt && cat /mnt/config.json");
|
|
68
|
+
|
|
69
|
+
// Manage who can mount the disk
|
|
70
|
+
const user = await d.addUser({ type: "token", nickname: "ci" });
|
|
71
|
+
await d.removeUser("token", user.identifier!);
|
|
54
72
|
|
|
55
|
-
|
|
56
|
-
|
|
73
|
+
// Delete
|
|
74
|
+
await d.delete();
|
|
57
75
|
```
|
|
58
76
|
|
|
59
|
-
|
|
77
|
+
API keys live at the account level, so those helpers are top-level:
|
|
60
78
|
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
79
|
+
```ts
|
|
80
|
+
await archil.listApiKeys();
|
|
81
|
+
await archil.createApiKey({ name: "ci-bot", description: "GitHub Actions" });
|
|
82
|
+
await archil.deleteApiKey("key-abc123");
|
|
65
83
|
```
|
|
66
84
|
|
|
67
|
-
|
|
85
|
+
### Named imports
|
|
68
86
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
87
|
+
If you prefer named imports over the namespace style, they work the same way:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { createDisk, getDisk, listDisks, configure } from "disk";
|
|
72
91
|
```
|
|
73
92
|
|
|
74
|
-
|
|
93
|
+
### Multiple accounts or regions
|
|
94
|
+
|
|
95
|
+
For multi-tenant scripts, instantiate `Archil` directly instead of using the module-level `configure`:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
import { Archil } from "disk";
|
|
75
99
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
100
|
+
const prod = new Archil({ apiKey: prodKey, region: "aws-us-east-1" });
|
|
101
|
+
const staging = new Archil({ apiKey: stagingKey, region: "aws-us-east-1" });
|
|
102
|
+
|
|
103
|
+
const prodDisks = await prod.disks.list();
|
|
104
|
+
const stagingDisks = await staging.disks.list();
|
|
79
105
|
```
|
|
80
106
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
107
|
+
## Connecting to a disk's data plane
|
|
108
|
+
|
|
109
|
+
To run a command against a disk, use `Disk.exec()` — it returns stdout, stderr, and an exit code from an Archil-managed container with the disk pre-mounted. No local filesystem involved.
|
|
84
110
|
|
|
85
|
-
|
|
86
|
-
|
|
111
|
+
To mount a disk as a real filesystem on your machine, use the [`archil`](https://archil.com) CLI — it mounts through the OS kernel via FUSE, so any program can read and write files with standard APIs.
|
|
112
|
+
|
|
113
|
+
For the rare case where you need raw Archil protocol access from Node.js (inodes, delegations, byte-level reads), install [`@archildata/native`](https://www.npmjs.com/package/@archildata/native) alongside `disk`:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npm install disk @archildata/native
|
|
87
117
|
```
|
|
88
118
|
|
|
89
|
-
|
|
119
|
+
Then `Disk.mount()` lazy-loads the native client:
|
|
90
120
|
|
|
91
|
-
```
|
|
92
|
-
|
|
121
|
+
```ts
|
|
122
|
+
import { getDisk } from "disk";
|
|
123
|
+
|
|
124
|
+
const d = await getDisk("dsk-abc123");
|
|
125
|
+
const client = await d.mount({ authToken: "<disk-token>" });
|
|
126
|
+
// `client` is an ArchilClient from @archildata/native — see that package's README.
|
|
127
|
+
await client.close();
|
|
93
128
|
```
|
|
94
129
|
|
|
95
|
-
|
|
130
|
+
`@archildata/native` supports Linux (x64 / arm64, glibc) and macOS (arm64). On other platforms, `mount()` throws; the rest of `disk` still works.
|
|
131
|
+
|
|
132
|
+
## Supported regions
|
|
96
133
|
|
|
97
|
-
|
|
134
|
+
| Region | Provider |
|
|
135
|
+
| ----------------- | -------- |
|
|
136
|
+
| `aws-us-east-1` | AWS |
|
|
137
|
+
| `aws-us-west-2` | AWS |
|
|
138
|
+
| `aws-eu-west-1` | AWS |
|
|
139
|
+
| `gcp-us-central1` | GCP |
|
|
98
140
|
|
|
99
|
-
|
|
100
|
-
- Disk.GPT: See [gpt](https://github.com/jhermsmeier/node-gpt)
|
|
141
|
+
## FAQ
|
|
101
142
|
|
|
102
|
-
|
|
143
|
+
### What's the difference between an API key and a disk token?
|
|
103
144
|
|
|
104
|
-
|
|
145
|
+
Archil has two credential types, and the examples above use both:
|
|
105
146
|
|
|
106
|
-
- **
|
|
107
|
-
- **
|
|
108
|
-
- **gpt**
|
|
147
|
+
- **API key** — account-level credential for the control plane. You use one whenever you call `disk` (CLI or library). Create and manage them at [console.archil.com](https://console.archil.com) or with `disk api-keys create`. Goes in the `ARCHIL_API_KEY` env var or the `--api-key` flag.
|
|
148
|
+
- **Disk token** — per-disk credential that lets a client mount a specific disk. Created automatically when you `disk create <name>` (the value is shown once; save it). You don't need one to run `disk` itself — only when something is actually mounting a disk.
|
|
109
149
|
|
|
110
|
-
|
|
150
|
+
## Support
|
|
111
151
|
|
|
112
|
-
|
|
113
|
-
- **close( callback )**
|
|
114
|
-
- **getEFIPart()**
|
|
115
|
-
- **readMBR( callback )**
|
|
116
|
-
- **writeMBR( callback )**
|
|
117
|
-
- **readGPT( callback )**
|
|
118
|
-
- **writeGPT( callback )**
|
|
119
|
-
- **writeGPT( callback )**: Not implemented
|
|
152
|
+
Questions, feature requests, or issues? Reach us at **support@archil.com**.
|