munola 0.0.0 → 0.4.4.1
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/CHANGELOG.md +47 -0
- data/README.md +98 -8
- data/exe/munola +6 -0
- data/lib/generators/munola/install/install_generator.rb +19 -0
- data/lib/munola/catalogue.rb +46 -0
- data/lib/munola/channel.rb +37 -0
- data/lib/munola/cli.rb +37 -0
- data/lib/munola/detector.rb +83 -0
- data/lib/munola/installer.rb +107 -0
- data/lib/munola/providers_config.rb +50 -0
- data/lib/munola/railtie.rb +7 -0
- data/lib/munola/version.rb +6 -0
- data/lib/munola.rb +14 -1
- metadata +69 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fc1f44ab0b5e72d5f18dda2afe879b156a0b9ac9a0ae337a1419b3641d2e91a1
|
|
4
|
+
data.tar.gz: d3f40bfc7e5c2225a268c025ef8a5ab4d141cc3109d1e0faa79c05d7204b210f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7401c008c0765293332500601bcb0243342f04e36f8332a4ca48a9f0de72525677b22aea0b1accb83989bcd8c072e70f114531c746057fd5e8a4e7288f139ef8
|
|
7
|
+
data.tar.gz: 5d91e09afc035996dfca5798b73f16f93cd4effad7a70b3da65dc919509892c5794b2dce05be6f9147e253bc02af125da98dd0ef45912ce507b5f2103f406d12
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
## munola 0.4.4.1 (2026-08-23)
|
|
2
|
+
|
|
3
|
+
The wrapper over the munola channel, first release with an implementation.
|
|
4
|
+
`munola init` writes the starter laws and upstream's bindings the way
|
|
5
|
+
`enola:install` does, then the recipe catalogue from enola-guides, binds the
|
|
6
|
+
recipes the tree shows a need for, fills the tenant foreign-key template
|
|
7
|
+
from the schema, writes `mcp-arch.yaml` with Prism and Rubydex on and fetches
|
|
8
|
+
the Rubydex library; `munola --version` names the munola version, its
|
|
9
|
+
upstream base and the binary that answered; `MUNOLA_BINARY` names a binary
|
|
10
|
+
to drive until the first munola release is cut. The channel's tag shape is
|
|
11
|
+
`munola-v<version>` on the fork's releases.
|
|
12
|
+
|
|
13
|
+
## enola 0.4.4 (2026-08-23)
|
|
14
|
+
|
|
15
|
+
The wrapper, first release with an implementation: a pure-Ruby `enola`
|
|
16
|
+
executable that drives upstream's v0.4.4. The binary is fetched on first use
|
|
17
|
+
from the release for the running platform, verified against the sha256 the
|
|
18
|
+
release publishes, and kept under `~/.cache/enola/upstream/0.4.4/`; a binary on
|
|
19
|
+
PATH is used only when it answers the pinned version; offline with an empty
|
|
20
|
+
cache is a refusal that names the cache and the release. Every argument and
|
|
21
|
+
exit code is forwarded; `--verbose` adds one stderr line naming channel,
|
|
22
|
+
version and where the binary came from; `enola --wrapper-probe` prints the
|
|
23
|
+
channel, pin, found version and which surfaces the binary answers.
|
|
24
|
+
|
|
25
|
+
Both providers by default: the gem vendors upstream's Prism provider script
|
|
26
|
+
at the pinned version and depends on the `prism` gem; `enola init` writes
|
|
27
|
+
`mcp-arch.yaml` with Prism (run by this Ruby) and Rubydex on, then runs the
|
|
28
|
+
binary's `constraints init`; the Rubydex engine library is fetched once per
|
|
29
|
+
binary version after the binary itself, a failure printed once as a named
|
|
30
|
+
skip. `Enola::Config.write_default` and `Enola::Providers` are the seams the
|
|
31
|
+
Rails layer and munola call.
|
|
32
|
+
|
|
33
|
+
## enola-rb 0.4.4 (2026-08-23)
|
|
34
|
+
|
|
35
|
+
The Rails layer, first release with an implementation. `rails generate
|
|
36
|
+
enola:install` writes `enola/constraints/` from the enola-guides starter laws,
|
|
37
|
+
binds the recipes the binary's own `constraints init` picks, writes the rest
|
|
38
|
+
as commented bindings and ignores `.enola/`; the `enola:init`,
|
|
39
|
+
`enola:snapshot` and `enola:check` rake tasks drive the binary the `enola` gem
|
|
40
|
+
fetches. A surface the pinned binary lacks is refused by name with the remedy;
|
|
41
|
+
an absent binary still leaves the laws written. Depends on `enola` at the same
|
|
42
|
+
version and on `enola-guides`. The generator writes the provider config first,
|
|
43
|
+
so a fresh app's graph carries Prism and Rubydex facts from its first snapshot.
|
|
44
|
+
|
|
45
|
+
## munola 0.0.0
|
|
46
|
+
|
|
47
|
+
Placeholder. `munola` is the same wrapper over another channel. Follows.
|
data/README.md
CHANGED
|
@@ -1,13 +1,103 @@
|
|
|
1
1
|
# enola-rb
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Three pure-Ruby gems, one repository, for running
|
|
4
|
+
[enola](https://github.com/enola-labs/enola), the architecture-graph tool,
|
|
5
|
+
from Ruby. None of them carries a binary or compiles anything.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
enola binary is on your path. Adding the `munola` gem switches it to the build
|
|
8
|
-
this project ships, which carries capabilities not yet in an upstream release.
|
|
7
|
+
## `enola`
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
The wrapper of the released enola. Its version is the upstream release it
|
|
10
|
+
drives: `enola 0.4.4` runs enola-labs' v0.4.4.
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
```ruby
|
|
13
|
+
gem "enola"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
bundle exec enola --generate .
|
|
18
|
+
bundle exec enola baseline pin .
|
|
19
|
+
bundle exec enola check .
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The first command that needs the binary downloads the release for your
|
|
23
|
+
platform (linux, darwin, windows; amd64, arm64), verifies it against the
|
|
24
|
+
sha256 file the same release publishes, and keeps it under
|
|
25
|
+
`~/.cache/enola/upstream/0.4.4/` (`ENOLA_CACHE_DIR` moves the root). An
|
|
26
|
+
`enola` already on your PATH is used only when it answers the pinned version;
|
|
27
|
+
offline with an empty cache is a refusal that names the cache and the release
|
|
28
|
+
rather than a fallback to whatever is installed. Nothing downloads at
|
|
29
|
+
`bundle install`.
|
|
30
|
+
|
|
31
|
+
Every argument and exit code is forwarded unchanged; the wrapper adds no flag
|
|
32
|
+
of its own to enola's surface. `--verbose` on any command writes one line to
|
|
33
|
+
stderr first, naming the channel, the version and where the binary came from.
|
|
34
|
+
`enola --wrapper-probe` prints the channel, the pin, the version the binary
|
|
35
|
+
answers and which surfaces it has (`constraints`, `providers`, `check`,
|
|
36
|
+
`hook`), read by running them, never by comparing version strings.
|
|
37
|
+
|
|
38
|
+
This gem is not an enola-labs release; it runs theirs.
|
|
39
|
+
|
|
40
|
+
## `enola-rb`
|
|
41
|
+
|
|
42
|
+
The Rails layer over `enola`. It depends on `enola` at the same version and on
|
|
43
|
+
[enola-guides](https://github.com/misabegovic/enola-guides), and adds nothing
|
|
44
|
+
to the binary's surface.
|
|
45
|
+
|
|
46
|
+
```ruby
|
|
47
|
+
gem "enola-rb"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
bin/rails generate enola:install
|
|
52
|
+
bin/rake enola:snapshot
|
|
53
|
+
bin/rake enola:check
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The generator writes `enola/constraints/` from the guides' starter laws (four
|
|
57
|
+
laws a Rails team keeps, each with its reason), asks the binary's own
|
|
58
|
+
`constraints init` to bind the shipped recipes whose roles resolve in the app,
|
|
59
|
+
writes every other shipped recipe as a commented binding to uncomment once the
|
|
60
|
+
directories exist, and ignores `.enola/`. It reads what `init` wrote rather
|
|
61
|
+
than its exit code, and when the binary cannot be fetched it still writes the
|
|
62
|
+
laws and says so. `enola:snapshot` generates and pins the baseline;
|
|
63
|
+
`enola:check` grades the working tree against it and fails on a new breach of
|
|
64
|
+
a declared law. A surface the pinned binary lacks is refused by name with the
|
|
65
|
+
remedy.
|
|
66
|
+
|
|
67
|
+
## `munola`
|
|
68
|
+
|
|
69
|
+
One person's taste on top of enola: the same wrapper over another channel,
|
|
70
|
+
the builds cut from [a fork of enola](https://github.com/misabegovic/enola),
|
|
71
|
+
versioned as the upstream they are built on plus a fourth segment
|
|
72
|
+
(`0.4.4.1` drives a build on v0.4.4), each release naming what differs from
|
|
73
|
+
that upstream. It is offered upstream where it fits and is not positioned
|
|
74
|
+
against it. What it adds is the channel and the catalogue.
|
|
75
|
+
|
|
76
|
+
```ruby
|
|
77
|
+
gem "munola"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
bin/rails generate munola:install --tenant-column company_id
|
|
82
|
+
bundle exec munola init .
|
|
83
|
+
bundle exec munola --version
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`munola init` does what `enola:install` does, then what only munola carries:
|
|
87
|
+
it writes the recipe catalogue the `enola-guides` gem ships (Ember
|
|
88
|
+
conventions, data ownership, API boundaries, background work, a tenant
|
|
89
|
+
foreign key) into `enola/recipes/`, binds the recipes the tree justifies
|
|
90
|
+
(`ember-cli-build.js`, a schema with `app/models`, `config/routes.rb` with
|
|
91
|
+
`app/policies`, `app/tasks`, a column most tables share confirmed against
|
|
92
|
+
`db/schema.rb`) and writes every other one as a commented binding; it fills
|
|
93
|
+
the tenant template from the schema's own table names, never from an
|
|
94
|
+
inflection table; it writes `mcp-arch.yaml` with both Ruby providers on by
|
|
95
|
+
default, Prism through the script the `enola` gem carries and Rubydex built
|
|
96
|
+
into the binary, and fetches the Rubydex library, a failed fetch reported as a
|
|
97
|
+
named skip. It never asks a question. `munola --version` names the munola
|
|
98
|
+
version, the upstream it is built on and which binary answered.
|
|
99
|
+
|
|
100
|
+
The first munola release is what makes the channel real; until it is cut,
|
|
101
|
+
`MUNOLA_BINARY=/path/to/enola` names the binary to drive, and every command
|
|
102
|
+
says so. `munola` depends on `enola` and `enola-rb` at its upstream version
|
|
103
|
+
and on `enola-guides` 0.3.1 or later.
|
data/exe/munola
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/generators"
|
|
4
|
+
require "munola"
|
|
5
|
+
|
|
6
|
+
module Munola
|
|
7
|
+
module Generators
|
|
8
|
+
class InstallGenerator < Rails::Generators::Base
|
|
9
|
+
desc "Writes enola/constraints/ and the munola recipe catalogue, binding what the tree shows a need for"
|
|
10
|
+
class_option :tenant_column, type: :string, default: nil, desc: "The column most tables carry; confirmed against db/schema.rb"
|
|
11
|
+
|
|
12
|
+
def install
|
|
13
|
+
Munola::Installer.new(destination_root, tenant_column: options[:tenant_column]).install.lines.each { |line| say line }
|
|
14
|
+
rescue Enola::Error => e
|
|
15
|
+
raise Thor::Error, "munola: #{e.message}"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "fileutils"
|
|
4
|
+
|
|
5
|
+
module Munola
|
|
6
|
+
# The recipes munola ships built in, read from the enola-guides gem so the
|
|
7
|
+
# content has one version line; the template carries a value the installer
|
|
8
|
+
# fills in from what the app shows.
|
|
9
|
+
module Catalogue
|
|
10
|
+
RECIPES = %w[ember-conventions data-ownership api-boundaries background-work tenant-foreign-key].freeze
|
|
11
|
+
TEMPLATES = %w[tenant-foreign-key].freeze
|
|
12
|
+
PLACEHOLDERS = { column: "TENANT_COLUMN", table: "TENANT_TABLE" }.freeze
|
|
13
|
+
|
|
14
|
+
def self.source_dir
|
|
15
|
+
File.join(EnolaRb::Guides.root, "recipes")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.source(name)
|
|
19
|
+
path = File.join(source_dir, "#{name}.yaml")
|
|
20
|
+
raise Enola::Unavailable, "the installed enola-guides gem has no recipe #{name}; it needs 0.3.1 or later" unless File.exist?(path)
|
|
21
|
+
|
|
22
|
+
path
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Writes every catalogue recipe the project does not already have into
|
|
26
|
+
# enola/recipes/, the template with its values filled or, without them,
|
|
27
|
+
# left as it is so the placeholders show what to decide.
|
|
28
|
+
def self.write(root, tenant: nil)
|
|
29
|
+
dir = File.join(root, "enola", "recipes")
|
|
30
|
+
FileUtils.mkdir_p(dir)
|
|
31
|
+
RECIPES.each_with_object([]) do |name, written|
|
|
32
|
+
target = File.join(dir, "#{name}.yaml")
|
|
33
|
+
next if File.exist?(target)
|
|
34
|
+
|
|
35
|
+
body = File.read(source(name))
|
|
36
|
+
body = fill(body, tenant) if TEMPLATES.include?(name) && tenant
|
|
37
|
+
File.write(target, body)
|
|
38
|
+
written << target
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.fill(body, tenant)
|
|
43
|
+
body.gsub(PLACEHOLDERS[:column], tenant.fetch(:column)).gsub(PLACEHOLDERS[:table], tenant.fetch(:table))
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Munola
|
|
4
|
+
CHANNEL = Enola::Channel.new(
|
|
5
|
+
name: "munola",
|
|
6
|
+
release_base: "https://github.com/misabegovic/enola/releases/download",
|
|
7
|
+
version: VERSION,
|
|
8
|
+
asset_prefix: "enola",
|
|
9
|
+
tag_prefix: "munola-v"
|
|
10
|
+
).freeze
|
|
11
|
+
|
|
12
|
+
# The binary this channel drives is fetched from the fork's releases; until
|
|
13
|
+
# the first one is cut, MUNOLA_BINARY names a binary to drive instead, and
|
|
14
|
+
# every command says which one answered.
|
|
15
|
+
class Resolver < Enola::Resolver
|
|
16
|
+
def initialize(override: ENV.fetch("MUNOLA_BINARY", nil), **options)
|
|
17
|
+
super(**options)
|
|
18
|
+
@override = override
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def resolve
|
|
22
|
+
return super unless @override
|
|
23
|
+
|
|
24
|
+
raise Enola::Unavailable, "MUNOLA_BINARY names #{@override}, which is not executable" unless File.executable?(@override)
|
|
25
|
+
|
|
26
|
+
Found.new(@override, "MUNOLA_BINARY (#{Enola::Probe.new(@override).version || 'no version answered'})")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.resolve
|
|
31
|
+
Resolver.new(channel: CHANNEL).resolve
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.channel_line(found = resolve)
|
|
35
|
+
"munola #{VERSION}, built on enola #{UPSTREAM_VERSION}; binary via #{found.source} (#{found.path})"
|
|
36
|
+
end
|
|
37
|
+
end
|
data/lib/munola/cli.rb
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "optparse"
|
|
4
|
+
|
|
5
|
+
module Munola
|
|
6
|
+
module CLI
|
|
7
|
+
def self.start(argv, stdout: $stdout, stderr: $stderr)
|
|
8
|
+
case argv.first
|
|
9
|
+
when "--version"
|
|
10
|
+
found = Munola.resolve
|
|
11
|
+
out, = Open3.capture2e(found.path, "--version")
|
|
12
|
+
stdout.puts Munola.channel_line(found)
|
|
13
|
+
stdout.puts out.strip
|
|
14
|
+
0
|
|
15
|
+
when "init"
|
|
16
|
+
init(argv.drop(1), stdout: stdout, stderr: stderr)
|
|
17
|
+
else
|
|
18
|
+
Enola::Runner.new(channel: CHANNEL, stderr: stderr).exec(argv)
|
|
19
|
+
end
|
|
20
|
+
rescue Enola::Error => e
|
|
21
|
+
stderr.puts "munola: #{e.message}"
|
|
22
|
+
127
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.init(args, stdout:, stderr:)
|
|
26
|
+
options = { tenant_column: nil }
|
|
27
|
+
parser = OptionParser.new do |opts|
|
|
28
|
+
opts.banner = "Usage: munola init [ROOT] [--tenant-column COLUMN]"
|
|
29
|
+
opts.on("--tenant-column COLUMN", "The column most tables carry; confirmed against db/schema.rb") { |v| options[:tenant_column] = v }
|
|
30
|
+
end
|
|
31
|
+
rest = parser.parse(args)
|
|
32
|
+
root = rest.first || Dir.pwd
|
|
33
|
+
Installer.new(root, tenant_column: options[:tenant_column], stderr: stderr).install.lines.each { |line| stdout.puts line }
|
|
34
|
+
0
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Munola
|
|
4
|
+
# Reads the tree for what the binary's own init cannot see: which catalogue
|
|
5
|
+
# recipes have the directories their roles need, and which column most
|
|
6
|
+
# tables share. It reads files; it never asks.
|
|
7
|
+
class Detector
|
|
8
|
+
Tenant = Struct.new(:column, :table, :share, keyword_init: true)
|
|
9
|
+
|
|
10
|
+
def initialize(root)
|
|
11
|
+
@root = File.expand_path(root)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def bindings
|
|
15
|
+
found = []
|
|
16
|
+
found << "ember-conventions" if file?("ember-cli-build.js")
|
|
17
|
+
found << "data-ownership" if schema? && dir?("app/models")
|
|
18
|
+
found << "api-boundaries" if file?("config/routes.rb") && dir?("app/policies")
|
|
19
|
+
found << "background-work" if dir?("app/tasks")
|
|
20
|
+
found
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def schema?
|
|
24
|
+
file?("db/schema.rb") || file?("db/structure.sql")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# The tenant column is the one present on most tables; a column the
|
|
28
|
+
# caller names is confirmed against the schema rather than trusted.
|
|
29
|
+
def tenant(column: nil)
|
|
30
|
+
tables = schema_tables
|
|
31
|
+
return nil if tables.empty?
|
|
32
|
+
|
|
33
|
+
counts = Hash.new(0)
|
|
34
|
+
tables.each_value { |columns| columns.uniq.each { |name| counts[name] += 1 } }
|
|
35
|
+
candidate = column || counts.select { |name, _| name.end_with?("_id") }.max_by { |name, count| [count, -name.length] }&.first
|
|
36
|
+
return nil unless candidate
|
|
37
|
+
|
|
38
|
+
share = counts.fetch(candidate, 0).fdiv(tables.size)
|
|
39
|
+
return nil if share < 0.5 && column.nil?
|
|
40
|
+
|
|
41
|
+
table = tenant_table(candidate, tables.keys)
|
|
42
|
+
Tenant.new(column: candidate, table: table, share: share)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def file?(rel)
|
|
48
|
+
File.file?(File.join(@root, rel))
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def dir?(rel)
|
|
52
|
+
File.directory?(File.join(@root, rel))
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def schema_tables
|
|
56
|
+
path = File.join(@root, "db", "schema.rb")
|
|
57
|
+
return {} unless File.file?(path)
|
|
58
|
+
|
|
59
|
+
tables = {}
|
|
60
|
+
current = nil
|
|
61
|
+
File.foreach(path) do |line|
|
|
62
|
+
if (m = line.match(/create_table\s+"([^"]+)"/))
|
|
63
|
+
current = m[1]
|
|
64
|
+
tables[current] = []
|
|
65
|
+
elsif current && (m = line.match(/^\s*t\.\w+\s+"([^"]+)"/))
|
|
66
|
+
tables[current] << m[1]
|
|
67
|
+
elsif line.strip == "end"
|
|
68
|
+
current = nil
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
tables
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# company_id names companies, category_id names categories, person_id
|
|
75
|
+
# names people only if the schema has that table: the table is looked up
|
|
76
|
+
# among the schema's own names, never guessed from an inflection table.
|
|
77
|
+
def tenant_table(column, names)
|
|
78
|
+
stem = column.delete_suffix("_id")
|
|
79
|
+
candidates = [stem, "#{stem}s", "#{stem}es", stem.sub(/y\z/, "ies")]
|
|
80
|
+
names.find { |name| candidates.include?(name) }
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "fileutils"
|
|
4
|
+
require "open3"
|
|
5
|
+
require "yaml"
|
|
6
|
+
|
|
7
|
+
module Munola
|
|
8
|
+
class Installer
|
|
9
|
+
Report = Struct.new(:written, :bound, :commented, :notes, keyword_init: true) do
|
|
10
|
+
def lines
|
|
11
|
+
out = written.map { |path| "wrote #{path}" }
|
|
12
|
+
out << "bound #{bound.join(', ')}" unless bound.empty?
|
|
13
|
+
out << "left commented, bind when the directories exist: #{commented.join(', ')}" unless commented.empty?
|
|
14
|
+
out + notes
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def initialize(root, tenant_column: nil, binary: nil, stderr: $stderr)
|
|
19
|
+
@root = File.expand_path(root)
|
|
20
|
+
@tenant_column = tenant_column
|
|
21
|
+
@binary = binary
|
|
22
|
+
@stderr = stderr
|
|
23
|
+
@report = Report.new(written: [], bound: [], commented: [], notes: [])
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# The Rails layer first (starter laws, the binary's own init, upstream's
|
|
27
|
+
# recipes commented), then what only munola carries: the catalogue, the
|
|
28
|
+
# bindings the tree justifies, the providers both on by default.
|
|
29
|
+
def install
|
|
30
|
+
rails = EnolaRb::Installer.new(@root, binary: resolved_binary, stderr: @stderr).install
|
|
31
|
+
@report.written.concat(rails.written)
|
|
32
|
+
@report.notes.concat(rails.notes)
|
|
33
|
+
|
|
34
|
+
detector = Detector.new(@root)
|
|
35
|
+
tenant = detector.tenant(column: @tenant_column)
|
|
36
|
+
values = tenant&.table ? { column: tenant.column, table: tenant.table } : nil
|
|
37
|
+
@report.written.concat(Catalogue.write(@root, tenant: values).map { |p| relative(p) })
|
|
38
|
+
bind(detector.bindings + (tenant&.table ? ["tenant-foreign-key"] : []))
|
|
39
|
+
note_tenant(tenant)
|
|
40
|
+
providers
|
|
41
|
+
@report.bound = (rails.bound + @bound).uniq
|
|
42
|
+
@report.commented = rails.unbound + @commented
|
|
43
|
+
@report
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
def resolved_binary
|
|
49
|
+
@binary ||= Munola.resolve.path
|
|
50
|
+
rescue Enola::Error
|
|
51
|
+
nil
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def bindings_path
|
|
55
|
+
File.join(@root, "enola", "constraints", "recipes.yaml")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def bind(names)
|
|
59
|
+
@bound = names & Catalogue::RECIPES
|
|
60
|
+
@commented = Catalogue::RECIPES - @bound
|
|
61
|
+
existing = File.exist?(bindings_path) ? File.read(bindings_path) : "use_recipe: []\n"
|
|
62
|
+
return if existing.include?("# munola catalogue")
|
|
63
|
+
|
|
64
|
+
doc = YAML.safe_load(existing) || {}
|
|
65
|
+
entries = Array(doc["use_recipe"]) + @bound.map { |name| { "recipe" => name, "as" => name, "mode" => "advisory" } }
|
|
66
|
+
body = YAML.dump({ "use_recipe" => entries }).sub(/\A---\n/, "")
|
|
67
|
+
tail = existing[/\n# Shipped recipes not bound.*\z/m].to_s
|
|
68
|
+
commented = @commented.map { |name| "# - recipe: #{name}\n# as: #{name}\n# mode: advisory\n" }.join
|
|
69
|
+
File.write(bindings_path, "#{body}#{tail}\n# munola catalogue recipes not bound because the tree shows no need for them yet.\n" \
|
|
70
|
+
"# Uncomment one to switch it on, then run `enola constraints lint`.\n#{commented}")
|
|
71
|
+
@report.written << relative(bindings_path) unless @report.written.include?(relative(bindings_path))
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def note_tenant(tenant)
|
|
75
|
+
if tenant&.table
|
|
76
|
+
note("tenant column #{tenant.column} on #{(tenant.share * 100).round}% of tables, referencing #{tenant.table}; tenant-foreign-key written with it")
|
|
77
|
+
elsif tenant && tenant.share.zero?
|
|
78
|
+
note("#{tenant.column} appears on no table in db/schema.rb; tenant-foreign-key keeps its placeholders")
|
|
79
|
+
elsif tenant
|
|
80
|
+
note("tenant column #{tenant.column} found but no table named for it in the schema; tenant-foreign-key keeps its TENANT_TABLE placeholder")
|
|
81
|
+
elsif @tenant_column
|
|
82
|
+
note("#{@tenant_column} appears on no table in db/schema.rb; tenant-foreign-key keeps its placeholders")
|
|
83
|
+
else
|
|
84
|
+
note("no column sits on most tables; tenant-foreign-key keeps its placeholders, pass --tenant-column to name one")
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def providers
|
|
89
|
+
path = ProvidersConfig.write(@root)
|
|
90
|
+
if path
|
|
91
|
+
@report.written << relative(path)
|
|
92
|
+
note("prism provider: the enola gem carries no provider script yet; mcp-arch.yaml names the slot") unless ProvidersConfig.prism_script
|
|
93
|
+
end
|
|
94
|
+
binary = resolved_binary
|
|
95
|
+
note(binary ? ProvidersConfig.fetch_rubydex(binary) : "rubydex library not fetched: no binary resolved; run `enola providers fetch rubydex` once it is")
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def relative(path)
|
|
99
|
+
path.delete_prefix("#{@root}/")
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def note(text)
|
|
103
|
+
@report.notes << text
|
|
104
|
+
@stderr.puts "munola: #{text}"
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "open3"
|
|
4
|
+
require "rbconfig"
|
|
5
|
+
|
|
6
|
+
module Munola
|
|
7
|
+
# Every munola project runs both Ruby providers by default: Prism through the
|
|
8
|
+
# script the enola gem carries, Rubydex built into the binary. The config is
|
|
9
|
+
# written once, never rewritten; the Rubydex library is fetched after the
|
|
10
|
+
# binary, and a fetch that fails is a named skip, never a silent absence.
|
|
11
|
+
module ProvidersConfig
|
|
12
|
+
RUBYDEX_VERSION = "0.4.0"
|
|
13
|
+
|
|
14
|
+
def self.write(root, ruby: RbConfig.ruby)
|
|
15
|
+
path = File.join(root, "mcp-arch.yaml")
|
|
16
|
+
return nil if File.exist?(path)
|
|
17
|
+
|
|
18
|
+
File.write(path, render(ruby))
|
|
19
|
+
path
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.render(ruby)
|
|
23
|
+
lines = ["repo: .", "repos:", " - .", "providers:"]
|
|
24
|
+
script = prism_script
|
|
25
|
+
if script
|
|
26
|
+
lines += [" - name: prism", " command: [#{ruby.inspect}, #{script.inspect}]", " expected_version: \"0.1.0\""]
|
|
27
|
+
else
|
|
28
|
+
lines << " # prism: the enola gem on this machine carries no provider script; add one here to run it"
|
|
29
|
+
end
|
|
30
|
+
lines += [" - name: rubydex", " expected_version: \"#{RUBYDEX_VERSION}\""]
|
|
31
|
+
"#{lines.join("\n")}\n"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.prism_script
|
|
35
|
+
return nil unless defined?(Enola::Providers) && Enola::Providers.respond_to?(:prism_script)
|
|
36
|
+
|
|
37
|
+
script = Enola::Providers.prism_script
|
|
38
|
+
script if script && File.exist?(script)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.fetch_rubydex(binary)
|
|
42
|
+
out, status = Open3.capture2e(binary, "providers", "fetch", "rubydex")
|
|
43
|
+
return "rubydex #{RUBYDEX_VERSION} library in place" if status.success?
|
|
44
|
+
|
|
45
|
+
"rubydex library not fetched (#{out.lines.last.to_s.strip}); the provider reads as a named skip until `enola providers fetch rubydex` succeeds"
|
|
46
|
+
rescue SystemCallError => e
|
|
47
|
+
"rubydex library not fetched (#{e.message}); the provider reads as a named skip until `enola providers fetch rubydex` succeeds"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
data/lib/munola.rb
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "enola"
|
|
4
|
+
require "enola-rb"
|
|
5
|
+
require_relative "munola/version"
|
|
6
|
+
require_relative "munola/channel"
|
|
7
|
+
require_relative "munola/catalogue"
|
|
8
|
+
require_relative "munola/detector"
|
|
9
|
+
require_relative "munola/providers_config"
|
|
10
|
+
require_relative "munola/installer"
|
|
11
|
+
require_relative "munola/cli"
|
|
12
|
+
require_relative "munola/railtie" if defined?(Rails::Railtie)
|
|
13
|
+
|
|
14
|
+
Enola.channel = Munola::CHANNEL
|
|
15
|
+
Enola.resolver_factory = -> { Munola::Resolver.new(channel: Munola::CHANNEL) }
|
|
16
|
+
|
|
3
17
|
module Munola
|
|
4
|
-
VERSION = "0.0.0"
|
|
5
18
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,87 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: munola
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Muhamed Isabegovic
|
|
8
8
|
autorequire:
|
|
9
|
-
bindir:
|
|
9
|
+
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-08-
|
|
12
|
-
dependencies:
|
|
11
|
+
date: 2026-08-23 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: enola
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - '='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 0.4.4
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - '='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 0.4.4
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: enola-rb
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - '='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 0.4.4
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - '='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 0.4.4
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: enola-guides
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 0.3.1
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 0.3.1
|
|
13
55
|
description: |
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
56
|
+
The same pure-Ruby wrapper as the enola gem over another channel: the
|
|
57
|
+
builds cut from a fork of enola, versioned as the upstream they are built
|
|
58
|
+
on plus a fourth segment, each release naming what differs. `munola init`
|
|
59
|
+
writes the recipe catalogue the enola-guides gem carries (Ember, data
|
|
60
|
+
ownership, API boundaries, background work, a tenant foreign key) into
|
|
61
|
+
the project and binds the recipes its tree justifies, and turns both Ruby
|
|
62
|
+
providers on by default. Offered upstream where it fits; no binary here,
|
|
63
|
+
nothing compiled.
|
|
18
64
|
email:
|
|
19
65
|
- m.isabegovic@hotmail.com
|
|
20
|
-
executables:
|
|
66
|
+
executables:
|
|
67
|
+
- munola
|
|
21
68
|
extensions: []
|
|
22
69
|
extra_rdoc_files: []
|
|
23
70
|
files:
|
|
71
|
+
- CHANGELOG.md
|
|
24
72
|
- LICENSE
|
|
25
73
|
- README.md
|
|
74
|
+
- exe/munola
|
|
75
|
+
- lib/generators/munola/install/install_generator.rb
|
|
26
76
|
- lib/munola.rb
|
|
77
|
+
- lib/munola/catalogue.rb
|
|
78
|
+
- lib/munola/channel.rb
|
|
79
|
+
- lib/munola/cli.rb
|
|
80
|
+
- lib/munola/detector.rb
|
|
81
|
+
- lib/munola/installer.rb
|
|
82
|
+
- lib/munola/providers_config.rb
|
|
83
|
+
- lib/munola/railtie.rb
|
|
84
|
+
- lib/munola/version.rb
|
|
27
85
|
homepage: https://github.com/misabegovic/enola-rb
|
|
28
86
|
licenses:
|
|
29
87
|
- Apache-2.0
|
|
@@ -48,5 +106,6 @@ requirements: []
|
|
|
48
106
|
rubygems_version: 3.5.22
|
|
49
107
|
signing_key:
|
|
50
108
|
specification_version: 4
|
|
51
|
-
summary:
|
|
109
|
+
summary: 'One person''s taste on top of enola: a channel of its own and a recipe catalogue
|
|
110
|
+
bound by what the tree shows.'
|
|
52
111
|
test_files: []
|