Sha256: 3f1e039b96732652d3b07d5aeff27d157914a0c3d90301bf890844de59ef09b4

Contents?: true

Size: 1.96 KB

Versions: 9

Compression:

Stored size: 1.96 KB

Contents

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

      CORDOVA_VERSION = `cordova -v`
      CORDOVA_PATH = `which cordova`

      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} at #{CORDOVA_PATH}"
        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
          say "Adding console plugin to project".colorize(:green)
          system "cordova plugin add org.apache.cordova.console"
        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

      def self.is_global_generator?
        true
      end

      private

      def version
        CORDOVA_VERSION.chomp
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
susanoo-0.10.0 lib/susanoo/generators/cordova.rb
susanoo-0.8.0 lib/susanoo/generators/cordova.rb
susanoo-0.7.4 lib/susanoo/generators/cordova.rb
susanoo-0.7.2 lib/susanoo/generators/cordova.rb
susanoo-0.7.1 lib/susanoo/generators/cordova.rb
susanoo-0.7.0 lib/susanoo/generators/cordova.rb
susanoo-0.5.1 lib/susanoo/generators/cordova.rb
susanoo-0.5.0 lib/susanoo/generators/cordova.rb
susanoo-0.4.1 lib/susanoo/generators/cordova.rb