pockethost 1.7.0 → 3.1.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +138 -86
  2. package/README.md +133 -0
  3. package/dist/cli.js +21932 -0
  4. package/package.json +59 -57
  5. package/changesetx.ts +0 -110
  6. package/common.ts +0 -1
  7. package/core.ts +0 -1
  8. package/readme.md +0 -129
  9. package/src/cli/commands/ConfigCommand/index.ts +0 -28
  10. package/src/cli/commands/PluginCommand/index.ts +0 -113
  11. package/src/cli/commands/PluginCommand/plugin-template/LICENSE.md +0 -16
  12. package/src/cli/commands/PluginCommand/plugin-template/package.json +0 -38
  13. package/src/cli/commands/PluginCommand/plugin-template/readme.md +0 -33
  14. package/src/cli/commands/PluginCommand/plugin-template/src/constants.ts +0 -22
  15. package/src/cli/commands/PluginCommand/plugin-template/src/db.ts +0 -30
  16. package/src/cli/commands/PluginCommand/plugin-template/src/index.ts +0 -3
  17. package/src/cli/commands/PluginCommand/plugin-template/src/log.ts +0 -5
  18. package/src/cli/commands/PluginCommand/plugin-template/src/plugin.ts +0 -58
  19. package/src/cli/commands/PluginCommand/util.ts +0 -140
  20. package/src/cli/commands/ServeCommand/index.ts +0 -36
  21. package/src/cli/index.ts +0 -70
  22. package/src/common/CleanupManager.ts +0 -65
  23. package/src/common/Logger.ts +0 -174
  24. package/src/common/ResourceAllocator.ts +0 -49
  25. package/src/common/TimerManager.ts +0 -64
  26. package/src/common/assert.ts +0 -26
  27. package/src/common/debug.ts +0 -8
  28. package/src/common/error.ts +0 -16
  29. package/src/common/events.ts +0 -53
  30. package/src/common/index.ts +0 -12
  31. package/src/common/mergeConfig.ts +0 -27
  32. package/src/common/mkSingleton.ts +0 -28
  33. package/src/common/plugin/action.ts +0 -164
  34. package/src/common/plugin/filter.ts +0 -197
  35. package/src/common/plugin/index.ts +0 -21
  36. package/src/common/promiseSerializer.ts +0 -22
  37. package/src/common/schema/BaseFields.ts +0 -10
  38. package/src/common/schema/Instance.ts +0 -46
  39. package/src/common/schema/InstanceLog.ts +0 -12
  40. package/src/common/schema/index.ts +0 -3
  41. package/src/common/schema/util.ts +0 -7
  42. package/src/constants.ts +0 -70
  43. package/src/core/Settings.ts +0 -119
  44. package/src/core/asyncExecutionGuard.ts +0 -49
  45. package/src/core/config.ts +0 -108
  46. package/src/core/exit.ts +0 -11
  47. package/src/core/index.ts +0 -8
  48. package/src/core/internal.ts +0 -3
  49. package/src/core/smartFetch.ts +0 -32
  50. package/src/core/tryFetch.ts +0 -69
  51. package/src/plugin.ts +0 -54
  52. package/src/server.ts +0 -129
package/CHANGELOG.md CHANGED
@@ -1,134 +1,186 @@
1
- # pockethost
1
+ # pockethost (CLI)
2
2
 
3
- ## 1.7.0
3
+ Formerly published as `phio`. Versions below 3.0.0 are phio's history.
4
+
5
+ ## 3.1.0
4
6
 
5
7
  ### Minor Changes
6
8
 
7
- - 3c7e9bf: Added plugin template command and updated docs
9
+ - `deploy` and `dev` now upload over HTTPS instead of SFTP. The CLI sends a list of file hashes, uploads only the
10
+ files PocketHost doesn't have yet (compressed), and PocketHost swaps the new set in all at once, restarting the
11
+ instance when anything outside `pb_public` changed. Files in the deployed folders that aren't in your project are
12
+ removed. Dotfiles (for example `pb_public/.well-known/`) are now deployed; `.git*` and `node_modules` stay excluded.
13
+ - Personal access tokens: set `POCKETHOST_TOKEN`, or run `pockethost token set` / `pockethost login --token`. Deploys
14
+ need no password or SSH key, so CI works on fresh runners (previously a new runner generated a new deploy key that
15
+ didn't match the registered `PocketHost CLI` key).
16
+ - New `pockethost token [set|clear|status]`. `info` shows the token in use. `logout` also removes a saved token.
17
+ - `deploy --commit <sha>` and `-m/--message <note>` are recorded with each deploy (`$GITHUB_SHA` is used
18
+ automatically).
19
+ - `--sftp` on `deploy` and `dev` keeps the previous SFTP sync.
20
+ - PocketHost no longer runs `bun install` when `package.json`, `bun.lock(b)` or `patches/` change (over SFTP or the
21
+ deploy API). Those files are copied as-is, and an existing `node_modules` on the instance is left alone. Bundle npm
22
+ code your hooks need into `pb_hooks`.
23
+
24
+ ## 3.0.0
25
+
26
+ ### Major Changes
27
+
28
+ - Renamed from `phio` to `pockethost`. Install with `npm i -g pockethost`; the command is `pockethost`. The `phio`
29
+ npm package is deprecated.
30
+ - Installs and runs on plain Node (>=20): the CLI ships as a single bundled `dist/cli.js` and no longer needs `tsx`
31
+ on your PATH (a clean `npm i -g phio@0.4.0` failed with `/usr/bin/env: 'tsx': No such file or directory`).
32
+ - New names, migrated automatically on first run:
33
+ - project file `.phioconfig` → `.pockethostconfig`
34
+ - config folder `~/.config/phio-nodejs` → `~/.config/pockethost` (Linux; macOS/Windows equivalents) (login and deploy key are copied over)
35
+ - environment variables `PHIO_*` → `POCKETHOST_*` (old names still work, with a warning)
36
+ - new deploy keys are labeled `PocketHost CLI`; existing `Phio` keys are reused
37
+ - Removed the undocumented library entry point (`main`/`types`); the package is CLI-only.
38
+ - `list` help text now says "List your instances".
39
+
40
+ ## 1.0.0 (never published; shipped as 3.0.0)
41
+
42
+ ### Major Changes
43
+
44
+ - SFTP-only deploy vendor: dropped legacy FTPS/FTP codepath and `basic-ftp` dependency
45
+ - Node `>=18` (hosting stack still requires Node 24)
46
+ - Dropped `fs-extra` and `email-validator`; leaner install
47
+
48
+ ## 0.4.0
49
+
50
+ ### Minor Changes
8
51
 
9
- ## 1.6.1
52
+ - SFTP deploy and dev sync (`ftp.pockethost.io:2222`, Ed25519 key auth)
53
+ - `phio sftp` — interactive SFTP via system client (`--print` for the command line)
54
+ - Auto-provision deploy key labeled `Phio` under Account → Keys
55
+ - Project instance linking via `.phioconfig` (migrates legacy `package.json` / `pockethost.json`)
56
+ - Walk up to project root from subdirectories before sync
57
+
58
+ ## 0.3.5
10
59
 
11
60
  ### Patch Changes
12
61
 
13
- - dc8f70b: Updated docs
62
+ - Fix: add support for bun.lock
14
63
 
15
- ## 1.6.0
64
+ ## 0.3.4
16
65
 
17
- ### Minor Changes
66
+ ### Patch Changes
18
67
 
19
- - 40bbb3c: Improve tryFetch by accepting node-fetch params
20
- - 12f029a: Add changeset maker
21
- - b7277cf: Add public instance URL calculators and refactor HTTP protocol detection
22
- - 45a8f45: Add internal app (remote control) support
23
- - 55b43a1: Remove unneeded params from GetOrProvisionInstanceUrl filter
24
- - 5be2c9e: Initial commit
25
- - a236f3e: Added several more filters
26
- - 35edc77: Enhancement: actions execute sequentially
27
- - 879845a: Enhancement: unsubscribe from filters
28
- - c473ed9: Added support for priorities in actions
29
- - 795fcd7: New action: KillInstance
30
- - c32b845: Added support for Settings filter whereby all settings are collected and displayed in DEBUG() mode
31
- - cce72b3: New action: AfterPluginsLoaded
32
- - 82dde2d: Enhancement: filters now have extensible data types
33
-
34
- ### Patch Changes
35
-
36
- - b55c585: Clean up dead code
37
- - 0e4bf43: Updated commit parser deps
38
- - f79b067: Added serve command details
39
- - dd3ceaa: Added filter debugging
40
- - 7931204: Fixed a bug where adding plugins was not saved correctly
41
- - 6e14f57: Updated plugin authoring guide
42
- - 7604930: Minor fix to GetOrProvisionInstanceUrl filter
43
- - 52b70cb: Fixed bug where --extra-plugins was not defaulting to '' correctly
44
- - Updated dependencies [c32b845]
45
- - @pockethost/plugin-launcher-spawn@1.0.0
46
- - @pockethost/plugin-auto-admin@1.0.0
47
- - @pockethost/plugin-console-logger@1.0.0
48
-
49
- ## 1.5.0
68
+ - 24988ee: Feat: logout command
69
+ - de7168b: Fix: various auth fixes
70
+ - 6262058: Fix: use correct token for log watching
71
+ - 5d28256: Enhance logs command with improved streaming and error handling
50
72
 
51
- ### Minor Changes
73
+ ## 0.3.3
74
+
75
+ ### Patch Changes
76
+
77
+ - 4bf6d1e: Fix: use client auth token instead of stored token
52
78
 
53
- - 5e9ed51: Added `--extra-plugins` global switch to temporarily load extra plugins from CLI
54
- - 2376b0d: Add InstanceConfig filter, fix instance logger namespace, add core instance app lib
55
- - 737b4b8: logSettings now exported from core
56
- - 114b1d2: Add namespace() export to core Logger service
79
+ ## 0.3.2
57
80
 
58
81
  ### Patch Changes
59
82
 
60
- - 211fba6: Plugin authoring docs update
61
- - 675e634: Added docs and updated maildev with plugin hook guards
62
- - 3daf7f5: Fix: [INFO] logging prefixes
63
- - 139468f: Updated documentation
64
- - 1e5321b: Fix: improve plugin loading order
65
- - Updated dependencies [517f602]
66
- - @pockethost/plugin-launcher-spawn@0.3.0
67
- - @pockethost/plugin-console-logger@0.2.1
68
- - @pockethost/plugin-auto-admin@0.1.1
83
+ - b85e156: Fix: nodev22 compat
69
84
 
70
- ## 1.4.0
85
+ ## 0.3.1
86
+
87
+ ### Patch Changes
88
+
89
+ - fd128bc: Node v22 compat
90
+
91
+ ## 0.3.0
71
92
 
72
93
  ### Minor Changes
73
94
 
74
- - b7e4323: Added ability for plugins to respond to `pockethost serve`
95
+ - 82b4c6b: Add support for PHIO_USERNAME, PHIO_PASSWORD, and PHIO_INSTANCE_NAME env vars
96
+ - 82b4c6b: Migrate to instance names only (no IDs)
97
+ - 82b4c6b: Remove support for global instance name - local package.json or pockethost.json required now
98
+
99
+ ### Patch Changes
100
+
101
+ - 1b46e08: Alphabetize instance lists
102
+ - 82b4c6b: Improved error message reporting
75
103
 
76
- ## 1.3.2
104
+ ## 0.2.5
77
105
 
78
106
  ### Patch Changes
79
107
 
80
- - b0a78d8: Updated plugin authoring guide
81
- - ac63ea7: Updated plugin documentation
82
- - Updated dependencies [eb0d011]
83
- - Updated dependencies [38d2c93]
84
- - @pockethost/plugin-launcher-spawn@0.2.0
85
- - @pockethost/plugin-console-logger@0.2.0
86
- - @pockethost/plugin-auto-admin@0.1.0
108
+ - 283da4e: Add 'info' command
109
+ - b17fca2: Add error handling when 'link' returns no instances
110
+ - 8aaa611: Add 'ls' alias
87
111
 
88
- ## 1.3.1
112
+ ## 0.2.4
89
113
 
90
114
  ### Patch Changes
91
115
 
92
- - 8288197: Added plugin authoring guide
116
+ - Fix: --include and --exclude now parse comma separated values correctly
93
117
 
94
- ## 1.3.0
118
+ ## 0.2.3
95
119
 
96
- ### Minor Changes
120
+ ### Patch Changes
121
+
122
+ - Fix: bad include path
97
123
 
98
- - 96f355a: Now auto-creates first admin account by default
99
- - 2fc2eeb: Added before/after instance start/stop events
100
- - 3f99ea0: Added subdomain to request action and filter context
101
- - 1384a86: BREAKING: refactored actions/filters
124
+ ## 0.2.2
102
125
 
103
126
  ### Patch Changes
104
127
 
105
- - 6812784: Added improved error parsing support
106
- - da82667: Fix: properly determine hostname when running on nonstandard port
107
- - cc4aa02: Moved mothership-related code into mothership plugin
108
- - Updated dependencies [9d626ec]
109
- - @pockethost/plugin-launcher-spawn@0.1.0
110
- - @pockethost/plugin-console-logger@0.1.0
128
+ - 467c4ba: Enh: Validate auth before tailing instance logs
129
+ - 4e8ddb5: Fix: auth token now stored correctly after refresh
111
130
 
112
- ## 1.2.0
131
+ ## 0.2.1
132
+
133
+ ### Patch Changes
134
+
135
+ - Fix: Link now uses package.json
136
+
137
+ ## 0.2.0
113
138
 
114
139
  ### Minor Changes
115
140
 
116
- - 72a6c6d: --version now displays version number
117
- - ac10d1f: Display notification when new pockethost update is available.
118
- - f9aea10: Debugging info removed from `plugin ls`
141
+ - Introduced deploy command
142
+
143
+ ### Patch Changes
144
+
145
+ - Command refactoring
146
+
147
+ ## 0.1.2
148
+
149
+ ### Patch Changes
150
+
151
+ - Enh: add --verbose flag to dev mode
152
+
153
+ ## 0.1.1
119
154
 
120
155
  ### Patch Changes
121
156
 
122
- - 76d57f6: CHANGELOG.md is now published with package.
123
- - 3783447: plugin-console-logger and plugin-launcher-spawn are now automatically installed.
157
+ - Fix: include and exclude defaults
124
158
 
125
- ## 1.1.0
159
+ ## 0.1.0
126
160
 
127
161
  ### Minor Changes
128
162
 
129
- - 1695b59: New feature: list plugins (pockethost plugin ls)
163
+ - afc6e91: Added `link` command to link to a specific instance
164
+ - fff79df: pockethost.io now runs `bun install` when uploading a `bun.lockb`
165
+ - 9fc57d6: Added whoami command
166
+ - 9fc57d6: Added list command
167
+ - afc6e91: Added --include and --exclude options to dev watch mode
168
+
169
+ ### Patch Changes
170
+
171
+ - afc6e91: Fix: log tailer will now restart on disconnect
172
+ - fff79df: Enh: watcher now looks for package.json and bun.lockb
173
+ - fff79df: Fix: watcher was incorrectly applying --include and --exclude
174
+ - fff79df: Enh: watcher now queues successive deployments that happen in rapid succession
175
+
176
+ ## 0.0.2
177
+
178
+ ### Patch Changes
179
+
180
+ - Forgot tsx dep
181
+
182
+ ## 0.0.1
130
183
 
131
184
  ### Patch Changes
132
185
 
133
- - 2514c09: Fix: make sure PH_PLUGINS contains only unique values.
134
- - 1228840: Fixed extra newline when listing configs
186
+ - a5bf2f3: Initial version
package/README.md ADDED
@@ -0,0 +1,133 @@
1
+ # pockethost: the PocketHost CLI
2
+
3
+ Deploy, sync, and tail logs for your [PocketHost](https://pockethost.io) instances.
4
+
5
+ Install globally (Node.js 20+):
6
+
7
+ ```bash
8
+ npm install -g pockethost
9
+ ```
10
+
11
+ ### Upgrading from `phio`
12
+
13
+ `phio` is now `pockethost`. Swap the package:
14
+
15
+ ```bash
16
+ npm rm -g phio && npm i -g pockethost
17
+ ```
18
+
19
+ Everything carries over on first run: your login and deploy key are copied from phio's config folder (`~/.config/phio-nodejs` on Linux), `.phioconfig` is
20
+ renamed to `.pockethostconfig` (commit it), and the `PHIO_*` environment variables keep working with a warning until
21
+ you rename them to `POCKETHOST_*`.
22
+
23
+ ## Commands
24
+
25
+ ```bash
26
+ pockethost login # or: pockethost login --token
27
+ pockethost token [set|clear|status]
28
+ pockethost logout
29
+ pockethost info # alias: pockethost whoami
30
+ pockethost list # alias: pockethost ls
31
+ pockethost link [instance]
32
+ pockethost dev [instance]
33
+ pockethost deploy [instance]
34
+ pockethost sftp [instance]
35
+ pockethost logs [instance]
36
+ ```
37
+
38
+ - **`pockethost dev`**: watch local changes and deploy them
39
+ - **`pockethost deploy`**: deploy once
40
+ - **`pockethost token`**: save, clear, or check a personal access token
41
+ - **`pockethost sftp`**: interactive SFTP session (uses system `sftp` when available)
42
+ - **`pockethost logs`**: tail instance logs
43
+
44
+ `dev` and `deploy` accept `-v/--verbose`, `-i/--include`, `-e/--exclude`, and `--sftp` (sync over SFTP instead of
45
+ HTTPS). `deploy` also takes `--commit <sha>` and `-m/--message <note>`.
46
+
47
+ Default includes: `pb_*`, `package.json`, `bun.lock`, `bun.lockb`, `patches/**`.
48
+
49
+ Default excludes: `pb_data/**`.
50
+
51
+ ## Configuration
52
+
53
+ Link a project directory to an instance:
54
+
55
+ ```bash
56
+ pockethost link my-instance
57
+ ```
58
+
59
+ This writes `.pockethostconfig`:
60
+
61
+ ```json
62
+ {
63
+ "instanceName": "my-instance"
64
+ }
65
+ ```
66
+
67
+ Older project files (`.phioconfig`, `package.json` → `pockethost.instanceName`, `pockethost.json`) are migrated to
68
+ `.pockethostconfig` automatically on first use.
69
+
70
+ ## How deploys work
71
+
72
+ `deploy` and `dev` talk to the instance over HTTPS (`https://<instance>.pockethost.io/_ph/deploy/v1`):
73
+
74
+ 1. Send a manifest of `{ path: sha256 }` for the matched files.
75
+ 2. Upload only the files the server is missing, as one gzip bundle per ~32 MB.
76
+ 3. Commit: the server swaps the file set in atomically (stopping the instance when anything outside `pb_public`
77
+ changes) and starts the instance again.
78
+
79
+ PocketHost doesn't install npm packages. `package.json`, `bun.lock(b)` and `patches/` are copied as plain files. Bundle
80
+ any npm code your hooks need into `pb_hooks`.
81
+
82
+ Only `pb_*` folders (never `pb_data`), `package.json`, `bun.lock(b)` and `patches/` are deployed. Files in those folders
83
+ on the instance that aren't in your project are removed. `node_modules` and `.git*` are never touched.
84
+
85
+ ## Authentication
86
+
87
+ `deploy` and `dev` use, in order:
88
+
89
+ 1. `POCKETHOST_TOKEN` (a personal access token, `ph_pat_…`)
90
+ 2. a token saved with `pockethost token set` (or `pockethost login --token`)
91
+ 3. your email/password login (`pockethost login`, or `POCKETHOST_USERNAME`/`POCKETHOST_PASSWORD`)
92
+
93
+ Create tokens under Account → API Tokens in the dashboard. Deploy from GitHub Actions:
94
+
95
+ ```yaml
96
+ - run: npx pockethost@latest deploy myapp-${{ github.ref_name }}
97
+ env:
98
+ POCKETHOST_TOKEN: ${{ secrets.POCKETHOST_TOKEN }}
99
+ ```
100
+
101
+ Docs: https://pockethost.io/docs/deploy-from-ci
102
+
103
+ ## Deploy key (`--sftp` and `pockethost sftp`)
104
+
105
+ `pockethost dev --sftp`, `pockethost deploy --sftp` and `pockethost sftp` use **SFTP** (`ftp.pockethost.io:2222`) using an Ed25519 deploy key
106
+ stored under `POCKETHOST_HOME` (default `~/.config/pockethost/`). The CLI auto-registers a **`PocketHost CLI`** key
107
+ under Account → Keys on first use (an existing **`Phio`** key from phio is reused). Run `pockethost info` to inspect
108
+ key status.
109
+
110
+ Customer docs: https://pockethost.io/docs/cli
111
+
112
+ ## Environment variables
113
+
114
+ | Variable | Purpose |
115
+ | -------- | ------- |
116
+ | `POCKETHOST_TOKEN` | Personal access token for `deploy`/`dev` (CI) |
117
+ | `POCKETHOST_USERNAME` | Override saved email (non-interactive login) |
118
+ | `POCKETHOST_PASSWORD` | Override saved password |
119
+ | `POCKETHOST_INSTANCE_NAME` | Override linked instance name |
120
+ | `POCKETHOST_MOTHERSHIP_URL` | Override mothership API URL |
121
+ | `POCKETHOST_HOME` | Override config directory |
122
+ | `POCKETHOST_PROJECT_DIR` | Override project root detection |
123
+
124
+ Environment variables take precedence over `.pockethostconfig`. The old `PHIO_*` names still work (with a deprecation
125
+ warning) and will be removed in the next major version.
126
+
127
+ ## Development (monorepo)
128
+
129
+ ```bash
130
+ pnpm dev:cli-client -- --help # from the repo root, runs src/ with tsx
131
+ pnpm --filter pockethost build # bundle to dist/cli.js
132
+ pnpm --filter pockethost test
133
+ ```