bpm 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (261) hide show
  1. data/.gitignore +4 -0
  2. data/.gitmodules +0 -0
  3. data/Gemfile +16 -0
  4. data/README.md +55 -0
  5. data/TODO.md +3 -0
  6. data/bin/bpm +8 -0
  7. data/bpm.gemspec +41 -0
  8. data/lib/bpm.rb +18 -0
  9. data/lib/bpm/cli.rb +6 -0
  10. data/lib/bpm/cli/base.rb +358 -0
  11. data/lib/bpm/cli/owner.rb +46 -0
  12. data/lib/bpm/credentials.rb +36 -0
  13. data/lib/bpm/default.json +9 -0
  14. data/lib/bpm/generator.rb +69 -0
  15. data/lib/bpm/init_generator.rb +43 -0
  16. data/lib/bpm/libgems_ext.rb +11 -0
  17. data/lib/bpm/libgems_ext/config_file.rb +33 -0
  18. data/lib/bpm/libgems_ext/dependency_installer.rb +150 -0
  19. data/lib/bpm/libgems_ext/installer.rb +39 -0
  20. data/lib/bpm/libgems_ext/libgems.rb +39 -0
  21. data/lib/bpm/libgems_ext/spec_fetcher.rb +11 -0
  22. data/lib/bpm/local.rb +76 -0
  23. data/lib/bpm/package.rb +277 -0
  24. data/lib/bpm/pipeline.rb +100 -0
  25. data/lib/bpm/pipeline/directive_processor.rb +47 -0
  26. data/lib/bpm/pipeline/generated_asset.rb +68 -0
  27. data/lib/bpm/pipeline/transport_processor.rb +32 -0
  28. data/lib/bpm/project.rb +427 -0
  29. data/lib/bpm/project_generator.rb +34 -0
  30. data/lib/bpm/remote.rb +104 -0
  31. data/lib/bpm/repository.rb +18 -0
  32. data/lib/bpm/server.rb +44 -0
  33. data/lib/bpm/version.rb +3 -0
  34. data/spec/cli/add_spec.rb +159 -0
  35. data/spec/cli/build_spec.rb +87 -0
  36. data/spec/cli/fetch_spec.rb +135 -0
  37. data/spec/cli/fetched_spec.rb +52 -0
  38. data/spec/cli/init_spec.rb +50 -0
  39. data/spec/cli/list_spec.rb +74 -0
  40. data/spec/cli/login_spec.rb +110 -0
  41. data/spec/cli/new_spec.rb +92 -0
  42. data/spec/cli/owner_spec.rb +114 -0
  43. data/spec/cli/push_spec.rb +73 -0
  44. data/spec/cli/remove_spec.rb +84 -0
  45. data/spec/cli/unpack_spec.rb +72 -0
  46. data/spec/cli/unyank_spec.rb +73 -0
  47. data/spec/cli/yank_spec.rb +73 -0
  48. data/spec/credentials_spec.rb +23 -0
  49. data/spec/fixtures/badrake-0.8.7.spd +0 -0
  50. data/spec/fixtures/builder-3.0.0.spd +0 -0
  51. data/spec/fixtures/bundler-1.1.pre.spd +0 -0
  52. data/spec/fixtures/coffee-1.0.1.pre.spd +0 -0
  53. data/spec/fixtures/core-test-0.4.9.spd +0 -0
  54. data/spec/fixtures/core-test/bin/cot +3 -0
  55. data/spec/fixtures/core-test/lib/main.js +1 -0
  56. data/spec/fixtures/core-test/package.json +46 -0
  57. data/spec/fixtures/core-test/resources/runner.css +1 -0
  58. data/spec/fixtures/core-test/tests/test.js +1 -0
  59. data/spec/fixtures/custom_generator-1.0.spd +0 -0
  60. data/spec/fixtures/custom_generator/lib/main.js +1 -0
  61. data/spec/fixtures/custom_generator/package.json +12 -0
  62. data/spec/fixtures/custom_generator/templates/init/project.json +19 -0
  63. data/spec/fixtures/custom_generator/templates/project/app.js +1 -0
  64. data/spec/fixtures/custom_generator/templates/project/lib/main.js +0 -0
  65. data/spec/fixtures/custom_generator/templates/project_generator.rb +20 -0
  66. data/spec/fixtures/hello_world/LICENSE +19 -0
  67. data/spec/fixtures/hello_world/README.md +21 -0
  68. data/spec/fixtures/hello_world/assets/bpm_packages.js +13 -0
  69. data/spec/fixtures/hello_world/assets/bpm_styles.css +14 -0
  70. data/spec/fixtures/hello_world/assets/papa-smurf.jpg +0 -0
  71. data/spec/fixtures/hello_world/hello_world.json +20 -0
  72. data/spec/fixtures/hello_world/lib/main.js +9 -0
  73. data/spec/fixtures/hello_world/packages/custom_package/assets/dummy.txt +1 -0
  74. data/spec/fixtures/hello_world/packages/custom_package/css/sample_styles.css +3 -0
  75. data/spec/fixtures/hello_world/packages/custom_package/custom_dir/basic-module.js +1 -0
  76. data/spec/fixtures/hello_world/packages/custom_package/lib/main.js +1 -0
  77. data/spec/fixtures/hello_world/packages/custom_package/package.json +22 -0
  78. data/spec/fixtures/hello_world/tests/main-test.js +8 -0
  79. data/spec/fixtures/highline-1.6.1.spd +0 -0
  80. data/spec/fixtures/ivory-0.0.1.spd +0 -0
  81. data/spec/fixtures/jquery-1.4.3.spd +0 -0
  82. data/spec/fixtures/optparse-1.0.1.spd +0 -0
  83. data/spec/fixtures/rake-0.8.6.spd +0 -0
  84. data/spec/fixtures/rake-0.8.7.spd +0 -0
  85. data/spec/fixtures/simple_hello/assets/bpm_packages.js +1 -0
  86. data/spec/fixtures/simple_hello/lib/main.js +1 -0
  87. data/spec/fixtures/spade-0.5.0.spd +0 -0
  88. data/spec/fixtures/src/README.txt +1 -0
  89. data/spec/fixtures/src/bundler-1.1.pre/.gitignore +22 -0
  90. data/spec/fixtures/src/bundler-1.1.pre/CHANGELOG.md +646 -0
  91. data/spec/fixtures/src/bundler-1.1.pre/ISSUES.md +47 -0
  92. data/spec/fixtures/src/bundler-1.1.pre/LICENSE +21 -0
  93. data/spec/fixtures/src/bundler-1.1.pre/README.md +29 -0
  94. data/spec/fixtures/src/bundler-1.1.pre/UPGRADING.md +103 -0
  95. data/spec/fixtures/src/bundler-1.1.pre/bin/bundle +20 -0
  96. data/spec/fixtures/src/bundler-1.1.pre/lib/bundler.js +23 -0
  97. data/spec/fixtures/src/bundler-1.1.pre/lib/bundler/definition.js +14 -0
  98. data/spec/fixtures/src/bundler-1.1.pre/lib/bundler/dependency.js +15 -0
  99. data/spec/fixtures/src/bundler-1.1.pre/lib/bundler/dsl.js +9 -0
  100. data/spec/fixtures/src/bundler-1.1.pre/lib/bundler/ui.js +6 -0
  101. data/spec/fixtures/src/bundler-1.1.pre/man/bundle-config.ronn +90 -0
  102. data/spec/fixtures/src/bundler-1.1.pre/man/bundle-exec.ronn +111 -0
  103. data/spec/fixtures/src/bundler-1.1.pre/man/bundle-install.ronn +314 -0
  104. data/spec/fixtures/src/bundler-1.1.pre/man/bundle-package.ronn +59 -0
  105. data/spec/fixtures/src/bundler-1.1.pre/man/bundle-update.ronn +176 -0
  106. data/spec/fixtures/src/bundler-1.1.pre/man/bundle.ronn +80 -0
  107. data/spec/fixtures/src/bundler-1.1.pre/man/gemfile.5.ronn +279 -0
  108. data/spec/fixtures/src/bundler-1.1.pre/man/index.txt +6 -0
  109. data/spec/fixtures/src/bundler-1.1.pre/package.json +19 -0
  110. data/spec/fixtures/src/coffee-1.0.1.pre/bin/cake +0 -0
  111. data/spec/fixtures/src/coffee-1.0.1.pre/bin/coffee +0 -0
  112. data/spec/fixtures/src/coffee-1.0.1.pre/lib/coffee.js +0 -0
  113. data/spec/fixtures/src/coffee-1.0.1.pre/lib/coffee/base.js +0 -0
  114. data/spec/fixtures/src/coffee-1.0.1.pre/lib/coffee/mocha/chai.js +0 -0
  115. data/spec/fixtures/src/coffee-1.0.1.pre/package.json +19 -0
  116. data/spec/fixtures/src/coffee-1.0.1.pre/qunit/coffee/test.js +0 -0
  117. data/spec/fixtures/src/coffee-1.0.1.pre/qunit/test.js +0 -0
  118. data/spec/fixtures/src/jquery/lib/main.js +7179 -0
  119. data/spec/fixtures/src/jquery/package.json +15 -0
  120. data/spec/fixtures/src/rake-0.8.6/CHANGES +436 -0
  121. data/spec/fixtures/src/rake-0.8.6/MIT-LICENSE +21 -0
  122. data/spec/fixtures/src/rake-0.8.6/README +196 -0
  123. data/spec/fixtures/src/rake-0.8.6/Rakefile +430 -0
  124. data/spec/fixtures/src/rake-0.8.6/TODO +20 -0
  125. data/spec/fixtures/src/rake-0.8.6/bin/rake +31 -0
  126. data/spec/fixtures/src/rake-0.8.6/doc/command_line_usage.rdoc +102 -0
  127. data/spec/fixtures/src/rake-0.8.6/doc/example/Rakefile1 +38 -0
  128. data/spec/fixtures/src/rake-0.8.6/doc/example/Rakefile2 +35 -0
  129. data/spec/fixtures/src/rake-0.8.6/doc/example/a.c +6 -0
  130. data/spec/fixtures/src/rake-0.8.6/doc/example/b.c +6 -0
  131. data/spec/fixtures/src/rake-0.8.6/doc/example/main.c +11 -0
  132. data/spec/fixtures/src/rake-0.8.6/doc/glossary.rdoc +51 -0
  133. data/spec/fixtures/src/rake-0.8.6/doc/jamis.rb +591 -0
  134. data/spec/fixtures/src/rake-0.8.6/doc/proto_rake.rdoc +127 -0
  135. data/spec/fixtures/src/rake-0.8.6/doc/rake.1.gz +0 -0
  136. data/spec/fixtures/src/rake-0.8.6/doc/rakefile.rdoc +534 -0
  137. data/spec/fixtures/src/rake-0.8.6/doc/rational.rdoc +151 -0
  138. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.4.14.rdoc +23 -0
  139. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.4.15.rdoc +35 -0
  140. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.5.0.rdoc +53 -0
  141. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.5.3.rdoc +78 -0
  142. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.5.4.rdoc +46 -0
  143. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.6.0.rdoc +141 -0
  144. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.7.0.rdoc +119 -0
  145. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.7.1.rdoc +59 -0
  146. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.7.2.rdoc +121 -0
  147. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.7.3.rdoc +47 -0
  148. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.8.0.rdoc +114 -0
  149. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.8.2.rdoc +165 -0
  150. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.8.3.rdoc +112 -0
  151. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.8.4.rdoc +147 -0
  152. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.8.5.rdoc +53 -0
  153. data/spec/fixtures/src/rake-0.8.6/doc/release_notes/rake-0.8.6.rdoc +55 -0
  154. data/spec/fixtures/src/rake-0.8.6/install.rb +88 -0
  155. data/spec/fixtures/src/rake-0.8.6/lib/rake.rb +2502 -0
  156. data/spec/fixtures/src/rake-0.8.6/lib/rake/alt_system.rb +108 -0
  157. data/spec/fixtures/src/rake-0.8.6/lib/rake/classic_namespace.rb +8 -0
  158. data/spec/fixtures/src/rake-0.8.6/lib/rake/clean.rb +33 -0
  159. data/spec/fixtures/src/rake-0.8.6/lib/rake/contrib/compositepublisher.rb +24 -0
  160. data/spec/fixtures/src/rake-0.8.6/lib/rake/contrib/ftptools.rb +153 -0
  161. data/spec/fixtures/src/rake-0.8.6/lib/rake/contrib/publisher.rb +75 -0
  162. data/spec/fixtures/src/rake-0.8.6/lib/rake/contrib/rubyforgepublisher.rb +18 -0
  163. data/spec/fixtures/src/rake-0.8.6/lib/rake/contrib/sshpublisher.rb +47 -0
  164. data/spec/fixtures/src/rake-0.8.6/lib/rake/contrib/sys.rb +209 -0
  165. data/spec/fixtures/src/rake-0.8.6/lib/rake/gempackagetask.rb +97 -0
  166. data/spec/fixtures/src/rake-0.8.6/lib/rake/loaders/makefile.rb +42 -0
  167. data/spec/fixtures/src/rake-0.8.6/lib/rake/packagetask.rb +184 -0
  168. data/spec/fixtures/src/rake-0.8.6/lib/rake/rake_test_loader.rb +5 -0
  169. data/spec/fixtures/src/rake-0.8.6/lib/rake/rdoctask.rb +209 -0
  170. data/spec/fixtures/src/rake-0.8.6/lib/rake/ruby182_test_unit_fix.rb +23 -0
  171. data/spec/fixtures/src/rake-0.8.6/lib/rake/runtest.rb +23 -0
  172. data/spec/fixtures/src/rake-0.8.6/lib/rake/tasklib.rb +23 -0
  173. data/spec/fixtures/src/rake-0.8.6/lib/rake/testtask.rb +161 -0
  174. data/spec/fixtures/src/rake-0.8.6/lib/rake/win32.rb +55 -0
  175. data/spec/fixtures/src/rake-0.8.6/package.json +18 -0
  176. data/spec/fixtures/src/rake-0.8.6/test/capture_stdout.rb +26 -0
  177. data/spec/fixtures/src/rake-0.8.7/CHANGES +440 -0
  178. data/spec/fixtures/src/rake-0.8.7/MIT-LICENSE +21 -0
  179. data/spec/fixtures/src/rake-0.8.7/README +196 -0
  180. data/spec/fixtures/src/rake-0.8.7/Rakefile +430 -0
  181. data/spec/fixtures/src/rake-0.8.7/TODO +20 -0
  182. data/spec/fixtures/src/rake-0.8.7/bin/rake +31 -0
  183. data/spec/fixtures/src/rake-0.8.7/doc/command_line_usage.rdoc +102 -0
  184. data/spec/fixtures/src/rake-0.8.7/doc/example/Rakefile1 +38 -0
  185. data/spec/fixtures/src/rake-0.8.7/doc/example/Rakefile2 +35 -0
  186. data/spec/fixtures/src/rake-0.8.7/doc/example/a.c +6 -0
  187. data/spec/fixtures/src/rake-0.8.7/doc/example/b.c +6 -0
  188. data/spec/fixtures/src/rake-0.8.7/doc/example/main.c +11 -0
  189. data/spec/fixtures/src/rake-0.8.7/doc/glossary.rdoc +51 -0
  190. data/spec/fixtures/src/rake-0.8.7/doc/jamis.rb +591 -0
  191. data/spec/fixtures/src/rake-0.8.7/doc/proto_rake.rdoc +127 -0
  192. data/spec/fixtures/src/rake-0.8.7/doc/rake.1.gz +0 -0
  193. data/spec/fixtures/src/rake-0.8.7/doc/rakefile.rdoc +534 -0
  194. data/spec/fixtures/src/rake-0.8.7/doc/rational.rdoc +151 -0
  195. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.4.14.rdoc +23 -0
  196. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.4.15.rdoc +35 -0
  197. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.5.0.rdoc +53 -0
  198. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.5.3.rdoc +78 -0
  199. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.5.4.rdoc +46 -0
  200. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.6.0.rdoc +141 -0
  201. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.7.0.rdoc +119 -0
  202. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.7.1.rdoc +59 -0
  203. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.7.2.rdoc +121 -0
  204. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.7.3.rdoc +47 -0
  205. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.8.0.rdoc +114 -0
  206. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.8.2.rdoc +165 -0
  207. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.8.3.rdoc +112 -0
  208. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.8.4.rdoc +147 -0
  209. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.8.5.rdoc +53 -0
  210. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.8.6.rdoc +55 -0
  211. data/spec/fixtures/src/rake-0.8.7/doc/release_notes/rake-0.8.7.rdoc +55 -0
  212. data/spec/fixtures/src/rake-0.8.7/install.rb +88 -0
  213. data/spec/fixtures/src/rake-0.8.7/lib/rake.rb +2506 -0
  214. data/spec/fixtures/src/rake-0.8.7/lib/rake/alt_system.rb +108 -0
  215. data/spec/fixtures/src/rake-0.8.7/lib/rake/classic_namespace.rb +8 -0
  216. data/spec/fixtures/src/rake-0.8.7/lib/rake/clean.rb +33 -0
  217. data/spec/fixtures/src/rake-0.8.7/lib/rake/contrib/compositepublisher.rb +24 -0
  218. data/spec/fixtures/src/rake-0.8.7/lib/rake/contrib/ftptools.rb +153 -0
  219. data/spec/fixtures/src/rake-0.8.7/lib/rake/contrib/publisher.rb +75 -0
  220. data/spec/fixtures/src/rake-0.8.7/lib/rake/contrib/rubyforgepublisher.rb +18 -0
  221. data/spec/fixtures/src/rake-0.8.7/lib/rake/contrib/sshpublisher.rb +47 -0
  222. data/spec/fixtures/src/rake-0.8.7/lib/rake/contrib/sys.rb +209 -0
  223. data/spec/fixtures/src/rake-0.8.7/lib/rake/gempackagetask.rb +97 -0
  224. data/spec/fixtures/src/rake-0.8.7/lib/rake/loaders/makefile.rb +42 -0
  225. data/spec/fixtures/src/rake-0.8.7/lib/rake/packagetask.rb +184 -0
  226. data/spec/fixtures/src/rake-0.8.7/lib/rake/rake_test_loader.rb +5 -0
  227. data/spec/fixtures/src/rake-0.8.7/lib/rake/rdoctask.rb +209 -0
  228. data/spec/fixtures/src/rake-0.8.7/lib/rake/ruby182_test_unit_fix.rb +23 -0
  229. data/spec/fixtures/src/rake-0.8.7/lib/rake/runtest.rb +23 -0
  230. data/spec/fixtures/src/rake-0.8.7/lib/rake/tasklib.rb +23 -0
  231. data/spec/fixtures/src/rake-0.8.7/lib/rake/testtask.rb +161 -0
  232. data/spec/fixtures/src/rake-0.8.7/lib/rake/win32.rb +55 -0
  233. data/spec/fixtures/src/rake-0.8.7/package.json +18 -0
  234. data/spec/fixtures/src/rake-0.8.7/test/capture_stdout.rb +26 -0
  235. data/spec/fixtures/src/spade/lib/main.js +1 -0
  236. data/spec/fixtures/src/spade/package.json +15 -0
  237. data/spec/fixtures/transporter/lib/main.js +3 -0
  238. data/spec/fixtures/transporter/packages/transport/lib/wrapper.js +5 -0
  239. data/spec/fixtures/transporter/packages/transport/package.json +21 -0
  240. data/spec/fixtures/transporter/transporter.json +18 -0
  241. data/spec/gauntlet_spec.rb +33 -0
  242. data/spec/package_spec.rb +319 -0
  243. data/spec/pipeline_spec.rb +213 -0
  244. data/spec/project_spec.rb +130 -0
  245. data/spec/spec_helper.rb +42 -0
  246. data/spec/support/cli.rb +93 -0
  247. data/spec/support/env.rb +18 -0
  248. data/spec/support/fake.rb +53 -0
  249. data/spec/support/fake_gem_server.rb +72 -0
  250. data/spec/support/fake_gemcutter.rb +50 -0
  251. data/spec/support/matchers.rb +32 -0
  252. data/spec/support/path.rb +63 -0
  253. data/spec/support/project.rb +43 -0
  254. data/templates/init/assets/bpm_packages.js +7 -0
  255. data/templates/init/assets/bpm_styles.css +7 -0
  256. data/templates/init/project.json +16 -0
  257. data/templates/project/LICENSE +19 -0
  258. data/templates/project/README.md +21 -0
  259. data/templates/project/app.js +1 -0
  260. data/templates/project/index.html +13 -0
  261. metadata +627 -0
@@ -0,0 +1,46 @@
1
+ module BPM::CLI
2
+ class Owner < Thor
3
+ default_task :list
4
+
5
+ desc "list [PACKAGE]", "Display owners of a package"
6
+ def list(package)
7
+ remote = BPM::Remote.new
8
+ if remote.logged_in?
9
+ yaml = remote.list_owners(package)
10
+ owners = YAML.load(yaml)
11
+
12
+ if owners.is_a?(Array)
13
+ say "Owners for package: #{package}"
14
+ owners.each do |owner|
15
+ say "- #{owner['email']}"
16
+ end
17
+ else
18
+ say owners
19
+ end
20
+ else
21
+ abort LOGIN_MESSAGE
22
+ end
23
+ end
24
+
25
+ desc "add [PACKAGE] [EMAIL]", "Allow another user to push new versions of your bpm package"
26
+ def add(package, email)
27
+ remote = BPM::Remote.new
28
+ if remote.logged_in?
29
+ say remote.add_owner(package, email)
30
+ else
31
+ abort LOGIN_MESSAGE
32
+ end
33
+ end
34
+
35
+ desc "remove [PACKAGE] [EMAIL]", "Allow another user to push new versions of your bpm package"
36
+ def remove(package, email)
37
+ remote = BPM::Remote.new
38
+ if remote.logged_in?
39
+ say remote.remove_owner(package, email)
40
+ else
41
+ abort LOGIN_MESSAGE
42
+ end
43
+ end
44
+ end
45
+ end
46
+
@@ -0,0 +1,36 @@
1
+ module BPM
2
+ class Credentials
3
+ attr_reader :email, :api_key
4
+
5
+ def initialize
6
+ parse
7
+ end
8
+
9
+ def save(email, api_key)
10
+ @email = email
11
+ @api_key = api_key
12
+ write
13
+ end
14
+
15
+ private
16
+
17
+ def write
18
+ FileUtils.mkdir_p(File.dirname(path))
19
+ File.open(path, "w") do |file|
20
+ file.write YAML.dump(:bpm_api_key => api_key, :bpm_email => email)
21
+ end
22
+ end
23
+
24
+ def path
25
+ LibGems.configuration.credentials_path
26
+ end
27
+
28
+ def parse
29
+ if File.exist?(path)
30
+ hash = YAML.load_file(path)
31
+ @email = hash[:bpm_email]
32
+ @api_key = hash[:bpm_api_key]
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,9 @@
1
+ {
2
+ "directories": {
3
+ "lib": "./lib",
4
+ "test": "./tests"
5
+ },
6
+
7
+ "dependencies": {
8
+ }
9
+ }
@@ -0,0 +1,69 @@
1
+ require 'thor'
2
+ require 'bpm'
3
+
4
+ module BPM
5
+
6
+ def self.generators
7
+ @generators ||= {}
8
+ end
9
+
10
+ def self.register_generator(pkg, type, generator)
11
+ generators[pkg] ||= {}
12
+ generators[pkg][type] = generator
13
+ end
14
+
15
+ def self.generator_for(pkg_or_type, type=nil, default=true)
16
+ if type
17
+ pkg = pkg_or_type
18
+ else
19
+ pkg = :default
20
+ type = pkg_or_type
21
+ end
22
+
23
+ generator = generators[pkg] && generators[pkg][type]
24
+ generator ||= generators[:default] && generators[:default][type] if default
25
+ generator
26
+ end
27
+
28
+ # Knows how to generate items out of the local templates directory
29
+ class Generator
30
+ include Thor::Actions
31
+
32
+ attr_reader :name
33
+
34
+ def initialize(thor, name, root, template_path=nil)
35
+ @thor, @name, @template_path = thor, name, template_path
36
+
37
+ self.destination_root = root
38
+ end
39
+
40
+ def dir_name
41
+ File.basename destination_root
42
+ end
43
+
44
+ def source_paths
45
+ [@template_path, self.class.source_root].compact
46
+ end
47
+
48
+ private
49
+
50
+ def app_const
51
+ name.gsub(/\W|-/, '_').squeeze('_').gsub(/(?:^|_)(.)/) { $1.upcase }
52
+ end
53
+
54
+ def current_year
55
+ Time.now.year
56
+ end
57
+
58
+ def respond_to?(*args)
59
+ super || @thor.respond_to?(*args)
60
+ end
61
+
62
+ def method_missing(name, *args, &blk)
63
+ @thor.send(name, *args, &blk)
64
+ end
65
+ end
66
+ end
67
+
68
+ require 'bpm/init_generator'
69
+ require 'bpm/project_generator'
@@ -0,0 +1,43 @@
1
+ require 'bpm/version'
2
+
3
+ module BPM
4
+ class InitGenerator < BPM::Generator
5
+
6
+ source_root File.join(::BPM::TEMPLATES_DIR, 'init')
7
+
8
+ def bpm_version
9
+ BPM::VERSION
10
+ end
11
+
12
+ def run
13
+ if File.exist?("package.json")
14
+ convert_package(destination_root)
15
+ else
16
+ template "project.json", "#{name}.json"
17
+ end
18
+
19
+ empty_directory "assets"
20
+
21
+ inside "assets" do
22
+ template "bpm_packages.js"
23
+ template "bpm_styles.css"
24
+ end
25
+
26
+ true
27
+ end
28
+
29
+ private
30
+
31
+ def convert_package(destination_root)
32
+ package = BPM::Package.new(destination_root)
33
+ package.load_json
34
+ File.open("#{name}.json", "w") do |f|
35
+ f.write JSON.pretty_generate(package.as_json)
36
+ end
37
+ puts "created #{name}.json from package.json"
38
+ end
39
+
40
+ end
41
+ end
42
+
43
+ BPM.register_generator(:default, :init, BPM::InitGenerator)
@@ -0,0 +1,11 @@
1
+ require 'bpm/libgems_ext/libgems'
2
+ require 'bpm/libgems_ext/config_file'
3
+ require 'bpm/libgems_ext/dependency_installer'
4
+ require 'bpm/libgems_ext/installer'
5
+ require 'bpm/libgems_ext/spec_fetcher'
6
+
7
+ # Empty sources to make sure we don't get ones from RubyGems
8
+ LibGems.sources = nil
9
+
10
+ # Reload from new paths
11
+ LibGems.load_configuration
@@ -0,0 +1,33 @@
1
+ require 'libgems/config_file'
2
+
3
+ module LibGems
4
+ class ConfigFile
5
+
6
+ # Duplicate, with slight work-arounds, but needed for SYSTEM_WIDE_CONFIG_FILE
7
+ system_config_path =
8
+ if defined?(Win32API) # Already required in original version
9
+ CSIDL_COMMON_APPDATA = 0x0023
10
+ path = 0.chr * 260
11
+ if RUBY_VERSION > '1.9' then
12
+ SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'PLPLP',
13
+ 'L', :stdcall
14
+ SHGetFolderPath.call nil, CSIDL_COMMON_APPDATA, nil, 1, path
15
+ else
16
+ SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'LLLLP',
17
+ 'L'
18
+ SHGetFolderPath.call 0, CSIDL_COMMON_APPDATA, 0, 1, path
19
+ end
20
+
21
+ path.strip
22
+ else
23
+ '/etc'
24
+ end
25
+
26
+ remove_const(:SYSTEM_WIDE_CONFIG_FILE)
27
+ SYSTEM_WIDE_CONFIG_FILE = File.join system_config_path, 'bpmrc'
28
+
29
+ def credentials_path
30
+ File.join(LibGems.user_dir, "credentials")
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,150 @@
1
+ require 'libgems/dependency_installer'
2
+
3
+ module LibGems
4
+ class DependencyInstaller
5
+
6
+ # Had to overwrite this all just to change the match from /gem$/ to /spd$/
7
+ # TODO: Consider whether extension should be settable in LibGems
8
+ def find_spec_by_name_and_version(gem_name,
9
+ version = LibGems::Requirement.default,
10
+ prerelease = false)
11
+ spec_and_source = nil
12
+
13
+ glob = if File::ALT_SEPARATOR then
14
+ gem_name.gsub File::ALT_SEPARATOR, File::SEPARATOR
15
+ else
16
+ gem_name
17
+ end
18
+
19
+ local_gems = Dir["#{glob}*"].sort.reverse
20
+
21
+ unless local_gems.empty? then
22
+ local_gems.each do |gem_file|
23
+ next unless gem_file =~ /spd$/
24
+ begin
25
+ spec = LibGems::Format.from_file_by_path(gem_file).spec
26
+ spec_and_source = [spec, gem_file]
27
+ break
28
+ rescue SystemCallError, LibGems::Package::FormatError
29
+ end
30
+ end
31
+ end
32
+
33
+ if spec_and_source.nil? then
34
+ dep = LibGems::Dependency.new gem_name, version
35
+ dep.prerelease = true if prerelease
36
+ spec_and_sources = find_gems_with_sources(dep).reverse
37
+
38
+ spec_and_source = spec_and_sources.find { |spec, source|
39
+ LibGems::Platform.match spec.platform
40
+ }
41
+ end
42
+
43
+ if spec_and_source.nil? then
44
+ raise LibGems::GemNotFoundException.new(
45
+ "Could not find #{prerelease ? 'prerelease ' : ''}package '#{gem_name}' (#{version}) locally or in a repository",
46
+ gem_name, version, @errors)
47
+ end
48
+
49
+ @specs_and_sources = [spec_and_source]
50
+ end
51
+
52
+ # Overwrite this to use our custom installer
53
+ def install dep_or_name, version = LibGems::Requirement.default
54
+ LibGems.with_rubygems_compat do
55
+ if String === dep_or_name then
56
+ find_spec_by_name_and_version dep_or_name, version, @prerelease
57
+ else
58
+ dep_or_name.prerelease = @prerelease
59
+ @specs_and_sources = [find_gems_with_sources(dep_or_name).last]
60
+ end
61
+
62
+ @installed_gems = []
63
+
64
+ gather_dependencies
65
+
66
+ @gems_to_install.each do |spec|
67
+ last = spec == @gems_to_install.last
68
+ # HACK is this test for full_name acceptable?
69
+ next if @source_index.any? { |n,_| n == spec.full_name } and not last
70
+
71
+ # TODO: make this sorta_verbose so other users can benefit from it
72
+ say "Installing spd #{spec.full_name}" if LibGems.configuration.really_verbose
73
+
74
+ _, source_uri = @specs_and_sources.assoc spec
75
+ begin
76
+ local_gem_path = LibGems::RemoteFetcher.fetcher.download spec, source_uri,
77
+ @cache_dir
78
+ rescue LibGems::RemoteFetcher::FetchError
79
+ next if @force
80
+ raise
81
+ end
82
+
83
+ inst = LibGems::Installer.new local_gem_path,
84
+ :bin_dir => @bin_dir,
85
+ :development => @development,
86
+ :env_shebang => @env_shebang,
87
+ :force => @force,
88
+ :format_executable => @format_executable,
89
+ :ignore_dependencies => @ignore_dependencies,
90
+ :install_dir => @install_dir,
91
+ :security_policy => @security_policy,
92
+ :source_index => @source_index,
93
+ :user_install => @user_install,
94
+ :wrappers => @wrappers
95
+
96
+ spec = inst.install
97
+
98
+ @installed_gems << spec
99
+ end
100
+
101
+ @installed_gems
102
+ end
103
+ end
104
+
105
+ def find_gems_with_sources(dep)
106
+ # Reset the errors
107
+ @errors = nil
108
+ gems_and_sources = []
109
+
110
+ if @domain == :both or @domain == :local then
111
+ Dir[File.join(Dir.pwd, "#{dep.name}-[0-9]*.spd")].each do |gem_file|
112
+ spec = LibGems::Format.from_file_by_path(gem_file).spec
113
+ gems_and_sources << [spec, gem_file] if spec.name == dep.name
114
+ end
115
+ end
116
+
117
+ if @domain == :both or @domain == :remote then
118
+ begin
119
+ requirements = dep.requirement.requirements.map do |req, ver|
120
+ req
121
+ end
122
+
123
+ all = !dep.prerelease? &&
124
+ # we only need latest if there's one requirement and it is
125
+ # guaranteed to match the newest specs
126
+ (requirements.length > 1 or
127
+ (requirements.first != ">=" and requirements.first != ">"))
128
+
129
+ found, @errors = LibGems::SpecFetcher.fetcher.fetch_with_errors dep, all, true, dep.prerelease?
130
+
131
+ gems_and_sources.push(*found)
132
+
133
+ rescue LibGems::RemoteFetcher::FetchError => e
134
+ if LibGems.configuration.really_verbose then
135
+ say "Error fetching remote data:\t\t#{e.message}"
136
+ say "Falling back to local-only install"
137
+ end
138
+ @domain = :local
139
+ end
140
+ end
141
+
142
+ gems_and_sources.sort_by do |gem, source|
143
+ [gem, source =~ /^http:\/\// ? 0 : 1] # local gems win
144
+ end
145
+ end
146
+
147
+ end
148
+ end
149
+
150
+
@@ -0,0 +1,39 @@
1
+ require 'libgems/installer'
2
+
3
+ module LibGems
4
+ class Installer
5
+
6
+ def app_script_text(bin_file_name)
7
+ <<-TEXT
8
+ #{shebang bin_file_name}
9
+ #
10
+ # This file was generated by BPM.
11
+ #
12
+ # The application '#{@spec.name}' is installed as part of an spd, and
13
+ # this file is here to facilitate running it.
14
+ #
15
+
16
+ version = "#{LibGems::Requirement.default}"
17
+
18
+ if ARGV.first =~ /^_(.*)_$/ and LibGems::Version.correct? $1 then
19
+ version = $1
20
+ ARGV.shift
21
+ end
22
+
23
+ gem '#{@spec.name}', version
24
+
25
+ path = LibGems.bin_path('#{@spec.name}', '#{bin_file_name}', version)
26
+ shebang = File.open(path){|f| f.readline }
27
+
28
+ if shebang =~ /^\#\!.*ruby/
29
+ load path
30
+ else
31
+ exec path, *ARGV
32
+ end
33
+ TEXT
34
+ end
35
+
36
+ end
37
+ end
38
+
39
+