@nearhost/cli 0.0.0-stage → 0.4.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/LICENSE +21 -0
- package/README.md +19 -2
- package/bin/nearhost.js +46 -0
- package/package.json +34 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Edward Coleridge Smith
|
|
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
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @nearhost/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Nearhost](https://nearhost.dev) gives every local and remote development server an address at `https://<name>.test`, with a certificate your browser trusts and SSH forwards that look after themselves.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npx @nearhost/cli
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
or install it for good:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install -g @nearhost/cli
|
|
13
|
+
nearhost
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
This package holds a small launcher. The binary comes in a platform package, `@nearhost/cli-<os>-<arch>`, which npm picks for your machine: macOS or Linux, on x64 or arm64. Nothing is downloaded by an install script, so it works with `--ignore-scripts`, pnpm and bun.
|
|
17
|
+
|
|
18
|
+
On Linux, Nearhost needs permission to bind ports 80 and 443. `nearhost doctor` tells you how to grant it.
|
|
19
|
+
|
|
20
|
+
Read the [docs](https://nearhost.dev/docs/) for the rest. The source is at [github.com/nearhost/nearhost](https://github.com/nearhost/nearhost).
|
package/bin/nearhost.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Runs the nearhost binary from the platform package npm installed next to
|
|
3
|
+
// this one. Each @nearhost/cli-<os>-<arch> package declares os and cpu, so
|
|
4
|
+
// npm installs only the one that matches this machine.
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
const { spawn } = require('node:child_process');
|
|
8
|
+
|
|
9
|
+
const pkg = `@nearhost/cli-${process.platform}-${process.arch}`;
|
|
10
|
+
|
|
11
|
+
let bin;
|
|
12
|
+
try {
|
|
13
|
+
bin = require.resolve(`${pkg}/bin/nearhost`);
|
|
14
|
+
} catch {
|
|
15
|
+
const supported = ['darwin', 'linux'].includes(process.platform) && ['x64', 'arm64'].includes(process.arch);
|
|
16
|
+
console.error(
|
|
17
|
+
supported
|
|
18
|
+
? `nearhost: ${pkg} is not installed. It is an optional dependency of @nearhost/cli; reinstall without --no-optional or --omit=optional.`
|
|
19
|
+
: `nearhost: there is no build for ${process.platform} on ${process.arch}. Nearhost runs on macOS and Linux, on x64 and arm64.`,
|
|
20
|
+
);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const child = spawn(bin, process.argv.slice(2), { stdio: 'inherit' });
|
|
25
|
+
|
|
26
|
+
// Ctrl-C and a closing terminal reach nearhost directly, as they reach every
|
|
27
|
+
// process in the foreground group; passing them on as well would count as a
|
|
28
|
+
// second signal, which makes `nearhost up` cut its shutdown short. A SIGTERM
|
|
29
|
+
// is sent to this process alone, so it is passed on.
|
|
30
|
+
process.on('SIGINT', () => {});
|
|
31
|
+
process.on('SIGHUP', () => {});
|
|
32
|
+
process.on('SIGTERM', () => child.kill('SIGTERM'));
|
|
33
|
+
|
|
34
|
+
child.on('error', (err) => {
|
|
35
|
+
console.error(`nearhost: could not run ${bin}: ${err.message}`);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
child.on('exit', (code, signal) => {
|
|
40
|
+
if (signal) {
|
|
41
|
+
process.removeAllListeners(signal);
|
|
42
|
+
process.kill(process.pid, signal);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
process.exit(code);
|
|
46
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nearhost/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Reach local and remote development servers at https://<name>.test",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dev server",
|
|
7
|
+
"https",
|
|
8
|
+
"ssh",
|
|
9
|
+
"tunnel",
|
|
10
|
+
"localhost",
|
|
11
|
+
"certificate"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://nearhost.dev",
|
|
14
|
+
"bugs": "https://github.com/nearhost/nearhost/issues",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/nearhost/nearhost.git",
|
|
18
|
+
"directory": "npm/cli"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"bin": {
|
|
22
|
+
"nearhost": "bin/nearhost.js"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"bin"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
},
|
|
30
|
+
"optionalDependencies": {
|
|
31
|
+
"@nearhost/cli-darwin-x64": "0.4.0",
|
|
32
|
+
"@nearhost/cli-darwin-arm64": "0.4.0",
|
|
33
|
+
"@nearhost/cli-linux-x64": "0.4.0",
|
|
34
|
+
"@nearhost/cli-linux-arm64": "0.4.0"
|
|
35
|
+
}
|
|
36
|
+
}
|