-
Notifications
You must be signed in to change notification settings - Fork 2
Show animated Prisma branding only on init and root help #253
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
Open
AmanVarshney01
wants to merge
9
commits into
main
Choose a base branch
from
feat/animated-prisma-help-logo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
09baec1
Add animated horizontal Prisma logo to root help
AmanVarshney01 a054a36
Remove redundant artwork comments
AmanVarshney01 d06b224
Remove implementation-detail animation tests
AmanVarshney01 a18e5f5
Use Node styleText for logo colors
AmanVarshney01 e415fdd
Preserve SIGTERM exit status during help animation
AmanVarshney01 69ff0f6
Merge remote-tracking branch 'origin/main' into feat/animated-prisma-…
AmanVarshney01 9a2d94a
Limit branding to init and root help and fix release checks
AmanVarshney01 b1cc820
Share artwork rendering and layout between help and init
AmanVarshney01 38758ac
Stop artwork rewrites on resize and isolate wordmark styling
AmanVarshney01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| import { styleText } from "node:util"; | ||
| import { resolveIsCI } from "../ci"; | ||
| import { | ||
| type HelpArtworkLine, | ||
| renderArtworkLine, | ||
| revealArtwork, | ||
| } from "../help-artwork"; | ||
| import type { OutputStream, Runtime } from "../runtime"; | ||
| import type { Invocation } from "./engine"; | ||
| import { textWidth } from "./palette"; | ||
|
|
||
| export async function runCommandArtwork( | ||
| artwork: readonly HelpArtworkLine[] | undefined, | ||
| { runtime, state, signal, delay }: Invocation, | ||
| ): Promise<void> { | ||
| if (signal.aborted) throw signal.reason; | ||
| const out = runtime.stderr; | ||
| if ( | ||
| state.format !== "human" || | ||
| state.logLevel === "error" || | ||
| !runtime.isTty.stderr | ||
| ) | ||
| return; | ||
| await writeArtworkFrames({ | ||
| out, | ||
| animate: | ||
| state.interactive && | ||
| canAnimateArtwork(runtime, state.argv, state.colorEnabled), | ||
| delay, | ||
| signal, | ||
| render: (progress) => { | ||
| const lines: string[] = []; | ||
| const rows = addArtwork( | ||
| lines, | ||
| artwork, | ||
| out.columns, | ||
| state.colorEnabled, | ||
| progress, | ||
| ); | ||
| return { text: rows === 0 ? "" : `${lines.join("\n")}\n`, rows }; | ||
| }, | ||
| }); | ||
| if (signal.aborted) throw signal.reason; | ||
| } | ||
|
|
||
| export function addArtwork( | ||
| lines: string[], | ||
| source: readonly HelpArtworkLine[] | undefined, | ||
| columns: number | undefined, | ||
| colorEnabled: boolean, | ||
| progress: number, | ||
| ): number { | ||
| const artwork = revealArtwork(source, progress)?.map((line) => | ||
| colorEnabled | ||
| ? styleText( | ||
| "reset", | ||
| styleText("bold", renderArtworkLine(line, true), { | ||
| validateStream: false, | ||
| }), | ||
| { validateStream: false }, | ||
| ) | ||
| : renderArtworkLine(line, false), | ||
| ); | ||
| if (!artwork?.length || columns === undefined || !Number.isFinite(columns)) { | ||
| return 0; | ||
| } | ||
| const start = 2; | ||
| const width = Math.max(...artwork.map(textWidth)); | ||
| const left = columns - width - 2; | ||
| if ( | ||
| artwork.length > lines.length - start || | ||
| lines | ||
| .slice(start, start + artwork.length) | ||
| .some((line) => textWidth(line) + 4 > left) | ||
| ) { | ||
| if (columns >= width + 4) { | ||
| lines.unshift(...artwork.map((row) => ` ${row}`), ""); | ||
| return artwork.length + 1; | ||
| } | ||
| return 0; | ||
| } | ||
| for (const [index, row] of artwork.entries()) { | ||
| const line = lines[start + index]; | ||
| lines[start + index] = `${line}${" ".repeat(left - textWidth(line))}${row}`; | ||
| } | ||
| return start + artwork.length; | ||
| } | ||
|
|
||
| export async function writeArtworkFrames({ | ||
| out, | ||
| render, | ||
| animate, | ||
| delay, | ||
| signal, | ||
| }: { | ||
| out: OutputStream; | ||
| render: (progress: number) => { text: string; rows: number }; | ||
| animate: boolean; | ||
| delay: (ms: number, signal: AbortSignal) => Promise<void>; | ||
| signal: AbortSignal; | ||
| }): Promise<void> { | ||
| const columns = out.columns; | ||
| const rows = out.rows; | ||
| const resized = () => out.columns !== columns || out.rows !== rows; | ||
| const final = render(1); | ||
| if (!animate || final.rows === 0 || final.rows + 1 >= (out.rows ?? 24)) { | ||
| out.write(final.text); | ||
| return; | ||
| } | ||
| const frame = (progress: number): string => | ||
| `${render(progress).text.split("\n").slice(0, final.rows).join("\n")}\n`; | ||
| try { | ||
| out.write(`\u001b[?25l${frame(0)}`); | ||
| for (let step = 1; step <= 30; step++) { | ||
| // biome-ignore lint/performance/noAwaitInLoops: Frames must be paced sequentially. | ||
| await delay(20, signal); | ||
| if (signal.aborted || resized()) break; | ||
| out.write(`\u001b[${final.rows}A\r${frame(step / 30)}`); | ||
| } | ||
| } finally { | ||
| try { | ||
| out.write( | ||
| resized() | ||
| ? `\r\n${render(1).text}` | ||
| : `\u001b[${final.rows}A\r${final.text}`, | ||
| ); | ||
| } finally { | ||
| out.write("\u001b[?25h"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export function canAnimateArtwork( | ||
| runtime: Runtime, | ||
| argv: readonly string[], | ||
| color: boolean, | ||
| ): boolean { | ||
| const terminator = argv.indexOf("--"); | ||
| const flags = terminator === -1 ? argv : argv.slice(0, terminator); | ||
| return ( | ||
| color && | ||
| !resolveIsCI(runtime) && | ||
| runtime.env.TERM !== "dumb" && | ||
| runtime.env.NO_COLOR === undefined && | ||
| runtime.env.PRISMA_REDUCED_MOTION !== "1" && | ||
| !flags.some((flag) => ["--no-interactive", "--quiet", "-q"].includes(flag)) | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Restore tarball dependency conformance before release.
The PR Quality Test already fails because the published Composer CLI and ORM releases require
@prisma/cli-engine0.3.0, while these packages now package0.3.1. Publish compatible Composer CLI and ORM releases first, update these pins to compatible releases, or defer the engine version bump.packages/cli-engine/package.json#L3-L3: keep0.3.1only when published dependents accept it.packages/cli/package.json#L52-L52: use dependency versions with a compatible engine requirement.packages/prisma/package.json#L53-L53: use dependency versions with a compatible engine requirement.📍 Affects 3 files
packages/cli-engine/package.json#L3-L3(this comment)packages/cli/package.json#L52-L52packages/prisma/package.json#L53-L53🤖 Prompt for AI Agents