Skip to content

Commit

Permalink
Merge 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sungyubLee committed Feb 17, 2017
2 parents f7beb9d + b7573a1 commit 0258da6
Show file tree
Hide file tree
Showing 42 changed files with 634 additions and 545 deletions.
13 changes: 0 additions & 13 deletions .eslintrc.js

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
.DS_Store
npm-debug.log
npm-debug.log
.idea
.vscode
101 changes: 57 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

Woowahan.js의 command line utility 입니다.

>> woowahan-cli를 사용하기 위해서는 nodejs, npm 이 설치되어있어야 합니다.
> woowahan-cli를 사용하기 위해서는 nodejs, npm 이 설치되어있어야 합니다.
## 구성요소
- WoowahanJS
- Webpack
- Babel
- bootstrap
- sass

## 설치

Expand Down Expand Up @@ -45,34 +44,39 @@ woowahan-cli new YourAppName
```
mkdir yourFolder
cd yourFolder
woowahan-cli new YourAppName
woowahan-cli init YourAppName
```

##### 프로젝트 생성시 기본구조 (new, init)
```
App
|- node_modules
|- src
|-- actions
|-- index.js
|-- layouts
|-- layout.js
`-- layout.hbs
|-- reducers
|-- posts.js
|-- sass
|-- style.scss
|-- views
|-- home
|-- index.js
`-- index.hbs
|-- posts
|-- index.js
`-- index.hbs
|-- index.html
|-- main.js
|- actions
|-- index.js
|- assets
|-- css
|-- default.scss
|- layouts
|-- default.js
`-- default.hbs
|- reducers
|-- idnex.js
|-- posts.js
|-- toolbox.js
|- views
|-- home
|-- index.js
`-- index.hbs
|-- posts
|-- row-items
| |-- index.js
| `-- index.hbs
|-- index.js
`-- index.hbs
|-- index.html
|-- main.js
|- .babelrc
|- .gitignore
|- README.md
|- package.json
|- webpack.config.js
```
Expand All @@ -99,28 +103,37 @@ npm run build
```
App
|- dist
|-- bundle.js
|-- css
|-- default.css
|-- index.html
|- node_modules
|- src
|-- actions
|-- index.js
|-- layouts
|-- layout.js
`-- layout.hbs
|-- reducers
|-- posts.js
|-- sass
|-- style.scss
|-- views
|-- home
|-- index.js
`-- index.hbs
|-- posts
|-- index.js
`-- index.hbs
|-- index.html
|-- main.js
|- actions
|-- index.js
|- assets
|-- css
|-- default.scss
|- layouts
|-- default.js
`-- default.hbs
|- reducers
|-- idnex.js
|-- posts.js
|-- toolbox.js
|- views
|-- home
|-- index.js
`-- index.hbs
|-- posts
|-- row-items
| |-- index.js
| `-- index.hbs
|-- index.js
`-- index.hbs
|-- index.html
|-- main.js
|- .babelrc
|- .gitignore
|- README.md
|- package.json
|- webpack.config.js
```
Expand Down
8 changes: 4 additions & 4 deletions bin/woowahan-cli
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env node
'use strict';
var program = require('commander');
var manifest = require('../package.json');

require('commander')
.version(require('../package').version)
program
.version(manifest.version)
.usage('<command> [options]')
.command('new', 'generate a new project')
.command('init', 'generate a new project current folder')
.parse(process.argv);


101 changes: 22 additions & 79 deletions bin/woowahan-cli-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,86 +2,29 @@
'use strict';

var program = require('commander');

program
.usage('[project-name] <option>')
.parse(process.argv);

var path = require('path');
var exists = require('fs').existsSync;
var fs = require('fs-extra');
var chalk = require('chalk');
var to = path.resolve('.');
var cliPath = path.resolve(__dirname, '..');
var packageJson = require('../lib/packageJson');
var ora = require('ora');
var exec = require('exec');
var recursiveReadDirectory = require('recursive-readdir');

if(exists(to)) {
var templatePath = path.resolve(cliPath, 'templates/app');

packageJson()
.then(function(result) {
var customPackageObj = result;
var targetPackage = path.resolve(to , 'package.json');
var spinner = ora({
text: '',
spinner: {
interval: 100,
frames: [
'⠄ NPM Installing .',
'⠆ NPM Installing ..',
'⠇ NPM Installing ...',
'⠋ NPM Installing ....',
'⠙ NPM Installing .....',
'⠸ NPM Installing ......',
'⠰ NPM Installing .......',
'⠠ NPM Installing ......',
'⠰ NPM Installing .....',
'⠸ NPM Installing ....',
'⠙ NPM Installing ...',
'⠋ NPM Installing ..',
'⠇ NPM Installing .',
'⠆ NPM Installing '
]
}
});

console.log();
console.log(chalk.cyan('initializing Woowahan App'));

try{

recursiveReadDirectory(templatePath, function (err, files) {
var filesLength = files.length;
var manifestManager = require('../lib/manifest-manager');
var currentDirectories = process.cwd().split('/');
var CLI = require('../lib/cli-task');

for(var cnt =0; cnt < filesLength; cnt++) {
var file = files[cnt].replace(templatePath+'/' , '');

console.log(chalk.green(' create ') + file);
}
console.log();

fs.copySync(templatePath, to);

fs.writeJsonSync(targetPackage, customPackageObj);

spinner.start();

exec('npm install', function(err, stdout, stderr) {
if(err !== null) {
spinner.stop();
console.log(chalk.yellow(err));
}
spinner.stop();
console.log(chalk.cyan('Successfully Installed!'));
console.log();
});
program
.usage('[project-name] <option>')
.parse(process.argv);

});
} catch(err) {
console.log(chalk.red('ERROR ' + err));
}
});
}
var CLIConfig = {};

CLIConfig.projectName = currentDirectories[currentDirectories.length-1];
CLIConfig.projectPath = path.resolve('.');

Promise
.resolve(CLIConfig)
.then(manifestManager)
.then(CLI.prepareWork)
.then(CLI.readTemplateFiles)
.then(CLI.writeTemplateFiles)
.then(CLI.npmInstall)
.then(CLI.finishWork)
.catch(function(err) {
console.error(chalk.yellow(err));
});
Loading

0 comments on commit 0258da6

Please sign in to comment.