staticz 1.1.2 → 1.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e625da7c786a60e0b0f05046b81e750c35b850b18e5c337324324f10b9c3617e
4
- data.tar.gz: ead9239fae7ac1d1e9d70ea0f9b2e26d61142db784414ff96dc654e897e3c399
3
+ metadata.gz: 77d19bdf7754a2be5d6e1f16f7ddf8f4cd4cd2763e463f7bca2cc9d44cae627a
4
+ data.tar.gz: 7a7cc76d596f758d927a25be84df313535906871d4f16065423b4e9880c4aed4
5
5
  SHA512:
6
- metadata.gz: 46792118d6680d1229ddd4e9a7b320cf5e8f33ced725530eb5713c9d0f13a532568e8efc08d728e5cfad7a175fa614fbd7fd513959c184c37102b9c6345849c3
7
- data.tar.gz: 521439fd1a9f283427533332ef40bc35a34e01b211fb6c0cf323f921fd018dd8af3dd5af52641b078356942d4232298df55bbd49944b660b25d2cde8069eb635
6
+ metadata.gz: 58bad0fd185159a24f18360d6aaf965885502f498524fef04ea2668a1ef6f375b5487f609714490bc190739e7459eae7db4ea9c19d9cae6ae723c989d696df6f
7
+ data.tar.gz: 850719e52d486b9cd50429a8e769435bf74a02f1992266a054e0601e9c9cd5342eb4be0bf6b358092736d0e2d7a09648cc3903fa538d2929a1978d071bd04f04
data/lib/builder.rb CHANGED
@@ -9,6 +9,16 @@ module Staticz
9
9
  end
10
10
 
11
11
  def build
12
+ if !manifest_exists?
13
+ puts "Manifest missing"
14
+ exit 1
15
+ end
16
+
17
+ if !src_folder_exists?
18
+ puts "src folder missing"
19
+ exit 1
20
+ end
21
+
12
22
  Staticz::Modules::LibLoader.load_files
13
23
 
14
24
  Dir.mkdir('build') unless File.exist?('build')
@@ -17,5 +27,15 @@ module Staticz
17
27
 
18
28
  Staticz::Manifest.instance.valid?
19
29
  end
30
+
31
+ private
32
+
33
+ def manifest_exists?
34
+ File.exist? "manifest.rb"
35
+ end
36
+
37
+ def src_folder_exists?
38
+ Dir.exist? "src"
39
+ end
20
40
  end
21
41
  end
@@ -1,5 +1,6 @@
1
1
  require "tty-option"
2
- require_relative "../templates/default"
2
+ require_relative "../templates/clean"
3
+ require_relative "../templates/simple"
3
4
  require_relative "../templates/layout"
4
5
 
5
6
  module Staticz
@@ -18,19 +19,24 @@ module Staticz
18
19
  desc "The name to give the app. Decides how the folder is named"
19
20
  end
20
21
 
21
- flag :help do
22
- short "-h"
23
- long "--help"
24
- desc "Print this page"
25
- end
26
-
27
22
  option :template do
28
23
  short "-t"
29
24
  long "--template name"
30
25
  desc "The template to use"
31
26
 
32
- default "default"
33
- permit %w[default layout]
27
+ default "clean"
28
+ permit %w[clean simple layout]
29
+ end
30
+
31
+ flag :with_gitignore do
32
+ long "--with-gitignore"
33
+ desc "Add basic .gitignore file"
34
+ end
35
+
36
+ flag :help do
37
+ short "-h"
38
+ long "--help"
39
+ desc "Print this page"
34
40
  end
35
41
 
36
42
  def run
@@ -46,6 +52,13 @@ module Staticz
46
52
 
47
53
  Object
48
54
  .const_get("Staticz::Templates::#{params[:template].capitalize}")
55
+ .tap do |template|
56
+ if params[:with_gitignore]
57
+ template.file ".gitignore", <<~GITIGNORE
58
+ build/
59
+ GITIGNORE
60
+ end
61
+ end
49
62
  .build(params[:name])
50
63
  end
51
64
  end
@@ -4,16 +4,27 @@ require_relative "../compilable"
4
4
 
5
5
  module Staticz
6
6
  module Compilable
7
- class SassC
7
+ class Scss
8
8
  include Compilable
9
9
 
10
10
  attr_reader :name
11
11
 
12
- compile "sass", "css", "Sass"
13
-
14
- def initialize(name)
12
+ def initialize(name, type:)
15
13
  @name = name
16
14
  @warnings = []
15
+ @type = type
16
+ end
17
+
18
+ def source_file_ending
19
+ @type
20
+ end
21
+
22
+ def build_file_ending
23
+ "css"
24
+ end
25
+
26
+ def file_type_name
27
+ @type.capitalize
17
28
  end
18
29
 
19
30
  def build(listener_class: nil)
@@ -0,0 +1,46 @@
1
+ require "slim"
2
+ require_relative "../compilable"
3
+
4
+ module Staticz
5
+ module Compilable
6
+ class Slim
7
+ include Compilable
8
+
9
+ attr_reader :name
10
+
11
+ compile "slim", "html", "Slim"
12
+
13
+ def initialize(name)
14
+ @name = name
15
+ end
16
+
17
+ def errors
18
+ errors = super
19
+
20
+ if exists?
21
+ begin
22
+ template = ::Slim::Template.new(source_path)
23
+ template.render
24
+ rescue => e
25
+ errors << e.message
26
+ end
27
+ end
28
+
29
+ errors
30
+ end
31
+
32
+ def build(listener_class: nil)
33
+ listener = listener_class&.new(self)
34
+
35
+ if valid?
36
+ template = ::Slim::Template.new(source_path)
37
+ File.write build_path, template.render
38
+
39
+ listener&.finish
40
+ else
41
+ listener&.error
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -17,11 +17,11 @@ module Staticz
17
17
  end
18
18
 
19
19
  def sass(name, &block)
20
- elements.push(Staticz::Compilable::SassC.new(generate_location_path(name)))
20
+ elements.push(Staticz::Compilable::Scss.new(generate_location_path(name), type: :sass))
21
21
  end
22
22
 
23
23
  def scss(name, &block)
24
- elements.push(Staticz::Compilable::ScssC.new(generate_location_path(name)))
24
+ elements.push(Staticz::Compilable::Scss.new(generate_location_path(name), type: :scss))
25
25
  end
26
26
 
27
27
  def generate_location_path(name)
@@ -1,11 +1,11 @@
1
1
  require "singleton"
2
2
  require_relative "sub"
3
3
  require_relative "compilable/haml"
4
+ require_relative "compilable/slim"
4
5
  require_relative "compilable/cs"
5
6
  require_relative "compilable/js"
6
7
  require_relative "compilable/react"
7
- require_relative "compilable/sassc"
8
- require_relative "compilable/scssc"
8
+ require_relative "compilable/scss"
9
9
  require_relative "compilable/simple_file"
10
10
  require_relative "js_bundle"
11
11
  require_relative "css_bundle"
@@ -32,12 +32,16 @@ module Staticz
32
32
  elements.push(Staticz::Compilable::Haml.new(name))
33
33
  end
34
34
 
35
+ def slim(name)
36
+ elements.push(Staticz::Compilable::Slim.new(name))
37
+ end
38
+
35
39
  def sass(name)
36
- elements.push(Staticz::Compilable::SassC.new(name))
40
+ elements.push(Staticz::Compilable::Scss.new(name, type: :sass))
37
41
  end
38
42
 
39
43
  def scss(name)
40
- elements.push(Staticz::Compilable::ScssC.new(name))
44
+ elements.push(Staticz::Compilable::Scss.new(name, type: :scss))
41
45
  end
42
46
 
43
47
  def js(name)
@@ -113,5 +117,14 @@ module Staticz
113
117
  e.print(0)
114
118
  end
115
119
  end
120
+
121
+ def index_missing?
122
+ elements
123
+ .filter do |e|
124
+ !e.is_a? Staticz::Sub
125
+ end.find do |e|
126
+ e.build_path == "build/index.html"
127
+ end.nil?
128
+ end
116
129
  end
117
130
  end
data/lib/manifest/sub.rb CHANGED
@@ -17,12 +17,16 @@ module Staticz
17
17
  elements.push(Staticz::Compilable::Haml.new("#{@name}/#{name}"))
18
18
  end
19
19
 
20
+ def slim(name, &block)
21
+ elements.push(Staticz::Compilable::Slim.new("#{@name}/#{name}"))
22
+ end
23
+
20
24
  def sass(name, &block)
21
- elements.push(Staticz::Compilable::SassC.new("#{@name}/#{name}"))
25
+ elements.push(Staticz::Compilable::Scss.new("#{@name}/#{name}", type: :sass))
22
26
  end
23
27
 
24
28
  def scss(name, &block)
25
- elements.push(Staticz::Compilable::ScssC.new("#{@name}/#{name}"))
29
+ elements.push(Staticz::Compilable::Scss.new("#{@name}/#{name}", type: :scss))
26
30
  end
27
31
 
28
32
  def js(name, &block)
@@ -10,11 +10,11 @@ module Staticz
10
10
  def self.build_reload_js
11
11
  <<~JS
12
12
  var hash = null;
13
-
13
+
14
14
  function checkForChanges() {
15
15
  console.log("Check for file changes");
16
16
  var response = new XMLHttpRequest();
17
- response.open("GET", "api/hash", true);
17
+ response.open("GET", "/api/hash", true);
18
18
  response.onload = function() {
19
19
  if (response.status === 200) {
20
20
  if (!hash) {
data/lib/server.rb CHANGED
@@ -32,10 +32,25 @@ module Staticz
32
32
  ]
33
33
  }
34
34
  end
35
+
35
36
  map "/" do
36
- use Rack::Static, urls: {"/" => "build/index.html"}
37
+ if Staticz::Manifest.instance.index_missing?
38
+ use Rack::Static,
39
+ urls: {"/" => "get_started.html"},
40
+ root: File.join(File.dirname(__FILE__), "templates", "files")
41
+
42
+ use Rack::Static,
43
+ urls: {"/logo.png" => "logo.png"},
44
+ root: File.join(File.dirname(__FILE__), "templates", "files")
45
+
46
+ use Rack::Static,
47
+ urls: {"/bolt.png" => "bolt.png"},
48
+ root: File.join(File.dirname(__FILE__), "templates", "files")
49
+ else
50
+ use Rack::Static, urls: {"/" => "build/index.html"}
51
+ end
37
52
 
38
- Staticz::Server.all_haml(Staticz::Manifest.instance.elements).each do |e|
53
+ Staticz::Server.all_templates(Staticz::Manifest.instance.elements).each do |e|
39
54
  use Rack::Static, urls: {"/#{e.name}" => e.build_path}
40
55
  end
41
56
 
@@ -53,12 +68,14 @@ module Staticz
53
68
  thin_server.start
54
69
  end
55
70
 
56
- def self.all_haml(elements)
71
+ def self.all_templates(elements)
57
72
  elements.map do |e|
58
73
  if e.is_a? Staticz::Compilable::Haml
59
74
  e
75
+ elsif e.is_a? Staticz::Compilable::Slim
76
+ e
60
77
  elsif e.is_a? Staticz::Sub
61
- all_haml(e.elements)
78
+ all_templates(e.elements)
62
79
  end
63
80
  end.flatten.select do |e|
64
81
  e
data/lib/staticz.rb CHANGED
@@ -6,7 +6,7 @@ require_relative "commands/manifest_command"
6
6
  require_relative "commands/build_command"
7
7
 
8
8
  module Staticz
9
- VERSION = "1.1.2"
9
+ VERSION = "1.1.5"
10
10
 
11
11
  def self.init
12
12
  cmd, args = case ARGV[0]
@@ -0,0 +1,14 @@
1
+ require_relative "template"
2
+
3
+ module Staticz::Templates
4
+ class Clean
5
+ extend Staticz::Template
6
+
7
+ folders "src"
8
+
9
+ file "manifest.rb", <<~RUBY
10
+ Staticz::Manifest.define do
11
+ end
12
+ RUBY
13
+ end
14
+ end
Binary file
@@ -0,0 +1,201 @@
1
+ <!DOCTYPE html>
2
+ <html lang='en'>
3
+ <head>
4
+ <meta charset='UTF-8'>
5
+ <meta content='width=device-width, initial-scale=1' name='viewport'>
6
+ <meta content='Get started with staticz' name='description'>
7
+ <meta content='website, staticz' name='keywords'>
8
+ <meta content='staticz.dev' property='og:site_name'>
9
+ <meta content='Get started with staticz' property='og:title'>
10
+ <meta content='Get started with staticz' property='og:description'>
11
+ <meta content='website' property='og:type'>
12
+ <meta content='https://staticz.dev/' property='og:url'>
13
+ <meta content='Get started with staticz' property='og:title'>
14
+ <link href='/bolt.png' rel='icon' type='image/x-icon'>
15
+ <link href='https://fonts.googleapis.com' rel='preconnect'>
16
+ <link crossorigin href='https://fonts.gstatic.com' rel='preconnect'>
17
+ <link href='https://fonts.googleapis.com/css2?family=Jua&amp;family=Plus+Jakarta+Sans:ital,wght@0,200..800;1,200..800&amp;display=swap' rel='stylesheet'>
18
+ <title>Get started with staticz</title>
19
+ <script src="reload.js" defer></script>
20
+ <style>
21
+ * {
22
+ box-sizing: border-box;
23
+ }
24
+
25
+ html, body {
26
+ padding: 0;
27
+ margin: 0;
28
+ }
29
+
30
+ body {
31
+ width: 100%;
32
+ min-height: 100vh;
33
+ overflow-x: hidden;
34
+ padding: 0.5rem;
35
+ padding-bottom: 2rem;
36
+ font-family: "Plus Jakarta Sans", sans-serif;
37
+ }
38
+
39
+ nav {
40
+ width: 100%;
41
+ padding: 0.125rem;
42
+ display: flex;
43
+ flex-direction: row;
44
+ justify-content: right;
45
+ align-items: center;
46
+ gap: 0.25rem;
47
+ }
48
+
49
+ .nav-link {
50
+ padding: 0.5rem 1rem;
51
+ color: rgb(51, 65, 85);
52
+ font-weight: bold;
53
+ text-decoration: none;
54
+ border-radius: 0.5rem;
55
+ transition: 150ms color, 150ms background-color;
56
+ }
57
+ .nav-link:hover {
58
+ color: rgb(91, 0, 255);
59
+ background-color: rgb(241, 245, 249);
60
+ }
61
+
62
+ header {
63
+ width: 100%;
64
+ max-width: 100%;
65
+ margin-top: 2rem;
66
+ display: flex;
67
+ flex-direction: column;
68
+ align-items: center;
69
+ }
70
+
71
+ .header-logo {
72
+ width: 16rem;
73
+ max-width: 100%;
74
+ }
75
+
76
+ .header-name {
77
+ font-size: 2rem;
78
+ font-weight: bold;
79
+ font-family: "Jua";
80
+ background: -webkit-linear-gradient(180deg, rgb(255, 251, 69) 0%, rgb(240, 69, 229) 59%, rgb(91, 0, 255) 100%);
81
+ -webkit-background-clip: text;
82
+ -webkit-text-fill-color: transparent;
83
+ }
84
+
85
+ main {
86
+ display: flex;
87
+ flex-direction: column;
88
+ align-items: center;
89
+ }
90
+
91
+ code {
92
+ padding: 0.2rem 0.4rem;
93
+ background-color: rgb(226, 232, 240);
94
+ border-radius: 0.25rem;
95
+ }
96
+
97
+ .main-heading {
98
+ text-align: center;
99
+ }
100
+
101
+ .main-staticz {
102
+ font-weight: bold;
103
+ font-family: "Jua";
104
+ background: -webkit-linear-gradient(180deg, rgb(255, 251, 69) 0%, rgb(240, 69, 229) 59%, rgb(91, 0, 255) 100%);
105
+ -webkit-background-clip: text;
106
+ -webkit-text-fill-color: transparent;
107
+ }
108
+
109
+ .main-list {
110
+ display: grid;
111
+ grid-template-columns: 1fr auto;
112
+ gap: 1rem;
113
+ }
114
+
115
+ .main-list-number {
116
+ width: 4rem;
117
+ height: 4rem;
118
+ display: flex;
119
+ justify-content: center;
120
+ align-items: center;
121
+ font-size: 1.5rem;
122
+ font-family: "Jua";
123
+ background-color: rgb(241, 245, 249);
124
+ border-radius: 2rem;
125
+ }
126
+
127
+ .main-list-text {
128
+ max-width: 16rem;
129
+ }
130
+
131
+ .main-list-text-link {
132
+ color: rgb(91, 0, 255);
133
+ font-weight: bold;
134
+ text-decoration: none;
135
+ transition: 150ms color;
136
+ }
137
+ .main-list-text-link:hover {
138
+ color: rgb(240, 69, 229);
139
+ }
140
+ </style>
141
+ </head>
142
+ <body>
143
+ <nav>
144
+ <a class='nav-link' href='https://staticz.philcomm.dev/' target='_blank'>Docs</a>
145
+ <a class='nav-link' href='https://github.com/OfficialPhilcomm/staticz' target='_blank'>GitHub</a>
146
+ <a class='nav-link' href='https://rubygems.org/gems/staticz' target='_blank'>RubyGems</a>
147
+ </nav>
148
+ <header>
149
+ <img class='header-logo' src='/logo.png'>
150
+ <div class='header-name'>staticz</div>
151
+ </header>
152
+ <main>
153
+ <h1 class='main-heading'>
154
+ Thank you for choosing
155
+ <span class='main-staticz'>staticz</span>
156
+ 🎉
157
+ </h1>
158
+ <h2 class='main-heading'>First Steps</h2>
159
+ <div class='main-list'>
160
+ <div class='main-list-number'>1</div>
161
+ <div class='main-list-text'>
162
+ First, add an index file by adding
163
+ <code>haml :index</code>
164
+ to
165
+ <code>manifest.rb</code>
166
+ .
167
+ Then create the file
168
+ <code>src/index.haml</code>
169
+ .
170
+ This will be your index file and replaces this page.
171
+ Careful, this page is only displayed if no index exists!
172
+ </div>
173
+ <div class='main-list-number'>2</div>
174
+ <div class='main-list-text'>
175
+ Add a stylesheet by adding
176
+ <code>sass :style</code>
177
+ to the manifest.
178
+ Now create the file
179
+ <code>src/style.sass</code>
180
+ . As the last step, add
181
+ <br>
182
+ <code>= stylesheet style_path</code>
183
+ <br>
184
+ to your index's head tag.
185
+ Et voilà! You have added a stylesheet.
186
+ </div>
187
+ <div class='main-list-number'>3</div>
188
+ <div class='main-list-text'>
189
+ There is many more things you can do now.
190
+ To get a better overview, check out the
191
+ <a class='main-list-text-link' href='https://staticz.philcomm.dev/' target='_blank'>
192
+ docs!
193
+ </a>
194
+ There you'll find everything you need to kickstart your static website development with
195
+ <span class='main-staticz'>staticz</span>
196
+ !
197
+ </div>
198
+ </div>
199
+ </main>
200
+ </body>
201
+ </html>
Binary file
@@ -64,9 +64,5 @@ module Staticz::Templates
64
64
  padding: 0
65
65
  margin: 0
66
66
  SASS
67
-
68
- file ".gitignore", <<~GITIGNORE
69
- build/
70
- GITIGNORE
71
67
  end
72
68
  end
@@ -1,7 +1,7 @@
1
1
  require_relative "template"
2
2
 
3
3
  module Staticz::Templates
4
- class Default
4
+ class Simple
5
5
  extend Staticz::Template
6
6
 
7
7
  folders "src", "src/css"
@@ -48,9 +48,5 @@ module Staticz::Templates
48
48
  padding: 0
49
49
  margin: 0
50
50
  SASS
51
-
52
- file ".gitignore", <<~GITIGNORE
53
- build/
54
- GITIGNORE
55
51
  end
56
52
  end
data/lib/utils/helpers.rb CHANGED
@@ -59,5 +59,5 @@ def react_component(name, css_class = nil)
59
59
  end
60
60
 
61
61
  def reload_js
62
- "<script src=\"reload.js\" defer></script>" if Staticz::Settings.development?
62
+ "<script src=\"/reload.js\" defer></script>" if Staticz::Settings.development?
63
63
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staticz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipp Schlesinger
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-03-15 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: haml
@@ -164,6 +163,20 @@ dependencies:
164
163
  - - "~>"
165
164
  - !ruby/object:Gem::Version
166
165
  version: 0.8.0
166
+ - !ruby/object:Gem::Dependency
167
+ name: slim
168
+ requirement: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: '5.2'
173
+ type: :runtime
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '5.2'
167
180
  description: Create websites with haml and sass, and compile them into static html
168
181
  and css
169
182
  email:
@@ -185,9 +198,9 @@ files:
185
198
  - lib/manifest/compilable/haml.rb
186
199
  - lib/manifest/compilable/js.rb
187
200
  - lib/manifest/compilable/react.rb
188
- - lib/manifest/compilable/sassc.rb
189
- - lib/manifest/compilable/scssc.rb
201
+ - lib/manifest/compilable/scss.rb
190
202
  - lib/manifest/compilable/simple_file.rb
203
+ - lib/manifest/compilable/slim.rb
191
204
  - lib/manifest/css_bundle.rb
192
205
  - lib/manifest/js_bundle.rb
193
206
  - lib/manifest/manifest.rb
@@ -197,8 +210,12 @@ files:
197
210
  - lib/server.rb
198
211
  - lib/settings.rb
199
212
  - lib/staticz.rb
200
- - lib/templates/default.rb
213
+ - lib/templates/clean.rb
214
+ - lib/templates/files/bolt.png
215
+ - lib/templates/files/get_started.html
216
+ - lib/templates/files/logo.png
201
217
  - lib/templates/layout.rb
218
+ - lib/templates/simple.rb
202
219
  - lib/templates/template.rb
203
220
  - lib/utils/colors.rb
204
221
  - lib/utils/helpers.rb
@@ -209,7 +226,6 @@ metadata:
209
226
  documentation_uri: https://github.com/OfficialPhilcomm/staticz
210
227
  source_code_uri: https://github.com/OfficialPhilcomm/staticz
211
228
  changelog_uri: https://github.com/OfficialPhilcomm/staticz/blob/master/changelog.md
212
- post_install_message:
213
229
  rdoc_options: []
214
230
  require_paths:
215
231
  - lib
@@ -224,8 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
240
  - !ruby/object:Gem::Version
225
241
  version: '0'
226
242
  requirements: []
227
- rubygems_version: 3.5.22
228
- signing_key:
243
+ rubygems_version: 3.6.7
229
244
  specification_version: 4
230
245
  summary: Static website compiler
231
246
  test_files: []
@@ -1,83 +0,0 @@
1
- require "sass-embedded"
2
- require "pastel"
3
- require_relative "../compilable"
4
-
5
- module Staticz
6
- module Compilable
7
- class ScssC
8
- include Compilable
9
-
10
- attr_reader :name
11
-
12
- compile "scss", "css", "Scss"
13
-
14
- def initialize(name)
15
- @name = name
16
- @warnings = []
17
- end
18
-
19
- def build(listener_class: nil)
20
- listener = listener_class&.new(self)
21
-
22
- if valid?
23
- File.write build_path, render
24
-
25
- listener&.finish
26
- else
27
- listener&.error
28
- end
29
- end
30
-
31
- def render
32
- Sass.compile(source_path, style: :compressed, logger: Sass::Logger.silent).css
33
- end
34
-
35
- def errors
36
- @_errors_cache ||= begin
37
- errors = super
38
-
39
- if exists?
40
- begin
41
- Sass.compile(source_path, style: :compressed, logger: Sass::Logger.silent).css
42
- rescue => e
43
- errors << e.message
44
- end
45
- end
46
-
47
- errors
48
- end
49
- end
50
-
51
- def debug(message, options)
52
- warn(message, debug)
53
- end
54
-
55
- def warn(message, options)
56
- pastel = Pastel.new
57
-
58
- line = options.span.start.line + 1
59
- start_index = options.span.start.column
60
- end_index = options.span.end.column
61
-
62
- @warnings << <<~WARNING
63
- #{pastel.yellow.bold("Warning")}: #{message}
64
-
65
- #{" " * line.to_s.size} #{pastel.blue("╷")}
66
- #{pastel.blue(line)} #{pastel.blue("│")} #{pastel.red(options.span.context.strip)}
67
- #{" " * line.to_s.size} #{pastel.blue("│")} #{" " * start_index}#{pastel.red("^" * (end_index - start_index))}
68
- #{" " * line.to_s.size} #{pastel.blue("╵")}
69
-
70
- #{options.stack}
71
- WARNING
72
- end
73
-
74
- def warnings
75
- if valid?
76
- Sass.compile(source_path, style: :compressed, logger: self)
77
- end
78
-
79
- @warnings
80
- end
81
- end
82
- end
83
- end