Skip to content

Commit

Permalink
Merge pull request #399 from platanus/platanus-config
Browse files Browse the repository at this point in the history
feat(cli-create): include platanus options if `platanus-config` is in…
  • Loading branch information
GabrielLyonB authored Mar 29, 2022
2 parents 7917ee9 + b89a6f3 commit e2998b3
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Features
- Update power api gem to use v2.0.0. Install "internal" API mode [#394](https://github.com/platanus/potassium/pull/394)
- Updates Webpacker to Shakapacker, upgrading Vue and TailwindCSS to their latest versions [#395](https://github.com/platanus/potassium/pull/395)
- Add some image handling and processing in shrine file storage option [#398](https://github.com/platanus/potassium/pull/398)
- Include `--platanus-config` option to skip most of the instalation options [#399](https://github.com/platanus/potassium/pull/399).
## 6.5.0

Features
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,34 @@ Use the `potassium create` command to create a new project:
> 2. If you feel that it's too slow, you may need to update rubygems: `gem update --system`.
> 3. Potassium uses node under the hood, so a check will also be performed to ensure you are running the supported version.
#### Platanus Configutarion

In case you want to use the Platanus Configuration you should use the following command:

$ potassium create <project-name> --platanus-config

This will create a project with the following configuration:
1. `database`: `'postgresql'`
2. `local`: `'es-CL'`
3. `email_service`: `'sendgrid'`
4. `devise`: `true`
5. `devise-user-model`: `true`
6. `admin`: `true`
7. `vue_admin`: `true`
8. `pundit`: `true`
9. `api`: `'rest'`
10. `storage`: `'shrine'`
11. `heroku`: `true`
12. `background_processor`: `true`
13. `draper`: `true`
14. `schedule`: `true`
15. `sentry`: `true`
16. `front_end`: `'vue'`
17. `google_tag_manager`: `true`
18. `test`: `true`
19. `spring`: `true`

The remaining question will be asked as usual.
### Adding recipes to an existing project

Use the `potassium install` command to add a recipe to a project:
Expand Down
2 changes: 2 additions & 0 deletions lib/potassium/cli/commands/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ module Potassium::CLI
c.action do |_global_options, options, _args|
require 'potassium/newest_version_ensurer'
require 'potassium/node_version_ensurer'
require 'potassium/platanus_config'
require 'potassium/generators/application'
require 'potassium/template_finder'

begin
Potassium::NewestVersionEnsurer.new.ensure! if options['version-check']
Potassium::NodeVersionEnsurer.new.ensure! if options['node-version-check']
options = Potassium::PlatanusConfig.new(options).generate! if options['platanus-config']
template_finder = Potassium::TemplateFinder.new
template = template_finder.default_template
template.cli_options = options
Expand Down
12 changes: 12 additions & 0 deletions lib/potassium/cli_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ module Potassium::CliOptions # rubocop:disable Metrics/ModuleLength
negatable: true,
default_value: true,
default_test_value: false
},
{
type: :switch,
name: 'platanus-config',
desc: 'Wheter to use the Platanus configuration.',
negatable: true,
default_value: false,
default_test_value: false
}
]

Expand All @@ -219,4 +227,8 @@ def create_arguments(test_env = false)
memo
end
end

def self.option_names
CREATE_OPTIONS.map { |option| option[:name] }.flatten.map(&:to_sym)
end
end
20 changes: 20 additions & 0 deletions lib/potassium/platanus_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module Potassium
class PlatanusConfig
def initialize(options)
@options = options
@option_key_names = Potassium::CliOptions.option_names
end

def generate!
default_options = {
'db': 'postgresql', 'locale': 'es-CL', 'email_service': 'sendgrid', 'devise': true,
'devise-user-model': true, 'admin': true, 'vue_admin': true, 'pundit': true,
'api': 'rest', 'storage': 'shrine', 'heroku': true, 'background_processor': true,
'draper': true, 'schedule': true, 'sentry': true, 'front_end': 'vue',
'google_tag_manager': true, 'test': true, 'spring': true
}
default_options = default_options.filter { |key, _| @option_key_names.include?(key) }
@options.merge(default_options, default_options.stringify_keys)
end
end
end

0 comments on commit e2998b3

Please sign in to comment.