Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
mono_repo_deps (0.2.1)
mona (0.2.3)
dry-auto_inject (~> 1.0.1)
dry-configurable (~> 1.0.1)
dry-container (~> 0.11.0)
Expand All @@ -15,7 +15,7 @@ GEM
remote: https://rubygems.org/
specs:
coderay (1.1.3)
concurrent-ruby (1.2.2)
concurrent-ruby (1.3.4)
diff-lcs (1.5.0)
dry-auto_inject (1.0.1)
dry-core (~> 1.0)
Expand All @@ -28,7 +28,7 @@ GEM
dry-core (1.0.0)
concurrent-ruby (~> 1.0)
zeitwerk (~> 2.6)
dry-inflector (1.0.0)
dry-inflector (1.1.0)
dry-system (1.0.1)
dry-auto_inject (~> 1.0, < 2)
dry-configurable (~> 1.0, < 2)
Expand All @@ -52,17 +52,19 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
sorbet-runtime (0.5.11221)
thor (1.3.0)
zeitwerk (2.6.12)
sorbet-runtime (0.5.11647)
thor (1.3.2)
zeitwerk (2.6.18)

PLATFORMS
x86_64-darwin-19
x86_64-darwin-21
x86_64-darwin-23
x86_64-linux

DEPENDENCIES
bundler (~> 2.2)
mono_repo_deps!
mona!
pry
rake (~> 13.0)
rspec (~> 3.0)
Expand Down
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MonoRepoDeps
# Mona

Dependency manager to split and organize Ruby modules and namespaces into highlevel packages and manage relations between them
Next version of [Rdm gem](https://github.com/droidlabs/rdm)
Expand All @@ -12,7 +12,7 @@ Main goal to implement the gem was to give developers an ability to keep a large

## Example Project File Structure
```bash
├── MonoRepoConfig.rb
├── Monafile.rb
├── Gemfile
├── Gemfile.lock
├── bounded_contexts
Expand Down Expand Up @@ -50,7 +50,7 @@ Main goal to implement the gem was to give developers an ability to keep a large
```

## Package
The main MonoRepoDeps entity is the "package".
The main Mona entity is the "package".
Package configuration is defined in Package.rb file.
Each package also have an 'entrypoint' file, which can be defined as package namespace module.

Expand Down Expand Up @@ -85,31 +85,31 @@ Main goal to implement the gem was to give developers an ability to keep a large
```bash
#!/usr/bin/env ruby
require 'bundler/setup'
require 'mono_repo_deps'
MonoRepoDeps.init_package
require 'mona'
Mona.init_package

Orders::ExportOrders.new.call
```

Let's take a look at ```MonoRepoDeps.init_package``` command. That is the core feature of MonoRepoDeps and it does the following actions
Let's take a look at ```Mona.init_package``` command. That is the core feature of Mona and it does the following actions
1. Detect which package the caller file belongs to
You can also provide that file directly using 'from:' parameter
```MonoRepoDeps.init_package(from: __FILE__)```
```Mona.init_package(from: __FILE__)```
or providing package name
```MonoRepoDeps.init_package('orders')```
```Mona.init_package('orders')```
2. Build dependencies tree: inside each project we have ```dependency do; end``` block which is provide us information which packages should be loaded before the current one
3. For each file in dependency tree:
* Using Project Code Loader to autoload/preload package classes and modules
* Call ```require``` for entrypoint file

## Configs
MonoRepoDeps Configs provides interface to declare and access key-value storage can be specified for certain environment
Mona Configs provides interface to declare and access key-value storage can be specified for certain environment

Instead of using ENV['SOME_VARIABLE_NAME'] in your ruby files you can set up MonoRepoDeps Configs and use env variables in your code like this:
Instead of using ENV['SOME_VARIABLE_NAME'] in your ruby files you can set up Mona Configs and use env variables in your code like this:
```ruby
MonoRepoDeps.configs.api_client.some_variable_name
Mona.configs.api_client.some_variable_name
```
Let's define MonoRepoDeps Config for ```api_client```
Let's define Mona Config for ```api_client```
```yml
# ./configs/api_client/default.yml
api_client:
Expand All @@ -120,13 +120,13 @@ Main goal to implement the gem was to give developers an ability to keep a large
some_variable_name: ENV['SOME_VARIABLE_NAME'] + ENV['TEST_ENV_NUMBER']
```

Rdm looks up for configs in directory have been set in MonoRepoConfig.rb file with ```set_configs_dir``` method
Rdm looks up for configs in directory have been set in Monafile.rb file with ```set_configs_dir``` method
Each config has at least default.yml configuration which can be complemented with :env.yml files
Running ```MonoRepoDeps.init_package``` with specified :env will check if corresponding :env.yml file exists and merge it's values to the default configuration
Running ```Mona.init_package``` with specified :env will check if corresponding :env.yml file exists and merge it's values to the default configuration

## Project
The 2 main entities within MonoRepoDeps project are 'project' and 'package'
Project declaration stored in MonoRepoConfig.rb and a parent directory of the file is considered as the project root
The 2 main entities within Mona project are 'project' and 'package'
Project declaration stored in Monafile.rb and a parent directory of the file is considered as the project root

### Project Configuration File Example

Expand Down Expand Up @@ -170,11 +170,11 @@ Main goal to implement the gem was to give developers an ability to keep a large
```

## Tasks
MonoRepoDeps tasks are an easy way to declare some procedures can be called on you packages/package
Mona tasks are an easy way to declare some procedures can be called on you packages/package

### Examples
```ruby
# MonoRepoConfig.rb
# Monafile.rb
setup do |project|
# ...
register_task :puts_package_name, on: :package do |package, args|
Expand All @@ -186,8 +186,8 @@ Main goal to implement the gem was to give developers an ability to keep a large

You can call defined task that way:
```ruby
MonoRepoDeps.tasks.puts_package_name(
packages: MonoRepoDeps.packages.filter(name: "orders"),
Mona.tasks.puts_package_name(
packages: Mona.packages.filter(name: "orders"),
args: [1, 2, 3]
)
```
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

require "bundler/setup"
require "mono_repo_deps"
require "mona"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand Down
2 changes: 1 addition & 1 deletion example/Gemfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
gem 'mono_repo_deps', path: '../'
gem 'mona', path: '../'
4 changes: 2 additions & 2 deletions example/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
mono_repo_deps (0.1.13)
mona (0.1.13)
dry-auto_inject (~> 1.0.1)
dry-configurable (~> 1.0.1)
dry-container (~> 0.11.0)
Expand Down Expand Up @@ -45,7 +45,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
mono_repo_deps!
mona!

BUNDLED WITH
2.4.20
File renamed without changes.
8 changes: 4 additions & 4 deletions example/bounded_contexts/cart/cart_app/bin/console
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'mono_repo_deps'
require 'mona'

# MonoRepoDeps.init(__dir__)
# Mona.init(__dir__)

MonoRepoDeps.import_package(:storefront_core)
Mona.import_package(:storefront_core)

require 'irb'
IRB.start
IRB.start
6 changes: 3 additions & 3 deletions example/bounded_contexts/cart/cart_core/bin/console
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'mono_repo_deps'
require 'mona'

MonoRepoDeps.init(__dir__)
Mona.init(__dir__)

require 'irb'
IRB.start
IRB.start
6 changes: 3 additions & 3 deletions example/bounded_contexts/cart/cart_datasets/bin/console
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'mono_repo_deps'
require 'mona'

MonoRepoDeps.init(__dir__)
Mona.init(__dir__)

require 'irb'
IRB.start
IRB.start
6 changes: 3 additions & 3 deletions example/bounded_contexts/orders/orders_app/bin/console
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'mono_repo_deps'
require 'mona'

MonoRepoDeps.init(__dir__)
Mona.init(__dir__)

require 'irb'
IRB.start
IRB.start
6 changes: 3 additions & 3 deletions example/bounded_contexts/orders/orders_core/bin/console
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'mono_repo_deps'
require 'mona'

MonoRepoDeps.init(__dir__)
Mona.init(__dir__)

require 'irb'
IRB.start
IRB.start
6 changes: 3 additions & 3 deletions example/bounded_contexts/orders/orders_datasets/bin/console
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'mono_repo_deps'
require 'mona'

MonoRepoDeps.init(__dir__)
Mona.init(__dir__)

require 'irb'
IRB.start
IRB.start
6 changes: 3 additions & 3 deletions example/bounded_contexts/orders/orders_query_api/bin/console
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'mono_repo_deps'
require 'mona'

MonoRepoDeps.init(__dir__)
Mona.init(__dir__)

require 'irb'
IRB.start
IRB.start
6 changes: 3 additions & 3 deletions example/bounded_contexts/orders/paypal_client/bin/console
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'mono_repo_deps'
require 'mona'

MonoRepoDeps.init(__dir__)
Mona.init(__dir__)

require 'irb'
IRB.start
IRB.start
6 changes: 3 additions & 3 deletions example/bounded_contexts/shared/db_connection/bin/console
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'mono_repo_deps'
require 'mona'

MonoRepoDeps.init(__dir__)
Mona.init(__dir__)

require 'irb'
IRB.start
IRB.start
6 changes: 3 additions & 3 deletions example/bounded_contexts/shared/test_utils/bin/console
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'mono_repo_deps'
require 'mona'

MonoRepoDeps.init(__dir__)
Mona.init(__dir__)

require 'irb'
IRB.start
IRB.start
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'mono_repo_deps'
require 'mona'

MonoRepoDeps.init(__dir__)
Mona.init(__dir__)

require 'irb'
IRB.start
IRB.start
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'mono_repo_deps'
require 'mona'

MonoRepoDeps.init(__dir__)
Mona.init(__dir__)

require 'irb'
IRB.start
IRB.start
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'mono_repo_deps'
require 'mona'

MonoRepoDeps.init(__dir__)
Mona.init(__dir__)

require 'irb'
IRB.start
IRB.start
15 changes: 15 additions & 0 deletions exe/mona
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "mona"
require "thor"

class MonaCli < Thor
desc "mona cd PACKAGE", "go to PACKAGE"
def cd(package)
puts "cd #{Mona.packages(File.expand_path(".")).find(package.to_sym).root_path}"
end
end

MonaCli.start(ARGV)
Loading