Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DataSmith
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
apps
DataSmith
Commits
f9f4c816
Commit
f9f4c816
authored
9 months ago
by
Sigmund, Dominik
Browse files
Options
Downloads
Patches
Plain Diff
Added License and empty dbml file
parent
688a1f12
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#82051
canceled
9 months ago
Stage: build
Stage: scan
Stage: release
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
commands/init.go
+34
-0
34 additions, 0 deletions
commands/init.go
templates/LICENSE.md.tmpl
+21
-0
21 additions, 0 deletions
templates/LICENSE.md.tmpl
with
55 additions
and
0 deletions
commands/init.go
+
34
−
0
View file @
f9f4c816
...
...
@@ -37,6 +37,12 @@ func InitProject(name string, dbType string) {
// Create datasmith.yaml file from template
createConfigFile
(
slug
,
name
,
dbType
)
// Create an empty database.dbml file
createDBMLFile
(
slug
)
// Create LICENSE.md file from template
createLicenseFile
(
slug
,
name
)
// TODO: copy base files
fmt
.
Printf
(
"Initialized new project structure in '%s'
\n
"
,
slug
)
...
...
@@ -92,6 +98,34 @@ func createConfigFile(projectDir, projectName, dbType string) {
}
}
// createDBMLFile creates an empty database.dbml file in the project directory
func
createDBMLFile
(
projectDir
string
)
{
dbmlFilePath
:=
filepath
.
Join
(
projectDir
,
"database.dbml"
)
file
,
err
:=
os
.
Create
(
dbmlFilePath
)
if
err
!=
nil
{
fmt
.
Printf
(
"Error creating database.dbml file: %v
\n
"
,
err
)
return
}
defer
file
.
Close
()
fmt
.
Printf
(
"Created file: %s/database.dbml
\n
"
,
projectDir
)
}
// createLicenseFile creates the LICENSE.md file from template
func
createLicenseFile
(
projectDir
,
projectName
string
)
{
data
:=
map
[
string
]
interface
{}{
"Name"
:
projectName
,
"Year"
:
time
.
Now
()
.
Year
(),
}
err
:=
templates
.
CreateFileFromTemplate
(
projectDir
,
""
,
"LICENSE.md"
,
"LICENSE.md"
,
data
)
if
err
!=
nil
{
fmt
.
Printf
(
"Error creating LICENSE.md file: %v
\n
"
,
err
)
}
else
{
fmt
.
Printf
(
"Created file: %s/LICENSE.md
\n
"
,
projectDir
)
}
}
// Help returns the help information for the init command
func
InitHelp
()
string
{
return
"init [name] [--type mysql|postgres] : Create a new project with the specified name and database type."
...
...
This diff is collapsed.
Click to expand it.
templates/LICENSE.md.tmpl
0 → 100644
+
21
−
0
View file @
f9f4c816
# MIT License
Copyright (c) {{ .Year }} {{ .Name }}
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment