Skip to content

Commit

Permalink
feat: prisma task support vscode and prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
bingtsingw committed Aug 21, 2022
1 parent 6cc8cde commit aef4c2d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 19 additions & 1 deletion prisma/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { chmodSync, existsSync } = require('fs');
const { install, packageJson, template } = require('mrm-core');
const { install, packageJson, template, json } = require('mrm-core');
const { join } = require('path');
const { hasPrettier } = require('../utils');

const task = async () => {
const { execa } = await import('execa');
Expand All @@ -20,6 +21,23 @@ const task = async () => {
const diff = 'prisma/diff.sh';
template(diff, join(__dirname, '../templates/prisma/diff.sh')).apply().save();
chmodSync(diff, 0755);

json('.vscode/settings.json')
.merge({
'[prisma]': {
'editor.defaultFormatter': 'Prisma.prisma',
},
})
.save();

if (hasPrettier) {
install(['prettier-plugin-prisma']);
json('.prettierrc.json')
.merge({
plugins: ['prettier-plugin-prisma'],
})
.save();
}
};

task.description = 'Add prisma';
Expand Down
3 changes: 3 additions & 0 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ const cosmiconfig = (name) => {

const hasHusky = !!packageJson().get('devDependencies.husky');

const hasPrettier = !!packageJson().get('devDependencies.prettier');

const hasTypescript = !!packageJson().get('devDependencies.typescript');

const hasLintStaged = !!packageJson().get('devDependencies.lint-staged');

module.exports.removeMatch = removeMatch;
module.exports.cosmiconfig = cosmiconfig;
module.exports.hasHusky = hasHusky;
module.exports.hasPrettier = hasPrettier;
module.exports.hasTypescript = hasTypescript;
module.exports.hasLintStaged = hasLintStaged;

0 comments on commit aef4c2d

Please sign in to comment.