Class: Hippo::Webpack::ClientConfig

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/hippo/webpack/client_config.rb

Constant Summary collapse

ROOT =
Pathname.new(__FILE__).dirname.join('..', '..', '..')

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#controlling_extensionObject (readonly)

Returns the value of attribute controlling_extension.



11
12
13
# File 'lib/hippo/webpack/client_config.rb', line 11

def controlling_extension
  @controlling_extension
end

#directoryObject (readonly)

Returns the value of attribute directory.



9
10
11
# File 'lib/hippo/webpack/client_config.rb', line 9

def directory
  @directory
end

#extension_pathObject (readonly)

Returns the value of attribute extension_path.



13
14
15
# File 'lib/hippo/webpack/client_config.rb', line 13

def extension_path
  @extension_path
end

#hippo_root_pathObject (readonly)

Returns the value of attribute hippo_root_path.



12
13
14
# File 'lib/hippo/webpack/client_config.rb', line 12

def hippo_root_path
  @hippo_root_path
end

#module_pathsObject (readonly)

Returns the value of attribute module_paths.



15
16
17
# File 'lib/hippo/webpack/client_config.rb', line 15

def module_paths
  @module_paths
end

Class Method Details

.source_rootObject



19
20
21
22
23
# File 'lib/hippo/webpack/client_config.rb', line 19

def self.source_root
    Hippo::Configuration.apply
    Hippo::Extensions.load_controlling_config
    Hippo::Extensions.controlling.root_path
end

Instance Method Details

#make_temp_dirObject



31
32
33
34
# File 'lib/hippo/webpack/client_config.rb', line 31

def make_temp_dir
    @directory = controlling_extension.root_path.join('tmp')
    @directory.mkdir unless @directory.exist?
end

#set_module_pathsObject



36
37
38
39
40
41
# File 'lib/hippo/webpack/client_config.rb', line 36

def set_module_paths
    @module_paths = Extensions.map { |e| e.root_path.join('client').to_s }.reverse + [
        controlling_extension.root_path.join('node_modules').to_s,
        directory.to_s
    ]
end

#set_varsObject



25
26
27
28
29
# File 'lib/hippo/webpack/client_config.rb', line 25

def set_vars
    @controlling_extension = Hippo::Extensions.controlling
    @hippo_root_path = ROOT
    @extension_path = controlling_extension.root_path
end

#write_asset_filesObject



43
44
45
46
47
48
49
50
51
52
# File 'lib/hippo/webpack/client_config.rb', line 43

def write_asset_files
    say "Generating config in #{directory}", :green
    opts = { verbose: false, force: true }
    template('config/jest.config.json',
             directory.join('jest.config.json'), opts)
    template(ROOT.join('templates','js', 'config-data.js'),
             directory.join('hippo/config-data.js'), opts)
    template(ROOT.join('templates','js', 'screen-definitions.js'),
             directory.join('hippo/screen-definitions.js'), opts)
end