Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.0.11 #43

Merged
merged 88 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
8472cbf
Bump github.com/essentialkaos/ek/v12 from 12.63.0 to 12.64.0
dependabot[bot] Apr 3, 2023
d477836
Merge pull request #42 from essentialkaos/dependabot/go_modules/devel…
andyone Apr 3, 2023
1043a5b
Improve CI workflows in templates
andyone Apr 17, 2023
3951e4f
Merge branch 'develop' of github.com:essentialkaos/scratch into develop
andyone Apr 17, 2023
b670f9f
Fix typos
andyone Apr 17, 2023
d4fb30a
Fix typos
andyone Apr 17, 2023
b9378e2
Improve CI workflows in templates
andyone Apr 17, 2023
9cbcc20
Improve CI workflow
andyone Apr 17, 2023
1a40cdc
Bump github.com/essentialkaos/ek/v12 from 12.64.0 to 12.64.1
dependabot[bot] Apr 19, 2023
f68912f
Merge pull request #44 from essentialkaos/dependabot/go_modules/devel…
andyone Apr 19, 2023
dfe9c55
Bump github.com/essentialkaos/ek/v12 from 12.64.1 to 12.65.0
dependabot[bot] Apr 28, 2023
3b6b730
Merge pull request #45 from essentialkaos/dependabot/go_modules/devel…
andyone Apr 28, 2023
9feb1b8
Remove goreportcard badge
andyone Apr 29, 2023
3361c6b
Remove goreportcard badge
andyone Apr 29, 2023
104eac3
Merge branch 'develop' of github.com:essentialkaos/scratch into develop
andyone Apr 29, 2023
0fc94b1
Improvements
andyone May 2, 2023
147f0a1
Improvements
andyone May 2, 2023
57ae8eb
Fixes
andyone May 2, 2023
ef3bd2e
Bump github.com/essentialkaos/ek/v12 from 12.65.0 to 12.66.0
dependabot[bot] May 4, 2023
e2088ce
Merge pull request #46 from essentialkaos/dependabot/go_modules/devel…
andyone May 4, 2023
459924b
Bump github.com/essentialkaos/ek/v12 from 12.66.0 to 12.67.0
dependabot[bot] May 8, 2023
f2c46e3
Merge pull request #47 from essentialkaos/dependabot/go_modules/devel…
andyone May 9, 2023
cbcb74a
Improve templates
andyone May 9, 2023
612d668
Merge branch 'develop' of github.com:essentialkaos/scratch into develop
andyone May 9, 2023
5215fce
Code refactoring
andyone May 9, 2023
8333260
Bump github.com/essentialkaos/depsy from 1.0.0 to 1.1.0
dependabot[bot] May 12, 2023
723cf44
Merge pull request #48 from essentialkaos/dependabot/go_modules/devel…
andyone May 12, 2023
b0331df
Bump github.com/essentialkaos/ek/v12 from 12.67.0 to 12.67.1
dependabot[bot] May 15, 2023
8051413
Merge pull request #49 from essentialkaos/dependabot/go_modules/devel…
andyone May 15, 2023
5765604
Bump github.com/essentialkaos/ek/v12 from 12.67.1 to 12.68.0
dependabot[bot] Jun 29, 2023
f0c338b
Merge pull request #50 from essentialkaos/dependabot/go_modules/devel…
andyone Jun 29, 2023
bcd49e3
Update typos configuration + Update CI workflow
andyone Jun 29, 2023
6319d92
Bump github.com/essentialkaos/ek/v12 from 12.68.0 to 12.69.0
dependabot[bot] Jul 14, 2023
ab67d12
Merge pull request #51 from essentialkaos/dependabot/go_modules/devel…
andyone Jul 14, 2023
5098e81
Improve CI workflow
andyone Jul 14, 2023
9697af0
Bump github.com/essentialkaos/ek/v12 from 12.69.0 to 12.70.0
dependabot[bot] Jul 17, 2023
2b8348c
Merge pull request #52 from essentialkaos/dependabot/go_modules/devel…
andyone Jul 17, 2023
03779e9
Bump github.com/essentialkaos/ek/v12 from 12.70.0 to 12.72.0
dependabot[bot] Jul 25, 2023
26dd8e0
Merge pull request #54 from essentialkaos/dependabot/go_modules/devel…
andyone Jul 25, 2023
2b2496a
Bump github.com/essentialkaos/ek/v12 from 12.72.0 to 12.73.1
dependabot[bot] Jul 27, 2023
c455ee4
Merge pull request #55 from essentialkaos/dependabot/go_modules/devel…
andyone Jul 27, 2023
407f46d
Bump github.com/essentialkaos/ek/v12 from 12.73.1 to 12.73.2
dependabot[bot] Aug 1, 2023
70f1803
Merge pull request #56 from essentialkaos/dependabot/go_modules/devel…
andyone Aug 1, 2023
1e9b886
Bump github.com/essentialkaos/ek/v12 from 12.73.2 to 12.75.1
dependabot[bot] Aug 4, 2023
d919b36
Merge pull request #58 from essentialkaos/dependabot/go_modules/devel…
andyone Aug 4, 2023
4ae405f
Bump actions/checkout from 3 to 4
dependabot[bot] Sep 5, 2023
dd10fde
Merge pull request #59 from essentialkaos/dependabot/github_actions/d…
andyone Sep 5, 2023
3b7d6e7
Dependencies update
andyone Sep 16, 2023
665c880
Improve templates
andyone Sep 16, 2023
0942531
Bump actions versions in templates
andyone Sep 16, 2023
c544725
Bump github.com/essentialkaos/ek/v12 from 12.76.1 to 12.77.1
dependabot[bot] Sep 25, 2023
74191e8
Merge pull request #61 from essentialkaos/dependabot/go_modules/devel…
andyone Sep 25, 2023
db855ea
Bump github.com/essentialkaos/ek/v12 from 12.77.1 to 12.78.0
dependabot[bot] Sep 29, 2023
4428cdd
Merge pull request #62 from essentialkaos/dependabot/go_modules/devel…
andyone Sep 29, 2023
a0a68cd
Bump github.com/essentialkaos/ek/v12 from 12.78.0 to 12.79.0
dependabot[bot] Oct 3, 2023
c8de17a
Merge pull request #63 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 3, 2023
83495c4
Bump github.com/essentialkaos/ek/v12 from 12.79.0 to 12.80.0
dependabot[bot] Oct 13, 2023
744e402
Merge pull request #64 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 13, 2023
0723378
Bump github.com/essentialkaos/ek/v12 from 12.80.0 to 12.82.0
dependabot[bot] Oct 17, 2023
ddd3b58
Merge pull request #65 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 17, 2023
77c087b
Bump github.com/essentialkaos/ek/v12 from 12.82.0 to 12.83.1
dependabot[bot] Oct 24, 2023
ddae53b
Merge pull request #67 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 25, 2023
43ec0bd
Bump github.com/essentialkaos/ek/v12 from 12.83.1 to 12.83.2
dependabot[bot] Nov 2, 2023
93c1586
Merge pull request #68 from essentialkaos/dependabot/go_modules/devel…
andyone Nov 2, 2023
c2c338d
Bump github.com/essentialkaos/ek/v12 from 12.83.2 to 12.84.0
dependabot[bot] Nov 14, 2023
7d904ee
Merge pull request #69 from essentialkaos/dependabot/go_modules/devel…
andyone Nov 14, 2023
8200bcc
Bump github.com/essentialkaos/ek/v12 from 12.84.0 to 12.85.0
dependabot[bot] Nov 15, 2023
770e912
Merge pull request #70 from essentialkaos/dependabot/go_modules/devel…
andyone Nov 15, 2023
3c51994
Bump github.com/essentialkaos/ek/v12 from 12.85.0 to 12.86.0
dependabot[bot] Nov 17, 2023
38bef43
Merge pull request #71 from essentialkaos/dependabot/go_modules/devel…
andyone Nov 17, 2023
e7281f0
Bump github.com/essentialkaos/ek/v12 from 12.86.0 to 12.88.1
dependabot[bot] Nov 22, 2023
516427c
Merge pull request #73 from essentialkaos/dependabot/go_modules/devel…
andyone Nov 22, 2023
03866d8
Improvements
andyone Nov 24, 2023
b85de33
Merge branch 'develop' of github.com:essentialkaos/scratch into develop
andyone Nov 24, 2023
dbab9c8
Bump github.com/essentialkaos/ek/v12 from 12.88.1 to 12.90.0
dependabot[bot] Nov 27, 2023
638df8b
Merge pull request #74 from essentialkaos/dependabot/go_modules/devel…
andyone Nov 29, 2023
ae62b9e
Bump github.com/essentialkaos/ek/v12 from 12.90.0 to 12.90.1
dependabot[bot] Dec 4, 2023
556f7af
Merge pull request #75 from essentialkaos/dependabot/go_modules/devel…
andyone Dec 4, 2023
d43ac74
Bump actions/setup-go from 4 to 5
dependabot[bot] Dec 7, 2023
21d7930
Merge pull request #76 from essentialkaos/dependabot/github_actions/d…
andyone Dec 8, 2023
d6754a0
Bump actions/setup-go from 4 to 5
andyone Dec 8, 2023
5144bd0
Bump github.com/essentialkaos/ek/v12 from 12.90.1 to 12.91.0
dependabot[bot] Dec 12, 2023
5efb5d0
Merge pull request #77 from essentialkaos/dependabot/go_modules/devel…
andyone Dec 12, 2023
676de5c
Bump github.com/essentialkaos/ek/v12 from 12.91.0 to 12.92.0
dependabot[bot] Dec 14, 2023
a8a02f5
Bump github/codeql-action from 2 to 3
dependabot[bot] Dec 14, 2023
c976479
Merge pull request #79 from essentialkaos/dependabot/github_actions/d…
andyone Dec 14, 2023
cad7b58
Merge pull request #78 from essentialkaos/dependabot/go_modules/devel…
andyone Dec 14, 2023
256eab9
Update codeql action to the latest version
andyone Dec 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 36 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,57 @@ on:
branches: [master, develop]
pull_request:
branches: [master]
workflow_dispatch:
inputs:
force_run:
description: 'Force workflow run'
required: true
type: choice
options: [yes, no]

permissions:
actions: read
contents: read
statuses: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
Go:
name: Go
runs-on: ubuntu-latest

env:
SRC_DIR: src/github.com/${{ github.repository }}
GO111MODULE: auto

strategy:
matrix:
go: [ '1.19.x', '1.20.x' ]
go: [ '1.20.x', '1.21.x' ]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
id: go

- name: Setup PATH
run: |
echo "GOPATH=${{ github.workspace }}" >> "$GITHUB_ENV"
echo "GOBIN=${{ github.workspace }}/bin" >> "$GITHUB_ENV"
echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH"

- name: Checkout
uses: actions/checkout@v3
with:
path: ${{env.SRC_DIR}}

- name: Download dependencies
working-directory: ${{env.SRC_DIR}}
run: make deps

- name: Build binary
working-directory: ${{env.SRC_DIR}}
- name: Run tests
run: make all

Typos:
name: Typos
runs-on: ubuntu-latest

needs: Go

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check spelling
continue-on-error: true
uses: crate-ci/typos@master
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: go

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
5 changes: 5 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[files]
extend-exclude = ["go.sum"]

[default.extend-identifiers]
O_WRONLY = "O_WRONLY"
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<p align="center">
<a href="https://kaos.sh/w/scratch/ci"><img src="https://kaos.sh/w/scratch/ci.svg" alt="GitHub Actions CI Status" /></a>
<a href="https://kaos.sh/r/scratch"><img src="https://kaos.sh/r/scratch.svg" alt="GoReportCard" /></a>
<a href="https://kaos.sh/b/scratch"><img src="https://kaos.sh/b/3b2ed0f2-1e39-4366-93f6-d955ca22ce3a.svg" alt="Codebeat badge" /></a>
<a href="https://kaos.sh/w/scratch/codeql"><img src="https://kaos.sh/w/scratch/codeql.svg" alt="GitHub Actions CodeQL Status" /></a>
<a href="#license"><img src="https://gh.kaos.st/apache2.svg"></a>
Expand All @@ -18,7 +17,7 @@

#### From sources

To install the `scratch` from sources, make sure you have a working Go 1.19+ workspace (_[instructions](https://golang.org/doc/install)_), then:
To install the `scratch` from sources, make sure you have a working Go 1.19+ workspace (_[instructions](https://go.dev/doc/install)_), then:

```
go install github.com/essentialkaos/scratch
Expand Down Expand Up @@ -70,10 +69,10 @@ Examples
List files in template "package"

scratch package .
Generate files based on tempalte "package" in current directory
Generate files based on template "package" in current directory

scratch service $GOPATH/src/github.com/essentialkaos/myapp
Generate files based on tempalte "service" in given directory
Generate files based on template "service" in given directory
```

### Contributing
Expand Down
56 changes: 21 additions & 35 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ const (

var optMap = options.Map{
OPT_NO_COLOR: {Type: options.BOOL},
OPT_HELP: {Type: options.BOOL, Alias: "u:usage"},
OPT_VER: {Type: options.BOOL, Alias: "ver"},
OPT_HELP: {Type: options.BOOL},
OPT_VER: {Type: options.MIXED},

OPT_COMPLETION: {},
OPT_GENERATE_MAN: {Type: options.BOOL},
}

// ////////////////////////////////////////////////////////////////////////////////// //

// Init is main app func
func Init() {
// Run is main utility function
func Run() {
preConfigureUI()

args, errs := options.Parse(optMap)
Expand All @@ -80,13 +80,16 @@ func Init() {

switch {
case options.Has(OPT_COMPLETION):
os.Exit(genCompletion())
os.Exit(printCompletion())
case options.Has(OPT_GENERATE_MAN):
os.Exit(genMan())
printMan()
os.Exit(0)
case options.GetB(OPT_VER):
os.Exit(showAbout())
genAbout().Print(options.GetS(OPT_VER))
os.Exit(0)
case options.GetB(OPT_HELP):
os.Exit(showUsage())
genUsage().Print()
os.Exit(0)
}

switch len(args) {
Expand Down Expand Up @@ -340,20 +343,8 @@ func printErrorAndExit(f string, a ...interface{}) {

// ////////////////////////////////////////////////////////////////////////////////// //

// showUsage prints usage info
func showUsage() int {
genUsage().Render()
return 0
}

// showAbout prints info about version
func showAbout() int {
genAbout().Render()
return 0
}

// genCompletion generates completion for different shells
func genCompletion() int {
// printCompletion prints completion for given shell
func printCompletion() int {
info := genUsage()

switch options.GetS(OPT_COMPLETION) {
Expand All @@ -370,16 +361,9 @@ func genCompletion() int {
return 0
}

// genMan generates man page
func genMan() int {
fmt.Println(
man.Generate(
genUsage(),
genAbout(),
),
)

return 0
// printMan prints man page
func printMan() {
fmt.Println(man.Generate(genUsage(), genAbout()))
}

// genUsage generates usage info
Expand All @@ -393,19 +377,19 @@ func genUsage() *usage.Info {
info.AddExample("package", "List files in template \"package\"")
info.AddExample(
"package .",
"Generate files based on tempalte \"package\" in current directory",
"Generate files based on template \"package\" in current directory",
)
info.AddExample(
"service $GOPATH/src/github.com/essentialkaos/myapp",
"Generate files based on tempalte \"service\" in given directory",
"Generate files based on template \"service\" in given directory",
)

return info
}

// genAbout generates info about version
func genAbout() *usage.About {
return &usage.About{
about := &usage.About{
App: APP,
Version: VER,
Desc: DESC,
Expand All @@ -414,6 +398,8 @@ func genAbout() *usage.About {
License: "Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0>",
UpdateChecker: usage.UpdateChecker{"essentialkaos/" + APP, update.GitHubChecker},
}

return about
}

// ////////////////////////////////////////////////////////////////////////////////// //
9 changes: 6 additions & 3 deletions app/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const (
VAR_DESC = "DESC"
VAR_DESC_README = "DESC_README"

VAR_CODEBEAT_UUID = "CODEBEAT_UUID"
VAR_CODEBEAT_UUID = "CODEBEAT_UUID"
VAR_CODECLIMATE_ID = "CODECLIMATE_ID"

VAR_SHORT_NAME_TITLE = "SHORT_NAME_TITLE"
VAR_SHORT_NAME_LOWER = "SHORT_NAME_LOWER"
Expand All @@ -45,7 +46,7 @@ const (
type Variables map[string]string // name → value

type Template struct {
Name string // Name of tempate
Name string // Name of template
Path string // Path to directory with template data

Vars Variables // Variables
Expand Down Expand Up @@ -74,7 +75,8 @@ var knownVars = &VariableInfoStore{
VAR_DESC: {"Description", `^.{16,128}$`, false},
VAR_DESC_README: {"Description for README file (part after 'app is… ')", `^.{16,128}$`, false},

VAR_CODEBEAT_UUID: {"Codebeat project UUID", ``, false},
VAR_CODEBEAT_UUID: {"Codebeat project UUID", ``, false},
VAR_CODECLIMATE_ID: {"Code climate project ID", ``, false},

VAR_SHORT_NAME_TITLE: {"Short name in title case", ``, true},
VAR_SHORT_NAME_LOWER: {"Short name in lower case", ``, true},
Expand All @@ -90,6 +92,7 @@ var knownVars = &VariableInfoStore{
VAR_DESC,
VAR_DESC_README,
VAR_CODEBEAT_UUID,
VAR_CODECLIMATE_ID,
},
}

Expand Down
7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ module github.com/essentialkaos/scratch

go 1.18

require github.com/essentialkaos/ek/v12 v12.63.0
require (
github.com/essentialkaos/depsy v1.1.0
github.com/essentialkaos/ek/v12 v12.92.0
)

require (
github.com/essentialkaos/go-linenoise/v3 v3.4.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/sys v0.15.0 // indirect
)
12 changes: 7 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk=
github.com/essentialkaos/ek/v12 v12.63.0 h1:9yaEu5W3bx//9y52ShqYCoFDKOcwEdrnvgSkUYyatgI=
github.com/essentialkaos/ek/v12 v12.63.0/go.mod h1:9MlSuHpewu7OZ9tM9dLFHvoA8dflBIUPCA0Ctt97wRs=
github.com/essentialkaos/depsy v1.1.0 h1:U6dp687UkQwXlZU17Hg2KMxbp3nfZAoZ8duaeUFYvJI=
github.com/essentialkaos/depsy v1.1.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8=
github.com/essentialkaos/ek/v12 v12.92.0 h1:3JIkHWNA6MNkJOfqzMWJ8jN9sRM7nRi7URoFRVFHZzI=
github.com/essentialkaos/ek/v12 v12.92.0/go.mod h1:9efMqo1S8EtYhmeelOSTmMQDGC2vRgPkjkKKfvUD2eU=
github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts=
github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
2 changes: 1 addition & 1 deletion scratch.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ import (
// ////////////////////////////////////////////////////////////////////////////////// //

func main() {
APP.Init()
APP.Run()
}
39 changes: 39 additions & 0 deletions templates/app/.codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: "2"

checks:
argument-count:
enabled: true
config:
threshold: 6
complex-logic:
enabled: true
config:
threshold: 6
file-lines:
enabled: true
config:
threshold: 1000
method-complexity:
enabled: true
config:
threshold: 8
method-count:
enabled: true
config:
threshold: 20
method-lines:
enabled: true
config:
threshold: 100
nested-control-flow:
enabled: true
config:
threshold: 6
return-statements:
enabled: true
config:
threshold: 6
similar-code:
enabled: false
identical-code:
enabled: false
Loading