mirror of
https://github.com/kunkunsh/kunkun.git
synced 2025-04-13 02:04:34 +00:00

* refactor: replace comlink with kkrpc * fix: import path in api pkg and btn styling in ui iframe page * fix: fixed fetch API from kkRPC migrate * refactor: replace comlink-stdio with kkrpc * update deno lock * bump @kksh/api * update API version * publish api pkg again to fix kkrpc version * update pnpm lock * dep: fix dependency problems * dep: update deno.lock * chore: remove 2 submodules they were added only for integration development * update pnpm lock * fix: test template path * format: with prettier * downgrade next version * ci: try to fix next build on windows * try to fix CI * Revert "try to fix CI" This reverts commit b9c63c392f50f1d2d3ceec406e49b1af2348c740. * upgrade tauri-api-adapter * try to fix next * remove templates from pnpm workspace * update CI test * publish @kksh/api with upgraded tauri-api-adapter to fix nextjs template
79 lines
2.6 KiB
TypeScript
79 lines
2.6 KiB
TypeScript
import os from "os"
|
|
import path from "path"
|
|
import { getRootDir } from "@/constants"
|
|
import type { BuildResult } from "@/types"
|
|
import { buildWithDockerAndValidate } from "@/utils"
|
|
import { $ } from "bun"
|
|
import { afterAll, expect, test } from "bun:test"
|
|
import fs from "fs-extra"
|
|
import { verifyCmd } from "../src/commands/verify"
|
|
|
|
const rootDir = getRootDir()
|
|
const createKKDir = path.join(rootDir, "../create-kunkun")
|
|
|
|
const createKKDistDir = path.join(createKKDir, "dist")
|
|
const createKKIndexjsPath = path.join(createKKDistDir, "index.mjs")
|
|
const testDir = path.join(os.tmpdir(), "kunkun-cli-test")
|
|
console.log("Test Dir: ", testDir)
|
|
const templateNames = ["react", "vue", "nuxt", "svelte", "sveltekit", "next", "template"]
|
|
|
|
fs.rmdirSync(testDir, { recursive: true })
|
|
fs.mkdirpSync(testDir)
|
|
const testTemplateDirs: string[] = []
|
|
for (const templateName of templateNames) {
|
|
const folderName = `${templateName}-ext`
|
|
await $`node ${createKKIndexjsPath} --outdir ${testDir} --name ${folderName} --template ${templateName}`
|
|
const templateDir = path.join(testDir, folderName)
|
|
console.log("templateDir", templateDir)
|
|
await $`pnpm install`.cwd(templateDir).quiet()
|
|
await $`pnpm build`.cwd(templateDir).quiet()
|
|
testTemplateDirs.push(templateDir)
|
|
}
|
|
|
|
test("Build And Verify", async () => {
|
|
for (const templateDir of testTemplateDirs) {
|
|
expect(verifyCmd(templateDir, false)).toBeTrue()
|
|
}
|
|
})
|
|
|
|
const testDirDocker = path.join(os.tmpdir(), "kunkun-cli-test-docker")
|
|
fs.rmdirSync(testDirDocker, { recursive: true })
|
|
fs.mkdirpSync(testDirDocker)
|
|
|
|
const templateData: Record<string, { dir: string; buildResult: BuildResult }> = {}
|
|
|
|
await Promise.all(
|
|
templateNames.map(async (templateName) => {
|
|
const folderName = `${templateName}-ext`
|
|
await $`node ${createKKIndexjsPath} --outdir ${testDirDocker} --name ${folderName} --template ${templateName}`
|
|
const templateDir = path.join(testDirDocker, folderName)
|
|
console.log("templateDir:", templateDir)
|
|
|
|
const buildResult = await buildWithDockerAndValidate(templateDir)
|
|
templateData[templateName] = {
|
|
dir: templateDir,
|
|
buildResult
|
|
}
|
|
})
|
|
)
|
|
console.log(templateData)
|
|
|
|
test("Template Exist", () => {
|
|
Object.entries(templateData).forEach(async ([templateName, { dir }]) => {
|
|
console.log("Expect dir exist: ", dir)
|
|
expect(fs.existsSync(dir)).toBeTrue()
|
|
})
|
|
})
|
|
|
|
test("Build Result Tarball Exist", () => {
|
|
Object.entries(templateData).forEach(async ([templateName, { buildResult, dir }]) => {
|
|
const expectedTarballPath = path.join(dir, buildResult.tarballFilename)
|
|
expect(fs.existsSync(expectedTarballPath)).toBeTrue()
|
|
})
|
|
})
|
|
|
|
afterAll(() => {
|
|
fs.rmdirSync(testDir, { recursive: true })
|
|
fs.rmdirSync(testDirDocker, { recursive: true })
|
|
})
|