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
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Validate Worker

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

jobs:
test-and-typecheck:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

- uses: actions/setup-node@v4
with:
node-version: 22

- name: Install dependencies
run: npm install

- name: Run tests
run: npm test

- name: Type-check Cloudflare Worker
run: npm run typecheck
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dev": "wrangler dev",
"tail": "wrangler tail",
"matrix-login": "tsx src/matrix-login.ts",
"typecheck": "tsc --noEmit",
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.node.json --noEmit",
"test": "tsx --test src/*.test.ts"
},
"keywords": [
Expand All @@ -22,6 +22,7 @@
"devDependencies": {
"@cloudflare/workers-types": "^4.0.0",
"@types/node": "^20.0.0",
"@types/prompts": "^2.4.9",
"prompts": "^2.4.2",
"tsx": "^4.0.0",
"typescript": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/filters.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from 'node:assert/strict';
import * as assert from 'node:assert/strict';
import test from 'node:test';
import {
evaluateImmediateFilter,
Expand Down
4 changes: 2 additions & 2 deletions src/matrix-login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// src/matrix-login.ts
// Script to login to Matrix and get a stable access token

import prompts from 'prompts';
import prompts, { type PromptObject } from 'prompts';

interface MatrixLoginResponse {
access_token: string;
Expand Down Expand Up @@ -31,7 +31,7 @@ async function main() {

try {
// Get user input using prompts library
const questions = [
const questions: PromptObject[] = [
{
type: 'text',
name: 'homeserver',
Expand Down
8 changes: 6 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
"target": "ES2021",
"module": "ES2022",
"lib": ["ES2021"],
"types": ["@cloudflare/workers-types", "node"],
"types": ["@cloudflare/workers-types"],
"moduleResolution": "node",
"noEmit": true,
"strict": true
}
},
"include": [
"src/index.ts",
"src/filters.ts"
Comment thread
Super-Genius marked this conversation as resolved.
]
}
16 changes: 16 additions & 0 deletions tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "ES2021",
"module": "ES2022",
"lib": ["ES2021"],
"types": ["node"],
"moduleResolution": "node",
"noEmit": true,
"strict": true,
"allowSyntheticDefaultImports": true
},
"include": [
"src/matrix-login.ts",
"src/**/*.test.ts"
]
}
Loading