Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Typescript #720

Merged
merged 57 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
8e9bb37
add tsconfig file
hawkrives May 8, 2024
0f5deb4
begin adding typescript stuff
hawkrives May 8, 2024
d9dccf8
tweak tsconfig
hawkrives May 8, 2024
0afc0da
ignore ts detritus
hawkrives May 8, 2024
0f90e96
add ts-eslint to eslint
hawkrives May 8, 2024
f3eebc0
migrate "presence" module to typescript
hawkrives May 8, 2024
1fde33a
fix noPropertyAccessFromIndexSignature + eslint conflict
hawkrives May 8, 2024
f652f6f
move ccc-lib/http to typescript
hawkrives May 8, 2024
1467144
migrate ccc-lib to ts
hawkrives May 8, 2024
3ba1378
migrating ccc-calendar to ts
hawkrives May 8, 2024
b5851da
fix no-unused-vars to only run the ts-eslint version
hawkrives May 8, 2024
0016f28
add local typedef for ical.js
hawkrives May 8, 2024
620b0a9
rename core server and institution modules to .ts
hawkrives May 8, 2024
b12cbfd
add typescript definitions for koa modules
hawkrives May 8, 2024
e5ec9d2
remove default-case override
hawkrives May 8, 2024
6377a74
reformat eslint.config.js
hawkrives May 8, 2024
9c26a5e
port ccc-server to ts
hawkrives May 8, 2024
853b474
add package.json script to invoke tsc
hawkrives May 8, 2024
8fe06c8
move to sentry 8-rc1 for better koa integration
hawkrives May 8, 2024
b8d86bf
migrate feeds to typescript
hawkrives May 8, 2024
2e9305e
migrate bonapp menus to typescript
hawkrives May 8, 2024
c4e8da1
use lodash-es
hawkrives May 8, 2024
1de9c9c
port carleton orgs to typescript
hawkrives May 8, 2024
87b9e96
change lodash types
hawkrives May 8, 2024
c5fdbf4
port News endpoints to ts
hawkrives May 11, 2024
53d8805
a few fixups to carleton's orgs endpoint
hawkrives May 11, 2024
36cc520
rename all remaining files to .ts
hawkrives May 11, 2024
a0103ea
begin updating dockerfile for tsc invocation
hawkrives May 11, 2024
9ac51e6
run tsc during ci
hawkrives May 11, 2024
06e2c63
Merge branch 'master' into hawken/tsc-on-js
hawkrives May 11, 2024
ff3780b
ignore the dist/ folder for eslint
hawkrives May 12, 2024
03826a7
switch to ava; add typed-query-selector; switch to printWidth=100
hawkrives May 12, 2024
1d8c25a
some reformatting
hawkrives May 12, 2024
50a4fa6
migrate remaining project files to typescript
hawkrives May 12, 2024
861898c
fix final run path in Dockerfile
hawkrives May 12, 2024
88c9107
add missing types folder to Dockerfile
hawkrives May 12, 2024
dafa334
build the project in CI, where appropriate
hawkrives May 12, 2024
936682a
remove .tsbuildinfo file when invoking `tsc` to ensure that it output…
hawkrives May 12, 2024
a635250
disallow JS files
hawkrives May 12, 2024
623ff89
avoid building twice during smoke tests
hawkrives May 12, 2024
6b4e64c
convert RSS timestamps to ISO
hawkrives May 12, 2024
a8be84a
fix deprecatedWpJson function
hawkrives May 12, 2024
36cc58a
fixes for wpjson feeds
hawkrives May 12, 2024
b5cd468
set default streams sort back to ascending
hawkrives May 12, 2024
a54f123
update Broadcast Media zod type
hawkrives May 12, 2024
8949963
Merge branch 'master' into hawken/tsc-on-js
hawkrives May 20, 2024
dc13fd8
migrate bonapp reports to typescript
hawkrives May 20, 2024
3602d79
switch stav mealtime report to gh pages
drewvolz May 23, 2024
105dbaa
fix zod validation of presence org results
drewvolz May 25, 2024
3191200
parse using nullish coaelescer per linter ask
drewvolz May 25, 2024
a0648ea
prettier changes
drewvolz May 25, 2024
169247f
fix event responses from google calendar
hawkrives May 25, 2024
0aad528
put back dotenv loading
hawkrives May 25, 2024
30c810e
allow offsets in datetimes
hawkrives May 25, 2024
82d8097
handle signals for build and watch scripts
drewvolz May 25, 2024
8581fac
formatting
drewvolz May 25, 2024
76385d1
Merge pull request #748 from frog-pond/drew/build-watch-script
hawkrives May 25, 2024
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: 19 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ on:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
node-version: [ 22.x ]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build

test:
runs-on: ubuntu-latest
strategy:
Expand All @@ -24,6 +40,7 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build
- run: npm test

smoke-test-stolaf:
Expand All @@ -40,6 +57,7 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build
- run: npm run test-stolaf-college

smoke-test-carleton:
Expand All @@ -56,6 +74,7 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build
- run: npm run test-carleton-college

lint:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@
# Logs
*.log
npm-debug.log*

# Typescript
/.tsbuildinfo
/dist/
32 changes: 24 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
FROM node:22-alpine
FROM node:22-alpine AS modules_dev
WORKDIR /app

RUN apk add -U curl
COPY --link ./package.json ./package-lock.json ./
RUN npm ci

WORKDIR /app
COPY ./package.json ./package-lock.json ./

FROM modules_dev AS modules
RUN npm ci --omit=dev

HEALTHCHECK --interval=20s --timeout=1s \
CMD curl -f http://localhost:80/ping

COPY ./source ./source
FROM modules_dev AS build
COPY --link tsconfig.json .
COPY --link ./source ./source
COPY --link ./types ./types
RUN npm run build


FROM node:22-alpine AS runtime
WORKDIR /app

RUN apk add -U curl

COPY --link ./package.json ./package-lock.json ./
COPY --link --from=modules /app/node_modules ./node_modules
COPY --link --from=build /app/dist ./dist

ENV NODE_ENV=production
ENV NODE_PORT=80
ENV INSTITUTION=unknown

CMD node -r dotenv/config ./source/ccc-server/index.js
HEALTHCHECK --interval=20s --timeout=1s \
CMD curl -f http://localhost:80/ping

CMD node ./dist/source/ccc-server/index.js
27 changes: 21 additions & 6 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,29 @@ import js from '@eslint/js'
import globals from 'globals'

import prettier from 'eslint-config-prettier'
import ts from 'typescript-eslint'

/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */
export default [
js.configs.recommended,
...ts.configs.strictTypeChecked,
...ts.configs.stylisticTypeChecked,
prettier,
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {...globals.node},
parserOptions: {
project: true,
tsconfigRoot: import.meta.dirname,
},
},
rules: {
'array-callback-return': 'error',
camelcase: ['warn', {properties: 'never', ignoreDestructuring: true}],
'consistent-this': ['error', 'self'],
curly: ['warn', 'multi-line'],
'default-case': 'error',
'guard-for-in': 'error',
eqeqeq: ['error', 'always', {null: 'ignore'}],
'linebreak-style': ['error', 'unix'],
Expand All @@ -29,10 +36,7 @@ export default [
'no-div-regex': 'error',
'no-eq-null': 'warn',
'no-extra-label': 'error',
'no-implicit-coercion': [
'error',
{boolean: true, number: true, string: true},
],
'no-implicit-coercion': ['error', {boolean: true, number: true, string: true}],
'no-implicit-globals': 'error',
'no-multi-assign': 'error',
'no-new-symbol': 'error',
Expand All @@ -42,14 +46,25 @@ export default [
'no-undef-init': 'off',
'no-underscore-dangle': 'off',
'no-unmodified-loop-condition': 'error',
'no-unused-vars': ['warn', {args: 'after-used', argsIgnorePattern: '^_'}],
'@typescript-eslint/no-unused-vars': ['warn', {args: 'after-used', argsIgnorePattern: '^_'}],
'no-useless-constructor': 'error',
'no-var': 'error',
'prefer-const': 'off',
'prefer-promise-reject-errors': 'error',
'prefer-spread': 'error',
quotes: ['warn', 'single', 'avoid-escape'],
'require-await': 'warn',
semi: 'off',

// conflicts with the noPropertyAccessFromIndexSignature tsconfig rule
'@typescript-eslint/dot-notation': ['error', {allowIndexSignaturePropertyAccess: true}],
},
},
{
files: ['**/*.js'],
...ts.configs.disableTypeChecked,
},
{
ignores: ['dist/*'],
},
]
Loading