discourse_theme 0.5.1 → 0.5.2
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 +4 -4
- data/lib/discourse_theme.rb +9 -9
- data/lib/discourse_theme/cli.rb +16 -1
- data/lib/discourse_theme/scaffold.rb +23 -5
- data/lib/discourse_theme/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20a594e3cf6429ad7b721ca546710a1f57706a74bb0c8346301dea8b76a58cea
|
4
|
+
data.tar.gz: 477808a79184cc9251865a86a77ccfa33a64318a90a774207a5441b683499546
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d5ad9c41ca00b3172167b1985cdb5da36ef6d8073ad6b4882f6760da05006f550a12447007d64fb8486e078245eab618979c80e18e78eaa4cc1487269dd780a
|
7
|
+
data.tar.gz: 7e40d9ec1727422c4875307b35b38a3d178330598c4a0b1c207779564fe8cf4dbbd07864e964e8e7eee1d5ffec47ad9cdc2821f28fd24ebe1bdb44677cd659cf
|
data/lib/discourse_theme.rb
CHANGED
@@ -14,15 +14,15 @@ require 'json'
|
|
14
14
|
require 'yaml'
|
15
15
|
require 'tty/prompt'
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
require_relative 'discourse_theme/version'
|
18
|
+
require_relative 'discourse_theme/config'
|
19
|
+
require_relative 'discourse_theme/ui'
|
20
|
+
require_relative 'discourse_theme/cli'
|
21
|
+
require_relative 'discourse_theme/client'
|
22
|
+
require_relative 'discourse_theme/downloader'
|
23
|
+
require_relative 'discourse_theme/uploader'
|
24
|
+
require_relative 'discourse_theme/watcher'
|
25
|
+
require_relative 'discourse_theme/scaffold'
|
26
26
|
|
27
27
|
module DiscourseTheme
|
28
28
|
class ThemeError < StandardError; end
|
data/lib/discourse_theme/cli.rb
CHANGED
@@ -29,7 +29,10 @@ module DiscourseTheme
|
|
29
29
|
components = settings.components
|
30
30
|
|
31
31
|
if command == "new"
|
32
|
-
raise DiscourseTheme::ThemeError.new "'#{dir} is not empty" if Dir.exists?(dir) && !Dir.empty?(dir)
|
32
|
+
raise DiscourseTheme::ThemeError.new "'#{dir}' is not empty" if Dir.exists?(dir) && !Dir.empty?(dir)
|
33
|
+
raise DiscourseTheme::ThemeError.new "git is not installed" if !command?("git")
|
34
|
+
raise DiscourseTheme::ThemeError.new "yarn is not installed" if !command?("yarn")
|
35
|
+
|
33
36
|
DiscourseTheme::Scaffold.generate(dir)
|
34
37
|
watch_theme?(args)
|
35
38
|
elsif command == "watch"
|
@@ -120,6 +123,18 @@ module DiscourseTheme
|
|
120
123
|
|
121
124
|
private
|
122
125
|
|
126
|
+
def command?(cmd)
|
127
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
128
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
129
|
+
exts.each do |ext|
|
130
|
+
exe = File.join(path, "#{cmd}#{ext}")
|
131
|
+
return true if File.executable?(exe) && !File.directory?(exe)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
false
|
136
|
+
end
|
137
|
+
|
123
138
|
def watch_theme?(args)
|
124
139
|
if UI.yes?("Would you like to start 'watching' this theme?")
|
125
140
|
args[0] = "watch"
|
@@ -67,11 +67,30 @@ module DiscourseTheme
|
|
67
67
|
def self.generate(dir)
|
68
68
|
UI.progress "Generating a scaffold theme at #{dir}"
|
69
69
|
|
70
|
-
name =
|
70
|
+
name = loop do
|
71
|
+
input = UI.ask("What would you like to call your theme?").to_s.strip
|
72
|
+
if input.empty?
|
73
|
+
UI.error("Theme name cannot be empty")
|
74
|
+
else
|
75
|
+
break input
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
71
79
|
is_component = UI.yes?("Is this a component?")
|
72
80
|
|
73
81
|
FileUtils.mkdir_p dir
|
74
82
|
Dir.chdir dir do
|
83
|
+
author = loop do
|
84
|
+
input = UI.ask("Who is authoring the theme?", default: ENV['USER']).to_s.strip
|
85
|
+
if input.empty?
|
86
|
+
UI.error("Author cannot be empty")
|
87
|
+
else
|
88
|
+
break input
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
description = UI.ask("How would you describe this theme?").to_s.strip
|
93
|
+
|
75
94
|
UI.info "Creating about.json"
|
76
95
|
about_template = ABOUT_JSON.dup
|
77
96
|
about_template[:name] = name
|
@@ -86,7 +105,6 @@ module DiscourseTheme
|
|
86
105
|
File.write('HELP', HELP)
|
87
106
|
|
88
107
|
UI.info "Creating package.json"
|
89
|
-
author = UI.ask("Who is authoring the theme?").strip
|
90
108
|
File.write('package.json', PACKAGE_JSON.sub("#AUTHOR", author))
|
91
109
|
|
92
110
|
UI.info "Creating .template-lintrc.js"
|
@@ -101,10 +119,10 @@ module DiscourseTheme
|
|
101
119
|
locale = "locales/en.yml"
|
102
120
|
UI.info "Creating #{locale}"
|
103
121
|
FileUtils.mkdir_p(File.dirname(locale))
|
104
|
-
description = UI.ask("How would you describe this theme?").strip
|
105
122
|
File.write(locale, EN_YML.sub("#DESCRIPTION", description))
|
106
123
|
|
107
|
-
|
124
|
+
encoded_name = name.downcase.gsub(/[^\w_-]+/, '_')
|
125
|
+
initializer = "javascripts/discourse/api-initializers/#{encoded_name}.js"
|
108
126
|
UI.info "Creating #{initializer}"
|
109
127
|
FileUtils.mkdir_p(File.dirname(initializer))
|
110
128
|
File.write(initializer, API_INITIALIZER)
|
@@ -116,7 +134,7 @@ module DiscourseTheme
|
|
116
134
|
end
|
117
135
|
|
118
136
|
UI.info "Initializing git repo"
|
119
|
-
puts `git init
|
137
|
+
puts `git init . --initial-branch=main`
|
120
138
|
|
121
139
|
UI.info "Installing dependencies"
|
122
140
|
puts `yarn`
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discourse_theme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitar
|