Skip to content

Commit

Permalink
GBL Admin: vite branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ewlarson committed Apr 18, 2024
1 parent e851a6e commit 8545c28
Show file tree
Hide file tree
Showing 10 changed files with 235 additions and 18 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,5 @@ end
gem 'net-ftp'
gem 'rexml'

gem "stimulus-rails"
gem "vite_rails", "~> 3.0"
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ GIT

GIT
remote: https://github.com/geobtaa/geoblacklight_admin.git
revision: 8e4b73e3a26758662dea2023943b77e3b7a42e4e
revision: 73b175f1f28d70ec3fe6c3ff6f04fe192e6baa91
branch: feature/vite
specs:
geoblacklight_admin (0.4.0)
Expand Down Expand Up @@ -713,6 +713,8 @@ GEM
mini_portile2 (~> 2.8.0)
stackprof (0.2.26)
statesman (10.0.0)
stimulus-rails (1.3.3)
railties (>= 6.0.0)
temple (0.10.3)
terser (1.2.2)
execjs (>= 0.3.0, < 3)
Expand Down Expand Up @@ -872,6 +874,7 @@ DEPENDENCIES
sqlite3 (~> 1.4)
stackprof (~> 0.2.12)
statesman (~> 10.0)
stimulus-rails
terser
turbolinks
twitter-typeahead-rails (= 0.11.1.pre.corejavascript)
Expand Down
9 changes: 9 additions & 0 deletions app/javascript/controllers/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Application } from "@hotwired/stimulus"

const application = Application.start()

// Configure Stimulus development experience
application.debug = false
window.Stimulus = application

export { application }
7 changes: 7 additions & 0 deletions app/javascript/controllers/hello_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
connect() {
this.element.textContent = "Hello World!"
}
}
14 changes: 6 additions & 8 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Load all the controllers within this directory and all subdirectories.
// Controller files must be named *_controller.js.
// This file is auto-generated by ./bin/rails stimulus:manifest:update
// Run that command whenever you add a new controller or create them with
// ./bin/rails generate stimulus controllerName

import { Application } from "stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"
import controller from './application_controller'
import { application } from "./application"

const application = Application.start()
const context = require.context("controllers", true, /_controller\.js$/)
application.load(definitionsFromContext(context))
import HelloController from "./hello_controller"
application.register("hello", HelloController)
4 changes: 3 additions & 1 deletion app/javascript/entrypoints/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ console.log('Vite ⚡️ Rails')
// If you want to use .jsx or .tsx, add the extension:
// <%= vite_javascript_tag 'application.jsx' %>

console.log('Visit the guide for more information: ', 'https://vite-ruby.netlify.app/guide/rails')
// console.log('Visit the guide for more information: ', 'https://vite-ruby.netlify.app/guide/rails')

// Example: Load Rails libraries in Vite.
//
Expand All @@ -26,3 +26,5 @@ console.log('Visit the guide for more information: ', 'https://vite-ruby.netlify

// Example: Import a stylesheet in app/frontend/index.css
// import '~/index.css'

import '@geoblacklight/admin'
115 changes: 113 additions & 2 deletions bin/bundle
Original file line number Diff line number Diff line change
@@ -1,3 +1,114 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
load Gem.bin_path('bundler', 'bundle')
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'bundle' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require "rubygems"

m = Module.new do
module_function

def invoked_as_script?
File.expand_path($0) == File.expand_path(__FILE__)
end

def env_var_version
ENV["BUNDLER_VERSION"]
end

def cli_arg_version
return unless invoked_as_script? # don't want to hijack other binstubs
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
bundler_version = nil
update_index = nil
ARGV.each_with_index do |a, i|
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
bundler_version = a
end
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
bundler_version = $1
update_index = i
end
bundler_version
end

def gemfile
gemfile = ENV["BUNDLE_GEMFILE"]
return gemfile if gemfile && !gemfile.empty?

File.expand_path("../../Gemfile", __FILE__)
end

def lockfile
lockfile =
case File.basename(gemfile)
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
else "#{gemfile}.lock"
end
File.expand_path(lockfile)
end

def lockfile_version
return unless File.file?(lockfile)
lockfile_contents = File.read(lockfile)
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
Regexp.last_match(1)
end

def bundler_requirement
@bundler_requirement ||=
env_var_version || cli_arg_version ||
bundler_requirement_for(lockfile_version)
end

def bundler_requirement_for(version)
return "#{Gem::Requirement.default}.a" unless version

bundler_gem_version = Gem::Version.new(version)

requirement = bundler_gem_version.approximate_recommendation

return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0")

requirement += ".a" if bundler_gem_version.prerelease?

requirement
end

def load_bundler!
ENV["BUNDLE_GEMFILE"] ||= gemfile

activate_bundler
end

def activate_bundler
gem_error = activation_error_handling do
gem "bundler", bundler_requirement
end
return if gem_error.nil?
require_error = activation_error_handling do
require "bundler/version"
end
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
exit 42
end

def activation_error_handling
yield
nil
rescue StandardError, LoadError => e
e
end
end

m.load_bundler!

if m.invoked_as_script?
load Gem.bin_path("bundler", "bundle")
end
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
"@babel/preset-env": "^7.7.1",
"@babel/preset-react": "^7.7.4",
"@blueprintjs/core": "^3.26.0",
"@geoblacklight/admin": "^0.4.0",
"@geoblacklight/frontend": "^4.4",
"@hotwired/stimulus": "^3.2.2",
"@kurkle/color": "^0.3.2",
"@material-ui/core": "4.11.3",
"@material-ui/icons": "^4.9.1",
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export default defineConfig({
plugins: [
rails(),
]
})
})
Loading

0 comments on commit 8545c28

Please sign in to comment.