From 1048150654a2eb488240dfb07e02fc0b81b65086 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 15 May 2017 12:58:20 -0400 Subject: [PATCH] chore: check that there are no unstaged shrinkwrap changes (#1379) See: https://github.com/resin-io/etcher/pull/1372 Signed-off-by: Juan Cruz Viotti --- .travis.yml | 2 +- Makefile | 3 +- appveyor.yml | 4 +-- package.json | 3 -- scripts/build/docker/Dockerfile-i686 | 2 +- scripts/build/docker/Dockerfile-x86_64 | 2 +- scripts/build/docker/Dockerfile.template | 2 +- .../build/electron-installer-debian-linux.sh | 6 ++-- scripts/ci/appveyor-deploy.bat | 2 +- scripts/ci/appveyor-install.bat | 16 ++++----- scripts/ci/appveyor-test.bat | 4 +-- .../ensure-all-node-requirements-available.sh | 4 +-- scripts/ci/ensure-staged-sass.sh | 18 +++++++++- scripts/ci/ensure-staged-shrinkwrap.sh | 36 +++++++++++++++++++ scripts/ci/travis-install.sh | 3 +- scripts/clean-shrinkwrap.js | 3 +- 16 files changed, 78 insertions(+), 32 deletions(-) create mode 100755 scripts/ci/ensure-staged-shrinkwrap.sh diff --git a/.travis.yml b/.travis.yml index 63d428db..f82e83c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js sudo: false node_js: - - "6.1.0" + - "6.10.3" services: - docker diff --git a/Makefile b/Makefile index b3456918..8bf7cb44 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ BUILD_OUTPUT_DIRECTORY = $(BUILD_DIRECTORY)/out # --------------------------------------------------------------------- ELECTRON_VERSION = $(shell jq -r '.devDependencies["electron"]' package.json) -NODE_VERSION = 6.1.0 +NODE_VERSION = 6.10.3 COMPANY_NAME = $(shell jq -r '.companyName' package.json) APPLICATION_NAME = $(shell jq -r '.displayName' package.json) APPLICATION_DESCRIPTION = $(shell jq -r '.description' package.json) @@ -541,6 +541,7 @@ info: sanity-checks: ./scripts/ci/ensure-all-node-requirements-available.sh ./scripts/ci/ensure-staged-sass.sh + ./scripts/ci/ensure-staged-shrinkwrap.sh ./scripts/ci/ensure-npm-dependencies-compatibility.sh ./scripts/ci/ensure-npm-valid-dependencies.sh ./scripts/ci/ensure-npm-shrinkwrap-versions.sh diff --git a/appveyor.yml b/appveyor.yml index ab1a20ea..7976c1c8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,7 +14,7 @@ cache: environment: global: ELECTRON_NO_ATTACH_CONSOLE: true - nodejs_version: 6.1.0 + nodejs_version: "6.10.3" matrix: - TARGET_ARCH: x64 - TARGET_ARCH: x86 @@ -23,7 +23,7 @@ matrix: fast_finish: true install: - - ps: Install-Product node $env:nodejs_version x64 + - ps: Update-NodeJsInstallation $env:nodejs_version $env:TARGET_ARCH - set PATH=C:\Program Files (x86)\Windows Kits\8.1\bin\x86;%PATH% - set PATH=C:\Program Files (x86)\NSIS;%PATH% - set PATH=C:\MinGW\bin;%PATH% diff --git a/package.json b/package.json index 522d4b82..d35f1b6b 100644 --- a/package.json +++ b/package.json @@ -64,9 +64,6 @@ "verbosity": 1 } }, - "optionalDependencies": { - "electron-installer-debian": "0.5.1" - }, "dependencies": { "angular": "1.6.3", "angular-if-state": "^1.0.0", diff --git a/scripts/build/docker/Dockerfile-i686 b/scripts/build/docker/Dockerfile-i686 index f41486b7..8735b8b1 100644 --- a/scripts/build/docker/Dockerfile-i686 +++ b/scripts/build/docker/Dockerfile-i686 @@ -34,7 +34,7 @@ RUN add-apt-repository ppa:ubuntu-toolchain-r/test \ RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \ && apt-get install -y nodejs RUN npm config set spin=false -RUN npm install -g uglify-es@3.0.3 +RUN npm install -g uglify-es@3.0.3 electron-installer-debian@0.5.1 # Python RUN pip install codespell==1.9.2 awscli cpplint diff --git a/scripts/build/docker/Dockerfile-x86_64 b/scripts/build/docker/Dockerfile-x86_64 index 711ebdbf..c6b7ae6d 100644 --- a/scripts/build/docker/Dockerfile-x86_64 +++ b/scripts/build/docker/Dockerfile-x86_64 @@ -34,7 +34,7 @@ RUN add-apt-repository ppa:ubuntu-toolchain-r/test \ RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \ && apt-get install -y nodejs RUN npm config set spin=false -RUN npm install -g uglify-es@3.0.3 +RUN npm install -g uglify-es@3.0.3 electron-installer-debian@0.5.1 # Python RUN pip install codespell==1.9.2 awscli cpplint diff --git a/scripts/build/docker/Dockerfile.template b/scripts/build/docker/Dockerfile.template index 11be29df..8460cd1f 100644 --- a/scripts/build/docker/Dockerfile.template +++ b/scripts/build/docker/Dockerfile.template @@ -34,7 +34,7 @@ RUN add-apt-repository ppa:ubuntu-toolchain-r/test \ RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \ && apt-get install -y nodejs RUN npm config set spin=false -RUN npm install -g uglify-es@3.0.3 +RUN npm install -g uglify-es@3.0.3 electron-installer-debian@0.5.1 # Python RUN pip install codespell==1.9.2 awscli cpplint diff --git a/scripts/build/electron-installer-debian-linux.sh b/scripts/build/electron-installer-debian-linux.sh index 24083ad2..b82e1015 100755 --- a/scripts/build/electron-installer-debian-linux.sh +++ b/scripts/build/electron-installer-debian-linux.sh @@ -25,9 +25,7 @@ if [[ "$OS" != "Linux" ]]; then exit 1 fi -ELECTRON_INSTALLER_DEBIAN="./node_modules/.bin/electron-installer-debian" - -./scripts/build/check-dependency.sh "$ELECTRON_INSTALLER_DEBIAN" +./scripts/build/check-dependency.sh electron-installer-debian function usage() { echo "Usage: $0" @@ -67,7 +65,7 @@ fi DEBIAN_ARCHITECTURE=$(./scripts/build/architecture-convert.sh -r "$ARGV_ARCHITECTURE" -t debian) cp scripts/build/debian/etcher-electron.sh "$ARGV_DIRECTORY" -"$ELECTRON_INSTALLER_DEBIAN" \ +electron-installer-debian \ --src "$ARGV_DIRECTORY" \ --dest "$ARGV_OUTPUT" \ --config "$ARGV_DEBIAN_CONFIGURATION" \ diff --git a/scripts/ci/appveyor-deploy.bat b/scripts/ci/appveyor-deploy.bat index 0b09494b..69d233dd 100755 --- a/scripts/ci/appveyor-deploy.bat +++ b/scripts/ci/appveyor-deploy.bat @@ -20,7 +20,7 @@ IF "%APPVEYOR_REPO_BRANCH%"=="" ( ) IF %APPVEYOR_REPO_BRANCH%==master ( - call make publish-aws-s3 + call make publish-aws-s3 || ( EXIT /B 1 ) ) EXIT /B %ERRORLEVEL% diff --git a/scripts/ci/appveyor-install.bat b/scripts/ci/appveyor-install.bat index c01ff338..566ab03e 100755 --- a/scripts/ci/appveyor-install.bat +++ b/scripts/ci/appveyor-install.bat @@ -19,16 +19,16 @@ IF "%APPVEYOR_REPO_BRANCH%"=="" ( EXIT /B 1 ) -call npm config set spin=false -call npm install -g npm@4.4.4 uglify-es@3.0.3 +call npm config set spin=false || ( EXIT /B 1 ) +call npm install -g uglify-es@3.0.3 || ( EXIT /B 1 ) -call choco install nsis -version 2.51 -call choco install jq -call choco install curl +call choco install nsis -version 2.51 || ( EXIT /B 1 ) +call choco install jq || ( EXIT /B 1 ) +call choco install curl || ( EXIT /B 1 ) -call pip install codespell==1.9.2 awscli cpplint +call pip install codespell==1.9.2 awscli cpplint || ( EXIT /B 1 ) -call make info -call make electron-develop +call make info || ( EXIT /B 1 ) +call make electron-develop || ( EXIT /B 1 ) EXIT /B %ERRORLEVEL% diff --git a/scripts/ci/appveyor-test.bat b/scripts/ci/appveyor-test.bat index 06799641..f454d570 100755 --- a/scripts/ci/appveyor-test.bat +++ b/scripts/ci/appveyor-test.bat @@ -19,7 +19,7 @@ IF "%APPVEYOR_REPO_BRANCH%"=="" ( EXIT /B 1 ) -call make sanity-checks -call npm test +call make sanity-checks || ( EXIT /B 1 ) +call npm test || ( EXIT /B 1 ) EXIT /B %ERRORLEVEL% diff --git a/scripts/ci/ensure-all-node-requirements-available.sh b/scripts/ci/ensure-all-node-requirements-available.sh index d4c89c95..0c3efeb7 100755 --- a/scripts/ci/ensure-all-node-requirements-available.sh +++ b/scripts/ci/ensure-all-node-requirements-available.sh @@ -31,7 +31,7 @@ PACKAGE_JSON=package.json # workaround for path-length bug in jq that only affects Windows https://github.com/stedolan/jq/issues/1155 NODE_MODULES=($(cat "$HERE/builtin-modules.json" | jq -r '.[]')) NPM_MODULES=($(jq -r '.dependencies | keys | .[]' "$PACKAGE_JSON")) -NPM_OPTIONAL_MODULES=($(jq -r '.optionalDependencies | keys | .[]' "$PACKAGE_JSON")) +NPM_OPTIONAL_MODULES=($(jq -r '.optionalDependencies // {} | keys | .[]' "$PACKAGE_JSON")) NPM_DEV_MODULES=($(jq -r '.devDependencies | keys | .[]' "$PACKAGE_JSON")) DEV_FILES_REGEX=^\(tests\|scripts\)/ @@ -91,7 +91,7 @@ git ls-tree -r HEAD | while IFS='' read line; do done fi # Check optionalDependencies from package.json - if [[ $requirement_found -eq 0 ]]; then + if [[ $requirement_found -eq 0 ]] && [[ -n "${NPM_OPTIONAL_MODULES:-}" ]]; then for module in "${NPM_OPTIONAL_MODULES[@]}"; do if [[ "$required" == "$module" ]]; then requirement_found=1 diff --git a/scripts/ci/ensure-staged-sass.sh b/scripts/ci/ensure-staged-sass.sh index fed53489..d7e6d68f 100755 --- a/scripts/ci/ensure-staged-sass.sh +++ b/scripts/ci/ensure-staged-sass.sh @@ -1,12 +1,28 @@ #!/bin/bash +### +# Copyright 2017 resin.io +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +### + set -e set -u npm run sass # From http://stackoverflow.com/a/9393642/1641422 -if [[ -n $(git status -s) ]]; then +if [[ -n $(git status -s | grep "\\.css$" || true) ]]; then echo "There are unstaged sass changes. Please commit the result of:" 1>&2 echo "" echo " npm run sass" 1>&2 diff --git a/scripts/ci/ensure-staged-shrinkwrap.sh b/scripts/ci/ensure-staged-shrinkwrap.sh new file mode 100755 index 00000000..544bcf29 --- /dev/null +++ b/scripts/ci/ensure-staged-shrinkwrap.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +### +# Copyright 2017 resin.io +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +### + +set -e +set -u + +echo "node version: $(node --version)" +echo "npm version: $(npm --version)" + +SHRINKWRAP_FILE=npm-shrinkwrap.json + +npm shrinkwrap --dev + +if [[ -n $(git status -s "$SHRINKWRAP_FILE") ]]; then + echo "There are unstaged $SHRINKWRAP_FILE changes. Please commit the result of:" 1>&2 + echo "" + echo " npm shrinkwrap --dev" 1>&2 + echo "" + git --no-pager diff "$SHRINKWRAP_FILE" + exit 1 +fi diff --git a/scripts/ci/travis-install.sh b/scripts/ci/travis-install.sh index 57b3507c..1b0019e7 100755 --- a/scripts/ci/travis-install.sh +++ b/scripts/ci/travis-install.sh @@ -35,9 +35,8 @@ else ./scripts/build/check-dependency.sh make ./scripts/build/check-dependency.sh npm - npm install -g npm@3.10.10 uglify-es@3.0.3 npm config set spin=false - + npm install -g uglify-es@3.0.3 pip install codespell==1.9.2 awscli cpplint brew install afsctool jq make info diff --git a/scripts/clean-shrinkwrap.js b/scripts/clean-shrinkwrap.js index 6fbca398..d4a7ae84 100644 --- a/scripts/clean-shrinkwrap.js +++ b/scripts/clean-shrinkwrap.js @@ -15,11 +15,10 @@ 'use strict'; -const _ = require('lodash'); const path = require('path'); const packageJSON = require('../package.json'); const spawn = require('child_process').spawn; -const shrinkwrapIgnore = _.union(packageJSON.shrinkwrapIgnore, _.keys(packageJSON.optionalDependencies)); +const shrinkwrapIgnore = packageJSON.shrinkwrapIgnore; console.log('Removing:', shrinkwrapIgnore.join(', '));