File tree Expand file tree Collapse file tree 6 files changed +82
-8
lines changed
Expand file tree Collapse file tree 6 files changed +82
-8
lines changed Original file line number Diff line number Diff line change 1- pnpm typecheck && pnpm test
1+ pnpm typecheck && pnpm test:unit
Original file line number Diff line number Diff line change 1212 "lint" : " eslint \" src/**/*.ts\" " ,
1313 "lint:fix" : " eslint \" src/**/*.ts\" --fix" ,
1414 "test" : " vitest run" ,
15- "test:unit" : " vitest run src/ " ,
15+ "test:unit" : " vitest run --config vitest.unit.config.ts " ,
1616 "test:integration" : " vitest run test/integration/" ,
1717 "test:watch" : " vitest" ,
1818 "test:coverage" : " vitest run --coverage" ,
Original file line number Diff line number Diff line change 11import { betterAuth } from 'better-auth' ;
22import { prismaAdapter } from 'better-auth/adapters/prisma' ;
33import { admin } from 'better-auth/plugins' ;
4+ import { createAccessControl } from 'better-auth/plugins/access' ;
5+ import { adminAc , defaultStatements } from 'better-auth/plugins/admin/access' ;
46import type { FastifyPluginAsync , FastifyRequest } from 'fastify' ;
57import fp from 'fastify-plugin' ;
68
79import { loadEnv } from '@/config/env.js' ;
810import { RATE_LIMIT_CONFIG } from '@/config/rate-limit.js' ;
911import { type PrismaClient } from '@/generated/client/client.js' ;
1012
13+ const ac = createAccessControl ( defaultStatements ) ;
14+
15+ const adminRole = ac . newRole ( {
16+ ...adminAc . statements ,
17+ } ) ;
18+
19+ const superAdminRole = ac . newRole ( {
20+ ...adminAc . statements ,
21+ } ) ;
22+
1123declare module 'fastify' {
1224 interface FastifyInstance {
1325 auth : ReturnType < typeof betterAuth > ;
@@ -91,8 +103,12 @@ const authPlugin: FastifyPluginAsync = async (app) => {
91103 socialProviders,
92104 plugins : [
93105 admin ( {
106+ ac,
107+ roles : {
108+ admin : adminRole ,
109+ super_admin : superAdminRole ,
110+ } ,
94111 defaultRole : 'user' ,
95- adminRoles : [ 'admin' , 'super_admin' ] ,
96112 } ) ,
97113 ] ,
98114 } ) ;
Original file line number Diff line number Diff line change 1+ import tsconfigPaths from 'vite-tsconfig-paths' ;
2+ import { defineConfig , mergeConfig } from 'vitest/config' ;
3+
4+ import { sharedConfig } from '../../vitest.shared' ;
5+
6+ export default mergeConfig (
7+ sharedConfig ,
8+ defineConfig ( {
9+ test : {
10+ name : '@repo/api-unit' ,
11+ include : [ 'src/**/*.spec.ts' ] ,
12+ globals : true ,
13+ root : './' ,
14+ } ,
15+ plugins : [ tsconfigPaths ( ) ] ,
16+ } )
17+ ) ;
Original file line number Diff line number Diff line change 11{
22 "name" : " create-blitzpack" ,
3- "version" : " 0.1.12 " ,
3+ "version" : " 0.1.13 " ,
44 "description" : " Create a new Blitzpack project - full-stack TypeScript monorepo with Next.js and Fastify" ,
55 "type" : " module" ,
66 "bin" : {
Original file line number Diff line number Diff line change @@ -87,18 +87,59 @@ export async function getProjectOptions(
8787}
8888
8989async function promptFeatureSelection ( ) : Promise < FeatureOptions | null > {
90+ let cancelled = false ;
91+
92+ const { setupType } = await prompts (
93+ {
94+ type : 'select' ,
95+ name : 'setupType' ,
96+ message : 'Setup type:' ,
97+ choices : [
98+ {
99+ title : 'Recommended' ,
100+ description : 'all features included' ,
101+ value : 'recommended' ,
102+ } ,
103+ {
104+ title : 'Customize' ,
105+ description : 'choose features' ,
106+ value : 'customize' ,
107+ } ,
108+ ] ,
109+ initial : 0 ,
110+ hint : '- Use arrow-keys, Enter to submit' ,
111+ } ,
112+ {
113+ onCancel : ( ) => {
114+ cancelled = true ;
115+ } ,
116+ }
117+ ) ;
118+
119+ if ( cancelled ) {
120+ return null ;
121+ }
122+
123+ if ( setupType === 'recommended' ) {
124+ return {
125+ testing : true ,
126+ admin : true ,
127+ uploads : true ,
128+ } ;
129+ }
130+
90131 const featureChoices = OPTIONAL_FEATURES . map ( ( feature ) => ( {
91- title : `${ feature . name } ${ chalk . dim ( `(${ feature . description } )` ) } ` ,
132+ title : feature . name ,
133+ description : feature . description ,
92134 value : feature . key ,
93- selected : true ,
135+ selected : false ,
94136 } ) ) ;
95137
96- let cancelled = false ;
97138 const { selectedFeatures } = await prompts (
98139 {
99140 type : 'multiselect' ,
100141 name : 'selectedFeatures' ,
101- message : 'Include optional features:' ,
142+ message : 'Select features to include :' ,
102143 choices : featureChoices ,
103144 hint : '- Space to toggle, Enter to confirm' ,
104145 instructions : false ,
You can’t perform that action at this time.
0 commit comments