Sha256: b2bb1145949de78bf4d0cd33c6c9540e2a605bc3f23c5fcd4a6043ab7cc5bacf

Contents?: true

Size: 1.71 KB

Versions: 6

Compression:

Stored size: 1.71 KB

Contents

class Component < Thor
  include Thor::Actions

  COMPONENTS = {
    "necolas/normalize.css" => "v1"
  }

  desc "create", "Create basic structure to use Component components."
  def create
    create_file "component.json" do

    name         = ask "App name:", :cyan
    default_name = "indefinido/#{name.split(' ')[0].downcase}"

    repo = ask "Repository (<username>/<project>): [#{default_name}]", :cyan
    repo = default_name if repo == ""

    desc = ask "App description:", :cyan

    repos = []
    if yes? "Choose some components? [y/n]", :cyan

      COMPONENTS.each_pair do |repo, version|
        repos << [repo,version] if yes? "  #{repo}(#{version})? [y/n] ", :magenta
      end
    end

<<-COMPONENT
{
  "name": "#{name}",
  "repo": "#{repo}",
  "description": "#{desc}",
  "version": "0.0.1",
  "keywords": [],
  "dependencies": {
    #{ repos.map do |repo| "\"#{repo[0]}\": \"#{repo[1]}\"" end.join ",\n    " }
  },
  "development": {},
  "paths": ["lib/components", "vendor/components"],
  "license": "MIT"
}
COMPONENT
    end

    empty_directory "vendor/components"
    empty_directory "vendor/assets/components"
  end

  desc "install [COMPONENT], [PATH]", "Install components to PATH, defaulted to ./vendor/components"
  def install component = "", path = "vendor/components"
    run "component install #{component} --out #{path}"
  end

  desc "search QUERY", "Search components repository for a given component"
  def search query
    run "component search #{query}"
  end

  desc "build [PATH]", "Build components to PATH, defaulted to ./vendor/assets/components"
  def build path="vendor/assets/components"
    run "component build --out #{path}"
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ende-0.1.5 lib/tasks/component.thor
ende-0.1.4 lib/tasks/component.thor
ende-0.1.3 lib/tasks/component.thor
ende-0.1.2 lib/tasks/component.thor
ende-0.1.1 lib/tasks/component.thor
ende-0.0.1 lib/tasks/component.thor