Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(build, types): cleanup #8472

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9a25784
chore(client, build): cleanup
millsp Jul 27, 2021
45b3204
chore(client): cleanup
millsp Jul 28, 2021
7dbe713
chore(client, eslint): parse other files too
millsp Jul 28, 2021
b5846c0
fix(integration-tests): directly import getTestClient
millsp Jul 28, 2021
7be8ea1
chore(client, prisma): generalize tsconfig
millsp Jul 28, 2021
03dee07
Merge branch 'master' of https://github.com/prisma/prisma into fix/ty…
millsp Jul 28, 2021
aeb913c
chore(client, prisma): split tsconfigs
millsp Jul 28, 2021
6b35f81
chore(client): fix eslint
millsp Jul 28, 2021
acea1da
chore(client): cleanup
millsp Jul 28, 2021
40ebfdb
chore(client): remove build time
millsp Jul 28, 2021
9a74ac3
chore(sdk): esbuild + inherited tsconfig
millsp Jul 29, 2021
fa0e156
chore(prisma): add sdk to discovery
millsp Jul 29, 2021
a71fc9c
chore(sdk): enable source maps
millsp Jul 29, 2021
659f9d5
chore(migrate): esbuild + inherited config
millsp Jul 29, 2021
9073368
chore(migrate): fix dist
millsp Jul 29, 2021
9a76117
chore(generator-helper): esbuild + inherited config
millsp Jul 29, 2021
d81d97f
chore(engine-core): esbuild + inherited tsconfig
millsp Jul 29, 2021
1aba830
chore(debug): esbuild + inherited tsconfig
millsp Jul 29, 2021
92d6152
chore(debug): fix build + discovery
millsp Jul 29, 2021
ae45e1e
fix(debug): fix debugLib types
millsp Jul 29, 2021
3edacbf
chore(cli): remove type gen + inherited tsconfig
millsp Jul 29, 2021
f054c44
chore(engines-wrapper): type discovery from prisma repo
millsp Jul 29, 2021
aff9efd
fix(cli): use build/index.js instead of dist/bin.js
millsp Jul 29, 2021
8c9a7c0
chore(integration-tests): esbuild + inherited tsconfig
millsp Jul 29, 2021
3be79ac
fix(cli): types
millsp Jul 29, 2021
07643a0
chore(react-prisma): esbuild + inherited tsconfig
millsp Jul 29, 2021
67e16d4
chore(prisma): expose dev command
millsp Jul 29, 2021
1a2b227
chore(prisma): pass tsconfig to esbuild
millsp Jul 29, 2021
c6546b2
chore: test
millsp Jul 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/lint.ts
Expand Up @@ -19,7 +19,7 @@ async function main() {
}
}

let packages = []
let packages = [] as string[]
if (args['--staged']) {
packages = await getStagedPackages()
} else {
Expand Down
26 changes: 13 additions & 13 deletions src/packages/cli/fixtures/test.sh
Expand Up @@ -4,7 +4,7 @@
#
# Test version command
#
VERSION=$(node ./dist/bin.js --version)
VERSION=$(node ./build/index.js --version)
if [[ ${VERSION} != *"@prisma/client"* ]]; then
echo "prisma --version is broken"
exit 1
Expand All @@ -14,7 +14,7 @@ fi
# Test custom generator path
#
cd ./fixtures/custom\ generator
GENERATE_RESULT=$(node ../../dist/bin.js generate)
GENERATE_RESULT=$(node ../../build/index.js generate)
if [[ ${GENERATE_RESULT} != *"onGenerate"* ]]; then
echo "custom generators are broken"
echo $GENERATE_RESULT
Expand All @@ -26,7 +26,7 @@ cd ../..
# Test introspection output with warnings
#
cd fixtures/introspection-warnings
INTROSPECTION=$(node ../../dist/bin.js introspect --url=file:./warnings.db 2>&1)
INTROSPECTION=$(node ../../build/index.js introspect --url=file:./warnings.db 2>&1)
if [[ ${INTROSPECTION} != *"column_name_that_becomes_empty_string"* ]]; then
echo "prisma introspect column_name_that_becomes_empty_string is broken"
echo $INTROSPECTION
Expand All @@ -46,13 +46,13 @@ cd ../../
# Test generate output command
#
cd fixtures/project/subdir
GENERATE=$(node ../../../dist/bin.js generate)
GENERATE=$(node ../../../build/index.js generate)
if [[ ${GENERATE} != *"Generated "* ]]; then
echo "prisma generate is broken"
exit 1
fi

GENERATE_DENYLIST=$(node ../../../dist/bin.js generate --schema=denylist.prisma 2>&1)
GENERATE_DENYLIST=$(node ../../../build/index.js generate --schema=denylist.prisma 2>&1)
if [[ ${GENERATE_DENYLIST} != *"Error validating model \"public\""* ]]; then
echo "prisma generate denylist is broken"
exit 1
Expand All @@ -64,29 +64,29 @@ fi

# Relative path
GENERATE_RELATIVE_SCHEMA_PATH="./schema.prisma"
GENERATE_RELATIVE_SCHEMA=$(node ../../../dist/bin.js generate --schema=$GENERATE_RELATIVE_SCHEMA_PATH)
GENERATE_RELATIVE_SCHEMA=$(node ../../../build/index.js generate --schema=$GENERATE_RELATIVE_SCHEMA_PATH)
if [[ ${GENERATE_RELATIVE_SCHEMA} != *"Generated "* ]]; then
echo "prisma generate --schema=$GENERATE_RELATIVE_SCHEMA_PATH is broken"
exit 1
fi
# Same case but should fail!
GENERATE_RELATIVE_SCHEMA_INVALID_PATH="./invalid.prisma"
GENERATE_RELATIVE_SCHEMA_INVALID=$(node ../../../dist/bin.js generate --schema=$GENERATE_RELATIVE_SCHEMA_INVALID_PATH 2>&1 > /dev/null)
GENERATE_RELATIVE_SCHEMA_INVALID=$(node ../../../build/index.js generate --schema=$GENERATE_RELATIVE_SCHEMA_INVALID_PATH 2>&1 > /dev/null)
if [[ ${GENERATE_RELATIVE_SCHEMA_INVALID} != *"Provided --schema at $GENERATE_RELATIVE_SCHEMA_INVALID_PATH doesn't exist."* ]]; then
echo "prisma generate --schema=$GENERATE_RELATIVE_SCHEMA_INVALID_PATH is broken (should fail)"
exit 1
fi

# Absolute path
GENERATE_ABSOLUTE_SCHEMA_PATH="$(pwd)/schema.prisma"
GENERATE_ABSOLUTE_SCHEMA=$(node ../../../dist/bin.js generate --schema=$GENERATE_ABSOLUTE_SCHEMA_PATH)
GENERATE_ABSOLUTE_SCHEMA=$(node ../../../build/index.js generate --schema=$GENERATE_ABSOLUTE_SCHEMA_PATH)
if [[ ${GENERATE_ABSOLUTE_SCHEMA} != *"Generated "* ]]; then
echo "prisma generate --schema=$GENERATE_ABSOLUTE_SCHEMA_PATH is broken"
exit 1
fi
# Same case but should fail!
GENERATE_ABSOLUTE_SCHEMA_INVALID_PATH="$(pwd)/invalid.prisma"
GENERATE_ABSOLUTE_SCHEMA_INVALID=$(node ../../../dist/bin.js generate --schema=$GENERATE_ABSOLUTE_SCHEMA_INVALID_PATH 2>&1 > /dev/null)
GENERATE_ABSOLUTE_SCHEMA_INVALID=$(node ../../../build/index.js generate --schema=$GENERATE_ABSOLUTE_SCHEMA_INVALID_PATH 2>&1 > /dev/null)
if [[ ${GENERATE_ABSOLUTE_SCHEMA_INVALID} != *"Provided --schema at $GENERATE_ABSOLUTE_SCHEMA_INVALID_PATH doesn't exist"* ]]; then
echo "prisma generate --schema=$GENERATE_ABSOLUTE_SCHEMA_INVALID_PATH is broken (should fail)"
exit 1
Expand All @@ -105,29 +105,29 @@ cd fixtures/project/ && yarn postinstall
cd ../..
# Relative path
GENERATE_RELATIVE_SCHEMA_FROM_PARENT_PATH="./fixtures/project/subdir/schema.prisma"
GENERATE_RELATIVE_SCHEMA_FROM_PARENT=$(SQLITE_URL=file:dev.db node ./dist/bin.js generate --schema=$GENERATE_RELATIVE_SCHEMA_FROM_PARENT_PATH)
GENERATE_RELATIVE_SCHEMA_FROM_PARENT=$(SQLITE_URL=file:dev.db node ./build/index.js generate --schema=$GENERATE_RELATIVE_SCHEMA_FROM_PARENT_PATH)
if [[ ${GENERATE_RELATIVE_SCHEMA_FROM_PARENT} != *"Generated "* ]]; then
echo "prisma generate --schema=$GENERATE_RELATIVE_SCHEMA_FROM_PARENT_PATH is broken"
exit 1
fi
# Same case but should fail!
GENERATE_RELATIVE_SCHEMA_FROM_PARENT_INVALID_PATH="./fixtures/project/subdir/invalid.prisma"
GENERATE_RELATIVE_SCHEMA_FROM_PARENT_INVALID=$(node ./dist/bin.js generate --schema=$GENERATE_RELATIVE_SCHEMA_FROM_PARENT_INVALID_PATH 2>&1 > /dev/null)
GENERATE_RELATIVE_SCHEMA_FROM_PARENT_INVALID=$(node ./build/index.js generate --schema=$GENERATE_RELATIVE_SCHEMA_FROM_PARENT_INVALID_PATH 2>&1 > /dev/null)
if [[ ${GENERATE_RELATIVE_SCHEMA_FROM_PARENT_INVALID} != *"Provided --schema at $GENERATE_RELATIVE_SCHEMA_FROM_PARENT_INVALID_PATH doesn't exist."* ]]; then
echo "prisma generate --schema=$GENERATE_RELATIVE_SCHEMA_FROM_PARENT_INVALID_PATH is broken (should fail)"
exit 1
fi

# Absolute path
GENERATE_ABSOLUTE_SCHEMA_FROM_PARENT_PATH="$(pwd)/fixtures/project/subdir/schema.prisma"
GENERATE_ABSOLUTE_SCHEMA_FROM_PARENT=$(SQLITE_URL=file:dev.db node ./dist/bin.js generate --schema=$GENERATE_ABSOLUTE_SCHEMA_FROM_PARENT_PATH)
GENERATE_ABSOLUTE_SCHEMA_FROM_PARENT=$(SQLITE_URL=file:dev.db node ./build/index.js generate --schema=$GENERATE_ABSOLUTE_SCHEMA_FROM_PARENT_PATH)
if [[ ${GENERATE_ABSOLUTE_SCHEMA_FROM_PARENT} != *"Generated "* ]]; then
echo "prisma generate --schema=$GENERATE_ABSOLUTE_SCHEMA_FROM_PARENT_PATH is broken"
exit 1
fi
# Same case but should fail!
GENERATE_ABSOLUTE_SCHEMA_FROM_PARENT_INVALID_PATH="$(pwd)/fixtures/project/subdir/invalid.prisma"
GENERATE_ABSOLUTE_SCHEMA_FROM_PARENT_INVALID=$(node ./dist/bin.js generate --schema=$GENERATE_ABSOLUTE_SCHEMA_FROM_PARENT_INVALID_PATH 2>&1 > /dev/null)
GENERATE_ABSOLUTE_SCHEMA_FROM_PARENT_INVALID=$(node ./build/index.js generate --schema=$GENERATE_ABSOLUTE_SCHEMA_FROM_PARENT_INVALID_PATH 2>&1 > /dev/null)
if [[ ${GENERATE_ABSOLUTE_SCHEMA_FROM_PARENT_INVALID} != *"Provided --schema at $GENERATE_ABSOLUTE_SCHEMA_FROM_PARENT_INVALID_PATH doesn't exist."* ]]; then
echo "prisma generate --schema=$GENERATE_ABSOLUTE_SCHEMA_FROM_PARENT_INVALID_PATH is broken (should fail)"
exit 1
Expand Down
33 changes: 15 additions & 18 deletions src/packages/cli/helpers/build.js
Expand Up @@ -9,40 +9,37 @@ const { promisify } = require('util')
const copyFile = promisify(fs.copyFile)
const lineReplace = require('line-replace')

const ESBUILD_DEFAULT = {
platform: 'node',
target: 'node12',
bundle: true,
tsconfig: 'tsconfig.build.json'
}

async function main() {
const before = Date.now()

await makeDir('./build')

await Promise.all([
run('node ./helpers/copy-prisma-client.js'),
run('tsc --build tsconfig.build.json', true),
])
await run('node ./helpers/copy-prisma-client.js')

await Promise.all([
esbuild.build({
platform: 'node',
bundle: true,
target: 'node12',
outfile: 'build/index.js',
...ESBUILD_DEFAULT,
entryPoints: ['src/bin.ts'],
outfile: 'build/index.js',
external: ['@prisma/engines', '_http_common'],
}),
esbuild.build({
platform: 'node',
bundle: true,
minify: true,
target: ['node12'],
outfile: 'preinstall/index.js',
...ESBUILD_DEFAULT,
entryPoints: ['scripts/preinstall.js'],
outfile: 'preinstall/index.js',
}),
esbuild.build({
platform: 'node',
bundle: true,
minify: true,
target: ['node12'],
outfile: 'install/index.js',
...ESBUILD_DEFAULT,
entryPoints: ['scripts/install.js'],
outfile: 'install/index.js',
minify: true,
}),
copy({
from: path.join(
Expand Down
4 changes: 3 additions & 1 deletion src/packages/cli/package.json
Expand Up @@ -71,6 +71,7 @@
"@prisma/studio-server": "0.417.0",
"@timsuchanek/copy": "1.4.5",
"@types/jest": "26.0.24",
"@types/rimraf": "3.0.1",
"@types/ws": "7.4.7",
"@typescript-eslint/eslint-plugin": "4.28.5",
"@typescript-eslint/parser": "4.28.5",
Expand Down Expand Up @@ -110,6 +111,8 @@
"typescript": "4.3.5"
},
"scripts": {
"dev": "DEV=true node helpers/build.js",
"build": "node helpers/build.js",
"test:commands": "./fixtures/test.sh && jest --maxConcurrency=1",
"test-update": "pnpm run test:commands -- -u",
"test": "pnpm run test:commands",
Expand All @@ -119,7 +122,6 @@
"lint": "eslint --cache --fix --ext .ts .",
"lint-ci": "eslint --ext .ts .",
"tsc": "tsc -d -p tsconfig.build.json && bash scripts/copy-runtime-dist.sh",
"build": "node helpers/build.js",
"prepublishOnly": "pnpm run build",
"preinstall": "node scripts/preinstall-entry.js",
"precommit": "lint-staged"
Expand Down
9 changes: 4 additions & 5 deletions src/packages/cli/src/Init.ts
Expand Up @@ -79,6 +79,8 @@ export const defaultPort = (provider: ConnectorType) => {
case 'postgresql':
return 5432
}

return undefined
}

export const defaultURL = (
Expand Down Expand Up @@ -276,12 +278,9 @@ export class Init implements Command {
}

try {
fs.writeFileSync(
path.join(outputDir, ".gitignore"),
defaultGitIgnore()
);
fs.writeFileSync(path.join(outputDir, '.gitignore'), defaultGitIgnore())
} catch (error) {
console.error("Failed to write .gitignore file, reason: ", error);
console.error('Failed to write .gitignore file, reason: ', error)
}

const steps: string[] = []
Expand Down
15 changes: 4 additions & 11 deletions src/packages/cli/tsconfig.build.json
@@ -1,15 +1,8 @@
{
"extends": "./tsconfig.json",
"extends": "../../../tsconfig.build.json",
"compilerOptions": {
"outDir": "dist"
"outDir": "dist",
"emitDeclarationOnly": true
},
"exclude": [
"dist",
"build",
"runtime",
"examples",
"src/__tests__",
"fixtures",
"**/node_modules/**"
]
"include": ["src"],
}
4 changes: 1 addition & 3 deletions src/packages/cli/tsconfig.eslint.json
@@ -1,5 +1,3 @@
{
"extends": "./tsconfig",
"include": ["src"],
"exclude": []
"extends": "./tsconfig.json"
}
15 changes: 1 addition & 14 deletions src/packages/cli/tsconfig.json
@@ -1,16 +1,3 @@
{
"compilerOptions": {
"lib": ["esnext", "esnext.asynciterable", "dom"],
"module": "commonjs",
"target": "es2018",
"strict": true,
"esModuleInterop": true,
"sourceMap": true,
"noImplicitAny": false,
"rootDir": "src",
"declaration": true,
"skipLibCheck": true,
"incremental": true
},
"exclude": ["scripts", "src/__tests__", "**/tmp-*"]
"extends": "../../../tsconfig.json"
}
15 changes: 3 additions & 12 deletions src/packages/client/.eslintignore
@@ -1,19 +1,10 @@
/node_modules
/dist
/generator-build
/declaration
/runtime
/runtime-dist
/fixtures
/index.d.ts
/scripts/
sandbox
/sandbox

/src/byline.ts
/src/__tests__/generation/node_modules
generated-dmmf.ts
/src/__tests__/types
/src/__tests__/runtime-tests
/src/__tests__/benchmarks
/src/sandbox
generated-dmmf.ts
/src/__tests__/__helpers__/dmmf-types.ts

36 changes: 6 additions & 30 deletions src/packages/client/.gitignore
@@ -1,32 +1,8 @@
node_modules
dist
build
runtime
runtime-browser
runtime-browser-dist
/node_modules
/declaration
/generator-build
/runtime

download
generator
cli
.DS_Store
!src/runtime
yarn-error.log
src/utils/transformed-dmmf.json
*-dmmf.json
*-dmmf-raw.json
db
query-engine*
test.sh
try-getConfig.ts
generator-build
@prisma
getConfig.sh
migrations
/schema.prisma
/dmmf.json
try-getDmmf.ts
write-test
prisma-client-*.tgz
*.tsbuildinfo
pnpm-lock.yaml
*.zip
*.tsbuildinfo
.DS_Store
2 changes: 0 additions & 2 deletions src/packages/client/.npmignore
@@ -1,2 +0,0 @@
runtime/prisma
runtime/schema-inferrer-bin