mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
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
This commit is contained in:
parent
2f3f0818c3
commit
3d312cf3b9
|
@ -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
|
||||
|
|
|
@ -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
3
.github/commit-msg
vendored
|
@ -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
3
.github/pre-commit
vendored
|
@ -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
Normal file
19
.github/required-apps
vendored
Normal 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
|
|
@ -3,6 +3,7 @@ extends: default
|
|||
|
||||
ignore: |
|
||||
internal/configuration/test_resources/config_bad_quoting.yml
|
||||
web/pnpm-lock.yaml
|
||||
web/node_modules/
|
||||
|
||||
rules:
|
||||
|
|
|
@ -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 =====
|
||||
|
|
|
@ -19,4 +19,5 @@ authelia.service
|
|||
bootstrap.sh
|
||||
|
||||
# Overrides
|
||||
!.healthcheck.env
|
||||
!.healthcheck.env
|
||||
!.pnpm-store
|
|
@ -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 =====
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
set -x
|
||||
|
||||
yarn install --frozen-lockfile && yarn start
|
||||
pnpm install --shamefully-hoist --frozen-lockfile && pnpm start
|
|
@ -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
Normal file
13324
web/pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load Diff
12773
web/yarn.lock
12773
web/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user