k_builder-dotnet 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/main.yml +31 -0
- data/.gitignore +50 -0
- data/.rspec +3 -0
- data/.rubocop.yml +82 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +25 -0
- data/Guardfile +30 -0
- data/LICENSE.txt +21 -0
- data/README.md +101 -0
- data/Rakefile +30 -0
- data/STORIES.md +50 -0
- data/USAGE.md +40 -0
- data/bin/console +16 -0
- data/bin/k +36 -0
- data/bin/kgitsync +76 -0
- data/bin/khotfix +244 -0
- data/bin/setup +11 -0
- data/docs/builder-two-projects.png +0 -0
- data/docs/new-project1.png +0 -0
- data/docs/new-project2.png +0 -0
- data/docs/new-solution.png +0 -0
- data/hooks/pre-commit +87 -0
- data/hooks/update-version +33 -0
- data/k_builder-dotnet.gemspec +42 -0
- data/lib/k_builder/dotnet.rb +16 -0
- data/lib/k_builder/dotnet/code_block.rb +19 -0
- data/lib/k_builder/dotnet/code_snippets.rb +27 -0
- data/lib/k_builder/dotnet/dependency.rb +39 -0
- data/lib/k_builder/dotnet/namespace.rb +20 -0
- data/lib/k_builder/dotnet/readme.md +108 -0
- data/lib/k_builder/dotnet/version.rb +7 -0
- metadata +79 -0
data/STORIES.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# K Builder Dotnet
|
2
|
+
|
3
|
+
> K Builder Dotnet provides various fluent builders for building dotnet assets, specifically for c#
|
4
|
+
|
5
|
+
As a C# Developer, I want to generate dotnet code, projects and solutions quickly, so I build repeating patterns quickly
|
6
|
+
|
7
|
+
## Development radar
|
8
|
+
|
9
|
+
### Stories next on list
|
10
|
+
|
11
|
+
As a C# Developer, I want to generate dotnet code, projects and solutions quickly, so I build repeating patterns quickly
|
12
|
+
|
13
|
+
-
|
14
|
+
|
15
|
+
As a C# Developer, I can DO_SOMETHING, so that I QUALITY_OF_LIFE
|
16
|
+
|
17
|
+
- Subtask
|
18
|
+
|
19
|
+
### Tasks next on list
|
20
|
+
|
21
|
+
Setup RubyGems and RubyDoc
|
22
|
+
|
23
|
+
- Build and deploy gem to [rubygems.org](https://rubygems.org/gems/k_builder-dotnet)
|
24
|
+
- Attach documentation to [rubydoc.info](https://rubydoc.info/github/to-do-/k_builder-dotnet/master)
|
25
|
+
|
26
|
+
Setup GitHub Action (test and lint)
|
27
|
+
|
28
|
+
- Setup Rspec action
|
29
|
+
- Setup RuboCop action
|
30
|
+
|
31
|
+
## Stories and tasks
|
32
|
+
|
33
|
+
### Tasks - completed
|
34
|
+
|
35
|
+
Setup project management, requirement and SCRUM documents
|
36
|
+
|
37
|
+
- Setup readme file
|
38
|
+
- Setup user stories and tasks
|
39
|
+
- Setup a project backlog
|
40
|
+
- Setup an examples/usage document
|
41
|
+
|
42
|
+
Setup new Ruby GEM
|
43
|
+
|
44
|
+
- Build out a standard GEM structure
|
45
|
+
- Add automated semantic versioning
|
46
|
+
- Add Rspec unit testing framework
|
47
|
+
- Add RuboCop linting
|
48
|
+
- Add Guard for automatic watch and test
|
49
|
+
- Add GitFlow support
|
50
|
+
- Add GitHub Repository
|
data/USAGE.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# K Builder Dotnet
|
2
|
+
|
3
|
+
> K Builder Dotnet provides various fluent builders for building dotnet assets, specifically for c#
|
4
|
+
|
5
|
+
As a C# Developer, I want to generate dotnet code, projects and solutions quickly, so I build repeating patterns quickly
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
### Sample Classes
|
10
|
+
|
11
|
+
#### Create solution
|
12
|
+
|
13
|
+
Create a new solution that contains many projects to solve a business problem.
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
solution = builder.new_solution(:pitstop)
|
17
|
+
```
|
18
|
+
|
19
|
+
![](docs/new-solution.png)
|
20
|
+
|
21
|
+
#### Create project(s)
|
22
|
+
|
23
|
+
Create two projects attached to the solution
|
24
|
+
|
25
|
+
![Build Two Projects](docs/builder-two-projects.png)
|
26
|
+
|
27
|
+
<table>
|
28
|
+
<tr>
|
29
|
+
<td>
|
30
|
+
|
31
|
+
![New Project 1](docs/new-project1.png)
|
32
|
+
|
33
|
+
</td>
|
34
|
+
<td>
|
35
|
+
|
36
|
+
![New Project 2](docs/new-project2.png)
|
37
|
+
|
38
|
+
</td>
|
39
|
+
</tr>
|
40
|
+
</table>
|
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require 'bundler/setup'
|
6
|
+
require 'k_builder_dotnet'
|
7
|
+
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
10
|
+
|
11
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
12
|
+
# require 'pry'
|
13
|
+
# Pry.start
|
14
|
+
|
15
|
+
require 'irb'
|
16
|
+
IRB.start(__FILE__)
|
data/bin/k
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# NOTE: you may need change file permissions
|
5
|
+
# chmod +x bin/k
|
6
|
+
|
7
|
+
help = %(
|
8
|
+
----------------------------------------------------------------------
|
9
|
+
Klue Scripts - Help
|
10
|
+
----------------------------------------------------------------------
|
11
|
+
k - This Help File
|
12
|
+
|
13
|
+
khotfix - Create Hot Fix
|
14
|
+
Hot fixes are created in GIT and versioned correctly.
|
15
|
+
The patch # will increment by 1.
|
16
|
+
e.g. v0.1.1 will become v0.1.2
|
17
|
+
The version.rb file will also store the current version.
|
18
|
+
usage:
|
19
|
+
khotfix 'name of my cool hotfix'
|
20
|
+
|
21
|
+
kgitsync - Synchronize the master and development git repositories
|
22
|
+
Pulls latest code, pushes current changes
|
23
|
+
usage:
|
24
|
+
kgitsync
|
25
|
+
|
26
|
+
----------------------------------------------------------------------
|
27
|
+
Rake Tasks
|
28
|
+
----------------------------------------------------------------------
|
29
|
+
|
30
|
+
rails db:seed - load seed data
|
31
|
+
|
32
|
+
rails db:seed sample=true - load sample data, useful in developer environments
|
33
|
+
|
34
|
+
rails db:seed reset=true - reset database
|
35
|
+
)
|
36
|
+
puts help
|
data/bin/kgitsync
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
#NOTE: you may need change file permissions
|
4
|
+
# chmod +x bin/kgitsync
|
5
|
+
|
6
|
+
# Set up colour support, if we have it
|
7
|
+
# Are stdout and stderr both connected to a terminal
|
8
|
+
# If not then don't set colours
|
9
|
+
if [ -t 1 -a -t 2 ]
|
10
|
+
then
|
11
|
+
if tput -V >/dev/null 2>&1
|
12
|
+
then
|
13
|
+
C_RED=`tput setaf 1`
|
14
|
+
C_GREEN=`tput setaf 2`
|
15
|
+
C_BROWN=`tput setaf 3`
|
16
|
+
C_BLUE=`tput setaf 4`
|
17
|
+
C_RESET=`tput sgr0`
|
18
|
+
fi
|
19
|
+
fi
|
20
|
+
|
21
|
+
|
22
|
+
exit_error ()
|
23
|
+
{
|
24
|
+
# dont display if string is zero length
|
25
|
+
[ -z "$1" ] || echo "${C_RED}Error: ${C_BROWN} $1 ${C_RESET}"
|
26
|
+
exit 1
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
# make sure we are in a git tree
|
31
|
+
[ "`git rev-parse --is-inside-work-tree`" = "true" ] || exit_error "NOT a git repository"
|
32
|
+
echo "Repository check OK"
|
33
|
+
|
34
|
+
CURRENT_BRANCH=`git branch | awk '/^\*/{print $2}'`
|
35
|
+
|
36
|
+
# check that we are on develop or master
|
37
|
+
#[ "${CURRENT_BRANCH}" = "master" -o "${CURRENT_BRANCH}" = "develop" ] || exit_error "You MUST be on either the master or development branch"
|
38
|
+
#echo "Branch check OK"
|
39
|
+
|
40
|
+
# check that the current branch is clean
|
41
|
+
[ -z "`git status --porcelain`" ] || exit_error "Working copy has uncommitted changes"
|
42
|
+
echo "Working copy is clean OK"
|
43
|
+
|
44
|
+
# fetch from origin
|
45
|
+
git fetch origin || exit_error "Failed to fetch from origin"
|
46
|
+
|
47
|
+
######################
|
48
|
+
# Do develop
|
49
|
+
######################
|
50
|
+
git checkout develop || exit_error "Failed to checkout develop branch"
|
51
|
+
echo "Switched to develop"
|
52
|
+
git merge origin/develop || exit_error "Failed to merge develop from origin"
|
53
|
+
echo "Develop branch upto date"
|
54
|
+
git push || exit_error "Failed to push develop to origin"
|
55
|
+
echo "Develop pushed to origin"
|
56
|
+
|
57
|
+
######################
|
58
|
+
# Do master
|
59
|
+
######################
|
60
|
+
git checkout master || exit_error "Failed to checkout master branch"
|
61
|
+
echo "Switched to master"
|
62
|
+
git merge origin/master || exit_error "Failed to merge master from origin"
|
63
|
+
echo "Master branch upto date"
|
64
|
+
git push || exit_error "Failed to push master to origin"
|
65
|
+
echo "Master pushed to origin"
|
66
|
+
|
67
|
+
######################
|
68
|
+
# Do tags
|
69
|
+
######################
|
70
|
+
git push --tags || exit_error "Failed to push tags to origin"
|
71
|
+
echo "Tags pushed to origin"
|
72
|
+
|
73
|
+
# return to the current branch
|
74
|
+
git checkout ${CURRENT_BRANCH} || exit_error "Failed to return to your origional branch ${CURRENT_BRANCH}"
|
75
|
+
|
76
|
+
echo "${C_GREEN}Done. you are on ${CURRENT_BRANCH}${C_RESET}"
|
data/bin/khotfix
ADDED
@@ -0,0 +1,244 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
#NOTE: you may need change file permissions
|
4
|
+
# chmod +x bin/khotfix
|
5
|
+
|
6
|
+
# Create a Versioned HotFix in Git and update the VERSION #
|
7
|
+
# USAGE
|
8
|
+
#
|
9
|
+
# ./bin/khotfix.sh 'my brand new hot fix'
|
10
|
+
|
11
|
+
# HELPERS
|
12
|
+
clear
|
13
|
+
|
14
|
+
l_heading ()
|
15
|
+
{
|
16
|
+
heading=$1
|
17
|
+
|
18
|
+
echo "======================================================================"
|
19
|
+
echo "${heading}"
|
20
|
+
echo "======================================================================"
|
21
|
+
}
|
22
|
+
|
23
|
+
l_line ()
|
24
|
+
{
|
25
|
+
echo "----------------------------------------------------------------------"
|
26
|
+
}
|
27
|
+
|
28
|
+
l_title ()
|
29
|
+
{
|
30
|
+
title=$1
|
31
|
+
|
32
|
+
l_line
|
33
|
+
echo "${title}"
|
34
|
+
l_line
|
35
|
+
}
|
36
|
+
|
37
|
+
l ()
|
38
|
+
{
|
39
|
+
title=$1
|
40
|
+
|
41
|
+
echo "${title}"
|
42
|
+
}
|
43
|
+
|
44
|
+
lkv ()
|
45
|
+
{
|
46
|
+
title=$1
|
47
|
+
value=$2
|
48
|
+
|
49
|
+
printf "%-25s : %s\n" "$title" "$value"
|
50
|
+
}
|
51
|
+
|
52
|
+
|
53
|
+
# expect 1 argument
|
54
|
+
MESSAGE=$1
|
55
|
+
|
56
|
+
l_heading "Make Hotfix - '${MESSAGE}'"
|
57
|
+
|
58
|
+
|
59
|
+
# This environment var will prevent git from asking for merge messages
|
60
|
+
export GIT_MERGE_AUTOEDIT=no
|
61
|
+
|
62
|
+
# Set up colour support, if we have it
|
63
|
+
# Are stdout and stderr both connected to a terminal, If not then don't set colours
|
64
|
+
if [ -t 1 -a -t 2 ]
|
65
|
+
then
|
66
|
+
if tput -V >/dev/null 2>&1
|
67
|
+
then
|
68
|
+
C_RED=`tput setaf 1`
|
69
|
+
C_GREEN=`tput setaf 2`
|
70
|
+
C_BROWN=`tput setaf 3`
|
71
|
+
C_BLUE=`tput setaf 4`
|
72
|
+
C_RESET=`tput sgr0`
|
73
|
+
fi
|
74
|
+
fi
|
75
|
+
|
76
|
+
|
77
|
+
exit_error ()
|
78
|
+
{
|
79
|
+
# dont display if string is zero length
|
80
|
+
[ -z "$1" ] || echo "${C_RED}Error: ${C_BROWN} $1 ${C_RESET}"
|
81
|
+
exit 1
|
82
|
+
}
|
83
|
+
|
84
|
+
|
85
|
+
# check arguments
|
86
|
+
[ ! -z "${MESSAGE}" ] || exit_error "You must pass a message when making a hotfix"
|
87
|
+
|
88
|
+
# make sure we are in a git tree
|
89
|
+
[ "`git rev-parse --is-inside-work-tree`" = "true" ] || exit_error "NOT a git repository"
|
90
|
+
l "Repository check OK"
|
91
|
+
|
92
|
+
CURRENT_BRANCH=`git branch | awk '/^\*/{print $2}'`
|
93
|
+
|
94
|
+
lkv "CURRENT_BRANCH" "${CURRENT_BRANCH}"
|
95
|
+
|
96
|
+
# check that we are on develop or master
|
97
|
+
[ "${CURRENT_BRANCH}" = "master" -o "${CURRENT_BRANCH}" = "develop" ] || exit_error "You MUST be on either the master or development branch"
|
98
|
+
l "OK: Branch"
|
99
|
+
|
100
|
+
# check that the current branch is NOT clean (we need changes to make a hotfix)
|
101
|
+
[ ! -z "`git status --porcelain`" ] || exit_error "Working copy is clean - no hotfix"
|
102
|
+
l "OK: Working copy has hotfix ready"
|
103
|
+
|
104
|
+
# fetch from origin
|
105
|
+
git fetch origin || exit_error "Failed to fetch from origin"
|
106
|
+
l "OK: Fsetch from origin"
|
107
|
+
|
108
|
+
# get the current directory that this script is in.
|
109
|
+
# we assume that the other scripts are in the same directory
|
110
|
+
SYNC_SCRIPT=kgitsync
|
111
|
+
SCRIPT_DIR=`dirname $0`
|
112
|
+
|
113
|
+
# ----------------------------------------------------------------------
|
114
|
+
# GET VERSION NUMBER
|
115
|
+
# ----------------------------------------------------------------------
|
116
|
+
|
117
|
+
l_title 'GET VERSION NUMBER'
|
118
|
+
|
119
|
+
# Get the last tag version
|
120
|
+
VERSION=`git tag | sort -V | tail -1`
|
121
|
+
lkv "CURENT VERSION" "${VERSION}"
|
122
|
+
|
123
|
+
# NOTE, if you don't have a TAG then you might need to manually do
|
124
|
+
# git flow hotfix start v0.01.001
|
125
|
+
# git flow hotfix finish v0.01.001
|
126
|
+
|
127
|
+
# Verify its format
|
128
|
+
[[ "`git tag | sort -V | tail -1`" =~ ^v[0-9]{1,2}.[0-9]{1,2}.[0-9]{1,3}$ ]] || exit_error "Bad version format, version=${VERSION}"
|
129
|
+
# extract the version components
|
130
|
+
IFS=. read MAJOR_VERSION MINOR_VERSION PATCH_VERSION <<< "${VERSION}"
|
131
|
+
|
132
|
+
# inc the patch version. note: force base 10 as leading 0 makes bash think this is octal
|
133
|
+
PATCH_VERSION=$((10#${PATCH_VERSION} + 1))
|
134
|
+
lkv 'Patch #' "${PATCH_VERSION}"
|
135
|
+
|
136
|
+
# assemble the new version
|
137
|
+
NEW_VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}"
|
138
|
+
lkv "NEW VERSION" "${NEW_VERSION}"
|
139
|
+
|
140
|
+
./hooks/update-version "${NEW_VERSION}" || exit_error "could not update version.rb you may need to run [chmod +x hooks/update-version]"
|
141
|
+
|
142
|
+
l_line
|
143
|
+
l 'git add .'
|
144
|
+
git add .
|
145
|
+
|
146
|
+
l 'git status'
|
147
|
+
l_line
|
148
|
+
git status
|
149
|
+
|
150
|
+
# ----------------------------------------------------------------------
|
151
|
+
# Before doing anything, add the files and then run the commit hook
|
152
|
+
# Then stash any changes - working directory will be clean after this
|
153
|
+
# The commit hook is where we can check for any debugging code that has
|
154
|
+
# gone into the code and abort the commit
|
155
|
+
# ----------------------------------------------------------------------
|
156
|
+
|
157
|
+
l 'check for debugging code'
|
158
|
+
./hooks/pre-commit || exit_error "remove debugging code from the commit - then run again"
|
159
|
+
|
160
|
+
l "Stash changes to [git_make_hotfix: ${MESSAGE}]"
|
161
|
+
|
162
|
+
git stash save "git_make_hotfix: ${MESSAGE}"
|
163
|
+
|
164
|
+
l "OK: Stashed"
|
165
|
+
|
166
|
+
l_title 'Master/Develop Branches'
|
167
|
+
# ----------------------------------------------------------------------
|
168
|
+
# update develop
|
169
|
+
# ----------------------------------------------------------------------
|
170
|
+
|
171
|
+
lkv "Develop" "Synchronized"
|
172
|
+
git checkout develop || exit_error "Failed to checkout develop branch"
|
173
|
+
lkv "Develop" "Switched"
|
174
|
+
git merge origin/develop || exit_error "Failed to merge develop from origin"
|
175
|
+
lkv "Develop" "Merged and upto date"
|
176
|
+
|
177
|
+
# ----------------------------------------------------------------------
|
178
|
+
# update master
|
179
|
+
# ----------------------------------------------------------------------
|
180
|
+
|
181
|
+
lkv "Master" "Synchronized"
|
182
|
+
git checkout master || exit_error "Failed to checkout master branch"
|
183
|
+
lkv "Master" "Switched"
|
184
|
+
git merge origin/master || exit_error "Failed to merge master from origin"
|
185
|
+
lkv "Master" "Merged and upto date"
|
186
|
+
|
187
|
+
# ----------------------------------------------------------------------
|
188
|
+
# start the hotfix
|
189
|
+
# ----------------------------------------------------------------------
|
190
|
+
|
191
|
+
l_title 'Hotfix'
|
192
|
+
|
193
|
+
lkv "Version" "${NEW_VERSION}"
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
lkv "git flow hotfix start" "${NEW_VERSION}"
|
198
|
+
|
199
|
+
git flow hotfix start "${NEW_VERSION}" || exit_error "Failed to start hotfix ${NEW_VERSION}"
|
200
|
+
|
201
|
+
HOTFIX_BRANCH="hotfix/${NEW_VERSION}"
|
202
|
+
|
203
|
+
lkv "started" "${HOTFIX_BRANCH}"
|
204
|
+
|
205
|
+
# ----------------------------------------------------------------------
|
206
|
+
# commit the stashed changes
|
207
|
+
# ----------------------------------------------------------------------
|
208
|
+
|
209
|
+
lkv "git stash" "pop"
|
210
|
+
|
211
|
+
git stash pop || exit_error "Failed to pop the stash into the hotfix"
|
212
|
+
|
213
|
+
lkv "git commit" "${MESSAGE}"
|
214
|
+
|
215
|
+
git commit -a -m"${MESSAGE}" || exit_error "Failed to commit the stash to ${HOTFIX_BRANCH}"
|
216
|
+
|
217
|
+
lkv "git commit succesful" "${HOTFIX_BRANCH}"
|
218
|
+
|
219
|
+
# ----------------------------------------------------------------------
|
220
|
+
# close the hotfix
|
221
|
+
# ----------------------------------------------------------------------
|
222
|
+
|
223
|
+
lkv "git flow hotfix finish" "${NEW_VERSION}"
|
224
|
+
|
225
|
+
git flow hotfix finish "${NEW_VERSION}" -m"${MESSAGE}" || exit_error "Failed to close ${HOTFIX_BRANCH}"
|
226
|
+
|
227
|
+
lkv "finished" "${HOTFIX_BRANCH}"
|
228
|
+
|
229
|
+
# closing the hotfix leaves you on the development branch
|
230
|
+
# return to the master ???? or should we stay on development
|
231
|
+
|
232
|
+
lkv "git checkout" "master"
|
233
|
+
|
234
|
+
git checkout master || exit_error "Failed to return to master branch"
|
235
|
+
|
236
|
+
# ----------------------------------------------------------------------
|
237
|
+
# now push the changes
|
238
|
+
# ----------------------------------------------------------------------
|
239
|
+
|
240
|
+
l_title 'Push Changes and Synchronize Master/Develop'
|
241
|
+
|
242
|
+
${SCRIPT_DIR}/${SYNC_SCRIPT}
|
243
|
+
|
244
|
+
l_heading 'Success'
|