Imports https://github.com/payloadcms/payload-admin-bar into the Payload monorepo. This package will now be regularly maintained directly alongside all Payload packages and now includes its own test suite. A few changes minor have been made between v1.0.7 and latest: 1. The package name has changed from `payload-admin-bar` to `@payloadcms/admin-bar`. ```diff - import { PayloadAdminBar } from 'payload-admin-bar' + import { PayloadAdminBar } from '@payloadcms/admin-bar' ``` 2. The `collection` prop has been renamed to `collectionSlug` 3. The `authCollection` prop has been renamed to `authCollectionSlug` Here's a screenshot of the admin bar in use within the Website Template: <img width="1057" alt="Screenshot 2025-03-05 at 1 20 04 PM" src="https://github.com/user-attachments/assets/2597a8fd-da75-4b2f-8979-4fc8132999e8" /> --------- Co-authored-by: Kalon Robson <kalon.robson@outlook.com>
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import path from 'path'
|
|
|
|
const [testConfigDir] = process.argv.slice(2)
|
|
|
|
import type { SanitizedConfig } from 'payload'
|
|
|
|
import fs from 'fs'
|
|
import { generateImportMap } from 'payload'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
let testDir: string
|
|
|
|
async function run() {
|
|
if (testConfigDir) {
|
|
testDir = path.resolve(dirname, testConfigDir)
|
|
|
|
const pathWithConfig = path.resolve(testDir, 'config.ts')
|
|
console.log('Generating ad-hoc import map for config:', pathWithConfig)
|
|
|
|
const config: SanitizedConfig = await (await import(pathWithConfig)).default
|
|
|
|
let rootDir = ''
|
|
|
|
if (
|
|
testConfigDir === 'live-preview' ||
|
|
testConfigDir === 'admin-root' ||
|
|
testConfigDir === 'admin-bar'
|
|
) {
|
|
rootDir = testDir
|
|
|
|
if (process.env.PAYLOAD_TEST_PROD === 'true') {
|
|
// If in prod mode, there may be a testSuite/prod folder. If so, use that as the rootDir
|
|
const prodDir = path.resolve(testDir, 'prod')
|
|
try {
|
|
fs.accessSync(prodDir, fs.constants.F_OK)
|
|
rootDir = prodDir
|
|
} catch (err) {
|
|
// Swallow err - no prod folder
|
|
}
|
|
}
|
|
} else {
|
|
rootDir = path.resolve(dirname, '..')
|
|
}
|
|
|
|
process.env.ROOT_DIR = rootDir
|
|
await generateImportMap(config, { log: true, force: true })
|
|
}
|
|
}
|
|
|
|
await run()
|