-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b5f0bd6
Showing
5 changed files
with
206 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.awcache/ | ||
.DS_Store | ||
.vscode | ||
node_modules/ | ||
dev_log.log | ||
webpack_stats.json | ||
npm-debug.log |
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,38 @@ | ||
<p align="center"><img src="https://github.com/gnarlycode/gnarly-assets/blob/master/gnarly-logo-600.png?raw=true" /></p> | ||
|
||
###### _GNARLY CODE_ Presents | ||
|
||
# Create Gnarly App | ||
|
||
Create React app targeted to opinionated stack. | ||
Powered by [@gnarlycode/react-app-tools](https://github.com/gnarlycode/react-app-tools) | ||
|
||
## How to create app | ||
|
||
```sh | ||
npm init @gnarlycode/gnarly-app app-name | ||
``` | ||
|
||
## How to use app | ||
|
||
> `npm run prettier` — run prettier | ||
> `npm run dev` — development server | ||
> `npm run build` — build the app | ||
> `npm run build-static` — build static html's | ||
> `npm run build-all` — build the app and then static html's | ||
> `npm start` — serve builded app | ||
> `npm run tsint` — check linter rules | ||
## Target stack: | ||
|
||
- [TypeScript](https://www.typescriptlang.org) | ||
- [React](https://reactjs.org/) | ||
- [Styled Components](https://www.styled-components.com/) | ||
|
||
###### Author: Dmitry Podlesny |
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,66 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs') | ||
const path = require('path') | ||
const spawn = require('cross-spawn') | ||
const commander = require('commander') | ||
const packageJson = require('./package.json') | ||
|
||
const endWithError = err => { | ||
console.error('\n' + err) | ||
process.exit(1) | ||
} | ||
|
||
const createApp = () => { | ||
let appDir | ||
|
||
const program = new commander.Command(packageJson.name) | ||
.version(packageJson.version) | ||
.arguments('<project-directory>') | ||
.usage(`<project-directory>`) | ||
.action(name => (appDir = name)) | ||
.parse(process.argv) | ||
|
||
if (!appDir) endWithError('Specify app directory') | ||
|
||
appDir = path.resolve(appDir) | ||
|
||
if (fs.existsSync(appDir)) endWithError('Directory already exists') | ||
|
||
console.log(`\nCreating a new Gnarly app in ${appDir}.\n`) | ||
fs.mkdirSync(appDir) | ||
|
||
const appName = path.basename(appDir) | ||
const appPackageJson = { | ||
name: appName, | ||
version: '0.1.0', | ||
private: true, | ||
} | ||
|
||
fs.writeFileSync( | ||
path.join(appDir, 'package.json'), | ||
JSON.stringify(appPackageJson, null, 2) + '\n', | ||
) | ||
|
||
process.chdir(appDir) | ||
|
||
const depName = '@gnarlycode/react-app-tools' | ||
|
||
const args = ['install', '--save', depName] | ||
|
||
const proc = spawn.sync('npm', args, { stdio: 'inherit' }) | ||
|
||
if (proc.status !== 0) endWithError(`Error while installing ${depName}`) | ||
|
||
const initPath = path.resolve( | ||
process.cwd(), | ||
'node_modules', | ||
depName, | ||
'bin', | ||
'init.js', | ||
) | ||
|
||
require(initPath) | ||
} | ||
|
||
createApp() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,29 @@ | ||
{ | ||
"name": "@gnarlycode/create-gnarly-app", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"bin": { | ||
"create-gnarly-app": "./index.js" | ||
}, | ||
"author": { | ||
"name": "Dmitry Podlesny", | ||
"email": "[email protected]" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/gnarlycode/create-gnarly-app.git" | ||
}, | ||
"homepage": "https://github.com/gnarlycode/create-gnarly-app#readme", | ||
"bugs": { | ||
"url": "https://github.com/gnarlycode/create-gnarly-app/issues" | ||
}, | ||
"license": "ISC", | ||
"dependencies": { | ||
"commander": "^2.17.0", | ||
"cross-spawn": "^6.0.5" | ||
} | ||
} |