Added git hooks
This commit is contained in:
4
.husky/pre-commit
Executable file
4
.husky/pre-commit
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
yarn run lint-staged
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
GroupSetFactoryArrayBody,
|
||||
SetFactoryArrayBody
|
||||
} from '../../src/types/ApiSchemasFrontend'
|
||||
import {NextRouter, useRouter} from 'next/router'
|
||||
import { NextRouter, useRouter } from 'next/router'
|
||||
|
||||
interface Props {
|
||||
children: ReactNodeLike
|
||||
@@ -93,7 +93,7 @@ interface StoredFile {
|
||||
}
|
||||
|
||||
export const postFetchJson = async (router: NextRouter, url: string, body: unknown) => {
|
||||
const res = await fetch(router.basePath+url, {
|
||||
const res = await fetch(router.basePath + url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -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) => {
|
||||
|
||||
@@ -4,12 +4,12 @@ import styles from './Home.module.css'
|
||||
import { useFactories } from '../../src/hooks/useFactories'
|
||||
import { EnrichedEntity } from '../../src/types'
|
||||
import { EntitySpan } from './EntitySpan/EntitySpan'
|
||||
import {postFetchJson, useGroups} from '../contexts/GroupProvider'
|
||||
import { postFetchJson, useGroups } from '../contexts/GroupProvider'
|
||||
import { Preferences } from './Preferences/Preferences'
|
||||
import { download, streamToArrayBuffer } from '../../src/download'
|
||||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/router'
|
||||
import {UploadDataBody} from '../../src/types/ApiSchemasFrontend'
|
||||
import { UploadDataBody } from '../../src/types/ApiSchemasFrontend'
|
||||
|
||||
export const Home: FC = () => {
|
||||
const router = useRouter()
|
||||
@@ -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>
|
||||
|
||||
@@ -2,16 +2,18 @@ import '../styles/globals.css'
|
||||
import type { AppProps } from 'next/app'
|
||||
import { FC } from 'react'
|
||||
import Head from 'next/head'
|
||||
import {useRouter} from 'next/router'
|
||||
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
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { setData } from '../../../src/database/groups'
|
||||
import { nextHandler } from '../../../src/utils/errors'
|
||||
import { waitForInitSchemas } from '../../../src/validation/schemas'
|
||||
import {validate} from '../../../src/validation'
|
||||
import {IdParam, UploadDataBody} from '../../../src/types/ApiSchemas'
|
||||
import { validate } from '../../../src/validation'
|
||||
import { IdParam, UploadDataBody } from '../../../src/types/ApiSchemas'
|
||||
|
||||
const handler = nextHandler(async (req, res) => {
|
||||
if (req.method !== 'POST') throw new Error('Invalid method')
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -43,15 +43,16 @@ export function addSchemas() {
|
||||
type: 'object',
|
||||
required: ['groups', 'ignored', 'base'],
|
||||
properties: {
|
||||
groups: { type: 'object',
|
||||
groups: {
|
||||
type: 'object',
|
||||
additionalProperties: {
|
||||
type: 'object',
|
||||
required: ['name', 'exports', 'malls'],
|
||||
properties: {
|
||||
name: {type: 'string', minLength: 1},
|
||||
exports: {type: 'array', items: {type: 'string', minLength: 3}},
|
||||
malls: {type: 'array', items: {type: 'string', minLength: 3}}
|
||||
},
|
||||
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 } },
|
||||
|
||||
Reference in New Issue
Block a user