spader 0.0.1.pre.pre → 0.0.3.pre.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/spader +68 -329
- data/lib/spader.rb +10 -10
- data/lib/spader/command.rb +13 -14
- data/lib/spader/commands/build.rb +156 -120
- data/lib/spader/commands/generate.rb +66 -62
- data/lib/spader/document.rb +24 -22
- data/lib/spader/documents/manifest.rb +2 -0
- data/lib/spader/documents/messages.rb +2 -0
- data/lib/spader/documents/project.rb +71 -31
- data/lib/spader/util.rb +152 -135
- data/lib/spader/zip.rb +57 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35f3d0356c590d5a277e303f4a3a6f5fc7ed4b83a7e2054e8dbec71317d86aa3
|
4
|
+
data.tar.gz: 1b6f9853d6afef2bdd83de25d0b47762fce00bce4d4614dce4707dd5c3bf0db4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 258ee052057b3f6f8f751b8a99d3a3991c9ecb683526ca3ea35962612c3b8545a66c11c5390e841b429d41b75b9e35a244e0c88210c95f47c47e34aec0211656
|
7
|
+
data.tar.gz: e26db02962f9a4edf3a2d4a06827aaad9e39bcbb2a9f8b17cb03bfac55c0bcf3ac82636658a0b847f2121d66a96e9ef364e7943d7d234447fe9ef3cd55d023a5
|
data/bin/spader
CHANGED
@@ -1,329 +1,68 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
#
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
#require_relative "rb/
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
#dmsg("
|
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
|
-
zip_it = ARGV.include?("--zip")
|
70
|
-
dl_libs = ARGV.include?("--download-libs")
|
71
|
-
generate_skeleton = ARGV.include?("--skeleton")
|
72
|
-
|
73
|
-
if ARGV.length() < 3 && !dl_libs && !generate_skeleton
|
74
|
-
dmsg("ruby spader.rb <browser> <environment> <version> [--zip]")
|
75
|
-
dmsg("OR")
|
76
|
-
dmsg("ruby spader.rb --download-libs")
|
77
|
-
dmsg("OR")
|
78
|
-
dmsg("ruby spader.rb --skeleton <extension name>")
|
79
|
-
exit(0)
|
80
|
-
end
|
81
|
-
|
82
|
-
if generate_skeleton
|
83
|
-
title = ARGV[1]
|
84
|
-
|
85
|
-
if title.nil?()
|
86
|
-
dmsg("ruby spader.rb --skeleton <extension name>")
|
87
|
-
exit(0)
|
88
|
-
end
|
89
|
-
|
90
|
-
dmsg("Initializing extension: #{title}")
|
91
|
-
generate_skeleton(__dir__ + "/#{title.downcase().gsub(" ", "_")}/", title)
|
92
|
-
exit(0)
|
93
|
-
end
|
94
|
-
|
95
|
-
browser = ARGV[0]
|
96
|
-
environment = ARGV[1]
|
97
|
-
version = ARGV[2].dup()
|
98
|
-
|
99
|
-
browser_requires_polyfill = is_browser_chromal?(browser)
|
100
|
-
build_info = DateTime.now().strftime("%Y-%m-%d @ %H:%M:%S")
|
101
|
-
out_dir = "dist/#{environment}/#{browser}/"
|
102
|
-
camel_domain = "dissident.be"
|
103
|
-
api_endpoint = "dissident.be"
|
104
|
-
charts_domain = "charts-dev.camelcamelcamel.com"
|
105
|
-
#analytics_endpoint = "127.0.0.1:8787/"
|
106
|
-
analytics_endpoint = "hello.camelcamelcamel.com/camelizer"
|
107
|
-
zoom_levels = [0.25, 0.33, 0.5, 0.67, 0.75, 0.8, 0.9, 1.0, 1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0, 5.0]
|
108
|
-
|
109
|
-
case browser
|
110
|
-
when "firefox"
|
111
|
-
zoom_levels = [0.3, 0.5, 0.67, 0.8, 0.9, 1.0, 1.1, 1.2, 1.33, 1.5, 1.7, 2.0, 2.4, 3.0]
|
112
|
-
when "safari"
|
113
|
-
zoom_levels = []
|
114
|
-
end
|
115
|
-
|
116
|
-
case environment
|
117
|
-
when "production"
|
118
|
-
out_dir << "#{version}/"
|
119
|
-
camel_domain = "camelcamelcamel.com"
|
120
|
-
api_endpoint = "izer.camelcamelcamel.com"
|
121
|
-
charts_domain = "charts.camelcamelcamel.com"
|
122
|
-
when "development"
|
123
|
-
version << "000"
|
124
|
-
end
|
125
|
-
|
126
|
-
if dl_libs
|
127
|
-
dl_libs(__dir__)
|
128
|
-
exit(0)
|
129
|
-
end
|
130
|
-
|
131
|
-
required_domains = [
|
132
|
-
"camelcamelcamel.com",
|
133
|
-
"amazon.com",
|
134
|
-
"amazon.co.uk",
|
135
|
-
"amazon.fr",
|
136
|
-
"amazon.de",
|
137
|
-
"amazon.es",
|
138
|
-
"amazon.ca",
|
139
|
-
"amazon.it",
|
140
|
-
"amazon.com.au",
|
141
|
-
"camelizer.net",
|
142
|
-
"camelizer.org",
|
143
|
-
]
|
144
|
-
|
145
|
-
html_templates = [
|
146
|
-
"html/main.html.erb",
|
147
|
-
"html/background.html.erb",
|
148
|
-
"html/camel.html.erb",
|
149
|
-
"html/options.html.erb",
|
150
|
-
]
|
151
|
-
|
152
|
-
js_templates = [
|
153
|
-
"js/3camelizer.js.erb",
|
154
|
-
"js/main.js.erb",
|
155
|
-
"js/background.js.erb",
|
156
|
-
"js/camel.js.erb",
|
157
|
-
"js/options.js.erb",
|
158
|
-
"js/content_script/announce.js.erb",
|
159
|
-
]
|
160
|
-
|
161
|
-
static_files = [
|
162
|
-
"js/jquery/jquery-3.5.1.min.js",
|
163
|
-
"js/foundation/foundation.js",
|
164
|
-
"js/tooltipster/tooltipster.bundle.js",
|
165
|
-
"js/util/what-input.js",
|
166
|
-
"js/content_script/get_all_anchors.js",
|
167
|
-
"js/content_script/set_firstrun_options.js",
|
168
|
-
"js/introjs/intro.js",
|
169
|
-
"txt/privacy.txt",
|
170
|
-
"icon/icon-16.png",
|
171
|
-
"icon/icon-32.png",
|
172
|
-
"icon/icon-48.png",
|
173
|
-
"icon/icon-64.png",
|
174
|
-
"icon/icon-96.png",
|
175
|
-
"icon/icon-128.png",
|
176
|
-
"icon/icon-256.png",
|
177
|
-
"icon/help-logo.png",
|
178
|
-
"icon/gradient.png",
|
179
|
-
"icon/chart_error.png",
|
180
|
-
"font/fa-solid-900.woff2",
|
181
|
-
"font/KFOmCnqEu92Fr1Mu7GxKOzY.woff2",
|
182
|
-
"font/KFOmCnqEu92Fr1Mu4mxK.woff2"
|
183
|
-
]
|
184
|
-
|
185
|
-
if browser_requires_polyfill
|
186
|
-
static_files << "js/browser/browser-polyfill.min.js"
|
187
|
-
end
|
188
|
-
|
189
|
-
translated_files = {
|
190
|
-
"manifest/#{browser}.json" => "manifest.json",
|
191
|
-
#"config/#{browser}.js" => "config.js",
|
192
|
-
#"environment/#{environment}.js" => "environment.js",
|
193
|
-
}
|
194
|
-
|
195
|
-
dirs = [
|
196
|
-
]
|
197
|
-
|
198
|
-
case browser
|
199
|
-
when"firefox"
|
200
|
-
translated_files["txt/links.txt"] = "amo-reviewer-links.txt"
|
201
|
-
end
|
202
|
-
|
203
|
-
SassC.load_paths << (__dir__ + "/scss/")
|
204
|
-
SassC.load_paths << (__dir__ + "/scss/foundation/")
|
205
|
-
|
206
|
-
dmsg("BUILDING #{browser}/#{environment} into #{out_dir}")
|
207
|
-
|
208
|
-
Dir.chdir(__dir__)
|
209
|
-
|
210
|
-
if Dir.exists?(out_dir)
|
211
|
-
dmsg(" Removing old dirs")
|
212
|
-
FileUtils.remove_dir(out_dir)
|
213
|
-
end
|
214
|
-
|
215
|
-
dmsg(" Ensuring dirs exist")
|
216
|
-
FileUtils.mkdir_p(out_dir)
|
217
|
-
|
218
|
-
dmsg(" Compiling SCSS")
|
219
|
-
Dir.chdir(__dir__ + "/scss/")
|
220
|
-
scss = SassC::Engine.new(read_file("3camelizer.scss"), style: :expanded).render()
|
221
|
-
|
222
|
-
Dir.chdir(__dir__)
|
223
|
-
|
224
|
-
dmsg(" Writing #{pretty_float(scss.length().to_f() / 1024.0)} KB to #{out_dir}/3camelizer.css")
|
225
|
-
write_file("#{out_dir}/3camelizer.css", scss)
|
226
|
-
|
227
|
-
if browser == "safari"
|
228
|
-
Dir.chdir(__dir__ + "/scss/")
|
229
|
-
scss = SassC::Engine.new(read_file("safari.scss"), style: :expanded).render()
|
230
|
-
|
231
|
-
Dir.chdir(__dir__)
|
232
|
-
|
233
|
-
dmsg(" Writing #{pretty_float(scss.length().to_f() / 1024.0)} KB to #{out_dir}/safari.css")
|
234
|
-
write_file("#{out_dir}/safari.css", scss)
|
235
|
-
end
|
236
|
-
|
237
|
-
dmsg(" Rendering JS")
|
238
|
-
js_templates.each do |infile|
|
239
|
-
outfile = out_dir + File.basename(infile, ".erb")
|
240
|
-
dmsg(" Rendering #{infile} to #{outfile}")
|
241
|
-
js = render(infile)
|
242
|
-
dmsg(" Writing #{pretty_float(js.length().to_f() / 1024.0)} KB")
|
243
|
-
write_file(outfile, js)
|
244
|
-
end
|
245
|
-
|
246
|
-
dmsg(" Rendering HTML...")
|
247
|
-
html_templates.each do |infile|
|
248
|
-
outfile = out_dir + File.basename(infile, ".erb")
|
249
|
-
dmsg(" Rendering #{infile} to #{outfile}")
|
250
|
-
html = render(infile)
|
251
|
-
dmsg(" Writing #{pretty_float(html.length().to_f() / 1024.0)} KB")
|
252
|
-
write_file(outfile, html)
|
253
|
-
end
|
254
|
-
|
255
|
-
dmsg(" Copying files...")
|
256
|
-
|
257
|
-
static_files.each do |infile|
|
258
|
-
outfile = out_dir + File.basename(infile)
|
259
|
-
dmsg(" Copying #{infile} to #{outfile}")
|
260
|
-
FileUtils.cp(infile, outfile)
|
261
|
-
end
|
262
|
-
|
263
|
-
translated_files.each do |infile,outfile|
|
264
|
-
outpath = out_dir + outfile
|
265
|
-
dmsg(" Copying #{infile} to #{outpath}")
|
266
|
-
FileUtils.cp(infile, outpath)
|
267
|
-
end
|
268
|
-
|
269
|
-
dirs.each do |indir|
|
270
|
-
Dir.entries(indir).each do |entry|
|
271
|
-
if entry[0, 1] == "."
|
272
|
-
next
|
273
|
-
end
|
274
|
-
|
275
|
-
dmsg(" Copying #{indir + "/" + entry} to #{out_dir + entry}")
|
276
|
-
|
277
|
-
FileUtils.cp(indir + "/" + entry, out_dir + entry)
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
dmsg(" Copying _locales to #{out_dir + "_locales"}")
|
282
|
-
FileUtils.cp_r("_locales", out_dir + "_locales")
|
283
|
-
|
284
|
-
dmsg(" Updating manifest.json")
|
285
|
-
manifest = JSON.parse(read_file(out_dir + "manifest.json"))
|
286
|
-
manifest["version"] = version
|
287
|
-
|
288
|
-
perms = [
|
289
|
-
"activeTab",
|
290
|
-
"storage",
|
291
|
-
# "cookies",
|
292
|
-
#"tabs",
|
293
|
-
]
|
294
|
-
|
295
|
-
if !is_browser_chromal?(browser)
|
296
|
-
perms << "tabs"
|
297
|
-
end
|
298
|
-
|
299
|
-
required_domains.each do |dom|
|
300
|
-
perms << "http://#{dom}/*"
|
301
|
-
perms << "https://#{dom}/*"
|
302
|
-
perms << "http://*.#{dom}/*"
|
303
|
-
perms << "https://*.#{dom}/*"
|
304
|
-
end
|
305
|
-
|
306
|
-
manifest["permissions"] += perms
|
307
|
-
|
308
|
-
if environment == "development"
|
309
|
-
manifest["permissions"] << "http://*.dissident.be/*"
|
310
|
-
manifest["permissions"] << "http://dissident.be/*"
|
311
|
-
manifest["permissions"] << "https://*.dissident.be/*"
|
312
|
-
manifest["permissions"] << "https://dissident.be/*"
|
313
|
-
end
|
314
|
-
|
315
|
-
manifest["default_locale"] = "en"
|
316
|
-
|
317
|
-
manifest["options_ui"] = {
|
318
|
-
"page" => "options.html",
|
319
|
-
}
|
320
|
-
|
321
|
-
write_file(out_dir + "manifest.json", JSON.pretty_generate(manifest))
|
322
|
-
|
323
|
-
if zip_it
|
324
|
-
dmsg(" Creating zip archive...")
|
325
|
-
zip_file = ZipFileGenerator.new(out_dir, "dist/3camelizer-#{browser}-#{environment}-#{version}.zip")
|
326
|
-
zip_file.write()
|
327
|
-
end
|
328
|
-
|
329
|
-
dmsg("Build complete!")
|
1
|
+
# encoding: UTF-8
|
2
|
+
#!/usr/bin/env ruby
|
3
|
+
|
4
|
+
# SPADER
|
5
|
+
# WebExtension maker's toolkit.
|
6
|
+
# Copyright (C) 2020 Cosmic Shovel, Inc.
|
7
|
+
|
8
|
+
require "spader"
|
9
|
+
|
10
|
+
#require_relative "rb/dl_libs"
|
11
|
+
#require_relative "rb/rendering_helpers"
|
12
|
+
|
13
|
+
########################################################################################
|
14
|
+
|
15
|
+
if ARGV.length() == 0 || ARGV[0] == "--help" || ARGV[0] == "-h"
|
16
|
+
puts "Usage: spader <command> <args>\nvalid commands: generate, download, build, help\nspader <command> --help"
|
17
|
+
exit(0)
|
18
|
+
end
|
19
|
+
|
20
|
+
spader_command = ARGV[0]
|
21
|
+
spader_command_args = ARGV.drop(1)
|
22
|
+
|
23
|
+
begin
|
24
|
+
|
25
|
+
case spader_command
|
26
|
+
when "build"
|
27
|
+
Spader.build(spader_command_args)
|
28
|
+
#dmsg("Building...")
|
29
|
+
#build(ARGV[1].dup(), ARGV[2].dup(), ARGV[3].dup(), ARGV[4].dup(), ARGV.include?("--zip"))
|
30
|
+
when "download"
|
31
|
+
Spader.download(spader_command_args)
|
32
|
+
#dmsg("Downloading...")
|
33
|
+
#dmsg("Not implemented!")
|
34
|
+
when "generate"
|
35
|
+
Spader.generate(spader_command_args)
|
36
|
+
#dmsg("Generating skeleton...")
|
37
|
+
|
38
|
+
#title = ARGV[1]
|
39
|
+
|
40
|
+
#if title.nil?()
|
41
|
+
# dmsg("ruby spader.rb --skeleton <extension name>")
|
42
|
+
# exit(0)
|
43
|
+
#end
|
44
|
+
|
45
|
+
#generate_skeleton(__dir__ + "/#{title.downcase().gsub(" ", "_")}/", title)
|
46
|
+
when "help"
|
47
|
+
case spader_command_args[0]
|
48
|
+
when "build"
|
49
|
+
puts "The build command compiles your code into a WebExtension."
|
50
|
+
when "download"
|
51
|
+
puts "The download command installs bit-perfect copies of third party libraries into your source directory ."
|
52
|
+
when "skeleton"
|
53
|
+
puts "The skeleton command generates an empty but build-able project directory."
|
54
|
+
else
|
55
|
+
puts "Invalid command: #{spader_command_args[0]}"
|
56
|
+
end
|
57
|
+
|
58
|
+
exit(0)
|
59
|
+
else
|
60
|
+
puts "Invalid command, exiting."
|
61
|
+
exit(0)
|
62
|
+
end
|
63
|
+
rescue Spader::Command::InvalidParametersError => e
|
64
|
+
puts "Aborting due to invalid parameters."
|
65
|
+
exit(1)
|
66
|
+
end
|
67
|
+
|
68
|
+
exit(0)
|
data/lib/spader.rb
CHANGED
@@ -58,13 +58,13 @@ module Spader
|
|
58
58
|
cmd.zip = true
|
59
59
|
end
|
60
60
|
|
61
|
+
opts.on("-h", "--help", "Show this help message") do
|
62
|
+
opts.show_usage()
|
63
|
+
end
|
64
|
+
|
61
65
|
begin
|
62
66
|
opts.order(args) do |path|
|
63
|
-
cmd.path =
|
64
|
-
|
65
|
-
if cmd.path[-1, 1] != File::SEPARATOR
|
66
|
-
cmd.path << File::SEPARATOR
|
67
|
-
end
|
67
|
+
cmd.path = make_path_absolute(path, Dir.pwd, :dir)
|
68
68
|
end
|
69
69
|
rescue OptionParser::ParseError => e
|
70
70
|
opts.warn(e.message)
|
@@ -87,17 +87,17 @@ module Spader
|
|
87
87
|
exit(1)
|
88
88
|
end
|
89
89
|
|
90
|
+
opts.on("-h", "--help", "Show this help message") do
|
91
|
+
opts.show_usage()
|
92
|
+
end
|
93
|
+
|
90
94
|
if args.empty?()
|
91
95
|
opts.show_usage()
|
92
96
|
end
|
93
97
|
|
94
98
|
begin
|
95
99
|
opts.order(args) do |path|
|
96
|
-
cmd.path =
|
97
|
-
|
98
|
-
if cmd.path[-1, 1] != File::SEPARATOR
|
99
|
-
cmd.path << File::SEPARATOR
|
100
|
-
end
|
100
|
+
cmd.path = make_path_absolute(path, Dir.pwd, :dir)
|
101
101
|
end
|
102
102
|
rescue OptionParser::ParseError => e
|
103
103
|
opts.warn(e.message)
|