@cdwr/fly-node 0.3.0 โ†’ 0.3.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,64 @@
1
+ ## 0.3.2 (2026-10-10)
2
+
3
+ ### โœจ Features
4
+
5
+ - **fly-node:** manage an app's public ip addresses ([21d1813e](https://github.com/codeware-sthlm/cdwr/commit/21d1813e))
6
+
7
+ ### ๐Ÿž Bug Fixes
8
+
9
+ - **fly-node:** machines.restart waits on the machine's state ([07297c53](https://github.com/codeware-sthlm/cdwr/commit/07297c53))
10
+ - **repo:** ship the licence in published tarballs ([aea1f581](https://github.com/codeware-sthlm/cdwr/commit/aea1f581))
11
+ - **fly-node:** stage every secret a deploy is given ([524abc74](https://github.com/codeware-sthlm/cdwr/commit/524abc74))
12
+ - **fly-node:** drop the unsupported confirm flag from ipv6 allocation ([778b3444](https://github.com/codeware-sthlm/cdwr/commit/778b3444))
13
+
14
+ ### โš™๏ธ Miscellaneous Chores
15
+
16
+ - **repo:** platform under FSL-1.1-MIT, npm packages stay MIT ([ce949b26](https://github.com/codeware-sthlm/cdwr/commit/ce949b26))
17
+
18
+ ## 0.3.1 (2026-08-25)
19
+
20
+ ### โœจ Features
21
+
22
+ - **app-cms:** show the certificates Fly issued for a domain ([c7983c5d](https://github.com/codeware-sthlm/cdwr/commit/c7983c5d))
23
+ - **fly-node:** restart app machines over the rest api ([3367b887](https://github.com/codeware-sthlm/cdwr/commit/3367b887))
24
+ - **fly-node:** expose the graphql client as its own entry point ([52db8c26](https://github.com/codeware-sthlm/cdwr/commit/52db8c26))
25
+ - **fly-node:** manage certificates over the graphql api ([15c0b89c](https://github.com/codeware-sthlm/cdwr/commit/15c0b89c))
26
+ - **fly-node:** add ssh exec to run commands in a machine ([ba3ee3c6](https://github.com/codeware-sthlm/cdwr/commit/ba3ee3c6))
27
+ - **fly-node:** add build response schema and export missing types ([73ce64e8](https://github.com/codeware-sthlm/cdwr/commit/73ce64e8))
28
+ - **fly-node:** add machine management methods ([dbdf0f54](https://github.com/codeware-sthlm/cdwr/commit/dbdf0f54))
29
+ - **repo:** shared preview database ([f48d959e](https://github.com/codeware-sthlm/cdwr/commit/f48d959e))
30
+ - **fly-node:** add option to stream to console ([1bb02e33](https://github.com/codeware-sthlm/cdwr/commit/1bb02e33))
31
+ - **fly-node:** support build arguments in deploy command ([dfa1736a](https://github.com/codeware-sthlm/cdwr/commit/dfa1736a))
32
+
33
+ ### ๐Ÿž Bug Fixes
34
+
35
+ - **app-cms:** show fly's own prose for a failed certificate check ([3c047d0c](https://github.com/codeware-sthlm/cdwr/commit/3c047d0c))
36
+ - **fly-node:** match config save to fly's real api ([6af2597c](https://github.com/codeware-sthlm/cdwr/commit/6af2597c))
37
+ - **fly-node:** pin flyctl to one file ci and local both read ([c18203bf](https://github.com/codeware-sthlm/cdwr/commit/c18203bf))
38
+ - **fly-node:** match certificate check and add to fly's real api ([020b06a8](https://github.com/codeware-sthlm/cdwr/commit/020b06a8))
39
+ - **fly-node:** treat a missing certificate as an answer, not a fault ([75714e87](https://github.com/codeware-sthlm/cdwr/commit/75714e87))
40
+ - **repo:** import defineConfig from vitest/config in test configs ([69a6d471](https://github.com/codeware-sthlm/cdwr/commit/69a6d471))
41
+ - **core:** split vitest-only exports into separate entry point ([489f297a](https://github.com/codeware-sthlm/cdwr/commit/489f297a))
42
+ - **fly-node:** add machines.update for per-machine config updates ([a5498c8e](https://github.com/codeware-sthlm/cdwr/commit/a5498c8e))
43
+
44
+ ### ๐Ÿงน Code Refactoring
45
+
46
+ - **repo:** split @cdwr/core into shared util libs ([797f20d0](https://github.com/codeware-sthlm/cdwr/commit/797f20d0))
47
+
48
+ ### ๐Ÿ“„ Documentation
49
+
50
+ - **fly-node:** document machine restarts in the FlyApi readme ([7030a6ac](https://github.com/codeware-sthlm/cdwr/commit/7030a6ac))
51
+ - **fly-node:** update README with machine methods ([57cfce9c](https://github.com/codeware-sthlm/cdwr/commit/57cfce9c))
52
+
53
+ ### โš™๏ธ Miscellaneous Chores
54
+
55
+ - repoint repo urls to codeware-sthlm/cdwr ([969d3614](https://github.com/codeware-sthlm/cdwr/commit/969d3614))
56
+ - migrate to nx 23.1.0 ([1fd45d5b](https://github.com/codeware-sthlm/cdwr/commit/1fd45d5b))
57
+
58
+ ### โœ… Tests
59
+
60
+ - **fly-node:** cover the graphql client with fixtures and a drift check ([eef458aa](https://github.com/codeware-sthlm/cdwr/commit/eef458aa))
61
+
1
62
  ## 0.3.0 (2026-01-02)
2
63
 
3
64
  ### โœจ Features
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Codeware Sthlm AB
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
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
13
+ copies or substantial portions of the Software.
14
+
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
@@ -44,6 +44,7 @@ It's built with a configuration-first approach, meaning that you provide a `fly.
44
44
  - [Deploy an application](#deploy-an-application)
45
45
  - [Application status](#application-status)
46
46
  - [List applications](#list-applications)
47
+ - [Manage machines](#manage-machines)
47
48
  - [Configuration \& scaling](#configuration--scaling)
48
49
  - [Add a custom domain](#add-a-custom-domain)
49
50
  - [Remove a custom domain](#remove-a-custom-domain)
@@ -53,6 +54,9 @@ It's built with a configuration-first approach, meaning that you provide a `fly.
53
54
  - [Add application secrets](#add-application-secrets)
54
55
  - [Remove application secrets](#remove-application-secrets)
55
56
  - [List secrets](#list-secrets)
57
+ - [Without the CLI: `FlyApi`](#without-the-cli-flyapi)
58
+ - [Manage certificates](#manage-certificates)
59
+ - [Restart machines](#restart-machines)
56
60
 
57
61
  ## Installation
58
62
 
@@ -65,7 +69,7 @@ npm install @cdwr/fly-node
65
69
  > [!IMPORTANT]
66
70
  > This library requires the Fly CLI (`flyctl`) to be installed and accessible in your PATH.
67
71
 
68
- **Version used in test**: v0.4.0
72
+ **Version used in test**: see [`verified-version.json`](./verified-version.json) โ€” the same file CI installs from, so the two cannot drift apart.
69
73
 
70
74
  **Installation Instructions**:
71
75
 
@@ -258,6 +262,19 @@ const response = await fly.deploy({
258
262
  // For existing apps: saves remote config to fly.{appName}.toml and uses it
259
263
  // For new apps: uses the local config file
260
264
 
265
+ // Deploy with existing image (skips build, useful for config-only updates)
266
+ const response = await fly.deploy({
267
+ app: 'foo-app',
268
+ config: 'apps/foo-app/fly.toml',
269
+ image: 'registry.fly.io/foo-app:deployment-01234567'
270
+ });
271
+ // Or use just the tag (will be expanded to full registry path)
272
+ const response = await fly.deploy({
273
+ app: 'foo-app',
274
+ config: 'apps/foo-app/fly.toml',
275
+ image: 'deployment-01234567'
276
+ });
277
+
261
278
  // With options that could be a pull request preview deployment
262
279
  const response = await fly.deploy({
263
280
  app: 'pr-19-foo-app',
@@ -266,6 +283,9 @@ const response = await fly.deploy({
266
283
  org: 'baz',
267
284
  postgres: 'db-preview',
268
285
  region: 'arn',
286
+ buildArgs: {
287
+ NEXT_PUBLIC_DEPLOY_ENV: 'preview'
288
+ },
269
289
  env: {
270
290
  DEPLOY_ID: 'qwerty'
271
291
  },
@@ -333,6 +353,23 @@ const status = await fly.statusExtended();
333
353
  const apps = await fly.apps.list();
334
354
  ```
335
355
 
356
+ #### Manage machines
357
+
358
+ Control individual machines within your applications.
359
+
360
+ ```ts
361
+ // Start a machine
362
+ await fly.machines.start('foo-app', 'machine-id-123');
363
+
364
+ // Stop a machine
365
+ await fly.machines.stop('foo-app', 'machine-id-123');
366
+
367
+ // Restart a machine (stop, wait until stopped, start, wait until started)
368
+ await fly.machines.restart('foo-app', 'machine-id-123');
369
+ ```
370
+
371
+ `restart` handles one machine: it waits until Fly reports it stopped (or suspended) before starting it, then until it is `started`. If the start fails after the stop, the error says the machine was left stopped.
372
+
336
373
  ### Configuration & scaling
337
374
 
338
375
  #### Add a custom domain
@@ -477,3 +514,94 @@ const secrets = await fly.secrets.list();
477
514
  const secrets = await fly.secrets.list({ app: 'foo-app' });
478
515
  const secrets = await fly.secrets.list({ config: 'apps/foo-app/fly.toml' });
479
516
  ```
517
+
518
+ ## Without the CLI: `FlyApi`
519
+
520
+ `Fly` drives the `flyctl` binary. That is the right tool in CI โ€” it builds and
521
+ deploys, and a runner has the binary installed โ€” but it cannot run inside an
522
+ application server: there is no binary in the image, and the interactive paths
523
+ need a pty.
524
+
525
+ `FlyApi` talks to Fly over its HTTP APIs instead. No binary, no subprocess,
526
+ usable from a running app. It is deliberately a small subset rather than a
527
+ second implementation of the CLI โ€” certificates, because a custom domain has
528
+ to be requested, checked and shown to a customer while they wait, and machine
529
+ restarts, because a setting read at boot needs a boot to take effect.
530
+
531
+ It has its own entry point, `@cdwr/fly-node/api`. Import from there rather than
532
+ the root barrel when the CLI half cannot come along: the root barrel reaches a
533
+ native pty module, which a slim application image does not have.
534
+
535
+ Fly splits the two operations across two APIs and so does `FlyApi` โ€”
536
+ certificates over GraphQL, machines over the REST Machines API. One token
537
+ authenticates both.
538
+
539
+ ### Manage certificates
540
+
541
+ ```ts
542
+ import { FlyApi } from '@cdwr/fly-node/api';
543
+
544
+ const fly = new FlyApi({ token: process.env.FLY_API_TOKEN });
545
+
546
+ // Request a certificate. Safe to call again โ€” Fly returns the existing one.
547
+ const { certificate, check } = await fly.certs.add('my-app', 'tours.example.com');
548
+
549
+ if (!certificate.isConfigured) {
550
+ // What the customer has to create, and what Fly resolves right now
551
+ console.log(FlyApi.dnsInstructions(certificate));
552
+ console.log(check?.dnsConfigured, check?.cnameRecords);
553
+ }
554
+
555
+ // Re-read issuance state โ€” the call behind a "check" button
556
+ await fly.certs.get('my-app', 'tours.example.com');
557
+
558
+ await fly.certs.list('my-app');
559
+ await fly.certs.remove('my-app', 'tours.example.com');
560
+ ```
561
+
562
+ Notes worth knowing:
563
+
564
+ - **Field names are Fly's own** (`isConfigured`, not `configured`), so results
565
+ can be read against Fly's schema without translating. Where the CLI covers
566
+ the same ground the shared fields agree.
567
+ - **Requesting before DNS exists is normal.** The certificate stays pending
568
+ until the records resolve; the validation fields are what you show meanwhile.
569
+ - **`rateLimitedUntil`** is set when Let's Encrypt has throttled further
570
+ attempts. It is the one failure correcting DNS will not fix, and retrying
571
+ makes it worse.
572
+ - **`list` does not resolve DNS.** `check` is only returned by `add`, because
573
+ resolving across every certificate on an app would turn one query into a
574
+ lookup per domain.
575
+ - **A hostname with no certificate is not an error.** Fly reports it as a
576
+ `NOT_FOUND` GraphQL error; `certs.get` translates that to `null`. Anything else
577
+ rejects with a `FlyApiError` carrying the codes Fly sent.
578
+
579
+ ### Restart machines
580
+
581
+ ```ts
582
+ import { FlyApi } from '@cdwr/fly-node/api';
583
+
584
+ const fly = new FlyApi({ token: process.env.FLY_API_TOKEN });
585
+
586
+ await fly.machines.list('my-app');
587
+
588
+ // Restart every machine on the app, one at a time
589
+ await fly.machines.restart('my-app');
590
+
591
+ // Or just one
592
+ await fly.machines.restart('my-app', 'e286000a123456');
593
+ ```
594
+
595
+ Notes worth knowing:
596
+
597
+ - **Restarts are sequential, not parallel.** A setting that only takes effect
598
+ at boot should not cost the app its availability to apply โ€” restarting
599
+ together would drop every machine at once. The trade is that a large app
600
+ takes longer.
601
+ - **A failed restart stops the run.** It does not skip ahead to the next
602
+ machine: a half-restarted app is running two configurations at once, and
603
+ silently returning "some of them" invites calling that done.
604
+ - **This is the REST Machines API, not GraphQL.** Fly's GraphQL machine
605
+ mutations are Nomad-era and no longer apply, so this half of `FlyApi` has its
606
+ own request helper with its own failure shape โ€” a non-2xx status and an
607
+ `error` field in the body, rather than GraphQL's 200-with-an-`errors`-array.