Skip to content

Commit

Permalink
add better init debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Oct 7, 2019
1 parent 639c04d commit 584488e
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 47 deletions.
2 changes: 1 addition & 1 deletion cli/cli/src/getSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function getSchema(): Promise<string> {
const schemaPath = await getSchemaPath()

if (!schemaPath) {
throw new Error(`Could not find ${schemaPath}`)
throw new Error(`Could not find schema.prisma`)
}

return readFile(schemaPath, 'utf-8')
Expand Down
3 changes: 2 additions & 1 deletion cli/introspection/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "@prisma/introspection",
"version": "0.0.77",
"version": "0.0.82",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "Apache-2.0",
"devDependencies": {
"@prisma/cli": "^0.1.8",
"@prisma/lift": "^0.3.9",
"@prisma/photon": "^0.2.82",
"@types/debug": "^4.1.5",
"@types/dotenv": "^6.1.1",
"@types/figures": "^3.0.1",
"@types/fs-extra": "^7.0.0",
Expand Down
15 changes: 13 additions & 2 deletions cli/introspection/src/prompt/components/DownloadProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,24 @@ const AnySpinner = Spinner as any
export interface Props {
steps: string[]
activeIndex: number
hideSpinner?: boolean
}

const DownloadProgress: React.FC<Props> = ({ steps, activeIndex }) => (
const DownloadProgress: React.FC<Props> = ({ steps, activeIndex, hideSpinner }) => (
<Box flexDirection="column">
{steps.map((step, index) => (
<Color dim={index > activeIndex} green={index < activeIndex} key={step}>
{index < activeIndex ? '✔' : index === activeIndex ? <AnySpinner type="dots" /> : `${index + 1}`}
{index < activeIndex ? (
'✔'
) : index === activeIndex ? (
hideSpinner ? (
'...'
) : (
<AnySpinner type="dots" />
)
) : (
`${index + 1}`
)}
{' '}
{step}
{' ...'}
Expand Down
25 changes: 20 additions & 5 deletions cli/introspection/src/prompt/screens/Step60DownloadExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import { exampleScript } from '../utils/templates/script'
import { ErrorBox } from '@prisma/ink-components'
import { photonDefaultConfig } from '../utils/defaults'
import EmptyDirError from '../components/EmptyDirError'
import Debug from 'debug'
const debug = Debug('download-example')
const debugEnabled = Debug.enabled('download-example')

const readdir = promisify(fs.readdir)

Expand Down Expand Up @@ -57,9 +60,9 @@ const Step60DownloadExample: React.FC = () => {
`Extracting content to ${chalk.bold(relativePath)}`,
]

const commandsSlice = introspectionResult ? 1 : selectedExample.setupCommands.length - 1
const commandsSlice = introspectionResult ? 1 : selectedExample.setupCommands.length

const steps = [...builtInSteps, ...selectedExample.setupCommands.slice(0, 1).map(c => c.description)]
const steps = [...builtInSteps, ...selectedExample.setupCommands.map(c => c.description)]

useEffect(() => {
async function prepare() {
Expand Down Expand Up @@ -139,7 +142,12 @@ const Step60DownloadExample: React.FC = () => {
if (step) {
try {
const command = replacePrisma2Command(step.command)
await execa.shell(command, { cwd: state.outputDir, preferLocal: true })
debug(`Executing ${command}`)
await execa.shell(command, {
cwd: state.outputDir,
preferLocal: true,
stdio: !debugEnabled ? undefined : ['inherit', 'inherit', 'inherit'],
})
} catch (e) {
const error = e.stderr || e.stdout || e.message
setError(commandError + '\n' + error)
Expand All @@ -150,15 +158,22 @@ const Step60DownloadExample: React.FC = () => {
}
setActiveIndex(activeIndex + 1)
} else {
router.setRoute('success')
if (debugEnabled) {
debug('Done')
process.exit(0)
} else {
router.setRoute('success')
}
}
}
if (examples && activeIndex > 1) {
runCommand() // because https://github.com/facebook/react/issues/14326#issuecomment-441680293
}
}, [examples, activeIndex])

return (
return debugEnabled ? (
<Box>Debugging</Box>
) : (
<Box flexDirection="column">
{showEmptyDirError ? (
<EmptyDirError />
Expand Down
5 changes: 5 additions & 0 deletions cli/introspection/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,11 @@
dependencies:
"@types/node" "*"

"@types/debug@^4.1.5":
version "4.1.5"
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd"
integrity sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ==

"@types/dotenv@^6.1.1":
version "6.1.1"
resolved "https://registry.yarnpkg.com/@types/dotenv/-/dotenv-6.1.1.tgz#f7ce1cc4fe34f0a4373ba99fefa437b0bec54b46"
Expand Down
13 changes: 7 additions & 6 deletions cli/prisma2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prisma2",
"version": "2.0.0-preview-13.1",
"version": "2.0.0-alpha.229",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "git@github.com:prisma/prisma2-cli.git",
Expand All @@ -20,15 +20,16 @@
"prisma2": "build/index.js"
},
"prisma": {
"version": "14576370b55d5152d9cb90f4f509bfa56760dbbd"
"version": "ccde3e9a2cbee5442685947b6c34504b3812ef21"
},
"devDependencies": {
"@prisma/cli": "^0.1.9",
"@prisma/cli": "^0.1.10",
"@prisma/fetch-engine": "^0.1.14",
"@prisma/introspection": "0.0.78",
"@prisma/lift": "0.3.16",
"@prisma/photon": "^0.2.90",
"@prisma/introspection": "0.0.82",
"@prisma/lift": "0.3.21",
"@prisma/photon": "^0.2.94",
"@sentry/node": "5",
"@types/debug": "^4.1.5",
"@types/mocha": "^5.2.7",
"@zeit/ncc": "0.18.5",
"dotenv": "^8.0.0",
Expand Down
69 changes: 37 additions & 32 deletions cli/prisma2/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,10 @@
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==

"@prisma/cli@0.1.9", "@prisma/cli@^0.1.9":
version "0.1.9"
resolved "https://registry.yarnpkg.com/@prisma/cli/-/cli-0.1.9.tgz#ebb1fbebb2d934e71d25a7e6264db5987254fa3b"
integrity sha512-1S2TSqrL0MPgIwrVbQRssR6/y399je9ryeihHzlkp+JVkcwxJG8/AYMQ/Lo3oU9nrurCc4zNDRHaVqvr1RTJQw==
"@prisma/cli@0.1.10", "@prisma/cli@^0.1.10":
version "0.1.10"
resolved "https://registry.yarnpkg.com/@prisma/cli/-/cli-0.1.10.tgz#0dcc76a8d670333e2ed0e0552c280149b646ab6d"
integrity sha512-12BRLNEZcQ5OrNERuDhVUS98pCSx5JZ/fQLO0wcrmo9uZxoNug9eY1Em7HuHTDJhqOBHnrQ0gpJOFcGJ6FUrGQ==
dependencies:
arg "^4.1.0"
chalk "^2.4.2"
Expand Down Expand Up @@ -389,10 +389,10 @@
strip-indent "^3.0.0"
terminal-link "^2.0.0"

"@prisma/introspection@0.0.78":
version "0.0.78"
resolved "https://registry.yarnpkg.com/@prisma/introspection/-/introspection-0.0.78.tgz#2d81f5cb7665f8708919f12f41c919f1cfcf205d"
integrity sha512-OF2BKdj3Zzx5zzIODkytG5EdaJCJKP4SjcJGxfe6mc0DeG3sLGyYKoSUa5vcVZI0QXembNg3LmRmH8XGLUgrCA==
"@prisma/introspection@0.0.82":
version "0.0.82"
resolved "https://registry.yarnpkg.com/@prisma/introspection/-/introspection-0.0.82.tgz#9fa896e1240c032a37e6fc68ab850854fe9d32b4"
integrity sha512-ilSV3SwiUz1sAm0GUOIdjLiXVxVcXiYc6qkNx4aZrL0zBqg7fQbp7Deu+OFm+PQmf6wRoFQFyPkTfz21vBpvNQ==
dependencies:
"@prisma/fetch-engine" "^0.1.14"
"@prisma/ink-components" "^0.0.1"
Expand All @@ -419,15 +419,15 @@
tar "^4.4.10"
terminal-link "^2.0.0"

"@prisma/lift@0.3.16":
version "0.3.16"
resolved "https://registry.yarnpkg.com/@prisma/lift/-/lift-0.3.16.tgz#1bc49733eeb8a6baba531ac0af7b4fb3246dde81"
integrity sha512-IsjH6mqDjD6HQ8O7+NQXLvSPWubYpe4LO4gUMEQNsIWJcQJigUzARqp+l9gAZv9geCHATu0GAR7yZhIwdrfe5A==
"@prisma/lift@0.3.21":
version "0.3.21"
resolved "https://registry.yarnpkg.com/@prisma/lift/-/lift-0.3.21.tgz#ba46c13a730c5d71ac373f0ff36dd464e841341d"
integrity sha512-Q0UPbkgtyQvVf+8I+LcSoINEqYRsJJqEKD8fYP9U7GFyNbIhRl9xlznkAAHqTjsNsu3NufugIITpZS1jbhj+3g==
dependencies:
"@prisma/fetch-engine" "^0.1.14"
"@prisma/get-platform" "^0.1.1"
"@prisma/ink-components" "^0.0.1"
"@prisma/studio-server" "0.103"
"@prisma/studio-server" "0.105.0"
"@types/execa" "^0.9.0"
adm-zip "^0.4.13"
ansi-escapes "^4.2.1"
Expand Down Expand Up @@ -463,13 +463,13 @@
strip-indent "^3.0.0"
supports-hyperlinks "^1.0.1"

"@prisma/photon@^0.2.90":
version "0.2.90"
resolved "https://registry.yarnpkg.com/@prisma/photon/-/photon-0.2.90.tgz#4995777345093580bdccb8ca9500f695b527f36f"
integrity sha512-hP5zj0GdZ4LyKn3D9+UtQtWjqm2RkyCqpvQeExEIXSQ5LQu47zGGTzXIFB9krG8Y+01U/lU/OXTFRV1laK9Wwg==
"@prisma/photon@^0.2.94":
version "0.2.94"
resolved "https://registry.yarnpkg.com/@prisma/photon/-/photon-0.2.94.tgz#17ff58db3e6351ebebb36308d0b63e4b34f13c37"
integrity sha512-O3wn4jUnxiMU5/YG6z5rqecN02KLcbyXoh/XNQ2QmBhcEDpX2GW2AFPAMshXFkvrIoCbP20Bc1fHeTn2hPHgmQ==
dependencies:
"@apexearth/copy" "^1.4.2"
"@prisma/cli" "0.1.9"
"@prisma/cli" "0.1.10"
"@prisma/engine-core" "0.0.96"
"@prisma/fetch-engine" "^0.1.14"
chalk "^2.4.2"
Expand All @@ -494,29 +494,29 @@
terminal-link "^1.3.0"
wtfnode "0.8.0"

"@prisma/studio-server@0.103":
version "0.103.0"
resolved "https://registry.yarnpkg.com/@prisma/studio-server/-/studio-server-0.103.0.tgz#46dfa074a3b3c5d241b95cabff87cac556a2a4be"
integrity sha512-sSxL5+8bfxfMeddcua0xWaEhLEska0srRNvo+0tqQmldqMumy4bMWTg64VGLj6DI1kcEpO1k+MKbYqUxY6lV/Q==
"@prisma/studio-server@0.105.0":
version "0.105.0"
resolved "https://registry.yarnpkg.com/@prisma/studio-server/-/studio-server-0.105.0.tgz#2102b4b0b6b44906d04b5c70f4f1c0f6ed8b3b36"
integrity sha512-THYYFVNRK6vSuEtRFwFeGUyRlRQsll26VdLGFt4de75afhtJslHXdU+ZfTfqgyjrbuxp4qkJLbnJ/B3kQZ4P0A==
dependencies:
"@prisma/studio" "0.103.0"
"@prisma/studio-transports" "0.103.0"
"@prisma/studio" "0.105.0"
"@prisma/studio-transports" "0.105.0"
"@sentry/node" "^5.6.2"
express "^4.17.1"
express-ws "^4.0.0"

"@prisma/studio-transports@0.103.0":
version "0.103.0"
resolved "https://registry.yarnpkg.com/@prisma/studio-transports/-/studio-transports-0.103.0.tgz#475090d636a86b0c1898c53e46907069263f0913"
integrity sha512-QF+PdF8+Ned1iNABtruPX53p03OO2kP26nFR0f4tyYBwkEtot28DukFbw+Ifi7hPDw80Ie/uG9NdfEYiau+sLA==
"@prisma/studio-transports@0.105.0":
version "0.105.0"
resolved "https://registry.yarnpkg.com/@prisma/studio-transports/-/studio-transports-0.105.0.tgz#69f54bdb2147fb354bed2dfa56af71458cd5aee9"
integrity sha512-k99eR3mSVD/RG+Dc+GcspgbMmC0TFPzOWFvTXiSPBF2jwGcjH3zASTr1pq32gVEiW7nCJrSOioM0jcMj/fDmEw==
dependencies:
"@sentry/node" "^5.6.2"
strip-ansi "^5.2.0"

"@prisma/studio@0.103.0":
version "0.103.0"
resolved "https://registry.yarnpkg.com/@prisma/studio/-/studio-0.103.0.tgz#a0173da47c40d7a3677b9cb15d986dc321408052"
integrity sha512-YP3N8CCwywXGJsyGCBbTUg2+fYeHqNkoLtvk9vf6+rNczyrLJW3p6T6v2HBKIvgFn24Rn8K6g5Bh7Nvj0lrDVw==
"@prisma/studio@0.105.0":
version "0.105.0"
resolved "https://registry.yarnpkg.com/@prisma/studio/-/studio-0.105.0.tgz#b2986097552a7c32dc8591eefa64d4c471baba05"
integrity sha512-83zt9+aLDMbuGDvzGbM91t+F8XHUpHHVuFuICR7L8YNtl8QlJGvuMzmbBUYcKny0XhNb9ECxm1rfIzmmlHDvNw==

"@sentry/core@5.6.2":
version "5.6.2"
Expand Down Expand Up @@ -638,6 +638,11 @@
dependencies:
"@types/node" "*"

"@types/debug@^4.1.5":
version "4.1.5"
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd"
integrity sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ==

"@types/events@*":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
Expand Down

0 comments on commit 584488e

Please sign in to comment.