Skip to content

Commit af1e086

Browse files
ikreymertw4lemma-sg
authored
TypeScript Conversion (#425)
Follows #424. Converts the upcoming 1.0.0 branch based on native browser-based traffic capture and recording to TypeScript. Fixes #426 --------- Co-authored-by: Tessa Walsh <[email protected]> Co-authored-by: emma <[email protected]>
1 parent 877d9f5 commit af1e086

36 files changed

+2427
-1387
lines changed

.eslintrc.cjs

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,32 @@
11
module.exports = {
2-
"env": {
3-
"browser": true,
4-
"es2021": true,
5-
"node": true,
6-
"jest": true
7-
},
8-
"extends": "eslint:recommended",
9-
"parserOptions": {
10-
"ecmaVersion": 12,
11-
"sourceType": "module"
12-
},
13-
"rules": {
14-
"indent": [
15-
"error",
16-
2
17-
],
18-
"linebreak-style": [
19-
"error",
20-
"unix"
21-
],
22-
"quotes": [
23-
"error",
24-
"double"
25-
],
26-
"semi": [
27-
"error",
28-
"always"
29-
],
30-
"no-constant-condition": [
31-
"error",
32-
{"checkLoops": false }
33-
],
34-
"no-use-before-define": [
35-
"error",
36-
{"variables": true, "functions": false, "classes": false, "allowNamedExports": true}
37-
]
38-
}
2+
env: {
3+
browser: true,
4+
es2021: true,
5+
node: true,
6+
jest: true,
7+
},
8+
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
9+
parser: "@typescript-eslint/parser",
10+
plugins: ["@typescript-eslint"],
11+
parserOptions: {
12+
ecmaVersion: 12,
13+
sourceType: "module",
14+
},
15+
rules: {
16+
indent: ["error", 2],
17+
"linebreak-style": ["error", "unix"],
18+
quotes: ["error", "double"],
19+
semi: ["error", "always"],
20+
"no-constant-condition": ["error", { checkLoops: false }],
21+
"no-use-before-define": [
22+
"error",
23+
{
24+
variables: true,
25+
functions: false,
26+
classes: false,
27+
allowNamedExports: true,
28+
},
29+
],
30+
},
31+
reportUnusedDisableDirectives: true,
3932
};

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ jobs:
4040
node-version: ${{ matrix.node-version }}
4141
- name: install requirements
4242
run: yarn install
43+
- name: build js
44+
run: yarn run tsc
4345
- name: build docker
4446
run: docker-compose build
4547
- name: run jest

Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,18 @@ RUN mkdir -p /tmp/ads && cd /tmp/ads && \
3838

3939
RUN yarn install --network-timeout 1000000
4040

41-
ADD *.js /app/
42-
ADD util/*.js /app/util/
41+
ADD tsconfig.json /app/
42+
ADD src /app/src
43+
44+
RUN yarn run tsc
4345

4446
ADD config/ /app/
4547

4648
ADD html/ /app/html/
4749

48-
RUN ln -s /app/main.js /usr/bin/crawl; ln -s /app/create-login-profile.js /usr/bin/create-login-profile
50+
RUN chmod u+x /app/dist/main.js /app/dist/create-login-profile.js
51+
52+
RUN ln -s /app/dist/main.js /usr/bin/crawl; ln -s /app/dist/create-login-profile.js /usr/bin/create-login-profile
4953

5054
WORKDIR /crawls
5155

defaultDriver.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

package.json

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"author": "Ilya Kreymer <[email protected]>, Webrecorder Software",
88
"license": "AGPL-3.0-or-later",
99
"scripts": {
10-
"lint": "eslint *.js util/*.js tests/*.test.js",
10+
"tsc": "tsc",
11+
"lint": "eslint *.js tests/*.test.js",
1112
"test": "yarn node --experimental-vm-modules $(yarn bin jest --bail 1)",
1213
"prepare": "husky install"
1314
},
@@ -18,23 +19,31 @@
1819
"crc": "^4.3.2",
1920
"get-folder-size": "^4.0.0",
2021
"husky": "^8.0.3",
21-
"ioredis": "^4.27.1",
22+
"ioredis": "^5.3.2",
2223
"js-yaml": "^4.1.0",
23-
"minio": "7.0.26",
24+
"minio": "^7.1.3",
2425
"p-queue": "^7.3.4",
2526
"puppeteer-core": "^20.7.4",
2627
"sharp": "^0.32.1",
27-
"sitemapper": "^3.2.5",
28+
"sitemapper": "^3.2.6",
29+
"tsc": "^2.0.4",
2830
"uuid": "8.3.2",
29-
"warcio": "^2.2.0",
31+
"warcio": "^2.2.1",
3032
"ws": "^7.4.4",
3133
"yargs": "^17.7.2"
3234
},
3335
"devDependencies": {
34-
"eslint": "^8.37.0",
36+
"@types/js-yaml": "^4.0.8",
37+
"@types/node": "^20.8.7",
38+
"@types/uuid": "^9.0.6",
39+
"@types/ws": "^8.5.8",
40+
"@typescript-eslint/eslint-plugin": "^6.10.0",
41+
"@typescript-eslint/parser": "^6.10.0",
42+
"eslint": "^8.53.0",
3543
"eslint-plugin-react": "^7.22.0",
3644
"jest": "^29.2.1",
37-
"md5": "^2.3.0"
45+
"md5": "^2.3.0",
46+
"typescript": "^5.2.2"
3847
},
3948
"jest": {
4049
"transform": {},

0 commit comments

Comments
 (0)