Added git hooks

This commit is contained in:
Sebastian Seedorf
2022-08-18 13:45:05 +02:00
parent 07469dde88
commit b97c922ff3
7 changed files with 42 additions and 26 deletions

4
.husky/pre-commit Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn run lint-staged

View File

@@ -129,7 +129,7 @@ export const GroupProvider: FC<Props> = ({ children, id, initial }) => {
factories: val factories: val
} as SetFactoryArrayBody).catch(console.error) } as SetFactoryArrayBody).catch(console.error)
}, },
[id] [id, router]
) )
const setBasicValues = useCallback<typeof _setBasicValues>( const setBasicValues = useCallback<typeof _setBasicValues>(
@@ -140,7 +140,7 @@ export const GroupProvider: FC<Props> = ({ children, id, initial }) => {
factories: val factories: val
} as SetFactoryArrayBody).catch(console.error) } as SetFactoryArrayBody).catch(console.error)
}, },
[id] [id, router]
) )
const addGroup = useCallback( const addGroup = useCallback(
@@ -180,7 +180,7 @@ export const GroupProvider: FC<Props> = ({ children, id, initial }) => {
})().catch(console.error) })().catch(console.error)
return true return true
}, },
[groups, id] [groups, id, router]
) )
const removeGroup = useCallback( const removeGroup = useCallback(
(name: string) => { (name: string) => {
@@ -195,7 +195,7 @@ export const GroupProvider: FC<Props> = ({ children, id, initial }) => {
{} {}
).catch(console.error) ).catch(console.error)
}, },
[id] [id, router]
) )
const renameGroup = useCallback( const renameGroup = useCallback(
(name: string, newName: string) => { (name: string, newName: string) => {
@@ -215,7 +215,7 @@ export const GroupProvider: FC<Props> = ({ children, id, initial }) => {
} as GroupRenameBody } as GroupRenameBody
).catch(console.error) ).catch(console.error)
}, },
[groups, id] [groups, id, router]
) )
const setFactories = useCallback( const setFactories = useCallback(
@@ -234,7 +234,7 @@ export const GroupProvider: FC<Props> = ({ children, id, initial }) => {
} as GroupSetFactoryArrayBody } as GroupSetFactoryArrayBody
).catch(console.error) ).catch(console.error)
}, },
[id] [id, router]
) )
const getInputType = useCallback( const getInputType = useCallback(
(uid: string) => { (uid: string) => {

View File

@@ -50,7 +50,13 @@ export const Home: FC = () => {
Store Store
</button> </button>
<button <button
onClick={() => postFetchJson(router, `/api/${router.query.id}/upload`, { groups, ignored: ignoredFactories, base: baseFactories } as UploadDataBody)} onClick={() =>
postFetchJson(router, `/api/${router.query.id}/upload`, {
groups,
ignored: ignoredFactories,
base: baseFactories
} as UploadDataBody)
}
> >
Upload Upload
</button> </button>

View File

@@ -6,12 +6,14 @@ import {useRouter} from 'next/router'
const MyApp: FC<AppProps> = ({ Component, pageProps }) => { const MyApp: FC<AppProps> = ({ Component, pageProps }) => {
const router = useRouter() const router = useRouter()
return <> return (
<>
<Head> <Head>
<link rel='icon' href={`${router.basePath}/favicon.ico`} /> <link rel='icon' href={`${router.basePath}/favicon.ico`} />
</Head> </Head>
<Component {...pageProps} /> <Component {...pageProps} />
</> </>
)
} }
export default MyApp export default MyApp

View File

@@ -16,7 +16,10 @@ export type InsertMeta<T> = T & {
type GroupFilter = Filter<InsertMeta<GroupData>> type GroupFilter = Filter<InsertMeta<GroupData>>
export async function setData(uuid: string|undefined, data: GroupData): Promise<string | undefined> { export async function setData(
uuid: string | undefined,
data: GroupData
): Promise<string | undefined> {
const collection = (await database.resolve())?.collection('setups') const collection = (await database.resolve())?.collection('setups')
if (!collection) return if (!collection) return
if (!uuid) { if (!uuid) {

View File

@@ -43,7 +43,8 @@ export function addSchemas() {
type: 'object', type: 'object',
required: ['groups', 'ignored', 'base'], required: ['groups', 'ignored', 'base'],
properties: { properties: {
groups: { type: 'object', groups: {
type: 'object',
additionalProperties: { additionalProperties: {
type: 'object', type: 'object',
required: ['name', 'exports', 'malls'], required: ['name', 'exports', 'malls'],
@@ -51,7 +52,7 @@ export function addSchemas() {
name: { type: 'string', minLength: 1 }, name: { type: 'string', minLength: 1 },
exports: { type: 'array', items: { type: 'string', minLength: 3 } }, exports: { type: 'array', items: { type: 'string', minLength: 3 } },
malls: { type: 'array', items: { type: 'string', minLength: 3 } } malls: { type: 'array', items: { type: 'string', minLength: 3 } }
}, }
} }
}, },
ignored: { type: 'array', items: { type: 'string', minLength: 3 } }, ignored: { type: 'array', items: { type: 'string', minLength: 3 } },