mono_repo_deps 0.1.13 → 0.2.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
  SHA256:
3
- metadata.gz: 753c01bf44250b01efb5d8cbc531c0dff8ffc286f4b188871c9918fac7b2e470
4
- data.tar.gz: ef3809b782fc7dd37ea35c0cfa96e24ede49e29b3a99ab4392f27ee55a512a83
3
+ metadata.gz: 689c1b114e7155c4f979478cf0923505fa425c106f9b9a9f2f9cc019d9539a4e
4
+ data.tar.gz: dc52f23c181e507fac026baedd3a5e11277df5b15fb9b81723ebae0fa04884bb
5
5
  SHA512:
6
- metadata.gz: 9b913cf21b3d81488e457f2d258dafe97d6bb6b1315a62874b6ece02c6807c1350fdf4cc54c45e36f06d18acebbbdb9734a3dc518e1488f2b0e6b2a81728c310
7
- data.tar.gz: 4f6f61ba7ae8e7d98d30eac631e60432b8ebcbbb2a88383bc8a0ce1aea63726dd4fb29e977d66085274e67ec26d8c30cb3df0c71557e525aa07dd206b1d7f7bf
6
+ metadata.gz: 3372ecbbf1912fa2ea402467d760a486dfdfaf2e4acb7dd9c99236d6b58a89cea20b0c2adf44681fe956fee140f338ff405cb3297f3c65d8562e40402252f0ab
7
+ data.tar.gz: 44ac182cf6738033b9b010931b7da4e8b96e553c8c9f89b4429e3d157f40535f75596639d827d2316972dc12b47f36e4014b9dba7a32810a010966c30c515146
@@ -4,9 +4,9 @@ end
4
4
 
5
5
  dependency do
6
6
  import 'cart_datasets'
7
- import 'orders_query_api', only: ['orders_datasets']
7
+ import 'orders_query_api'
8
8
  end
9
9
 
10
10
  dependency :test do
11
11
  import 'test_utils'
12
- end
12
+ end
@@ -1,3 +1,5 @@
1
+ require 'set'
2
+
1
3
  class MonoRepoDeps::Package::DependencyBypasser
2
4
  include MonoRepoDeps::Mixins
3
5
 
@@ -11,31 +13,28 @@ class MonoRepoDeps::Package::DependencyBypasser
11
13
  params(
12
14
  package_name: Symbol,
13
15
  env: Symbol,
14
- only: T.nilable(T::Array[Symbol]),
15
- skip: T.nilable(T::Array[Symbol]),
16
- imported: T::Array[Symbol],
17
- packages_order: T::Array[Symbol],
18
16
  )
19
17
  .returns(T::Array[Symbol])
20
18
  end
21
- def call(package_name:, env:, only: nil, skip: nil, imported: [], packages_order: [])
19
+ def call(package_name:, env:)
20
+ walk(package_name: package_name, env: env, imported: Set.new)
21
+ end
22
+
23
+ private
24
+
25
+ def walk(package_name:, env:, imported:, packages_order: [])
22
26
  package = packages_repo.find!(package_name)
23
27
 
24
- return [] if imported.include?(package_name)
25
- imported.push(package.name)
28
+ return if !imported.add?(package_name)
26
29
 
27
30
  package_dependencies = package.get_dependencies(env)
28
- package_dependencies = package_dependencies.select { only.include?(_1.name) } unless only.nil?
29
- package_dependencies = package_dependencies.reject { skip.include?(_1.name) } unless skip.nil?
30
-
31
- package_dependencies.each do |dependency_dto|
32
- self.call(
33
- package_name: dependency_dto.name,
34
- skip: dependency_dto.skip,
35
- only: dependency_dto.only,
31
+
32
+ package_dependencies.each do |name|
33
+ walk(
34
+ package_name: name,
36
35
  imported: imported,
37
36
  packages_order: packages_order,
38
- env: env
37
+ env: env# MonoRepoDeps::Package::DEFAULT_ENV,
39
38
  )
40
39
  end
41
40
 
@@ -30,7 +30,6 @@ class MonoRepoDeps::Package::Factory
30
30
  package.get_dependency_envs.each do |env|
31
31
  already_imported = package
32
32
  .get_dependencies(env)
33
- .map(&:name)
34
33
  .group_by{ |e| e }
35
34
  .select { |k, v| v.size > 1 }
36
35
  .keys
@@ -59,17 +58,13 @@ class MonoRepoDeps::Package::Factory
59
58
  sig do
60
59
  params(
61
60
  package_name: T.any(Symbol, String),
62
- skip: T.nilable(T::Array[Symbol]),
63
- only: T.nilable(T::Array[Symbol]),
64
61
  )
65
62
  .void
66
63
  end
67
- def import(package_name, skip: nil, only: nil)
64
+ def import(package_name)
68
65
  package_name = package_name.to_sym
69
- skip = skip&.map(&:to_sym)
70
- only = only&.map(&:to_sym)
71
66
 
72
- @dependencies[@current_env] << MonoRepoDeps::Package::DependencyDto.new(name: package_name, skip: skip, only: only)
67
+ @dependencies[@current_env] << package_name
73
68
 
74
69
  nil
75
70
  end
@@ -14,24 +14,32 @@ class MonoRepoDeps::Package::Initializer
14
14
  params(
15
15
  package_name: T.any(Symbol, String),
16
16
  env: Symbol,
17
- imported: T::Array[Symbol]
17
+ prevent_eager_load: T::Boolean
18
18
  )
19
19
  .void
20
20
  end
21
- def call(package_name, env:, imported: [])
22
- package_name = package_name.to_sym
23
- packages_import_order = []
21
+ def call(package_name, env:, prevent_eager_load: false)
22
+ package = repo.find!(package_name.to_sym)
23
+ sorted_packages = nil
24
24
 
25
25
  time = Benchmark.realtime do
26
- packages_import_order = dependency_bypasser
27
- .call(package_name: package_name, env: env, imported: imported)
28
- .map { repo.find(_1) }
29
- .each { MonoRepoDeps.current_project.loader.push_dir(_1.workdir_path) }
30
- .tap { MonoRepoDeps.current_project.loader.setup }
31
- .each { |package| require package.entrypoint_file if File.exist?(package.entrypoint_file) }
26
+ sorted_packages = dependency_bypasser
27
+ .call(package_name: package.name, env: env)
28
+ .map { |name| repo.find(name) }
29
+
30
+ sorted_packages.each do |sorted_package|
31
+ MonoRepoDeps.current_project.loader.push_dir(sorted_package.workdir_path)
32
+ MonoRepoDeps.current_project.loader.loader.do_not_eager_load(sorted_package.workdir_path) if prevent_eager_load
33
+ end
34
+
35
+ MonoRepoDeps.current_project.loader.setup
36
+
37
+ sorted_packages.each do |package|
38
+ require package.entrypoint_file if File.exist?(package.entrypoint_file)
39
+ end
32
40
  end
33
41
 
34
- puts "imported package '#{package_name}' with #{packages_import_order.size} dependencies in #{'%.2f' % time} seconds for env: #{env}"
42
+ puts "imported package '#{package_name}' with #{sorted_packages.size} dependencies in #{'%.2f' % time} seconds for env: #{env}"
35
43
 
36
44
  nil
37
45
  end
@@ -5,14 +5,12 @@ class MonoRepoDeps::Package
5
5
 
6
6
  DEFAULT_ENV = :_default_
7
7
 
8
- DependencyDto = Struct.new(:name, :only, :skip, keyword_init: true)
9
-
10
8
  sig do
11
9
  params(
12
10
  name: Symbol,
13
11
  root_path: String,
14
12
  package_dirname: String,
15
- dependencies: T::Hash[Symbol, DependencyDto]
13
+ dependencies: T::Hash[Symbol, Symbol]
16
14
  )
17
15
  .void
18
16
  end
@@ -26,12 +24,18 @@ class MonoRepoDeps::Package
26
24
  end
27
25
 
28
26
  sig do
29
- params(env: T.nilable(Symbol)).returns(T::Array[DependencyDto])
27
+ params(env: T.nilable(Symbol)).returns(T::Array[Symbol])
30
28
  end
31
29
  def get_dependencies(env = nil)
32
- [DEFAULT_ENV, env].uniq.compact.inject([]) do |acc, item|
33
- acc += @dependencies.fetch(item, [])
34
- end
30
+ default_deps = @dependencies.fetch(DEFAULT_ENV, [])
31
+ env_deps = @dependencies.fetch(env, [])
32
+
33
+ default_deps | env_deps
34
+ end
35
+
36
+ def get_bc
37
+ # /app/bounded_contexts/jobs/microservices/jobs_app
38
+ @root_path.split('/')[3]
35
39
  end
36
40
 
37
41
  def get_dependency_envs
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MonoRepoDeps
4
- VERSION = "0.1.13"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -45,12 +45,12 @@ module MonoRepoDeps
45
45
  class << self
46
46
  attr_accessor :current_project
47
47
 
48
- def init_package(package_name = nil, from: caller_locations.first.path, env: nil)
48
+ def init_package(package_name = nil, from: caller_locations.first.path, env: nil, prevent_eager_load: false)
49
49
  sync_current_project!(from) do
50
50
  package_name ||= Container["package.builder"].call(from, current_project.root_path, current_project.package_dirname).name
51
51
  env ||= current_project.env
52
52
 
53
- Container["package.initializer"].call(package_name, env: env)
53
+ Container["package.initializer"].call(package_name, env: env, prevent_eager_load: prevent_eager_load)
54
54
  end
55
55
  end
56
56
 
@@ -84,34 +84,6 @@ module MonoRepoDeps
84
84
  end
85
85
  end
86
86
 
87
- def check_classes(from = caller_locations.first.path)
88
- sync_current_project!(from) do
89
- all_packages = Container["package.repo"].all
90
- total_count = all_packages.size
91
- imported = []
92
- packages_order = []
93
-
94
- all_packages.each_with_index do |package, idx|
95
- puts "loading package #{package.name} (#{idx+1}/#{total_count}/#{imported.size})"
96
-
97
- Container["package.dependency_bypasser"].call(
98
- package_name: package.name,
99
- imported: imported,
100
- packages_order: packages_order,
101
- env: current_project.env
102
- )
103
- end
104
-
105
- packages_order
106
- .uniq
107
- .map { Container["package.repo"].find(_1) }
108
- .each { current_project.loader.push_dir(_1.workdir_path) }
109
- .tap { current_project.loader.setup }
110
- .each { require _1.entrypoint_file if File.exist?(_1.entrypoint_file) }
111
- .tap { current_project.loader.check_classes }
112
- end
113
- end
114
-
115
87
  def sync_current_project!(path, &block)
116
88
  path = File.expand_path(path)
117
89
  path = File.dirname(path) unless File.directory?(path)
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mono_repo_deps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Kononov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-30 00:00:00.000000000 Z
11
+ date: 2024-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: sorbet-static-and-runtime
14
+ name: sorbet-runtime
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.11105
19
+ version: 0.5.11164
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.5.11105
26
+ version: 0.5.11164
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dry-auto_inject
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -292,7 +292,7 @@ metadata:
292
292
  homepage_uri: https://github.com/droidlabs/mono_repo_deps
293
293
  source_code_uri: https://github.com/droidlabs/mono_repo_deps
294
294
  changelog_uri: https://github.com/droidlabs/mono_repo_deps
295
- post_install_message:
295
+ post_install_message:
296
296
  rdoc_options: []
297
297
  require_paths:
298
298
  - lib
@@ -308,7 +308,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
308
308
  version: '0'
309
309
  requirements: []
310
310
  rubygems_version: 3.1.6
311
- signing_key:
311
+ signing_key:
312
312
  specification_version: 4
313
313
  summary: A Ruby gem for efficiently managing dependencies within a monorepo.
314
314
  test_files: []