plutonium 0.10.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/Rakefile +1 -2
- data/app/assets/application.js.bk +31419 -0
- data/app/assets/plutonium-logo-original.png +0 -0
- data/app/assets/plutonium-logo-white.png +0 -0
- data/app/assets/plutonium-logo.png +0 -0
- data/app/assets/plutonium.css +1 -0
- data/app/assets/plutonium.ico +0 -0
- data/app/assets/plutonium.js +12416 -0
- data/app/assets/plutonium.js.map +7 -0
- data/app/assets/plutonium.min.js +39 -0
- data/app/assets/plutonium.min.js.map +7 -0
- data/app/views/application/_flash_alerts.html.erb +5 -2
- data/app/views/application/_flash_toasts.html.erb +2 -0
- data/app/views/application/_resource_header.html.erb +263 -697
- data/app/views/application/_resource_sidebar.html.erb +14 -12
- data/app/views/components/action_button/action_button_component.rb +3 -3
- data/app/views/components/attributes.rb +184 -0
- data/app/views/components/base.rb +19 -40
- data/app/views/components/block/block_component.html.erb +1 -1
- data/app/views/components/block/block_component.rb +11 -7
- data/app/views/components/breadcrumbs/breadcrumbs_component.rb +3 -3
- data/app/views/components/button/button_component.html.erb +2 -2
- data/app/views/components/button/button_component.rb +10 -5
- data/app/views/components/dyna_frame_content/dyna_frame_content_component.html.erb +1 -0
- data/app/views/components/dyna_frame_content/dyna_frame_content_component.rb +3 -3
- data/app/views/components/dyna_frame_host/dyna_frame_host_component.html.erb +1 -2
- data/app/views/components/dyna_frame_host/dyna_frame_host_component.rb +12 -5
- data/app/views/components/empty_card/empty_card_component.rb +3 -3
- data/app/views/components/form/form_builder.rb +1 -1
- data/app/views/components/form/form_component.rb +3 -3
- data/app/views/components/has_many_panel/has_many_panel_component.html.erb +25 -0
- data/app/views/components/has_many_panel/has_many_panel_component.rb +16 -0
- data/app/views/components/header/header_component.rb +3 -3
- data/app/views/components/interactive_action_form/interactive_action_form_component.rb +3 -3
- data/app/views/components/nav_grid_menu/nav_grid_menu_component.html.erb +24 -0
- data/app/views/components/nav_grid_menu/nav_grid_menu_component.rb +23 -0
- data/app/views/components/nav_grid_menu_item/nav_grid_menu_item_component.html.erb +4 -0
- data/app/views/components/nav_grid_menu_item/nav_grid_menu_item_component.rb +20 -0
- data/app/views/components/nav_user/nav_user_component.html.erb +50 -0
- data/app/views/components/nav_user/nav_user_component.rb +32 -0
- data/app/views/components/nav_user_link/nav_user_link_component.html.erb +7 -0
- data/app/views/components/nav_user_link/nav_user_link_component.rb +23 -0
- data/app/views/components/nav_user_section/nav_user_section_component.html.erb +7 -0
- data/app/views/components/nav_user_section/nav_user_section_component.rb +18 -0
- data/app/views/components/nested_resource_form_fields/nested_resource_form_fields_component.html.erb +1 -3
- data/app/views/components/nested_resource_form_fields/nested_resource_form_fields_component.rb +11 -5
- data/app/views/components/pagination/pagination_component.html.erb +1 -1
- data/app/views/components/pagination/pagination_component.rb +10 -7
- data/app/views/components/panel/panel_component.html.erb +13 -6
- data/app/views/components/panel/panel_component.rb +11 -5
- data/app/views/components/resource_header/resource_header_component.html.erb +81 -0
- data/app/views/components/resource_header/resource_header_component.rb +20 -0
- data/app/views/components/resource_layout/resource_layout_component.html.erb +32 -0
- data/app/views/components/resource_layout/resource_layout_component.rb +39 -0
- data/app/views/components/sidebar/sidebar_component.html.erb +3 -33
- data/app/views/components/sidebar/sidebar_component.rb +3 -3
- data/app/views/components/sidebar_menu/sidebar_menu_component.html.erb +4 -2
- data/app/views/components/sidebar_menu/sidebar_menu_component.rb +10 -6
- data/app/views/components/sidebar_menu_item/sidebar_menu_item_component.html.erb +63 -71
- data/app/views/components/sidebar_menu_item/sidebar_menu_item_component.rb +27 -8
- data/app/views/components/skeleton/table/table_component.html.erb +1 -1
- data/app/views/components/skeleton/table/table_component.rb +3 -3
- data/app/views/components/table/table_component.html.erb +40 -89
- data/app/views/components/table/table_component.rb +124 -28
- data/app/views/components/table_search_input/table_search_input_component.html.erb +1 -1
- data/app/views/components/table_search_input/table_search_input_component.rb +11 -6
- data/app/views/components/table_toolbar/table_toolbar_component.html.erb +1 -1
- data/app/views/components/table_toolbar/table_toolbar_component.rb +11 -3
- data/app/views/components/toolbar/toolbar_component.html.erb +2 -2
- data/app/views/components/toolbar/toolbar_component.rb +16 -8
- data/app/views/layouts/resource.html copy.erb +2 -2
- data/app/views/layouts/resource.html.erb +21 -37
- data/app/views/layouts/rodauth.html.erb +32 -25
- data/app/views/resource/_interactive_resource_action_form.html.erb +1 -1
- data/app/views/resource/_resource_details.html.erb +8 -5
- data/app/views/resource/_resource_table.html.erb +70 -1
- data/app/views/resource/interactive_resource_collection_action.html.erb +1 -0
- data/app/views/resource/interactive_resource_record_action.html.erb +1 -0
- data/app/views/resource/interactive_resource_recordless_action.html.erb +1 -0
- data/app/views/resource/new.html.erb +1 -0
- data/app/views/rodauth/add_recovery_codes.html.erb +8 -7
- data/app/views/rodauth/otp_auth.html.erb +1 -1
- data/app/views/rodauth/otp_setup.html.erb +10 -8
- data/config/initializers/simple_form.rb +22 -2
- data/esbuild.config.js +35 -31
- data/lib/generators/pu/core/assets/assets_generator.rb +41 -0
- data/lib/generators/pu/core/assets/templates/tailwind.config.js +18 -0
- data/lib/generators/pu/core/install/templates/config/initializers/plutonium.rb +3 -0
- data/lib/generators/pu/core/ruby/ruby_generator.rb +30 -0
- data/lib/generators/pu/core/ruby/templates/.keep +0 -0
- data/lib/generators/pu/docker/install/install_generator.rb +35 -0
- data/lib/generators/pu/docker/install/templates/.keep +0 -0
- data/lib/generators/pu/docker/install/templates/Dockerfile.dev.tt +30 -0
- data/lib/generators/pu/docker/install/templates/Dockerfile.tt +75 -0
- data/lib/generators/pu/docker/install/templates/bin/console +3 -0
- data/lib/generators/pu/docker/install/templates/bin/restart +3 -0
- data/lib/generators/pu/docker/install/templates/bin/shell +3 -0
- data/lib/generators/pu/docker/install/templates/docker-compose.yml +29 -0
- data/lib/generators/pu/gem/dotenv/dotenv_generator.rb +32 -0
- data/lib/generators/pu/gem/dotenv/templates/.env +6 -0
- data/lib/generators/pu/gem/dotenv/templates/.env.local +5 -0
- data/lib/generators/pu/gem/dotenv/templates/.env.local.template +5 -0
- data/lib/generators/pu/gem/dotenv/templates/.env.template +6 -0
- data/lib/generators/pu/gem/dotenv/templates/.keep +0 -0
- data/lib/generators/pu/gem/dotenv/templates/config/initializers/001_ensure_required_env.rb +21 -0
- data/lib/generators/pu/gem/redis/redis_generator.rb +22 -0
- data/lib/generators/pu/gem/redis/templates/.keep +0 -0
- data/lib/generators/pu/gen/component/component_generator.rb +13 -10
- data/lib/generators/pu/gen/component/templates/component.html.erb.tt +1 -1
- data/lib/generators/pu/gen/component/templates/component.rb.tt +10 -4
- data/lib/generators/pu/lib/plutonium_generators/concerns/actions.rb +154 -32
- data/lib/generators/pu/lib/plutonium_generators/generator.rb +6 -6
- data/lib/generators/pu/lib/plutonium_generators/installer.rb +1 -1
- data/lib/generators/pu/pkg/app/app_generator.rb +4 -4
- data/lib/generators/pu/pkg/app/templates/app/controllers/concerns/controller.rb.tt +28 -0
- data/lib/generators/pu/pkg/app/templates/app/controllers/controller.rb.tt +5 -0
- data/lib/generators/pu/pkg/app/templates/app/controllers/dashboard_controller.rb.tt +1 -1
- data/lib/generators/pu/res/conn/conn_generator.rb +4 -4
- data/lib/generators/pu/res/conn/templates/app/controllers/resource_controller.rb.tt +1 -1
- data/lib/generators/pu/res/model/model_generator.rb +3 -3
- data/lib/generators/pu/res/scaffold/templates/policy.rb.tt +6 -0
- data/lib/generators/pu/rodauth/account_generator.rb +10 -10
- data/lib/generators/pu/rodauth/install_generator.rb +9 -2
- data/lib/generators/pu/rodauth/migration/sequel/audit_logging.erb +2 -2
- data/lib/generators/pu/rodauth/migration_generator.rb +1 -1
- data/lib/generators/pu/rodauth/templates/app/{misc → rodauth}/account_rodauth_plugin.rb.tt +2 -2
- data/lib/generators/pu/rodauth/templates/app/{misc → rodauth}/rodauth_plugin.rb.tt +0 -3
- data/lib/generators/pu/rodauth/templates/db/migrate/install_rodauth.rb.tt +5 -0
- data/lib/generators/pu/service/postgres/postgres_generator.rb +61 -0
- data/lib/generators/pu/service/postgres/templates/.keep +0 -0
- data/lib/generators/pu/service/postgres/templates/bin/initdb.d/create-multiple-postgresql-databases.sh +22 -0
- data/lib/generators/pu/service/postgres/templates/database.yml.tt +93 -0
- data/lib/generators/pu/service/sidekiq/sidekiq_generator.rb +57 -0
- data/lib/generators/pu/service/sidekiq/templates/.keep +0 -0
- data/lib/generators/pu/service/sidekiq/templates/app/sidekiq/sidekiq_job.rb +3 -0
- data/lib/generators/pu/service/sidekiq/templates/config/initializers/sidekiq.rb +53 -0
- data/lib/generators/pu/service/sidekiq/templates/config/sidekiq.yml +6 -0
- data/lib/plutonium/config.rb +2 -9
- data/lib/plutonium/core/associations/renderers/basic_renderer.rb +28 -0
- data/lib/plutonium/core/associations/renderers/factory.rb +36 -0
- data/lib/plutonium/core/associations/renderers/has_many_renderer.rb +16 -0
- data/lib/plutonium/core/autodiscovery/association_renderer_discoverer.rb +31 -0
- data/lib/plutonium/core/controllers/authorizable.rb +13 -17
- data/lib/plutonium/core/controllers/base.rb +3 -7
- data/lib/plutonium/core/controllers/entity_scoping.rb +3 -3
- data/lib/plutonium/core/controllers/presentable.rb +6 -1
- data/lib/plutonium/core/definers/association_renderer_definer.rb +33 -0
- data/lib/plutonium/core/fields/inputs/checkbox_input.rb +13 -0
- data/lib/plutonium/core/fields/inputs/factory.rb +1 -0
- data/lib/plutonium/core/fields/inputs/polymorphic_belongs_to_association_input.rb +1 -1
- data/lib/plutonium/core/ui/detail.rb +1 -0
- data/lib/plutonium/helpers/application_helper.rb +8 -9
- data/lib/plutonium/helpers/assets_helper.rb +33 -0
- data/lib/plutonium/helpers/display_helper.rb +13 -0
- data/lib/plutonium/helpers/form_helper.rb +1 -1
- data/lib/plutonium/helpers.rb +1 -0
- data/lib/plutonium/icons.rb +12 -5
- data/lib/plutonium/pkg/app.rb +10 -0
- data/lib/plutonium/pundit/context.rb +18 -0
- data/lib/plutonium/pundit/policy_finder.rb +25 -0
- data/lib/plutonium/railtie.rb +24 -8
- data/lib/plutonium/reloader.rb +18 -7
- data/lib/plutonium/resource/controller.rb +5 -0
- data/lib/plutonium/resource/policy.rb +69 -47
- data/lib/plutonium/resource/presenter.rb +1 -0
- data/lib/plutonium/resource/query_object.rb +139 -130
- data/lib/plutonium/rodauth/controller_methods.rb +7 -3
- data/lib/plutonium/version.rb +1 -1
- data/lib/plutonium.rb +10 -54
- data/lib/tasks/create_rodauth_admin.rake +16 -0
- data/package-lock.json +782 -17
- data/package.json +31 -8
- data/postcss.config.js +17 -7
- data/src/.npmignore +2 -0
- data/src/js/controllers/color_mode_controller.js +41 -0
- data/src/js/controllers/frame_navigator_controller.js +99 -0
- data/src/js/controllers/has_many_panel_controller.js +8 -0
- data/src/js/controllers/nav_grid_menu_controller.js +8 -0
- data/src/js/controllers/nav_grid_menu_item_controller.js +8 -0
- data/{app/views/components/tab_bar/tab_bar_controller.js → src/js/controllers/nav_user_controller.js} +2 -2
- data/src/js/controllers/nav_user_link_controller.js +8 -0
- data/src/js/controllers/nav_user_section_controller.js +8 -0
- data/src/js/controllers/register_controllers.js +45 -0
- data/{app/assets/javascripts → src/js}/controllers/resource_dismiss_controller.js +2 -0
- data/{app/assets/javascripts → src/js}/controllers/resource_drop_down_controller.js +2 -0
- data/src/js/controllers/resource_header_controller.js +8 -0
- data/src/js/controllers/resource_layout_controller.js +8 -0
- data/src/js/controllers/sidebar_menu_controller.js +8 -0
- data/src/js/controllers/sidebar_menu_item_controller.js +8 -0
- data/src/js/core.js +4 -0
- data/{app/assets/javascripts/plutonium-app.js → src/js/plutonium.js} +1 -1
- data/{app/assets/javascripts → src/js}/turbo/turbo_debug.js +2 -4
- data/tailwind.config.js +85 -84
- metadata +106 -41
- data/app/assets/build/plutonium.js +0 -5122
- data/app/assets/javascripts/controllers/index.js +0 -34
- data/app/assets/javascripts/plutonium.js +0 -1
- data/app/views/application/_color_modes.html.erb +0 -57
- data/app/views/components/tab_bar/tab_bar_component.html.erb +0 -11
- data/app/views/components/tab_bar/tab_bar_component.rb +0 -9
- data/app/views/resource/_nav_user.html.erb +0 -4
- data/app/views/resource/_tab_menu.html.erb +0 -13
- data/css.manifest +0 -3
- data/js.manifest +0 -4
- data/lib/generators/pu/pkg/app/templates/app/controllers/app_controller.rb.tt +0 -5
- data/lib/generators/pu/pkg/app/templates/app/controllers/package_controller.rb.tt +0 -26
- data/public/plutonium-assets/application.css +0 -25086
- data/public/plutonium-assets/plutonium-app-36KN5FVJ.js +0 -6
- data/public/plutonium-assets/plutonium-app-36KN5FVJ.js.map +0 -7
- data/public/plutonium-assets/plutonium-app-6WILQCTT.js +0 -39
- data/public/plutonium-assets/plutonium-app-6WILQCTT.js.map +0 -7
- data/public/plutonium-assets/plutonium.2d4f0c333cd000051d3b.css +0 -3424
- data/public/plutonium-assets/plutonium.50232e35b5495f5ad90d.css +0 -3415
- /data/{app/assets/build → lib/generators/pu/core/assets/templates}/.keep +0 -0
- /data/lib/generators/pu/rodauth/templates/app/{misc → rodauth}/rodauth_app.rb.tt +0 -0
- /data/{app/assets/stylesheets → src/css}/plutonium.css +0 -0
- /data/{app/views/components/form → src/js/controllers}/form_controller.js +0 -0
- /data/{app/views/components/interactive_action_form → src/js/controllers}/interactive_action_form_controller.js +0 -0
- /data/{app/views/components/nested_resource_form_fields → src/js/controllers}/nested_resource_form_fields_controller.js +0 -0
- /data/{app/views/components/table → src/js/controllers}/table_controller.js +0 -0
- /data/{app/views/components/table_search_input → src/js/controllers}/table_search_input_controller.js +0 -0
- /data/{app/views/components/table_toolbar → src/js/controllers}/table_toolbar_controller.js +0 -0
- /data/{app/views/components/toolbar → src/js/controllers}/toolbar_controller.js +0 -0
- /data/{app/assets/javascripts → src/js}/turbo/index.js +0 -0
- /data/{app/assets/javascripts → src/js}/turbo/turbo_actions.js +0 -0
- /data/{app/assets/javascripts → src/js}/turbo/turbo_frame_monkey_patch.js +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# syntax = docker/dockerfile:1
|
|
2
|
+
|
|
3
|
+
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
|
|
4
|
+
ARG RUBY_VERSION=<%= ruby_version %>
|
|
5
|
+
FROM registry.docker.com/library/ruby:$RUBY_VERSION
|
|
6
|
+
|
|
7
|
+
WORKDIR /rails
|
|
8
|
+
|
|
9
|
+
# Install packages needed to build gems and node modules
|
|
10
|
+
RUN apt-get update -qq && \
|
|
11
|
+
apt-get install --no-install-recommends -y build-essential curl git libpq-dev node-gyp pkg-config python-is-python3
|
|
12
|
+
|
|
13
|
+
# Install JavaScript dependencies
|
|
14
|
+
ARG NODE_VERSION=22.2.0
|
|
15
|
+
ARG YARN_VERSION=1.22.22
|
|
16
|
+
ENV PATH=/usr/local/node/bin:$PATH
|
|
17
|
+
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
|
|
18
|
+
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
|
|
19
|
+
npm install -g yarn@$YARN_VERSION && \
|
|
20
|
+
rm -rf /tmp/node-build-master
|
|
21
|
+
|
|
22
|
+
# Additional dependencies go here
|
|
23
|
+
|
|
24
|
+
# Upgrade RubyGems and install the latest Bundler version
|
|
25
|
+
RUN gem update --system && gem install bundler
|
|
26
|
+
|
|
27
|
+
# Document that we're going to expose port 3000
|
|
28
|
+
EXPOSE 3000
|
|
29
|
+
# Use Bash as the default command
|
|
30
|
+
CMD ["/bin/bash"]
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# syntax = docker/dockerfile:1
|
|
2
|
+
|
|
3
|
+
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
|
|
4
|
+
ARG RUBY_VERSION=<%= ruby_version %>
|
|
5
|
+
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
|
|
6
|
+
|
|
7
|
+
# Rails app lives here
|
|
8
|
+
WORKDIR /rails
|
|
9
|
+
|
|
10
|
+
# Set production environment
|
|
11
|
+
ENV RAILS_ENV="production" \
|
|
12
|
+
BUNDLE_DEPLOYMENT="1" \
|
|
13
|
+
BUNDLE_PATH="/usr/local/bundle" \
|
|
14
|
+
BUNDLE_WITHOUT="development"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# Throw-away build stage to reduce size of final image
|
|
18
|
+
FROM base as build
|
|
19
|
+
|
|
20
|
+
# Install packages needed to build gems and node modules
|
|
21
|
+
RUN apt-get update -qq && \
|
|
22
|
+
apt-get install --no-install-recommends -y build-essential curl git libpq-dev node-gyp pkg-config python-is-python3
|
|
23
|
+
|
|
24
|
+
# Install JavaScript dependencies
|
|
25
|
+
ARG NODE_VERSION=22.2.0
|
|
26
|
+
ARG YARN_VERSION=1.22.22
|
|
27
|
+
ENV PATH=/usr/local/node/bin:$PATH
|
|
28
|
+
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
|
|
29
|
+
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
|
|
30
|
+
npm install -g yarn@$YARN_VERSION && \
|
|
31
|
+
rm -rf /tmp/node-build-master
|
|
32
|
+
|
|
33
|
+
# Install application gems
|
|
34
|
+
COPY .ruby-version Gemfile Gemfile.lock ./
|
|
35
|
+
RUN bundle install && \
|
|
36
|
+
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
|
|
37
|
+
bundle exec bootsnap precompile --gemfile
|
|
38
|
+
|
|
39
|
+
# Install node modules
|
|
40
|
+
COPY package.json yarn.lock ./
|
|
41
|
+
RUN yarn install --frozen-lockfile
|
|
42
|
+
|
|
43
|
+
# Copy application code
|
|
44
|
+
COPY . .
|
|
45
|
+
|
|
46
|
+
# Precompile bootsnap code for faster boot times
|
|
47
|
+
RUN bundle exec bootsnap precompile app/ lib/
|
|
48
|
+
|
|
49
|
+
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
|
|
50
|
+
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# Final stage for app image
|
|
54
|
+
FROM base
|
|
55
|
+
|
|
56
|
+
# Install packages needed for deployment
|
|
57
|
+
RUN apt-get update -qq && \
|
|
58
|
+
apt-get install --no-install-recommends -y curl postgresql-client && \
|
|
59
|
+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
|
60
|
+
|
|
61
|
+
# Copy built artifacts: gems, application
|
|
62
|
+
COPY --from=build /usr/local/bundle /usr/local/bundle
|
|
63
|
+
COPY --from=build /rails /rails
|
|
64
|
+
|
|
65
|
+
# Run and own only the runtime files as a non-root user for security
|
|
66
|
+
RUN useradd rails --create-home --shell /bin/bash && \
|
|
67
|
+
chown -R rails:rails db log tmp
|
|
68
|
+
USER rails:rails
|
|
69
|
+
|
|
70
|
+
# Entrypoint prepares the database.
|
|
71
|
+
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
|
|
72
|
+
|
|
73
|
+
# Start the server by default, this can be overwritten at runtime
|
|
74
|
+
EXPOSE 3000
|
|
75
|
+
CMD ["./bin/rails", "server"]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
x-managed-by: plutonium
|
|
3
|
+
|
|
4
|
+
x-app: &app
|
|
5
|
+
build: # x-app
|
|
6
|
+
context: . # x-app
|
|
7
|
+
dockerfile: Dockerfile.dev # x-app
|
|
8
|
+
# x-app properties
|
|
9
|
+
volumes: # x-app
|
|
10
|
+
- ".:/rails" # x-app
|
|
11
|
+
- "./.volumes/bundle:/usr/local/bundle" # x-app
|
|
12
|
+
- "./.volumes/node_modules:/rails/node_modules" # x-app
|
|
13
|
+
- "./.volumes/shell_history:/root/shell_history" # x-app
|
|
14
|
+
depends_on: [] # x-app
|
|
15
|
+
environment: # x-app
|
|
16
|
+
RUBY_DEBUG_OPEN: true # x-app
|
|
17
|
+
PORT: 3000 # x-app
|
|
18
|
+
HISTFILE: /root/shell_history/.bash_history # x-app
|
|
19
|
+
tty: true # for binding.pry # x-app
|
|
20
|
+
stdin_open: true # for binding.pry # x-app
|
|
21
|
+
|
|
22
|
+
services:
|
|
23
|
+
web:
|
|
24
|
+
<<: *app
|
|
25
|
+
command: /bin/sh -c "rm -f tmp/pids/server.pid && bundle && yarn && bin/dev" # web
|
|
26
|
+
# web properties
|
|
27
|
+
ports: # web
|
|
28
|
+
- "3000:3000" # app
|
|
29
|
+
# additional services go here
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../../lib/plutonium_generators"
|
|
4
|
+
|
|
5
|
+
module Pu
|
|
6
|
+
module Gem
|
|
7
|
+
class DotenvGenerator < Rails::Generators::Base
|
|
8
|
+
include PlutoniumGenerators::Generator
|
|
9
|
+
|
|
10
|
+
source_root File.expand_path("templates", __dir__)
|
|
11
|
+
|
|
12
|
+
desc "Set up dotenv"
|
|
13
|
+
|
|
14
|
+
def start
|
|
15
|
+
in_root do
|
|
16
|
+
[".env", ".env.local", ".env.template", ".env.local.template"].each do |file|
|
|
17
|
+
copy_file file
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
copy_file "config/initializers/001_ensure_required_env.rb"
|
|
21
|
+
|
|
22
|
+
gitignore "!/.env.template", "!/.env.local.template", "!/.env"
|
|
23
|
+
|
|
24
|
+
insert_into_file "Gemfile", "\ngem \"dotenv\", :groups => [:development, :test]\n", after: /^gem ["']rails["'].*\n/
|
|
25
|
+
bundle!
|
|
26
|
+
end
|
|
27
|
+
rescue => e
|
|
28
|
+
exception "#{self.class} failed:", e
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
return if ENV["SECRET_KEY_BASE_DUMMY"].present?
|
|
2
|
+
|
|
3
|
+
# Add required env vars to this list
|
|
4
|
+
required_env_vars = %w[]
|
|
5
|
+
|
|
6
|
+
if Rails.env.production?
|
|
7
|
+
required_env_vars += %w[RAILS_MASTER_KEY DATABASE_URL]
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Add additional env vars here
|
|
11
|
+
|
|
12
|
+
# Check required env vars
|
|
13
|
+
required_env_vars.each do |env_var|
|
|
14
|
+
if !ENV.has_key?(env_var) || ENV[env_var].blank?
|
|
15
|
+
raise <<~EOL
|
|
16
|
+
Missing required environment variable: #{env_var}
|
|
17
|
+
|
|
18
|
+
Ask a teammate for the appropriate value.
|
|
19
|
+
EOL
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../../lib/plutonium_generators"
|
|
4
|
+
|
|
5
|
+
module Pu
|
|
6
|
+
module Gem
|
|
7
|
+
class RedisGenerator < Rails::Generators::Base
|
|
8
|
+
include PlutoniumGenerators::Generator
|
|
9
|
+
|
|
10
|
+
source_root File.expand_path("templates", __dir__)
|
|
11
|
+
|
|
12
|
+
desc "Set up redis"
|
|
13
|
+
|
|
14
|
+
def start
|
|
15
|
+
bundle "redis"
|
|
16
|
+
bundle "hiredis"
|
|
17
|
+
rescue => e
|
|
18
|
+
exception "#{self.class} failed:", e
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
File without changes
|
|
@@ -20,10 +20,9 @@ module Pu
|
|
|
20
20
|
template "component.html.erb", "#{component_path}.html.erb"
|
|
21
21
|
template "controller.js", controller_path
|
|
22
22
|
|
|
23
|
-
controllers_index_file = File.join __dir__, "../../../../../
|
|
23
|
+
controllers_index_file = File.join __dir__, "../../../../../src/js/controllers/register_controllers.js"
|
|
24
24
|
insert_into_file controllers_index_file, controller_import, after: /.*Import controllers here*\n/
|
|
25
25
|
insert_into_file controllers_index_file, controller_registration, after: /.*Register controllers here*\n/
|
|
26
|
-
insert_into_file controllers_index_file, controller_export, after: /.*Export controllers here*\n/
|
|
27
26
|
end
|
|
28
27
|
|
|
29
28
|
protected
|
|
@@ -45,7 +44,7 @@ module Pu
|
|
|
45
44
|
end
|
|
46
45
|
|
|
47
46
|
def component_namespace
|
|
48
|
-
["
|
|
47
|
+
["PlutoniumUi", component_module].compact.join "::"
|
|
49
48
|
end
|
|
50
49
|
|
|
51
50
|
def component_reference
|
|
@@ -68,8 +67,16 @@ module Pu
|
|
|
68
67
|
[component_module, component_name].compact.join("::").gsub("::", "__").underscore
|
|
69
68
|
end
|
|
70
69
|
|
|
70
|
+
def controller_filename
|
|
71
|
+
"#{[component_module, component_name].compact.join("::").underscore}_controller.js"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def controllers_dir
|
|
75
|
+
File.join "src", "js", "controllers"
|
|
76
|
+
end
|
|
77
|
+
|
|
71
78
|
def controller_path
|
|
72
|
-
|
|
79
|
+
File.join controllers_dir, controller_filename
|
|
73
80
|
end
|
|
74
81
|
|
|
75
82
|
def controller_identifier
|
|
@@ -77,20 +84,16 @@ module Pu
|
|
|
77
84
|
end
|
|
78
85
|
|
|
79
86
|
def controller_reference
|
|
80
|
-
[component_module, "#{component_name}Controller"].compact.join("
|
|
87
|
+
[component_module, "#{component_name}Controller"].compact.join("")
|
|
81
88
|
end
|
|
82
89
|
|
|
83
90
|
def controller_import
|
|
84
|
-
"import #{controller_reference} from \"
|
|
91
|
+
"import #{controller_reference} from \"./#{controller_filename}\"\n"
|
|
85
92
|
end
|
|
86
93
|
|
|
87
94
|
def controller_registration
|
|
88
95
|
" application.register(\"#{controller_identifier}\", #{controller_reference})\n"
|
|
89
96
|
end
|
|
90
|
-
|
|
91
|
-
def controller_export
|
|
92
|
-
"export { #{controller_reference} }\n"
|
|
93
|
-
end
|
|
94
97
|
end
|
|
95
98
|
end
|
|
96
99
|
end
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
module <%= component_namespace %>
|
|
2
|
-
class <%= component_classname %> <
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
class <%= component_classname %> < PlutoniumUi::Base
|
|
3
|
+
private
|
|
4
|
+
|
|
5
|
+
def base_attributes
|
|
6
|
+
# base attributes go here
|
|
7
|
+
{
|
|
8
|
+
classname: "<%= controller_identifier %>",
|
|
9
|
+
controller: "<%= controller_identifier %>"
|
|
10
|
+
}
|
|
11
|
+
end
|
|
6
12
|
end
|
|
7
13
|
end
|
|
8
14
|
|
|
@@ -22,7 +22,10 @@ module PlutoniumGenerators
|
|
|
22
22
|
|
|
23
23
|
in_root do
|
|
24
24
|
create_file ".ruby-version", version, force: true, verbose: false
|
|
25
|
-
gsub_file
|
|
25
|
+
gsub_file("Gemfile", /^ruby .*/, "ruby File.read(\".ruby-version\").strip", verbose: false)
|
|
26
|
+
%w[Dockerfile Dockerfile.prod Dockerfile.dev].each do |file|
|
|
27
|
+
gsub_file(file, /^ARG RUBY_VERSION=.*/, "ARG RUBY_VERSION=#{version}", verbose: false) if File.exist?(file)
|
|
28
|
+
end
|
|
26
29
|
end
|
|
27
30
|
end
|
|
28
31
|
|
|
@@ -95,29 +98,84 @@ module PlutoniumGenerators
|
|
|
95
98
|
# gsub_file "Gemfile", /(:?^.*#.*\n)*.*gem ['"]#{gem}['"].*\n/, "", verbose: false
|
|
96
99
|
# end
|
|
97
100
|
|
|
98
|
-
#
|
|
99
|
-
# Evaluates the given template and merges it with the project's docker-compose.yml
|
|
100
|
-
#
|
|
101
|
-
# @param [String] source the template filename
|
|
102
|
-
#
|
|
103
|
-
# @return [void]
|
|
104
|
-
#
|
|
105
|
-
def docker_compose(source)
|
|
106
|
-
|
|
101
|
+
# #
|
|
102
|
+
# # Evaluates the given template and merges it with the project's docker-compose.yml
|
|
103
|
+
# #
|
|
104
|
+
# # @param [String] source the template filename
|
|
105
|
+
# #
|
|
106
|
+
# # @return [void]
|
|
107
|
+
# #
|
|
108
|
+
# def docker_compose(source)
|
|
109
|
+
# log :docker_compose, source
|
|
110
|
+
|
|
111
|
+
# in_root do
|
|
112
|
+
# compose_file = "docker-compose.yml"
|
|
113
|
+
# compose_definition = YAML.load_file(compose_file) if File.exist?(compose_file)
|
|
114
|
+
# compose_definition ||= {
|
|
115
|
+
# version: "3.7",
|
|
116
|
+
# services: {}
|
|
117
|
+
# }
|
|
118
|
+
# compose_definition.deep_stringify_keys!
|
|
119
|
+
|
|
120
|
+
# new_definition = YAML.load template_eval("docker-compose/#{source}.yml.tt")
|
|
121
|
+
# compose_definition.deep_merge! new_definition.deep_stringify_keys
|
|
122
|
+
|
|
123
|
+
# create_file compose_file, YAML.dump(compose_definition), force: true
|
|
124
|
+
# end
|
|
125
|
+
# end
|
|
126
|
+
|
|
127
|
+
def managed_compose(file = "docker-compose.yml")
|
|
128
|
+
@managed_compose ||= {}
|
|
129
|
+
|
|
130
|
+
@managed_compose[file] ||= in_root do
|
|
131
|
+
next unless File.exist?(file)
|
|
132
|
+
|
|
133
|
+
parsed_yaml = YAML.load_file(file, aliases: true)
|
|
134
|
+
parsed_yaml if parsed_yaml["x-managed-by"] == "plutonium"
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def add_compose_service(service, config, file = "docker-compose.yml")
|
|
139
|
+
docker_compose = managed_compose(file)
|
|
140
|
+
error "Docker compose is not managed by plutonium" unless docker_compose
|
|
141
|
+
error "#{service} is already added to compose" if docker_compose["services"].key?(service.to_s)
|
|
107
142
|
|
|
108
143
|
in_root do
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
144
|
+
insert_into_file file, indent(config, 2), after: /.*# additional services go here.*\n/
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def add_compose_env(key, value, service = "x-app", file = "docker-compose.yml")
|
|
149
|
+
raise NotImplementedError, "only service: x-app is currently supported" unless service == "x-app"
|
|
150
|
+
|
|
151
|
+
docker_compose = managed_compose(file)
|
|
152
|
+
error "Docker compose is not managed by plutonium" unless docker_compose
|
|
153
|
+
|
|
154
|
+
in_root do
|
|
155
|
+
gsub_file file, "environment: {} # x-app", "environment: # #{service}"
|
|
156
|
+
gsub_file file, /.*#{key}:.*# #{service}.*\n/, ""
|
|
157
|
+
config = "#{key}: #{value} # #{service}\n"
|
|
158
|
+
insert_into_file file, indent(config, 4), after: /.*environment: # #{service}.*\n/
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def add_compose_dependency(value, service = "x-app", file = "docker-compose.yml")
|
|
163
|
+
raise NotImplementedError, "only service: x-app is currently supported" unless service == "x-app"
|
|
164
|
+
|
|
165
|
+
docker_compose = managed_compose(file)
|
|
166
|
+
error "Docker compose is not managed by plutonium" unless docker_compose
|
|
167
|
+
|
|
168
|
+
in_root do
|
|
169
|
+
gsub_file file, "depends_on: [] # x-app", "depends_on: # #{service}"
|
|
170
|
+
gsub_file file, /.*- #{value}.*# #{service}.*\n/, ""
|
|
171
|
+
config = "- #{value} # #{service}\n"
|
|
172
|
+
insert_into_file file, indent(config, 4), after: /.*depends_on: # #{service}.*\n/
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def add_docker_dependency(config, file = "Dockerfile.dev")
|
|
177
|
+
in_root do
|
|
178
|
+
insert_into_file file, "#{config}\n", after: /.*# Additional dependencies go here*\n\n/
|
|
121
179
|
end
|
|
122
180
|
end
|
|
123
181
|
|
|
@@ -283,6 +341,23 @@ module PlutoniumGenerators
|
|
|
283
341
|
end
|
|
284
342
|
end
|
|
285
343
|
|
|
344
|
+
#
|
|
345
|
+
# Insert the given directives into .dockerignore
|
|
346
|
+
#
|
|
347
|
+
# @param [String] *directives directives to ignore
|
|
348
|
+
#
|
|
349
|
+
# @return [void]
|
|
350
|
+
#
|
|
351
|
+
def dockerignore(*directives)
|
|
352
|
+
in_root do
|
|
353
|
+
# Doing this one by one so that duplication detection during insertion will work
|
|
354
|
+
directives.each do |directive|
|
|
355
|
+
log :dockerignore, directive
|
|
356
|
+
insert_into_file ".dockerignore", "#{directive}\n", verbose: false
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
end
|
|
360
|
+
|
|
286
361
|
#
|
|
287
362
|
# Similar to #run, this executes a command but returns both success and output
|
|
288
363
|
#
|
|
@@ -313,6 +388,58 @@ module PlutoniumGenerators
|
|
|
313
388
|
[success, output]
|
|
314
389
|
end
|
|
315
390
|
|
|
391
|
+
def bin_directory
|
|
392
|
+
# Copy the directory and store the list of copied files
|
|
393
|
+
@copied_files = directory "bin"
|
|
394
|
+
# Change permissions of the copied files to make them executable
|
|
395
|
+
in_root do
|
|
396
|
+
@copied_files.each do |file|
|
|
397
|
+
file = file.split("/bin/")[1]
|
|
398
|
+
file = "bin/#{file}"
|
|
399
|
+
puts file
|
|
400
|
+
chmod file, "+x" if File.file?(file)
|
|
401
|
+
end
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
def bundle!
|
|
406
|
+
log :bundle, "install"
|
|
407
|
+
|
|
408
|
+
Bundler.with_unbundled_env do
|
|
409
|
+
run "bundle install", verbose: false
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
def bundle(*gems, **options)
|
|
414
|
+
gems = Array(gems).join " "
|
|
415
|
+
options = hash_to_cli_options options
|
|
416
|
+
cmd_args = "add #{gems} #{options}"
|
|
417
|
+
|
|
418
|
+
log :bundle, cmd_args
|
|
419
|
+
Bundler.with_unbundled_env do
|
|
420
|
+
run "bundle #{cmd_args}", verbose: false
|
|
421
|
+
end
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
def unbundle(*gems)
|
|
425
|
+
gems = Array(gems).join " "
|
|
426
|
+
cmd_args = "remove #{gems}"
|
|
427
|
+
|
|
428
|
+
log :bundle, cmd_args
|
|
429
|
+
Bundler.with_unbundled_env do
|
|
430
|
+
run "bundle remove #{Array(gems).join " "}", verbose: false
|
|
431
|
+
end
|
|
432
|
+
end
|
|
433
|
+
|
|
434
|
+
def add_required_env_vars(*vars)
|
|
435
|
+
vars = Array(vars).join " "
|
|
436
|
+
log :equired_env_vars, vars
|
|
437
|
+
in_root do
|
|
438
|
+
cmd = "required_env_vars += %w[#{vars}]\n"
|
|
439
|
+
insert_into_file "config/initializers/001_ensure_required_env.rb", cmd, after: /# Add additional env vars here.*\n/
|
|
440
|
+
end
|
|
441
|
+
end
|
|
442
|
+
|
|
316
443
|
private
|
|
317
444
|
|
|
318
445
|
#
|
|
@@ -351,16 +478,11 @@ module PlutoniumGenerators
|
|
|
351
478
|
end
|
|
352
479
|
end
|
|
353
480
|
|
|
354
|
-
def
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
def unbundle(*gems)
|
|
361
|
-
Bundler.with_unbundled_env do
|
|
362
|
-
run "bundle remove #{Array(gems).join " "}"
|
|
363
|
-
end
|
|
481
|
+
def hash_to_cli_options(hash)
|
|
482
|
+
hash.map do |key, value|
|
|
483
|
+
formatted_value = value.is_a?(Array) ? value.join(",") : value
|
|
484
|
+
"--#{key.to_s.tr("_", "-")}=#{formatted_value}"
|
|
485
|
+
end.join(" ")
|
|
364
486
|
end
|
|
365
487
|
end
|
|
366
488
|
end
|
|
@@ -64,13 +64,13 @@ module PlutoniumGenerators
|
|
|
64
64
|
@prompt ||= TTY::Prompt.new
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
def appname
|
|
68
|
-
|
|
69
|
-
end
|
|
67
|
+
# def appname
|
|
68
|
+
# defined?(Rails.application) ? Rails.application.class.module_parent.name : "PlutoniumGenerators"
|
|
69
|
+
# end
|
|
70
70
|
|
|
71
|
-
def app_name
|
|
72
|
-
|
|
73
|
-
end
|
|
71
|
+
# def app_name
|
|
72
|
+
# appname.underscore
|
|
73
|
+
# end
|
|
74
74
|
|
|
75
75
|
def pug_installed?(feature, version: nil)
|
|
76
76
|
installed_version = read_config(:installed, feature)
|
|
@@ -28,10 +28,10 @@ module Pu
|
|
|
28
28
|
template "lib/engine.rb", "packages/#{package_namespace}/lib/engine.rb"
|
|
29
29
|
template "config/routes.rb", "packages/#{package_namespace}/config/routes.rb"
|
|
30
30
|
|
|
31
|
-
template "app/controllers/
|
|
32
|
-
"packages/#{package_namespace}/app/controllers/#{package_namespace}
|
|
33
|
-
template "app/controllers/
|
|
34
|
-
"packages/#{package_namespace}/app/controllers/#{package_namespace}/
|
|
31
|
+
template "app/controllers/concerns/controller.rb",
|
|
32
|
+
"packages/#{package_namespace}/app/controllers/#{package_namespace}/concerns/controller.rb"
|
|
33
|
+
template "app/controllers/controller.rb",
|
|
34
|
+
"packages/#{package_namespace}/app/controllers/#{package_namespace}/controller.rb"
|
|
35
35
|
|
|
36
36
|
template "app/controllers/dashboard_controller.rb",
|
|
37
37
|
"packages/#{package_namespace}/app/controllers/#{package_namespace}/dashboard_controller.rb"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module <%= package_name %>
|
|
2
|
+
module Concerns
|
|
3
|
+
module Controller
|
|
4
|
+
extend ActiveSupport::Concern
|
|
5
|
+
include Plutonium::Application::Controller
|
|
6
|
+
<%- if rodauth_account.present? -%>
|
|
7
|
+
include Plutonium::Auth.rodauth(:<%= rodauth_account %>)
|
|
8
|
+
<%- elsif public_access? -%>
|
|
9
|
+
include Plutonium::Auth::Public
|
|
10
|
+
<%- end -%>
|
|
11
|
+
# add concerns above.
|
|
12
|
+
|
|
13
|
+
included do
|
|
14
|
+
boot <%= package_name %>
|
|
15
|
+
<%- if bring_your_own_auth? -%>
|
|
16
|
+
|
|
17
|
+
helper_method :current_user
|
|
18
|
+
<%- end -%>
|
|
19
|
+
end
|
|
20
|
+
<%- if bring_your_own_auth? -%>
|
|
21
|
+
|
|
22
|
+
def current_user
|
|
23
|
+
raise NotImplementedError, "#{self.class}#current_user must return a non nil value"
|
|
24
|
+
end
|
|
25
|
+
<%- end -%>
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|