forked from Shopify/shopify-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
152 lines (128 loc) · 3.91 KB
/
Rakefile
File metadata and controls
152 lines (128 loc) · 3.91 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
ENV["SHOPIFY_CLI_TEST"] = "1"
require_relative "bin/load_shopify"
require_relative "utilities/utilities"
require "rake/testtask"
require "rubocop/rake_task"
require "bundler/gem_tasks"
require "shellwords"
require "digest"
require "open3"
Rake::TestTask.new do |t|
t.libs += %w(test)
t.test_files = FileList["test/**/*_test.rb"]
t.verbose = false
t.warning = false
end
desc "A set of tasks that run in Linux environments"
namespace :linux do
desc "Runs the test suite in a Linux Docker environment"
task :test do
Utilities::Docker.run_and_rm_container("bundle", "exec", "rake", "test")
end
end
RuboCop::RakeTask.new
task(default: [:test, :rubocop])
desc("Start up irb with cli loaded")
task :console do
exec("irb", "-r", "./bin/load_shopify.rb", "-r", "byebug")
end
namespace :rdoc do
repo = "https://github.com/Shopify/shopify-cli.wiki.git"
intermediate = "markdown_intermediate"
file_to_doc = [
"lib/shopify_cli/admin_api.rb",
"lib/shopify_cli/context.rb",
"lib/shopify_cli/db.rb",
"lib/shopify_cli/git.rb",
"lib/shopify_cli/heroku.rb",
"lib/shopify_cli/js_deps.rb",
"lib/shopify_cli/lazy_delegator.rb",
"lib/shopify_cli/method_object.rb",
"lib/shopify_cli/partners_api.rb",
"lib/shopify_cli/process_supervision.rb",
"lib/shopify_cli/project.rb",
"lib/shopify_cli/result.rb",
"lib/shopify_cli/transform_data_structure.rb",
"lib/shopify_cli/tunnel.rb",
]
task all: [:markdown, :wiki, :cleanup]
desc("Generate markdown files from rdoc comments")
task :markdown do
require "rdoc/rdoc"
require "docgen/markdown"
options = RDoc::Options.new
options.setup_generator("markdown")
options.op_dir = intermediate
options.files = file_to_doc
RDoc::RDoc.new.document(options)
end
desc("Copy markdown documentation to the wiki and commit them")
task :wiki do
require "tmpdir"
Dir.mktmpdir do |temp_dir|
system("git clone --depth=1 #{repo} #{temp_dir}")
FileUtils.cp(Dir[File.join(intermediate, "*.md")], temp_dir)
Dir.chdir(temp_dir) do
system("git add --all")
system('git commit -am "auto doc update"')
system("git push")
end
end
end
desc("Clean up any documentation related files")
task :cleanup do
FileUtils.rm_r(intermediate)
end
end
desc("Generate markdown documentation and update the wiki")
task(rdoc: "rdoc:all")
namespace :package do
require "shopify_cli/packager"
task all: [:debian, :rpm, :homebrew]
desc("Builds a Debian package of the CLI")
task :debian do
ShopifyCLI::Packager.new.build_debian
end
desc("Builds an RPM package of the CLI")
task :rpm do
ShopifyCLI::Packager.new.build_rpm
end
desc("Builds a Homebrew package of the CLI")
task :homebrew do
ShopifyCLI::Packager.new.build_homebrew
end
end
desc("Builds all distribution packages of the CLI")
task(package: "package:all")
namespace :extensions do
task :update do
version = ENV.fetch("VERSION").strip
error("Invalid version") unless /^v\d+\.\d+\.\d+/.match(version)
File.write(Paths.extension("version"), version)
end
task :symlink do
source = Paths.root("..", "shopify-cli-extensions", "shopify-extensions")
error("Unable to find shopify-extensions executable: #{executable}") unless File.executable?(source)
target = Paths.extension("shopify-extensions")
File.delete(target) if File.exist?(target)
File.symlink(source, target)
end
task :install do
target = Paths.extension("shopify-extensions")
require_relative Paths.extension("shopify_extensions.rb")
File.delete(target) if File.exist?(target)
ShopifyExtensions.install(target: target)
end
module Paths
def self.extension(*args)
root("ext", "shopify-extensions", *args)
end
def self.root(*args)
Pathname(File.dirname(__FILE__)).join(*args).to_s
end
end
end
def error(message, output: STDERR, code: 1)
output.puts(message)
exit(code)
end