-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
108 lines (87 loc) · 2.54 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << 'spec'
t.pattern = 'spec/**/*_spec.rb'
end
def find_pkg(dir, name, glob)
Dir.chdir dir do
cp = CompiledPackage.get(name)
globs = Dir.glob(glob)
if block_given?
found = yield globs
else
found = globs.first
end
if found
cp.filename = found;
cp.save
else
cp.delete
end
end
end
desc 'Start a console'
task :console do
ENV['RACK_ENV'] ||= 'development'
require "pry"
require "pry-debundle"
Pry.debundle!
require_relative 'config/application'
ARGV.clear
pry
end
namespace :parcel do
desc "npm install parcel and friends. Assumes package.js and such already exist."
task :install do |task|
`npm install`
end
desc "watch for changes in dev mode"
task :dev do |task|
system 'parcel --watch --debug'
end
desc "build assets for production use"
task :release do |task|
system 'npx parcel build --log-level verbose --detailed-report --public-url /js/ --dist-dir app/assets/js/ app/js/*'
end
end
desc 'rebuild static packages'
task :repackage do
build_key = "Nchan:nchapp:nchan_last_build"
gitdir_pkgs="gitdir/nchan/dev/package/pkgs"
prebuilt_pkgs='app/assets/packages'
ENV['RACK_ENV'] ||= 'development'
require_relative 'config/application'
ARGV.clear
find_pkg prebuilt_pkgs, :'nginx-common.deb', "nginx-common*.deb" do |ls|
ls.reject! { |f| f =~ /ubuntu/ }
ls.first
end
find_pkg prebuilt_pkgs, :'nginx-extras.deb', "nginx-extras*.deb" do |ls|
ls.reject! { |f| f =~ /ubuntu/ }
ls.first
end
find_pkg prebuilt_pkgs, :'nginx-common.ubuntu.deb', "nginx-common*ubuntu*.deb"
find_pkg prebuilt_pkgs, :'nginx-extras.ubuntu.deb', "nginx-extras*ubuntu*.deb"
find_pkg prebuilt_pkgs, :'nginx-mod-nchan.rpm', "nginx-mod-nchan*.x86_64.rpm"
find_pkg prebuilt_pkgs, :'nginx-mod-nchan.src.rpm', "nginx-mod-nchan*.src.rpm"
last_build=Queris.redis.get build_key
current_commit=Nchapp::Application.nchan_current_commit
if last_build != current_commit
puts "old build: #{last_build}"
puts "new ver: #{current_commit}"
puts "should rebuild."
system "gitdir/nchan/dev/package/repackage.sh"
#find_pkg gitdir_pkgs, :debian, "*.deb"
find_pkg gitdir_pkgs, :tarball, "*.tar.gz"
Queris.redis.set build_key, current_commit
else
puts "on latest build #{current_commit}"
end
end
desc 'update documentation to nchan master'
task :update do
ENV['RACK_ENV'] ||= 'development'
require_relative 'config/application'
ARGV.clear
end
task default: :test