Skip to content

Create a new generated npm workspace for typescript ANTLR generated code #1371

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ frontend/.postinstall
lib/gen/*/*/*.go
lib/gen/*/*/*.ts
lib/gen/featuresearch/**
lib/gen/antlrv4/ts-antlrv4/antlr/**

# Ignore coverage files
coverage
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a new target like: build-antlr-ts

It should call the npm run build command in the lib/gen/antlrv4/ts-antlrv4 directory.

We currently have one shot commands such as make start-local and make debug-local and make precommit and make playwright-test. It will be necessary to add this target as a pre-requisite target for those.

https://github.com/GoogleChrome/webstatus.dev/blob/401f3e814e1ce0d6eebbd73d77c2bafd3a3c3f1f/DEVELOPMENT.md

https://github.com/GoogleChrome/webstatus.dev/blob/401f3e814e1ce0d6eebbd73d77c2bafd3a3c3f1f/docs/testing.md

Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,17 @@ node-test: playwright-install
################################
# ANTLR
################################
antlr-gen: clean-antlr
antlr-gen: clean-antlr antlr-gen-go antlr-gen-ts

antlr-gen-go:
java -jar /usr/local/lib/antlr-$${ANTLR4_VERSION}-complete.jar -Dlanguage=Go -o lib/gen/featuresearch/parser -visitor -no-listener antlr/FeatureSearch.g4

antlr-gen-ts:
java -jar /usr/local/lib/antlr-$${ANTLR4_VERSION}-complete.jar -Dlanguage=TypeScript -o lib/gen/antlrv4/ts-antlrv4 -visitor antlr/FeatureSearch.g4

clean-antlr:
rm -rf lib/gen/featuresearch/parser
rm -rf lib/gen/antlrv4/ts-antlrv4/antlr

################################
# License
Expand Down
20 changes: 20 additions & 0 deletions lib/gen/antlrv4/ts-antlrv4/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@webstatus.dev/ts-antlrv4",
"version": "1.0.0",
"description": "TypeScript ANTLR4 generated code for webstatus.dev",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "Apache-2.0",
"scripts": {
"build": "tsc",
"clean": "rimraf dist"
Comment on lines +9 to +10
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"build": "tsc",
"clean": "rimraf dist"
"build": "tsc",
"clean": "rm -rf dist"

We should rely on the system rm command.

},
"dependencies": {
"antlr4": "^4.13.1"
},
"devDependencies": {
"@types/antlr4": "^4.9.3",
"typescript": "^5.0.0",
"rimraf": "^5.0.0"
Comment on lines +17 to +18
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove this

Suggested change
"typescript": "^5.0.0",
"rimraf": "^5.0.0"
"typescript": "^5.0.0"

}
}
20 changes: 20 additions & 0 deletions lib/gen/antlrv4/ts-antlrv4/tsconfig.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we should have a common tsconfig that both the frontend and this package extend

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "ES2020",
"moduleResolution": "node",
"declaration": true,
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": [
"antlr/**/*.ts"
],
"exclude": [
"node_modules",
"dist"
]
}
150 changes: 149 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"license": "Apache-2.0",
"workspaces": [
"frontend",
"lib/gen/openapi/ts-webstatus.dev-backend-types"
"lib/gen/openapi/ts-webstatus.dev-backend-types",
"lib/gen/antlrv4/ts-antlrv4"
],
"devDependencies": {
"@playwright/test": "^1.50.1",
Expand Down
Loading