Skip to content

Commit

Permalink
initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
manneredboor committed Aug 7, 2018
0 parents commit b5f0bd6
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
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
38 changes: 38 additions & 0 deletions README.md
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
66 changes: 66 additions & 0 deletions index.js
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()
66 changes: 66 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions package.json
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"
}
}

0 comments on commit b5f0bd6

Please sign in to comment.