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

Proposed v 1.15 - Update dependencies, remove @prisma/internals, fix node 14 support #11

Merged
merged 5 commits into from
Dec 4, 2022

Conversation

zackdotcomputer
Copy link

This is 3 main changes:

  1. Update all dependencies to latest, including a fix via npm audit fix for the minimatch CVE
  2. Break the dependency on @prisma/internals by moving to vanilla console.log for logging (which is what Prisma's logger was doing anyways) and by bringing the parseEnv function into the codebase locally.
  3. Fix a usage of replaceAll that was breaking compatibility with Node 14 per String replaceAll function not present until Node 15/16 #10 .

Copy link
Owner

@Brakebein Brakebein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing! Regarding @prisma/internals dependency, see comment below.

@@ -68,7 +68,7 @@ function extractAnnotation(
*/
function encapsulateString(value: string): string {
return /^$|^(?!true$|false$)[^0-9\[]/.test(value)
? `'${value.replaceAll(/'/g, "\\'")}'`
? `'${value.replace(/'/g, "\\'")}'`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why I used replaceAll, since the regular expression is already global.

@@ -2,15 +2,14 @@ import fs from 'node:fs/promises';
import path from 'node:path';
import makeDir from 'make-dir';
import { generatorHandler } from '@prisma/generator-helper';
import { parseEnvValue, logger } from '@prisma/internals';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why there is the need to get rid of @prisma/internals? It is installed anyway along with @prisma/client. Hence, parseEnvValue doesn't need to be implemented twice. And the prisma logger has the nice side effect that it prefixes the output with cyan-colored "prisma:info".

Can you elaborate more on the reasons why?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure - I had both felt nervous about the local usage of it because it was leading to Prisma to issue a warning saying that it wasn't intended for external use and because I was having issues where it would deadlock my imports because of the CJS -> ESM -> CJS back and forth apparently causing problems for webpack's compiled imports.

That was, though, with the root package we're both forked off of (I wrote this PR for that package but then found your fork and decided to contribute here instead).

I do think parseEnvValue is easy enough to clone out and use directly. I can see if this fork has the same CJS/ESM conflict that the origin package had, if that's not causing runtime issues anymore for me I'm happy to switch back to it.

@Brakebein Brakebein merged commit 61c7425 into Brakebein:main Dec 4, 2022
@zackdotcomputer
Copy link
Author

Thanks @Brakebein - sorry I fell off on the follow-ups. I was doing this for a migration at work and it has been more difficult than we'd hoped (as they always are). Let me know if I can help out here, though. Happy for this package to thrive especially since we'll be using it in production as of this week...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants