Skip to content

Commit

Permalink
Merge branch 'main' into feat/storybook-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydrichards authored Dec 16, 2024
2 parents 28e52ef + 9253b43 commit bdc4149
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/chart.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/public/r/styles/new-york/chart.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/www/registry/default/ui/chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ChartContainer.displayName = "Chart"

const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
const colorConfig = Object.entries(config).filter(
([_, config]) => config.theme || config.color
([, config]) => config.theme || config.color
)

if (!colorConfig.length) {
Expand Down
2 changes: 1 addition & 1 deletion apps/www/registry/new-york/ui/chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ChartContainer.displayName = "Chart"

const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
const colorConfig = Object.entries(config).filter(
([_, config]) => config.theme || config.color
([, config]) => config.theme || config.color
)

if (!colorConfig.length) {
Expand Down
6 changes: 6 additions & 0 deletions packages/shadcn/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @shadcn/ui

## 2.1.8

### Patch Changes

- [#6093](https://github.com/shadcn-ui/ui/pull/6093) [`c8fda09`](https://github.com/shadcn-ui/ui/commit/c8fda09a63f793e9e2e5a86d8f8faad5af9d1ab4) Thanks [@shadcn](https://github.com/shadcn)! - detect and use next version

## 2.1.7

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/shadcn/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shadcn",
"version": "2.1.7",
"version": "2.1.8",
"description": "Add components to your apps.",
"publishConfig": {
"access": "public"
Expand Down
1 change: 1 addition & 0 deletions packages/shadcn/src/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export const add = new Command()
cwd: options.cwd,
force: options.overwrite,
srcDir: options.srcDir,
components: options.components,
})
if (!projectPath) {
logger.break()
Expand Down
35 changes: 33 additions & 2 deletions packages/shadcn/src/utils/create-project.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,49 @@
import path from "path"
import { initOptionsSchema } from "@/src/commands/init"
import { getPackageManager } from "@/src/utils/get-package-manager"
import { handleError } from "@/src/utils/handle-error"
import { highlighter } from "@/src/utils/highlighter"
import { logger } from "@/src/utils/logger"
import { fetchRegistry } from "@/src/utils/registry"
import { spinner } from "@/src/utils/spinner"
import { execa } from "execa"
import fs from "fs-extra"
import prompts from "prompts"
import { z } from "zod"

export async function createProject(
options: Pick<z.infer<typeof initOptionsSchema>, "cwd" | "force" | "srcDir">
options: Pick<
z.infer<typeof initOptionsSchema>,
"cwd" | "force" | "srcDir" | "components"
>
) {
options = {
srcDir: false,
...options,
}

let nextVersion = "14.2.16"

const isRemoteComponent =
options.components?.length === 1 &&
!!options.components[0].match(/\/chat\/b\//)
if (options.components && isRemoteComponent) {
try {
const [result] = await fetchRegistry(options.components)
const { meta } = z
.object({
meta: z.object({
nextVersion: z.string(),
}),
})
.parse(result)
nextVersion = meta.nextVersion
} catch (error) {
logger.break()
handleError(error)
}
}

if (!options.force) {
const { proceed } = await prompts({
type: "confirm",
Expand Down Expand Up @@ -93,10 +120,14 @@ export async function createProject(
`--use-${packageManager}`,
]

if (nextVersion.startsWith("15")) {
args.push("--turbopack")
}

try {
await execa(
"npx",
["create-next-app@14.2.16", projectPath, "--silent", ...args],
[`create-next-app@${nextVersion}`, projectPath, "--silent", ...args],
{
cwd: options.cwd,
}
Expand Down
2 changes: 1 addition & 1 deletion packages/shadcn/src/utils/registry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export async function getItemTargetPath(
)
}

async function fetchRegistry(paths: string[]) {
export async function fetchRegistry(paths: string[]) {
try {
const results = await Promise.all(
paths.map(async (path) => {
Expand Down

0 comments on commit bdc4149

Please sign in to comment.