From 02be8e8703eee2a6a8c259825a5c4535e7bd77b4 Mon Sep 17 00:00:00 2001 From: George Song Date: Wed, 22 Sep 2021 13:11:52 -0700 Subject: [PATCH] build: workaround npm _install_ behavior around scripts * Consolidate dev setup with `npm run setup` which will run `presetup` * CI needs to run `presetup` manually and run `npm i --ignore-scripts` so we don't try to run `husky install` in the `prepare` stage See https://github.com/npm/cli/issues/2660 --- .github/workflows/deploy-develop.yml | 4 ++-- .github/workflows/deploy-draft.yml | 4 ++-- .github/workflows/deploy-main.yml | 4 ++-- docker/docker-compose.quickstart.yaml | 3 +-- docker/images/Dockerfile.quickstart | 3 +-- package-lock.json | 1 - package.json | 5 +++-- 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy-develop.yml b/.github/workflows/deploy-develop.yml index 59f736f4050..f807ec6d8ab 100644 --- a/.github/workflows/deploy-develop.yml +++ b/.github/workflows/deploy-develop.yml @@ -29,8 +29,8 @@ jobs: NODE_ENV: ${{ secrets.NODE_ENV }} - name: npm install run: | - npm run preinstall - npm install + npm run presetup + npm install --ignore-scripts env: NODE_ENV: ${{ secrets.NODE_ENV }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/deploy-draft.yml b/.github/workflows/deploy-draft.yml index 376707a2ce1..23f95be311a 100644 --- a/.github/workflows/deploy-draft.yml +++ b/.github/workflows/deploy-draft.yml @@ -52,8 +52,8 @@ jobs: NODE_ENV: ${{ secrets.NODE_ENV }} - name: Install dependencies run: | - npm run preinstall - npm install --immutable + npm run presetup + npm install --ignore-scripts env: NODE_ENV: ${{ secrets.NODE_ENV }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/deploy-main.yml b/.github/workflows/deploy-main.yml index 43e0e3580dd..7b359ba9230 100644 --- a/.github/workflows/deploy-main.yml +++ b/.github/workflows/deploy-main.yml @@ -30,8 +30,8 @@ jobs: NODE_ENV: ${{ secrets.NODE_ENV }} - name: npm install run: | - npm run preinstall - npm install + npm run presetup + npm install --ignore-scripts env: NODE_ENV: ${{ secrets.NODE_ENV }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/docker/docker-compose.quickstart.yaml b/docker/docker-compose.quickstart.yaml index 1469ac4e92b..9490f91c3b1 100644 --- a/docker/docker-compose.quickstart.yaml +++ b/docker/docker-compose.quickstart.yaml @@ -14,8 +14,7 @@ services: - ../.env.development init: true command: > - sh -c "npm run preinstall --if-present && - scripts/npm-install.sh && + sh -c "npm run setup && npm run develop -- -H 0.0.0.0 -p ${PORT:-8000} 2>&1" ports: - ${PORT:-8000}:${PORT:-8000} diff --git a/docker/images/Dockerfile.quickstart b/docker/images/Dockerfile.quickstart index 694a0047b51..df671e08955 100644 --- a/docker/images/Dockerfile.quickstart +++ b/docker/images/Dockerfile.quickstart @@ -17,8 +17,7 @@ RUN apk update && apk --no-cache add \ pkgconfig ARG NPM_TOKEN -RUN npm run preinstall --if-present -RUN scripts/npm-install.sh +RUN npm run setup FROM base as dev-server diff --git a/package-lock.json b/package-lock.json index b053d0e7134..7c343155f80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,6 @@ "": { "name": "docs", "version": "0.1.0", - "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { "@enterprisedb/icons": "^1.4.0", diff --git a/package.json b/package.json index 479f3595c05..3bfbe54b37b 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,10 @@ "fix-mtimes": "python3 scripts/source/git-restore-mtime.py", "format": "prettier --write src/**/*.js gatsby-*.js", "logs": "docker-compose -f docker/docker-compose.quickstart.yaml logs -f", - "preinstall": "./scripts/npm-preinstall.sh", - "postinstall": "husky install", + "prepare": "husky install", + "presetup": "./scripts/npm-preinstall.sh", "serve-build": "gatsby serve --prefix-paths", + "setup": "./scripts/npm-install.sh", "shell": "docker exec -it edb-docs /bin/sh", "start": "docker-compose -f docker/docker-compose.quickstart.yaml up -d", "stop": "docker-compose -f docker/docker-compose.quickstart.yaml down",