build: remove unused config (#1990)

This commit is contained in:
Himself65 2023-04-17 23:11:46 -05:00 committed by GitHub
parent 91c3040db7
commit 7be96a2e41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 7 additions and 37 deletions

View File

@ -20,10 +20,7 @@ For more information on Next.js, take a look at the [Next.js Documentation](http
`preset.config.mjs` contains the build presets for the application. The presets are used to configure the build process for different environments. The presets are: `preset.config.mjs` contains the build presets for the application. The presets are used to configure the build process for different environments. The presets are:
- `enableIndexedDBProvider`: Enables the IndexedDB provider for the application. This is used to store data in the browser.
- `enableBroadCastChannelProvider`: Enables the Broadcast Channel provider for the application. This is used to communicate between local browser tabs. - `enableBroadCastChannelProvider`: Enables the Broadcast Channel provider for the application. This is used to communicate between local browser tabs.
- `prefetchWorkspace`: **deprecated**
- `exposeInternal`: Exposes internal variables into `globalThis` for debugging purposes.
- `enableDebugPage`: Enables the debug page for the application. This is used for debugging purposes. - `enableDebugPage`: Enables the debug page for the application. This is used for debugging purposes.
## BlockSuite Integration ## BlockSuite Integration

View File

@ -1,16 +1,11 @@
import 'dotenv/config'; import 'dotenv/config';
const config = { const config = {
enableIndexedDBProvider: Boolean(process.env.ENABLE_IDB_PROVIDER ?? '1'),
enableBroadCastChannelProvider: Boolean( enableBroadCastChannelProvider: Boolean(
process.env.ENABLE_BC_PROVIDER ?? '1' process.env.ENABLE_BC_PROVIDER ?? '1'
), ),
prefetchWorkspace: Boolean(process.env.PREFETCH_WORKSPACE ?? '1'),
exposeInternal: Boolean(process.env.EXPOSE_INTERNAL ?? '1'),
enableDebugPage: Boolean( enableDebugPage: Boolean(
process.env.ENABLE_DEBUG_PAGE ?? process.env.NODE_ENV === 'development' process.env.ENABLE_DEBUG_PAGE ?? process.env.NODE_ENV === 'development'
), ),
enableSubpage: Boolean(process.env.ENABLE_SUBPAGE ?? '1'),
enableChangeLog: Boolean(process.env.ENABLE_CHANGELOG ?? '1'),
}; };
export default config; export default config;

View File

@ -19,7 +19,6 @@ export const createAffineProviders = (
createAffineWebSocketProvider(blockSuiteWorkspace), createAffineWebSocketProvider(blockSuiteWorkspace),
config.enableBroadCastChannelProvider && config.enableBroadCastChannelProvider &&
createBroadCastChannelProvider(blockSuiteWorkspace), createBroadCastChannelProvider(blockSuiteWorkspace),
config.enableIndexedDBProvider &&
createIndexedDBProvider(blockSuiteWorkspace), createIndexedDBProvider(blockSuiteWorkspace),
] as any[] ] as any[]
).filter(v => Boolean(v)); ).filter(v => Boolean(v));

View File

@ -1,5 +1,4 @@
import { MuiFade, Tooltip } from '@affine/component'; import { MuiFade, Tooltip } from '@affine/component';
import { config } from '@affine/env';
import { useTranslation } from '@affine/i18n'; import { useTranslation } from '@affine/i18n';
import { CloseIcon, NewIcon } from '@blocksuite/icons'; import { CloseIcon, NewIcon } from '@blocksuite/icons';
import { lazy, Suspense, useState } from 'react'; import { lazy, Suspense, useState } from 'react';
@ -21,9 +20,7 @@ const ContactModal = lazy(() =>
export type IslandItemNames = 'whatNew' | 'contact' | 'shortcuts'; export type IslandItemNames = 'whatNew' | 'contact' | 'shortcuts';
export const HelpIsland = ({ export const HelpIsland = ({
showList = config.enableChangeLog showList = ['whatNew', 'contact', 'shortcuts'],
? ['whatNew', 'contact', 'shortcuts']
: ['contact', 'shortcuts'],
}: { }: {
showList?: IslandItemNames[]; showList?: IslandItemNames[];
}) => { }) => {

View File

@ -1,4 +1,3 @@
import { config } from '@affine/env';
import { useTranslation } from '@affine/i18n'; import { useTranslation } from '@affine/i18n';
import { WorkspaceFlavour } from '@affine/workspace/type'; import { WorkspaceFlavour } from '@affine/workspace/type';
import { import {
@ -135,7 +134,7 @@ export const WorkSpaceSliderBar: React.FC<WorkSpaceSliderBarProps> = ({
currentWorkspace={currentWorkspace} currentWorkspace={currentWorkspace}
onClick={onOpenWorkspaceListModal} onClick={onOpenWorkspaceListModal}
/> />
{config.enableChangeLog && <ChangeLog />} <ChangeLog />
<StyledListItem <StyledListItem
data-testid="slider-bar-quick-search-button" data-testid="slider-bar-quick-search-button"
onClick={useCallback(() => { onClick={useCallback(() => {

View File

@ -1,5 +1,5 @@
import { DebugLogger } from '@affine/debug'; import { DebugLogger } from '@affine/debug';
import { config, DEFAULT_HELLO_WORLD_PAGE_ID } from '@affine/env'; import { DEFAULT_HELLO_WORLD_PAGE_ID } from '@affine/env';
import { ensureRootPinboard, initPage } from '@affine/env/blocksuite'; import { ensureRootPinboard, initPage } from '@affine/env/blocksuite';
import { setUpLanguage, useTranslation } from '@affine/i18n'; import { setUpLanguage, useTranslation } from '@affine/i18n';
import { createAffineGlobalChannel } from '@affine/workspace/affine/sync'; import { createAffineGlobalChannel } from '@affine/workspace/affine/sync';
@ -448,11 +448,7 @@ export const WorkspaceLayoutInner: FC<PropsWithChildren> = ({ children }) => {
{!isPublicWorkspace && ( {!isPublicWorkspace && (
<HelpIsland <HelpIsland
showList={ showList={
router.query.pageId router.query.pageId ? undefined : ['whatNew', 'contact']
? undefined
: config.enableChangeLog
? ['whatNew', 'contact']
: ['contact']
} }
/> />
)} )}

View File

@ -11,14 +11,8 @@ export const publicRuntimeConfigSchema = z.object({
hash: z.string(), hash: z.string(),
serverAPI: z.string(), serverAPI: z.string(),
editorVersion: z.string(), editorVersion: z.string(),
enableIndexedDBProvider: z.boolean(),
enableBroadCastChannelProvider: z.boolean(), enableBroadCastChannelProvider: z.boolean(),
prefetchWorkspace: z.boolean(),
enableDebugPage: z.boolean(), enableDebugPage: z.boolean(),
// expose internal api to globalThis, **development only**
exposeInternal: z.boolean(),
enableSubpage: z.boolean(),
enableChangeLog: z.boolean(),
}); });
export type PublicRuntimeConfig = z.infer<typeof publicRuntimeConfigSchema>; export type PublicRuntimeConfig = z.infer<typeof publicRuntimeConfigSchema>;
@ -103,7 +97,7 @@ export function getEnvironment() {
environment = { environment = {
origin: window.location.origin, origin: window.location.origin,
isDesktop: window.appInfo?.electron, isDesktop: !!window.appInfo?.electron,
isBrowser: true, isBrowser: true,
isServer: false, isServer: false,
isDebug, isDebug,

View File

@ -162,7 +162,6 @@ export const createLocalProviders = (
[ [
config.enableBroadCastChannelProvider && config.enableBroadCastChannelProvider &&
createBroadCastChannelProvider(blockSuiteWorkspace), createBroadCastChannelProvider(blockSuiteWorkspace),
config.enableIndexedDBProvider &&
createIndexedDBProvider(blockSuiteWorkspace), createIndexedDBProvider(blockSuiteWorkspace),
] as any[] ] as any[]
).filter(v => Boolean(v)); ).filter(v => Boolean(v));

View File

@ -8,12 +8,7 @@ export default function getConfig() {
editorVersion: 'UNKNOWN', editorVersion: 'UNKNOWN',
serverAPI: 'http://127.0.0.1:3000/', serverAPI: 'http://127.0.0.1:3000/',
enableBroadCastChannelProvider: true, enableBroadCastChannelProvider: true,
enableIndexedDBProvider: true,
enableDebugPage: true, enableDebugPage: true,
prefetchWorkspace: false,
exposeInternal: true,
enableSubpage: true,
enableChangeLog: true,
}, },
}; };
} }

View File

@ -10,7 +10,6 @@ test('public single page', async ({ page, browser }) => {
await openHomePage(page); await openHomePage(page);
const [a] = await createFakeUser(); const [a] = await createFakeUser();
await loginUser(page, a); await loginUser(page, a);
await waitMarkdownImported(page);
const name = `test-${Date.now()}`; const name = `test-${Date.now()}`;
await createWorkspace({ name }, page); await createWorkspace({ name }, page);
await waitMarkdownImported(page); await waitMarkdownImported(page);