A platform for community discussion. Free, open, simple.
DEV: plugin generator will now ask for github username (#6337)
Joffrey JAFFEUXacc96abe1a4a
diff --git a/lib/generators/plugin/plugin_generator.rb b/lib/generators/plugin/plugin_generator.rbindex 9cc6801c7a1..6f371e1e85a 100644--- a/lib/generators/plugin/plugin_generator.rb+++ b/lib/generators/plugin/plugin_generator.rb@@ -1,11 +1,12 @@require 'rails/generators/named_base'class PluginGenerator < Rails::Generators::NamedBase+ attr_writer :github_username+desc 'This generator creates a Discourse plugin skeleton'source_root File.expand_path('templates', __dir__)- class_option :author, type: :string, desc: "Plugin author", required: trueclass_option :stylesheet, type: :boolean, desc: "Generate Stylesheet", default: trueclass_option :javascript, type: :boolean, desc: "Generate Javascript initializer", default: trueclass_option :scheduled_job, type: :boolean, desc: "Generate scheduled job", default: false@@ -18,14 +19,20 @@ class PluginGenerator < Rails::Generators::NamedBaseenddef create_readme_file+ ensure_github_username+template 'README.md.erb', File.join('plugins', dasherized_name, "README.md")enddef create_license_file+ ensure_github_username+template 'LICENSE.erb', File.join('plugins', dasherized_name, "LICENSE")enddef create_plugin_file+ ensure_github_username+template 'plugin.rb.erb', File.join('plugins', dasherized_name, "plugin.rb")end@@ -49,6 +56,10 @@ class PluginGenerator < Rails::Generators::NamedBaseendend+ def ensure_github_username+ @github_username ||= ask("Github username?")+ end+def underscored_namename.underscoreenddiff --git a/lib/generators/plugin/templates/LICENSE.erb b/lib/generators/plugin/templates/LICENSE.erbindex 9d4652c4be4..bc12283e18b 100644--- a/lib/generators/plugin/templates/LICENSE.erb+++ b/lib/generators/plugin/templates/LICENSE.erb@@ -1,6 +1,6 @@The MIT License (MIT)-Copyright (c) 2018 <%= @options['author'] %>.+Copyright (c) 2018 <%= @github_username %>.Permission is hereby granted, free of charge, to any person obtaining a copy ofthis software and associated documentation files (the "Software"), to deal indiff --git a/lib/generators/plugin/templates/README.md.erb b/lib/generators/plugin/templates/README.md.erbindex 323f2b6f271..6db29ed09c4 100644--- a/lib/generators/plugin/templates/README.md.erb+++ b/lib/generators/plugin/templates/README.md.erb@@ -5,7 +5,7 @@## InstallationFollow [Install a Plugin](https://meta.discourse.org/t/install-a-plugin/19157)-how-to from the official Discourse Meta, using `git clone https://github.com/<%= @options['author'] %>/<%= dasherized_name %>.git`+how-to from the official Discourse Meta, using `git clone https://github.com/<%= @github_username %>/<%= dasherized_name %>.git`as the plugin command.## Usagediff --git a/lib/generators/plugin/templates/plugin.rb.erb b/lib/generators/plugin/templates/plugin.rb.erbindex e0278a0c932..55a3dec64c8 100644--- a/lib/generators/plugin/templates/plugin.rb.erb+++ b/lib/generators/plugin/templates/plugin.rb.erb@@ -1,8 +1,8 @@# name: <%= name %>-# about: AWESOME_PLUGIN+# about:# version: 0.1-# authors: <%= @options['author'] %>-# url: https://github.com/<%= @options['author'] %>+# authors: <%= @github_username %>+# url: https://github.com/<%= @github_username %><% if @options["stylesheet"] %>register_asset "stylesheets/common/<%= dasherized_name %>.scss"