Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,4 @@ jobs:
pnpm version ${{ inputs.upgrade }} --message "chore: release %s"
git push --follow-tags

- run: pnpm publish

- name: Build and create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |-
name=$(node -p "require('./package.json').name")
version=$(node -p "require('./package.json').version")
pnpm add --global pkg
pnpm build
pkg --out-path build dist/cjs/cli.js

gh release create "v$version" \
--title "Release v$version" \
--notes "Release v$version" \
"./build/$name-linux" \
"./build/$name-macos" \
"./build/$name-win.exe"
- run: pnpm publish --provenance
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ Usage notes:
- `--proxy <url>`: proxy all requests to the given http(s) URL (`PROXY_TARGET`)
- Specifying a port number prevents HTTP to HTTPS redirect.

### Standalone binaries

If you don't have Node.js installed just use a packaged version! Download it from the [release page](https://github.com/daquinoaldo/https-localhost/releases).

## Use as module

Install as a dependency:
Expand Down
10 changes: 1 addition & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,5 @@
"engines": {
"node": ">=24"
},
"packageManager": "pnpm@12.3.4",
"pkg": {
"scripts": "*.js",
"targets": [
"node16-macos-x64",
"node16-linux-x64",
"node16-win-x64"
]
}
"packageManager": "pnpm@12.3.4"
}
44 changes: 0 additions & 44 deletions src/certs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,6 @@ export type CertificatePair = {
cert: Buffer
}

function isRelease(v: unknown): v is { tag_name: string } {
return typeof v === "object" && v !== null && "tag_name" in v
}

function isVersioned(v: unknown): v is { version?: string } {
return typeof v === "object" && v !== null
}

function checkUpdates(): void {
try {
const options = {
host: "api.github.com",
path: "/repos/daquinoaldo/https-localhost/releases/latest",
method: "GET",
headers: { "User-Agent": "node.js" },
}
https
.request(options, res => {
let body = ""
res.on("data", (chunk: Buffer) => {
body += chunk.toString("utf8")
})
res.on("end", () => {
try {
const currentVersion: unknown = JSON.parse(
fs.readFileSync(path.resolve(__dirname, "../package.json"), "utf8"),
)
const latestVersion: unknown = JSON.parse(body)
if (!isRelease(latestVersion)) return
const current = isVersioned(currentVersion) ? (currentVersion.version ?? "") : ""
if (current !== latestVersion.tag_name.replace("v", "")) {
console.warn("[https-localhost] New update available.")
}
} catch {}
})
})
.end()
} catch {
// Just catch everything, this is not a critic part and can fail.
// It is important to not affect the script behavior.
}
}

function getExe(): string {
switch (process.platform) {
case "darwin":
Expand Down Expand Up @@ -164,7 +121,6 @@ export async function getCerts({
certPath?: string
reinstall?: boolean
} = {}): Promise<CertificatePair> {
if ((process as NodeJS.Process & { pkg?: boolean }).pkg === true) checkUpdates()
if (reinstall || !fs.existsSync(path.join(certPath, getExe())))
await generate({ appDataPath: certPath, domain })
try {
Expand Down
Loading