plutonium 0.15.17 → 0.15.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,8 @@ module Pu
15
15
  install_dependencies
16
16
  copy_tailwind_config
17
17
  configure_application
18
+ replace_build_script
19
+ import_styles
18
20
  rescue => e
19
21
  exception "#{self.class} failed:", e
20
22
  end
@@ -23,10 +25,11 @@ module Pu
23
25
 
24
26
  def copy_tailwind_config
25
27
  copy_file "tailwind.config.js", force: true
28
+ copy_file "postcss.config.js", force: true
26
29
  end
27
30
 
28
31
  def install_dependencies
29
- run "yarn add @radioactive-labs/plutonium flowbite @tailwindcss/forms"
32
+ run "yarn add @radioactive-labs/plutonium flowbite @tailwindcss/forms @tailwindcss/typography postcss-cli cssnano"
30
33
  end
31
34
 
32
35
  def configure_application
@@ -39,6 +42,17 @@ module Pu
39
42
  configure_plutonium "config.assets.stylesheet = \"application\""
40
43
  configure_plutonium "config.assets.script = \"application\""
41
44
  end
45
+
46
+ def replace_build_script
47
+ gsub_file "package.json",
48
+ /"build:css":.*/,
49
+ '"build:css": "postcss ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css"'
50
+ end
51
+
52
+ def import_styles
53
+ prepend_to_file "app/assets/stylesheets/application.tailwind.css",
54
+ "@import \"gem:plutonium/src/css/plutonium.css\";\n"
55
+ end
42
56
  end
43
57
  end
44
58
  end
@@ -0,0 +1,12 @@
1
+ const { execSync } = require('child_process');
2
+ const plutoniumGemPath = execSync("bundle show plutonium").toString().trim();
3
+
4
+ module.exports = {
5
+ plugins: {
6
+ [`${plutoniumGemPath}/postcss-gem-import.js`]: {},
7
+ 'postcss-import': {},
8
+ tailwindcss: {},
9
+ autoprefixer: {},
10
+ cssnano: {}
11
+ }
12
+ }
@@ -18,7 +18,10 @@ module Pu
18
18
  source_module = (source_feature == "main_app") ? "ApplicationRecord" : "#{source_feature.camelize}::ResourceRecord"
19
19
 
20
20
  Plutonium.eager_load_rails!
21
- available_resources = source_module.constantize.descendants.map(&:to_s).sort
21
+ available_resources = source_module.constantize.descendants.reject do |model|
22
+ next true if model.abstract_class?
23
+ next true if source_module == "ApplicationRecord" && model.ancestors.any? { |ancestor| ancestor.to_s.end_with?("::ResourceRecord") }
24
+ end.map(&:to_s).sort
22
25
  error "No resources found" if available_resources.blank?
23
26
  selected_resources = prompt.multi_select("Select resources", available_resources)
24
27
 
@@ -33,18 +33,7 @@ module Plutonium
33
33
  head {
34
34
  render_title
35
35
  render_metatags
36
- render_security_metatags
37
- render_turbo_metatags
38
- render_font_tags
39
- render_favicon_tag
40
- render_assets_tags
41
-
42
- # plain assets
43
- # plain head
44
- # <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/quill/1.3.7/quill.snow.min.css" integrity="sha512-/FHUK/LsH78K9XTqsR9hbzr21J8B8RwHR/r8Jv9fzry6NVAOVIGFKQCNINsbhK7a1xubVu2r5QZcz2T9cKpubw==" crossorigin="anonymous" referrerpolicy="no-referrer" /> '
45
- # <script src="https://cdnjs.cloudflare.com/ajax/libs/quill/1.3.7/quill.min.js" integrity="sha512-P2W2rr8ikUPfa31PLBo5bcBQrsa+TNj8jiKadtaIrHQGMo6hQM6RdPjQYxlNguwHz8AwSQ28VkBK6kHBLgd/8g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
46
- # <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slim-select/2.6.0/slimselect.min.css" integrity="sha512-GvqWM4KWH8mbgWIyvwdH8HgjUbyZTXrCq0sjGij9fDNiXz3vJoy3jCcAaWNekH2rJe4hXVWCJKN+bEW8V7AAEQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
47
- # <script src="https://cdnjs.cloudflare.com/ajax/libs/slim-select/2.6.0/slimselect.min.js" integrity="sha512-0E8oaoA2v32h26IycsmRDShtQ8kMgD91zWVBxdIvUCjU3xBw81PV61QBsBqNQpWkp/zYJZip8Ag3ifmzz1wCKQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
36
+ render_assets
48
37
  }
49
38
  end
50
39
 
@@ -53,6 +42,7 @@ module Plutonium
53
42
  render_before_main
54
43
  render_main(&)
55
44
  render_after_main
45
+ render_body_scripts
56
46
  }
57
47
  end
58
48
 
@@ -90,6 +80,12 @@ module Plutonium
90
80
  end
91
81
 
92
82
  def render_metatags
83
+ render_base_metatags
84
+ render_security_metatags
85
+ render_turbo_metatags
86
+ end
87
+
88
+ def render_base_metatags
93
89
  meta(charset: "utf-8")
94
90
  meta(name: "viewport", content: "width=device-width,initial-scale=1")
95
91
  end
@@ -105,30 +101,35 @@ module Plutonium
105
101
  meta(name: "turbo-refresh-scroll", content: "preserve")
106
102
  end
107
103
 
108
- def render_font_tags
104
+ def render_fonts
109
105
  link(rel: "preconnect", href: "https://fonts.googleapis.com")
110
106
  link(rel: "preconnect", href: "https://fonts.gstatic.com", crossorigin: true)
111
107
  link(href: "https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap", rel: "stylesheet")
112
108
  end
113
109
 
114
- def render_favicon_tag
110
+ def render_favicon
115
111
  favicon_link_tag(Plutonium.configuration.assets.favicon) if Plutonium.configuration.assets.favicon
116
112
  end
117
113
 
118
- def render_assets_tags
119
- render_asset_style_tags
120
- render_asset_scripts_tags
114
+ def render_assets
115
+ render_favicon
116
+ render_fonts
117
+ render_styles
118
+ render_scripts
121
119
  end
122
120
 
123
- def render_asset_style_tags
121
+ def render_styles
124
122
  url = resource_asset_url_for(:css, resource_stylesheet_asset)
125
123
  stylesheet_link_tag(url, "data-turbo-track": "reload")
126
124
  end
127
125
 
128
- def render_asset_scripts_tags
126
+ def render_scripts
129
127
  url = resource_asset_url_for(:js, resource_script_asset)
130
128
  javascript_include_tag(url, "data-turbo-track": "reload", type: "module")
131
129
  end
130
+
131
+ def render_body_scripts
132
+ end
132
133
  end
133
134
  end
134
135
  end
@@ -1,5 +1,5 @@
1
1
  module Plutonium
2
- VERSION = "0.15.17"
2
+ VERSION = "0.15.19"
3
3
  NEXT_MAJOR_VERSION = VERSION.split(".").tap { |v|
4
4
  v[1] = v[1].to_i + 1
5
5
  v[2] = 0
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@radioactive-labs/plutonium",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@radioactive-labs/plutonium",
9
- "version": "0.1.9",
9
+ "version": "0.1.10",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@hotwired/stimulus": "^3.2.2",
@@ -16,6 +16,7 @@
16
16
  },
17
17
  "devDependencies": {
18
18
  "@tailwindcss/forms": "^0.5.7",
19
+ "@tailwindcss/typography": "^0.5.15",
19
20
  "autoprefixer": "^10.4.18",
20
21
  "concurrently": "^8.2.2",
21
22
  "cssnano": "^7.0.2",
@@ -1470,6 +1471,36 @@
1470
1471
  "tailwindcss": ">=3.0.0 || >= 3.0.0-alpha.1"
1471
1472
  }
1472
1473
  },
1474
+ "node_modules/@tailwindcss/typography": {
1475
+ "version": "0.5.15",
1476
+ "resolved": "https://registry.npmjs.org/@tailwindcss/typography/-/typography-0.5.15.tgz",
1477
+ "integrity": "sha512-AqhlCXl+8grUz8uqExv5OTtgpjuVIwFTSXTrh8y9/pw6q2ek7fJ+Y8ZEVw7EB2DCcuCOtEjf9w3+J3rzts01uA==",
1478
+ "dev": true,
1479
+ "license": "MIT",
1480
+ "dependencies": {
1481
+ "lodash.castarray": "^4.4.0",
1482
+ "lodash.isplainobject": "^4.0.6",
1483
+ "lodash.merge": "^4.6.2",
1484
+ "postcss-selector-parser": "6.0.10"
1485
+ },
1486
+ "peerDependencies": {
1487
+ "tailwindcss": ">=3.0.0 || insiders || >=4.0.0-alpha.20"
1488
+ }
1489
+ },
1490
+ "node_modules/@tailwindcss/typography/node_modules/postcss-selector-parser": {
1491
+ "version": "6.0.10",
1492
+ "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz",
1493
+ "integrity": "sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==",
1494
+ "dev": true,
1495
+ "license": "MIT",
1496
+ "dependencies": {
1497
+ "cssesc": "^3.0.0",
1498
+ "util-deprecate": "^1.0.2"
1499
+ },
1500
+ "engines": {
1501
+ "node": ">=4"
1502
+ }
1503
+ },
1473
1504
  "node_modules/@trysound/sax": {
1474
1505
  "version": "0.2.0",
1475
1506
  "resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz",
@@ -2829,10 +2860,11 @@
2829
2860
  }
2830
2861
  },
2831
2862
  "node_modules/cross-spawn": {
2832
- "version": "7.0.3",
2833
- "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
2834
- "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
2863
+ "version": "7.0.6",
2864
+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
2865
+ "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
2835
2866
  "dev": true,
2867
+ "license": "MIT",
2836
2868
  "dependencies": {
2837
2869
  "path-key": "^3.1.0",
2838
2870
  "shebang-command": "^2.0.0",
@@ -4401,17 +4433,38 @@
4401
4433
  "dev": true,
4402
4434
  "license": "MIT"
4403
4435
  },
4436
+ "node_modules/lodash.castarray": {
4437
+ "version": "4.4.0",
4438
+ "resolved": "https://registry.npmjs.org/lodash.castarray/-/lodash.castarray-4.4.0.tgz",
4439
+ "integrity": "sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==",
4440
+ "dev": true,
4441
+ "license": "MIT"
4442
+ },
4404
4443
  "node_modules/lodash.debounce": {
4405
4444
  "version": "4.0.8",
4406
4445
  "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
4407
4446
  "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow=="
4408
4447
  },
4448
+ "node_modules/lodash.isplainobject": {
4449
+ "version": "4.0.6",
4450
+ "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
4451
+ "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==",
4452
+ "dev": true,
4453
+ "license": "MIT"
4454
+ },
4409
4455
  "node_modules/lodash.memoize": {
4410
4456
  "version": "4.1.2",
4411
4457
  "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz",
4412
4458
  "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==",
4413
4459
  "dev": true
4414
4460
  },
4461
+ "node_modules/lodash.merge": {
4462
+ "version": "4.6.2",
4463
+ "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
4464
+ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
4465
+ "dev": true,
4466
+ "license": "MIT"
4467
+ },
4415
4468
  "node_modules/lodash.uniq": {
4416
4469
  "version": "4.5.0",
4417
4470
  "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz",
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radioactive-labs/plutonium",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Core assets for the Plutonium gem",
5
5
  "type": "module",
6
6
  "main": "src/js/core.js",
@@ -25,6 +25,7 @@
25
25
  },
26
26
  "devDependencies": {
27
27
  "@tailwindcss/forms": "^0.5.7",
28
+ "@tailwindcss/typography": "^0.5.15",
28
29
  "autoprefixer": "^10.4.18",
29
30
  "concurrently": "^8.2.2",
30
31
  "cssnano": "^7.0.2",
@@ -0,0 +1,28 @@
1
+ import { execSync } from 'child_process';
2
+
3
+ const plugin = (opts = {}) => {
4
+ return {
5
+ postcssPlugin: 'postcss-gem-import',
6
+ Once(root) {
7
+ root.walkAtRules('import', (rule) => {
8
+ const importPath = rule.params.replace(/['"]/g, '');
9
+
10
+ if (importPath.startsWith('gem:')) {
11
+ const gemName = importPath.split('gem:')[1].split('/')[0];
12
+
13
+ try {
14
+ const gemPath = execSync(`bundle show ${gemName}`, { encoding: 'utf8' }).trim();
15
+ const newPath = importPath.replace(`gem:${gemName}`, gemPath);
16
+ rule.params = `"${newPath}"`;
17
+ } catch (error) {
18
+ throw rule.error(`Failed to resolve gem path for ${gemName}: ${error.message}`);
19
+ }
20
+ }
21
+ });
22
+ }
23
+ };
24
+ };
25
+
26
+ plugin.postcss = true;
27
+
28
+ export default plugin;
data/postcss.config.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const config = {
2
2
  plugins: {
3
+ 'postcss-import': {},
3
4
  tailwindcss: {},
4
5
  autoprefixer: {}
5
6
  }
data/src/css/core.css ADDED
@@ -0,0 +1,13 @@
1
+ @layer components {
2
+ .pu-color-input::-webkit-color-swatch-wrapper {
3
+ @apply p-0;
4
+ }
5
+
6
+ .pu-color-input::-webkit-color-swatch {
7
+ @apply border-none rounded-lg;
8
+ }
9
+
10
+ .pu-color-input::-moz-color-swatch {
11
+ @apply border-none rounded-lg;
12
+ }
13
+ }