shopify_theme_builder 0.1.0.pre → 0.2.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/AGENTS.md +121 -0
- data/LICENSE.txt +1 -1
- data/README.md +74 -9
- data/exe/theme-watcher +13 -0
- data/lib/shopify_theme_builder/builder.rb +22 -0
- data/lib/shopify_theme_builder/liquid_processor.rb +164 -0
- data/lib/shopify_theme_builder/version.rb +1 -1
- data/lib/shopify_theme_builder/watcher.rb +27 -0
- data/lib/shopify_theme_builder.rb +46 -2
- metadata +44 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: de0bb008961c3b947c4496bd5605d24144073d22d4c721587b3f529073ed1096
|
|
4
|
+
data.tar.gz: 4e494faa701e5bd4dd47c9b609155626bab03438d85cc7a3603bd9e42e5a0ca3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd5f70a0f803adcef6eba571c822f8d7d1b45de0c24aa0360c84bc4c19c431357426d53c471c7735e3e3fdd72d1f7774d2f9d141b90409f59402e52d6f6f8cf4
|
|
7
|
+
data.tar.gz: 94d70495fd131b5201586e2035c0d4c1ca862718547a112afb755c88b20eb3d34ba3658995c30c252de369dd60010221a213a0cd6d6d600c682a4e34adf60c9c
|
data/AGENTS.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
This document provides guidance for AI agents working on the ShopifyThemeBuilder Ruby gem.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
ShopifyThemeBuilder is a Ruby gem that provides an opinionated builder for Shopify themes with the following key features:
|
|
8
|
+
- Component-based nested folder structure
|
|
9
|
+
- Tailwind CSS integration
|
|
10
|
+
- Stimulus framework support
|
|
11
|
+
- Streamlined Shopify theme development workflow
|
|
12
|
+
|
|
13
|
+
## Project Structure
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
shopify_theme_builder/
|
|
17
|
+
├── lib/
|
|
18
|
+
│ ├── shopify_theme_builder.rb # Main gem entry point
|
|
19
|
+
│ └── shopify_theme_builder/
|
|
20
|
+
│ └── version.rb # Gem version definition
|
|
21
|
+
├── spec/ # Test files
|
|
22
|
+
├── bin/ # Executable scripts
|
|
23
|
+
├── sig/ # RBS type signatures
|
|
24
|
+
├── Gemfile # Dependencies
|
|
25
|
+
├── Rakefile # Rake tasks
|
|
26
|
+
├── shopify_theme_builder.gemspec # Gem specification
|
|
27
|
+
└── README.md # Project documentation
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Key Information
|
|
31
|
+
|
|
32
|
+
- **Language**: Ruby (>= 3.2.0 required)
|
|
33
|
+
- **Purpose**: Shopify theme development tooling
|
|
34
|
+
- **Architecture**: Component-based approach with modern frontend tools
|
|
35
|
+
- **License**: MIT
|
|
36
|
+
- **Authors**: Massimiliano Lattanzio, Nebulab Team
|
|
37
|
+
|
|
38
|
+
## Development Guidelines
|
|
39
|
+
|
|
40
|
+
### Ruby Standards
|
|
41
|
+
- Follow Ruby style conventions
|
|
42
|
+
- Maintain compatibility with Ruby 3.2+
|
|
43
|
+
- Follow semantic versioning for releases
|
|
44
|
+
- Follow Rubocop linting rules (run with `bin/rubocop`)
|
|
45
|
+
|
|
46
|
+
### Testing
|
|
47
|
+
- Use RSpec for testing (run with `bin/rspec`)
|
|
48
|
+
- Ensure all new features have corresponding tests
|
|
49
|
+
- Test files are located in the `spec/` directory
|
|
50
|
+
|
|
51
|
+
### Code Structure
|
|
52
|
+
- Main functionality should be in `lib/shopify_theme_builder/`
|
|
53
|
+
- Keep the main entry point (`lib/shopify_theme_builder.rb`) clean
|
|
54
|
+
- Use proper module namespacing under `ShopifyThemeBuilder`
|
|
55
|
+
|
|
56
|
+
### Dependencies
|
|
57
|
+
- Minimize external dependencies
|
|
58
|
+
- Consider the impact on Shopify theme development workflow
|
|
59
|
+
- Ensure compatibility with Tailwind CSS and Stimulus
|
|
60
|
+
|
|
61
|
+
## Common Tasks
|
|
62
|
+
|
|
63
|
+
### Adding New Features
|
|
64
|
+
1. Create corresponding spec files in `spec/`
|
|
65
|
+
2. Implement functionality in `lib/shopify_theme_builder/`
|
|
66
|
+
3. Update version in `lib/shopify_theme_builder/version.rb` if needed
|
|
67
|
+
4. Run tests with `bin/rspec`
|
|
68
|
+
5. Update documentation if necessary
|
|
69
|
+
|
|
70
|
+
### Development Setup
|
|
71
|
+
- Run `bin/setup` to install dependencies
|
|
72
|
+
- Use `bin/console` for interactive testing
|
|
73
|
+
- Install locally with `bundle exec rake install`
|
|
74
|
+
|
|
75
|
+
### Release Process
|
|
76
|
+
1. Run `bin/release <version>` (e.g., `bin/release 0.1.0`)
|
|
77
|
+
2. This will create a git commit updating version in `lib/shopify_theme_builder/version.rb`, create git tags and push to RubyGems
|
|
78
|
+
|
|
79
|
+
## Context for AI Agents
|
|
80
|
+
|
|
81
|
+
When working on this project:
|
|
82
|
+
|
|
83
|
+
1. **Focus Area**: This gem is specifically for Shopify theme development, so consider:
|
|
84
|
+
- Shopify Liquid templating
|
|
85
|
+
- Theme file structure requirements
|
|
86
|
+
- Asset compilation and optimization
|
|
87
|
+
- Component organization patterns
|
|
88
|
+
|
|
89
|
+
2. **Target Users**: Developers building Shopify themes who want:
|
|
90
|
+
- Better code organization
|
|
91
|
+
- Modern CSS framework integration (Tailwind)
|
|
92
|
+
- JavaScript framework integration (Stimulus)
|
|
93
|
+
- Streamlined build processes
|
|
94
|
+
|
|
95
|
+
3. **Integration Points**: Consider how this gem interacts with:
|
|
96
|
+
- Shopify CLI and development tools
|
|
97
|
+
- Tailwind CSS build processes
|
|
98
|
+
- Stimulus controller organization
|
|
99
|
+
- Component-based architecture
|
|
100
|
+
|
|
101
|
+
4. **Best Practices**:
|
|
102
|
+
- Maintain backward compatibility
|
|
103
|
+
- Provide clear error messages
|
|
104
|
+
- Support different Shopify theme structures
|
|
105
|
+
- Optimize for developer experience
|
|
106
|
+
|
|
107
|
+
## Repository Information
|
|
108
|
+
|
|
109
|
+
- **GitHub**: https://github.com/nebulab/shopify_theme_builder
|
|
110
|
+
- **Owner**: nebulab
|
|
111
|
+
- **Main Branch**: main
|
|
112
|
+
- **License**: MIT
|
|
113
|
+
- **Documentation**: https://github.com/nebulab/shopify_theme_builder#readme
|
|
114
|
+
- **Bug Reports**: https://github.com/nebulab/shopify_theme_builder/issues
|
|
115
|
+
|
|
116
|
+
## Notes
|
|
117
|
+
|
|
118
|
+
- This is currently in pre-release (version 0.1.0.pre)
|
|
119
|
+
- Usage instructions are still being developed
|
|
120
|
+
- The gem focuses on modern frontend tooling for Shopify themes
|
|
121
|
+
- Component-based architecture is a core principle
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -1,31 +1,96 @@
|
|
|
1
1
|
# ShopifyThemeBuilder
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
ShopifyThemeBuilder is a Ruby gem that facilitates the development of Shopify themes by enabling the use of a components folder where you can organize your files and separate liquid, JSON, CSS, JavaScript, comment and doc into a dedicated file. It watches for changes in your component folder and automatically compiles all files into Shopify-compatible Liquid templates.
|
|
11
|
+
|
|
12
|
+
## What problem does it solve?
|
|
13
|
+
|
|
14
|
+
Shopify themes have a specific structure where different types of files are stored in designated folders. For example:
|
|
15
|
+
- Sections: Contains Liquid files that define the structure and layout of different sections of the theme.
|
|
16
|
+
- Blocks: Contains reusable Liquid files that can be included in sections.
|
|
17
|
+
- Snippets: Contains reusable Liquid files that can be included in other files.
|
|
18
|
+
|
|
19
|
+
All these files are stored in the `sections`, `blocks`, and `snippets` folders respectively and cannot be organized in subfolders.
|
|
20
|
+
|
|
21
|
+
Additionally, all files can include JSON, comments, docs, CSS and JavaScript code, which must be included in the main Liquid file, resulting in large and hard-to-maintain files.
|
|
22
|
+
|
|
23
|
+
## How does it work?
|
|
24
|
+
|
|
25
|
+
ShopifyThemeBuilder allows you to create a `components` folder (default is `_components`) where you can organize your theme files in a more modular way. Each component can have its own comments, docs, Liquid, JSON, CSS, and JavaScript files. When you run the watcher, it monitors changes in the components folder and automatically compiles the files into the appropriate Shopify theme structure. Example:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
_components/
|
|
29
|
+
button/
|
|
30
|
+
comment.txt
|
|
31
|
+
doc.txt
|
|
32
|
+
block.liquid
|
|
33
|
+
schema.json
|
|
34
|
+
style.css
|
|
35
|
+
index.js
|
|
36
|
+
blocks/
|
|
37
|
+
button.liquid
|
|
38
|
+
```
|
|
39
|
+
|
|
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
|
+
|
|
7
42
|
|
|
8
43
|
## Installation
|
|
9
44
|
|
|
10
45
|
Install the gem and add to the application's Gemfile by executing:
|
|
11
46
|
|
|
12
47
|
```bash
|
|
13
|
-
bundle add shopify_theme_builder
|
|
48
|
+
bundle add shopify_theme_builder --group "development"
|
|
14
49
|
```
|
|
15
50
|
|
|
16
51
|
## Usage
|
|
17
52
|
|
|
18
|
-
|
|
53
|
+
To watch for changes in the default components folder and build the theme, run:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
bundle exec theme-watcher
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
You can customize the components folder by passing options:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
bundle exec theme-watcher my_components
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
If you prefer, you can import the watcher executable locally using:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
bundle binstubs shopify_theme_builder
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
It will create a `bin/theme-watcher` file that you can run with:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
bin/theme-watcher
|
|
75
|
+
```
|
|
76
|
+
|
|
19
77
|
|
|
20
78
|
## Development
|
|
21
79
|
|
|
22
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `
|
|
80
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
81
|
+
|
|
82
|
+
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
|
+
|
|
84
|
+
## TODO
|
|
23
85
|
|
|
24
|
-
|
|
86
|
+
- [ ] Run the tailwind build process automatically.
|
|
87
|
+
- [ ] Check if stimulus controllers are loaded correctly in Shopify themes.
|
|
88
|
+
- [ ] Create a command to build an example component with all the files.
|
|
89
|
+
- [ ] Decompile existing Shopify files into components structure (?).
|
|
25
90
|
|
|
26
91
|
## Contributing
|
|
27
92
|
|
|
28
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
93
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nebulab/shopify_theme_builder.
|
|
29
94
|
|
|
30
95
|
## License
|
|
31
96
|
|
data/exe/theme-watcher
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ShopifyThemeBuilder
|
|
4
|
+
# Builder is responsible for building Shopify theme files
|
|
5
|
+
# by delegating processing to appropriate classes based on file types.
|
|
6
|
+
class Builder
|
|
7
|
+
def initialize(files_to_process:)
|
|
8
|
+
@files_to_process = files_to_process
|
|
9
|
+
@processed_files = []
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def build
|
|
13
|
+
puts "Processing #{@files_to_process.count} files..."
|
|
14
|
+
|
|
15
|
+
@files_to_process.each do |file|
|
|
16
|
+
@processed_files << ShopifyThemeBuilder::LiquidProcessor.new(file).process
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
puts "Built #{@processed_files.count} files." if @processed_files.any?
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ShopifyThemeBuilder
|
|
4
|
+
# LiquidProcessor is responsible for processing Liquid files
|
|
5
|
+
# by combining various related files (Liquid, schema, CSS, JS, doc, comment)
|
|
6
|
+
# into a single compiled Liquid file suitable for Shopify themes.
|
|
7
|
+
# It supports specific Liquid file types and organizes the output
|
|
8
|
+
# into designated folders based on the file type.
|
|
9
|
+
# Requirements:
|
|
10
|
+
# - The current folder must contain one Liquid file named: section.liquid, snippet.liquid, or block.liquid.
|
|
11
|
+
# - Blocks must have a schema.json file.
|
|
12
|
+
# - Schema file must be named schema.json.
|
|
13
|
+
# - CSS file must be named style.css.
|
|
14
|
+
# - JS file must be named index.js.
|
|
15
|
+
# - Documentation file must be named doc.txt.
|
|
16
|
+
# - Comment file must be named comment.txt.
|
|
17
|
+
class LiquidProcessor
|
|
18
|
+
LIQUID_FILE_TYPES = %w[section snippet block].freeze
|
|
19
|
+
SUPPORTED_FILES = {
|
|
20
|
+
comment: "comment.txt",
|
|
21
|
+
doc: "doc.txt",
|
|
22
|
+
liquid: LIQUID_FILE_TYPES.map { |type| "#{type}.liquid" },
|
|
23
|
+
schema: "schema.json",
|
|
24
|
+
stylesheet: "style.css",
|
|
25
|
+
javascript: "index.js"
|
|
26
|
+
}.freeze
|
|
27
|
+
SUPPORTED_VALUES = SUPPORTED_FILES.values.flatten.freeze
|
|
28
|
+
|
|
29
|
+
def initialize(file)
|
|
30
|
+
@file = file
|
|
31
|
+
@contents = +""
|
|
32
|
+
@logger = Logger.new($stdout)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def process
|
|
36
|
+
return unless processable?
|
|
37
|
+
|
|
38
|
+
compile_content
|
|
39
|
+
|
|
40
|
+
File.write(compiled_filename, @contents.lstrip)
|
|
41
|
+
|
|
42
|
+
compiled_filename
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
# Returns true if the file is processable, false otherwise.
|
|
48
|
+
def processable?
|
|
49
|
+
supported? && correct_liquid_file? && correct_filename?
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Checks if the file is in the list of supported files.
|
|
53
|
+
def supported?
|
|
54
|
+
unless SUPPORTED_VALUES.include?(file_name)
|
|
55
|
+
@logger.error "Skipping unsupported file: #{@file}"
|
|
56
|
+
return false
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
true
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Checks if there is exactly one liquid file in the directory.
|
|
63
|
+
def correct_liquid_file?
|
|
64
|
+
if liquid_files.empty?
|
|
65
|
+
@logger.error "No liquid file found in #{file_dir}"
|
|
66
|
+
return false
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
if liquid_files.size > 1
|
|
70
|
+
@logger.error "Multiple liquid files found in #{file_dir}"
|
|
71
|
+
return false
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
true
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Checks if the compiled filename is valid.
|
|
78
|
+
def correct_filename?
|
|
79
|
+
if compiled_filename.nil?
|
|
80
|
+
@logger.error(
|
|
81
|
+
"Invalid file name for file: #{@file}\nProbably because the file is directly under the components folder."
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
return false
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
true
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def file_name
|
|
91
|
+
@file_name ||= File.basename(@file)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def file_dir
|
|
95
|
+
@file_dir ||= File.dirname(@file)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Returns an array of liquid files in the directory.
|
|
99
|
+
def liquid_files
|
|
100
|
+
@liquid_files ||= Dir.glob(LIQUID_FILE_TYPES.map { |type| "#{file_dir}/#{type}.liquid" })
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def liquid_file
|
|
104
|
+
@liquid_file ||= liquid_files.first
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def liquid_file_type
|
|
108
|
+
@liquid_file_type ||= File.basename(liquid_file, ".liquid")
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Returns the compiled filename based on the component name and liquid file type.
|
|
112
|
+
# Example: _folder_to_watch/button/section.liquid -> sections/button.liquid
|
|
113
|
+
def compiled_filename
|
|
114
|
+
filename_arr = file_dir.split(File::SEPARATOR) # Split the directory path into an array.
|
|
115
|
+
filename_arr = filename_arr.drop(1) # Remove the base components folder from the path. E.g., _components
|
|
116
|
+
filename_arr -= LIQUID_FILE_TYPES # Remove liquid file types from the path. E.g., section, snippet, block
|
|
117
|
+
filename_arr -= LIQUID_FILE_TYPES.map { |type| "#{type}s" } # Remove pluralized liquid file types from the path.
|
|
118
|
+
filename = filename_arr.join("--") # Join remaining parts with '--'. E.g., button--subbutton
|
|
119
|
+
|
|
120
|
+
return nil if filename.empty?
|
|
121
|
+
|
|
122
|
+
"#{liquid_file_type}s/#{filename}.liquid"
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Compiles the content by aggregating various related files.
|
|
126
|
+
def compile_content
|
|
127
|
+
SUPPORTED_FILES.each_key do |key|
|
|
128
|
+
@contents << formatted_content(key)
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Returns the formatted content for a given content type.
|
|
133
|
+
# For liquid, it returns the raw content.
|
|
134
|
+
# For others, it wraps the content in appropriate Liquid tags.
|
|
135
|
+
# E.g., {% schema %}...{% endschema %}
|
|
136
|
+
# If the file does not exist, it returns an empty string.
|
|
137
|
+
# If there is a default content method defined, it includes that content as well.
|
|
138
|
+
# E.g., for comment, it includes a default comment about the source file.
|
|
139
|
+
def formatted_content(content_type)
|
|
140
|
+
content_type_file = content_type == :liquid ? liquid_file : "#{file_dir}/#{SUPPORTED_FILES[content_type]}"
|
|
141
|
+
|
|
142
|
+
content = respond_to?("default_#{content_type}", true) ? send("default_#{content_type}") : ""
|
|
143
|
+
content += file_content(content_type_file) if File.exist?(content_type_file)
|
|
144
|
+
|
|
145
|
+
return "" if content.empty?
|
|
146
|
+
return content if content_type == :liquid
|
|
147
|
+
|
|
148
|
+
"\n{% #{content_type} %}#{content}{% end#{content_type} %}\n"
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def file_content(file)
|
|
152
|
+
content = File.read(file).strip
|
|
153
|
+
content.empty? ? "" : "\n#{content}\n"
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def default_comment
|
|
157
|
+
"\n------------------------------------------------------------\n\
|
|
158
|
+
IMPORTANT: The contents of this file are auto-generated.\n\
|
|
159
|
+
Avoid editing this file directly.\n\n\
|
|
160
|
+
Compiled from #{liquid_file}\n\
|
|
161
|
+
------------------------------------------------------------\n"
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "filewatcher"
|
|
4
|
+
|
|
5
|
+
module ShopifyThemeBuilder
|
|
6
|
+
# Watcher class for ShopifyThemeBuilder.
|
|
7
|
+
# It wraps the Filewatcher functionality to monitor file changes.
|
|
8
|
+
# It delegates method calls to the underlying Filewatcher instance.
|
|
9
|
+
# Check: https://github.com/filewatcher/filewatcher
|
|
10
|
+
class Watcher
|
|
11
|
+
def initialize(...)
|
|
12
|
+
@filewatcher = Filewatcher.new(...)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def method_missing(name, ...)
|
|
16
|
+
if @filewatcher.respond_to?(name)
|
|
17
|
+
@filewatcher.send(name, ...)
|
|
18
|
+
else
|
|
19
|
+
super
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def respond_to_missing?(name, include_private)
|
|
24
|
+
@filewatcher.respond_to?(name) || super
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -1,8 +1,52 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "fileutils"
|
|
4
|
+
require "logger"
|
|
3
5
|
require_relative "shopify_theme_builder/version"
|
|
6
|
+
require_relative "shopify_theme_builder/watcher"
|
|
7
|
+
require_relative "shopify_theme_builder/liquid_processor"
|
|
8
|
+
require_relative "shopify_theme_builder/builder"
|
|
4
9
|
|
|
10
|
+
# The main module for ShopifyThemeBuilder.
|
|
5
11
|
module ShopifyThemeBuilder
|
|
6
|
-
class
|
|
7
|
-
|
|
12
|
+
class << self
|
|
13
|
+
def watch(folders_to_watch: ["_components"])
|
|
14
|
+
create_folders(folders_to_watch)
|
|
15
|
+
|
|
16
|
+
initial_build(folders_to_watch)
|
|
17
|
+
|
|
18
|
+
watch_folders(folders_to_watch)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def create_folders(folders_to_watch)
|
|
24
|
+
puts "Creating necessary folders..."
|
|
25
|
+
|
|
26
|
+
FileUtils.mkdir_p(folders_to_watch)
|
|
27
|
+
FileUtils.mkdir_p("sections")
|
|
28
|
+
FileUtils.mkdir_p("blocks")
|
|
29
|
+
FileUtils.mkdir_p("snippets")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def initial_build(folders_to_watch)
|
|
33
|
+
puts "Doing an initial build..."
|
|
34
|
+
|
|
35
|
+
folders_to_watch.each do |folder|
|
|
36
|
+
Builder.new(files_to_process: Dir.glob("#{folder}/**/*.*")).build
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def watch_folders(folders_to_watch)
|
|
41
|
+
puts "Watching for changes in '#{folders_to_watch.join(", ")}' folders..."
|
|
42
|
+
|
|
43
|
+
Watcher.new(folders_to_watch).watch do |changes|
|
|
44
|
+
changes.each_key do |filename|
|
|
45
|
+
relative_filename = filename.gsub("#{Dir.pwd}/", "")
|
|
46
|
+
|
|
47
|
+
Builder.new(files_to_process: [relative_filename]).build if relative_filename.start_with?(*folders_to_watch)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
8
52
|
end
|
metadata
CHANGED
|
@@ -1,35 +1,71 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shopify_theme_builder
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Massimiliano Lattanzio
|
|
8
|
+
- Nebulab Team
|
|
8
9
|
bindir: exe
|
|
9
10
|
cert_chain: []
|
|
10
11
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
-
dependencies:
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: filewatcher
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.1'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.1'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: logger
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.7'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.7'
|
|
12
41
|
email:
|
|
13
42
|
- massimiliano.lattanzio@gmail.com
|
|
14
|
-
executables:
|
|
43
|
+
executables:
|
|
44
|
+
- theme-watcher
|
|
15
45
|
extensions: []
|
|
16
46
|
extra_rdoc_files: []
|
|
17
47
|
files:
|
|
48
|
+
- AGENTS.md
|
|
18
49
|
- LICENSE.txt
|
|
19
50
|
- README.md
|
|
20
51
|
- Rakefile
|
|
52
|
+
- exe/theme-watcher
|
|
21
53
|
- lib/shopify_theme_builder.rb
|
|
54
|
+
- lib/shopify_theme_builder/builder.rb
|
|
55
|
+
- lib/shopify_theme_builder/liquid_processor.rb
|
|
22
56
|
- lib/shopify_theme_builder/version.rb
|
|
57
|
+
- lib/shopify_theme_builder/watcher.rb
|
|
23
58
|
- sig/shopify_theme_builder.rbs
|
|
24
|
-
homepage: https://github.com/
|
|
59
|
+
homepage: https://github.com/nebulab/shopify_theme_builder?tab=readme-ov-file#readme
|
|
25
60
|
licenses:
|
|
26
61
|
- MIT
|
|
27
62
|
metadata:
|
|
28
63
|
allowed_push_host: https://rubygems.org
|
|
29
|
-
bug_tracker_uri: https://github.com/
|
|
30
|
-
homepage_uri: https://github.com/
|
|
31
|
-
source_code_uri: https://github.com/
|
|
32
|
-
changelog_uri: https://github.com/
|
|
64
|
+
bug_tracker_uri: https://github.com/nebulab/shopify_theme_builder/issues
|
|
65
|
+
homepage_uri: https://github.com/nebulab/shopify_theme_builder?tab=readme-ov-file#readme
|
|
66
|
+
source_code_uri: https://github.com/nebulab/shopify_theme_builder
|
|
67
|
+
changelog_uri: https://github.com/nebulab/shopify_theme_builder/releases
|
|
68
|
+
rubygems_mfa_required: 'true'
|
|
33
69
|
rdoc_options: []
|
|
34
70
|
require_paths:
|
|
35
71
|
- lib
|