portless 0.10.2 → 0.11.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 +121 -2
- package/dist/{chunk-EZJWUTUA.js → chunk-6PDLZVDS.js} +19 -693
- package/dist/cli.js +1944 -260
- package/dist/index.d.ts +2 -9
- package/dist/index.js +1 -5
- package/package.json +13 -12
- package/LICENSE +0 -201
package/README.md
CHANGED
|
@@ -38,8 +38,112 @@ When auto-starting, portless reuses the configuration (port, TLS, TLD) from the
|
|
|
38
38
|
|
|
39
39
|
In non-interactive environments (no TTY, or `CI=1`), portless exits with a descriptive error instead of prompting, so task runners like turborepo and CI scripts fail early with a clear message.
|
|
40
40
|
|
|
41
|
+
## Configuration
|
|
42
|
+
|
|
43
|
+
Bare `portless` works out of the box. It runs the `"dev"` script from `package.json` through the proxy, inferring the app name from the package name, git root, or directory:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
portless # -> runs "dev" script, https://<project>.localhost
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Use an optional `portless.json` to override defaults:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{ "name": "myapp" }
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
portless # -> runs "dev" script, https://myapp.localhost
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The script defaults to `"dev"`. The name is inferred from `package.json` if not set in config.
|
|
60
|
+
|
|
61
|
+
### Monorepo
|
|
62
|
+
|
|
63
|
+
One `portless.json` at the repo root covers all workspace packages. Portless discovers packages from `pnpm-workspace.yaml`, or the `"workspaces"` field in `package.json` (npm, yarn, bun):
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"apps": {
|
|
68
|
+
"apps/web": { "name": "myapp" },
|
|
69
|
+
"apps/api": { "name": "api.myapp" }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
portless # from repo root: starts all workspace packages with a "dev" script
|
|
76
|
+
cd apps/web && portless # start just one package
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The `apps` map is optional and only needed for name overrides. Packages not listed still auto-discover with names inferred from their `package.json`.
|
|
80
|
+
|
|
81
|
+
Without an `apps` map, hostnames follow the `<package>.<project>.localhost` convention. The project name comes from the most common npm scope across workspace packages (e.g. `@myorg/web` and `@myorg/api` produce `myorg`), falling back to the workspace root directory name. If a package's short name matches the project name, it gets the bare `<project>.localhost` without duplication.
|
|
82
|
+
|
|
83
|
+
### Config fields
|
|
84
|
+
|
|
85
|
+
| Field | Type | Default | Description |
|
|
86
|
+
| --------- | ------- | -------- | --------------------------------------------------------- |
|
|
87
|
+
| `name` | string | inferred | Base app name. Worktree prefix still applies. |
|
|
88
|
+
| `script` | string | `"dev"` | Name of a `package.json` script to run. |
|
|
89
|
+
| `appPort` | number | auto | Fixed port for the child process. |
|
|
90
|
+
| `proxy` | boolean | auto | Whether to route through the proxy. Auto-detected. |
|
|
91
|
+
| `apps` | object | | Overrides for workspace packages, keyed by relative path. |
|
|
92
|
+
| `turbo` | boolean | `true` | Set `false` to use direct spawning instead of turborepo. |
|
|
93
|
+
|
|
94
|
+
### package.json "portless" key
|
|
95
|
+
|
|
96
|
+
Instead of a separate `portless.json`, you can add a `"portless"` key to your `package.json`. A string value is shorthand for setting the name:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"name": "@myorg/web",
|
|
101
|
+
"portless": "myapp"
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
An object supports all per-app fields (`name`, `script`, `appPort`, `proxy`):
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"name": "@myorg/web",
|
|
110
|
+
"portless": { "name": "myapp", "script": "dev:app" }
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The `package.json` `"portless"` key takes precedence over `portless.json` app entries but is overridden by CLI flags.
|
|
115
|
+
|
|
116
|
+
### --script flag
|
|
117
|
+
|
|
118
|
+
Override the default script for a single invocation:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
portless --script start # run "start" instead of "dev"
|
|
122
|
+
portless --script test # run "test" instead of "dev"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Turborepo
|
|
126
|
+
|
|
127
|
+
To use portless with turborepo, put `portless` as the `dev` script and the real command in a separate script:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"scripts": {
|
|
132
|
+
"dev": "portless",
|
|
133
|
+
"dev:app": "next dev"
|
|
134
|
+
},
|
|
135
|
+
"portless": { "name": "myapp", "script": "dev:app" }
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Turbo runs each package's `dev` script, which invokes portless. Portless reads the config, detects the package manager, and runs `pnpm run dev:app` (or yarn/bun/npm) through the proxy. No changes to `turbo.json` are needed.
|
|
140
|
+
|
|
141
|
+
`pnpm dev` at the root works through turbo as usual. People without portless can run `pnpm run dev:app` directly.
|
|
142
|
+
|
|
41
143
|
## Use in package.json
|
|
42
144
|
|
|
145
|
+
You can still use portless in `package.json` scripts:
|
|
146
|
+
|
|
43
147
|
```json
|
|
44
148
|
{
|
|
45
149
|
"scripts": {
|
|
@@ -48,6 +152,18 @@ In non-interactive environments (no TTY, or `CI=1`), portless exits with a descr
|
|
|
48
152
|
}
|
|
49
153
|
```
|
|
50
154
|
|
|
155
|
+
With a `portless.json`, you can simplify to:
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
{
|
|
159
|
+
"scripts": {
|
|
160
|
+
"dev": "next dev"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Then run `portless` or `portless run` to go through the proxy.
|
|
166
|
+
|
|
51
167
|
## Subdomains
|
|
52
168
|
|
|
53
169
|
Organize services with subdomains:
|
|
@@ -163,7 +279,9 @@ LAN mode depends on the system mDNS tools that portless already spawns: macOS sh
|
|
|
163
279
|
## Commands
|
|
164
280
|
|
|
165
281
|
```bash
|
|
166
|
-
portless
|
|
282
|
+
portless # Run dev script through proxy
|
|
283
|
+
portless # From monorepo root: run all workspace packages
|
|
284
|
+
portless run [--name <name>] [cmd] [args...] # Infer name, run through proxy
|
|
167
285
|
portless <name> <cmd> [args...] # Run app at https://<name>.localhost
|
|
168
286
|
portless alias <name> <port> # Register a static route (e.g. for Docker)
|
|
169
287
|
portless alias <name> <port> --force # Overwrite an existing route
|
|
@@ -200,6 +318,7 @@ portless proxy stop # Stop the proxy
|
|
|
200
318
|
--foreground Run proxy in foreground instead of daemon
|
|
201
319
|
--tld <tld> Use a custom TLD instead of .localhost (e.g. test)
|
|
202
320
|
--wildcard Allow unregistered subdomains to fall back to parent route
|
|
321
|
+
--script <name> Run a specific package.json script (default: dev)
|
|
203
322
|
--app-port <number> Use a fixed port for the app (skip auto-assignment)
|
|
204
323
|
--force Kill the existing process and take over its route
|
|
205
324
|
--name <name> Use <name> as the app name
|
|
@@ -280,7 +399,7 @@ devServer: {
|
|
|
280
399
|
}
|
|
281
400
|
```
|
|
282
401
|
|
|
283
|
-
Portless automatically sets `NODE_EXTRA_CA_CERTS` in child processes so Node.js trusts the portless CA. If you run a separate Node.js process outside portless, point it at the CA manually: `NODE_EXTRA_CA_CERTS
|
|
402
|
+
Portless automatically sets `NODE_EXTRA_CA_CERTS` in child processes so Node.js trusts the portless CA. If you run a separate Node.js process outside portless, point it at the CA manually: `NODE_EXTRA_CA_CERTS=~/.portless/ca.pem`. Alternatively, use `--no-tls` for plain HTTP.
|
|
284
403
|
|
|
285
404
|
Portless detects this misconfiguration and responds with `508 Loop Detected` along with a message pointing to this fix.
|
|
286
405
|
|