monoz 0.1.0 → 0.2.0
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/MIT-LICENSE +20 -0
- data/README.md +19 -6
- data/bin/monoz +1 -1
- data/lib/monoz/cli/main.rb +4 -2
- data/lib/monoz/configuration.rb +11 -9
- data/lib/monoz/project.rb +54 -52
- data/lib/monoz/project_collection.rb +5 -4
- data/lib/monoz/services/bundle_service.rb +19 -0
- data/lib/monoz/services/init_service.rb +2 -2
- data/lib/monoz/version.rb +1 -1
- data/lib/monoz.rb +1 -1
- metadata +3 -2
- data/lib/monoz/cli/bundle.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd7a1b2e7eee574ad959399f006f5ca5678bd810165be8f50e4a0a590d7b1e8f
|
4
|
+
data.tar.gz: 9dff952ec312b73c783aaf5b6e13c73304cd07a6a9200291f1db68a42c7fc6d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 144a67fc74ec7fd2af382836f421ae3a59b2bbe13b1ff2655f31d5268ca7d94d37ff672ff5441850be58650a4ac40bb973868cd01c7a42983d8206576415ce67
|
7
|
+
data.tar.gz: c54341f5ba64cb74d6c9b5a1626f92491fb2cb7c8a30fb1fdea1ee3e9fba5d5494127d67ef2d3f0a0ce1444f2ee04cbd064b3ce446bd485e0449da0b3b3ff3c6
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2023 Rasmus Kjellberg
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -51,7 +51,7 @@ For example, a Monoz repository with both a frontend and a backend application t
|
|
51
51
|
|
52
52
|
### Bundle projects
|
53
53
|
|
54
|
-
To manage the dependencies of your projects, you can use the monoz bundle command. This command will create a new Gemfile.lock file in each project directory based on the dependencies specified in their respective
|
54
|
+
To manage the dependencies of your projects, you can use the `monoz bundle` command. This command will run `bundle` and create a new Gemfile.lock file in each project directory based on the dependencies specified in their respective `Gemfile`.
|
55
55
|
|
56
56
|
To bundle all the projects in the Monoz repository, simply run:
|
57
57
|
|
@@ -59,9 +59,7 @@ To bundle all the projects in the Monoz repository, simply run:
|
|
59
59
|
$ monoz bundle
|
60
60
|
```
|
61
61
|
|
62
|
-
This will
|
63
|
-
|
64
|
-
If you want to update the dependencies of your projects, you can use the `monoz bundle update` command. This command will update the `Gemfile.lock` file of each project based on the latest available versions of their dependencies.
|
62
|
+
If you instead want to update the dependencies of your projects, you can use the `monoz bundle update` command. This command will update the `Gemfile.lock` file of each project based on the latest available versions of their dependencies.
|
65
63
|
|
66
64
|
To update the dependencies of all projects in the Monoz repository, simply run:
|
67
65
|
|
@@ -71,11 +69,26 @@ $ monoz bundle update
|
|
71
69
|
|
72
70
|
Note that when you add a new dependency to a project, you'll need to run `monoz bundle` to update its `Gemfile.lock` file before you can use the new dependency. Similarly, if you update the dependencies of a project's `Gemfile`, you'll need to run `monoz bundle` to update its `Gemfile.lock` file with the new versions.
|
73
71
|
|
72
|
+
#### Run other bundler commands
|
73
|
+
|
74
|
+
You can also run other bundler commands on all projects in the repository using the `monoz bundle` command followed by the desired arguments. For example, to run the RSpec tests for all projects, you can use the following command:
|
75
|
+
|
76
|
+
```console
|
77
|
+
$ monoz bundle exec rspec
|
78
|
+
|
79
|
+
[kiqr_core] bundle exec rspec
|
80
|
+
[core_api] bundle exec rspec
|
81
|
+
[content_api] bundle exec rspec
|
82
|
+
[kiqr_cloud] bundle exec rspec
|
83
|
+
```
|
84
|
+
|
85
|
+
This will execute the `bundle exec rspec` command in each project directory, ensuring that all the necessary dependencies are installed and loaded for each project. Similarly, you can run other bundler commands such as `bundle install`, `bundle update`, and so on, by appending the desired arguments to the `monoz bundle` command.
|
86
|
+
|
74
87
|
### Inspect projects
|
75
88
|
|
76
|
-
You can inspect the projects in your Monoz repository using the monoz inspect command. This command will display a table that shows the projects in the repository, their type (app or gem), the gem name (if it's a gem), the test framework(s) used, and the projects that depend on them.
|
89
|
+
You can inspect the projects in your Monoz repository using the `monoz inspect` command. This command will display a table that shows the projects in the repository, their type (app or gem), the gem name (if it's a gem), the test framework(s) used, and the projects that depend on them.
|
77
90
|
|
78
|
-
Here's an example output of the monoz inspect command:
|
91
|
+
Here's an example output of the `monoz inspect` command:
|
79
92
|
|
80
93
|
```console
|
81
94
|
$ monoz inspect
|
data/bin/monoz
CHANGED
data/lib/monoz/cli/main.rb
CHANGED
@@ -12,8 +12,10 @@ module Monoz
|
|
12
12
|
Monoz::Services::InitService.new(self).call(path)
|
13
13
|
end
|
14
14
|
|
15
|
-
desc "bundle", "Run bundle commands in all projects"
|
16
|
-
|
15
|
+
desc "bundle [COMMAND]", "Run bundle commands in all projects"
|
16
|
+
def bundle(*command)
|
17
|
+
Monoz::Services::BundleService.new(self).call(*command)
|
18
|
+
end
|
17
19
|
|
18
20
|
desc "inspect", "Inspect this monozrepo"
|
19
21
|
subcommand "inspect", Monoz::Cli::Inspect
|
data/lib/monoz/configuration.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "yaml"
|
2
4
|
require "active_support/core_ext/module/delegation"
|
3
5
|
|
@@ -27,17 +29,17 @@ module Monoz
|
|
27
29
|
end
|
28
30
|
|
29
31
|
private
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
def find_config_file(dir_path)
|
33
|
+
while dir_path != "/"
|
34
|
+
config_file_path = File.join(dir_path, "monoz.yml")
|
35
|
+
return config_file_path if File.exist?(config_file_path)
|
34
36
|
|
35
|
-
|
37
|
+
dir_path = File.dirname(dir_path)
|
38
|
+
end
|
36
39
|
end
|
37
|
-
end
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
41
|
+
def load_config(config_file_path)
|
42
|
+
YAML.load_file(config_file_path)
|
43
|
+
end
|
42
44
|
end
|
43
45
|
end
|
data/lib/monoz/project.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Monoz
|
2
4
|
class Project
|
3
5
|
attr_reader :name, :root_path, :gemspec, :type, :dependencies, :gem_name, :dependants
|
4
6
|
|
5
7
|
def initialize(root_path)
|
6
8
|
@root_path = root_path
|
7
|
-
|
9
|
+
|
8
10
|
parse_project_files
|
9
11
|
parse_dependencies
|
10
12
|
|
@@ -46,68 +48,68 @@ module Monoz
|
|
46
48
|
end
|
47
49
|
|
48
50
|
private
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
def parse_project_files
|
52
|
+
@gemspec = parse_gemspec
|
53
|
+
end
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
55
|
+
def parse_dependencies
|
56
|
+
@dependencies = gem_dependencies
|
57
|
+
end
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
+
def parse_gemspec
|
60
|
+
return nil unless (gemspec_file = gemspec_path) && File.exist?(gemspec_file)
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
spec = Gem::Specification.load(gemspec_file)
|
63
|
+
{
|
64
|
+
name: spec.name,
|
65
|
+
version: spec.version.to_s
|
66
|
+
}
|
67
|
+
end
|
66
68
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
def setup_instance_variables
|
70
|
+
@name = File.basename(root_path)
|
71
|
+
@gem_name = @gemspec.dig(:name) if is_gem?
|
72
|
+
@type = is_gem? ? "gem" : "app"
|
73
|
+
@test_frameworks =
|
74
|
+
@dependants = []
|
75
|
+
end
|
74
76
|
|
75
|
-
|
76
|
-
|
77
|
-
|
77
|
+
def gemspec_path
|
78
|
+
Dir.glob(File.join(@root_path, "*.gemspec")).first
|
79
|
+
end
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
-
|
81
|
+
def gemfile_path
|
82
|
+
Dir.glob(File.join(@root_path, "Gemfile")).first
|
83
|
+
end
|
84
|
+
|
85
|
+
def gem_dependencies
|
86
|
+
dependencies = {}
|
87
|
+
|
88
|
+
# Check if a Gemfile exists
|
89
|
+
if (gemfile = gemfile_path) && File.exist?(gemfile)
|
90
|
+
gemfile_content = File.read(gemfile)
|
91
|
+
|
92
|
+
# Use regex to find all gem entries
|
93
|
+
gem_entries = gemfile_content.scan(/gem\s+['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?(?:,\s*['"]([^'"]+)['"])?/)
|
82
94
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
# Use regex to find all gem entries
|
91
|
-
gem_entries = gemfile_content.scan(/gem\s+['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?(?:,\s*['"]([^'"]+)['"])?/)
|
92
|
-
|
93
|
-
# Add each gem and its version to the hash
|
94
|
-
gem_entries.each do |gem_entry|
|
95
|
-
gem_name = gem_entry[0]
|
96
|
-
version_spec = gem_entry[1] || ""
|
97
|
-
dependencies[gem_name] = version_spec
|
95
|
+
# Add each gem and its version to the hash
|
96
|
+
gem_entries.each do |gem_entry|
|
97
|
+
gem_name = gem_entry[0]
|
98
|
+
version_spec = gem_entry[1] || ""
|
99
|
+
dependencies[gem_name] = version_spec
|
100
|
+
end
|
98
101
|
end
|
99
|
-
end
|
100
102
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
103
|
+
# Check if a gemspec exists
|
104
|
+
if (gemspec_file = gemspec_path) && File.exist?(gemspec_file)
|
105
|
+
spec = Gem::Specification.load(gemspec_file)
|
106
|
+
spec.dependencies.each do |dep|
|
107
|
+
dependencies[dep.name] = dep.requirement.to_s
|
108
|
+
end
|
106
109
|
end
|
107
|
-
end
|
108
110
|
|
109
|
-
|
110
|
-
|
111
|
+
dependencies
|
112
|
+
end
|
111
113
|
|
112
114
|
public
|
113
115
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "pathname"
|
2
4
|
require "active_support/core_ext/module/delegation"
|
3
5
|
require "terminal-table"
|
@@ -12,13 +14,13 @@ module Monoz
|
|
12
14
|
project_folders = Monoz.config.dig("folders") || ["apps", "gems"]
|
13
15
|
|
14
16
|
search_paths = project_folders.map { |folder| File.join(file_path, folder) }
|
15
|
-
|
17
|
+
|
16
18
|
search_paths.each do |search_path|
|
17
19
|
Dir.glob(File.join(search_path, "*/Gemfile")).each do |gemfile_path|
|
18
20
|
project_path = File.dirname(gemfile_path)
|
19
21
|
project = Project.new(project_path)
|
20
22
|
if project.valid?
|
21
|
-
@items << project
|
23
|
+
@items << project
|
22
24
|
refresh_dependants(project)
|
23
25
|
end
|
24
26
|
end
|
@@ -68,7 +70,7 @@ module Monoz
|
|
68
70
|
end
|
69
71
|
table = Terminal::Table.new(
|
70
72
|
headings: ["Project", "Type", "Gem Name", "Test Framework(s)", "Dependants"],
|
71
|
-
rows
|
73
|
+
rows:,
|
72
74
|
style: { padding_left: 2, padding_right: 2, border_i: "o" },
|
73
75
|
)
|
74
76
|
puts table
|
@@ -116,6 +118,5 @@ module Monoz
|
|
116
118
|
|
117
119
|
sorted_items
|
118
120
|
end
|
119
|
-
|
120
121
|
end
|
121
122
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "yaml"
|
4
|
+
require "fileutils"
|
5
|
+
require "active_support"
|
6
|
+
|
7
|
+
module Monoz
|
8
|
+
module Services
|
9
|
+
class BundleService < Monoz::Services::BaseService
|
10
|
+
def call(*command)
|
11
|
+
Monoz.projects.order(:dependants).each do |project|
|
12
|
+
say "[#{project.name}] ", [:blue, :bold], false
|
13
|
+
say("bundle #{command.join(" ")}".strip, :green)
|
14
|
+
project.run "bundle", *command
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -11,7 +11,7 @@ module Monoz
|
|
11
11
|
project_dir = File.dirname(config_file_path)
|
12
12
|
|
13
13
|
if File.exist?(config_file_path)
|
14
|
-
|
14
|
+
say "Error: monoz.yaml already exists in #{config_file_path}", :red
|
15
15
|
return
|
16
16
|
end
|
17
17
|
|
@@ -26,7 +26,7 @@ module Monoz
|
|
26
26
|
system "git", "init"
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
say "Successfully initialized Monoz in #{project_dir}", :green
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
data/lib/monoz/version.rb
CHANGED
data/lib/monoz.rb
CHANGED
@@ -10,7 +10,6 @@ module Monoz
|
|
10
10
|
end
|
11
11
|
|
12
12
|
module Cli
|
13
|
-
autoload "Bundle", "monoz/cli/bundle"
|
14
13
|
autoload "Inspect", "monoz/cli/inspect"
|
15
14
|
autoload "Main", "monoz/cli/main"
|
16
15
|
autoload "Run", "monoz/cli/run"
|
@@ -18,6 +17,7 @@ module Monoz
|
|
18
17
|
|
19
18
|
module Services
|
20
19
|
autoload "BaseService", "monoz/services/base_service"
|
20
|
+
autoload "BundleService", "monoz/services/bundle_service"
|
21
21
|
autoload "InitService", "monoz/services/init_service"
|
22
22
|
autoload "RunActionService", "monoz/services/run_action_service"
|
23
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monoz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kjellberg
|
@@ -60,16 +60,17 @@ executables:
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- MIT-LICENSE
|
63
64
|
- README.md
|
64
65
|
- bin/monoz
|
65
66
|
- lib/monoz.rb
|
66
|
-
- lib/monoz/cli/bundle.rb
|
67
67
|
- lib/monoz/cli/inspect.rb
|
68
68
|
- lib/monoz/cli/main.rb
|
69
69
|
- lib/monoz/configuration.rb
|
70
70
|
- lib/monoz/project.rb
|
71
71
|
- lib/monoz/project_collection.rb
|
72
72
|
- lib/monoz/services/base_service.rb
|
73
|
+
- lib/monoz/services/bundle_service.rb
|
73
74
|
- lib/monoz/services/init_service.rb
|
74
75
|
- lib/monoz/services/run_action_service.rb
|
75
76
|
- lib/monoz/version.rb
|
data/lib/monoz/cli/bundle.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "thor"
|
4
|
-
require "yaml"
|
5
|
-
|
6
|
-
module Monoz
|
7
|
-
module Cli
|
8
|
-
class Bundle < Thor
|
9
|
-
default_task :install
|
10
|
-
|
11
|
-
desc "install", "Install dependencies in all projects"
|
12
|
-
def install
|
13
|
-
Monoz.projects.order(:dependants).each do |project|
|
14
|
-
say "#{project.type} ", project.text_color, false
|
15
|
-
say "[#{project.name}] ", [:blue, :bold], false
|
16
|
-
say "bundle install", :green
|
17
|
-
project.run "bundle", "install"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
desc "update", "Update dependencies in all projects"
|
22
|
-
def update
|
23
|
-
Monoz.projects.order(:dependants).each do |project|
|
24
|
-
say "#{project.type} ", project.text_color, false
|
25
|
-
say "[#{project.name}] ", [:blue, :bold], false
|
26
|
-
say "bundle update", :green
|
27
|
-
project.run "bundle", "update"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|