Class: Bridgetown::Commands::Plugins::New
- Inherits:
-
Bridgetown::Command
- Object
- Samovar::Command
- Bridgetown::Command
- Bridgetown::Commands::Plugins::New
- Includes:
- Automations, GitHelpers, Freyia::Setup
- Defined in:
- bridgetown-core/lib/bridgetown-core/commands/plugins.rb
Constant Summary
Constants included from Automations
Automations::CODEBERG_REGEX, Automations::CODEBERG_REPO_REGEX, Automations::CODEBERG_TREE_REGEX, Automations::GITHUB_BLOB_REGEX, Automations::GITHUB_REGEX, Automations::GITHUB_REPO_REGEX, Automations::GITHUB_TREE_REGEX, Automations::GITLAB_BLOB_REGEX, Automations::GITLAB_REGEX, Automations::GITLAB_REPO_REGEX, Automations::GITLAB_TREE_REGEX
Instance Method Summary collapse
-
#call ⇒ Object
rubocop:disable Metrics.
Methods included from GitHelpers
#destroy_existing_repo, #initialize_new_repo, #user_default_branch
Methods included from Automations
#add_gem, #add_initializer, #add_npm_for_gem, #add_npm_package, #apply_from_url, #create_builder, included, #javascript_import, #remove_npm_package, #ruby_configure
Methods inherited from Bridgetown::Command
Instance Method Details
#call ⇒ Object
rubocop:disable Metrics
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'bridgetown-core/lib/bridgetown-core/commands/plugins.rb', line 149 def call # rubocop:disable Metrics self.source_paths = [Dir.pwd] self.destination_root = Dir.pwd folder_name = name.underscore module_name = folder_name.camelize run "git clone https://github.com/bridgetownrb/bridgetown-sample-plugin #{name}" new_gemspec = "#{folder_name}.gemspec" inside name do # rubocop:todo Metrics/BlockLength destroy_existing_repo initialize_new_repo FileUtils.mv "sample_plugin.gemspec", new_gemspec gsub_file new_gemspec, "https://github.com/bridgetownrb/bridgetown-sample-plugin", "https://github.com/username/#{name}" gsub_file new_gemspec, "bridgetown-sample-plugin", name gsub_file new_gemspec, "sample_plugin", folder_name gsub_file new_gemspec, "SamplePlugin", module_name gsub_file "package.json", "https://github.com/bridgetownrb/bridgetown-sample-plugin", "https://github.com/username/#{name}" gsub_file "package.json", "bridgetown-sample-plugin", name gsub_file "package.json", "sample_plugin", folder_name FileUtils.mv "lib/sample_plugin.rb", "lib/#{folder_name}.rb" gsub_file "lib/#{folder_name}.rb", "sample_plugin", folder_name gsub_file "lib/#{folder_name}.rb", "SamplePlugin", module_name FileUtils.mv "lib/sample_plugin", "lib/#{folder_name}" gsub_file "lib/#{folder_name}/builder.rb", "SamplePlugin", module_name gsub_file "lib/#{folder_name}/builder.rb", "sample_plugin", folder_name gsub_file "lib/#{folder_name}/version.rb", "SamplePlugin", module_name FileUtils.mv "test/test_sample_plugin.rb", "test/test_#{folder_name}.rb" gsub_file "test/test_#{folder_name}.rb", "SamplePlugin", module_name gsub_file "test/test_#{folder_name}.rb", "sample plugin", module_name gsub_file "test/helper.rb", "sample_plugin", folder_name gsub_file "test/fixtures/src/index.html", "sample_plugin", folder_name gsub_file "test/fixtures/config/initializers.rb", "sample_plugin", folder_name FileUtils.mv "components/sample_plugin", "components/#{folder_name}" FileUtils.mv "content/sample_plugin", "content/#{folder_name}" FileUtils.mv "layouts/sample_plugin", "layouts/#{folder_name}" gsub_file "layouts/#{folder_name}/layout.html", "sample_plugin", folder_name gsub_file "content/#{folder_name}/example_page.md", "sample_plugin", folder_name gsub_file "components/#{folder_name}/layout_help.liquid", "sample_plugin", folder_name gsub_file "components/#{folder_name}/plugin_component.rb", "SamplePlugin", module_name gsub_file "frontend/javascript/index.js", "sample_plugin", folder_name gsub_file "frontend/javascript/index.js", "SamplePlugin", module_name gsub_file "frontend/styles/index.css", "sample_plugin", folder_name end say "" say_status "Done!", "Have fun writing your new #{name} plugin :)" say_status "Remember:", "Don't forget to rename the SamplePlugin " \ "code identifiers and paths to your own " \ "identifier, as well as update your README " \ "and CHANGELOG files as necessary." end |