Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@prisma/generator-helper
Advanced tools
This package is intended for Prisma's internal use
@prisma/generator-helper is a utility package designed to assist in the creation of custom generators for Prisma. It provides a set of tools and types to facilitate the development of generators that can extend or customize the behavior of Prisma's schema and client generation.
Generator Definition
This feature allows you to define a custom generator by specifying the manifest and generation logic. The `onManifest` function provides metadata about the generator, while the `onGenerate` function contains the logic to execute when the generator is run.
const { generatorHandler } = require('@prisma/generator-helper');
generatorHandler({
onManifest() {
return {
defaultOutput: 'default-output-path',
prettyName: 'My Custom Generator',
};
},
onGenerate(options) {
console.log('Generating with options:', options);
},
});
Helper Types
The package provides TypeScript types for Prisma's Data Model Meta Format (DMMF), which can be used to type-check and process the Prisma schema programmatically.
const { DMMF } = require('@prisma/generator-helper');
/**
* @param {DMMF.Document} dmmf
*/
function processDMMF(dmmf) {
console.log('Processing DMMF:', dmmf);
}
File Writing Utilities
This feature includes utilities for safely writing files, ensuring that directories are created as needed and that existing files are not overwritten unintentionally.
const { writeFileSafely } = require('@prisma/generator-helper');
const path = require('path');
const outputPath = path.join(__dirname, 'output.txt');
writeFileSafely(outputPath, 'Generated content').then(() => {
console.log('File written successfully');
});
Yeoman Generator is a robust scaffolding tool for building out new projects. It provides a higher-level abstraction for creating generators, including prompts, file system utilities, and more. Compared to @prisma/generator-helper, Yeoman is more general-purpose and not specifically tailored to Prisma.
Plop is a micro-generator framework that makes it easy to create code generators with a simple API. It focuses on simplicity and ease of use, making it a good alternative for smaller, less complex generator tasks. Unlike @prisma/generator-helper, Plop is not specifically designed for Prisma and lacks Prisma-specific utilities and types.
Hygen is a fast and lightweight code generator that uses plain text templates. It is designed for quick and easy setup and usage. While it is versatile and can be used for various generation tasks, it does not offer the Prisma-specific features and types provided by @prisma/generator-helper.
⚠️ Warning: This package is intended for Prisma's internal use. Its release cycle does not follow SemVer, which means we might release breaking changes (change APIs, remove functionality) without any prior warning.
If you are using this package, it would be helpful if you could help us gain an understanding where, how and why you are using it. Your feedback will be valuable to us to define a better API. Please share this information at https://github.com/prisma/prisma/discussions/13877 - Thanks!
FAQs
This package is intended for Prisma's internal use
We found that @prisma/generator-helper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.