Skip to content

Commit

Permalink
fixes for new generator architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Oct 11, 2019
1 parent 6cdff3c commit 7d43ac7
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 127 deletions.
2 changes: 1 addition & 1 deletion cli/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prisma/cli",
"version": "0.1.3",
"version": "0.1.11",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "git@github.com:prisma/prisma2.git",
Expand Down
2 changes: 1 addition & 1 deletion cli/cli/src/getSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function getSchemaSync(): string {
const schemaPath = getSchemaPathSync()

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

return fs.readFileSync(schemaPath, 'utf-8')
Expand Down
2 changes: 1 addition & 1 deletion cli/generator-helper/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prisma/generator-helper",
"version": "0.0.8",
"version": "0.0.11",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"typings": "dist/index.d.ts",
Expand Down
12 changes: 1 addition & 11 deletions cli/generator-helper/src/GeneratorProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ export class GeneratorProcess {
if (!fs.existsSync(executablePath)) {
throw new Error(`Can't find executable ${executablePath}`)
}

if (!hasChmodX(executablePath)) {
throw new Error(
`${chalk.bold(
executablePath,
)} is not executable. Please run ${chalk.greenBright(
`chmod +x ${path.relative(process.cwd(), executablePath)}`,
)}`,
)
}
}
async init() {
if (!this.initPromise) {
Expand All @@ -47,7 +37,7 @@ export class GeneratorProcess {
}
initSingleton(): Promise<void> {
return new Promise((resolve, reject) => {
this.child = spawn(this.executablePath, {
this.child = spawn(process.execPath, [this.executablePath], {
stdio: ['pipe', 'inherit', 'pipe'],
})

Expand Down
14 changes: 7 additions & 7 deletions cli/generator-helper/src/__tests__/generatorHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ const stubOptions: GeneratorOptions = {
}

describe('generatorHandler', () => {
test('not executable', async () => {
expect(() => {
const generator = new GeneratorProcess(
path.join(__dirname, 'not-executable'),
)
}).toThrow('is not executable')
})
// test('not executable', async () => {
// expect(() => {
// const generator = new GeneratorProcess(
// path.join(__dirname, 'not-executable'),
// )
// }).toThrow('is not executable')
// })
test('parsing error', async () => {
const generator = new GeneratorProcess(
path.join(__dirname, 'invalid-executable'),
Expand Down
7 changes: 4 additions & 3 deletions cli/ink-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prisma/ink-components",
"version": "0.0.1",
"version": "0.0.7",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "git@github.com:prisma/prisma2.git",
Expand All @@ -10,6 +10,7 @@
"dependencies": {
"chalk": "^2.4.2",
"cli-truncate": "^2.0.0",
"debug": "^4.1.1",
"figures": "^3.0.0",
"ink-spinner": "^3.0.1",
"string-width": "^4.1.0",
Expand All @@ -25,8 +26,8 @@
],
"devDependencies": {
"@types/node": "^12.0.10",
"ink": "^2.3.0",
"react": "^16.9.0",
"ink": "^2.5.0",
"react": "^16.10.2",
"typescript": "^3.5.1"
},
"peerDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions cli/ink-components/src/components/TabIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react'
import { Key } from 'readline'
import { useStdin } from '../hooks/useStdin'
import { ActionKey } from '../helpers'
import Debug from 'debug'
const debug = Debug('TabIndex')

interface TabIndexRegisterArgs {
tabIndex: number
Expand Down
13 changes: 8 additions & 5 deletions cli/ink-components/src/hooks/useStdin.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { StdinContext } from 'ink'
import { useStdin as inkUseStdin } from 'ink'
import React from 'react'
import { Key } from 'readline'
import { action, ActionKey } from '../helpers'
import { Key, emitKeypressEvents } from 'readline'
import { action } from '../helpers'
import Debug from 'debug'

export function useStdin(
keyHandler: ({ actionKey: ActionKey, text: string, key: Key }) => void,
deps: any[] = [],
) {
const { stdin, setRawMode } = React.useContext(StdinContext)
const { stdin, setRawMode } = inkUseStdin()

emitKeypressEvents(stdin)

let didCancel = false

Expand All @@ -22,7 +25,7 @@ export function useStdin(
stdin.on('keypress', handler)

return () => {
didCancel = true
// didCancel = true
stdin.removeListener('keypress', handler)
setRawMode!(false)
}
Expand Down
51 changes: 32 additions & 19 deletions cli/ink-components/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ csstype@^2.2.0:
resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.6.tgz#c34f8226a94bbb10c32cc0d714afdf942291fc41"
integrity sha512-RpFbQGUE74iyPgvr46U9t1xoQBM8T4BL8SxrN66Le2xYAPSaDJJKeztV3awugusb3g3G9iL8StmkBBXhcbbXhg==

debug@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791"
integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==
dependencies:
ms "^2.1.1"

emoji-regex@^7.0.1:
version "7.0.3"
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156"
Expand Down Expand Up @@ -165,12 +172,13 @@ ink-spinner@^3.0.1:
cli-spinners "^1.0.0"
prop-types "^15.5.10"

ink@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/ink/-/ink-2.3.0.tgz#222136be17bb72fc742e19090483e7e0e7dc3690"
integrity sha512-931rgXHAS3hM++8ygWPOBeHOFwTzHh3pDAVZtiBVOUH6tVvJijym43ODUy22ySo2NwYUFeR/Zj3xuWzBEKMiHw==
ink@^2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/ink/-/ink-2.5.0.tgz#66cf988b65ca06d14f00f385eb531fde29f95819"
integrity sha512-HUkVglJ11cXK+W1a5cKNoOCxLkDi5hbDMAWSFDcwF2kpNd0eoX+2/cpaTP9BTFaQ8RJk7O59NxKMmyPXkmxo7w==
dependencies:
"@types/react" "^16.8.6"
ansi-escapes "^4.2.1"
arrify "^1.0.1"
auto-bind "^2.0.0"
chalk "^2.4.1"
Expand All @@ -180,8 +188,8 @@ ink@^2.3.0:
lodash.throttle "^4.1.1"
log-update "^3.0.0"
prop-types "^15.6.2"
react-reconciler "^0.20.0"
scheduler "^0.13.2"
react-reconciler "^0.21.0"
scheduler "^0.15.0"
signal-exit "^3.0.2"
slice-ansi "^1.0.0"
string-length "^2.0.0"
Expand Down Expand Up @@ -242,6 +250,11 @@ min-indent@^1.0.0:
resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.0.tgz#cfc45c37e9ec0d8f0a0ec3dd4ef7f7c3abe39256"
integrity sha1-z8RcN+nsDY8KDsPdTvf3w6vjklY=

ms@^2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==

object-assign@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
Expand All @@ -268,20 +281,20 @@ react-is@^16.8.1:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.9.0.tgz#21ca9561399aad0ff1a7701c01683e8ca981edcb"
integrity sha512-tJBzzzIgnnRfEm046qRcURvwQnZVXmuCbscxUO5RWrGTXpon2d4c8mI0D8WE6ydVIm29JiLB6+RslkIvym9Rjw==

react-reconciler@^0.20.0:
version "0.20.4"
resolved "https://registry.yarnpkg.com/react-reconciler/-/react-reconciler-0.20.4.tgz#3da6a95841592f849cb4edd3d38676c86fd920b2"
integrity sha512-kxERc4H32zV2lXMg/iMiwQHOtyqf15qojvkcZ5Ja2CPkjVohHw9k70pdDBwrnQhLVetUJBSYyqU3yqrlVTOajA==
react-reconciler@^0.21.0:
version "0.21.0"
resolved "https://registry.yarnpkg.com/react-reconciler/-/react-reconciler-0.21.0.tgz#8180342ab3c8295f860025a86d0a03742a294ea7"
integrity sha512-h4Rl3L3O6G9V4Ff+F+tCXX8ElDVn0Psk/odT+NPWeA55Yk5G7+kHT8D+Q3yE+51C72LbrYcX6OfLmCZ/7Nx9cw==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"
scheduler "^0.13.6"
scheduler "^0.15.0"

react@^16.9.0:
version "16.9.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.9.0.tgz#40ba2f9af13bc1a38d75dbf2f4359a5185c4f7aa"
integrity sha512-+7LQnFBwkiw+BobzOF6N//BdoNw0ouwmSJTEm9cglOOmsg/TMiFHZLe2sEoN5M7LgJTj9oHH0gxklfnQe66S1w==
react@^16.10.2:
version "16.10.2"
resolved "https://registry.yarnpkg.com/react/-/react-16.10.2.tgz#a5ede5cdd5c536f745173c8da47bda64797a4cf0"
integrity sha512-MFVIq0DpIhrHFyqLU0S3+4dIcBhhOvBE8bJ/5kHPVOVaGdo0KuiQzpcjCPsf585WvhypqtrMILyoE2th6dT+Lw==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
Expand All @@ -295,10 +308,10 @@ restore-cursor@^2.0.0:
onetime "^2.0.0"
signal-exit "^3.0.2"

scheduler@^0.13.2, scheduler@^0.13.6:
version "0.13.6"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.6.tgz#466a4ec332467b31a91b9bf74e5347072e4cd889"
integrity sha512-IWnObHt413ucAYKsD9J1QShUKkbKLQQHdxRyw73sw4FN26iWr3DY/H34xGPe4nmL1DwXyWmSWmMrA9TfQbE/XQ==
scheduler@^0.15.0:
version "0.15.0"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.15.0.tgz#6bfcf80ff850b280fed4aeecc6513bc0b4f17f8e"
integrity sha512-xAefmSfN6jqAa7Kuq7LIJY0bwAPG3xlCj0HMEBQk1lxYiDKZscY2xJ5U/61ZTrYbmNQbXa+gc7czPkVo11tnCg==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
Expand Down

0 comments on commit 7d43ac7

Please sign in to comment.