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 <jviotti@openmailbox.org>
This commit is contained in:
Juan Cruz Viotti 2017-05-15 12:58:20 -04:00 committed by GitHub
parent 697c86362c
commit 1048150654
16 changed files with 78 additions and 32 deletions

View File

@ -1,7 +1,7 @@
language: node_js language: node_js
sudo: false sudo: false
node_js: node_js:
- "6.1.0" - "6.10.3"
services: services:
- docker - docker

View File

@ -19,7 +19,7 @@ BUILD_OUTPUT_DIRECTORY = $(BUILD_DIRECTORY)/out
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
ELECTRON_VERSION = $(shell jq -r '.devDependencies["electron"]' package.json) 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) COMPANY_NAME = $(shell jq -r '.companyName' package.json)
APPLICATION_NAME = $(shell jq -r '.displayName' package.json) APPLICATION_NAME = $(shell jq -r '.displayName' package.json)
APPLICATION_DESCRIPTION = $(shell jq -r '.description' package.json) APPLICATION_DESCRIPTION = $(shell jq -r '.description' package.json)
@ -541,6 +541,7 @@ info:
sanity-checks: sanity-checks:
./scripts/ci/ensure-all-node-requirements-available.sh ./scripts/ci/ensure-all-node-requirements-available.sh
./scripts/ci/ensure-staged-sass.sh ./scripts/ci/ensure-staged-sass.sh
./scripts/ci/ensure-staged-shrinkwrap.sh
./scripts/ci/ensure-npm-dependencies-compatibility.sh ./scripts/ci/ensure-npm-dependencies-compatibility.sh
./scripts/ci/ensure-npm-valid-dependencies.sh ./scripts/ci/ensure-npm-valid-dependencies.sh
./scripts/ci/ensure-npm-shrinkwrap-versions.sh ./scripts/ci/ensure-npm-shrinkwrap-versions.sh

View File

@ -14,7 +14,7 @@ cache:
environment: environment:
global: global:
ELECTRON_NO_ATTACH_CONSOLE: true ELECTRON_NO_ATTACH_CONSOLE: true
nodejs_version: 6.1.0 nodejs_version: "6.10.3"
matrix: matrix:
- TARGET_ARCH: x64 - TARGET_ARCH: x64
- TARGET_ARCH: x86 - TARGET_ARCH: x86
@ -23,7 +23,7 @@ matrix:
fast_finish: true fast_finish: true
install: 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)\Windows Kits\8.1\bin\x86;%PATH%
- set PATH=C:\Program Files (x86)\NSIS;%PATH% - set PATH=C:\Program Files (x86)\NSIS;%PATH%
- set PATH=C:\MinGW\bin;%PATH% - set PATH=C:\MinGW\bin;%PATH%

View File

@ -64,9 +64,6 @@
"verbosity": 1 "verbosity": 1
} }
}, },
"optionalDependencies": {
"electron-installer-debian": "0.5.1"
},
"dependencies": { "dependencies": {
"angular": "1.6.3", "angular": "1.6.3",
"angular-if-state": "^1.0.0", "angular-if-state": "^1.0.0",

View File

@ -34,7 +34,7 @@ RUN add-apt-repository ppa:ubuntu-toolchain-r/test \
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \ RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \
&& apt-get install -y nodejs && apt-get install -y nodejs
RUN npm config set spin=false 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 # Python
RUN pip install codespell==1.9.2 awscli cpplint RUN pip install codespell==1.9.2 awscli cpplint

View File

@ -34,7 +34,7 @@ RUN add-apt-repository ppa:ubuntu-toolchain-r/test \
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \ RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \
&& apt-get install -y nodejs && apt-get install -y nodejs
RUN npm config set spin=false 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 # Python
RUN pip install codespell==1.9.2 awscli cpplint RUN pip install codespell==1.9.2 awscli cpplint

View File

@ -34,7 +34,7 @@ RUN add-apt-repository ppa:ubuntu-toolchain-r/test \
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \ RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \
&& apt-get install -y nodejs && apt-get install -y nodejs
RUN npm config set spin=false 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 # Python
RUN pip install codespell==1.9.2 awscli cpplint RUN pip install codespell==1.9.2 awscli cpplint

View File

@ -25,9 +25,7 @@ if [[ "$OS" != "Linux" ]]; then
exit 1 exit 1
fi 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() { function usage() {
echo "Usage: $0" echo "Usage: $0"
@ -67,7 +65,7 @@ fi
DEBIAN_ARCHITECTURE=$(./scripts/build/architecture-convert.sh -r "$ARGV_ARCHITECTURE" -t debian) DEBIAN_ARCHITECTURE=$(./scripts/build/architecture-convert.sh -r "$ARGV_ARCHITECTURE" -t debian)
cp scripts/build/debian/etcher-electron.sh "$ARGV_DIRECTORY" cp scripts/build/debian/etcher-electron.sh "$ARGV_DIRECTORY"
"$ELECTRON_INSTALLER_DEBIAN" \ electron-installer-debian \
--src "$ARGV_DIRECTORY" \ --src "$ARGV_DIRECTORY" \
--dest "$ARGV_OUTPUT" \ --dest "$ARGV_OUTPUT" \
--config "$ARGV_DEBIAN_CONFIGURATION" \ --config "$ARGV_DEBIAN_CONFIGURATION" \

View File

@ -20,7 +20,7 @@ IF "%APPVEYOR_REPO_BRANCH%"=="" (
) )
IF %APPVEYOR_REPO_BRANCH%==master ( IF %APPVEYOR_REPO_BRANCH%==master (
call make publish-aws-s3 call make publish-aws-s3 || ( EXIT /B 1 )
) )
EXIT /B %ERRORLEVEL% EXIT /B %ERRORLEVEL%

View File

@ -19,16 +19,16 @@ IF "%APPVEYOR_REPO_BRANCH%"=="" (
EXIT /B 1 EXIT /B 1
) )
call npm config set spin=false call npm config set spin=false || ( EXIT /B 1 )
call npm install -g npm@4.4.4 uglify-es@3.0.3 call npm install -g uglify-es@3.0.3 || ( EXIT /B 1 )
call choco install nsis -version 2.51 call choco install nsis -version 2.51 || ( EXIT /B 1 )
call choco install jq call choco install jq || ( EXIT /B 1 )
call choco install curl 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 info || ( EXIT /B 1 )
call make electron-develop call make electron-develop || ( EXIT /B 1 )
EXIT /B %ERRORLEVEL% EXIT /B %ERRORLEVEL%

View File

@ -19,7 +19,7 @@ IF "%APPVEYOR_REPO_BRANCH%"=="" (
EXIT /B 1 EXIT /B 1
) )
call make sanity-checks call make sanity-checks || ( EXIT /B 1 )
call npm test call npm test || ( EXIT /B 1 )
EXIT /B %ERRORLEVEL% EXIT /B %ERRORLEVEL%

View File

@ -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 # 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 '.[]')) NODE_MODULES=($(cat "$HERE/builtin-modules.json" | jq -r '.[]'))
NPM_MODULES=($(jq -r '.dependencies | keys | .[]' "$PACKAGE_JSON")) 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")) NPM_DEV_MODULES=($(jq -r '.devDependencies | keys | .[]' "$PACKAGE_JSON"))
DEV_FILES_REGEX=^\(tests\|scripts\)/ DEV_FILES_REGEX=^\(tests\|scripts\)/
@ -91,7 +91,7 @@ git ls-tree -r HEAD | while IFS='' read line; do
done done
fi fi
# Check optionalDependencies from package.json # 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 for module in "${NPM_OPTIONAL_MODULES[@]}"; do
if [[ "$required" == "$module" ]]; then if [[ "$required" == "$module" ]]; then
requirement_found=1 requirement_found=1

View File

@ -1,12 +1,28 @@
#!/bin/bash #!/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 -e
set -u set -u
npm run sass npm run sass
# From http://stackoverflow.com/a/9393642/1641422 # 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 "There are unstaged sass changes. Please commit the result of:" 1>&2
echo "" echo ""
echo " npm run sass" 1>&2 echo " npm run sass" 1>&2

View File

@ -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

View File

@ -35,9 +35,8 @@ else
./scripts/build/check-dependency.sh make ./scripts/build/check-dependency.sh make
./scripts/build/check-dependency.sh npm ./scripts/build/check-dependency.sh npm
npm install -g npm@3.10.10 uglify-es@3.0.3
npm config set spin=false npm config set spin=false
npm install -g uglify-es@3.0.3
pip install codespell==1.9.2 awscli cpplint pip install codespell==1.9.2 awscli cpplint
brew install afsctool jq brew install afsctool jq
make info make info

View File

@ -15,11 +15,10 @@
'use strict'; 'use strict';
const _ = require('lodash');
const path = require('path'); const path = require('path');
const packageJSON = require('../package.json'); const packageJSON = require('../package.json');
const spawn = require('child_process').spawn; const spawn = require('child_process').spawn;
const shrinkwrapIgnore = _.union(packageJSON.shrinkwrapIgnore, _.keys(packageJSON.optionalDependencies)); const shrinkwrapIgnore = packageJSON.shrinkwrapIgnore;
console.log('Removing:', shrinkwrapIgnore.join(', ')); console.log('Removing:', shrinkwrapIgnore.join(', '));