teapot 1.3.1 → 2.0.0.pre.rc1

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +0 -1
  3. data/.travis.yml +6 -0
  4. data/Gemfile +1 -1
  5. data/bin/teapot +3 -3
  6. data/lib/teapot/command/build.rb +123 -0
  7. data/lib/teapot/{metadata.rb → command/clean.rb} +19 -20
  8. data/lib/teapot/command/create.rb +112 -0
  9. data/lib/teapot/command/fetch.rb +183 -0
  10. data/lib/teapot/command/list.rb +97 -0
  11. data/lib/teapot/command/status.rb +74 -0
  12. data/lib/teapot/command/visualize.rb +70 -0
  13. data/lib/teapot/command.rb +52 -132
  14. data/lib/teapot/context.rb +27 -11
  15. data/lib/teapot/loader.rb +6 -22
  16. data/lib/teapot/target.rb +2 -2
  17. data/lib/teapot/version.rb +1 -1
  18. data/spec/teapot/command_spec.rb +20 -12
  19. data/spec/teapot/context_spec.rb +13 -16
  20. data/teapot.gemspec +6 -4
  21. metadata +35 -45
  22. data/PLANNING.md +0 -20
  23. data/lib/teapot/controller/build.rb +0 -107
  24. data/lib/teapot/controller/clean.rb +0 -35
  25. data/lib/teapot/controller/create.rb +0 -73
  26. data/lib/teapot/controller/fetch.rb +0 -173
  27. data/lib/teapot/controller/generate.rb +0 -45
  28. data/lib/teapot/controller/list.rb +0 -82
  29. data/lib/teapot/controller/visualize.rb +0 -50
  30. data/lib/teapot/controller.rb +0 -81
  31. data/lib/teapot/dependency.rb +0 -25
  32. data/lib/teapot/generator.rb +0 -138
  33. data/lib/teapot/merge.rb +0 -142
  34. data/lib/teapot/repository.rb +0 -135
  35. data/lib/teapot/substitutions.rb +0 -258
  36. data/spec/teapot/generator_spec/teapot.rb +0 -54
  37. data/spec/teapot/generator_spec/template/$NAME.txt +0 -1
  38. data/spec/teapot/generator_spec.rb +0 -46
  39. data/spec/teapot/merge_spec.rb +0 -50
  40. data/spec/teapot/metadata_spec.rb +0 -31
  41. data/spec/teapot/substitutions_spec.rb +0 -65
  42. data/spec/teapot/wait_spec/teapot.rb +0 -41
  43. data/spec/teapot/wait_spec.rb +0 -53
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teapot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 2.0.0.pre.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-28 00:00:00.000000000 Z
11
+ date: 2017-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -38,20 +38,34 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rugged
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: build
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '1.0'
61
+ version: '1.1'
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '1.0'
68
+ version: '1.1'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: build-files
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -95,33 +109,33 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '1.0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: facets
112
+ name: build-text
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: '3.1'
117
+ version: '1.0'
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: '3.1'
124
+ version: '1.0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: samovar
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - "~>"
116
130
  - !ruby/object:Gem::Version
117
- version: '1.2'
131
+ version: '1.6'
118
132
  type: :runtime
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
- version: '1.2'
138
+ version: '1.6'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: bundler
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +156,14 @@ dependencies:
142
156
  requirements:
143
157
  - - "~>"
144
158
  - !ruby/object:Gem::Version
145
- version: 3.4.0
159
+ version: '3.6'
146
160
  type: :development
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: 3.4.0
166
+ version: '3.6'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: rake
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -180,33 +194,25 @@ files:
180
194
  - ".travis.yml"
181
195
  - Gemfile
182
196
  - Gemfile.local
183
- - PLANNING.md
184
197
  - README.md
185
198
  - Rakefile
186
199
  - bin/teapot
187
200
  - lib/teapot.rb
188
201
  - lib/teapot/command.rb
202
+ - lib/teapot/command/build.rb
203
+ - lib/teapot/command/clean.rb
204
+ - lib/teapot/command/create.rb
205
+ - lib/teapot/command/fetch.rb
206
+ - lib/teapot/command/list.rb
207
+ - lib/teapot/command/status.rb
208
+ - lib/teapot/command/visualize.rb
189
209
  - lib/teapot/configuration.rb
190
210
  - lib/teapot/context.rb
191
- - lib/teapot/controller.rb
192
- - lib/teapot/controller/build.rb
193
- - lib/teapot/controller/clean.rb
194
- - lib/teapot/controller/create.rb
195
- - lib/teapot/controller/fetch.rb
196
- - lib/teapot/controller/generate.rb
197
- - lib/teapot/controller/list.rb
198
- - lib/teapot/controller/visualize.rb
199
211
  - lib/teapot/definition.rb
200
- - lib/teapot/dependency.rb
201
- - lib/teapot/generator.rb
202
212
  - lib/teapot/identity_set.rb
203
213
  - lib/teapot/loader.rb
204
- - lib/teapot/merge.rb
205
- - lib/teapot/metadata.rb
206
214
  - lib/teapot/package.rb
207
215
  - lib/teapot/project.rb
208
- - lib/teapot/repository.rb
209
- - lib/teapot/substitutions.rb
210
216
  - lib/teapot/target.rb
211
217
  - lib/teapot/version.rb
212
218
  - materials/kurocha.png
@@ -217,17 +223,9 @@ files:
217
223
  - spec/teapot/command_spec.rb
218
224
  - spec/teapot/context_spec.rb
219
225
  - spec/teapot/context_spec/teapot.rb
220
- - spec/teapot/generator_spec.rb
221
- - spec/teapot/generator_spec/teapot.rb
222
- - spec/teapot/generator_spec/template/$NAME.txt
223
226
  - spec/teapot/identity_set_spec.rb
224
- - spec/teapot/merge_spec.rb
225
- - spec/teapot/metadata_spec.rb
226
- - spec/teapot/substitutions_spec.rb
227
227
  - spec/teapot/target_spec.rb
228
228
  - spec/teapot/target_spec/teapot.rb
229
- - spec/teapot/wait_spec.rb
230
- - spec/teapot/wait_spec/teapot.rb
231
229
  - teapot.gemspec
232
230
  homepage: http://www.teapot.nz
233
231
  licenses:
@@ -244,12 +242,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
244
242
  version: 2.1.0
245
243
  required_rubygems_version: !ruby/object:Gem::Requirement
246
244
  requirements:
247
- - - ">="
245
+ - - ">"
248
246
  - !ruby/object:Gem::Version
249
- version: '0'
247
+ version: 1.3.1
250
248
  requirements: []
251
249
  rubyforge_project:
252
- rubygems_version: 2.6.10
250
+ rubygems_version: 2.6.12
253
251
  signing_key:
254
252
  specification_version: 4
255
253
  summary: Teapot is a tool for managing complex cross-platform builds.
@@ -258,14 +256,6 @@ test_files:
258
256
  - spec/teapot/command_spec.rb
259
257
  - spec/teapot/context_spec.rb
260
258
  - spec/teapot/context_spec/teapot.rb
261
- - spec/teapot/generator_spec.rb
262
- - spec/teapot/generator_spec/teapot.rb
263
- - spec/teapot/generator_spec/template/$NAME.txt
264
259
  - spec/teapot/identity_set_spec.rb
265
- - spec/teapot/merge_spec.rb
266
- - spec/teapot/metadata_spec.rb
267
- - spec/teapot/substitutions_spec.rb
268
260
  - spec/teapot/target_spec.rb
269
261
  - spec/teapot/target_spec/teapot.rb
270
- - spec/teapot/wait_spec.rb
271
- - spec/teapot/wait_spec/teapot.rb
data/PLANNING.md DELETED
@@ -1,20 +0,0 @@
1
- # Planning
2
-
3
- Teapot 2.0 will feature isolated build directories and private dependencies.
4
-
5
- ## Isolated Build Directories
6
-
7
- Individual packages will be built into discrete directories:
8
-
9
- ```
10
- teapot/#{platform}/libpng/include/png.h
11
- teapot/#{platform}/libpng/lib/libpng.a
12
- ```
13
-
14
- ## Private Dependencies
15
-
16
- All dependencies by default are public.
17
-
18
- Given a package, C, that depends on B, and B publicly depends on A, C also depends on A.
19
-
20
- The problem is that some dependencies of B should not also be dependencies of A, for example internal build tools, etc. It's not necessary for a consumer of A to be aware of C in all cases.
@@ -1,107 +0,0 @@
1
- # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
20
-
21
- require_relative '../controller'
22
- require 'build/controller'
23
-
24
- module Teapot
25
- class Controller
26
- class BuildFailedError < StandardError
27
- end
28
-
29
- def show_dependencies(walker)
30
- outputs = {}
31
-
32
- walker.tasks.each do |node, task|
33
- # puts "Task #{task} (#{node}) outputs:"
34
-
35
- task.outputs.each do |path|
36
- path = path.to_s
37
-
38
- # puts "\t#{path}"
39
-
40
- outputs[path] = task
41
- end
42
- end
43
-
44
- walker.tasks.each do |node, task|
45
- dependencies = {}
46
- task.inputs.each do |path|
47
- path = path.to_s
48
-
49
- if generating_task = outputs[path]
50
- dependencies[path] = generating_task
51
- end
52
- end
53
-
54
- puts "Task #{task.inspect} has #{dependencies.count} dependencies."
55
- dependencies.each do |path, task|
56
- puts "\t#{task.inspect}: #{path}"
57
- end
58
- end
59
- end
60
-
61
- def build(dependency_names)
62
- chain = context.dependency_chain(dependency_names, context.configuration)
63
-
64
- ordered = chain.ordered
65
-
66
- if @options[:only]
67
- ordered = context.direct_targets(ordered)
68
- end
69
-
70
- controller = Build::Controller.new(logger: self.logger, limit: @options[:limit]) do |controller|
71
- ordered.each do |resolution|
72
- target = resolution.provider
73
-
74
- environment = target.environment(context.configuration, chain)
75
-
76
- if target.build
77
- controller.add_target(target, environment.flatten)
78
- end
79
- end
80
- end
81
-
82
- walker = nil
83
-
84
- # We need to catch interrupt here, and exit with the correct exit code:
85
- begin
86
- controller.run do |walker|
87
- # show_dependencies(walker)
88
-
89
- # Only run once is asked:
90
- unless @options[:continuous]
91
- if walker.failed?
92
- raise BuildFailedError.new("Failed to build all nodes successfully!")
93
- end
94
-
95
- break
96
- end
97
- end
98
- rescue Interrupt
99
- if walker && walker.failed?
100
- raise BuildFailedError.new("Failed to build all nodes successfully!")
101
- end
102
- end
103
-
104
- return chain, ordered
105
- end
106
- end
107
- end
@@ -1,35 +0,0 @@
1
- # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
20
-
21
- require_relative '../controller'
22
-
23
- module Teapot
24
- class Controller
25
- def clean
26
- configuration = context.configuration
27
-
28
- log "Removing #{configuration.platforms_path}...".color(:cyan)
29
- FileUtils.rm_rf configuration.platforms_path
30
-
31
- log "Removing #{configuration.packages_path}...".color(:cyan)
32
- FileUtils.rm_rf configuration.packages_path
33
- end
34
- end
35
- end
@@ -1,73 +0,0 @@
1
- # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
20
-
21
- require_relative '../controller'
22
- require_relative 'fetch'
23
-
24
- require 'build/name'
25
-
26
- module Teapot
27
- class Controller
28
- def create(project_name, source, packages)
29
- name = Build::Name.new(project_name)
30
-
31
- log "Creating project named #{project_name} at path #{@root}...".color(:cyan)
32
-
33
- File.open(@root + TEAPOT_FILE, "w") do |output|
34
- output.puts "\# Teapot v#{VERSION} configuration generated at #{Time.now.to_s}", ''
35
-
36
- output.puts "required_version #{LOADER_VERSION.dump}", ''
37
-
38
- output.puts "\# Build Targets", ''
39
-
40
- output.puts "\# Configurations", ''
41
-
42
- output.puts "define_configuration #{name.target.dump} do |configuration|"
43
-
44
- output.puts "\tconfiguration[:source] = #{source.dump}", ''
45
-
46
- packages.each do |name|
47
- output.puts "\tconfiguration.require #{name.dump}"
48
- end
49
-
50
- output.puts "end", ''
51
- end
52
-
53
- # Fetch the initial packages:
54
- self.fetch
55
-
56
- # Generate the default project if it is possible to do so:
57
- generate_project(project_name)
58
-
59
- self.reload!
60
-
61
- # Fetch any additional packages:
62
- self.fetch
63
- end
64
-
65
- private
66
-
67
- def generate_project(project_name)
68
- if context.generators.key? 'project'
69
- generate('project', [project_name], true)
70
- end
71
- end
72
- end
73
- end
@@ -1,173 +0,0 @@
1
- # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
20
-
21
- require_relative '../controller'
22
- require_relative '../repository'
23
-
24
- module Teapot
25
- class Controller
26
- def fetch(**options)
27
- resolved = Set.new
28
- configuration = context.configuration
29
- unresolved = context.unresolved(configuration.packages)
30
-
31
- while true
32
- configuration.packages.each do |package|
33
- next if resolved.include? package
34
-
35
- fetch_package(context, configuration, package, **options)
36
-
37
- # We are done with this package, don't try to process it again:
38
- resolved << package
39
- end
40
-
41
- # Resolve any/all imports:
42
- configuration.materialize
43
-
44
- previously_unresolved = unresolved
45
- unresolved = context.unresolved(configuration.packages)
46
-
47
- # No additional packages were resolved, we have reached a fixed point:
48
- if previously_unresolved == unresolved || unresolved.count == 0
49
- break
50
- end
51
- end
52
-
53
- if unresolved.count > 0
54
- log "Could not fetch all packages!".color(:red)
55
- unresolved.each do |package|
56
- log "\t#{package}".color(:red)
57
- end
58
- else
59
- log "Completed fetch successfully.".color(:green)
60
- end
61
- end
62
-
63
- private
64
-
65
- def current_commit(package)
66
- IO.popen(['git', '--git-dir', (package.path + '.git').to_s, 'rev-parse', '--verify', 'HEAD']) do |io|
67
- io.read.chomp!
68
- end
69
- end
70
-
71
- def current_branch(package)
72
- IO.popen(['git', '--git-dir', (package.path + '.git').to_s, 'rev-parse', '--abbrev-ref', 'HEAD']) do |io|
73
- io.read.chomp!
74
- end
75
- end
76
-
77
- def current_metadata(package)
78
- {
79
- branch: current_branch(package),
80
- commit: current_commit(package)
81
- }
82
- end
83
-
84
- def link_local_package(context, configuration, package)
85
- log "Linking local #{package}...".color(:cyan)
86
-
87
- local_path = context.root + package.options[:local]
88
-
89
- # Where we are going to put the package:
90
- destination_path = package.path
91
-
92
- # Make the top level directory if required:
93
- destination_path.dirname.create
94
-
95
- unless destination_path.exist?
96
- destination_path.make_symlink(local_path)
97
- end
98
- end
99
-
100
- def clone_or_pull_package(context, configuration, package, package_lock)
101
- log "Fetching #{package}...".color(:cyan)
102
-
103
- # Where we are going to put the package:
104
- destination_path = package.path
105
-
106
- base_uri = URI(package.options[:source].to_s)
107
-
108
- if base_uri.scheme == nil || base_uri.scheme == 'file'
109
- base_uri = URI "file://" + File.expand_path(base_uri.path, context.root) + "/"
110
- end
111
-
112
- branch = package.options.fetch(:branch, 'master')
113
-
114
- if package_lock
115
- log "Package locked to commit: #{package_lock[:branch]}/#{package_lock[:commit]}"
116
-
117
- branch = package_lock[:branch]
118
- end
119
-
120
- commit = package_lock ? package_lock[:commit] : nil
121
-
122
- unless destination_path.exist?
123
- log "Cloning package at path #{destination_path} ...".color(:cyan)
124
-
125
- begin
126
- external_url = package.external_url(context.root)
127
-
128
- Repository.new(destination_path).clone!(external_url, branch, commit)
129
- rescue
130
- log "Failed to clone #{external_url}...".color(:red)
131
-
132
- raise
133
- end
134
- else
135
- log "Updating package at path #{destination_path} ...".color(:cyan)
136
-
137
- commit = package_lock ? package_lock[:commit] : nil
138
- Repository.new(destination_path).update(branch, commit)
139
- end
140
- end
141
-
142
- def fetch_package(context, configuration, package, update: false, local: false)
143
- if package.local?
144
- link_local_package(context, configuration, package)
145
- elsif package.external?
146
- lock_store = configuration.lock_store
147
-
148
- # If we are updating, don't bother reading the current branch/commit details.
149
- unless update
150
- package_lock = lock_store.transaction(true){|store| store[package.name]}
151
- end
152
-
153
- unless local
154
- clone_or_pull_package(context, configuration, package, package_lock)
155
- end
156
-
157
- # Lock the package, unless it was already locked:
158
- unless package_lock
159
- metadata = current_metadata(package)
160
-
161
- lock_store.transaction do |store|
162
- store_metadata = store[package.name]
163
-
164
- if store_metadata.nil? or store_metadata[:commit] != metadata[:commit]
165
- log("Updating lockfile for package #{package.name}: #{metadata[:commit]}...")
166
- store[package.name] = metadata
167
- end
168
- end
169
- end
170
- end
171
- end
172
- end
173
- end
@@ -1,45 +0,0 @@
1
- # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
20
-
21
- require_relative '../controller'
22
-
23
- module Teapot
24
- class Controller
25
- def generate(name, arguments, force = false)
26
- context.configuration.load_all
27
-
28
- unless force
29
- # Check dirty status of local repository:
30
- if Repository.new(@root).status.size != 0
31
- abort "You have unstaged changes/unadded files. Please stash/commit them before running the generator.".color(:red)
32
- end
33
- end
34
-
35
- generator = context.generators[name]
36
-
37
- unless generator
38
- abort "Could not find generator with name #{name.inspect}".color(:red)
39
- end
40
-
41
- log "Generating #{name.inspect} with arguments #{arguments.inspect}".color(:cyan)
42
- generator.generate!(*arguments)
43
- end
44
- end
45
- end