multitenancy-rails 0.0.2
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 +7 -0
- data/.rspec +3 -0
- data/.standard.yml +3 -0
- data/AGENTS.md +67 -0
- data/CLAUDE.md +67 -0
- data/LICENSE.txt +21 -0
- data/README.md +574 -0
- data/Rakefile +10 -0
- data/docs/README.md +72 -0
- data/docs/api.md +130 -0
- data/docs/generator.md +88 -0
- data/docs/getting-started.md +111 -0
- data/docs/integrations.md +145 -0
- data/docs/rake-tasks.md +53 -0
- data/docs/themes.md +159 -0
- data/lib/generators/multitenancy/multitenancy_generator.rb +88 -0
- data/lib/generators/multitenancy/templates/application_controller.rb +7 -0
- data/lib/generators/multitenancy/templates/home/index.html.erb +2 -0
- data/lib/generators/multitenancy/templates/home_controller.rb +9 -0
- data/lib/generators/multitenancy/templates/importmap.rb +4 -0
- data/lib/generators/multitenancy/templates/javascript/application.js +12 -0
- data/lib/generators/multitenancy/templates/javascript/controllers/hello_controller.js +7 -0
- data/lib/generators/multitenancy/templates/layouts/application.html.erb +32 -0
- data/lib/generators/multitenancy/templates/locales/en.yml +4 -0
- data/lib/generators/multitenancy/templates/routes.rb +6 -0
- data/lib/generators/multitenancy/templates/stylesheets/application.css +13 -0
- data/lib/generators/multitenancy/templates/tailwind/application.css +4 -0
- data/lib/multitenancy/controller.rb +25 -0
- data/lib/multitenancy/integrations/factory_bot.rb +15 -0
- data/lib/multitenancy/integrations/importmap.rb +79 -0
- data/lib/multitenancy/integrations/minitest.rb +49 -0
- data/lib/multitenancy/integrations/rails.rb +15 -0
- data/lib/multitenancy/integrations/rspec.rb +58 -0
- data/lib/multitenancy/integrations/tailwind_css.rb +51 -0
- data/lib/multitenancy/integrations.rb +12 -0
- data/lib/multitenancy/rails.rb +8 -0
- data/lib/multitenancy/railtie.rb +32 -0
- data/lib/multitenancy/stim.rb +39 -0
- data/lib/multitenancy/theme.rb +66 -0
- data/lib/multitenancy/version.rb +5 -0
- data/lib/multitenancy-rails.rb +1 -0
- data/lib/multitenancy.rb +74 -0
- data/lib/tasks/multitenancy_tailwindcss.rake +58 -0
- metadata +141 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "multitenancy/rails"
|
data/lib/multitenancy.rb
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "active_support"
|
|
4
|
+
require "rails/application"
|
|
5
|
+
|
|
6
|
+
module Multitenancy
|
|
7
|
+
extend ActiveSupport::Autoload
|
|
8
|
+
|
|
9
|
+
autoload :Controller
|
|
10
|
+
autoload :Integrations
|
|
11
|
+
autoload :Railtie
|
|
12
|
+
autoload :Stim
|
|
13
|
+
autoload :Theme
|
|
14
|
+
|
|
15
|
+
class Error < StandardError; end
|
|
16
|
+
|
|
17
|
+
class << self
|
|
18
|
+
attr_reader :config
|
|
19
|
+
|
|
20
|
+
def root
|
|
21
|
+
@root ||= ::Rails::Application.find_root(Dir.pwd)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def themes_root
|
|
25
|
+
root.join("themes")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def themes
|
|
29
|
+
current_paths = themes_root.exist? ? themes_root.children.select(&:directory?).sort : []
|
|
30
|
+
keys = current_paths.map(&:to_s)
|
|
31
|
+
|
|
32
|
+
return @themes if @themes_keys == keys
|
|
33
|
+
|
|
34
|
+
@themes_cache ||= {}
|
|
35
|
+
current_paths.each { |path| @themes_cache[path.to_s] ||= Multitenancy::Theme.new(path: path) }
|
|
36
|
+
@themes_cache.delete_if { |key, _| !keys.include?(key) }
|
|
37
|
+
|
|
38
|
+
@themes_keys = keys
|
|
39
|
+
@themes = keys.map { |key| @themes_cache[key] }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def reset!
|
|
43
|
+
@themes = nil
|
|
44
|
+
@themes_keys = nil
|
|
45
|
+
@themes_cache = nil
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
@config = ActiveSupport::OrderedOptions.new
|
|
50
|
+
@config.paths = %w[
|
|
51
|
+
app/controllers
|
|
52
|
+
app/channels
|
|
53
|
+
app/helpers
|
|
54
|
+
app/services
|
|
55
|
+
app/structs
|
|
56
|
+
app/models
|
|
57
|
+
app/mailers
|
|
58
|
+
app/presenters
|
|
59
|
+
app/decorators
|
|
60
|
+
app/queries
|
|
61
|
+
app/resources
|
|
62
|
+
app/serializers
|
|
63
|
+
app/transformers
|
|
64
|
+
app/validators
|
|
65
|
+
app/workers
|
|
66
|
+
app/jobs
|
|
67
|
+
app/mailers
|
|
68
|
+
app/notifications
|
|
69
|
+
app/policies
|
|
70
|
+
lib
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
require "multitenancy/railtie"
|
|
74
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
namespace :multitenancy do
|
|
2
|
+
namespace :tailwindcss do
|
|
3
|
+
desc "Build Tailwind CSS for all multitenancy themes"
|
|
4
|
+
task build: :environment do
|
|
5
|
+
targets = Multitenancy::Integrations::TailwindCss.compilation_targets
|
|
6
|
+
|
|
7
|
+
if targets.empty?
|
|
8
|
+
puts "No multitenancy themes with Tailwind CSS found."
|
|
9
|
+
next
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
targets.each do |target|
|
|
13
|
+
theme = target[:theme]
|
|
14
|
+
puts "Building Tailwind CSS for theme '#{theme.name}'..."
|
|
15
|
+
|
|
16
|
+
command = Multitenancy::Integrations::TailwindCss.compile_command(target, debug: Rails.env.development?)
|
|
17
|
+
|
|
18
|
+
system(*command, exception: true)
|
|
19
|
+
puts " ✓ #{target[:output]}"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
desc "Watch and build Tailwind CSS for all multitenancy themes"
|
|
24
|
+
task watch: :environment do
|
|
25
|
+
targets = Multitenancy::Integrations::TailwindCss.compilation_targets
|
|
26
|
+
|
|
27
|
+
if targets.empty?
|
|
28
|
+
puts "No multitenancy themes with Tailwind CSS found."
|
|
29
|
+
next
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
pids = targets.map do |target|
|
|
33
|
+
theme = target[:theme]
|
|
34
|
+
puts "Watching Tailwind CSS for theme '#{theme.name}'..."
|
|
35
|
+
|
|
36
|
+
command = Multitenancy::Integrations::TailwindCss.watch_command(target, debug: true)
|
|
37
|
+
|
|
38
|
+
spawn(*command)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
trap("INT") do
|
|
42
|
+
pids.each { |pid| Process.kill("INT", pid) rescue nil }
|
|
43
|
+
exit
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
trap("TERM") do
|
|
47
|
+
pids.each { |pid| Process.kill("TERM", pid) rescue nil }
|
|
48
|
+
exit
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
Process.waitall
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
if Rake::Task.task_defined?("assets:precompile")
|
|
57
|
+
Rake::Task["assets:precompile"].enhance(["multitenancy:tailwindcss:build"])
|
|
58
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: multitenancy-rails
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Marcos G. Zimmermann
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: zeitwerk
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: activesupport
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: railties
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: standard
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
68
|
+
description: Multitenancy for Rails applications
|
|
69
|
+
email:
|
|
70
|
+
- mgzmaster@gmail.com
|
|
71
|
+
executables: []
|
|
72
|
+
extensions: []
|
|
73
|
+
extra_rdoc_files: []
|
|
74
|
+
files:
|
|
75
|
+
- ".rspec"
|
|
76
|
+
- ".standard.yml"
|
|
77
|
+
- AGENTS.md
|
|
78
|
+
- CLAUDE.md
|
|
79
|
+
- LICENSE.txt
|
|
80
|
+
- README.md
|
|
81
|
+
- Rakefile
|
|
82
|
+
- docs/README.md
|
|
83
|
+
- docs/api.md
|
|
84
|
+
- docs/generator.md
|
|
85
|
+
- docs/getting-started.md
|
|
86
|
+
- docs/integrations.md
|
|
87
|
+
- docs/rake-tasks.md
|
|
88
|
+
- docs/themes.md
|
|
89
|
+
- lib/generators/multitenancy/multitenancy_generator.rb
|
|
90
|
+
- lib/generators/multitenancy/templates/application_controller.rb
|
|
91
|
+
- lib/generators/multitenancy/templates/home/index.html.erb
|
|
92
|
+
- lib/generators/multitenancy/templates/home_controller.rb
|
|
93
|
+
- lib/generators/multitenancy/templates/importmap.rb
|
|
94
|
+
- lib/generators/multitenancy/templates/javascript/application.js
|
|
95
|
+
- lib/generators/multitenancy/templates/javascript/controllers/hello_controller.js
|
|
96
|
+
- lib/generators/multitenancy/templates/layouts/application.html.erb
|
|
97
|
+
- lib/generators/multitenancy/templates/locales/en.yml
|
|
98
|
+
- lib/generators/multitenancy/templates/routes.rb
|
|
99
|
+
- lib/generators/multitenancy/templates/stylesheets/application.css
|
|
100
|
+
- lib/generators/multitenancy/templates/tailwind/application.css
|
|
101
|
+
- lib/multitenancy-rails.rb
|
|
102
|
+
- lib/multitenancy.rb
|
|
103
|
+
- lib/multitenancy/controller.rb
|
|
104
|
+
- lib/multitenancy/integrations.rb
|
|
105
|
+
- lib/multitenancy/integrations/factory_bot.rb
|
|
106
|
+
- lib/multitenancy/integrations/importmap.rb
|
|
107
|
+
- lib/multitenancy/integrations/minitest.rb
|
|
108
|
+
- lib/multitenancy/integrations/rails.rb
|
|
109
|
+
- lib/multitenancy/integrations/rspec.rb
|
|
110
|
+
- lib/multitenancy/integrations/tailwind_css.rb
|
|
111
|
+
- lib/multitenancy/rails.rb
|
|
112
|
+
- lib/multitenancy/railtie.rb
|
|
113
|
+
- lib/multitenancy/stim.rb
|
|
114
|
+
- lib/multitenancy/theme.rb
|
|
115
|
+
- lib/multitenancy/version.rb
|
|
116
|
+
- lib/tasks/multitenancy_tailwindcss.rake
|
|
117
|
+
homepage: https://github.com/marcosgz/multitenancy-rails
|
|
118
|
+
licenses:
|
|
119
|
+
- MIT
|
|
120
|
+
metadata:
|
|
121
|
+
homepage_uri: https://github.com/marcosgz/multitenancy-rails
|
|
122
|
+
source_code_uri: https://github.com/marcosgz/multitenancy-rails
|
|
123
|
+
changelog_uri: https://github.com/marcosgz/multitenancy-rails/blob/main/CHANGELOG.md
|
|
124
|
+
rdoc_options: []
|
|
125
|
+
require_paths:
|
|
126
|
+
- lib
|
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '3.1'
|
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
|
+
requirements:
|
|
134
|
+
- - ">="
|
|
135
|
+
- !ruby/object:Gem::Version
|
|
136
|
+
version: '0'
|
|
137
|
+
requirements: []
|
|
138
|
+
rubygems_version: 4.0.16
|
|
139
|
+
specification_version: 4
|
|
140
|
+
summary: Multitenancy for Rails applications
|
|
141
|
+
test_files: []
|