Skip to content

Commit 2478423

Browse files
STmihanFrayxRulez
andauthored
Add script for generating grammars.dat and setup CI (#2)
* Make script work in node.js. The function `generate()` now just returns the blob. * Log which language is loading right now * Add GitHub action script for build and publish grammars.dat as artifact * Add Create Pull Request workflow * Update README.md Co-authored-by: Fela Ameghino <[email protected]>
1 parent e686941 commit 2478423

File tree

7 files changed

+365
-1930
lines changed

7 files changed

+365
-1930
lines changed

Diff for: .github/workflows/build-grammars.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Update grammars
2+
3+
on: [ workflow_dispatch ]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
node-version: [18.x]
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-node@v3
14+
with:
15+
node-version: 18
16+
- run: npm install
17+
- run: npm start
18+
- name: Upload a Build Artifact
19+
uses: actions/[email protected]
20+
with:
21+
name: grammars.dat
22+
path: ./libprisma/grammars.dat
23+
- name: Create Pull Request
24+
uses: peter-evans/create-pull-request@v5
25+
with:
26+
commit-message: Update grammars
27+
title: Update grammars
28+
branch: update-grammars

Diff for: .gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ bld/
3535

3636
# Visual Studio 2015/2017 cache/options directory
3737
.vs/
38+
# Webstorm cache directory
39+
.idea/
3840
# Uncomment if you have tasks that create the project's static files in wwwroot
3941
#wwwroot/
4042

@@ -360,4 +362,4 @@ MigrationBackup/
360362
.ionide/
361363

362364
# Fody - auto-generated XML schema
363-
FodyWeavers.xsd
365+
FodyWeavers.xsd

Diff for: README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ for (auto it = tokens.begin(); it != tokens.end(); ++it)
2828
```
2929
3030
### How to update
31-
As mentioned, grammars dictionary is generated starting from prism.js source code.
32-
Currently, this is done manually by visiting prism's [test drive](https://prismjs.com/test.html).
33-
Once on the page, it is necessary to select all the languages, open the browser console and paste in both `isEqual.js` and `generate.js`.
34-
After a few seconds, the file `grammars.dat` will be downloaded.
35-
36-
TODO: would be great to automate this step, or at least to make the script auto-execute rather to require all the user input.
31+
Run
32+
```sh
33+
npm install
34+
npm start
35+
```
36+
The new version of `grammars.dat` will appear in the `libprisma/grammars.dat`.
3737

3838
### Supported languages
3939
| Language | Aliases |

0 commit comments

Comments
 (0)