refactor: ♻️ update import map to simplify local imports paths

This commit is contained in:
Julien Oculi 2024-07-01 13:11:20 +02:00
parent 27faac00e3
commit 01e007939d
24 changed files with 60 additions and 57 deletions

View file

@ -1,8 +1,8 @@
import { asset } from '$fresh/runtime.ts' import { asset } from '$fresh/runtime.ts'
import SearchBox from '../islands/SearchBox.tsx' import AiChatBox from ':islands/AiChatBox.tsx'
import ThemePicker from '../islands/ThemePicker.tsx' import MoreBox from ':islands/MoreBox.tsx'
import MoreBox from '../islands/MoreBox.tsx' import SearchBox from ':islands/SearchBox.tsx'
import AiChatBox from '../islands/AiChatBox.tsx' import ThemePicker from ':islands/ThemePicker.tsx'
export function Header() { export function Header() {
return ( return (

View file

@ -1,4 +1,4 @@
import RegisterServiceWorker from '../islands/RegisterServiceWorker.tsx' import RegisterServiceWorker from ':islands/RegisterServiceWorker.tsx'
export function ProgressiveWebApp() { export function ProgressiveWebApp() {
return <RegisterServiceWorker /> return <RegisterServiceWorker />

View file

@ -15,6 +15,9 @@
"lint": { "rules": { "tags": ["fresh", "recommended"] } }, "lint": { "rules": { "tags": ["fresh", "recommended"] } },
"exclude": ["**/_fresh/*", "packages/"], "exclude": ["**/_fresh/*", "packages/"],
"imports": { "imports": {
":components/": "./components/",
":islands/": "./islands/",
":src/": "./src/",
"$fresh/": "https://deno.land/x/fresh@1.6.8/", "$fresh/": "https://deno.land/x/fresh@1.6.8/",
"$std/": "https://deno.land/std@0.208.0/", "$std/": "https://deno.land/std@0.208.0/",
"@cohabit/cohamail/": "./packages/@cohabit__cohamail@0.2.1/", "@cohabit/cohamail/": "./packages/@cohabit__cohamail@0.2.1/",

View file

@ -1,3 +1,4 @@
import { requestApi } from ':src/utils.ts'
import { startAuthentication } from '@simplewebauthn/browser' import { startAuthentication } from '@simplewebauthn/browser'
import { PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types' import { PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types'
import { Button, Input } from 'univoq' import { Button, Input } from 'univoq'
@ -5,7 +6,6 @@ import type {
WebAuthnLoginFinishPayload, WebAuthnLoginFinishPayload,
WebAuthnLoginStartPayload, WebAuthnLoginStartPayload,
} from '../routes/api/webauthn/login/[step].ts' } from '../routes/api/webauthn/login/[step].ts'
import { requestApi } from '../src/utils.ts'
export default function LoginForm() { export default function LoginForm() {
return ( return (

View file

@ -1,3 +1,4 @@
import { requestApi } from ':src/utils.ts'
import { startRegistration } from '@simplewebauthn/browser' import { startRegistration } from '@simplewebauthn/browser'
import { PublicKeyCredentialCreationOptionsJSON } from '@simplewebauthn/types' import { PublicKeyCredentialCreationOptionsJSON } from '@simplewebauthn/types'
import { Button, Input } from 'univoq' import { Button, Input } from 'univoq'
@ -5,7 +6,6 @@ import type {
WebAuthnRegisterFinishPayload, WebAuthnRegisterFinishPayload,
WebAuthnRegisterStartPayload, WebAuthnRegisterStartPayload,
} from '../routes/api/webauthn/register/[step].ts' } from '../routes/api/webauthn/register/[step].ts'
import { requestApi } from '../src/utils.ts'
function isWebAuthnSupported(): boolean { function isWebAuthnSupported(): boolean {
return 'credentials' in navigator return 'credentials' in navigator

View file

@ -1,4 +1,4 @@
import { requestApi } from '../src/utils.ts' import { requestApi } from ':src/utils.ts'
export default function RegisterServiceWorker() { export default function RegisterServiceWorker() {
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {

View file

@ -1,4 +1,4 @@
import { main } from '../src/serviceworker/mod.ts' import { main } from ':src/serviceworker/mod.ts'
const IS_SW = 'onpushsubscriptionchange' in self const IS_SW = 'onpushsubscriptionchange' in self

View file

@ -1,8 +1,8 @@
import { asset, Head, Partial } from '$fresh/runtime.ts' import { asset, Head, Partial } from '$fresh/runtime.ts'
import { type PageProps } from '$fresh/server.ts' import { type PageProps } from '$fresh/server.ts'
import { Footer } from '../components/Footer.tsx' import { Footer } from ':components/Footer.tsx'
import { Header } from '../components/Header.tsx' import { Header } from ':components/Header.tsx'
import { ProgressiveWebApp } from '../components/ProgressiveWebApp.tsx' import { ProgressiveWebApp } from ':components/ProgressiveWebApp.tsx'
export default function App({ Component }: PageProps) { export default function App({ Component }: PageProps) {
return ( return (

View file

@ -1,6 +1,6 @@
import { FreshContext } from '$fresh/server.ts' import { FreshContext } from '$fresh/server.ts'
import { SessionStore } from ':src/session/mod.ts'
import { getCookies, setCookie } from '@std/http/cookie' import { getCookies, setCookie } from '@std/http/cookie'
import { SessionStore } from '../src/session/mod.ts'
export async function handler(request: Request, ctx: FreshContext) { export async function handler(request: Request, ctx: FreshContext) {
// Update fresh context state with session // Update fresh context state with session

View file

@ -1,6 +1,6 @@
import { FreshContext } from '$fresh/server.ts' import { FreshContext } from '$fresh/server.ts'
import { SessionStore } from '../../src/session/mod.ts' import { SessionStore } from ':src/session/mod.ts'
import { respondApi } from '../../src/utils.ts' import { respondApi } from ':src/utils.ts'
export function handler(request: Request, ctx: FreshContext) { export function handler(request: Request, ctx: FreshContext) {
// Check CSRF token // Check CSRF token

View file

@ -2,13 +2,13 @@ import 'npm:iterator-polyfill'
// Polyfill AsyncIterator // Polyfill AsyncIterator
import { FreshContext } from '$fresh/server.ts' import { FreshContext } from '$fresh/server.ts'
import { db } from ':src/db/mod.ts'
import { SessionHandlers, SessionStore } from ':src/session/mod.ts'
import { respondApi } from ':src/utils.ts'
import { Contact, type Mail, send } from '@cohabit/cohamail/mod.ts' import { Contact, type Mail, send } from '@cohabit/cohamail/mod.ts'
import { magicLinkTemplate } from '@cohabit/cohamail/templates/mod.ts' import { magicLinkTemplate } from '@cohabit/cohamail/templates/mod.ts'
import { SessionHandlers, SessionStore } from '../../../src/session/mod.ts'
import { respondApi } from '../../../src/utils.ts'
import { sleep } from '@jotsr/delayed'
import { User } from '@cohabit/ressources_manager/src/models/mod.ts' import { User } from '@cohabit/ressources_manager/src/models/mod.ts'
import { db } from '../../../src/db/mod.ts' import { sleep } from '@jotsr/delayed'
type MagicLinkInfos = { type MagicLinkInfos = {
remoteId: string remoteId: string

View file

@ -1,17 +1,17 @@
import { db } from ':src/db/mod.ts'
import type { SessionHandlers } from ':src/session/mod.ts'
import { respondApi } from ':src/utils.ts'
import { getRelyingParty } from ':src/webauthn/mod.ts'
import { Credential, Ref, User } from '@cohabit/ressources_manager/mod.ts'
import { Passkey } from '@cohabit/ressources_manager/src/models/src/credential.ts'
import { import {
generateAuthenticationOptions, generateAuthenticationOptions,
verifyAuthenticationResponse, verifyAuthenticationResponse,
} from '@simplewebauthn/server' } from '@simplewebauthn/server'
import { getRelyingParty } from '../../../../src/webauthn/mod.ts'
import { import {
AuthenticationResponseJSON, AuthenticationResponseJSON,
PublicKeyCredentialRequestOptionsJSON, PublicKeyCredentialRequestOptionsJSON,
} from '@simplewebauthn/types' } from '@simplewebauthn/types'
import { respondApi } from '../../../../src/utils.ts'
import type { SessionHandlers } from '../../../../src/session/mod.ts'
import { db } from '../../../../src/db/mod.ts'
import { Credential, Ref, User } from '@cohabit/ressources_manager/mod.ts'
import { Passkey } from '@cohabit/ressources_manager/src/models/src/credential.ts'
import { decodeBase64 } from '@std/encoding' import { decodeBase64 } from '@std/encoding'
type Params = { step: 'start' | 'finish' } type Params = { step: 'start' | 'finish' }

View file

@ -1,3 +1,5 @@
import { SessionHandlers } from ':src/session/mod.ts'
import { respondApi } from ':src/utils.ts'
import { import {
generateRegistrationOptions, generateRegistrationOptions,
verifyRegistrationResponse, verifyRegistrationResponse,
@ -6,15 +8,13 @@ import type {
PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialCreationOptionsJSON,
RegistrationResponseJSON, RegistrationResponseJSON,
} from '@simplewebauthn/types' } from '@simplewebauthn/types'
import { respondApi } from '../../../../src/utils.ts'
import { SessionHandlers } from '../../../../src/session/mod.ts'
//TODO improve workspace imports //TODO improve workspace imports
import { Passkey } from '@cohabit/ressources_manager/src/models/src/credential.ts' import { db } from ':src/db/mod.ts'
import { getRelyingParty } from ':src/webauthn/mod.ts'
import { Credential, Ref, User } from '@cohabit/ressources_manager/mod.ts' import { Credential, Ref, User } from '@cohabit/ressources_manager/mod.ts'
import { getRelyingParty } from '../../../../src/webauthn/mod.ts' import { Passkey } from '@cohabit/ressources_manager/src/models/src/credential.ts'
import { encodeBase64 } from '@std/encoding' import { encodeBase64 } from '@std/encoding'
import { db } from '../../../../src/db/mod.ts'
type Params = { step: 'start' | 'finish' } type Params = { step: 'start' | 'finish' }

View file

@ -1,5 +1,5 @@
import { Handlers } from '$fresh/server.ts' import { Handlers } from '$fresh/server.ts'
import { respondApi } from '../../../src/utils.ts' import { respondApi } from ':src/utils.ts'
export const handler: Handlers = { export const handler: Handlers = {
async POST(request: Request) { async POST(request: Request) {

View file

@ -1,6 +1,6 @@
import { Handlers } from '$fresh/server.ts' import { Handlers } from '$fresh/server.ts'
import { respondApi } from '../../../src/utils.ts' import { respondApi } from ':src/utils.ts'
import { publicKey } from '../../../src/webpush/mod.ts' import { publicKey } from ':src/webpush/mod.ts'
export const handler: Handlers = { export const handler: Handlers = {
GET() { GET() {

View file

@ -1,5 +1,5 @@
import { AutoGrid } from '../../components/AutoGrid.tsx' import { AutoGrid } from ':components/AutoGrid.tsx'
import { BlogCard, blogMock } from '../../components/BlogCard.tsx' import { BlogCard, blogMock } from ':components/BlogCard.tsx'
export default function Blog() { export default function Blog() {
return ( return (

View file

@ -1,12 +1,12 @@
import { Head } from '$fresh/runtime.ts' import { Head } from '$fresh/runtime.ts'
import { AutoGrid } from '../components/AutoGrid.tsx' import { AutoGrid } from ':components/AutoGrid.tsx'
import { BlogCard, blogMock } from '../components/BlogCard.tsx' import { BlogCard, blogMock } from ':components/BlogCard.tsx'
import { CohabitInfoTable } from '../components/CohabitInfoTable.tsx' import { CohabitInfoTable } from ':components/CohabitInfoTable.tsx'
import { Heros } from '../components/Heros.tsx' import { Heros } from ':components/Heros.tsx'
import { MachineCard, machineMock } from '../components/MachineCard.tsx' import { MachineCard, machineMock } from ':components/MachineCard.tsx'
import { MemberCard, memberMock } from '../components/MemberCard.tsx' import { MemberCard, memberMock } from ':components/MemberCard.tsx'
import { ProjectCard, projectMock } from '../components/ProjectCard.tsx' import { ProjectCard, projectMock } from ':components/ProjectCard.tsx'
import { SponsorCards } from '../components/SponsorCards.tsx' import { SponsorCards } from ':components/SponsorCards.tsx'
export default function Home() { export default function Home() {
return ( return (

View file

@ -1,5 +1,5 @@
import { PageProps } from '$fresh/server.ts' import { PageProps } from '$fresh/server.ts'
import { MachineCard, machineMock } from '../../components/MachineCard.tsx' import { MachineCard, machineMock } from ':components/MachineCard.tsx'
export default function Machine({ params }: PageProps) { export default function Machine({ params }: PageProps) {
const machine = machineMock.at(Number(params.id)) const machine = machineMock.at(Number(params.id))

View file

@ -1,5 +1,5 @@
import { AutoGrid } from '../../components/AutoGrid.tsx' import { AutoGrid } from ':components/AutoGrid.tsx'
import { MachineCard, machineMock } from '../../components/MachineCard.tsx' import { MachineCard, machineMock } from ':components/MachineCard.tsx'
export default function Machine() { export default function Machine() {
return ( return (

View file

@ -1,6 +1,6 @@
import { PageProps } from '$fresh/server.ts' import { PageProps } from '$fresh/server.ts'
import { Markdown } from '../../../components/Markdown.tsx' import { Markdown } from ':components/Markdown.tsx'
import { MemberCard, memberMock } from '../../../components/MemberCard.tsx' import { MemberCard, memberMock } from ':components/MemberCard.tsx'
const db = [ const db = [
'julien.oculi', 'julien.oculi',

View file

@ -1,5 +1,5 @@
import { AutoGrid } from '../../components/AutoGrid.tsx' import { AutoGrid } from ':components/AutoGrid.tsx'
import { MemberCard, memberMock } from '../../components/MemberCard.tsx' import { MemberCard, memberMock } from ':components/MemberCard.tsx'
export default function Membres() { export default function Membres() {
return ( return (

View file

@ -1,8 +1,8 @@
import { Button } from 'univoq' import LoginForm from ':islands/LoginForm.tsx'
import LoginForm from '../../islands/LoginForm.tsx' import PassKeyRegister from ':islands/PassKeyRegister.tsx'
import PassKeyRegister from '../../islands/PassKeyRegister.tsx' import type { SessionPageProps } from ':src/session/mod.ts'
import type { SessionPageProps } from '../../src/session/mod.ts'
import type { User } from '@cohabit/ressources_manager/mod.ts' import type { User } from '@cohabit/ressources_manager/mod.ts'
import { Button } from 'univoq'
export default function Profil({ state }: SessionPageProps) { export default function Profil({ state }: SessionPageProps) {
const user = state.session?.get<User>('user') const user = state.session?.get<User>('user')

View file

@ -1,5 +1,5 @@
import { PageProps } from '$fresh/server.ts' import { PageProps } from '$fresh/server.ts'
import { ProjectCard, projectMock } from '../../components/ProjectCard.tsx' import { ProjectCard, projectMock } from ':components/ProjectCard.tsx'
export default function Projets({ params }: PageProps) { export default function Projets({ params }: PageProps) {
const Projets = projectMock.at(Number(params.id)) const Projets = projectMock.at(Number(params.id))

View file

@ -1,5 +1,5 @@
import { AutoGrid } from '../../components/AutoGrid.tsx' import { AutoGrid } from ':components/AutoGrid.tsx'
import { ProjectCard, projectMock } from '../../components/ProjectCard.tsx' import { ProjectCard, projectMock } from ':components/ProjectCard.tsx'
export default function Project() { export default function Project() {
return ( return (