Class: Nor::FrontendGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Nor::FrontendGenerator
- Defined in:
- lib/generators/nor/frontend/frontend_generator.rb
Instance Attribute Summary collapse
-
#frontend_path ⇒ Object
readonly
Returns the value of attribute frontend_path.
Instance Method Summary collapse
- #create_next_app ⇒ Object
-
#initialize(args, *options) ⇒ FrontendGenerator
constructor
A new instance of FrontendGenerator.
- #install_dependencies ⇒ Object
- #install_templates ⇒ Object
Constructor Details
#initialize(args, *options) ⇒ FrontendGenerator
Returns a new instance of FrontendGenerator.
6 7 8 9 |
# File 'lib/generators/nor/frontend/frontend_generator.rb', line 6 def initialize(args, *) super @frontend_path = File.join(destination_root, 'frontend') end |
Instance Attribute Details
#frontend_path ⇒ Object (readonly)
Returns the value of attribute frontend_path.
3 4 5 |
# File 'lib/generators/nor/frontend/frontend_generator.rb', line 3 def frontend_path @frontend_path end |
Instance Method Details
#create_next_app ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/generators/nor/frontend/frontend_generator.rb', line 11 def create_next_app if revoke? && frontend_exist? say_status :remove, relative_to_original_destination_root(frontend_path) FileUtils.remove_dir(frontend_path, force: true) elsif frontend_exist? say_status('skipped', 'Create Next app: directory frontend already exist!') else run 'yarn create next-app frontend' inside frontend_path do gsub_file 'package.json', 'create-next-example-app', 'next-on-rails-frontend' gsub_file 'package.json', '"dev": "next dev"', '"dev": "node server.js"' if `which json`.present? run "json -I -f package.json -e 'this.license=\"MIT\"'" run "json -I -f package.json -e 'this.private=true'" run "json -I -f package.json -e 'this.version=\"0.1.0\"'" end remove_file 'components/head.js' remove_file 'components/nav.js' remove_file 'pages/index.js' remove_file 'next.config.js' end end end |
#install_dependencies ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/generators/nor/frontend/frontend_generator.rb', line 35 def install_dependencies return if revoke? inside frontend_path do run 'yarn add next-compose-plugins @zeit/next-sass node-sass bootstrap compression express inflection lodash nookies nprogress next-on-rails [email protected] [email protected] [email protected]' run 'yarn add --dev babel-eslint eslint eslint-config-standard eslint-plugin-import eslint-plugin-node eslint-plugin-promise eslint-plugin-react eslint-plugin-standard prettier sass-lint' end end |
#install_templates ⇒ Object
44 45 46 47 48 |
# File 'lib/generators/nor/frontend/frontend_generator.rb', line 44 def install_templates return if revoke? directory 'frontend' end |