Skip to content

Commit

Permalink
[0.1.7] Actually (finally) fix build output (#13)
Browse files Browse the repository at this point in the history
* Actually (finally) fix build output (using tsup)

* Bump version

* Add "type-check" to CI

* add type checking for /example files

* Build before type-check
  • Loading branch information
nkeil authored Mar 31, 2024
1 parent 21f0c16 commit 4d86a53
Show file tree
Hide file tree
Showing 9 changed files with 506 additions and 25 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ jobs:
- name: Build
run: pnpm build

- name: Type Check
run: pnpm type-check

- name: Test
run: pnpm test

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
node_modules/

dist/
dist1/
dist2/

# dotenv environment variable files
.env
Expand Down
4 changes: 2 additions & 2 deletions example/db.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { prisma } from './db';
import { prisma } from './db.js';
import { assert, beforeEach, test } from 'vitest';

const POPULATION = 1000;
Expand Down Expand Up @@ -48,7 +48,7 @@ test('findRandom distribution', async () => {
const mean = sum / NUM_TRIALS;
const std = Math.sqrt(
Object.keys(results)
.map((idx) => results[idx] * Math.pow(+idx - mean, 2))
.map((idx) => (results[idx] ?? 0) * Math.pow(+idx - mean, 2))
.reduce((a, b) => a + b) / NUM_TRIALS,
);
console.log({ mean, std });
Expand Down
2 changes: 1 addition & 1 deletion example/db.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PrismaClient } from '@prisma/client';
import prismaRandom from '../dist';
import prismaRandom from '../dist/index.js';

export const prisma = new PrismaClient().$extends(prismaRandom());
2 changes: 1 addition & 1 deletion example/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { prisma } from './db';
import { prisma } from './db.js';

const main = async () => {
const user = await prisma.user.findRandom();
Expand Down
2 changes: 1 addition & 1 deletion example/seed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { prisma } from './db';
import { prisma } from './db.js';

const users = [
{ firstName: 'Ida', lastName: 'Lupino' },
Expand Down
26 changes: 16 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "prisma-extension-random",
"version": "0.1.6",
"version": "0.1.7",
"type": "module",
"license": "MIT",
"author": "Nicolas Keil <nkeil.dev@gmail.com>",
"description": "Add some randomness to your favorite Prisma queries!",
Expand All @@ -20,22 +21,27 @@
],
"packageManager": "pnpm@8.15.5",
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"import": "./dist/index.js",
"default": "./dist/index.js"
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
},
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"files": [
"dist/**/*"
],
"scripts": {
"build": "rimraf dist && tsc",
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
"watch": "pnpm build --watch src",
"dev": "tsx example/index.ts",
"test": "npx prisma db push && vitest",
"format": "prettier --write \"**/*.ts\" \"**/*.md\" --ignore-unknown --no-error-on-unmatched-pattern",
Expand All @@ -49,7 +55,7 @@
"@types/node": "^20.12.2",
"prettier": "^3.2.5",
"prisma": "^5.11.0",
"rimraf": "^5.0.5",
"tsup": "^8.0.2",
"tsx": "^4.7.1",
"typescript": "5.4.3",
"vitest": "^1.4.0"
Expand Down
Loading

0 comments on commit 4d86a53

Please sign in to comment.