tailwind_dsl 0.0.28 → 0.0.30
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/.builders/boot.rb +4 -1
- data/.builders/generators/utilities.rb +2 -0
- data/CHANGELOG.md +14 -0
- data/lib/tailwind_dsl/etl/component_query.rb +207 -0
- data/lib/tailwind_dsl/etl/component_structures/generator.rb +4 -4
- data/lib/tailwind_dsl/etl/extractors/batch_extraction.rb +19 -34
- data/lib/tailwind_dsl/etl/extractors/data_extractor.rb +19 -4
- data/lib/tailwind_dsl/version.rb +1 -1
- data/lib/tailwind_dsl.rb +3 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +3 -3
- data/lib/tailwind_dsl/etl/component_structures/raw_component_query.rb +0 -215
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3377172941fc6ad9c2db29fa772f5743714f73ac4b4ef69f911069cb00c4c9d8
|
|
4
|
+
data.tar.gz: e0204ff9d27587aedac8f33a84d1019eaffafdefb2a8793669d2cdf03f9ea9f8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cd678c918f7b5de5a6bc91c25988f12e0de6da89a5212aeb9f363ffcaa4b0b79fb21a937c7d2d9bf8b49ecc76d43c673b0f150eca91d0907b029b25a1ed1738e
|
|
7
|
+
data.tar.gz: a0e1be62691f5aff54e4326658048968eb222b9c8002348e37950961fecba68e4aa424daeb01fd7c4ae6d1ccbb0a92338638b124325596d4235addefece8ad9b
|
data/.builders/boot.rb
CHANGED
|
@@ -6,7 +6,10 @@ CONFIG_KEY = :tailwind_dsl
|
|
|
6
6
|
|
|
7
7
|
log.kv 'working folder', Dir.pwd
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
# require 'gpt3/builder'
|
|
10
|
+
# require '/Users/davidcruwys/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/gpt3-builder-0.0.3/lib/gpt3/builder'
|
|
11
|
+
|
|
12
|
+
# require_relative '../lib/tailwind_dsl'
|
|
10
13
|
|
|
11
14
|
KConfig.configure do |config|
|
|
12
15
|
config.handlebars.defaults.add_all_defaults
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [0.0.29](https://github.com/klueless-io/tailwind_dsl/compare/v0.0.28...v0.0.29) (2022-10-26)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* rename raw_component_query ([07b736e](https://github.com/klueless-io/tailwind_dsl/commit/07b736e1602f8be4507a4d1ec5da066c7673e797))
|
|
7
|
+
|
|
8
|
+
## [0.0.28](https://github.com/klueless-io/tailwind_dsl/compare/v0.0.27...v0.0.28) (2022-10-24)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* remove sample specs from git hub actions ([2595490](https://github.com/klueless-io/tailwind_dsl/commit/2595490dc3e90d343c5e3e8f203ad4f71ba8dec4))
|
|
14
|
+
|
|
1
15
|
## [0.0.27](https://github.com/klueless-io/tailwind_dsl/compare/v0.0.26...v0.0.27) (2022-10-24)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This is Reusable across concerns, it should be in it's own folder or in the ETL root
|
|
4
|
+
# Rename to component_list or component_query
|
|
5
|
+
|
|
6
|
+
module TailwindDsl
|
|
7
|
+
module Etl
|
|
8
|
+
# Component Query will return a list of raw components that are available for processing
|
|
9
|
+
#
|
|
10
|
+
# The query requires a uikit to be passed in, this is used to flatten and filter the components
|
|
11
|
+
class ComponentQuery
|
|
12
|
+
DesignSystem = Struct.new(:name, :source_path, :target_path, keyword_init: true) do
|
|
13
|
+
def debug
|
|
14
|
+
puts format('%-30<key>s : %<value>s', key: 'Design system', value: name)
|
|
15
|
+
puts format('%-30<key>s : %<value>s', key: 'Source path', value: source_path)
|
|
16
|
+
puts format('%-30<key>s : %<value>s', key: 'Target path', value: target_path)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
Group = Struct.new(:key, :type, :sub_keys, :folder, keyword_init: true) do
|
|
21
|
+
def debug
|
|
22
|
+
puts format('%-30<key>s : %<value>s', key: 'Group key', value: key)
|
|
23
|
+
puts format('%-30<key>s : %<value>s', key: 'Group type', value: type)
|
|
24
|
+
puts format('%-30<key>s : %<value>s', key: 'Group sub keys', value: sub_keys)
|
|
25
|
+
puts format('%-30<key>s : %<value>s', key: 'Group folder', value: folder)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
FilePath = Struct.new(
|
|
30
|
+
:source_file,
|
|
31
|
+
:target_html_file,
|
|
32
|
+
:target_clean_html_file,
|
|
33
|
+
:target_tailwind_config_file,
|
|
34
|
+
:target_settings_file,
|
|
35
|
+
:target_data_file,
|
|
36
|
+
:target_model_file,
|
|
37
|
+
:target_astro_file,
|
|
38
|
+
keyword_init: true
|
|
39
|
+
) do
|
|
40
|
+
# rubocop:disable Metrics/AbcSize
|
|
41
|
+
def debug
|
|
42
|
+
puts format('%-30<key>s : %<value>s', key: 'Source file', value: source_file)
|
|
43
|
+
puts format('%-30<key>s : %<value>s', key: 'Target html file', value: target_html_file)
|
|
44
|
+
puts format('%-30<key>s : %<value>s', key: 'Target clean html file', value: target_clean_html_file)
|
|
45
|
+
puts format('%-30<key>s : %<value>s', key: 'Target tailwind config file', value: target_tailwind_config_file)
|
|
46
|
+
puts format('%-30<key>s : %<value>s', key: 'Target settings file', value: target_settings_file)
|
|
47
|
+
puts format('%-30<key>s : %<value>s', key: 'Target data file', value: target_data_file)
|
|
48
|
+
puts format('%-30<key>s : %<value>s', key: 'Target model file', value: target_model_file)
|
|
49
|
+
puts format('%-30<key>s : %<value>s', key: 'Target astro file', value: target_astro_file)
|
|
50
|
+
end
|
|
51
|
+
# rubocop:enable Metrics/AbcSize
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class Component
|
|
55
|
+
attr_reader :name
|
|
56
|
+
attr_reader :design_system
|
|
57
|
+
attr_reader :group
|
|
58
|
+
attr_reader :absolute
|
|
59
|
+
attr_reader :relative
|
|
60
|
+
|
|
61
|
+
# Storage buckets for data that is extracted from the source file
|
|
62
|
+
attr_accessor :captured_comment_text
|
|
63
|
+
attr_accessor :captured_comment_list
|
|
64
|
+
attr_accessor :captured_tailwind_config
|
|
65
|
+
|
|
66
|
+
def initialize(name:, design_system:, group:, absolute:, relative:)
|
|
67
|
+
@name = name
|
|
68
|
+
@design_system = design_system
|
|
69
|
+
@group = group
|
|
70
|
+
@absolute = absolute
|
|
71
|
+
@relative = relative
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def to_h
|
|
75
|
+
{
|
|
76
|
+
name: name,
|
|
77
|
+
design_system: design_system.to_h,
|
|
78
|
+
group: group.to_h,
|
|
79
|
+
absolute: absolute.to_h,
|
|
80
|
+
relative: relative.to_h
|
|
81
|
+
}
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def debug
|
|
85
|
+
puts format('%-30<key>s : %<value>s', key: 'Component', value: name)
|
|
86
|
+
design_system.debug
|
|
87
|
+
group.debug
|
|
88
|
+
puts ':: Absolute paths'
|
|
89
|
+
absolute.debug
|
|
90
|
+
puts '::Relative paths'
|
|
91
|
+
relative.debug
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
attr_reader :uikit
|
|
96
|
+
# Location for raw components
|
|
97
|
+
attr_reader :source_root_path
|
|
98
|
+
# Location for component structures
|
|
99
|
+
attr_reader :target_root_path
|
|
100
|
+
attr_reader :current_design_system
|
|
101
|
+
attr_reader :components
|
|
102
|
+
|
|
103
|
+
def initialize(uikit, **args)
|
|
104
|
+
@uikit = uikit
|
|
105
|
+
@source_root_path = args[:source_root_path] || raise(ArgumentError, 'Missing source_root_path')
|
|
106
|
+
@target_root_path = args[:target_root_path] || raise(ArgumentError, 'Missing target_root_path')
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
class << self
|
|
110
|
+
def query(uikit, source_root_path:, target_root_path:)
|
|
111
|
+
instance = new(uikit, source_root_path: source_root_path, target_root_path: target_root_path)
|
|
112
|
+
instance.call
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def call
|
|
117
|
+
@components = build_components.sort_by { |component| [component.design_system.name, component.group.key, component.name] }
|
|
118
|
+
|
|
119
|
+
self
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Flattened list of components in hash format
|
|
123
|
+
# @return [Array<Hash>] list
|
|
124
|
+
def to_h
|
|
125
|
+
components.map(&:to_h)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
private
|
|
129
|
+
|
|
130
|
+
# rubocop:disable Metrics/AbcSize
|
|
131
|
+
def build_components
|
|
132
|
+
uikit.design_systems.flat_map do |design_system|
|
|
133
|
+
@current_design_system = design_system
|
|
134
|
+
design_system.groups.flat_map do |group|
|
|
135
|
+
group.files.map do |file|
|
|
136
|
+
Component.new(
|
|
137
|
+
name: file.file_name_only,
|
|
138
|
+
design_system: DesignSystem.new(**map_design_system),
|
|
139
|
+
group: Group.new(**map_group(group)),
|
|
140
|
+
absolute: FilePath.new(**map_absolute_file(file)),
|
|
141
|
+
relative: FilePath.new(**map_relative_file(file))
|
|
142
|
+
)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
# rubocop:enable Metrics/AbcSize
|
|
148
|
+
|
|
149
|
+
def design_system_name
|
|
150
|
+
current_design_system.name
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def source_path
|
|
154
|
+
File.join(source_root_path, design_system_name)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def target_path
|
|
158
|
+
File.join(target_root_path, design_system_name)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def map_design_system
|
|
162
|
+
{
|
|
163
|
+
name: design_system_name,
|
|
164
|
+
source_path: source_path,
|
|
165
|
+
target_path: target_path
|
|
166
|
+
}
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def map_group(group)
|
|
170
|
+
{
|
|
171
|
+
key: group.key,
|
|
172
|
+
type: group.type,
|
|
173
|
+
sub_keys: group.sub_keys,
|
|
174
|
+
folder: group.folder
|
|
175
|
+
}
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def map_relative_file(file)
|
|
179
|
+
{
|
|
180
|
+
source_file: file.file,
|
|
181
|
+
target_html_file: file.target.html_file,
|
|
182
|
+
target_clean_html_file: file.target.clean_html_file,
|
|
183
|
+
target_tailwind_config_file: file.target.tailwind_config_file,
|
|
184
|
+
target_settings_file: file.target.settings_file,
|
|
185
|
+
target_data_file: file.target.data_file,
|
|
186
|
+
target_model_file: file.target.model_file,
|
|
187
|
+
target_astro_file: file.target.astro_file
|
|
188
|
+
}
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# rubocop:disable Metrics/AbcSize
|
|
192
|
+
def map_absolute_file(file)
|
|
193
|
+
{
|
|
194
|
+
source_file: File.join(source_path, file.file),
|
|
195
|
+
target_html_file: File.join(target_path, file.target.html_file),
|
|
196
|
+
target_clean_html_file: File.join(target_path, file.target.clean_html_file),
|
|
197
|
+
target_tailwind_config_file: File.join(target_path, file.target.tailwind_config_file),
|
|
198
|
+
target_settings_file: File.join(target_path, file.target.settings_file),
|
|
199
|
+
target_data_file: File.join(target_path, file.target.data_file),
|
|
200
|
+
target_model_file: File.join(target_path, file.target.model_file),
|
|
201
|
+
target_astro_file: File.join(target_path, file.target.astro_file)
|
|
202
|
+
}
|
|
203
|
+
end
|
|
204
|
+
# rubocop:enable Metrics/AbcSize
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
end
|
|
@@ -54,10 +54,10 @@ module TailwindDsl
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def query_components
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
ComponentQuery.query(uikit,
|
|
58
|
+
source_root_path: source_root_path,
|
|
59
|
+
target_root_path: target_root_path)
|
|
60
|
+
.components
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
def process_components
|
|
@@ -9,8 +9,7 @@ module TailwindDsl
|
|
|
9
9
|
attr_reader :components
|
|
10
10
|
attr_reader :target_root_path
|
|
11
11
|
attr_reader :batch_size
|
|
12
|
-
attr_reader :
|
|
13
|
-
attr_reader :filter_design_system # this should be renamed and reshaped to a complex filter object
|
|
12
|
+
attr_reader :filter
|
|
14
13
|
|
|
15
14
|
# Create comment for this initialize method
|
|
16
15
|
|
|
@@ -18,56 +17,38 @@ module TailwindDsl
|
|
|
18
17
|
# @param [String] target_root_path root directory where the extracted data will be written to, this is the root path for all design systems and groups
|
|
19
18
|
# @param [Hash] args
|
|
20
19
|
# @option args [Integer] :batch_size number of components to process, default is 1
|
|
21
|
-
# @option args [
|
|
22
|
-
#
|
|
20
|
+
# @option args [Hash] :filter filter components before processing
|
|
21
|
+
# design_system: name of the design system to filter on, default is nil meaning all
|
|
23
22
|
# @option args [Class] :extract_handler class that implements an extract method
|
|
24
23
|
def initialize(components, target_root_path, **args)
|
|
25
24
|
@components = components
|
|
26
25
|
@target_root_path = target_root_path
|
|
27
26
|
@batch_size = args[:batch_size] || 1
|
|
28
|
-
@
|
|
29
|
-
@filter_design_system = args[:filter_design_system] || nil
|
|
27
|
+
@filter = args[:filter] || nil
|
|
30
28
|
@extract_handler = args[:extract_handler]
|
|
31
29
|
end
|
|
32
30
|
|
|
33
|
-
#
|
|
34
|
-
# Create a data file at: design_system.name -> group-hierarchy -> component-name.data.json
|
|
35
|
-
# Create a model file at: design_system.name -> group-hierarchy -> component-name.model.rb
|
|
36
|
-
|
|
37
|
-
# Process: Collect all components and optionally filter them by design system name.
|
|
38
|
-
# Also filter by other keys (to be determined)
|
|
39
|
-
# Only process files that have not been processed before.
|
|
40
|
-
# Look for the next component to be processed, if it does not exist in the target folder then process it.
|
|
41
|
-
# decrement the batch_left counter and continue until batch_left is 0.
|
|
42
|
-
# if :use_prompt is true then display the input/output files and ask if you wish to process the component or skip.
|
|
43
|
-
# process the component by calling the GPT3 API and save the results to the target folder.
|
|
44
|
-
|
|
31
|
+
# rubocop:disable Metrics/AbcSize
|
|
45
32
|
def extract
|
|
46
33
|
raise "Batch size must be greater than 0, got: #{batch_size}" if batch_size <= 0
|
|
47
34
|
|
|
48
35
|
remaining = batch_size
|
|
49
36
|
|
|
50
37
|
filter_components.each do |component|
|
|
51
|
-
# puts "Processing: #{component.design_system.name} -> #{component.group.key} -> #{component.name} -> remaining#: #{remaining}"
|
|
52
|
-
|
|
53
38
|
component_guard(component)
|
|
39
|
+
|
|
54
40
|
extractor.component = component
|
|
55
41
|
|
|
56
42
|
next if File.exist?(extractor.target_file)
|
|
57
43
|
|
|
58
|
-
|
|
59
|
-
# puts "Input: #{component.cleansed_html_path}"
|
|
60
|
-
# puts "Output: #{component_model_path}"
|
|
61
|
-
# puts 'Process? (y/n)'
|
|
62
|
-
# next unless STDIN.gets.chomp == 'y'
|
|
63
|
-
# end
|
|
64
|
-
|
|
44
|
+
component.debug
|
|
65
45
|
extractor.extract
|
|
66
46
|
|
|
67
47
|
remaining -= 1
|
|
68
48
|
break if remaining.zero?
|
|
69
49
|
end
|
|
70
50
|
end
|
|
51
|
+
# rubocop:enable Metrics/AbcSize
|
|
71
52
|
|
|
72
53
|
def extractor
|
|
73
54
|
return @extractor if defined? @extractor
|
|
@@ -89,15 +70,19 @@ module TailwindDsl
|
|
|
89
70
|
raise "Folder does not exist: '#{path}', make sure you run component structure generator first." unless File.exist?(path)
|
|
90
71
|
end
|
|
91
72
|
|
|
73
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
|
92
74
|
def filter_components
|
|
93
|
-
return components unless
|
|
94
|
-
|
|
95
|
-
|
|
75
|
+
return components unless filter
|
|
76
|
+
|
|
77
|
+
result = components
|
|
78
|
+
# inclusions
|
|
79
|
+
result = result.select { |component| component.design_system.name == filter[:design_system] } if filter[:design_system]
|
|
80
|
+
result = result.select { |component| component.group.key == filter[:group_key] } if filter[:group_key]
|
|
81
|
+
# exclusions
|
|
82
|
+
result = result.reject { |component| component.group.key == filter[:exclude_group_key] } if filter[:exclude_group_key]
|
|
83
|
+
result
|
|
96
84
|
end
|
|
97
|
-
|
|
98
|
-
# def target_file(component)
|
|
99
|
-
# raise NotImplementedError, 'target_file is not implemented'
|
|
100
|
-
# end
|
|
85
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
|
101
86
|
end
|
|
102
87
|
end
|
|
103
88
|
end
|
|
@@ -11,12 +11,27 @@ module TailwindDsl
|
|
|
11
11
|
component.absolute.target_data_file
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
# rubocop:disable Metrics/AbcSize
|
|
14
15
|
def extract
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
builder = Gpt3::Builder::Gpt3Builder.init
|
|
17
|
+
|
|
18
|
+
tokens = 250
|
|
19
|
+
|
|
20
|
+
source_file = component.absolute.target_clean_html_file
|
|
21
|
+
source = File.read(source_file)
|
|
22
|
+
|
|
23
|
+
target_file = component.absolute.target_data_file
|
|
24
|
+
component_type = component.group.sub_keys.last
|
|
25
|
+
|
|
26
|
+
builder
|
|
27
|
+
.start("Extract JSON data from '#{component_type}' HTML component")
|
|
28
|
+
.message('HTML:')
|
|
29
|
+
.example(source)
|
|
30
|
+
.message('JSON:')
|
|
31
|
+
.complete(engine: 'code-davinci-002', max_tokens: tokens, suffix: "\n")
|
|
32
|
+
.write_result(target_file)
|
|
19
33
|
end
|
|
34
|
+
# rubocop:enable Metrics/AbcSize
|
|
20
35
|
end
|
|
21
36
|
end
|
|
22
37
|
end
|
data/lib/tailwind_dsl/version.rb
CHANGED
data/lib/tailwind_dsl.rb
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'cmdlet'
|
|
4
|
+
require 'gpt3/builder'
|
|
4
5
|
|
|
5
6
|
require_relative 'tailwind_dsl/version'
|
|
6
7
|
# require_relative '_'
|
|
7
8
|
|
|
9
|
+
require_relative 'tailwind_dsl/etl/component_query'
|
|
10
|
+
|
|
8
11
|
require_relative 'tailwind_dsl/etl/raw_components/load'
|
|
9
12
|
require_relative 'tailwind_dsl/etl/raw_components/transformer'
|
|
10
13
|
|
|
@@ -15,7 +18,6 @@ require_relative 'tailwind_dsl/etl/raw_components/schema/group'
|
|
|
15
18
|
require_relative 'tailwind_dsl/etl/raw_components/schema/design_system'
|
|
16
19
|
require_relative 'tailwind_dsl/etl/raw_components/schema/uikit'
|
|
17
20
|
|
|
18
|
-
require_relative 'tailwind_dsl/etl/component_structures/raw_component_query'
|
|
19
21
|
require_relative 'tailwind_dsl/etl/component_structures/generator'
|
|
20
22
|
|
|
21
23
|
require_relative 'tailwind_dsl/etl/extractors/base_extractor'
|
data/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwind_dsl",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.30",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "tailwind_dsl",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.30",
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
|
|
12
12
|
"@semantic-release/changelog": "^6.0.1",
|
data/package.json
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tailwind_dsl
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.30
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Cruwys
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-10-
|
|
11
|
+
date: 2022-10-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cmdlet
|
|
@@ -2174,8 +2174,8 @@ files:
|
|
|
2174
2174
|
- lib/_.rb
|
|
2175
2175
|
- lib/tailwind_dsl.rb
|
|
2176
2176
|
- lib/tailwind_dsl/astro_demo/generate_astro_page_data.rb
|
|
2177
|
+
- lib/tailwind_dsl/etl/component_query.rb
|
|
2177
2178
|
- lib/tailwind_dsl/etl/component_structures/generator.rb
|
|
2178
|
-
- lib/tailwind_dsl/etl/component_structures/raw_component_query.rb
|
|
2179
2179
|
- lib/tailwind_dsl/etl/element.rb
|
|
2180
2180
|
- lib/tailwind_dsl/etl/extractors/base_extractor.rb
|
|
2181
2181
|
- lib/tailwind_dsl/etl/extractors/batch_extraction.rb
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# This is Reusable across concerns, it should be in it's own folder or in the ETL root
|
|
4
|
-
# Rename to component_list or component_query
|
|
5
|
-
|
|
6
|
-
module TailwindDsl
|
|
7
|
-
module Etl
|
|
8
|
-
module ComponentStructures
|
|
9
|
-
# Raw Component Query will return a list of raw components that are available for processing
|
|
10
|
-
#
|
|
11
|
-
# This is a two pass process:
|
|
12
|
-
# 1. Query the raw component folder for all files that match the pattern and build up a graph with required information
|
|
13
|
-
|
|
14
|
-
# puts '%-20s %s' % ['name', name]
|
|
15
|
-
# puts '%-20s %s' % ['source_path', source_path]
|
|
16
|
-
# puts '%-20s %s' % ['target_path', target_path]
|
|
17
|
-
# 2. Flatten the graph into a list of rows
|
|
18
|
-
class RawComponentQuery
|
|
19
|
-
DesignSystem = Struct.new(:name, :source_path, :target_path, keyword_init: true) do
|
|
20
|
-
def debug
|
|
21
|
-
puts format('%-30<key>s : %<value>s', key: 'Design system', value: name)
|
|
22
|
-
puts format('%-30<key>s : %<value>s', key: 'Source path', value: source_path)
|
|
23
|
-
puts format('%-30<key>s : %<value>s', key: 'Target path', value: target_path)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
Group = Struct.new(:key, :type, :sub_keys, :folder, keyword_init: true) do
|
|
28
|
-
def debug
|
|
29
|
-
puts format('%-30<key>s : %<value>s', key: 'Group key', value: key)
|
|
30
|
-
puts format('%-30<key>s : %<value>s', key: 'Group type', value: type)
|
|
31
|
-
puts format('%-30<key>s : %<value>s', key: 'Group sub keys', value: sub_keys)
|
|
32
|
-
puts format('%-30<key>s : %<value>s', key: 'Group folder', value: folder)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
FilePath = Struct.new(
|
|
37
|
-
:source_file,
|
|
38
|
-
:target_html_file,
|
|
39
|
-
:target_clean_html_file,
|
|
40
|
-
:target_tailwind_config_file,
|
|
41
|
-
:target_settings_file,
|
|
42
|
-
:target_data_file,
|
|
43
|
-
:target_model_file,
|
|
44
|
-
:target_astro_file,
|
|
45
|
-
keyword_init: true
|
|
46
|
-
) do
|
|
47
|
-
# rubocop:disable Metrics/AbcSize
|
|
48
|
-
def debug
|
|
49
|
-
puts format('%-30<key>s : %<value>s', key: 'Source file', value: source_file)
|
|
50
|
-
puts format('%-30<key>s : %<value>s', key: 'Target html file', value: target_html_file)
|
|
51
|
-
puts format('%-30<key>s : %<value>s', key: 'Target clean html file', value: target_clean_html_file)
|
|
52
|
-
puts format('%-30<key>s : %<value>s', key: 'Target tailwind config file', value: target_tailwind_config_file)
|
|
53
|
-
puts format('%-30<key>s : %<value>s', key: 'Target settings file', value: target_settings_file)
|
|
54
|
-
puts format('%-30<key>s : %<value>s', key: 'Target data file', value: target_data_file)
|
|
55
|
-
puts format('%-30<key>s : %<value>s', key: 'Target model file', value: target_model_file)
|
|
56
|
-
puts format('%-30<key>s : %<value>s', key: 'Target astro file', value: target_astro_file)
|
|
57
|
-
end
|
|
58
|
-
# rubocop:enable Metrics/AbcSize
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
class Component
|
|
62
|
-
attr_reader :name
|
|
63
|
-
attr_reader :design_system
|
|
64
|
-
attr_reader :group
|
|
65
|
-
attr_reader :absolute
|
|
66
|
-
attr_reader :relative
|
|
67
|
-
|
|
68
|
-
# Storage buckets for data that is extracted from the source file
|
|
69
|
-
attr_accessor :captured_comment_text
|
|
70
|
-
attr_accessor :captured_comment_list
|
|
71
|
-
attr_accessor :captured_tailwind_config
|
|
72
|
-
|
|
73
|
-
def initialize(name:, design_system:, group:, absolute:, relative:)
|
|
74
|
-
@name = name
|
|
75
|
-
@design_system = design_system
|
|
76
|
-
@group = group
|
|
77
|
-
@absolute = absolute
|
|
78
|
-
@relative = relative
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def to_h
|
|
82
|
-
{
|
|
83
|
-
name: name,
|
|
84
|
-
design_system: design_system.to_h,
|
|
85
|
-
group: group.to_h,
|
|
86
|
-
absolute: absolute.to_h,
|
|
87
|
-
relative: relative.to_h
|
|
88
|
-
}
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def debug
|
|
92
|
-
puts format('%-30<key>s : %<value>s', key: 'Component', value: name)
|
|
93
|
-
design_system.debug
|
|
94
|
-
group.debug
|
|
95
|
-
puts ':: Absolute paths'
|
|
96
|
-
absolute.debug
|
|
97
|
-
puts '::Relative paths'
|
|
98
|
-
relative.debug
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
attr_reader :uikit
|
|
103
|
-
# Location for raw components
|
|
104
|
-
attr_reader :source_root_path
|
|
105
|
-
# Location for component structures
|
|
106
|
-
attr_reader :target_root_path
|
|
107
|
-
attr_reader :current_design_system
|
|
108
|
-
attr_reader :components
|
|
109
|
-
|
|
110
|
-
def initialize(uikit, **args)
|
|
111
|
-
@uikit = uikit
|
|
112
|
-
@source_root_path = args[:source_root_path] || raise(ArgumentError, 'Missing source_root_path')
|
|
113
|
-
@target_root_path = args[:target_root_path] || raise(ArgumentError, 'Missing target_root_path')
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
class << self
|
|
117
|
-
def query(uikit, source_root_path:, target_root_path:)
|
|
118
|
-
instance = new(uikit, source_root_path: source_root_path, target_root_path: target_root_path)
|
|
119
|
-
instance.call
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def call
|
|
124
|
-
@components = build_components.sort_by { |component| [component.design_system.name, component.group.key, component.name] }
|
|
125
|
-
|
|
126
|
-
self
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
# Flattened list of components in hash format
|
|
130
|
-
# @return [Array<Hash>] list
|
|
131
|
-
def to_h
|
|
132
|
-
components.map(&:to_h)
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
private
|
|
136
|
-
|
|
137
|
-
# rubocop:disable Metrics/AbcSize
|
|
138
|
-
def build_components
|
|
139
|
-
uikit.design_systems.flat_map do |design_system|
|
|
140
|
-
@current_design_system = design_system
|
|
141
|
-
design_system.groups.flat_map do |group|
|
|
142
|
-
group.files.map do |file|
|
|
143
|
-
Component.new(
|
|
144
|
-
name: file.file_name_only,
|
|
145
|
-
design_system: DesignSystem.new(**map_design_system),
|
|
146
|
-
group: Group.new(**map_group(group)),
|
|
147
|
-
absolute: FilePath.new(**map_absolute_file(file)),
|
|
148
|
-
relative: FilePath.new(**map_relative_file(file))
|
|
149
|
-
)
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
# rubocop:enable Metrics/AbcSize
|
|
155
|
-
|
|
156
|
-
def design_system_name
|
|
157
|
-
current_design_system.name
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
def source_path
|
|
161
|
-
File.join(source_root_path, design_system_name)
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
def target_path
|
|
165
|
-
File.join(target_root_path, design_system_name)
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
def map_design_system
|
|
169
|
-
{
|
|
170
|
-
name: design_system_name,
|
|
171
|
-
source_path: source_path,
|
|
172
|
-
target_path: target_path
|
|
173
|
-
}
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
def map_group(group)
|
|
177
|
-
{
|
|
178
|
-
key: group.key,
|
|
179
|
-
type: group.type,
|
|
180
|
-
sub_keys: group.sub_keys,
|
|
181
|
-
folder: group.folder
|
|
182
|
-
}
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
def map_relative_file(file)
|
|
186
|
-
{
|
|
187
|
-
source_file: file.file,
|
|
188
|
-
target_html_file: file.target.html_file,
|
|
189
|
-
target_clean_html_file: file.target.clean_html_file,
|
|
190
|
-
target_tailwind_config_file: file.target.tailwind_config_file,
|
|
191
|
-
target_settings_file: file.target.settings_file,
|
|
192
|
-
target_data_file: file.target.data_file,
|
|
193
|
-
target_model_file: file.target.model_file,
|
|
194
|
-
target_astro_file: file.target.astro_file
|
|
195
|
-
}
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
# rubocop:disable Metrics/AbcSize
|
|
199
|
-
def map_absolute_file(file)
|
|
200
|
-
{
|
|
201
|
-
source_file: File.join(source_path, file.file),
|
|
202
|
-
target_html_file: File.join(target_path, file.target.html_file),
|
|
203
|
-
target_clean_html_file: File.join(target_path, file.target.clean_html_file),
|
|
204
|
-
target_tailwind_config_file: File.join(target_path, file.target.tailwind_config_file),
|
|
205
|
-
target_settings_file: File.join(target_path, file.target.settings_file),
|
|
206
|
-
target_data_file: File.join(target_path, file.target.data_file),
|
|
207
|
-
target_model_file: File.join(target_path, file.target.model_file),
|
|
208
|
-
target_astro_file: File.join(target_path, file.target.astro_file)
|
|
209
|
-
}
|
|
210
|
-
end
|
|
211
|
-
# rubocop:enable Metrics/AbcSize
|
|
212
|
-
end
|
|
213
|
-
end
|
|
214
|
-
end
|
|
215
|
-
end
|