bridgetown-plugin-tailwindcss 0.1.0 → 0.1.5
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/Gemfile +2 -0
- data/Rakefile +32 -1
- data/bridgetown-plugin-tailwindcss.gemspec +5 -4
- data/lib/bridgetown-plugin-tailwindcss.rb +3 -2
- data/lib/bridgetown-plugin-tailwindcss/command.rb +152 -97
- data/lib/bridgetown-plugin-tailwindcss/utils.rb +84 -6
- data/lib/bridgetown-plugin-tailwindcss/version.rb +1 -1
- data/package.json +7 -2
- data/yarn.lock +803 -0
- metadata +22 -8
- data/lib/bridgetown-plugin-tailwindcss/builder.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9986754f4c6f0a83586367fd810524cff649bef87c142982f717716c61b376c3
|
4
|
+
data.tar.gz: 582319a24342772b910fb4c548aa386ac7f36354ddbad01007e26d1f3c8109f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd7a4d92bd480318bf7a09fe1d0ad78a92acedcf37e64fbe889e9c807776e863c7e9031ac83d45e58ecbbc81ee35bd365282ecb17e7a0f1ea249940a53ddefa6
|
7
|
+
data.tar.gz: 7781f8c310ab4834f86fb03f3b7560682f04add80d5c49b914b154d89f3f5b9166a44f574450bbd00f066fb87cc779fb2582bcdaeb1e96f6b6777fa993873f00
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -2,16 +2,47 @@
|
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
require "rspec/core/rake_task"
|
5
|
+
require "./lib/bridgetown-plugin-tailwindcss/utils"
|
5
6
|
|
6
7
|
RSpec::Core::RakeTask.new(:spec)
|
7
8
|
|
8
9
|
task :default => :spec
|
9
10
|
task :test => :spec
|
10
11
|
|
11
|
-
task :
|
12
|
+
task :deploy do
|
12
13
|
Rake.sh "./script/release"
|
13
14
|
end
|
14
15
|
|
16
|
+
task :format do
|
17
|
+
Rake.sh "./script/fmt -a"
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
namespace :bump do
|
22
|
+
task :current do
|
23
|
+
puts TailwindCss::Utils::Bump.new.current_version
|
24
|
+
end
|
25
|
+
|
26
|
+
task :set do
|
27
|
+
question = "What would you like to set your version to? IE: [2.1.0] :"
|
28
|
+
value = TailwindCss::Utils::Actions.new.ask(question)
|
29
|
+
|
30
|
+
TailwindCss::Utils::Bump.new.bump_version_to_string(value)
|
31
|
+
end
|
32
|
+
|
33
|
+
task :major do
|
34
|
+
TailwindCss::Utils::Bump.new.bump_version(:major)
|
35
|
+
end
|
36
|
+
|
37
|
+
task :minor do
|
38
|
+
TailwindCss::Utils::Bump.new.bump_version(:minor)
|
39
|
+
end
|
40
|
+
|
41
|
+
task :patch do
|
42
|
+
TailwindCss::Utils::Bump.new.bump_version(:patch)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
15
46
|
def filelist(*strings)
|
16
47
|
Rake::FileList.new(strings) do |fl|
|
17
48
|
fl.exclude(/node_modules/)
|
@@ -5,10 +5,10 @@ require_relative "lib/bridgetown-plugin-tailwindcss/version"
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "bridgetown-plugin-tailwindcss"
|
7
7
|
spec.version = TailwindCss::VERSION
|
8
|
-
spec.author = "
|
9
|
-
spec.email = "
|
10
|
-
spec.summary = "
|
11
|
-
spec.homepage = "https://github.com/
|
8
|
+
spec.author = "Konnor Rogers"
|
9
|
+
spec.email = "konnor7414@gmail.com"
|
10
|
+
spec.summary = "A plugin to add tailwindcss to a site"
|
11
|
+
spec.homepage = "https://github.com/paramagicdev/bridgetown-plugin-tailwindcss"
|
12
12
|
spec.license = "MIT"
|
13
13
|
|
14
14
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|script|spec|features|frontend)/!) }
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.required_ruby_version = ">= 2.5.0"
|
20
20
|
|
21
21
|
spec.add_dependency "bridgetown", ">= 0.14", "< 2.0"
|
22
|
+
spec.add_dependency "thor", "~> 1.0"
|
22
23
|
|
23
24
|
spec.add_development_dependency "bundler"
|
24
25
|
spec.add_development_dependency "nokogiri", "~> 1.6"
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "bridgetown"
|
4
|
-
require "bridgetown-plugin-tailwindcss/
|
4
|
+
require "bridgetown-plugin-tailwindcss/command.rb"
|
5
|
+
require "bridgetown-plugin-tailwindcss/utils.rb"
|
5
6
|
|
6
7
|
Bridgetown::PluginManager.new_source_manifest(
|
7
|
-
origin: TailwindCss
|
8
|
+
origin: TailwindCss
|
8
9
|
)
|
@@ -1,115 +1,170 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bridgetown"
|
4
|
+
require_relative "utils"
|
5
|
+
|
6
|
+
module Bridgetown
|
7
|
+
module Commands
|
8
|
+
class TailwindInit < Bridgetown::Command
|
9
|
+
ACTIONS = TailwindCss::Utils::Actions.new
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def init_with_program(prog)
|
13
|
+
prog.command(:tailwind_init) do |c|
|
14
|
+
c.syntax "tailwind_init"
|
15
|
+
c.description "Initialize config for Tailwind"
|
16
|
+
# c.option 'path', '--path', 'Choose the path to install tailwind'
|
17
|
+
|
18
|
+
c.action do |_args, _options|
|
19
|
+
run
|
20
|
+
end
|
21
|
+
end
|
16
22
|
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def generate_tailwind
|
23
|
-
install_tailwind
|
24
|
-
write_files
|
25
|
-
end
|
26
23
|
|
27
|
-
|
28
|
-
yarn_add = "yarn add -D"
|
29
|
-
packages = "tailwindcss postcss-import postcss-loader"
|
30
|
-
Bridgetown::Utils::Exec.run(yarn_add, packages)
|
31
|
-
end
|
24
|
+
private
|
32
25
|
|
33
|
-
|
34
|
-
|
35
|
-
|
26
|
+
def run
|
27
|
+
write_files
|
28
|
+
end
|
36
29
|
|
37
|
-
|
38
|
-
|
39
|
-
|
30
|
+
def write_files
|
31
|
+
webpack_config = File.expand_path("webpack.config.js")
|
32
|
+
tailwind_config = File.expand_path("tailwind.config.js")
|
40
33
|
|
41
|
-
|
42
|
-
|
43
|
-
|
34
|
+
ACTIONS.create_file(webpack_config, webpack_file_contents)
|
35
|
+
ACTIONS.create_file(tailwind_config, tailwind_config_contents)
|
36
|
+
prepend_to_stylesheet
|
37
|
+
end
|
44
38
|
|
45
|
-
|
46
|
-
|
39
|
+
def prepend_to_stylesheet
|
40
|
+
frontend_stylesheet = File.join("frontend", "styles", "index.scss")
|
41
|
+
frontend_stylesheet = File.expand_path(frontend_stylesheet)
|
47
42
|
|
48
|
-
|
49
|
-
frontend_stylesheet = File.join("frontend", "styles", "index.scss")
|
50
|
-
frontend_stylesheet = File.expand_path(frontend_stylesheet)
|
43
|
+
return unless File.exist?(frontend_stylesheet)
|
51
44
|
|
52
|
-
|
45
|
+
ACTIONS.prepend_to_file(frontend_stylesheet, import_tailwind_contents)
|
46
|
+
end
|
53
47
|
|
54
|
-
|
55
|
-
|
48
|
+
def import_tailwind_contents
|
49
|
+
<<~IMPORT
|
50
|
+
@import 'tailwindcss/base';
|
51
|
+
@import 'tailwindcss/components';
|
52
|
+
@import 'tailwindcss/utilities';
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
@import 'tailwindcss/base';
|
60
|
-
@import 'tailwindcss/components';
|
61
|
-
@import 'tailwindcss/utilities';
|
62
|
-
IMPORT
|
63
|
-
end
|
54
|
+
IMPORT
|
55
|
+
end
|
64
56
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
57
|
+
def tailwind_config_contents
|
58
|
+
<<~TAILWIND
|
59
|
+
module.exports = {
|
60
|
+
purge: {
|
61
|
+
enabled: true,
|
62
|
+
content: ['./src/**/*.html'],
|
63
|
+
},
|
64
|
+
theme: {
|
65
|
+
extend: {},
|
66
|
+
},
|
67
|
+
variants: {},
|
68
|
+
plugins: [],
|
69
|
+
}
|
70
|
+
TAILWIND
|
71
|
+
end
|
80
72
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
73
|
+
def webpack_file_contents
|
74
|
+
<<~WEBPACK
|
75
|
+
const path = require("path");
|
76
|
+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
77
|
+
const ManifestPlugin = require("webpack-manifest-plugin");
|
78
|
+
|
79
|
+
module.exports = {
|
80
|
+
entry: "./frontend/javascript/index.js",
|
81
|
+
devtool: "source-map",
|
82
|
+
// Set some or all of these to true if you want more verbose logging:
|
83
|
+
stats: {
|
84
|
+
modules: false,
|
85
|
+
builtAt: false,
|
86
|
+
timings: false,
|
87
|
+
children: false,
|
88
|
+
},
|
89
|
+
output: {
|
90
|
+
path: path.resolve(__dirname, "output", "_bridgetown", "static", "js"),
|
91
|
+
filename: "all.[contenthash].js",
|
92
|
+
},
|
93
|
+
resolve: {
|
94
|
+
extensions: [".js", ".jsx"],
|
97
95
|
},
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
96
|
+
plugins: [
|
97
|
+
new MiniCssExtractPlugin({
|
98
|
+
filename: "../css/all.[contenthash].css",
|
99
|
+
}),
|
100
|
+
new ManifestPlugin({
|
101
|
+
fileName: path.resolve(__dirname, ".bridgetown-webpack", "manifest.json"),
|
102
|
+
}),
|
103
|
+
],
|
104
|
+
module: {
|
105
|
+
rules: [
|
106
|
+
{
|
107
|
+
test: /\.(js|jsx)/,
|
108
|
+
use: {
|
109
|
+
loader: "babel-loader",
|
110
|
+
options: {
|
111
|
+
presets: ["@babel/preset-env"],
|
112
|
+
plugins: [
|
113
|
+
"@babel/plugin-proposal-class-properties",
|
114
|
+
[
|
115
|
+
"@babel/plugin-transform-runtime",
|
116
|
+
{
|
117
|
+
helpers: false,
|
118
|
+
},
|
119
|
+
],
|
120
|
+
],
|
121
|
+
},
|
122
|
+
},
|
123
|
+
},
|
124
|
+
{
|
125
|
+
test: /\.(s[ac]|c)ss$/,
|
126
|
+
use: [
|
127
|
+
MiniCssExtractPlugin.loader,
|
128
|
+
"css-loader",
|
129
|
+
{
|
130
|
+
loader: "sass-loader",
|
131
|
+
options: {
|
132
|
+
sassOptions: {
|
133
|
+
includePaths: [
|
134
|
+
path.resolve(__dirname, "src/_components"),
|
135
|
+
path.resolve(__dirname, "src/_includes"),
|
136
|
+
],
|
137
|
+
},
|
138
|
+
},
|
139
|
+
},
|
140
|
+
],
|
141
|
+
},
|
142
|
+
{
|
143
|
+
loader: "postcss-loader",
|
144
|
+
options: {
|
145
|
+
ident: "postcss",
|
146
|
+
plugins: [
|
147
|
+
require("postcss-import"),
|
148
|
+
require("tailwindcss"),
|
149
|
+
require("autoprefixer"),
|
150
|
+
],
|
151
|
+
},
|
152
|
+
},
|
153
|
+
{
|
154
|
+
test: /\.woff2?$|\.ttf$|\.eot$|\.svg$/,
|
155
|
+
loader: "file-loader",
|
156
|
+
options: {
|
157
|
+
outputPath: "../fonts",
|
158
|
+
publicPath: "../fonts",
|
159
|
+
},
|
160
|
+
},
|
107
161
|
],
|
108
162
|
},
|
109
|
-
}
|
110
|
-
|
111
|
-
|
112
|
-
|
163
|
+
};
|
164
|
+
|
165
|
+
WEBPACK
|
166
|
+
end
|
167
|
+
end
|
113
168
|
end
|
114
169
|
end
|
115
170
|
end
|
@@ -1,10 +1,88 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
module TailwindCss
|
6
|
+
module Utils
|
7
|
+
class Actions < Thor
|
8
|
+
include Thor::Actions
|
9
|
+
end
|
10
|
+
# @see https://ruby-doc.org/core-2.7.1/Regexp.html#class-Regexp-label-Capturing
|
11
|
+
# capture groups
|
12
|
+
class Bump < Thor
|
13
|
+
include Thor::Actions
|
14
|
+
|
15
|
+
VERSION_REGEX = %r!(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)!.freeze
|
16
|
+
|
17
|
+
# rubocop:disable Metrics/BlockLength
|
18
|
+
no_commands do
|
19
|
+
def current_version
|
20
|
+
VERSION
|
21
|
+
end
|
22
|
+
|
23
|
+
def bump_version_to_string(string)
|
24
|
+
say("Bumping from #{VERSION} to #{string}", :red)
|
25
|
+
|
26
|
+
version_files.each do |file|
|
27
|
+
gsub_file(file, VERSION_REGEX, string)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def bump_version(type, version: VERSION, value: nil)
|
32
|
+
say(version_change(type, version: version, value: value), :red)
|
33
|
+
|
34
|
+
version_files.each do |file|
|
35
|
+
gsub_file(file, VERSION_REGEX,
|
36
|
+
to_version(type, version: version, value: value))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def version_files
|
43
|
+
@package_json = File.expand_path("package.json")
|
44
|
+
@version_file = File.expand_path(File.join(__dir__, "version.rb"))
|
45
|
+
|
46
|
+
[@package_json, @version_file]
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_version(type, version: nil, value: nil)
|
50
|
+
from = version
|
51
|
+
match = VERSION_REGEX.match(from)
|
52
|
+
|
53
|
+
groups = {
|
54
|
+
major: match[:major],
|
55
|
+
minor: match[:minor],
|
56
|
+
patch: match[:patch],
|
57
|
+
}
|
58
|
+
|
59
|
+
unless groups.key?(type)
|
60
|
+
raise "\nYou gave #{type} but the only accepted types are
|
61
|
+
#{groups.keys}"
|
62
|
+
end
|
63
|
+
|
64
|
+
groups[type] = value || (groups[type].to_i + 1).to_s
|
65
|
+
|
66
|
+
bump_to_zero(type, groups)
|
67
|
+
|
68
|
+
"#{groups[:major]}.#{groups[:minor]}.#{groups[:patch]}"
|
69
|
+
end
|
70
|
+
|
71
|
+
def bump_to_zero(type, groups)
|
72
|
+
return if type == :patch
|
73
|
+
|
74
|
+
groups[:patch] = "0"
|
75
|
+
|
76
|
+
return if type == :minor
|
77
|
+
|
78
|
+
groups[:minor] = "0"
|
79
|
+
end
|
80
|
+
|
81
|
+
def version_change(type, version: nil, value: nil)
|
82
|
+
"Bumping from #{version} to #{to_version(type, version: version, value: value)}"
|
83
|
+
end
|
7
84
|
end
|
85
|
+
# rubocop:enable Metrics/BlockLength
|
8
86
|
end
|
9
87
|
end
|
10
88
|
end
|