lib/teapot/command/create.rb in teapot-2.0.0.pre.rc2 vs lib/teapot/command/create.rb in teapot-2.0.0.pre.rc3
- old
+ new
@@ -27,22 +27,14 @@
module Teapot
module Command
class Create < Samovar::Command
self.description = "Create a new teapot package using the specified repository."
- options do
- option "-t/--target-name <name>", "The target to use to create the project", default: 'Generate/Project/Initial'
- end
-
one :project_name, "The name of the new project in title-case, e.g. 'My Project'."
one :source, "The source repository to use for fetching packages, e.g. https://github.com/kurocha."
many :packages, "Any additional packages you'd like to include in the project."
- def target_name
- @options[:target_name]
- end
-
def invoke(parent)
logger = parent.logger
nested = parent['--root', parent.options[:root] || project_name.gsub(/\s+/, '-').downcase]
root = nested.root
@@ -62,18 +54,26 @@
# Fetch the initial packages:
Fetch[].invoke(nested)
context = nested.context
- Build[target_name, *@packages, '--', project_name].invoke(nested)
+ # The targets to build to create the initial project:
+ target_names = context.configuration.targets[:create]
- # Fetch any additional packages:
- Fetch[].invoke(nested)
+ if target_names.any?
+ # Generate the initial project files:
+ Build[*target_names].invoke(nested)
+
+ # Fetch any additional packages:
+ Fetch[].invoke(nested)
+ end
+ # Stage all files:
index = repository.index
index.add_all
+ # Commit the initial project files:
Rugged::Commit.create(repository,
tree: index.write_tree(repository),
message: "Initial project files.",
parents: repository.empty? ? [] : [repository.head.target].compact,
update_ref: 'HEAD'
@@ -91,22 +91,23 @@
# A very basic teapot file to pull in the initial dependencies.
File.open(root + TEAPOT_FILE, "w") do |output|
output.puts "\# Teapot v#{VERSION} configuration generated at #{Time.now.to_s}", ''
output.puts "required_version #{LOADER_VERSION.dump}", ''
+
+ output.puts "define_project #{name.target.dump} do |project|"
+ output.puts "\tproject.title = #{name.text.dump}"
+ output.puts "end", ''
output.puts "\# Build Targets", ''
output.puts "\# Configurations", ''
output.puts "define_configuration #{name.target.dump} do |configuration|"
-
output.puts "\tconfiguration[:source] = #{source.dump}", ''
-
packages.each do |name|
output.puts "\tconfiguration.require #{name.dump}"
end
-
output.puts "end", ''
end
end
end
end