Skip to content

A platform for community discussion. Free, open, simple.

DEV: removes plugin generator (#14101)

Joffrey JAFFEUXefbc2481d8d4
diff --git a/lib/generators/plugin/plugin_generator.rb b/lib/generators/plugin/plugin_generator.rb
deleted file mode 100644
index 6f7a2b2011b..00000000000
--- a/lib/generators/plugin/plugin_generator.rb
+++ /dev/null
@@ -1,125 +0,0 @@
-# frozen_string_literal: true
-
-require 'rails/generators/named_base'
-
-class PluginGenerator < Rails::Generators::NamedBase
- attr_writer :about
- attr_writer :github_username
-
- desc 'This generator creates a Discourse plugin skeleton'
-
- source_root File.expand_path('templates', __dir__)
-
- class_option :no_license, type: :boolean, desc: "No license", default: false
-
- def create_plugin
- @about ||= ask("What is the purpose of your plugin?")
- @github_username ||= ask("Github username?")
-
- readme_file
- routes_file
- engine_file
- plugin_file
- controller_file
- license_file
- stylesheet_file
- javascript_file
- settings_file
- locales_file
- end
-
- def controller_file
- template 'plugin_controller.rb.erb', File.join('plugins', dasherized_name, "app/controllers/#{underscored_name}/#{underscored_name}_controller.rb")
- template 'controller.rb.erb', File.join('plugins', dasherized_name, "app/controllers/#{underscored_name}/actions_controller.rb")
- template 'controller_spec.rb.erb', File.join('plugins', dasherized_name, "spec/requests/actions_controller_spec.rb")
- end
-
- def readme_file
- template 'README.md.erb', File.join('plugins', dasherized_name, "README.md")
- end
-
- def license_file
- return if @options['no_license']
-
- template 'LICENSE.erb', File.join('plugins', dasherized_name, "LICENSE")
- end
-
- def engine_file
- template 'engine.rb.erb', File.join('plugins', dasherized_name, "lib", dasherized_name, "engine.rb")
- end
-
- def routes_file
- template 'routes.rb.erb', File.join('plugins', dasherized_name, "config", "routes.rb")
- template 'route_constraint.rb.erb', File.join('plugins', dasherized_name, "lib", "#{underscored_name}_constraint.rb")
- end
-
- def plugin_file
- template 'plugin.rb.erb', File.join('plugins', dasherized_name, "plugin.rb")
- end
-
- def stylesheet_file
- template 'stylesheet.scss.erb', File.join('plugins', dasherized_name, 'assets/stylesheets/common', "#{dasherized_name}.scss")
- template 'stylesheet.scss.erb', File.join('plugins', dasherized_name, 'assets/stylesheets/desktop', "#{dasherized_name}.scss")
- template 'stylesheet.scss.erb', File.join('plugins', dasherized_name, 'assets/stylesheets/mobile', "#{dasherized_name}.scss")
- end
-
- def javascript_file
- template 'acceptance-test.js.es6.erb', File.join('plugins', dasherized_name, "test/javascripts/acceptance", "#{dasherized_name}-test.js.es6")
- template 'javascript.js.es6.erb', File.join('plugins', dasherized_name, 'assets/javascripts/initializers', "#{dasherized_name}.js.es6")
- template 'route-map.js.es6.erb', File.join('plugins', dasherized_name, 'assets/javascripts/discourse', "#{dasherized_name}-route-map.js.es6")
-
- folder = 'assets/javascripts/discourse/templates'
- template "#{folder}/template.hbs.erb", path(folder, "actions.hbs")
- template "#{folder}/template-show.hbs.erb", path(folder, "actions-show.hbs")
- template "#{folder}/template-index.hbs.erb", path(folder, "actions-index.hbs")
-
- folder = 'assets/javascripts/discourse/routes'
- template "#{folder}/route.js.es6.erb", path(folder, "#{dasherized_name}-actions.js.es6")
- template "#{folder}/route-show.js.es6.erb", path(folder, "#{dasherized_name}-actions-show.js.es6")
- template "#{folder}/route-index.js.es6.erb", path(folder, "#{dasherized_name}-actions-index.js.es6")
-
- folder = 'assets/javascripts/discourse/controllers'
- template "#{folder}/controller.js.es6.erb", path(folder, "actions.js.es6")
- template "#{folder}/controller-show.js.es6.erb", path(folder, "actions-show.js.es6")
- template "#{folder}/controller-index.js.es6.erb", path(folder, "actions-index.js.es6")
-
- folder = 'assets/javascripts/discourse/models'
- template "#{folder}/model.js.es6.erb", path(folder, "action.js.es6")
-
- folder = 'assets/javascripts/discourse/adapters'
- template "#{folder}/adapter.js.es6.erb", path(folder, "action.js.es6")
- end
-
- def settings_file
- template 'settings.yml.erb', File.join('plugins', dasherized_name, 'config', 'settings.yml')
- end
-
- def locales_file
- template 'client.en.yml.erb', path('config/locales/client.en.yml')
- template 'server.en.yml.erb', File.join('plugins', dasherized_name, 'config/locales', 'server.en.yml')
- end
-
- def create_gitignore_entry
- plugin_entry = "!/plugins/#{dasherized_name}"
-
- unless File.readlines(".gitignore").grep(/#{plugin_entry}/).size > 0
- open('.gitignore', 'a') { |f| f.puts "\n#{plugin_entry}" }
- end
- end
-
- def underscored_name
- name.underscore
- end
-
- def dasherized_name
- underscored_name.dasherize
- end
-
- def classified_name
- name.tableize.classify
- end
-
- def path(*args)
- File.join('plugins', dasherized_name, args)
- end
-end
diff --git a/lib/generators/plugin/templates/LICENSE.erb b/lib/generators/plugin/templates/LICENSE.erb
deleted file mode 100644
index bc12283e18b..00000000000
--- a/lib/generators/plugin/templates/LICENSE.erb
+++ /dev/null
@@ -1,20 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2018 <%= @github_username %>.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/lib/generators/plugin/templates/README.md.erb b/lib/generators/plugin/templates/README.md.erb
deleted file mode 100644
index 6db29ed09c4..00000000000
--- a/lib/generators/plugin/templates/README.md.erb
+++ /dev/null
@@ -1,16 +0,0 @@
-# <%= name %>
-
-<%= name %> is a plugin for ...
-
-## Installation
-
-Follow [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/<%= @github_username %>/<%= dasherized_name %>.git`
-as the plugin command.
-
-## Usage
-
-## Feedback
-
-If you have issues or suggestions for the plugin, please bring them up on
-[Discourse Meta](https://meta.discourse.org).
diff --git a/lib/generators/plugin/templates/acceptance-test.js.es6.erb b/lib/generators/plugin/templates/acceptance-test.js.es6.erb
deleted file mode 100644
index 472650a2666..00000000000
--- a/lib/generators/plugin/templates/acceptance-test.js.es6.erb
+++ /dev/null
@@ -1,9 +0,0 @@
-import { acceptance } from "discourse/tests/helpers/qunit-helpers";
-
-acceptance("<%= name %>", { loggedIn: true });
-
-test("<%= name %> works", async assert => {
- await visit("/admin/plugins/<%= dasherized_name %>");
-
- assert.ok(false, "it shows the <%= name %> button");
-});
diff --git a/lib/generators/plugin/templates/assets/javascripts/discourse/adapters/adapter.js.es6.erb b/lib/generators/plugin/templates/assets/javascripts/discourse/adapters/adapter.js.es6.erb
deleted file mode 100644
index f952121c62d..00000000000
--- a/lib/generators/plugin/templates/assets/javascripts/discourse/adapters/adapter.js.es6.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-import RestAdapter from "discourse/adapters/rest";
-
-export default RestAdapter.extend({
- basePath() {
- return "/<%= dasherized_name %>/";
- }
-});
diff --git a/lib/generators/plugin/templates/assets/javascripts/discourse/controllers/controller-index.js.es6.erb b/lib/generators/plugin/templates/assets/javascripts/discourse/controllers/controller-index.js.es6.erb
deleted file mode 100644
index 1e7a349b558..00000000000
--- a/lib/generators/plugin/templates/assets/javascripts/discourse/controllers/controller-index.js.es6.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-import Controller from "@ember/controller";
-export default Controller.extend({
- actions: {
- }
-});
diff --git a/lib/generators/plugin/templates/assets/javascripts/discourse/controllers/controller-show.js.es6.erb b/lib/generators/plugin/templates/assets/javascripts/discourse/controllers/controller-show.js.es6.erb
deleted file mode 100644
index 1e7a349b558..00000000000
--- a/lib/generators/plugin/templates/assets/javascripts/discourse/controllers/controller-show.js.es6.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-import Controller from "@ember/controller";
-export default Controller.extend({
- actions: {
- }
-});
diff --git a/lib/generators/plugin/templates/assets/javascripts/discourse/controllers/controller.js.es6.erb b/lib/generators/plugin/templates/assets/javascripts/discourse/controllers/controller.js.es6.erb
deleted file mode 100644
index 1c0ee0801d4..00000000000
--- a/lib/generators/plugin/templates/assets/javascripts/discourse/controllers/controller.js.es6.erb
+++ /dev/null
@@ -1,2 +0,0 @@
-import Controller from "@ember/controller";
-export default Controller.extend({});
diff --git a/lib/generators/plugin/templates/assets/javascripts/discourse/models/model.js.es6.erb b/lib/generators/plugin/templates/assets/javascripts/discourse/models/model.js.es6.erb
deleted file mode 100644
index 0c432d3f71d..00000000000
--- a/lib/generators/plugin/templates/assets/javascripts/discourse/models/model.js.es6.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-import RestModel from "discourse/models/rest";
-
-export default RestModel.extend({});
diff --git a/lib/generators/plugin/templates/assets/javascripts/discourse/routes/route-index.js.es6.erb b/lib/generators/plugin/templates/assets/javascripts/discourse/routes/route-index.js.es6.erb
deleted file mode 100644
index 4766f115e9f..00000000000
--- a/lib/generators/plugin/templates/assets/javascripts/discourse/routes/route-index.js.es6.erb
+++ /dev/null
@@ -1,13 +0,0 @@
-import DiscourseRoute from 'discourse/routes/discourse'
-
-export default DiscourseRoute.extend({
- controllerName: "actions-index",
-
- model(params) {
- return this.store.findAll("action");
- },
-
- renderTemplate() {
- this.render("actions-index");
- }
-});
diff --git a/lib/generators/plugin/templates/assets/javascripts/discourse/routes/route-show.js.es6.erb b/lib/generators/plugin/templates/assets/javascripts/discourse/routes/route-show.js.es6.erb
deleted file mode 100644
index 34ef38ac50b..00000000000
--- a/lib/generators/plugin/templates/assets/javascripts/discourse/routes/route-show.js.es6.erb
+++ /dev/null
@@ -1,13 +0,0 @@
-import DiscourseRoute from 'discourse/routes/discourse'
-
-export default DiscourseRoute.extend({
- controllerName: "actions-show",
-
- model(params) {
- return this.store.find("action", params.id);
- },
-
- renderTemplate() {
- this.render("actions-show");
- }
-});
diff --git a/lib/generators/plugin/templates/assets/javascripts/discourse/routes/route.js.es6.erb b/lib/generators/plugin/templates/assets/javascripts/discourse/routes/route.js.es6.erb
deleted file mode 100644
index 702e29cdfd1..00000000000
--- a/lib/generators/plugin/templates/assets/javascripts/discourse/routes/route.js.es6.erb
+++ /dev/null
@@ -1,9 +0,0 @@
-import DiscourseRoute from 'discourse/routes/discourse'
-
-export default DiscourseRoute.extend({
- controllerName: "actions",
-
- renderTemplate() {
- this.render("actions");
- }
-});
diff --git a/lib/generators/plugin/templates/assets/javascripts/discourse/templates/template-index.hbs.erb b/lib/generators/plugin/templates/assets/javascripts/discourse/templates/template-index.hbs.erb
deleted file mode 100644
index 2f9b14cc039..00000000000
--- a/lib/generators/plugin/templates/assets/javascripts/discourse/templates/template-index.hbs.erb
+++ /dev/null
@@ -1 +0,0 @@
-controller-index.hbs
diff --git a/lib/generators/plugin/templates/assets/javascripts/discourse/templates/template-show.hbs.erb b/lib/generators/plugin/templates/assets/javascripts/discourse/templates/template-show.hbs.erb
deleted file mode 100644
index c15471b8b9f..00000000000
--- a/lib/generators/plugin/templates/assets/javascripts/discourse/templates/template-show.hbs.erb
+++ /dev/null
@@ -1 +0,0 @@
-controller-show.hbs id: {{model.id}}
diff --git a/lib/generators/plugin/templates/assets/javascripts/discourse/templates/template.hbs.erb b/lib/generators/plugin/templates/assets/javascripts/discourse/templates/template.hbs.erb
deleted file mode 100644
index ed4d67a9483..00000000000
--- a/lib/generators/plugin/templates/assets/javascripts/discourse/templates/template.hbs.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-controller.hbs
-
-{{outlet}}
diff --git a/lib/generators/plugin/templates/client.en.yml.erb b/lib/generators/plugin/templates/client.en.yml.erb
deleted file mode 100644
index ac043b828c4..00000000000
--- a/lib/generators/plugin/templates/client.en.yml.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-en:
- js:
- <%= underscored_name %>:
diff --git a/lib/generators/plugin/templates/controller.rb.erb b/lib/generators/plugin/templates/controller.rb.erb
deleted file mode 100644
index 2c88888a516..00000000000
--- a/lib/generators/plugin/templates/controller.rb.erb
+++ /dev/null
@@ -1,15 +0,0 @@
-module <%= classified_name %>
- class ActionsController < ::ApplicationController
- requires_plugin <%= classified_name %>
-
- before_action :ensure_logged_in
-
- def index
- render_json_dump({ actions: [] })
- end
-
- def show
- render_json_dump({ action: { id: params[:id] } })
- end
- end
-end
diff --git a/lib/generators/plugin/templates/controller_spec.rb.erb b/lib/generators/plugin/templates/controller_spec.rb.erb
deleted file mode 100644
index 15472e1e4b3..00000000000
--- a/lib/generators/plugin/templates/controller_spec.rb.erb
+++ /dev/null
@@ -1,13 +0,0 @@
-require 'rails_helper'
-
-describe <%= name %>::ActionsController do
- before do
- Jobs.run_immediately!
- end
-
- it 'can list' do
- sign_in(Fabricate(:user))
- get "/<%= dasherized_name %>/list.json"
- expect(response.status).to eq(200)
- end
-end
diff --git a/lib/generators/plugin/templates/engine.rb.erb b/lib/generators/plugin/templates/engine.rb.erb
deleted file mode 100644
index 449db3929f1..00000000000
--- a/lib/generators/plugin/templates/engine.rb.erb
+++ /dev/null
@@ -1,12 +0,0 @@
-module <%= classified_name %>
- class Engine < ::Rails::Engine
- engine_name "<%= classified_name %>".freeze
- isolate_namespace <%= classified_name %>
-
- config.after_initialize do
- Discourse::Application.routes.append do
- mount ::<%= classified_name %>::Engine, at: "/<%= dasherized_name %>"
- end
- end
- end
-end
diff --git a/lib/generators/plugin/templates/javascript.js.es6.erb b/lib/generators/plugin/templates/javascript.js.es6.erb
deleted file mode 100644
index bd73e7175e6..00000000000
--- a/lib/generators/plugin/templates/javascript.js.es6.erb
+++ /dev/null
@@ -1,13 +0,0 @@
-import { withPluginApi } from "discourse/lib/plugin-api";
-
-function initialize<%= classified_name %>(api) {
- // https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse/lib/plugin-api.js.es6
-}
-
-export default {
- name: "<%= dasherized_name %>",
-
- initialize() {
- withPluginApi("0.8.31", initialize<%= classified_name %>);
- }
-};
diff --git a/lib/generators/plugin/templates/plugin.rb.erb b/lib/generators/plugin/templates/plugin.rb.erb
deleted file mode 100644
index aa33a6aa55c..00000000000
--- a/lib/generators/plugin/templates/plugin.rb.erb
+++ /dev/null
@@ -1,21 +0,0 @@
-# frozen_string_literal: true
-
-# name: <%= name %>
-# about: <%= @about %>
-# version: 0.1
-# authors: <%= @github_username %>
-# url: https://github.com/<%= @github_username %>
-
-register_asset 'stylesheets/common/<%= dasherized_name %>.scss'
-register_asset 'stylesheets/desktop/<%= dasherized_name %>.scss', :desktop
-register_asset 'stylesheets/mobile/<%= dasherized_name %>.scss', :mobile
-
-enabled_site_setting :<%= underscored_name %>_enabled
-
-PLUGIN_NAME ||= '<%= classified_name %>'
-
-load File.expand_path('lib/<%= dasherized_name %>/engine.rb', __dir__)
-
-after_initialize do
- # https://github.com/discourse/discourse/blob/main/lib/plugin/instance.rb
-end
diff --git a/lib/generators/plugin/templates/plugin_controller.rb.erb b/lib/generators/plugin/templates/plugin_controller.rb.erb
deleted file mode 100644
index 4f86ef504c5..00000000000
--- a/lib/generators/plugin/templates/plugin_controller.rb.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-module <%= classified_name %>
- class <%= classified_name %>Controller < ::ApplicationController
- requires_plugin <%= classified_name %>
-
- before_action :ensure_logged_in
-
- def index
- end
- end
-end
diff --git a/lib/generators/plugin/templates/route-map.js.es6.erb b/lib/generators/plugin/templates/route-map.js.es6.erb
deleted file mode 100644
index 76f1c73ed4e..00000000000
--- a/lib/generators/plugin/templates/route-map.js.es6.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-export default function() {
- this.route("<%= dasherized_name %>", function() {
- this.route("actions", function() {
- this.route("show", { path: "/:id" });
- });
- });
-};
diff --git a/lib/generators/plugin/templates/route_constraint.rb.erb b/lib/generators/plugin/templates/route_constraint.rb.erb
deleted file mode 100644
index 2954ac262f4..00000000000
--- a/lib/generators/plugin/templates/route_constraint.rb.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-class <%= classified_name %>Constraint
- def matches?(request)
- SiteSetting.<%= underscored_name %>_enabled
- end
-end
diff --git a/lib/generators/plugin/templates/routes.rb.erb b/lib/generators/plugin/templates/routes.rb.erb
deleted file mode 100644
index 4f31f596ce4..00000000000
--- a/lib/generators/plugin/templates/routes.rb.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-require_dependency "<%= underscored_name %>_constraint"
-
-<%= classified_name %>::Engine.routes.draw do
- get "/" => "<%= underscored_name %>#index", constraints: <%= classified_name %>Constraint.new
- get "/actions" => "actions#index", constraints: <%= classified_name %>Constraint.new
- get "/actions/:id" => "actions#show", constraints: <%= classified_name %>Constraint.new
-end
diff --git a/lib/generators/plugin/templates/scheduled_job.rb.erb b/lib/generators/plugin/templates/scheduled_job.rb.erb
deleted file mode 100644
index c2b6ed03840..00000000000
--- a/lib/generators/plugin/templates/scheduled_job.rb.erb
+++ /dev/null
@@ -1,8 +0,0 @@
-module Jobs
- class ::<%= classified_name %>::Check < ::Jobs::Scheduled
- every 1.day
-
- def execute(args = nil)
- end
- end
-end
diff --git a/lib/generators/plugin/templates/server.en.yml.erb b/lib/generators/plugin/templates/server.en.yml.erb
deleted file mode 100644
index 574f41acd75..00000000000
--- a/lib/generators/plugin/templates/server.en.yml.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-en:
- site_settings:
- <%= underscored_name %>_enabled: "Enable <%= name %> plugin"
diff --git a/lib/generators/plugin/templates/settings.yml.erb b/lib/generators/plugin/templates/settings.yml.erb
deleted file mode 100644
index 3f43a52beb6..00000000000
--- a/lib/generators/plugin/templates/settings.yml.erb
+++ /dev/null
@@ -1,4 +0,0 @@
-plugins:
- <%= underscored_name %>_enabled:
- default: true
- client: true
diff --git a/lib/generators/plugin/templates/stylesheet.scss.erb b/lib/generators/plugin/templates/stylesheet.scss.erb
deleted file mode 100644
index ef54f605be4..00000000000
--- a/lib/generators/plugin/templates/stylesheet.scss.erb
+++ /dev/null
@@ -1,2 +0,0 @@
-.<%= dasherized_name %> {
-}