coderaft 0.0.8 → 0.0.10
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 +12 -6
- package/code.mjs +3 -3
- package/code.tar.zst +0 -0
- package/dist/_chunks/server.mjs +39 -5
- package/dist/cli.mjs +6 -6
- package/dist/index.d.mts +1 -1
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -34,21 +34,27 @@ Compared to [`code-server`](https://www.npmjs.com/package/code-server) and [`ope
|
|
|
34
34
|
|
|
35
35
|
</details>
|
|
36
36
|
|
|
37
|
-
## CLI
|
|
37
|
+
## CLI
|
|
38
38
|
|
|
39
|
-
Start
|
|
39
|
+
Start an instance:
|
|
40
40
|
|
|
41
41
|
```sh
|
|
42
42
|
npx coderaft -o .
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
### Docker
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
docker run -it --rm -p 6063:6063 node:alpine npx -y coderaft
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Programmatic
|
|
46
52
|
|
|
47
53
|
```ts
|
|
48
54
|
import { startCodeServer } from "coderaft";
|
|
49
55
|
|
|
50
56
|
const instance = await startCodeServer({
|
|
51
|
-
port:
|
|
57
|
+
port: 6063,
|
|
52
58
|
host: "127.0.0.1",
|
|
53
59
|
defaultFolder: "/path/to/workspace",
|
|
54
60
|
// connectionToken: "my-secret", // auto-generated if omitted
|
|
@@ -112,7 +118,7 @@ Accepts all `createCodeServer` options plus:
|
|
|
112
118
|
|
|
113
119
|
| Option | Type | Description |
|
|
114
120
|
| ------ | -------- | -------------------------------------------------------------------- |
|
|
115
|
-
| `port` | `number` | TCP port to listen on. Defaults to `$PORT` or `
|
|
121
|
+
| `port` | `number` | TCP port to listen on. Defaults to `$PORT` or `6063`. |
|
|
116
122
|
| `host` | `string` | Host/interface to bind. Defaults to Node's default (all interfaces). |
|
|
117
123
|
|
|
118
124
|
Returns a `CodeServerHandle`:
|
|
@@ -133,7 +139,7 @@ interface CodeServerHandle {
|
|
|
133
139
|
|
|
134
140
|
| Option | Description |
|
|
135
141
|
| ----------------------------- | ---------------------------------------------- |
|
|
136
|
-
| `-p, --port <port>` | Port to listen on (default: `$PORT` or `
|
|
142
|
+
| `-p, --port <port>` | Port to listen on (default: `$PORT` or `6063`) |
|
|
137
143
|
| `-H, --host <host>` | Host/interface to bind |
|
|
138
144
|
| `--server-base-path <path>` | Base path for the web UI (default: `/`) |
|
|
139
145
|
| `--socket-path <path>` | Path to a socket file to listen on |
|
package/code.mjs
CHANGED
|
@@ -4,14 +4,14 @@ import { tmpdir } from "node:os";
|
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
|
|
6
6
|
// Auto-updated by scripts/pack.ts
|
|
7
|
-
const codeArchiveHash = "
|
|
7
|
+
const codeArchiveHash = "932c7f505a988efd";
|
|
8
8
|
|
|
9
9
|
const archivePath = fileURLToPath(new URL("./code.tar.zst", import.meta.url));
|
|
10
10
|
|
|
11
11
|
const verbose = !!process.env.DEBUG;
|
|
12
12
|
|
|
13
13
|
const gray = (str) => `\x1b[90m${str}\x1b[0m`;
|
|
14
|
-
const log = (...args) => console.log(gray(`[
|
|
14
|
+
const log = (...args) => console.log(gray(`[coderaft] ${args.join(" ")}`));
|
|
15
15
|
const vlog = verbose ? log : () => {};
|
|
16
16
|
|
|
17
17
|
export async function loadCode() {
|
|
@@ -20,7 +20,7 @@ export async function loadCode() {
|
|
|
20
20
|
return { modulesDir: resolve(process.env.CODE_MODULES_DIR) };
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const cacheDir = join(tmpdir(), "
|
|
23
|
+
const cacheDir = join(tmpdir(), "coderaft", codeArchiveHash);
|
|
24
24
|
const modulesDir = join(cacheDir, "node_modules");
|
|
25
25
|
const markerPath = join(cacheDir, ".complete");
|
|
26
26
|
|
package/code.tar.zst
CHANGED
|
Binary file
|
package/dist/_chunks/server.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
2
3
|
import { createReadStream, readFileSync, readdirSync, unlinkSync } from "node:fs";
|
|
3
4
|
import { createServer } from "node:http";
|
|
4
|
-
import { homedir } from "node:os";
|
|
5
|
+
import os, { homedir } from "node:os";
|
|
5
6
|
import { extname, join, normalize, sep } from "node:path";
|
|
6
7
|
import { stat } from "node:fs/promises";
|
|
7
8
|
import { loadCode } from "#code";
|
|
9
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
8
10
|
const STATIC_MIME = {
|
|
9
11
|
".js": "text/javascript",
|
|
10
12
|
".mjs": "text/javascript",
|
|
@@ -47,8 +49,8 @@ async function serveStatic(res, root, relPath) {
|
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
const MANIFEST_BODY = JSON.stringify({
|
|
50
|
-
name: "
|
|
51
|
-
short_name: "
|
|
52
|
+
name: "coderaft",
|
|
53
|
+
short_name: "coderaft",
|
|
52
54
|
start_url: ".",
|
|
53
55
|
display: "fullscreen",
|
|
54
56
|
display_override: ["window-controls-overlay"],
|
|
@@ -75,13 +77,21 @@ async function createCodeServer(opts = {}) {
|
|
|
75
77
|
cleanupStaleLocks(opts.vscode?.["user-data-dir"] ?? join(homedir(), ".vscode-server-oss", "data"));
|
|
76
78
|
const { modulesDir } = await loadCode();
|
|
77
79
|
const vsRootPath = join(modulesDir, "code-server", "lib", "vscode");
|
|
80
|
+
ensureNetworkInterface();
|
|
78
81
|
const _log = console.log;
|
|
79
82
|
console.log = (...args) => {
|
|
80
83
|
if (typeof args[0] === "string" && args[0].includes("[reconnection-grace-time]")) return;
|
|
81
84
|
if (args.length === 2 && typeof args[1] === "string" && !args[1].trim()) return;
|
|
82
85
|
_log(...args);
|
|
83
86
|
};
|
|
84
|
-
const
|
|
87
|
+
const mod = await import(join(vsRootPath, "out/server-main.js"));
|
|
88
|
+
const _product = globalThis._VSCODE_PRODUCT_JSON;
|
|
89
|
+
if (_product) {
|
|
90
|
+
_product.nameShort = "coderaft";
|
|
91
|
+
_product.nameLong = "coderaft";
|
|
92
|
+
_product.applicationName = "coderaft";
|
|
93
|
+
}
|
|
94
|
+
const vscodeServer = await (await mod.loadCodeWithNls()).createServer(null, {
|
|
85
95
|
"default-folder": defaultFolder,
|
|
86
96
|
...withoutToken ? {} : { "connection-token": connectionToken },
|
|
87
97
|
"reconnection-grace-time": "10800",
|
|
@@ -158,7 +168,7 @@ async function createCodeServer(opts = {}) {
|
|
|
158
168
|
};
|
|
159
169
|
}
|
|
160
170
|
async function startCodeServer(opts = {}) {
|
|
161
|
-
const port = opts.port ?? (Number(process.env.PORT) ||
|
|
171
|
+
const port = opts.port ?? (Number(process.env.PORT) || 6063);
|
|
162
172
|
const handler = await createCodeServer(opts);
|
|
163
173
|
const server = createServer((req, res) => {
|
|
164
174
|
handler.handleRequest(req, res);
|
|
@@ -196,6 +206,30 @@ async function startCodeServer(opts = {}) {
|
|
|
196
206
|
}
|
|
197
207
|
};
|
|
198
208
|
}
|
|
209
|
+
function ensureNetworkInterface() {
|
|
210
|
+
const original = os.networkInterfaces;
|
|
211
|
+
const BLACKLISTED = new Set([
|
|
212
|
+
"00:00:00:00:00:00",
|
|
213
|
+
"ff:ff:ff:ff:ff:ff",
|
|
214
|
+
"ac:de:48:00:11:22"
|
|
215
|
+
]);
|
|
216
|
+
os.networkInterfaces = function networkInterfaces() {
|
|
217
|
+
const ifaces = original.call(os);
|
|
218
|
+
for (const name in ifaces) for (const info of ifaces[name]) if (info.mac && !BLACKLISTED.has(info.mac)) return ifaces;
|
|
219
|
+
const { createHash } = __require("node:crypto");
|
|
220
|
+
const hash = createHash("md5").update(os.hostname()).digest();
|
|
221
|
+
hash[0] = (hash[0] | 2) & 254;
|
|
222
|
+
ifaces._coderaft = [{
|
|
223
|
+
address: "10.0.0.1",
|
|
224
|
+
netmask: "255.255.255.0",
|
|
225
|
+
family: "IPv4",
|
|
226
|
+
mac: [...hash.subarray(0, 6)].map((b) => b.toString(16).padStart(2, "0")).join(":"),
|
|
227
|
+
internal: false,
|
|
228
|
+
cidr: "10.0.0.1/24"
|
|
229
|
+
}];
|
|
230
|
+
return ifaces;
|
|
231
|
+
};
|
|
232
|
+
}
|
|
199
233
|
function cleanupStaleLocks(userDataDir) {
|
|
200
234
|
const storageDir = join(userDataDir, "User", "workspaceStorage");
|
|
201
235
|
try {
|
package/dist/cli.mjs
CHANGED
|
@@ -75,10 +75,10 @@ const { values, positionals } = parseArgs({
|
|
|
75
75
|
});
|
|
76
76
|
if (values.help) {
|
|
77
77
|
console.log(`
|
|
78
|
-
Usage:
|
|
78
|
+
Usage: coderaft [options]
|
|
79
79
|
|
|
80
80
|
Server:
|
|
81
|
-
-p, --port <port> Port to listen on (default: $PORT or
|
|
81
|
+
-p, --port <port> Port to listen on (default: $PORT or 6063)
|
|
82
82
|
-H, --host <host> Host/interface to bind
|
|
83
83
|
--server-base-path <path> Base path for the web UI (default: /)
|
|
84
84
|
--socket-path <path> Path to a socket file to listen on
|
|
@@ -206,10 +206,9 @@ for (const key of [
|
|
|
206
206
|
]) if (values[key] !== void 0) vscode[key] = values[key];
|
|
207
207
|
if (values["logs-path"]) vscode.logsPath = values["logs-path"];
|
|
208
208
|
const dir = positionals[0];
|
|
209
|
-
|
|
210
|
-
if (autoPort0 || dir) vscode["disable-workspace-trust"] = true;
|
|
209
|
+
if (dir) vscode["disable-workspace-trust"] = true;
|
|
211
210
|
const handle = await startCodeServer({
|
|
212
|
-
port: values.port ? Number(values.port) :
|
|
211
|
+
port: values.port ? Number(values.port) : void 0,
|
|
213
212
|
host: values.host,
|
|
214
213
|
defaultFolder: dir || values["default-folder"],
|
|
215
214
|
connectionToken: values["connection-token"],
|
|
@@ -233,8 +232,9 @@ if (values.open) {
|
|
|
233
232
|
}
|
|
234
233
|
let shuttingDown = false;
|
|
235
234
|
const shutdown = () => {
|
|
236
|
-
if (shuttingDown)
|
|
235
|
+
if (shuttingDown) process.exit(0);
|
|
237
236
|
shuttingDown = true;
|
|
237
|
+
setTimeout(() => process.exit(0), 3e3).unref();
|
|
238
238
|
handle.close().finally(() => process.exit(0));
|
|
239
239
|
};
|
|
240
240
|
process.on("SIGINT", shutdown);
|
package/dist/index.d.mts
CHANGED
|
@@ -87,7 +87,7 @@ interface CreateCodeServerOptions {
|
|
|
87
87
|
vscode?: VSCodeServerOptions;
|
|
88
88
|
}
|
|
89
89
|
interface StartCodeServerOptions extends CreateCodeServerOptions {
|
|
90
|
-
/** TCP port to listen on. Defaults to `$PORT` or `
|
|
90
|
+
/** TCP port to listen on. Defaults to `$PORT` or `6063`. */
|
|
91
91
|
port?: number;
|
|
92
92
|
/** Host/interface to bind. Defaults to Node's default (all interfaces). */
|
|
93
93
|
host?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coderaft",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"repository": "pithings/coderaft",
|
|
5
5
|
"bin": {
|
|
6
6
|
"coderaft": "./dist/cli.mjs"
|
|
@@ -21,22 +21,23 @@
|
|
|
21
21
|
"build": "obuild"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
+
"code-server": "^4.114.1",
|
|
24
25
|
"@anthropic-ai/sandbox-runtime": "0.0.42",
|
|
25
|
-
"@github/copilot": "
|
|
26
|
-
"@github/copilot-sdk": "
|
|
27
|
-
"@microsoft/1ds-core-js": "
|
|
28
|
-
"@microsoft/1ds-post-js": "
|
|
29
|
-
"@parcel/watcher": "
|
|
30
|
-
"@vscode/deviceid": "
|
|
31
|
-
"@vscode/fs-copyfile": "
|
|
26
|
+
"@github/copilot": "workspace:*",
|
|
27
|
+
"@github/copilot-sdk": "workspace:*",
|
|
28
|
+
"@microsoft/1ds-core-js": "workspace:*",
|
|
29
|
+
"@microsoft/1ds-post-js": "workspace:*",
|
|
30
|
+
"@parcel/watcher": "workspace:*",
|
|
31
|
+
"@vscode/deviceid": "workspace:*",
|
|
32
|
+
"@vscode/fs-copyfile": "workspace:*",
|
|
32
33
|
"@vscode/iconv-lite-umd": "0.7.1",
|
|
33
|
-
"@vscode/native-watchdog": "
|
|
34
|
-
"@vscode/proxy-agent": "
|
|
35
|
-
"@vscode/ripgrep": "
|
|
36
|
-
"@vscode/spdlog": "
|
|
34
|
+
"@vscode/native-watchdog": "workspace:*",
|
|
35
|
+
"@vscode/proxy-agent": "workspace:*",
|
|
36
|
+
"@vscode/ripgrep": "workspace:*",
|
|
37
|
+
"@vscode/spdlog": "workspace:*",
|
|
37
38
|
"@vscode/tree-sitter-wasm": "^0.3.0",
|
|
38
39
|
"@vscode/vscode-languagedetection": "1.0.23",
|
|
39
|
-
"@vscode/windows-process-tree": "
|
|
40
|
+
"@vscode/windows-process-tree": "workspace:*",
|
|
40
41
|
"@vscode/windows-registry": "^1.2.0",
|
|
41
42
|
"@xterm/addon-clipboard": "^0.3.0-beta.191",
|
|
42
43
|
"@xterm/addon-image": "^0.10.0-beta.191",
|
|
@@ -48,7 +49,6 @@
|
|
|
48
49
|
"@xterm/addon-webgl": "^0.20.0-beta.190",
|
|
49
50
|
"@xterm/headless": "^6.1.0-beta.191",
|
|
50
51
|
"@xterm/xterm": "^6.1.0-beta.191",
|
|
51
|
-
"code-server": "^4.114.0",
|
|
52
52
|
"cookie": "^0.7.0",
|
|
53
53
|
"http-proxy-agent": "^7.0.0",
|
|
54
54
|
"https-proxy-agent": "^7.0.2",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"katex": "^0.16.22",
|
|
57
57
|
"kerberos": "2.1.1",
|
|
58
58
|
"minimist": "^1.2.8",
|
|
59
|
-
"node-pty": "
|
|
59
|
+
"node-pty": "workspace:*",
|
|
60
60
|
"tas-client": "0.3.1",
|
|
61
61
|
"typescript": "^6.0.2",
|
|
62
62
|
"vscode-oniguruma": "1.7.0",
|