Closed kentcdodds closed 1 year ago
To be clear, this is with v0.0.12
Thanks! It's fixed and released in v0.0.13
.
Here is the output, that i tested with the given diff!.
{
"type": "GitDiff",
"files": [
{
"type": "ChangedFile",
"chunks": [
{
"type": "BinaryFilesChunk",
"pathBefore": "var/folders/kt/zd3bfncd0c3gjx25hbcq483c0000gn/T/kcdshop/diff/example/exercises__sep__01.nested-routing__sep__01.problem.outlet/xn2ci7n8yna/app/assets/img.png",
"pathAfter": "var/folders/kt/zd3bfncd0c3gjx25hbcq483c0000gn/T/kcdshop/diff/example/exercises__sep__01.nested-routing__sep__01.solution.outlet/xn2ci7n8yna/app/assets/img.png"
}
],
"path": "var/folders/kt/zd3bfncd0c3gjx25hbcq483c0000gn/T/kcdshop/diff/example/exercises__sep__01.nested-routing__sep__01.solution.outlet/xn2ci7n8yna/app/assets/img.png"
},
{
"type": "AddedFile",
"chunks": [
{
"type": "BinaryFilesChunk",
"pathBefore": "/dev/null",
"pathAfter": "var/folders/kt/zd3bfncd0c3gjx25hbcq483c0000gn/T/kcdshop/diff/example/exercises__sep__01.nested-routing__sep__01.solution.outlet/xn2ci7n8yna/app/assets/img2.png"
}
],
"path": "var/folders/kt/zd3bfncd0c3gjx25hbcq483c0000gn/T/kcdshop/diff/example/exercises__sep__01.nested-routing__sep__01.solution.outlet/xn2ci7n8yna/app/assets/img2.png"
},
{
"type": "ChangedFile",
"chunks": [
{
"context": "import {",
"type": "Chunk",
"toFileRange": {
"start": 7,
"lines": 10
},
"fromFileRange": {
"start": 7,
"lines": 9
},
"changes": [
{
"type": "UnchangedLine",
"lineBefore": 7,
"lineAfter": 7,
"content": "\tScripts,"
},
{
"type": "UnchangedLine",
"lineBefore": 8,
"lineAfter": 8,
"content": "\tScrollRestoration,"
},
{
"type": "UnchangedLine",
"lineBefore": 9,
"lineAfter": 9,
"content": "} from '@remix-run/react'"
},
{
"type": "DeletedLine",
"lineBefore": 10,
"content": "import tailwindStylesheetUrl from './styles/tailwind.css'"
},
{
"type": "UnchangedLine",
"lineBefore": 11,
"lineAfter": 10,
"content": "import { KCDShop } from './kcdshop.tsx'"
},
{
"type": "UnchangedLine",
"lineBefore": 12,
"lineAfter": 11,
"content": ""
},
{
"type": "AddedLine",
"lineAfter": 12,
"content": "import tailwindStylesheetUrl from './styles/tailwind.css'"
},
{
"type": "AddedLine",
"lineAfter": 13,
"content": ""
},
{
"type": "UnchangedLine",
"lineBefore": 13,
"lineAfter": 14,
"content": "export const links: LinksFunction = () => {"
},
{
"type": "UnchangedLine",
"lineBefore": 14,
"lineAfter": 15,
"content": "\treturn [{ rel: 'stylesheet', href: tailwindStylesheetUrl }]"
},
{
"type": "UnchangedLine",
"lineBefore": 15,
"lineAfter": 16,
"content": "}"
}
]
}
],
"path": "var/folders/kt/zd3bfncd0c3gjx25hbcq483c0000gn/T/kcdshop/diff/example/exercises__sep__01.nested-routing__sep__01.solution.outlet/xn2ci7n8yna/app/root.tsx"
},
{
"type": "DeletedFile",
"chunks": [
{
"type": "Chunk",
"toFileRange": {
"start": 0,
"lines": 0
},
"fromFileRange": {
"start": 1,
"lines": 5
},
"changes": [
{
"type": "DeletedLine",
"lineBefore": 1,
"content": "import { json } from '@remix-run/node'"
},
{
"type": "DeletedLine",
"lineBefore": 2,
"content": ""
},
{
"type": "DeletedLine",
"lineBefore": 3,
"content": "export async function loader() {"
},
{
"type": "DeletedLine",
"lineBefore": 4,
"content": "\treturn json({ iAm: 'deleted' })"
},
{
"type": "DeletedLine",
"lineBefore": 5,
"content": "}"
}
]
}
],
"path": "var/folders/kt/zd3bfncd0c3gjx25hbcq483c0000gn/T/kcdshop/diff/example/exercises__sep__01.nested-routing__sep__01.problem.outlet/xn2ci7n8yna/app/routes/deleted.tsx"
},
{
"type": "ChangedFile",
"chunks": [
{
"type": "Chunk",
"toFileRange": {
"start": 1,
"lines": 7
},
"fromFileRange": {
"start": 1,
"lines": 12
},
"changes": [
{
"type": "DeletedLine",
"lineBefore": 1,
"content": "import { Link } from '@remix-run/react'"
},
{
"type": "DeletedLine",
"lineBefore": 2,
"content": ""
},
{
"type": "UnchangedLine",
"lineBefore": 3,
"lineAfter": 1,
"content": "export default function Index() {"
},
{
"type": "UnchangedLine",
"lineBefore": 4,
"lineAfter": 2,
"content": "\treturn ("
},
{
"type": "DeletedLine",
"lineBefore": 5,
"content": "\t\t<main className=\"relative min-h-screen bg-white\">"
},
{
"type": "AddedLine",
"lineAfter": 3,
"content": "\t\t<main className=\"relative min-h-screen bg-white sm:flex sm:items-center sm:justify-center\">"
},
{
"type": "UnchangedLine",
"lineBefore": 6,
"lineAfter": 4,
"content": "\t\t\t<h1>Welcome to the app</h1>"
},
{
"type": "DeletedLine",
"lineBefore": 7,
"content": "\t\t\t<Link to=\"/whatever\" className=\"text-blue-800 underline\">"
},
{
"type": "DeletedLine",
"lineBefore": 8,
"content": "\t\t\t\tGo to \"/whatever\""
},
{
"type": "DeletedLine",
"lineBefore": 9,
"content": "\t\t\t</Link>"
},
{
"type": "UnchangedLine",
"lineBefore": 10,
"lineAfter": 5,
"content": "\t\t</main>"
},
{
"type": "UnchangedLine",
"lineBefore": 11,
"lineAfter": 6,
"content": "\t)"
},
{
"type": "UnchangedLine",
"lineBefore": 12,
"lineAfter": 7,
"content": "}"
}
]
}
],
"path": "var/folders/kt/zd3bfncd0c3gjx25hbcq483c0000gn/T/kcdshop/diff/example/exercises__sep__01.nested-routing__sep__01.solution.outlet/xn2ci7n8yna/app/routes/index.tsx"
},
{
"type": "AddedFile",
"chunks": [
{
"type": "Chunk",
"toFileRange": {
"start": 1,
"lines": 3
},
"fromFileRange": {
"start": 0,
"lines": 0
},
"changes": [
{
"type": "AddedLine",
"lineAfter": 1,
"content": "export default function Parent() {"
},
{
"type": "AddedLine",
"lineAfter": 2,
"content": "\treturn <p>I am a parent</p>"
},
{
"type": "AddedLine",
"lineAfter": 3,
"content": "}"
}
]
}
],
"path": "var/folders/kt/zd3bfncd0c3gjx25hbcq483c0000gn/T/kcdshop/diff/example/exercises__sep__01.nested-routing__sep__01.solution.outlet/xn2ci7n8yna/app/routes/parent.tsx"
},
{
"type": "ChangedFile",
"chunks": [
{
"type": "Chunk",
"toFileRange": {
"start": 1,
"lines": 14
},
"fromFileRange": {
"start": 1,
"lines": 19
},
"changes": [
{
"type": "UnchangedLine",
"lineBefore": 1,
"lineAfter": 1,
"content": "{"
},
{
"type": "DeletedLine",
"lineBefore": 2,
"content": " \"name\": \"exercises.01.nested-routing.01.problem.outlet\","
},
{
"type": "AddedLine",
"lineAfter": 2,
"content": " \"name\": \"exercises.01.nested-routing.01.solution.outlet\","
},
{
"type": "UnchangedLine",
"lineBefore": 3,
"lineAfter": 3,
"content": " \"private\": true,"
},
{
"type": "UnchangedLine",
"lineBefore": 4,
"lineAfter": 4,
"content": " \"sideEffects\": false,"
},
{
"type": "DeletedLine",
"lineBefore": 5,
"content": " \"kcd-workshop\": {"
},
{
"type": "DeletedLine",
"lineBefore": 6,
"content": " \"testRequiresApp\": true,"
},
{
"type": "DeletedLine",
"lineBefore": 7,
"content": " \"scripts\": {"
},
{
"type": "DeletedLine",
"lineBefore": 8,
"content": " \"test\": \"echo \\\"\\\\x1b[36mhello\\\\x1b[37mworld\\\" && sleep 0.7 && echo hi && sleep 0.7 && echo hi && sleep 0.7 && echo hi && sleep 0.7 && echo hi && sleep 0.7 && echo hi && sleep 0.7 && echo hi && sleep 0.7 && echo hi && sleep 0.7 && echo hi && sleep 0.7 && echo hi && sleep 0.7 && echo hi && sleep 0.7 && echo hi && sleep 0.7 && echo hi && sleep 0.7 && echo hi && sleep 0.7 && echo hi && sleep 0.7 && echo hi && sleep 0.7 && echo hi && sleep 0.7 && echo hi && sleep 0.7 && echo hi\""
},
{
"type": "DeletedLine",
"lineBefore": 9,
"content": " }"
},
{
"type": "DeletedLine",
"lineBefore": 10,
"content": " },"
},
{
"type": "UnchangedLine",
"lineBefore": 11,
"lineAfter": 5,
"content": " \"type\": \"module\","
},
{
"type": "UnchangedLine",
"lineBefore": 12,
"lineAfter": 6,
"content": " \"scripts\": {"
},
{
"type": "UnchangedLine",
"lineBefore": 13,
"lineAfter": 7,
"content": " \"build\": \"run-s build:*\","
},
{
"type": "UnchangedLine",
"lineBefore": 14,
"lineAfter": 8,
"content": " \"build:remix\": \"remix build\","
},
{
"type": "UnchangedLine",
"lineBefore": 15,
"lineAfter": 9,
"content": " \"build:server\": \"tsx ./other/build-server.ts\","
},
{
"type": "UnchangedLine",
"lineBefore": 16,
"lineAfter": 10,
"content": " \"dev\": \"remix dev -c \\\"tsx ./index.js\\\" --manual\","
},
{
"type": "AddedLine",
"lineAfter": 11,
"content": " \"test\": \"echo TODO\","
},
{
"type": "UnchangedLine",
"lineBefore": 17,
"lineAfter": 12,
"content": " \"format\": \"prettier --write .\","
},
{
"type": "UnchangedLine",
"lineBefore": 18,
"lineAfter": 13,
"content": " \"lint\": \"eslint --cache --cache-location ./node_modules/.cache/eslint .\","
},
{
"type": "UnchangedLine",
"lineBefore": 19,
"lineAfter": 14,
"content": " \"start\": \"cross-env NODE_ENV=production node .\","
}
]
}
],
"path": "var/folders/kt/zd3bfncd0c3gjx25hbcq483c0000gn/T/kcdshop/diff/example/exercises__sep__01.nested-routing__sep__01.solution.outlet/xn2ci7n8yna/package.json"
}
]
}
That works great! Thank you šš
Here's the diff:
And here's the result of calling
parseGitDiff(diffOutput, { noPrefix: true })
: