Class: Hippo::Command::App

Inherits:
NamedCommand show all
Defined in:
lib/hippo/command/app.rb

Instance Attribute Summary collapse

Attributes inherited from NamedCommand

#class_name, #client_dir, #identifier, #namespace, #spec_dir

Instance Method Summary collapse

Methods inherited from NamedCommand

source_root

Instance Attribute Details

#titleObject (readonly)

Returns the value of attribute title


12
13
14
# File 'lib/hippo/command/app.rb', line 12

def title
  @title
end

Instance Method Details

#create_client_filesObject


56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/hippo/command/app.rb', line 56

def create_client_files
    self.class.source_root.join('client').children.each do | path |
        next unless path.directory?
        empty_directory "#{client_dir}/#{path.basename}"
        create_file "#{client_dir}/#{path.basename}/.gitkeep"
    end
    create_file "#{client_dir}/components/.gitkeep", ""
    template "client/models/base.js",   "#{client_dir}/models/base.js"
    template "client/index.js",         "#{client_dir}/index.js"
    template "client/extension.js",     "#{client_dir}/extension.js"
    template "client/styles.scss",      "#{client_dir}/styles.scss"
end

#create_filesObject


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/hippo/command/app.rb', line 27

def create_files
    [
        "Gemfile", "Rakefile", "Guardfile", "config.ru",
        ".babelrc", "config/database.yml"
    ].each{ |f| template(f) }
    [
        ".eslintrc.js", ".rubocop.yml", "spec/client/.eslintrc.js"
    ].each{ |f| template("../#{f}", f) }
    template "lib/namespace.rb", "lib/#{identifier}.rb"
    template "lib/namespace/version.rb", "lib/#{identifier}/version.rb"
    template "lib/namespace/extension.rb", "lib/#{identifier}/extension.rb"
    template "lib/namespace/base_model.rb", "lib/#{identifier}/model.rb"
    template "config/screens.rb"
    template "config/routes.rb"
    template "config/webpack.config.js"

    template "config/jest.config.json"
    template "config/jest/babel-transform.js"
    template "config/initialize.rb"
    template ".gitignore"
    template "spec/client/setup.js"
    template "spec/server/spec_helper.rb"

    create_file "log/.gitkeep",""
    create_file "views/.gitkeep",""
    create_file "tmp/.gitkeep",""
    create_file "db/migrate/.gitkeep",""
end

#knitterizeObject


70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/hippo/command/app.rb', line 70

def knitterize
    yarn = Knitter::Yarn.new(self.destination_root)
    yarn.init
    return unless options[:packages]
    say 'Installing node modules', :green
    [
        'jest',
        'hippo-fw',
        'react-router',
        'webpack',
        'webpack-dev-server'
    ].each do | package_name |
        say(sprintf('    %-20s', package_name + ''), nil, false)
        package = Knitter::Package.new(package_name, yarn: yarn)
        package.add
        say 'done', :green
    end

end

#load_namespaceObject

override


16
17
18
19
# File 'lib/hippo/command/app.rb', line 16

def load_namespace # override
    @namespace  = name.underscore.camelize
    @identifier = @namespace.underscore.dasherize
end

#set_variablesObject


21
22
23
24
25
# File 'lib/hippo/command/app.rb', line 21

def set_variables
    super
    @title = options[:title] || @namespace
    self.destination_root = options[:directory] || name
end