tailwind_dsl 0.0.13 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.builders/boot.rb +1 -0
- data/.builders/generators/utilities.rb +37 -16
- data/CHANGELOG.md +16 -0
- data/lib/tailwind_dsl/etl/component_models/extractor.rb +43 -0
- data/lib/tailwind_dsl/etl/component_structures/generator.rb +4 -2
- data/lib/tailwind_dsl/etl/component_structures/raw_component_query.rb +10 -12
- data/lib/tailwind_dsl/etl/raw_components/director.rb +2 -0
- data/lib/tailwind_dsl/version.rb +1 -1
- data/lib/tailwind_dsl.rb +2 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6646b23144a973701ff3a0357cdf6eb27fcc34e26690d2fdbcd77abf1b4767b
|
4
|
+
data.tar.gz: 1930985fae4778a5d7576ba843f2f727c634c14802fa3c572d0513df5e2eb3f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6ccea6907b5a4a1ff3cdc20fa20d0ce6dc814890d1cc4524e2fba9b124b85d599c5ae1046de94ddf10b20bde5292ddf79cdd7f0d0c38d6fa117a0bf7bb73ee1
|
7
|
+
data.tar.gz: 8feb59692ddaf59ffe373c1492e08e45dfe546ab63bfc09554afe47322975ad0fb8de5ec91046bb506b0ad303543157a1c0e86c0c5098db85098d12d059ebfc5
|
data/.builders/boot.rb
CHANGED
@@ -31,6 +31,7 @@ KConfig.configure(CONFIG_KEY) do |config|
|
|
31
31
|
config.target_folders.add(:builder , builder_folder)
|
32
32
|
config.target_folders.add(:data , base_folder, '.data')
|
33
33
|
config.target_folders.add(:components , base_folder, '.components')
|
34
|
+
config.target_folders.add(:component_models , base_folder, '.component_models')
|
34
35
|
|
35
36
|
config.target_folders.add(:template_merakiui , global_template, 'tailwind', 'merakiui')
|
36
37
|
config.target_folders.add(:template_devdojo , global_template, 'tailwind', 'devdojo')
|
@@ -11,21 +11,31 @@ KManager.action :utilities do
|
|
11
11
|
cd(:data)
|
12
12
|
|
13
13
|
# Raw components are source HTML/Tailwind files that have embedded information such as tailwind.config.js and usage instructions
|
14
|
-
|
14
|
+
source_component_path = File.expand_path('~/dev/kgems/k_templates/templates/tailwind')
|
15
15
|
|
16
16
|
# Target components are the processed components that are ready to be consumed by the TailwindDSL
|
17
|
-
|
17
|
+
target_component_path = k_builder.target_folders.get(:components)
|
18
|
+
|
19
|
+
# The component data shapes are reflected model based on the data inside of a HTML templates
|
20
|
+
target_component_model_path = k_builder.target_folders.get(:component_models)
|
18
21
|
|
19
|
-
|
20
|
-
|
22
|
+
# Builds the design_system.json by reading all the HTML templates for every UIKit found the source_component_path
|
23
|
+
uikit = helpers.build_design_systems(source_component_path)
|
21
24
|
|
22
|
-
add('design_system.json', content:
|
25
|
+
add('design_system.json', content: JSON.pretty_generate(uikit.to_h))
|
23
26
|
|
24
|
-
|
27
|
+
# Separate clean and raw components, tailwind configuration, settings into their own folders
|
28
|
+
component_generator = helpers.generate_components(uikit, source_component_path, target_component_path, reset_root_path: false)
|
29
|
+
components = component_generator.components
|
30
|
+
|
31
|
+
# Use GPT3 to extract component models in supervised fashion
|
32
|
+
helpers.extract_next_component_model(components, target_component_model_path, batch_size: 1, use_prompt: true, filter_design_system: 'tui')
|
33
|
+
# puts target_component_path
|
34
|
+
# /Users/davidcruwys/dev/kgems/tailwind_dsl/.components
|
25
35
|
|
26
36
|
# Goals
|
27
37
|
# - Generate a Tailwind component complete design system so that I can see both the component plus the original source code
|
28
|
-
# There should be a deep hierarchy of folders and files in a menu structure
|
38
|
+
# [✔️] There should be a deep hierarchy of folders and files in a menu structure
|
29
39
|
# When you click on a menu item, there should be a preview of the component
|
30
40
|
# The menus should be collapsible
|
31
41
|
# The menus should be searchable
|
@@ -39,21 +49,32 @@ KManager.action :utilities do
|
|
39
49
|
|
40
50
|
end
|
41
51
|
|
42
|
-
def build_design_systems(
|
52
|
+
def build_design_systems(source_component_path)
|
43
53
|
director = TailwindDsl::Etl::RawComponents::Director.new
|
44
54
|
|
45
|
-
director.add_design_system(File.join(
|
46
|
-
# director.add_design_system(File.join(
|
47
|
-
# director.add_design_system(File.join(
|
48
|
-
# director.add_design_system(File.join(
|
49
|
-
# director.add_design_system(File.join(
|
50
|
-
# director.add_design_system(File.join(
|
55
|
+
director.add_design_system(File.join(source_component_path, 'tui'))
|
56
|
+
# director.add_design_system(File.join(source_component_path, 'codepen'))
|
57
|
+
# director.add_design_system(File.join(source_component_path, 'devdojo'))
|
58
|
+
# director.add_design_system(File.join(source_component_path, 'merakiui'))
|
59
|
+
# director.add_design_system(File.join(source_component_path, 'noq'))
|
60
|
+
# director.add_design_system(File.join(source_component_path, 'starter-kit'))
|
51
61
|
director.uikit
|
52
62
|
end
|
53
63
|
|
54
|
-
def generate_components(uikit,
|
55
|
-
generator = TailwindDsl::Etl::ComponentStructures::Generator.new(uikit,
|
64
|
+
def generate_components(uikit, source_component_path, target_folder, reset_root_path: false)
|
65
|
+
generator = TailwindDsl::Etl::ComponentStructures::Generator.new(uikit, source_component_path, target_folder, reset_root_path: reset_root_path)
|
56
66
|
generator.generate
|
67
|
+
generator
|
68
|
+
end
|
69
|
+
|
70
|
+
# Extracts the next component model using GPT3
|
71
|
+
#
|
72
|
+
# This needs to be supervised and verified, so it will only do a few models at a time
|
73
|
+
def extract_next_component_model(components, target_folder, batch_size: 1, use_prompt: false, filter_design_system: nil)
|
74
|
+
puts target_folder
|
75
|
+
extractor = TailwindDsl::Etl::ComponentModels::Extractor.new(components, target_folder, batch_size: batch_size, use_prompt: use_prompt, filter_design_system: filter_design_system)
|
76
|
+
extractor.extract
|
57
77
|
end
|
58
78
|
end
|
79
|
+
|
59
80
|
KManager.opts.sleep = 2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## [0.0.14](https://github.com/klueless-io/tailwind_dsl/compare/v0.0.13...v0.0.14) (2022-10-18)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* refactor sample data directories ([23e4efb](https://github.com/klueless-io/tailwind_dsl/commit/23e4efb2863643cfbc8744e656a873900a421572))
|
7
|
+
* refactor sample data directories ([4017917](https://github.com/klueless-io/tailwind_dsl/commit/401791784e51fbe771c841294a4ad837f99c8ec9))
|
8
|
+
* start working on component model extractor ([929292d](https://github.com/klueless-io/tailwind_dsl/commit/929292dcdae8d79ccd12e2eae30d3e6710bac3f2))
|
9
|
+
|
10
|
+
## [0.0.13](https://github.com/klueless-io/tailwind_dsl/compare/v0.0.12...v0.0.13) (2022-10-18)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* refactor tests ([91b730d](https://github.com/klueless-io/tailwind_dsl/commit/91b730d91f99cf06810581d2d1684bb836eae860))
|
16
|
+
|
1
17
|
## [0.0.12](https://github.com/klueless-io/tailwind_dsl/compare/v0.0.11...v0.0.12) (2022-10-14)
|
2
18
|
|
3
19
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TailwindDsl
|
4
|
+
module Etl
|
5
|
+
module ComponentModels
|
6
|
+
# Extract component models by reading the cleansed component HTML and then using GPT3 to infer both the data/model structure.
|
7
|
+
class Extractor
|
8
|
+
attr_reader :components
|
9
|
+
attr_reader :target_root_path
|
10
|
+
attr_reader :batch_size
|
11
|
+
attr_reader :use_prompt
|
12
|
+
|
13
|
+
def initialize(components, target_root_path, batch_size: 1, use_prompt: false, filter_design_system: nil)
|
14
|
+
@components = components
|
15
|
+
@target_root_path = target_root_path
|
16
|
+
@batch_size = batch_size
|
17
|
+
@batch_left = batch_size
|
18
|
+
@use_prompt = use_prompt
|
19
|
+
end
|
20
|
+
|
21
|
+
# Goal: Extract the next (batch_size) component models using GPT3 and save them to target_root_path
|
22
|
+
# Create a data file at: design_system.name -> group-hierarchy -> component-name.data.json
|
23
|
+
# Create a model file at: design_system.name -> group-hierarchy -> component-name.model.rb
|
24
|
+
|
25
|
+
# Process: Collect all components and optionally filter them by design system name.
|
26
|
+
# Look for the next component to be processed, if it does not exist in the target folder then process it.
|
27
|
+
# decrement the batch_left counter and continue until batch_left is 0.
|
28
|
+
# if :use_prompt is true then display the input/output files and ask if you wish to process the component or skip.
|
29
|
+
# process the component by calling the GPT3 API and save the results to the target folder.
|
30
|
+
|
31
|
+
def extract; end
|
32
|
+
|
33
|
+
# def components
|
34
|
+
# @components ||= components.design_systems.map do |design_system|
|
35
|
+
# design_system.components.map do |component|
|
36
|
+
# Component.new(design_system, component, source_root_path, target_root_path)
|
37
|
+
# end
|
38
|
+
# end.flatten
|
39
|
+
# end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -21,7 +21,9 @@ module TailwindDsl
|
|
21
21
|
# .gsub(/(\n\s*\n)+/, "\n")
|
22
22
|
attr_reader :uikit
|
23
23
|
attr_reader :components
|
24
|
+
# Location for raw components
|
24
25
|
attr_reader :source_root_path
|
26
|
+
# Location for component structures
|
25
27
|
attr_reader :target_root_path
|
26
28
|
attr_reader :reset_root_path
|
27
29
|
|
@@ -54,8 +56,8 @@ module TailwindDsl
|
|
54
56
|
|
55
57
|
def query_components
|
56
58
|
RawComponentQuery.query(uikit,
|
57
|
-
|
58
|
-
|
59
|
+
source_root_path: source_root_path,
|
60
|
+
target_root_path: target_root_path).records
|
59
61
|
end
|
60
62
|
|
61
63
|
def process_components
|
@@ -8,8 +8,6 @@ module TailwindDsl
|
|
8
8
|
# This is a two pass process:
|
9
9
|
# 1. Query the raw component folder for all files that match the pattern and build up a graph with required information
|
10
10
|
# 2. Flatten the graph into a list of rows
|
11
|
-
#
|
12
|
-
# If you need to debug, then pass in the debug flag and it will output the graph to the console
|
13
11
|
class RawComponentQuery
|
14
12
|
DesignSystem = Struct.new(
|
15
13
|
:name,
|
@@ -64,22 +62,22 @@ module TailwindDsl
|
|
64
62
|
end
|
65
63
|
|
66
64
|
attr_reader :uikit
|
67
|
-
|
68
|
-
attr_reader :
|
65
|
+
# Location for raw components
|
66
|
+
attr_reader :source_root_path
|
67
|
+
# Location for component structures
|
68
|
+
attr_reader :target_root_path
|
69
69
|
attr_reader :current_design_system
|
70
|
-
attr_reader :debug
|
71
70
|
attr_reader :records
|
72
71
|
|
73
72
|
def initialize(uikit, **args)
|
74
73
|
@uikit = uikit
|
75
|
-
@
|
76
|
-
@
|
77
|
-
@debug = args[:debug] || false
|
74
|
+
@source_root_path = args[:source_root_path] || raise(ArgumentError, 'Missing source_root_path')
|
75
|
+
@target_root_path = args[:target_root_path] || raise(ArgumentError, 'Missing target_root_path')
|
78
76
|
end
|
79
77
|
|
80
78
|
class << self
|
81
|
-
def query(uikit,
|
82
|
-
instance = new(uikit,
|
79
|
+
def query(uikit, source_root_path:, target_root_path:)
|
80
|
+
instance = new(uikit, source_root_path: source_root_path, target_root_path: target_root_path)
|
83
81
|
instance.call
|
84
82
|
end
|
85
83
|
end
|
@@ -119,11 +117,11 @@ module TailwindDsl
|
|
119
117
|
end
|
120
118
|
|
121
119
|
def source_path
|
122
|
-
File.join(
|
120
|
+
File.join(source_root_path, design_system_name)
|
123
121
|
end
|
124
122
|
|
125
123
|
def target_path
|
126
|
-
File.join(
|
124
|
+
File.join(target_root_path, design_system_name)
|
127
125
|
end
|
128
126
|
|
129
127
|
def map_design_system
|
data/lib/tailwind_dsl/version.rb
CHANGED
data/lib/tailwind_dsl.rb
CHANGED
@@ -17,6 +17,8 @@ require_relative 'tailwind_dsl/etl/raw_components/schema/uikit'
|
|
17
17
|
|
18
18
|
require_relative 'tailwind_dsl/etl/component_structures/raw_component_query'
|
19
19
|
require_relative 'tailwind_dsl/etl/component_structures/generator'
|
20
|
+
|
21
|
+
require_relative 'tailwind_dsl/etl/component_models/extractor'
|
20
22
|
# require_relative 'tailwind_dsl/astro_demo/generate_astro_page_data'
|
21
23
|
|
22
24
|
module TailwindDsl
|
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "tailwind_dsl",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.15",
|
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.15",
|
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,7 +1,7 @@
|
|
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.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
@@ -2151,6 +2151,7 @@ files:
|
|
2151
2151
|
- lib/_.rb
|
2152
2152
|
- lib/tailwind_dsl.rb
|
2153
2153
|
- lib/tailwind_dsl/astro_demo/generate_astro_page_data.rb
|
2154
|
+
- lib/tailwind_dsl/etl/component_models/extractor.rb
|
2154
2155
|
- lib/tailwind_dsl/etl/component_structures/generator.rb
|
2155
2156
|
- lib/tailwind_dsl/etl/component_structures/raw_component_query.rb
|
2156
2157
|
- lib/tailwind_dsl/etl/element.rb
|