add 'rake watch' tasks
Add two 'rake watch' tasks: - 'rake watch:server' Watch for changes using the Ruby web server. - 'rake watch:deploy:local' Watch for changes using a local web server (eg nginx). Fix #24
This commit is contained in:
parent
955e0ef1e2
commit
de1440b1d8
3 changed files with 42 additions and 10 deletions
7
Gemfile
7
Gemfile
|
@ -4,7 +4,7 @@ source "https://rubygems.org"
|
|||
gem "nanoc", "~> 4.12"
|
||||
gem "nanoc-live", "~> 1.0"
|
||||
gem "nanoc-gunzip.rb", "~> 0.1"
|
||||
gem "nanoc-webpack.rb", "~> 0.1", git: "https://github.com/0x1eef/nanoc-webpack.rb", branch: "feat/depends_on"
|
||||
gem "nanoc-webpack.rb", "~> 0.1"
|
||||
gem "rainpress", "~> 1.0"
|
||||
gem "sass"
|
||||
gem "standardrb"
|
||||
|
@ -13,3 +13,8 @@ gem "paint"
|
|||
gem "dotenv"
|
||||
gem "adsf"
|
||||
gem "puma"
|
||||
|
||||
require 'rbconfig'
|
||||
if RbConfig::CONFIG['target_os'] =~ /(?i-mx:bsd|dragonfly)/
|
||||
gem 'rb-kqueue', '>= 0.2'
|
||||
end
|
||||
|
|
15
Gemfile.lock
15
Gemfile.lock
|
@ -1,11 +1,3 @@
|
|||
GIT
|
||||
remote: https://github.com/0x1eef/nanoc-webpack.rb
|
||||
revision: d610596e4b3c0e83922cf0b80d2b40ec94d39b84
|
||||
branch: feat/depends_on
|
||||
specs:
|
||||
nanoc-webpack.rb (0.1.0)
|
||||
ryo.rb (~> 0.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
|
@ -80,6 +72,8 @@ GEM
|
|||
listen (~> 3.0)
|
||||
nanoc-cli (~> 4.11, >= 4.11.14)
|
||||
nanoc-core (~> 4.11, >= 4.11.14)
|
||||
nanoc-webpack.rb (0.1.0)
|
||||
ryo.rb (~> 0.3)
|
||||
nio4r (2.5.8)
|
||||
paint (2.3.0)
|
||||
parallel (1.22.1)
|
||||
|
@ -100,6 +94,8 @@ GEM
|
|||
rb-fsevent (0.11.2)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
rb-kqueue (0.2.8)
|
||||
ffi (>= 0.5.0)
|
||||
regexp_parser (2.6.0)
|
||||
rexml (3.2.5)
|
||||
rubocop (1.35.1)
|
||||
|
@ -150,10 +146,11 @@ DEPENDENCIES
|
|||
nanoc (~> 4.12)
|
||||
nanoc-gunzip.rb (~> 0.1)
|
||||
nanoc-live (~> 1.0)
|
||||
nanoc-webpack.rb (~> 0.1)!
|
||||
nanoc-webpack.rb (~> 0.1)
|
||||
paint
|
||||
puma
|
||||
rainpress (~> 1.0)
|
||||
rb-kqueue (>= 0.2)
|
||||
ryo.rb
|
||||
sass
|
||||
standardrb
|
||||
|
|
30
Rakefile.rb
30
Rakefile.rb
|
@ -2,14 +2,17 @@
|
|||
|
||||
require "bundler/setup"
|
||||
require "ryo"
|
||||
require "listen"
|
||||
require_relative "lib/tasks"
|
||||
include Tasks
|
||||
|
||||
namespace :nanoc do
|
||||
desc "Compile the website"
|
||||
task :compile do
|
||||
sh "nanoc co"
|
||||
end
|
||||
|
||||
desc "Delete the build directory"
|
||||
task :clean do
|
||||
build_dir = Ryo.from(YAML.load_file("./nanoc.yaml")).output_dir
|
||||
sh "rm -rf #{build_dir}"
|
||||
|
@ -17,38 +20,65 @@ namespace :nanoc do
|
|||
end
|
||||
task build: "nanoc:compile"
|
||||
|
||||
desc "Start a Ruby web server on localhost"
|
||||
task server: ["nanoc:compile"] do
|
||||
Dir.chdir(File.join(Dir.getwd, "build", "al-quran")) do
|
||||
sh "ruby -S bundle exec adsf"
|
||||
end
|
||||
end
|
||||
|
||||
namespace :watch do
|
||||
desc "Watch for changes (server task)"
|
||||
task :server do
|
||||
Listen.to(File.join(Dir.getwd, "src")) do
|
||||
Rake::Task["build"].invoke
|
||||
end.start
|
||||
Rake::Task["server"].invoke
|
||||
end
|
||||
|
||||
namespace :deploy do
|
||||
desc "Watch for changes (deploy:local task)"
|
||||
task :local do
|
||||
Listen.to(File.join(Dir.getwd, "src")) do
|
||||
Rake::Task["deploy:local"].invoke
|
||||
end.start
|
||||
sleep
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :deploy do
|
||||
desc "Deploy to a local web server (eg nginx)"
|
||||
task local: ["env:development", "nanoc:compile"] do
|
||||
Deploy::Local.call
|
||||
end
|
||||
|
||||
desc "Deploy to production"
|
||||
task remote: ["env:production", "nanoc:clean", "nanoc:compile"] do
|
||||
Deploy::Remote.call
|
||||
end
|
||||
end
|
||||
|
||||
namespace :env do
|
||||
desc "Set environment variables for the production environment"
|
||||
task :production do
|
||||
require "dotenv"
|
||||
Dotenv.load
|
||||
end
|
||||
|
||||
desc "Set environment variables for the development environment"
|
||||
task :development do
|
||||
ENV["NODE_ENV"] ||= "development"
|
||||
end
|
||||
end
|
||||
|
||||
namespace :linter do
|
||||
desc "Run the Ruby linter"
|
||||
task :ruby do
|
||||
sh "bundle exec rubocop lib/ src/"
|
||||
end
|
||||
|
||||
desc "Run the TypeScript linter"
|
||||
task :typescript do
|
||||
sh "npm run eslint"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue