-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): Add local developer preview (#81)
- Loading branch information
Showing
56 changed files
with
1,381 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as React from 'react'; | ||
import { render } from 'ink'; | ||
import { StepRunnerStep } from '../containers/StepRunner'; | ||
import { StepContainer } from '../containers/StepContainer'; | ||
import { cleanupStep } from '../steps/cleanup'; | ||
|
||
import program = require('commander'); | ||
|
||
const steps: StepRunnerStep[] = [cleanupStep]; | ||
program | ||
.command('cleanup') | ||
.description('Deletes the bojagi temp folder') | ||
.action(args => { | ||
render(<StepContainer steps={steps} commandArgs={args} />); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as React from 'react'; | ||
import { render } from 'ink'; | ||
import { PreviewContainer } from '../containers/PreviewContainer'; | ||
import { ConfigProvider } from '../context/configContext'; | ||
|
||
import program = require('commander'); | ||
|
||
program | ||
.command('preview') | ||
.option('-d, --dir [dir]', 'The root folder to search components in') | ||
.option( | ||
'--webpack-config [path]', | ||
'Path to the webpack config file, defaults to webpack.config.js' | ||
) | ||
.option('--port [port]', 'Port that the preview server is going to be available in') | ||
.description('starts a local preview server') | ||
.action(({ port }) => { | ||
render( | ||
<ConfigProvider config={{ dryRun: true, previewPort: port }}> | ||
<PreviewContainer /> | ||
</ConfigProvider> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as React from 'react'; | ||
import { render } from 'ink'; | ||
import { StepRunnerStep } from '../containers/StepRunner'; | ||
import { scanStep } from '../steps/scan'; | ||
import { StepContainer } from '../containers/StepContainer'; | ||
import { cleanupStep } from '../steps/cleanup'; | ||
|
||
import program = require('commander'); | ||
|
||
const steps: StepRunnerStep[] = [cleanupStep, scanStep]; | ||
program | ||
.command('scan') | ||
.option('-d, --dir [dir]', 'The root folder to search components in') | ||
.option( | ||
'--webpack-config [path]', | ||
'Path to the webpack config file, defaults to webpack.config.js' | ||
) | ||
.description('Scans for components') | ||
.action(args => { | ||
render(<StepContainer steps={steps} commandArgs={args} />); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/cli/src/containers/PreviewContainer/DevServerMessage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as React from 'react'; | ||
import { Box, Color } from 'ink'; | ||
import Spinner from 'ink-spinner'; | ||
import { Message } from '../../components/Message'; | ||
|
||
export function DevServerMessage({ foundComponents, devServer, established, ready, errors }) { | ||
if (!foundComponents || !devServer) { | ||
return null; | ||
} | ||
if (!established) { | ||
return ( | ||
<Message emoji="hatching_chick"> | ||
Starting Bojagi Preview <Spinner type="dots3" /> | ||
</Message> | ||
); | ||
} | ||
if (!ready) { | ||
return ( | ||
<Message emoji="hatching_chick"> | ||
Bundling <Spinner type="dots3" /> | ||
</Message> | ||
); | ||
} | ||
if (errors.length > 0) { | ||
return ( | ||
<Box marginX={3} marginBottom={1} flexDirection="column"> | ||
<Color red>Following compile errors happened:</Color> | ||
{errors.map(err => ( | ||
<Box key={err.message}>{err.message}</Box> | ||
))} | ||
</Box> | ||
); | ||
} | ||
return <Message emoji="chicken">Bojagi Preview server started</Message>; | ||
} |
Oops, something went wrong.