Skip to content

Commit

Permalink
preview fix 0.2.0-alpha.4
Browse files Browse the repository at this point in the history
  • Loading branch information
chakAs3 committed Nov 19, 2023
1 parent 3dba96d commit efeda21
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions packages/storybook-nuxt-cli/src/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { spawn } from 'node:child_process'

import path from 'node:path'
import { existsSync } from 'node:fs'

// Unicode icons for better display
const CHECKMARK = '\u2714' // ✔
const CROSSMARK = '\u274C' // ❌
const STARTMARK = '\u25B6' // ▶

const logger = console

async function buildStorybook() {
logger.log(`${STARTMARK} Building Storybook ...`)
logger.log()
// Path to the project root
const projectRoot = process.cwd()

logger.info('🔌 projectRoot :', projectRoot)

const buildNuxtProcess = spawn('npx', ['storybook', 'build', '--output-dir', '.output/pub'], {
cwd: projectRoot,
stdio: 'inherit',
})
buildNuxtProcess.on('close', async (code) => {
if (code !== 0)
logger.error(`${CROSSMARK} nuxt build failed with code ${code}`)

else
logger.log(`${CHECKMARK} nuxt build successfully!`)
})

// Install required packages using pnpm
}

// Function to detect the package manager
export function detectPackageManager() {
if (existsSync(path.join(process.cwd(), 'package-lock.json')))
return 'npm'

else if (existsSync(path.join(process.cwd(), 'yarn.lock')))
return 'yarn'

else if (existsSync(path.join(process.cwd(), 'pnpm-lock.yaml')))
return 'pnpm'

else if (existsSync(path.join(process.cwd(), 'bun.lock')))
return 'bun'

return undefined
}

export { buildStorybook }

0 comments on commit efeda21

Please sign in to comment.