diff --git a/packages/app-store-cli/src/constants.ts b/packages/app-store-cli/src/constants.ts index 500c973154..f23c8ff97f 100644 --- a/packages/app-store-cli/src/constants.ts +++ b/packages/app-store-cli/src/constants.ts @@ -1,4 +1,6 @@ import path from "path"; +import os from "os"; export const APP_STORE_PATH = path.join(__dirname, "..", "..", "app-store"); export const TEMPLATES_PATH = path.join(APP_STORE_PATH, "templates"); +export const IS_WINDOWS_PLATFORM = os.platform() === "win32"; \ No newline at end of file diff --git a/packages/app-store-cli/src/core.ts b/packages/app-store-cli/src/core.ts index cec46792da..e80d88630b 100644 --- a/packages/app-store-cli/src/core.ts +++ b/packages/app-store-cli/src/core.ts @@ -1,7 +1,7 @@ import fs from "fs"; import path from "path"; -import { APP_STORE_PATH, TEMPLATES_PATH } from "./constants"; +import { APP_STORE_PATH, TEMPLATES_PATH, IS_WINDOWS_PLATFORM} from "./constants"; import execSync from "./utils/execSync"; const slugify = (str: string) => { @@ -69,8 +69,8 @@ export const BaseAppFork = { }) { const appDirPath = getAppDirPath(slug, isTemplate); if (!editMode) { - await execSync(`mkdir -p ${appDirPath}`); - await execSync(`cp -r ${TEMPLATES_PATH}/${template}/* ${appDirPath}`); + await execSync(IS_WINDOWS_PLATFORM ? `mkdir ${appDirPath}` : `mkdir -p ${appDirPath}`); + await execSync(IS_WINDOWS_PLATFORM ? `xcopy "${TEMPLATES_PATH}\\${template}\\*" "${appDirPath}" /e /i` : `cp -r ${TEMPLATES_PATH}/${template}/* ${appDirPath}`); } else { if (!oldSlug) { throw new Error("oldSlug is required when editMode is true"); @@ -79,7 +79,7 @@ export const BaseAppFork = { // We need to rename only if they are different const oldAppDirPath = getAppDirPath(oldSlug, isTemplate); - await execSync(`mv ${oldAppDirPath} ${appDirPath}`); + await execSync(IS_WINDOWS_PLATFORM ? `move ${oldAppDirPath} ${appDirPath}` : `mv ${oldAppDirPath} ${appDirPath}`); } } updatePackageJson({ slug, appDirPath, appDescription: description }); @@ -126,7 +126,7 @@ export const BaseAppFork = { delete: async function ({ slug, isTemplate }: { slug: string; isTemplate: boolean }) { const appDirPath = getAppDirPath(slug, isTemplate); - await execSync(`rm -rf ${appDirPath}`); + await execSync(IS_WINDOWS_PLATFORM ? `rd /s /q ${appDirPath}` : `rm -rf ${appDirPath}`); }, };