staticz 1.0.7 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/manifest/compilable/cs.rb +6 -8
- data/lib/manifest/compilable/haml.rb +1 -5
- data/lib/manifest/compilable/js.rb +6 -6
- data/lib/manifest/compilable/react.rb +6 -8
- data/lib/manifest/compilable/sass.rb +6 -8
- data/lib/manifest/compilable/scss.rb +6 -8
- data/lib/manifest/compilable/simple_file.rb +4 -6
- data/lib/manifest/compilable.rb +34 -5
- data/lib/manifest/css_bundle.rb +81 -0
- data/lib/manifest/js_bundle.rb +85 -0
- data/lib/manifest/manifest.rb +22 -2
- data/lib/manifest/sub.rb +16 -2
- data/lib/server.rb +23 -11
- data/lib/staticz.rb +5 -0
- data/lib/utils/helpers.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a80ecb49f81917fbaaf10fabec468748de38f060525fe63826c9b24f6f40fe7e
|
4
|
+
data.tar.gz: d0d42fa919ad0e332a6b310a855ec72af64786401e32825f52ace50303ba08f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b9956372490bdd8bb44ff5533c05e107f9d5997ccf8b42186037dc4dc4e475b55972712c613cc88de3e208999d5ee985f152d215f774d3b43d907c4e43b6738
|
7
|
+
data.tar.gz: 104e0a387444c5e8e962936fce024bf416389bc8b4e1a118473827bc6765f1d164511cd9d5ebe313405ac7150e8c09a8e420776e7f2b47162c7d5647a86c9f25
|
@@ -8,11 +8,7 @@ module Staticz
|
|
8
8
|
|
9
9
|
attr_reader :name
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
def build_file_ending = "js"
|
14
|
-
|
15
|
-
def tile_type_name = "Coff"
|
11
|
+
compile "coffee", "js", "Coff"
|
16
12
|
|
17
13
|
def initialize(name)
|
18
14
|
@name = name
|
@@ -20,11 +16,13 @@ module Staticz
|
|
20
16
|
|
21
17
|
def build
|
22
18
|
if exists?
|
23
|
-
|
24
|
-
|
25
|
-
File.write build_path, js
|
19
|
+
File.write build_path, render
|
26
20
|
end
|
27
21
|
end
|
22
|
+
|
23
|
+
def render
|
24
|
+
CoffeeScript.compile File.read(source_path)
|
25
|
+
end
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
@@ -7,11 +7,7 @@ module Staticz
|
|
7
7
|
|
8
8
|
attr_reader :name
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
def build_file_ending = "js"
|
13
|
-
|
14
|
-
def tile_type_name = "Js"
|
10
|
+
compile "js", "js", "Js"
|
15
11
|
|
16
12
|
def initialize(name)
|
17
13
|
@name = name
|
@@ -19,9 +15,13 @@ module Staticz
|
|
19
15
|
|
20
16
|
def build
|
21
17
|
if exists?
|
22
|
-
File.write build_path,
|
18
|
+
File.write build_path, render
|
23
19
|
end
|
24
20
|
end
|
21
|
+
|
22
|
+
def render
|
23
|
+
File.read(source_path)
|
24
|
+
end
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -8,11 +8,7 @@ module Staticz
|
|
8
8
|
|
9
9
|
attr_reader :name
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
def build_file_ending = "js"
|
14
|
-
|
15
|
-
def tile_type_name = "React"
|
11
|
+
compile "js", "js", "React"
|
16
12
|
|
17
13
|
def initialize(name)
|
18
14
|
@name = name
|
@@ -20,11 +16,13 @@ module Staticz
|
|
20
16
|
|
21
17
|
def build
|
22
18
|
if exists?
|
23
|
-
|
24
|
-
|
25
|
-
File.write build_path, engine["code"]
|
19
|
+
File.write build_path, render
|
26
20
|
end
|
27
21
|
end
|
22
|
+
|
23
|
+
def render
|
24
|
+
Babel::Transpiler.transform(File.read(source_path))["code"]
|
25
|
+
end
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
@@ -8,11 +8,7 @@ module Staticz
|
|
8
8
|
|
9
9
|
attr_reader :name
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
def build_file_ending = "css"
|
14
|
-
|
15
|
-
def tile_type_name = "Sass"
|
11
|
+
compile "sass", "css", "Sass"
|
16
12
|
|
17
13
|
def initialize(name)
|
18
14
|
@name = name
|
@@ -20,12 +16,14 @@ module Staticz
|
|
20
16
|
|
21
17
|
def build
|
22
18
|
if valid?
|
23
|
-
|
24
|
-
|
25
|
-
File.write build_path, engine.render
|
19
|
+
File.write build_path, render
|
26
20
|
end
|
27
21
|
end
|
28
22
|
|
23
|
+
def render
|
24
|
+
::SassC::Engine.new(File.read(source_path), syntax: :sass, style: :compressed).render
|
25
|
+
end
|
26
|
+
|
29
27
|
def errors
|
30
28
|
errors = super
|
31
29
|
|
@@ -8,11 +8,7 @@ module Staticz
|
|
8
8
|
|
9
9
|
attr_reader :name
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
def build_file_ending = "css"
|
14
|
-
|
15
|
-
def tile_type_name = "Scss"
|
11
|
+
compile "scss", "css", "Scss"
|
16
12
|
|
17
13
|
def initialize(name)
|
18
14
|
@name = name
|
@@ -20,12 +16,14 @@ module Staticz
|
|
20
16
|
|
21
17
|
def build
|
22
18
|
if valid?
|
23
|
-
|
24
|
-
|
25
|
-
File.write build_path, engine.render
|
19
|
+
File.write build_path, render
|
26
20
|
end
|
27
21
|
end
|
28
22
|
|
23
|
+
def render
|
24
|
+
::SassC::Engine.new(File.read(source_path), syntax: :scss, style: :compressed).render
|
25
|
+
end
|
26
|
+
|
29
27
|
def errors
|
30
28
|
errors = super
|
31
29
|
|
@@ -5,6 +5,8 @@ module Staticz
|
|
5
5
|
class SimpleFile
|
6
6
|
include Compilable
|
7
7
|
|
8
|
+
compile "", "", "File"
|
9
|
+
|
8
10
|
attr_reader :name
|
9
11
|
|
10
12
|
def source_path
|
@@ -16,14 +18,10 @@ module Staticz
|
|
16
18
|
end
|
17
19
|
|
18
20
|
def create_link_function
|
21
|
+
link_path = "/#{name}"
|
22
|
+
Object.send(:define_method, path_method_name) { link_path }
|
19
23
|
end
|
20
24
|
|
21
|
-
def path_method_name
|
22
|
-
"no path created"
|
23
|
-
end
|
24
|
-
|
25
|
-
def tile_type_name = "File"
|
26
|
-
|
27
25
|
def initialize(name)
|
28
26
|
@name = name
|
29
27
|
end
|
data/lib/manifest/compilable.rb
CHANGED
@@ -2,6 +2,25 @@ require "io/console"
|
|
2
2
|
|
3
3
|
module Staticz
|
4
4
|
module Compilable
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
end
|
8
|
+
module ClassMethods
|
9
|
+
def compile(source_file_ending, build_file_ending, file_type_name)
|
10
|
+
define_method :source_file_ending do
|
11
|
+
source_file_ending
|
12
|
+
end
|
13
|
+
|
14
|
+
define_method :build_file_ending do
|
15
|
+
build_file_ending
|
16
|
+
end
|
17
|
+
|
18
|
+
define_method :file_type_name do
|
19
|
+
file_type_name
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
5
24
|
def path
|
6
25
|
name.to_s
|
7
26
|
end
|
@@ -19,7 +38,7 @@ module Staticz
|
|
19
38
|
end
|
20
39
|
|
21
40
|
def path_method_name
|
22
|
-
"#{path.gsub(/[
|
41
|
+
"#{path.gsub(/[.\/-]/, "_")}_path"
|
23
42
|
end
|
24
43
|
|
25
44
|
def valid?
|
@@ -35,18 +54,28 @@ module Staticz
|
|
35
54
|
end
|
36
55
|
|
37
56
|
def create_link_function
|
38
|
-
link_path = "
|
39
|
-
|
57
|
+
link_path = "/#{name}.#{build_file_ending}"
|
58
|
+
shortened_link_path = "/#{name}"
|
59
|
+
Object.send(:define_method, path_method_name) do |shorten: false|
|
60
|
+
if shorten
|
61
|
+
shortened_link_path
|
62
|
+
else
|
63
|
+
link_path
|
64
|
+
end
|
65
|
+
end
|
40
66
|
end
|
41
67
|
|
42
|
-
def print(indentation)
|
68
|
+
def print(indentation, *args)
|
43
69
|
valid_symbol = if valid?
|
44
70
|
Colors.in_green("✔")
|
45
71
|
else
|
46
72
|
Colors.in_red("✘")
|
47
73
|
end
|
48
74
|
|
49
|
-
|
75
|
+
compilable_string = "#{" " * (indentation * 3)}└─ #{file_type_name}: #{path} #{valid_symbol}"
|
76
|
+
compilable_string << " -> #{path_method_name}" if !args.include? :no_path
|
77
|
+
|
78
|
+
puts compilable_string
|
50
79
|
|
51
80
|
_height, width = IO.console.winsize
|
52
81
|
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require_relative "sub"
|
2
|
+
|
3
|
+
module Staticz
|
4
|
+
class CSSBundle
|
5
|
+
attr_reader :name, :location, :elements
|
6
|
+
|
7
|
+
def initialize(name, location)
|
8
|
+
@name = name
|
9
|
+
@location = location
|
10
|
+
@elements = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def sub(name, &block)
|
14
|
+
s = Staticz::Sub.new(generate_location_path(name))
|
15
|
+
elements.push(s)
|
16
|
+
s.instance_eval(&block)
|
17
|
+
end
|
18
|
+
|
19
|
+
def sass(name, &block)
|
20
|
+
elements.push(Staticz::Compilable::Sass.new(generate_location_path(name)))
|
21
|
+
end
|
22
|
+
|
23
|
+
def scss(name, &block)
|
24
|
+
elements.push(Staticz::Compilable::Scss.new(generate_location_path(name)))
|
25
|
+
end
|
26
|
+
|
27
|
+
def generate_location_path(name)
|
28
|
+
if location.empty?
|
29
|
+
name
|
30
|
+
else
|
31
|
+
"#{location}/#{name}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def build
|
36
|
+
File.write "build/#{name}_bundle.css", render
|
37
|
+
end
|
38
|
+
|
39
|
+
def render
|
40
|
+
render_elements elements
|
41
|
+
end
|
42
|
+
|
43
|
+
def render_elements(elements)
|
44
|
+
elements
|
45
|
+
.map do |element|
|
46
|
+
if element.is_a? Staticz::Sub
|
47
|
+
render_elements element.elements
|
48
|
+
else
|
49
|
+
[
|
50
|
+
"/* #{element.name} */",
|
51
|
+
element.render
|
52
|
+
].join("\n\n")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
.join("\n\n")
|
56
|
+
end
|
57
|
+
|
58
|
+
def path_method_name
|
59
|
+
"#{name.to_s.gsub(/[.\/-]/, "_")}_css_bundle_path"
|
60
|
+
end
|
61
|
+
|
62
|
+
def create_link_function
|
63
|
+
link_path = "/#{name}_bundle.css"
|
64
|
+
|
65
|
+
Object.send(:define_method, path_method_name) do
|
66
|
+
link_path
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def print(indentation)
|
71
|
+
puts "#{" " * (indentation * 3)}└─ CSSBundle: #{name} -> #{path_method_name}"
|
72
|
+
elements.each do |e|
|
73
|
+
e.print(indentation + 1, :no_path)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def path
|
78
|
+
"src/#{name}"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require_relative "sub"
|
2
|
+
|
3
|
+
module Staticz
|
4
|
+
class JSBundle
|
5
|
+
attr_reader :name, :location, :elements
|
6
|
+
|
7
|
+
def initialize(name, location)
|
8
|
+
@name = name
|
9
|
+
@location = location
|
10
|
+
@elements = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def sub(name, &block)
|
14
|
+
s = Staticz::Sub.new(generate_location_path(name))
|
15
|
+
elements.push(s)
|
16
|
+
s.instance_eval(&block)
|
17
|
+
end
|
18
|
+
|
19
|
+
def js(name, &block)
|
20
|
+
elements.push(Staticz::Compilable::Js.new(generate_location_path(name)))
|
21
|
+
end
|
22
|
+
|
23
|
+
def coffee(name, &block)
|
24
|
+
elements.push(Staticz::Compilable::Cs.new(generate_location_path(name)))
|
25
|
+
end
|
26
|
+
|
27
|
+
def react(name, &block)
|
28
|
+
elements.push(Staticz::Compilable::React.new(generate_location_path(name)))
|
29
|
+
end
|
30
|
+
|
31
|
+
def generate_location_path(name)
|
32
|
+
if location.empty?
|
33
|
+
name
|
34
|
+
else
|
35
|
+
"#{location}/#{name}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def build
|
40
|
+
File.write "build/#{name}_bundle.js", render
|
41
|
+
end
|
42
|
+
|
43
|
+
def render
|
44
|
+
render_elements elements
|
45
|
+
end
|
46
|
+
|
47
|
+
def render_elements(elements)
|
48
|
+
elements
|
49
|
+
.map do |element|
|
50
|
+
if element.is_a? Staticz::Sub
|
51
|
+
render_elements element.elements
|
52
|
+
else
|
53
|
+
[
|
54
|
+
"// #{element.name}",
|
55
|
+
element.render
|
56
|
+
].join("\n\n")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
.join("\n\n")
|
60
|
+
end
|
61
|
+
|
62
|
+
def path_method_name
|
63
|
+
"#{name.to_s.gsub(/[.\/-]/, "_")}_js_bundle_path"
|
64
|
+
end
|
65
|
+
|
66
|
+
def create_link_function
|
67
|
+
link_path = "/#{name}_bundle.js"
|
68
|
+
|
69
|
+
Object.send(:define_method, path_method_name) do
|
70
|
+
link_path
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def print(indentation)
|
75
|
+
puts "#{" " * (indentation * 3)}└─ JSBundle: #{name} -> #{path_method_name}"
|
76
|
+
elements.each do |e|
|
77
|
+
e.print(indentation + 1, :no_path)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def path
|
82
|
+
"src/#{name}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/manifest/manifest.rb
CHANGED
@@ -7,6 +7,8 @@ require_relative "compilable/react"
|
|
7
7
|
require_relative "compilable/sass"
|
8
8
|
require_relative "compilable/scss"
|
9
9
|
require_relative "compilable/simple_file"
|
10
|
+
require_relative "js_bundle"
|
11
|
+
require_relative "css_bundle"
|
10
12
|
|
11
13
|
module Staticz
|
12
14
|
class Manifest
|
@@ -53,15 +55,33 @@ module Staticz
|
|
53
55
|
elements.push(Staticz::Compilable::SimpleFile.new(name))
|
54
56
|
end
|
55
57
|
|
58
|
+
def js_bundle(name, &block)
|
59
|
+
s = Staticz::JSBundle.new(name, "")
|
60
|
+
elements.push(s)
|
61
|
+
|
62
|
+
s.instance_eval(&block)
|
63
|
+
end
|
64
|
+
|
65
|
+
def css_bundle(name, &block)
|
66
|
+
s = Staticz::CSSBundle.new(name, "")
|
67
|
+
elements.push(s)
|
68
|
+
|
69
|
+
s.instance_eval(&block)
|
70
|
+
end
|
71
|
+
|
56
72
|
def build
|
57
73
|
load "#{Dir.pwd}/manifest.rb"
|
58
74
|
|
75
|
+
create_link_functions
|
76
|
+
|
59
77
|
elements.each do |e|
|
60
|
-
e.
|
78
|
+
e.build
|
61
79
|
end
|
80
|
+
end
|
62
81
|
|
82
|
+
def create_link_functions
|
63
83
|
elements.each do |e|
|
64
|
-
e.
|
84
|
+
e.create_link_function
|
65
85
|
end
|
66
86
|
end
|
67
87
|
|
data/lib/manifest/sub.rb
CHANGED
@@ -41,6 +41,20 @@ module Staticz
|
|
41
41
|
elements.push(Staticz::Compilable::SimpleFile.new("#{@name}/#{name}"))
|
42
42
|
end
|
43
43
|
|
44
|
+
def js_bundle(name, &block)
|
45
|
+
s = Staticz::JSBundle.new("#{@name}/#{name}", @name)
|
46
|
+
elements.push(s)
|
47
|
+
|
48
|
+
s.instance_eval(&block)
|
49
|
+
end
|
50
|
+
|
51
|
+
def css_bundle(name, &block)
|
52
|
+
s = Staticz::CSSBundle.new("#{@name}/#{name}", @name)
|
53
|
+
elements.push(s)
|
54
|
+
|
55
|
+
s.instance_eval(&block)
|
56
|
+
end
|
57
|
+
|
44
58
|
def build
|
45
59
|
Dir.mkdir("build/#{name}") if !Dir.exist?("build/#{name}")
|
46
60
|
|
@@ -55,10 +69,10 @@ module Staticz
|
|
55
69
|
end
|
56
70
|
end
|
57
71
|
|
58
|
-
def print(indentation)
|
72
|
+
def print(indentation, *args)
|
59
73
|
puts "#{" " * (indentation * 3)}└─ Sub: #{name}"
|
60
74
|
elements.each do |e|
|
61
|
-
e.print(indentation + 1)
|
75
|
+
e.print(indentation + 1, *args)
|
62
76
|
end
|
63
77
|
end
|
64
78
|
|
data/lib/server.rb
CHANGED
@@ -46,6 +46,7 @@ module Staticz
|
|
46
46
|
build_manifest
|
47
47
|
|
48
48
|
Thread.new { listen_to_file_changes }
|
49
|
+
Thread.new { listen_to_manifest_changes }
|
49
50
|
thin_server.start
|
50
51
|
end
|
51
52
|
|
@@ -68,25 +69,36 @@ module Staticz
|
|
68
69
|
folders << "lib" if Dir.exist? "lib"
|
69
70
|
|
70
71
|
listener = Listen.to(*folders) do |modified, added, removed|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
.join(", ")
|
72
|
+
trigger_rebuild(modified, added, removed)
|
73
|
+
end
|
74
|
+
listener.start
|
75
|
+
end
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
puts "Rebuilding successful"
|
77
|
+
def listen_to_manifest_changes
|
78
|
+
listener = Listen.to("./", only: /^manifest.rb$/) do |modified, added, removed|
|
79
|
+
trigger_rebuild(modified, added, removed)
|
81
80
|
end
|
82
81
|
listener.start
|
83
82
|
end
|
84
83
|
|
85
|
-
def
|
86
|
-
|
84
|
+
def trigger_rebuild(modified, added, removed)
|
85
|
+
file_names = (modified + added + removed)
|
86
|
+
.map do |file|
|
87
|
+
file.gsub "#{Dir.pwd}/", ""
|
88
|
+
end
|
89
|
+
.join(", ")
|
87
90
|
|
91
|
+
$stdout.clear_screen
|
92
|
+
puts "#{file_names} changed, rebuilding..."
|
93
|
+
build_manifest
|
94
|
+
puts "Rebuilding successful"
|
95
|
+
end
|
96
|
+
|
97
|
+
def build_manifest
|
88
98
|
Staticz::Builder.new
|
89
99
|
Staticz::Manifest.instance.print
|
100
|
+
|
101
|
+
Staticz::Modules::Reload.generate_hash
|
90
102
|
end
|
91
103
|
end
|
92
104
|
end
|
data/lib/staticz.rb
CHANGED
@@ -27,7 +27,12 @@ module Staticz
|
|
27
27
|
Staticz::Settings.development!
|
28
28
|
Staticz::Server.new
|
29
29
|
when 'manifest'
|
30
|
+
Staticz::Settings.development!
|
31
|
+
|
30
32
|
load "#{Dir.pwd}/manifest.rb"
|
33
|
+
Staticz::Modules::LibLoader.load_files
|
34
|
+
Staticz::Manifest.instance.create_link_functions
|
35
|
+
|
31
36
|
Staticz::Manifest.instance.print
|
32
37
|
when 'build'
|
33
38
|
Staticz::Settings.production!
|
data/lib/utils/helpers.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: staticz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipp Schlesinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|
@@ -127,6 +127,8 @@ files:
|
|
127
127
|
- lib/manifest/compilable/sass.rb
|
128
128
|
- lib/manifest/compilable/scss.rb
|
129
129
|
- lib/manifest/compilable/simple_file.rb
|
130
|
+
- lib/manifest/css_bundle.rb
|
131
|
+
- lib/manifest/js_bundle.rb
|
130
132
|
- lib/manifest/manifest.rb
|
131
133
|
- lib/manifest/sub.rb
|
132
134
|
- lib/modules/lib_loader.rb
|
@@ -165,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
167
|
- !ruby/object:Gem::Version
|
166
168
|
version: '0'
|
167
169
|
requirements: []
|
168
|
-
rubygems_version: 3.3.
|
170
|
+
rubygems_version: 3.3.7
|
169
171
|
signing_key:
|
170
172
|
specification_version: 4
|
171
173
|
summary: Static website compiler
|