shopify_theme_builder 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de0bb008961c3b947c4496bd5605d24144073d22d4c721587b3f529073ed1096
4
- data.tar.gz: 4e494faa701e5bd4dd47c9b609155626bab03438d85cc7a3603bd9e42e5a0ca3
3
+ metadata.gz: 307e28c3c750b87460a048c082ba3c3287a480419c1b1c52faa84660de8b543a
4
+ data.tar.gz: 1ea87aa101f2858f46090e8f12d61c231bb4671dbd10aaa53b5427497690ae28
5
5
  SHA512:
6
- metadata.gz: bd5f70a0f803adcef6eba571c822f8d7d1b45de0c24aa0360c84bc4c19c431357426d53c471c7735e3e3fdd72d1f7774d2f9d141b90409f59402e52d6f6f8cf4
7
- data.tar.gz: 94d70495fd131b5201586e2035c0d4c1ca862718547a112afb755c88b20eb3d34ba3658995c30c252de369dd60010221a213a0cd6d6d600c682a4e34adf60c9c
6
+ metadata.gz: 4997036e87e815574d49b2857e4c8f859fcd53afcd279652ec3b81b563d454bd0826c21101a616c82cb8b0b570817e1c3d6d20a827c7d91d0940f81ed5d4766c
7
+ data.tar.gz: 199222a677430c7ec42719ef04574050327f61f8648c5096b7d60c9f06ac9a4c03b42fdbc90e307f41b46fd916eebb79fbac437a82c67ba00f87ce3805126279
data/README.md CHANGED
@@ -39,6 +39,9 @@ blocks/
39
39
 
40
40
  All files inside the `button` folder will be compiled into a single `button.liquid` file in the `blocks` folder, combining the comment, doc, Liquid, JSON, CSS, and JavaScript code.
41
41
 
42
+ ## Tailwind CSS Support
43
+
44
+ ShopifyThemeBuilder also supports Tailwind CSS integration. You can specify an input CSS file that includes Tailwind directives and an output CSS file where the compiled styles will be saved. The watcher will automatically run the Tailwind build process whenever changes are detected in the components folder.
42
45
 
43
46
  ## Installation
44
47
 
@@ -53,27 +56,28 @@ bundle add shopify_theme_builder --group "development"
53
56
  To watch for changes in the default components folder and build the theme, run:
54
57
 
55
58
  ```bash
56
- bundle exec theme-watcher
59
+ bundle exec theme-builder watch
57
60
  ```
58
61
 
59
- You can customize the components folder by passing options:
60
-
61
- ```bash
62
- bundle exec theme-watcher my_components
63
- ```
62
+ You can customize multiple options when running the watcher:
63
+ - `--folders`: Specify one or more folders to watch (default is `_components`).
64
+ - `--tailwind-input-file`: Specify the Tailwind CSS input file (default is `src/styles/tailwind.css`).
65
+ - `--tailwind-output-file`: Specify the Tailwind CSS output file (default is `assets/tailwind-output.css`).
66
+ - `--skip-tailwind`: Skip the Tailwind CSS build process (default is `false`).
64
67
 
65
- If you prefer, you can import the watcher executable locally using:
68
+ If you need help with all available options, or how to set them, run:
66
69
 
67
70
  ```bash
68
- bundle binstubs shopify_theme_builder
71
+ bundle exec theme-builder help watch
69
72
  ```
70
73
 
71
- It will create a `bin/theme-watcher` file that you can run with:
74
+ ## After Running the Watcher
72
75
 
73
- ```bash
74
- bin/theme-watcher
75
- ```
76
+ The watcher will create a CSS file that can be included in your Shopify theme layout in this way:
76
77
 
78
+ ```liquid
79
+ {{ 'tailwind-output.css' | asset_url | stylesheet_tag }}
80
+ ```
77
81
 
78
82
  ## Development
79
83
 
@@ -81,10 +85,10 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
81
85
 
82
86
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, run `bin/release VERSION`, which will update the version file, create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
83
87
 
84
- ## TODO
88
+ ## Next Steps
85
89
 
86
- - [ ] Run the tailwind build process automatically.
87
- - [ ] Check if stimulus controllers are loaded correctly in Shopify themes.
90
+ - [x] Run the tailwind build process automatically.
91
+ - [ ] Add Stimulus JS support.
88
92
  - [ ] Create a command to build an example component with all the files.
89
93
  - [ ] Decompile existing Shopify files into components structure (?).
90
94
 
data/exe/theme-builder ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "shopify_theme_builder"
6
+
7
+ ShopifyThemeBuilder::CommandLine.start(ARGV)
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+
5
+ module ShopifyThemeBuilder
6
+ # CommandLine class to handle CLI commands using Thor.
7
+ class CommandLine < Thor
8
+ desc "watch", "Watch for changes in the components folder and build the theme accordingly"
9
+ method_option :folders, type: :array, default: ["_components"], desc: "Folders to watch for changes"
10
+ method_option :tailwind_input_file, type: :string, default: "./assets/tailwind.css", desc: "Tailwind CSS input file"
11
+ method_option :tailwind_output_file, type: :string, default: "./assets/tailwind-output.css",
12
+ desc: "Tailwind CSS output file"
13
+ method_option :skip_tailwind, type: :boolean, default: false, desc: "Skip Tailwind CSS processing"
14
+ def watch
15
+ ShopifyThemeBuilder.watch(
16
+ folders_to_watch: options[:folders],
17
+ tailwind_input_file: options[:tailwind_input_file],
18
+ tailwind_output_file: options[:tailwind_output_file],
19
+ skip_tailwind: options[:skip_tailwind]
20
+ )
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ShopifyThemeBuilder
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -6,16 +6,26 @@ require_relative "shopify_theme_builder/version"
6
6
  require_relative "shopify_theme_builder/watcher"
7
7
  require_relative "shopify_theme_builder/liquid_processor"
8
8
  require_relative "shopify_theme_builder/builder"
9
+ require_relative "shopify_theme_builder/command_line"
9
10
 
10
11
  # The main module for ShopifyThemeBuilder.
11
12
  module ShopifyThemeBuilder
12
13
  class << self
13
- def watch(folders_to_watch: ["_components"])
14
+ def watch(
15
+ folders_to_watch: ["_components"],
16
+ tailwind_input_file: "./assets/tailwind.css",
17
+ tailwind_output_file: "./assets/tailwind-output.css",
18
+ skip_tailwind: false
19
+ )
14
20
  create_folders(folders_to_watch)
15
21
 
16
22
  initial_build(folders_to_watch)
17
23
 
18
- watch_folders(folders_to_watch)
24
+ run_tailwind(tailwind_input_file, tailwind_output_file) unless skip_tailwind
25
+
26
+ watch_folders(folders_to_watch) do
27
+ run_tailwind(tailwind_input_file, tailwind_output_file) unless skip_tailwind
28
+ end
19
29
  end
20
30
 
21
31
  private
@@ -46,7 +56,15 @@ module ShopifyThemeBuilder
46
56
 
47
57
  Builder.new(files_to_process: [relative_filename]).build if relative_filename.start_with?(*folders_to_watch)
48
58
  end
59
+
60
+ yield if block_given?
49
61
  end
50
62
  end
63
+
64
+ def run_tailwind(tailwind_input_file, tailwind_output_file)
65
+ puts "Running Tailwind CSS build..."
66
+
67
+ system("tailwindcss", "-i", tailwind_input_file, "-o", tailwind_output_file)
68
+ end
51
69
  end
52
70
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_theme_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Massimiliano Lattanzio
@@ -38,10 +38,44 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: tailwindcss-ruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '5.0'
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '3.0'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '5.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: thor
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.4'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.4'
41
75
  email:
42
76
  - massimiliano.lattanzio@gmail.com
43
77
  executables:
44
- - theme-watcher
78
+ - theme-builder
45
79
  extensions: []
46
80
  extra_rdoc_files: []
47
81
  files:
@@ -49,9 +83,10 @@ files:
49
83
  - LICENSE.txt
50
84
  - README.md
51
85
  - Rakefile
52
- - exe/theme-watcher
86
+ - exe/theme-builder
53
87
  - lib/shopify_theme_builder.rb
54
88
  - lib/shopify_theme_builder/builder.rb
89
+ - lib/shopify_theme_builder/command_line.rb
55
90
  - lib/shopify_theme_builder/liquid_processor.rb
56
91
  - lib/shopify_theme_builder/version.rb
57
92
  - lib/shopify_theme_builder/watcher.rb
data/exe/theme-watcher DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "shopify_theme_builder"
6
-
7
- $stdout.sync = true
8
-
9
- if ARGV.empty?
10
- ShopifyThemeBuilder.watch
11
- else
12
- ShopifyThemeBuilder.watch(folders_to_watch: ARGV)
13
- end