template / commit
more improvements
.vscode/settings.json | 1 + IMPROVEMENTS.md | 27 ++- internal/core/default_config.go | 398 +--------------------------------------- internal/core/defaults.yaml | 288 +++++++++++++++++++++++++++++ internal/core/profile.go | 4 +- 5 files changed, 313 insertions(+), 405 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 1ebfb6b..d867dac 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,6 +2,7 @@ "cSpell.words": [ "bashdb", "chdir", + "omitempty", "filetemplate", "hackathon", "golangci", diff --git a/IMPROVEMENTS.md b/IMPROVEMENTS.md index a641dbb..2fb179d 100644 --- a/IMPROVEMENTS.md +++ b/IMPROVEMENTS.md @@ -91,24 +91,21 @@ rather than returning errors. --- -## 7. Clean up `default_config.go` +## ✅ 7. Clean up `default_config.go` -At 396 lines, [default_config.go](internal/core/default_config.go) is unwieldy. -Options: +[default_config.go](internal/core/default_config.go) shrunk from 396 lines to 18 +by switching to `//go:embed defaults.yaml`. All 14 profiles now live in +[defaults.yaml](internal/core/defaults.yaml) as plain YAML, editable without +touching Go code. -- Split into per-profile files: `profiles_daily.go`, `profiles_git.go`, etc. -- Or load default profiles from an embedded YAML file (`//go:embed defaults.yaml`) - so non-Go contributors can read and edit profiles without touching Go code. - -The embedded YAML approach also makes it easy to write a single test that validates -every default profile passes `validateProfile()`. +Added `omitempty` to the `IsDefault` and `IsDisabled` bool fields in `Profile` +so marshaling produces clean output (zero values omitted). --- -## 8. Minor housekeeping +## ✅ 8. Minor housekeeping -- **Empty `src/` directory** — remove it. -- **`.DS_Store`** — add `**/.DS_Store` to [.gitignore](.gitignore) to prevent - future commits of macOS metadata files. -- **CI image pinning** — `.gitlab-ci.yml` uses `golang:1.25` (unpinned minor). - Pin to a patch tag (`golang:1.25.x`) for reproducible builds. +- **Empty `src/` directory** — removed. +- **`.DS_Store`** — `**/.DS_Store` added to [.gitignore](.gitignore). +- **CI image pinning** — [.gitlab-ci.yml](.gitlab-ci.yml) pinned to + `golang:1.25.4`. diff --git a/internal/core/default_config.go b/internal/core/default_config.go index e681d00..4cecca1 100644 --- a/internal/core/default_config.go +++ b/internal/core/default_config.go @@ -1,396 +1,18 @@ package core -func defaultConfig() Config { - config := Config{ - Profiles: []Profile{ - { - Name: "daily", - Description: "Creates a MD file in ~/DailyNotes folder in the format YYYY-MM-DD[-vX].md", - TargetDirectory: "~/DailyNotes", - Type: FileType, - NamePatterns: []ParameterizedText{ - "{{$version := getVersion}}" + - "{{.YYYY_MM_DD}}" + - `{{if .ProjectName}}-{{.ProjectName | snakecase }}{{end}}` + - "{{if (gt $version 1)}}v{{$version}}{{end}}" + - ".md", - }, - FileTemplate: `# {{.FileNameWithoutExtension}} - -Today's notes for {{.Year}}-{{.Month}}-{{.Day}}. - -## Todo - -1. Check email -2. Check chat -3. Check calendar -4. Check yesterday's notes -5. Have fun! -6. ADD MORE ITEMS HERE`, - PostScripts: []ParameterizedText{ - "code . {{ if .FullPath }}\"{{.FullPath}}\"{{else}}(ls -t | head -n1){{ end }}", - }, - RunPostscriptOnFailure: true, - }, - { - Name: "note", - Description: "Creates a MD file in ~/Notes in the format YYYY-MM-DD[-ProjectName][-vVersion].md", - OS: "All", - TargetDirectory: "~/Notes", - Type: FileType, - NamePatterns: []ParameterizedText{ - "{{$version := getVersion}}" + - "{{.Year}}-{{.Month}}-{{.Day}}" + - "{{if .ProjectName}}-{{.ProjectName}}{{end}}" + - "{{if (gt $version 1)}}n{{$version}}{{end}}" + - ".md", - }, - PostScripts: []ParameterizedText{ - "code \"{{.FullPath}}\"", - }, - }, - { - Name: "note-here", - Description: "Creates a MD file in the current folder in the format YYYY-MM-DD[-HH[-MM[-SS]]][-ProjectName][-vVersion].md", - OS: "All", - Type: FileType, - IsDefault: true, - TargetDirectory: ".", // current folder - NamePatterns: []ParameterizedText{ - "{{$version := getVersion}}" + - "{{.Year}}-{{.Month}}-{{.Day}}" + - "{{if .ProjectName}}-{{.ProjectName}}{{end}}" + - "{{if (gt $version 1)}}n{{$version}}{{end}}" + - ".md", - "{{$version := getVersion}}" + - "{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}" + - "{{if .ProjectName}}-{{.ProjectName}}{{end}}" + - "{{if (gt $version 1)}}n{{$version}}{{end}}" + - ".md", - "{{$version := getVersion}}" + - "{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}" + - "{{if .ProjectName}}-{{.ProjectName}}{{end}}" + - "{{if (gt $version 1)}}n{{$version}}{{end}}" + - ".md", - "{{$version := getVersion}}" + - "{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}-{{.Second}}" + - "{{if .ProjectName}}-{{.ProjectName}}{{end}}" + - "{{if (gt $version 1)}}n{{$version}}{{end}}" + - ".md", - }, - PostScripts: []ParameterizedText{ - "code \"{{.FullPath}}\"", - }, - }, - { - Name: "blog", - Description: "Creates a MD file in the ~/Blog folder in the format YYYY-MM-DD[-ProjectName][-vVersion].md", - OS: "All", - TargetDirectory: "~/Blog", - FileTemplate: `# {{.ProjectName}} - -Created by template, on {{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}-{{.Second}}. - -## Spelling - -cspell:words nanite - -## Removed writing - -## Writing -`, - Type: FileType, - NamePatterns: []ParameterizedText{ - "{{$version := getVersion}}" + - "{{.Year}}-{{.Month}}-{{.Day}}" + - `{{if .ProjectName}}-{{.ProjectName | snakecase }}{{end}}` + - "{{if (gt $version 1)}}v{{$version}}{{end}}" + - ".md", - }, - PostScripts: []ParameterizedText{ - "code . \"{{.FileName}}\"", - }, - }, - { - Name: "work-win", - Description: "Creates a folder in the c:/work folder in the format YYYY-MM-DD[-hh][-mm][-ss][-ProjectName]", - OS: "Windows", - TargetDirectory: "C:/work", - Type: FolderType, - NamePatterns: []ParameterizedText{ - "{{.Year}}-{{.Month}}-{{.Day}}{{if .ProjectName}}-{{.ProjectName}}{{end}}", - "{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}{{if .ProjectName}}-{{.ProjectName}}{{end}}", - "{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}{{if .ProjectName}}-{{.ProjectName}}{{end}}", - "{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}-{{.Second}}{{if .ProjectName}}-{{.ProjectName}}{{end}}", - }, - PostScripts: []ParameterizedText{ - "explorer \"{{.Path}}\"", - }, - }, - { - Name: "therapy", - Description: "Creates a MD file in the ~/Therapy folder in the format YYYY-MM-DD[-vVersion].md", - OS: "All", - TargetDirectory: "~/Therapy", - FileTemplate: `# {{if .ProjectName}}{{.ProjectName}}{{else}}Therapy notes{{end}} +import ( + _ "embed" -{{if .ProjectName}}Therapy notes on {{.ProjectName}}{{else}}Therapy notes{{end}} + "gopkg.in/yaml.v3" +) -## Spelling - -cspell:words cromulent embiggen - -## Writing - -{{if .ProjectName}}Hello {{.ProjectName}},{{else}}Hello,{{end}} - -Start writing here... - -Sincerely, me -`, - Type: FileType, - NamePatterns: []ParameterizedText{ - "{{$version := getVersion}}" + - "{{.Year}}-{{.Month}}-{{.Day}}" + - "{{if (gt $version 1)}}v{{$version}}{{end}}" + - ".md", - }, - PostScripts: []ParameterizedText{ - "code . {{.FullPath}}", - }, - }, - { - Name: "work", - Description: "Creates a folder in the ~/Work folder in the format YYYY-MM-DD[-hh][-mm][-ss][-ProjectName]", - TargetDirectory: "~/Work", - Type: FolderType, - NamePatterns: []ParameterizedText{ - "{{.Year}}-{{.Month}}-{{.Day}}{{if .ProjectName}}-{{.ProjectName}}{{end}}", - "{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}{{if .ProjectName}}-{{.ProjectName}}{{end}}", - "{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}{{if .ProjectName}}-{{.ProjectName}}{{end}}", - "{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}-{{.Second}}{{if .ProjectName}}-{{.ProjectName}}{{end}}", - }, - PostScripts: []ParameterizedText{ - "code .", - "chmod +x repro.sh", - }, - Files: []FileInFolder{ - { - FileTemplate: `# {{.ProjectName}} - -Work notes on {{.ProjectName}} -`, - Name: "README.md", - }, - { - FileTemplate: `clear - -echo "Let's test {{.ProjectName}}!"`, - Name: "repro.sh", - }, - { - FileTemplate: `{ - "version": "0.2.0", - "configurations": [ - { - "type": "bashdb", - "request": "launch", - "name": "Debug repo.sh", - "cwd": "${workspaceFolder}", - "program": "${workspaceFolder}/repro.sh", - "terminalKind": "integrated" - } - ] -} - `, - Name: ".vscode/launch.json", - }, - }, - }, - { - Name: "folder", - Description: "Creates a folder in the current folder in the format YYYY-MM-DD[-ProjectName][-vVersion]", - Type: FolderType, - TargetDirectory: ".", // current folder - PostScripts: []ParameterizedText{}, - NamePatterns: []ParameterizedText{ - "{{$version := getVersion}}" + - "{{.Year}}-{{.Month}}-{{.Day}}" + - "{{if .ProjectName}}-{{.ProjectName}}{{end}}" + - "{{if (gt $version 1)}}-n{{$version}}{{end}}", - }, - }, - { - Name: "create-react-app", - Type: FolderType, - Description: "Creates a folder in the current folder in the format create-react-app[-ProjectName][-vVersion], runs `npx create-react-app` to initialize the folder, and opens the folder in VSCode", - TargetDirectory: ".", // current folder - NamePatterns: []ParameterizedText{ - "{{$version := getVersion}}" + - "create-react-app" + - "{{if .ProjectName}}-{{.ProjectName}}{{end}}" + - "{{if (gt $version 1)}}-n{{$version}}{{end}}", - }, - PostScripts: []ParameterizedText{ - "npx create-react-app .", - "code .", - }, - }, - { - Name: "git", - Description: "Creates a folder in the ~/code folder in the format YYYY-MM-DD[-hh][-mm][-ss][-ProjectName]", - TargetDirectory: "~/code", - Type: FolderType, - NamePatterns: []ParameterizedText{ - "{{.Year}}-{{.Month}}-{{.Day}}{{if .ProjectName}}-{{.ProjectName}}{{end}}", - "{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}{{if .ProjectName}}-{{.ProjectName}}{{end}}", - "{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}{{if .ProjectName}}-{{.ProjectName}}{{end}}", - "{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}-{{.Second}}{{if .ProjectName}}-{{.ProjectName}}{{end}}", - }, - PostScripts: []ParameterizedText{ - "git init", - "code .", - }, - }, - { - Name: "git-clone", - Description: "DISABLED - Clones a repository into a new folder under ~/code in the format YYYY-MM-DD[-hh][-mm][-ss][-ProjectName]", - IsDisabled: true, - TargetDirectory: "~/code", - Type: FolderType, - NamePatterns: []ParameterizedText{ - "{{.Year}}-{{.Month}}-{{.Day}}{{if .ProjectName}}-{{.ProjectName}}{{end}}", - "{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}{{if .ProjectName}}-{{.ProjectName}}{{end}}", - "{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}{{if .ProjectName}}-{{.ProjectName}}{{end}}", - "{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}-{{.Second}}{{if .ProjectName}}-{{.ProjectName}}{{end}}", - }, - PostScripts: []ParameterizedText{ - "git clone {{.Url}} .", - "code .", - }, - }, - { - Name: "log", - Description: "Creates a log file in the current folder", - Type: FileType, - NamePatterns: []ParameterizedText{ - "{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}-{{.Second}}{{if .ProjectName}}-{{.ProjectName}}{{end}}.log", - }, - TargetDirectory: ".", - PostScripts: []ParameterizedText{ - "code . {{.FullPath}}", - }, - }, +//go:embed defaults.yaml +var defaultConfigYAML []byte - { - Name: "dolt", - Description: "Creates a `YYYY-MM-DD-ProjectName` folder for testing SQL in dolt and MySQL", - Type: FolderType, - NamePatterns: []ParameterizedText{ - "{{.Year}}-{{.Month}}-{{.Day}}-{{.ProjectName}}", - }, - TargetDirectory: "~/Work", - PostScripts: []ParameterizedText{ - "code .", - "chmod +x repro.sh", - }, - Files: []FileInFolder{ - { - Name: "README.md", - FileTemplate: `# {{.ProjectName}} - -Work notes on {{.ProjectName}}`, - }, - { - Name: ".vscode/launch.json", - FileTemplate: `{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "bashdb", - "request": "launch", - "name": "Debug repo.sh", - "cwd": "${workspaceFolder}", - "program": "${workspaceFolder}/repro.sh", - "terminalKind": "integrated" - } - ] -}`, - }, - { - Name: "repro.sh", - FileTemplate: `clear - -echo "Let's test {{.ProjectName}}!" - -echo "setting up dolt" -rm -rf db -mkdir db -cd db -dolt init -dolt version - -echo "running against dolt $(dolt version)" - -echo "dolt setup.sql" -echo ">>>>>>>>>>>>>>>>>>>>>>" -dolt sql < ../setup.sql -echo "<<<<<<<<<<<<<<<<<<<<<<" - -echo "dolt test.sql" -echo ">>>>>>>>>>>>>>>>>>>>>>" -dolt sql < ../test.sql -echo "<<<<<<<<<<<<<<<<<<<<<<" - -echo "mysql start" -mysql.server start -mysql -u root -e "drop database if exists db; create database db;" - -echo "mysql setup.sql" -echo ">>>>>>>>>>>>>>>>>>>>>>" -cat ../setup.sql | mysql -u root --table -echo "<<<<<<<<<<<<<<<<<<<<<<" - -echo "mysql test.sql" -echo ">>>>>>>>>>>>>>>>>>>>>>" -cat ../test.sql | mysql -u root --table -echo "<<<<<<<<<<<<<<<<<<<<<<" - -echo "stop mysql" -killall mysqld mysqld_safe`, - }, - { - Name: "setup.sql", - FileTemplate: `use db; - -SET foreign_key_checks=0; - -CREATE TABLE t(a INT, b INT); -INSERT INTO t(a, b) VALUES -(1, 1), -(1, 2), -(1, 3), -(2, 4), -(2, 5), -(2, 6); - -SET foreign_key_checks=1;`, - }, - { - Name: "test.sql", - FileTemplate: `use db; - -SELECT SUM(b) OVER (PARTITION BY a) FROM t ORDER BY 1; -SELECT SUM(b) OVER () FROM t ORDER BY 1; -SELECT SUM(b) OVER (PARTITION BY a), SUM(b) OVER () FROM t;`, - }, - }, - }, - }, +func defaultConfig() Config { + var config Config + if err := yaml.Unmarshal(defaultConfigYAML, &config); err != nil { + panic("defaults.yaml is invalid: " + err.Error()) } - return config } diff --git a/internal/core/defaults.yaml b/internal/core/defaults.yaml new file mode 100644 index 0000000..273e5ce --- /dev/null +++ b/internal/core/defaults.yaml @@ -0,0 +1,288 @@ +profiles: + - name: daily + description: Creates a MD file in ~/DailyNotes folder in the format YYYY-MM-DD[-vX].md + type: file + runpostscriptonfailure: true + postscripts: + - code . {{ if .FullPath }}"{{.FullPath}}"{{else}}(ls -t | head -n1){{ end }} + namepatterns: + - '{{$version := getVersion}}{{.YYYY_MM_DD}}{{if .ProjectName}}-{{.ProjectName | snakecase }}{{end}}{{if (gt $version 1)}}v{{$version}}{{end}}.md' + targetdirectory: ~/DailyNotes + filetemplate: |- + # {{.FileNameWithoutExtension}} + + Today's notes for {{.Year}}-{{.Month}}-{{.Day}}. + + ## Todo + + 1. Check email + 2. Check chat + 3. Check calendar + 4. Check yesterday's notes + 5. Have fun! + 6. ADD MORE ITEMS HERE + - name: note + description: Creates a MD file in ~/Notes in the format YYYY-MM-DD[-ProjectName][-vVersion].md + type: file + os: All + postscripts: + - code "{{.FullPath}}" + namepatterns: + - '{{$version := getVersion}}{{.Year}}-{{.Month}}-{{.Day}}{{if .ProjectName}}-{{.ProjectName}}{{end}}{{if (gt $version 1)}}n{{$version}}{{end}}.md' + targetdirectory: ~/Notes + - name: note-here + description: Creates a MD file in the current folder in the format YYYY-MM-DD[-HH[-MM[-SS]]][-ProjectName][-vVersion].md + isdefault: true + type: file + os: All + postscripts: + - code "{{.FullPath}}" + namepatterns: + - '{{$version := getVersion}}{{.Year}}-{{.Month}}-{{.Day}}{{if .ProjectName}}-{{.ProjectName}}{{end}}{{if (gt $version 1)}}n{{$version}}{{end}}.md' + - '{{$version := getVersion}}{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}{{if .ProjectName}}-{{.ProjectName}}{{end}}{{if (gt $version 1)}}n{{$version}}{{end}}.md' + - '{{$version := getVersion}}{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}{{if .ProjectName}}-{{.ProjectName}}{{end}}{{if (gt $version 1)}}n{{$version}}{{end}}.md' + - '{{$version := getVersion}}{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}-{{.Second}}{{if .ProjectName}}-{{.ProjectName}}{{end}}{{if (gt $version 1)}}n{{$version}}{{end}}.md' + targetdirectory: . + - name: blog + description: Creates a MD file in the ~/Blog folder in the format YYYY-MM-DD[-ProjectName][-vVersion].md + type: file + os: All + postscripts: + - code . "{{.FileName}}" + namepatterns: + - '{{$version := getVersion}}{{.Year}}-{{.Month}}-{{.Day}}{{if .ProjectName}}-{{.ProjectName | snakecase }}{{end}}{{if (gt $version 1)}}v{{$version}}{{end}}.md' + targetdirectory: ~/Blog + filetemplate: | + # {{.ProjectName}} + + Created by template, on {{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}-{{.Second}}. + + ## Spelling + + cspell:words nanite + + ## Removed writing + + ## Writing + - name: work-win + description: Creates a folder in the c:/work folder in the format YYYY-MM-DD[-hh][-mm][-ss][-ProjectName] + type: folder + os: Windows + postscripts: + - explorer "{{.Path}}" + namepatterns: + - '{{.Year}}-{{.Month}}-{{.Day}}{{if .ProjectName}}-{{.ProjectName}}{{end}}' + - '{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}{{if .ProjectName}}-{{.ProjectName}}{{end}}' + - '{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}{{if .ProjectName}}-{{.ProjectName}}{{end}}' + - '{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}-{{.Second}}{{if .ProjectName}}-{{.ProjectName}}{{end}}' + targetdirectory: C:/work + - name: therapy + description: Creates a MD file in the ~/Therapy folder in the format YYYY-MM-DD[-vVersion].md + type: file + os: All + postscripts: + - code . {{.FullPath}} + namepatterns: + - '{{$version := getVersion}}{{.Year}}-{{.Month}}-{{.Day}}{{if (gt $version 1)}}v{{$version}}{{end}}.md' + targetdirectory: ~/Therapy + filetemplate: | + # {{if .ProjectName}}{{.ProjectName}}{{else}}Therapy notes{{end}} + + {{if .ProjectName}}Therapy notes on {{.ProjectName}}{{else}}Therapy notes{{end}} + + ## Spelling + + cspell:words cromulent embiggen + + ## Writing + + {{if .ProjectName}}Hello {{.ProjectName}},{{else}}Hello,{{end}} + + Start writing here... + + Sincerely, me + - name: work + description: Creates a folder in the ~/Work folder in the format YYYY-MM-DD[-hh][-mm][-ss][-ProjectName] + type: folder + postscripts: + - code . + - chmod +x repro.sh + namepatterns: + - '{{.Year}}-{{.Month}}-{{.Day}}{{if .ProjectName}}-{{.ProjectName}}{{end}}' + - '{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}{{if .ProjectName}}-{{.ProjectName}}{{end}}' + - '{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}{{if .ProjectName}}-{{.ProjectName}}{{end}}' + - '{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}-{{.Second}}{{if .ProjectName}}-{{.ProjectName}}{{end}}' + targetdirectory: ~/Work + files: + - name: README.md + file: | + # {{.ProjectName}} + + Work notes on {{.ProjectName}} + - name: repro.sh + file: |- + clear + + echo "Let's test {{.ProjectName}}!" + - name: .vscode/launch.json + file: |- + { + "version": "0.2.0", + "configurations": [ + { + "type": "bashdb", + "request": "launch", + "name": "Debug repo.sh", + "cwd": "${workspaceFolder}", + "program": "${workspaceFolder}/repro.sh", + "terminalKind": "integrated" + } + ] + } + + - name: folder + description: Creates a folder in the current folder in the format YYYY-MM-DD[-ProjectName][-vVersion] + type: folder + namepatterns: + - '{{$version := getVersion}}{{.Year}}-{{.Month}}-{{.Day}}{{if .ProjectName}}-{{.ProjectName}}{{end}}{{if (gt $version 1)}}-n{{$version}}{{end}}' + targetdirectory: . + - name: create-react-app + description: Creates a folder in the current folder in the format create-react-app[-ProjectName][-vVersion], runs `npx create-react-app` to initialize the folder, and opens the folder in VSCode + type: folder + postscripts: + - npx create-react-app . + - code . + namepatterns: + - '{{$version := getVersion}}create-react-app{{if .ProjectName}}-{{.ProjectName}}{{end}}{{if (gt $version 1)}}-n{{$version}}{{end}}' + targetdirectory: . + - name: git + description: Creates a folder in the ~/code folder in the format YYYY-MM-DD[-hh][-mm][-ss][-ProjectName] + type: folder + postscripts: + - git init + - code . + namepatterns: + - '{{.Year}}-{{.Month}}-{{.Day}}{{if .ProjectName}}-{{.ProjectName}}{{end}}' + - '{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}{{if .ProjectName}}-{{.ProjectName}}{{end}}' + - '{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}{{if .ProjectName}}-{{.ProjectName}}{{end}}' + - '{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}-{{.Second}}{{if .ProjectName}}-{{.ProjectName}}{{end}}' + targetdirectory: ~/code + - name: git-clone + description: DISABLED - Clones a repository into a new folder under ~/code in the format YYYY-MM-DD[-hh][-mm][-ss][-ProjectName] + isdisabled: true + type: folder + postscripts: + - git clone {{.Url}} . + - code . + namepatterns: + - '{{.Year}}-{{.Month}}-{{.Day}}{{if .ProjectName}}-{{.ProjectName}}{{end}}' + - '{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}{{if .ProjectName}}-{{.ProjectName}}{{end}}' + - '{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}{{if .ProjectName}}-{{.ProjectName}}{{end}}' + - '{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}-{{.Second}}{{if .ProjectName}}-{{.ProjectName}}{{end}}' + targetdirectory: ~/code + - name: log + description: Creates a log file in the current folder + type: file + postscripts: + - code . {{.FullPath}} + namepatterns: + - '{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}-{{.Second}}{{if .ProjectName}}-{{.ProjectName}}{{end}}.log' + targetdirectory: . + - name: dolt + description: Creates a `YYYY-MM-DD-ProjectName` folder for testing SQL in dolt and MySQL + type: folder + postscripts: + - code . + - chmod +x repro.sh + namepatterns: + - '{{.Year}}-{{.Month}}-{{.Day}}-{{.ProjectName}}' + targetdirectory: ~/Work + files: + - name: README.md + file: |- + # {{.ProjectName}} + + Work notes on {{.ProjectName}} + - name: .vscode/launch.json + file: |- + { + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "bashdb", + "request": "launch", + "name": "Debug repo.sh", + "cwd": "${workspaceFolder}", + "program": "${workspaceFolder}/repro.sh", + "terminalKind": "integrated" + } + ] + } + - name: repro.sh + file: |- + clear + + echo "Let's test {{.ProjectName}}!" + + echo "setting up dolt" + rm -rf db + mkdir db + cd db + dolt init + dolt version + + echo "running against dolt $(dolt version)" + + echo "dolt setup.sql" + echo ">>>>>>>>>>>>>>>>>>>>>>" + dolt sql < ../setup.sql + echo "<<<<<<<<<<<<<<<<<<<<<<" + + echo "dolt test.sql" + echo ">>>>>>>>>>>>>>>>>>>>>>" + dolt sql < ../test.sql + echo "<<<<<<<<<<<<<<<<<<<<<<" + + echo "mysql start" + mysql.server start + mysql -u root -e "drop database if exists db; create database db;" + + echo "mysql setup.sql" + echo ">>>>>>>>>>>>>>>>>>>>>>" + cat ../setup.sql | mysql -u root --table + echo "<<<<<<<<<<<<<<<<<<<<<<" + + echo "mysql test.sql" + echo ">>>>>>>>>>>>>>>>>>>>>>" + cat ../test.sql | mysql -u root --table + echo "<<<<<<<<<<<<<<<<<<<<<<" + + echo "stop mysql" + killall mysqld mysqld_safe + - name: setup.sql + file: |- + use db; + + SET foreign_key_checks=0; + + CREATE TABLE t(a INT, b INT); + INSERT INTO t(a, b) VALUES + (1, 1), + (1, 2), + (1, 3), + (2, 4), + (2, 5), + (2, 6); + + SET foreign_key_checks=1; + - name: test.sql + file: |- + use db; + + SELECT SUM(b) OVER (PARTITION BY a) FROM t ORDER BY 1; + SELECT SUM(b) OVER () FROM t ORDER BY 1; + SELECT SUM(b) OVER (PARTITION BY a), SUM(b) OVER () FROM t; + diff --git a/internal/core/profile.go b/internal/core/profile.go index 7f28409..ca4cc1d 100644 --- a/internal/core/profile.go +++ b/internal/core/profile.go @@ -47,8 +47,8 @@ type FileInFolder struct { type Profile struct { Name string Description string `yaml:"description,omitempty"` - IsDefault bool - IsDisabled bool + IsDefault bool `yaml:"isdefault,omitempty"` + IsDisabled bool `yaml:"isdisabled,omitempty"` Type ProfileType OS OSType `yaml:"os,omitempty"` RunPostscriptOnFailure bool `yaml:"runpostscriptonfailure,omitempty"`