create-discourse-plugin 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8649d262fc966d404263a71cf21248facc90ed0d06aec144924bf7db7a3d7cc3
4
+ data.tar.gz: 57f69b7ffa53b7b621ed2ac9130ded8841e50643f4be4e1de842af084ab56a0f
5
+ SHA512:
6
+ metadata.gz: b0ba42fb7fed8dd6bb65a354c985efa5edf0f3b4beaf8342d9428b1b7b6a37237a13a285834c7c9284e0dc9602296b123cfb096605ec7fa76062a2bca5725bd2
7
+ data.tar.gz: 3663084dae7edf53cf065fb0fec3497d151c02605c932d2bf930e2b1c460aa980031c1e0a7e8052ff09278cd6e89615127e99e29cf348fe57d5a01050be6172d
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # just run the script from `lib/create-discourse-plugin`
4
+
5
+ require_relative '../lib/create-discourse-plugin.rb'
@@ -0,0 +1,64 @@
1
+ # Helper
2
+ class Helpers
3
+ def self.to_snake_case(string)
4
+ string.dup.gsub!('-', '_')
5
+ end
6
+
7
+ def self.to_pascal_case(string)
8
+ string.dup.split('-').map(&:capitalize).join
9
+ end
10
+
11
+ def self.to_pascal_spaced_case(string)
12
+ string.dup.split('-').map(&:capitalize).join(' ')
13
+ end
14
+ end
15
+
16
+ plugin_name = ARGV[0]
17
+
18
+ if plugin_name.nil?
19
+ puts 'Please provide a plugin name, use kebab-case.'
20
+ plugin_name = gets.chomp
21
+ end
22
+
23
+ system "gh repo create #{plugin_name} --template discourse/discourse-plugin-skeleton --private --clone"
24
+
25
+ puts '🚂 Renaming directories...'
26
+
27
+ File.rename "./#{plugin_name}/lib/my_plugin_module", "./#{plugin_name}/lib/#{Helpers.to_snake_case(plugin_name)}"
28
+
29
+ File.rename "./#{plugin_name}/app/controllers/my_plugin_module", "./#{plugin_name}/app/controllers/#{Helpers.to_snake_case(plugin_name)}"
30
+
31
+ to_update_files = # assume all start with ./#{plugin_name}/
32
+ [
33
+ "app/controllers/#{Helpers.to_snake_case(plugin_name)}/examples_controller.rb",
34
+ 'config/locales/client.en.yml',
35
+ 'config/routes.rb',
36
+ 'config/settings.yml',
37
+ "lib/#{Helpers.to_snake_case(plugin_name)}/engine.rb",
38
+ 'plugin.rb',
39
+ 'README.md'
40
+ ]
41
+
42
+ to_update_files.each do |file|
43
+ puts "🚂 Updating #{file}..."
44
+
45
+ updated_file = ''
46
+ File.foreach("./#{plugin_name}/#{file}") do |line|
47
+ updated_file << line.gsub('MyPluginModule', Helpers.to_pascal_case(plugin_name))
48
+ .gsub('my_plugin_module', Helpers.to_snake_case(plugin_name))
49
+ .gsub('my-plugin', plugin_name)
50
+ .gsub('discourse-plugin-name', plugin_name)
51
+ .gsub('TODO_plugin_name', Helpers.to_snake_case(plugin_name))
52
+ .gsub('plugin_name_enabled', "#{Helpers.to_snake_case(plugin_name)}_enabled")
53
+ .gsub('discourse_plugin_name', Helpers.to_snake_case(plugin_name))
54
+ .gsub('Plugin Name', Helpers.to_pascal_spaced_case(plugin_name))
55
+ .gsub('lib/my_plugin_module/engine', "lib/#{Helpers.to_snake_case(plugin_name)}/engine")
56
+ end
57
+
58
+ File.open("./#{plugin_name}/#{file}", 'w') { |f| f.write(updated_file) }
59
+ end
60
+
61
+ puts 'Done! 🎉'
62
+
63
+ puts 'Do not forget to update the README.md and plugin.rb file with the plugin description and the url of the plugin.'
64
+ puts 'You are ready to start developing your plugin! 🚀'
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: create-discourse-plugin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gabriel Grubba
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-07-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Based on the Discourse plugin skeleton, this script creates a new plugin
14
+ with the provided name.
15
+ email: grubba27@hotmail.com
16
+ executables:
17
+ - create-discourse-plugin
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - bin/create-discourse-plugin
22
+ - lib/create-discourse-plugin.rb
23
+ homepage:
24
+ licenses:
25
+ - MIT
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 2.7.0
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubygems_version: 3.5.6
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Create a Discourse plugin from a template.
46
+ test_files: []