diff --git a/.dockerignore b/.dockerignore index 1c1b74334..22385ea5f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,3 +5,4 @@ README.md .gitignore .git example/ +tmp/ diff --git a/Dockerfile b/Dockerfile index e7f5a2c54..b6c6387da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ ENV GOLANG_PROTOBUF_VERSION=1.3.1 ENV GRPC_GATEWAY_VERSION=1.11.3 ENV GRPC_WEB_VERSION=1.0.6 ENV PROTOBUF_VERSION=3.6.1 -ENV TERRAFORM_VERSION=0.12.12 +ENV TERRAFORM_VERSION=0.12.13 ENV K8S_VERSION=1.14.8 RUN apk add --update --no-cache build-base curl git upx && \ diff --git a/README.md b/README.md index 94ef2fd0d..75fc37733 100644 --- a/README.md +++ b/README.md @@ -123,3 +123,26 @@ In order to use this you need ensure you have these installed. * protoc-gen-swagger [Swagger] +### Commit0 Demo +- clone the repo +- run `make build-docker-local` +- add an alias `alias commit0='docker run -it -v "$(pwd):/project" -v "${HOME}/.aws:/root/.aws" commit0:v0'` +- remember to also add this alias to your bash profile if you want it to persist when you open a new terminal +- create a temporary directory `mkdir tmp; cd tmp` +- create the project `commit0 create beier-demo` +- when prompted, select `Amazon AWS`, `us-west-2`, and your commit AWS profile +- `cd beier-demo` +- generate the codebase `commit0 generate --apply` +- go to the react repo `cd react` +- push to the prepped Github Repo. This repo already has AWS credentials loaded in Github Secrets +``` +git init +git add -A +git commit -m commit0 +git remote add origin git@github.com:commitdev/commit0-demo.git +git push -u origin master --force +``` +- Wait for Github Actions to finish +- View the site at http://beier-demo-staging.s3-website-us-west-2.amazonaws.com/ +- go to signup, just ensure you have a strong enough password it needs caps, symbol and numerics ex `@Testing123` +- Alternatively you can run the app locally `npm install; npm start` diff --git a/go.mod b/go.mod index a5df3a4f7..2073c39c9 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.12 require ( github.com/aws/aws-sdk-go v1.25.33 - github.com/aws/aws-sdk-go-v2 v0.16.0 github.com/chzyer/logex v1.1.10 // indirect github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect diff --git a/go.sum b/go.sum index 100b5940e..3f777d374 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,6 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5 github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/aws/aws-sdk-go v1.25.33 h1:8muvpP+Bq5e0CDkM9PDZ6tN74fVUq5v3zSCRaZ93ykM= github.com/aws/aws-sdk-go v1.25.33/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go-v2 v0.16.0 h1:X5pkFnjRNdDEX18NwDGWMaWL5ocNQX0qIYEhEcsTy64= -github.com/aws/aws-sdk-go-v2 v0.16.0/go.mod h1:pFLIN9LDjOEwHfruGweAXEq0XaD6uRkY8FsRkxhuBIg= github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= @@ -19,7 +17,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/gobuffalo/envy v1.7.0 h1:GlXgaiBkmrYMHco6t4j7SacKO4XUjvh5pwXh0f4uxXU= github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= github.com/gobuffalo/logger v1.0.0/go.mod h1:2zbswyIUa45I+c+FLXuWl9zSWEiVuthsk8ze5s8JvPs= @@ -29,8 +26,6 @@ github.com/gobuffalo/packd v0.3.0 h1:eMwymTkA1uXsqxS0Tpoop3Lc0u3kTfiMBE6nKtQU4g4 github.com/gobuffalo/packd v0.3.0/go.mod h1:zC7QkmNkYVGKPw4tHpBQ+ml7W/3tIebgeo1b36chA3Q= github.com/gobuffalo/packr/v2 v2.5.2 h1:4EvjeIpQLZuRIljwnidYgbRXbr1yIzVRrESiLjqKj6s= github.com/gobuffalo/packr/v2 v2.5.2/go.mod h1:sgEE1xNZ6G0FNN5xn9pevVu4nywaxHvgup67xisti08= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= @@ -102,8 +97,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/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/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -124,7 +117,6 @@ golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0 h1:Dh6fw+p6FyRl5x/FvNswO1j golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0 h1:Dh6fw+p6FyRl5x/FvNswO1ji0lIGzm3KP8Y9VkS9PTE= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= diff --git a/internal/generate/ci/generate.go b/internal/generate/ci/generate.go index 8c6758edf..2949559a7 100644 --- a/internal/generate/ci/generate.go +++ b/internal/generate/ci/generate.go @@ -48,7 +48,7 @@ func Generate(t *templator.CITemplator, cfg *config.Commit0Config, ciConfig conf ciFilename = ".travis.yml" ciTemp = t.TravisCI case "github": - ciConfigPath = fmt.Sprintf("%s/%s", basePath, ".github/workflow/") + ciConfigPath = fmt.Sprintf("%s/%s", basePath, ".github/workflows/") ciFilename = "config.yml" ciTemp = t.Github default: diff --git a/internal/generate/generate_helper.go b/internal/generate/generate_helper.go index ce56a8bb1..b7a263266 100644 --- a/internal/generate/generate_helper.go +++ b/internal/generate/generate_helper.go @@ -64,8 +64,12 @@ func GenerateArtifactsHelper(t *templator.Templator, cfg *config.Commit0Config, // @TODO : This strucuture probably needs to be adjusted. Probably too generic. switch cfg.Frontend.Framework { case util.React: - log.Println(aurora.Cyan(emoji.Sprintf("Creating React frontend"))) - react.Generate(t, cfg, &wg, pathPrefix) + if cfg.Infrastructure.AWS.Cognito.Enabled && cfg.Frontend.Env.CognitoPoolID != "" { + log.Println(aurora.Cyan(emoji.Sprintf("Creating React frontend"))) + react.Generate(t, cfg, &wg, pathPrefix) + } else { + log.Println(aurora.Yellow(emoji.Sprintf(":warning: Missing React environment variables, skipping generation"))) + } } } diff --git a/templates/ci/github.tmpl b/templates/ci/github.tmpl index 6baa1de4d..173e1467c 100644 --- a/templates/ci/github.tmpl +++ b/templates/ci/github.tmpl @@ -18,8 +18,6 @@ jobs: - run: npm install - - run: npm test - - run: npm run build - name: upload build artifacts diff --git a/templates/react/src/utils/selectors.js b/templates/react/src/utils/selectors.js index c0e144a6e..fa902c747 100644 --- a/templates/react/src/utils/selectors.js +++ b/templates/react/src/utils/selectors.js @@ -1,8 +1,5 @@ import React from 'react' import hoistNonReactStatic from 'hoist-non-react-statics' -import { getProp, keyBy } from './helpers' -import Interface from './Interface' -import PropTypes from 'prop-types' // ref: https://reactjs.org/docs/higher-order-components.html function withSelector(selector) { @@ -32,83 +29,7 @@ function getDisplayName(WrappedComponent) { return WrappedComponent.displayName || WrappedComponent.name || 'Component' } -const FormProgressPropDefs = { - forms: PropTypes.arrayOf( - PropTypes.shape({ - formTemplateId: PropTypes.string, - }) - ).isRequired, - formResponses: PropTypes.arrayOf( - PropTypes.shape({ - formTemplateId: PropTypes.string.isRequired, - }) - ).isRequired, - formTabs: PropTypes.arrayOf( - PropTypes.shape({ - index: PropTypes.number.isRequired, - }) - ).isRequired, -} - -class FormProgress extends Interface { - constructor(params) { - super(params, FormProgressPropDefs) - Object.assign(this, params) - // TODO rename all step => tab, too confusing - this.formResponseMap = keyBy(params.formResponses, 'formTemplateId') - this.tabIndices = this.formTabs.map(s => s.index) - } - - // returns the index of the first form in formTabs that's incomplete (memoized) - getNextIndex() { - return ( - this.nextIndex || - (this.nextIndex = this.forms.findIndex( - form => !this.formResponseMap[form.formTemplateId] - )) - ) - } - - getNextPath() { - const lastFormIndex = this.forms.length - 1 - return this.isComplete() ? lastFormIndex : this.getNextIndex() - } - - // form is complete when no more forms to fill - isComplete() { - return this.getNextIndex() < 0 - } - - // returns the index of the active step tab - getActiveTab() { - if (this.isComplete()) return this.tabIndices.length - 1 - - // find the latest step that's the form has - let activeForm = this.tabIndices - .slice() - .reverse() - .find(step => this.getNextIndex() >= step) - return this.tabIndices.findIndex(step => step === activeForm) - } - - // calculate the step progress based on the number of forms in the current step - getTabProgress() { - const nextIndex = this.getNextIndex() - if (nextIndex < 0) { - return 0 - } - const maxIndex = this.tabIndices.findIndex(tabIndex => tabIndex > nextIndex) - const max = this.tabIndices[maxIndex] - const min = this.tabIndices[maxIndex - 1] - if (maxIndex <= 0) { - return 0 - } - return Math.floor(((nextIndex - min) / (max - min)) * 100) - } -} - export default { withSelector, getDisplayName, - // getFormProgress, } diff --git a/templates/react/src/views/Dashboard.js b/templates/react/src/views/Dashboard.js index c271943f4..652f30b17 100644 --- a/templates/react/src/views/Dashboard.js +++ b/templates/react/src/views/Dashboard.js @@ -1,16 +1,10 @@ import React from 'react' -import Button from '@material-ui/core/Button' import Grid from '@material-ui/core/Grid' -import Card from '@material-ui/core/Card' -import CardActions from '@material-ui/core/CardActions' import Centered from '../components/Centered' import { Text } from '../components/Text' import SampleRestQuery from '../components/graphql/SampleRestQuery' import AppNavbar from '../components/AppNavbar' -import { to } from '../utils/router' -import Query from '../components/graphql/Query' -import Queries from '../constants/queries' function Dashboard({ location }) { return ( @@ -28,25 +22,4 @@ function Dashboard({ location }) { ) } -function Forms(data = {}) { - const { formTemplates = [] } = data - return ( - - {formTemplates.map(form => ( - - - - - - ))} - - ) -} - export default Dashboard