class DGD::Manifest::AppDirectory

Constants

DEFAULT_EMPTY_DIRS
DEFAULT_FILE_LOCATIONS

Attributes

location[R]
name[RW]

Public Class Methods

new(directory) click to toggle source
# File lib/dgd-tools/manifest.rb, line 431
def initialize(directory)
    @location = directory
end

Public Instance Methods

create!() click to toggle source
# File lib/dgd-tools/manifest.rb, line 490
def create!
    if File.exist?(@location) && (!File.directory?(@location) || Dir["#{@location}/**"].size != 0)
        raise "Cannot create a new DGD manifest project over a file or in an existing non-empty directory!"
    end

    puts "Creating new DGD manifest project at #{@location}..."
    FileUtils.mkdir_p @location
    Dir.chdir @location do
        DEFAULT_FILE_LOCATIONS.each do |file_desc, file_location|
            File.open(file_location, "wb") do |f|
                contents = send("#{file_desc}_contents")
                f.write(contents)
            end
        end

        DEFAULT_EMPTY_DIRS.each do |dir|
            FileUtils.mkdir dir
            FileUtils.touch File.join(dir, ".keep")
        end

        result = system "bundle"
        raise("Could not run bundler to install dgd-tools for #{@location}!") unless result

        result = system "bundle exec dgd-manifest install"
        raise("Error when running dgd-manifest for #{@location}!") unless result
    end

    puts "Successfully created project at #{@location}."
end
gems_rb_contents() click to toggle source
# File lib/dgd-tools/manifest.rb, line 482
        def gems_rb_contents
            <<~FILE_CONTENTS
                source "https://rubygems.org"

                gem "dgd-tools", ">= #{DGD::VERSION}"
            FILE_CONTENTS
        end
gitignore_contents() click to toggle source
# File lib/dgd-tools/manifest.rb, line 435
        def gitignore_contents
            <<~FILE_CONTENTS
                # DGD Manifest files
                .root
                dgd.config
                state/*
                wafer
                websocket-to-tcp-tunnel
                dgd
                log/*
                skotos.database
                skotos.database.old
                .repos/**
            FILE_CONTENTS
        end
manifest_contents() click to toggle source
# File lib/dgd-tools/manifest.rb, line 451
        def manifest_contents
            <<FILE_CONTENTS
{
    "name": "#{@name}",
    "version": "0.1.0",
    "description": "TODO: put description here",
    "app_root": "app",
    "goods": [
        "# This is an example goods file - substitute your own.",
        "https://raw.githubusercontent.com/ChatTheatre/dgd-tools/main/goods/skotos_httpd.goods"
    ],
    "unbundled_goods": [
        {
            "#": "this is an example of unbundled goods - substitute your own",
            "name": "kernellib",
            "git": {
                "url": "https://github.com/ChatTheatre/kernellib.git",
                "branch": "master"
            },
            "paths": {
                "src/doc/kernel": "doc/kernel",
                "src/include/kernel": "include/kernel",
                "src/include/*.h": "include",
                "src/kernel": "kernel"
            }
        }
    ]
}
FILE_CONTENTS
        end