require yarn, not npm

Change-Id: I2dbb037d4cbb0de7952dde19196c6937d18924e9
Reviewed-on: https://gerrit.instructure.com/122554
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Cody Cutrer 2017-08-12 12:25:33 -06:00
parent 5418ceed1f
commit 622ed3314a
9 changed files with 22 additions and 33 deletions

View File

@ -37,7 +37,7 @@ If you look at package.json, you can see there are 2 scripts for building
your assets with webpack (webpack and webpack-production). If you want to include
the translations (eg when you run webpack-production), make sure you've
run "rake i18nliner:generate_js" first so translations are in place,
webpack depends on those already existing. You can use these scripts with "npm run":
webpack depends on those already existing. You can use these scripts with "yarn run":
`yarn run webpack`

View File

@ -1,12 +1,6 @@
#!/bin/bash
set -e
if hash yarn 2>/dev/null; then
yarn install
yarn test
else
echo "npm is deprecated in canvas-lms, install & use yarn instead"
npm install
npm test
fi
yarn install
yarn test

View File

@ -52,7 +52,7 @@ namespace :canvas do
if npm_install
log_time('Making sure node_modules are up to date') {
Rake::Task['js:npm_install'].invoke
Rake::Task['js:yarn_install'].invoke
}
end

View File

@ -13,14 +13,14 @@ namespace :js do
puts "Building client app '#{app_name}'"
if File.exists?('./package.json')
output = `yarn install || npm install` rescue `npm cache clean && npm install`
output = `yarn install`
unless $?.exitstatus == 0
puts "INSTALL FAILURE:\n#{output}"
raise "Package installation failure for client app #{app_name}"
end
end
puts "\tRunning 'npm run build'..."
puts "\tRunning 'yarn run build'..."
output = `./script/build`
unless $?.exitstatus == 0
puts "BUILD FAILURE:\n#{output}"
@ -38,18 +38,18 @@ namespace :js do
task :webpack do
if ENV['RAILS_ENV'] == 'production' || ENV['USE_OPTIMIZED_JS'] == 'true' || ENV['USE_OPTIMIZED_JS'] == 'True'
puts "--> Building PRODUCTION webpack bundles"
system "npm run webpack-production"
system "yarn run webpack-production"
else
puts "--> Building DEVELOPMENT webpack bundles"
system "npm run webpack-development"
system "yarn run webpack-development"
end
raise "Error running js:webpack: \nABORTING" if $?.exitstatus != 0
end
desc "Ensure up-to-date node environment"
task :npm_install do
task :yarn_install do
puts "node is: #{`node -v`.strip} (#{`which node`.strip})"
output = `yarn install || npm install`
output = `yarn install`
unless $?.success?
puts output
raise 'error running yarn install'

View File

@ -91,10 +91,10 @@ function rake_db_migrate_dev_and_test {
( echo " failed to migrate db (test) (see $LOG)"; kill -INT $$ )
}
function npm_install {
echo_console_and_log " Installing npm packages ..."
(yarn install || npm install) >>"$LOG" 2>&1 || \
( echo " failed to install npm packages (see $LOG)"; kill -INT $$ )
function yarn_install {
echo_console_and_log " Installing node packages ..."
yarn install >>"$LOG" 2>&1 || \
( echo " failed to install node packages (see $LOG)"; kill -INT $$ )
}
function compile_assets {
@ -117,7 +117,7 @@ function update_canvas {
rebase_canvas
bundle_install_with_check
rake_db_migrate_dev_and_test
npm_install
yarn_install
# skip if QUICK_MODE
if ! $1; then

View File

@ -3,6 +3,6 @@
# clean up old stuff
rm -rf vendor/bundle node_modules Gemfile.lock
bundle update
npm install
yarn install
bundle exec rake db:create db:initial_setup
script/docker_update_build.sh

View File

@ -1,5 +1,5 @@
#!/bin/bash
# little shortcut for doing npm install/update/whatever for each of our
# little shortcut for doing yarn install/update/whatever for each of our
# gems that do node-y stuff
# canvas (mis|ab)uses devDependencies, we try not to for these ones
@ -9,12 +9,7 @@ export NODE_ENV=production
for path in $(ls -1 gems/{,plugins/}*/package.json 2> /dev/null); do
pushd $(dirname $path) > /dev/null
if hash yarn 2>/dev/null; then
echo "running yarn $1 for $path"
yarn $1
else
echo "npm is deprecated in canvas-lms. You should start using yarn instead. see https://yarnpkg.com. Running npm $1 for $path"
npm $1
fi
echo "running yarn $1 for $path"
yarn $1
popd > /dev/null
done

View File

@ -7,7 +7,7 @@ git clean client_apps public spec/javascripts node_modules coverage-js gems/*/no
rm -rfv gems/plugins/*/node_modules
echo "yarn installing..."
(yarn install || npm install)
yarn install
echo "everything's clean, now compiling assets..."
bundle exec rake canvas:compile_assets

View File

@ -10,8 +10,8 @@ export JSPEC_WD=$(pwd)
# error messages if there is a spec that fails.
if [ "$1" == "--watch" ]; then
export JSPEC_PATH=$2
npm run test-watch --silent || true
yarn run test-watch --silent || true
else
export JSPEC_PATH=$1
npm run test || true
yarn run test || true
fi