staticz 1.0.10 → 1.0.12
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/lib/builder.rb +7 -5
- data/lib/commands/base_command.rb +33 -0
- data/lib/commands/build_command.rb +108 -0
- data/lib/commands/manifest_command.rb +37 -0
- data/lib/commands/new_command.rb +41 -0
- data/lib/commands/server_command.rb +61 -0
- data/lib/manifest/compilable/cs.rb +12 -8
- data/lib/manifest/compilable/haml.rb +8 -7
- data/lib/manifest/compilable/js.rb +13 -7
- data/lib/manifest/compilable/react.rb +12 -8
- data/lib/manifest/compilable/sass.rb +12 -8
- data/lib/manifest/compilable/scss.rb +12 -8
- data/lib/manifest/compilable/simple_file.rb +9 -3
- data/lib/manifest/compilable.rb +25 -2
- data/lib/manifest/css_bundle.rb +91 -0
- data/lib/manifest/js_bundle.rb +95 -0
- data/lib/manifest/manifest.rb +24 -2
- data/lib/manifest/sub.rb +24 -4
- data/lib/server.rb +7 -4
- data/lib/settings.rb +16 -0
- data/lib/staticz.rb +19 -37
- data/lib/template.rb +2 -0
- metadata +38 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 514a1a85d3b4dfaa09b9f9b193e8e7e8d6ab5932233ddc23e28982c0b9bd33b4
         | 
| 4 | 
            +
              data.tar.gz: 6ed2e3c26f0e82a78fa3669aa0ce0d1753875d8e27d71b07ccacd54092b08dfd
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ded82ed2f8c9af219f81624e7210537d88dd0ee0f0d3188d50a2616f29e4473f2866b10b9b057d41cab6e63e54849365aae1480b86ec5301910dacc6cd340a6b
         | 
| 7 | 
            +
              data.tar.gz: 33ee4a79b001ede15aa7fcb05ecbede3e8edd30c099eb82798f0da3ed4070424ea5789136389682e2c92149abe3da713e57e7e6be16aefb732e444579e65d9af
         | 
    
        data/lib/builder.rb
    CHANGED
    
    | @@ -1,19 +1,21 @@ | |
| 1 | 
            +
            require "tty-spinner"
         | 
| 1 2 | 
             
            require_relative "modules/lib_loader"
         | 
| 3 | 
            +
            require_relative "manifest/manifest"
         | 
| 2 4 |  | 
| 3 5 | 
             
            module Staticz
         | 
| 4 6 | 
             
              class Builder
         | 
| 5 | 
            -
                def initialize
         | 
| 6 | 
            -
                   | 
| 7 | 
            +
                def initialize(listener_class: nil)
         | 
| 8 | 
            +
                  @listener_class = listener_class
         | 
| 7 9 | 
             
                end
         | 
| 8 10 |  | 
| 9 | 
            -
                private
         | 
| 10 | 
            -
             | 
| 11 11 | 
             
                def build
         | 
| 12 12 | 
             
                  Staticz::Modules::LibLoader.load_files
         | 
| 13 13 |  | 
| 14 14 | 
             
                  Dir.mkdir('build') unless File.exist?('build')
         | 
| 15 15 |  | 
| 16 | 
            -
                  Staticz::Manifest.instance.build
         | 
| 16 | 
            +
                  Staticz::Manifest.instance.build(listener_class: @listener_class)
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  Staticz::Manifest.instance.valid?
         | 
| 17 19 | 
             
                end
         | 
| 18 20 | 
             
              end
         | 
| 19 21 | 
             
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            require "tty-option"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Staticz
         | 
| 4 | 
            +
              class BaseCommand
         | 
| 5 | 
            +
                include TTY::Option
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                usage do
         | 
| 8 | 
            +
                  program "staticz"
         | 
| 9 | 
            +
                  no_command
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  description "Staticz helps create static websites",
         | 
| 12 | 
            +
                    "\nCommands:",
         | 
| 13 | 
            +
                    "  staticz new - Create a new project",
         | 
| 14 | 
            +
                    "  staticz server - Run the development server",
         | 
| 15 | 
            +
                    "  staticz manifest - Print out all files and how they will be built",
         | 
| 16 | 
            +
                    "  staticz build - Compile the project"
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                argument :mode do
         | 
| 20 | 
            +
                  desc "[new server manifest build]"
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                flag :help do
         | 
| 24 | 
            +
                  short "-h"
         | 
| 25 | 
            +
                  long "--help"
         | 
| 26 | 
            +
                  desc "Print this page"
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                def run
         | 
| 30 | 
            +
                  print help
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
| @@ -0,0 +1,108 @@ | |
| 1 | 
            +
            require "tty-option"
         | 
| 2 | 
            +
            require_relative "../settings"
         | 
| 3 | 
            +
            require_relative "../builder"
         | 
| 4 | 
            +
            require_relative "../utils/colors"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            module Staticz
         | 
| 7 | 
            +
              class BuildCommand
         | 
| 8 | 
            +
                include TTY::Option
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                usage do
         | 
| 11 | 
            +
                  program "staticz"
         | 
| 12 | 
            +
                  command "build"
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  description "Compile the project"
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                flag :verbose do
         | 
| 18 | 
            +
                  short "-v"
         | 
| 19 | 
            +
                  long "--verbose"
         | 
| 20 | 
            +
                  desc "Use verbose output"
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                flag :help do
         | 
| 24 | 
            +
                  short "-h"
         | 
| 25 | 
            +
                  long "--help"
         | 
| 26 | 
            +
                  desc "Print this page"
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                option :environment do
         | 
| 30 | 
            +
                  desc "Set the environment"
         | 
| 31 | 
            +
                  short "-e"
         | 
| 32 | 
            +
                  long "--environment environment"
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  default :production
         | 
| 35 | 
            +
                  permit [:development, :production]
         | 
| 36 | 
            +
                  convert :symbol
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                def run
         | 
| 40 | 
            +
                  if params[:help]
         | 
| 41 | 
            +
                    print help
         | 
| 42 | 
            +
                    exit
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  if !params[:environment]
         | 
| 46 | 
            +
                    puts "Environment must either be development or production"
         | 
| 47 | 
            +
                    exit 1
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                  if params[:verbose]
         | 
| 51 | 
            +
                    Staticz::Settings.verbose!
         | 
| 52 | 
            +
                  end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                  Staticz::Settings.set_environment(params[:environment])
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                  result = Staticz::Builder.new(listener_class: BuildListener).build
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                  if result.flatten.include? false
         | 
| 59 | 
            +
                    exit 1
         | 
| 60 | 
            +
                  end
         | 
| 61 | 
            +
                end
         | 
| 62 | 
            +
              end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
              class BuildListener
         | 
| 65 | 
            +
                def initialize(compilable)
         | 
| 66 | 
            +
                  @compilable = compilable
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                  if Staticz::Settings.verbose?
         | 
| 69 | 
            +
                    puts "Compiling #{generate_text}"
         | 
| 70 | 
            +
                  else
         | 
| 71 | 
            +
                    @spinner = TTY::Spinner.new(
         | 
| 72 | 
            +
                      "[:spinner] #{generate_text}",
         | 
| 73 | 
            +
                      format: :classic,
         | 
| 74 | 
            +
                      success_mark: Colors.in_green("✔"),
         | 
| 75 | 
            +
                      error_mark: Colors.in_red("✖")
         | 
| 76 | 
            +
                    )
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                    @spinner.auto_spin
         | 
| 79 | 
            +
                  end
         | 
| 80 | 
            +
                end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                def finish
         | 
| 83 | 
            +
                  @spinner.success(Colors.in_green("(successful)")) if !Staticz::Settings.verbose?
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                def error
         | 
| 87 | 
            +
                  if Staticz::Settings.verbose?
         | 
| 88 | 
            +
                    puts Colors.in_red("Error:")
         | 
| 89 | 
            +
                  else
         | 
| 90 | 
            +
                    @spinner.error(Colors.in_red("(error)"))
         | 
| 91 | 
            +
                  end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                  @compilable.errors.each do |error|
         | 
| 94 | 
            +
                    puts Colors.in_red(error)
         | 
| 95 | 
            +
                  end
         | 
| 96 | 
            +
                end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                private
         | 
| 99 | 
            +
             | 
| 100 | 
            +
                def generate_text
         | 
| 101 | 
            +
                  if @compilable.is_a? Staticz::JSBundle
         | 
| 102 | 
            +
                    @compilable.name
         | 
| 103 | 
            +
                  else
         | 
| 104 | 
            +
                    "#{@compilable.source_path} -> #{@compilable.build_path}"
         | 
| 105 | 
            +
                  end
         | 
| 106 | 
            +
                end
         | 
| 107 | 
            +
              end
         | 
| 108 | 
            +
            end
         | 
| @@ -0,0 +1,37 @@ | |
| 1 | 
            +
            require "tty-option"
         | 
| 2 | 
            +
            require_relative "../settings"
         | 
| 3 | 
            +
            require_relative "../modules/lib_loader"
         | 
| 4 | 
            +
            require_relative "../manifest/manifest"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            module Staticz
         | 
| 7 | 
            +
              class ManifestCommand
         | 
| 8 | 
            +
                include TTY::Option
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                usage do
         | 
| 11 | 
            +
                  program "staticz"
         | 
| 12 | 
            +
                  command "manifest"
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  description "Print out all files and how they will be built"
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                flag :help do
         | 
| 18 | 
            +
                  short "-h"
         | 
| 19 | 
            +
                  long "--help"
         | 
| 20 | 
            +
                  desc "Print this page"
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                def run
         | 
| 24 | 
            +
                  if params[:help]
         | 
| 25 | 
            +
                    print help
         | 
| 26 | 
            +
                  else
         | 
| 27 | 
            +
                    Staticz::Settings.development!
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                    load "#{Dir.pwd}/manifest.rb"
         | 
| 30 | 
            +
                    Staticz::Modules::LibLoader.load_files
         | 
| 31 | 
            +
                    Staticz::Manifest.instance.create_link_functions
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                    Staticz::Manifest.instance.print
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
| @@ -0,0 +1,41 @@ | |
| 1 | 
            +
            require "tty-option"
         | 
| 2 | 
            +
            require_relative "../template"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module Staticz
         | 
| 5 | 
            +
              class NewCommand
         | 
| 6 | 
            +
                include TTY::Option
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                usage do
         | 
| 9 | 
            +
                  program "staticz"
         | 
| 10 | 
            +
                  command "staticz"
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  description "Create a new project"
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                argument :name do
         | 
| 16 | 
            +
                  required
         | 
| 17 | 
            +
                  desc "testies"
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                flag :help do
         | 
| 21 | 
            +
                  short "-h"
         | 
| 22 | 
            +
                  long "--help"
         | 
| 23 | 
            +
                  desc "Print this page"
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                def run
         | 
| 27 | 
            +
                  if params[:help]
         | 
| 28 | 
            +
                    print help
         | 
| 29 | 
            +
                    exit 1
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  if !params[:name]
         | 
| 33 | 
            +
                    puts "Name missing"
         | 
| 34 | 
            +
                    print help
         | 
| 35 | 
            +
                    exit 1
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                  Staticz::Template.new(params[:name])
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
            end
         | 
| @@ -0,0 +1,61 @@ | |
| 1 | 
            +
            require "tty-option"
         | 
| 2 | 
            +
            require_relative "../settings"
         | 
| 3 | 
            +
            require_relative "../server"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Staticz
         | 
| 6 | 
            +
              class ServerCommand
         | 
| 7 | 
            +
                include TTY::Option
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                usage do
         | 
| 10 | 
            +
                  program "staticz"
         | 
| 11 | 
            +
                  command "server"
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  description "Run the development server"
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                flag :help do
         | 
| 17 | 
            +
                  short "-h"
         | 
| 18 | 
            +
                  long "--help"
         | 
| 19 | 
            +
                  desc "Print this page"
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                option :port do
         | 
| 23 | 
            +
                  desc "Define the port used for the webserver"
         | 
| 24 | 
            +
                  short "-p"
         | 
| 25 | 
            +
                  long "--port port"
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  default 3000
         | 
| 28 | 
            +
                  convert :integer
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                option :environment do
         | 
| 32 | 
            +
                  desc "Set the environment"
         | 
| 33 | 
            +
                  short "-e"
         | 
| 34 | 
            +
                  long "--environment environment"
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  default :development
         | 
| 37 | 
            +
                  permit [:development, :production]
         | 
| 38 | 
            +
                  convert :symbol
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                def run
         | 
| 42 | 
            +
                  if params[:help]
         | 
| 43 | 
            +
                    print help
         | 
| 44 | 
            +
                    exit
         | 
| 45 | 
            +
                  end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  if !params[:port]
         | 
| 48 | 
            +
                    puts "A given port must be an integer"
         | 
| 49 | 
            +
                    exit 1
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  if !params[:environment]
         | 
| 53 | 
            +
                    puts "Environment must either be development or production"
         | 
| 54 | 
            +
                    exit 1
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                  Staticz::Settings.set_environment(params[:environment])
         | 
| 58 | 
            +
                  Staticz::Server.new(params[:port])
         | 
| 59 | 
            +
                end
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
            end
         | 
| @@ -8,23 +8,27 @@ 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
         | 
| 19 15 | 
             
                  end
         | 
| 20 16 |  | 
| 21 | 
            -
                  def build
         | 
| 17 | 
            +
                  def build(listener_class: nil)
         | 
| 18 | 
            +
                    listener = listener_class&.new(self)
         | 
| 19 | 
            +
             | 
| 22 20 | 
             
                    if exists?
         | 
| 23 | 
            -
                       | 
| 21 | 
            +
                      File.write build_path, render
         | 
| 24 22 |  | 
| 25 | 
            -
                       | 
| 23 | 
            +
                      listener&.finish
         | 
| 24 | 
            +
                    else
         | 
| 25 | 
            +
                      listener&.error
         | 
| 26 26 | 
             
                    end
         | 
| 27 27 | 
             
                  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  def render
         | 
| 30 | 
            +
                    CoffeeScript.compile File.read(source_path)
         | 
| 31 | 
            +
                  end
         | 
| 28 32 | 
             
                end
         | 
| 29 33 | 
             
              end
         | 
| 30 34 | 
             
            end
         | 
| @@ -8,11 +8,7 @@ module Staticz | |
| 8 8 |  | 
| 9 9 | 
             
                  attr_reader :name
         | 
| 10 10 |  | 
| 11 | 
            -
                   | 
| 12 | 
            -
             | 
| 13 | 
            -
                  def build_file_ending = "html"
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                  def tile_type_name = "Haml"
         | 
| 11 | 
            +
                  compile "haml", "html", "Haml"
         | 
| 16 12 |  | 
| 17 13 | 
             
                  def initialize(name)
         | 
| 18 14 | 
             
                    @name = name
         | 
| @@ -33,11 +29,16 @@ module Staticz | |
| 33 29 | 
             
                    errors
         | 
| 34 30 | 
             
                  end
         | 
| 35 31 |  | 
| 36 | 
            -
                  def build
         | 
| 32 | 
            +
                  def build(listener_class: nil)
         | 
| 33 | 
            +
                    listener = listener_class&.new(self)
         | 
| 34 | 
            +
             | 
| 37 35 | 
             
                    if valid?
         | 
| 38 36 | 
             
                      engine = ::Haml::Engine.new(File.read(source_path))
         | 
| 39 | 
            -
             | 
| 40 37 | 
             
                      File.write build_path, engine.render
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                      listener&.finish
         | 
| 40 | 
            +
                    else
         | 
| 41 | 
            +
                      listener&.error
         | 
| 41 42 | 
             
                    end
         | 
| 42 43 | 
             
                  end
         | 
| 43 44 | 
             
                end
         | 
| @@ -7,21 +7,27 @@ 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
         | 
| 18 14 | 
             
                  end
         | 
| 19 15 |  | 
| 20 | 
            -
                  def build
         | 
| 16 | 
            +
                  def build(listener_class: nil)
         | 
| 17 | 
            +
                    listener = listener_class&.new(self)
         | 
| 18 | 
            +
             | 
| 21 19 | 
             
                    if exists?
         | 
| 22 | 
            -
                      File.write build_path,  | 
| 20 | 
            +
                      File.write build_path, render
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                      listener&.finish
         | 
| 23 | 
            +
                    else
         | 
| 24 | 
            +
                      listener&.error
         | 
| 23 25 | 
             
                    end
         | 
| 24 26 | 
             
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  def render
         | 
| 29 | 
            +
                    File.read(source_path)
         | 
| 30 | 
            +
                  end
         | 
| 25 31 | 
             
                end
         | 
| 26 32 | 
             
              end
         | 
| 27 33 | 
             
            end
         | 
| @@ -8,23 +8,27 @@ 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
         | 
| 19 15 | 
             
                  end
         | 
| 20 16 |  | 
| 21 | 
            -
                  def build
         | 
| 17 | 
            +
                  def build(listener_class: nil)
         | 
| 18 | 
            +
                    listener = listener_class&.new(self)
         | 
| 19 | 
            +
             | 
| 22 20 | 
             
                    if exists?
         | 
| 23 | 
            -
                       | 
| 21 | 
            +
                      File.write build_path, render
         | 
| 24 22 |  | 
| 25 | 
            -
                       | 
| 23 | 
            +
                      listener&.finish
         | 
| 24 | 
            +
                    else
         | 
| 25 | 
            +
                      listener&.error
         | 
| 26 26 | 
             
                    end
         | 
| 27 27 | 
             
                  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  def render
         | 
| 30 | 
            +
                    Babel::Transpiler.transform(File.read(source_path))["code"]
         | 
| 31 | 
            +
                  end
         | 
| 28 32 | 
             
                end
         | 
| 29 33 | 
             
              end
         | 
| 30 34 | 
             
            end
         | 
| @@ -8,24 +8,28 @@ 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
         | 
| 19 15 | 
             
                  end
         | 
| 20 16 |  | 
| 21 | 
            -
                  def build
         | 
| 17 | 
            +
                  def build(listener_class: nil)
         | 
| 18 | 
            +
                    listener = listener_class&.new(self)
         | 
| 19 | 
            +
             | 
| 22 20 | 
             
                    if valid?
         | 
| 23 | 
            -
                       | 
| 21 | 
            +
                      File.write build_path, render
         | 
| 24 22 |  | 
| 25 | 
            -
                       | 
| 23 | 
            +
                      listener&.finish
         | 
| 24 | 
            +
                    else
         | 
| 25 | 
            +
                      listener&.error
         | 
| 26 26 | 
             
                    end
         | 
| 27 27 | 
             
                  end
         | 
| 28 28 |  | 
| 29 | 
            +
                  def render
         | 
| 30 | 
            +
                    ::SassC::Engine.new(File.read(source_path), syntax: :sass, style: :compressed).render
         | 
| 31 | 
            +
                  end
         | 
| 32 | 
            +
             | 
| 29 33 | 
             
                  def errors
         | 
| 30 34 | 
             
                    errors = super
         | 
| 31 35 |  | 
| @@ -8,24 +8,28 @@ 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
         | 
| 19 15 | 
             
                  end
         | 
| 20 16 |  | 
| 21 | 
            -
                  def build
         | 
| 17 | 
            +
                  def build(listener_class: nil)
         | 
| 18 | 
            +
                    listener = listener_class&.new(self)
         | 
| 19 | 
            +
             | 
| 22 20 | 
             
                    if valid?
         | 
| 23 | 
            -
                       | 
| 21 | 
            +
                      File.write build_path, render
         | 
| 24 22 |  | 
| 25 | 
            -
                       | 
| 23 | 
            +
                      listener&.finish
         | 
| 24 | 
            +
                    else
         | 
| 25 | 
            +
                      listener&.error
         | 
| 26 26 | 
             
                    end
         | 
| 27 27 | 
             
                  end
         | 
| 28 28 |  | 
| 29 | 
            +
                  def render
         | 
| 30 | 
            +
                    ::SassC::Engine.new(File.read(source_path), syntax: :scss, style: :compressed).render
         | 
| 31 | 
            +
                  end
         | 
| 32 | 
            +
             | 
| 29 33 | 
             
                  def errors
         | 
| 30 34 | 
             
                    errors = super
         | 
| 31 35 |  | 
| @@ -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
         | 
| @@ -20,15 +22,19 @@ module Staticz | |
| 20 22 | 
             
                    Object.send(:define_method, path_method_name) { link_path }
         | 
| 21 23 | 
             
                  end
         | 
| 22 24 |  | 
| 23 | 
            -
                  def tile_type_name = "File"
         | 
| 24 | 
            -
             | 
| 25 25 | 
             
                  def initialize(name)
         | 
| 26 26 | 
             
                    @name = name
         | 
| 27 27 | 
             
                  end
         | 
| 28 28 |  | 
| 29 | 
            -
                  def build
         | 
| 29 | 
            +
                  def build(listener_class: nil)
         | 
| 30 | 
            +
                    listener = listener_class&.new(self)
         | 
| 31 | 
            +
             | 
| 30 32 | 
             
                    if exists?
         | 
| 31 33 | 
             
                      File.write build_path, File.read(source_path)
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                      listener&.finish
         | 
| 36 | 
            +
                    else
         | 
| 37 | 
            +
                      listener&.error
         | 
| 32 38 | 
             
                    end
         | 
| 33 39 | 
             
                  end
         | 
| 34 40 | 
             
                end
         | 
    
        data/lib/manifest/compilable.rb
    CHANGED
    
    | @@ -1,7 +1,27 @@ | |
| 1 1 | 
             
            require "io/console"
         | 
| 2 | 
            +
            require_relative "../utils/colors"
         | 
| 2 3 |  | 
| 3 4 | 
             
            module Staticz
         | 
| 4 5 | 
             
              module Compilable
         | 
| 6 | 
            +
                def self.included(base)
         | 
| 7 | 
            +
                  base.extend(ClassMethods)
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
                module ClassMethods
         | 
| 10 | 
            +
                  def compile(source_file_ending, build_file_ending, file_type_name)
         | 
| 11 | 
            +
                    define_method :source_file_ending do
         | 
| 12 | 
            +
                      source_file_ending
         | 
| 13 | 
            +
                    end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                    define_method :build_file_ending do
         | 
| 16 | 
            +
                      build_file_ending
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    define_method :file_type_name do
         | 
| 20 | 
            +
                      file_type_name
         | 
| 21 | 
            +
                    end
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 5 25 | 
             
                def path
         | 
| 6 26 | 
             
                  name.to_s
         | 
| 7 27 | 
             
                end
         | 
| @@ -46,14 +66,17 @@ module Staticz | |
| 46 66 | 
             
                  end
         | 
| 47 67 | 
             
                end
         | 
| 48 68 |  | 
| 49 | 
            -
                def print(indentation)
         | 
| 69 | 
            +
                def print(indentation, *args)
         | 
| 50 70 | 
             
                  valid_symbol = if valid?
         | 
| 51 71 | 
             
                    Colors.in_green("✔")
         | 
| 52 72 | 
             
                  else
         | 
| 53 73 | 
             
                    Colors.in_red("✘")
         | 
| 54 74 | 
             
                  end
         | 
| 55 75 |  | 
| 56 | 
            -
                   | 
| 76 | 
            +
                  compilable_string = "#{" " * (indentation * 3)}└─ #{file_type_name}: #{path} #{valid_symbol}"
         | 
| 77 | 
            +
                  compilable_string << " -> #{path_method_name}" if !args.include? :no_path
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                  puts compilable_string
         | 
| 57 80 |  | 
| 58 81 | 
             
                  _height, width = IO.console.winsize
         | 
| 59 82 |  | 
| @@ -0,0 +1,91 @@ | |
| 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(listener_class: nil)
         | 
| 36 | 
            +
                  listener = listener_class&.new(self)
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                  File.write "build/#{name}_bundle.css", render
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  listener&.finish
         | 
| 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(/[.\/-]/, "_")}_css_bundle_path"
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                def create_link_function
         | 
| 67 | 
            +
                  link_path = "/#{name}_bundle.css"
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                  Object.send(:define_method, path_method_name) do
         | 
| 70 | 
            +
                    link_path
         | 
| 71 | 
            +
                  end
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                def valid?
         | 
| 75 | 
            +
                  elements.map do |e|
         | 
| 76 | 
            +
                    e.valid?
         | 
| 77 | 
            +
                  end
         | 
| 78 | 
            +
                end
         | 
| 79 | 
            +
             | 
| 80 | 
            +
                def print(indentation)
         | 
| 81 | 
            +
                  puts "#{" " * (indentation * 3)}└─ CSSBundle: #{name} -> #{path_method_name}"
         | 
| 82 | 
            +
                  elements.each do |e|
         | 
| 83 | 
            +
                    e.print(indentation + 1, :no_path)
         | 
| 84 | 
            +
                  end
         | 
| 85 | 
            +
                end
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                def path
         | 
| 88 | 
            +
                  "src/#{name}"
         | 
| 89 | 
            +
                end
         | 
| 90 | 
            +
              end
         | 
| 91 | 
            +
            end
         | 
| @@ -0,0 +1,95 @@ | |
| 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(listener_class: nil)
         | 
| 40 | 
            +
                  listener = listener_class&.new(self)
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                  File.write "build/#{name}_bundle.js", render
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  listener&.finish
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                def render
         | 
| 48 | 
            +
                  render_elements elements
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                def render_elements(elements)
         | 
| 52 | 
            +
                  elements
         | 
| 53 | 
            +
                    .map do |element|
         | 
| 54 | 
            +
                      if element.is_a? Staticz::Sub
         | 
| 55 | 
            +
                        render_elements element.elements
         | 
| 56 | 
            +
                      else
         | 
| 57 | 
            +
                        [
         | 
| 58 | 
            +
                          "// #{element.name}",
         | 
| 59 | 
            +
                          element.render
         | 
| 60 | 
            +
                        ].join("\n\n")
         | 
| 61 | 
            +
                      end
         | 
| 62 | 
            +
                    end
         | 
| 63 | 
            +
                    .join("\n\n")
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                def path_method_name
         | 
| 67 | 
            +
                  "#{name.to_s.gsub(/[.\/-]/, "_")}_js_bundle_path"
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                def create_link_function
         | 
| 71 | 
            +
                  link_path = "/#{name}_bundle.js"
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                  Object.send(:define_method, path_method_name) do
         | 
| 74 | 
            +
                    link_path
         | 
| 75 | 
            +
                  end
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                def valid?
         | 
| 79 | 
            +
                  elements.map do |e|
         | 
| 80 | 
            +
                    e.valid?
         | 
| 81 | 
            +
                  end
         | 
| 82 | 
            +
                end
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                def print(indentation)
         | 
| 85 | 
            +
                  puts "#{" " * (indentation * 3)}└─ JSBundle: #{name} -> #{path_method_name}"
         | 
| 86 | 
            +
                  elements.each do |e|
         | 
| 87 | 
            +
                    e.print(indentation + 1, :no_path)
         | 
| 88 | 
            +
                  end
         | 
| 89 | 
            +
                end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                def path
         | 
| 92 | 
            +
                  "src/#{name}"
         | 
| 93 | 
            +
                end
         | 
| 94 | 
            +
              end
         | 
| 95 | 
            +
            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,13 +55,27 @@ module Staticz | |
| 53 55 | 
             
                  elements.push(Staticz::Compilable::SimpleFile.new(name))
         | 
| 54 56 | 
             
                end
         | 
| 55 57 |  | 
| 56 | 
            -
                def  | 
| 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 | 
            +
             | 
| 72 | 
            +
                def build(listener_class: nil)
         | 
| 57 73 | 
             
                  load "#{Dir.pwd}/manifest.rb"
         | 
| 58 74 |  | 
| 59 75 | 
             
                  create_link_functions
         | 
| 60 76 |  | 
| 61 77 | 
             
                  elements.each do |e|
         | 
| 62 | 
            -
                    e.build
         | 
| 78 | 
            +
                    e.build(listener_class: listener_class)
         | 
| 63 79 | 
             
                  end
         | 
| 64 80 | 
             
                end
         | 
| 65 81 |  | 
| @@ -69,6 +85,12 @@ module Staticz | |
| 69 85 | 
             
                  end
         | 
| 70 86 | 
             
                end
         | 
| 71 87 |  | 
| 88 | 
            +
                def valid?
         | 
| 89 | 
            +
                  elements.map do |e|
         | 
| 90 | 
            +
                    e.valid?
         | 
| 91 | 
            +
                  end
         | 
| 92 | 
            +
                end
         | 
| 93 | 
            +
             | 
| 72 94 | 
             
                def self.define(&block)
         | 
| 73 95 | 
             
                  Staticz::Manifest.instance.define(block)
         | 
| 74 96 | 
             
                end
         | 
    
        data/lib/manifest/sub.rb
    CHANGED
    
    | @@ -41,11 +41,25 @@ module Staticz | |
| 41 41 | 
             
                  elements.push(Staticz::Compilable::SimpleFile.new("#{@name}/#{name}"))
         | 
| 42 42 | 
             
                end
         | 
| 43 43 |  | 
| 44 | 
            -
                def  | 
| 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 | 
            +
             | 
| 58 | 
            +
                def build(listener_class: nil)
         | 
| 45 59 | 
             
                  Dir.mkdir("build/#{name}") if !Dir.exist?("build/#{name}")
         | 
| 46 60 |  | 
| 47 61 | 
             
                  elements.each do |e|
         | 
| 48 | 
            -
                    e.build
         | 
| 62 | 
            +
                    e.build(listener_class: listener_class)
         | 
| 49 63 | 
             
                  end
         | 
| 50 64 | 
             
                end
         | 
| 51 65 |  | 
| @@ -55,10 +69,16 @@ module Staticz | |
| 55 69 | 
             
                  end
         | 
| 56 70 | 
             
                end
         | 
| 57 71 |  | 
| 58 | 
            -
                def  | 
| 72 | 
            +
                def valid?
         | 
| 73 | 
            +
                  elements.map do |e|
         | 
| 74 | 
            +
                    e.valid?
         | 
| 75 | 
            +
                  end
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                def print(indentation, *args)
         | 
| 59 79 | 
             
                  puts "#{" " * (indentation * 3)}└─ Sub: #{name}"
         | 
| 60 80 | 
             
                  elements.each do |e|
         | 
| 61 | 
            -
                    e.print(indentation + 1)
         | 
| 81 | 
            +
                    e.print(indentation + 1, *args)
         | 
| 62 82 | 
             
                  end
         | 
| 63 83 | 
             
                end
         | 
| 64 84 |  | 
    
        data/lib/server.rb
    CHANGED
    
    | @@ -1,13 +1,16 @@ | |
| 1 1 | 
             
            require "thin"
         | 
| 2 2 | 
             
            require "listen"
         | 
| 3 3 | 
             
            require "io/console"
         | 
| 4 | 
            -
             | 
| 5 4 | 
             
            require_relative "manifest/manifest"
         | 
| 6 5 | 
             
            require_relative "modules/reload"
         | 
| 6 | 
            +
            require_relative "builder"
         | 
| 7 | 
            +
            require_relative "utils/helpers"
         | 
| 7 8 |  | 
| 8 9 | 
             
            module Staticz
         | 
| 9 10 | 
             
              class Server
         | 
| 10 | 
            -
                def initialize
         | 
| 11 | 
            +
                def initialize(port)
         | 
| 12 | 
            +
                  @port = port
         | 
| 13 | 
            +
             | 
| 11 14 | 
             
                  Thin::Logging.silent = true
         | 
| 12 15 |  | 
| 13 16 | 
             
                  app = Rack::Builder.new do
         | 
| @@ -40,7 +43,7 @@ module Staticz | |
| 40 43 | 
             
                    end
         | 
| 41 44 | 
             
                  end
         | 
| 42 45 |  | 
| 43 | 
            -
                  thin_server = Thin::Server.new '127.0.0.1',  | 
| 46 | 
            +
                  thin_server = Thin::Server.new '127.0.0.1', port
         | 
| 44 47 | 
             
                  thin_server.app = app
         | 
| 45 48 |  | 
| 46 49 | 
             
                  build_manifest
         | 
| @@ -95,7 +98,7 @@ module Staticz | |
| 95 98 | 
             
                end
         | 
| 96 99 |  | 
| 97 100 | 
             
                def build_manifest
         | 
| 98 | 
            -
                  Staticz::Builder.new
         | 
| 101 | 
            +
                  Staticz::Builder.new.build
         | 
| 99 102 | 
             
                  Staticz::Manifest.instance.print
         | 
| 100 103 |  | 
| 101 104 | 
             
                  Staticz::Modules::Reload.generate_hash
         | 
    
        data/lib/settings.rb
    CHANGED
    
    | @@ -1,5 +1,9 @@ | |
| 1 1 | 
             
            module Staticz
         | 
| 2 2 | 
             
              class Settings
         | 
| 3 | 
            +
                def self.set_environment(environment)
         | 
| 4 | 
            +
                  @@env = environment
         | 
| 5 | 
            +
                end
         | 
| 6 | 
            +
             | 
| 3 7 | 
             
                def self.development!
         | 
| 4 8 | 
             
                  @@env = :development
         | 
| 5 9 | 
             
                end
         | 
| @@ -15,6 +19,18 @@ module Staticz | |
| 15 19 | 
             
                def self.production?
         | 
| 16 20 | 
             
                  @@env == :production
         | 
| 17 21 | 
             
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                def self.verbose!
         | 
| 24 | 
            +
                  @@verbose = true
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                def self.verbose?
         | 
| 28 | 
            +
                  if defined? @@verbose
         | 
| 29 | 
            +
                    @@verbose == true
         | 
| 30 | 
            +
                  else
         | 
| 31 | 
            +
                    false
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                end
         | 
| 18 34 | 
             
              end
         | 
| 19 35 | 
             
            end
         | 
| 20 36 |  | 
    
        data/lib/staticz.rb
    CHANGED
    
    | @@ -1,44 +1,26 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
            require_relative " | 
| 3 | 
            -
            require_relative " | 
| 4 | 
            -
            require_relative " | 
| 5 | 
            -
            require_relative " | 
| 6 | 
            -
            require_relative " | 
| 1 | 
            +
            require "tty-option"
         | 
| 2 | 
            +
            require_relative "commands/base_command"
         | 
| 3 | 
            +
            require_relative "commands/new_command"
         | 
| 4 | 
            +
            require_relative "commands/server_command"
         | 
| 5 | 
            +
            require_relative "commands/manifest_command"
         | 
| 6 | 
            +
            require_relative "commands/build_command"
         | 
| 7 7 |  | 
| 8 8 | 
             
            module Staticz
         | 
| 9 9 | 
             
              def self.init
         | 
| 10 | 
            -
                 | 
| 11 | 
            -
             | 
| 12 | 
            -
                   | 
| 13 | 
            -
             | 
| 14 | 
            -
                   | 
| 15 | 
            -
             | 
| 16 | 
            -
                   | 
| 17 | 
            -
                 | 
| 18 | 
            -
             | 
| 19 | 
            -
                case ARGV[0]
         | 
| 20 | 
            -
                when 'new'
         | 
| 21 | 
            -
                  if ARGV[1]
         | 
| 22 | 
            -
                    Staticz::Template.new(ARGV[1])
         | 
| 23 | 
            -
                  else
         | 
| 24 | 
            -
                    puts usage
         | 
| 25 | 
            -
                  end
         | 
| 26 | 
            -
                when 'server'
         | 
| 27 | 
            -
                  Staticz::Settings.development!
         | 
| 28 | 
            -
                  Staticz::Server.new
         | 
| 29 | 
            -
                when 'manifest'
         | 
| 30 | 
            -
                  Staticz::Settings.development!
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                  load "#{Dir.pwd}/manifest.rb"
         | 
| 33 | 
            -
                  Staticz::Modules::LibLoader.load_files
         | 
| 34 | 
            -
                  Staticz::Manifest.instance.create_link_functions
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                  Staticz::Manifest.instance.print
         | 
| 37 | 
            -
                when 'build'
         | 
| 38 | 
            -
                  Staticz::Settings.production!
         | 
| 39 | 
            -
                  Staticz::Builder.new
         | 
| 10 | 
            +
                cmd, args = case ARGV[0]
         | 
| 11 | 
            +
                when "new"
         | 
| 12 | 
            +
                  [Staticz::NewCommand.new, ARGV[1..]]
         | 
| 13 | 
            +
                when "server"
         | 
| 14 | 
            +
                  [Staticz::ServerCommand.new, ARGV[1..]]
         | 
| 15 | 
            +
                when "manifest"
         | 
| 16 | 
            +
                  [Staticz::ManifestCommand.new, ARGV[1..]]
         | 
| 17 | 
            +
                when "build"
         | 
| 18 | 
            +
                  [Staticz::BuildCommand.new, ARGV[1..]]
         | 
| 40 19 | 
             
                else
         | 
| 41 | 
            -
                   | 
| 20 | 
            +
                  [Staticz::BaseCommand.new, ARGV]
         | 
| 42 21 | 
             
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                cmd.parse args
         | 
| 24 | 
            +
                cmd.run
         | 
| 43 25 | 
             
              end
         | 
| 44 26 | 
             
            end
         | 
    
        data/lib/template.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.12
         | 
| 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-10-16 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: haml
         | 
| @@ -108,6 +108,34 @@ dependencies: | |
| 108 108 | 
             
                - - "~>"
         | 
| 109 109 | 
             
                  - !ruby/object:Gem::Version
         | 
| 110 110 | 
             
                    version: '0.7'
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            +
              name: tty-option
         | 
| 113 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - "~>"
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: '0.2'
         | 
| 118 | 
            +
              type: :runtime
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                requirements:
         | 
| 122 | 
            +
                - - "~>"
         | 
| 123 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            +
                    version: '0.2'
         | 
| 125 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            +
              name: tty-spinner
         | 
| 127 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 | 
            +
                requirements:
         | 
| 129 | 
            +
                - - '='
         | 
| 130 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            +
                    version: '0.9'
         | 
| 132 | 
            +
              type: :runtime
         | 
| 133 | 
            +
              prerelease: false
         | 
| 134 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 | 
            +
                requirements:
         | 
| 136 | 
            +
                - - '='
         | 
| 137 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 138 | 
            +
                    version: '0.9'
         | 
| 111 139 | 
             
            description: Create websites with haml and sass, and compile them into static html
         | 
| 112 140 | 
             
              and css
         | 
| 113 141 | 
             
            email:
         | 
| @@ -119,6 +147,11 @@ extra_rdoc_files: [] | |
| 119 147 | 
             
            files:
         | 
| 120 148 | 
             
            - bin/staticz
         | 
| 121 149 | 
             
            - lib/builder.rb
         | 
| 150 | 
            +
            - lib/commands/base_command.rb
         | 
| 151 | 
            +
            - lib/commands/build_command.rb
         | 
| 152 | 
            +
            - lib/commands/manifest_command.rb
         | 
| 153 | 
            +
            - lib/commands/new_command.rb
         | 
| 154 | 
            +
            - lib/commands/server_command.rb
         | 
| 122 155 | 
             
            - lib/manifest/compilable.rb
         | 
| 123 156 | 
             
            - lib/manifest/compilable/cs.rb
         | 
| 124 157 | 
             
            - lib/manifest/compilable/haml.rb
         | 
| @@ -127,6 +160,8 @@ files: | |
| 127 160 | 
             
            - lib/manifest/compilable/sass.rb
         | 
| 128 161 | 
             
            - lib/manifest/compilable/scss.rb
         | 
| 129 162 | 
             
            - lib/manifest/compilable/simple_file.rb
         | 
| 163 | 
            +
            - lib/manifest/css_bundle.rb
         | 
| 164 | 
            +
            - lib/manifest/js_bundle.rb
         | 
| 130 165 | 
             
            - lib/manifest/manifest.rb
         | 
| 131 166 | 
             
            - lib/manifest/sub.rb
         | 
| 132 167 | 
             
            - lib/modules/lib_loader.rb
         | 
| @@ -165,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 165 200 | 
             
                - !ruby/object:Gem::Version
         | 
| 166 201 | 
             
                  version: '0'
         | 
| 167 202 | 
             
            requirements: []
         | 
| 168 | 
            -
            rubygems_version: 3.3. | 
| 203 | 
            +
            rubygems_version: 3.3.7
         | 
| 169 204 | 
             
            signing_key:
         | 
| 170 205 | 
             
            specification_version: 4
         | 
| 171 206 | 
             
            summary: Static website compiler
         |