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

View File

@@ -50,7 +50,13 @@ export const Home: FC = () => {
Store
</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
</button>

View File

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

View File

@@ -16,7 +16,10 @@ export type InsertMeta<T> = T & {
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')
if (!collection) return
if (!uuid) {

View File

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