Skip to content

Commit

Permalink
Revert "Update Repository to Node 20" (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
RichDom2185 authored Jan 27, 2024
1 parent f2ccd5e commit 32242aa
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 198 deletions.
21 changes: 4 additions & 17 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v4

- name: Check for package-lock.json
run: |
if [ -e package-lock.json ]; then
echo "package-lock.json found; please do not use NPM! This project uses Yarn!"
exit 1
fi
exit 0
- name: Install dependencies (apt)
run: |
sudo apt-get install -y --no-install-recommends libxi-dev libgl1-mesa-dev
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v4
- name: Use Node.js 💻
uses: actions/setup-node@v1
with:
node-version: 20
cache: yarn
node-version: '16.x'

- name: Install dependencies
run: yarn install --frozen-lockfile
Expand Down
273 changes: 136 additions & 137 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,137 +1,136 @@
{
"private": true,
"name": "modules",
"version": "1.0.0",
"repository": "https://github.com/source-academy/modules.git",
"license": "Apache-2.0",
"scripts-info": {
"//NOTE": "Run `npm i npm-scripts-info -g` to install once globally, then run `npm-scripts-info` as needed to list these descriptions",
"create": "Interactively initialise a new bundle or tab from their templates",
"devserver": "Start the tab development server",
"devserver:lint": "Lint code related to the dev server",
"devserver:tsc": "Run tsc over dev server code",
"docs": "Build only documentation",
"lint": "Lint bundle and tab code",
"build": "Lint code, then build modules and documentation",
"build:help": "Show help for the build scripts",
"serve": "Start the HTTP server to serve all files in `build/`, with the same directory structure",
"scripts": "Run a script within the scripts directory",
"scripts:build": "Compile build scripts",
"scripts:lint": "Lint build script code",
"prepare": "Enable git hooks",
"test": "Run unit tests",
"test:watch": "Watch files for changes and rerun tests related to changed files",
"dev": "Build bundles and tabs only, then serve. Skips linting / type checking, does not build jsons and HTML docs. For rapid testing during development",
"watch": "Watch files for changes and rebuild on those changes",
"postinstall": "Install all patches to node_modules packages"
},
"type": "module",
"scripts": {
"build": "yarn scripts build",
"build:help": "yarn scripts build --help",
"create": "yarn scripts create",
"dev": "yarn scripts build modules && yarn serve",
"docs": "yarn scripts build docs",
"lint": "yarn scripts lint",
"prepare": "husky install",
"postinstall": "patch-package && yarn scripts:build",
"scripts": "node --max-old-space-size=4096 scripts/bin.js",
"serve": "http-server --cors=* -c-1 -p 8022 ./build",
"test": "yarn scripts test",
"test:all": "yarn test && yarn scripts:test",
"test:watch": "yarn scripts test --watch",
"watch": "yarn scripts watch",
"devserver": "vite",
"devserver:lint": "yarn scripts devserver lint",
"devserver:tsc": "tsc --project devserver/tsconfig.json",
"scripts:all": "node scripts/scripts_manager.js",
"scripts:build": "node scripts/scripts_manager.js build",
"scripts:lint": "node scripts/scripts_manager.js lint",
"scripts:tsc": "tsc --project scripts/src/tsconfig.json",
"scripts:test": "node scripts/scripts_manager.js test"
},
"devDependencies": {
"@types/dom-mediacapture-record": "^1.0.11",
"@types/eslint": "^8.4.10",
"@types/estree": "^1.0.0",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.198",
"@types/node": "^20.8.9",
"@types/plotly.js-dist": "npm:@types/plotly.js",
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"@vitejs/plugin-react": "^4.0.4",
"acorn": "^8.8.1",
"acorn-jsx": "^5.3.2",
"astring": "^1.8.4",
"chalk": "^5.0.1",
"commander": "^9.4.0",
"console-table-printer": "^2.11.1",
"cross-env": "^7.0.3",
"esbuild": "^0.18.20",
"eslint": "^8.21.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-import-resolver-typescript": "^2.7.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.8.1",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.4.0",
"eslint-plugin-simple-import-sort": "^8.0.0",
"http-server": "^0.12.3",
"husky": "5",
"jest": "^29.4.1",
"jest-environment-jsdom": "^29.4.1",
"re-resizable": "^6.9.11",
"react-hotkeys": "^2.0.0",
"react-responsive": "^9.0.2",
"sass": "^1.66.1",
"ts-jest": "^29.1.1",
"typedoc": "^0.25.1",
"typescript": "5.0",
"vite": "^4.5.2",
"yarnhook": "^0.5.1"
},
"dependencies": {
"@blueprintjs/core": "^4.20.2",
"@blueprintjs/icons": "^4.4.0",
"@blueprintjs/popover2": "^1.4.3",
"@box2d/core": "^0.10.0",
"@box2d/debug-draw": "^0.10.0",
"@jscad/modeling": "2.9.6",
"@jscad/regl-renderer": "^2.6.1",
"@jscad/stl-serializer": "^2.1.13",
"ace-builds": "^1.25.1",
"classnames": "^2.3.1",
"dayjs": "^1.10.4",
"gl-matrix": "^3.3.0",
"js-slang": "^1.0.20",
"lodash": "^4.17.21",
"patch-package": "^6.5.1",
"phaser": "^3.54.0",
"plotly.js-dist": "^2.17.1",
"postinstall-postinstall": "^2.1.0",
"react": "^18.2.0",
"react-ace": "^10.1.0",
"react-dom": "^18.2.0",
"regl": "^2.1.0",
"save-file": "^2.3.1",
"source-academy-utils": "^1.0.0",
"source-academy-wabt": "^1.0.4",
"tslib": "^2.3.1"
},
"jest": {
"projects": [
"src/jest.config.js",
"scripts/src/jest.config.js"
]
},
"resolutions": {
"@types/react": "^18.2.0",
"esbuild": "^0.18.20",
"**/gl": "^6.0.2"
}
}
{
"private": true,
"name": "modules",
"version": "1.0.0",
"repository": "https://github.com/source-academy/modules.git",
"license": "Apache-2.0",
"scripts-info": {
"//NOTE": "Run `npm i npm-scripts-info -g` to install once globally, then run `npm-scripts-info` as needed to list these descriptions",
"create": "Interactively initialise a new bundle or tab from their templates",
"devserver": "Start the tab development server",
"devserver:lint": "Lint code related to the dev server",
"devserver:tsc": "Run tsc over dev server code",
"docs": "Build only documentation",
"lint": "Lint bundle and tab code",
"build": "Lint code, then build modules and documentation",
"build:help": "Show help for the build scripts",
"serve": "Start the HTTP server to serve all files in `build/`, with the same directory structure",
"scripts": "Run a script within the scripts directory",
"scripts:build": "Compile build scripts",
"scripts:lint": "Lint build script code",
"prepare": "Enable git hooks",
"test": "Run unit tests",
"test:watch": "Watch files for changes and rerun tests related to changed files",
"dev": "Build bundles and tabs only, then serve. Skips linting / type checking, does not build jsons and HTML docs. For rapid testing during development",
"watch": "Watch files for changes and rebuild on those changes",
"postinstall": "Install all patches to node_modules packages"
},
"type": "module",
"scripts": {
"build": "yarn scripts build",
"build:help": "yarn scripts build --help",
"create": "yarn scripts create",
"dev": "yarn scripts build modules && yarn serve",
"docs": "yarn scripts build docs",
"lint": "yarn scripts lint",
"prepare": "husky install",
"postinstall": "patch-package && yarn scripts:build",
"scripts": "node --max-old-space-size=4096 scripts/bin.js",
"serve": "http-server --cors=* -c-1 -p 8022 ./build",
"test": "yarn scripts test",
"test:all": "yarn test && yarn scripts:test",
"test:watch": "yarn scripts test --watch",
"watch": "yarn scripts watch",
"devserver": "vite",
"devserver:lint": "yarn scripts devserver lint",
"devserver:tsc": "tsc --project devserver/tsconfig.json",
"scripts:all": "node scripts/scripts_manager.js",
"scripts:build": "node scripts/scripts_manager.js build",
"scripts:lint": "node scripts/scripts_manager.js lint",
"scripts:tsc": "tsc --project scripts/src/tsconfig.json",
"scripts:test": "node scripts/scripts_manager.js test"
},
"devDependencies": {
"@types/dom-mediacapture-record": "^1.0.11",
"@types/eslint": "^8.4.10",
"@types/estree": "^1.0.0",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.198",
"@types/node": "^20.8.9",
"@types/plotly.js-dist": "npm:@types/plotly.js",
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"@vitejs/plugin-react": "^4.0.4",
"acorn": "^8.8.1",
"acorn-jsx": "^5.3.2",
"astring": "^1.8.4",
"chalk": "^5.0.1",
"commander": "^9.4.0",
"console-table-printer": "^2.11.1",
"cross-env": "^7.0.3",
"esbuild": "^0.18.20",
"eslint": "^8.21.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-import-resolver-typescript": "^2.7.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.8.1",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.4.0",
"eslint-plugin-simple-import-sort": "^8.0.0",
"http-server": "^0.12.3",
"husky": "5",
"jest": "^29.4.1",
"jest-environment-jsdom": "^29.4.1",
"re-resizable": "^6.9.11",
"react-hotkeys": "^2.0.0",
"react-responsive": "^9.0.2",
"sass": "^1.66.1",
"ts-jest": "^29.1.1",
"typedoc": "^0.25.1",
"typescript": "5.0",
"vite": "^4.5.2",
"yarnhook": "^0.5.1"
},
"dependencies": {
"@blueprintjs/core": "^4.20.2",
"@blueprintjs/icons": "^4.4.0",
"@blueprintjs/popover2": "^1.4.3",
"@box2d/core": "^0.10.0",
"@box2d/debug-draw": "^0.10.0",
"@jscad/modeling": "2.9.6",
"@jscad/regl-renderer": "^2.6.1",
"@jscad/stl-serializer": "^2.1.13",
"ace-builds": "^1.25.1",
"classnames": "^2.3.1",
"dayjs": "^1.10.4",
"gl-matrix": "^3.3.0",
"js-slang": "^1.0.20",
"lodash": "^4.17.21",
"patch-package": "^6.5.1",
"phaser": "^3.54.0",
"plotly.js-dist": "^2.17.1",
"postinstall-postinstall": "^2.1.0",
"react": "^18.2.0",
"react-ace": "^10.1.0",
"react-dom": "^18.2.0",
"regl": "^2.1.0",
"save-file": "^2.3.1",
"source-academy-utils": "^1.0.0",
"source-academy-wabt": "^1.0.4",
"tslib": "^2.3.1"
},
"jest": {
"projects": [
"src/jest.config.js",
"scripts/src/jest.config.js"
]
},
"resolutions": {
"@types/react": "^18.2.0",
"esbuild": "^0.18.20"
}
}
3 changes: 1 addition & 2 deletions scripts/src/build/modules/__tests__/bundle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ test('building a bundle', async () => {
const call = (fs.writeFile as jest.MockedFunction<typeof fs.writeFile>).mock.calls[0];

expect(call[0]).toEqual('build/bundles/test0.js')
const removeExports = (call[1] as string).slice("export default".length, -1);
const bundleText = `(${removeExports})`;
const bundleText = `(${call[1]})`;
const mockContext = {
moduleContexts: {
test0: {
Expand Down
35 changes: 22 additions & 13 deletions scripts/src/build/modules/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import type {
ArrowFunctionExpression,
CallExpression,
ExportDefaultDeclaration,
ExpressionStatement,
Identifier,
Program,
VariableDeclaration,
Expand Down Expand Up @@ -36,21 +36,30 @@ export const outputBundle = async (name: string, bundleText: string, outDir: str
const callExpression = varDeclarator.init as CallExpression;
const moduleCode = callExpression.callee as ArrowFunctionExpression;

const output: ExportDefaultDeclaration = {
type: 'ExportDefaultDeclaration',
declaration: {
...moduleCode,
params: [
{
type: 'Identifier',
name: 'require',
} as Identifier,
],
const output = {
type: 'ArrowFunctionExpression',
body: {
type: 'BlockStatement',
body: moduleCode.body.type === 'BlockStatement'
? moduleCode.body.body
: [{
type: 'ExpressionStatement',
expression: moduleCode.body,
} as ExpressionStatement],
},
};
params: [
{
type: 'Identifier',
name: 'require',
} as Identifier,
],
} as ArrowFunctionExpression;

let newCode = generate(output);
if (newCode.endsWith(';')) newCode = newCode.slice(0, -1);

const outFile = `${outDir}/bundles/${name}.js`;
await fs.writeFile(outFile, generate(output));
await fs.writeFile(outFile, newCode);
const { size } = await fs.stat(outFile);
return {
severity: 'success',
Expand Down
Loading

0 comments on commit 32242aa

Please sign in to comment.