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: 0 additions & 4 deletions .eslintrc.js

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
# Checkout to target branch
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -36,12 +36,12 @@ jobs:
runs-on: ubuntu-latest
steps:
# Checkout to target branch
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# Setup node environment
- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: 15
node-version-file: '.nvmrc'
registry-url: https://registry.npmjs.org/

# Bump version to the next prerelease (patch) with rc suffix
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/lint-and-build-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on:
push:
pull_request:

jobs:
lint-and-build:
name: Check lint and build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Generate version file
run: yarn prebuild
- name: Run linter
run: yarn lint:test
- name: Build project
run: yarn build

10 changes: 5 additions & 5 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 12
node-version-file: '.nvmrc'
registry-url: https://registry.npmjs.org/
- run: yarn
- run: yarn lint:test
- run: yarn prebuild
- run: yarn build
- run: yarn publish --access=public
env:
Expand All @@ -24,7 +24,7 @@ jobs:
needs: publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Get package info
id: package
uses: codex-team/action-nodejs-package-info@v1
Expand Down
2 changes: 2 additions & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
24

2 changes: 1 addition & 1 deletion create-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const cjsPackageJsonContent = {
};

/**
* MJS package.json content
* package.json content for the MJS bundle
*/
const mjsPackageJsonContent = {
type: 'module',
Expand Down
36 changes: 36 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import CodeX from 'eslint-config-codex';
import path from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

export default [
...CodeX,
{
files: ['eslint.config.mjs'],
rules: {
'n/no-unpublished-import': 'off',
},
},
{
files: ['src/**/*.ts', 'src/**/*.js', 'types/**/*.ts'],
languageOptions: {
parserOptions: {
project: path.resolve(__dirname, 'tsconfig.json'),
},
},
},
{
files: ['create-packages.js'],
languageOptions: {
globals: {
require: 'readonly',
},
sourceType: 'script',
},
},
{
ignores: ['dist/**', 'node_modules/**', 'playground/**', 'example/**'],
},
];
27 changes: 16 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
{
"name": "@hawk.so/nodejs",
"version": "3.1.6",
"version": "3.2.0",
"description": "Node.js catcher for Hawk",
"license": "AGPL-3.0-only",
"engines": {
"node": "24.x"
},
"main": "./dist/cjs/src/index.js",
"module": "dist/mjs/src/index.js",
"types": "./dist/mjs/src/index.d.ts",
"exports": {
".": {
"import": "./dist/mjs/src/index.js",
"require": "./dist/cjs/src/index.js"
"require": "./dist/cjs/src/index.js",
"types": "./dist/mjs/src/index.d.ts"
}
},
"scripts": {
"prebuild": "node -p \"'export const VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
"build": "yarn clean && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && node ./create-packages.js",
"build:watch": "yarn clean && tsc-watch",
"example": "node ./example/example.js",
"lint": "eslint -c ./.eslintrc.js src/ --ext .ts,.js --fix",
"lint:test": "eslint -c ./.eslintrc.js src/ --ext .ts,.js",
"lint": "eslint . --fix",
"lint:test": "eslint .",
"clean": "rimraf dist"
},
"dependencies": {
"@hawk.so/types": "^0.1.15",
"@hawk.so/types": "^0.3.0",
"axios": "^0.21.1",
"stack-trace": "^0.0.10"
},
"devDependencies": {
"@types/node": "^14.0.11",
"eslint": "6.7.2",
"eslint-config-codex": "^1.3.6",
"rimraf": "^3.0.2",
"tsc-watch": "^4.2.8",
"typescript": "^3.9.5"
"@types/node": "^24.0.0",
"eslint": "9.39.2",
"eslint-config-codex": "^2.0.3",
"rimraf": "^6.1.2",
"tsc-watch": "^7.2.0",
"typescript": "^5.9.3"
},
"repository": {
"type": "git",
Expand Down
5 changes: 5 additions & 0 deletions playground/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
dist/
*.log
.env

1 change: 1 addition & 0 deletions playground/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v24.11.1
43 changes: 43 additions & 0 deletions playground/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Hawk Playground

Simple Node.js + TypeScript playground app for testing `@hawk.so/nodejs`.

## Prerequisites

**Important**: The parent package (`@hawk.so/nodejs`) must be built before running the playground tests.

1. Build the parent package first:
```bash
cd ..
yarn install
yarn build
```

## Setup

1. Install dependencies:

```bash
cd playground
yarn install
```

## Running Tests

Run the test script that raises an exception and sends it to Hawk:

```bash
yarn test
```

The test script uses `ts-node` to run TypeScript directly without needing a build step.

## Configuration

You can set a custom Hawk integration token via environment variable:
```bash
HAWK_TOKEN=your_token_here yarn test
```

The default token is from the example configuration.

4 changes: 4 additions & 0 deletions playground/Untitled
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
No files matching the pattern "src/" were found.
Please check for typing mistakes in the pattern.

error Command failed with exit code 2.
23 changes: 23 additions & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "hawk-playground",
"version": "1.0.0",
"description": "Playground app for testing @hawk.so/nodejs",
"main": "dist/index.js",
"engines": {
"node": ">=24"
},
"scripts": {
"build": "tsc",
"test": "ts-node src/test.ts",
"test:dev": "ts-node src/test.ts"
},
"dependencies": {
"@hawk.so/nodejs": "file:../"
},
"devDependencies": {
"@types/node": "^20.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.3.0"
}
}

57 changes: 57 additions & 0 deletions playground/src/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Test script for @hawk.so/nodejs
* This script raises an exception and checks if it's sent to Hawk
*/
import HawkCatcher from '@hawk.so/nodejs';

/**
* Initialize Hawk catcher
* Replace with your actual integration token
*/
const HAWK_TOKEN = process.env.HAWK_TOKEN || 'eyJpbnRlZ3JhdGlvbklkIjoiNWIwZjBmYmUtNTM2OS00ODM0LWEwMjctNTZkMTM1YmU1OGU3Iiwic2VjcmV0IjoiYWY4ZjY1OTQtNzExOS00MWVmLWI4ZTAtMTcyMDYwZjBmODc2In0=';

console.log('Initializing Hawk Catcher...');
HawkCatcher.init(HAWK_TOKEN);
console.log('Hawk Catcher initialized successfully');

/**
* Test function that raises an exception
*/
function testException(): void {
console.log('\n--- Testing exception handling ---');

try {
/**
* Raise a test error
*/
throw new Error('Test exception from Hawk playground - this should be sent to Hawk');
} catch (error) {
/**
* TypeScript strict mode: error is of type 'unknown'
*/
if (error instanceof Error) {
console.log('Caught exception:', error.message);
console.log('Sending exception to Hawk...');

/**
* Send the exception to Hawk
*/
HawkCatcher.send(error, {
testContext: 'playground-test',
timestamp: new Date().toISOString()
});

console.log('Exception sent to Hawk (check your Hawk dashboard)');
} else {
console.error('Caught non-Error exception:', error);
}
}
}

/**
* Run the test
*/
console.log('\n=== Hawk Playground Test ===');
testException();
console.log('\n=== Test completed ===');

26 changes: 26 additions & 0 deletions playground/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": false,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"moduleResolution": "node",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"lib": ["es2020"]
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"dist"
]
}

Loading
Loading