importmap-jets 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0657363b6efabda2b1e1893b1ca66bbf6196f2910de3a49edc6fd976b99a3a78
4
- data.tar.gz: 6120ee57892eafadbefd0a8639afd09536ad8c588b8b50ee23917ac845f4afa1
3
+ metadata.gz: 96f67b3f25375fc7a5a4660f33acf20a2519aed51d0db84cd25e718c072d66de
4
+ data.tar.gz: cffdc835f426566fc2e43e055bb77acca54ffae3f78e8444cefd9fc50df2fc13
5
5
  SHA512:
6
- metadata.gz: 7fde4a90463af20b3e3287c6f174124e7b5e7056a184419e48dd4d80334c50d447443e0aa0668b6cad81ed5de3bb385800de84fd85a07b6c398a384cb082d590
7
- data.tar.gz: 61524fbf63a42add8ac011866cfcda640306866d92fbf781b014041efc44621a5d8a01b9976d352d1551eefb826cc4b29f9934907aac1b4825ff509ac8e8e2a9
6
+ metadata.gz: 6e08f9d8af599de5f2afa74ea73a5dd79b42854d8cc7be0572f67281daaa34be74236f61ef82911bab98fd3a0b8a51b20a55e0f539a3f7129586f552fd9f3b12
7
+ data.tar.gz: 74a28b78855ddbc5db11196887ed9694bceb6091c715ad329f2cc77b1e0efedf675f9cebd917ebe9d7285b58f16b271e0c2f3125fceae9af4e30720b01520d4c
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "importmap"
5
+ Importmap::CLI.start(ARGV)
@@ -0,0 +1,6 @@
1
+ # Pin npm packages by running bin/importmap
2
+
3
+ pin "application", preload: true
4
+ pin "jquery", to: "https://ga.jspm.io/npm:jquery@3.7.0/dist/jquery.js", preload: true
5
+ pin "@rubyonjets/ujs-compat", to: "https://ga.jspm.io/npm:@rubyonjets/ujs-compat@1.1.0/index.js", preload: true
6
+ pin_all_from "app/javascript/controllers", under: "controllers"
@@ -0,0 +1,36 @@
1
+ APPLICATION_LAYOUT_PATH = Jets.root.join("app/views/layouts/application.html.erb")
2
+
3
+ if APPLICATION_LAYOUT_PATH.exist?
4
+ say "Add Importmap include tags in application layout"
5
+ insert_into_file APPLICATION_LAYOUT_PATH.to_s, "\n <%= javascript_importmap_tags %>", before: /\s*<\/head>/
6
+ else
7
+ say "Default application.html.erb is missing!", :red
8
+ say " Add <%= javascript_importmap_tags %> within the <head> tag in your custom layout."
9
+ end
10
+
11
+ say "Create application.js module as entrypoint"
12
+ create_file Jets.root.join("app/javascript/application.js") do <<-JS
13
+ // Configure your import map in config/importmap.rb. Read more: https://github.com/boltops-tools/importmap-jets
14
+ import jquery from 'jquery'
15
+ window.$ = jquery
16
+ import Jets from "@rubyonjets/ujs-compat"
17
+ Jets.start()
18
+ JS
19
+ end
20
+
21
+ say "Use vendor/javascript for downloaded pins"
22
+ empty_directory "vendor/javascript"
23
+ keep_file "vendor/javascript"
24
+
25
+ if (sprockets_manifest_path = Jets.root.join("app/assets/config/manifest.js")).exist?
26
+ say "Ensure JavaScript files are in the Sprocket manifest"
27
+ append_to_file sprockets_manifest_path,
28
+ %(//= link_tree ../../javascript .js\n//= link_tree ../../../vendor/javascript .js\n)
29
+ end
30
+
31
+ say "Configure importmap paths in config/importmap.rb"
32
+ copy_file "#{__dir__}/config/importmap.rb", "config/importmap.rb"
33
+
34
+ say "Copying binstub"
35
+ copy_file "#{__dir__}/bin/importmap", "bin/importmap"
36
+ chmod "bin", 0755 & ~File.umask, verbose: false
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ImportmapJets
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: importmap-jets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-02 00:00:00.000000000 Z
11
+ date: 2023-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: importmap
@@ -38,6 +38,9 @@ files:
38
38
  - app/assets/javascripts/es-module-shims.js.map
39
39
  - app/assets/javascripts/es-module-shims.min.js
40
40
  - app/helpers/importmap/importmap_tags_helper.rb
41
+ - install/bin/importmap
42
+ - install/config/importmap.rb
43
+ - install/install.rb
41
44
  - lib/importmap-jets.rb
42
45
  - lib/importmap_jets.rb
43
46
  - lib/importmap_jets/autoloader.rb