Skip to content

chore: migrate remaining chalk usage to miniChalk utility#15782

Open
roli-lpci wants to merge 2 commits intopayloadcms:mainfrom
roli-lpci:chore/remove-chalk-dependency
Open

chore: migrate remaining chalk usage to miniChalk utility#15782
roli-lpci wants to merge 2 commits intopayloadcms:mainfrom
roli-lpci:chore/remove-chalk-dependency

Conversation

@roli-lpci
Copy link

Summary

Removes the chalk dependency from the published create-payload-app package and cleans up a dead chalk import left behind in plugin-multi-tenant after #14003.

  • Adds a local miniChalk utility to create-payload-app following the same pattern already used in packages/payload and packages/plugin-multi-tenant
  • Uses proper SGR close codes (\x1b[39m, \x1b[49m, \x1b[22m) instead of full reset (\x1b[0m) so nested calls like miniChalk.bold(... miniChalk.green(...) ...) preserve outer styles — matching chalk's nesting behavior
  • Converts chalk tagged template literals in messages.ts to direct miniChalk function calls
  • Removes chalk from create-payload-app/package.json dependencies

Files changed

File Change
packages/create-payload-app/src/utils/miniChalk.ts New — lightweight chalk replacement with nested style support
packages/create-payload-app/src/utils/log.ts chalk → miniChalk
packages/create-payload-app/src/utils/messages.ts chalk → miniChalk, tagged templates → function calls
packages/create-payload-app/src/lib/create-project.ts chalk → miniChalk
packages/create-payload-app/src/lib/wrap-next-config.ts chalk → miniChalk
packages/create-payload-app/src/main.ts chalk → miniChalk
packages/plugin-multi-tenant/src/index.ts Remove unused chalk import (already uses miniChalk)
packages/create-payload-app/package.json Remove chalk dependency

Test plan

  • TypeScript compilation passes (tsc --noEmit) for both create-payload-app and plugin-multi-tenant
  • ESLint passes with zero new errors on all changed files
  • npx create-payload-app shows colored output correctly (bold labels, bg-colored badges, dim text)
  • Nested styles render correctly (e.g. bold text containing green highlight in Install Payload in this project?)

Remove the chalk dependency from create-payload-app and the unused
chalk import from plugin-multi-tenant. This continues the migration
started in payloadcms#14003 by replacing all remaining chalk v4 calls with the
project's existing miniChalk utility pattern.

Changes:
- Add miniChalk utility to create-payload-app with proper SGR close
  codes for correct nested styling (e.g. bold wrapping bgBlack)
- Migrate all 5 create-payload-app source files from chalk to miniChalk
- Convert chalk tagged template literals to miniChalk function calls
- Remove unused chalk import from plugin-multi-tenant/src/index.ts
- Remove chalk from create-payload-app/package.json

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
User-facing CLI tools should respect the NO_COLOR convention
(https://no-color.org/) and FORCE_COLOR env vars. Without this,
piped output and NO_COLOR=1 usage would contain raw ANSI escapes.

Also documents the intentional divergence from the existing
miniChalk implementations (specific SGR close codes vs full reset).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant