Skip to content

Commit

Permalink
ci: upgrade prettier, manage package version from tag
Browse files Browse the repository at this point in the history
  • Loading branch information
QcFe committed Feb 12, 2025
1 parent 31f13b5 commit 8cc811e
Show file tree
Hide file tree
Showing 22 changed files with 103 additions and 108 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ jobs:
restore-keys: ${{ runner.os }}-gradle-
- name: Setup .npmrc
run: printf '@polito:registry=https://npm.pkg.github.com\n//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}\n' > .npmrc
- name: Enforce version
run: npm version "$APP_VERSION" --no-git-tag-version
- name: Install npm dependencies
run: npm install
- name: Prepare fastlane
Expand Down Expand Up @@ -270,6 +272,8 @@ jobs:
key: ${{ runner.os }}-npm-${{ hashFiles('./package-lock.json') }}
- name: Setup .npmrc
run: printf '@polito:registry=https://npm.pkg.github.com\n//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}\n' > .npmrc
- name: Enforce version
run: npm version "$APP_VERSION" --no-git-tag-version
- name: Cache pods
uses: actions/cache@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion .prettierrc → .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
module.exports = {
"plugins": [require.resolve("@trivago/prettier-plugin-sort-imports")],
"singleQuote": true,
"trailingComma": "all",
"arrowParens": "avoid",
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/components/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const ListItem = ({
numberOfLines={
multilineTitle
? undefined
: titleProps?.numberOfLines ?? (card ? 2 : 1)
: (titleProps?.numberOfLines ?? (card ? 2 : 1))
}
ellipsizeMode={titleProps?.ellipsizeMode ?? 'tail'}
{...titleProps}
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/components/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export const Tab = ({
color: selected
? palettes.text[50]
: dark
? palettes.primary[400]
: palettes.primary[500],
? palettes.primary[400]
: palettes.primary[500],
fontWeight: fontWeights.medium,
},
textStyle,
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/components/TopTabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export const TopTabBar = ({
options.tabBarLabel !== undefined
? options.tabBarLabel
: options.title !== undefined
? options.title
: route.name;
? options.title
: route.name;

const isFocused = state.index === index;

Expand Down
8 changes: 4 additions & 4 deletions lib/ui/utils/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ export function getEventSpanningInfo(
!showAdjacentMonths && monthDaysLeft < 7 && monthDaysLeft < eventDuration
? monthDaysLeft + 1
: eventDaysLeft > weekDaysLeft
? weekDaysLeft
: eventDaysLeft < eventDuration
? eventDaysLeft
: eventDuration;
? weekDaysLeft
: eventDaysLeft < eventDuration
? eventDaysLeft
: eventDuration;
// - 6 to take in account the padding
const eventWidth = dayWidth * eventWeekDuration - 6;

Expand Down
8 changes: 4 additions & 4 deletions lib/ui/utils/utility-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type DeepPartialObject<T> = { [P in keyof T]?: DeepPartial<T[P]> };
export type DeepPartial<T> = T extends Function
? T
: T extends Array<infer U>
? DeepPartialArray<U>
: T extends object
? DeepPartialObject<T>
: T | undefined;
? DeepPartialArray<U>
: T extends object
? DeepPartialObject<T>
: T | undefined;
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polito/students-app",
"version": "1.6.9",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android --active-arch-only --appIdSuffix=dev",
Expand Down Expand Up @@ -135,7 +135,7 @@
"jest": "^29.6.3",
"lint-staged": "^15.2.10",
"pod-install": "^0.3.4",
"prettier": "2.8.8",
"prettier": "^3.5.0",
"react-test-renderer": "18.3.1",
"typescript": "5.0.4"
},
Expand Down
15 changes: 8 additions & 7 deletions src/core/hooks/useNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ import {
UnreadNotificationsByScope,
} from '../types/notifications';

type PathExtractor<T, Paths extends any[] = []> = T extends Array<Notification>
? never
: T extends object
? {
[K in keyof T]: PathExtractor<T[K], [...Paths, K]>;
}[keyof T]
: Paths;
type PathExtractor<T, Paths extends any[] = []> =
T extends Array<Notification>
? never
: T extends object
? {
[K in keyof T]: PathExtractor<T[K], [...Paths, K]>;
}[keyof T]
: Paths;

type CourseTransactionId =
| 'avvisidoc'
Expand Down
2 changes: 1 addition & 1 deletion src/features/agenda/components/AgendaNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const AgendaNavigator = () => {
headerLargeStyle: {
backgroundColor: colors.headersBackground,
},
animation: params?.animated ?? true ? 'default' : 'none',
animation: (params?.animated ?? true) ? 'default' : 'none',
})}
/>
<Stack.Screen
Expand Down
2 changes: 1 addition & 1 deletion src/features/courses/navigation/CourseSharedScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const CourseSharedScreens = (
headerLargeTitle: false,
headerShadowVisible: false,
headerBackTitleVisible: false,
animation: params?.animated ?? true ? 'default' : 'none',
animation: (params?.animated ?? true) ? 'default' : 'none',
})}
/>
<Stack.Screen
Expand Down
16 changes: 8 additions & 8 deletions src/features/courses/screens/CoursesScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ export const CoursesScreen = () => {
{coursesQuery.data &&
(coursesQuery.data.length > 0 ? (
Object.entries(
coursesQuery.data.reduce((byPeriod, course) => {
(byPeriod[course.teachingPeriod] =
byPeriod[course.teachingPeriod] ?? []).push(course);
return byPeriod;
}, {} as Record<string, CourseOverview[]>) as Record<
string,
CourseOverview[]
>,
coursesQuery.data.reduce(
(byPeriod, course) => {
(byPeriod[course.teachingPeriod] =
byPeriod[course.teachingPeriod] ?? []).push(course);
return byPeriod;
},
{} as Record<string, CourseOverview[]>,
) as Record<string, CourseOverview[]>,
).map(([period, courses]) => (
<Section key={period}>
<SectionHeader
Expand Down
16 changes: 9 additions & 7 deletions src/features/offering/screens/DegreeCourseScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const DegreeCourseScreen = ({ route }: Props) => {
id: edition.toString(),
title: edition,
state: edition === currentYear ? 'on' : undefined,
} as MenuAction),
}) as MenuAction,
);
}, [currentYear, isOffline, offeringCourse]);

Expand Down Expand Up @@ -234,12 +234,14 @@ export const DegreeCourseScreen = ({ route }: Props) => {
}
/>
<OverviewList emptyStateText={t('degreeCourseScreen.noStaff')}>
{offeringCourse?.staff.slice(0, 3).map(item => (
<StaffListItem
key={`${item.id}${item.courseId}`}
staff={item}
/>
))}
{offeringCourse?.staff
.slice(0, 3)
.map(item => (
<StaffListItem
key={`${item.id}${item.courseId}`}
staff={item}
/>
))}
</OverviewList>
</Section>
<Section>
Expand Down
54 changes: 27 additions & 27 deletions src/features/places/components/MapNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,33 +183,33 @@ export const MapNavigator = ({
label: headerBackTitle,
})
: headerLeft === undefined && canGoBack
? ({ tintColor }) => (
<HeaderBackButton
tintColor={tintColor}
backImage={
headerBackImageSource !== undefined
? () => (
<Image
source={headerBackImageSource}
style={[
styles.backImage,
{ tintColor },
]}
/>
)
: undefined
}
onPress={navigation.goBack}
canGoBack={canGoBack}
label={
headerBackTitle ??
previousDescriptor?.options.title
}
labelVisible={IS_IOS && headerBackTitleVisible}
labelStyle={headerBackTitleStyle}
/>
)
: headerLeft
? ({ tintColor }) => (
<HeaderBackButton
tintColor={tintColor}
backImage={
headerBackImageSource !== undefined
? () => (
<Image
source={headerBackImageSource}
style={[
styles.backImage,
{ tintColor },
]}
/>
)
: undefined
}
onPress={navigation.goBack}
canGoBack={canGoBack}
label={
headerBackTitle ??
previousDescriptor?.options.title
}
labelVisible={IS_IOS && headerBackTitleVisible}
labelStyle={headerBackTitleStyle}
/>
)
: headerLeft
: undefined
}
headerRight={
Expand Down
2 changes: 1 addition & 1 deletion src/features/places/components/MarkersLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const MarkersLayer = ({
priority:
selectedPoiId === poi.id
? 0
: subcategory?.priority ?? category.priority ?? 100,
: (subcategory?.priority ?? category.priority ?? 100),
};
});
}, [
Expand Down
4 changes: 2 additions & 2 deletions src/features/places/components/PlacesBottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export const PlacesBottomSheet = forwardRef<
const listItems = useMemo(
() =>
typing && !isLoading
? placesSearched.map(p => searchPlaceToListItem(p, true)) ?? []
: listProps?.data ?? [],
? (placesSearched.map(p => searchPlaceToListItem(p, true)) ?? [])
: (listProps?.data ?? []),
[
isLoading,
listProps?.data,
Expand Down
17 changes: 2 additions & 15 deletions src/features/places/hooks/useSearchPlaceToListItem.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';

import { DEFAULT_CATEGORY_MARKER } from '../constants';
import { SearchPlace, isPlace } from '../types';
import { usePlaceCategoriesMap } from './usePlaceCategoriesMap';

/**
* Converts a place or building to a list item object
*/
export const useSearchPlaceToListItem = () => {
const { t } = useTranslation();
const placeCategoriesMap = usePlaceCategoriesMap();

return useCallback(
(place: SearchPlace, isRecentlyViewed = false) => {
const markerUrl = !placeCategoriesMap
? DEFAULT_CATEGORY_MARKER.markerUrl
: place.category?.subCategory?.id
? placeCategoriesMap[place.category.subCategory.id].markerUrl
: place.category.id
? placeCategoriesMap[place.category.id]?.markerUrl
: DEFAULT_CATEGORY_MARKER.markerUrl;
return {
title: isPlace(place)
? place.room.name ?? place.category.subCategory?.name
? (place.room.name ?? place.category.subCategory?.name)
: place.name,
subtitle: isPlace(place)
? `${
Expand All @@ -35,11 +25,8 @@ export const useSearchPlaceToListItem = () => {
linkTo: isPlace(place)
? { screen: 'Place', params: { placeId: place.id } }
: { screen: 'Building', params: { buildingId: place.id } },
// leadingItem: (
// <Image source={{ uri: markerUrl }} width={30} height={30} />
// ),
};
},
[placeCategoriesMap, t],
[t],
);
};
2 changes: 1 addition & 1 deletion src/features/places/utils/category.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const formatPlaceCategory = (name?: string) =>
name?.length ? name.split(' - ')[1] ?? name : undefined;
name?.length ? (name.split(' - ')[1] ?? name) : undefined;
8 changes: 4 additions & 4 deletions src/features/teaching/components/ExamCTA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ export const ExamCTA = ({ exam, absolute = false }: Props) => {
examUnavailable
? t('examScreen.notAvailable')
: examRequestable
? t('examScreen.ctaRequest')
: examAvailable
? t('examScreen.ctaBook')
: t('examScreen.ctaCancel')
? t('examScreen.ctaRequest')
: examAvailable
? t('examScreen.ctaBook')
: t('examScreen.ctaCancel')
}
action={action}
loading={mutationsLoading}
Expand Down
Loading

0 comments on commit 8cc811e

Please sign in to comment.