Skip to content

Commit

Permalink
feat: Allow the use of the generate function without the onGenerate
Browse files Browse the repository at this point in the history
  • Loading branch information
unlight committed Jul 4, 2023
1 parent ed40f13 commit a566cca
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 22 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022
Copyright (c) 2023

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
33 changes: 15 additions & 18 deletions Taskfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
PATH="$PWD/node_modules/.bin":$PATH
set -e

build_hybrid() {
build() {
set -x
rm -rfv dist
npx tsup src/index.ts -d=dist/esm --keep-names --format=esm --target=es2020 --sourcemap
npx tsup src/index.ts -d=dist/cjs --keep-names --format=cjs --target=es2020 --sourcemap
npx tsup src/index.ts -d=dist --dts-only
echo {\"type\": \"module\"} >dist/esm/package.json
echo {\"type\": \"commonjs\"} >dist/cjs/package.json
cp -fv README.md LICENSE dist
cat package.json | jq "del(.type)" >dist/package.json

# bin
rm -rf dist
mkdir dist
# https://esbuild.github.io/api/#target
cp -fv src/bin.js dist
cp -fv README.md LICENSE dist
npx pkgroll --target=es2020
cat package.json | jq '.main = "./index.cjs"' |
jq '.types = "./index.d.ts"' |
jq '.exports.".".require = "./index.cjs"' |
jq '.exports.".".types = "./index.d.ts"' |
jq '.typesVersions."*".generate = ["./generate.d.ts"]' |
jq '.exports."./generate".require = "./generate.cjs"' |
jq '.exports."./generate".types = "./generate.d.ts"' \
>dist/package.json
set +x
}

compatibilty_check() {
Expand Down Expand Up @@ -57,13 +61,6 @@ compatibilty_check() {
set +x
}

bundle() {
set -x
npx tsup src/index.ts --format cjs --target es2020
cp -fv README.md LICENSE package.json dist
cp -fv src/bin.js dist
}

commit_lint() {
if git-branch-is -q -r "^(master)"; then
commitlint --edit
Expand Down
22 changes: 20 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "0.0.0-dev",
"license": "MIT",
"description": "Generate object types, inputs, args, etc. from prisma schema file for usage with @nestjs/graphql module",
"main": "index.js",
"bin": "bin.js",
"repository": {
"type": "git",
Expand All @@ -20,6 +19,25 @@
"prisma-generator",
"nestjs-graphql"
],
"main": "./dist/index.cjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
},
"./generate": {
"require": "./dist/generate.cjs",
"types": "./dist/generate.d.ts"
}
},
"typesVersions": {
"*": {
"generate": [
"dist/generate.d.ts"
]
}
},
"scripts": {
"test": "npm run eslint && npm run tscheck && npm run test:cov",
"mocha": "node node_modules/mocha/bin/mocha",
Expand All @@ -32,7 +50,7 @@
"eslint": "node node_modules/eslint/bin/eslint \"src/**/*.{ts,tsx}\"",
"eslint:w": "watchexec -w src \"npm run eslint\"",
"eslint:fix": "npm run eslint -- --fix",
"build": "sh Taskfile bundle",
"build": "sh Taskfile build",
"prisma:g": "node node_modules/prisma/build/index.js generate",
"format": "npx prettier ./@generated --write",
"regen": "rm -rf @generated && npm run prisma:g && npm run format",
Expand Down
2 changes: 1 addition & 1 deletion src/bin.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('./index.js');
require('./index.cjs');

0 comments on commit a566cca

Please sign in to comment.