chore: safely accesses more dependencies
This commit is contained in:
@@ -5,7 +5,7 @@ import { getTranslation } from '@payloadcms/translations'
|
||||
import { type MappedField, useConfig } from '@payloadcms/ui'
|
||||
import { fieldAffectsData, fieldIsPresentationalOnly } from 'payload/types'
|
||||
import React from 'react'
|
||||
import ReactDiffViewerDefault from 'react-diff-viewer-continued'
|
||||
import ReactDiffViewerImport from 'react-diff-viewer-continued'
|
||||
|
||||
import type { Props } from '../types.d.ts'
|
||||
|
||||
@@ -13,7 +13,8 @@ import Label from '../../Label/index.js'
|
||||
import { diffStyles } from '../styles.js'
|
||||
import './index.scss'
|
||||
|
||||
const ReactDiffViewer = ReactDiffViewerDefault.default
|
||||
const ReactDiffViewer = (ReactDiffViewerImport.default ||
|
||||
ReactDiffViewerImport) as unknown as typeof ReactDiffViewerImport.default
|
||||
|
||||
const baseClass = 'relationship-diff'
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
'use client'
|
||||
import React from 'react'
|
||||
import ReactDiffViewerDefault from 'react-diff-viewer-continued'
|
||||
import ReactDiffViewerImport from 'react-diff-viewer-continued'
|
||||
|
||||
const ReactDiffViewer = ReactDiffViewerDefault.default
|
||||
const DiffMethod = ReactDiffViewerDefault.DiffMethod
|
||||
const ReactDiffViewer = (ReactDiffViewerImport.default ||
|
||||
ReactDiffViewerImport) as unknown as typeof ReactDiffViewerImport.default
|
||||
|
||||
const DiffMethod = ReactDiffViewerImport.DiffMethod
|
||||
|
||||
export const DiffViewer: React.FC<{
|
||||
comparisonToRender: string
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
'use client'
|
||||
import React from 'react'
|
||||
import ReactDiffViewerDefault from 'react-diff-viewer-continued'
|
||||
import ReactDiffViewerImport from 'react-diff-viewer-continued'
|
||||
|
||||
const ReactDiffViewer = ReactDiffViewerDefault.default
|
||||
const DiffMethod = ReactDiffViewerDefault.DiffMethod
|
||||
const ReactDiffViewer = (ReactDiffViewerImport.default ||
|
||||
ReactDiffViewerImport) as unknown as typeof ReactDiffViewerImport.default
|
||||
|
||||
const DiffMethod = ReactDiffViewerImport.DiffMethod
|
||||
|
||||
export const DiffViewer: React.FC<{
|
||||
comparisonToRender: string
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import pino from 'pino'
|
||||
import PinoPretty from 'pino-pretty'
|
||||
import pinoImport from 'pino'
|
||||
import pinoPrettyImport from 'pino-pretty'
|
||||
|
||||
export type PayloadLogger = pino.Logger
|
||||
const pino = (pinoImport.default || pinoImport) as unknown as typeof pinoImport.default
|
||||
const pinoPretty = (pinoPrettyImport.default ||
|
||||
pinoPrettyImport) as unknown as typeof pinoPrettyImport.default
|
||||
|
||||
export type PayloadLogger = pinoImport.default.Logger
|
||||
|
||||
const prettyOptions = {
|
||||
colorize: true,
|
||||
@@ -9,14 +13,14 @@ const prettyOptions = {
|
||||
translateTime: 'SYS:HH:MM:ss',
|
||||
}
|
||||
|
||||
export const defaultLoggerOptions: pino.LoggerOptions = {
|
||||
export const defaultLoggerOptions: pinoImport.default.LoggerOptions = {
|
||||
transport: {
|
||||
options: prettyOptions,
|
||||
target: 'pino-pretty',
|
||||
},
|
||||
}
|
||||
|
||||
export const prettySyncLoggerDestination = PinoPretty.default({
|
||||
export const prettySyncLoggerDestination = pinoPretty({
|
||||
...prettyOptions,
|
||||
destination: 1, // stdout
|
||||
sync: true,
|
||||
@@ -24,11 +28,11 @@ export const prettySyncLoggerDestination = PinoPretty.default({
|
||||
|
||||
const getLogger = (
|
||||
name = 'payload',
|
||||
options?: pino.LoggerOptions,
|
||||
destination?: pino.DestinationStream,
|
||||
options?: pinoImport.default.LoggerOptions,
|
||||
destination?: pinoImport.default.DestinationStream,
|
||||
): PayloadLogger => {
|
||||
if (options) {
|
||||
return pino.default(
|
||||
return pino(
|
||||
{
|
||||
name: options?.name || name,
|
||||
enabled: process.env.DISABLE_LOGGING !== 'true',
|
||||
@@ -38,7 +42,7 @@ const getLogger = (
|
||||
)
|
||||
}
|
||||
|
||||
return pino.default(prettySyncLoggerDestination)
|
||||
return pino(prettySyncLoggerDestination)
|
||||
}
|
||||
|
||||
export default getLogger
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { execSync } from 'child_process'
|
||||
import Conf from 'conf'
|
||||
import ConfImport from 'conf'
|
||||
import { randomBytes } from 'crypto'
|
||||
import findUp from 'find-up'
|
||||
import fs from 'fs'
|
||||
@@ -10,6 +10,8 @@ import type { ServerInitEvent } from './events/serverInit.js'
|
||||
|
||||
import { oneWayHash } from './oneWayHash.js'
|
||||
|
||||
const Conf = (ConfImport.default || ConfImport) as unknown as typeof ConfImport.default
|
||||
|
||||
export type BaseEvent = {
|
||||
envID: string
|
||||
nodeEnv: string
|
||||
@@ -61,7 +63,7 @@ export const sendEvent = async ({ event, payload }: Args): Promise<void> => {
|
||||
* generated from random data and completely anonymous.
|
||||
*/
|
||||
const getEnvID = (): string => {
|
||||
const conf = new Conf.default()
|
||||
const conf = new Conf()
|
||||
const ENV_ID = 'envID'
|
||||
|
||||
const val = conf.get(ENV_ID)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import EditorDefault from '@monaco-editor/react'
|
||||
import EditorImport from '@monaco-editor/react'
|
||||
import React from 'react'
|
||||
|
||||
import type { Props } from './types.d.ts'
|
||||
@@ -7,7 +7,7 @@ import { useTheme } from '../../providers/Theme/index.js'
|
||||
import { ShimmerEffect } from '../ShimmerEffect/index.js'
|
||||
import './index.scss'
|
||||
|
||||
const Editor = EditorDefault.default
|
||||
const Editor = (EditorImport.default || EditorImport) as unknown as typeof EditorImport.default
|
||||
|
||||
const baseClass = 'code-editor'
|
||||
|
||||
|
||||
@@ -6,30 +6,30 @@ import type { Config, SanitizedConfig } from '../packages/payload/src/config/typ
|
||||
import { mongooseAdapter } from '../packages/db-mongodb/src/index.js'
|
||||
import { postgresAdapter } from '../packages/db-postgres/src/index.js'
|
||||
import { buildConfig as buildPayloadConfig } from '../packages/payload/src/config/build.js'
|
||||
import {
|
||||
AlignFeature,
|
||||
BlockQuoteFeature,
|
||||
BlocksFeature,
|
||||
BoldFeature,
|
||||
CheckListFeature,
|
||||
HeadingFeature,
|
||||
IndentFeature,
|
||||
InlineCodeFeature,
|
||||
ItalicFeature,
|
||||
LinkFeature,
|
||||
OrderedListFeature,
|
||||
ParagraphFeature,
|
||||
RelationshipFeature,
|
||||
StrikethroughFeature,
|
||||
SubscriptFeature,
|
||||
SuperscriptFeature,
|
||||
TreeViewFeature,
|
||||
UnderlineFeature,
|
||||
UnorderedListFeature,
|
||||
UploadFeature,
|
||||
lexicalEditor,
|
||||
} from '../packages/richtext-lexical/src'
|
||||
// import { slateEditor } from '../packages/richtext-slate/src/index.js'
|
||||
// import {
|
||||
// AlignFeature,
|
||||
// BlockQuoteFeature,
|
||||
// BlocksFeature,
|
||||
// BoldFeature,
|
||||
// CheckListFeature,
|
||||
// HeadingFeature,
|
||||
// IndentFeature,
|
||||
// InlineCodeFeature,
|
||||
// ItalicFeature,
|
||||
// LinkFeature,
|
||||
// OrderedListFeature,
|
||||
// ParagraphFeature,
|
||||
// RelationshipFeature,
|
||||
// StrikethroughFeature,
|
||||
// SubscriptFeature,
|
||||
// SuperscriptFeature,
|
||||
// TreeViewFeature,
|
||||
// UnderlineFeature,
|
||||
// UnorderedListFeature,
|
||||
// UploadFeature,
|
||||
// lexicalEditor,
|
||||
// } from '../packages/richtext-lexical/src'
|
||||
import { slateEditor } from '../packages/richtext-slate/src/index.js'
|
||||
|
||||
// process.env.PAYLOAD_DATABASE = 'postgres'
|
||||
|
||||
@@ -66,42 +66,9 @@ export function buildConfigWithDefaults(testConfig?: Partial<Config>): Promise<S
|
||||
const config: Config = {
|
||||
db: databaseAdapters[process.env.PAYLOAD_DATABASE || 'mongoose'],
|
||||
secret: 'TEST_SECRET',
|
||||
// editor: slateEditor({
|
||||
// admin: {
|
||||
// upload: {
|
||||
// collections: {
|
||||
// media: {
|
||||
// fields: [
|
||||
// {
|
||||
// name: 'alt',
|
||||
// type: 'text',
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// }),
|
||||
editor: lexicalEditor({
|
||||
features: [
|
||||
ParagraphFeature(),
|
||||
RelationshipFeature(),
|
||||
LinkFeature({
|
||||
fields: [
|
||||
{
|
||||
name: 'description',
|
||||
type: 'text',
|
||||
},
|
||||
],
|
||||
}),
|
||||
CheckListFeature(),
|
||||
UnorderedListFeature(),
|
||||
OrderedListFeature(),
|
||||
AlignFeature(),
|
||||
BlockQuoteFeature(),
|
||||
BoldFeature(),
|
||||
ItalicFeature(),
|
||||
UploadFeature({
|
||||
editor: slateEditor({
|
||||
admin: {
|
||||
upload: {
|
||||
collections: {
|
||||
media: {
|
||||
fields: [
|
||||
@@ -112,56 +79,89 @@ export function buildConfigWithDefaults(testConfig?: Partial<Config>): Promise<S
|
||||
],
|
||||
},
|
||||
},
|
||||
}),
|
||||
UnderlineFeature(),
|
||||
StrikethroughFeature(),
|
||||
SubscriptFeature(),
|
||||
SuperscriptFeature(),
|
||||
InlineCodeFeature(),
|
||||
TreeViewFeature(),
|
||||
HeadingFeature(),
|
||||
IndentFeature(),
|
||||
BlocksFeature({
|
||||
blocks: [
|
||||
{
|
||||
slug: 'myBlock',
|
||||
fields: [
|
||||
{
|
||||
name: 'someText',
|
||||
type: 'text',
|
||||
},
|
||||
{
|
||||
name: 'someTextRequired',
|
||||
type: 'text',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'radios',
|
||||
type: 'radio',
|
||||
options: [
|
||||
{
|
||||
label: 'Option 1',
|
||||
value: 'option1',
|
||||
},
|
||||
{
|
||||
label: 'Option 2',
|
||||
value: 'option2',
|
||||
},
|
||||
{
|
||||
label: 'Option 3',
|
||||
value: 'option3',
|
||||
},
|
||||
],
|
||||
validate: (value) => {
|
||||
return value !== 'option2' ? true : 'Cannot be option2'
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
},
|
||||
}),
|
||||
// editor: lexicalEditor({
|
||||
// features: [
|
||||
// ParagraphFeature(),
|
||||
// RelationshipFeature(),
|
||||
// LinkFeature({
|
||||
// fields: [
|
||||
// {
|
||||
// name: 'description',
|
||||
// type: 'text',
|
||||
// },
|
||||
// ],
|
||||
// }),
|
||||
// CheckListFeature(),
|
||||
// UnorderedListFeature(),
|
||||
// OrderedListFeature(),
|
||||
// AlignFeature(),
|
||||
// BlockQuoteFeature(),
|
||||
// BoldFeature(),
|
||||
// ItalicFeature(),
|
||||
// UploadFeature({
|
||||
// collections: {
|
||||
// media: {
|
||||
// fields: [
|
||||
// {
|
||||
// name: 'alt',
|
||||
// type: 'text',
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// },
|
||||
// }),
|
||||
// UnderlineFeature(),
|
||||
// StrikethroughFeature(),
|
||||
// SubscriptFeature(),
|
||||
// SuperscriptFeature(),
|
||||
// InlineCodeFeature(),
|
||||
// TreeViewFeature(),
|
||||
// HeadingFeature(),
|
||||
// IndentFeature(),
|
||||
// BlocksFeature({
|
||||
// blocks: [
|
||||
// {
|
||||
// slug: 'myBlock',
|
||||
// fields: [
|
||||
// {
|
||||
// name: 'someText',
|
||||
// type: 'text',
|
||||
// },
|
||||
// {
|
||||
// name: 'someTextRequired',
|
||||
// type: 'text',
|
||||
// required: true,
|
||||
// },
|
||||
// {
|
||||
// name: 'radios',
|
||||
// type: 'radio',
|
||||
// options: [
|
||||
// {
|
||||
// label: 'Option 1',
|
||||
// value: 'option1',
|
||||
// },
|
||||
// {
|
||||
// label: 'Option 2',
|
||||
// value: 'option2',
|
||||
// },
|
||||
// {
|
||||
// label: 'Option 3',
|
||||
// value: 'option3',
|
||||
// },
|
||||
// ],
|
||||
// validate: (value) => {
|
||||
// return value !== 'option2' ? true : 'Cannot be option2'
|
||||
// },
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// }),
|
||||
// ],
|
||||
// }),
|
||||
sharp,
|
||||
telemetry: false,
|
||||
...testConfig,
|
||||
|
||||
Reference in New Issue
Block a user