Skip to content

Commit

Permalink
feat: Heroku updates: (#135)
Browse files Browse the repository at this point in the history
* Heroku updates:
- Now supports
- adds procfile creation
- adds .nvmrc
- fixes typo in package.json
- updates package.json conditionals (removes server-express)
- fixes named export bug in test/helpers.ts

* Adds Procfile until Pipeline bug resolved

* bump Node version req

* remove 16.x
  • Loading branch information
mthomps4 authored May 11, 2021
1 parent e015ba2 commit f2d657c
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 30 deletions.
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");

// 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

0 comments on commit f2d657c

Please sign in to comment.