Skip to content

Commit a1bed46

Browse files
JensAstrupshadcn
andauthored
chore(apps): Update lodash (#4397)
* chore(apps): Refactor usage of lodash.template to lodash to address security vulnerability * chore(cli): Refactor usage of lodash.template to lodash to address security vulnerability * deps: update lock * chore: changesets * style: fix format * fix: import * chore: build registry --------- Co-authored-by: shadcn <[email protected]>
1 parent 805ed41 commit a1bed46

File tree

11 files changed

+52
-46
lines changed

11 files changed

+52
-46
lines changed

.changeset/twenty-trains-check.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"shadcn-ui": patch
3+
---
4+
5+
replace lodash.template

apps/www/__registry__/new-york/block/chart-area-interactive.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,16 @@ export default function Component() {
141141

142142
const filteredData = chartData.filter((item) => {
143143
const date = new Date(item.date)
144-
const now = new Date()
144+
const referenceDate = new Date("2024-06-30")
145145
let daysToSubtract = 90
146146
if (timeRange === "30d") {
147147
daysToSubtract = 30
148148
} else if (timeRange === "7d") {
149149
daysToSubtract = 7
150150
}
151-
now.setDate(now.getDate() - daysToSubtract)
152-
return date >= now
151+
const startDate = new Date(referenceDate)
152+
startDate.setDate(startDate.getDate() - daysToSubtract)
153+
return date >= startDate
153154
})
154155

155156
return (

apps/www/components/theme-customizer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client"
22

33
import * as React from "react"
4-
import template from "lodash.template"
4+
import template from "lodash/template"
55
import { Check, Copy, Moon, Repeat, Sun } from "lucide-react"
66
import { useTheme } from "next-themes"
77

apps/www/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"geist": "^1.2.2",
6868
"input-otp": "^1.2.2",
6969
"jotai": "^2.1.0",
70-
"lodash.template": "^4.5.0",
70+
"lodash": "^4.17.21",
7171
"lucide-react": "0.359.0",
7272
"markdown-wasm": "^1.2.0",
7373
"next": "14.3.0-canary.43",
@@ -90,7 +90,7 @@
9090
},
9191
"devDependencies": {
9292
"@shikijs/compat": "^1.1.7",
93-
"@types/lodash.template": "^4.5.1",
93+
"@types/lodash": "^4.17.7",
9494
"@types/node": "^17.0.45",
9595
"@types/react": "^18.2.65",
9696
"@types/react-color": "^3.0.6",

apps/www/public/r/styles/default/input.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"files": [
55
{
66
"path": "ui/input.tsx",
7-
"content": "import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst Input = React.forwardRef<\n HTMLInputElement,\n React.ComponentProps<\"input\">\n>(({ className, type, ...props }, ref) => {\n return (\n <input\n type={type}\n className={cn(\n \"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\n className\n )}\n ref={ref}\n {...props}\n />\n )\n})\nInput.displayName = \"Input\"\n\nexport { Input }\n",
7+
"content": "import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst Input = React.forwardRef<HTMLInputElement, React.ComponentProps<\"input\">>(\n ({ className, type, ...props }, ref) => {\n return (\n <input\n type={type}\n className={cn(\n \"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\n className\n )}\n ref={ref}\n {...props}\n />\n )\n }\n)\nInput.displayName = \"Input\"\n\nexport { Input }\n",
88
"type": "registry:ui",
99
"target": ""
1010
}

apps/www/public/r/styles/new-york/chart-area-interactive.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

apps/www/public/r/styles/new-york/input.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"files": [
55
{
66
"path": "ui/input.tsx",
7-
"content": "import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst Input = React.forwardRef<\n HTMLInputElement,\n React.ComponentProps<\"input\">\n>(({ className, type, ...props }, ref) => {\n return (\n <input\n type={type}\n className={cn(\n \"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\n className\n )}\n ref={ref}\n {...props}\n />\n )\n})\nInput.displayName = \"Input\"\n\nexport { Input }\n",
7+
"content": "import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst Input = React.forwardRef<HTMLInputElement, React.ComponentProps<\"input\">>(\n ({ className, type, ...props }, ref) => {\n return (\n <input\n type={type}\n className={cn(\n \"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\n className\n )}\n ref={ref}\n {...props}\n />\n )\n }\n)\nInput.displayName = \"Input\"\n\nexport { Input }\n",
88
"type": "registry:ui",
99
"target": ""
1010
}

apps/www/scripts/build-registry.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { existsSync, promises as fs, readFileSync } from "fs"
33
import { tmpdir } from "os"
44
import path from "path"
55
import { cwd } from "process"
6-
import template from "lodash.template"
6+
import template from "lodash/template"
77
import { rimraf } from "rimraf"
88
import { Project, ScriptKind, SyntaxKind } from "ts-morph"
99
import { z } from "zod"

packages/cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"fast-glob": "^3.3.2",
5858
"fs-extra": "^11.1.0",
5959
"https-proxy-agent": "^6.2.0",
60-
"lodash.template": "^4.5.0",
60+
"lodash": "^4.17.21",
6161
"node-fetch": "^3.3.0",
6262
"ora": "^6.1.2",
6363
"prompts": "^2.4.2",
@@ -70,7 +70,7 @@
7070
"@types/babel__core": "^7.20.1",
7171
"@types/diff": "^5.0.3",
7272
"@types/fs-extra": "^11.0.1",
73-
"@types/lodash.template": "^4.5.1",
73+
"@types/lodash": "^4.17.7",
7474
"@types/prompts": "^2.4.2",
7575
"rimraf": "^4.1.3",
7676
"tsup": "^6.6.3",

packages/cli/src/commands/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import * as templates from "@/src/utils/templates"
2424
import chalk from "chalk"
2525
import { Command } from "commander"
2626
import { execa } from "execa"
27-
import template from "lodash.template"
27+
import template from "lodash/template"
2828
import ora from "ora"
2929
import prompts from "prompts"
3030
import { z } from "zod"

0 commit comments

Comments
 (0)