Skip to content

Commit

Permalink
Fixes #762
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Nov 7, 2019
1 parent cad6a01 commit 22b8749
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { useInitState } from '../components/InitState'
import fs from 'fs'
import { promisify } from 'util'
import EmptyDirError from '../components/EmptyDirError'
import { isDirEmpty } from '../utils/isDirEmpty'

const readdir = promisify(fs.readdir)
const exists = promisify(fs.exists)

const Step3LanguageSelection: React.FC = () => {
Expand All @@ -22,8 +22,8 @@ const Step3LanguageSelection: React.FC = () => {
async function runEffect() {
if (state.useStarterKit) {
if (await exists(state.outputDir)) {
const files = await readdir(state.outputDir)
if (files.length > 0) {
const isEmpty = await isDirEmpty(state.outputDir)
if (!isEmpty) {
setShowEmptyDirError(true)
setTimeout(() => {
process.exit(1)
Expand Down
11 changes: 6 additions & 5 deletions cli/introspection/src/prompt/screens/Step60DownloadExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ import { ErrorBox } from '@prisma/ink-components'
import { photonDefaultConfig } from '../utils/defaults'
import EmptyDirError from '../components/EmptyDirError'
import Debug from 'debug'
import { isDirEmpty } from '../utils/isDirEmpty'
const debug = Debug('download-example')
const debugEnabled = Debug.enabled('download-example')

const readdir = promisify(fs.readdir)

const readFile = promisify(fs.readFile)
const writeFile = promisify(fs.writeFile)
const exists = promisify(fs.exists)
Expand Down Expand Up @@ -66,8 +65,8 @@ const Step60DownloadExample: React.FC = () => {
useEffect(() => {
async function prepare() {
if (await exists(state.outputDir)) {
const files = await readdir(state.outputDir)
if (files.length > 0) {
const isEmpty = await isDirEmpty(state.outputDir)
if (!isEmpty) {
setShowEmptyDirError(true)
setTimeout(() => {
process.exit(1)
Expand Down Expand Up @@ -280,9 +279,11 @@ export async function replaceCommand(command: string): Promise<string> {

async function isYarnInstalled(): Promise<boolean> {
try {
await execa.shell(`yarn --version`, { stdio: `ignore` })
const result = await execa.shell(`yarn --version`, { stdio: `ignore` })
debug('result', result)
return true
} catch (err) {
debug('failed', err)
return false
}
}
10 changes: 10 additions & 0 deletions cli/introspection/src/prompt/utils/isDirEmpty.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import fs from 'fs'
import { promisify } from 'util'

const readdir = promisify(fs.readdir)
const allowList = ['.DS_Store']

export async function isDirEmpty(dir: string) {
const files = await readdir(dir)
return files.filter(f => !allowList.includes(f)).length === 0
}
80 changes: 36 additions & 44 deletions cli/prisma2/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,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.20", "@prisma/cli@^0.1.20":
version "0.1.20"
resolved "https://registry.yarnpkg.com/@prisma/cli/-/cli-0.1.20.tgz#ba01969f759b53d6c03703569c6453d7d39d06bd"
integrity sha512-cGwfyjyTsv5Etrt6Njqa7egh+shSj3kMYIhNEJWMoMPdsJ+QKYka8KMz/k537pMO7og5y63sQgklZO+4i5Oo6w==
"@prisma/cli@0.1.21", "@prisma/cli@^0.1.21":
version "0.1.21"
resolved "https://registry.yarnpkg.com/@prisma/cli/-/cli-0.1.21.tgz#575568dff38078aba5021413e8c852dcf1becea4"
integrity sha512-MBuefpawkoCSVc/CPFWtzPY6ONEXMWA2VVtJOpeczHjo7CprCrwKiePbeuIF54/jZ3OcdF4ggswLP8jep3b3ng==
dependencies:
arg "^4.1.0"
chalk "^2.4.2"
Expand Down Expand Up @@ -415,10 +415,10 @@
strip-indent "^3.0.0"
terminal-link "^2.0.0"

"@prisma/introspection@0.0.95":
version "0.0.95"
resolved "https://registry.yarnpkg.com/@prisma/introspection/-/introspection-0.0.95.tgz#5ad833d6bd8fbe39e601328c7abf2033ab9f4941"
integrity sha512-9WDt+hxmWtRGBnHzsZ47jxUPSkEldrHd6tP7ksZ8CAZzxkuiBzGYEaz41U+hGm16mFFyaONUgXqoFAhSZu/BQA==
"@prisma/introspection@0.0.97":
version "0.0.97"
resolved "https://registry.yarnpkg.com/@prisma/introspection/-/introspection-0.0.97.tgz#52e160548b2500540d3e2c346ffda7ef6b06017b"
integrity sha512-rZNX7pMWkD9PELniotNxWYSXqP/flvwn7YKE48eLFqvJv0F3vYmn3ZcBDw3uSbO/PcgXoju4Faq8xq1/o6+Qjw==
dependencies:
"@prisma/fetch-engine" "^0.3.4"
"@prisma/ink-components" "^0.0.7"
Expand All @@ -445,15 +445,15 @@
tar "^4.4.10"
terminal-link "^2.0.0"

"@prisma/lift@0.3.69":
version "0.3.69"
resolved "https://registry.yarnpkg.com/@prisma/lift/-/lift-0.3.69.tgz#9017163a229985354dd400eea3c0727a577ff782"
integrity sha512-3OBGK0A7I6YCFa48POJ64XaJqPuPKKCS+ILQ0EA30A5sd84NxGfnifGAWZtpdOitAYp2zLaGAJQPXGB2w/V2Zw==
"@prisma/lift@0.3.74":
version "0.3.74"
resolved "https://registry.yarnpkg.com/@prisma/lift/-/lift-0.3.74.tgz#85ceb95d7dcb3b4c81779d32df2ef2cc09273f0d"
integrity sha512-c1hhBq1AWWcH3XHlbA2BociEBjamY/BB7UD5dY+bBKwc9rWf0Hk8sipvXzVtYAnGno23U1I1rv/PnyjQ36SfUw==
dependencies:
"@prisma/fetch-engine" "^0.3.2"
"@prisma/get-platform" "^0.1.1"
"@prisma/ink-components" "^0.0.7"
"@prisma/studio-server" "0.138.0"
"@prisma/studio-server" "0.144.0"
"@types/execa" "^0.9.0"
adm-zip "^0.4.13"
ansi-escapes "^4.2.1"
Expand Down Expand Up @@ -490,13 +490,13 @@
strip-indent "^3.0.0"
supports-hyperlinks "^1.0.1"

"@prisma/photon@^0.2.143":
version "0.2.143"
resolved "https://registry.yarnpkg.com/@prisma/photon/-/photon-0.2.143.tgz#833bd65ff4a395f1c5f0af3b8395d2ca2ba102f9"
integrity sha512-tlkMJvmk4S4y5op9iSGHNrmsORq+YVR8otjSkKG5Y6I++FTJD0YnQIumGzAyGUN8b5OF4y10k07vMeboRr4XfA==
"@prisma/photon@^0.2.146":
version "0.2.146"
resolved "https://registry.yarnpkg.com/@prisma/photon/-/photon-0.2.146.tgz#9af2c99bf3d3256bb5c68caa582375f14b1e59ab"
integrity sha512-wb4SHRh3HQ3mr25Ac1HFZK7P8Cn2/CLJc+KT6baX2V9pYs22oqTTdlCKF4AnaUnmG6BeueXeL1q6N7xSHYZ8IA==
dependencies:
"@apexearth/copy" "^1.4.2"
"@prisma/cli" "0.1.20"
"@prisma/cli" "0.1.21"
"@prisma/engine-core" "2.0.0"
"@prisma/fetch-engine" "^0.3.4"
"@prisma/generator-helper" "^0.0.14"
Expand All @@ -522,10 +522,10 @@
terminal-link "^1.3.0"
wtfnode "0.8.0"

"@prisma/sdk@^0.0.21":
version "0.0.21"
resolved "https://registry.yarnpkg.com/@prisma/sdk/-/sdk-0.0.21.tgz#f4f61eaa1fd32019f417797cb9403336f0b9a2aa"
integrity sha512-nueJ5DLZkood2DgkjPcQPG+Cq4mCRgKkDf49Ljmvb7EY7/5rffL3yB+2XrEOH5AX+iEWB7j4sBFRL6OViYik4g==
"@prisma/sdk@^0.0.22":
version "0.0.22"
resolved "https://registry.yarnpkg.com/@prisma/sdk/-/sdk-0.0.22.tgz#f05169ac5264d922c1e81382d435b375e5d4df4c"
integrity sha512-69XLEZ5sUjvaM0uVoN539jltpzrHH5gAqnco5bi0TUboEloBizr+1GdSlEfWiIN0fmHva4nV8wKdUWBf04iz1Q==
dependencies:
"@prisma/cli" "^0.1.12"
"@prisma/engine-core" "^0.0.98"
Expand All @@ -538,37 +538,29 @@
p-map "^3.0.0"
prisma-datamodel "1.36.0-test.2"

"@prisma/studio-server@0.138.0":
version "0.138.0"
resolved "https://registry.yarnpkg.com/@prisma/studio-server/-/studio-server-0.138.0.tgz#01dd0ea31a167dcffef83df87e6ae9a64953b2ea"
integrity sha512-lQjmX3EBahG8uVf+QZtZF+tTPYghdvWLaI9Y4ZnB0d58MuUm95+fLC1GuHcIwjpOLg2wCOFyqqWSdykgpKc7dg==
"@prisma/studio-server@0.144.0":
version "0.144.0"
resolved "https://registry.yarnpkg.com/@prisma/studio-server/-/studio-server-0.144.0.tgz#126a0ed6ed8289468bfa96e10ba7a0c35bfdd554"
integrity sha512-pU0B2DxOO+kL1PAl6OItleX0pYX7er6MpW6l6W617MmZtQLYwLEFEmu+Hs6ZryOYpBfUj+QNrUe253HGZD6blg==
dependencies:
"@prisma/studio" "0.138.0"
"@prisma/studio-transports" "0.138.0"
"@prisma/studio" "0.144.0"
"@prisma/studio-transports" "0.144.0"
"@sentry/node" "^5.6.2"
express "^4.17.1"
express-ws "^4.0.0"

"@prisma/studio-transports@0.138.0":
version "0.138.0"
resolved "https://registry.yarnpkg.com/@prisma/studio-transports/-/studio-transports-0.138.0.tgz#0a72cc035c4f1d07d2a373a620c09c66b59f2d2a"
integrity sha512-8gesAtEYUA9+R+nBypcT6N9q+5dtDdZ/WeAcLw3xNffyG4zJ2wTp7FRFpgsif4yg3d18J53QTWjH8ig9DG8cWA==
"@prisma/studio-transports@0.144.0", "@prisma/studio-transports@^0.144.0":
version "0.144.0"
resolved "https://registry.yarnpkg.com/@prisma/studio-transports/-/studio-transports-0.144.0.tgz#9ffd8972aaaa5632ec39d158e819a6c8b8358482"
integrity sha512-pOf4LNp8T49zFMcb1GSO6nlRne3DcgKJ6KmuSr1KASMhWW4yBbAL81Cn8XpwJVYIQS5MKyDxlUPkfNw93zLkUA==
dependencies:
"@sentry/node" "^5.6.2"
strip-ansi "^5.2.0"

"@prisma/studio-transports@^0.141.0":
version "0.141.0"
resolved "https://registry.yarnpkg.com/@prisma/studio-transports/-/studio-transports-0.141.0.tgz#e3ad744fca11894f7ba5c8e12b6195aed6512bc8"
integrity sha512-VM4sqXPgJSs2Y5Jxcl1K6vjdeY9y2p9GYeoDs50Rq9hyzLU3HR60B8Ooe3qVIEeJld24Um9SpKxsOnlgfCqfxw==
dependencies:
"@sentry/node" "^5.6.2"
strip-ansi "^5.2.0"

"@prisma/studio@0.138.0":
version "0.138.0"
resolved "https://registry.yarnpkg.com/@prisma/studio/-/studio-0.138.0.tgz#8f2f0abdf30cec8eba449c9105cdd4e436b4e400"
integrity sha512-T7UbKdkznHMNmO5dHJd9aIs/vnRiUSvuuVSwEO5EotRfszNAY9syeETNNL7WBlB/WqJT2I0zgHON4bDxlWYwMA==
"@prisma/studio@0.144.0":
version "0.144.0"
resolved "https://registry.yarnpkg.com/@prisma/studio/-/studio-0.144.0.tgz#7e5d2ca2074bec3dc101c38d01e59af61041e65e"
integrity sha512-dI/+JkKv0xOCOwKjSJ2xptik8yLp0GTrxzfm9R/XUXE8AC+2m3x0DvNb2R03u8KrHb+6QQHbyXDLc6Yo2MhuhA==

"@sentry/core@5.7.1":
version "5.7.1"
Expand Down
4 changes: 2 additions & 2 deletions cli/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prisma/sdk",
"version": "0.0.21",
"version": "0.0.22",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "git@github.com:prisma/prisma2.git",
Expand All @@ -10,7 +10,7 @@
"scripts": {
"build": "tsc -d",
"prepublishOnly": "yarn build && yarn test",
"postinstall": "yarn download",
"postinstall": "node scripts/download.js",
"download": "node scripts/download.js",
"test": "jest"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ Object {
"isList": false,
"isRequired": false,
"kind": "scalar",
"type": "String",
"type": "Int",
},
"name": "after",
},
Expand All @@ -492,7 +492,7 @@ Object {
"isList": false,
"isRequired": false,
"kind": "scalar",
"type": "String",
"type": "Int",
},
"name": "before",
},
Expand Down
2 changes: 2 additions & 0 deletions cli/sdk/src/__tests__/getGenerators/getGenerators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { getGenerators, getGenerator } from '../../getGenerators'
import { pick } from '../../pick'
import { omit } from '../../omit'

jest.setTimeout(10000)

describe('getGenerators', () => {
test('basic', async () => {
const aliases = {
Expand Down

0 comments on commit 22b8749

Please sign in to comment.