Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Heroku updates: #135

Merged
merged 4 commits into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
node-version: [12.x, 14.x]

steps:
- name: Checkout
Expand Down
2 changes: 2 additions & 0 deletions packages/create-bison-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ module.exports = async ({ name, ...answers }) => {
variables.host.createAppsAndPipelines,
task: async () => {
const repoName = variables.githubRepo.match(/(\w+\/\w+).git$/)[1];
// ! Bug w/ Pipelines, better error handling needed.
// await fsPromises.writeFile("Procfile", "web: yarn db:deploy && yarn start");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a follow up issue to track this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll get this added as a follow-up.


// create staging app
await execa(
Expand Down
2 changes: 1 addition & 1 deletion packages/create-bison-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"bin": "cli.js",
"engines": {
"node": ">=10"
"node": ">=12"
},
"scripts": {
"test:e2e": "start-server-and-test 'node ./scripts/createAppAndStartServer foo --acceptDefaults' 3001 'cypress run --spec cypress/integration/createBisonAppWithDefaults.test.js'",
Expand Down
1 change: 1 addition & 0 deletions packages/create-bison-app/template/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v14.6.0
1 change: 1 addition & 0 deletions packages/create-bison-app/template/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: yarn db:deploy && yarn start
7 changes: 1 addition & 6 deletions packages/create-bison-app/template/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"db:migrate": "yarn -s prisma migrate dev && yarn build:prisma",
"db:deploy": "yarn -s primsa deploy && yarn build:prisma",
"db:deploy": "yarn -s prisma migrate deploy && yarn build:prisma",
"db:reset": "yarn prisma migrate reset && yarn build:prisma",
"db:setup": "yarn db:migrate && yarn prisma generate",
"db:drop": "DOTENV_CONFIG_PATH=./prisma/.env ts-node -r dotenv/config ./scripts/dropDatabase",
Expand Down Expand Up @@ -46,12 +46,7 @@
"@chakra-ui/react": "1.3.4",
"@chakra-ui/theme": "1.7.1",
"@prisma/client": "^2.19.0",
<% if (host.name === 'vercel') { -%>
"apollo-server-micro": "^2.18.1",
<% } -%>
<% if (host.name === 'heroku') { -%>
"apollo-server-express": "^2.18.1",
<% } -%>
"bcryptjs": "^2.4.3",
"cross-fetch": "3.0.5",
"@emotion/react": "^11.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
<% if (host.name === 'heroku') { -%>
import express from 'express';
import { ApolloServer } from 'apollo-server-express'
<% } -%>
<% if (host.name === 'vercel') { -%>
import { ApolloServer } from 'apollo-server-micro';
<% } -%>

import { createContext } from '../../graphql/context';
import { schema } from '../../graphql/schema';

export const GRAPHQL_PATH = '/api/graphql';

<% if (host.name === 'heroku') { -%>
<% } -%>
<% if (host.name === 'vercel') { -%>
// this config block is REQUIRED on Vercel! It stops the body of incoming HTTP requests from being parsed
export const config = {
api: {
bodyParser: false,
},
};
<% } -%>

export const server = new ApolloServer({
schema,
Expand All @@ -30,14 +19,4 @@ export const server = new ApolloServer({
cacheControl: true,
});

<% if (host.name === 'vercel') { -%>
export default server.createHandler({ path: GRAPHQL_PATH });
<% } -%>
<% if (host.name === 'heroku') { -%>
const app = express();
server.applyMiddleware({ app });

app.listen({ port: process.env.PORT || 4000 }, () =>
console.log(`🚀 Server ready at http://localhost:4000${server.graphqlPath}`)
);
<% } -%>
2 changes: 1 addition & 1 deletion packages/create-bison-app/template/tests/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import request from 'supertest';
import { User } from '@prisma/client';
import { Client } from 'pg';

import server, { GRAPHQL_PATH } from '../pages/api/graphql';
import { server, GRAPHQL_PATH } from '../pages/api/graphql';
import { appJwtForUser } from '../services/auth';
import { prisma, connect, disconnect } from '../lib/prisma';

Expand Down