monos 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/Rakefile +5 -4
- data/lib/mono.rb +20 -4
- data/lib/mono/base.rb +6 -116
- data/lib/mono/commands/env.rb +2 -2
- data/lib/mono/tool.rb +30 -2
- data/lib/mono/version.rb +11 -8
- data/lib/monos.rb +1 -1
- data/test/test_base.rb +3 -3
- data/test/test_path.rb +3 -3
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4962b6373c3d482ef91c0e9657e169217a96ffb7
|
4
|
+
data.tar.gz: 98eb5aa97ffed451336eb0b27402a2de03b45ffb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b98911c5622bc280477824a78f28fa3da0e556ac5b3284d27a8e37dcd2c00b3162be3c13c1dbdc3118d4156fc4ef9eb769e48ff21b29695906607a426845dcac
|
7
|
+
data.tar.gz: 6a0cb4ef8100b218f1ef322b2fa352f4e20f3b6838249f8504ba35fd1ed106e2cc3b3a4ab1a47527301b3443aa62250624fa75e547e6990991a67ff04ba6126d
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# monos - monorepo / mono source tree tools and (startup) scripts
|
2
2
|
|
3
3
|
|
4
|
-
* home :: [github.com/rubycoco/
|
5
|
-
* bugs :: [github.com/rubycoco/
|
4
|
+
* home :: [github.com/rubycoco/monos](https://github.com/rubycoco/monos)
|
5
|
+
* bugs :: [github.com/rubycoco/monos/issues](https://github.com/rubycoco/monos/issues)
|
6
6
|
* gem :: [rubygems.org/gems/monos](https://rubygems.org/gems/monos)
|
7
7
|
* rdoc :: [rubydoc.info/gems/monos](http://rubydoc.info/gems/monos)
|
8
8
|
* forum :: [opensport](http://groups.google.com/group/opensport)
|
data/Rakefile
CHANGED
@@ -3,12 +3,12 @@ require './lib/mono/version.rb'
|
|
3
3
|
|
4
4
|
Hoe.spec 'monos' do
|
5
5
|
|
6
|
-
self.version =
|
6
|
+
self.version = Mono::Module::Tool::VERSION
|
7
7
|
|
8
8
|
self.summary = "monos - monorepo / mono source tree tools and (startup) scripts"
|
9
9
|
self.description = summary
|
10
10
|
|
11
|
-
self.urls = { home: 'https://github.com/rubycoco/
|
11
|
+
self.urls = { home: 'https://github.com/rubycoco/monos' }
|
12
12
|
|
13
13
|
self.author = 'Gerald Bauer'
|
14
14
|
self.email = 'opensport@googlegroups.com'
|
@@ -20,8 +20,9 @@ Hoe.spec 'monos' do
|
|
20
20
|
self.licenses = ['Public Domain']
|
21
21
|
|
22
22
|
self.extra_deps = [
|
23
|
-
['
|
24
|
-
['gitti
|
23
|
+
['monofile', '>= 0.2.2'],
|
24
|
+
['gitti', '>= 0.6.1'],
|
25
|
+
['gitti-backup', '>= 0.4.1'],
|
25
26
|
]
|
26
27
|
|
27
28
|
self.spec_extras = {
|
data/lib/mono.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'monofile'
|
2
|
+
|
3
|
+
|
1
4
|
## first add git support
|
2
5
|
## note: use the "modular" version WITHOUT auto-include gitti,
|
3
6
|
## thus, require 'gitti/base' (and NOT 'gitti')
|
@@ -11,9 +14,6 @@ module Mono
|
|
11
14
|
end
|
12
15
|
|
13
16
|
|
14
|
-
## some more stdlibs
|
15
|
-
# require 'optparse'
|
16
|
-
|
17
17
|
|
18
18
|
|
19
19
|
###
|
@@ -31,4 +31,20 @@ require 'mono/commands/run'
|
|
31
31
|
require 'mono/tool'
|
32
32
|
|
33
33
|
|
34
|
-
|
34
|
+
|
35
|
+
module Mono
|
36
|
+
def self.monofile
|
37
|
+
path = Monofile.find
|
38
|
+
|
39
|
+
if path
|
40
|
+
Monofile.read( path )
|
41
|
+
else
|
42
|
+
puts "!! WARN: no mono configuration file found; looking for #{Monofile::NAMES.join(', ')} in (#{Dir.getwd})"
|
43
|
+
Monofile.new ## return empty set -todo/check: return nil - why? why not?
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end ## module Mono
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
puts Mono::Module::Tool.banner # say hello
|
data/lib/mono/base.rb
CHANGED
@@ -1,57 +1,5 @@
|
|
1
|
-
|
2
|
-
module Mono
|
3
|
-
|
4
|
-
def self.root ## root of single (monorepo) source tree
|
5
|
-
@@root ||= begin
|
6
|
-
## todo/fix:
|
7
|
-
## check if windows - otherwise use /sites
|
8
|
-
## check if root directory exists?
|
9
|
-
if ENV['MOPATH']
|
10
|
-
## use expand path to make (assure) absolute path - why? why not?
|
11
|
-
File.expand_path( ENV['MOPATH'] )
|
12
|
-
elsif Dir.exist?( 'C:/Sites' )
|
13
|
-
'C:/Sites'
|
14
|
-
else
|
15
|
-
'/sites'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.root=( path )
|
21
|
-
## use expand path to make (assure) absolute path - why? why not?
|
22
|
-
@@root = File.expand_path( path )
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
MONOFILES = ['monorepo.yml', 'monotree.yml', 'repos.yml']
|
29
|
-
|
30
|
-
def self.find_monofile
|
31
|
-
MONOFILES.each do |name|
|
32
|
-
return "./#{name}" if File.exist?( "./#{name}")
|
33
|
-
end
|
34
|
-
|
35
|
-
nil ## no monofile found; return nil
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.monofile
|
39
|
-
path = find_monofile
|
40
|
-
|
41
|
-
if path
|
42
|
-
GitRepoSet.read( path )
|
43
|
-
else
|
44
|
-
puts "!! WARN: no mono configuration file found; looking for #{MONOFILES.join(', ')} in (#{Dir.getwd})"
|
45
|
-
GitRepoSet.new( {} ) ## return empty set -todo/check: return nil - why? why not?
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end ## module Mono
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
1
|
#####################
|
54
|
-
# add
|
2
|
+
# add repo helper
|
55
3
|
|
56
4
|
##
|
57
5
|
## todo/fix: ALWAYS assert name format
|
@@ -63,15 +11,15 @@ class MonoGitHub
|
|
63
11
|
## @rubycoco/gitti or
|
64
12
|
## gitti@rubycoco
|
65
13
|
## => rubycoco/gitti
|
66
|
-
|
67
|
-
path =
|
14
|
+
mononame = Mononame.parse( name )
|
15
|
+
path = mononame.real_path
|
68
16
|
|
69
17
|
org_path = File.dirname( path )
|
70
18
|
FileUtils.mkdir_p( org_path ) unless Dir.exist?( org_path ) ## make sure path exists
|
71
19
|
|
72
20
|
### note: use a github clone url (using ssh) like:
|
73
21
|
## git@github.com:rubycoco/gitti.git
|
74
|
-
ssh_clone_url = "git@github.com:#{
|
22
|
+
ssh_clone_url = "git@github.com:#{mononame.to_path}.git"
|
75
23
|
|
76
24
|
Dir.chdir( org_path ) do
|
77
25
|
Gitti::Git.clone( ssh_clone_url, depth: depth )
|
@@ -84,77 +32,19 @@ MonoGithub = MonoGitHub ## add convenience (typo?) alias
|
|
84
32
|
|
85
33
|
class MonoGitProject
|
86
34
|
def self.open( name, &block )
|
87
|
-
|
35
|
+
mononame = Mononame.parse( name )
|
36
|
+
path = mononame.real_path
|
88
37
|
Gitti::GitProject.open( path, &block )
|
89
38
|
end
|
90
39
|
end
|
91
40
|
|
92
41
|
|
93
42
|
|
94
|
-
class MonoFile
|
95
|
-
## e.g. openfootball/austria etc.
|
96
|
-
## expand to to "real" absolute path
|
97
|
-
##
|
98
|
-
## todo/check: assert name must be {orgname,username}/reponame
|
99
|
-
def self.real_path( path )
|
100
|
-
"#{Mono.root}/#{norm_name( path )}"
|
101
|
-
end
|
102
|
-
|
103
|
-
def self.norm_name( path )
|
104
|
-
# turn
|
105
|
-
# - @yorobot/stage/one
|
106
|
-
# - one@yorobot/stage
|
107
|
-
# - stage/one@yorobot
|
108
|
-
# => into
|
109
|
-
# - yorobot/stage/one
|
110
|
-
|
111
|
-
|
112
|
-
parts = path.split( '@' )
|
113
|
-
raise ArgumentError, "no (required) @ found in name; got >#{path}<" if parts.size == 1
|
114
|
-
raise ArgumentError, "too many @ found (#{parts.size-1}) in name; got >#{path}<" if parts.size > 2
|
115
|
-
|
116
|
-
norm_name = String.new('')
|
117
|
-
norm_name << parts[1] ## add orgs path first
|
118
|
-
if parts[0].length > 0 ## has leading repo name (w/ optional path)
|
119
|
-
norm_name << '/'
|
120
|
-
norm_name << parts[0]
|
121
|
-
end
|
122
|
-
norm_name
|
123
|
-
end
|
124
|
-
|
125
|
-
def self.exist?( path )
|
126
|
-
File.exist?( real_path( path ))
|
127
|
-
end
|
128
|
-
|
129
|
-
|
130
|
-
## path always relative to Mono.root
|
131
|
-
## todo/fix: use File.expand_path( path, Mono.root ) - why? why not?
|
132
|
-
## or always enfore "absolut" path e.g. do NOT allow ../ or ./ or such
|
133
|
-
def self.open( path, mode='r:utf-8', &block )
|
134
|
-
full_path = real_path( path )
|
135
|
-
## make sure path exists if we open for writing/appending - why? why not?
|
136
|
-
if mode[0] == 'w' || mode[0] == 'a'
|
137
|
-
FileUtils.mkdir_p( File.dirname( full_path ) ) ## make sure path exists
|
138
|
-
end
|
139
|
-
|
140
|
-
File.open( full_path, mode ) do |file|
|
141
|
-
block.call( file )
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
def self.read_utf8( path )
|
146
|
-
open( path, 'r:utf-8') { |file| file.read }
|
147
|
-
end
|
148
|
-
end ## class MonoFile
|
149
|
-
|
150
|
-
|
151
|
-
|
152
43
|
module Mono
|
153
44
|
#################
|
154
45
|
## add some short cuts
|
155
46
|
def self.open( name, &block ) MonoGitProject.open( name, &block ); end
|
156
47
|
def self.clone( name, depth: nil ) MonoGitHub.clone( name, depth: depth ); end
|
157
|
-
def self.real_path( name ) MonoFile.real_path( name ); end
|
158
48
|
end ## module Mono
|
159
49
|
|
160
50
|
|
data/lib/mono/commands/env.rb
CHANGED
@@ -2,7 +2,7 @@ module Mono
|
|
2
2
|
|
3
3
|
def self.env ## check environment setup
|
4
4
|
puts "Mono.root (MOPATH): >#{Mono.root}<"
|
5
|
-
puts "
|
5
|
+
puts "Mono::Module::Tool.root: >#{Mono::Module::Tool.root}<"
|
6
6
|
puts
|
7
7
|
|
8
8
|
## add ruby version and path - why? why not? e.g.
|
@@ -19,7 +19,7 @@ module Mono
|
|
19
19
|
Git.config( /user/, show_origin: true )
|
20
20
|
|
21
21
|
puts
|
22
|
-
puts "
|
22
|
+
puts "monofile => (#{Monofile.find}):"
|
23
23
|
pp Mono.monofile
|
24
24
|
end
|
25
25
|
|
data/lib/mono/tool.rb
CHANGED
@@ -4,9 +4,37 @@ module Mono
|
|
4
4
|
class Tool
|
5
5
|
def self.main( args=ARGV )
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
options = {}
|
8
|
+
OptionParser.new do |parser|
|
9
|
+
## note:
|
10
|
+
## you can add many/multiple modules
|
11
|
+
## e.g. -r gitti -r mono etc.
|
12
|
+
parser.on( '-r NAME', '--require NAME') do |name|
|
13
|
+
options[:requires] ||= []
|
14
|
+
options[:requires] << name
|
15
|
+
end
|
16
|
+
## todo/fix:
|
17
|
+
## add --verbose
|
18
|
+
## add -d/--debug
|
19
|
+
end.parse!( args )
|
20
|
+
|
21
|
+
|
22
|
+
## add check for auto-require (e.g. ./config.rb)
|
23
|
+
if options[:requires] ## use custom (auto-)requires
|
24
|
+
options[:requires].each do |path|
|
25
|
+
puts "[monofile] auto-require >#{path}<..."
|
26
|
+
require( path )
|
27
|
+
end
|
28
|
+
else ## use/try defaults
|
29
|
+
config_path = "./config.rb"
|
30
|
+
if File.exist?( config_path )
|
31
|
+
puts "[monofile] auto-require (default) >#{config_path}<..."
|
32
|
+
require( config_path )
|
33
|
+
end
|
34
|
+
end
|
9
35
|
|
36
|
+
|
37
|
+
## note: for now assume first argument is command
|
10
38
|
cmd = if args.size == 0
|
11
39
|
'status' ## make status "default" command
|
12
40
|
else
|
data/lib/mono/version.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
## note: use a different module/namespace
|
2
2
|
## for the gem version info e.g. MonoCore vs Mono
|
3
3
|
|
4
|
-
module
|
4
|
+
module Mono
|
5
|
+
module Module
|
6
|
+
module Tool ## todo/check: rename to MonoMeta, MonoModule or such - why? why not?
|
5
7
|
|
6
|
-
## note: move root to its own namespace to avoid
|
7
|
-
## conflict with Mono.root!!!!
|
8
8
|
MAJOR = 1 ## todo: namespace inside version or something - why? why not??
|
9
|
-
MINOR =
|
10
|
-
PATCH =
|
9
|
+
MINOR = 1
|
10
|
+
PATCH = 0
|
11
11
|
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
12
12
|
|
13
13
|
def self.version
|
@@ -18,16 +18,19 @@ module MonoCore ## todo/check: rename to MonoMeta, MonoModule or such - why? w
|
|
18
18
|
"monos/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
19
19
|
end
|
20
20
|
|
21
|
+
## note: move root to its own namespace to avoid
|
22
|
+
## conflict with Mono.root!!!!
|
21
23
|
def self.root
|
22
24
|
File.expand_path( File.dirname(File.dirname(__FILE__) ))
|
23
25
|
end
|
24
26
|
|
25
|
-
end # module
|
26
|
-
|
27
|
+
end # module Tool
|
28
|
+
end # module Module
|
29
|
+
end # module Mono
|
27
30
|
|
28
31
|
##################################
|
29
32
|
# add a convenience shortcut for now - why? why not?
|
30
33
|
module Mono
|
31
|
-
VERSION =
|
34
|
+
VERSION = Mono::Module::Tool::VERSION
|
32
35
|
end
|
33
36
|
|
data/lib/monos.rb
CHANGED
data/test/test_base.rb
CHANGED
@@ -9,9 +9,9 @@ class TestBase < MiniTest::Test
|
|
9
9
|
Git = Mono::Git
|
10
10
|
|
11
11
|
def test_version
|
12
|
-
puts
|
13
|
-
puts
|
14
|
-
puts
|
12
|
+
puts Mono::Module::Tool::VERSION
|
13
|
+
puts Mono::Module::Tool.banner
|
14
|
+
puts Mono::Module::Tool.root
|
15
15
|
|
16
16
|
puts Mono::VERSION
|
17
17
|
end
|
data/test/test_path.rb
CHANGED
@@ -12,10 +12,10 @@ def test_real_path
|
|
12
12
|
'@yorobot/stage/one',
|
13
13
|
'one@yorobot/stage',
|
14
14
|
'stage/one@yorobot',
|
15
|
-
].each do |
|
16
|
-
puts "#{
|
15
|
+
].each do |path|
|
16
|
+
puts "#{path} => >#{Monopath.parse( path )}<"
|
17
17
|
|
18
|
-
assert_equal "#{Mono.root}/yorobot/stage/one",
|
18
|
+
assert_equal "#{Mono.root}/yorobot/stage/one", Monopath.real_path( path )
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: monofile
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.2
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: gitti
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,7 +118,7 @@ files:
|
|
104
118
|
- test/helper.rb
|
105
119
|
- test/test_base.rb
|
106
120
|
- test/test_path.rb
|
107
|
-
homepage: https://github.com/rubycoco/
|
121
|
+
homepage: https://github.com/rubycoco/monos
|
108
122
|
licenses:
|
109
123
|
- Public Domain
|
110
124
|
metadata: {}
|