Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/sui-studio/bin/sui-studio-generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ program
.option('-S, --scope <scope>', 'add scope for this component')
.option('-W, --swc', 'Use the new SWC compiler', false)
.option('-J, --jest', 'Generate jest tests', false)
.option('-D, --component-dir', 'Path where the component will be generated')
.on('--help', () => {
console.log(' Examples:')
console.log('')
Expand All @@ -33,7 +34,7 @@ program

const BASE_DIR = process.cwd()
const [category, component] = program.args
const {context, scope, prefix = 'sui', swc, jest} = program.opts()
const {context, componentDir, scope, prefix = 'sui', swc, jest} = program.opts()

if (!component) showError('component must be defined')
if (!category) showError('category must be defined')
Expand All @@ -49,7 +50,7 @@ if (!wordsOnlyRegex.test(category)) {

const componentInPascal = toPascalCase(`${category.replace(/s$/, '')} ${component}`)

const COMPONENT_DIR = `/components/${category}/${component}/`
const COMPONENT_DIR = `${componentDir}/${category}/${component}/`
const COMPONENT_PATH = `${BASE_DIR}${COMPONENT_DIR}`
const COMPONENT_ENTRY_JS_POINT_FILE = `${COMPONENT_PATH}src/index.js`
const COMPONENT_PACKAGE_JSON_FILE = `${COMPONENT_PATH}package.json`
Expand Down Expand Up @@ -300,7 +301,7 @@ return (<${componentInPascal} />)

writeFile(
COMPONENT_PLAYGROUND_FILE,
`import ${componentInPascal} from 'components/${category}/${component}/src'
`import ${componentInPascal} from 'packages/components/${category}/${component}/src'
export default () => <${componentInPascal} />
`
),
Expand Down