k_director 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18ab7fb018cc2541e5291875d29564ba3fe6b348fa79fda67b90e20d95ee4dd9
4
- data.tar.gz: d407e5cc00ebacc6515ecefde9834ef82c2c41dd708839c7577f5bea843540e3
3
+ metadata.gz: 0672ad44c4bedc02e26c444b2d2dd018d12e6d979a8d87fe751c30544e77b878
4
+ data.tar.gz: a58c986bc9d6b969368e423b124710726b59f9f3a7157f1c61ae9119bef6433b
5
5
  SHA512:
6
- metadata.gz: c8ae08868a7b6a549bb2f9196f5bda48da9a9552c236cf7ddc60473d8f9945382d15cf06b925079c7b274e381542bd35024b2810e1a3e56ff527c5e0bf68ef63
7
- data.tar.gz: 779391f8dca111e5496141cafd2c65e6680f476b1998b11c4d274b5b60a111eea6b4c55a8be8add8e84ded0ebe9a864a611d2b082eb1d0bf027d44a625803fd6
6
+ metadata.gz: 98a1a2ffa7ebfb543395ec9362d2c05721d98fb2158b51daf8af4040297abbd0a2209ce31b59ac637fb598caaaa6af17c7c246e2ae0c5be90023f93666e305d8
7
+ data.tar.gz: 187c6b3e7b2be6f0f51994741771cae2399f87db17fba890afb042035235698627110a9aa43696591de970c2b9d32c21fce68d82dd2a3cc23054cd6be17d4100
data/docs/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## [0.6.2](https://github.com/klueless-io/k_director/compare/v0.6.1...v0.6.2) (2022-02-01)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * merge main and semver gha workflows ([5c3a9e4](https://github.com/klueless-io/k_director/commit/5c3a9e4a6f01129cc513760b86453a4201835765))
7
+ * merge main and semver gha workflows - final ([0c5eb76](https://github.com/klueless-io/k_director/commit/0c5eb76d8008d5ec869fdb9c9adcc306e6a51604))
8
+ * merge main and semver gha workflows [#2](https://github.com/klueless-io/k_director/issues/2) ([f20f719](https://github.com/klueless-io/k_director/commit/f20f719f5f82d5761b9886b1d294750a761a7376))
9
+ * merge main and semver gha workflows [#2](https://github.com/klueless-io/k_director/issues/2) ([2102bca](https://github.com/klueless-io/k_director/commit/2102bca3ebe67d75e4d8d6c12cf962420371264c))
10
+ * merge main and semver gha workflows [#2](https://github.com/klueless-io/k_director/issues/2) ([9f384fd](https://github.com/klueless-io/k_director/commit/9f384fd88ab7ec39fd15b256b61c146e113f4a8d))
11
+ * merge main and semver gha workflows [#2](https://github.com/klueless-io/k_director/issues/2) ([bd4dbcd](https://github.com/klueless-io/k_director/commit/bd4dbcd842f5dee4dabc7eb9495a6f143a02d3ef))
12
+ * merge main and semver gha workflows [#2](https://github.com/klueless-io/k_director/issues/2) ([79c793d](https://github.com/klueless-io/k_director/commit/79c793d46accb10dc81a0bc0b9f8bbc451f03df7))
13
+ * merge main and semver gha workflows [#2](https://github.com/klueless-io/k_director/issues/2) ([353bc81](https://github.com/klueless-io/k_director/commit/353bc81eab7759fba7be3d12ca73293699c70146))
14
+ * merge main and semver gha workflows [#2](https://github.com/klueless-io/k_director/issues/2) ([61f4772](https://github.com/klueless-io/k_director/commit/61f4772cac5400b0085f9081a46f8fbc68471534))
15
+ * merge main and semver gha workflows [#3](https://github.com/klueless-io/k_director/issues/3) ([ee13161](https://github.com/klueless-io/k_director/commit/ee131618a66dea1a0996f4be897bcfe6b902482f))
16
+ * merge main and semver gha workflows [#3](https://github.com/klueless-io/k_director/issues/3) ([074b65c](https://github.com/klueless-io/k_director/commit/074b65cfd95d1e6fc355f8ec0d47f03ec6c9b867))
17
+ * merge main and semver gha workflows [#4](https://github.com/klueless-io/k_director/issues/4) ([8001aa5](https://github.com/klueless-io/k_director/commit/8001aa5be830197baaa5e956c6b5bd010479fd60))
18
+ * merge main and semver gha workflows [#5](https://github.com/klueless-io/k_director/issues/5) ([6ba2432](https://github.com/klueless-io/k_director/commit/6ba2432126c8c1fe5e157d470e6c8609cea174d6))
19
+ * merge main and semver gha workflows [#6](https://github.com/klueless-io/k_director/issues/6) ([62eb60e](https://github.com/klueless-io/k_director/commit/62eb60e55dbfed3aa16faf17e137b39505e2e8a8))
20
+ * merge main and semver gha workflows [#7](https://github.com/klueless-io/k_director/issues/7) ([30fba4b](https://github.com/klueless-io/k_director/commit/30fba4b7da6aced100dfd68a750e051f6ddc0da8))
21
+ * merge main and semver gha workflows [#8](https://github.com/klueless-io/k_director/issues/8) ([e6a55f7](https://github.com/klueless-io/k_director/commit/e6a55f73235a556861140358592f6b5d031dec24))
22
+
1
23
  ## [0.6.1](https://github.com/klueless-io/k_director/compare/v0.6.0...v0.6.1) (2022-01-31)
2
24
 
3
25
 
data/k_director.gemspec CHANGED
@@ -44,5 +44,6 @@ Gem::Specification.new do |spec|
44
44
  spec.add_dependency 'k_log', '~> 0.0.0'
45
45
  # spec.add_dependency 'k_type', '~> 0.0.0'
46
46
  spec.add_dependency 'k_builder', '~> 0.0.0'
47
+ spec.add_dependency 'k_ext-github', '~> 0.0.0'
47
48
  spec.add_dependency 'k_util', '~> 0.0.0'
48
49
  end
@@ -12,22 +12,146 @@ module KDirector
12
12
  def initialize(parent, **opts)
13
13
  super(parent, **opts)
14
14
 
15
- @options.repo_name ||= parent.options.repo_name
16
- @options.repo_organization ||= parent.options.repo_organization
17
- end
15
+ defaults = {
16
+ repo_name: opts[:repo_name], # || parent.builder.dom&[:github]&[:repo_name]
17
+ user: opts[:user] || default_github_user, # || parent.builder.dom&[:github]&[:user]
18
+ organization: opts[:organization] # || parent.builder.dom&[:github]&[:organization]
19
+ }
18
20
 
19
- def repo
20
- return parent.options.repo if defined? parent.options.repo
21
+ parent.builder.group_set(:github, **defaults)
22
+ end
21
23
 
22
- parent.options.repo = OpenStruct.new(name: nil, organization: nil)
24
+ def repo_name
25
+ parent.builder.dom[:github][:repo_name]
23
26
  end
24
27
 
25
- def name
26
- repo.repo_name
28
+ def user
29
+ parent.builder.dom[:github][:user]
27
30
  end
28
31
 
29
32
  def organization
30
- repo.repo_organization
33
+ parent.builder.dom[:github][:organization]
34
+ end
35
+
36
+ def list_repositories
37
+ repos = create_api.all_repositories
38
+
39
+ KExt::Github::Printer.repositories_as_table repos
40
+
41
+ log.kv 'Repository count', repos.length
42
+ rescue StandardError => e
43
+ log.exception(e)
44
+ end
45
+
46
+ def open_repository(**opts)
47
+ info = repo_info(**opts)
48
+
49
+ system("open -a 'Google Chrome' #{info.link}")
50
+ end
51
+
52
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
53
+ def create_repository(**opts)
54
+ info = repo_info(**opts)
55
+
56
+ if info.repo_name.blank?
57
+ log.error 'Repository name is required'
58
+ return
59
+ end
60
+
61
+ repo = create_api.all_repositories.find { |r| r.full_name == info.full_name }
62
+
63
+ if repo.nil?
64
+ log.heading 'Repository create'
65
+ log.kv 'Repository Name', info.repo_name
66
+ log.kv 'Repository Full Name', info.full_name
67
+ log.kv 'Organization Name', info.organization if info.organization
68
+ success = create_api.create_repository(info.repo_name, organization: info.organization)
69
+ log.info "Repository: #{info.full_name} created" if success
70
+ log.error "Repository: #{info.full_name} was not created" unless success
71
+
72
+ system("open -a 'Google Chrome' #{info.link}") if opts[:open]
73
+ else
74
+ log.warn 'Repository already exists, nothing to create'
75
+ end
76
+
77
+ log_repo_info(info)
78
+ rescue StandardError => e
79
+ log.exception(e)
80
+ end
81
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
82
+
83
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
84
+ def delete_repository(**opts)
85
+ info = repo_info(**opts)
86
+
87
+ if info.repo_name.blank?
88
+ log.error 'Repository name is required'
89
+ return
90
+ end
91
+
92
+ repo = create_api.all_repositories.find { |r| r.full_name == info.full_name }
93
+
94
+ if repo.present?
95
+ log.heading 'Repository delete'
96
+ log.kv 'Repository Name', info.repo_name
97
+ log.kv 'Repository Full Name', info.full_name
98
+ log.kv 'Organization Name', info.organization if info.organization
99
+ success = delete_api.delete_repository(info.full_name, organization: info.organization)
100
+ log.info "Repository: #{info.full_name} deleted" if success
101
+ log.error "Repository: #{info.full_name} was not deleted" unless success
102
+ # system("open -a 'Google Chrome' #{info.link}") if opts[:open]
103
+ else
104
+ log.warn 'Repository does not exist, nothing to delete'
105
+ end
106
+
107
+ log_repo_info(info)
108
+ rescue StandardError => e
109
+ log.exception(e)
110
+ end
111
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
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
117
+ organization = opts[:organization] || self.organization
118
+ account = organization || username
119
+ full_name = [account, repo_name].compact.join('/')
120
+ link = "https://github.com/#{full_name}"
121
+ ssh_link = "git@github.com:#{full_name}.git"
122
+
123
+ OpenStruct.new(
124
+ repo_name: repo_name,
125
+ full_name: full_name,
126
+ link: link,
127
+ ssh_link: ssh_link,
128
+ username: username,
129
+ organization: organization
130
+ )
131
+ end
132
+
133
+ private
134
+
135
+ def default_github_user
136
+ KExt::Github.configuration.user
137
+ end
138
+
139
+ def create_api
140
+ token = KExt::Github.configuration.personal_access_token
141
+ KExt::Github::Api.instance(token)
142
+ end
143
+
144
+ def delete_api
145
+ token = KExt::Github.configuration.personal_access_token_delete
146
+ KExt::Github::Api.instance(token)
147
+ end
148
+
149
+ def log_repo_info(info)
150
+ log.kv 'SSH', info.ssh_link
151
+ log.kv 'HTTPS', info.git_link
152
+ log.kv 'GITHUB', KUtil.console.hyperlink(info.link, info.link)
153
+
154
+ # log.json repo.to_h
31
155
  end
32
156
  end
33
157
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KDirector
4
- VERSION = '0.6.2'
4
+ VERSION = '0.7.0'
5
5
  end
data/lib/k_director.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'k_log'
4
4
  require 'k_util'
5
5
  require 'k_builder'
6
+ require 'k_ext/github'
6
7
 
7
8
  require_relative 'k_director/version'
8
9
  require_relative 'k_director/builders/actions_builder'
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "k_director",
3
- "version": "0.6.2",
3
+ "version": "0.7.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "k_director",
9
- "version": "0.6.2",
9
+ "version": "0.7.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.6.2",
3
+ "version": "0.7.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.6.2
4
+ version: 0.7.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-01 00:00:00.000000000 Z
11
+ date: 2022-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: k_log
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: k_ext-github
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.0.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: k_util
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -91,10 +105,8 @@ files:
91
105
  - lib/k_director/dsls/children/blueprint.rb
92
106
  - lib/k_director/dsls/children/github.rb
93
107
  - lib/k_director/version.rb
94
- - main-advanced.yml
95
108
  - package-lock.json
96
109
  - package.json
97
- - semver.yml
98
110
  - sig/k_director.rbs
99
111
  homepage: http://appydave.com/gems/k_director
100
112
  licenses:
data/main-advanced.yml DELETED
@@ -1,90 +0,0 @@
1
- name: Build Application
2
-
3
- on:
4
- push:
5
- branches: [ main ]
6
- pull_request:
7
- branches: [ main ]
8
-
9
- jobs:
10
- build:
11
- runs-on: ubuntu-latest
12
- name: Ruby ${{ matrix.ruby }}
13
- strategy:
14
- matrix:
15
- ruby: ['2.7.1'] #, '3.1.0']
16
-
17
- steps:
18
- - uses: actions/checkout@v2
19
- - name: Set up Ruby
20
- uses: ruby/setup-ruby@v1
21
- with:
22
- ruby-version: ${{ matrix.ruby }}
23
- bundler-cache: true
24
-
25
- - id: lint
26
- - name: Run rubocop
27
- run: bundle exec rubocop
28
-
29
- - name: Slack notification on rubocop error
30
- if: steps.lint.conclusion == 'failure'
31
- uses: rtCamp/action-slack-notify@v2
32
- env:
33
- SLACK_CHANNEL: klueless-repos
34
- SLACK_COLOR: '#ff0000'
35
- SLACK_ICON: https://avatars.githubusercontent.com/u/2956762?s=64&v=4
36
- SLACK_TITLE: 'Rubocop failure on $ - try:'
37
- SLACK_MESSAGE: 'cop -a'
38
- SLACK_USERNAME: klueless-io
39
- SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
40
-
41
- - id: rspec
42
- - name: Run tests
43
- run: bundle exec rspec
44
-
45
- - name: Slack notify on rspec error
46
- if: steps.rspec.conclusion == 'failure'
47
- uses: rtCamp/action-slack-notify@v2
48
- env:
49
- SLACK_CHANNEL: klueless-repos
50
- SLACK_COLOR: '#ff0000'
51
- SLACK_ICON: https://avatars.githubusercontent.com/u/2956762?s=64&v=4
52
- SLACK_TITLE: 'RSpec failure on ${{github.repository}} - try:'
53
- SLACK_MESSAGE: 'rspec'
54
- SLACK_USERNAME: klueless-io
55
- SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
56
-
57
- release:
58
- needs: build
59
- runs-on: ubuntu-latest
60
- steps:
61
- - uses: actions/checkout@v2
62
- - uses: actions/setup-node@v2
63
- with:
64
- node-version: '16'
65
-
66
- # - uses: hmarr/debug-action@v2 # TURN on ENV DEBUG
67
-
68
- - name: Cache node modules
69
- uses: actions/cache@v2
70
- id: cache-node-modules
71
- env:
72
- cache-name: cache-node-modules
73
- with:
74
- path: ~/.npm
75
- key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
76
- restore-keys: |
77
- ${{ runner.os }}-build-${{ env.cache-name }}-
78
- ${{ runner.os }}-build-
79
- ${{ runner.os }}-
80
-
81
- - name: Install semantic-release dependencies
82
- if: steps.cache.outputs.cache-hit != 'true'
83
- run: npm ci
84
-
85
- # SEE MORE: https://github.com/semantic-release/semantic-release/issues/753
86
- - name: Run SemVer
87
- run: npm run release
88
- env:
89
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90
- GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
data/semver.yml DELETED
@@ -1,54 +0,0 @@
1
- name: SemVer
2
- on:
3
- workflow_run:
4
- workflows: ["Build Application"]
5
- branches: [main]
6
- types:
7
- - completed
8
- jobs:
9
- release:
10
- runs-on: ubuntu-latest
11
- if: ${{ github.event.workflow_run.conclusion == 'success' }}
12
- steps:
13
- - uses: actions/checkout@v2
14
- - uses: actions/setup-node@v2
15
- with:
16
- node-version: '16'
17
-
18
- # - uses: hmarr/debug-action@v2 # TURN on ENV DEBUG
19
-
20
- - name: Cache node modules
21
- uses: actions/cache@v2
22
- id: cache-node-modules
23
- env:
24
- cache-name: cache-node-modules
25
- with:
26
- path: ~/.npm
27
- key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
28
- restore-keys: |
29
- ${{ runner.os }}-build-${{ env.cache-name }}-
30
- ${{ runner.os }}-build-
31
- ${{ runner.os }}-
32
-
33
- - name: Install semantic-release dependencies
34
- if: steps.cache.outputs.cache-hit != 'true'
35
- run: npm ci
36
-
37
- # SEE MORE: https://github.com/semantic-release/semantic-release/issues/753
38
- - name: Run SemVer
39
- run: npm run release
40
- env:
41
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42
- GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
43
-
44
- # - name: Slack notify new version created
45
- # if: success()
46
- # uses: rtCamp/action-slack-notify@v2
47
- # env:
48
- # SLACK_CHANNEL: klueless-repos
49
- # SLACK_COLOR: '#00ff00'
50
- # SLACK_ICON: https://avatars.githubusercontent.com/u/2956762?s=64&v=4
51
- # SLACK_TITLE: 'New version released on ${{github.repository}}'
52
- # SLACK_MESSAGE: 'git pull'
53
- # SLACK_USERNAME: klueless-io
54
- # SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}