Skip to content

Commit

Permalink
fix: drop yarn in favour of npm per upstream
Browse files Browse the repository at this point in the history
In signalapp/Signal-Desktop@2478bf1b the upstream
moved from using yarn to using npm for their build
tooling.

This commit updates the snapcraft.yaml to follow suit.
  • Loading branch information
jnsgruk committed Jul 3, 2024
1 parent 99931a8 commit 797f135
Showing 1 changed file with 24 additions and 32 deletions.
56 changes: 24 additions & 32 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,18 @@ parts:
LINUX_CI_STEPS="$(curl -s "${UPSTREAM_URL}/.github/workflows/ci.yml")"
NODE_VERSION="$(curl "${UPSTREAM_URL}/package.json" | jq -r '.engines.node')"
YARN_VERSION="$(echo "$LINUX_CI_STEPS" | grep -m1 -Po "npm install -g yarn@\K[^ ]+")"
NPM_VERSION="$(echo "$LINUX_CI_STEPS" | grep -m1 -Po "npm install -g yarn@[\d.]+ npm@\K[^ ]+")"
NPM_VERSION="$(echo "$LINUX_CI_STEPS" | grep -m1 -Po "npm install -g npm@\K[^ ]+")"
# Install the correct version of nodejs required by Signal-Desktop
asdf plugin add nodejs
asdf install nodejs "$NODE_VERSION"
asdf global nodejs "$NODE_VERSION"
# Configure NPM proxy
npm config set proxy "${http_proxy:-}"
npm config set https-proxy "${https_proxy:-}"
# Install and configure Yarn
npm install -g "yarn@${YARN_VERSION}" "npm@${NPM_VERSION}"
yarn config set python /usr/bin/python3
yarn config set proxy "${http_proxy:-}"
yarn config set https-proxy "${https_proxy:-}"
npm config set -g registry https://registry.npmjs.org/
npm config set -g proxy "${http_proxy:-}"
npm config set -g https-proxy "${http_proxy:-}"
npm install -g "npm@${NPM_VERSION}"
signal-desktop:
after:
Expand All @@ -111,25 +106,22 @@ parts:
build-environment:
- SIGNAL_ENV: "production"
override-build: |
# Use the version of nodejs/yarn we configured before
# Use the version of nodejs we configured before
source "$(pwd)/../../nodejs/build/asdf.sh"
git lfs install
# Disable yarn auto clean functionality
rm .yarnclean
# If we're in a proxy environment, we need to patch some packages
if [[ -n "${http_proxy:-}" ]]; then
# Setup proxy access
export HTTP_PROXY="${http_proxy}"
export HTTPS_PROXY="${https_proxy}"
export HTTPS_PROXY="${http_proxy}"
export ELECTRON_GET_USE_PROXY=1
export GLOBAL_AGENT_HTTP_PROXY="${http_proxy}"
export GLOBAL_AGENT_HTTPS_PROXY="${http_proxy}"
# The patch applied uses this package to ensure proxy is used
yarn global add https-proxy-agent
npm install https-proxy-agent
# Update the package.json so the build uses the patched libraries
cat package.json \
Expand All @@ -139,30 +131,30 @@ parts:
# Build the sticker-creator
pushd sticker-creator
yarn install
yarn build
npm ci --legacy-peer-deps
npm run build
popd
# Install the dependencies for the Signal-Desktop application.
# We cannot use `--frozen-lockfile` due to the patching above.
yarn install
npm install
npm ci --legacy-peer-deps
# This is the equivalent of 'yarn generate'. The upstream package.json
# This is the equivalent of 'npm run generate'. The upstream package.json
# uses npm-run-all to run multiple things, which has a bug that prevents
# this from succeeding in the snapcraft build env, so this just breaks
# that apart into its component parts.
yarn build-protobuf
yarn build:esbuild
yarn build:icu-types
yarn build:compact-locales
yarn sass
yarn get-expire-time
yarn copy-components
# This is the equivalent of 'yarn build-linux' which also runs 'yarn generate'
npm run build-protobuf
npm run build:esbuild
npm run build:icu-types
npm run build:compact-locales
npm run sass
npm run get-expire-time
npm run copy-components
# This is the equivalent of 'npm run build-linux' which also runs 'npm run generate'
# which is broken (as described above).
yarn build:esbuild:prod
yarn build:release --linux dir
npm run build:esbuild:prod
npm run build:release -- --linux dir
# Stage the built release. Directory is called 'linux-unpacked' for amd64,
# and 'linux-arm64-unpacked' for arm64.
Expand Down

0 comments on commit 797f135

Please sign in to comment.