mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-24 13:15:45 +00:00
fix
This commit is contained in:
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -19,13 +19,13 @@ jobs:
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 20
|
||||
node-version: 22
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
name: Install pnpm
|
||||
id: pnpm-install
|
||||
with:
|
||||
version: 9.0.6
|
||||
version: 10.4.1
|
||||
run_install: false
|
||||
|
||||
- name: Get pnpm store directory
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import os from "os"
|
||||
import path from "path"
|
||||
import { execa } from "execa"
|
||||
import fs from "fs-extra"
|
||||
import { afterAll, beforeAll, describe, expect, it } from "vitest"
|
||||
|
||||
@@ -656,6 +657,64 @@ describe("shadcn init - next-monorepo", () => {
|
||||
}, 300000)
|
||||
})
|
||||
|
||||
describe("shadcn init - postInit git commit", () => {
|
||||
// Use os.tmpdir() to create projects outside the monorepo tree.
|
||||
let testBaseDir: string
|
||||
|
||||
beforeAll(async () => {
|
||||
testBaseDir = path.join(os.tmpdir(), `shadcn-postinit-test-${process.pid}`)
|
||||
await fs.ensureDir(testBaseDir)
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
await fs.remove(testBaseDir)
|
||||
})
|
||||
|
||||
it("should create a git repo with initial commit for next template", async () => {
|
||||
const projectName = "postinit-next-app"
|
||||
const emptyDir = path.join(testBaseDir, "empty-next")
|
||||
await fs.ensureDir(emptyDir)
|
||||
|
||||
await npxShadcn(emptyDir, ["init", "--defaults", "--name", projectName], {
|
||||
timeout: 120000,
|
||||
})
|
||||
|
||||
const projectPath = path.join(emptyDir, projectName)
|
||||
|
||||
// Verify .git directory was created.
|
||||
expect(await fs.pathExists(path.join(projectPath, ".git"))).toBe(true)
|
||||
|
||||
// Verify initial commit exists.
|
||||
const { stdout } = await execa("git", ["log", "--oneline", "-1"], {
|
||||
cwd: projectPath,
|
||||
})
|
||||
expect(stdout).toContain("initial commit")
|
||||
})
|
||||
|
||||
it("should create a git repo with initial commit for vite template", async () => {
|
||||
const projectName = "postinit-vite-app"
|
||||
const emptyDir = path.join(testBaseDir, "empty-vite")
|
||||
await fs.ensureDir(emptyDir)
|
||||
|
||||
await npxShadcn(
|
||||
emptyDir,
|
||||
["init", "--defaults", "--name", projectName, "-t", "vite"],
|
||||
{ timeout: 120000 }
|
||||
)
|
||||
|
||||
const projectPath = path.join(emptyDir, projectName)
|
||||
|
||||
// Verify .git directory was created.
|
||||
expect(await fs.pathExists(path.join(projectPath, ".git"))).toBe(true)
|
||||
|
||||
// Verify initial commit exists.
|
||||
const { stdout } = await execa("git", ["log", "--oneline", "-1"], {
|
||||
cwd: projectPath,
|
||||
})
|
||||
expect(stdout).toContain("initial commit")
|
||||
})
|
||||
})
|
||||
|
||||
describe("shadcn init - deprecated --src-dir", () => {
|
||||
it("should reject --src-dir as unknown option", async () => {
|
||||
const fixturePath = await createFixtureTestDirectory("next-app")
|
||||
|
||||
Reference in New Issue
Block a user