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
4 changes: 2 additions & 2 deletions .github/workflows/package-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: Package Validity

on:
push:
branches: ["master"]
branches: ["master", "latest-release", "beta"]
paths:
- "packages/**"
- ".github/workflows/package-ci.yml"
pull_request:
branches: ["master"]
branches: ["master", "latest-release", "beta"]
paths:
- "packages/**"
- ".github/workflows/package-ci.yml"
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Package Release

on:
push:
branches:
- latest-release
- beta

permissions:
contents: write
issues: write
pull-requests: write

jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
builder_changed: ${{ steps.filter.outputs.builder }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for changeset detection

- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
builder:
- 'packages/builder/**'
# Add more packages here as repo grows
# package2:
# - 'packages/package2/**'

release-builder:
needs: detect-changes
if: needs.detect-changes.outputs.builder_changed == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/builder
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Important for semantic release to work correctly

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: "10.8.1"
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build package
run: pnpm build

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm semantic-release

# Add more jobs for additional packages as repo grows
# release-package2:
# needs: detect-changes
# if: needs.detect-changes.outputs.package2_changed == 'true'
# ... (similar setup to release-builder)
118 changes: 0 additions & 118 deletions packages/builder/lib/commandLine/keys.js

This file was deleted.

74 changes: 74 additions & 0 deletions packages/builder/lib/commandLine/keys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env node
import { getPublicKeyFromJwk } from '../utils.js';

let webcrypto: Crypto;
try {
const nodeCrypto = await import('node:crypto');
webcrypto = nodeCrypto.webcrypto as Crypto;
} catch {
console.error('Error: This command requires Node.js environment.');
console.error("Please ensure you're running Node.js 16.0.0 or later.");
process.exit(1);
}

async function generateVapidKeys(): Promise<void> {
try {
console.log('Generating VAPID keys...');

const keypair = await webcrypto.subtle.generateKey(
{ name: 'ECDSA', namedCurve: 'P-256' },
true,
['sign', 'verify'],
);

const privateJWK = await webcrypto.subtle.exportKey(
'jwk',
keypair.privateKey,
);
const privateJWKWithAlg = { alg: 'ES256', ...privateJWK };
const publicKey = getPublicKeyFromJwk(privateJWKWithAlg);

// Display in a nice formatted output
const resultText = `
VAPID Keys Generated Successfully

Public Key:
${publicKey}

Private Key (JWK):
${JSON.stringify(privateJWKWithAlg, null, 2)}

Store these keys securely. Never expose your private key.
`;

console.log(resultText);
} catch (error: unknown) {
console.error('Error generating VAPID keys:');
if (error instanceof Error) {
console.error(error.message);
} else {
console.error('An unknown error occurred.');
}
console.error(
'\nThis tool requires Node.js v16.0.0 or later with WebCrypto API support.',
);
process.exit(1);
}
}

// Simple command parsing
const args = process.argv.slice(2);
const command = args[0];

if (command === 'generate-vapid-keys') {
generateVapidKeys();
} else {
console.log(`
PushForge CLI Tools

Usage:
npx @pushforge/builder generate-vapid-keys Generate VAPID key pair for Web Push Authentication

For more information, visit: https://github.com/draphy/pushforge
`);
}
19 changes: 14 additions & 5 deletions packages/builder/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@pushforge/builder",
"version": "0.1.0",
"version": "0.0.0-development",
"description": "A robust, cross-platform Web Push notification library that handles VAPID authentication and payload encryption following the Web Push Protocol standard. Works in Node.js 16+, Browsers, Deno, Bun and Cloudflare Workers.",
"private": false,
"main": "lib/main.ts",
"main": "dist/lib/main.js",
"module": "dist/lib/main.js",
"types": "dist/lib/main.d.ts",
"author": "David Raphi",
Expand All @@ -23,17 +23,26 @@
"default": "./dist/lib/main.js"
}
},
"files": ["dist/lib/**/*.js", "dist/lib/**/*.d.ts"],
"files": ["dist/lib/**/*.js", "dist/lib/**/*.d.ts", "README.md", "LICENSE"],
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "tsc --build",
"test": "vitest run",
"test:watch": "vitest"
"test:watch": "vitest",
"semantic-release": "semantic-release"
},
"bin": {
"generate-vapid-keys": "./lib/commandLine/keys.js"
"generate-vapid-keys": "./dist/lib/commandLine/keys.js"
},
"devDependencies": {
"@semantic-release/commit-analyzer": "^11.1.0",
"@semantic-release/github": "^9.2.6",
"@semantic-release/npm": "^11.0.3",
"@semantic-release/release-notes-generator": "^12.1.0",
"@types/node": "^22.14.1",
"semantic-release": "^24.2.3",
"vitest": "^3.1.2"
},
"keywords": [
Expand Down
18 changes: 18 additions & 0 deletions packages/builder/release.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
branches: ['latest-release', { name: 'beta', prerelease: true }],
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
'@semantic-release/npm',
[
'@semantic-release/github',
{
assets: [
{ path: 'dist/**/*.js', label: 'JS distribution' },
{ path: 'dist/**/*.d.ts', label: 'TypeScript declarations' },
],
},
],
],
tagFormat: 'builder@${version}',
};
Loading