Skip to content

Commit

Permalink
Fix autoformat CI & format codebase (#2581)
Browse files Browse the repository at this point in the history
* Update pnpm version

* Fix autoformat

* Improve autoformat msg

* Attempt to fix autoformat 2

* Fix autoformat

* Ignore deleted files in auto-format

* Fix diff filter

* Autoformat whole codebase

* Improve error message for autoformat CI

* Test autoformat CI

* Revert "Test autoformat CI"

This reverts commit 0bf2f46.
  • Loading branch information
HeavenVolkoff committed Jul 4, 2024
1 parent 31e710e commit 5614627
Show file tree
Hide file tree
Showing 137 changed files with 2,023 additions and 1,669 deletions.
22 changes: 18 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ jobs:
timeout-minutes: 7
permissions: {}
steps:
- name: Checkout repository
- name: 'PR commits + 1'
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"

- name: 'Checkout PR branch and all PR commits'
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: ${{ env.PR_FETCH_DEPTH }}

- name: Setup Node.js, pnpm and dependencies
uses: ./.github/actions/setup-pnpm
Expand All @@ -38,10 +44,18 @@ jobs:

- name: Perform style check
run: |-
set -eux
pnpm autoformat only-frontend
if [ -n "$(git diff --name-only --cached)" ]; then
set -eu
pnpm autoformat only-frontend >/dev/null
_files="$(git diff --name-only --cached)"
if [ -n "$_files" ]; then
echo "Some files are not correctly formatted. Please run 'pnpm autoformat' and commit the changes." >&2
while IFS= read -r _file || [ -n "$_file" ]; do
echo "::error file=${_file},title=Incorrectly formatted file::Please run 'pnpm autoformat' and commit the changes."
done < <(printf '%s' "$_files")
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ If you encounter any issues, ensure that you are using the following versions of

- Rust version: **1.78**
- Node version: **18.18**
- Pnpm version: **9.1.1**
- Pnpm version: **9.4.0**

After cleaning out your build artifacts using `pnpm clean`, `git clean`, or `cargo clean`, it is necessary to re-run the `setup-system` script.

Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export const platform = {
getThumbnailUrlByThumbKey: (thumbKey) =>
constructServerUrl(
`/thumbnail/${encodeURIComponent(
thumbKey.base_directory_str
)}/${encodeURIComponent(thumbKey.shard_hex)}/${encodeURIComponent(thumbKey.cas_id)}.webp`
thumbKey.base_directory_str
)}/${encodeURIComponent(thumbKey.shard_hex)}/${encodeURIComponent(thumbKey.cas_id)}.webp`
),
getFileUrl: (libraryId, locationLocalId, filePathId) =>
constructServerUrl(`/file/${libraryId}/${locationLocalId}/${filePathId}`),
Expand Down
6 changes: 5 additions & 1 deletion apps/landing/src/app/api/slack/webhook/createRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export const fields = {
} as const;

export const COMMAND_NAME = '/release' as const;
export const EVENT_SCHEMAS = [createSlashCommand(COMMAND_NAME), createViewSubmission(), createBlockActions()] as const;
export const EVENT_SCHEMAS = [
createSlashCommand(COMMAND_NAME),
createViewSubmission(),
createBlockActions()
] as const;

export async function createModal(
trigger_id: string,
Expand Down
38 changes: 22 additions & 16 deletions apps/landing/src/app/api/slack/webhook/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export function createSlashCommand<T extends string>(command: T) {
command: z.literal(command),
text: z.string().transform((s) => s.split(' ')),
api_app_id: z.string(),
is_enterprise_install: z.union([z.literal('false'), z.literal('true')]).transform((v) => v === 'true'),
is_enterprise_install: z
.union([z.literal('false'), z.literal('true')])
.transform((v) => v === 'true'),
response_url: z.string(),
trigger_id: z.string()
});
Expand Down Expand Up @@ -88,23 +90,27 @@ const BLOCK_ACTIONS_INNER = z.object({
z.object({
type: z.string(),
block_id: z.string(),
text: z.object({
type: z.string(),
text: z.string(),
verbatim: z.boolean()
}).optional(),
elements: z.array(
z.object({
text: z
.object({
type: z.string(),
action_id: z.string(),
text: z.object({
type: z.string(),
text: z.string(),
emoji: z.boolean()
}),
url: z.string().optional()
text: z.string(),
verbatim: z.boolean()
})
).optional()
.optional(),
elements: z
.array(
z.object({
type: z.string(),
action_id: z.string(),
text: z.object({
type: z.string(),
text: z.string(),
emoji: z.boolean()
}),
url: z.string().optional()
})
)
.optional()
})
)
}),
Expand Down
4 changes: 2 additions & 2 deletions apps/landing/src/app/team/people.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const teamMembers: Array<TeamMemberProps> = [
name: 'Valerie Wong',
location: 'Vancouver, Canada',
role: 'Director of Operations',
imageUrl: '/images/team/valerie.jpeg',
imageUrl: '/images/team/valerie.jpeg'
},
{
name: 'Ericson Soares',
Expand All @@ -43,7 +43,7 @@ export const teamMembers: Array<TeamMemberProps> = [
role: 'Rust Engineer',
imageUrl: '/images/team/matheus.jpg',
socials: {
github: 'https://github.com/matheus-consoli',
github: 'https://github.com/matheus-consoli'
}
},
{
Expand Down
26 changes: 13 additions & 13 deletions apps/mobile/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@ import {
NavigationContainer,
useNavigationContainerRef
} from '@react-navigation/native';
import {
ClientContextProvider,
LibraryContextProvider,
P2PContextProvider,
RspcProvider,
initPlausible,
useBridgeQuery,
useClientContext,
useInvalidateQuery,
usePlausibleEvent,
usePlausiblePageViewMonitor,
usePlausiblePingMonitor
} from '@sd/client';
import { QueryClient } from '@tanstack/react-query';
import dayjs from 'dayjs';
import advancedFormat from 'dayjs/plugin/advancedFormat';
Expand All @@ -30,6 +17,19 @@ import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { MenuProvider } from 'react-native-popup-menu';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { useSnapshot } from 'valtio';
import {
ClientContextProvider,
initPlausible,
LibraryContextProvider,
P2PContextProvider,
RspcProvider,
useBridgeQuery,
useClientContext,
useInvalidateQuery,
usePlausibleEvent,
usePlausiblePageViewMonitor,
usePlausiblePingMonitor
} from '@sd/client';

import { GlobalModals } from './components/modal/GlobalModals';
import { Toast, toastConfig } from './components/primitive/Toast';
Expand Down
50 changes: 28 additions & 22 deletions apps/mobile/src/components/browse/BrowseLocations.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useNavigation } from '@react-navigation/native';
import { useLibraryQuery } from '@sd/client';
import { Plus } from 'phosphor-react-native';
import { useRef, useState } from 'react';
import { FlatList, Text, View } from 'react-native';
import { useLibraryQuery } from '@sd/client';
import { ModalRef } from '~/components/layout/Modal';
import { tw, twStyle } from '~/lib/tailwind';
import { BrowseStackScreenProps } from '~/navigation/tabs/BrowseStack';
import { SettingsStackScreenProps } from '~/navigation/tabs/SettingsStack';

import { Plus } from 'phosphor-react-native';
import Empty from '../layout/Empty';
import Fade from '../layout/Fade';
import { LocationItem } from '../locations/LocationItem';
Expand All @@ -32,51 +32,57 @@ const BrowseLocations = () => {
<View style={tw`flex-row gap-3`}>
<Button
style={twStyle(`rounded-full`, {
borderColor: showAll ? tw.color('accent') : tw.color('border-app-lightborder')
borderColor: showAll
? tw.color('accent')
: tw.color('border-app-lightborder')
})}
variant="outline"
onPress={() => setShowAll((prev) => !prev)}
>
<Text style={tw`text-xs text-ink`}>{showAll ? 'Show less' : 'Show all'} ({locations?.length})</Text>
<Text style={tw`text-xs text-ink`}>
{showAll ? 'Show less' : 'Show all'} ({locations?.length})
</Text>
</Button>
<Button
onPress={() => modalRef.current?.present()}
style={tw`flex-row gap-1 rounded-full`}
variant="gray"
>
<Plus size={10} weight="bold" style={tw`text-white`} />
<Text style={tw`text-xs text-ink`}>Add</Text>
<Text style={tw`text-xs text-ink`}>Add</Text>
</Button>
</View>
</View>
<View style={tw`relative -m-1`}>
<Fade color='black' width={30} height="100%">
<Fade color="black" width={30} height="100%">
<FlatList
data={locations}
ListEmptyComponent={<Empty description="You have not added any locations" icon="Folder" />}
ListEmptyComponent={
<Empty description="You have not added any locations" icon="Folder" />
}
numColumns={showAll ? 3 : 1}
horizontal={showAll ? false : true}
contentContainerStyle={twStyle(locations?.length === 0 && 'w-full','px-5')}
contentContainerStyle={twStyle(locations?.length === 0 && 'w-full', 'px-5')}
key={showAll ? '_locations' : 'alllocationcols'}
keyExtractor={(item) => item.id.toString()}
scrollEnabled={showAll ? false : true}
showsHorizontalScrollIndicator={false}
renderItem={({ item }) => {
return (
<LocationItem
location={item}
style={twStyle(showAll && 'max-w-[31%] flex-1')}
editLocation={() =>
navigation.navigate('SettingsStack', {
screen: 'EditLocationSettings',
params: { id: item.id },
initial: false
})
}
onPress={() => navigation.navigate('Location', { id: item.id })}
return (
<LocationItem
location={item}
style={twStyle(showAll && 'max-w-[31%] flex-1')}
editLocation={() =>
navigation.navigate('SettingsStack', {
screen: 'EditLocationSettings',
params: { id: item.id },
initial: false
})
}
onPress={() => navigation.navigate('Location', { id: item.id })}
/>
)}
}
);
}}
/>
</Fade>
</View>
Expand Down
38 changes: 22 additions & 16 deletions apps/mobile/src/components/browse/BrowseTags.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useNavigation } from '@react-navigation/native';
import { useLibraryQuery } from '@sd/client';
import { Plus } from 'phosphor-react-native';
import React, { useRef, useState } from 'react';
import { FlatList, Text, View } from 'react-native';
import { useLibraryQuery } from '@sd/client';
import { ModalRef } from '~/components/layout/Modal';
import { tw, twStyle } from '~/lib/tailwind';
import { BrowseStackScreenProps } from '~/navigation/tabs/BrowseStack';
Expand All @@ -28,47 +28,53 @@ const BrowseTags = () => {
<Text style={tw`text-lg font-bold text-white`}>Tags</Text>
<View style={tw`flex-row gap-3`}>
<Button
testID='show-all-tags-button'
testID="show-all-tags-button"
style={twStyle(`rounded-full`, {
borderColor: showAll ? tw.color('accent') : tw.color('border-app-lightborder')
borderColor: showAll
? tw.color('accent')
: tw.color('border-app-lightborder')
})}
variant="outline"
onPress={() => setShowAll((prev) => !prev)}
>
<Text style={tw`text-xs text-ink`}>{showAll ? 'Show less' : 'Show all'} ({tagData?.length})</Text>
<Text style={tw`text-xs text-ink`}>
{showAll ? 'Show less' : 'Show all'} ({tagData?.length})
</Text>
</Button>
<Button
testID='create-tag-button'
testID="create-tag-button"
onPress={() => modalRef.current?.present()}
style={tw`flex-row gap-1 rounded-full`}
variant="gray"
>
<Plus size={10} weight="bold" style={tw`text-white`} />
<Text style={tw`text-xs text-ink`}>Add</Text>
<Text style={tw`text-xs text-ink`}>Add</Text>
</Button>
</View>
</View>
<View style={tw`relative -m-1`}>
<Fade color='black' width={20} height="100%">
<Fade color="black" width={20} height="100%">
<FlatList
data={tagData}
ListEmptyComponent={<Empty description="You have not created any tags" icon="Tags" />}
ListEmptyComponent={
<Empty description="You have not created any tags" icon="Tags" />
}
numColumns={showAll ? 3 : 1}
contentContainerStyle={twStyle(tagData?.length === 0 && 'w-full','px-5')}
contentContainerStyle={twStyle(tagData?.length === 0 && 'w-full', 'px-5')}
horizontal={showAll ? false : true}
key={showAll ? '_tags' : 'alltagcols'}
keyExtractor={(item) => item.id.toString()}
scrollEnabled={showAll ? false : true}
showsHorizontalScrollIndicator={false}
renderItem={({ item }) => (
<TagItem
style={twStyle(showAll && 'max-w-[31%] flex-1')}
key={item.id}
tag={item}
onPress={() =>
navigation.navigate('Tag', { id: item.id, color: item.color! })
}
/>
style={twStyle(showAll && 'max-w-[31%] flex-1')}
key={item.id}
tag={item}
onPress={() =>
navigation.navigate('Tag', { id: item.id, color: item.color! })
}
/>
)}
/>
</Fade>
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/components/drawer/DrawerContent.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { DrawerContentScrollView } from '@react-navigation/drawer';
import { DrawerContentComponentProps } from '@react-navigation/drawer/lib/typescript/src/types';
import { AppLogo } from '@sd/assets/images';
import { JobManagerContextProvider, useLibraryQuery } from '@sd/client';
import { Image } from 'expo-image';
import { CheckCircle } from 'phosphor-react-native';
import { useRef } from 'react';
import { Platform, Pressable, Text, View } from 'react-native';
import { JobManagerContextProvider, useLibraryQuery } from '@sd/client';
import Layout from '~/constants/Layout';
import { tw, twStyle } from '~/lib/tailwind';

Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/components/drawer/DrawerLibraryManager.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useDrawerStatus } from '@react-navigation/drawer';
import { useNavigation } from '@react-navigation/native';
import { useClientContext } from '@sd/client';
import { MotiView } from 'moti';
import { CaretRight, CloudArrowDown, Gear, Lock, Plus } from 'phosphor-react-native';
import { useEffect, useRef, useState } from 'react';
import { Alert, Pressable, Text, View } from 'react-native';
import { useClientContext } from '@sd/client';
import { tw, twStyle } from '~/lib/tailwind';
import { currentLibraryStore } from '~/utils/nav';

Expand Down
Loading

0 comments on commit 5614627

Please sign in to comment.