Kobold 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95561edd1b18544bfc735599c499a2b0d415a2b1638a30a56257fda2175adbbc
4
- data.tar.gz: a87c0b8575ea4abf21acf6325b32d8f4c371db5c6f0f9e0b7df97edb8a196021
3
+ metadata.gz: 9a104942e0236e764a6fa1adbd31d8e65fa84f550ff56c4138db311191dcb58a
4
+ data.tar.gz: 696e18a91d1a5d84d9ba8f3cebe96cc18805bce71a94b4227fdb482bca9fc8ce
5
5
  SHA512:
6
- metadata.gz: 7e5df73b29da03d20e409b39d4752011bd56e38d5e1bef5132f09bd732a9ee4ac73e71043c2d7048f8e66b7ae36e5b5a77cff91bf15fa1ffbc6a433f7b34c340
7
- data.tar.gz: 430e6ad01c0d0c89853811362b6e51cb7ce0e62d424bcd3e8cd1a875e11de3cc85f4b72bf680ea0e5529d12aee030afe8e74b0a1a0d2b863ede06543bd65601b
6
+ metadata.gz: e403e1b4a039586145d0de0b2311ebccb258e418fef3c43981ddbf0324d234b3d9fbe3a65c3892da01edd3b63233e427dfc2ba3af65dfe559b85c86d33aefbf8
7
+ data.tar.gz: f2f7d927a487911b8ddc39967378761568bb28ab9e8c199a8c5c4136dcb23a309101494e95b7f0f8484f3c61dc16cfc84f1043dfa2c7046595cbe7a2648f2229
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 "kobold_config", "format_version", value: Kobold::FORMAT_VERSION
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 Kobold::CONFIG_TITLES.include? key
26
- #puts "skipping #{key}"
22
+ if key[0] == '_'
27
23
  next
28
24
  end
29
- repo_dir = "#{KOBOLD_DIR}/repo_cache/#{key.gsub('/', '-')}"
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}/branches" # these are also worktrees, but just for the branch specifically if possible. TODO for later
38
- #puts "#{value["source"]}/#{key}.git", "#{repo_dir}/source"
39
- source_repo = Git.clone "#{value["source"]}/#{key}.git", "#{repo_dir}/source"
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
- # check if requested version exists
46
- if value["tag"]
47
- dir_name = value["tag"].to_s.gsub("/","-")
48
- # TODO make the thing
49
- else # use hash as name
50
- if value["commit"]
51
- # use given commit name, also check it exists
52
- begin # git errors when it does not find the hash
53
- #if value["commit"].is_a? Float
54
- # value["commit"] = value["commit"].to_i.to_s
55
- #end
56
- commit_val = value["commit"].to_s.delete_prefix('"').delete_suffix('"').delete_prefix("'").delete_suffix("'")
57
- if commit_val == 'latest'
58
- # TODO just use source git repo
59
- target_symlink = "#{repo_dir}/source"
60
- elsif commit_sha
61
- commit_sha = source_repo.object(commit_val).sha;
62
- target_symlink = "#{repo_dir}/worktrees/#{commit_sha}"
63
- if !Dir.exist? target_symlink
64
- # make it
65
- source_repo.worktree(target_symlink, commit_sha).add
66
- end
67
- else
68
- raise "Cannot find commit"
69
- end
70
- rescue # we catch this error here
71
- raise "Cannot find commit"
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
- raise "No commit given for #{key}"
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"] + key.split('/').last)
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
- File.symlink(target_symlink, "#{value['dir']}/#{key.split('/').last}")
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"] + key.split('/').last)
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kobold
4
- VERSION = "0.2.0"
5
- FORMAT_VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
+ FORMAT_VERSION = "0.3.0"
6
6
  end
data/lib/Kobold.rb CHANGED
@@ -1,15 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "Kobold/version"
4
- require "tty-config"
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 "Kobold/vars.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"
9
+ require_relative 'Kobold/vars.rb'
10
+ require_relative 'Kobold/read_config.rb'
11
+ require_relative 'Kobold/first_time_setup.rb'
12
+ require_relative 'Kobold/invoke.rb'
13
+ require_relative 'Kobold/init.rb'
13
14
 
14
15
  module Kobold
15
16
  KOBOLD_DIR = "#{Dir.home}/.local/share/Kobold"
data/prototyping/.kobold CHANGED
@@ -1,15 +1,28 @@
1
1
  [_kobold_config]
2
- format_version = 0.2.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
- [raysan5/raylib]
10
+ [raylib-linux]
11
+ repo = raysan5/raylib
11
12
  source = https://github.com
12
- dir = external/
13
- commit = 'latest'
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.2.0
4
+ version: 0.3.0
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-03 00:00:00.000000000 Z
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
@@ -93,7 +107,6 @@ files:
93
107
  - lib/Kobold/init.rb
94
108
  - lib/Kobold/invoke.rb
95
109
  - lib/Kobold/read_config.rb
96
- - lib/Kobold/vars.rb
97
110
  - lib/Kobold/version.rb
98
111
  - prototyping/.gitignore
99
112
  - prototyping/.kobold
@@ -121,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
134
  - !ruby/object:Gem::Version
122
135
  version: '0'
123
136
  requirements: []
124
- rubygems_version: 3.4.7
137
+ rubygems_version: 3.3.25
125
138
  signing_key:
126
139
  specification_version: 4
127
140
  summary: Version manager for various libraries and projects.
data/lib/Kobold/vars.rb DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- #require_relative "Kobold/version"
4
-
5
- module Kobold
6
- CONFIG_TITLES = [
7
- "_kobold_config",
8
- "_kobold_include",
9
- ]
10
- end