lux_assets 0.2.15 → 0.2.19
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/.version +1 -1
- data/lib/lux_assets/asset.rb +1 -1
- data/lib/lux_assets/base.rb +3 -0
- data/lib/lux_assets/element.rb +1 -1
- data/lib/lux_assets/manifest.rb +21 -9
- data/lib/vendor/lux/assets_helper.rb +15 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26be1a6eda380c7ac142aa001e3075dd57379f1d63e2e121fdddc074e7669a6d
|
4
|
+
data.tar.gz: c45fb60c37bfc1495c346235f2ee04d3c0d32219ebd208708bc2b271fff32b3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb6c626705f2df785dc82f515eba8468dbf5f8fce1393079e7da2b070b643d6e4ae3dfe4910b2eaa43f6d952e67ed2fad9cd81dc1ad253ed9066157627b91724
|
7
|
+
data.tar.gz: 11eaa505bbcd8eece08353e8f0b7efbcc916dc8ef0eeeed7c0d62b6bb0462d03b8b1a571e520704ebeb324f64bd183df7864d761c87612d955cb933566cb256c
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.19
|
data/lib/lux_assets/asset.rb
CHANGED
@@ -81,7 +81,7 @@ class LuxAssets::Asset
|
|
81
81
|
def compile_js
|
82
82
|
save_data @data.join(";\n") do
|
83
83
|
# babel fix and minify
|
84
|
-
command = 'node_modules/babel-cli/.bin/babel --minified --no-comments --compact true -o "%{file}" "%{file}"' % { file: @asset_path }
|
84
|
+
command = './node_modules/babel-cli/.bin/babel --minified --no-comments --compact true -o "%{file}" "%{file}"' % { file: @asset_path }
|
85
85
|
LuxAssets::Cli.run command, message: "Babel filter and minify: #{@asset_path}"
|
86
86
|
end
|
87
87
|
end
|
data/lib/lux_assets/base.rb
CHANGED
@@ -104,6 +104,9 @@ module LuxAssets
|
|
104
104
|
# touch all files and reset the timestamp
|
105
105
|
Dir['./public/assets/*']
|
106
106
|
.each { |file| system 'touch -t 201001010101 %s' % file }
|
107
|
+
|
108
|
+
# add integirty checks
|
109
|
+
LuxAssets::Manifest.update_integrity
|
107
110
|
end
|
108
111
|
|
109
112
|
# get all files as a hash
|
data/lib/lux_assets/element.rb
CHANGED
@@ -76,7 +76,7 @@ class LuxAssets::Element
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def compile_ts
|
79
|
-
LuxAssets::Cli.run "node_modules/typescript/.bin/tsc --outFile '#{@cache}' '#{@source}'", cache_file: @cache, message: "Compile TypeScript: #{@source}"
|
79
|
+
LuxAssets::Cli.run "./node_modules/typescript/.bin/tsc --outFile '#{@cache}' '#{@source}'", cache_file: @cache, message: "Compile TypeScript: #{@source}"
|
80
80
|
end
|
81
81
|
|
82
82
|
end
|
data/lib/lux_assets/manifest.rb
CHANGED
@@ -1,25 +1,37 @@
|
|
1
1
|
# manifest file
|
2
2
|
|
3
3
|
module LuxAssets::Manifest
|
4
|
-
|
5
|
-
MANIFEST.
|
4
|
+
INTEGRITY = 'sha512'
|
5
|
+
MANIFEST = Pathname.new(ENV.fetch('ASSETS_MANIFEST') { './public/manifest.json' })
|
6
|
+
MANIFEST.write '{"files":{},"integrity":{}}' unless MANIFEST.exist?
|
6
7
|
|
7
8
|
extend self
|
8
9
|
|
9
10
|
def add name, path
|
10
|
-
json = JSON.load MANIFEST.read
|
11
|
-
|
12
11
|
unless json['files'][name] == path
|
13
|
-
json['files'][name]
|
14
|
-
|
12
|
+
json['files'][name] = path
|
13
|
+
write
|
15
14
|
end
|
16
15
|
|
17
16
|
!File.exist?('./public'+path)
|
18
17
|
end
|
19
18
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
19
|
+
def update_integrity
|
20
|
+
for name, path in json['files']
|
21
|
+
json['integrity'][name] = '%s-%s' % [INTEGRITY, `openssl dgst -#{INTEGRITY} -binary ./public#{path} | openssl base64 -A`.chomp]
|
22
|
+
end
|
23
|
+
|
24
|
+
write
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def json
|
30
|
+
@json ||= JSON.load MANIFEST.read
|
31
|
+
end
|
32
|
+
|
33
|
+
def write
|
34
|
+
MANIFEST.write JSON.pretty_generate(@json)
|
23
35
|
end
|
24
36
|
end
|
25
37
|
|
@@ -5,16 +5,25 @@ module HtmlHelper
|
|
5
5
|
def asset_include path, opts={}
|
6
6
|
raise ArgumentError.new("Asset path can't be empty") if path.empty?
|
7
7
|
|
8
|
-
ext
|
9
|
-
type
|
10
|
-
type
|
8
|
+
ext = path.split('?').first.split('.').last
|
9
|
+
type = ['css', 'sass', 'scss'].include?(ext) ? :style : :script
|
10
|
+
type = :style if path.include?('fonts.googleapis.com')
|
11
11
|
|
12
12
|
current.response.early_hints path, type
|
13
13
|
|
14
|
+
data = {}
|
15
|
+
|
16
|
+
data[:crossorigin] = opts[:crossorigin] || :anonymous
|
17
|
+
data[:integrity] = opts[:integrity] if opts[:integrity]
|
18
|
+
|
14
19
|
if type == :style
|
15
|
-
|
20
|
+
data[:media] = opts[:media] || :all
|
21
|
+
data[:rel] = :stylesheet
|
22
|
+
data[:href] = path
|
23
|
+
data.tag :link
|
16
24
|
else
|
17
|
-
|
25
|
+
data[:src] = path
|
26
|
+
data.tag :script
|
18
27
|
end
|
19
28
|
end
|
20
29
|
|
@@ -55,6 +64,7 @@ module HtmlHelper
|
|
55
64
|
|
56
65
|
nil
|
57
66
|
else
|
67
|
+
opts[:integrity] = manifest['integrity'][file]
|
58
68
|
return asset_include(Lux.config.assets_root.to_s + mfile, opts)
|
59
69
|
end
|
60
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lux_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dino Reic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|