aro 0.2.6 → 0.2.7

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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +5 -2
  3. data/README.md +10 -54
  4. data/aro.gemspec +2 -1
  5. data/bin/oss_om +2 -0
  6. data/checksums/aro-0.2.7.gem.sha512 +1 -0
  7. data/listen.rb +1 -1
  8. data/locale/en.cor.yml +21 -32
  9. data/locale/en.yml +8 -60
  10. data/sys/aro/action.rb +153 -0
  11. data/sys/aro/d.rb +3 -1
  12. data/sys/aro/db/migrate/1793913747_create_data_bases.rb +2 -0
  13. data/sys/aro/db/migrate/1793913777_create_data_base_directories.rb +2 -0
  14. data/sys/aro/db/migrate/1793913796_create_data_base_files.rb +2 -0
  15. data/sys/aro/db/migrate/1793913841_create_menus.rb +2 -0
  16. data/sys/aro/db/migrate/1793913861_create_menu_items.rb +3 -2
  17. data/sys/aro/db.rb +19 -33
  18. data/sys/aro/designer.rb +166 -97
  19. data/sys/aro/locale.rb +4 -2
  20. data/sys/aro/mancy.rb +6 -39
  21. data/sys/aro/models/concerns/tar_go_for_root_sec.rb +37 -0
  22. data/sys/aro/models/concerns/uuid.rb +2 -0
  23. data/sys/aro/models/data_base.rb +33 -8
  24. data/sys/aro/models/directory.rb +2 -0
  25. data/sys/aro/models/file.rb +3 -1
  26. data/sys/aro/models/menu.rb +64 -0
  27. data/sys/aro/models/menu_item.rb +70 -4
  28. data/sys/aro/oss_open_menu.rb +331 -0
  29. data/sys/aro/p.rb +15 -9
  30. data/sys/aro/r.rb +2 -0
  31. data/sys/aro/{cor.rb → settings/cor.rb} +91 -215
  32. data/sys/aro/settings/git.rb +69 -0
  33. data/sys/aro/settings/ssh.rb +123 -0
  34. data/sys/aro/store.rb +87 -36
  35. data/sys/aro/v.rb +2 -0
  36. data/sys/aro.rb +2 -0
  37. data/sys/ma_ain.rb +202 -0
  38. data/sys/reiquire.rb +41 -54
  39. data/sys/shr/prompt.rb +6 -1
  40. data/sys/shr/version.rb +7 -8
  41. metadata +31 -23
  42. data/locale/en.cards.yml +0 -519
  43. data/locale/en.cmd.yml +0 -34
  44. data/locale/en.usage.yml +0 -142
  45. data/sys/aro/cmd.rb +0 -96
  46. data/sys/aro/db/migrate/1763374647_create_tecks.rb +0 -20
  47. data/sys/aro/db/migrate/1763432541_create_tlogs.rb +0 -20
  48. data/sys/aro/ma_ain.rb +0 -54
  49. data/sys/aro/models/teck.rb +0 -251
  50. data/sys/aro/models/tlog.rb +0 -21
  51. data/sys/aro/views/base.rb +0 -25
  52. data/sys/aro/views/teck.rb +0 -30
  53. data/sys/cli/constants.rb +0 -45
  54. data/sys/cli/create.rb +0 -23
  55. data/sys/cli/nterface.rb +0 -37
  56. data/sys/cli/teck.rb +0 -107
  57. data/sys/cli/usage.rb +0 -25
  58. data/sys/cli.rb +0 -23
  59. data/sys/shr/t.rb +0 -74
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  =begin
2
4
 
3
5
  menu.rb
@@ -24,4 +26,66 @@ class Aro::Dom::Menu < ActiveRecord::Base
24
26
  def directory
25
27
  Aro::Dom::DataBase::Directory.find_by(uuid: uuid)
26
28
  end
29
+
30
+ def generate_new_item(localized_name, for_type: :user)
31
+ new_menu_item = new_menu_item&.to_s
32
+ new_menu_item = menu_items.create(type_flag: for_type)
33
+ Aro::Dom::DataBase.sync_menu_item!(new_menu_item, localized_name)
34
+ new_menu_item
35
+ end
36
+
37
+ def rename_item(menu_item, new_name)
38
+ raise "invalid menu item!" unless !menu_item.nil? &&
39
+ self.menu_items.include?(menu_item)
40
+
41
+ Aro::Dom::DataBase.sync_menu_item!(menu_item, new_name)
42
+ end
43
+
44
+ def generate_ma_ain!
45
+ return unless is_menu_named?(:ma_ain) &&
46
+ menu_items.empty?
47
+
48
+ [:settings, :quit].each{|k|
49
+ i = generate_new_item(k, for_type: :system)
50
+
51
+ i.aro_file.write!(
52
+ Aro::Dom::Store.build_exec_oss_om_params!(
53
+ Aro::Dom::Ma_ain,
54
+ "exec_#{k}!",
55
+ k
56
+ )
57
+ )
58
+ }
59
+ end
60
+
61
+ def generate_settings!
62
+ return unless is_menu_named?(:settings) &&
63
+ menu_items.empty?
64
+
65
+ [:cor, :git, :ssh].each{|k|
66
+ i = generate_new_item(k, for_type: :system)
67
+
68
+ i.aro_file.write!(
69
+ Aro::Dom::Store.build_exec_oss_om_params!(
70
+ Aro::Dom::Oss_OpenMenu,
71
+ "open_#{k}!",
72
+ k
73
+ )
74
+ )
75
+ }
76
+ end
77
+
78
+ def generate_user_default!
79
+ return unless menu_items.empty?
80
+ generate_new_item(I18n.t("open_menu.default_user_item_text", localized_name: localized_name))
81
+ end
82
+
83
+ private
84
+
85
+ def is_menu_named?(name_sym)
86
+ name_sym = name_sym&.to_sym
87
+
88
+ !directory.nil? &&
89
+ directory.unix_path.to_sym == name_sym
90
+ end
27
91
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  =begin
2
4
 
3
5
  menu.rb
@@ -9,10 +11,15 @@
9
11
  =end
10
12
 
11
13
  class Aro::Dom::MenuItem < ActiveRecord::Base
14
+ include Aro::Dom::TarGoForRootSec
12
15
  include Aro::Dom::Uuid
16
+
13
17
  belongs_to :menu, class_name: "Aro::Dom::Menu"
14
18
 
15
- after_create :sync
19
+ enum :type_flag, [
20
+ :system,
21
+ :user
22
+ ]
16
23
 
17
24
  def as_tty
18
25
  {name: localized_name, value: uuid}
@@ -39,9 +46,68 @@ class Aro::Dom::MenuItem < ActiveRecord::Base
39
46
  )
40
47
  end
41
48
 
42
- private
49
+ def actionable?
50
+ !action_storage_key.nil?
51
+ end
52
+
53
+ def action_storage_key
54
+ return @ask unless @ask.nil? || @ask.empty?
55
+ action_typedef_key = store.safe_get_key("action_key")&.to_sym
56
+ unless Aro::Dom::Action::TYPES.select{|k, v| v[:key] == action_typedef_key}.any?
57
+ raise "missing or invalid #{__method__}! (#{action_typedef_key})"
58
+ end
59
+
60
+ @ask = action_typedef_key.to_s.gsub("exec_", "").upcase.to_sym
61
+ @ask
62
+ end
63
+
64
+ def action_display_text
65
+ raise "invalid action typedef!" if !Aro::Dom::Action::TYPES.keys.include?(action_storage_key) ||
66
+ Aro::Dom::Action::TYPES[action_storage_key].nil?
67
+
68
+ action_params = store.safe_get_key("action_params")&.symbolize_keys
69
+ unless action_params.kind_of?(Hash)
70
+ raise "missing or invalid action_params: #{action_params.inspect}"
71
+ end
72
+
73
+ puts action_params
74
+ puts "here " * 111
75
+ puts action_storage_key.class
76
+ result = nil
77
+ case action_storage_key
78
+ when :OSS_OM
79
+ result = [:aro_class_name, :aro_class_method].map{|k|
80
+ action_params[k].to_s.split("::").last
81
+ }.join(".")
82
+ when :SYSTEM
83
+ result = :todo_unpack_system_action_here.to_s
84
+ when :CREATE_DATA_BASE
85
+ result = :todo_unpack_create_data_base_action_here.to_s
86
+ end
87
+
88
+ result
89
+ end
90
+
91
+ def store
92
+ Aro::Dom::Ma_ain.instance.get_store_for(aro_file)
93
+ end
94
+
95
+ def run!
96
+ raise "invalid action typedef!" if !Aro::Dom::Action::TYPES.keys.include?(action_storage_key) ||
97
+ Aro::Dom::Action::TYPES[action_storage_key].nil?
43
98
 
44
- def sync
45
- Aro::Dom::DataBase.sync_menu_item(self)
99
+ unless action_storage_key.nil?
100
+ Aro::Dom::Action.perform(
101
+ Aro::Dom::Action::TYPES.keys.select{|k|
102
+ k == action_storage_key
103
+ }.first,
104
+ store.safe_get_key("action_params")
105
+ )
106
+ else
107
+ Aro::Dom::Ma_ain.i2097i_bookmark
108
+ puts __method__
109
+ puts inspect
110
+ puts :todo_implement_invalid_action_handling
111
+ end
46
112
  end
47
113
  end
@@ -0,0 +1,331 @@
1
+ # frozen_string_literal: true
2
+
3
+ =begin
4
+
5
+ oss_open_menu.rb
6
+
7
+ aro dom oss_open_menu.
8
+
9
+ by i2097i
10
+
11
+ =end
12
+
13
+ module Aro
14
+ module Dom
15
+ class Oss_OpenMenu
16
+
17
+ EXEC_CLASSES = [
18
+ "Aro::Cor",
19
+ "Aro::Dom::Oss_OpenMenu",
20
+ "Aro::Dom::Ma_ain",
21
+ "Aro::Dom::Git",
22
+ "Aro::Dom::Ssh"
23
+ ]
24
+
25
+ EXEC_METHODS = [
26
+ :open_cor!,
27
+ :open_git!,
28
+ :open_ssh!
29
+ ]
30
+
31
+ def self.boot!
32
+ # soft-load (source vars only) existing .cor
33
+ Aro::P.say("sourcing existing Aro::Cor env...")
34
+ Aro::Cor.instance.source_config
35
+
36
+ # set up oss_om workspace
37
+ Aro::P.say("Aro::Dom::Ma_ain.init!")
38
+ return unless Aro::Dom::Ma_ain.init!
39
+
40
+ # hard-load (source and generate config if needed)
41
+ Aro::P.say("Aro::Cor.instance.load_env!")
42
+ Aro::Cor.instance.load_env!
43
+
44
+ # kick off database
45
+ Aro::P.say("Aro::Db.ensure_connected!")
46
+ Aro::Db.ensure_connected!
47
+
48
+ # reload i18n locale configuration
49
+ Aro::P.say("Reiquire.reload_i18n!")
50
+ Reiquire.reload_i18n!
51
+
52
+ puts TTY::Font.new(:standard).write(
53
+ "f#{Aro::Mancy::ARO_DIRECTORY}",
54
+ letter_spacing: 1
55
+ )
56
+ end
57
+
58
+ def self.domain(git_username = nil)
59
+ if git_username.nil?
60
+ git_username = `git config user.name`&.strip
61
+ raise "invalid git config!" if git_username.nil?
62
+ end
63
+ "#{git_username}@oss_om.#{Aro::Dom::Ma_ain.aro_mancy_name}.local"
64
+ end
65
+
66
+ def self.install!
67
+ begin
68
+ ensure_global_git!
69
+ rescue RuntimeError => e
70
+ Aro::P.say(e)
71
+ return false
72
+ end
73
+ # soft-load (source vars only) existing .cor
74
+ Aro::P.say("sourcing existing Aro::Cor env...")
75
+ Aro::Cor.instance.source_config
76
+
77
+ # set up oss_om workspace
78
+ Aro::P.say("Aro::Dom::Ma_ain.init!")
79
+ Aro::Dom::Ma_ain.init!
80
+
81
+ key_path = Aro::Cor.ivar(:OSS_OM_HOME)
82
+ Aro::Dom::Designer.design_oss_om unless !key_path.nil? && Dir.exist?(key_path)
83
+
84
+ private_key_path = Aro::Dom::Ssh.id_key_path
85
+ required_local_files = [
86
+ ".gitignore",
87
+ ".git/config",
88
+ File.basename(private_key_path),
89
+ File.basename(private_key_path) + :".pub".to_s,
90
+ ]
91
+ missing_required_files = required_local_files.any?{|rlf| !::File.exist?(rlf)}
92
+ return Aro::Dom::Git.log unless missing_required_files
93
+ # run the install program until setup is complete
94
+ # return false to cancel
95
+ while missing_required_files do
96
+ gitconfig_path = ::File.join(key_path, ".git/config")
97
+ Aro::P.say("checking for local .git/config at #{gitconfig_path}")
98
+ if ::File.exist?(gitconfig_path)
99
+ break unless required_local_files.empty?{|rlf| !::File.exist?(rlf)}
100
+
101
+ Aro::P.say("#{self.name} already installed. continuing...")
102
+ return Aro::Dom::Git.log
103
+ else
104
+ Aro::P.say("missing local .git/config!")
105
+ Aro::P.say("setting up local git config...")
106
+
107
+ default_git_email = `git config user.email`.strip
108
+ default_text = default_git_email.nil? ? "" : " (default: #{default_git_email})"
109
+ git_email = Aro::Dom::Designer.get_new_value_from_user(
110
+ "enter git config user.email#{default_text}: ",
111
+ "(enter to use default):"
112
+ )
113
+ git_email = default_git_email if git_email.nil?
114
+ if git_email.nil? || git_email.empty?
115
+ Aro::P.say("missing git email! unable to continue #{self.name}.#{__method__}")
116
+ return false
117
+ end
118
+ Aro::P.say("using #{git_email} for email.")
119
+
120
+ default_git_username = (`git config user.email`.strip || git_email).split("@")[0]
121
+ git_username = Aro::Dom::Designer.get_new_value_from_user(
122
+ "enter git config user.name (default is #{default_git_username}): ",
123
+ "(enter to use default):"
124
+ )
125
+ git_username ||= default_git_username
126
+ if git_username.nil? || git_username.empty?
127
+ Aro::P.say("missing git username! unable to continue #{self.name}.#{__method__}")
128
+ return false
129
+ end
130
+ Aro::P.say("using #{git_username} for username.")
131
+
132
+ unless ::File.exist?(private_key_path)
133
+ key_domain = domain(git_username)
134
+
135
+ Aro::P.say("generating new ssh key in #{key_path} using domain #{key_domain}")
136
+ Aro::P.say("ssh-keygen -t RSA -f #{private_key_path} -b #{Aro::Mancy::NUMERALS[:MMXCVII] * 2} -C #{key_domain}")
137
+ keygen_result = `ssh-keygen -t RSA -f #{private_key_path} -b #{Aro::Mancy::NUMERALS[:MMXCVII] * 2} -C "#{key_domain}"`
138
+ Aro::P.say("ssh-keygen result: #{keygen_result}")
139
+ unless ::File.exist?(private_key_path)
140
+ Aro::P.say("oss_om ssh-keygen failed! unable to continue #{self.name}.#{__method__}")
141
+ return false
142
+ end
143
+ system("chmod 700 #{private_key_path}")
144
+ Aro::P.say("#{self.name} uses the project .gitignore to ensure privacy.")
145
+ Aro::P.say("write .gitignore!")
146
+ File.open(".gitignore", "w+") do |f|
147
+ f.write([
148
+ "#",
149
+ "#",
150
+ "# auto-generated by #{self.name} > #{key_domain} on #{Time.now}",
151
+ "#",
152
+ "# ignore oss_om private key!",
153
+ File.basename(private_key_path),
154
+ "#",
155
+ "# ignore entire '.oss_om/' directory!",
156
+ "#{Aro::Dom::Ma_ain::ARO_DIRECTORY.to_s}/*",
157
+ "#",
158
+ "#"
159
+ ].join("\n"))
160
+ f.write("\n")
161
+ end
162
+ end
163
+
164
+ Aro::P.say("system(git init)")
165
+ system(:"git init".to_s)
166
+
167
+ ensure_git_hooks_installed!
168
+
169
+ default_config = {
170
+ user_email: git_email,
171
+ user_name: git_username,
172
+ init_defaultBranch: :foss_om,
173
+ user_signingkey: "#{private_key_path}.pub",
174
+ gpg_format: :ssh,
175
+ commit_gpgsign: true,
176
+ core_editor: :nano
177
+ }.each{|k, v|
178
+ Aro::P.say("system(git config #{k.to_s.gsub("_", ".")} #{v})")
179
+ system(:"git config #{k.to_s.gsub("_", ".")} #{v}".to_s)
180
+ }
181
+ end
182
+
183
+ Aro::P.say("system(git checkout -b #{default_config[:init_defaultBranch]})")
184
+ system(:"git checkout -b #{default_config[:init_defaultBranch]}".to_s)
185
+ Aro::P.say("system(git branch -D main")
186
+ system(:"git branch -D main".to_s)
187
+ Aro::P.say("system(git add .)")
188
+ system(:"git add .".to_s)
189
+ Aro::P.say("system(git commit -m '#{key_domain} initial commit'")
190
+ system(:"git commit -m \"#{key_domain} initial commit\"".to_s)
191
+
192
+ Aro::P.say("#{self.name} installed successfully.")
193
+ end
194
+
195
+ return Aro::Dom::Git.log
196
+ end
197
+
198
+ def self.create_exec_oss_om_entry_for(menu_item)
199
+ # todo: this is a placeholder
200
+ # remove when is_encrypted complete
201
+ allow_exec_unsecure_oss_om_entries = true
202
+
203
+ unless allow_exec_unsecure_oss_om_entries || Aro::Dom::Ma_ain.is_encrypted?
204
+ Aro::P.say(__method__)
205
+ Aro::P.say("redirecting to settings until Aro::Dom::Ma_ain.is_encrypted!")
206
+ Aro::Dom::Ma_ain.exec_settings!
207
+ return
208
+ end
209
+
210
+ const_options = [
211
+ {name: :back, value: :back}
212
+ ] + EXEC_CLASSES.map{|exec_class_name|
213
+ {name: exec_class_name, value: exec_class_name}
214
+ }
215
+
216
+ selected_const_name = Aro::P.default_select(
217
+ I18n.t("open_menu.select_exec_oss_om_const"),
218
+ const_options
219
+ )
220
+
221
+ return if selected_const_name == :back
222
+ Aro::P.say("'#{selected_const_name}' selected")
223
+
224
+ selected_const = selected_const_name.constantize
225
+ raise "invalid const! #{selected_const}" unless EXEC_CLASSES.include?(selected_const.name)
226
+
227
+ method_options = [{name: :back, value: :back}] +
228
+ selected_const.methods.select{|m|
229
+ selected_const::EXEC_METHODS.include?(m)
230
+ }.map{|m|
231
+ {name: m, value: m}
232
+ }
233
+
234
+ selected_method_name = Aro::P.default_select(
235
+ I18n.t("open_menu.select_exec_oss_om_method", class: selected_const_name),
236
+ method_options
237
+ )
238
+
239
+ return if selected_method_name == :back
240
+ Aro::P.say("oss_om_method '#{selected_method_name}' selected")
241
+
242
+ menu_item.store.save_exec_oss_om_params!(
243
+ selected_const_name.constantize,
244
+ selected_method_name,
245
+ menu_item.localized_name
246
+ )
247
+ end
248
+
249
+ def self.create_exec_system_entry_for(menu_item)
250
+ unless Aro::Dom::Ma_ain.is_encrypted?
251
+ Aro::P.say(__method__)
252
+ Aro::P.say("redirecting to settings until Aro::Dom::Ma_ain.is_encrypted!")
253
+ Aro::Dom::Ma_ain.exec_settings!
254
+ return
255
+ end
256
+
257
+ puts __method__
258
+ puts self.name
259
+ Aro::Dom::Ma_ain.i2097i_bookmark
260
+ end
261
+
262
+ def self.create_exec_data_base_entry_for(menu_item)
263
+ unless Aro::Dom::Ma_ain.is_encrypted?
264
+ Aro::P.say(__method__)
265
+ Aro::P.say("redirecting to settings until Aro::Dom::Ma_ain.is_encrypted!")
266
+ Aro::Dom::Ma_ain.exec_settings!
267
+ return
268
+ end
269
+
270
+ puts __method__
271
+ puts self.name
272
+ Aro::Dom::Ma_ain.i2097i_bookmark
273
+ end
274
+
275
+ def self.open_git!
276
+ Aro::Dom::Git.open!
277
+ end
278
+
279
+ def self.open_ssh!
280
+ Aro::Dom::Ssh.open!
281
+ end
282
+
283
+ def self.open_cor!
284
+ Aro::Cor.open!
285
+ end
286
+
287
+ private
288
+
289
+ def self.ensure_global_git!
290
+ raise "git not installed!" unless Aro::Mancy::O == system(:"which -s git".to_s).to_s.strip.to_i
291
+ raise "git not configured!" unless system(:"git config user.name".to_s) || false
292
+ end
293
+
294
+ def self.ensure_git_hooks_installed!
295
+ raise "git not initialized!" unless Dir.exist?(".git")
296
+ pre_commit_hook_path = ::File.join(
297
+ Aro::Cor.ivar(:OSS_OM_HOME),
298
+ ".git/hooks/pre-commit"
299
+ )
300
+
301
+ Aro::Dom::Ma_ain.i2097i_bookmark
302
+ puts "todo: ensure pre-commit file matches current generated content"
303
+ pre_commit_validation_allow_invalid = true
304
+ pre_commit_hook_valid = ::File.exist?(pre_commit_hook_path) && pre_commit_validation_allow_invalid
305
+ return true if pre_commit_hook_valid
306
+ Aro::P.say("warning: pre_commit_validation_allow_invalid is set to #{pre_commit_validation_allow_invalid}!")
307
+
308
+ File.open(pre_commit_hook_path, "w+") do |f|
309
+ f.write([
310
+ "#",
311
+ "#",
312
+ "# auto-generated by #{self.name} > #{self.domain} on #{Time.now}",
313
+ "#",
314
+ "# #{self.name} pre-commit git hook.",
315
+ "#",
316
+ "# validate .gitignore",
317
+ "# tar oss_om using id_oss_om keypair",
318
+ "echo '#{self.name} pre-commit hook running'",
319
+ "echo 'todo:'",
320
+ "echo 'initialize tar_oss_om.tar.gz'",
321
+ ].join("\n"))
322
+ f.write("\n")
323
+ end
324
+ Aro::P.say("system(chmod +x #{pre_commit_hook_path}")
325
+ system("chmod +x #{pre_commit_hook_path}")
326
+ Aro::P.say("git hook installed successfully.")
327
+ end
328
+
329
+ end
330
+ end
331
+ end
data/sys/aro/p.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  =begin
2
4
 
3
5
  p.rb
@@ -9,20 +11,24 @@
9
11
  =end
10
12
 
11
13
  require_relative :"../shr/prompt".to_s
12
- require_relative :"./r".to_s
13
14
 
14
15
  module Aro
15
16
  class P < Aro::Prompt
17
+
16
18
  def self.say(message)
17
- if Aro::Dom::Ma_ain.instance.nil? &&
18
- Aro::Mancy.in_aro? &&
19
- !Aro::T.is_dev_tarot?
20
-
21
- Aro::R.say(normalize_message(message))
22
- else
23
- super("#{Aro::Dom::Ma_ain.ps1_display || Aro::Mancy.ps1_display}#{normalize_message(message)}")
24
- end
19
+ super("#{Aro::Dom::Ma_ain.ps1_display || Aro::Mancy.ps1_display}#{normalize_message(message)}")
25
20
  end
21
+
22
+ def self.default_select(display_text, options)
23
+ Aro::P.p.select(
24
+ Aro::Dom::Ma_ain.mini_hud_for(display_text),
25
+ options,
26
+ show_help: :always,
27
+ cycle: true,
28
+ per_page: 11
29
+ )
30
+ end
31
+
26
32
  end
27
33
  end
28
34
 
data/sys/aro/r.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  =begin
2
4
 
3
5
  r.rb