Skip to content

Commit

Permalink
Update dependency local-time to v3 (o19s#939)
Browse files Browse the repository at this point in the history
* Update dependency local-time to v3

* Now have importmaps!

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Eric Pugh <[email protected]>
  • Loading branch information
renovate[bot] and epugh committed Feb 1, 2024
1 parent 6b63449 commit 13dc501
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,5 @@ group :test do
gem 'capybara'
gem 'selenium-webdriver'
end

gem 'importmap-rails', '~> 2.0'
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ GEM
thor
i18n (1.14.1)
concurrent-ruby (~> 1.0)
importmap-rails (2.0.1)
actionpack (>= 6.0.0)
activesupport (>= 6.0.0)
railties (>= 6.0.0)
intercom-rails (0.4.2)
activesupport (> 3.0)
io-console (0.7.2)
Expand Down Expand Up @@ -505,6 +509,7 @@ DEPENDENCIES
devise_invitable (~> 2.0)
font-awesome-sass
gabba
importmap-rails (~> 2.0)
intercom-rails
jbuilder (~> 2.7)
jquery-rails
Expand Down
4 changes: 4 additions & 0 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//= link_tree ../images
//= link application.js
//= link 'application.css'
//= link_tree ../../javascript .js
//= link_tree ../../../vendor/javascript .js

//= link local-time/app/assets/javascripts/local-time.es2017-umd.js
5 changes: 3 additions & 2 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
// about supported directives.
//
// The long list of requires for the main Angular 1 application has been moved to core.js.
//
// We have introduced importmaps, which live in application2.js. This should probably be migrated
// over to that file assuming import maps works the way we are hoping!

//= require bootstrap/dist/js/bootstrap.bundle
//= require jquery
Expand All @@ -23,5 +26,3 @@

//= require codemirror/lib/codemirror
//= require codemirror/mode/javascript/javascript

//= require local-time/app/assets/javascripts/local-time
10 changes: 10 additions & 0 deletions app/javascript/application2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
// This is a importmap version of the classic application.js so that we can have
// both sprockets and importmaps at the same time.


// Note: the file in vendor/javascript/vendored-local-time.js is the one that was downloaded via
// importmap pin. See https://github.com/basecamp/local_time/issues/113 for others who suggested
// remaining it
import LocalTime from "local-time"
LocalTime.start()
2 changes: 1 addition & 1 deletion app/views/admin/announcements/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<div class="mb-3">
<%= form.label :text, class: 'form-label' %>
<%= form.text_field :text, required: true, class: 'form-control' %>
<%= form.text_area :text, required: true, rows: 5, class: 'form-control' %>
<div class="form-text">The announcement. You can use HTML and emojis.</div>
</div>

Expand Down
12 changes: 7 additions & 5 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta charset="utf-8"/>

<%= favicon_link_tag asset_path "favicon.ico" %>
<%= favicon_link_tag asset_path "favicon.ico" %>
<% if flash[:unfurl] %>
<!-- We have unfurl -->
Expand Down Expand Up @@ -54,9 +54,11 @@
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= csrf_meta_tags %>
<%= javascript_include_tag 'application' %>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= csrf_meta_tags %>
<%= javascript_importmap_tags 'application2' %>
<%= javascript_include_tag 'application' %>


</head>

Expand Down
4 changes: 4 additions & 0 deletions bin/importmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby

require_relative "../config/application"
require "importmap/commands"
6 changes: 6 additions & 0 deletions config/importmap.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

# Pin npm packages by running ./bin/importmap

pin 'application2', preload: true
pin "local-time", to: "vendored-local-time.js"# @3.0.2
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"d3-tip": "~0.9.1",
"file-saver": "^2.0.5",
"jquery": "~3.7.0",
"local-time": "^2.1.0",
"local-time": "^3.0.0",
"ng-json-explorer": "http://github.com/o19s/ng-json-explorer",
"ng-tags-input": "3.2.0",
"ngclipboard": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions spec/karma/config/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function(config) {
// to run a single one
files: [
'tmp/assets/core*.js',
'tmp/assets/application*.js',
'tmp/assets/application.js',
'tmp/assets/application_spec*.js',
'spec/javascripts/mock/*.js',
'spec/javascripts/**/*_spec.js',
Expand All @@ -28,7 +28,7 @@ module.exports = function(config) {

// list of files to exclude
exclude: [

'**/application2.js', // ignore this importmap related file when running core JS app tests
],


Expand Down
Empty file added vendor/javascript/.keep
Empty file.
2 changes: 2 additions & 0 deletions vendor/javascript/vendored-local-time.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 13dc501

Please sign in to comment.