bridgetown-plugin-tailwindcss 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a4ce91a98c46bff19d557ae368e8f28cdd6abffb27acb37e1a24614e9b0e649a
4
+ data.tar.gz: 9244712044140697ca0278d98ccf8f300b1d5d219c35bca39b7eec4a4708282e
5
+ SHA512:
6
+ metadata.gz: 1f50d417e22fc75c27c7f401f8f3b837b94976e6fce3c8843fd56e419106d34c1cf8a15bfbabf90261dab13c4d53f28d95fe965ca234cde5afff219c5cf6791c
7
+ data.tar.gz: b7a664a5d0970ef790e2148afd38038fa5c98d1d1eb6078be0d687497dc1700f22f8ec64398e443ef447f98f29bb8406d202b9a6d77f10f5b8be79b040e96b58
@@ -0,0 +1,39 @@
1
+ /vendor
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
16
+ *.gem
17
+ Gemfile.lock
18
+ .bundle
19
+ .ruby-version
20
+
21
+ # Node
22
+ node_modules
23
+ .npm
24
+ .node_repl_history
25
+
26
+ # Yarn
27
+ yarn-error.log
28
+ yarn-debug.log*
29
+ .pnp/
30
+ .pnp.js
31
+
32
+ # Yarn Integrity file
33
+ .yarn-integrity
34
+
35
+ spec/dest
36
+ .bridgetown-metadata
37
+ .bridgetown-cache
38
+ .bridgetown-webpack
39
+ tags
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,22 @@
1
+ require: rubocop-bridgetown
2
+
3
+ inherit_gem:
4
+ rubocop-bridgetown: .rubocop.yml
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 2.5
8
+ Include:
9
+ - lib/**/*.rb
10
+
11
+ Exclude:
12
+ - .gitignore
13
+ - .rspec
14
+ - .rubocop.yml
15
+
16
+ - Gemfile.lock
17
+ - CHANGELOG.md
18
+ - LICENSE.txt
19
+ - README.md
20
+
21
+ - script/**/*
22
+ - vendor/**/*
@@ -0,0 +1,7 @@
1
+ # master
2
+
3
+ * Use this file to keep track of plugin updates
4
+
5
+ # 0.1.0 / 2020-05-01
6
+
7
+ * First version
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec
5
+
6
+ gem "bridgetown", ENV["BRIDGETOWN_VERSION"] if ENV["BRIDGETOWN_VERSION"]
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020-present
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,64 @@
1
+ # Sample plugin for Bridgetown
2
+
3
+ _NOTE: This isn't a real plugin! Copy this sample code and use it to create your own Ruby gem! [Help guide here…](https://www.bridgetownrb.com/docs/plugins)_ 😃
4
+
5
+ A Bridgetown plugin to [fill in the blank]…
6
+
7
+ ## Installation
8
+
9
+ Run this command to add this plugin to your site's Gemfile:
10
+
11
+ ```shell
12
+ $ bundle add my-awesome-plugin -g bridgetown_plugins
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ The plugin will…
18
+
19
+ ### Optional configuration options
20
+
21
+ The plugin will automatically use any of the following metadata variables if they are present in your site's `_data/site_metadata.yml` file.
22
+
23
+
24
+
25
+ ## Testing
26
+
27
+ * Run `bundle exec rspec` to run the test suite
28
+ * Or run `script/cibuild` to validate with Rubocop and test with rspec together.
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it (https://github.com/username/my-awesome-plugin/fork)
33
+ 2. Clone the fork using `git clone` to your local development machine.
34
+ 3. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 5. Push to the branch (`git push origin my-new-feature`)
37
+ 6. Create a new Pull Request
38
+
39
+ ----
40
+
41
+ ## Releasing (you can delete this section in your own plugin repo)
42
+
43
+ To release a new version of the plugin, simply bump up the version number in both `version.rb` and
44
+ `package.json`, and then run `script/release`. This will require you to have a registered account
45
+ with both the [RubyGems.org](https://rubygems.org) and [NPM](https://www.npmjs.com) registries.
46
+ You can optionally remove the `package.json` and `frontend` folder if you don't need to package frontend
47
+ assets for Webpack.
48
+
49
+ If you run into any problems or need further guidance, please check out our [Bridgetown community resources](https://www.bridgetownrb.com/docs/community)
50
+ where friendly folks are standing by to help you build and release your plugin or theme.
51
+
52
+ **NOTE:** make sure you add the `bridgetown-plugin` [topic](https://github.com/topics/bridgetown-plugin) to your
53
+ plugin's GitHub repo so the plugin or theme will show up on [Bridgetown's official Plugin Directory](https://www.bridgetownrb.com/plugins)! (There may be a day or so delay before you see it appear.)
54
+
55
+
56
+
57
+ ```javascript
58
+ // frontend/styles/index.js
59
+ @import 'tailwindcss/base';
60
+ @import 'tailwindcss/components';
61
+ @import 'tailwindcss/utilities';
62
+
63
+ // ...
64
+ ```
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
9
+ task :test => :spec
10
+
11
+ task :release do
12
+ Rake.sh "./script/release"
13
+ end
14
+
15
+ def filelist(*strings)
16
+ Rake::FileList.new(strings) do |fl|
17
+ fl.exclude(/node_modules/)
18
+ fl.exclude(/Rakefile/)
19
+ fl.exclude(/\.md/)
20
+ fl.exclude(/\.txt/)
21
+ fl.exclude(/tags/)
22
+ end
23
+ end
24
+
25
+ def file_rename(file, regex, string)
26
+ return nil unless file =~ regex
27
+
28
+ new_file = file.gsub(regex, string)
29
+ Rake.mkdir_p(File.dirname(new_file))
30
+ Rake.mv(file, new_file)
31
+ end
32
+
33
+ PLUGIN_NAME = "bridgetown-plugin-tailwindcss"
34
+ UNDERSCORE_PLUGIN_NAME = PLUGIN_NAME.gsub(/-/, "_")
35
+ MODULE_NAME = "TailwindCss"
36
+
37
+ SAMPLE_PLUGIN = /sample-plugin/
38
+ UNDERSCORE_SAMPLE_PLUGIN = /sample_plugin/
39
+ BRIDGETOWN_SAMPLE_PLUGIN = /bridgetown-sample-plugin/
40
+ SAMPLE_PLUGIN_MODULE = /SamplePlugin/
41
+
42
+ ALL_REGEX_ARY = [
43
+ SAMPLE_PLUGIN,
44
+ UNDERSCORE_SAMPLE_PLUGIN,
45
+ BRIDGETOWN_SAMPLE_PLUGIN,
46
+ SAMPLE_PLUGIN_MODULE
47
+ ]
48
+
49
+ # Reverse it so files come first, then directories
50
+ ALL_FILES = filelist("**/*").reverse
51
+
52
+ # https://avdi.codes/rake-part-2-file-lists/
53
+ namespace :plugin do
54
+ desc "Renames and rewrites files"
55
+ task rename: [:rewrite_files, :rename_files] do
56
+ end
57
+
58
+ desc "Renames the plugin"
59
+ task :rename_files do
60
+ ALL_FILES.map do |file|
61
+ file_rename(file, BRIDGETOWN_SAMPLE_PLUGIN, PLUGIN_NAME)
62
+ file_rename(file, SAMPLE_PLUGIN, PLUGIN_NAME)
63
+ file_rename(file, UNDERSCORE_SAMPLE_PLUGIN, UNDERSCORE_PLUGIN_NAME)
64
+ end
65
+ end
66
+
67
+ desc "Renames the plugin inside of files"
68
+ task :rewrite_files do
69
+ ALL_FILES.each do |file|
70
+ next if File.directory?(file)
71
+
72
+ # Fixes an issue with non-unicode characters
73
+ text = File.read(file).encode("UTF-8", invalid: :replace, replace: "?")
74
+
75
+ # Go to next iteration, unless it contains the regex
76
+ next unless ALL_REGEX_ARY.any? { |regex| text =~ regex }
77
+
78
+ # Check for /bridgetown-sample-plugin/ first, if that doesnt
79
+ # exist, then check for regular /sample-plugin/
80
+ replacement_text = text.gsub(SAMPLE_PLUGIN_MODULE, MODULE_NAME)
81
+ replacement_text = replacement_text.gsub(BRIDGETOWN_SAMPLE_PLUGIN, PLUGIN_NAME)
82
+ replacement_text = replacement_text.gsub(SAMPLE_PLUGIN, PLUGIN_NAME)
83
+ replacement_text = replacement_text.gsub(UNDERSCORE_SAMPLE_PLUGIN,
84
+ UNDERSCORE_PLUGIN_NAME)
85
+ File.open(file, "w") { |file| file.puts replacement_text }
86
+ end
87
+ end
88
+ end
89
+
90
+
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/bridgetown-plugin-tailwindcss/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "bridgetown-plugin-tailwindcss"
7
+ spec.version = TailwindCss::VERSION
8
+ spec.author = "Bridgetown Team"
9
+ spec.email = "maintainers@bridgetownrb.com"
10
+ spec.summary = "Sample code for creating new Bridgetown plugins"
11
+ spec.homepage = "https://github.com/bridgetownrb/bridgetown-plugin-tailwindcss"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|script|spec|features|frontend)/!) }
15
+ spec.test_files = spec.files.grep(%r!^spec/!)
16
+ spec.require_paths = ["lib"]
17
+ spec.metadata = { "yarn-add" => "bridgetown-plugin-tailwindcss@#{TailwindCss::VERSION}" }
18
+
19
+ spec.required_ruby_version = ">= 2.5.0"
20
+
21
+ spec.add_dependency "bridgetown", ">= 0.14", "< 2.0"
22
+
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "nokogiri", "~> 1.6"
25
+ spec.add_development_dependency "rake", "~> 12.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "rubocop-bridgetown", "~> 0.2"
28
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bridgetown"
4
+ require "bridgetown-plugin-tailwindcss/builder"
5
+
6
+ Bridgetown::PluginManager.new_source_manifest(
7
+ origin: TailwindCss,
8
+ )
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TailwindCss
4
+ class Builder < Bridgetown::Builder
5
+ end
6
+ end
7
+
8
+ TailwindCss::Builder.register
@@ -0,0 +1,115 @@
1
+ require 'bridgetown'
2
+ require 'utils'
3
+
4
+ class Command < Bridgetown::Command
5
+ include Utils
6
+
7
+ class << self
8
+ def init_with_program(prog)
9
+ prog.command(:init) do |c|
10
+ c.syntax "init"
11
+ c.description 'Initialize config for Tailwind'
12
+ # c.option 'path', '--path', 'Choose the path to install tailwind'
13
+
14
+ c.action do |args, options|
15
+ generate_tailwind
16
+ end
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def generate_tailwind
23
+ install_tailwind
24
+ write_files
25
+ end
26
+
27
+ def install_tailwind
28
+ yarn_add = "yarn add -D"
29
+ packages = "tailwindcss postcss-import postcss-loader"
30
+ Bridgetown::Utils::Exec.run(yarn_add, packages)
31
+ end
32
+
33
+ def write_files
34
+ webpack_config = File.expand_path("webpack.config.js")
35
+ tailwind_config = File.expand_path("tailwind.config.js")
36
+
37
+ File.open(webpack_config) do |f|
38
+ f.write(webpack_file_contents)
39
+ end
40
+
41
+ File.open(tailwind_config) do |f|
42
+ f.write(tailwind_config_contents)
43
+ end
44
+
45
+ prepend_to_stylesheet
46
+ end
47
+
48
+ def prepend_to_stylesheet
49
+ frontend_stylesheet = File.join("frontend", "styles", "index.scss")
50
+ frontend_stylesheet = File.expand_path(frontend_stylesheet)
51
+
52
+ return unless File.exist?(frontend_stylesheet)
53
+
54
+ prepend_to_file(frontend_stylesheet, import_tailwind_contents)
55
+ end
56
+
57
+ def import_tailwind_contents
58
+ <<~IMPORT
59
+ @import 'tailwindcss/base';
60
+ @import 'tailwindcss/components';
61
+ @import 'tailwindcss/utilities';
62
+ IMPORT
63
+ end
64
+
65
+ def tailwind_config_contents
66
+ <<~TAILWIND
67
+ module.exports = {
68
+ purge: {
69
+ enabled: true,
70
+ content: ['./src/**/*.html'],
71
+ },
72
+ theme: {
73
+ extend: {},
74
+ },
75
+ variants: {},
76
+ plugins: [],
77
+ }
78
+ TAILWIND
79
+ end
80
+
81
+ def webpack_file_contents
82
+ <<~WEBPACK
83
+ {
84
+ test: /\.(s[ac]|c)ss$/,
85
+ use: [
86
+ MiniCssExtractPlugin.loader,
87
+ "css-loader",
88
+ {
89
+ loader: "sass-loader",
90
+ options: {
91
+ sassOptions: {
92
+ includePaths: [
93
+ path.resolve(__dirname, "src/_components"),
94
+ path.resolve(__dirname, "src/_includes"),
95
+ ],
96
+ },
97
+ },
98
+ },
99
+ {
100
+ loader: "postcss-loader",
101
+ options: {
102
+ ident: "postcss",
103
+ plugins: [
104
+ require("postcss-import"),
105
+ require("tailwindcss"),
106
+ require("autoprefixer"),
107
+ ],
108
+ },
109
+ },
110
+ ],
111
+ },
112
+ WEBPACK
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,10 @@
1
+ module Utils
2
+ def prepend_to_file(file, str)
3
+ File.open(file, 'w') do |open_file|
4
+ open_file.puts(str)
5
+ File.foreach(file) do |line|
6
+ open_file.puts(line)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TailwindCss
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "bridgetown-plugin-tailwindcss",
3
+ "version": "0.1.0",
4
+ "main": "frontend/javascript/index.js",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/paramagicdev/bridgetown-plugin-tailwindcss.git"
8
+ },
9
+ "author": "Konnor Rogers <konnor7414@gmail.com>",
10
+ "homepage": "https://www.bridgetownrb.com",
11
+ "license": "MIT",
12
+ "private": false,
13
+ "files": [
14
+ "frontend"
15
+ ]
16
+ }
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bridgetown-plugin-tailwindcss
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bridgetown Team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-05-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bridgetown
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0.14'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0.14'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: nokogiri
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.6'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.6'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '12.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '12.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rubocop-bridgetown
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '0.2'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '0.2'
103
+ description:
104
+ email: maintainers@bridgetownrb.com
105
+ executables: []
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - ".gitignore"
110
+ - ".rspec"
111
+ - ".rubocop.yml"
112
+ - CHANGELOG.md
113
+ - Gemfile
114
+ - LICENSE.txt
115
+ - README.md
116
+ - Rakefile
117
+ - bridgetown-plugin-tailwindcss.gemspec
118
+ - lib/bridgetown-plugin-tailwindcss.rb
119
+ - lib/bridgetown-plugin-tailwindcss/builder.rb
120
+ - lib/bridgetown-plugin-tailwindcss/command.rb
121
+ - lib/bridgetown-plugin-tailwindcss/utils.rb
122
+ - lib/bridgetown-plugin-tailwindcss/version.rb
123
+ - package.json
124
+ - tags
125
+ homepage: https://github.com/bridgetownrb/bridgetown-plugin-tailwindcss
126
+ licenses:
127
+ - MIT
128
+ metadata:
129
+ yarn-add: bridgetown-plugin-tailwindcss@0.1.0
130
+ post_install_message:
131
+ rdoc_options: []
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 2.5.0
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ requirements: []
145
+ rubygems_version: 3.0.3
146
+ signing_key:
147
+ specification_version: 4
148
+ summary: Sample code for creating new Bridgetown plugins
149
+ test_files: []