Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: better messaging when no arg passed to payload cli #10550

Merged
merged 1 commit into from
Jan 13, 2025
Merged
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
18 changes: 16 additions & 2 deletions packages/payload/src/bin/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import { Cron } from 'croner'
import minimist from 'minimist'
import { pathToFileURL } from 'node:url'
Expand All @@ -11,7 +12,18 @@ import { generateImportMap } from './generateImportMap/index.js'
import { generateTypes } from './generateTypes.js'
import { info } from './info.js'
import { loadEnv } from './loadEnv.js'
import { migrate } from './migrate.js'
import { migrate, availableCommands as migrateCommands } from './migrate.js'

// Note: this does not account for any user bin scripts
const availableScripts = [
'generate:db-schema',
'generate:importmap',
'generate:types',
'info',
'jobs:run',
'run',
...migrateCommands,
] as const

export const bin = async () => {
loadEnv()
Expand Down Expand Up @@ -137,6 +149,8 @@ export const bin = async () => {
process.exit(0)
}

console.error(`Unknown script: "${script}".`)
console.error(script ? `Unknown command: "${script}"` : 'Please provide a command to run')
console.log(`\nAvailable commands:\n${availableScripts.map((c) => ` - ${c}`).join('\n')}`)

process.exit(1)
}
2 changes: 1 addition & 1 deletion packages/payload/src/bin/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const prettySyncLogger = {
loggerOptions: {},
}

const availableCommands = [
export const availableCommands = [
'migrate',
'migrate:create',
'migrate:down',
Expand Down
Loading