fix: update build system and dependencies

This commit is contained in:
DecDuck
2025-05-09 12:53:37 +10:00
parent f46d5fb347
commit 83e41aa298
4 changed files with 1247 additions and 618 deletions

View File

@@ -1,10 +1,7 @@
import { defineBuildConfig } from 'unbuild'
import { defineBuildConfig } from "unbuild";
export default defineBuildConfig({
declaration: true,
entries: [
'./src/cli',
'./src/index'
],
inlineDependencies: true
})
entries: ["./src/cli", "./src/index"],
failOnWarn: false,
});

View File

@@ -7,6 +7,7 @@
"exports": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"bin": "./bin/headscalez",
"private": false,
"files": [
"dist",
"bin"
@@ -16,24 +17,22 @@
"prepack": "unbuild",
"dev": "jiti ./src/cli.ts",
"start": "npx concurrently 'yarn dev' 'node server.mjs'",
"release": "yarn test && standard-version && git push --follow-tags && npm publish",
"release": "yarn test && standard-version && git push --follow-tags && npm publish --access=public",
"test": "yarn lint"
},
"dependencies": {
"consola": "^2.15.3",
"decompress": "^4.2.1",
"fs-extra": "^10.0.0",
"node-graceful-shutdown": "^1.1.0",
"fs-extra": "^11.3.0",
"node-graceful-shutdown": "^1.1.5",
"ofetch": "^1.4.1",
"ora": "^5.4.1"
"execa": "^9.5.3"
},
"devDependencies": {
"@nuxtjs/eslint-config-typescript": "^6.0.1",
"@types/node": "^22.15.17",
"eslint": "^7.30.0",
"execa": "^5.1.1",
"jiti": "^1.10.1",
"jiti": "^2.4.2",
"standard-version": "^9.3.0",
"typescript": "^4.3.5",
"unbuild": "^0.3.1"
"unbuild": "^3.5.0"
}
}

View File

@@ -3,11 +3,9 @@ import os from "os";
import fs, { ReadStream } from "fs";
import fsExtra from "fs-extra";
import { ofetch } from "ofetch";
import type { ExecaChildProcess } from "execa";
import execa from "execa";
import { execa, ResultPromise } from "execa";
import { onShutdown } from "node-graceful-shutdown";
import { headscaleFormula as formula } from "./formula";
import stream, { Stream, Writable } from "stream";
import createConfig from "./config";
export interface HeadscaleOptions {
@@ -22,8 +20,8 @@ export interface HeadscaleOptions {
export type HeadscaleOptionsResolved = Required<HeadscaleOptions>;
export interface HeadscaleService {
service: ExecaChildProcess;
close: () => Promise<void>;
service: ResultPromise<{}>;
close: () => Promise<boolean>;
}
export async function startHeadscale(
@@ -56,11 +54,11 @@ export async function startHeadscale(
// config consts
const databasePath = path.resolve(opts.dir, "headscale.sqlite");
const cachePath = path.resolve(opts.dir, "cache");
const noisePrivateKey = path.resolve(opts.dir, "noise_private.key")
const noisePrivateKey = path.resolve(opts.dir, "noise_private.key");
const derpPrivateKey = path.resolve(opts.dir, "derp_private.key");
const socketPath = path.resolve(opts.dir, "headscale.socket");
// log/config
const configPath = path.resolve(opts.dir, "config.yaml");
const logPath = path.resolve(opts.dir, "headscale.log");
@@ -73,7 +71,7 @@ export async function startHeadscale(
const response = await ofetch<ReadableStream>(platform.source, {
responseType: "stream" as any,
});
const destination: Writable = fs.createWriteStream(binaryPath);
const destination = fs.createWriteStream(binaryPath);
await response.pipeTo(
new WritableStream({
@@ -93,7 +91,13 @@ export async function startHeadscale(
await execa("chmod", ["+x", binaryPath]);
}
const config = createConfig(opts, { databasePath, cachePath, noisePrivateKey, derpPrivateKey, socketPath });
const config = createConfig(opts, {
databasePath,
cachePath,
noisePrivateKey,
derpPrivateKey,
socketPath,
});
fs.writeFileSync(configPath, config);
// Port and args
@@ -111,9 +115,11 @@ export async function startHeadscale(
stderr,
});
const close = () => Promise.resolve(service.cancel());
const close = () => Promise.resolve(service.kill());
onShutdown(() => close());
onShutdown(async () => {
close();
});
return {
service,

1809
yarn.lock

File diff suppressed because it is too large Load Diff