teapot 2.2.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 40d564684024a42a0762e51eef5fdcccea99eb81
4
- data.tar.gz: 4dcc60428ead96eca66951c50ba891dcd366741f
2
+ SHA256:
3
+ metadata.gz: 505d95b6a2ff7e5926b1bc5133feacbd1b2fd34de76098a3679b92d04564fabb
4
+ data.tar.gz: ed41d5bb91594b0b3eae63c8fd1e87674b565f6d233212550c7467c8144934cc
5
5
  SHA512:
6
- metadata.gz: 39344b2e907c0718480aeb96439bfd509c5bfabdfd8e859ea5185fd573e9b96d42594ecc4644699c7cec9270e771b598c2c381d0bc557905d3b6ed04c2f8836e
7
- data.tar.gz: ab69319d540e01679dee8cd9ddfbb45d69fd22d363cc2dce531bc4b34c50fc198e9de35cb287516e2ddb37396ccb2dc9ca829ff7825e6e2497535684cfce015c
6
+ metadata.gz: 1c6c628f2a7ca144025d8730b9dd26fe7e80c57d656098e7a376271967ca567d40168b5a46f24248338a5983591fd030309e936f1a306f34736626381173b9a5
7
+ data.tar.gz: 2eeb2992f80ed8f17d95821ea15299feab6193c134cb019d0fe9bb0e412b4987c09d774f17dc2c375546cded1e89c3b000271f77cc531c71534c5535aa501efb
data/.travis.yml CHANGED
@@ -1,27 +1,24 @@
1
- # Setup the environment:
2
1
  language: ruby
3
- sudo: false
4
- dist: trusty
2
+ dist: xenial
5
3
  cache: bundler
6
4
 
7
- before_install:
5
+ before_script:
8
6
  # For testing purposes:
9
7
  - git config --global user.email "samuel@oriontransfer.net"
10
8
  - git config --global user.name "Samuel Williams"
11
9
 
12
- rvm:
13
- - 2.1
14
- - 2.2
15
- - 2.3
16
- - 2.4
17
- - jruby-head
18
- - ruby-head
19
-
20
- # Setup the compilers:
21
10
  matrix:
22
- allow_failures:
23
- - rvm: ruby-head
24
- - rvm: jruby-head
11
+ include:
12
+ - rvm: 2.3
13
+ - rvm: 2.4
14
+ - rvm: 2.5
15
+ - rvm: 2.6
16
+ - rvm: 2.6
17
+ os: osx
18
+ before_install: brew install pkgconfig zlib curl openssl libssh2 libgit2
19
+ # env: RUGGED_USE_SYSTEM_LIBRARIES=y
20
+ - rvm: 2.6
21
+ env: COVERAGE=BriefSummary,Coveralls
25
22
 
26
23
  addons:
27
24
  apt:
@@ -32,5 +29,5 @@ addons:
32
29
  - clang-4.0
33
30
  - libc++-dev
34
31
  - libc++abi-dev
35
- env:
36
- - CC=clang-4.0 CXX=clang++-4.0
32
+ # env:
33
+ # - CC=clang-4.0 CXX=clang++-4.0
data/Gemfile CHANGED
@@ -2,14 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in teapot.gemspec
4
4
  gemspec
5
-
6
- group :development do
7
- gem 'pry'
8
- gem 'pry-coolline'
9
- gem 'pry-byebug', platform: :mri
10
- end
11
-
12
- group :test do
13
- gem 'simplecov'
14
- gem 'coveralls', require: false
15
- end
data/README.md CHANGED
@@ -10,6 +10,7 @@ Teapot is a decentralised build tool for managing complex cross-platform project
10
10
  [![Build Status](https://secure.travis-ci.org/kurocha/teapot.svg)](http://travis-ci.org/kurocha/teapot)
11
11
  [![Code Climate](https://codeclimate.com/github/kurocha/teapot.svg)](https://codeclimate.com/github/kurocha/teapot)
12
12
  [![Coverage Status](https://coveralls.io/repos/kurocha/teapot/badge.svg)](https://coveralls.io/r/kurocha/teapot)
13
+ [![Gitter Chat](https://badges.gitter.im/kurocha/community.svg)](https://gitter.im/kurocha/community)
13
14
 
14
15
  ## Installation
15
16
 
data/bin/teapot CHANGED
@@ -20,40 +20,42 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  # THE SOFTWARE.
22
22
 
23
- require 'teapot/command'
23
+ require_relative '../lib/teapot/command'
24
24
 
25
- options = Teapot::Command.parse(ARGV)
25
+ if command = Teapot::Command.parse(ARGV)
26
+ logger = command.logger
26
27
 
27
- begin
28
- options.invoke
29
- rescue Teapot::IncompatibleTeapotError => error
30
- $stderr.puts error.message.color(:red)
31
- $stderr.puts "Supported minimum version #{Teapot::MINIMUM_LOADER_VERSION.dump} to #{Teapot::LOADER_VERSION.dump}."
32
-
33
- exit 1
34
- rescue Build::Dependency::UnresolvedDependencyError => error
35
- $stderr.puts "Unresolved dependencies:"
28
+ begin
29
+ command.invoke
30
+ rescue Teapot::IncompatibleTeapotError => error
31
+ logger.error(command, error) do
32
+ "Supported minimum version #{Teapot::MINIMUM_LOADER_VERSION.dump} to #{Teapot::LOADER_VERSION.dump}."
33
+ end
34
+
35
+ exit 1
36
+ rescue Build::Dependency::UnresolvedDependencyError => error
37
+ logger.error(command, error) do |buffer|
38
+ buffer.puts "Unresolved dependencies:"
36
39
 
37
- error.chain.unresolved.each do |name, parent|
38
- $stderr.puts "#{parent} depends on #{name.inspect}".color(:red)
39
-
40
- conflicts = error.chain.conflicts[name]
41
-
42
- if conflicts
43
- conflicts.each do |conflict|
44
- $stderr.puts " - provided by #{conflict.name}".color(:red)
40
+ error.chain.unresolved.each do |name, parent|
41
+ buffer.puts "#{parent} depends on #{name.inspect}"
42
+
43
+ conflicts = error.chain.conflicts[name]
44
+
45
+ if conflicts
46
+ conflicts.each do |conflict|
47
+ buffer.puts " - provided by #{conflict.name}"
48
+ end
49
+ end
45
50
  end
51
+
52
+ buffer.puts "Cannot continue due to unresolved dependencies!".color(:red)
46
53
  end
54
+
55
+ exit 2
56
+ rescue StandardError => error
57
+ logger.error(command, error)
58
+
59
+ exit 3
47
60
  end
48
-
49
- $stderr.puts "Cannot continue due to unresolved dependencies!".color(:red)
50
-
51
- exit 2
52
- rescue StandardError => error
53
- $stderr.puts error.message.color(:red)
54
-
55
- # Could be nice to have some improved error reporting.
56
- $stderr.puts error.backtrace
57
-
58
- exit 3
59
61
  end
@@ -33,12 +33,9 @@ require_relative 'context'
33
33
  require_relative 'configuration'
34
34
  require_relative 'version'
35
35
 
36
- require 'uri'
37
- require 'rainbow'
38
- require 'rainbow/ext/string'
39
36
  require 'fileutils'
40
37
 
41
- require 'build/logger'
38
+ require 'console'
42
39
 
43
40
  module Teapot
44
41
  module Command
@@ -57,16 +54,16 @@ module Teapot
57
54
  option '-v/--version', "Print out the application version."
58
55
  end
59
56
 
60
- nested '<command>',
61
- 'create' => Create,
62
- 'clone' => Clone,
63
- 'fetch' => Fetch,
64
- 'list' => List,
65
- 'status' => Status,
66
- 'build' => Build,
67
- 'visualize' => Visualize,
68
- 'clean' => Clean,
69
- default: 'build'
57
+ nested :command, {
58
+ "create" => Create,
59
+ "clone" => Clone,
60
+ "fetch" => Fetch,
61
+ "list" => List,
62
+ "status" => Status,
63
+ "build" => Build,
64
+ "visualize" => Visualize,
65
+ "clean" => Clean,
66
+ }, default: 'build'
70
67
 
71
68
  def root
72
69
  ::Build::Files::Path.expand(@options[:root] || Dir.getwd)
@@ -81,15 +78,13 @@ module Teapot
81
78
  end
82
79
 
83
80
  def logger
84
- @logger ||= Logger.new($stderr).tap do |logger|
85
- logger.formatter = ::Build::CompactFormatter.new(verbose: verbose?)
86
-
81
+ @logger ||= Console::Logger.new(Console.logger, verbose: self.verbose?).tap do |logger|
87
82
  if verbose?
88
- logger.level = Logger::DEBUG
83
+ logger.debug!
89
84
  elsif quiet?
90
- logger.level = Logger::WARN
85
+ logger.warn!
91
86
  else
92
- logger.level = Logger::INFO
87
+ logger.info!
93
88
  end
94
89
  end
95
90
  end
@@ -102,15 +97,13 @@ module Teapot
102
97
  Context.new(root, configuration: configuration)
103
98
  end
104
99
 
105
- def invoke(program_name: File.basename($0))
100
+ def invoke
106
101
  if @options[:version]
107
102
  puts "teapot v#{Teapot::VERSION}"
108
- elsif @options[:help] or @command.nil?
109
- print_usage(program_name)
103
+ elsif @options[:help]
104
+ print_usage(output: $stdout)
110
105
  else
111
- track_time do
112
- @command.invoke(self)
113
- end
106
+ @command.invoke
114
107
  end
115
108
  end
116
109
  end
@@ -18,7 +18,7 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'samovar'
21
+ require_relative 'selection'
22
22
 
23
23
  require 'build/controller'
24
24
 
@@ -27,19 +27,18 @@ module Teapot
27
27
  class BuildFailedError < StandardError
28
28
  end
29
29
 
30
- class Build < Samovar::Command
30
+ class Build < Selection
31
31
  self.description = "Build the specified target."
32
32
 
33
33
  options do
34
34
  option '-j/-l/--limit <n>', "Limit the build to <n> concurrent processes.", type: Integer
35
- option '--only', "Only build direct dependencies."
36
35
  option '-c/--continuous', "Run the build graph continually (experimental)."
37
36
  end
38
37
 
39
38
  many :targets, "Build these targets, or use them to help the dependency resolution process."
40
39
  split :argv, "Arguments passed to child process(es) of build if any."
41
40
 
42
- def invoke(parent)
41
+ def invoke
43
42
  context = parent.context
44
43
 
45
44
  # The targets to build:
@@ -50,23 +49,11 @@ module Teapot
50
49
  end
51
50
 
52
51
  chain = selection.chain
53
-
54
- ordered = chain.ordered
55
-
56
- if @options[:only]
57
- ordered = selection.direct_targets(ordered)
58
- end
52
+ environment = context.configuration.environment
59
53
 
60
54
  controller = ::Build::Controller.new(logger: parent.logger, limit: @options[:limit]) do |controller|
61
- ordered.each do |resolution|
62
- target = resolution.provider
63
-
64
- if target.build
65
- environment = target.environment(selection.configuration, chain)
66
-
67
- controller.add_target(target, environment.flatten, self.argv)
68
- end
69
- end
55
+
56
+ controller.add_chain(chain, self.argv, environment)
70
57
  end
71
58
 
72
59
  walker = nil
@@ -91,7 +78,7 @@ module Teapot
91
78
  end
92
79
  end
93
80
 
94
- return chain, ordered
81
+ return chain
95
82
  end
96
83
 
97
84
  def show_dependencies(walker)
@@ -25,15 +25,15 @@ module Teapot
25
25
  class Clean < Samovar::Command
26
26
  self.description = "Delete everything in the teapot directory."
27
27
 
28
- def invoke(parent)
28
+ def invoke
29
29
  context = parent.context
30
30
  logger = parent.logger
31
31
  configuration = context.configuration
32
32
 
33
- logger.info "Removing #{configuration.platforms_path}...".color(:cyan)
34
- FileUtils.rm_rf configuration.platforms_path
33
+ logger.info "Removing #{configuration.build_path}..."
34
+ FileUtils.rm_rf configuration.build_path
35
35
 
36
- logger.info "Removing #{configuration.packages_path}...".color(:cyan)
36
+ logger.info "Removing #{configuration.packages_path}..."
37
37
  FileUtils.rm_rf configuration.packages_path
38
38
  end
39
39
  end
@@ -31,11 +31,9 @@ module Teapot
31
31
  class Clone < Samovar::Command
32
32
  self.description = "Clone a remote repository and fetch all dependencies."
33
33
 
34
- one :source, "The source repository to clone."
34
+ one :source, "The source repository to clone.", required: true
35
35
 
36
- def invoke(parent)
37
- raise ArgumentError, "source is required" unless @source
38
-
36
+ def invoke
39
37
  logger = parent.logger
40
38
 
41
39
  name = File.basename(::Build::URI[@source].path, ".git")
@@ -47,11 +45,11 @@ module Teapot
47
45
  raise ArgumentError.new("#{root} already exists!")
48
46
  end
49
47
 
50
- logger.info "Cloning #{@source} to #{root}...".color(:cyan)
51
- repository = Rugged::Repository.clone_at(@source, root.to_s, credentials: self.method(:credentials))
48
+ logger.info "Cloning #{@source} to #{root}..."
49
+ _repository = Rugged::Repository.clone_at(@source, root.to_s, credentials: self.method(:credentials))
52
50
 
53
51
  # Fetch the initial packages:
54
- Fetch[].invoke(nested)
52
+ Fetch[parent: nested].invoke
55
53
  end
56
54
 
57
55
  def credentials(url, username, types)
@@ -29,17 +29,14 @@ module Teapot
29
29
  class Create < Samovar::Command
30
30
  self.description = "Create a new teapot package using the specified repository."
31
31
 
32
- one :project_name, "The name of the new project in title-case, e.g. 'My Project'."
33
- one :source, "The source repository to use for fetching packages, e.g. https://github.com/kurocha."
34
- many :packages, "Any additional packages you'd like to include in the project."
32
+ one :name, "The name of the new project in title-case, e.g. 'My Project'.", required: true
33
+ one :source, "The source repository to use for fetching packages, e.g. https://github.com/kurocha.", required: true
34
+ many :packages, "Any packages you'd like to include in the project.", default: ["generate-project"]
35
35
 
36
- def invoke(parent)
37
- raise ArgumentError, "project_name is required" unless @project_name
38
- raise ArgumentError, "source is required" unless @source
39
-
36
+ def invoke
40
37
  logger = parent.logger
41
38
 
42
- nested = parent['--root', parent.options[:root] || project_name.gsub(/\s+/, '-').downcase]
39
+ nested = parent['--root', parent.options[:root] || name.gsub(/\s+/, '-').downcase]
43
40
  root = nested.root
44
41
 
45
42
  if root.exist?
@@ -51,11 +48,11 @@ module Teapot
51
48
 
52
49
  repository = Rugged::Repository.init_at(root.to_s)
53
50
 
54
- logger.info "Creating project named #{project_name} at path #{root}...".color(:cyan)
55
- generate_project(root, @project_name, @source, @packages)
51
+ logger.info "Creating project named #{name} at path #{root}..."
52
+ generate_project(root, @name, @source, @packages)
56
53
 
57
54
  # Fetch the initial packages:
58
- Fetch[].invoke(nested)
55
+ Fetch[parent: nested].invoke
59
56
 
60
57
  context = nested.context
61
58
  selection = context.select
@@ -63,10 +60,10 @@ module Teapot
63
60
 
64
61
  if target_names.any?
65
62
  # Generate the initial project files:
66
- Build[*target_names].invoke(nested)
63
+ Build[*target_names, parent: nested].invoke
67
64
 
68
65
  # Fetch any additional packages:
69
- Fetch[].invoke(nested)
66
+ Fetch[parent: nested].invoke
70
67
  end
71
68
 
72
69
  # Stage all files:
@@ -82,8 +79,8 @@ module Teapot
82
79
  )
83
80
  end
84
81
 
85
- def generate_project(root, project_name, source, packages)
86
- name = ::Build::Name.new(project_name)
82
+ def generate_project(root, name, source, packages)
83
+ name = ::Build::Name.new(name)
87
84
 
88
85
  # Otherwise the initial commit will try to include teapot/
89
86
  File.open(root + ".gitignore", "w") do |output|
@@ -18,8 +18,7 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'samovar'
22
-
21
+ require_relative 'selection'
23
22
  require 'rugged'
24
23
 
25
24
  module Teapot
@@ -48,19 +47,21 @@ module Teapot
48
47
 
49
48
  many :packages, "Only update the specified packages, or all packages if none specified."
50
49
 
51
- def invoke(parent)
52
- logger = parent.logger
53
- context = parent.context
54
-
55
- updated = Set.new
50
+ def context
51
+ parent.context
52
+ end
53
+
54
+ def invoke
56
55
  selection = context.select
57
56
 
58
57
  packages = selection.configuration.packages
59
58
 
60
- if @packages.any?
61
- packages = packages.slice(@packages)
59
+ if specified_packages = self.packages
60
+ packages = packages.slice(specified_packages)
62
61
  end
63
62
 
63
+ logger = parent.logger
64
+
64
65
  # If no additional packages were resolved, we have reached a fixed point:
65
66
  while packages.any?
66
67
  packages.each do |package|
@@ -78,12 +79,15 @@ module Teapot
78
79
  end
79
80
 
80
81
  if selection.unresolved.count > 0
81
- logger.error "Could not fetch all packages!".color(:red)
82
- selection.unresolved.each do |package|
83
- logger.error "\t#{package}".color(:red)
82
+ logger.error(self) do |buffer|
83
+ buffer.puts "Could not fetch all packages!"
84
+
85
+ selection.unresolved.each do |package|
86
+ buffer.puts "\t#{package}"
87
+ end
84
88
  end
85
89
  else
86
- logger.info "Completed fetch successfully.".color(:green)
90
+ logger.info "Completed fetch successfully."
87
91
  end
88
92
  end
89
93
 
@@ -99,7 +103,7 @@ module Teapot
99
103
  end
100
104
 
101
105
  def link_local_package(context, configuration, package, logger)
102
- logger.info "Linking local #{package}...".color(:cyan)
106
+ logger.info "Linking local #{package}..." #.color(:cyan)
103
107
 
104
108
  local_path = context.root + package.options[:local]
105
109
 
@@ -120,7 +124,7 @@ module Teapot
120
124
  end
121
125
 
122
126
  def clone_or_pull_package(context, configuration, package, package_lock, logger)
123
- logger.info "Processing #{package}...".color(:cyan)
127
+ logger.info "Processing #{package}..." #.color(:cyan)
124
128
 
125
129
  # Where we are going to put the package:
126
130
  destination_path = package.path
@@ -141,7 +145,7 @@ module Teapot
141
145
  end
142
146
 
143
147
  if destination_path.exist?
144
- logger.info "Updating package at path #{destination_path}...".color(:cyan)
148
+ logger.info "Updating package at path #{destination_path}..." #.color(:cyan)
145
149
 
146
150
  repository = Rugged::Repository.new(destination_path.to_s)
147
151
 
@@ -166,7 +170,7 @@ module Teapot
166
170
  # Reset it to the requested commit if required:
167
171
  repository.reset(commit_id, :hard)
168
172
  else
169
- logger.info "Cloning package at path #{destination_path}...".color(:cyan)
173
+ logger.info "Cloning package at path #{destination_path}..." #.color(:cyan)
170
174
 
171
175
  external_url = package.external_url(context.root)
172
176