panda-core 0.8.4 β 0.9.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/lib/panda/core/version.rb +1 -1
- data/lib/tasks/assets.rake +124 -45
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '09a8389d14bf25a5ebc6d546d1b3857b3515166393f9f5c9ba424337932b7ea5'
|
|
4
|
+
data.tar.gz: 406ab4fe14528cf664fcffaa8a371348bb71b91a68797db02002eee69d20d8f9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 663c29fcfcb8e35cb7c4c8029ab242eae56421964bb9e9acc74b6d1c1f04d5e8ae9d4bb426349f5fec6c1df5f258047c490ba85ef5f8fc4fe429689b8538dc02
|
|
7
|
+
data.tar.gz: 22012fde38aaea3b480b31b1063515c079cc90c71e5e4a8a80428aafac457fac1a629c8b102076939bf4124ef026ae626e296d6b23b4d170b73974a62ee956bc
|
data/lib/panda/core/version.rb
CHANGED
data/lib/tasks/assets.rake
CHANGED
|
@@ -1,98 +1,177 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
#
|
|
4
|
+
# Panda Core Asset Tasks
|
|
5
|
+
#
|
|
6
|
+
# This file contains BOTH:
|
|
7
|
+
# 1. Engine-level CSS compilation (existing functionality)
|
|
8
|
+
# 2. Dummy-app asset preparation for system tests (new)
|
|
9
|
+
#
|
|
10
|
+
# These tasks are used by:
|
|
11
|
+
# - engine developers running local dev
|
|
12
|
+
# - panda-cms CI preparing dummy app
|
|
13
|
+
# - system specs that depend on Propshaft + Importmap + Cuprite
|
|
14
|
+
#
|
|
15
|
+
|
|
3
16
|
namespace :panda do
|
|
4
17
|
namespace :core do
|
|
5
18
|
namespace :assets do
|
|
19
|
+
# --------------------------------------------------------------------------
|
|
20
|
+
# πΌ 1. EXISTING TASKS β ENGINE CSS COMPILATION
|
|
21
|
+
# --------------------------------------------------------------------------
|
|
22
|
+
|
|
6
23
|
desc "Compile Panda Core assets for development (overwrites panda-core.css)"
|
|
7
24
|
task :compile do
|
|
8
|
-
puts "πΌ Compiling Panda Core assets..."
|
|
25
|
+
puts "πΌ Compiling Panda Core CSS assets (development mode)..."
|
|
9
26
|
|
|
10
|
-
|
|
11
|
-
output_dir = Panda::Core::Engine.root.join("public", "panda-core-assets")
|
|
27
|
+
output_dir = panda_engine_root.join("public", "panda-core-assets")
|
|
12
28
|
FileUtils.mkdir_p(output_dir)
|
|
13
29
|
|
|
14
|
-
# Compile CSS using Tailwind CSS v4
|
|
15
30
|
compile_css_development(output_dir)
|
|
16
31
|
|
|
17
32
|
puts "π Asset compilation complete!"
|
|
18
33
|
puts "π Output directory: #{output_dir}"
|
|
19
34
|
puts ""
|
|
20
|
-
puts "π‘ CSS is served via Rack middleware from Core gem at /panda-core-assets/panda-core.css"
|
|
21
|
-
puts " No need to copy to CMS or other apps - they load it from Core automatically!"
|
|
22
35
|
end
|
|
23
36
|
|
|
24
|
-
desc "Compile and version Panda Core assets for release"
|
|
37
|
+
desc "Compile and version Panda Core CSS assets for release"
|
|
25
38
|
task :release do
|
|
26
|
-
puts "πΌ Compiling Panda Core assets for release..."
|
|
39
|
+
puts "πΌ Compiling Panda Core CSS assets for release..."
|
|
27
40
|
|
|
28
|
-
|
|
29
|
-
require_relative "../panda/core/version"
|
|
41
|
+
require_relative "../../panda/core/version"
|
|
30
42
|
version = Panda::Core::VERSION
|
|
31
|
-
puts "Version: #{version}"
|
|
32
43
|
|
|
33
|
-
|
|
34
|
-
output_dir = Panda::Core::Engine.root.join("public", "panda-core-assets")
|
|
44
|
+
output_dir = panda_engine_root.join("public", "panda-core-assets")
|
|
35
45
|
FileUtils.mkdir_p(output_dir)
|
|
36
46
|
|
|
37
|
-
# Compile CSS with versioning
|
|
38
47
|
compile_css_release(output_dir, version)
|
|
39
48
|
|
|
40
49
|
puts "π Release asset compilation complete!"
|
|
41
50
|
puts "π Output directory: #{output_dir}"
|
|
42
51
|
puts "π¦ Versioned: panda-core-#{version}.css"
|
|
43
|
-
puts "π Symlink: panda-core.css -> panda-core-#{version}.css"
|
|
44
52
|
end
|
|
45
53
|
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
# --------------------------------------------------------------------------
|
|
55
|
+
# π§© INTERNAL HELPERS (CSS)
|
|
56
|
+
# --------------------------------------------------------------------------
|
|
57
|
+
|
|
58
|
+
def panda_engine_root
|
|
59
|
+
Panda::Core::Engine.root
|
|
60
|
+
end
|
|
48
61
|
|
|
49
|
-
|
|
62
|
+
def compile_css_development(output_dir)
|
|
63
|
+
engine_root = panda_engine_root
|
|
50
64
|
input_file = engine_root.join("app/assets/tailwind/application.css")
|
|
51
65
|
output_file = output_dir.join("panda-core.css")
|
|
52
66
|
|
|
53
|
-
# Get content paths from ModuleRegistry
|
|
54
67
|
content_paths = Panda::Core::ModuleRegistry.tailwind_content_paths
|
|
55
|
-
content_flags = content_paths.map { |
|
|
68
|
+
content_flags = content_paths.map { |p| "--content '#{p}'" }.join(" ")
|
|
56
69
|
|
|
57
|
-
# Compile with all registered module content
|
|
58
70
|
cmd = "bundle exec tailwindcss -i #{input_file} -o #{output_file} #{content_flags} --minify"
|
|
59
71
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
puts "π¦ Included content from: #{Panda::Core::ModuleRegistry.registered_modules.join(", ")}" if Panda::Core::ModuleRegistry.registered_modules.any?
|
|
63
|
-
else
|
|
64
|
-
puts "β CSS compilation failed"
|
|
65
|
-
exit 1
|
|
72
|
+
unless system(cmd)
|
|
73
|
+
abort("β CSS compilation failed")
|
|
66
74
|
end
|
|
75
|
+
|
|
76
|
+
puts "β
CSS compiled: #{output_file} (#{File.size(output_file)} bytes)"
|
|
67
77
|
end
|
|
68
78
|
|
|
69
79
|
def compile_css_release(output_dir, version)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
engine_root = Panda::Core::Engine.root
|
|
80
|
+
engine_root = panda_engine_root
|
|
73
81
|
input_file = engine_root.join("app/assets/tailwind/application.css")
|
|
74
82
|
versioned_file = output_dir.join("panda-core-#{version}.css")
|
|
75
83
|
|
|
76
|
-
# Get content paths from ModuleRegistry
|
|
77
84
|
content_paths = Panda::Core::ModuleRegistry.tailwind_content_paths
|
|
78
|
-
content_flags = content_paths.map { |
|
|
85
|
+
content_flags = content_paths.map { |p| "--content '#{p}'" }.join(" ")
|
|
79
86
|
|
|
80
|
-
# Compile to versioned file with all registered module content
|
|
81
87
|
cmd = "bundle exec tailwindcss -i #{input_file} -o #{versioned_file} #{content_flags} --minify"
|
|
82
88
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
unless system(cmd)
|
|
90
|
+
abort("β CSS compilation failed")
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
symlink = output_dir.join("panda-core.css")
|
|
94
|
+
FileUtils.rm_f(symlink)
|
|
95
|
+
FileUtils.ln_sf(File.basename(versioned_file), symlink)
|
|
96
|
+
|
|
97
|
+
puts "β
Release CSS compiled + symlink generated"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# --------------------------------------------------------------------------
|
|
101
|
+
# π 2. NEW TASKS β DUMMY APP ASSET PREPARATION (FOR CI + SYSTEM TESTS)
|
|
102
|
+
# --------------------------------------------------------------------------
|
|
103
|
+
|
|
104
|
+
desc "Compile Panda Core + host app assets into spec/dummy/public/assets (CI)"
|
|
105
|
+
task compile_dummy: :environment do
|
|
106
|
+
dummy_root = find_dummy_root
|
|
107
|
+
assets_root = dummy_root.join("public/assets")
|
|
108
|
+
|
|
109
|
+
puts "π§ Compiling assets into dummy app:"
|
|
110
|
+
puts "π #{assets_root}"
|
|
111
|
+
|
|
112
|
+
FileUtils.mkdir_p(assets_root)
|
|
113
|
+
|
|
114
|
+
Dir.chdir(dummy_root) do
|
|
115
|
+
# Runs the engine's asset compile pipeline in the dummy app context
|
|
116
|
+
unless system("bundle exec rake app:panda:core:assets:compile")
|
|
117
|
+
abort("β Failed to compile Panda Core assets in dummy app")
|
|
118
|
+
end
|
|
95
119
|
end
|
|
120
|
+
|
|
121
|
+
puts "β
Dummy assets compiled"
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
desc "Generate importmap.json for Rails 8 dummy app"
|
|
125
|
+
task generate_dummy_importmap: :environment do
|
|
126
|
+
dummy_root = find_dummy_root
|
|
127
|
+
importmap_out = dummy_root.join("public/assets/importmap.json")
|
|
128
|
+
|
|
129
|
+
puts "πΊοΈ Generating importmap.json..."
|
|
130
|
+
FileUtils.mkdir_p(importmap_out.dirname)
|
|
131
|
+
|
|
132
|
+
Dir.chdir(dummy_root) do
|
|
133
|
+
map = Rails.application.importmap
|
|
134
|
+
File.write(importmap_out, JSON.pretty_generate(map.to_json))
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
puts "β
importmap.json written to #{importmap_out}"
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
desc "Verify dummy app asset readiness (fail-fast for CI)"
|
|
141
|
+
task verify_dummy: :environment do
|
|
142
|
+
dummy_root = find_dummy_root
|
|
143
|
+
assets_root = dummy_root.join("public/assets")
|
|
144
|
+
manifest = assets_root.join(".manifest.json")
|
|
145
|
+
importmap = assets_root.join("importmap.json")
|
|
146
|
+
|
|
147
|
+
abort("β Missing directory: #{assets_root}") unless Dir.exist?(assets_root)
|
|
148
|
+
abort("β Missing #{manifest}") unless File.exist?(manifest)
|
|
149
|
+
abort("β Missing #{importmap}") unless File.exist?(importmap)
|
|
150
|
+
|
|
151
|
+
begin
|
|
152
|
+
parsed = JSON.parse(File.read(manifest))
|
|
153
|
+
abort("β Empty manifest!") if parsed.empty?
|
|
154
|
+
rescue
|
|
155
|
+
abort("β Invalid .manifest.json")
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
puts "β
Dummy assets verified"
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# --------------------------------------------------------------------------
|
|
162
|
+
# π§© INTERNAL HELPERS (DUMMY APP)
|
|
163
|
+
# --------------------------------------------------------------------------
|
|
164
|
+
|
|
165
|
+
def find_dummy_root
|
|
166
|
+
root = Rails.root
|
|
167
|
+
return root if root.basename.to_s == "dummy"
|
|
168
|
+
|
|
169
|
+
# For engines, Rails.root will be e.g. panda-cms/
|
|
170
|
+
# In CI we want panda-cms/spec/dummy/
|
|
171
|
+
possible = root.join("spec/dummy")
|
|
172
|
+
return possible if possible.exist?
|
|
173
|
+
|
|
174
|
+
abort("β Cannot find dummy root at #{possible}")
|
|
96
175
|
end
|
|
97
176
|
end
|
|
98
177
|
end
|