Sha256: 342bce998173566169a9cc810682b927ebc4a8e0113bce984a3fd2d122f14188

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

module Susanoo
  module Generators
    class Cordova < Thor::Group
      include Thor::Actions

      CORDOVA_VERSION = "v3.3.0"

      def initialize_project
        fname = Susanoo::Project.folder_name.dup

        # Java Package name
        package_name = ask "Java Package Name: ".colorize(:light_green)
        if package_name.chomp.strip.empty?
          package_name = "com.example.#{fname.gsub("-", "_")}"
        else
          if package_name.chomp.split(".").length < 3
            say "Package name format should be like 'suffix.domain.subdomain'".colorize(:red)
            exit 1
          end
        end

        # Project name
        project_name = ask "Project Name [#{fname.colorize(:light_red)}".colorize(:light_green) + "]: ".colorize(:light_green)

        say "Initializing project with Apache Cordova #{version}"
        system "cordova create #{Susanoo::Project.folder_name} #{package_name.chomp} #{project_name.chomp}"
      end

      def platforms
        platforms = ask "Platforms (comma separated): ".colorize(:light_blue)
        inside Susanoo::Project.folder_name do
          platforms.chomp.split(",").each do |platform|
            say "Adding #{platform.strip} platform ...".colorize(:green)
            system "cordova platform add #{platform.strip}"
          end
        end
      end

      def remove_default_files
        say "Removing cordova default files . . .".colorize(:yellow)
        inside Susanoo::Project.folder_name do
          inside "www" do
            remove_file "index.html"
            remove_file "js"
            remove_file "css"
            remove_file "img"
          end
        end
      end

      private

      def version
        CORDOVA_VERSION
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
susanoo-0.1.0 lib/Susanoo/generators/cordova.rb