sandcastle-testing-shailesh
v1.0.0
Published
1. `npx create-react-app appname --template typescript` 2. `yarn add @sc/api @sc/components @sc/modules @sc/plugins` 3. `yarn add -D customize-cra react-app-rewired` 4. open `package.json` and make following changes... ``` "name": "@sc/appname"
Downloads
4
Readme
Welcome to Sandcastle
How create a new app
npx create-react-app appname --template typescript
yarn add @sc/api @sc/components @sc/modules @sc/plugins
yarn add -D customize-cra react-app-rewired
open
package.json
and make following changes..."name": "@sc/appname", "scripts": { "clean": "rm -rf node_modules build", "start": "react-app-rewired start", "build": "react-app-rewired build", "test": "CI=true react-app-rewired test", "eject": "react-scripts eject" }
create a file called
config-overrides.js
and set its content toconst { override, babelInclude, addBundleVisualizer } = require('customize-cra') const path = require('path') module.exports = override( process.env.BUNDLE_VISUALIZE && addBundleVisualizer(), babelInclude([ path.resolve('./'), path.resolve('../../plugins'), path.resolve('../../platform'), ]), )
create a file called
.env
and set its content toSKIP_PREFLIGHT_CHECK=true
How to deploy
- sudo yarn production
- sudo yarn build-10mf
- (if live site build change: yarn build, zip build)
- sudo git commit -am "Production Build"
- sudo git push
- sudo yarn ssh-production
- cd sandcastle
- sudo git pull
- (if live site build changed: cd apps/livesite, sudo rm -rf build/ && sudo unzip build)
- sudo yarn restart-servers
- logout
- sudo yarn deploy-production
How to update the db schema in production
- update schema
platform/api/db/prisma/datamodel.prisma
- test locally
platform/api/db/prisma/npx prisma deploy
- if you created a new table, update this file
platform/server/data/resolvers
- Add to
Query
key - Add to
Mutation
key (createX, updateX, updateManyX, upsertX, deleteX, deleteManyX) - Add a new resolver key for the new table
- Update any resolvers to reflect new relationships
- secret is to clone a previous key as an example
- Add to
- deploy on production
How to create a white label
I. Set up cloudfront for app
- create a new distribution and point it to the sandcastle app
- connect it to your domain
- get domain from client
- ask client to point dns to cloudfront url
- create ssl for it (using amazon acm)
- connect ssl to it
II. Set up cloudfront for sites
- clone TMF distribution for _.domain.com a. point it to sandcastesites s3 b. get domain from client c. ask client to point dns to cloudfront url d. add domain to cloudfront _.domain.com e. create ssl for it (using amazon acm or set up via nginx proxy & acm upload)
- update config.js & .env files to use cloudfront id & s3 dynamically (pull from db)
How to set up this app from scratch
Prerequisites: Make sure node, yarn, redis, docker, docker-compose, and prisma are installed globally
How to install everything
- git clone http://github.com/ambid/sandcastle
- chown -R {owner} ./sandcastle
- cd sandcastle
- yarn
How to set up environment variables
- touch ./client.local.js ./env.local
- for ./env.local, populate with
SKIP_PREFLIGHT_CHECK=true
SERVER_ENDPOINT=localhost
REACT_APP_SERVER_ENDPOINT=$SERVER_ENDPOINT
DOMAINS_ENDPOINT=localhost
INTEGRATIONS_ENDPOINT=zjbdm9olm3.execute-api.us-east-1.amazonaws.com
CLOUDFRONT_DISTRIBUTION_ID=E3SM2W9RZFSO5L
REACT_APP_CLOUDFRONT_DISTRIBUTION_ID=$CLOUDFRONT_DISTRIBUTION_ID
S3_SITES_BUCKET=sandcastlesites-staging
REACT_APP_CNAME=localhost
- for ./client.local.js, populate with
import { InMemoryCache } from "apollo-cache-inmemory";
import { ApolloClient } from "apollo-client";
import { createUploadLink } from "apollo-upload-client";
import "isomorphic-fetch";
const uri = "http://localhost:4000"; // should be the url of the graphql server
export const client = new ApolloClient({
link: createUploadLink({ uri }),
cache: new InMemoryCache()
});
How to set up the prisma server from scratch...
- cd api/db/
- mv prisma xprisma
- mkdir prisma && cd prisma
- npx prisma init > Create new database | mysql | Javascript |
- sudo rm -rf ./generated && sudo mv ../xprisma/* ./
- sudo rm -rf ../xprisma
- docker-compose up -d
- npx prisma deploy
- Paste in and execute the contents of
./newAccount.graphql
How to start everything
- yarn local <- sets the .env files so that system knows to work on local resources
- yarn start-all <- starts all the servers
- yarn start <- starts the app
- yarn storybook <- starts the component storybook