Kobold 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/Kobold/init.rb +1 -1
- data/lib/Kobold/invoke.rb +119 -40
- data/lib/Kobold/version.rb +2 -2
- data/lib/Kobold.rb +7 -7
- data/prototyping/.kobold +22 -9
- metadata +17 -5
- data/.kobold +0 -6
- data/lib/Kobold/vars.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75fef6957b1c19312541b59a16ac8570a1b86e5b7f41f79dba2c41800be12191
|
4
|
+
data.tar.gz: 017ddeb8d702b82e6394fb39728e88cf4d1b9ee0faeea5fb5d576adad2bb0836
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad1f5519736e748bde54452c285e236d3c3512affb98f66052a8af32a11eb1a1108a46880d026c5fd6362bf118886b45c9e1e449050566e45db00f711b0f4db8
|
7
|
+
data.tar.gz: e135292d11f7009d8202d357bfe6fecf93fb5fa0f5811dc4e807c2e221e4e9d6cfc4483b5a4392072d69eaf164e6bf30bc3cd1981d07d8cd5a7d1c8d2db40b46
|
data/lib/Kobold/init.rb
CHANGED
@@ -12,7 +12,7 @@ module Kobold
|
|
12
12
|
kobold_config = TTY::Config.new
|
13
13
|
kobold_config.filename = ".kobold"
|
14
14
|
kobold_config.extname = ".ini"
|
15
|
-
kobold_config.set "
|
15
|
+
kobold_config.set "_kobold_config", "format_version", value: Kobold::FORMAT_VERSION
|
16
16
|
kobold_config.write
|
17
17
|
File.rename ".kobold.ini", ".kobold"
|
18
18
|
end
|
data/lib/Kobold/invoke.rb
CHANGED
@@ -16,17 +16,13 @@ module Kobold
|
|
16
16
|
end
|
17
17
|
settings = Kobold.read_config(Dir.pwd)
|
18
18
|
|
19
|
-
#puts Kobold::FORMAT_VERSION + " " + settings["kobold_config"]["format_version"]
|
20
19
|
if Kobold::FORMAT_VERSION == settings["_kobold_config"]["format_version"]
|
21
|
-
#settings.delete "kobold_config"
|
22
|
-
|
23
20
|
# iterate over all dependencies
|
24
21
|
settings.each do |key, value|
|
25
|
-
if
|
26
|
-
#puts "skipping #{key}"
|
22
|
+
if key[0] == '_'
|
27
23
|
next
|
28
24
|
end
|
29
|
-
repo_dir = "#{KOBOLD_DIR}/repo_cache/#{
|
25
|
+
repo_dir = "#{KOBOLD_DIR}/repo_cache/#{value['repo'].gsub('/', '-')}"
|
30
26
|
|
31
27
|
source_repo = nil;
|
32
28
|
# check if source exists
|
@@ -34,45 +30,108 @@ module Kobold
|
|
34
30
|
# if it doesnt, make it
|
35
31
|
FileUtils.mkdir_p "#{repo_dir}/source"
|
36
32
|
FileUtils.mkdir_p "#{repo_dir}/worktrees"
|
37
|
-
FileUtils.mkdir_p "#{repo_dir}/
|
38
|
-
|
39
|
-
|
33
|
+
FileUtils.mkdir_p "#{repo_dir}/worktrees/branched"
|
34
|
+
FileUtils.mkdir_p "#{repo_dir}/worktrees/sha"
|
35
|
+
FileUtils.mkdir_p "#{repo_dir}/worktrees/labelled"
|
36
|
+
FileUtils.mkdir_p "#{repo_dir}/branches"
|
37
|
+
source_repo = clone_git_repo "#{value["source"]}/#{value['repo']}.git", "#{repo_dir}/source"
|
40
38
|
else
|
41
39
|
source_repo = Git.open("#{repo_dir}/source")
|
42
40
|
end
|
43
41
|
|
42
|
+
# must be scoped here, used in various inner scopes
|
44
43
|
target_symlink = nil
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
44
|
+
|
45
|
+
# Structure of a segment of following code:
|
46
|
+
# if it declares a branch: make the branch
|
47
|
+
# if it has a label
|
48
|
+
# it must have a sha
|
49
|
+
# if it has a branch
|
50
|
+
# use that branch + sha
|
51
|
+
# else
|
52
|
+
# use source + sha
|
53
|
+
# end
|
54
|
+
# else check if it has a branch
|
55
|
+
# if it has a sha
|
56
|
+
# make the sha
|
57
|
+
# else
|
58
|
+
# make it point to branch
|
59
|
+
# end
|
60
|
+
# else check if it has a sha
|
61
|
+
# make the sha on the source
|
62
|
+
# else
|
63
|
+
# use source
|
64
|
+
# end
|
65
|
+
|
66
|
+
branch_repo = nil
|
67
|
+
if value["branch"]
|
68
|
+
branch_repo_path = "#{repo_dir}/branches/#{value["branch"]}"
|
69
|
+
# check if branch already exists, make it if it doesnt
|
70
|
+
if !Dir.exist? branch_repo_path
|
71
|
+
FileUtils.mkdir_p "#{repo_dir}/branches"
|
72
|
+
source_repo.worktree(branch_repo_path, value["branch"]).add
|
73
|
+
end
|
74
|
+
branch_repo = Git.open(branch_repo_path)
|
75
|
+
end
|
76
|
+
|
77
|
+
target_symlink = nil
|
78
|
+
# if it has a label
|
79
|
+
if value["label"]
|
80
|
+
|
81
|
+
if !value["commit"]
|
82
|
+
raise "Must give a specific sha when making a label. #{key} has no specific sha given"
|
83
|
+
end
|
84
|
+
if value["branch"]
|
85
|
+
worktree_path = "#{repo_dir}/worktrees/labelled/#{value["label"]}/#{value["branch"]}"
|
86
|
+
_commit_val = value["commit"].to_s.delete_prefix('"').delete_suffix('"').delete_prefix("'").delete_suffix("'")
|
87
|
+
worktree_sha = branch_repo.object(_commit_val).sha;
|
88
|
+
target_symlink = "#{worktree_path}/#{worktree_sha}"
|
89
|
+
if !Dir.exist? target_symlink
|
90
|
+
FileUtils.mkdir_p "#{worktree_path}"
|
91
|
+
branch_repo.worktree(target_symlink, worktree_sha).add
|
92
|
+
end
|
93
|
+
else
|
94
|
+
branch = source_repo.branch.name
|
95
|
+
worktree_path = "#{repo_dir}/worktrees/labelled/#{value["label"]}/#{branch}"
|
96
|
+
_commit_val = value["commit"].to_s.delete_prefix('"').delete_suffix('"').delete_prefix("'").delete_suffix("'")
|
97
|
+
worktree_sha = source_repo.object(_commit_val).sha;
|
98
|
+
target_symlink = "#{worktree_path}/#{worktree_sha}"
|
99
|
+
if !Dir.exist? target_symlink
|
100
|
+
FileUtils.mkdir_p "#{worktree_path}"
|
101
|
+
source_repo.worktree(target_symlink, worktree_sha).add
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
elsif value["branch"]
|
106
|
+
|
107
|
+
if value['sha']
|
108
|
+
worktree_path = "#{repo_dir}/worktrees/branched/#{branch}"
|
109
|
+
_commit_val = value["commit"].to_s.delete_prefix('"').delete_suffix('"').delete_prefix("'").delete_suffix("'")
|
110
|
+
worktree_sha = branch_repo.object(_commit_val).sha;
|
111
|
+
target_symlink = "#{worktree_path}/#{worktree_sha}"
|
112
|
+
if !Dir.exist? target_symlink
|
113
|
+
FileUtils.mkdir_p "#{worktree_path}"
|
114
|
+
branch_repo.worktree(target_symlink, worktree_sha).add
|
72
115
|
end
|
73
116
|
else
|
74
|
-
|
117
|
+
target_symlink = "#{repo_dir}/branches/#{value['branch']}"
|
75
118
|
end
|
119
|
+
|
120
|
+
elsif value["commit"]
|
121
|
+
|
122
|
+
worktree_path = "#{repo_dir}/worktrees/sha"
|
123
|
+
_commit_val = value["commit"].to_s.delete_prefix('"').delete_suffix('"').delete_prefix("'").delete_suffix("'")
|
124
|
+
worktree_sha = source_repo.object(_commit_val).sha;
|
125
|
+
target_symlink = "#{worktree_path}/#{worktree_sha}"
|
126
|
+
if !Dir.exist? target_symlink
|
127
|
+
FileUtils.mkdir_p "#{worktree_path}"
|
128
|
+
source_repo.worktree(target_symlink, worktree_sha).add
|
129
|
+
end
|
130
|
+
|
131
|
+
else
|
132
|
+
|
133
|
+
target_symlink = "#{repo_dir}/source"
|
134
|
+
|
76
135
|
end
|
77
136
|
|
78
137
|
# build the symlink
|
@@ -81,11 +140,14 @@ module Kobold
|
|
81
140
|
#puts "value: " + value["dir"] + key.split('/').last
|
82
141
|
#puts !File.symlink?(value["dir"] + key.split('/').last)
|
83
142
|
|
84
|
-
symlink1 = File.symlink?(value["dir"] +
|
143
|
+
symlink1 = File.symlink?(value["dir"] + value['repo'].split('/').last)
|
85
144
|
symlink2 = File.symlink? value["dir"]
|
86
145
|
|
87
146
|
if !(symlink1 || symlink2)
|
88
|
-
|
147
|
+
puts "value['dir'] #{value['dir']}"
|
148
|
+
puts "value['repo'] #{value['repo']}"
|
149
|
+
puts "target_symlink #{target_symlink}"
|
150
|
+
File.symlink(target_symlink, "#{value['dir']}/#{value['repo'].split('/').last}")
|
89
151
|
end
|
90
152
|
#File.symlink(target_symlink, "#{value['dir']}/#{key.split('/').last}")
|
91
153
|
|
@@ -96,7 +158,7 @@ module Kobold
|
|
96
158
|
FileUtils.mkdir_p dir_components
|
97
159
|
File.symlink(target_symlink, value["dir"]) if !File.symlink? value["dir"]
|
98
160
|
|
99
|
-
symlink1 = File.symlink?(value["dir"] +
|
161
|
+
symlink1 = File.symlink?(value["dir"] + ['repo'].split('/').last)
|
100
162
|
symlink2 = File.symlink? value["dir"]
|
101
163
|
|
102
164
|
if !(symlink1 || symlink2)
|
@@ -119,5 +181,22 @@ module Kobold
|
|
119
181
|
raise "Wrong format version"
|
120
182
|
end
|
121
183
|
end
|
184
|
+
|
185
|
+
private
|
186
|
+
|
187
|
+
def clone_git_repo(url, path)
|
188
|
+
progress_bar = TTY::ProgressBar.new("[:bar] Cloning: #{url} ", bar_format: :blade, total: nil, width: 45)
|
189
|
+
|
190
|
+
thread = Thread.new(abort_on_exception: true) do
|
191
|
+
Git.clone url, path
|
192
|
+
end
|
193
|
+
progress_bar.start
|
194
|
+
while thread.status
|
195
|
+
progress_bar.advance
|
196
|
+
sleep 0.016
|
197
|
+
end
|
198
|
+
puts
|
199
|
+
return thread.value
|
200
|
+
end
|
122
201
|
end
|
123
202
|
end
|
data/lib/Kobold/version.rb
CHANGED
data/lib/Kobold.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
4
|
-
require
|
3
|
+
require_relative 'Kobold/version'
|
4
|
+
require 'tty-config'
|
5
5
|
require 'fileutils'
|
6
6
|
require 'git'
|
7
|
+
require 'tty-progressbar'
|
7
8
|
|
8
|
-
require_relative
|
9
|
-
require_relative
|
10
|
-
require_relative
|
11
|
-
require_relative
|
12
|
-
require_relative "Kobold/init.rb"
|
9
|
+
require_relative 'Kobold/read_config.rb'
|
10
|
+
require_relative 'Kobold/first_time_setup.rb'
|
11
|
+
require_relative 'Kobold/invoke.rb'
|
12
|
+
require_relative 'Kobold/init.rb'
|
13
13
|
|
14
14
|
module Kobold
|
15
15
|
KOBOLD_DIR = "#{Dir.home}/.local/share/Kobold"
|
data/prototyping/.kobold
CHANGED
@@ -1,15 +1,28 @@
|
|
1
1
|
[_kobold_config]
|
2
|
-
format_version = 0.
|
2
|
+
format_version = 0.3.0
|
3
3
|
|
4
|
-
[_kobold_include]
|
5
|
-
files = "
|
6
|
-
dir1/
|
7
|
-
dir2/
|
8
|
-
"
|
4
|
+
;[_kobold_include]
|
5
|
+
;files = "
|
6
|
+
;dir1/
|
7
|
+
;dir2/
|
8
|
+
;"
|
9
9
|
|
10
|
-
[
|
10
|
+
[raylib-linux]
|
11
|
+
repo = raysan5/raylib
|
11
12
|
source = https://github.com
|
12
|
-
dir = external/
|
13
|
-
commit = '
|
13
|
+
dir = external/linux-x64/
|
14
|
+
commit = 'b8cd102'
|
15
|
+
label = linux-x64
|
16
|
+
|
17
|
+
[raylib-web]
|
18
|
+
repo = raysan5/raylib
|
19
|
+
source = https://github.com
|
20
|
+
dir = external/emscripten/
|
21
|
+
commit = 'b8cd102'
|
22
|
+
label = web
|
14
23
|
|
24
|
+
[raygui]
|
25
|
+
repo = raysan5/raygui
|
26
|
+
source = https://github.com
|
27
|
+
dir = external/
|
15
28
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Kobold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CatsAtTheRodeo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-option
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.18.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: tty-progressbar
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.18.2
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.18.2
|
69
83
|
description:
|
70
84
|
email:
|
71
85
|
- contact@tradam.dev
|
@@ -74,7 +88,6 @@ executables:
|
|
74
88
|
extensions: []
|
75
89
|
extra_rdoc_files: []
|
76
90
|
files:
|
77
|
-
- ".kobold"
|
78
91
|
- ".rubocop.yml"
|
79
92
|
- CHANGELOG.md
|
80
93
|
- Kobold Notes/.obsidian/app.json
|
@@ -93,7 +106,6 @@ files:
|
|
93
106
|
- lib/Kobold/init.rb
|
94
107
|
- lib/Kobold/invoke.rb
|
95
108
|
- lib/Kobold/read_config.rb
|
96
|
-
- lib/Kobold/vars.rb
|
97
109
|
- lib/Kobold/version.rb
|
98
110
|
- prototyping/.gitignore
|
99
111
|
- prototyping/.kobold
|
@@ -121,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
133
|
- !ruby/object:Gem::Version
|
122
134
|
version: '0'
|
123
135
|
requirements: []
|
124
|
-
rubygems_version: 3.
|
136
|
+
rubygems_version: 3.3.25
|
125
137
|
signing_key:
|
126
138
|
specification_version: 4
|
127
139
|
summary: Version manager for various libraries and projects.
|
data/.kobold
DELETED