Diff Review Approval

deploy.ts

Approved
export async function ship(env: string) {
const url = await build(env);
return publish(url);
const out = await build(env, { cache: true });
return publish(out.url, { preview: true });
}
Smiling man in a floral shirt

Brian Eno

Caching here cuts the cold build in half. Lovely.

About this piece

Diff Review Approval

Two lines out, two lines in. A reviewer leaves a short note on the new line, a second cursor presses Approve to mark the change approved, and the review plays again.

Usage

The import and the props worth knowing about, in one place.

import { Code19 } from "@/components/beste/piece/code19";

<Code19
  fileName="deploy.ts"
  lines={[
    {
      "kind": "context",
      "text": "export async function ship(env: string) {"
    },
    {
      "kind": "removed",
      "text": "  const url = await build(env);"
    },
    {
      "kind": "removed",
      "text": "  return publish(url);"
    },
    {
      "kind": "added",
      "text": "  const out = await build(env, { cache: true });"
    },
    {
      "kind": "added",
      "text": "  return publish(out.url, { preview: true });"
    },
    {
      "kind": "context",
      "text": "}"
    }
  ]}
  commentLine={3}
  comment={{
    "author": "Brian Eno",
    "avatar": {
      "src": "https://images.unsplash.com/photo-1656337789708-cdf37b07112d?q=80&w=200&h=200&auto=format&fit=crop",
      "alt": "Smiling man in a floral shirt"
    },
    "body": "Caching here cuts the cold build in half. Lovely."
  }}
  approveLabel="Approve"
  approvedLabel="Approved"
  framed={true}
  stepMs={1000}
/>

More Code pieces

View all Code

Make sync retries configurable

src/sync/retry.ts

In reviewApproved
export function retry(task: Task) {
const max = 3;
const max = config.retries ?? 3;
return run(task, max);
Smiling man in a floral shirt

Leonard Cohen

Nice and small. Maybe call it retryLimit so it reads well in the config? Happy to ship either way.

pricing.ts
export function total(cart: Cart) {
const sum = cart.lines.reduce(add, 0)
return sum
const discount = coupon(cart, sum)
return sum - discount
}
function greet(name) {
return 'Hi ' + name;
return `Hello, ${name}!`;
}
const greeting = "Hello, Beste!";ts
greet.ts
export function greet(name: string) {
return `Hello, ${name}!`;
}
 
console.log(greet("Beste"));
const user = await fetchUser("42");