Skip to content

Commit 264f05c

Browse files
authored
Bump NodeJS to version 20 (#1513)
* Create .node-version file * Fix `gl` build error via dependency resolution Also bumps the version of `node-gyp` transitive dependency to address a security vulnerability. * Bump `gpu.js`, `gl` dependencies in ./sicp_publish * Update CI workflows Bumps dependency versions, as well as remove manual caching. * Fix workflow errors due to missing libraries * Bump NodeJS to v20.11.0 * Update README * Update Node version * Remove duplicate header * Change H1s to H2s for better hierarchy * Reformat README * Remove soft breaks * Add syntax highlighting for commands * Fix license line break
1 parent 9b48944 commit 264f05c

File tree

9 files changed

+660
-829
lines changed

9 files changed

+660
-829
lines changed

.github/workflows/deploy-docs.yml

+7-14
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,20 @@ jobs:
77
deploy:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@master
10+
- name: Checkout repository
11+
uses: actions/checkout@v4
1112
- name: Use Node.js
12-
uses: actions/setup-node@v2-beta
13+
uses: actions/setup-node@v4
1314
with:
14-
node-version: '16'
15+
node-version: 20
16+
cache: yarn
1517
- name: Install TeX Live
1618
run: |
1719
sudo apt-get update -y
1820
sudo apt-get install -y texlive texlive-fonts-extra texlive-lang-cjk latexmk
19-
- name: Get yarn cache directory path
20-
id: yarn-cache-dir-path
21-
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
22-
- uses: actions/cache@v2
23-
id: yarn-cache
24-
with:
25-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
26-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
27-
restore-keys: |
28-
${{ runner.os }}-yarn-
21+
sudo apt-get install -y --no-install-recommends libxi-dev libgl1-mesa-dev
2922
- name: Fetch Yarn dependencies
30-
run: yarn install
23+
run: yarn install --frozen-lockfile
3124
- name: Build
3225
run: |
3326
yarn run jsdoc prepare

.github/workflows/nodejs.yml

+16-17
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,36 @@ name: Node.js CI
55

66
on:
77
push:
8-
branches: [ master ]
8+
branches:
9+
- master
910
pull_request:
10-
branches: [ master ]
11+
branches:
12+
- master
1113

1214
jobs:
1315
build:
14-
1516
runs-on: ubuntu-latest
16-
17-
strategy:
18-
matrix:
19-
node-version: [16.x]
20-
2117
steps:
22-
- uses: actions/checkout@v2
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
submodules: recursive
2322
- name: Check for package-lock.json
2423
run: |
2524
if [ -e package-lock.json ]; then
2625
echo "package-lock.json found; please do not use NPM! This project uses Yarn!"
2726
exit 1
2827
fi
2928
exit 0
30-
- name: Checkout code
31-
uses: actions/checkout@v2
32-
with:
33-
submodules: recursive
34-
- name: Use Node.js ${{ matrix.node-version }}
35-
uses: actions/setup-node@v1
29+
- name: Install dependencies (apt)
30+
run: |
31+
sudo apt-get install -y --no-install-recommends libxi-dev libgl1-mesa-dev
32+
- name: Setup Node
33+
uses: actions/setup-node@v4
3634
with:
37-
node-version: ${{ matrix.node-version }}
38-
- run: yarn
35+
node-version: 20
36+
cache: yarn
37+
- run: yarn install --frozen-lockfile
3938
- run: yarn build
4039
- run: yarn format:ci
4140
- run: yarn eslint

.github/workflows/publish-npm.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout repository
14-
uses: actions/checkout@v2
14+
uses: actions/checkout@v4
1515
with:
1616
ref: master
1717
submodules: recursive
@@ -33,14 +33,17 @@ jobs:
3333
runs-on: ubuntu-latest
3434
steps:
3535
- name: Checkout repository
36-
uses: actions/checkout@v2
36+
uses: actions/checkout@v4
3737
with:
3838
ref: master
3939
submodules: recursive
40+
- name: Install dependencies (apt)
41+
run: |
42+
sudo apt-get install -y --no-install-recommends libxi-dev libgl1-mesa-dev
4043
- name: Setup Node.js
41-
uses: actions/setup-node@v1
44+
uses: actions/setup-node@v4
4245
with:
43-
node-version: 16
46+
node-version: 20
4447
- name: Install dependencies
4548
run: yarn install --frozen-lockfile
4649
- name: Publish to npm

.node-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.11.0

README.md

+44-85
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
# js-slang
22

3-
Open-source implementations of the programming language _Source_. Source is a
4-
series of small subsets of JavaScript, designed for teaching university-level
5-
programming courses for computer science majors, following Structure and
6-
Interpretation of Computer Programs, JavaScript Adaptation
7-
(<https://sourceacademy.org/sicpjs/>).
3+
Open-source implementations of the programming language _Source_. Source is a series of small subsets of JavaScript, designed for teaching university-level programming courses for computer science majors, following Structure and Interpretation of Computer Programs, JavaScript Adaptation (<https://sourceacademy.org/sicpjs/>).
84

9-
# Table of Contents
5+
## Table of Contents
106

11-
- [Requirements](#requirements)
7+
- [Prerequisites](#prerequisites)
128
- [Usage](#usage)
139
- [Documentation](#documentation)
14-
- [Requirements](#requirements-1)
10+
- [Requirements](#requirements)
1511
- [Testing](#testing)
1612
- [Error messages](#error-messages)
1713
- [Using your js-slang in Source Academy](#using-your-js-slang-in-source-academy)
@@ -20,18 +16,16 @@ Interpretation of Computer Programs, JavaScript Adaptation
2016
- [Talks and Presentations](#talks-and-presentations)
2117
- [License](#license)
2218

23-
# Requirements
19+
## Prerequisites
2420

25-
- node: known working version: v16.14.0
21+
- NodeJS v20
22+
- Python: On MacBook Pro with chip Apple M1 Pro, use python 3.10.12. Here is [the correct way to set Python 3 as default on a Mac](https://opensource.com/article/19/5/python-3-default-mac).
2623

27-
- python: On MacBook Pro with chip Apple M1 Pro, use python 3.10.12. Here is
28-
[the correct way to set Python 3 as default on a Mac](https://opensource.com/article/19/5/python-3-default-mac).
29-
30-
# Usage
24+
## Usage
3125

3226
To build,
3327

34-
```{.}
28+
```bash
3529
$ git clone --recurse-submodules https://github.com/source-academy/js-slang.git
3630
$ cd js-slang
3731
$ yarn
@@ -40,27 +34,25 @@ $ yarn build
4034

4135
This repository uses git submodules. To update existing repositories with a submodule,
4236

43-
```{.}
37+
```bash
4438
# Init is only required on the very first time.
4539
$ git submodule update --init --recursive
4640
# Required subsequently every time you want to update the submodules.
4741
$ git submodule update --recursive --remote
4842
```
4943

50-
To add \"js-slang\" to your PATH, build it as per the above instructions, then
51-
run
44+
To add \"js-slang\" to your PATH, build it as per the above instructions, then run
5245

53-
```{.}
46+
```bash
5447
$ cd dist
5548
$ npm link
5649
```
5750

58-
If you do not wish to add \"js-slang\" to your PATH, replace \"js-slang\" with
59-
\"node dist/repl/repl.js\" in the following examples.
51+
If you do not wish to add \"js-slang\" to your PATH, replace \"js-slang\" with \"node dist/repl/repl.js\" in the following examples.
6052

6153
To try out _Source_ in a REPL, run
6254

63-
```{.}
55+
```bash
6456
$ js-slang -c [chapter] # default: 1
6557
```
6658

@@ -99,15 +91,15 @@ Currently, valid CHAPTER/VARIANT combinations are:
9991

10092
Hint: In `bash` you can take the `PROGRAM_STRING` out of a file as follows:
10193

102-
```{.}
94+
```bash
10395
$ js-slang -n --chapter=1 -e "$(< my_source_program.js)"
10496
```
10597

106-
# Documentation
98+
## Documentation
10799

108100
Source is documented here: <https://docs.sourceacademy.org/>
109101

110-
# Requirements
102+
### Requirements
111103

112104
- `bash`: known working version: GNU bash, version 5.0.16
113105
- `latexmk`: Version 4.52c
@@ -116,7 +108,7 @@ Source is documented here: <https://docs.sourceacademy.org/>
116108

117109
To build the documentation, run
118110

119-
```{.}
111+
```bash
120112
$ git clone https://github.com/source-academy/js-slang.git
121113
$ cd js-slang
122114
$ yarn
@@ -126,117 +118,84 @@ $ cd docs/specs
126118
$ make # to make the PDF documents using LaTeX
127119
```
128120

129-
Note: The documentation may not build on Windows, depending on your bash setup,
130-
[see above](https://github.com/source-academy/js-slang#requirements).
121+
**Note:** The documentation may not build on Windows, depending on your bash setup, [see above](https://github.com/source-academy/js-slang#requirements).
131122

132-
Documentation on the Source libraries are generated from inline documentation in
133-
the library sources, a copy of which are kept in `docs/lib/*.js`. The command
134-
`yarn jsdoc` generates the documentation and places it in the folder
135-
`docs/source`. You can test the documentation using a local server:
123+
Documentation on the Source libraries are generated from inline documentation in the library sources, a copy of which are kept in `docs/lib/*.js`. The command `yarn jsdoc` generates the documentation and places it in the folder `docs/source`. You can test the documentation using a local server:
136124

137-
```{.}
125+
```bash
138126
$ cd docs/source; python -m http.server 8000
139127
```
140128

141-
Documentation of libraries is displayed in autocomplete in the frontend. This
142-
documentation is generated by `./scripts/updateAutocompleteDocs.py` and placed
143-
in `src/editors/ace/docTooltip/*.json` files. This script is run by
144-
`yarn build`prior to`tsc`. To add a Source variant to the frontend autocomplete,
145-
edit `src/editors/ace/docTooltip/index.ts`
146-
and`./scripts/updateAutocompleteDocs.py`.
129+
Documentation of libraries is displayed in autocomplete in the frontend. This documentation is generated by `./scripts/updateAutocompleteDocs.py` and placed in `src/editors/ace/docTooltip/*.json` files. This script is run by `yarn build`prior to`tsc`. To add a Source variant to the frontend autocomplete, edit `src/editors/ace/docTooltip/index.ts` and`./scripts/updateAutocompleteDocs.py`.
147130

148-
# Testing
131+
## Testing
149132

150-
`js-slang` comes with an extensive test suite. To run the tests after you made
151-
your modifications, run `yarn test`. Regression tests are run automatically when
152-
you want to push changes to this repository. The regression tests are generated
153-
using `jest` and stored as snapshots in `src/\_\_tests\_\_`. After modifying
154-
`js-slang`, carefully inspect any failing regression tests reported in red in
155-
the command line. If you are convinced that the regression tests and not your
156-
changes are at fault, you can update the regression tests as follows:
133+
`js-slang` comes with an extensive test suite. To run the tests after you made your modifications, run `yarn test`. Regression tests are run automatically when you want to push changes to this repository. The regression tests are generated using `jest` and stored as snapshots in `src/\_\_tests\_\_`. After modifying `js-slang`, carefully inspect any failing regression tests reported in red in the command line. If you are convinced that the regression tests and not your changes are at fault, you can update the regression tests as follows:
157134

158-
```{.}
135+
```bash
159136
$ yarn test -- --updateSnapshot
160137
```
161138

162-
# Error messages
139+
## Error messages
163140

164-
To enable verbose messages, have the statement `"enable verbose";` as the first
165-
line of your program. This also causes the program to be run by the interpreter.
141+
To enable verbose messages, have the statement `"enable verbose";` as the first line of your program. This also causes the program to be run by the interpreter.
166142

167-
There are two main kinds of error messages: those that occur at runtime and
168-
those that occur at parse time. The first can be found in
169-
`interpreter-errors.ts`, while the second can be found in `rules/`.
143+
There are two main kinds of error messages: those that occur at runtime and those that occur at parse time. The first can be found in `interpreter-errors.ts`, while the second can be found in `rules/`.
170144

171-
Each error subclass will have `explain()` and `elaborate()`. Displaying the
172-
error will always cause the first to be called; the second is only called when
173-
verbose mode is enabled. As such, `explain()` should be made to return a string
174-
containing the most basic information about what the error entails. Any
175-
additional details about the error message, including specifics and correction
176-
guides, should be left to `elaborate()`.
145+
Each error subclass will have `explain()` and `elaborate()`. Displaying the error will always cause the first to be called; the second is only called when verbose mode is enabled. As such, `explain()` should be made to return a string containing the most basic information about what the error entails. Any additional details about the error message, including specifics and correction guides, should be left to `elaborate()`.
177146

178-
Please remember to write test cases to reflect your added functionalities. The
179-
god of this repository is self-professed to be very particular about test cases.
147+
Please remember to write test cases to reflect your added functionalities. The god of this repository is self-professed to be very particular about test cases.
180148

181-
# Using your js-slang in Source Academy
149+
## Using your js-slang in Source Academy
182150

183-
js-slang is used by the [Source Academy](https://sourceacademy.org), the
184-
immersive online experiential environment for learning programming. For this,
185-
js-slang is
186-
[deployed as an NPM package](https://www.npmjs.com/package/js-slang). The
187-
frontend of the Source Academy then includes the js-slang package in its
188-
deployment bundle.
151+
js-slang is used by the [Source Academy](https://sourceacademy.org), the immersive online experiential environment for learning programming. For this, js-slang is [deployed as an NPM package](https://www.npmjs.com/package/js-slang). The frontend of the Source Academy then includes the js-slang package in its deployment bundle.
189152

190-
# Using your js-slang in your local Source Academy
153+
## Using your js-slang in your local Source Academy
191154

192-
A common issue when developing modifications to js-slang is how to test it using
193-
your own local frontend. Assume that you have built your own frontend locally,
194-
here is how you can make it use your own js-slang, instead of the one that the
195-
Source Academy team has deployed to npm.
155+
A common issue when developing modifications to js-slang is how to test it using your own local frontend. Assume that you have built your own frontend locally, here is how you can make it use your own js-slang, instead of the one that the Source Academy team has deployed to npm.
196156

197157
First, build and link your local js-slang:
198158

199-
```{.}
159+
```bash
200160
$ cd js-slang
201161
$ yarn build
202162
$ yarn link
203163
```
204164

205165
Then, from your local copy of frontend:
206166

207-
```{.}
167+
```bash
208168
$ cd frontend
209169
$ yarn link "js-slang"
210170
```
211171

212172
Then start the frontend and the new js-slang will be used.
213173

214-
# Building and publishing SICP package
174+
## Building and publishing SICP package
215175

216176
To build SICP package
217177

218-
```{.}
178+
```bash
219179
$ cd js-slang
220180
$ yarn
221181
$ yarn build_sicp_package
222182
```
223183

224184
To publish SICP package, update version number in `sicp_publish/package.json`
225185

226-
```{.}
186+
```bash
227187
$ cd js-slang/sicp_publish
228188
$ npm publish
229189
```
230190

231-
# Talks and Presentations
191+
## Talks and Presentations
232192

233-
- **How `js-slang` works under the hood** [17th Jan 2023][The
234-
Gathering][[slides](https://docs.google.com/presentation/d/1GFR39iznBZxWv948zUsmcbCSSDasm4xYs3Jc5GF7A3I/edit?usp=sharing)]
193+
- **How `js-slang` works under the hood** (17th Jan 2023 – The Gathering) ([slides](https://docs.google.com/presentation/d/1GFR39iznBZxWv948zUsmcbCSSDasm4xYs3Jc5GF7A3I/edit?usp=sharing))
235194

236-
# License
195+
## License
237196

238197
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
239-
All sources in this repository are licensed under the
240-
[Apache License Version 2][apache2].
198+
199+
All sources in this repository are licensed under the [Apache License Version 2][apache2].
241200

242201
[apache2]: https://www.apache.org/licenses/LICENSE-2.0.txt

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
"source-map": "0.7.3",
4848
"xmlhttprequest-ts": "^1.0.1"
4949
},
50+
"resolutions": {
51+
"**/gl": "^6.0.2"
52+
},
5053
"scripts": {
5154
"build": "yarn docs && tsc --build --force",
5255
"build:slang": "tsc --build --force",

sicp_publish/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020
"acorn-loose": "^8.0.0",
2121
"acorn-walk": "^8.0.0",
2222
"astring": "^1.4.3",
23-
"gpu.js": "^2.10.4",
23+
"gpu.js": "^2.16.0",
2424
"lodash": "^4.17.20",
2525
"source-map": "^0.7.3",
2626
"xmlhttprequest-ts": "^1.0.1"
2727
},
28+
"resolutions": {
29+
"**/gl": "^6.0.2"
30+
},
2831
"main": "dist/sicp",
2932
"types": "dist/sicp",
3033
"files": [

0 commit comments

Comments
 (0)