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