bpm 1.0.0.beta.6 → 1.0.0.beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +26 -0
- data/TODO.md +0 -3
- data/lib/bpm/cli/base.rb +3 -3
- data/lib/bpm/default.json +5 -1
- data/lib/bpm/errors.rb +8 -0
- data/lib/bpm/generator.rb +8 -0
- data/lib/bpm/init_generator.rb +1 -1
- data/lib/bpm/package.rb +113 -11
- data/lib/bpm/pipeline/format_processor.rb +28 -0
- data/lib/bpm/pipeline/generated_asset.rb +2 -2
- data/lib/bpm/pipeline/package_pipeline.rb +79 -0
- data/lib/bpm/pipeline/plugin_asset.rb +7 -8
- data/lib/bpm/pipeline/plugin_processor.rb +52 -0
- data/lib/bpm/pipeline.rb +89 -26
- data/lib/bpm/project.rb +55 -29
- data/lib/bpm/version.rb +1 -1
- data/lib/bpm.rb +3 -1
- data/spec/cli/list_spec.rb +1 -0
- data/spec/cli/pack_spec.rb +125 -103
- data/spec/fixtures/projects/coffee/coffee.json +17 -0
- data/spec/fixtures/projects/coffee/index.html.handlebars +1 -0
- data/spec/fixtures/projects/coffee/lib/main.coffee +1 -0
- data/spec/fixtures/projects/coffee/packages/coffee-script/compiler.js +4 -0
- data/spec/fixtures/projects/coffee/packages/coffee-script/lib/main.js +1 -0
- data/spec/fixtures/projects/coffee/packages/coffee-script/package.json +15 -0
- data/spec/fixtures/projects/coffee/packages/handlebars/format.js +6 -0
- data/spec/fixtures/projects/coffee/packages/handlebars/lib/main.js +2 -0
- data/spec/fixtures/projects/coffee/packages/handlebars/package.json +16 -0
- data/spec/fixtures/projects/coffee/packages/spade/lib/main.js +1 -0
- data/spec/fixtures/projects/coffee/packages/spade/package.json +14 -0
- data/spec/fixtures/projects/coffee/packages/spade/transport.js +3 -0
- data/spec/fixtures/projects/coffee/templates/section.handlebars +1 -0
- data/spec/fixtures/projects/minitrans/packages/transport/package.json +5 -1
- data/spec/fixtures/projects/transporter/packages/transport/package.json +5 -1
- data/spec/package_pipeline_spec.rb +30 -0
- data/spec/package_spec.rb +328 -316
- data/spec/plugins/format_spec.rb +38 -0
- data/spec/plugins/transport_spec.rb +1 -1
- data/spec/support/matchers.rb +1 -2
- metadata +57 -24
data/spec/package_spec.rb
CHANGED
@@ -1,308 +1,320 @@
|
|
1
1
|
require "spec_helper"
|
2
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
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
#
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
#
|
222
|
-
|
223
|
-
|
224
|
-
#
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
#
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
#
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
#
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
#
|
279
|
-
|
280
|
-
|
281
|
-
#
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
3
|
+
describe BPM::Package do
|
4
|
+
it "should have 'lib' as default lib_path'" do
|
5
|
+
subject.send(:lib_path).should == 'lib'
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should have 'tests' as default tests_path'" do
|
9
|
+
subject.send(:tests_path).should == 'tests'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe BPM::Package, "#to_spec" do
|
14
|
+
let(:email) { "user@example.com" }
|
15
|
+
|
16
|
+
before do
|
17
|
+
FileUtils.mkdir_p(home("core-test", "lib"))
|
18
|
+
FileUtils.mkdir_p(home("core-test", "resources"))
|
19
|
+
FileUtils.mkdir_p(home("core-test", "tests"))
|
20
|
+
cd home('core-test')
|
21
|
+
end
|
22
|
+
|
23
|
+
subject do
|
24
|
+
package = BPM::Package.new(nil, email)
|
25
|
+
package.json_path = package_fixture("core-test", "package.json")
|
26
|
+
if spec = package.to_spec
|
27
|
+
spec
|
28
|
+
else
|
29
|
+
puts "Errors: #{package.errors}"
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def expand_sort(files)
|
35
|
+
files.map { |f| File.expand_path(f) }.sort
|
36
|
+
end
|
37
|
+
|
38
|
+
it "transforms the name" do
|
39
|
+
subject.name.should == "core-test"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "transforms the version" do
|
43
|
+
subject.version.should == LibGems::Version.new("0.4.9")
|
44
|
+
end
|
45
|
+
|
46
|
+
it "transforms the author" do
|
47
|
+
subject.authors.should == ["Charles Jolley"]
|
48
|
+
end
|
49
|
+
|
50
|
+
it "transforms the email" do
|
51
|
+
subject.email.should == email
|
52
|
+
end
|
53
|
+
|
54
|
+
it "transforms the homepage" do
|
55
|
+
subject.homepage.should == "https://github.com/strobecorp/core-test"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "transforms the description" do
|
59
|
+
subject.description.should == "Flexible testing library for JavaScript."
|
60
|
+
end
|
61
|
+
|
62
|
+
it "transforms the description" do
|
63
|
+
subject.summary.should == "A fully featured asynchronous testing library for JavaScript, compatible with other frameworks."
|
64
|
+
end
|
65
|
+
|
66
|
+
it "transforms the dependencies" do
|
67
|
+
subject.dependencies.map{|d| [d.name, d.requirement]}.should == [["ivory", "= 0.0.1"], ["optparse", "= 1.0.1"]]
|
68
|
+
end
|
69
|
+
|
70
|
+
it "packs metadata into requirements" do
|
71
|
+
metadata = JSON.parse(subject.requirements.first)
|
72
|
+
metadata["licenses"].should == [
|
73
|
+
{"type" => "MIT",
|
74
|
+
"url" => "https://github.com/strobecorp/core-test/raw/master/LICENSE"}
|
75
|
+
]
|
76
|
+
metadata["engines"].should == ["browser", "all"]
|
77
|
+
metadata["main"].should == "./lib/main"
|
78
|
+
metadata["bin"].should == {"cot" => "./bin/cot"}
|
79
|
+
end
|
80
|
+
|
81
|
+
it "expands paths from the directories and bpm:build" do
|
82
|
+
others = ["tmp/blah.js", "tmp/whee.txt"]
|
83
|
+
files = ["bin/cot", "lib/main.js", "lib/core.js", "lib/test.js", "package.json", "resources/additions.css", "resources/runner.css", "index.html", "extras/extra_file.html"]
|
84
|
+
test_files = ["tests/apis/core-test.js", "tests/system/test/assert-test.js"]
|
85
|
+
|
86
|
+
FileUtils.mkdir_p(["bin/", "resources/", "lib/", "tests/apis", "tests/system/test", "tmp/", "extras/"])
|
87
|
+
FileUtils.touch(files + test_files + others)
|
88
|
+
|
89
|
+
expand_sort(subject.files).should == expand_sort(files + test_files)
|
90
|
+
expand_sort(subject.test_files).should == expand_sort(test_files)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "hacks the file name to return .bpkg" do
|
94
|
+
subject.file_name.should == "core-test-0.4.9.bpkg"
|
95
|
+
end
|
96
|
+
|
97
|
+
it "sets the rubyforge_project to appease older versions of rubygems" do
|
98
|
+
subject.rubyforge_project.should == "bpm"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe BPM::Package, "#to_s" do
|
103
|
+
let(:email) { "user@example.com" }
|
104
|
+
|
105
|
+
subject do
|
106
|
+
package = BPM::Package.new package_fixture('core-test')
|
107
|
+
package.valid?
|
108
|
+
package
|
109
|
+
end
|
110
|
+
|
111
|
+
it "gives the name and version" do
|
112
|
+
subject.full_name.should == "core-test-0.4.9"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe BPM::Package, "converting" do
|
117
|
+
before do
|
118
|
+
cd(home)
|
119
|
+
end
|
120
|
+
|
121
|
+
subject do
|
122
|
+
package = BPM::Package.new
|
123
|
+
package.fill_from_gemspec(fixtures('gems', "core-test-0.4.9.bpkg"))
|
124
|
+
package.as_json
|
125
|
+
end
|
126
|
+
|
127
|
+
it "can recreate the same package.json from the package" do
|
128
|
+
# These don't come out in the same order
|
129
|
+
actual = Hash[subject.sort]
|
130
|
+
expected = Hash[JSON.parse(File.read(package_fixture("core-test", "package.json"))).sort].reject{|k,v| v.empty? }
|
131
|
+
actual.should == expected
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe BPM::Package, "validating" do
|
136
|
+
before do
|
137
|
+
FileUtils.mkdir_p home('core-test')
|
138
|
+
cd home('core-test')
|
139
|
+
end
|
140
|
+
|
141
|
+
subject { BPM::Package.new }
|
142
|
+
|
143
|
+
shared_examples_for "a good parser" do
|
144
|
+
it "had a problem parsing package.json" do
|
145
|
+
lambda {
|
146
|
+
subject.load_json
|
147
|
+
}.should raise_error
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
context "with a blank file" do
|
152
|
+
before do
|
153
|
+
FileUtils.touch("package.json")
|
154
|
+
subject.json_path = "package.json"
|
155
|
+
end
|
156
|
+
it_should_behave_like "a good parser"
|
157
|
+
end
|
158
|
+
|
159
|
+
context "with bad json" do
|
160
|
+
before do
|
161
|
+
File.open("package.json", "w") do |f|
|
162
|
+
f.write "---bad json---"
|
163
|
+
end
|
164
|
+
subject.json_path = "package.json"
|
165
|
+
end
|
166
|
+
it_should_behave_like "a good parser"
|
167
|
+
end
|
168
|
+
|
169
|
+
context "json can't be read" do
|
170
|
+
before do
|
171
|
+
FileUtils.cp package_fixture("core-test", "package.json"), "."
|
172
|
+
FileUtils.chmod 0000, "package.json"
|
173
|
+
subject.json_path = "package.json"
|
174
|
+
end
|
175
|
+
it_should_behave_like "a good parser"
|
176
|
+
end
|
177
|
+
|
178
|
+
context "json can't be found" do
|
179
|
+
before do
|
180
|
+
subject.json_path = "package.json"
|
181
|
+
end
|
182
|
+
it_should_behave_like "a good parser"
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
describe BPM::Package, "validation errors" do
|
188
|
+
let(:email) { "user@example.com" }
|
189
|
+
|
190
|
+
before do
|
191
|
+
FileUtils.mkdir_p home("core-test", "lib")
|
192
|
+
FileUtils.mkdir_p home("core-test", "tests")
|
193
|
+
cd home("core-test")
|
194
|
+
end
|
195
|
+
|
196
|
+
subject do
|
197
|
+
BPM::Package.new(nil, email)
|
198
|
+
end
|
199
|
+
|
200
|
+
def write_package
|
201
|
+
path = home("core-test", "package.json")
|
202
|
+
package = JSON.parse(File.read(package_fixture("core-test","package.json")))
|
203
|
+
yield package
|
204
|
+
File.open(path, "w") do |file|
|
205
|
+
file.write package.to_json
|
206
|
+
end
|
207
|
+
subject.json_path = path
|
208
|
+
end
|
209
|
+
|
210
|
+
%w[name description summary homepage author version].each do |field|
|
211
|
+
it "is invalid without a #{field} field" do
|
212
|
+
write_package do |package|
|
213
|
+
if %w(description summary).include?(field)
|
214
|
+
package.delete 'description'
|
215
|
+
package.delete 'summary'
|
216
|
+
else
|
217
|
+
package.delete(field)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
subject.should have_error("Package requires a '#{field}' field")
|
222
|
+
end
|
223
|
+
|
224
|
+
it "is invalid with a blank #{field} field" do
|
225
|
+
write_package do |package|
|
226
|
+
if %w(description summary).include?(field)
|
227
|
+
package['description'] = package['summary'] = ''
|
228
|
+
else
|
229
|
+
package[field] = ''
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
subject.should have_error("Package requires a '#{field}' field")
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
it "is invalid without a proper version number" do
|
238
|
+
write_package do |package|
|
239
|
+
package["version"] = "bad"
|
240
|
+
end
|
241
|
+
|
242
|
+
subject.should have_error("Malformed version number string bad")
|
243
|
+
end
|
244
|
+
|
245
|
+
it "is valid without specifying a test directory" do
|
246
|
+
write_package do |package|
|
247
|
+
package["directories"].delete("tests")
|
248
|
+
end
|
249
|
+
|
250
|
+
subject.should be_valid
|
251
|
+
subject.to_spec.test_files.should == []
|
252
|
+
end
|
253
|
+
|
254
|
+
it "is valid and has files without specifying bin" do
|
255
|
+
write_package do |package|
|
256
|
+
package.delete("bin")
|
257
|
+
end
|
258
|
+
|
259
|
+
subject.should be_valid
|
260
|
+
subject.to_spec.files.should == ["package.json"]
|
261
|
+
end
|
262
|
+
|
263
|
+
%w(lib tests).each do |dir|
|
264
|
+
it "is invalid if #{dir} points to a file" do
|
265
|
+
FileUtils.touch(home("core-test", "somefile"))
|
266
|
+
write_package do |package|
|
267
|
+
package["directories"][dir] = "./somefile"
|
268
|
+
end
|
269
|
+
|
270
|
+
subject.should have_error("'./somefile', specified for #{dir} directory, is not a directory")
|
271
|
+
end
|
272
|
+
|
273
|
+
it "is invalid with a #{dir} directory that doesn't exist" do
|
274
|
+
write_package do |package|
|
275
|
+
package["directories"][dir] = "nope"
|
276
|
+
end
|
277
|
+
|
278
|
+
subject.should have_error("'nope', specified for #{dir} directory, is not a directory")
|
279
|
+
end
|
280
|
+
|
281
|
+
it "is valid with a #{dir} directory that exists" do
|
282
|
+
FileUtils.mkdir_p(home("core-test", "somewhere", "else"))
|
283
|
+
write_package do |package|
|
284
|
+
package["directories"][dir] = "./somewhere/else"
|
285
|
+
end
|
286
|
+
|
287
|
+
subject.should be_valid
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
it "is valid with a lib directory array" do
|
292
|
+
FileUtils.mkdir_p(home("core-test", "vendor", "lib"))
|
293
|
+
write_package do |package|
|
294
|
+
package["directories"]["lib"] = ["./lib", "./vendor/lib"]
|
295
|
+
end
|
296
|
+
|
297
|
+
subject.valid?
|
298
|
+
subject.should be_valid
|
299
|
+
end
|
300
|
+
|
301
|
+
it "is invalid if any lib directories don't exist" do
|
302
|
+
write_package do |package|
|
303
|
+
package["directories"]["lib"] = ["./lib", "./fake"]
|
304
|
+
end
|
305
|
+
|
306
|
+
subject.should have_error "'./fake', specified for lib directory, is not a directory"
|
307
|
+
end
|
308
|
+
|
309
|
+
it "is invalid if the lib directory array is empty" do
|
310
|
+
write_package do |package|
|
311
|
+
package["directories"]["lib"] = []
|
312
|
+
end
|
313
|
+
|
314
|
+
subject.should have_error("A lib directory is required")
|
315
|
+
end
|
316
|
+
|
317
|
+
end
|
306
318
|
|
307
319
|
describe BPM::Package, 'InvalidPackageError' do
|
308
320
|
|
@@ -332,16 +344,16 @@ describe BPM::Package, 'InvalidPackageError' do
|
|
332
344
|
|
333
345
|
end
|
334
346
|
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
347
|
+
describe BPM::Package, "templates" do
|
348
|
+
|
349
|
+
subject do
|
350
|
+
package = BPM::Package.new(package_fixture("custom_generator"))
|
351
|
+
package.load_json
|
352
|
+
package
|
353
|
+
end
|
354
|
+
|
355
|
+
it "should have project template" do
|
356
|
+
subject.template_path('project').should == package_fixture("custom_generator", "templates", "project").to_s
|
357
|
+
end
|
358
|
+
|
359
|
+
end
|