Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ COPY README.md /shlink-dashboard/README.md

WORKDIR /shlink-dashboard
RUN npm ci --omit dev && npm cache clean --force
RUN mv src node_modules/@shlinkio/dashboard-server
RUN mkdir data && chown $UID:0 data

# Install tini
Expand Down
3 changes: 3 additions & 0 deletions scripts/create-dist-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ try {
// Install prod dependencies inside build dir
execSync('npm ci --omit=dev', { cwd: './build' });

// Move bundled src to node_modules, so that it is treated as an external package
fs.renameSync('./build/src', './build/node_modules/@shlinkio/dashboard-server');

zip.addLocalFolder('./build', fileBaseName);
zip.writeZip(versionFileName);
console.log(chalk.green('Dist file properly generated'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
ShlinkShortUrlIdentifier,
} from '@shlinkio/shlink-js-sdk/api-contract';
import { fromPartial } from '@total-typescript/shoehorn';
import { ShlinkApiProxyClient } from '../../app/api/ShlinkApiProxyClient.client';
import { ShlinkApiProxyClient } from '../../../app/api/ShlinkApiProxyClient.client';

describe('ShlinkApiProxyClient', () => {
let proxyClient: ShlinkApiProxyClient;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { fromPartial } from '@total-typescript/shoehorn';
import type { SessionStorage } from 'react-router';
import type { Authenticator } from 'remix-auth';
import { AuthHelper } from '../../app/auth/auth-helper.server';
import type { SessionData, ShlinkSessionData } from '../../app/auth/session-context';
import { AuthHelper } from '../../../app/auth/auth-helper.server';
import type { SessionData, ShlinkSessionData } from '../../../app/auth/session-context';

describe('AuthHelper', () => {
const authenticate = vi.fn();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fromPartial } from '@total-typescript/shoehorn';
import { Authenticator } from 'remix-auth';
import { createAuthenticator, CREDENTIALS_STRATEGY } from '../../app/auth/auth.server';
import type { UsersService } from '../../app/users/UsersService.server';
import { createAuthenticator, CREDENTIALS_STRATEGY } from '../../../app/auth/auth.server';
import type { UsersService } from '../../../app/users/UsersService.server';

describe('auth', () => {
const getUserByCredentials = vi.fn();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generatePassword, hashPassword, verifyPassword } from '../../app/auth/passwords.server';
import { generatePassword, hashPassword, verifyPassword } from '../../../app/auth/passwords.server';

describe('passwords', () => {
it('can hash and then verify a password', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createSessionStorage } from '../../app/auth/session.server';
import { createSessionStorage } from '../../../app/auth/session.server';

describe('createSessionStorage', () => {
it('creates a session storage', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from '@testing-library/react';
import type { ReactNode } from 'react';
import { CopyToClipboard } from '../../app/common/CopyToClipboard';
import { checkAccessibility } from '../__helpers__/accessibility';
import { CopyToClipboard } from '../../../app/common/CopyToClipboard';
import { checkAccessibility } from '../../__helpers__/accessibility';

describe('<CopyToClipboard />', () => {
const setUp = (children?: ReactNode) => render(<CopyToClipboard text="The text">{children}</CopyToClipboard>);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router';
import type { SessionData } from '../../app/auth/session-context';
import { SessionProvider } from '../../app/auth/session-context';
import { MainHeader } from '../../app/common/MainHeader';
import { checkAccessibility } from '../__helpers__/accessibility';
import { renderWithEvents } from '../__helpers__/set-up-test';
import type { SessionData } from '../../../app/auth/session-context';
import { SessionProvider } from '../../../app/auth/session-context';
import { MainHeader } from '../../../app/common/MainHeader';
import { checkAccessibility } from '../../__helpers__/accessibility';
import { renderWithEvents } from '../../__helpers__/set-up-test';

describe('<MainHeader />', () => {
const setUp = (session: SessionData | null = null) => renderWithEvents(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { fromPartial } from '@total-typescript/shoehorn';
import type { unstable_RouterContextProvider } from 'react-router';
import type { AuthHelper } from '../../app/auth/auth-helper.server';
import type { SessionData } from '../../app/auth/session-context';
import type { Role } from '../../app/entities/User';
import type { AuthHelper } from '../../../app/auth/auth-helper.server';
import type { SessionData } from '../../../app/auth/session-context';
import type { Role } from '../../../app/entities/User';
import {
authMiddleware,
ensureAdminMiddleware,
ensureNotManagedMiddleware,
} from '../../app/middleware/middleware.server';
} from '../../../app/middleware/middleware.server';

describe('middleware', () => {
const next = vi.fn().mockResolvedValue(new Response('Success', { status: 200 }));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { createRoutesStub } from 'react-router';
import type { AuthHelper } from '../../app/auth/auth-helper.server';
import ChangePassword, { action, loader } from '../../app/routes/change-password';
import { INVALID_PASSWORD_FORMAT } from '../../app/routes/profile/change-password-action.server';
import { PasswordMismatchError } from '../../app/users/PasswordMismatchError.server';
import type { UsersService } from '../../app/users/UsersService.server';
import { ValidationError } from '../../app/validation/ValidationError.server';
import { renderWithEvents } from '../__helpers__/set-up-test';
import type { AuthHelper } from '../../../app/auth/auth-helper.server';
import ChangePassword, { action, loader } from '../../../app/routes/change-password';
import { INVALID_PASSWORD_FORMAT } from '../../../app/routes/profile/change-password-action.server';
import { PasswordMismatchError } from '../../../app/users/PasswordMismatchError.server';
import type { UsersService } from '../../../app/users/UsersService.server';
import { ValidationError } from '../../../app/validation/ValidationError.server';
import { renderWithEvents } from '../../__helpers__/set-up-test';

describe('change-password', () => {
describe('loader', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router';
import type { SessionData } from '../../../app/auth/session-context';
import { SessionProvider } from '../../../app/auth/session-context';
import { NoServers } from '../../../app/routes/index/NoServers';
import { checkAccessibility } from '../../__helpers__/accessibility';
import type { SessionData } from '../../../../app/auth/session-context';
import { SessionProvider } from '../../../../app/auth/session-context';
import { NoServers } from '../../../../app/routes/index/NoServers';
import { checkAccessibility } from '../../../__helpers__/accessibility';

describe('<NoServers />', () => {
const setUp = (session: SessionData | null = null) => render(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router';
import type { Server } from '../../../app/entities/Server';
import { ServersList } from '../../../app/routes/index/ServersList';
import { checkAccessibility } from '../../__helpers__/accessibility';
import type { Server } from '../../../../app/entities/Server';
import { ServersList } from '../../../../app/routes/index/ServersList';
import { checkAccessibility } from '../../../__helpers__/accessibility';

describe('<ServersList />', () => {
const setUp = (servers: Server[]) => render(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router';
import type { Server } from '../../../app/entities/Server';
import { WelcomeCard } from '../../../app/routes/index/WelcomeCard';
import { checkAccessibility } from '../../__helpers__/accessibility';
import type { Server } from '../../../../app/entities/Server';
import { WelcomeCard } from '../../../../app/routes/index/WelcomeCard';
import { checkAccessibility } from '../../../__helpers__/accessibility';

describe('<WelcomeCard />', () => {
const setUp = (servers: Server[]) => render(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { render, screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { createRoutesStub } from 'react-router';
import type { AuthHelper } from '../../../app/auth/auth-helper.server';
import type { SessionData } from '../../../app/auth/session-context';
import type { Server } from '../../../app/entities/Server';
import Home, { loader } from '../../../app/routes/index/home';
import type { ServersService } from '../../../app/servers/ServersService.server';
import type { AuthHelper } from '../../../../app/auth/auth-helper.server';
import type { SessionData } from '../../../../app/auth/session-context';
import type { Server } from '../../../../app/entities/Server';
import Home, { loader } from '../../../../app/routes/index/home';
import type { ServersService } from '../../../../app/servers/ServersService.server';

describe('home', () => {
describe('loader', () => {
Expand Down
6 changes: 3 additions & 3 deletions test/routes/login.test.tsx → test/app/routes/login.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { createRoutesStub } from 'react-router';
import type { AuthHelper } from '../../app/auth/auth-helper.server';
import Login, { action, loader } from '../../app/routes/login';
import { renderWithEvents } from '../__helpers__/set-up-test';
import type { AuthHelper } from '../../../app/auth/auth-helper.server';
import Login, { action, loader } from '../../../app/routes/login';
import { renderWithEvents } from '../../__helpers__/set-up-test';

describe('login', () => {
const login = vi.fn().mockResolvedValue(fromPartial({}));
Expand Down
4 changes: 2 additions & 2 deletions test/routes/logout.test.ts → test/app/routes/logout.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fromPartial } from '@total-typescript/shoehorn';
import type { LoaderFunctionArgs } from 'react-router';
import type { AuthHelper } from '../../app/auth/auth-helper.server';
import { loader as logoutLoader } from '../../app/routes/logout';
import type { AuthHelper } from '../../../app/auth/auth-helper.server';
import { loader as logoutLoader } from '../../../app/routes/logout';

describe('logout', () => {
const logout = vi.fn();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import type { FC, PropsWithChildren, RefAttributes } from 'react';
import { ChangePasswordForm } from '../../../app/routes/profile/ChangePasswordForm';
import { checkAccessibility } from '../../__helpers__/accessibility';
import { ChangePasswordForm } from '../../../../app/routes/profile/ChangePasswordForm';
import { checkAccessibility } from '../../../__helpers__/accessibility';

describe('<ChangePasswordForm />', () => {
const Form: FC<PropsWithChildren<RefAttributes<HTMLFormElement>>> = ({ children, ref }) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import type { FC, PropsWithChildren, RefAttributes } from 'react';
import type { SessionData } from '../../../app/auth/session-context';
import { EditProfileForm } from '../../../app/routes/profile/EditProfileForm';
import { checkAccessibility } from '../../__helpers__/accessibility';
import type { SessionData } from '../../../../app/auth/session-context';
import { EditProfileForm } from '../../../../app/routes/profile/EditProfileForm';
import { checkAccessibility } from '../../../__helpers__/accessibility';

describe('<EditProfileForm />', () => {
const Form: FC<PropsWithChildren<RefAttributes<HTMLFormElement>>> = ({ children, ref }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import type { FC, PropsWithChildren, RefAttributes } from 'react';
import { useState } from 'react';
import type { ProfileFormProps } from '../../../app/routes/profile/ProfileForm';
import { ProfileForm } from '../../../app/routes/profile/ProfileForm';
import { PROFILE_ACTION } from '../../../app/users/user-profile-actions';
import { checkAccessibility } from '../../__helpers__/accessibility';
import { renderWithEvents } from '../../__helpers__/set-up-test';
import type { ProfileFormProps } from '../../../../app/routes/profile/ProfileForm';
import { ProfileForm } from '../../../../app/routes/profile/ProfileForm';
import { PROFILE_ACTION } from '../../../../app/users/user-profile-actions';
import { checkAccessibility } from '../../../__helpers__/accessibility';
import { renderWithEvents } from '../../../__helpers__/set-up-test';

type Fetcher = ProfileFormProps['fetcher'];
type SetUpOptions = Partial<Pick<Fetcher, 'state' | 'data'>> & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { fromPartial } from '@total-typescript/shoehorn';
import {
changePasswordAction,
INVALID_PASSWORD_FORMAT,
} from '../../../app/routes/profile/change-password-action.server';
import { IncorrectPasswordError } from '../../../app/users/IncorrectPasswordError.server';
import { PasswordMismatchError } from '../../../app/users/PasswordMismatchError.server';
import type { UsersService } from '../../../app/users/UsersService.server';
import { ValidationError } from '../../../app/validation/ValidationError.server';
} from '../../../../app/routes/profile/change-password-action.server';
import { IncorrectPasswordError } from '../../../../app/users/IncorrectPasswordError.server';
import { PasswordMismatchError } from '../../../../app/users/PasswordMismatchError.server';
import type { UsersService } from '../../../../app/users/UsersService.server';
import { ValidationError } from '../../../../app/validation/ValidationError.server';

describe('change-password-action', () => {
const editUserPassword = vi.fn();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { fromPartial } from '@total-typescript/shoehorn';
import { expect } from 'vitest';
import type { User } from '../../../app/entities/User';
import { editProfileAction } from '../../../app/routes/profile/edit-profile-action.server';
import type { UsersService } from '../../../app/users/UsersService.server';
import type { User } from '../../../../app/entities/User';
import { editProfileAction } from '../../../../app/routes/profile/edit-profile-action.server';
import type { UsersService } from '../../../../app/users/UsersService.server';

describe('edit-profile-action', () => {
const editUser = vi.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import type { UNSAFE_DataWithResponseInit } from 'react-router';
import { createRoutesStub } from 'react-router';
import type { AuthHelper } from '../../../app/auth/auth-helper.server';
import { SessionProvider } from '../../../app/auth/session-context';
import type { User } from '../../../app/entities/User';
import Profile, { action } from '../../../app/routes/profile/profile';
import { CHANGE_PASSWORD_ACTION, PROFILE_ACTION } from '../../../app/users/user-profile-actions';
import type { UsersService } from '../../../app/users/UsersService.server';
import type { AuthHelper } from '../../../../app/auth/auth-helper.server';
import { SessionProvider } from '../../../../app/auth/session-context';
import type { User } from '../../../../app/entities/User';
import Profile, { action } from '../../../../app/routes/profile/profile';
import { CHANGE_PASSWORD_ACTION, PROFILE_ACTION } from '../../../../app/users/user-profile-actions';
import type { UsersService } from '../../../../app/users/UsersService.server';

describe('profile', () => {
describe('action', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { fromPartial } from '@total-typescript/shoehorn';
import type { ActionFunctionArgs } from 'react-router';
import type { AuthHelper } from '../../app/auth/auth-helper.server';
import { action } from '../../app/routes/save-tags-colors';
import type { TagsService } from '../../app/tags/TagsService.server';
import type { AuthHelper } from '../../../app/auth/auth-helper.server';
import { action } from '../../../app/routes/save-tags-colors';
import type { TagsService } from '../../../app/tags/TagsService.server';

describe('save-tags-colors', () => {
const updateTagColors = vi.fn();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { createRoutesStub } from 'react-router';
import { type PlainServer } from '../../../app/entities/Server';
import { DeleteServerModal } from '../../../app/routes/servers/DeleteServerModal';
import { checkAccessibility } from '../../__helpers__/accessibility';
import { renderWithEvents } from '../../__helpers__/set-up-test';
import { type PlainServer } from '../../../../app/entities/Server';
import { DeleteServerModal } from '../../../../app/routes/servers/DeleteServerModal';
import { checkAccessibility } from '../../../__helpers__/accessibility';
import { renderWithEvents } from '../../../__helpers__/set-up-test';

describe('<DeleteServerModal />', () => {
const onClose = vi.fn();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router';
import type { ServerFormFieldsProps } from '../../../app/routes/servers/ServerFormFields';
import { ServerFormFields } from '../../../app/routes/servers/ServerFormFields';
import { checkAccessibility } from '../../__helpers__/accessibility';
import type { ServerFormFieldsProps } from '../../../../app/routes/servers/ServerFormFields';
import { ServerFormFields } from '../../../../app/routes/servers/ServerFormFields';
import { checkAccessibility } from '../../../__helpers__/accessibility';

describe('<ServerFormFields />', () => {
const setUp = (props: Partial<ServerFormFieldsProps> = {}) => render(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { createRoutesStub } from 'react-router';
import CreateServer, { action } from '../../../app/routes/servers/create-server';
import type { ServersService } from '../../../app/servers/ServersService.server';
import { checkAccessibility } from '../../__helpers__/accessibility';
import { renderWithEvents } from '../../__helpers__/set-up-test';
import CreateServer, { action } from '../../../../app/routes/servers/create-server';
import type { ServersService } from '../../../../app/servers/ServersService.server';
import { checkAccessibility } from '../../../__helpers__/accessibility';
import { renderWithEvents } from '../../../__helpers__/set-up-test';

describe('create-server', () => {
describe('action', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fromPartial } from '@total-typescript/shoehorn';
import { action } from '../../../app/routes/servers/delete-server';
import type { ServersService } from '../../../app/servers/ServersService.server';
import { action } from '../../../../app/routes/servers/delete-server';
import type { ServersService } from '../../../../app/servers/ServersService.server';

describe('delete-server', () => {
describe('action', () => {
Expand Down
Loading
Loading