Skip to content

Commit

Permalink
feat(parser): update pacscript file parser to follow spec (#835)
Browse files Browse the repository at this point in the history
* feat(parser): update pacscript file parser to follow spec

* chore(parser): add jo and jq as runtime dependencies

* feat(git): add branch config

* chore: fixup some json parsing issues

* chore: remove outdated comment

* chore: fixes maintainers and adds git pkgver

* chore(package-list): fix maintainer text

* chore: increase gitpkgver timeout and handle git+https

* drop 5.0.0 programs tagging

---------

Co-authored-by: Paul Cosma <[email protected]>
Co-authored-by: oklopfer <[email protected]>
  • Loading branch information
3 people authored May 2, 2024
1 parent 0fbb6c2 commit 190e60c
Show file tree
Hide file tree
Showing 46 changed files with 1,197 additions and 301 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ COPY --from=client /root/client/dist/ /root/client/dist/
COPY --from=server /root/server/dist/ /root/server/dist/
COPY ./Makefile ./Makefile

RUN apt update && apt install make git -y
RUN apt update && apt install make git jo jq -y

RUN make dist \
&& rm -rf server client
Expand Down
7 changes: 5 additions & 2 deletions client/src/components/package-details/MinimalPackageTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ const MinimalPackageTable: FC<{ packages: (PackageInfo | string)[] }> = ({
{packages.map((pkg, i) => (
<MinimalPackageTableRow
external={typeof pkg === 'string'}
key={(typeof pkg === 'string' ? pkg : pkg.name) + i}
pkg={typeof pkg === 'string' ? pkg : pkg.name}
key={
(typeof pkg === 'string' ? pkg : pkg.packageName) +
i
}
pkg={typeof pkg === 'string' ? pkg : pkg.packageName}
/>
))}
</Tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const PackageDetailsHeader: FC<{ data: PackageInfo; isMobile: boolean }> = (
<>
<HStack justify='space-between'>
<HStack>
<Heading>{data.name}</Heading>
<Heading>{data.packageName}</Heading>
</HStack>
{!isMobile && <InstallNowButton />}
</HStack>
Expand Down
82 changes: 52 additions & 30 deletions client/src/components/package-details/PackageDetailsMaintainer.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import { EmailIcon } from '@chakra-ui/icons'
import { Icon, Link, Tooltip } from '@chakra-ui/react'
import { FC } from 'react'
import { FC, Fragment } from 'react'
import { useTranslation } from 'react-i18next'

const PackageDetailsMaintainer: FC<{ text: string }> = ({ text }) => {
const PackageDetailsMaintainer: FC<{ text: string[] }> = ({
text: maintainers,
}) => {
const { t } = useTranslation()

if (
!text ||
text === '-' ||
text.toLowerCase() === 'orphan' ||
text.toLowerCase() === 'orphaned'
!maintainers?.length ||
maintainers[0] === '-' ||
maintainers[0].toLowerCase() === 'orphan' ||
maintainers[0].toLowerCase() === 'orphaned'
) {
return <>{t('packageDetails.orphaned')}</>
}

if (!['<', '>', '@'].every(symbol => text.includes(symbol))) {
return <>{text}</>
if (!['<', '>', '@'].every(symbol => maintainers.join().includes(symbol))) {
return <>{maintainers.join(', ')}</>
}

const shortenName = (name: string, splitBy: string): string =>
Expand All @@ -28,33 +30,53 @@ const PackageDetailsMaintainer: FC<{ text: string }> = ({ text }) => {
'',
)

let name = text.split('<')[0].trim()
if (name.length > 15) {
if (name.includes(' ')) {
name = shortenName(name, ' ')
} else if (name.includes('-')) {
name = shortenName(name, '-')
} else {
name = name.substring(0, 12) + '..'
const maintainerInfos = maintainers.map(maintainer => {
let name = maintainer.split('<')[0].trim()
if (name.length > 15) {
if (name.includes(' ')) {
name = shortenName(name, ' ')
} else if (name.includes('-')) {
name = shortenName(name, '-')
} else {
name = name.substring(0, 12) + '..'
}
}
}

const fullEmail = text.split('<')[1].split('>')[0].trim()
const shortEmail =
fullEmail.split('@')[0].length > 15
? fullEmail.split('@')[0].substring(0, 13) +
'[..]@' +
fullEmail.split('@')[1]
: fullEmail
const fullEmail = maintainer.split('<')[1]?.split('>')[0]?.trim()
return {
name,
fullEmail,
shortEmail:
fullEmail?.split('@')[0]?.length > 15
? fullEmail.split('@')[0]?.substring(0, 13) +
'[..]@' +
fullEmail.split('@')[1]
: fullEmail,
}
})

return (
<>
<span>{name}, </span>
<Tooltip openDelay={500} label={`Contact ${name} via email`}>
<Link color='pink.400' href={'mailto: ' + fullEmail}>
{shortEmail} <Icon size='md' mx='2px' as={EmailIcon} />
</Link>
</Tooltip>
{maintainerInfos.map((maintainer, idx) => (
<Fragment key={idx}>
<span>{maintainer.name} </span>
{maintainer.fullEmail && (
<Tooltip
openDelay={500}
label={`Contact ${name} via email`}
>
<Link
color='pink.400'
href={'mailto: ' + maintainer.fullEmail}
>
{maintainer.shortEmail}{' '}
<Icon size='md' mx='2px' as={EmailIcon} />{' '}
</Link>
</Tooltip>
)}
<br />
</Fragment>
))}
</>
)
}
Expand Down
21 changes: 14 additions & 7 deletions client/src/components/package-details/PackageDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@ const PackageDetailsPage: FC<PackageDetailsPageProps> = ({
}) => (
<>
<Helmet>
<title>{data.name} - Pacstall</title>
<title>{data.packageName} - Pacstall</title>
<meta
name='keywords'
content={data.name + ',' + data.name.split('-').join(',')}
content={
data.packageName +
',' +
data.packageName.split('-').join(',')
}
/>
<meta name='description' content={data.description} />

<meta name='twitter:card' content='summary' />
<meta property='og:title' content={data.name} />
<meta property='og:title' content={data.packageName} />
<meta property='og:type' content='article' />
<meta property='og:url' content={location.href} />
<meta property='og:image' content='/public/app.png' />
Expand All @@ -48,13 +52,16 @@ const PackageDetailsPage: FC<PackageDetailsPageProps> = ({
requiredByModal={requiredByModal}
/>
<HowToInstall
name={data.name}
prettyName={data.name}
name={data.packageName}
prettyName={data.packageName}
isMobile={isMobile}
/>
</Container>
<PackageRequiredByModal name={data.name} {...requiredByModal} />
<PackageDependenciesModal name={data.name} {...dependenciesModal} />
<PackageRequiredByModal name={data.packageName} {...requiredByModal} />
<PackageDependenciesModal
name={data.packageName}
{...dependenciesModal}
/>
</>
)

Expand Down
8 changes: 4 additions & 4 deletions client/src/components/package-details/PackageDetailsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ const PackageDetailsTable: FC<{
<Table mt='10'>
<Tbody>
<Entry header={t('packageDetails.table.name')}>
{data.name}
{data.packageName}
</Entry>

<Entry header={t('packageDetails.table.version')}>
<Text fontWeight='bold'>
<SemanticVersionColor
git={data.name.endsWith('-git')}
git={data.packageName.endsWith('-git')}
version={data.version}
status={data.updateStatus}
/>
</Text>
</Entry>

<Entry header={t('packageDetails.table.maintainer')}>
<PackageDetailsMaintainer text={data.maintainer} />
<PackageDetailsMaintainer text={data.maintainers} />
</Entry>

<Entry header={t('packageDetails.table.lastUpdatedAt')}>
Expand Down Expand Up @@ -114,7 +114,7 @@ const PackageDetailsTable: FC<{
<Link
color='pink.400'
isExternal
href={`https://github.com/pacstall/pacstall-programs/blob/master/packages/${data.name}/${data.name}.pacscript`}
href={`https://github.com/pacstall/pacstall-programs/blob/master/packages/${data.packageName}/${data.packageName}.pacscript`}
>
{t('packageDetails.openInGithub')}{' '}
<Icon
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/packages/PackageTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const PackageTable: FC<{
<Tbody>
{packages.map(pkg => (
<PackageTableRow
key={pkg.name}
key={pkg.packageName}
disabled={linksDisabled}
pkg={pkg}
/>
Expand Down
30 changes: 19 additions & 11 deletions client/src/components/packages/PackageTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,29 @@ const PackageTableRow: FC<{ pkg: PackageInfo; disabled?: boolean }> = ({
const { t } = useTranslation()

return (
<Tr key={pkg.name} transition={'ease-in-out'} transitionDelay='0.5s'>
<Tr
key={pkg.packageName}
transition={'ease-in-out'}
transitionDelay='0.5s'
>
<Td>
<Tooltip openDelay={500} label={pkg.description}>
<Text
fontSize='md'
fontWeight={useColorModeValue('700', '500')}
>
{disabled === true ? (
<span>{pkg.name}</span>
<span>{pkg.packageName}</span>
) : (
<Link
as={Rlink}
color={useColorModeValue(
'pink.600',
'pink.400',
)}
to={`/packages/${pkg.name}`}
to={`/packages/${pkg.packageName}`}
>
{pkg.name}
{pkg.packageName}
</Link>
)}
</Text>
Expand All @@ -49,20 +53,24 @@ const PackageTableRow: FC<{ pkg: PackageInfo; disabled?: boolean }> = ({
<Tooltip
openDelay={500}
label={
pkg.maintainer
pkg.maintainers.length
? t(
'packageSearch.maintainerTooltip.maintainedBy',
{
name: pkg.maintainer.split('<')[0].trim(),
name: pkg.maintainers
.map(maintainer =>
maintainer.split('<')[0].trim(),
)
.join(', '),
},
)
: t('packageSearch.maintainerTooltip.noMaintainer')
}
>
<Text fontSize='sm'>
{(pkg.maintainer || t('packageDetails.orphaned'))
.split('<')[0]
.trim()}
{pkg.maintainers
.map(maintainer => maintainer.split('<')[0].trim())
.join(', ') || t('packageDetails.orphaned')}
</Text>
</Tooltip>
</Td>
Expand All @@ -71,7 +79,7 @@ const PackageTableRow: FC<{ pkg: PackageInfo; disabled?: boolean }> = ({
>
<Text fontSize='sm'>
<SemanticVersionColor
git={pkg.name.endsWith('-git')}
git={pkg.packageName.endsWith('-git')}
fill
version={pkg.version.substring(0, 14)}
status={pkg.updateStatus}
Expand All @@ -82,7 +90,7 @@ const PackageTableRow: FC<{ pkg: PackageInfo; disabled?: boolean }> = ({
display={useBreakpointValue({ base: 'none', md: 'table-cell' })}
>
<Text fontSize='sm'>
<SmartCodeSnippetInstall size='sm' name={pkg.name} />
<SmartCodeSnippetInstall size='sm' name={pkg.packageName} />
</Text>
</Td>
</Tr>
Expand Down
3 changes: 1 addition & 2 deletions client/src/hooks/useRandomPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ const pickRandomPackage = (packages: PackageInfo[]) => {
const idx = Math.floor(Math.random() * packages.length)
return (
packages[idx].packageName ||
packages[idx].name.split('-').slice(0, -1).join('-') ||
packages[idx].name
packages[idx].packageName.split('-').slice(0, -1).join('-')
)
}

Expand Down
9 changes: 4 additions & 5 deletions client/src/types/package-info.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
export default interface PackageInfo {
name: string
version: string
packageName: string
maintainer: string
maintainers: string[]
description: string
url: string
source: string[]
runtimeDependencies: string[]
buildDependencies: string[]
optionalDependencies: string[]
breaks: string[]
conflicts: string[]
gives: string
replace: string[]
replaces: string[]
hash?: string
ppa: string[]
pacstallDependencies: string[]
Expand Down
4 changes: 2 additions & 2 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"strictNullChecks": false,
"strictNullChecks": false
},
"include": ["**/*.tsx", "**/*.ts", "**/*.css"],
"exclude": ["node_modules"],
"exclude": ["node_modules"]
}
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ services:
PACSTALL_MATOMO_ENABLED: "true"
MATOMO_DOMAIN: "http://matomo"
MATOMO_SITE_ID: "1"
PACSTALL_PROGRAMS_GIT_BRANCH: "master"

matomo:
image: matomo
Expand Down
Loading

0 comments on commit 190e60c

Please sign in to comment.