teapot 2.3.0 → 3.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0dd1292b87cd5db2fadc2379f270574504222ca5865d020c1463c072ddb14e79
4
- data.tar.gz: 9c7a12f5887482e46b896d5a3e77147a28d3563cdf2ec194f489ab064f75d9ef
3
+ metadata.gz: 9ddf54a5f033a10d5fc574f0222df4cb5f567416d4d279d0a272052527eacfad
4
+ data.tar.gz: 147d1d9e73c9fd945cdc3d64beba318b2f660aa2aabd974ac3dd9ec487455cc5
5
5
  SHA512:
6
- metadata.gz: 4dfac1b253ce27cd86644dfae4f9b1ee3b8cc43a1436b11022a33a18b17e0ba53bd79deb420b236b9dd7b1d48f5859a5f1d2cfafc223cbc3689801eefc1f20cc
7
- data.tar.gz: 797f3d03946859f2e8c8fefc4a610a3f7bb14d6dad90fdc8063989b7cf1a66524b5608ebeeb7c984455603c8d9a6096be5c0bef74385a4711d326c4bd0af3c13
6
+ metadata.gz: e394f73f673ac474050f75fbbe2d8a9a2f3eaf381c49b5f928814deb6ec7d32fae0143155025d06da768dad39eadaa39bb7ee7ad89e3588a13f20205b34a9c80
7
+ data.tar.gz: bc7f8a41f4b8ded58880e777cb3f412245a198885f9cc0002ed43944673956d03c98fbe5c4cb3bd11902b131547e3135ac3537e54233ff0892a2c5a19591b60a
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ .rspec_status
6
7
  Gemfile.lock
7
8
  InstalledFiles
8
9
  _yardoc
@@ -15,4 +16,6 @@ spec/reports
15
16
  test/tmp
16
17
  test/version_tmp
17
18
  tmp
19
+
18
20
  kurocha
21
+ dependency.svg
@@ -16,7 +16,7 @@ matrix:
16
16
  - rvm: 2.6
17
17
  os: osx
18
18
  before_install: brew install pkgconfig zlib curl openssl libssh2 libgit2
19
- env: RUGGED_USE_SYSTEM_LIBRARIES=y
19
+ # env: RUGGED_USE_SYSTEM_LIBRARIES=y
20
20
  - rvm: 2.6
21
21
  env: COVERAGE=BriefSummary,Coveralls
22
22
 
@@ -29,5 +29,5 @@ addons:
29
29
  - clang-4.0
30
30
  - libc++-dev
31
31
  - libc++abi-dev
32
- env:
33
- - CC=clang-4.0 CXX=clang++-4.0
32
+ # env:
33
+ # - CC=clang-4.0 CXX=clang++-4.0
data/Gemfile CHANGED
@@ -2,11 +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
- end
9
-
10
- # group :test do
11
- # gem 'rugged', git: 'git://github.com/libgit2/rugged.git', submodules: true
12
- # end
data/bin/teapot CHANGED
@@ -20,40 +20,6 @@
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)
26
-
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:"
36
-
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)
45
- end
46
- end
47
- 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
- end
25
+ Teapot::Command::Top.call
@@ -33,19 +33,12 @@ 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
45
- def self.parse(*args)
46
- Top.parse(*args)
47
- end
48
-
49
42
  class Top < Samovar::Command
50
43
  self.description = "A decentralised package manager and build tool."
51
44
 
@@ -57,7 +50,7 @@ module Teapot
57
50
  option '-v/--version', "Print out the application version."
58
51
  end
59
52
 
60
- nested '<command>', {
53
+ nested :command, {
61
54
  "create" => Create,
62
55
  "clone" => Clone,
63
56
  "fetch" => Fetch,
@@ -81,15 +74,13 @@ module Teapot
81
74
  end
82
75
 
83
76
  def logger
84
- @logger ||= Logger.new($stderr).tap do |logger|
85
- logger.formatter = ::Build::CompactFormatter.new(verbose: verbose?)
86
-
77
+ @logger ||= Console::Logger.new(Console.logger, verbose: self.verbose?).tap do |logger|
87
78
  if verbose?
88
- logger.level = Logger::DEBUG
79
+ logger.debug!
89
80
  elsif quiet?
90
- logger.level = Logger::WARN
81
+ logger.warn!
91
82
  else
92
- logger.level = Logger::INFO
83
+ logger.info!
93
84
  end
94
85
  end
95
86
  end
@@ -102,16 +93,44 @@ module Teapot
102
93
  Context.new(root, configuration: configuration)
103
94
  end
104
95
 
105
- def invoke(program_name: File.basename($0))
96
+ def call
106
97
  if @options[:version]
107
98
  puts "teapot v#{Teapot::VERSION}"
108
- elsif @options[:help] or @command.nil?
109
- print_usage(program_name)
99
+ elsif @options[:help]
100
+ print_usage(output: $stdout)
110
101
  else
111
- track_time do
112
- @command.invoke(self)
102
+ @command.call
103
+ end
104
+ rescue Teapot::IncompatibleTeapotError => error
105
+ logger.error(command, error) do
106
+ "Supported minimum version #{Teapot::MINIMUM_LOADER_VERSION.dump} to #{Teapot::LOADER_VERSION.dump}."
107
+ end
108
+
109
+ raise
110
+ rescue ::Build::Dependency::UnresolvedDependencyError => error
111
+ logger.error(command, error) do |buffer|
112
+ buffer.puts "Unresolved dependencies:"
113
+
114
+ error.chain.unresolved.each do |name, parent|
115
+ buffer.puts "#{parent} depends on #{name.inspect}"
116
+
117
+ conflicts = error.chain.conflicts[name]
118
+
119
+ if conflicts
120
+ conflicts.each do |conflict|
121
+ buffer.puts " - provided by #{conflict.name}"
122
+ end
123
+ end
113
124
  end
125
+
126
+ buffer.puts "Cannot continue due to unresolved dependencies!"
114
127
  end
128
+
129
+ raise
130
+ rescue StandardError => error
131
+ logger.error(command, error)
132
+
133
+ raise
115
134
  end
116
135
  end
117
136
  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 call
43
42
  context = parent.context
44
43
 
45
44
  # The targets to build:
@@ -50,23 +49,10 @@ 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
+ controller.add_chain(chain, self.argv, environment)
70
56
  end
71
57
 
72
58
  walker = nil
@@ -91,7 +77,7 @@ module Teapot
91
77
  end
92
78
  end
93
79
 
94
- return chain, ordered
80
+ return chain
95
81
  end
96
82
 
97
83
  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 call
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 call
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].call
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 call
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].call
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].call
67
64
 
68
65
  # Fetch any additional packages:
69
- Fetch[].invoke(nested)
66
+ Fetch[parent: nested].call
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 call
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