From 6af0eb7ea58edf3cc2f812237a724b807b91d3e2 Mon Sep 17 00:00:00 2001 From: Brandon Bayer Date: Sat, 25 Apr 2020 14:06:39 +0700 Subject: [PATCH] Fix Linux & Remove top level await support in console, temporarily (#231) (patch) --- packages/blitz/bin/blitz | 2 +- packages/blitz/src/bin/cli.ts | 14 +++++++++----- packages/cli/bin/run | 2 +- packages/cli/src/commands/console.ts | 7 +++++-- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/blitz/bin/blitz b/packages/blitz/bin/blitz index 885da93312..7ade3e9f11 100755 --- a/packages/blitz/bin/blitz +++ b/packages/blitz/bin/blitz @@ -1,3 +1,3 @@ -#!/usr/bin/env node --experimental-repl-await +#!/usr/bin/env node require('../dist/cli') diff --git a/packages/blitz/src/bin/cli.ts b/packages/blitz/src/bin/cli.ts index 3e95ad9918..ab6349f6f1 100755 --- a/packages/blitz/src/bin/cli.ts +++ b/packages/blitz/src/bin/cli.ts @@ -51,13 +51,17 @@ if (fs.existsSync(localCLIPkgPath)) { const cli = require(pkgPath as string) const options = require('minimist')(process.argv.slice(2)) -if (options._.length === 0 && (options.v || options.version)) { - // TODO: remove - console.log('debug:', usageType) - console.log('debug: pkgPath:', pkgPath, '\n') +const hasVersionFlag = options._.length === 0 && (options.v || options.version) +const hasVerboseFlag = options._.length === 0 && (options.V || options.verbose) + +if (hasVersionFlag) { + if (hasVerboseFlag) { + console.log('debug:', usageType) + console.log('debug: pkgPath:', pkgPath, '\n') + } try { const osName = require('os-name') - console.log(`${osName()} ${process.platform}-${process.arch} node-${process.version}\n`) + console.log(`${osName()} | ${process.platform}-${process.arch} | Node: ${process.version}\n`) let globalInstallPath let localButGlobalLinked = usageType === 'local' && fs.existsSync(globalLinkedPath) diff --git a/packages/cli/bin/run b/packages/cli/bin/run index 7af883b034..d0a3afa252 100755 --- a/packages/cli/bin/run +++ b/packages/cli/bin/run @@ -1,3 +1,3 @@ -#!/usr/bin/env node --experimental-repl-await +#!/usr/bin/env node require('@blitzjs/cli').run() diff --git a/packages/cli/src/commands/console.ts b/packages/cli/src/commands/console.ts index 3a4b5f1104..3ab1af8a9c 100644 --- a/packages/cli/src/commands/console.ts +++ b/packages/cli/src/commands/console.ts @@ -37,8 +37,11 @@ export default class Console extends Command { async run() { log.branded('You have entered the Blitz console') console.log(chalk.yellow('Tips: - Exit by typing .exit or pressing Ctrl-D')) - console.log(chalk.yellow(' - Use your db like this: await db.user.findMany()')) - console.log(chalk.yellow(' - Use your queries/mutations like this: await getUsers()')) + console.log(chalk.yellow(' - Use your db like this: db.user.findMany().then(console.log)')) + console.log(chalk.yellow(' - Use your queries/mutations like this: getUsers().then(console.log)')) + console.log( + chalk.yellow(' - Top level `await` support coming: https://github.com/blitz-js/blitz/issues/230'), + ) setupTsnode() await runPrismaGeneration({silent: true})