monos 0.5.0 → 1.1.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
  SHA1:
3
- metadata.gz: 7785eb99b7c2f8d35ea8b0f11e06ae8cf366f613
4
- data.tar.gz: f141af65145dd3b7095f7145314558b6245ad54a
3
+ metadata.gz: 4962b6373c3d482ef91c0e9657e169217a96ffb7
4
+ data.tar.gz: 98eb5aa97ffed451336eb0b27402a2de03b45ffb
5
5
  SHA512:
6
- metadata.gz: db773ecea48e74063358fb5c862aaa940bdef1601244e395c54f7f61de7e870525b2c747f77d75c84ff4cd3b4bcdfc221a8eee477085ec56ba426b6ab24f12bd
7
- data.tar.gz: 8076d1725422bce4a74dc07d7dd4eec7252b4e5dea8abbb335fd8663f59bbc5295ecf5353c9147fa36a7c79c6827d9b4d43e97029dc0c2f6379f69a9b0fbece2
6
+ metadata.gz: b98911c5622bc280477824a78f28fa3da0e556ac5b3284d27a8e37dcd2c00b3162be3c13c1dbdc3118d4156fc4ef9eb769e48ff21b29695906607a426845dcac
7
+ data.tar.gz: 6a0cb4ef8100b218f1ef322b2fa352f4e20f3b6838249f8504ba35fd1ed106e2cc3b3a4ab1a47527301b3443aa62250624fa75e547e6990991a67ff04ba6126d
@@ -12,8 +12,10 @@ lib/mono/commands/fetch.rb
12
12
  lib/mono/commands/run.rb
13
13
  lib/mono/commands/status.rb
14
14
  lib/mono/commands/sync.rb
15
+ lib/mono/experimental.rb
15
16
  lib/mono/tool.rb
16
17
  lib/mono/version.rb
17
18
  lib/monos.rb
18
19
  test/helper.rb
19
20
  test/test_base.rb
21
+ test/test_path.rb
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/git](https://github.com/rubycoco/git)
5
- * bugs :: [github.com/rubycoco/git/issues](https://github.com/rubycoco/git/issues)
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 = MonoCore::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/git' }
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
- ['gitti', '>= 0.6.0' ],
24
- ['gitti-backup', '>= 0.4.1' ],
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 = {
@@ -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,15 +14,13 @@ module Mono
11
14
  end
12
15
 
13
16
 
14
- ## some more stdlibs
15
- # require 'optparse'
16
-
17
17
 
18
18
 
19
19
  ###
20
20
  # our own code
21
- require 'mono/version' # let version always go first
21
+ require 'mono/version' # let version always go first
22
22
  require 'mono/base'
23
+ require 'mono/experimental'
23
24
 
24
25
  require 'mono/commands/status'
25
26
  require 'mono/commands/fetch'
@@ -31,4 +32,19 @@ require 'mono/tool'
31
32
 
32
33
 
33
34
 
34
- puts MonoCore.banner # say hello
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
@@ -1,40 +1,50 @@
1
+ #####################
2
+ # add repo helper
1
3
 
2
- module Mono
4
+ ##
5
+ ## todo/fix: ALWAYS assert name format
6
+ ## (rename to mononame and monopath) - why? why not?
7
+
8
+ class MonoGitHub
9
+ def self.clone( name, depth: nil )
10
+ ## lets you use:
11
+ ## @rubycoco/gitti or
12
+ ## gitti@rubycoco
13
+ ## => rubycoco/gitti
14
+ mononame = Mononame.parse( name )
15
+ path = mononame.real_path
16
+
17
+ org_path = File.dirname( path )
18
+ FileUtils.mkdir_p( org_path ) unless Dir.exist?( org_path ) ## make sure path exists
3
19
 
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
- ENV['MOPATH']
11
- elsif Dir.exist?( 'C:/Sites' )
12
- 'C:/Sites'
13
- else
14
- '/sites'
15
- end
20
+ ### note: use a github clone url (using ssh) like:
21
+ ## git@github.com:rubycoco/gitti.git
22
+ ssh_clone_url = "git@github.com:#{mononame.to_path}.git"
23
+
24
+ Dir.chdir( org_path ) do
25
+ Gitti::Git.clone( ssh_clone_url, depth: depth )
16
26
  end
17
27
  end
28
+ end
29
+ MonoGithub = MonoGitHub ## add convenience (typo?) alias
18
30
 
19
- def self.monofile
20
- path = if File.exist?( './monorepo.yml' )
21
- './monorepo.yml'
22
- elsif File.exist?( './monotree.yml' )
23
- './monotree.yml'
24
- elsif File.exist?( './repos.yml' )
25
- './repos.yml'
26
- else
27
- puts "!! WARN: no mono configuration file (that is, {monorepo,monotree,repos}.yml) found in >#{Dir.getwd}<"
28
- nil
29
- end
30
-
31
- if path
32
- GitRepoSet.read( path )
33
- else
34
- GitRepoSet.new( {} ) ## return empty set -todo/check: return nil - why? why not?
35
- end
31
+
32
+
33
+ class MonoGitProject
34
+ def self.open( name, &block )
35
+ mononame = Mononame.parse( name )
36
+ path = mononame.real_path
37
+ Gitti::GitProject.open( path, &block )
36
38
  end
39
+ end
40
+
37
41
 
42
+
43
+ module Mono
44
+ #################
45
+ ## add some short cuts
46
+ def self.open( name, &block ) MonoGitProject.open( name, &block ); end
47
+ def self.clone( name, depth: nil ) MonoGitHub.clone( name, depth: depth ); end
38
48
  end ## module Mono
39
49
 
40
50
 
@@ -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 "MonoCore.root: >#{MonoCore.root}<"
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 "monorepo.yml:"
22
+ puts "monofile => (#{Monofile.find}):"
23
23
  pp Mono.monofile
24
24
  end
25
25
 
@@ -1,5 +1,4 @@
1
1
  module Mono
2
-
3
2
  ## pass along hash of repos (e.g. monorepo.yml or repos.yml )
4
3
  def self.fetch
5
4
  repos = Mono.monofile
@@ -0,0 +1,104 @@
1
+ ##############
2
+ # experimental stuff
3
+ #
4
+
5
+ module Mono
6
+
7
+ ######################
8
+ ### lint/print mono (source) tree
9
+ ### - check for git repos (via .git/ dir)
10
+ #
11
+ # turn into
12
+ # - tree or
13
+ # - lint or
14
+ # - doctor or
15
+ # - check or such command - why? why not?
16
+ def self.walk( path=root)
17
+ repos = walk_dir( path )
18
+ repos
19
+ end
20
+
21
+
22
+ ###############
23
+ # private helpers
24
+ private
25
+
26
+ ## todo/check - use max_depth or max_level or such - why? why not?
27
+ def self.walk_dir( path, repos=[], level=1, depth: nil )
28
+ entries = Dir.entries(path)
29
+
30
+ ## filter dirs
31
+ dirs = entries.select do |entry|
32
+ if ['..', '.'].include?( entry ) ## first check for excludes
33
+ false
34
+ else
35
+ full_path = File.join( path, entry )
36
+ File.directory?( full_path )
37
+ end
38
+ end
39
+
40
+ if dirs.size == 0 ## shortcircuit - no dirs in dir
41
+ return repos
42
+ end
43
+
44
+ repos_count = 0 ## note: local (only) repos count
45
+ warns_count = 0
46
+ sub_dirs = []
47
+
48
+
49
+
50
+ buf = String.new('') ## use an output buffer (allows optional print)
51
+
52
+
53
+ buf << ">#{path}< - level #{level}:\n"
54
+ dirs.each do |entry|
55
+ next if ['..', '.', '.git'].include?( entry )
56
+ full_path = File.join( path, entry )
57
+
58
+ if Dir.exist?( File.join( full_path, '.git' ))
59
+ repos_count += 1
60
+
61
+ if level == 1
62
+ warns_count += 1
63
+ buf << "!! WARN - top-level repo (w/o user/org) >#{entry}< @ #{path}\n"
64
+ end
65
+
66
+ if level > 2
67
+ warns_count += 1
68
+ buf << "!! WARN - hidden (?) sub-level #{level} repo (nested too deep?) >#{entry}< @ #{path}\n"
69
+ end
70
+
71
+ buf << " repo ##{'%-2d' % repos_count} | "
72
+ buf << "#{'%-20s' % entry} @ #{File.basename(path)} (#{path})"
73
+ buf << "\n"
74
+ repos << full_path
75
+
76
+ ## check for bare bone git repos - todo/fix: add .gitconfig or such and more - why? why not?
77
+ elsif Dir.exist?( File.join( full_path, 'hooks' )) &&
78
+ Dir.exist?( File.join( full_path, 'info' )) &&
79
+ Dir.exist?( File.join( full_path, 'objects' )) &&
80
+ Dir.exist?( File.join( full_path, 'refs' ))
81
+ warns_count += 1
82
+ buf << "!! WARN - skip bare git repo >#{entry}< @ #{path}\n"
83
+ else
84
+ buf << " x >#{entry}<\n"
85
+ sub_dirs << entry
86
+ end
87
+ end
88
+ buf << " #{repos_count} repos(s), #{dirs.size} dir(s), #{warns_count} warn(s)\n"
89
+ buf << "\n"
90
+
91
+ ## note: skip output of "plain" diretory listings (no repos, no warnings)
92
+ puts buf if repos_count > 0 || warns_count > 0
93
+
94
+
95
+ sub_dirs.each do |entry|
96
+ ## continue walking
97
+ full_path = File.join( path, entry )
98
+ walk_dir( full_path, repos, level+1, depth: depth )
99
+ end
100
+
101
+ repos
102
+ end
103
+
104
+ end # module Mono
@@ -4,9 +4,37 @@ module Mono
4
4
  class Tool
5
5
  def self.main( args=ARGV )
6
6
 
7
- ## note: for now assume first argument is command
8
- ## add options later
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
@@ -30,6 +58,11 @@ class Tool
30
58
  Mono.backup
31
59
  when 'run', 'r', 'exec'
32
60
  Mono.run( args )
61
+
62
+ ##################
63
+ ## for debugging / linting
64
+ when 'walk'
65
+ Mono.walk
33
66
  else
34
67
  puts "!! ERROR: unknown command >#{cmd}<"
35
68
  exit 1
@@ -1,12 +1,12 @@
1
1
  ## note: use a different module/namespace
2
2
  ## for the gem version info e.g. MonoCore vs Mono
3
3
 
4
- module MonoCore ## todo/check: rename to MonoMeta, MonoModule or such - why? why not?
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
- MAJOR = 0 ## todo: namespace inside version or something - why? why not??
9
- MINOR = 5
8
+ MAJOR = 1 ## todo: namespace inside version or something - why? why not??
9
+ MINOR = 1
10
10
  PATCH = 0
11
11
  VERSION = [MAJOR,MINOR,PATCH].join('.')
12
12
 
@@ -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 MonoCore
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 = MonoCore::VERSION
34
+ VERSION = Mono::Module::Tool::VERSION
32
35
  end
33
36
 
@@ -1,5 +1,5 @@
1
1
  # note: allow require 'monos' too
2
2
  # (in addition to require 'mono')
3
3
 
4
- require_relative './mono'
4
+ require_relative './mono' ## todo/check: use just 'mono' - why? why not?
5
5
 
@@ -9,9 +9,9 @@ class TestBase < MiniTest::Test
9
9
  Git = Mono::Git
10
10
 
11
11
  def test_version
12
- puts MonoCore::VERSION
13
- puts MonoCore.banner
14
- puts MonoCore.root
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
@@ -0,0 +1,23 @@
1
+ ###
2
+ # to run use
3
+ # ruby -I ./lib -I ./test test/test_path.rb
4
+
5
+ require 'helper'
6
+
7
+ class TestPath < MiniTest::Test
8
+
9
+
10
+ def test_real_path
11
+ [
12
+ '@yorobot/stage/one',
13
+ 'one@yorobot/stage',
14
+ 'stage/one@yorobot',
15
+ ].each do |path|
16
+ puts "#{path} => >#{Monopath.parse( path )}<"
17
+
18
+ assert_equal "#{Mono.root}/yorobot/stage/one", Monopath.real_path( path )
19
+ end
20
+ end
21
+
22
+ end # class TestPath
23
+
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.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-10-21 00:00:00.000000000 Z
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
16
30
  requirements:
17
31
  - - ">="
18
32
  - !ruby/object:Gem::Version
19
- version: 0.6.0
33
+ version: 0.6.1
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - ">="
25
39
  - !ruby/object:Gem::Version
26
- version: 0.6.0
40
+ version: 0.6.1
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: gitti-backup
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -97,12 +111,14 @@ files:
97
111
  - lib/mono/commands/run.rb
98
112
  - lib/mono/commands/status.rb
99
113
  - lib/mono/commands/sync.rb
114
+ - lib/mono/experimental.rb
100
115
  - lib/mono/tool.rb
101
116
  - lib/mono/version.rb
102
117
  - lib/monos.rb
103
118
  - test/helper.rb
104
119
  - test/test_base.rb
105
- homepage: https://github.com/rubycoco/git
120
+ - test/test_path.rb
121
+ homepage: https://github.com/rubycoco/monos
106
122
  licenses:
107
123
  - Public Domain
108
124
  metadata: {}