k_director 0.8.1 → 0.10.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/.builders/boot.rb +3 -3
- data/.vscode/settings.json +5 -0
- data/docs/CHANGELOG.md +34 -0
- data/lib/k_director/directors/base_director.rb +4 -0
- data/lib/k_director/dsls/children/package_json.rb +298 -8
- data/lib/k_director/dsls/children/package_json_configuration.rb +29 -5
- data/lib/k_director/dsls/nuxt3_dsl.rb +9 -2
- data/lib/k_director/dsls/ruby_gem_dsl.rb +7 -0
- data/lib/k_director/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '080f78bce274be30bf0b77765c7fe6b40c56a9a5f40b385dd55ed96cd81b440b'
|
4
|
+
data.tar.gz: 7f12eeaf1ccdac94be739700260e30282766f85f9d4fad8f6e9cb81bd47359f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20fb925316d432b16e5ac5b5074f5e2d86845225262dae2460962b51199555d757e889a8a3fdd62b86dab2f60b7f35c5892a875b530369b9d83268e52d657be2
|
7
|
+
data.tar.gz: 2e5d5485a94a94cbfa2a86110e7bea1a5af50b32febc51830d935b5e4592ddc1bcd9d4424044acbb3d0ec0b606197e1c674bac57e43ccd5386a70bd1a0663272
|
data/.builders/boot.rb
CHANGED
@@ -40,10 +40,10 @@ def dasherize
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def k_builder
|
43
|
-
@k_builder ||= KBuilder::BaseBuilder.init(
|
43
|
+
@k_builder ||= KBuilder::BaseBuilder.init(KConfig.configuration(CONFIG_KEY))
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
KConfig.configure(CONFIG_KEY) do |config|
|
47
47
|
builder_folder = Dir.pwd
|
48
48
|
base_folder = File.expand_path('../', builder_folder)
|
49
49
|
global_template = File.expand_path('~/dev/kgems/k_templates/templates')
|
@@ -58,7 +58,7 @@ KBuilder.configure(CONFIG_KEY) do |config|
|
|
58
58
|
# config.target_folders.add(:database , :data, 'database')
|
59
59
|
end
|
60
60
|
|
61
|
-
|
61
|
+
KConfig.configuration(CONFIG_KEY).debug
|
62
62
|
|
63
63
|
area = KManager.add_area(CONFIG_KEY)
|
64
64
|
resource_manager = area.resource_manager
|
data/docs/CHANGELOG.md
CHANGED
@@ -1,3 +1,37 @@
|
|
1
|
+
## [0.10.1](https://github.com/klueless-io/k_director/compare/v0.10.0...v0.10.1) (2022-02-06)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* package_json, add set by group, remove and re ove by group ([93317f8](https://github.com/klueless-io/k_director/commit/93317f8b590ac2551e72072e93ca9b7f0d54f568))
|
7
|
+
|
8
|
+
# [0.10.0](https://github.com/klueless-io/k_director/compare/v0.9.0...v0.10.0) (2022-02-06)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* package_json set key converted to string and stripped ([784b33d](https://github.com/klueless-io/k_director/commit/784b33db2a045e8273e4e5a30747f0b05cc50cfd))
|
14
|
+
|
15
|
+
|
16
|
+
### Features
|
17
|
+
|
18
|
+
* add package_json dsl support to nuxt3 and rubygem ([9b4650d](https://github.com/klueless-io/k_director/commit/9b4650d48deaeb158ef25300b12f9de5725bf2c0))
|
19
|
+
* add sort package json keys to package_json dsl ([90e2041](https://github.com/klueless-io/k_director/commit/90e2041759714faa1333c51226102e7ab8041a0a))
|
20
|
+
|
21
|
+
# [0.9.0](https://github.com/klueless-io/k_director/compare/v0.8.1...v0.9.0) (2022-02-05)
|
22
|
+
|
23
|
+
|
24
|
+
### Features
|
25
|
+
|
26
|
+
* add package_json dsl support ([15b3ad7](https://github.com/klueless-io/k_director/commit/15b3ad7472a3374e646c391a7271fb7782636afe))
|
27
|
+
|
28
|
+
## [0.8.1](https://github.com/klueless-io/k_director/compare/v0.8.0...v0.8.1) (2022-02-05)
|
29
|
+
|
30
|
+
|
31
|
+
### Bug Fixes
|
32
|
+
|
33
|
+
* add tests for package_json configuration ([d900065](https://github.com/klueless-io/k_director/commit/d900065bf810771841b97de03dfa9011c48c8e43))
|
34
|
+
|
1
35
|
# [0.8.0](https://github.com/klueless-io/k_director/compare/v0.7.3...v0.8.0) (2022-02-04)
|
2
36
|
|
3
37
|
|
@@ -17,14 +17,6 @@ module KDirector
|
|
17
17
|
|
18
18
|
set_package_file('package.json')
|
19
19
|
set_dependency_type(:development)
|
20
|
-
|
21
|
-
# defaults = {
|
22
|
-
# repo_name: opts[:repo_name], # || parent.builder.dom&[:PackageJson]&[:repo_name]
|
23
|
-
# username: opts[:username] || default_PackageJson_username, # || parent.builder.dom&[:PackageJson]&[:username]
|
24
|
-
# organization: opts[:organization] # || parent.builder.dom&[:PackageJson]&[:organization]
|
25
|
-
# }
|
26
|
-
|
27
|
-
# parent.builder.group_set(:PackageJson, **repo_info_hash(**defaults))
|
28
20
|
end
|
29
21
|
|
30
22
|
# ----------------------------------------------------------------------
|
@@ -44,6 +36,304 @@ module KDirector
|
|
44
36
|
|
45
37
|
self
|
46
38
|
end
|
39
|
+
|
40
|
+
# Init an NPN package
|
41
|
+
#
|
42
|
+
# run npm init -y
|
43
|
+
#
|
44
|
+
# Note: npm init does not support --silent operation
|
45
|
+
def npm_init
|
46
|
+
run_command 'npm init -y'
|
47
|
+
|
48
|
+
load
|
49
|
+
|
50
|
+
self
|
51
|
+
end
|
52
|
+
|
53
|
+
# Space separated list of packages
|
54
|
+
def npm_install(packages, options: nil)
|
55
|
+
npm_add_or_install(packages, parse_options(options))
|
56
|
+
|
57
|
+
self
|
58
|
+
end
|
59
|
+
alias npm_i npm_install
|
60
|
+
|
61
|
+
def npm_add(packages, options: nil)
|
62
|
+
npm_add_or_install(packages, parse_options(options, '--package-lock-only --no-package-lock'))
|
63
|
+
|
64
|
+
self
|
65
|
+
end
|
66
|
+
alias npm_a npm_add
|
67
|
+
|
68
|
+
def npm_add_group(key, options: nil)
|
69
|
+
group = get_group(key)
|
70
|
+
|
71
|
+
puts "Adding #{group.description}"
|
72
|
+
|
73
|
+
npm_add(group.package_names, options: options)
|
74
|
+
|
75
|
+
self
|
76
|
+
end
|
77
|
+
alias npm_ag npm_add_group
|
78
|
+
|
79
|
+
# Add a group of NPN packages which get defined in configuration
|
80
|
+
def npm_install_group(key, options: nil)
|
81
|
+
group = get_group(key)
|
82
|
+
|
83
|
+
puts "Installing #{group.description}"
|
84
|
+
|
85
|
+
npm_install(group.package_names, options: options)
|
86
|
+
|
87
|
+
self
|
88
|
+
end
|
89
|
+
|
90
|
+
# Load the existing package.json into memory
|
91
|
+
#
|
92
|
+
# ToDo: Would be useful to record the update timestamp on the package
|
93
|
+
# so that we only load if the in memory package is not the latest.
|
94
|
+
#
|
95
|
+
# The reason this can happen, is because external tools such are
|
96
|
+
# npm install are updating the package.json and after this happens
|
97
|
+
# we need to call load, but if there is any bug in the code we may
|
98
|
+
# for get to load, or we may load multiple times.
|
99
|
+
def load
|
100
|
+
raise KDirector::Error, 'package.json does not exist' unless File.exist?(package_file)
|
101
|
+
|
102
|
+
# puts 'loading...'
|
103
|
+
|
104
|
+
content = File.read(package_file)
|
105
|
+
@package = JSON.parse(content)
|
106
|
+
|
107
|
+
self
|
108
|
+
end
|
109
|
+
|
110
|
+
# Write the package.json file
|
111
|
+
def write
|
112
|
+
# puts 'writing...'
|
113
|
+
|
114
|
+
content = JSON.pretty_generate(@package)
|
115
|
+
|
116
|
+
File.write(package_file, content)
|
117
|
+
|
118
|
+
self
|
119
|
+
end
|
120
|
+
|
121
|
+
# Remove a script reference by key
|
122
|
+
def remove_script(key)
|
123
|
+
remove(key, group: 'scripts')
|
124
|
+
# load
|
125
|
+
|
126
|
+
# @package['scripts']&.delete(key)
|
127
|
+
|
128
|
+
# write
|
129
|
+
|
130
|
+
self
|
131
|
+
end
|
132
|
+
|
133
|
+
# Add a script with key and value (command line to run)
|
134
|
+
def add_script(key, value)
|
135
|
+
set(key, value, group: 'scripts')
|
136
|
+
|
137
|
+
self
|
138
|
+
end
|
139
|
+
|
140
|
+
# ----------------------------------------------------------------------
|
141
|
+
# Attributes: Think getter/setter
|
142
|
+
#
|
143
|
+
# The following getter/setters can be referenced both inside and outside
|
144
|
+
# of the fluent builder fluent API. They do not implement the fluent
|
145
|
+
# interface unless prefixed by set_.
|
146
|
+
#
|
147
|
+
# set_: Only setters with the prefix _set are considered fluent.
|
148
|
+
# ----------------------------------------------------------------------
|
149
|
+
|
150
|
+
# Package
|
151
|
+
# ----------------------------------------------------------------------
|
152
|
+
|
153
|
+
# Load the package.json into a memory as object
|
154
|
+
def package
|
155
|
+
return @package if defined? @package
|
156
|
+
|
157
|
+
load
|
158
|
+
|
159
|
+
@package
|
160
|
+
end
|
161
|
+
|
162
|
+
# Package.set
|
163
|
+
# ----------------------------------------------------------------------
|
164
|
+
|
165
|
+
# Set a property value in the package
|
166
|
+
def set(key, value, group: nil)
|
167
|
+
load
|
168
|
+
|
169
|
+
key = key.to_s.strip
|
170
|
+
|
171
|
+
if group.nil?
|
172
|
+
@package[key] = value
|
173
|
+
else
|
174
|
+
group = group.to_s.strip
|
175
|
+
@package[group] = {} unless @package[group]
|
176
|
+
@package[group][key] = value
|
177
|
+
end
|
178
|
+
|
179
|
+
write
|
180
|
+
|
181
|
+
self
|
182
|
+
end
|
183
|
+
|
184
|
+
def remove(key, group: nil)
|
185
|
+
load
|
186
|
+
|
187
|
+
key = key.to_s.strip
|
188
|
+
|
189
|
+
if group.nil?
|
190
|
+
@package.delete(key)
|
191
|
+
else
|
192
|
+
group = group.to_s.strip
|
193
|
+
@package[group]&.delete(key)
|
194
|
+
end
|
195
|
+
|
196
|
+
@package['scripts']&.delete(key)
|
197
|
+
|
198
|
+
write
|
199
|
+
|
200
|
+
self
|
201
|
+
end
|
202
|
+
|
203
|
+
# Package.sort using `npx sort-package-json`
|
204
|
+
# ----------------------------------------------------------------------
|
205
|
+
|
206
|
+
# Sort the package.json keys using `npx sort-package-json`
|
207
|
+
def sort
|
208
|
+
run_command 'npx sort-package-json'
|
209
|
+
|
210
|
+
load
|
211
|
+
|
212
|
+
self
|
213
|
+
end
|
214
|
+
|
215
|
+
# Dependency option
|
216
|
+
# ----------------------------------------------------------------------
|
217
|
+
|
218
|
+
# Getter for dependency option
|
219
|
+
def dependency_option
|
220
|
+
dependency_type == :development ? '-D' : '-P'
|
221
|
+
end
|
222
|
+
|
223
|
+
# Dependency type
|
224
|
+
# ----------------------------------------------------------------------
|
225
|
+
|
226
|
+
# Fluent setter for target folder
|
227
|
+
# rubocop:disable Naming/AccessorMethodName
|
228
|
+
def set_dependency_type(value)
|
229
|
+
self.dependency_type = value
|
230
|
+
|
231
|
+
self
|
232
|
+
end
|
233
|
+
# rubocop:enable Naming/AccessorMethodName
|
234
|
+
|
235
|
+
# Package file
|
236
|
+
# ----------------------------------------------------------------------
|
237
|
+
|
238
|
+
# Fluent setter for package file
|
239
|
+
# rubocop:disable Naming/AccessorMethodName
|
240
|
+
def set_package_file(value)
|
241
|
+
self.package_file = value
|
242
|
+
|
243
|
+
self
|
244
|
+
end
|
245
|
+
# rubocop:enable Naming/AccessorMethodName
|
246
|
+
|
247
|
+
# Setter for package file
|
248
|
+
def package_file=(_value)
|
249
|
+
@package_file = File.join(k_builder.target_folder, 'package.json')
|
250
|
+
end
|
251
|
+
|
252
|
+
# Remove package-lock.json
|
253
|
+
# ----------------------------------------------------------------------
|
254
|
+
|
255
|
+
def remove_package_lock
|
256
|
+
file = File.join(k_builder.target_folder, 'package-lock.json')
|
257
|
+
|
258
|
+
File.delete(file) if File.exist?(file)
|
259
|
+
|
260
|
+
self
|
261
|
+
end
|
262
|
+
|
263
|
+
# Remove yarn.lock
|
264
|
+
# ----------------------------------------------------------------------
|
265
|
+
|
266
|
+
def remove_yarn_lock
|
267
|
+
file = File.join(k_builder.target_folder, 'yarn.lock')
|
268
|
+
|
269
|
+
File.delete(file) if File.exist?(file)
|
270
|
+
|
271
|
+
self
|
272
|
+
end
|
273
|
+
|
274
|
+
# Create yarn.lock
|
275
|
+
# ----------------------------------------------------------------------
|
276
|
+
|
277
|
+
def create_yarn_lock
|
278
|
+
run_command 'yarn install --check-files'
|
279
|
+
|
280
|
+
self
|
281
|
+
end
|
282
|
+
|
283
|
+
# -----------------------------------
|
284
|
+
# Helpers
|
285
|
+
# -----------------------------------
|
286
|
+
|
287
|
+
def parse_options(options = nil, required_options = nil)
|
288
|
+
options = [] if options.nil?
|
289
|
+
options = options.split if options.is_a?(String)
|
290
|
+
options.reject(&:empty?)
|
291
|
+
|
292
|
+
required_options = [] if required_options.nil?
|
293
|
+
required_options = required_options.split if required_options.is_a?(String)
|
294
|
+
|
295
|
+
options | required_options
|
296
|
+
end
|
297
|
+
|
298
|
+
def options_any?(options, *any_options)
|
299
|
+
(options & any_options).any?
|
300
|
+
end
|
301
|
+
|
302
|
+
def execute(command)
|
303
|
+
puts "RUN: #{command}"
|
304
|
+
run_command command
|
305
|
+
load
|
306
|
+
end
|
307
|
+
|
308
|
+
def npm_add_or_install(packages, options)
|
309
|
+
# if -P or -D is not in the options then use the current builder dependency option
|
310
|
+
options.push dependency_option unless options_any?(options, '-P', '-D')
|
311
|
+
packages = packages.join(' ') if packages.is_a?(Array)
|
312
|
+
command = "npm install #{options.join(' ')} #{packages}"
|
313
|
+
execute command
|
314
|
+
end
|
315
|
+
|
316
|
+
# # Debug method to open the package file in vscode
|
317
|
+
# # ToDo: Maybe remove
|
318
|
+
# def vscode
|
319
|
+
# puts "cd #{output_path}"
|
320
|
+
# puts package_file
|
321
|
+
# run_command "code #{package_file}"
|
322
|
+
# end
|
323
|
+
|
324
|
+
private
|
325
|
+
|
326
|
+
def get_group(key)
|
327
|
+
group = configuration.package_json.package_groups[key]
|
328
|
+
|
329
|
+
raise KConfig::PackageJson::Error, "unknown package group: #{key}" if group.nil?
|
330
|
+
|
331
|
+
group
|
332
|
+
end
|
333
|
+
|
334
|
+
def run_command(command)
|
335
|
+
parent.k_builder.run_command(command)
|
336
|
+
end
|
47
337
|
end
|
48
338
|
end
|
49
339
|
end
|
@@ -37,11 +37,35 @@ module KDirector
|
|
37
37
|
|
38
38
|
# Setup the default package groups
|
39
39
|
def set_default_package_groups
|
40
|
-
set_package_group('webpack' , 'Webpack V5', %w[webpack webpack-cli webpack-dev-server])
|
41
|
-
set_package_group('swc' , 'SWC Transpiler', %w[@swc/cli @swc/core swc-loader])
|
42
|
-
set_package_group('babel' , 'Babel Transpiler', %w[@babel/core @babel/cli @babel/preset-env babel-loader])
|
43
|
-
set_package_group('typescript' , 'Typescript', %w[typescript ts-loader])
|
44
|
-
set_package_group('
|
40
|
+
set_package_group('webpack' , 'Webpack V5' , %w[webpack webpack-cli webpack-dev-server])
|
41
|
+
set_package_group('swc' , 'SWC Transpiler' , %w[@swc/cli @swc/core swc-loader])
|
42
|
+
set_package_group('babel' , 'Babel Transpiler' , %w[@babel/core @babel/cli @babel/preset-env babel-loader])
|
43
|
+
set_package_group('typescript' , 'Typescript' , %w[typescript ts-loader])
|
44
|
+
set_package_group('semver-ruby' , 'Semantic Release for Ruby' , %w[semantic-release github:klueless-js/semantic-release-rubygem @semantic-release/changelog @semantic-release/git])
|
45
|
+
|
46
|
+
set_package_group('semver-nuxt' , 'Semantic Release for Nuxt' , %w[
|
47
|
+
semantic-release
|
48
|
+
@semantic-release/changelog
|
49
|
+
@semantic-release/git
|
50
|
+
])
|
51
|
+
|
52
|
+
set_package_group('tailwind-nuxt' , 'TailwindCSS for Nuxt' , %w[
|
53
|
+
tailwindcss@latest
|
54
|
+
postcss@latest
|
55
|
+
autoprefixer@latest
|
56
|
+
])
|
57
|
+
|
58
|
+
# this does not work yet
|
59
|
+
set_package_group('storybook-nuxt' , 'Storybook for (Vite/Nuxt)' , %w[
|
60
|
+
@storybook/vue3@6.4.18
|
61
|
+
@storybook/addon-postcss@2.0.0
|
62
|
+
@storybook/addon-storysource@6.4.18
|
63
|
+
storybook-builder-vite
|
64
|
+
])
|
65
|
+
|
66
|
+
# Currently these two need to be foreced
|
67
|
+
# @storybook/addon-docs@6.4.18
|
68
|
+
# @storybook/addon-essentials@6.4.18
|
45
69
|
end
|
46
70
|
|
47
71
|
def debug
|
@@ -10,14 +10,21 @@ module KDirector
|
|
10
10
|
|
11
11
|
def github(**opts, &block)
|
12
12
|
github = KDirector::Dsls::Children::Github.new(self, **opts)
|
13
|
-
github.instance_eval(&block)
|
13
|
+
github.instance_eval(&block) if block_given?
|
14
|
+
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def package_json(**opts, &block)
|
19
|
+
package_json = KDirector::Dsls::Children::PackageJson.new(self, **opts)
|
20
|
+
package_json.instance_eval(&block) if block_given?
|
14
21
|
|
15
22
|
self
|
16
23
|
end
|
17
24
|
|
18
25
|
def blueprint(**opts, &block)
|
19
26
|
blueprint = KDirector::Dsls::Children::Blueprint.new(self, **opts)
|
20
|
-
blueprint.instance_eval(&block)
|
27
|
+
blueprint.instance_eval(&block) if block_given?
|
21
28
|
|
22
29
|
self
|
23
30
|
end
|
@@ -15,6 +15,13 @@ module KDirector
|
|
15
15
|
self
|
16
16
|
end
|
17
17
|
|
18
|
+
def package_json(**opts, &block)
|
19
|
+
package_json = KDirector::Dsls::Children::PackageJson.new(self, **opts)
|
20
|
+
package_json.instance_eval(&block) if block_given?
|
21
|
+
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
18
25
|
def blueprint(**opts, &block)
|
19
26
|
blueprint = KDirector::Dsls::Children::Blueprint.new(self, **opts)
|
20
27
|
blueprint.instance_eval(&block) if block_given?
|
data/lib/k_director/version.rb
CHANGED
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "k_director",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.10.2",
|
4
4
|
"lockfileVersion": 2,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "k_director",
|
9
|
-
"version": "0.
|
9
|
+
"version": "0.10.2",
|
10
10
|
"devDependencies": {
|
11
11
|
"@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
|
12
12
|
"@semantic-release/changelog": "^6.0.1",
|
data/package.json
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: k_director
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: k_config
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- ".releaserc.json"
|
101
101
|
- ".rspec"
|
102
102
|
- ".rubocop.yml"
|
103
|
+
- ".vscode/settings.json"
|
103
104
|
- Gemfile
|
104
105
|
- Guardfile
|
105
106
|
- README.md
|