mirror of
https://github.com/kunkunsh/kunkun.git
synced 2025-04-11 17:29:44 +00:00

* chore: add extension templates * feat: add create-kunkun and cli package * fix: cli and create-kunkun package location * fix: cli package test * ci: run test for CI pipeline only on Linux The most important E2E test is run with docker, Linux anyways, no need to run on Mac and Windows
40 lines
1.9 KiB
TypeScript
40 lines
1.9 KiB
TypeScript
import path from "path"
|
|
import fs from "fs-extra"
|
|
import { getRootDir } from "../src/constants"
|
|
import { cleanExtension, patchManifestJsonSchema, patchPkgJsonDep } from "../src/patch"
|
|
|
|
const distPath = path.join(getRootDir(), "dist")
|
|
const distTemplatesPath = path.join(distPath, "templates")
|
|
// clear distTemplatesPath
|
|
fs.emptyDirSync(distTemplatesPath)
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
/* copy ../../templates to dist/templates */
|
|
/* -------------------------------------------------------------------------- */
|
|
const templatesPath = path.join(getRootDir(), "../..", "templates")
|
|
await fs.copy(templatesPath, distTemplatesPath)
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
/* Clean Dist Folder */
|
|
/* -------------------------------------------------------------------------- */
|
|
for (const p of fs.readdirSync(distTemplatesPath)) {
|
|
cleanExtension(path.join(distPath, "templates", p))
|
|
}
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
/* Patch Templates */
|
|
/* -------------------------------------------------------------------------- */
|
|
for (const p of fs.readdirSync(distTemplatesPath)) {
|
|
const pkgJsonPath = path.join(distPath, "templates", p, "package.json")
|
|
if (fs.existsSync(pkgJsonPath)) {
|
|
/* ----------------------- Patch Package Dependencies ----------------------- */
|
|
// Replace local dependencies (workspace:*) with real dependencies
|
|
await patchPkgJsonDep(pkgJsonPath)
|
|
/* ----------------------- Patch Manifest JSON Schema ----------------------- */
|
|
// Replace local template with remote schema
|
|
patchManifestJsonSchema(pkgJsonPath)
|
|
// remove node_modules
|
|
fs.rmdirSync(path.join(distPath, "templates", p, "node_modules"), { recursive: true })
|
|
}
|
|
}
|