Update code to deal with new paths under src

This commit is contained in:
Alex Gleason 2023-09-18 16:37:15 -05:00
parent efdec35d98
commit dd97a46a03
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
21 changed files with 69 additions and 41 deletions

View File

@ -48,9 +48,8 @@ module.exports = {
'\\.(css|scss|json)$',
],
'import/resolver': {
node: {
paths: ['src'],
},
typescript: true,
node: true,
},
polyfills: [
'es:all', // core-js

1
.gitignore vendored
View File

@ -10,6 +10,7 @@
yarn-error.log*
/junit.xml
*.timestamp-*
*.bundled_*
/dist/
/static/

View File

@ -188,6 +188,7 @@
"cross-env": "^7.0.3",
"danger": "^11.0.7",
"eslint": "^8.49.0",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-plugin-compat": "^4.2.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jsdoc": "^46.8.1",

View File

@ -20,8 +20,8 @@ const SiteLogo: React.FC<ISiteLogo> = ({ className, theme, ...rest }) => {
/** Soapbox logo. */
const soapboxLogo = darkMode
? require('assets/images/soapbox-logo-white.svg')
: require('assets/images/soapbox-logo.svg');
? require('soapbox/assets/images/soapbox-logo-white.svg')
: require('soapbox/assets/images/soapbox-logo.svg');
// Use the right logo if provided, then use fallbacks.
const getSrc = () => {

View File

@ -18,7 +18,7 @@ const VerificationBadge: React.FC<IVerificationBadge> = ({ className }) => {
const soapboxConfig = useSoapboxConfig();
// Prefer a custom icon if found
const icon = soapboxConfig.verifiedIcon || require('assets/icons/verified.svg');
const icon = soapboxConfig.verifiedIcon || require('soapbox/assets/icons/verified.svg');
// Render component based on file extension
const Element = icon.endsWith('.svg') ? Icon : 'img';

View File

@ -7,7 +7,7 @@ import * as BuildConfig from 'soapbox/build-config';
export const custom = (filename: string, fallback: any = {}): any => {
if (BuildConfig.NODE_ENV === 'test') return fallback;
const modules = import.meta.glob('../../custom/*.json', { eager: true });
const modules = import.meta.glob('../custom/*.json', { eager: true });
const key = `../../custom/${filename}.json`;
return modules[key] ? modules[key] : fallback;

View File

@ -3,8 +3,8 @@ import React from 'react';
/** Get crypto icon URL by ticker symbol, or fall back to generic icon */
const getIcon = (ticker: string): string => {
const modules: Record<string, any> = import.meta.glob('../../../../../node_modules/cryptocurrency-icons/svg/color/*.svg', { eager: true });
const key = `../../../../../node_modules/cryptocurrency-icons/svg/color/${ticker}.svg`;
const modules: Record<string, any> = import.meta.glob('../../../../node_modules/cryptocurrency-icons/svg/color/*.svg', { eager: true });
const key = `../../../../node_modules/cryptocurrency-icons/svg/color/${ticker}.svg`;
return modules[key]?.default || genericIcon;
};

View File

@ -7,7 +7,7 @@
<meta name="apple-mobile-web-app-capable" content="yes">
<link href="/manifest.json" rel="manifest">
<!--server-generated-meta-->
<script type="module" src="./soapbox/main.tsx"></script>
<script type="module" src="./main.tsx"></script>
</head>
<body class="theme-mode-light no-reduce-motion">
<div id="soapbox" class="h-full">

View File

@ -17,9 +17,9 @@ import '@fontsource/roboto-mono/400.css';
import 'line-awesome/dist/font-awesome-line-awesome/css/all.css';
import 'react-datepicker/dist/react-datepicker.css';
import '../soapbox/iframe';
import '../styles/application.scss';
import '../styles/tailwind.css';
import './iframe';
import './styles/application.scss';
import './styles/tailwind.css';
import './precheck';
import { default as Soapbox } from './containers/soapbox';

View File

@ -4,7 +4,7 @@ type MessageModule = { default: MessageJson };
/** Import custom messages */
const importCustom = async (locale: string): Promise<MessageModule> => {
try {
return await import(`../../custom/locales/${locale}.json`);
return await import(`../custom/locales/${locale}.json`);
} catch {
return ({ default: {} });
}

View File

@ -2,8 +2,8 @@ import { Record as ImmutableRecord, fromJS } from 'immutable';
import { normalizeAccount } from '../account';
const AVATAR_MISSING = require('assets/images/avatar-missing.png');
const HEADER_MISSING = require('assets/images/header-missing.png');
const AVATAR_MISSING = require('soapbox/assets/images/avatar-missing.png');
const HEADER_MISSING = require('soapbox/assets/images/header-missing.png');
describe('normalizeAccount()', () => {
it('adds base fields', () => {

View File

@ -100,7 +100,7 @@ const normalizePleromaLegacyFields = (account: ImmutableMap<string, any>) => {
const normalizeAvatar = (account: ImmutableMap<string, any>) => {
const avatar = account.get('avatar');
const avatarStatic = account.get('avatar_static');
const missing = require('assets/images/avatar-missing.png');
const missing = require('soapbox/assets/images/avatar-missing.png');
return account.withMutations(account => {
account.set('avatar', avatar || avatarStatic || missing);
@ -112,7 +112,7 @@ const normalizeAvatar = (account: ImmutableMap<string, any>) => {
const normalizeHeader = (account: ImmutableMap<string, any>) => {
const header = account.get('header');
const headerStatic = account.get('header_static');
const missing = require('assets/images/header-missing.png');
const missing = require('soapbox/assets/images/header-missing.png');
return account.withMutations(account => {
account.set('header', header || headerStatic || missing);

View File

@ -53,7 +53,7 @@ export const GroupRecord = ImmutableRecord({
const normalizeAvatar = (group: ImmutableMap<string, any>) => {
const avatar = group.get('avatar');
const avatarStatic = group.get('avatar_static');
const missing = require('assets/images/avatar-missing.png');
const missing = require('soapbox/assets/images/avatar-missing.png');
return group.withMutations(group => {
group.set('avatar', avatar || avatarStatic || missing);
@ -65,7 +65,7 @@ const normalizeAvatar = (group: ImmutableMap<string, any>) => {
const normalizeHeader = (group: ImmutableMap<string, any>) => {
const header = group.get('header');
const headerStatic = group.get('header_static');
const missing = require('assets/images/header-missing.png');
const missing = require('soapbox/assets/images/header-missing.png');
return group.withMutations(group => {
group.set('header', header || headerStatic || missing);

View File

@ -10,8 +10,8 @@ import { contentSchema, filteredArray, makeCustomEmojiMap } from './utils';
import type { Resolve } from 'soapbox/utils/types';
const avatarMissing = require('assets/images/avatar-missing.png');
const headerMissing = require('assets/images/header-missing.png');
const avatarMissing = require('soapbox/assets/images/avatar-missing.png');
const headerMissing = require('soapbox/assets/images/header-missing.png');
const birthdaySchema = z.string().regex(/^\d{4}-\d{2}-\d{2}$/);

View File

@ -9,8 +9,8 @@ import { groupRelationshipSchema } from './group-relationship';
import { groupTagSchema } from './group-tag';
import { filteredArray, makeCustomEmojiMap } from './utils';
const avatarMissing = require('assets/images/avatar-missing.png');
const headerMissing = require('assets/images/header-missing.png');
const avatarMissing = require('soapbox/assets/images/avatar-missing.png');
const headerMissing = require('soapbox/assets/images/header-missing.png');
const groupSchema = z.object({
avatar: z.string().catch(avatarMissing),

View File

@ -37,7 +37,7 @@ export const isRemote = (account: Pick<Account, 'acct'>): boolean => !isLocal(ac
const DEFAULT_HEADERS: string[] = [
'/headers/original/missing.png', // Mastodon
'/images/banner.png', // Pleroma
require('assets/images/header-missing.png'), // header not provided by backend
require('soapbox/assets/images/header-missing.png'), // header not provided by backend
];
/** Check if the avatar is a default avatar */
@ -49,7 +49,7 @@ export const isDefaultHeader = (url: string) => {
const DEFAULT_AVATARS = [
'/avatars/original/missing.png', // Mastodon
'/images/avi.png', // Pleroma
require('assets/images/avatar-missing.png'), // avatar not provided by backend
require('soapbox/assets/images/avatar-missing.png'), // avatar not provided by backend
];
/** Check if the avatar is a default avatar */

View File

@ -1,6 +1,6 @@
import { execSync } from 'node:child_process';
import pkg from '../../../package.json';
import pkg from '../../package.json';
const { CI_COMMIT_TAG, CI_COMMIT_REF_NAME, CI_COMMIT_SHA } = process.env;

View File

@ -35,21 +35,21 @@ const play = (audio: HTMLAudioElement): void => {
const soundCache: Record<Sounds, HTMLAudioElement> = {
boop: createAudio([
{
src: require('../../assets/sounds/boop.ogg'),
src: require('../assets/sounds/boop.ogg'),
type: 'audio/ogg',
},
{
src: require('../../assets/sounds/boop.mp3'),
src: require('../assets/sounds/boop.mp3'),
type: 'audio/mpeg',
},
]),
chat: createAudio([
{
src: require('../../assets/sounds/chat.oga'),
src: require('../assets/sounds/chat.oga'),
type: 'audio/ogg',
},
{
src: require('../../assets/sounds/chat.mp3'),
src: require('../assets/sounds/chat.mp3'),
type: 'audio/mpeg',
},
]),

View File

@ -1,7 +1,7 @@
{
"compilerOptions": {
"baseUrl": "src/",
"outDir": "build/",
"baseUrl": "./",
"outDir": "dist",
"sourceMap": true,
"strict": true,
"module": "ESNext",
@ -12,6 +12,9 @@
"moduleResolution": "node",
"resolveJsonModule": true,
"esModuleInterop": true,
"paths": {
"soapbox/*": ["src/*"],
},
"typeRoots": [
"./types",
"./node_modules/@types",

View File

@ -1,5 +1,5 @@
/// <reference types="vitest" />
import path from 'path';
import { fileURLToPath, URL } from 'node:url';
import react from '@vitejs/plugin-react';
import { visualizer } from 'rollup-plugin-visualizer';
@ -62,7 +62,7 @@ export default defineConfig({
short_name: 'Soapbox',
description: 'A social media frontend with a focus on custom branding and ease of use.',
},
srcDir: 'soapbox/service-worker',
srcDir: 'service-worker',
filename: 'sw.ts',
}),
viteStaticCopy({
@ -79,8 +79,7 @@ export default defineConfig({
],
resolve: {
alias: [
{ find: 'soapbox', replacement: path.resolve(__dirname, 'src', 'soapbox') },
{ find: 'assets', replacement: path.resolve(__dirname, 'src', 'assets') },
{ find: 'soapbox', replacement: fileURLToPath(new URL('./src', import.meta.url)) },
],
},
assetsInclude: ['**/*.oga'],
@ -90,6 +89,6 @@ export default defineConfig({
cache: {
dir: '../node_modules/.vitest',
},
setupFiles: 'soapbox/jest/test-setup.ts',
setupFiles: 'jest/test-setup.ts',
},
});

View File

@ -4322,7 +4322,7 @@ end-of-stream@^1.1.0, end-of-stream@^1.4.4:
dependencies:
once "^1.4.0"
enhanced-resolve@^5.15.0:
enhanced-resolve@^5.12.0, enhanced-resolve@^5.15.0:
version "5.15.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz#1af946c7d93603eb88e9896cee4904dc012e9c35"
integrity sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==
@ -4546,7 +4546,20 @@ eslint-import-resolver-node@^0.3.7:
is-core-module "^2.13.0"
resolve "^1.22.4"
eslint-module-utils@^2.8.0:
eslint-import-resolver-typescript@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.6.0.tgz#36f93e1eb65a635e688e16cae4bead54552e3bbd"
integrity sha512-QTHR9ddNnn35RTxlaEnx2gCxqFlF2SEN0SE2d17SqwyM7YOSI2GHWRYp5BiRkObTUNYPupC/3Fq2a0PpT+EKpg==
dependencies:
debug "^4.3.4"
enhanced-resolve "^5.12.0"
eslint-module-utils "^2.7.4"
fast-glob "^3.3.1"
get-tsconfig "^4.5.0"
is-core-module "^2.11.0"
is-glob "^4.0.3"
eslint-module-utils@^2.7.4, eslint-module-utils@^2.8.0:
version "2.8.0"
resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.8.0.tgz#e439fee65fc33f6bba630ff621efc38ec0375c49"
integrity sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==
@ -5110,6 +5123,13 @@ get-symbol-description@^1.0.0:
call-bind "^1.0.2"
get-intrinsic "^1.1.1"
get-tsconfig@^4.5.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/get-tsconfig/-/get-tsconfig-4.7.0.tgz#06ce112a1463e93196aa90320c35df5039147e34"
integrity sha512-pmjiZ7xtB8URYm74PlGJozDNyhvsVLUcpBa8DZBG3bWHwaHa9bPiRpiSfovw+fjhwONSCWKRyk+JQHEGZmMrzw==
dependencies:
resolve-pkg-maps "^1.0.0"
git-config-path@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/git-config-path/-/git-config-path-1.0.1.tgz#6d33f7ed63db0d0e118131503bab3aca47d54664"
@ -5688,7 +5708,7 @@ is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.7:
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055"
integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==
is-core-module@^2.13.0, is-core-module@^2.5.0, is-core-module@^2.9.0:
is-core-module@^2.11.0, is-core-module@^2.13.0, is-core-module@^2.5.0, is-core-module@^2.9.0:
version "2.13.0"
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.13.0.tgz#bb52aa6e2cbd49a30c2ba68c42bf3435ba6072db"
integrity sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==
@ -8157,6 +8177,11 @@ resolve-pathname@^3.0.0:
resolved "https://registry.yarnpkg.com/resolve-pathname/-/resolve-pathname-3.0.0.tgz#99d02224d3cf263689becbb393bc560313025dcd"
integrity sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng==
resolve-pkg-maps@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz#616b3dc2c57056b5588c31cdf4b3d64db133720f"
integrity sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==
resolve@^1.1.7, resolve@^1.14.2, resolve@^1.19.0, resolve@^1.22.2, resolve@^1.22.4:
version "1.22.6"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.6.tgz#dd209739eca3aef739c626fea1b4f3c506195362"