Use yarn pnp as module linker (#2252)

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2022-07-30 23:32:19 +02:00 committed by GitHub
parent 20a48b38d7
commit 6ba957585a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 271 additions and 7285 deletions

View file

@ -30,7 +30,7 @@ jobs:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.node }}-yarn-${{ hashFiles('**/yarn.lock') }} key: ${{ runner.os }}-${{ matrix.node }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: | restore-keys: |
${{ runner.os }}-yarn-18 ${{ runner.os }}-yarn-${{ matrix.node }}
- name: Set up NodeJS - name: Set up NodeJS
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:

View file

@ -66,7 +66,6 @@ jobs:
needs: build-frontend needs: build-frontend
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
# renovate: datasource=docker depName=cypress/browsers versioning=docker
image: cypress/browsers:node16.14.2-slim-chrome103-ff102 image: cypress/browsers:node16.14.2-slim-chrome103-ff102
options: --user 1001 --shm-size=2g options: --user 1001 --shm-size=2g
strategy: strategy:
@ -78,22 +77,46 @@ jobs:
- name: Check out repo - name: Check out repo
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Cache build
uses: actions/cache@v3.0.5
id: build-cache
with:
path: .next
key: build-${{ github.sha }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
if: steps.build-cache.outputs.cache-hit != 'true'
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- name: Cache yarn cache
uses: actions/cache@v3
id: yarn-cache
if: steps.build-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-16-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-16
- name: Install dependencies
if: steps.build-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Download built frontend - name: Download built frontend
uses: actions/download-artifact@master uses: actions/download-artifact@master
with: with:
name: next-build name: next-build
path: .next path: .next
- uses: cypress-io/github-action@v4 - name: Run server
with: run: yarn start:ci &
browser: ${{ matrix.browser }}
start: 'yarn start:ci' - name: Wait for server
parallel: true run: curl --max-time 120 http://127.0.0.1:3001/
record: true
group: "UI - ${{ matrix.browser }}" - name: Run cypress
wait-on: 'http://127.0.0.1:3001/' run: "yarn cy:run:${{ matrix.browser }} --record true --parallel --group \"UI - ${{ matrix.browser }}\""
wait-on-timeout: 120
install-command: yarn install --immutable --silent
env: env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -1,4 +1,4 @@
nodeLinker: node-modules nodeLinker: pnp
plugins: plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs - path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

View file

@ -28,7 +28,7 @@ COPY --chown=node .yarn/ .yarn/
COPY --chown=node public/ public/ COPY --chown=node public/ public/
COPY --chown=node --from=builder /usr/src/app/.next/ .next/ COPY --chown=node --from=builder /usr/src/app/.next/ .next/
USER node USER node
RUN yarn workspaces focus --all --production && rm -rf .yarn/cache RUN yarn workspaces focus --all --production
EXPOSE 3001/tcp EXPOSE 3001/tcp
CMD ["/usr/local/bin/yarn", "start:for-real-backend"] CMD ["/usr/local/bin/yarn", "start:for-real-backend"]

View file

@ -18,6 +18,7 @@ react and to improve it.
## Preparation ## Preparation
You need at least Node 14 (we recommend Node 18) and [yarn](https://yarnpkg.com/). You need at least Node 14 (we recommend Node 18) and [yarn](https://yarnpkg.com/).
You MUST use yarn! There is no support for npm.
## Development mode ## Development mode

18
cypress.config.js Normal file
View file

@ -0,0 +1,18 @@
/*
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
module.exports = {
e2e: {
defaultCommandTimeout: 15000,
video: false,
projectId: 'ht3vbo',
e2e: {
baseUrl: 'http://127.0.0.1:3001/',
specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}'
}
},
};

View file

@ -1,18 +0,0 @@
/*
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { defineConfig } from 'cypress'
export default defineConfig({
defaultCommandTimeout: 15000,
video: false,
projectId: 'ht3vbo',
e2e: {
baseUrl: 'http://127.0.0.1:3001/',
specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}'
}
})

View file

@ -11,7 +11,8 @@
"types": [ "types": [
"cypress", "cypress",
"cypress-commands", "cypress-commands",
"cypress-file-upload" "cypress-file-upload",
"node"
] ]
}, },
"include": [ "include": [

View file

@ -12,18 +12,16 @@ const createJestConfig = nextJest({
// Add any custom config to be passed to Jest // Add any custom config to be passed to Jest
const customJestConfig = { const customJestConfig = {
setupFilesAfterEnv: [ setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
'@testing-library/jest-dom/extend-expect'
],
moduleNameMapper: { moduleNameMapper: {
// Handle module aliases (this will be automatically configured for you soon) // Handle module aliases (this will be automatically configured for you soon)
'^@/components/(.*)$': '<rootDir>/src/components/$1', '^@/components/(.*)$': '<rootDir>/src/components/$1',
// fix uuid / jest problem https://github.com/uuidjs/uuid/pull/616 // fix uuid / jest problem https://github.com/uuidjs/uuid/pull/616
'^uuid$': require.resolve('uuid'), '^uuid$': require.resolve('uuid')
}, },
roots: ["<rootDir>/src"], roots: ['<rootDir>/src'],
testEnvironment: 'jsdom', testEnvironment: 'jsdom',
testPathIgnorePatterns: ["/node_modules/", "/cypress/"] testPathIgnorePatterns: ['/node_modules/', '/cypress/']
} }
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async // createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async

9
netlify/deploy-main.sh Normal file → Executable file
View file

@ -1,14 +1,17 @@
#!/bin/bash #!/bin/bash
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) #
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
# #
# SPDX-License-Identifier: AGPL-3.0-only # SPDX-License-Identifier: AGPL-3.0-only
#
json=$(yarn netlify deploy --build --prod --json --message "${1:0:8}: $2") cd "$(dirname "$0")"
json=$(./netlify-cli.sh deploy --build --prod --json --message "${1:0:8}: $2")
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Error while executing netlify! Will try again without json..." echo "Error while executing netlify! Will try again without json..."
yarn netlify deploy --build --prod --message "${1:0:8}: $2" ./netlify-cli.sh deploy --build --prod --message "${1:0:8}: $2"
exit 1 exit 1
fi fi

View file

@ -1,14 +1,17 @@
#!/bin/bash #!/bin/bash
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) #
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
# #
# SPDX-License-Identifier: AGPL-3.0-only # SPDX-License-Identifier: AGPL-3.0-only
#
json=$(yarn netlify deploy --build --context deploy-preview --alias "$1" --json --message "[#$1] $2") cd "$(dirname "$0")"
json=$(./netlify-cli.sh deploy --build --context deploy-preview --alias "$1" --json --message "[#$1] $2")
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Error while executing netlify! Will try again without json..." echo "Error while executing netlify! Will try again without json..."
yarn netlify deploy --build --context deploy-preview --alias "$1" --message "[#$1] $2" ./netlify-cli.sh deploy --build --context deploy-preview --alias "$1" --message "[#$1] $2"
exit 1 exit 1
fi fi

10
netlify/netlify-cli.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
#
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
#
NETLIFY_VERSION=10.13.0
exec npx --yes netlify-cli@${NETLIFY_VERSION}

View file

@ -83,13 +83,17 @@ const rawNextConfig = {
} }
] ]
}) })
const wasmModulePath = path.dirname(require.resolve('@hpcc-js/wasm'))
const emojiPickerDataModulePath = path.dirname(require.resolve('emoji-picker-element-data/en/emojibase/data.json'))
config.plugins.push( config.plugins.push(
new CopyWebpackPlugin({ new CopyWebpackPlugin({
patterns: [ patterns: [
{ from: path.join(__dirname, 'node_modules/@hpcc-js/wasm/dist/graphvizlib.wasm'), to: 'static/js' }, { from: path.join(wasmModulePath, 'graphvizlib.wasm'), to: 'static/js' },
{ from: path.join(__dirname, 'node_modules/@hpcc-js/wasm/dist/expatlib.wasm'), to: 'static/js' }, { from: path.join(wasmModulePath, 'expatlib.wasm'), to: 'static/js' },
{ {
from: path.join(__dirname, 'node_modules/emoji-picker-element-data/en/emojibase/data.json'), from: emojiPickerDataModulePath,
to: 'static/js/emoji-data.json' to: 'static/js/emoji-data.json'
} }
] ]

View file

@ -40,7 +40,9 @@
}, },
"dependencies": { "dependencies": {
"@codemirror/autocomplete": "6.1.0", "@codemirror/autocomplete": "6.1.0",
"@codemirror/commands": "6.0.1",
"@codemirror/lang-markdown": "6.0.1", "@codemirror/lang-markdown": "6.0.1",
"@codemirror/language": "6.2.1",
"@codemirror/language-data": "6.1.0", "@codemirror/language-data": "6.1.0",
"@codemirror/state": "6.1.0", "@codemirror/state": "6.1.0",
"@codemirror/theme-one-dark": "6.0.0", "@codemirror/theme-one-dark": "6.0.0",
@ -50,6 +52,8 @@
"@hedgedoc/markdown-it-image-size": "1.0.3", "@hedgedoc/markdown-it-image-size": "1.0.3",
"@hedgedoc/markdown-it-task-lists": "1.0.5", "@hedgedoc/markdown-it-task-lists": "1.0.5",
"@hedgedoc/realtime": "0.1.1", "@hedgedoc/realtime": "0.1.1",
"@hpcc-js/wasm": "1.12.8",
"@lezer/common": "1.0.0",
"@matejmazur/react-katex": "3.1.3", "@matejmazur/react-katex": "3.1.3",
"@mrdrogdrog/optional": "0.1.2", "@mrdrogdrog/optional": "0.1.2",
"@react-hook/resize-observer": "1.2.6", "@react-hook/resize-observer": "1.2.6",
@ -62,8 +66,11 @@
"copy-webpack-plugin": "11.0.0", "copy-webpack-plugin": "11.0.0",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"d3-graphviz": "4.1.1", "d3-graphviz": "4.1.1",
"d3-selection": "2.0.0",
"deepmerge": "4.2.2", "deepmerge": "4.2.2",
"diff": "5.1.0", "diff": "5.1.0",
"dom-serializer": "2.0.0",
"domhandler": "5.0.3",
"dompurify": "2.3.10", "dompurify": "2.3.10",
"emoji-picker-element": "1.12.1", "emoji-picker-element": "1.12.1",
"emoji-picker-element-data": "1.3.0", "emoji-picker-element-data": "1.3.0",
@ -72,6 +79,7 @@
"flowchart.js": "1.17.1", "flowchart.js": "1.17.1",
"fork-awesome": "1.2.0", "fork-awesome": "1.2.0",
"highlight.js": "11.6.0", "highlight.js": "11.6.0",
"htmlparser2": "8.0.1",
"i18next": "21.8.16", "i18next": "21.8.16",
"i18next-browser-languagedetector": "6.1.4", "i18next-browser-languagedetector": "6.1.4",
"i18next-resources-to-backend": "1.0.0", "i18next-resources-to-backend": "1.0.0",
@ -118,6 +126,7 @@
"vega-embed": "6.21.0", "vega-embed": "6.21.0",
"vega-lite": "5.4.0", "vega-lite": "5.4.0",
"words-count": "2.0.2", "words-count": "2.0.2",
"ws": "8.8.1",
"y-codemirror.next": "0.3.2", "y-codemirror.next": "0.3.2",
"y-protocols": "1.0.5", "y-protocols": "1.0.5",
"yjs": "13.5.41" "yjs": "13.5.41"
@ -125,12 +134,14 @@
"devDependencies": { "devDependencies": {
"@next/bundle-analyzer": "12.2.2", "@next/bundle-analyzer": "12.2.2",
"@testing-library/cypress": "8.0.3", "@testing-library/cypress": "8.0.3",
"@testing-library/dom": "8.16.0",
"@testing-library/jest-dom": "5.16.4", "@testing-library/jest-dom": "5.16.4",
"@testing-library/react": "13.3.0", "@testing-library/react": "13.3.0",
"@testing-library/user-event": "14.3.0", "@testing-library/user-event": "14.3.0",
"@types/d3-graphviz": "2.6.7", "@types/d3-graphviz": "2.6.7",
"@types/diff": "5.0.2", "@types/diff": "5.0.2",
"@types/dompurify": "2.3.3", "@types/dompurify": "2.3.3",
"@types/jest": "28.1.6",
"@types/js-yaml": "4.0.5", "@types/js-yaml": "4.0.5",
"@types/luxon": "3.0.0", "@types/luxon": "3.0.0",
"@types/markdown-it": "12.2.3", "@types/markdown-it": "12.2.3",
@ -142,9 +153,11 @@
"@types/react-bootstrap-typeahead": "5.1.8", "@types/react-bootstrap-typeahead": "5.1.8",
"@types/react-dom": "18.0.6", "@types/react-dom": "18.0.6",
"@types/sass": "1.43.1", "@types/sass": "1.43.1",
"@types/testing-library__jest-dom": "5.14.5",
"@types/uuid": "8.3.4", "@types/uuid": "8.3.4",
"@typescript-eslint/eslint-plugin": "5.31.0", "@typescript-eslint/eslint-plugin": "5.31.0",
"@typescript-eslint/parser": "5.31.0", "@typescript-eslint/parser": "5.31.0",
"csstype": "3.1.0",
"cypress": "10.3.1", "cypress": "10.3.1",
"cypress-commands": "3.0.0", "cypress-commands": "3.0.0",
"cypress-fill-command": "1.0.2", "cypress-fill-command": "1.0.2",
@ -160,7 +173,6 @@
"eslint-plugin-testing-library": "5.5.1", "eslint-plugin-testing-library": "5.5.1",
"jest": "28.1.3", "jest": "28.1.3",
"jest-environment-jsdom": "28.1.3", "jest-environment-jsdom": "28.1.3",
"netlify-cli": "10.13.0",
"prettier": "2.7.1", "prettier": "2.7.1",
"react-test-renderer": "18.2.0", "react-test-renderer": "18.2.0",
"ts-loader": "9.3.1", "ts-loader": "9.3.1",

View file

@ -94,13 +94,13 @@
"regexManagers": [ "regexManagers": [
{ {
"fileMatch": [ "fileMatch": [
"\\.yml$", "netlify-cli.sh$"
"\\.yaml$"
], ],
"matchStrings": [ "matchStrings": [
"# renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\s+\\S+:\\s+\"?[^:]+:(?<currentValue>[^\"]*?)\"?\\s" "NETLIFY_VERSION=(?<currentValue>.*?)\\n"
], ],
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}" "datasourceTemplate" : "npm",
"depNameTemplate" : "netlify-cli"
} }
] ]
} }

View file

@ -13,7 +13,8 @@
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"jsx": "preserve", "jsx": "preserve",
"incremental": true "incremental": true,
"types": ["node", "@testing-library/jest-dom", "@types/jest"]
}, },
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules", "cypress", "cypress.config.ts"] "exclude": ["node_modules", "cypress", "cypress.config.ts"]

7392
yarn.lock

File diff suppressed because it is too large Load diff