-
-
Save ericvicenti/4a10c1349ba4ab0e4f6e6e2f95cfcfd8 to your computer and use it in GitHub Desktop.
React FS Renderer Example
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
Show hidden characters
{ | |
"presets": ["react", "latest"] | |
} |
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
import React from 'react'; | |
import { | |
renderToFS, | |
} from 'react-fs-renderer'; | |
const JSONFile = ({ name, json }) => ( | |
<file | |
name={`${name}.json`} | |
children={JSON.stringify(json)} | |
/> | |
); | |
const MyProjectTemplate = ({ name, displayName }) => ( | |
<folder> | |
<JSONFile name="app" json={{ name, displayName }} /> | |
<JSONFile name="package" json={{ | |
name, | |
version: '0.0.0', | |
main: 'src/${}.js', | |
dependencies: {react: '^15.4.2'} | |
}} /> | |
<folder name="src"> | |
<file name={`${name}.js`} children={"mainFileContent"} /> | |
</folder> | |
</folder> | |
); | |
renderToFS( | |
<MyProjectTemplate | |
displayName="My Great App" | |
name="GreatApp" | |
/>, | |
'./testDir' | |
); |
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
{ | |
"name": "MyProjectTemplateGenerator", | |
"version": "0.0.0", | |
"main": "lib/MyProjectTemplateGenerator.js", | |
"scripts": { | |
"go": "node lib/MyProjectTemplateGenerator", | |
"build": "babel MyProjectTemplateGenerator.js --out-dir lib" | |
}, | |
"dependencies": { | |
"react": "^15.4.2", | |
"react-fs-renderer": "^1.0.0" | |
}, | |
"devDependencies": { | |
"babel": "^6.5.2", | |
"babel-plugin-transform-runtime": "^6.22.0", | |
"babel-preset-latest": "^6.22.0", | |
"babel-preset-react": "^6.22.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment