Skip to content

Commit

Permalink
chore: clean up debugs
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed May 5, 2020
1 parent cf0adc4 commit faa6756
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 88 deletions.
4 changes: 2 additions & 2 deletions src/packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"prisma2": "build/index.js"
},
"prisma": {
"version": "3cd2e8691906b5d6be11fe6e7e154f2a9928b6ff"
"version": "f401775ef1c681c705db8fd8d6cecaa5a4eb44fd"
},
"devDependencies": {
"@apexearth/copy": "^1.4.5",
Expand Down Expand Up @@ -146,4 +146,4 @@
"eslint"
]
}
}
}
4 changes: 3 additions & 1 deletion src/packages/cli/scripts/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ let createdLockFile = false
async function main() {
if (
fs.existsSync(lockFile) &&
JSON.parse(fs.readFileSync(lockFile) > Date.now() - 20000)
JSON.parse(
parseInt(fs.readFileSync(lockFile, 'utf-8')) > Date.now() - 20000,
)
) {
debug(
`Lock file already exists, so we're skipping the download of the prisma binaries`,
Expand Down
1 change: 0 additions & 1 deletion src/packages/cli/src/Version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class Version implements Command {
'--json': Boolean,
})
const platform = await getPlatform()
debug({ __dirname })

const introspectionEngine = await this.resolveEngine(
'introspection-engine',
Expand Down
2 changes: 0 additions & 2 deletions src/packages/cli/src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ process.env.NODE_NO_WARNINGS = '1'
// react: psst 🙊
process.env.NODE_ENV = 'production'

debug({ argv: process.argv })

if (process.argv.length > 1 && process.argv[1].endsWith('prisma2')) {
console.log(
chalk.yellow('deprecated') +
Expand Down
13 changes: 1 addition & 12 deletions src/packages/client/src/generation/generateClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ export async function generateClient({
runtimePath || (useDotPrisma ? '@prisma/client/runtime' : './runtime')

const finalOutputDir = useDotPrisma ? getDotPrismaDir(outputDir) : outputDir
debug({ useDotPrisma, outputDir, finalOutputDir })

const { prismaClientDmmf, fileMap } = await buildClient({
datamodel,
Expand Down Expand Up @@ -188,7 +187,6 @@ export async function generateClient({
// TODO: Windows, / is not working here...
const copyTarget = path.join(outputDir, 'runtime')
await makeDir(copyTarget)
debug({ copyRuntime, outputDir, copyTarget, runtimeSourceDir })
if (runtimeSourceDir !== copyTarget) {
await copy({
from: runtimeSourceDir,
Expand All @@ -210,15 +208,13 @@ export async function generateClient({
for (const filePath of Object.values(binaryPaths.queryEngine)) {
const fileName = path.basename(filePath)
const target = path.join(finalOutputDir, fileName)
const before = Date.now()
const [sourceFileSize, targetFileSize] = await Promise.all([
fileSize(filePath),
fileSize(target),
])

// If the target doesn't exist yet, copy it
if (!targetFileSize) {
debug(`Copying ${filePath} to ${target}`)
await copyFile(filePath, target)
continue
}
Expand All @@ -229,7 +225,6 @@ export async function generateClient({
sourceFileSize &&
targetFileSize !== sourceFileSize
) {
debug(`Copying ${filePath} to ${target}`)
await copyFile(filePath, target)
continue
}
Expand All @@ -240,14 +235,9 @@ export async function generateClient({
getVersion(target).catch(() => null),
])

const after = Date.now()
if (sourceVersion && targetVersion && sourceVersion === targetVersion) {
debug(`Getting hashes took ${after - before}ms`)
debug(
`Skipping ${filePath} to ${target} as both files have md5 hash ${sourceVersion}`,
)
// skip
} else {
debug(`Copying ${filePath} to ${target}`)
await copyFile(filePath, target)
}
}
Expand Down Expand Up @@ -275,7 +265,6 @@ export async function generateClient({
process.env.INIT_CWD,
'node_modules/.prisma/client',
)
debug({ finalOutputDir, backupPath })
if (finalOutputDir !== backupPath) {
await copy({
from: finalOutputDir,
Expand Down
7 changes: 6 additions & 1 deletion src/packages/client/src/runtime/getPrismaClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { printStack } from './utils/printStack'
import stripAnsi from 'strip-ansi'
import { printJsonWithErrors } from './utils/printJsonErrors'
import { InternalDatasource } from './utils/printDatasources'
import { omit } from './utils/omit'

export type ErrorFormat = 'pretty' | 'colorless' | 'minimal'

Expand Down Expand Up @@ -214,7 +215,11 @@ export function getPrismaClient(config: GetPrismaClientOptions): any {
flags: options.forceTransactions ? ['--always-force-transactions'] : [],
}

debug({ engineConfig: this.engineConfig })
const sanitizedEngineConfig = omit(this.engineConfig, [
'env',
'datasources',
])
debug({ engineConfig: sanitizedEngineConfig })

this.engine = new NodeEngine(this.engineConfig)
this.fetcher = new PrismaClientFetcher(this, false, this.hooks)
Expand Down
19 changes: 0 additions & 19 deletions src/packages/fetch-engine/src/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ export async function download(options: DownloadOptions): Promise<BinaryPaths> {
options.version,
options.failSilent,
)
debug({ needsToBeDownloaded })
return !job.envVarPath && (options.ignoreCache || needsToBeDownloaded)
})

Expand Down Expand Up @@ -273,41 +272,29 @@ async function binaryNeedsToBeDownloaded(
failSilent,
})

debug({ fileExists: targetExists, cachedFile })

if (cachedFile) {
debug({ cachedFile })
const sha256FilePath = cachedFile + '.sha256'
if (await exists(sha256FilePath)) {
const sha256File = await readFile(sha256FilePath, 'utf-8')
const sha256Cache = await hasha.fromFile(cachedFile, {
algorithm: 'sha256',
})
debug({ sha256File, sha256Cache, cachedFile, sha256FilePath })
if (sha256File === sha256Cache) {
if (!targetExists) {
await copy(cachedFile, job.targetFilePath)
}
const targetSha256 = await hasha.fromFile(job.targetFilePath, {
algorithm: 'sha256',
})
debug({ targetSha256 })
if (sha256File !== targetSha256) {
debug(
`sha256 of target file is incorrect, therefore it's corrupt and we need to copy it over again.`,
)
await copy(cachedFile, job.targetFilePath)
} else {
debug(`sha256 of target is correct, so there's nothing to do :)`)
}
return false
} else {
debug(`Cached sha256 is not correct!`)
debug(`Took it from ${sha256FilePath}`)
return true
}
} else {
debug(`No sha256 exists for ${cachedFile}. Looked at ${sha256FilePath}`)
return true
}
}
Expand All @@ -320,7 +307,6 @@ async function binaryNeedsToBeDownloaded(
// 3. If same platform, always check --version
if (job.binaryTarget === nativePlatform) {
const works = await checkVersionCommand(job.targetFilePath)
debug({ works })
return !works
}

Expand All @@ -330,8 +316,6 @@ async function binaryNeedsToBeDownloaded(
export async function getVersion(enginePath: string): Promise<string> {
const result = await execa(enginePath, ['--version'])

debug(`Getting version of ${enginePath}. Result: `, result)

return result.stdout
}

Expand All @@ -341,10 +325,8 @@ export async function checkVersionCommand(
try {
const version = await getVersion(enginePath)

debug(`Getting version of ${enginePath}. Result: `, version)
return version.length > 0
} catch (e) {
debug(`Version command does not work`, e)
return false
}
}
Expand Down Expand Up @@ -448,7 +430,6 @@ async function downloadBinary(options: DownloadBinaryOptions): Promise<void> {
progressCb(0)
}

debug(`Downloading zip`)
const { sha256, zippedSha256 } = await downloadZip(
downloadUrl,
targetFilePath,
Expand Down
4 changes: 0 additions & 4 deletions src/packages/fetch-engine/src/downloadZip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ export async function downloadZip(
`sha256 of ${url} (uzipped) should be ${sha256} but is ${hash}`,
)
}

debug(`sha-256 are correct
zipped: ${zippedSha256}
unzipped: ${sha256}`)
})
} finally {
//
Expand Down
2 changes: 0 additions & 2 deletions src/packages/generator-helper/src/GeneratorProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ export class GeneratorProcess {
const spawnCommand = isBinary ? command : process.execPath
const spawnArgs = isBinary ? args : ['--max-old-space-size=8096', command]

debug({ isBinary, command, args, spawnCommand, spawnArgs })

this.child = spawn(spawnCommand, spawnArgs, {
stdio: ['pipe', 'inherit', 'pipe'],
})
Expand Down
5 changes: 0 additions & 5 deletions src/packages/get-platform/src/getPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ export async function getOpenSSLVersion(): Promise<string | undefined> {
`),
])

debug({ version })
debug({ ls })

if (version) {
const v = parseOpenSSLVersion(version)
if (v) {
Expand Down Expand Up @@ -136,8 +133,6 @@ async function gracefulExec(cmd: string): Promise<string | undefined> {
export async function getPlatform(): Promise<Platform> {
const { platform, libssl, distro } = await getos()

debug({ platform, libssl })

if (platform === 'darwin') {
return 'darwin'
}
Expand Down
8 changes: 0 additions & 8 deletions src/packages/migrate/src/Migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ export class Migrate {
}: WatchOptions = { clear: true, providerAliases: {} },
renderer?: DevComponentRenderer,
) => {
debug('Running watchUp')
renderer && renderer.setState({ error: undefined })
const datamodel = this.getDatamodel()
try {
Expand Down Expand Up @@ -349,13 +348,6 @@ export class Migrate {
})

if (datamodelSteps.length === 0) {
debug(`No datamodelSteps`)
debug(`No datamodelSteps`)
debug(`No datamodelSteps`)
debug(`No datamodelSteps`)
debug(`No datamodelSteps`)
debug(`No datamodelSteps`)
debug({ datamodelSteps, databaseSteps, warnings })
return undefined
}

Expand Down
2 changes: 1 addition & 1 deletion src/packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"scripts"
],
"prisma": {
"version": "3cd2e8691906b5d6be11fe6e7e154f2a9928b6ff"
"version": "f401775ef1c681c705db8fd8d6cecaa5a4eb44fd"
},
"devDependencies": {
"@types/jest": "25.2.1",
Expand Down
2 changes: 0 additions & 2 deletions src/packages/sdk/src/Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class Generator {
}
async init(): Promise<void> {
await this.generatorProcess.init()
this.debug(`Sending "getManifest" rpc to generator`)
this.manifest = await this.generatorProcess.getManifest()
}
stop(): void {
Expand All @@ -29,7 +28,6 @@ export class Generator {
`Please first run .setOptions() on the Generator to initialize the options`,
)
}
this.debug(`Sending "generate" rpc to generator`)
return this.generatorProcess.generate(this.options)
}
setOptions(options: GeneratorOptions): void {
Expand Down

0 comments on commit faa6756

Please sign in to comment.