discourse_theme 0.7.6 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/discourse_theme/scaffold.rb +52 -42
- 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: 8115db0a38be583770d879d2c54bf167e27d1f05582ec38144c8598d1b3111d8
|
4
|
+
data.tar.gz: 1963461e7ea2b640514b2ef049ee968d619fc6163c67e0e039969fbe04db23d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4e0de4798c6667049fbcd3ad97e50f17d3677972d269916f7fa11e0e4a3d310373a6eb58242dad20d3b7fec4f1de4c0b3c255fed30fe0b15e89dce9cac723d8
|
7
|
+
data.tar.gz: e70dad03335fb5dcd6c2f3a074d4e0aca04aba798fc31bc52c9a6137b8422f46da12a1497543d104767907473b6e5e411cd592e41e68a218112873bb5c619107
|
@@ -1,19 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'date'
|
3
4
|
require 'json'
|
4
5
|
|
5
6
|
module DiscourseTheme
|
6
7
|
class Scaffold
|
7
8
|
|
8
|
-
BLANK_FILES = %w{
|
9
|
-
common/common.scss
|
10
|
-
|
11
|
-
settings.yml
|
12
|
-
}
|
13
|
-
|
14
9
|
ABOUT_JSON = {
|
15
|
-
about_url:
|
16
|
-
license_url:
|
10
|
+
about_url: "TODO: Put your theme's public repo or Meta topic URL here",
|
11
|
+
license_url: "TODO: Put your theme's LICENSE URL here",
|
17
12
|
assets: {}
|
18
13
|
}
|
19
14
|
|
@@ -21,6 +16,28 @@ module DiscourseTheme
|
|
21
16
|
Are you a bit lost? Be sure to read https://meta.discourse.org/t/how-to-develop-custom-themes/60848
|
22
17
|
STR
|
23
18
|
|
19
|
+
LICENSE = <<~STR
|
20
|
+
Copyright #YEAR #AUTHOR
|
21
|
+
|
22
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
23
|
+
of this software and associated documentation files (the "Software"), to deal
|
24
|
+
in the Software without restriction, including without limitation the rights
|
25
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
26
|
+
copies of the Software, and to permit persons to whom the Software is
|
27
|
+
furnished to do so, subject to the following conditions:
|
28
|
+
|
29
|
+
The above copyright notice and this permission notice shall be included in all
|
30
|
+
copies or substantial portions of the Software.
|
31
|
+
|
32
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
33
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
34
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
35
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
36
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
37
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
38
|
+
SOFTWARE.
|
39
|
+
STR
|
40
|
+
|
24
41
|
GIT_IGNORE = <<~STR
|
25
42
|
.discourse-site
|
26
43
|
node_modules
|
@@ -30,7 +47,7 @@ module DiscourseTheme
|
|
30
47
|
API_INITIALIZER = <<~STR
|
31
48
|
import { apiInitializer } from "discourse/lib/api";
|
32
49
|
|
33
|
-
export default apiInitializer("
|
50
|
+
export default apiInitializer("1.8.0", (api) => {
|
34
51
|
console.log("hello world from api initializer!");
|
35
52
|
});
|
36
53
|
STR
|
@@ -68,6 +85,11 @@ module DiscourseTheme
|
|
68
85
|
description: "#DESCRIPTION"
|
69
86
|
YAML
|
70
87
|
|
88
|
+
SETTINGS_YML = <<~YAML
|
89
|
+
todo_rename_and_use_setting:
|
90
|
+
default: ""
|
91
|
+
YAML
|
92
|
+
|
71
93
|
def self.generate(dir)
|
72
94
|
UI.progress "Generating a scaffold theme at #{dir}"
|
73
95
|
|
@@ -95,7 +117,6 @@ module DiscourseTheme
|
|
95
117
|
|
96
118
|
description = UI.ask("How would you describe this theme?").to_s.strip
|
97
119
|
|
98
|
-
UI.info "Creating about.json"
|
99
120
|
about_template = ABOUT_JSON.dup
|
100
121
|
about_template[:name] = name
|
101
122
|
if is_component
|
@@ -103,46 +124,35 @@ module DiscourseTheme
|
|
103
124
|
else
|
104
125
|
about_template[:color_schemes] = {}
|
105
126
|
end
|
106
|
-
File.write('about.json', JSON.pretty_generate(about_template))
|
107
|
-
|
108
|
-
UI.info "Creating HELP"
|
109
|
-
File.write('HELP', HELP)
|
110
|
-
|
111
|
-
UI.info "Creating package.json"
|
112
|
-
File.write('package.json', PACKAGE_JSON.sub("#AUTHOR", author))
|
113
|
-
|
114
|
-
UI.info "Creating .template-lintrc.js"
|
115
|
-
File.write('.template-lintrc.js', TEMPLATE_LINT_RC)
|
116
|
-
|
117
|
-
UI.info "Creating .eslintrc"
|
118
|
-
File.write('.eslintrc', ESLINT_RC)
|
119
|
-
|
120
|
-
UI.info "Creating .gitignore"
|
121
|
-
File.write('.gitignore', GIT_IGNORE)
|
122
|
-
|
123
|
-
locale = "locales/en.yml"
|
124
|
-
UI.info "Creating #{locale}"
|
125
|
-
FileUtils.mkdir_p(File.dirname(locale))
|
126
|
-
File.write(locale, EN_YML.sub("#DESCRIPTION", description))
|
127
127
|
|
128
128
|
encoded_name = name.downcase.gsub(/[^a-zA-Z0-9_-]+/, '_')
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
129
|
+
|
130
|
+
write('about.json', JSON.pretty_generate(about_template))
|
131
|
+
write('HELP', HELP)
|
132
|
+
write('LICENSE', LICENSE.sub("#YEAR", "#{Date.today.year}").sub("#AUTHOR", author))
|
133
|
+
write('.eslintrc', ESLINT_RC)
|
134
|
+
write('.gitignore', GIT_IGNORE)
|
135
|
+
write('.template-lintrc.js', TEMPLATE_LINT_RC)
|
136
|
+
write('package.json', PACKAGE_JSON.sub("#AUTHOR", author))
|
137
|
+
write('settings.yml', SETTINGS_YML)
|
138
|
+
write('common/common.scss', '')
|
139
|
+
write("javascripts/discourse/api-initializers/#{encoded_name}.js", API_INITIALIZER)
|
140
|
+
write('locales/en.yml', EN_YML.sub("#DESCRIPTION", description))
|
139
141
|
|
140
142
|
UI.info "Initializing git repo"
|
141
|
-
puts `git init
|
143
|
+
puts `git init && git symbolic-ref HEAD refs/heads/main`
|
142
144
|
|
143
145
|
UI.info "Installing dependencies"
|
144
146
|
puts `yarn`
|
145
147
|
end
|
146
148
|
end
|
149
|
+
|
150
|
+
private
|
151
|
+
|
152
|
+
def self.write(filename, contents)
|
153
|
+
UI.info "Creating #{filename}"
|
154
|
+
FileUtils.mkdir_p(File.dirname(filename))
|
155
|
+
File.write(filename, contents)
|
156
|
+
end
|
147
157
|
end
|
148
158
|
end
|
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.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitar
|