dgd-tools 0.1.5 → 0.1.6
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/.gitignore +2 -0
- data/Gemfile.lock +1 -1
- data/exe/dgd-manifest +11 -0
- data/exe/skotos-xml-diff +11 -0
- data/lib/dgd-tools/manifest.rb +55 -42
- data/lib/dgd-tools/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f64aa1b29bc2fb6a0c10292a25246ce4fbe5a43b7fa23dc19a84ab01abc58013
|
4
|
+
data.tar.gz: 60fb058d6f25ca80348e5236450ed3c5fe812137d04e0fce237d36b6b252dfca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30b54b93e1b4e5da44c7cf0bc6e526dd489d74301df20cd4d9644c69aab509416d3082d2646dd6394331f81643a92cbc24933141fdca024057ed6e003866b37a
|
7
|
+
data.tar.gz: 525305f71a39842d01f7ce99f3bce1d85d7dc0e5493411e09759cf003a8632609130281f40ba8ff25bf7edb8ffa73de5e9b53d3c3022c4143a8b99be70a9c4f9
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/exe/dgd-manifest
CHANGED
@@ -11,6 +11,17 @@ if ARGV == ["--version"]
|
|
11
11
|
exit
|
12
12
|
end
|
13
13
|
|
14
|
+
if ARGV.size == 1 && ["-h", "--help"].include?(ARGV[0])
|
15
|
+
puts <<HELP_INFO
|
16
|
+
dgd-manifest commands:
|
17
|
+
|
18
|
+
new [project_name]: create a new DGD-manifest project
|
19
|
+
test: make sure the dgd.manifest file is well-formed and usable
|
20
|
+
install: compile the DGD application to a config file and a root directory
|
21
|
+
HELP_INFO
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
|
14
25
|
case ARGV[0]
|
15
26
|
when "new"
|
16
27
|
unless ARGV.size == 2
|
data/exe/skotos-xml-diff
CHANGED
@@ -6,6 +6,17 @@
|
|
6
6
|
|
7
7
|
require "dgd-tools/skotos_xml_obj"
|
8
8
|
|
9
|
+
if ARGV.size == 1 && ["-h", "--help"].include?(ARGV[0])
|
10
|
+
print <<HELP_INFO
|
11
|
+
skotos-xml-diff [file1] [file2]
|
12
|
+
|
13
|
+
OR
|
14
|
+
|
15
|
+
skotos-xml-diff [dir1] [dir2]
|
16
|
+
HELP_INFO
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
|
9
20
|
if ARGV.size != 2
|
10
21
|
STDERR.puts "Usage: skotos-xml-diff <obj_or_dir_1> <obj_or_dir_2>"
|
11
22
|
exit -1
|
data/lib/dgd-tools/manifest.rb
CHANGED
@@ -30,24 +30,26 @@ module DGD::Manifest
|
|
30
30
|
# This is a repo of everything DGD Manifest saves between runs.
|
31
31
|
# It includes downloaded Git repos, Goods files and more.
|
32
32
|
class Repo
|
33
|
-
attr_reader :
|
33
|
+
attr_reader :shared_dir
|
34
34
|
|
35
35
|
def initialize
|
36
|
+
@no_manifest_file = true
|
36
37
|
@home = ENV["HOME"]
|
37
|
-
@
|
38
|
-
Dir.mkdir(@
|
38
|
+
@shared_dir = "#{@home}/.dgd-tools"
|
39
|
+
Dir.mkdir(@shared_dir) unless File.directory?(@shared_dir)
|
40
|
+
|
39
41
|
["git", "goods"].each do |subdir|
|
40
|
-
full_subdir = "#{@
|
42
|
+
full_subdir = "#{@shared_dir}/#{subdir}"
|
41
43
|
Dir.mkdir(full_subdir) unless File.directory?(full_subdir)
|
42
44
|
end
|
43
45
|
|
44
|
-
unless File.exist?("#{@
|
45
|
-
dgd_dir = "#{@
|
46
|
+
unless File.exist?("#{@shared_dir}/dgd/bin/dgd")
|
47
|
+
dgd_dir = "#{@shared_dir}/dgd"
|
46
48
|
if File.directory?(dgd_dir)
|
47
49
|
# Not clear to me what to do here...
|
48
50
|
else
|
49
51
|
DGD::Manifest.system_call("git clone https://github.com/ChatTheatre/dgd.git #{dgd_dir}")
|
50
|
-
Dir.chdir("#{@
|
52
|
+
Dir.chdir("#{@shared_dir}/dgd/src") do
|
51
53
|
DGD::Manifest.system_call(DGD_BUILD_COMMAND)
|
52
54
|
end
|
53
55
|
end
|
@@ -60,25 +62,33 @@ module DGD::Manifest
|
|
60
62
|
end
|
61
63
|
|
62
64
|
def manifest_file(path)
|
63
|
-
raise "Already have a dgd.manifest file!"
|
65
|
+
raise "Already have a dgd.manifest file!" unless @no_manifest_file
|
64
66
|
|
67
|
+
@no_manifest_file = false
|
65
68
|
@manifest_file ||= AppFile.new(self, path)
|
66
69
|
end
|
67
70
|
|
68
|
-
|
69
|
-
|
71
|
+
protected
|
72
|
+
|
73
|
+
# This includes files to assemble... But also subdirectories and commands. This format is
|
74
|
+
# unstable and ugly, and should not be exposed to outside parties who might later depend on it.
|
75
|
+
def assembly_operations(location)
|
76
|
+
operations = []
|
77
|
+
|
78
|
+
raise("No manifest file!") if @no_manifest_file
|
70
79
|
|
71
80
|
@manifest_file.specs.each do |spec|
|
72
81
|
git_repo = spec.source
|
73
|
-
git_repo.use_details(spec.source_details)
|
82
|
+
git_repo.use_details(spec.source_details) # This sets things like checked-out branch
|
74
83
|
|
75
84
|
spec.paths.each do |from, to|
|
85
|
+
# Note: git_repo.local_dir is an absolute path.
|
76
86
|
from_path = "#{git_repo.local_dir}/#{from}"
|
77
87
|
if File.directory?(from_path)
|
78
88
|
files = Dir["#{from_path}/**/*"].to_a + Dir["#{from_path}/**/.*"].to_a
|
79
89
|
dirs = files.select { |file| File.directory?(file) }
|
80
90
|
non_dirs = files - dirs
|
81
|
-
|
91
|
+
operations << { cmd: "cp", from: from_path, to: to, dirs: dirs, non_dirs: non_dirs, comment: :single_dir }
|
82
92
|
elsif from_path["*"] # If from_path contains at least one asterisk
|
83
93
|
components = from.split("/")
|
84
94
|
first_wild_idx = components.index { |item| item["*"] }
|
@@ -91,51 +101,56 @@ module DGD::Manifest
|
|
91
101
|
dirs.uniq!
|
92
102
|
|
93
103
|
non_dirs = files - dirs
|
94
|
-
|
104
|
+
operations << { cmd: "cp", from: "#{git_repo.local_dir}/#{no_wild_from_path}", to: to, dirs: dirs, non_dirs: non_dirs, comment: :path_wildcard }
|
95
105
|
else
|
96
106
|
# A single file
|
97
|
-
|
107
|
+
operations << { cmd: "cp", from: from_path, to: to, dirs: [], non_dirs: [from_path], comment: :single_file }
|
98
108
|
end
|
99
109
|
end
|
100
110
|
end
|
101
111
|
|
102
|
-
|
112
|
+
app_path = "#{File.expand_path(location)}/#{@manifest_file.app_root}"
|
113
|
+
app_files = Dir["#{app_path}/**/*"].to_a
|
114
|
+
app_dirs = app_files.select { |f| File.directory?(f) }
|
115
|
+
app_non_dirs = app_files - app_dirs
|
116
|
+
unless app_dirs.empty? && app_non_dirs.empty?
|
117
|
+
operations << { cmd: "cp", from: app_path, to: ".", dirs: app_dirs, non_dirs: app_non_dirs, comment: :app_files } # No source
|
118
|
+
end
|
119
|
+
|
120
|
+
operations
|
103
121
|
end
|
104
122
|
|
123
|
+
public
|
124
|
+
|
105
125
|
def assemble_app(location)
|
106
126
|
dgd_root = "#{File.expand_path(location)}/#{GENERATED_ROOT}"
|
107
|
-
app_path = "#{File.expand_path(location)}/#{@manifest_file.app_root}"
|
108
127
|
FileUtils.rm_rf(dgd_root)
|
109
|
-
FileUtils.cp_r(app_path, dgd_root)
|
110
128
|
|
111
|
-
|
112
|
-
|
129
|
+
Dir.chdir(location) do
|
130
|
+
write_config_file("#{location}/dgd.config")
|
131
|
+
FileUtils.mkdir_p("#{location}/state") # Statedir for statedumps, editor files, etc.
|
113
132
|
|
114
|
-
|
115
|
-
|
133
|
+
assembly_operations(location).each do |sd_hash|
|
134
|
+
to_path = "#{dgd_root}/#{sd_hash[:to]}"
|
116
135
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
136
|
+
# Make appropriate dirs, including empty ones
|
137
|
+
sd_hash[:dirs].each do |dir|
|
138
|
+
FileUtils.mkdir_p dir.sub(sd_hash[:from], to_path)
|
139
|
+
end
|
121
140
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
141
|
+
# Copy all files
|
142
|
+
sd_hash[:non_dirs].each do |from_file|
|
143
|
+
to_file = from_file.sub(sd_hash[:from], "#{dgd_root}/#{sd_hash[:to]}")
|
144
|
+
to_dir = File.dirname(to_file)
|
145
|
+
FileUtils.mkdir_p to_dir
|
146
|
+
FileUtils.cp from_file, to_file
|
147
|
+
end
|
128
148
|
end
|
129
149
|
end
|
130
150
|
end
|
131
151
|
|
132
152
|
def precheck(location)
|
133
|
-
|
134
|
-
app_files = Dir["#{app_path}/**"].to_a.select { |f| !File.directory?(f) }
|
135
|
-
|
136
|
-
subdirs = files_to_assemble
|
137
|
-
all_files = subdirs.flat_map { |sd| sd[:non_dirs] } + app_files
|
138
|
-
all_files.sort!
|
153
|
+
all_files = assembly_operations(location).flat_map { |sd| sd[:non_dirs] }
|
139
154
|
|
140
155
|
if all_files.size != all_files.uniq.size
|
141
156
|
repeated = all_files.uniq.select { |f| all_files.count(f) > 1 }
|
@@ -146,7 +161,7 @@ module DGD::Manifest
|
|
146
161
|
def write_config_file(path)
|
147
162
|
File.open(path, "wb") do |f|
|
148
163
|
f.write <<CONTENTS
|
149
|
-
/* These are SkotOS limits. They are
|
164
|
+
/* These are SkotOS limits. They are larger than you are likely to need. They should
|
150
165
|
be configurable but they are not yet. */
|
151
166
|
telnet_port = ([
|
152
167
|
"*":50100 /* telnet port number */
|
@@ -193,7 +208,7 @@ CONTENTS
|
|
193
208
|
@git_url = git_url
|
194
209
|
@repo = repo
|
195
210
|
local_path = git_url.tr("/\\", "_")
|
196
|
-
@local_dir = "#{@repo.
|
211
|
+
@local_dir = "#{@repo.shared_dir}/git/#{local_path}"
|
197
212
|
|
198
213
|
if File.directory?(@local_dir)
|
199
214
|
Dir.chdir(@local_dir) do
|
@@ -205,9 +220,7 @@ CONTENTS
|
|
205
220
|
end
|
206
221
|
|
207
222
|
def default_branch
|
208
|
-
|
209
|
-
output = `git rev-parse --abbrev-ref origin/HEAD`.chomp
|
210
|
-
@default_branch = output.gsub(/^origin\//, "")
|
223
|
+
@default_branch ||= `git rev-parse --abbrev-ref origin/HEAD`.chomp.gsub(/^origin\//, "")
|
211
224
|
end
|
212
225
|
|
213
226
|
def use_details(details)
|
data/lib/dgd-tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dgd-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Gibbs
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|