refactor: replace yarn with pnpm (#2424)

* Check for pnpm in authelia-scripts
* Improve husky hooks to check for required apps
* Use pnpm in coverage dockerfile
* Use pnpm in dev workflow
* Stop buildx log truncation
* Ignore pnpm lockfile in yamllint
* Update versions required for docker and docker-compose in contributing docs
pull/2426/head
Amir Zarrinkafsh 2021-09-29 17:24:21 +10:00 committed by GitHub
parent 2f3f0818c3
commit 3d312cf3b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 13380 additions and 12795 deletions

View File

@ -17,7 +17,7 @@ if [[ ! "${BUILDKITE_BRANCH}" =~ ^(v.*) ]] && [[ "${BUILDKITE_COMMAND_EXIT_STATU
fi
bash <(curl -s --connect-timeout 10 --retry 10 --retry-max-time 0 https://codecov.io/bash) -Z -c -s 'coverage*.txt' -F backend "${BUILDKITE_AGENT_META_DATA_CODECOV}"
if [[ "${BUILDKITE_LABEL}" =~ ":selenium:" ]]; then
cd web && yarn report
cd web && pnpm report
fi
bash <(curl -s --connect-timeout 10 --retry 10 --retry-max-time 0 https://codecov.io/bash) -Z -c -f '!*.go' -f '!*.zst' -F frontend "${BUILDKITE_AGENT_META_DATA_CODECOV}"
fi

View File

@ -3,7 +3,15 @@
set +u
if [[ "${BUILDKITE_LABEL}" == ":service_dog: Linting" ]]; then
cd web && yarn install && cd ../
cd web && pnpm install --shamefully-hoist && cd ../
fi
if [[ "${BUILDKITE_LABEL}" == ":docker: Build Image [coverage]" ]]; then
cp -R /buildkite/.pnpm-store .
fi
if [[ "${BUILDKITE_LABEL}" =~ ":debian: Build Package" ]]; then
buildkite-agent artifact download "authelia-linux-${ARCH}.tar.gz" .
fi
if [[ "${BUILDKITE_LABEL}" =~ ":selenium:" ]]; then
@ -14,10 +22,6 @@ if [[ "${BUILDKITE_LABEL}" =~ ":selenium:" ]]; then
docker tag authelia/authelia authelia:dist
fi
if [[ "${BUILDKITE_LABEL}" =~ ":debian: Build Package" ]]; then
buildkite-agent artifact download "authelia-linux-${ARCH}.tar.gz" .
fi
if [[ "${BUILDKITE_LABEL}" == ":docker: Deploy Manifest" ]]; then
echo "--- :go: :react: :swagger: Extract pre-built binary"
buildkite-agent artifact download "authelia-linux-*-musl.tar.gz" .

3
.github/commit-msg vendored
View File

@ -1,4 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
. "$(dirname "$0")/required-apps"
cd web && yarn run commitlint --edit $1
cd web && ${PMGR} commitlint

3
.github/pre-commit vendored
View File

@ -1,5 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
. "$(dirname "$0")/required-apps"
golangci-lint run -v --fix && \
cd web && yarn lint
cd web && ${PMGR} lint

19
.github/required-apps vendored 100644
View File

@ -0,0 +1,19 @@
#!/bin/sh
PMGR=pnpm
if [[ ! -x "$(command -v golangci-lint)" ]]; then
echo "You must install golangci-lint."
exit 1
fi
if [[ ! -x "$(command -v pnpm)" ]]; then
PMGR=yarn
if [[ ! -x "$(command -v yarn)" ]]; then
PMGR=npm
if [[ ! -x "$(command -v npm)" ]]; then
echo "You must install a node package manager."
exit 1
fi
fi
fi

View File

@ -3,6 +3,7 @@ extends: default
ignore: |
internal/configuration/test_resources/config_bad_quoting.yml
web/pnpm-lock.yaml
web/node_modules/
rules:

View File

@ -5,10 +5,12 @@ FROM node:16-alpine AS builder-frontend
WORKDIR /node/src/app
COPY .pnpm-store /root/.pnpm-store
COPY web ./
# Install the dependencies and build
RUN yarn install --frozen-lockfile && GENERATE_SOURCEMAP=false INLINE_RUNTIME_CHUNK=false yarn coverage
RUN yarn global add pnpm && \
pnpm install --shamefully-hoist --frozen-lockfile && GENERATE_SOURCEMAP=false INLINE_RUNTIME_CHUNK=false pnpm coverage
# =======================================
# ===== Build image for the backend =====

View File

@ -20,3 +20,4 @@ bootstrap.sh
# Overrides
!.healthcheck.env
!.pnpm-store

View File

@ -8,7 +8,7 @@ WORKDIR /node/src/app
COPY web ./
# Install the dependencies and build
RUN yarn install --frozen-lockfile && GENERATE_SOURCEMAP=false INLINE_RUNTIME_CHUNK=false yarn coverage
RUN yarn install --frozen-lockfile && GENERATE_SOURCEMAP=false INLINE_RUNTIME_CHUNK=false yarn build
# =======================================
# ===== Build image for the backend =====

View File

@ -191,14 +191,16 @@ func readVersion(cmd string, args ...string) {
func readVersions() {
readVersion("go", "version")
readVersion("node", "--version")
readVersion("pnpm", "--version")
readVersion("docker", "--version")
readVersion("docker-compose", "--version")
readVersion("docker-compose", "version")
}
// Bootstrap bootstrap authelia dev environment.
func Bootstrap(cobraCmd *cobra.Command, args []string) {
bootstrapPrintln("Checking command installation...")
checkCommandExist("node")
checkCommandExist("pnpm")
checkCommandExist("docker")
checkCommandExist("docker-compose")

View File

@ -66,7 +66,7 @@ func buildAutheliaBinary(xflags []string, buildkite bool) {
}
func buildFrontend() {
cmd := utils.CommandWithStdout("yarn", "install")
cmd := utils.CommandWithStdout("pnpm", "install", "--shamefully-hoist")
cmd.Dir = webDirectory
err := cmd.Run()
@ -74,7 +74,7 @@ func buildFrontend() {
log.Fatal(err)
}
cmd = utils.CommandWithStdout("yarn", "build")
cmd = utils.CommandWithStdout("pnpm", "build")
cmd.Dir = webDirectory
cmd.Env = append(os.Environ(), "GENERATE_SOURCEMAP=false", "INLINE_RUNTIME_CHUNK=false")

View File

@ -142,7 +142,7 @@ func runSuiteSetupTeardown(command string, suite string) error {
if _, err := os.Stat("../../web/.nyc_output"); err == nil {
log.Infof("Generating frontend coverage reports for suite %s...", suite)
cmd := utils.Command("yarn", "report")
cmd := utils.Command("pnpm", "report")
cmd.Dir = "web"
cmd.Env = os.Environ()

View File

@ -17,7 +17,7 @@ func RunUnitTest(cobraCmd *cobra.Command, args []string) {
log.Fatal(err)
}
cmd := utils.Shell("yarn test")
cmd := utils.Shell("pnpm test")
cmd.Dir = webDirectory
cmd.Env = append(os.Environ(), "CI=true")

View File

@ -11,7 +11,7 @@ type Docker struct{}
func (d *Docker) Build(tag, dockerfile, target, ldflags string) error {
return utils.CommandWithStdout(
"docker", "build", "-t", tag, "-f", dockerfile,
"--build-arg", "LDFLAGS_EXTRA="+ldflags,
"--progress=plain", "--build-arg", "LDFLAGS_EXTRA="+ldflags,
target).Run()
}

View File

@ -34,10 +34,10 @@ Here are the versions used for testing in Buildkite:
```console
$ docker --version
Docker version 19.03.5, build 633a0ea838
Docker version 20.10.8, build 3967b7d
$ docker-compose --version
docker-compose version 1.24.1, build unknown
docker-compose version 1.28.0, build unknown
```
### How can I serve my application under example.com?

View File

@ -3,7 +3,9 @@ FROM node:16-alpine
ARG USER_ID
ARG GROUP_ID
RUN deluser node && \
RUN yarn global add pnpm && \
pnpm config set --global store-dir /tmp/.pnpm-store && \
deluser node && \
addgroup --gid ${GROUP_ID} dev && \
adduser --uid ${USER_ID} -G dev -D dev

View File

@ -14,6 +14,7 @@ services:
volumes:
- './example/compose/authelia/resources/:/resources'
- '../../web:/app'
- '~/.pnpm-store:/tmp/.pnpm-store'
labels:
# Traefik 1.x
- 'traefik.frontend.rule=Host:login.example.com'

View File

@ -2,4 +2,4 @@
set -x
yarn install --frozen-lockfile && yarn start
pnpm install --shamefully-hoist --frozen-lockfile && pnpm start

View File

@ -29,7 +29,7 @@
"coverage": "COVERAGE=true craco build",
"test": "craco test --coverage --no-cache",
"report": "nyc report -r clover -r json -r lcov -r text",
"eject": "react-scripts eject"
"commitlint": "commitlint --edit $1"
},
"eslintConfig": {
"extends": "react-app"

13324
web/pnpm-lock.yaml 100644

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff