diff --git a/README.md b/README.md index 5796351b..48a2679f 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,6 @@ An opinionated productive web framework that helps scaling business easier, i.e. - utilise `configs/.env.` to support multiple environments deployment ## Table Of Contents - - [Overview](#overview) - [Features](#features) - [package `cmd`](#package-cmd) @@ -41,6 +40,8 @@ An opinionated productive web framework that helps scaling business easier, i.e. - [package `view`](#package-view) - [package `worker`](#package-worker) - [Getting Started](#getting-started) + - [Prerequisites](#prerequisites) + - [Quick Start](#quick-start) - [Acknowledgement](#acknowledgement) - [Contribution](#contribution) - [License](#license) @@ -315,14 +316,15 @@ $ mkdir && cd $_ && go mod init $_ && git init package main import ( - "github.com/appist/appy/support" + "github.com/appist/appy/cmd" ) func main() { - support.Scaffold(support.ScaffoldOption{ - DBAdapter: "postgres", // only "mysql" and "postgres" are supported - Description: "my first awesome app", // used in HTML's description meta tag, package.json and CLI help - }) + err := cmd.Scaffold() + + if err != nil { + panic(err) + } } ``` @@ -332,37 +334,18 @@ func main() { $ go run . ``` -#### Step 4: Install project dependencies for backend and frontend. - -```bash -$ go mod download -$ npm install -``` - -#### Step 5: Setup your local environment with databases running in docker compose cluster. +#### Step 4: Setup the databases using Docker Compose. ```bash $ go run . setup ``` -#### Step 6: Start developing your application locally. +#### Step 5: Start developing your application locally. ```bash $ go run . start ``` -#### Step 7: Build the application binary with release mode. - -```bash -$ go run . build -``` - -#### Step 8: Tear down everything once you're done testing. - -```bash -$ go run . teardown -``` - ## Acknowledgement - [asynq](https://github.com/hibiken/asynq) - For processing background jobs diff --git a/cmd/build.go b/cmd/build.go index 4a50da93..6e4faaec 100644 --- a/cmd/build.go +++ b/cmd/build.go @@ -24,11 +24,6 @@ func newBuildCommand(asset *support.Asset, logger *support.Logger, server *pack. static bool ) - goExe := "go" - if runtime.GOOS == "windows" { - goExe += ".exe" - } - cmd := &Command{ Use: "build", Short: "Compile the static assets into go files and build the release build binary (only available in debug build)", @@ -42,7 +37,7 @@ func newBuildCommand(asset *support.Asset, logger *support.Logger, server *pack. } if platform != "" && !support.ArrayContains(platforms, platform) { - logger.Fatalf("the '%s' platform isn't supported, refer to `%s tool dist list` for the supported value", platform, goExe) + logger.Fatalf("the '%s' platform isn't supported, refer to `go tool dist list` for the supported value", platform) } wd, err := os.Getwd() @@ -77,7 +72,7 @@ func newBuildCommand(asset *support.Asset, logger *support.Logger, server *pack. }, } - cmd.Flags().StringVar(&platform, "platform", "", fmt.Sprintf("The platform for the binary to run on, see `%s tool dist list` for full list", goExe)) + cmd.Flags().StringVar(&platform, "platform", "", "The platform for the binary to run on, see `go tool dist list` for full list") cmd.Flags().BoolVar(&static, "static", false, "Specify if the binary should statically be built") return cmd } @@ -87,16 +82,6 @@ func buildCompressedBinary(logger *support.Logger, platform string, static bool, logger.Info("Building the binary...") - goExe := "go" - if runtime.GOOS == "windows" { - goExe += ".exe" - } - - goPath, err := exec.LookPath(goExe) - if err != nil { - return err - } - buildCmdArgs := []string{"build", "-a", "-tags", "netgo jsoniter", "-ldflags", "-X github.com/appist/appy/support.Build=release -s -w"} if static { buildCmdArgs[len(buildCmdArgs)-1] += " -extldflags '-static'" @@ -112,12 +97,12 @@ func buildCompressedBinary(logger *support.Logger, platform string, static bool, } } - buildCmd := exec.Command(goPath, append(buildCmdArgs, []string{"-o", name, "."}...)...) + buildCmd := exec.Command("go", append(buildCmdArgs, []string{"-o", name, "."}...)...) buildCmd.Env = os.Environ() buildCmd.Env = append(buildCmd.Env, buildCmdEnv...) buildCmd.Stderr = os.Stderr - if err = buildCmd.Run(); err != nil { + if err := buildCmd.Run(); err != nil { return err } fi, _ := os.Stat(name) @@ -129,7 +114,7 @@ func buildCompressedBinary(logger *support.Logger, platform string, static bool, upxExe += ".exe" } - _, err = exec.LookPath(upxExe) + _, err := exec.LookPath(upxExe) if err == nil { logger.Info("Compressing the binary with upx...") @@ -253,25 +238,15 @@ var assets http.FileSystem func getPlatforms() ([]string, error) { var data []byte - goExe := "go" - if runtime.GOOS == "windows" { - goExe += ".exe" - } - - goPath, err := exec.LookPath(goExe) - if err != nil { - return nil, err - } - - cmd := exec.Command(goPath, "tool", "dist", "list") + cmd := exec.Command("go", "tool", "dist", "list") cmd.Env = os.Environ() cmd.Stderr = os.Stderr stdout, _ := cmd.StdoutPipe() - if err = cmd.Start(); err != nil { + if err := cmd.Start(); err != nil { return nil, err } - data, err = ioutil.ReadAll(stdout) + data, err := ioutil.ReadAll(stdout) if err != nil { return nil, err } diff --git a/support/scaffold.go b/cmd/scaffold.go similarity index 60% rename from support/scaffold.go rename to cmd/scaffold.go index 94f6ad51..200a6906 100644 --- a/support/scaffold.go +++ b/cmd/scaffold.go @@ -1,49 +1,63 @@ -package support +package cmd import ( "encoding/hex" "fmt" "io/ioutil" "os" + "os/exec" "path/filepath" + "regexp" "runtime" "strings" "text/template" - "github.com/pkg/errors" + "github.com/AlecAivazis/survey/v2" + "github.com/appist/appy/support" ) -// ScaffoldOption contains the information of how a new application should be -// created. -type ScaffoldOption struct { - // DBAdapter indicates the database adapter to use. By default, it is - // "postgres". Possible values are "mysql" and "postgres". - DBAdapter string - - // Description indicates the project description that will be used in HTML's - // description meta tag, package.json and CLI help. - Description string -} - -// Scaffold creates a new application. -func Scaffold(opt ScaffoldOption) error { - if opt.DBAdapter == "" { - opt.DBAdapter = "postgres" +var ( + scaffoldQ = []*survey.Question{ + { + Name: "description", + Prompt: &survey.Input{ + Message: "What does your app do?", + Help: "Note: This will be used in HTML's description meta tag, package.json and CLI help message.", + Default: "", + }, + }, + { + Name: "dbAdapter", + Prompt: &survey.Select{ + Message: "Which database adapter would you like to use?", + Options: support.SupportedDBAdapters, + Default: "postgres", + }, + }, } +) - if !ArrayContains(SupportedDBAdapters, opt.DBAdapter) { - return errors.Errorf("DBAdapter '%s' is not supported, only '%s' are supported", opt.DBAdapter, SupportedDBAdapters) +// Scaffold creates a new application. +func Scaffold() error { + answers := struct { + Description string `survey:"description"` + DBAdapter string `survey:"dbAdapter"` + }{} + + err := survey.Ask(scaffoldQ, &answers) + if err != nil { + return err } - moduleName := ModuleName() + moduleName := support.ModuleName() _, dirname, _, _ := runtime.Caller(0) tplPath := filepath.Dir(dirname) + "/templates/scaffold" - masterKeyDev := hex.EncodeToString(GenerateRandomBytes(32)) - masterKeyTest := hex.EncodeToString(GenerateRandomBytes(32)) + masterKeyDev := hex.EncodeToString(support.GenerateRandomBytes(32)) + masterKeyTest := hex.EncodeToString(support.GenerateRandomBytes(32)) var dbURIPrimaryDev, dbURIPrimaryTest string - switch opt.DBAdapter { + switch answers.DBAdapter { case "mysql": dbURIPrimaryDev = getEncryptedValue(fmt.Sprintf("mysql://root:whatever@0.0.0.0:23306/%s", moduleName), masterKeyDev) dbURIPrimaryTest = getEncryptedValue(fmt.Sprintf("mysql://root:whatever@0.0.0.0:23306/%s_test", moduleName), masterKeyTest) @@ -52,12 +66,12 @@ func Scaffold(opt ScaffoldOption) error { dbURIPrimaryTest = getEncryptedValue(fmt.Sprintf("postgresql://postgres:whatever@0.0.0.0:25432/%s_test?sslmode=disable&connect_timeout=5", moduleName), masterKeyTest) } - httpCSRFSecretDev := getEncryptedValue(hex.EncodeToString(GenerateRandomBytes(32)), masterKeyDev) - httpSessionSecretsDev := getEncryptedValue(hex.EncodeToString(GenerateRandomBytes(32)), masterKeyDev) + httpCSRFSecretDev := getEncryptedValue(hex.EncodeToString(support.GenerateRandomBytes(32)), masterKeyDev) + httpSessionSecretsDev := getEncryptedValue(hex.EncodeToString(support.GenerateRandomBytes(32)), masterKeyDev) workerRedisAddrDev := getEncryptedValue("0.0.0.0:26379", masterKeyDev) - httpCSRFSecretTest := getEncryptedValue(hex.EncodeToString(GenerateRandomBytes(32)), masterKeyTest) - httpSessionSecretsTest := getEncryptedValue(hex.EncodeToString(GenerateRandomBytes(32)), masterKeyTest) + httpCSRFSecretTest := getEncryptedValue(hex.EncodeToString(support.GenerateRandomBytes(32)), masterKeyTest) + httpSessionSecretsTest := getEncryptedValue(hex.EncodeToString(support.GenerateRandomBytes(32)), masterKeyTest) workerRedisAddrTest := getEncryptedValue("0.0.0.0:26379", masterKeyTest) if err := filepath.Walk(tplPath, @@ -96,7 +110,7 @@ func Scaffold(opt ScaffoldOption) error { "blockHead": "{{block head()}}", "blockBody": "{{block body()}}", "blockEnd": "{{end}}", - "dbAdapter": opt.DBAdapter, + "dbAdapter": answers.DBAdapter, "dbURIPrimaryDev": dbURIPrimaryDev, "httpCSRFSecretDev": httpCSRFSecretDev, "httpSessionSecretsDev": httpSessionSecretsDev, @@ -107,7 +121,7 @@ func Scaffold(opt ScaffoldOption) error { "workerRedisAddrTest": workerRedisAddrTest, "extendApplicationLayout": "{{extends \"../layouts/application.html\"}}", "projectName": moduleName, - "projectDesc": opt.Description, + "projectDesc": answers.Description, "masterKeyDev": masterKeyDev, "masterKeyTest": masterKeyTest, "translateWelcome": "{{t(\"welcome\", `{\"Name\": \"John Doe\", \"Title\": \"` + t(\"title\") + `\"}`)}}", @@ -119,9 +133,11 @@ func Scaffold(opt ScaffoldOption) error { } version := strings.ReplaceAll(runtime.Version(), "go", "") + re := regexp.MustCompile(`[a-zA-Z].*`) + version = re.ReplaceAllString(version, "") versionSplits := strings.Split(version, ".") - return ioutil.WriteFile( + err = ioutil.WriteFile( "go.mod", []byte(`module `+moduleName+` @@ -134,11 +150,51 @@ require ( )`), 0777, ) + + if err != nil { + return err + } + + err = installBackend() + if err != nil { + return err + } + + err = installFrontend() + if err != nil { + return err + } + + return nil } func getEncryptedValue(value string, masterKey string) string { plaintext := []byte(value) - ciphertext, _ := AESEncrypt(plaintext, []byte(masterKey)) + ciphertext, _ := support.AESEncrypt(plaintext, []byte(masterKey)) return hex.EncodeToString(ciphertext) } + +func installBackend() error { + cmd := exec.Command("go", "mod", "download") + cmd.Env = os.Environ() + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + if err := cmd.Run(); err != nil { + return err + } + + return nil +} + +func installFrontend() error { + cmd := exec.Command("npm", "install") + cmd.Env = os.Environ() + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + if err := cmd.Run(); err != nil { + return err + } + + return nil +} diff --git a/support/templates/scaffold/.dockerignore.tpl b/cmd/templates/scaffold/.dockerignore.tpl similarity index 100% rename from support/templates/scaffold/.dockerignore.tpl rename to cmd/templates/scaffold/.dockerignore.tpl diff --git a/support/templates/scaffold/.editorconfig.tpl b/cmd/templates/scaffold/.editorconfig.tpl similarity index 100% rename from support/templates/scaffold/.editorconfig.tpl rename to cmd/templates/scaffold/.editorconfig.tpl diff --git a/support/templates/scaffold/.gitignore.tpl b/cmd/templates/scaffold/.gitignore.tpl similarity index 100% rename from support/templates/scaffold/.gitignore.tpl rename to cmd/templates/scaffold/.gitignore.tpl diff --git a/support/templates/scaffold/Dockerfile.tpl b/cmd/templates/scaffold/Dockerfile.tpl similarity index 100% rename from support/templates/scaffold/Dockerfile.tpl rename to cmd/templates/scaffold/Dockerfile.tpl diff --git a/support/templates/scaffold/Makefile.tpl b/cmd/templates/scaffold/Makefile.tpl similarity index 100% rename from support/templates/scaffold/Makefile.tpl rename to cmd/templates/scaffold/Makefile.tpl diff --git a/support/templates/scaffold/README.md.tpl b/cmd/templates/scaffold/README.md.tpl similarity index 100% rename from support/templates/scaffold/README.md.tpl rename to cmd/templates/scaffold/README.md.tpl diff --git a/support/templates/scaffold/assets/fonts/.gitkeep.tpl b/cmd/templates/scaffold/assets/fonts/.gitkeep.tpl similarity index 100% rename from support/templates/scaffold/assets/fonts/.gitkeep.tpl rename to cmd/templates/scaffold/assets/fonts/.gitkeep.tpl diff --git a/support/templates/scaffold/assets/images/.gitkeep.tpl b/cmd/templates/scaffold/assets/images/.gitkeep.tpl similarity index 100% rename from support/templates/scaffold/assets/images/.gitkeep.tpl rename to cmd/templates/scaffold/assets/images/.gitkeep.tpl diff --git a/support/templates/scaffold/assets/medias/.gitkeep.tpl b/cmd/templates/scaffold/assets/medias/.gitkeep.tpl similarity index 100% rename from support/templates/scaffold/assets/medias/.gitkeep.tpl rename to cmd/templates/scaffold/assets/medias/.gitkeep.tpl diff --git a/support/templates/scaffold/assets/scripts/.gitkeep.tpl b/cmd/templates/scaffold/assets/scripts/.gitkeep.tpl similarity index 100% rename from support/templates/scaffold/assets/scripts/.gitkeep.tpl rename to cmd/templates/scaffold/assets/scripts/.gitkeep.tpl diff --git a/support/templates/scaffold/assets/styles/welcome.css.tpl b/cmd/templates/scaffold/assets/styles/welcome.css.tpl similarity index 100% rename from support/templates/scaffold/assets/styles/welcome.css.tpl rename to cmd/templates/scaffold/assets/styles/welcome.css.tpl diff --git a/support/templates/scaffold/cmd/cmd.go.tpl b/cmd/templates/scaffold/cmd/cmd.go.tpl similarity index 100% rename from support/templates/scaffold/cmd/cmd.go.tpl rename to cmd/templates/scaffold/cmd/cmd.go.tpl diff --git a/support/templates/scaffold/configs/.env.development.tpl b/cmd/templates/scaffold/configs/.env.development.tpl similarity index 100% rename from support/templates/scaffold/configs/.env.development.tpl rename to cmd/templates/scaffold/configs/.env.development.tpl diff --git a/support/templates/scaffold/configs/.env.test.tpl b/cmd/templates/scaffold/configs/.env.test.tpl similarity index 100% rename from support/templates/scaffold/configs/.env.test.tpl rename to cmd/templates/scaffold/configs/.env.test.tpl diff --git a/support/templates/scaffold/configs/development.key.tpl b/cmd/templates/scaffold/configs/development.key.tpl similarity index 100% rename from support/templates/scaffold/configs/development.key.tpl rename to cmd/templates/scaffold/configs/development.key.tpl diff --git a/support/templates/scaffold/configs/test.key.tpl b/cmd/templates/scaffold/configs/test.key.tpl similarity index 100% rename from support/templates/scaffold/configs/test.key.tpl rename to cmd/templates/scaffold/configs/test.key.tpl diff --git a/support/templates/scaffold/db/migrate/primary/schema.go.tpl b/cmd/templates/scaffold/db/migrate/primary/schema.go.tpl similarity index 100% rename from support/templates/scaffold/db/migrate/primary/schema.go.tpl rename to cmd/templates/scaffold/db/migrate/primary/schema.go.tpl diff --git a/support/templates/scaffold/db/seed/primary/seed.go.tpl b/cmd/templates/scaffold/db/seed/primary/seed.go.tpl similarity index 100% rename from support/templates/scaffold/db/seed/primary/seed.go.tpl rename to cmd/templates/scaffold/db/seed/primary/seed.go.tpl diff --git a/support/templates/scaffold/docker-compose.yml.tpl b/cmd/templates/scaffold/docker-compose.yml.tpl similarity index 100% rename from support/templates/scaffold/docker-compose.yml.tpl rename to cmd/templates/scaffold/docker-compose.yml.tpl diff --git a/support/templates/scaffold/main.go.tpl b/cmd/templates/scaffold/main.go.tpl similarity index 100% rename from support/templates/scaffold/main.go.tpl rename to cmd/templates/scaffold/main.go.tpl index 59865ff4..6461f726 100644 --- a/support/templates/scaffold/main.go.tpl +++ b/cmd/templates/scaffold/main.go.tpl @@ -10,12 +10,12 @@ import ( _ "{{.projectName}}/db/migrate/primary" _ "{{.projectName}}/db/seed/primary" - // Import GraphQL handler. - _ "{{.projectName}}/pkg/graphql" - // Import HTTP handlers. _ "{{.projectName}}/pkg/handler" + // Import GraphQL handler. + _ "{{.projectName}}/pkg/graphql" + // Import background jobs. _ "{{.projectName}}/pkg/job" diff --git a/cmd/templates/scaffold/package.json.tpl b/cmd/templates/scaffold/package.json.tpl new file mode 100644 index 00000000..a7df78b9 --- /dev/null +++ b/cmd/templates/scaffold/package.json.tpl @@ -0,0 +1,132 @@ +{ + "name": "{{.projectName}}", + "description": "{{.projectDesc}}", + "main": "web/src/main.ts", + "scripts": { + "build": "NODE_ENV=production npx webpack --mode=production --progress", + "format": "npx prettier --write '**/*.{css,mjs,js,json,less,md,pug,sass,scss,svelte,ts,tsx,yml,yaml}'", + "start": "NODE_ENV=development npx webpack-dev-server --mode=development", + "test": "npx jest web/src", + "test:e2e": "npx codeceptjs run-multiple default --steps --config=web/tests/e2e/codecept.conf.js", + "test:watch": "npm test -- --watch" + }, + "license": "UNLICENSED", + "dependencies": { + "page": "^1.11.6", + "register-service-worker": "^1.7.1", + "svelte": "^3.23.2", + "svelte-i18n": "^3.0.4" + }, + "devDependencies": { + "@appist/webpack-preset-appy": "^0.1.6", + "@types/jest": "^26.0.3", + "@types/node": "^14.0.14", + "husky": "^4.2.5", + "lint-staged": "^10.2.11", + "typescript": "^3.9.5", + "webpack-cli": "^3.3.12" + }, + "babel": { + "compact": true, + "plugins": [ + "@babel/plugin-syntax-dynamic-import" + ], + "presets": [ + [ + "@babel/preset-env", + { + "targets": { + "node": "current" + } + } + ], + "@babel/preset-typescript" + ] + }, + "husky": { + "hooks": { + "pre-commit": [ + "lint-staged" + ] + } + }, + "jest": { + "collectCoverage": true, + "coverageDirectory": "tmp/coverage/web", + "coveragePathIgnorePatterns": [ + "/node_modules/", + ".+\\.(css|styl|less|sass|scss|svg|png|jpg|jpeg|ttf|woff|woff2)$" + ], + "globals": { + "ts-jest": { + "diagnostics": false + } + }, + "transform": { + ".+\\.(css|styl|less|sass|scss|svg|png|jpg|jpeg|ttf|woff|woff2)$": "jest-transform-stub", + "^.+\\.m?jsx?$": "babel-jest", + "^.+\\.tsx?$": "ts-jest", + "^.+\\.svelte$": [ + "svelte-jester", + { + "preprocess": true + } + ] + }, + "moduleFileExtensions": [ + "js", + "jsx", + "json", + "svelte", + "ts", + "tsx", + "mjs" + ], + "moduleNameMapper": { + "^@assets/(.*)$": "/assets/$1", + "^@/(.*)$": "/web/src/$1" + }, + "setupFiles": [ + "/web/tests/unit/setup.js" + ], + "setupFilesAfterEnv": [ + "@testing-library/jest-dom/extend-expect" + ] + }, + "lint-staged": { + "**/*.{css,mjs,js,json,less,md,pug,sass,scss,svelte,ts,tsx,yml,yaml}": "npx prettier --write", + "**/*.go": "make codecheck" + }, + "prettier": { + "arrowParens": "avoid", + "bracketSpacing": true, + "cursorOffset": -1, + "endOfLine": "auto", + "htmlWhitespaceSensitivity": "css", + "insertPragma": false, + "jsxBracketSameLine": false, + "jsxSingleQuote": false, + "printWidth": 80, + "proseWrap": "preserve", + "quoteProps": "as-needed", + "requirePragma": false, + "semi": true, + "singleQuote": false, + "tabWidth": 2, + "trailingComma": "es5", + "useTabs": false + }, + "pwa": { + "appleStatusBarStyle": "black-translucent", + "background": "#ffffff", + "developerName": "", + "developerURL": "", + "display": "standalone", + "dir": "auto", + "lang": "en-US", + "orientation": "any", + "scope": "/", + "start_url": "./index.html", + "theme_color": "" + } +} diff --git a/support/templates/scaffold/pkg/app/app.go.tpl b/cmd/templates/scaffold/pkg/app/app.go.tpl similarity index 100% rename from support/templates/scaffold/pkg/app/app.go.tpl rename to cmd/templates/scaffold/pkg/app/app.go.tpl diff --git a/support/templates/scaffold/pkg/app/asset.go.tpl b/cmd/templates/scaffold/pkg/app/asset.go.tpl similarity index 100% rename from support/templates/scaffold/pkg/app/asset.go.tpl rename to cmd/templates/scaffold/pkg/app/asset.go.tpl diff --git a/support/templates/scaffold/pkg/app/config.go.tpl b/cmd/templates/scaffold/pkg/app/config.go.tpl similarity index 100% rename from support/templates/scaffold/pkg/app/config.go.tpl rename to cmd/templates/scaffold/pkg/app/config.go.tpl diff --git a/support/templates/scaffold/pkg/graphql/config.yml.tpl b/cmd/templates/scaffold/pkg/graphql/config.yml.tpl similarity index 75% rename from support/templates/scaffold/pkg/graphql/config.yml.tpl rename to cmd/templates/scaffold/pkg/graphql/config.yml.tpl index 5c388f5d..20a84a8c 100644 --- a/support/templates/scaffold/pkg/graphql/config.yml.tpl +++ b/cmd/templates/scaffold/pkg/graphql/config.yml.tpl @@ -11,5 +11,7 @@ model: filename: pkg/graphql/model/models_gen.go resolver: - filename: pkg/graphql/graphql.go - type: ResolverRoot + layout: follow-schema + dir: pkg/graphql/resolver + package: resolver + type: Root diff --git a/support/templates/scaffold/pkg/graphql/generated/generated.go.tpl b/cmd/templates/scaffold/pkg/graphql/generated/generated.go.tpl similarity index 100% rename from support/templates/scaffold/pkg/graphql/generated/generated.go.tpl rename to cmd/templates/scaffold/pkg/graphql/generated/generated.go.tpl diff --git a/support/templates/scaffold/pkg/graphql/graphql.go.tpl b/cmd/templates/scaffold/pkg/graphql/graphql.go.tpl similarity index 100% rename from support/templates/scaffold/pkg/graphql/graphql.go.tpl rename to cmd/templates/scaffold/pkg/graphql/graphql.go.tpl diff --git a/support/templates/scaffold/pkg/graphql/model/models_gen.go.tpl b/cmd/templates/scaffold/pkg/graphql/model/models_gen.go.tpl similarity index 100% rename from support/templates/scaffold/pkg/graphql/model/models_gen.go.tpl rename to cmd/templates/scaffold/pkg/graphql/model/models_gen.go.tpl diff --git a/cmd/templates/scaffold/pkg/graphql/resolver/mutation.resolvers.go.tpl b/cmd/templates/scaffold/pkg/graphql/resolver/mutation.resolvers.go.tpl new file mode 100644 index 00000000..ba3b007a --- /dev/null +++ b/cmd/templates/scaffold/pkg/graphql/resolver/mutation.resolvers.go.tpl @@ -0,0 +1,20 @@ +package resolver + +// This file will be automatically regenerated based on the schema, any resolver implementations +// will be copied through when generating and any unknown code will be moved to the end. + +import ( + "{{.projectName}}/pkg/graphql/generated" + "{{.projectName}}/pkg/graphql/model" + "context" +) + +// AddTodo adds a new todo. +func (r *mutationRoot) AddTodo(c context.Context, description, username string) (*model.Todo, error) { + panic("not implemented") +} + +// Mutation returns generated.MutationResolver implementation. +func (r *Root) Mutation() generated.MutationResolver { return &mutationRoot{r} } + +type mutationRoot struct{ *Root } diff --git a/cmd/templates/scaffold/pkg/graphql/resolver/query.resolvers.go.tpl b/cmd/templates/scaffold/pkg/graphql/resolver/query.resolvers.go.tpl new file mode 100644 index 00000000..9fd5cdd5 --- /dev/null +++ b/cmd/templates/scaffold/pkg/graphql/resolver/query.resolvers.go.tpl @@ -0,0 +1,20 @@ +package resolver + +// This file will be automatically regenerated based on the schema, any resolver implementations +// will be copied through when generating and any unknown code will be moved to the end. + +import ( + "{{.projectName}}/pkg/graphql/generated" + "{{.projectName}}/pkg/graphql/model" + "context" +) + +// Todos returns all the todos. +func (r *queryRoot) Todos(c context.Context) ([]*model.Todo, error) { + panic("not implemented") +} + +// Query returns generated.QueryResolver implementation. +func (r *Root) Query() generated.QueryResolver { return &queryRoot{r} } + +type queryRoot struct{ *Root } diff --git a/cmd/templates/scaffold/pkg/graphql/resolver/resolver.go.tpl b/cmd/templates/scaffold/pkg/graphql/resolver/resolver.go.tpl new file mode 100644 index 00000000..6f47214a --- /dev/null +++ b/cmd/templates/scaffold/pkg/graphql/resolver/resolver.go.tpl @@ -0,0 +1,4 @@ +package resolver + +// Root is the entry for GraphQL resolving. +type Root struct{} diff --git a/cmd/templates/scaffold/pkg/graphql/resolver/subscription.resolvers.go.tpl b/cmd/templates/scaffold/pkg/graphql/resolver/subscription.resolvers.go.tpl new file mode 100644 index 00000000..0971fb42 --- /dev/null +++ b/cmd/templates/scaffold/pkg/graphql/resolver/subscription.resolvers.go.tpl @@ -0,0 +1,20 @@ +package resolver + +// This file will be automatically regenerated based on the schema, any resolver implementations +// will be copied through when generating and any unknown code will be moved to the end. + +import ( + "{{.projectName}}/pkg/graphql/generated" + "{{.projectName}}/pkg/graphql/model" + "context" +) + +// TodoAdded broadcast the message when a new todo is added. +func (r *subscriptionRoot) TodoAdded(c context.Context, channel string) (<-chan *model.Todo, error) { + panic("not implemented") +} + +// Subscription returns generated.SubscriptionResolver implementation. +func (r *Root) Subscription() generated.SubscriptionResolver { return &subscriptionRoot{r} } + +type subscriptionRoot struct{ *Root } diff --git a/support/templates/scaffold/pkg/graphql/schema/mutation.gql.tpl b/cmd/templates/scaffold/pkg/graphql/schema/mutation.gql.tpl similarity index 100% rename from support/templates/scaffold/pkg/graphql/schema/mutation.gql.tpl rename to cmd/templates/scaffold/pkg/graphql/schema/mutation.gql.tpl diff --git a/support/templates/scaffold/pkg/graphql/schema/query.gql.tpl b/cmd/templates/scaffold/pkg/graphql/schema/query.gql.tpl similarity index 100% rename from support/templates/scaffold/pkg/graphql/schema/query.gql.tpl rename to cmd/templates/scaffold/pkg/graphql/schema/query.gql.tpl diff --git a/support/templates/scaffold/pkg/graphql/schema/scalar.gql.tpl b/cmd/templates/scaffold/pkg/graphql/schema/scalar.gql.tpl similarity index 100% rename from support/templates/scaffold/pkg/graphql/schema/scalar.gql.tpl rename to cmd/templates/scaffold/pkg/graphql/schema/scalar.gql.tpl diff --git a/support/templates/scaffold/pkg/graphql/schema/subscription.gql.tpl b/cmd/templates/scaffold/pkg/graphql/schema/subscription.gql.tpl similarity index 100% rename from support/templates/scaffold/pkg/graphql/schema/subscription.gql.tpl rename to cmd/templates/scaffold/pkg/graphql/schema/subscription.gql.tpl diff --git a/support/templates/scaffold/pkg/graphql/schema/type.gql.tpl b/cmd/templates/scaffold/pkg/graphql/schema/type.gql.tpl similarity index 100% rename from support/templates/scaffold/pkg/graphql/schema/type.gql.tpl rename to cmd/templates/scaffold/pkg/graphql/schema/type.gql.tpl diff --git a/support/templates/scaffold/pkg/handler/handler.go.tpl b/cmd/templates/scaffold/pkg/handler/handler.go.tpl similarity index 100% rename from support/templates/scaffold/pkg/handler/handler.go.tpl rename to cmd/templates/scaffold/pkg/handler/handler.go.tpl diff --git a/support/templates/scaffold/pkg/handler/middleware/example.go.tpl b/cmd/templates/scaffold/pkg/handler/middleware/example.go.tpl similarity index 100% rename from support/templates/scaffold/pkg/handler/middleware/example.go.tpl rename to cmd/templates/scaffold/pkg/handler/middleware/example.go.tpl diff --git a/support/templates/scaffold/pkg/handler/middleware/example_test.go.tpl b/cmd/templates/scaffold/pkg/handler/middleware/example_test.go.tpl similarity index 100% rename from support/templates/scaffold/pkg/handler/middleware/example_test.go.tpl rename to cmd/templates/scaffold/pkg/handler/middleware/example_test.go.tpl diff --git a/support/templates/scaffold/pkg/handler/welcome.go.tpl b/cmd/templates/scaffold/pkg/handler/welcome.go.tpl similarity index 100% rename from support/templates/scaffold/pkg/handler/welcome.go.tpl rename to cmd/templates/scaffold/pkg/handler/welcome.go.tpl diff --git a/support/templates/scaffold/pkg/job/job.go.tpl b/cmd/templates/scaffold/pkg/job/job.go.tpl similarity index 100% rename from support/templates/scaffold/pkg/job/job.go.tpl rename to cmd/templates/scaffold/pkg/job/job.go.tpl diff --git a/support/templates/scaffold/pkg/job/middleware/example.go.tpl b/cmd/templates/scaffold/pkg/job/middleware/example.go.tpl similarity index 100% rename from support/templates/scaffold/pkg/job/middleware/example.go.tpl rename to cmd/templates/scaffold/pkg/job/middleware/example.go.tpl diff --git a/support/templates/scaffold/pkg/job/middleware/example_test.go.tpl b/cmd/templates/scaffold/pkg/job/middleware/example_test.go.tpl similarity index 100% rename from support/templates/scaffold/pkg/job/middleware/example_test.go.tpl rename to cmd/templates/scaffold/pkg/job/middleware/example_test.go.tpl diff --git a/support/templates/scaffold/pkg/locales/en.yml.tpl b/cmd/templates/scaffold/pkg/locales/en.yml.tpl similarity index 100% rename from support/templates/scaffold/pkg/locales/en.yml.tpl rename to cmd/templates/scaffold/pkg/locales/en.yml.tpl diff --git a/support/templates/scaffold/pkg/locales/zh-CN.yml.tpl b/cmd/templates/scaffold/pkg/locales/zh-CN.yml.tpl similarity index 100% rename from support/templates/scaffold/pkg/locales/zh-CN.yml.tpl rename to cmd/templates/scaffold/pkg/locales/zh-CN.yml.tpl diff --git a/support/templates/scaffold/pkg/locales/zh-TW.yml.tpl b/cmd/templates/scaffold/pkg/locales/zh-TW.yml.tpl similarity index 100% rename from support/templates/scaffold/pkg/locales/zh-TW.yml.tpl rename to cmd/templates/scaffold/pkg/locales/zh-TW.yml.tpl diff --git a/support/templates/scaffold/pkg/mailer/mailer.go.tpl b/cmd/templates/scaffold/pkg/mailer/mailer.go.tpl similarity index 100% rename from support/templates/scaffold/pkg/mailer/mailer.go.tpl rename to cmd/templates/scaffold/pkg/mailer/mailer.go.tpl diff --git a/support/templates/scaffold/pkg/mailer/welcome.go.tpl b/cmd/templates/scaffold/pkg/mailer/welcome.go.tpl similarity index 100% rename from support/templates/scaffold/pkg/mailer/welcome.go.tpl rename to cmd/templates/scaffold/pkg/mailer/welcome.go.tpl diff --git a/support/templates/scaffold/pkg/model/.gitkeep.tpl b/cmd/templates/scaffold/pkg/model/.gitkeep.tpl similarity index 100% rename from support/templates/scaffold/pkg/model/.gitkeep.tpl rename to cmd/templates/scaffold/pkg/model/.gitkeep.tpl diff --git a/support/templates/scaffold/pkg/viewhelper/viewhelper.go.tpl b/cmd/templates/scaffold/pkg/viewhelper/viewhelper.go.tpl similarity index 100% rename from support/templates/scaffold/pkg/viewhelper/viewhelper.go.tpl rename to cmd/templates/scaffold/pkg/viewhelper/viewhelper.go.tpl diff --git a/support/templates/scaffold/pkg/views/layouts/application.html.tpl b/cmd/templates/scaffold/pkg/views/layouts/application.html.tpl similarity index 100% rename from support/templates/scaffold/pkg/views/layouts/application.html.tpl rename to cmd/templates/scaffold/pkg/views/layouts/application.html.tpl diff --git a/support/templates/scaffold/pkg/views/layouts/mailer.html.tpl b/cmd/templates/scaffold/pkg/views/layouts/mailer.html.tpl similarity index 100% rename from support/templates/scaffold/pkg/views/layouts/mailer.html.tpl rename to cmd/templates/scaffold/pkg/views/layouts/mailer.html.tpl diff --git a/support/templates/scaffold/pkg/views/layouts/mailer.txt.tpl b/cmd/templates/scaffold/pkg/views/layouts/mailer.txt.tpl similarity index 100% rename from support/templates/scaffold/pkg/views/layouts/mailer.txt.tpl rename to cmd/templates/scaffold/pkg/views/layouts/mailer.txt.tpl diff --git a/support/templates/scaffold/pkg/views/mailers/welcome.html.tpl b/cmd/templates/scaffold/pkg/views/mailers/welcome.html.tpl similarity index 100% rename from support/templates/scaffold/pkg/views/mailers/welcome.html.tpl rename to cmd/templates/scaffold/pkg/views/mailers/welcome.html.tpl diff --git a/support/templates/scaffold/pkg/views/mailers/welcome.txt.tpl b/cmd/templates/scaffold/pkg/views/mailers/welcome.txt.tpl similarity index 100% rename from support/templates/scaffold/pkg/views/mailers/welcome.txt.tpl rename to cmd/templates/scaffold/pkg/views/mailers/welcome.txt.tpl diff --git a/support/templates/scaffold/pkg/views/welcome/index.html.tpl b/cmd/templates/scaffold/pkg/views/welcome/index.html.tpl similarity index 100% rename from support/templates/scaffold/pkg/views/welcome/index.html.tpl rename to cmd/templates/scaffold/pkg/views/welcome/index.html.tpl diff --git a/support/templates/scaffold/postcss.config.js.tpl b/cmd/templates/scaffold/postcss.config.js.tpl similarity index 100% rename from support/templates/scaffold/postcss.config.js.tpl rename to cmd/templates/scaffold/postcss.config.js.tpl diff --git a/support/templates/scaffold/svelte.config.js.tpl b/cmd/templates/scaffold/svelte.config.js.tpl similarity index 100% rename from support/templates/scaffold/svelte.config.js.tpl rename to cmd/templates/scaffold/svelte.config.js.tpl diff --git a/support/templates/scaffold/tsconfig.json.tpl b/cmd/templates/scaffold/tsconfig.json.tpl similarity index 76% rename from support/templates/scaffold/tsconfig.json.tpl rename to cmd/templates/scaffold/tsconfig.json.tpl index c85d77de..42e5a81f 100644 --- a/support/templates/scaffold/tsconfig.json.tpl +++ b/cmd/templates/scaffold/tsconfig.json.tpl @@ -2,6 +2,7 @@ "compilerOptions": { "allowSyntheticDefaultImports": true, "baseUrl": "web/src", + "declaration": true, "emitDecoratorMetadata": true, "esModuleInterop": true, "experimentalDecorators": true, @@ -22,13 +23,11 @@ "strictPropertyInitialization": true, "strictNullChecks": true, "target": "esnext", - "types": ["jest", "node", "@pyoner/svelte-types"], - "typeRoots": ["node_modules/@types", "web/src/typings"], + "types": ["jest", "node", "svelte"], "paths": { - "@assets": ["../../assets"], - "@": ["*"] + "@assets/*": ["../../assets/*"], + "@/*": ["*"] } }, - "exclude": ["node_modules"], - "include": ["web/src/**/*"] + "exclude": ["node_modules"] } diff --git a/support/templates/scaffold/web/public/favicon.ico.tpl b/cmd/templates/scaffold/web/public/favicon.ico.tpl similarity index 100% rename from support/templates/scaffold/web/public/favicon.ico.tpl rename to cmd/templates/scaffold/web/public/favicon.ico.tpl diff --git a/support/templates/scaffold/web/public/index.html.tpl b/cmd/templates/scaffold/web/public/index.html.tpl similarity index 100% rename from support/templates/scaffold/web/public/index.html.tpl rename to cmd/templates/scaffold/web/public/index.html.tpl diff --git a/support/templates/scaffold/web/public/brand.png.tpl b/cmd/templates/scaffold/web/public/logo.png.tpl similarity index 100% rename from support/templates/scaffold/web/public/brand.png.tpl rename to cmd/templates/scaffold/web/public/logo.png.tpl diff --git a/support/templates/scaffold/web/public/robots.txt.tpl b/cmd/templates/scaffold/web/public/robots.txt.tpl similarity index 100% rename from support/templates/scaffold/web/public/robots.txt.tpl rename to cmd/templates/scaffold/web/public/robots.txt.tpl diff --git a/support/templates/scaffold/web/src/components/App.svelte.spec.ts.tpl b/cmd/templates/scaffold/web/src/components/App.svelte.spec.ts.tpl similarity index 100% rename from support/templates/scaffold/web/src/components/App.svelte.spec.ts.tpl rename to cmd/templates/scaffold/web/src/components/App.svelte.spec.ts.tpl diff --git a/support/templates/scaffold/web/src/components/App.svelte.tpl b/cmd/templates/scaffold/web/src/components/App.svelte.tpl similarity index 100% rename from support/templates/scaffold/web/src/components/App.svelte.tpl rename to cmd/templates/scaffold/web/src/components/App.svelte.tpl diff --git a/cmd/templates/scaffold/web/src/index.d.ts.tpl b/cmd/templates/scaffold/web/src/index.d.ts.tpl new file mode 100644 index 00000000..b03740c3 --- /dev/null +++ b/cmd/templates/scaffold/web/src/index.d.ts.tpl @@ -0,0 +1,29 @@ +declare module "*.gif" { + const src: string; + export default src; +} + +declare module "*.jpg" { + const src: string; + export default src; +} + +declare module "*.jpeg" { + const src: string; + export default src; +} + +declare module "*.png" { + const src: string; + export default src; +} + +declare module "*.webp" { + const src: string; + export default src; +} + +declare module "*.svg" { + const src: string; + export default src; +} diff --git a/support/templates/scaffold/web/src/initI18n.ts.tpl b/cmd/templates/scaffold/web/src/initI18n.ts.tpl similarity index 100% rename from support/templates/scaffold/web/src/initI18n.ts.tpl rename to cmd/templates/scaffold/web/src/initI18n.ts.tpl diff --git a/support/templates/scaffold/web/src/initServiceWorker.ts.tpl b/cmd/templates/scaffold/web/src/initServiceWorker.ts.tpl similarity index 100% rename from support/templates/scaffold/web/src/initServiceWorker.ts.tpl rename to cmd/templates/scaffold/web/src/initServiceWorker.ts.tpl diff --git a/support/templates/scaffold/web/src/locales/en.json.tpl b/cmd/templates/scaffold/web/src/locales/en.json.tpl similarity index 100% rename from support/templates/scaffold/web/src/locales/en.json.tpl rename to cmd/templates/scaffold/web/src/locales/en.json.tpl diff --git a/support/templates/scaffold/web/src/locales/zh-CN.json.tpl b/cmd/templates/scaffold/web/src/locales/zh-CN.json.tpl similarity index 100% rename from support/templates/scaffold/web/src/locales/zh-CN.json.tpl rename to cmd/templates/scaffold/web/src/locales/zh-CN.json.tpl diff --git a/support/templates/scaffold/web/src/locales/zh-TW.json.tpl b/cmd/templates/scaffold/web/src/locales/zh-TW.json.tpl similarity index 100% rename from support/templates/scaffold/web/src/locales/zh-TW.json.tpl rename to cmd/templates/scaffold/web/src/locales/zh-TW.json.tpl diff --git a/support/templates/scaffold/web/src/main.ts.tpl b/cmd/templates/scaffold/web/src/main.ts.tpl similarity index 100% rename from support/templates/scaffold/web/src/main.ts.tpl rename to cmd/templates/scaffold/web/src/main.ts.tpl diff --git a/support/templates/scaffold/web/src/pages/Home.svelte.spec.ts.tpl b/cmd/templates/scaffold/web/src/pages/Home.svelte.spec.ts.tpl similarity index 100% rename from support/templates/scaffold/web/src/pages/Home.svelte.spec.ts.tpl rename to cmd/templates/scaffold/web/src/pages/Home.svelte.spec.ts.tpl diff --git a/support/templates/scaffold/web/src/pages/Home.svelte.tpl b/cmd/templates/scaffold/web/src/pages/Home.svelte.tpl similarity index 100% rename from support/templates/scaffold/web/src/pages/Home.svelte.tpl rename to cmd/templates/scaffold/web/src/pages/Home.svelte.tpl diff --git a/support/templates/scaffold/web/src/stores/index.ts.tpl b/cmd/templates/scaffold/web/src/stores/index.ts.tpl similarity index 100% rename from support/templates/scaffold/web/src/stores/index.ts.tpl rename to cmd/templates/scaffold/web/src/stores/index.ts.tpl diff --git a/support/templates/scaffold/web/src/typings/.gitkeep.tpl b/cmd/templates/scaffold/web/src/typings/.gitkeep.tpl similarity index 100% rename from support/templates/scaffold/web/src/typings/.gitkeep.tpl rename to cmd/templates/scaffold/web/src/typings/.gitkeep.tpl diff --git a/support/templates/scaffold/web/tests/e2e/codecept.conf.js.tpl b/cmd/templates/scaffold/web/tests/e2e/codecept.conf.js.tpl similarity index 100% rename from support/templates/scaffold/web/tests/e2e/codecept.conf.js.tpl rename to cmd/templates/scaffold/web/tests/e2e/codecept.conf.js.tpl diff --git a/support/templates/scaffold/web/tests/e2e/features/welcome.feature.tpl b/cmd/templates/scaffold/web/tests/e2e/features/welcome.feature.tpl similarity index 100% rename from support/templates/scaffold/web/tests/e2e/features/welcome.feature.tpl rename to cmd/templates/scaffold/web/tests/e2e/features/welcome.feature.tpl diff --git a/support/templates/scaffold/web/tests/e2e/step_definitions/welcome.js.tpl b/cmd/templates/scaffold/web/tests/e2e/step_definitions/welcome.js.tpl similarity index 100% rename from support/templates/scaffold/web/tests/e2e/step_definitions/welcome.js.tpl rename to cmd/templates/scaffold/web/tests/e2e/step_definitions/welcome.js.tpl diff --git a/support/templates/scaffold/web/tests/e2e/steps.js.tpl b/cmd/templates/scaffold/web/tests/e2e/steps.js.tpl similarity index 100% rename from support/templates/scaffold/web/tests/e2e/steps.js.tpl rename to cmd/templates/scaffold/web/tests/e2e/steps.js.tpl diff --git a/support/templates/scaffold/web/tests/unit/setup.js.tpl b/cmd/templates/scaffold/web/tests/unit/setup.js.tpl similarity index 100% rename from support/templates/scaffold/web/tests/unit/setup.js.tpl rename to cmd/templates/scaffold/web/tests/unit/setup.js.tpl diff --git a/support/templates/scaffold/webpack.config.js.tpl b/cmd/templates/scaffold/webpack.config.js.tpl similarity index 100% rename from support/templates/scaffold/webpack.config.js.tpl rename to cmd/templates/scaffold/webpack.config.js.tpl diff --git a/go.mod b/go.mod index 60a5f31e..4a0b2b77 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.14 require ( github.com/99designs/gqlgen v0.11.3 + github.com/AlecAivazis/survey/v2 v2.0.7 github.com/BurntSushi/toml v0.3.1 github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect github.com/CloudyKit/jet v2.1.2+incompatible @@ -43,7 +44,7 @@ require ( github.com/onsi/ginkgo v1.12.0 // indirect github.com/onsi/gomega v1.9.0 // indirect github.com/otiai10/copy v1.2.0 - github.com/pkg/errors v0.9.1 + github.com/pkg/errors v0.9.1 // indirect github.com/radovskyb/watcher v1.0.7 github.com/shirou/gopsutil v2.20.5+incompatible github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd diff --git a/go.sum b/go.sum index 825f4a98..6c61f281 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/99designs/gqlgen v0.11.3 h1:oFSxl1DFS9X///uHV3y6CEfpcXWrDUxVblR4Xib2bs4= github.com/99designs/gqlgen v0.11.3/go.mod h1:RgX5GRRdDWNkh4pBrdzNpNPFVsdoUFY2+adM6nb1N+4= +github.com/AlecAivazis/survey/v2 v2.0.7 h1:+f825XHLse/hWd2tE/V5df04WFGimk34Eyg/z35w/rc= +github.com/AlecAivazis/survey/v2 v2.0.7/go.mod h1:mlizQTaPjnR4jcpwRSaSlkbsRfYFEyKgLQvYTzxxiHA= github.com/BurntSushi/toml v0.3.0/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -9,6 +11,8 @@ github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3 github.com/CloudyKit/jet v2.1.2+incompatible h1:ybZoYzMBdoijK6I+Ke3vg9GZsmlKo/ZhKdNMWz0P26c= github.com/CloudyKit/jet v2.1.2+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8 h1:xzYJEypr/85nBpB11F9br+3HUrpgb+fcm5iADzXXYEw= +github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8/go.mod h1:oX5x61PbNXchhh0oikYAH+4Pcfw5LKv21+Jnpr6r6Pc= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= @@ -151,6 +155,8 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hibiken/asynq v0.9.4 h1:lxd3LaDihcaq/NiyzQi5zqPDphjMk3zfxmtWOLOe1ww= github.com/hibiken/asynq v0.9.4/go.mod h1:T2LLFy2NDRH0yniH/62wKygCrAKuaO4dHyOFYGmSdJY= +github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174 h1:WlZsjVhE8Af9IcZDGgJGQpNflI3+MJSBhsgT5PCtzBQ= +github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= @@ -166,6 +172,8 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kidstuff/mongostore v0.0.0-20181113001930-e650cd85ee4b/go.mod h1:g2nVr8KZVXJSS97Jo8pJ0jgq29P6H7dG0oplUA86MQw= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -175,6 +183,8 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.4 h1:5Myjjh3JY/NaAi4IsUbHADytDyl1VE1Y9PXDlL+P/VQ= +github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= @@ -192,6 +202,8 @@ github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czP github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM= github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= @@ -204,6 +216,8 @@ github.com/mattn/go-sqlite3 v1.9.0 h1:pDRiWfl+++eC2FEFRy6jXmQlvp4Yh3z1MJKg4UeYM/ github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/memcachier/mc v2.0.1+incompatible/go.mod h1:7bkvFE61leUBvXz+yxsOnGBQSZpBSPIMUQSmmSHvuXc= +github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= +github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= @@ -332,6 +346,8 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190506204251-e1dfcc566284/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= @@ -369,6 +385,7 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190530182044-ad28b68e88f1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/support/scaffold_test.go b/support/scaffold_test.go deleted file mode 100644 index 0358f5d1..00000000 --- a/support/scaffold_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package support - -import ( - "io/ioutil" - "os" - "testing" - - "github.com/appist/appy/test" -) - -type scaffoldSuite struct { - test.Suite -} - -func (s *scaffoldSuite) TestScaffold() { - scaffoldPath := "./tmp/scaffold" - - err := os.RemoveAll(scaffoldPath) - s.Nil(err) - - err = os.MkdirAll(scaffoldPath, 0777) - s.Nil(err) - - err = os.Chdir(scaffoldPath) - s.Nil(err) - - err = ioutil.WriteFile("go.mod", []byte("module appist"), 0777) - s.Nil(err) - - opts := ScaffoldOption{ - DBAdapter: "foobar", - Description: "scaffold test", - } - err = Scaffold(opts) - s.EqualError(err, "DBAdapter 'foobar' is not supported, only '[mysql postgres]' are supported") - - opts = ScaffoldOption{ - Description: "scaffold test", - } - err = Scaffold(opts) - s.Nil(err) -} - -func TestScaffoldSuite(t *testing.T) { - test.Run(t, new(scaffoldSuite)) -} diff --git a/support/templates/scaffold/babel.config.json.tpl b/support/templates/scaffold/babel.config.json.tpl deleted file mode 100644 index f0e12674..00000000 --- a/support/templates/scaffold/babel.config.json.tpl +++ /dev/null @@ -1,15 +0,0 @@ -{ - "compact": false, - "plugins": ["@babel/plugin-syntax-dynamic-import"], - "presets": [ - [ - "@babel/preset-env", - { - "targets": { - "node": "current" - } - } - ], - "@babel/preset-typescript" - ] -} diff --git a/support/templates/scaffold/jest.config.js.tpl b/support/templates/scaffold/jest.config.js.tpl deleted file mode 100644 index e9395c97..00000000 --- a/support/templates/scaffold/jest.config.js.tpl +++ /dev/null @@ -1,27 +0,0 @@ -module.exports = { - collectCoverage: true, - coverageDirectory: "tmp/coverage/web", - globals: { - "ts-jest": { - diagnostics: false, - }, - }, - transform: { - ".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$": "jest-transform-stub", - "^.+\\.m?jsx?$": "babel-jest", - "^.+\\.tsx?$": "ts-jest", - "^.+\\.svelte$": [ - "svelte-jester", - { - preprocess: true, - }, - ], - }, - moduleFileExtensions: ["js", "jsx", "json", "svelte", "ts", "tsx", "mjs"], - moduleNameMapper: { - "^@assets/(.*)$": "/assets/$1", - "^@/(.*)$": "/web/src/$1", - }, - setupFiles: ["/web/tests/unit/setup.js"], - setupFilesAfterEnv: ["@testing-library/jest-dom/extend-expect"], -}; diff --git a/support/templates/scaffold/package.json.tpl b/support/templates/scaffold/package.json.tpl deleted file mode 100644 index 6dca317a..00000000 --- a/support/templates/scaffold/package.json.tpl +++ /dev/null @@ -1,53 +0,0 @@ -{ - "name": "{{.projectName}}", - "description": "{{.projectDesc}}", - "main": "web/src/main.ts", - "scripts": { - "build": "NODE_ENV=production npx webpack --mode=production --progress", - "format": "npx prettier --write '**/*.{css,mjs,js,json,less,md,pug,sass,scss,svelte,ts,tsx,yml,yaml}'", - "start": "NODE_ENV=development npx webpack-dev-server --mode=development", - "test": "npx jest web/src", - "test:e2e": "npx codeceptjs run-multiple default --steps --config=web/tests/e2e/codecept.conf.js" - }, - "license": "UNLICENSED", - "dependencies": { - "page": "^1.11.6", - "register-service-worker": "^1.7.1", - "svelte": "^3.23.0", - "svelte-i18n": "^3.0.3" - }, - "devDependencies": { - "@appist/webpack-preset-appy": "^0.1.1", - "@pyoner/svelte-types": "^3.4.4-2", - "@types/jest": "^25.2.3", - "@types/node": "^14.0.11", - "husky": "^4.2.5", - "lint-staged": "^10.2.9", - "typescript": "^3.9.5", - "webpack-cli": "^3.3.11" - }, - "husky": { - "hooks": { - "pre-commit": [ - "lint-staged" - ] - } - }, - "lint-staged": { - "**/*.{css,mjs,js,json,less,md,pug,sass,scss,svelte,ts,tsx,yml,yaml}": "npx prettier --write", - "**/*.go": "make codecheck" - }, - "pwa": { - "appleStatusBarStyle": "black-translucent", - "background": "#ffffff", - "developerName": "", - "developerURL": "", - "display": "standalone", - "dir": "auto", - "lang": "en-US", - "orientation": "any", - "scope": "/", - "start_url": "./index.html", - "theme_color": "" - } -} diff --git a/support/templates/scaffold/pkg/graphql/resolver/resolver.go.tpl b/support/templates/scaffold/pkg/graphql/resolver/resolver.go.tpl deleted file mode 100644 index c7c88bfc..00000000 --- a/support/templates/scaffold/pkg/graphql/resolver/resolver.go.tpl +++ /dev/null @@ -1,49 +0,0 @@ -package resolver - -import ( - "{{.projectName}}/pkg/graphql/generated" - "{{.projectName}}/pkg/graphql/model" - "context" -) - -// Root is the entry for GraphQL resolving. -type Root struct{} - -// Mutation defines the GraphQL mutations in `pkg/graphql/resolver/mutation`. -func (r *Root) Mutation() generated.MutationResolver { - return &Mutation{r} -} - -// Query defines the GraphQL queries in `pkg/graphql/resolver/query`. -func (r *Root) Query() generated.QueryResolver { - return &Query{r} -} - -// Subscription defines the GraphQL queries in `pkg/graphql/resolver/subscription`. -func (r *Root) Subscription() generated.SubscriptionResolver { - return &Subscription{r} -} - -// Mutation is the entry for all GraphQL mutations. -type Mutation struct{ *Root } - -// AddTodo adds a new todo. -func (r *Mutation) AddTodo(c context.Context, description, username string) (*model.Todo, error) { - panic("not implemented") -} - -// Query is the entry for all GraphQL queries. -type Query struct{ *Root } - -// Todos returns all the todos. -func (r *Query) Todos(c context.Context) ([]*model.Todo, error) { - panic("not implemented") -} - -// Subscription is the entry for all GraphQL subscriptions. -type Subscription struct{ *Root } - -// TodoAdded broadcast the message when a new todo is added. -func (r *Subscription) TodoAdded(c context.Context, channel string) (<-chan *model.Todo, error) { - panic("not implemented") -} diff --git a/support/templates/scaffold/prettier.config.js.tpl b/support/templates/scaffold/prettier.config.js.tpl deleted file mode 100644 index 6caa2d9e..00000000 --- a/support/templates/scaffold/prettier.config.js.tpl +++ /dev/null @@ -1,19 +0,0 @@ -module.exports = { - arrowParens: "avoid", - bracketSpacing: true, - cursorOffset: -1, - endOfLine: "auto", - htmlWhitespaceSensitivity: "css", - insertPragma: false, - jsxBracketSameLine: false, - jsxSingleQuote: false, - printWidth: 100, - proseWrap: "preserve", - quoteProps: "as-needed", - requirePragma: false, - semi: true, - singleQuote: false, - tabWidth: 2, - trailingComma: "es5", - useTabs: false, -};