Skip to content

Commit

Permalink
fix: Better Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
William Luke committed Apr 30, 2019
1 parent 89251fa commit ec0ad23
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"node-watch": "^0.6.2",
"ora": "^3.4.0",
"parse-github-url": "^1.0.2",
"pkginfo": "^0.4.1",
"pluralize": "^7.0.0",
"prettier": "^1.17.0",
"pretty-error": "2.2.0-rc.1",
Expand Down
32 changes: 16 additions & 16 deletions src/cli/commands/build/renderers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,26 +158,26 @@ export function renderPrismaEjectFile(filePath: string, config: ConfigWithInfo)
`
}

export function renderSimpleIndexFile(filePath: string, info: ConfigWithInfo) {
export function renderSimpleIndexFile(filePath: string, config: ConfigWithInfo) {
const fileDir = path.dirname(filePath)

return `\
import * as path from 'path'
import { ApolloServer, makeSchema, express, yogaEject, middleware } from '@atto-byte/yoga'
${renderImportIf('* as types', fileDir, info.yogaConfig.resolversPath)}
${renderImportIf('context', fileDir, info.yogaConfig.contextPath)}
${renderImportIf('expressMiddleware', fileDir, info.yogaConfig.expressPath)}
${renderImportIf('graphqlMiddleware', fileDir, info.yogaConfig.graphqlMiddlewarePath)}
${renderImportIf('* as types', fileDir, config.yogaConfig.resolversPath)}
${renderImportIf('context', fileDir, config.yogaConfig.contextPath)}
${renderImportIf('expressMiddleware', fileDir, config.yogaConfig.expressPath)}
${renderImportIf('graphqlMiddleware', fileDir, config.yogaConfig.graphqlMiddlewarePath)}
export default yogaEject({
async server() {
let schema = makeSchema({
types,
outputs: {
schema: ${info.yogaConfig.output.schemaPath &&
renderPathJoin(fileDir, info.yogaConfig.output.schemaPath)},
typegen: ${info.yogaConfig.output.typegenPath &&
renderPathJoin(fileDir, info.yogaConfig.output.typegenPath)}
schema: ${config.yogaConfig.output.schemaPath &&
renderPathJoin(fileDir, config.yogaConfig.output.schemaPath)},
typegen: ${config.yogaConfig.output.typegenPath &&
renderPathJoin(fileDir, config.yogaConfig.output.typegenPath)}
},
nonNullDefaults: {
input: true,
Expand All @@ -186,17 +186,17 @@ export default yogaEject({
typegenAutoConfig: {
sources: [
${
info.yogaConfig.contextPath
config.yogaConfig.contextPath
? `{
source: ${renderPathJoin(fileDir, info.yogaConfig.contextPath)},
source: ${renderPathJoin(fileDir, config.yogaConfig.contextPath)},
alias: 'ctx',
}`
: ''
},
${
info.yogaConfig.typesPath
config.yogaConfig.typesPath
? `{
source: ${renderPathJoin(fileDir, info.yogaConfig.typesPath)},
source: ${renderPathJoin(fileDir, config.yogaConfig.typesPath)},
alias: 'types',
}`
: ''
Expand All @@ -205,14 +205,14 @@ export default yogaEject({
contextType: 'ctx.Context'
}
})
${info.yogaConfig.graphqlMiddlewarePath ? 'schema = middleware.applyMiddleware(schema, ...graphqlMiddleware)' : ''}
${config.yogaConfig.graphqlMiddlewarePath ? 'schema = middleware.applyMiddleware(schema, ...graphqlMiddleware)' : ''}
const apolloServer = new ApolloServer.ApolloServer({
schema,
${info.yogaConfig.contextPath ? 'context' : ''}
${config.yogaConfig.contextPath ? 'context' : ''}
})
const app = express()
${info.yogaConfig.expressPath ? 'await expressMiddleware({app})' : ''}
${config.yogaConfig.expressPath ? 'await expressMiddleware({app})' : ''}
apolloServer.applyMiddleware({ app, path: '/' })
return app
Expand Down
5 changes: 3 additions & 2 deletions src/yogaDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export function client(
datamodelInfo: DatamodelInfo,
): PrismaClientInput {
if (input === undefined) {
logger.warn("No Prisma Client Input found trying to resolve path")
const clientPath = requiredPath(
join(projectDir, datamodelInfo.clientPath, 'index.ts'),
`${buildError(
Expand All @@ -233,7 +234,7 @@ export function client(
'prisma deploy',
)} to generate the needed files.`,
)

logger.done(`Prisma Client Input found @ ${clientPath}`)
return importFile<PrismaClientInput>(clientPath, 'prisma', true)
}

Expand Down Expand Up @@ -285,7 +286,7 @@ function prisma(
if (input === undefined && hasPrisma) {
input = {}
}

logger.info("Prisma Found in Project")
const importedDatamodelInfo = datamodelInfo(
projectDir,
input!.datamodelInfoPath,
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"resolveJsonModule": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "es5",
Expand Down

0 comments on commit ec0ad23

Please sign in to comment.