Skip to content

Commit 3d434bb

Browse files
committed
Type updates and runtime error handling
Update project types and add a guard wrapper to log an appropriate error message if no sketch is provided at runtime.
1 parent 9280927 commit 3d434bb

File tree

11 files changed

+793
-1074
lines changed

11 files changed

+793
-1074
lines changed

.github/workflows/CD.yml

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,23 @@ on:
77
concurrency: cd-${{ github.ref }}
88

99
jobs:
10-
build-and-deploy:
10+
build:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
14-
name: Checkout the latest code for the current PR
13+
- uses: P5-wrapper/setup-action@v1
1514
with:
1615
token: ${{ secrets.GH_TOKEN }}
1716

18-
- uses: actions/setup-node@v2
19-
name: Setup node
20-
with:
21-
node-version: 16
22-
23-
- uses: pnpm/action-setup@v2.0.1
24-
name: Install pnpm
25-
id: pnpm-install
26-
with:
27-
version: 7
28-
run_install: false
29-
30-
- name: Get pnpm store directory
31-
id: pnpm-cache
32-
run: |
33-
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
34-
35-
- uses: actions/cache@v3
36-
name: Setup pnpm cache
37-
with:
38-
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
39-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
40-
restore-keys: |
41-
${{ runner.os }}-pnpm-store-
42-
43-
- name: Install dependencies
44-
run: pnpm install
45-
4617
- name: Build the demo application
4718
run: pnpm build:demo
4819

20+
deploy:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: P5-wrapper/setup-action@v1
24+
with:
25+
token: ${{ secrets.GH_TOKEN }}
26+
4927
- name: Deploy the demo application
5028
uses: JamesIves/github-pages-deploy-action@v4
5129
with:

.github/workflows/CI.yml

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,13 @@ on:
77
concurrency: ci-${{ github.ref }}
88

99
jobs:
10-
format-lint-test-and-build:
10+
format:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
14-
name: Checkout the latest code for the current PR
13+
- uses: P5-wrapper/setup-action@v1
1514
with:
1615
token: ${{ secrets.GH_TOKEN }}
1716

18-
- uses: actions/setup-node@v2
19-
name: Setup node
20-
with:
21-
node-version: 16
22-
23-
- uses: pnpm/action-setup@v2.0.1
24-
name: Install pnpm
25-
id: pnpm-install
26-
with:
27-
version: 7
28-
run_install: false
29-
30-
- name: Get pnpm store directory
31-
id: pnpm-cache
32-
run: |
33-
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
34-
35-
- uses: actions/cache@v3
36-
name: Setup pnpm cache
37-
with:
38-
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
39-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
40-
restore-keys: |
41-
${{ runner.os }}-pnpm-store-
42-
43-
- name: Install dependencies
44-
run: pnpm install
45-
4617
- name: Check formatting
4718
run: pnpm format:check
4819

@@ -56,6 +27,13 @@ jobs:
5627
commit_message: Apply fixed formatting issues
5728
branch: ${{ github.head_ref }}
5829

30+
lint:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: P5-wrapper/setup-action@v1
34+
with:
35+
token: ${{ secrets.GH_TOKEN }}
36+
5937
- name: Lint
6038
run: pnpm lint
6139

@@ -69,8 +47,22 @@ jobs:
6947
commit_message: Apply fixed linting issues
7048
branch: ${{ github.head_ref }}
7149

50+
test:
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: P5-wrapper/setup-action@v1
54+
with:
55+
token: ${{ secrets.GH_TOKEN }}
56+
7257
- name: Test
7358
run: pnpm test
7459

60+
build:
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: P5-wrapper/setup-action@v1
64+
with:
65+
token: ${{ secrets.GH_TOKEN }}
66+
7567
- name: Build
7668
run: pnpm build

.github/workflows/CODEQL.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
language: ["javascript"]
21+
language: ["javascript", "typescript"]
2222

2323
steps:
2424
- name: Checkout repository
25-
uses: actions/checkout@v2
25+
uses: actions/checkout@v3
2626

2727
- name: Initialize CodeQL
28-
uses: github/codeql-action/init@v1
28+
uses: github/codeql-action/init@v2
2929
with:
3030
languages: ${{ matrix.language }}
3131

3232
- name: Perform CodeQL Analysis
33-
uses: github/codeql-action/analyze@v1
33+
uses: github/codeql-action/analyze@v2

config/eslint/eslint.config.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ module.exports = {
66
extends: [
77
"eslint:recommended",
88
"plugin:@typescript-eslint/recommended",
9-
"plugin:prettier/recommended",
109
"plugin:react-hooks/recommended",
1110
"plugin:react/recommended"
1211
],
@@ -18,7 +17,7 @@ module.exports = {
1817
ecmaVersion: 12,
1918
sourceType: "module"
2019
},
21-
plugins: ["@typescript-eslint", "prettier", "react", "simple-import-sort"],
20+
plugins: ["@typescript-eslint", "react", "simple-import-sort"],
2221
overrides: [
2322
{
2423
files: [".js", ".jsx", ".ts", ".tsx"]
@@ -28,10 +27,7 @@ module.exports = {
2827
"@typescript-eslint/no-explicit-any": "off",
2928
"linebreak-style": ["error", "unix"],
3029
"simple-import-sort/exports": "error",
31-
"simple-import-sort/imports": "error",
32-
indent: ["error", 2],
33-
quotes: ["error", "double"],
34-
semi: ["error", "always"]
30+
"simple-import-sort/imports": "error"
3531
},
3632
settings: {
3733
react: {

config/typescript/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"outDir": "../../dist",
3+
"outDir": "../../dist/components",
44
"declaration": true,
55
"esModuleInterop": true,
66
"forceConsistentCasingInFileNames": true,

package.json

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
],
1313
"scripts": {
1414
"aui": "pnpm audit && pnpm update && pnpm install",
15-
"build": "pnpm clean && pnpm build:demo && pnpm build:components",
1615
"build:components": "rollup -c config/rollup/rollup.config.js",
1716
"build:demo": "webpack --config config/webpack/webpack.config.js --mode production",
17+
"build": "pnpm clean && pnpm build:demo && pnpm build:components",
1818
"ci": "pnpm format:check && pnpm lint && pnpm test && pnpm build",
1919
"clean": "rimraf dist",
20-
"format": "pnpm prettier --write .",
2120
"format:check": "pnpm prettier --check .",
22-
"lint": "eslint --config config/eslint/eslint.config.js src/ --ignore-path .gitignore",
21+
"format": "pnpm prettier --write .",
2322
"lint:fix": "pnpm lint --fix",
23+
"lint": "eslint --config config/eslint/eslint.config.js src/ --ignore-path .gitignore",
2424
"prettier": "prettier --config config/prettier/prettier.config.js --ignore-path .gitignore",
2525
"release": "pnpm build && gh-pages -d dist/demo && pnpm publish",
2626
"start": "webpack serve --config config/webpack/webpack.config.js --mode development",
27-
"test": "jest --config config/jest/jest.config.js --coverage",
28-
"test:watch": "pnpm test --watch"
27+
"test:watch": "pnpm test --watch",
28+
"test": "jest --config config/jest/jest.config.js --coverage"
2929
},
3030
"keywords": [
3131
"react",
@@ -62,35 +62,29 @@
6262
"url": "https://github.com/jamesrweb/react-p5-wrapper/issues"
6363
},
6464
"dependencies": {
65-
"@types/p5": "^1.4.2",
66-
"microdiff": "^1.3.0",
67-
"p5": "^1.4.2",
68-
"rooks": "^5.14.0"
65+
"microdiff": "^1.3.1",
66+
"p5": "^1.4.2"
6967
},
7068
"peerDependencies": {
7169
"react": ">= 17.0.2",
7270
"react-dom": ">= 17.0.2"
7371
},
7472
"devDependencies": {
75-
"@babel/cli": "^7.18.9",
76-
"@babel/core": "^7.18.9",
77-
"@babel/preset-env": "^7.18.9",
73+
"@babel/core": "^7.18.10",
74+
"@babel/preset-env": "^7.18.10",
7875
"@babel/preset-react": "^7.18.6",
7976
"@babel/preset-typescript": "^7.18.6",
80-
"@testing-library/jest-dom": "^5.16.4",
8177
"@testing-library/react": "^13.3.0",
82-
"@types/deep-equal": "^1.0.1",
83-
"@types/jest": "^28.1.6",
84-
"@types/react": "^18.0.15",
78+
"@types/jest": "^28.1.7",
79+
"@types/p5": "^1.4.2",
80+
"@types/react": "^18.0.17",
8581
"@types/react-dom": "^18.0.6",
86-
"@typescript-eslint/eslint-plugin": "^5.30.7",
87-
"@typescript-eslint/parser": "^5.30.7",
82+
"@typescript-eslint/eslint-plugin": "^5.33.1",
83+
"@typescript-eslint/parser": "^5.33.1",
8884
"babel-loader": "^8.2.5",
8985
"canvas": "^2.9.3",
9086
"css-loader": "^6.7.1",
91-
"eslint": "^8.20.0",
92-
"eslint-config-prettier": "^8.5.0",
93-
"eslint-plugin-prettier": "^4.2.1",
87+
"eslint": "^8.22.0",
9488
"eslint-plugin-react": "^7.30.1",
9589
"eslint-plugin-react-hooks": "^4.6.0",
9690
"eslint-plugin-simple-import-sort": "^7.0.0",
@@ -103,16 +97,16 @@
10397
"react": "^18.2.0",
10498
"react-dom": "^18.2.0",
10599
"rimraf": "^3.0.2",
106-
"rollup": "^2.77.0",
100+
"rollup": "^2.78.0",
107101
"rollup-plugin-terser": "^7.0.2",
108102
"rollup-plugin-typescript2": "^0.32.1",
109103
"style-loader": "^3.3.1",
110-
"ts-jest": "^28.0.7",
104+
"ts-jest": "^28.0.8",
111105
"ts-loader": "^9.3.1",
112106
"tslib": "^2.4.0",
113107
"typescript": "^4.7.4",
114108
"webpack": "^5.74.0",
115109
"webpack-cli": "^4.10.0",
116-
"webpack-dev-server": "^4.9.3"
110+
"webpack-dev-server": "^4.10.0"
117111
}
118112
}

0 commit comments

Comments
 (0)