Skip to content

Instantly share code, notes, and snippets.

@swalkinshaw

swalkinshaw/Capfile

Last active Feb 28, 2017
Embed
What would you like to do?
Sage + Capistrano
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
# Load tasks from gems
require 'capistrano/bower'
require 'capistrano/gulp'
require 'capistrano/npm'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
# Customize this path to change the location of your custom tasks.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
set :application, 'my_app_name'
set :repo_url, 'git@example.com:me/my_repo.git'
set :branch, :master
set :deploy_to, -> { "/srv/www/#{fetch(:application)}" }
set :log_level, :info
# rest of the usual config
set :npm_flags, %w(--silent --no-progress)
set :gulp_tasks, '--production'
set :gulp_file, -> { release_path.join('path/to/sage/Gulpfile.js') }
set :gulp_target_path, -> { release_path.join('path/to/sage') }
namespace :deploy do
before :updated, 'gulp'
end
gem 'capistrano'
gem 'capistrano-bower'
gem 'capistrano-gulp'
gem 'capistrano-npm'
@alicam

This comment has been minimized.

Copy link

@alicam alicam commented Aug 9, 2016

Thanks Scott. I'm further towards getting a Sage build to work, but no luck yet. I'm stuck with this error during the deploy to staging:

DEBUG[80b7fdee] Command: cd /srv/users/serverpilot/apps/clear/releases/20160809065451/web/app/themes/clear2016 && ( WP_ENV=staging /usr/bin/env gulp --no-color --gulpfile /srv/users/serverpilot/apps/clear/releases/20160809065451/web/app/themes/clear2016/gulpfile.js )
DEBUG[80b7fdee] [02:55:24]
DEBUG[80b7fdee] Local gulp not found in ~/apps/clear/releases/20160809065451/web/app/themes/clear2016
DEBUG[80b7fdee] [02:55:24]
DEBUG[80b7fdee] Try running: npm install gulp
cap aborted!

I DO have gulp installed globally. I assume it can't be installed locally... this is a release that was just loaded earlier in the same build script so how or when does a local gulp install happen, before which I assume it can't be found, hence the above error?

I hope I'm making sense.

I feel like there is an "npm install gulp" that's meant to be in my build script and isn't. Is that possible?

SO sorry. Totally noob here trying something I'm barely understanding :)

A

@alicam

This comment has been minimized.

Copy link

@alicam alicam commented Aug 9, 2016

Also read elsewhere that set :gulp_tasks, '--production' is not appropriate for staging because it means that the devDependencies in package.json are skipped? So I have removed that, assuming that's true(?).

@swalkinshaw

This comment has been minimized.

Copy link
Owner Author

@swalkinshaw swalkinshaw commented Aug 9, 2016

Try adding set :npm_flags, %w(--silent --no-progress). You are right about devDependencies but had the wrong place. That's to do with npm and not gulp.

@alicam

This comment has been minimized.

Copy link

@alicam alicam commented Aug 10, 2016

Excellent. Last one, I hope!

The dependency "tree" on my local/dev machine ends up creating tons of node_modules directories. But in staging, there are many fewer. And then I get dependency errors when the gulp task runs, saying dependent modules weren't found.

Should the staging/prod server configs mean that a different number of node_modules be loaded?? Seems strange.

@alicam

This comment has been minimized.

Copy link

@alicam alicam commented Aug 10, 2016

No wait. It worked later. Possible an i/o error on the machine?! Scratch that either way!

@rjksn

This comment has been minimized.

Copy link

@rjksn rjksn commented Feb 28, 2017

Is this still relevant since it seems 9.0.0-beta.2 uses yarn instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment