build(fe-paths): update convoluted relative paths to absolutes with alias
This commit is contained in:
parent
804de64a56
commit
b930b0cec5
25 changed files with 78 additions and 63 deletions
|
@ -12,10 +12,10 @@
|
|||
},
|
||||
"scripts": {
|
||||
"start": "vite ./src --config ./vite.config.js",
|
||||
"build": "vite build ./src",
|
||||
"build": "vite build ./src --config ./vite.config.js",
|
||||
"lint": "biome check src *.js --verbose && biome format src *.js --verbose",
|
||||
"lint:fix": "biome check src ./*.js --apply --verbose && biome format src ./*.js --write --verbose",
|
||||
"test": "yarn vitest run src",
|
||||
"test": "yarn vitest run",
|
||||
"typecheck": "yarn tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -5,16 +5,16 @@ import {
|
|||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
|
||||
import NavigationBar from "./components/NavigationBar"
|
||||
import AsyncTaskContext from "./contexts/AsyncTaskContext"
|
||||
import LocationContext from "./contexts/LocationContext"
|
||||
import NavigationBar from "@/components/NavigationBar"
|
||||
import AsyncTaskContext from "@/contexts/AsyncTaskContext"
|
||||
import LocationContext from "@/contexts/LocationContext"
|
||||
|
||||
import { Router, Route } from "./router"
|
||||
import { Router, Route } from "@/router"
|
||||
|
||||
import FileListView from "./components/FileListView"
|
||||
import RegisterView from "./components/RegisterView"
|
||||
import LoginView from "./components/LoginView"
|
||||
import LogoutView from "./components/LogoutView"
|
||||
import FileListView from "@/components/FileListView"
|
||||
import RegisterView from "@/components/RegisterView"
|
||||
import LoginView from "@/components/LoginView"
|
||||
import LogoutView from "@/components/LogoutView"
|
||||
|
||||
const routeLabels = {
|
||||
ITEM_DETAILS: "item-details",
|
||||
|
|
|
@ -7,11 +7,11 @@ import { type UseQueryResult } from "@tanstack/react-query"
|
|||
import {
|
||||
renderWithContexts as render,
|
||||
getAxiosMockAdapter,
|
||||
} from "../../tests/helpers"
|
||||
} from "@/tests/helpers"
|
||||
import FileDetails from "."
|
||||
import { type FileData } from "../../types/files"
|
||||
import * as fileQueries from "../../hooks/files"
|
||||
import * as locationContextUtils from "../../contexts/LocationContext"
|
||||
import { type FileData } from "@/types/files"
|
||||
import * as fileQueries from "@/hooks/files"
|
||||
import * as locationContextUtils from "@/contexts/LocationContext"
|
||||
|
||||
describe("FileDetails", () => {
|
||||
const mockItem = {
|
||||
|
|
|
@ -6,13 +6,9 @@ import MuiDeleteIcon from "@mui/icons-material/Delete"
|
|||
import MuiDownloadIcon from "@mui/icons-material/Download"
|
||||
import MuiIconButton from "@mui/material/IconButton"
|
||||
|
||||
import { byteSizeToUnits } from "../../utils"
|
||||
import { useLocationContext } from "../../contexts/LocationContext"
|
||||
import {
|
||||
useFileDetails,
|
||||
useFileMutations,
|
||||
useFileFetches,
|
||||
} from "../../hooks/files"
|
||||
import { byteSizeToUnits } from "@/utils"
|
||||
import { useLocationContext } from "@/contexts/LocationContext"
|
||||
import { useFileDetails, useFileMutations, useFileFetches } from "@/hooks/files"
|
||||
|
||||
interface FileDetailsProps {
|
||||
itemId: string
|
||||
|
|
|
@ -5,7 +5,7 @@ import userEvent from "@testing-library/user-event"
|
|||
import {
|
||||
renderWithContexts as render,
|
||||
getAxiosMockAdapter,
|
||||
} from "../../tests/helpers"
|
||||
} from "@/tests/helpers"
|
||||
import FileList from "."
|
||||
import AxiosMockAdapter from "axios-mock-adapter"
|
||||
|
||||
|
|
|
@ -11,11 +11,11 @@ import MuiListItemIcon from "@mui/material/ListItemIcon"
|
|||
import MuiIconButton from "@mui/material/IconButton"
|
||||
import MuiTypography from "@mui/material/Typography"
|
||||
|
||||
import { byteSizeToUnits } from "../../utils"
|
||||
import { useLocationContext } from "../../contexts/LocationContext"
|
||||
import { useAsyncTaskContext } from "../../contexts/AsyncTaskContext"
|
||||
import { useFileMutations, useFileFetches } from "../../hooks/files"
|
||||
import { type FileData } from "../../types/files"
|
||||
import { byteSizeToUnits } from "@/utils"
|
||||
import { useLocationContext } from "@/contexts/LocationContext"
|
||||
import { useAsyncTaskContext } from "@/contexts/AsyncTaskContext"
|
||||
import { useFileMutations, useFileFetches } from "@/hooks/files"
|
||||
import { type FileData } from "@/types/files"
|
||||
interface FileListProps {
|
||||
data: Array<FileData>
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ import { render, screen, waitFor } from "@testing-library/react"
|
|||
import { QueryClientProvider, QueryClient } from "@tanstack/react-query"
|
||||
import AxiosMockAdapter from "axios-mock-adapter"
|
||||
|
||||
import axios from "../../axios"
|
||||
import { LocationContext } from "../../contexts/LocationContext"
|
||||
import axios from "@/axios"
|
||||
import { LocationContext } from "@/contexts/LocationContext"
|
||||
import FileListView from "."
|
||||
|
||||
const routes = {
|
||||
|
|
|
@ -2,10 +2,10 @@ import React from "react"
|
|||
|
||||
import Box from "@mui/material/Box"
|
||||
|
||||
import FileList from "../FileList"
|
||||
import FileDetails from "../FileDetails"
|
||||
import { useOwnFileList } from "../../hooks/files"
|
||||
import { useLocationContext } from "../../contexts/LocationContext"
|
||||
import FileList from "@/components/FileList"
|
||||
import FileDetails from "@/components/FileDetails"
|
||||
import { useOwnFileList } from "@/hooks/files"
|
||||
import { useLocationContext } from "@/contexts/LocationContext"
|
||||
|
||||
function FileListView() {
|
||||
const { isLoading, data } = useOwnFileList()
|
||||
|
|
|
@ -5,8 +5,8 @@ import userEvent from "@testing-library/user-event"
|
|||
import { QueryClientProvider, QueryClient } from "@tanstack/react-query"
|
||||
import AxiosMockAdapter from "axios-mock-adapter"
|
||||
|
||||
import axios from "../../axios"
|
||||
import * as locationHook from "../../contexts/LocationContext"
|
||||
import axios from "@/axios"
|
||||
import * as locationHook from "@/contexts/LocationContext"
|
||||
import LoginView from "."
|
||||
|
||||
function renderComponent() {
|
||||
|
|
|
@ -10,9 +10,9 @@ import Button from "@mui/material/Button"
|
|||
import Link from "@mui/material/Link"
|
||||
import Alert from "@mui/material/Alert"
|
||||
|
||||
import { useLogin } from "../../queries/auth"
|
||||
import axiosWithDefaults from "../../axios"
|
||||
import TextInput from "../TextInput"
|
||||
import { useLogin } from "@/queries/auth"
|
||||
import axiosWithDefaults from "@/axios"
|
||||
import TextInput from "@/components/TextInput"
|
||||
|
||||
function LoginView() {
|
||||
const [emailAddress, setEmailAddress] = React.useState<string>("")
|
||||
|
|
|
@ -2,7 +2,7 @@ import React from "react"
|
|||
import Box from "@mui/material/Box"
|
||||
import Typography from "@mui/material/Typography"
|
||||
|
||||
import { useLogout } from "../../queries/auth"
|
||||
import { useLogout } from "@/queries/auth"
|
||||
|
||||
function LogoutView() {
|
||||
const { logout } = useLogout()
|
||||
|
|
|
@ -4,11 +4,11 @@ import userEvent from "@testing-library/user-event"
|
|||
import { screen, render, waitFor } from "@testing-library/react"
|
||||
import { QueryClientProvider, QueryClient } from "@tanstack/react-query"
|
||||
|
||||
import * as locationHook from "../../contexts/LocationContext"
|
||||
import { getAxiosMockAdapter } from "../../tests/helpers"
|
||||
import * as locationHook from "@/contexts/LocationContext"
|
||||
import { getAxiosMockAdapter } from "@/tests/helpers"
|
||||
import NavigationBar from "."
|
||||
|
||||
import { type FileData } from "../../types/files"
|
||||
import { type FileData } from "@/types/files"
|
||||
|
||||
function renderComponent() {
|
||||
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
||||
|
|
|
@ -7,9 +7,9 @@ import Button from "@mui/material/Button"
|
|||
import Typography from "@mui/material/Typography"
|
||||
import UploadIcon from "@mui/icons-material/Upload"
|
||||
|
||||
import { useFileMutations } from "../../hooks/files"
|
||||
import { useLogout } from "../../queries/auth"
|
||||
import { useCurrentUser } from "../../queries/user"
|
||||
import { useFileMutations } from "@/hooks/files"
|
||||
import { useLogout } from "@/queries/auth"
|
||||
import { useCurrentUser } from "@/queries/user"
|
||||
|
||||
function UploadFileButton() {
|
||||
const fileRef = useRef(null)
|
||||
|
|
|
@ -4,7 +4,7 @@ import userEvent from "@testing-library/user-event"
|
|||
import { QueryClientProvider, QueryClient } from "@tanstack/react-query"
|
||||
import AxiosMockAdapter from "axios-mock-adapter"
|
||||
|
||||
import axios from "../../axios"
|
||||
import axios from "@/axios"
|
||||
import RegisterView from "."
|
||||
|
||||
function renderComponent() {
|
||||
|
|
|
@ -10,8 +10,8 @@ import InputLabel from "@mui/material/InputLabel"
|
|||
import FormHelperText from "@mui/material/FormHelperText"
|
||||
import Button from "@mui/material/Button"
|
||||
|
||||
import axiosWithDefaults from "../../axios"
|
||||
import TextInput from "../TextInput"
|
||||
import axiosWithDefaults from "@/axios"
|
||||
import TextInput from "@/components/TextInput"
|
||||
import { validateEmail, validatePassword } from "./validation"
|
||||
|
||||
function RegisterView() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { useQuery, useQueryClient } from "@tanstack/react-query"
|
||||
|
||||
import axios from "../axios"
|
||||
import { type FileData } from "../types/files"
|
||||
import axios from "@/axios"
|
||||
import { type FileData } from "@/types/files"
|
||||
|
||||
function useOwnFileList() {
|
||||
return useQuery({
|
||||
|
|
|
@ -4,8 +4,8 @@ import { renderHook, waitFor } from "@testing-library/react"
|
|||
import { QueryClientProvider, QueryClient } from "@tanstack/react-query"
|
||||
import AxiosMockAdapter from "axios-mock-adapter"
|
||||
|
||||
import * as locationHook from "../contexts/LocationContext"
|
||||
import axiosWithDefaults from "../axios"
|
||||
import * as locationHook from "@/contexts/LocationContext"
|
||||
import axiosWithDefaults from "@/axios"
|
||||
import { useLogout } from "./auth"
|
||||
|
||||
function WithProviders({ children }: { children: React.ReactNode }) {
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
*
|
||||
*/
|
||||
import { useQueryClient, useMutation } from "@tanstack/react-query"
|
||||
import { useLocationContext } from "../contexts/LocationContext"
|
||||
import axiosWithDefaults from "../axios"
|
||||
|
||||
import { useLocationContext } from "@/contexts/LocationContext"
|
||||
import axiosWithDefaults from "@/axios"
|
||||
|
||||
/*
|
||||
* Handles the log-out interaction.
|
||||
|
|
|
@ -4,7 +4,7 @@ import { renderHook, waitFor } from "@testing-library/react"
|
|||
import { QueryClientProvider, QueryClient } from "@tanstack/react-query"
|
||||
import AxiosMockAdapter from "axios-mock-adapter"
|
||||
|
||||
import axiosWithDefaults from "../axios"
|
||||
import axiosWithDefaults from "@/axios"
|
||||
import { useCurrentUser } from "./user"
|
||||
|
||||
function WithProviders({ children }: { children: React.ReactNode }) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { useQuery } from "@tanstack/react-query"
|
||||
|
||||
import axiosWithDefaults from "../axios"
|
||||
import axiosWithDefaults from "@/axios"
|
||||
|
||||
/*
|
||||
* Current user data fetch.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { afterEach, describe, it, vi, expect } from "vitest"
|
||||
import { render, screen } from "@testing-library/react"
|
||||
|
||||
import { LocationContext } from "../contexts/LocationContext"
|
||||
import { LocationContext } from "@/contexts/LocationContext"
|
||||
import Router from "./Router"
|
||||
import Route from "./Route"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import React, { Children } from "react"
|
||||
|
||||
import { useLocationContext } from "../contexts/LocationContext"
|
||||
import { useLocationContext } from "@/contexts/LocationContext"
|
||||
|
||||
interface RouterProps {
|
||||
children: React.ReactNode
|
||||
|
|
|
@ -4,8 +4,8 @@ import { QueryClientProvider, QueryClient } from "@tanstack/react-query"
|
|||
import axios from "../axios"
|
||||
import AxiosMockAdapter from "axios-mock-adapter"
|
||||
|
||||
import AsyncTaskContext, { type AsyncTask } from "../contexts/AsyncTaskContext"
|
||||
import LocationContext from "../contexts/LocationContext"
|
||||
import AsyncTaskContext, { type AsyncTask } from "@/contexts/AsyncTaskContext"
|
||||
import LocationContext from "@/contexts/LocationContext"
|
||||
|
||||
interface ContextInitialValues {
|
||||
asyncTaskContext: Array<AsyncTask>
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
"strict": true,
|
||||
"noImplicitAny": true,
|
||||
"skipLibCheck": true,
|
||||
"types": ["node", "mocha"]
|
||||
"types": ["node", "mocha"],
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
import legacy from "@vitejs/plugin-legacy"
|
||||
import basicSSL from "@vitejs/plugin-basic-ssl"
|
||||
|
||||
import path from "node:path"
|
||||
import { defineConfig } from "vite"
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [legacy(), basicSSL()],
|
||||
build: {
|
||||
outDir: "./dist",
|
||||
rollupOptions: {
|
||||
external: "./src",
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 1234,
|
||||
strictPort: true,
|
||||
|
@ -13,7 +19,15 @@ export default defineConfig({
|
|||
test: {
|
||||
environment: "jsdom",
|
||||
setupFiles: ["./src/tests/testSetup.ts"],
|
||||
testMatch: ["./src/**/*.test.tsx?"],
|
||||
include: ["./src/**/*.test.ts", "./src/**/*.test.tsx"],
|
||||
globals: true,
|
||||
},
|
||||
resolve: {
|
||||
alias: [
|
||||
{
|
||||
find: "@",
|
||||
replacement: path.resolve(__dirname, "./src"),
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
|
Reference in a new issue