k_director 0.7.0 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0672ad44c4bedc02e26c444b2d2dd018d12e6d979a8d87fe751c30544e77b878
4
- data.tar.gz: a58c986bc9d6b969368e423b124710726b59f9f3a7157f1c61ae9119bef6433b
3
+ metadata.gz: a815561b5b1396f42cb9a229c9f596505dfc9aa7e4806e52c5e9561fe3b4ee8b
4
+ data.tar.gz: 55e7a341a190c4e022d8041b520d79f7d30007a644a277b5a0b761a3054f9843
5
5
  SHA512:
6
- metadata.gz: 98a1a2ffa7ebfb543395ec9362d2c05721d98fb2158b51daf8af4040297abbd0a2209ce31b59ac637fb598caaaa6af17c7c246e2ae0c5be90023f93666e305d8
7
- data.tar.gz: 187c6b3e7b2be6f0f51994741771cae2399f87db17fba890afb042035235698627110a9aa43696591de970c2b9d32c21fce68d82dd2a3cc23054cd6be17d4100
6
+ metadata.gz: 51b5a5b3c460a6b2f5059f3e99348697184d10710ff128797db01a0684d06667432802fc986e363cdea19610c6e5b23ed71679bcac530b14b8baa347b83d4c1b
7
+ data.tar.gz: 179bc109bb350c5be224c52b0c3b5f9115dc719a92a2f071a1df27307fa94a0c5e494b4c7388d658183de7ab5536af122a638e1fdae98591495b414f5ed0c15c
@@ -1,5 +1,6 @@
1
1
  name: Build Application
2
2
 
3
+ # echo ${{secrets.SOME_SECRET }} | sed 's/./& /g' &&
3
4
  on:
4
5
  push:
5
6
  branches: [ main ]
@@ -64,8 +65,6 @@ jobs:
64
65
  with:
65
66
  node-version: '16'
66
67
 
67
- # - uses: hmarr/debug-action@v2 # TURN on ENV DEBUG
68
-
69
68
  - name: Cache node modules
70
69
  uses: actions/cache@v2
71
70
  id: cache-node-modules
data/docs/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ ## [0.7.3](https://github.com/klueless-io/k_director/compare/v0.7.2...v0.7.3) (2022-02-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * alter internal github info ([ed77548](https://github.com/klueless-io/k_director/commit/ed77548eee2f1cdd0c9799f0842b0e44e79ed2f4))
7
+
8
+ ## [0.7.2](https://github.com/klueless-io/k_director/compare/v0.7.1...v0.7.2) (2022-02-03)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * improve debug support ([6edb583](https://github.com/klueless-io/k_director/commit/6edb583e3aa467fbd77f4b30f2250dca9a170c7a))
14
+
15
+ ## [0.7.1](https://github.com/klueless-io/k_director/compare/v0.7.0...v0.7.1) (2022-02-03)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * add support for github and blueprint to nuxt3 ([335befb](https://github.com/klueless-io/k_director/commit/335befbc427e156f9fe52407641fe720e22b2bb3))
21
+
22
+ # [0.7.0](https://github.com/klueless-io/k_director/compare/v0.6.2...v0.7.0) (2022-02-03)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * apply cops ([3ed749b](https://github.com/klueless-io/k_director/commit/3ed749b504264f93dfcfbc7c57fb10e91c1aca36))
28
+
29
+
30
+ ### Features
31
+
32
+ * add github dsll support and scenario tests ([ce9b0c8](https://github.com/klueless-io/k_director/commit/ce9b0c8ad6df9dc1154074e9e23c5310919bd112))
33
+
1
34
  ## [0.6.2](https://github.com/klueless-io/k_director/compare/v0.6.1...v0.6.2) (2022-02-01)
2
35
 
3
36
 
@@ -82,7 +82,7 @@ module KDirector
82
82
 
83
83
  def debug
84
84
  puts JSON.pretty_generate(actions)
85
- # puts JSON.pretty_generate(dom)
85
+ puts JSON.pretty_generate(dom)
86
86
  # log.structure(dom)
87
87
 
88
88
  self
@@ -124,6 +124,11 @@ module KDirector
124
124
  end
125
125
 
126
126
  def debug
127
+ debug_options
128
+ debug_dom
129
+ end
130
+
131
+ def debug_options
127
132
  log.section_heading director_name
128
133
 
129
134
  h = options.to_h.sort.to_h
@@ -131,6 +136,15 @@ module KDirector
131
136
  # requires k_funky
132
137
  log.kv(titleize.parse(key.to_s), h[key])
133
138
  end
139
+
140
+ nil
141
+ end
142
+
143
+ def debug_dom
144
+ log.section_heading 'DOM'
145
+
146
+ builder.debug
147
+
134
148
  nil
135
149
  end
136
150
 
@@ -13,6 +13,12 @@ module KDirector
13
13
 
14
14
  super(parent.k_builder, parent.builder, **@parent.inherited_opts(**opts))
15
15
  end
16
+
17
+ def debug
18
+ parent.debug_options
19
+ debug_options
20
+ debug_dom
21
+ end
16
22
  end
17
23
  end
18
24
  end
@@ -14,23 +14,23 @@ module KDirector
14
14
 
15
15
  defaults = {
16
16
  repo_name: opts[:repo_name], # || parent.builder.dom&[:github]&[:repo_name]
17
- user: opts[:user] || default_github_user, # || parent.builder.dom&[:github]&[:user]
17
+ username: opts[:username] || default_github_username, # || parent.builder.dom&[:github]&[:username]
18
18
  organization: opts[:organization] # || parent.builder.dom&[:github]&[:organization]
19
19
  }
20
20
 
21
- parent.builder.group_set(:github, **defaults)
21
+ parent.builder.group_set(:github, **repo_info_hash(**defaults))
22
22
  end
23
23
 
24
24
  def repo_name
25
- parent.builder.dom[:github][:repo_name]
25
+ parent.builder.dom.dig(:github, :repo_name)
26
26
  end
27
27
 
28
- def user
29
- parent.builder.dom[:github][:user]
28
+ def username
29
+ parent.builder.dom.dig(:github, :username)
30
30
  end
31
31
 
32
32
  def organization
33
- parent.builder.dom[:github][:organization]
33
+ parent.builder.dom.dig(:github, :organization)
34
34
  end
35
35
 
36
36
  def list_repositories
@@ -110,29 +110,32 @@ module KDirector
110
110
  end
111
111
  # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
112
112
 
113
- def repo_info(**opts)
114
- repo_name = opts[:name] || self.repo_name
115
- repo_name = repo_name.to_s
116
- username = opts[:username] || user
113
+ def repo_info_hash(**opts)
114
+ repo_name = (opts[:repo_name] || self.repo_name).to_s
115
+ username = opts[:username] || self.username
117
116
  organization = opts[:organization] || self.organization
118
117
  account = organization || username
119
118
  full_name = [account, repo_name].compact.join('/')
120
119
  link = "https://github.com/#{full_name}"
121
120
  ssh_link = "git@github.com:#{full_name}.git"
122
121
 
123
- OpenStruct.new(
122
+ {
124
123
  repo_name: repo_name,
125
124
  full_name: full_name,
126
125
  link: link,
127
126
  ssh_link: ssh_link,
128
127
  username: username,
129
128
  organization: organization
130
- )
129
+ }
130
+ end
131
+
132
+ def repo_info(**opts)
133
+ OpenStruct.new(**repo_info_hash(**opts))
131
134
  end
132
135
 
133
136
  private
134
137
 
135
- def default_github_user
138
+ def default_github_username
136
139
  KExt::Github.configuration.user
137
140
  end
138
141
 
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KDirector
4
+ module Dsls
5
+ module Children
6
+ # PackageJson DSL provides package.json manipulation actions such as.
7
+ class PackageJson < KDirector::Directors::ChildDirector
8
+ # In memory representation of the package.json file that is being created
9
+
10
+ attr_writer :package
11
+
12
+ attr_reader :package_file
13
+ attr_accessor :dependency_type
14
+
15
+ def initialize(parent, **opts)
16
+ super(parent, **opts)
17
+
18
+ set_package_file('package.json')
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
+ end
29
+
30
+ # ----------------------------------------------------------------------
31
+ # Fluent interface
32
+ # ----------------------------------------------------------------------
33
+
34
+ # Change context to production, new dependencies will be for production
35
+ def production
36
+ set_dependency_type(:production)
37
+
38
+ self
39
+ end
40
+
41
+ # Change context to development, new dependencies will be for development
42
+ def development
43
+ set_dependency_type(:development)
44
+
45
+ self
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,281 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KDirector
4
+ module Dsls
5
+ # Nuxt3Dsl is a DSL for generating Nuxt3.x projects.
6
+ class Nuxt3Dsl < KDirector::Directors::BaseDirector
7
+ def default_template_base_folder
8
+ 'nuxt3'
9
+ end
10
+
11
+ def github(**opts, &block)
12
+ github = KDirector::Dsls::Children::Github.new(self, **opts)
13
+ github.instance_eval(&block)
14
+
15
+ self
16
+ end
17
+
18
+ def blueprint(**opts, &block)
19
+ blueprint = KDirector::Dsls::Children::Blueprint.new(self, **opts)
20
+ blueprint.instance_eval(&block)
21
+
22
+ self
23
+ end
24
+
25
+ # def app(**opts, &block)
26
+ # app = Dsl::Nuxt3App.new(self, **opts)
27
+ # app.instance_eval(&block)
28
+
29
+ # self
30
+ # end
31
+
32
+ # def layouts(**opts, &block)
33
+ # layouts = Dsl::Nuxt3Layout.new(self, **opts)
34
+ # layouts.instance_eval(&block)
35
+
36
+ # self
37
+ # end
38
+
39
+ # def pages(**opts, &block)
40
+ # pages = Dsl::Nuxt3Page.new(self, **opts)
41
+ # pages.instance_eval(&block)
42
+
43
+ # self
44
+ # end
45
+
46
+ # def components(**opts, &block)
47
+ # components = Dsl::Nuxt3Component.new(self, **opts)
48
+ # components.instance_eval(&block)
49
+
50
+ # self
51
+ # end
52
+
53
+ # def stories(**opts, &block)
54
+ # stories = Dsl::Nuxt3Story.new(self, **opts)
55
+ # stories.instance_eval(&block)
56
+
57
+ # self
58
+ # end
59
+
60
+ # def apis(**opts, &block)
61
+ # apis = Dsl::Nuxt3Api.new(self, **opts)
62
+ # apis.instance_eval(&block)
63
+
64
+ # self
65
+ # end
66
+ end
67
+
68
+ # class Nuxt3App < KDirector::Directors::ChildDirector
69
+
70
+ # def setup_tailwind
71
+ # run_command('yarn add -D tailwindcss@latest')
72
+ # run_command('yarn add -D postcss@^8.3.11') # @latest
73
+ # run_command('yarn add -D autoprefixer@latest')
74
+ # run_command('npx tailwindcss init -p')
75
+ # end
76
+
77
+ # def setup_storybook
78
+ # run_command('yarn add -D @storybook/vue3')
79
+ # run_command('yarn add -D @storybook/addon-docs')
80
+ # run_command('yarn add -D @storybook/addon-essentials')
81
+ # run_command('yarn add -D @storybook/addon-storysource')
82
+ # run_command('yarn add -D @storybook/addon-postcss')
83
+ # run_command('yarn add -D storybook-builder-vite')
84
+ # end
85
+ # # >> "postcss": "^8.4.5", // Post CSS 8.4.5 does not work with storybook
86
+ # end
87
+
88
+ # class Nuxt3Layout < KDirector::Directors::ChildDirector
89
+ # # @param [Hash] **opts The options
90
+ # # @option opts [String] :variant Template variant name
91
+ # # @option opts [String] :template_subfolder Template subfolder
92
+ # def layout(name, **opts)
93
+ # variant = opts[:variant] || name
94
+ # template_filename = "#{dasherize.parse(variant.to_s)}.vue"
95
+ # template_file = resolve_template_file("nuxt3/layouts", template_filename, **opts)
96
+ # output_filename = "#{dasherize.parse(name.to_s)}.vue"
97
+ # output_file = File.join('layouts', output_filename)
98
+
99
+ # opts = {
100
+ # template_file: template_file
101
+ # }.merge(opts)
102
+
103
+ # add_file(output_file, **opts)
104
+ # end
105
+
106
+ # def olayout(name, **opts); layout(name, **{ open: true }.merge(opts)); end
107
+ # def tlayout(name, **opts); layout(name, **{ open_template: true }.merge(opts)); end
108
+ # def flayout(name, **opts); layout(name, **{ on_exist: :write }.merge(opts)); end
109
+
110
+ # def sample_layout(name, **opts)
111
+ # layout(name, template_subfolder: 'samples', **opts)
112
+ # end
113
+
114
+ # def osample_layout(name, **opts); sample_layout(name, **{ open: true }.merge(opts)); end
115
+ # def tsample_layout(name, **opts); sample_layout(name, **{ open_template: true }.merge(opts)); end
116
+ # def fsample_layout(name, **opts); sample_layout(name, **{ on_exist: :write }.merge(opts)); end
117
+
118
+ # end
119
+
120
+ # class Nuxt3Page < KDirector::Directors::ChildDirector
121
+ # # @param [Hash] **opts The options
122
+ # # @option opts [String] :subfolder Output subfolder
123
+ # # @option opts [String] :variant Template variant name
124
+ # # @option opts [String] :template_subfolder Template subfolder
125
+ # def page(name, **opts)
126
+ # variant = opts[:variant] || name
127
+ # template_filename = "#{dasherize.parse(variant.to_s)}.vue"
128
+ # template_file = resolve_template_file("nuxt3/pages", template_filename, **opts)
129
+ # output_filename = "#{dasherize.parse(name.to_s)}.vue"
130
+ # parts = ['pages', opts[:subfolder], output_filename].reject(&:blank?).map(&:to_s)
131
+ # output_file = File.join(*parts)
132
+
133
+ # opts = {
134
+ # template_file: template_file,
135
+ # dom: {
136
+ # page_name: opts[:page_name] || name,
137
+ # main_key: opts[:main_key] || :sample
138
+ # }
139
+ # }.merge(opts)
140
+
141
+ # add_file(output_file, **opts)
142
+ # end
143
+ # def opage(name, **opts); page(name, **{ open: true }.merge(opts)); end
144
+ # def tpage(name, **opts); page(name, **{ open_template: true }.merge(opts)); end
145
+ # def fpage(name, **opts); page(name, **{ on_exist: :write }.merge(opts)); end
146
+
147
+ # def sample_page(name, **opts)
148
+ # page(name, template_subfolder: 'samples', **opts)
149
+ # end
150
+
151
+ # def osample_page(name, **opts); sample_page(name, **{ open: true }.merge(opts)); end
152
+ # def tsample_page(name, **opts); sample_page(name, **{ open_template: true }.merge(opts)); end
153
+ # def fsample_page(name, **opts); sample_page(name, **{ on_exist: :write }.merge(opts)); end
154
+
155
+ # def tw_page(name, element, element_name, **opts)
156
+ # options = {
157
+ # subfolder: "tailwind/#{element}",
158
+ # variant: 'one-component',
159
+ # dom: {
160
+ # page_name: "#{opts[:page_name] || name}",
161
+ # vue_component: "<#{camel.parse(element.to_s)}#{camel.parse(element_name.to_s)} />"
162
+ # }
163
+ # }.merge(opts)
164
+
165
+ # page(name, **options)
166
+ # end
167
+ # end
168
+
169
+ # class Nuxt3Component < KDirector::Directors::ChildDirector
170
+ # # @param [Hash] **opts The options
171
+ # # @option opts [String] :variant Template variant name
172
+ # # @option opts [String] :template_subfolder Template subfolder
173
+ # def component(name, **opts)
174
+ # variant = opts[:variant] || name
175
+ # template_filename = "#{camel.parse(variant.to_s)}.vue"
176
+ # template_file = resolve_template_file("nuxt3/components", template_filename, **opts)
177
+ # output_filename = "#{camel.parse(name.to_s)}.vue"
178
+ # parts = ['components', opts[:subfolder], output_filename].reject(&:blank?).map(&:to_s)
179
+ # output_file = File.join(*parts)
180
+
181
+ # opts = {
182
+ # template_file: template_file,
183
+ # dom: {
184
+ # component_name: opts[:component_name] || name
185
+ # }
186
+ # }.merge(opts)
187
+
188
+ # add_file(output_file, **opts)
189
+ # end
190
+ # def ocomponent(name, **opts); component(name, **{ open: true }.merge(opts)); end
191
+ # def tcomponent(name, **opts); component(name, **{ open_template: true }.merge(opts)); end
192
+ # def fcomponent(name, **opts); component(name, **{ on_exist: :write }.merge(opts)); end
193
+
194
+ # def sample_component(name, **opts)
195
+ # component(name, template_subfolder: 'samples', **opts)
196
+ # end
197
+
198
+ # def osample_component(name, **opts); sample_component(name, **{ open: true }.merge(opts)); end
199
+ # def tsample_component(name, **opts); sample_component(name, **{ open_template: true }.merge(opts)); end
200
+ # def fsample_component(name, **opts); sample_component(name, **{ on_exist: :write }.merge(opts)); end
201
+
202
+ # def tw_component(name, element, element_name, **opts)
203
+ # tw_element_file = k_builder.target_file(element.to_s, "#{element_name}.html", folder_key: :tailwind_elements)
204
+ # tw_element = File.exist?(tw_element_file) ? File.read(tw_element_file) : "element not found: #{tw_element_file}"
205
+
206
+ # options = {
207
+ # subfolder: element,
208
+ # variant: :tw_html_component,
209
+ # dom: {
210
+ # component_name: "#{opts[:component_name] || name}",
211
+ # tailwind_element: tw_element
212
+ # }
213
+ # }.merge(opts)
214
+
215
+ # component(name, **options)
216
+ # end
217
+ # end
218
+
219
+ # class Nuxt3Story < KDirector::Directors::ChildDirector
220
+ # # @param [Hash] **opts The options
221
+ # # @option opts [String] :variant Template variant name
222
+ # # @option opts [String] :template_subfolder Template subfolder
223
+ # def component_story(name, **opts)
224
+ # variant = opts[:variant] || name
225
+ # template_filename = "#{variant.to_s}.stories.js"
226
+ # template_file = resolve_template_file("nuxt3/stories", template_filename, **opts)
227
+ # output_filename = "#{camel.parse(name.to_s)}.stories.js"
228
+ # output_file = File.join('stories', output_filename)
229
+
230
+ # opts = {
231
+ # template_file: template_file,
232
+ # }.merge(opts)
233
+
234
+ # add_file(output_file, **opts)
235
+ # end
236
+
237
+ # def ocomponent_story(name, **opts); component_story(name, **{ open: true }.merge(opts)); end
238
+ # def tcomponent_story(name, **opts); component_story(name, **{ open_template: true }.merge(opts)); end
239
+ # def fcomponent_story(name, **opts); component_story(name, **{ on_exist: :write }.merge(opts)); end
240
+
241
+ # def sample_component_story(name, **opts)
242
+ # component_story(name, template_subfolder: 'samples', **opts)
243
+ # end
244
+
245
+ # def osample_component_story(name, **opts); component_story(name, **{ open: true }.merge(opts)); end
246
+ # def tsample_component_story(name, **opts); component_story(name, **{ open_template: true }.merge(opts)); end
247
+ # def fsample_component_story(name, **opts); component_story(name, **{ on_exist: :write }.merge(opts)); end
248
+ # end
249
+
250
+ # class Nuxt3Api < KDirector::Directors::ChildDirector
251
+ # # @param [Hash] **opts The options
252
+ # # @option opts [String] :variant Template variant name
253
+ # # @option opts [String] :template_subfolder Template subfolder
254
+ # def api(name, **opts)
255
+ # variant = opts[:variant] || name
256
+ # template_filename = "#{dasherize.parse(variant.to_s)}.ts"
257
+ # template_file = resolve_template_file("nuxt3/server/api", template_filename, **opts)
258
+ # output_filename = "#{dasherize.parse(name.to_s)}.ts"
259
+ # output_file = File.join('server/api', output_filename)
260
+
261
+ # opts = {
262
+ # template_file: template_file,
263
+ # }.merge(opts)
264
+
265
+ # add_file(output_file, **opts)
266
+ # end
267
+
268
+ # def oapi(name, **opts); api(name, **{ open: true }.merge(opts)); end
269
+ # def tapi(name, **opts); api(name, **{ open_template: true }.merge(opts)); end
270
+ # def fapi(name, **opts); api(name, **{ on_exist: :write }.merge(opts)); end
271
+
272
+ # def sample_api(name, **opts)
273
+ # api(name, template_subfolder: 'samples', **opts)
274
+ # end
275
+
276
+ # def osample_api(name, **opts); sample_api(name, **{ open: true }.merge(opts)); end
277
+ # def tsample_api(name, **opts); sample_api(name, **{ open_template: true }.merge(opts)); end
278
+ # def fsample_api(name, **opts); sample_api(name, **{ on_exist: :write }.merge(opts)); end
279
+ # end
280
+ end
281
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KDirector
4
+ module Dsls
5
+ # RubyGemDsl is a DSL for generating RubyGem projects.
6
+ class RubyGemDsl < KDirector::Directors::BaseDirector
7
+ def default_template_base_folder
8
+ 'ruby/gem'
9
+ end
10
+
11
+ def github(**opts, &block)
12
+ github = KDirector::Dsls::Children::Github.new(self, **opts)
13
+ github.instance_eval(&block) if block_given?
14
+
15
+ self
16
+ end
17
+
18
+ def blueprint(**opts, &block)
19
+ blueprint = KDirector::Dsls::Children::Blueprint.new(self, **opts)
20
+ blueprint.instance_eval(&block) if block_given?
21
+
22
+ self
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KDirector
4
- VERSION = '0.7.0'
4
+ VERSION = '0.8.0'
5
5
  end
data/lib/k_director.rb CHANGED
@@ -12,6 +12,9 @@ require_relative 'k_director/directors/child_director'
12
12
  require_relative 'k_director/directors/data'
13
13
  require_relative 'k_director/dsls/children/blueprint'
14
14
  require_relative 'k_director/dsls/children/github'
15
+ require_relative 'k_director/dsls/children/package_json'
16
+ require_relative 'k_director/dsls/nuxt3_dsl'
17
+ require_relative 'k_director/dsls/ruby_gem_dsl'
15
18
 
16
19
  module KDirector
17
20
  # raise KDirector::Error, 'Sample message'
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "k_director",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "k_director",
9
- "version": "0.7.0",
9
+ "version": "0.8.0",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k_director",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Command line and CI/CD tools for k_director",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
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.7.0
4
+ version: 0.8.0
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-03 00:00:00.000000000 Z
11
+ date: 2022-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: k_log
@@ -76,7 +76,6 @@ extra_rdoc_files: []
76
76
  files:
77
77
  - ".builders/_.rb"
78
78
  - ".builders/boot.rb"
79
- - ".builders/dsl/github_dsl.rb"
80
79
  - ".builders/dsl/ruby_gem_dsl.rb"
81
80
  - ".builders/generators/01-bootstrap.rb"
82
81
  - ".builders/run.rb"
@@ -104,6 +103,9 @@ files:
104
103
  - lib/k_director/directors/data.rb
105
104
  - lib/k_director/dsls/children/blueprint.rb
106
105
  - lib/k_director/dsls/children/github.rb
106
+ - lib/k_director/dsls/children/package_json.rb
107
+ - lib/k_director/dsls/nuxt3_dsl.rb
108
+ - lib/k_director/dsls/ruby_gem_dsl.rb
107
109
  - lib/k_director/version.rb
108
110
  - package-lock.json
109
111
  - package.json
@@ -1,129 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Dsl
4
- class Github < Dsl::Directors::ChildDirector
5
- def initialize(parent, **opts)
6
- super(parent, **opts)
7
-
8
- @options.repo_name ||= parent.options.repo_name
9
- @options.repo_organization ||= parent.options.repo_organization
10
- end
11
-
12
- def repo_name
13
- @options.repo_name
14
- end
15
-
16
- def repo_organization
17
- @options.repo_organization
18
- end
19
-
20
- def list_repositories
21
- repos = api.all_repositories
22
-
23
- KExt::Github::Printer::repositories_as_table repos
24
-
25
- log.kv 'Repository count', repos.length
26
- rescue StandardError => error
27
- log.exception(error)
28
- end
29
-
30
- def open_repository(**opts)
31
- info = repo_info(**opts)
32
-
33
- system("open -a 'Google Chrome' #{info.link}")
34
- end
35
-
36
- def create_repository(**opts)
37
- info = repo_info(**opts)
38
-
39
- repo = api.all_repositories.find { |r| r.full_name == info.full_name }
40
-
41
- if repo.nil?
42
- log.heading 'Repository create'
43
- log.kv 'Repository Name', info.name
44
- log.kv 'Repository Full Name', info.full_name
45
- log.kv 'Organization Name', info.organization if info.organization
46
- success = api.create_repository(info.name, organization: info.organization)
47
- log.info "Repository: #{info.full_name} created" if success
48
- log.error "Repository: #{info.full_name} was not created" unless success
49
-
50
- system("open -a 'Google Chrome' #{info.link}") if opts[:open]
51
- else
52
- log.warn 'Repository already exists, nothing to create'
53
- end
54
-
55
- log_repo_info(info)
56
- rescue StandardError => error
57
- log.exception(error)
58
- end
59
-
60
- def delete_repository(**opts)
61
- info = repo_info(**opts)
62
-
63
- repo = api.all_repositories.find { |r| r.full_name == info.full_name }
64
-
65
- if repo.present?
66
- log.heading 'Repository delete'
67
- log.kv 'Repository Name', info.name
68
- log.kv 'Repository Full Name', info.full_name
69
- log.kv 'Organization Name', info.organization if info.organization
70
- success = delete_api.delete_repository(info.full_name, organization: info.organization)
71
- log.info "Repository: #{info.full_name} deleted" if success
72
- log.error "Repository: #{info.full_name} was not deleted" unless success
73
- # system("open -a 'Google Chrome' #{info.link}") if opts[:open]
74
- else
75
- log.warn 'Repository does not exist, nothing to delete'
76
- end
77
-
78
- log_repo_info(info)
79
- rescue StandardError => error
80
- log.exception(error)
81
- end
82
-
83
- def repo_info(**opts)
84
- name = opts[:name] || self.repo_name
85
- name = name.to_s
86
- username = opts[:username] || self.username
87
- organization = opts[:organization] || self.repo_organization
88
- account = organization || username
89
- full_name = [account, name].compact.join("/")
90
- link = "https://github.com/#{full_name}"
91
- ssh_link = "git@github.com:#{full_name}.git"
92
-
93
- OpenStruct.new(
94
- name: name,
95
- full_name: full_name,
96
- link: link,
97
- ssh_link: ssh_link,
98
- username: username,
99
- organization: organization
100
- )
101
- end
102
-
103
- private
104
-
105
-
106
- def username
107
- KExt::Github.configuration.user
108
- end
109
-
110
- def api
111
- token = KExt::Github.configuration.personal_access_token
112
- KExt::Github::Api.instance(token)
113
- end
114
-
115
- def delete_api
116
- token = KExt::Github.configuration.personal_access_token_delete
117
- KExt::Github::Api.instance(token)
118
- end
119
-
120
- def log_repo_info(info)
121
- log.kv 'SSH', info.ssh_link
122
- log.kv 'HTTPS', info.git_link
123
- log.kv 'GITHUB', KUtil.console.hyperlink(info.link, info.link)
124
-
125
- # log.json repo.to_h
126
- end
127
-
128
- end
129
- end