isomorfeus 1.0.0.zeta25 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -21
  3. data/README.md +26 -31
  4. data/bin/ismos +2 -2
  5. data/bin/isomorfeus +2 -3
  6. data/lib/isomorfeus/cli.rb +118 -31
  7. data/lib/isomorfeus/command.rb +29 -31
  8. data/lib/isomorfeus/console.rb +21 -21
  9. data/lib/isomorfeus/installer/bundle.rb +13 -0
  10. data/lib/isomorfeus/installer/dsl.rb +67 -0
  11. data/lib/isomorfeus/installer/gemfile.rb +39 -0
  12. data/lib/isomorfeus/installer/install_targets.rb +29 -0
  13. data/lib/isomorfeus/installer/new_project.rb +19 -56
  14. data/lib/isomorfeus/installer/options_mangler.rb +16 -16
  15. data/lib/isomorfeus/installer/rack_servers.rb +5 -11
  16. data/lib/isomorfeus/installer/target/web.rb +54 -0
  17. data/lib/isomorfeus/installer/templates/.gitignore.erb +25 -25
  18. data/lib/isomorfeus/installer/templates/Gemfile.erb +20 -36
  19. data/lib/isomorfeus/installer/templates/anonymous_policy.rb.erb +3 -3
  20. data/lib/isomorfeus/installer/templates/app_loader.rb.erb +8 -8
  21. data/lib/isomorfeus/installer/templates/config.ru.erb +23 -23
  22. data/lib/isomorfeus/installer/templates/hello_component.rb.erb +5 -5
  23. data/lib/isomorfeus/installer/templates/iodine.rb.erb +5 -0
  24. data/lib/isomorfeus/installer/templates/isomorfeus_loader.rb.erb +16 -16
  25. data/lib/isomorfeus/installer/templates/isomorfeus_web_worker_loader.rb.erb +2 -2
  26. data/lib/isomorfeus/installer/templates/{mail_components_loader.rb.erb → mail_loader.rb.erb} +18 -18
  27. data/lib/isomorfeus/installer/templates/mail_preview.mustache.erb +14 -0
  28. data/lib/isomorfeus/installer/templates/my_app.rb.erb +10 -10
  29. data/lib/isomorfeus/installer/templates/navigation_links.rb.erb +8 -8
  30. data/lib/isomorfeus/installer/templates/not_found_404_component.rb.erb +6 -6
  31. data/lib/isomorfeus/installer/templates/roda_app.rb.erb +71 -0
  32. data/lib/isomorfeus/installer/templates/spec_helper.rb.erb +19 -22
  33. data/lib/isomorfeus/installer/templates/web.mustache.erb +15 -0
  34. data/lib/isomorfeus/installer/templates/{test_spec.rb.erb → web_spec.rb.erb} +12 -12
  35. data/lib/isomorfeus/installer/templates/welcome_component.rb.erb +5 -5
  36. data/lib/isomorfeus/installer/test_app_files.rb +24 -0
  37. data/lib/isomorfeus/installer/upgrade.rb +11 -0
  38. data/lib/isomorfeus/installer.rb +57 -261
  39. data/lib/isomorfeus/version.rb +3 -3
  40. data/lib/isomorfeus.rb +10 -8
  41. metadata +68 -63
  42. data/bin/yandle +0 -9
  43. data/lib/isomorfeus/installer/databases/arangodb.rb +0 -13
  44. data/lib/isomorfeus/installer/templates/Procfile.erb +0 -1
  45. data/lib/isomorfeus/installer/templates/ProcfileDebug.erb +0 -3
  46. data/lib/isomorfeus/installer/templates/ProcfileDev.erb +0 -3
  47. data/lib/isomorfeus/installer/templates/app.rb.erb +0 -57
  48. data/lib/isomorfeus/installer/templates/application.css.erb +0 -0
  49. data/lib/isomorfeus/installer/templates/application.js.erb +0 -25
  50. data/lib/isomorfeus/installer/templates/application_common.js.erb +0 -17
  51. data/lib/isomorfeus/installer/templates/application_ssr.js.erb +0 -23
  52. data/lib/isomorfeus/installer/templates/application_web_worker.js.erb +0 -6
  53. data/lib/isomorfeus/installer/templates/arango_config.rb.erb +0 -20
  54. data/lib/isomorfeus/installer/templates/debug.js.erb +0 -131
  55. data/lib/isomorfeus/installer/templates/development.js.erb +0 -110
  56. data/lib/isomorfeus/installer/templates/development_ssr.js.erb +0 -115
  57. data/lib/isomorfeus/installer/templates/iodine_config.rb.erb +0 -14
  58. data/lib/isomorfeus/installer/templates/mail_components.js.erb +0 -23
  59. data/lib/isomorfeus/installer/templates/package.json.erb +0 -43
  60. data/lib/isomorfeus/installer/templates/production.js.erb +0 -100
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6207b3d86a4615a850ef236a5e8daf498d1cc914d6cbe3301137d896326b70dc
4
- data.tar.gz: 0d8759e282fba6e15feb909b8826a901fe8f6417eb19c3b28d83701ead609963
3
+ metadata.gz: 288a0c72ad3886bedb653c2e83fc017b3b1d37a1aa857e363910c5cf63f072b7
4
+ data.tar.gz: f04c3656fb19537853f975df2f8721ace76d768047622d35931eea30953d455f
5
5
  SHA512:
6
- metadata.gz: 350518b31f0dd858edc53123ff6553e6c0a4998c1275a132ed613272b9e55bea60b58da153eb301966b2dd748246f1bd2595b9428377fdc143294214a970d004
7
- data.tar.gz: e4f8d8343931aedf9b89a40b75c62172b2a3528a6f68a60d76a20974d50cb5a6115ec03b8c7e58bb546d9fc6580f86e31b74ba5cfd7a0ab2440217269c874989
6
+ metadata.gz: 196f99eb757cf450e4575ee49ef38cff20cf1cfbc06fb0473fcdb03768d0d0a7caa55b0998e8d24a5925781104e5723191857f86605cc04e17af0f538a4a29ce
7
+ data.tar.gz: 32972969e1062d2e4945482abb28d91f0d6ccd996e01e3e01955733f08397eb74541029fe86f4e1bd49d593d7a4806bf75c71ad995cec34ef650277ac0ebd227
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2018, 2019 Jan Biedermann
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2018, 2019 Jan Biedermann
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,31 +1,26 @@
1
- # Isomorfeus Framework Installer
2
-
3
- Create new isomorfeus applications with ease.
4
-
5
- ### Community and Support
6
- At the [Isomorfeus Framework Project](http://isomorfeus.com)
7
-
8
- ## Installation
9
- ```shell script
10
- gem install isomorfeus
11
- ```
12
-
13
- ## Creating new applications
14
- To create a new application execute:
15
- ```shell script
16
- isomorfeus new my_application
17
- ```
18
-
19
- ### Commands
20
- ```shell script
21
- $ isomorfeus help
22
- Commands:
23
- isomorfeus console # Open console for current project.
24
- isomorfeus help [COMMAND] # Describe available commands or one specific command
25
- isomorfeus new project_name # Create a new isomorfeus project with project_name.
26
- ```
27
-
28
- ### Yandle
29
- There is a convenience command to execute yarn and bundle: `yandle`:
30
- - `yandle` - will execute `yarn install` followed by `bundle install`
31
- - `yandle update` or `yandle upgrade` - will execute `yarn upgrade` followed by `bundle update`
1
+ # Isomorfeus Framework Installer
2
+
3
+ Create new isomorfeus applications with ease.
4
+
5
+ ### Community and Support
6
+ At the [Isomorfeus Framework Project](http://isomorfeus.com)
7
+
8
+ ## Installation
9
+ ```shell script
10
+ gem install isomorfeus
11
+ ```
12
+
13
+ ## Creating new applications
14
+ To create a new application execute:
15
+ ```shell script
16
+ isomorfeus new my_application
17
+ ```
18
+
19
+ ### Commands
20
+ ```shell script
21
+ $ isomorfeus help
22
+ Commands:
23
+ isomorfeus console # Open console for current project.
24
+ isomorfeus help [COMMAND] # Describe available commands or one specific command
25
+ isomorfeus new project_name # Create a new isomorfeus project with project_name.
26
+ ```
data/bin/ismos CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env ruby
2
- require_relative '../lib/isomorfeus/command'
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/isomorfeus/command'
data/bin/isomorfeus CHANGED
@@ -1,3 +1,2 @@
1
- #!/usr/bin/env ruby
2
- require_relative '../lib/isomorfeus/command'
3
-
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/isomorfeus/command'
@@ -1,31 +1,118 @@
1
- module Isomorfeus
2
- class CLI < Thor
3
-
4
- desc "new project_name", "Create a new isomorfeus project with project_name."
5
- option :rack_server, default: 'iodine', aliases: '-r',
6
- desc: "Select rack server, one of: #{Isomorfeus::Installer.sorted_rack_servers.join(', ')}. (optional)"
7
- option :yarn_and_bundle, default: true, required: false, type: :boolean, aliases: '-y', desc: "Execute yarn install and bundle install. (optional)"
8
- def new(project_name)
9
- Isomorfeus::Installer.set_project_names(project_name)
10
- Isomorfeus::Installer.options = options
11
- Isomorfeus::Installer::NewProject.execute(yarn_and_bundle: options[:yarn_and_bundle])
12
- end
13
-
14
- desc "console", "Open console for current project."
15
- def console
16
- Isomorfeus::Console.new.run
17
- end
18
-
19
- desc "test_app", "Create a test_app for internal framework tests."
20
- option :module, required: true, type: :string, aliases: '-m', desc: "Isomorfeus module name for which to generate the test app, eg: 'i18n'. (required)"
21
- option :source_dir, required: false, type: :string, aliases: '-s', desc: "Recursively copy files from source dir into app. (optional)"
22
- option :rack_server, default: 'iodine', aliases: '-r',
23
- desc: "Select rack server, one of: #{Isomorfeus::Installer.sorted_rack_servers.join(', ')}. (optional)"
24
- option :yarn_and_bundle, default: true, required: false, type: :boolean, aliases: '-y', desc: "Execute yarn install and bundle install. (optional)"
25
- def test_app
26
- Isomorfeus::Installer.set_project_names('test_app')
27
- Isomorfeus::Installer.options = options
28
- Isomorfeus::Installer::NewProject.execute(yarn_and_bundle: options[:yarn_and_bundle])
29
- end
30
- end
31
- end
1
+ module Isomorfeus
2
+ class CLI < Thor
3
+
4
+ desc "new project_name", "Create a new isomorfeus project with project_name."
5
+ option :rack_server, default: 'iodine', aliases: '-r',
6
+ desc: "Select rack server, one of: #{Isomorfeus::Installer.sorted_rack_servers.join(', ')}."
7
+ option :targets, default: 'web', required: false, type: :string, aliases: '-t', desc: <<~DESC
8
+ Select targets to install.
9
+ Available targets:
10
+ web: Create web applications
11
+ all: web
12
+ Example:
13
+ -t all - Setup project for all targets
14
+ -t web - Setup project for web applications only
15
+ DESC
16
+ option :bundle, default: 'yes', required: false, type: :string, aliases: '-y',
17
+ desc: "Execute bundle install: -y or -y yes, do not execute: -y no"
18
+ def new(project_name)
19
+ Isomorfeus::Installer.set_project_names(project_name)
20
+ Isomorfeus::Installer.options = options
21
+ begin
22
+ puts "Creating project directory #{Isomorfeus::Installer.project_dir}"
23
+ Dir.mkdir(Isomorfeus::Installer.project_dir)
24
+ rescue
25
+ if Dir.exist?(Isomorfeus::Installer.project_dir) && Gem.win_platform?
26
+ # this is a workaround for Windows being unable to delete existing app directories of test_apps
27
+ # because of some node_modules
28
+ puts "Using existing directory #{Isomorfeus::Installer.project_dir}!"
29
+ else
30
+ puts "Directory #{Isomorfeus::Installer.project_dir} could not be created!"
31
+ exit 1
32
+ end
33
+ end
34
+ Dir.chdir(Isomorfeus::Installer.project_dir)
35
+ puts "within the project directory:"
36
+ Isomorfeus::Installer::NewProject.execute
37
+ Isomorfeus::Installer::InstallTargets.execute
38
+ Isomorfeus::Installer::Gemfile.execute
39
+ Isomorfeus::Installer::Bundle.execute
40
+ Dir.chdir('..')
41
+ end
42
+
43
+ # desc "add_target target", "Add a target to a existing Isomorfeus Project."
44
+ # long_desc <<~DESC
45
+ # Add a target to a existing Isomorfeus Project.
46
+ # \x5
47
+ # \x5Available targets:
48
+ # \x5 native: Create mobile applications with Preact'
49
+ # \x5
50
+ # \x5 Example:
51
+ # \x5 isomorfeus add_target native - Add mobile as target to a existing project
52
+ # DESC
53
+ # option :yarn_and_bundle, default: 'yes', required: false, type: :string, aliases: '-y',
54
+ # desc: "Execute bundle install: -y or -y yes, do not execute: -y no"
55
+ # def add(project_name)
56
+ # Isomorfeus::Installer.set_project_names(project_name)
57
+ # Isomorfeus::Installer.options = options
58
+ # Isomorfeus::Installer::InstallTargets.execute
59
+ # Isomorfeus::Installer::Gemfile.execute
60
+ # Isomorfeus::Installer::Bundle.execute
61
+ # end
62
+
63
+ desc "console", "Open console for current project."
64
+ def console
65
+ Isomorfeus::Console.new.run
66
+ end
67
+
68
+ desc "upgrade", "Install updated config and provide hints for upgrading."
69
+ option :yarn_and_bundle, default: 'yes', required: false, type: :string, aliases: '-y',
70
+ desc: "Execute bundle install: -y or -y yes, do not execute: -y no"
71
+ def upgrade
72
+ Isomorfeus::Installer::Upgrade.execute
73
+ Isomorfeus::Installer::Bundle.execute
74
+ end
75
+
76
+ desc "versions", "Show versions of important Isomorfeus gems"
77
+ def versions
78
+ output = ''
79
+ %w[isomorfeus-asset-manager isomorfeus-redux isomorfeus-preact isomorfeus-data isomorfeus-i18n isomorfeus-mailer isomorfeus-operation
80
+ isomorfeus-policy isomorfeus-transport isomorfeus].each do |gem|
81
+ o = `bundle info #{gem} 2>&1`
82
+ o.each_line do |line|
83
+ output << line if line.include?('*') && line.include?(gem)
84
+ end
85
+ end
86
+ puts output
87
+ end
88
+
89
+ desc "test_app", "Create a test_app for internal framework tests."
90
+ option :module, required: true, type: :string, aliases: '-m',
91
+ desc: "Isomorfeus module name for which to generate the test app, eg: 'i18n'. (required)"
92
+ option :source_dir, required: true, type: :string, aliases: '-s',
93
+ desc: "Recursively copy files from source dir into app. (optional)"
94
+ option :targets, default: 'web', required: false, type: :string, aliases: '-t',
95
+ desc: 'Select targets to install.'
96
+ option :rack_server, default: 'iodine', aliases: '-r',
97
+ desc: "Select rack server, one of: #{Isomorfeus::Installer.sorted_rack_servers.join(', ')}. (optional, default: iodine)"
98
+ option :yarn_and_bundle, default: 'yes', required: false, type: :string, aliases: '-y',
99
+ desc: "Execute bundle install: -y or -y yes, do not execute: -y no"
100
+ def test_app
101
+ Isomorfeus::Installer.set_project_names('test_app')
102
+ Isomorfeus::Installer.options = options
103
+ begin
104
+ Dir.mkdir(Isomorfeus::Installer.project_dir)
105
+ Dir.chdir(Isomorfeus::Installer.project_dir)
106
+ rescue
107
+ puts "Directory #{installer.project_dir} could not be created!"
108
+ exit 1
109
+ end
110
+ Isomorfeus::Installer::NewProject.execute
111
+ Isomorfeus::Installer::InstallTargets.execute
112
+ Isomorfeus::Installer::Gemfile.execute
113
+ Isomorfeus::Installer::TestAppFiles.execute
114
+ Isomorfeus::Installer::Bundle.execute
115
+ Dir.chdir('..')
116
+ end
117
+ end
118
+ end
@@ -1,31 +1,29 @@
1
- if %w[c con console].include?(ARGV[0])
2
- require 'pry'
3
- require_relative '../isomorfeus/console'
4
-
5
- Isomorfeus::Console.new.run
6
- else
7
- require 'thor'
8
- require 'bundler'
9
- require 'fileutils'
10
- require 'erb'
11
- require 'active_support/core_ext/string'
12
- require 'opal-webpack-loader/installer_cli'
13
- require_relative '../isomorfeus/installer'
14
- require_relative '../isomorfeus/installer/rack_servers'
15
- require_relative '../isomorfeus/version'
16
- require_relative '../isomorfeus/installer/options_mangler'
17
- require_relative '../isomorfeus/installer/new_project'
18
- require_relative '../isomorfeus/cli'
19
-
20
- Isomorfeus::Installer.module_directories.each do |mod_dir|
21
- mod_path = File.realpath(File.join(Isomorfeus::Installer.base_path, mod_dir))
22
- modules = Dir.glob('*.rb', base: mod_path)
23
- modules.each do |mod|
24
- require_relative File.join(mod_path, mod)
25
- end
26
- end
27
-
28
- require_relative '../isomorfeus/cli'
29
-
30
- Isomorfeus::CLI.start(ARGV)
31
- end
1
+ if %w[c con console].include?(ARGV[0])
2
+ require 'pry'
3
+ require_relative '../isomorfeus/console'
4
+
5
+ Isomorfeus::Console.new.run
6
+ else
7
+ require 'thor'
8
+ require 'bundler'
9
+ require 'fileutils'
10
+ require 'erb'
11
+ require 'active_support/core_ext/string'
12
+ require 'oj'
13
+ require_relative '../isomorfeus/version'
14
+ require_relative '../isomorfeus/installer'
15
+ require_relative '../isomorfeus/installer/rack_servers'
16
+ require_relative '../isomorfeus/installer/options_mangler'
17
+ require_relative '../isomorfeus/installer/dsl'
18
+ require_relative '../isomorfeus/installer/gemfile'
19
+ require_relative '../isomorfeus/installer/install_targets'
20
+ require_relative '../isomorfeus/installer/new_project'
21
+ require_relative '../isomorfeus/installer/test_app_files'
22
+ require_relative '../isomorfeus/installer/upgrade'
23
+ require_relative '../isomorfeus/installer/target/web'
24
+ require_relative '../isomorfeus/installer/bundle'
25
+
26
+ require_relative '../isomorfeus/cli'
27
+
28
+ Isomorfeus::CLI.start(ARGV)
29
+ end
@@ -1,21 +1,21 @@
1
- module Isomorfeus
2
- class Console
3
- def initialize
4
- config_ru = File.read('config.ru')
5
- config_ru.each_line do |line|
6
- if line.start_with?('require_relative')
7
- file = line[17..-1].rstrip.tr('"','').tr("'",'')
8
- file = file + '.rb' unless file.end_with?('.rb')
9
- require File.join(Dir.pwd, file)
10
- end
11
- end
12
- Isomorfeus.zeitwerk.enable_reloading
13
- Isomorfeus.zeitwerk.setup
14
- Isomorfeus.zeitwerk.eager_load
15
- end
16
-
17
- def run
18
- Isomorfeus.pry
19
- end
20
- end
21
- end
1
+ module Isomorfeus
2
+ class Console
3
+ def initialize
4
+ config_ru = File.read('config.ru')
5
+ config_ru.each_line do |line|
6
+ if line.start_with?('require_relative')
7
+ file = line[17..-1].rstrip.tr('"','').tr("'",'')
8
+ file = file + '.rb' unless file.end_with?('.rb')
9
+ require File.join(Dir.pwd, file)
10
+ end
11
+ end
12
+ Isomorfeus.zeitwerk.enable_reloading
13
+ Isomorfeus.zeitwerk.setup
14
+ Isomorfeus.zeitwerk.eager_load
15
+ end
16
+
17
+ def run
18
+ Isomorfeus.pry
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ module Isomorfeus
2
+ module Installer
3
+ class Bundle
4
+ def self.execute
5
+ puts 'Executing bundle install:'
6
+ bundle_command = Gem.bin_path("bundler", "bundle")
7
+ Bundler.with_original_env do
8
+ system("#{Gem.ruby} #{bundle_command} install")
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,67 @@
1
+ module Isomorfeus
2
+ module Installer
3
+ module DSL
4
+ def copy_file(from, to)
5
+ puts "Copying #{from} to #{to}."
6
+ FileUtils.copy(from, to)
7
+ end
8
+
9
+ def create_directory(directory)
10
+ unless Dir.exist?(directory)
11
+ puts "Creating directory #{directory}."
12
+ FileUtils.mkdir_p(directory)
13
+ FileUtils.touch(File.join(directory, '.keep'))
14
+ end
15
+ end
16
+
17
+ def create_file_from_template(templates_path, template_file, target_file_path, data_hash)
18
+ template = ERB.new(File.read(File.join(templates_path, template_file), mode: 'r'))
19
+ result = template.result_with_hash(data_hash)
20
+ ext = File.exist?(target_file_path) ? '_new' : ''
21
+ puts "Generating #{target_file_path + ext}."
22
+ File.write(target_file_path + ext, result, mode: 'w')
23
+ end
24
+
25
+ def create_common_framework_directories
26
+ # no created: handlers
27
+ %w[channels components data layouts locales mail_components operations policies server].each do |isomorfeus_dir|
28
+ create_directory(File.join('app', isomorfeus_dir))
29
+ end
30
+ create_directory('data')
31
+ create_directory('public')
32
+ create_directory('spec')
33
+ create_directory('config')
34
+ end
35
+
36
+ def install_basic_components
37
+ data_hash = { app_class: Isomorfeus::Installer.app_class }
38
+ create_file_from_template(Isomorfeus::Installer.templates_path, 'my_app.rb.erb',
39
+ File.join('app', 'components', Isomorfeus::Installer.app_class.underscore + '.rb'), data_hash)
40
+ create_file_from_template(Isomorfeus::Installer.templates_path,'hello_component.rb.erb',
41
+ File.join('app', 'components', 'hello_component.rb'), {})
42
+ create_file_from_template(Isomorfeus::Installer.templates_path, 'navigation_links.rb.erb',
43
+ File.join('app', 'components', 'navigation_links.rb'), {})
44
+ create_file_from_template(Isomorfeus::Installer.templates_path, 'not_found_404_component.rb.erb',
45
+ File.join('app', 'components', 'not_found_404_component.rb'), {})
46
+ create_file_from_template(Isomorfeus::Installer.templates_path, 'welcome_component.rb.erb',
47
+ File.join('app', 'components', 'welcome_component.rb'), {})
48
+ end
49
+
50
+ def install_basic_policy
51
+ create_file_from_template(Isomorfeus::Installer.templates_path, 'anonymous_policy.rb.erb',
52
+ File.join('app', 'policies', 'anonymous_policy.rb'), {})
53
+ end
54
+
55
+ def install_spec_files
56
+ data_hash = { roda_app_class: Isomorfeus::Installer.roda_app_class, roda_app_path: Isomorfeus::Installer.roda_app_path,
57
+ rack_server: Isomorfeus::Installer.rack_server_name }
58
+ create_file_from_template(Isomorfeus::Installer.templates_path, 'spec_helper.rb.erb', File.join('spec', 'spec_helper.rb'), data_hash)
59
+ create_file_from_template(Isomorfeus::Installer.templates_path, 'web_spec.rb.erb', File.join('spec', 'web_spec.rb'), {})
60
+ end
61
+
62
+ def config_path(config_file)
63
+ File.join( 'config', config_file)
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,39 @@
1
+ module Isomorfeus
2
+ module Installer
3
+ class Gemfile
4
+ extend Isomorfeus::Installer::DSL
5
+
6
+ class << self
7
+ def execute
8
+ install_gemfile
9
+ end
10
+
11
+ def generate_gem_line(gem_hash)
12
+ line = "gem '#{gem_hash[:name]}', '#{gem_hash[:version]}'"
13
+ line << ", require: false" if gem_hash.key?(:require) && !gem_hash[:require]
14
+ line << "\n"
15
+ end
16
+
17
+ def install_gemfile
18
+ rack_server_gems = ''
19
+ Isomorfeus::Installer.rack_servers[Isomorfeus::Installer.options[:rack_server]]&.fetch(:gems)&.each do |gem|
20
+ rack_server_gems << generate_gem_line(gem)
21
+ end
22
+ data_hash = { rack_server_gems: rack_server_gems.chop }
23
+
24
+ if Isomorfeus::Installer.project_name == 'test_app'
25
+ gem_lines = ''
26
+ %i[isomorfeus isomorfeus-data isomorfeus-i18n isomorfeus-mailer isomorfeus-operation isomorfeus-policy isomorfeus-transport].each do |i_module|
27
+ gem_lines << "gem '#{i_module}', path: #{Isomorfeus::Installer.isomorfeus_module == i_module ? "'..'\n" : "'../../#{i_module}'"}\n"
28
+ end
29
+ data_hash[:isomorfeus_gems] = gem_lines.chop
30
+ else
31
+ data_hash[:isomorfeus_gems] = "gem 'isomorfeus', '~> #{Isomorfeus::VERSION}'"
32
+ end
33
+
34
+ create_file_from_template(Isomorfeus::Installer.templates_path, 'Gemfile.erb', 'Gemfile', data_hash)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,29 @@
1
+ module Isomorfeus
2
+ module Installer
3
+ class InstallTargets
4
+ class << self
5
+ def execute
6
+ targets_string = Isomorfeus::Installer.options[:targets]
7
+ targets_string = 'web' if targets_string == 'all'
8
+ targets = targets_string.split(' ')
9
+ targets = targets_string.split(',') if targets.empty?
10
+ targets = targets_string.split(', ') if targets.empty?
11
+
12
+ # install web first
13
+ targets.unshift(targets.delete('web')) if targets.include?('web')
14
+
15
+ targets.each do |target|
16
+ target = target.camelize
17
+ if Isomorfeus::Installer::Target.const_defined?(target, false)
18
+
19
+ target_class = Isomorfeus::Installer::Target.const_get(target)
20
+ target_class.execute
21
+ else
22
+ raise "No such target #{target} available."
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,56 +1,19 @@
1
- require 'opal-webpack-loader/installer_cli'
2
- require 'opal-webpack-loader/version'
3
-
4
- module Isomorfeus
5
- module Installer
6
- class NewProject
7
- def self.execute(yarn_and_bundle: true)
8
- begin
9
- Dir.mkdir(Isomorfeus::Installer.project_dir)
10
- Dir.chdir(Isomorfeus::Installer.project_dir)
11
- rescue
12
- puts "Directory #{installer.project_dir} could not be created!"
13
- exit 1
14
- end
15
-
16
- begin
17
- Isomorfeus::Installer.create_directories
18
- Isomorfeus::Installer.install_framework
19
-
20
- OpalWebpackLoader::Installer::CLI.start(['iso'])
21
- Isomorfeus::Installer.install_webpack_config
22
-
23
- Isomorfeus::Installer.install_styles
24
- Isomorfeus::Installer.install_js_entries
25
- Isomorfeus::Installer.install_isomorfeus_entries
26
-
27
- Isomorfeus::Installer.create_components
28
- Isomorfeus::Installer.create_policy
29
- Isomorfeus::Installer.create_spec
30
-
31
- Isomorfeus::Installer.create_package_json
32
- Isomorfeus::Installer.create_gemfile
33
- Isomorfeus::Installer.create_procfile
34
-
35
- Isomorfeus::Installer.copy_source_dir_files if Isomorfeus::Installer.source_dir
36
-
37
- if yarn_and_bundle
38
- puts 'Executing yarn install:'
39
- system('env -i PATH=$PATH yarn install')
40
- puts 'Executing bundle install:'
41
- bundle_command = Gem.bin_path("bundler", "bundle")
42
- Bundler.with_original_env do
43
- system("#{Gem.ruby} #{bundle_command} install")
44
- end
45
- end
46
-
47
- Dir.chdir('..')
48
- puts 'Project setup finished, make your dreams come true :)'
49
- rescue Exception => e
50
- puts e.backtrace.join("\n")
51
- puts "Installation failed: #{e.message}"
52
- end
53
- end
54
- end
55
- end
56
- end
1
+ module Isomorfeus
2
+ module Installer
3
+ class NewProject
4
+ extend Isomorfeus::Installer::DSL
5
+
6
+ def self.execute
7
+ begin
8
+ create_common_framework_directories
9
+ install_basic_components
10
+ install_basic_policy
11
+ install_spec_files
12
+ rescue Exception => e
13
+ puts e.backtrace.join("\n")
14
+ puts "Installation failed: #{e.message}"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,16 +1,16 @@
1
- module Isomorfeus
2
- module Installer
3
- module OptionsMangler
4
- def self.mangle_options(options)
5
- if options.key?(:rack_server) && Isomorfeus::Installer.sorted_rack_servers.include?(options[:rack_server])
6
- Isomorfeus::Installer.rack_server = Isomorfeus::Installer.rack_servers[options[:rack_server]]
7
- Isomorfeus::Installer.rack_server_name = options[:rack_server]
8
- else
9
- Isomorfeus::Installer.rack_server = Isomorfeus::Installer.rack_servers['iodine']
10
- end
11
- Isomorfeus::Installer.source_dir = File.expand_path(options[:source_dir]) if options.key?(:source_dir)
12
- Isomorfeus::Installer.isomorfeus_module = "isomorfeus-#{options[:module]}".to_sym if options.key?(:module)
13
- end
14
- end
15
- end
16
- end
1
+ module Isomorfeus
2
+ module Installer
3
+ module OptionsMangler
4
+ def self.mangle_options(options)
5
+ if options.key?(:rack_server) && Isomorfeus::Installer.sorted_rack_servers.include?(options[:rack_server])
6
+ Isomorfeus::Installer.rack_server = Isomorfeus::Installer.rack_servers[options[:rack_server]]
7
+ Isomorfeus::Installer.rack_server_name = options[:rack_server]
8
+ else
9
+ Isomorfeus::Installer.rack_server = Isomorfeus::Installer.rack_servers['iodine']
10
+ end
11
+ Isomorfeus::Installer.source_dir = File.expand_path(options[:source_dir]) if options.key?(:source_dir)
12
+ Isomorfeus::Installer.isomorfeus_module = "isomorfeus-#{options[:module]}".to_sym if options.key?(:module)
13
+ end
14
+ end
15
+ end
16
+ end