chore: fix build errors
This commit is contained in:
parent
1be0facd64
commit
3e67d18749
@ -44,6 +44,15 @@ export const route = createRoute({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const getVersion = (version: string) => {
|
||||||
|
const isValid = semver.valid(semver.coerce(version))
|
||||||
|
|
||||||
|
if (isValid) {
|
||||||
|
return isValid
|
||||||
|
}
|
||||||
|
return format(new Date(), 'dd.MM.yy')
|
||||||
|
}
|
||||||
|
|
||||||
const getNextVersion = ({
|
const getNextVersion = ({
|
||||||
version,
|
version,
|
||||||
isSemver,
|
isSemver,
|
||||||
@ -52,11 +61,15 @@ const getNextVersion = ({
|
|||||||
if (version === '') {
|
if (version === '') {
|
||||||
return '1.0.0'
|
return '1.0.0'
|
||||||
}
|
}
|
||||||
const nextVersion = semver.inc(version, 'patch')
|
const isValid = semver.valid(semver.coerce(version))
|
||||||
if (!nextVersion) {
|
|
||||||
throw new Error('Incorrect semver')
|
if (isValid) {
|
||||||
|
const nextVersion = semver.inc(isValid, 'patch')
|
||||||
|
if (!nextVersion) {
|
||||||
|
throw new Error('Incorrect semver')
|
||||||
|
}
|
||||||
|
return nextVersion
|
||||||
}
|
}
|
||||||
return nextVersion
|
|
||||||
}
|
}
|
||||||
return format(new Date(), 'dd.MM.yy')
|
return format(new Date(), 'dd.MM.yy')
|
||||||
}
|
}
|
||||||
@ -64,7 +77,6 @@ const getNextVersion = ({
|
|||||||
export const registerVersionCreateAuto = (api: typeof changelogVersionApi) => {
|
export const registerVersionCreateAuto = (api: typeof changelogVersionApi) => {
|
||||||
return api.openapi(route, async (c) => {
|
return api.openapi(route, async (c) => {
|
||||||
const userId = verifyAuthentication(c)
|
const userId = verifyAuthentication(c)
|
||||||
|
|
||||||
const data: z.infer<typeof VersionCreateAutoInput> = await c.req.json()
|
const data: z.infer<typeof VersionCreateAutoInput> = await c.req.json()
|
||||||
const changelogResult = await db.query.changelog.findFirst({
|
const changelogResult = await db.query.changelog.findFirst({
|
||||||
where: and(
|
where: and(
|
||||||
@ -136,10 +148,12 @@ export const registerVersionCreateAuto = (api: typeof changelogVersionApi) => {
|
|||||||
.insert(changelog_version)
|
.insert(changelog_version)
|
||||||
.values({
|
.values({
|
||||||
changelogId: changelogResult.id,
|
changelogId: changelogResult.id,
|
||||||
version: getNextVersion({
|
version: data.version
|
||||||
version: data.version ?? changelogResult.versions[0].version,
|
? getVersion(data.version)
|
||||||
isSemver: changelogResult.isSemver ?? true,
|
: getNextVersion({
|
||||||
}),
|
version: changelogResult.versions[0].version,
|
||||||
|
isSemver: changelogResult.isSemver ?? true,
|
||||||
|
}),
|
||||||
status: 'draft',
|
status: 'draft',
|
||||||
markdown,
|
markdown,
|
||||||
})
|
})
|
||||||
|
@ -25,7 +25,7 @@ export const ChangelogVersionCreateStep02 = () => {
|
|||||||
resolver: zodResolver(VersionCreateAutoInput),
|
resolver: zodResolver(VersionCreateAutoInput),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
changelogId: id,
|
changelogId: id,
|
||||||
version: null,
|
version: '',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ import {
|
|||||||
import '@mdxeditor/editor/style.css'
|
import '@mdxeditor/editor/style.css'
|
||||||
import { format } from 'date-fns'
|
import { format } from 'date-fns'
|
||||||
import { CalendarIcon } from 'lucide-react'
|
import { CalendarIcon } from 'lucide-react'
|
||||||
import { useEffect, useRef, useState } from 'react'
|
import { useEffect, useRef } from 'react'
|
||||||
import { ChangelogVersionDelete } from '../components/Changelog/VersionDelete'
|
import { ChangelogVersionDelete } from '../components/Changelog/VersionDelete'
|
||||||
import { VersionStatus } from '../components/Changelog/VersionStatus'
|
import { VersionStatus } from '../components/Changelog/VersionStatus'
|
||||||
|
|
||||||
@ -55,7 +55,6 @@ const Component = () => {
|
|||||||
const { data, error, isPending, refetch } = useChangelogVersionById({
|
const { data, error, isPending, refetch } = useChangelogVersionById({
|
||||||
id: versionId,
|
id: versionId,
|
||||||
})
|
})
|
||||||
const [editorValue, setEditorValue] = useState('')
|
|
||||||
const form = useForm<z.infer<typeof VersionUpdateInput>>({
|
const form = useForm<z.infer<typeof VersionUpdateInput>>({
|
||||||
resolver: zodResolver(VersionUpdateInput),
|
resolver: zodResolver(VersionUpdateInput),
|
||||||
defaultValues: data,
|
defaultValues: data,
|
||||||
|
@ -17,7 +17,7 @@ export const VersionCreateInput = z
|
|||||||
|
|
||||||
export const VersionCreateAutoInput = z
|
export const VersionCreateAutoInput = z
|
||||||
.object({
|
.object({
|
||||||
version: z.string().optional().nullable(),
|
version: z.string().optional(),
|
||||||
changelogId: z.string().uuid(),
|
changelogId: z.string().uuid(),
|
||||||
})
|
})
|
||||||
.openapi({
|
.openapi({
|
||||||
|
Loading…
Reference in New Issue
Block a user