From d04e022e8383e9c325793b83612c45bcb65f2af5 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Mon, 11 Jan 2021 15:52:13 -0600 Subject: [PATCH 1/2] drop use of GitHub package registry Having to always authenticate to use packages hosted on GitHub was a bit of a pain for developers and breaks dependabot. --- .github/workflows/build-dev.yml | 3 --- .github/workflows/test-pull-request.yml | 3 --- .npmrc | 1 - .yarnrc | 1 - CONTRIBUTING.md | 25 ------------------------- package.json | 4 ++-- yarn.lock | 16 ++++++++-------- 7 files changed, 10 insertions(+), 43 deletions(-) delete mode 100644 .npmrc delete mode 100644 .yarnrc diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index 1cb1e78a..490f12d0 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -12,11 +12,8 @@ jobs: - uses: actions/setup-node@v1 with: node-version: '12.x' - registry-url: 'https://npm.pkg.github.com' - uses: actions/checkout@v2 - run: yarn install - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: yarn coverage - name: Coveralls uses: coverallsapp/github-action@master diff --git a/.github/workflows/test-pull-request.yml b/.github/workflows/test-pull-request.yml index 04271ae7..bab8512b 100644 --- a/.github/workflows/test-pull-request.yml +++ b/.github/workflows/test-pull-request.yml @@ -16,11 +16,8 @@ jobs: - uses: actions/setup-node@v1 with: node-version: '12.x' - registry-url: 'https://npm.pkg.github.com' - uses: actions/checkout@v2 - run: yarn install - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | yarn lint git diff --exit-code diff --git a/.npmrc b/.npmrc deleted file mode 100644 index 7a0415be..00000000 --- a/.npmrc +++ /dev/null @@ -1 +0,0 @@ -@pybricks:registry=https://npm.pkg.github.com diff --git a/.yarnrc b/.yarnrc deleted file mode 100644 index 3cf5777a..00000000 --- a/.yarnrc +++ /dev/null @@ -1 +0,0 @@ -"@pybricks:registry" "https://npm.pkg.github.com" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3ed68d63..88b68915 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,28 +4,6 @@ These are the tools you will need to build and run `pybricks-code` locally. -## Important Note about Github Packages - -**This step is mandatory and cannot be skipped. Otherwise you will have no access to some referenced dependencies in [package.json](./package.json)!** - -We are currently depending on a couple of packages from the Github package -registry. [Github requires you](https://docs.github.com/en/free-pro-team@latest/packages/guides/configuring-npm-for-use-with-github-packages#authenticating-with-a-personal-access-token) to log in first before you can install public packages. - -To do this, first you will need to create a new authentication token at -. - -- Click the *Generate a new token* button. -- Select the **repo** and **read:packages** scopes. -- Click the *Generate token* button. -- Click the clipboard icon top copy the token to be used below. - -Then run the following command and enter your username, authentication token -and email: - - npm login --registry=https://npm.pkg.github.com - -This only needs to be done once. - ## IDE Technically you can use any text editor you like but the project is set up to @@ -68,9 +46,6 @@ where you would like to save the source code and run: cd pybricks-code yarn install -If you see a 401 not authorized error after running `yarn install`, then you -probably skipped the logging into the Github package registry as [described above](#important-note-about-github-packages). - # Software Stack This project was bootstrapped with [Create React App][create-react-app]. diff --git a/package.json b/package.json index 2616b809..5e755238 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "dependencies": { "@blueprintjs/core": "^3.36.0", "@craco/craco": "^6.0.0", - "@pybricks/firmware": "4.3.0", - "@pybricks/mpy-cross-v5": "^1.1.0", + "@pybricks/firmware": "4.4.0", + "@pybricks/mpy-cross-v5": "^1.2.0", "@shopify/react-i18n": "^5.2.0", "@testing-library/dom": "^7.29.2", "@testing-library/jest-dom": "^5.11.8", diff --git a/yarn.lock b/yarn.lock index 52db7021..1959be12 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1484,17 +1484,17 @@ schema-utils "^2.6.5" source-map "^0.7.3" -"@pybricks/firmware@4.3.0": - version "4.3.0" - resolved "https://npm.pkg.github.com/download/@pybricks/firmware/4.3.0/89f260a050abcc837c803b7851edcb234944d5aff0a2f45706b556796fbc3a45#817b3bd9aa3daf77c80b67a5c5d5776779773491" - integrity sha512-5cTtBpTtRa0P98DS+M2WswYsF4FCQdeL65tMZd98S47sjZn/Yzw6AJzhSFfZHPJbRQzqDcHJm065awQHb7SXMg== +"@pybricks/firmware@4.4.0": + version "4.4.0" + resolved "https://registry.yarnpkg.com/@pybricks/firmware/-/firmware-4.4.0.tgz#bdb7fd5476b914533b09d796fb2d98ec1e911ae1" + integrity sha512-le6EgkipT74D5lmi47FJa2B/Jms4XuRbh6ReoUH9bgaW5TolmE4wwN67uwA2c3fVY16ApCMe9dZoj/5y6ai50w== dependencies: jszip "^3.5.0" -"@pybricks/mpy-cross-v5@^1.1.0": - version "1.1.0" - resolved "https://npm.pkg.github.com/download/@pybricks/mpy-cross-v5/1.1.0/01b9fe3498310264b7b826d7bb596ef593b3b92de93503933ca14fb9efb5160e#5fe7eb7f5b8d0f783c16eab92d4e1b96bcfba0cb" - integrity sha512-rARDzR1/PfzGLJVnyOeDRSsWmdHOPSQed0IeRG8T3YpFSGywR8z/UoSq1jurVETZvSEIOj1P4nmd0ZAPa3+bMA== +"@pybricks/mpy-cross-v5@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@pybricks/mpy-cross-v5/-/mpy-cross-v5-1.2.0.tgz#29cbd949c579c0551792d2fd1cd777d193aa925c" + integrity sha512-A1FXGP0teuZa3tPBTz9niCdEol4Ld6jOABl9FkglmutGWO99eLwuyYibh8wQqHNKwXRHrzCJmo/W+/42HmSjog== "@redux-saga/core@^1.1.3": version "1.1.3" From 69e52be2590664300f68c8fc7f39dd873cbce384 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Mon, 11 Jan 2021 16:34:38 -0600 Subject: [PATCH 2/2] remove wasm file extension rename workaround This modifies the webpack config instead of renaming the .wasm file to workaround default webpack behavior regarding import .wasm files. --- craco.config.js | 18 +++++++++++++++++- package.json | 3 --- src/react-app-env.d.ts | 2 +- src/sagas/.gitignore | 1 - src/sagas/mpy.ts | 2 +- yarn.lock | 5 ----- 6 files changed, 19 insertions(+), 12 deletions(-) delete mode 100644 src/sagas/.gitignore diff --git a/craco.config.js b/craco.config.js index 9d2219c9..dd1d624a 100644 --- a/craco.config.js +++ b/craco.config.js @@ -1,6 +1,11 @@ // https://github.com/gsoft-inc/craco/blob/master/packages/craco/README.md#configuration -const { getLoader, getLoaders, loaderByName } = require('@craco/craco'); +const { + addBeforeLoader, + getLoader, + getLoaders, + loaderByName, +} = require('@craco/craco'); module.exports = { webpack: { @@ -45,6 +50,17 @@ module.exports = { /\.json$/, ]; + // work around default handling of .wasm files + // https://github.com/webpack/webpack/issues/7352 + addBeforeLoader(webpackConfig, loaderByName('file-loader'), { + test: /\.wasm$/, + type: 'javascript/auto', + loader: 'file-loader', + options: { + name: 'static/[name].[hash:8].[ext]', + }, + }); + return webpackConfig; }, }, diff --git a/package.json b/package.json index 5e755238..f3324fd0 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "zen-push": "^0.2.1" }, "scripts": { - "prepare": "mkdirp public/static/js && ncp node_modules/@pybricks/mpy-cross-v5/build/mpy-cross.wasm src/sagas/mpy-cross.emcwasm", "start": "craco start", "build": "craco build", "test": "craco test --env=./test/env.js", @@ -76,8 +75,6 @@ "eslint-plugin-prettier": "^3.3.1", "eslint-plugin-react": "^7.22.0", "jest-mock-extended": "^1.0.9", - "mkdirp": "^1.0.4", - "ncp": "^2.0.0", "prettier": "^2.2.1" } } diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts index 7830f648..e1cd6f56 100644 --- a/src/react-app-env.d.ts +++ b/src/react-app-env.d.ts @@ -5,7 +5,7 @@ declare module '*.json' { export default src; } -declare module '*.emcwasm' { +declare module '*.wasm' { const src: string; export default src; } diff --git a/src/sagas/.gitignore b/src/sagas/.gitignore deleted file mode 100644 index 57cbe67d..00000000 --- a/src/sagas/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.emcwasm diff --git a/src/sagas/mpy.ts b/src/sagas/mpy.ts index ed16c9bd..5c15c43d 100644 --- a/src/sagas/mpy.ts +++ b/src/sagas/mpy.ts @@ -2,6 +2,7 @@ // Copyright (c) 2020 The Pybricks Authors import { CompileResult, compile as mpyCrossCompile } from '@pybricks/mpy-cross-v5'; +import wasm from '@pybricks/mpy-cross-v5/build/mpy-cross.wasm'; import { call, put, takeEvery } from 'redux-saga/effects'; import { MpyActionType, @@ -9,7 +10,6 @@ import { didCompile, didFailToCompile, } from '../actions/mpy'; -import wasm from './mpy-cross.emcwasm'; /** * Compiles a script to .mpy and dispatches either didCompile on success or diff --git a/yarn.lock b/yarn.lock index 1959be12..e530fa31 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8266,11 +8266,6 @@ natural-compare@^1.4.0: resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= -ncp@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ncp/-/ncp-2.0.0.tgz#195a21d6c46e361d2fb1281ba38b91e9df7bdbb3" - integrity sha1-GVoh1sRuNh0vsSgbo4uR6d9727M= - negotiator@0.6.2: version "0.6.2" resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb"