Skip to content

Commit

Permalink
feat: remove prisma-fmt binary (#16923)
Browse files Browse the repository at this point in the history
* feat: remove prisma-fmt binary

* chore: revert unwanted changes

* chore: removed "Format Binary" from snapshots

* chore: remove useless code

* code-review: removed more format mentions related to the binary

Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>
Co-authored-by: Jan Piotrowski <piotrowski+github@gmail.com>
  • Loading branch information
3 people committed Jan 17, 2023
1 parent 0a15440 commit f6e1ca6
Show file tree
Hide file tree
Showing 24 changed files with 33 additions and 174 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ sandbox
introspection-engine*
query-engine*
migration-engine*
prisma-fmt*
libquery_engine*
libquery-engine*
query_engine-windows.dll.node
Expand Down
1 change: 0 additions & 1 deletion packages/cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ node_modules
migration-engine*
query-engine*
introspection-engine*
prisma-fmt*
libquery*
yarn-error.log
dist
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/src/Version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ export class Version implements Command {
.with({ 'introspection-engine': P.select() }, (currEngineInfo) => {
return ['Introspection Engine', currEngineInfo]
})
.with({ 'format-binary': P.select() }, (currEngineInfo) => {
return ['Format Binary', currEngineInfo]
})
.exhaustive()
})

Expand Down
2 changes: 0 additions & 2 deletions packages/cli/src/__tests__/commands/Version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ describe('version', () => {
binaries: {
'introspection-engine': enginesDir,
'migration-engine': enginesDir,
'prisma-fmt': enginesDir,
'libquery-engine': enginesDir,
},
version,
Expand Down Expand Up @@ -78,7 +77,6 @@ describe('version', () => {
binaries: {
'introspection-engine': enginesDir,
'migration-engine': enginesDir,
'prisma-fmt': enginesDir,
'query-engine': enginesDir,
},
version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Current platform : TEST_PLATFORM
Query Engine (Node-API) : libquery-engine ENGINE_VERSION (at sanitized_path/libquery_engine-TEST_PLATFORM.LIBRARY_TYPE.node)
Migration Engine : migration-engine-cli ENGINE_VERSION (at sanitized_path/migration-engine-TEST_PLATFORM)
Introspection Engine : introspection-core ENGINE_VERSION (at sanitized_path/introspection-engine-TEST_PLATFORM)
Format Binary : prisma-fmt ENGINE_VERSION (at sanitized_path/prisma-fmt-TEST_PLATFORM)
Format Wasm : @prisma/prisma-fmt-wasm CLI_VERSION.ENGINE_VERSION
Default Engines Hash : ENGINE_VERSION
Studio : STUDIO_VERSION
Expand All @@ -20,7 +19,6 @@ Current platform : TEST_PLATFORM
Query Engine (Node-API) : libquery-engine ENGINE_VERSION (at sanitized_path/libquery_engine-TEST_PLATFORM.LIBRARY_TYPE.node, resolved by PRISMA_QUERY_ENGINE_LIBRARY)
Migration Engine : migration-engine-cli ENGINE_VERSION (at sanitized_path/migration-engine-TEST_PLATFORM, resolved by PRISMA_MIGRATION_ENGINE_BINARY)
Introspection Engine : introspection-core ENGINE_VERSION (at sanitized_path/introspection-engine-TEST_PLATFORM, resolved by PRISMA_INTROSPECTION_ENGINE_BINARY)
Format Binary : prisma-fmt ENGINE_VERSION (at sanitized_path/prisma-fmt-TEST_PLATFORM, resolved by PRISMA_FMT_BINARY)
Format Wasm : @prisma/prisma-fmt-wasm CLI_VERSION.ENGINE_VERSION
Default Engines Hash : ENGINE_VERSION
Studio : STUDIO_VERSION
Expand All @@ -33,7 +31,6 @@ Current platform : TEST_PLATFORM
Query Engine (Binary) : query-engine ENGINE_VERSION (at sanitized_path/query-engine-TEST_PLATFORM)
Migration Engine : migration-engine-cli ENGINE_VERSION (at sanitized_path/migration-engine-TEST_PLATFORM)
Introspection Engine : introspection-core ENGINE_VERSION (at sanitized_path/introspection-engine-TEST_PLATFORM)
Format Binary : prisma-fmt ENGINE_VERSION (at sanitized_path/prisma-fmt-TEST_PLATFORM)
Format Wasm : @prisma/prisma-fmt-wasm CLI_VERSION.ENGINE_VERSION
Default Engines Hash : ENGINE_VERSION
Studio : STUDIO_VERSION
Expand All @@ -46,7 +43,6 @@ Current platform : TEST_PLATFORM
Query Engine (Binary) : query-engine ENGINE_VERSION (at sanitized_path/query-engine-TEST_PLATFORM, resolved by PRISMA_QUERY_ENGINE_BINARY)
Migration Engine : migration-engine-cli ENGINE_VERSION (at sanitized_path/migration-engine-TEST_PLATFORM, resolved by PRISMA_MIGRATION_ENGINE_BINARY)
Introspection Engine : introspection-core ENGINE_VERSION (at sanitized_path/introspection-engine-TEST_PLATFORM, resolved by PRISMA_INTROSPECTION_ENGINE_BINARY)
Format Binary : prisma-fmt ENGINE_VERSION (at sanitized_path/prisma-fmt-TEST_PLATFORM, resolved by PRISMA_FMT_BINARY)
Format Wasm : @prisma/prisma-fmt-wasm CLI_VERSION.ENGINE_VERSION
Default Engines Hash : ENGINE_VERSION
Studio : STUDIO_VERSION
Expand Down
8 changes: 0 additions & 8 deletions packages/cli/src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,41 +248,33 @@ function handleIndividualError(error: Error): void {
path.join(__dirname, '../../engines/query-engine-darwin')
path.join(__dirname, '../../engines/introspection-engine-darwin')
path.join(__dirname, '../../engines/migration-engine-darwin')
path.join(__dirname, '../../engines/prisma-fmt-darwin')
// Windows
path.join(__dirname, '../../engines/query-engine-windows.exe')
path.join(__dirname, '../../engines/introspection-engine-windows.exe')
path.join(__dirname, '../../engines/migration-engine-windows.exe')
path.join(__dirname, '../../engines/prisma-fmt-windows.exe')

// Debian openssl-1.0.x
path.join(__dirname, '../../engines/query-engine-debian-openssl-1.0.x')
path.join(__dirname, '../../engines/introspection-engine-debian-openssl-1.0.x')
path.join(__dirname, '../../engines/migration-engine-debian-openssl-1.0.x')
path.join(__dirname, '../../engines/prisma-fmt-debian-openssl-1.0.x')
// Debian openssl-1.1.x
path.join(__dirname, '../../engines/query-engine-debian-openssl-1.1.x')
path.join(__dirname, '../../engines/introspection-engine-debian-openssl-1.1.x')
path.join(__dirname, '../../engines/migration-engine-debian-openssl-1.1.x')
path.join(__dirname, '../../engines/prisma-fmt-debian-openssl-1.1.x')
// Debian openssl-3.0.x
path.join(__dirname, '../../engines/query-engine-debian-openssl-3.0.x')
path.join(__dirname, '../../engines/introspection-engine-debian-openssl-3.0.x')
path.join(__dirname, '../../engines/migration-engine-debian-openssl-3.0.x')
path.join(__dirname, '../../engines/prisma-fmt-debian-openssl-3.0.x')

// Red Hat Enterprise Linux openssl-1.0.x
path.join(__dirname, '../../engines/query-engine-rhel-openssl-1.0.x')
path.join(__dirname, '../../engines/introspection-engine-rhel-openssl-1.0.x')
path.join(__dirname, '../../engines/migration-engine-rhel-openssl-1.0.x')
path.join(__dirname, '../../engines/prisma-fmt-rhel-openssl-1.0.x')
// Red Hat Enterprise Linux openssl-1.1.x
path.join(__dirname, '../../engines/query-engine-rhel-openssl-1.1.x')
path.join(__dirname, '../../engines/introspection-engine-rhel-openssl-1.1.x')
path.join(__dirname, '../../engines/migration-engine-rhel-openssl-1.1.x')
path.join(__dirname, '../../engines/prisma-fmt-rhel-openssl-1.1.x')
// Red Hat Enterprise Linux openssl-3.0.x
path.join(__dirname, '../../engines/query-engine-rhel-openssl-3.0.x')
path.join(__dirname, '../../engines/introspection-engine-rhel-openssl-3.0.x')
path.join(__dirname, '../../engines/migration-engine-rhel-openssl-3.0.x')
path.join(__dirname, '../../engines/prisma-fmt-rhel-openssl-3.0.x')
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const MODELS_COUNT = 100
const fieldsCount = 5

// can be used to generate schema for this benchmark
// generated schema needs prisma-fmt pass to be valid
// generated schema needs `format` pass to be valid
async function main() {
const models = Array.from({ length: MODELS_COUNT }).map((v, i) => `Model${i}`)
const modelsStr = models
Expand Down
3 changes: 1 addition & 2 deletions packages/engines/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ node_modules
query-engine*
libquery_engine*
introspection-engine*
migration-engine*
prisma-fmt*
migration-engine*
9 changes: 0 additions & 9 deletions packages/engines/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export async function ensureBinariesExist() {
[cliQueryEngineBinaryType]: binaryDir,
[BinaryType.migrationEngine]: binaryDir,
[BinaryType.introspectionEngine]: binaryDir,
[BinaryType.prismaFmt]: binaryDir,
}
debug(`binaries to download ${Object.keys(binaries).join(', ')}`)
await download({
Expand All @@ -61,35 +60,27 @@ export { enginesVersion } from '@prisma/engines-version'

path.join(__dirname, '../query-engine-darwin')
path.join(__dirname, '../introspection-engine-darwin')
path.join(__dirname, '../prisma-fmt-darwin')

path.join(__dirname, '../query-engine-darwin-arm64')
path.join(__dirname, '../introspection-engine-darwin-arm64')
path.join(__dirname, '../prisma-fmt-darwin-arm64')

path.join(__dirname, '../query-engine-debian-openssl-1.0.x')
path.join(__dirname, '../introspection-engine-debian-openssl-1.0.x')
path.join(__dirname, '../prisma-fmt-debian-openssl-1.0.x')

path.join(__dirname, '../query-engine-debian-openssl-1.1.x')
path.join(__dirname, '../introspection-engine-debian-openssl-1.1.x')
path.join(__dirname, '../prisma-fmt-debian-openssl-1.1.x')

path.join(__dirname, '../query-engine-debian-openssl-3.0.x')
path.join(__dirname, '../introspection-engine-debian-openssl-3.0.x')
path.join(__dirname, '../prisma-fmt-debian-openssl-3.0.x')

path.join(__dirname, '../query-engine-rhel-openssl-1.0.x')
path.join(__dirname, '../introspection-engine-rhel-openssl-1.0.x')
path.join(__dirname, '../prisma-fmt-rhel-openssl-1.0.x')

path.join(__dirname, '../query-engine-rhel-openssl-1.1.x')
path.join(__dirname, '../introspection-engine-rhel-openssl-1.1.x')
path.join(__dirname, '../prisma-fmt-rhel-openssl-1.1.x')

path.join(__dirname, '../query-engine-rhel-openssl-3.0.x')
path.join(__dirname, '../introspection-engine-rhel-openssl-3.0.x')
path.join(__dirname, '../prisma-fmt-rhel-openssl-3.0.x')

// Node API
path.join(__dirname, '../libquery_engine-darwin.dylib.node')
Expand Down
2 changes: 0 additions & 2 deletions packages/engines/src/scripts/localinstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ async function main() {
[BinaryType.libqueryEngine]: path.join(cacheDir, BinaryType.libqueryEngine),
[BinaryType.migrationEngine]: path.join(cacheDir, BinaryType.migrationEngine),
[BinaryType.introspectionEngine]: path.join(cacheDir, BinaryType.introspectionEngine),
[BinaryType.prismaFmt]: path.join(cacheDir, BinaryType.prismaFmt),
}

if (branch !== undefined) {
Expand Down Expand Up @@ -66,7 +65,6 @@ async function main() {
[BinaryType.queryEngine]: path.join(folder, BinaryType.queryEngine.concat(binExt)),
[BinaryType.migrationEngine]: path.join(folder, BinaryType.migrationEngine.concat(binExt)),
[BinaryType.introspectionEngine]: path.join(folder, BinaryType.introspectionEngine.concat(binExt)),
[BinaryType.prismaFmt]: path.join(folder, BinaryType.prismaFmt.concat(binExt)),
}

for (const [binaryType, outputPath] of Object.entries(engineOutputPaths)) {
Expand Down
1 change: 0 additions & 1 deletion packages/engines/src/scripts/postinstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ async function main() {
[cliQueryEngineBinaryType]: baseDir,
[BinaryType.migrationEngine]: baseDir,
[BinaryType.introspectionEngine]: baseDir,
[BinaryType.prismaFmt]: baseDir,
}

await download({
Expand Down
3 changes: 1 addition & 2 deletions packages/fetch-engine/src/__tests__/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
*engine*
prisma-fmt*
*engine*
83 changes: 0 additions & 83 deletions packages/fetch-engine/src/__tests__/download.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ describe('download', () => {
// Make sure to not mix forward and backward slashes in the path
// or del glob pattern would not work on Windows
await del(path.posix.join(dirname, '/**/*engine*'))
await del(path.posix.join(dirname, '/**/prisma-fmt*'))
})
afterEach(() => {
delete process.env.PRISMA_QUERY_ENGINE_BINARY
Expand All @@ -38,15 +37,13 @@ describe('download', () => {
const queryEnginePath = path.join(baseDir, getBinaryName(BinaryType.queryEngine, platform))
const introspectionEnginePath = path.join(baseDir, getBinaryName(BinaryType.introspectionEngine, platform))
const migrationEnginePath = path.join(baseDir, getBinaryName(BinaryType.migrationEngine, platform))
const prismaFmtPath = path.join(baseDir, getBinaryName(BinaryType.prismaFmt, platform))

await download({
binaries: {
[BinaryType.libqueryEngine]: baseDir,
[BinaryType.queryEngine]: baseDir,
[BinaryType.introspectionEngine]: baseDir,
[BinaryType.migrationEngine]: baseDir,
[BinaryType.prismaFmt]: baseDir,
},
binaryTargets: [
'darwin',
Expand Down Expand Up @@ -112,20 +109,6 @@ describe('download', () => {
"migration-engine-rhel-openssl-1.1.x",
"migration-engine-rhel-openssl-3.0.x",
"migration-engine-windows.exe",
"prisma-fmt-darwin",
"prisma-fmt-darwin-arm64",
"prisma-fmt-debian-openssl-1.0.x",
"prisma-fmt-debian-openssl-1.1.x",
"prisma-fmt-debian-openssl-3.0.x",
"prisma-fmt-linux-arm64-openssl-1.0.x",
"prisma-fmt-linux-arm64-openssl-1.1.x",
"prisma-fmt-linux-arm64-openssl-3.0.x",
"prisma-fmt-linux-musl",
"prisma-fmt-linux-musl-openssl-3.0.x",
"prisma-fmt-rhel-openssl-1.0.x",
"prisma-fmt-rhel-openssl-1.1.x",
"prisma-fmt-rhel-openssl-3.0.x",
"prisma-fmt-windows.exe",
"query-engine-darwin",
"query-engine-darwin-arm64",
"query-engine-debian-openssl-1.0.x",
Expand All @@ -148,7 +131,6 @@ describe('download', () => {
expect(await getVersion(queryEnginePath, BinaryType.queryEngine)).toContain(CURRENT_ENGINES_HASH)
expect(await getVersion(introspectionEnginePath, BinaryType.introspectionEngine)).toContain(CURRENT_ENGINES_HASH)
expect(await getVersion(migrationEnginePath, BinaryType.migrationEngine)).toContain(CURRENT_ENGINES_HASH)
expect(await getVersion(prismaFmtPath, BinaryType.prismaFmt)).toContain(CURRENT_ENGINES_HASH)
})

test('download all binaries & cache them', async () => {
Expand All @@ -158,7 +140,6 @@ describe('download', () => {
const queryEnginePath = path.join(baseDir, getBinaryName(BinaryType.queryEngine, platform))
const introspectionEnginePath = path.join(baseDir, getBinaryName(BinaryType.introspectionEngine, platform))
const migrationEnginePath = path.join(baseDir, getBinaryName(BinaryType.migrationEngine, platform))
const prismaFmtPath = path.join(baseDir, getBinaryName(BinaryType.prismaFmt, platform))

const before0 = Date.now()
await download({
Expand All @@ -167,7 +148,6 @@ describe('download', () => {
[BinaryType.queryEngine]: baseDir,
[BinaryType.introspectionEngine]: baseDir,
[BinaryType.migrationEngine]: baseDir,
[BinaryType.prismaFmt]: baseDir,
},
binaryTargets: [
'darwin',
Expand Down Expand Up @@ -365,62 +345,6 @@ It took ${timeInMsToDownloadAll}ms to execute download() for all binaryTargets.`
"name": "migration-engine-windows.exe",
"size": 23651328,
},
{
"name": "prisma-fmt-darwin",
"size": 3695536,
},
{
"name": "prisma-fmt-darwin-arm64",
"size": 3426856,
},
{
"name": "prisma-fmt-debian-openssl-1.0.x",
"size": 5159640,
},
{
"name": "prisma-fmt-debian-openssl-1.1.x",
"size": 5159640,
},
{
"name": "prisma-fmt-debian-openssl-3.0.x",
"size": 5159640,
},
{
"name": "prisma-fmt-linux-arm64-openssl-1.0.x",
"size": 4976912,
},
{
"name": "prisma-fmt-linux-arm64-openssl-1.1.x",
"size": 4976912,
},
{
"name": "prisma-fmt-linux-arm64-openssl-3.0.x",
"size": 4976912,
},
{
"name": "prisma-fmt-linux-musl",
"size": 5128056,
},
{
"name": "prisma-fmt-linux-musl-openssl-3.0.x",
"size": 5128256,
},
{
"name": "prisma-fmt-rhel-openssl-1.0.x",
"size": 5135904,
},
{
"name": "prisma-fmt-rhel-openssl-1.1.x",
"size": 5135904,
},
{
"name": "prisma-fmt-rhel-openssl-3.0.x",
"size": 5135904,
},
{
"name": "prisma-fmt-windows.exe",
"size": 3421696,
},
{
"name": "query-engine-darwin",
"size": 24036112,
Expand Down Expand Up @@ -493,9 +417,6 @@ It took ${timeInMsToDownloadAll}ms to execute download() for all binaryTargets.`
expect(await getVersion(migrationEnginePath, BinaryType.migrationEngine)).toMatchInlineSnapshot(
`"migration-engine-cli c9e863f2d8de6fa0c4bcd609df078ea2dde3c2b2"`,
)
expect(await getVersion(prismaFmtPath, BinaryType.prismaFmt)).toMatchInlineSnapshot(
`"prisma-fmt c9e863f2d8de6fa0c4bcd609df078ea2dde3c2b2"`,
)

//
// Cache test 1
Expand All @@ -505,9 +426,7 @@ It took ${timeInMsToDownloadAll}ms to execute download() for all binaryTargets.`

// Delete all artifacts
const deletedEngines = await del(path.posix.join(baseDir, '/*engine*'))
const deletedPrismafmt = await del(path.posix.join(baseDir, '/prisma-fmt*'))
expect(deletedEngines.length).toBeGreaterThan(0)
expect(deletedPrismafmt.length).toBeGreaterThan(0)

const before = Date.now()
await download({
Expand All @@ -516,7 +435,6 @@ It took ${timeInMsToDownloadAll}ms to execute download() for all binaryTargets.`
'query-engine': baseDir,
'introspection-engine': baseDir,
'migration-engine': baseDir,
'prisma-fmt': baseDir,
},
binaryTargets: [
'darwin',
Expand Down Expand Up @@ -555,7 +473,6 @@ It took ${timeInMsToDownloadAllFromCache1}ms to execute download() for all binar
'query-engine': baseDir,
'introspection-engine': baseDir,
'migration-engine': baseDir,
'prisma-fmt': baseDir,
},
binaryTargets: [
'darwin',
Expand Down
2 changes: 0 additions & 2 deletions packages/fetch-engine/src/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export enum BinaryType {
libqueryEngine = 'libquery-engine',
migrationEngine = 'migration-engine',
introspectionEngine = 'introspection-engine',
prismaFmt = 'prisma-fmt',
}
export type BinaryDownloadConfiguration = {
[binary in BinaryType]?: string // that is a path to the binary download location
Expand All @@ -57,7 +56,6 @@ const BINARY_TO_ENV_VAR = {
[BinaryType.queryEngine]: 'PRISMA_QUERY_ENGINE_BINARY',
[BinaryType.libqueryEngine]: 'PRISMA_QUERY_ENGINE_LIBRARY',
[BinaryType.introspectionEngine]: 'PRISMA_INTROSPECTION_ENGINE_BINARY',
[BinaryType.prismaFmt]: 'PRISMA_FMT_BINARY',
}

type BinaryDownloadJob = {
Expand Down
Loading

0 comments on commit f6e1ca6

Please sign in to comment.