-
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
1 parent
2a67474
commit 43398db
Showing
4 changed files
with
139 additions
and
3 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 |
---|---|---|
@@ -1,5 +1,46 @@ | ||
# ConciseCSS - Generator | ||
> The best way for you start your project! | ||
# License | ||
## Experimental version | ||
This is an experimental version of Concise generator. | ||
|
||
## Usage | ||
|
||
Meke sure you have [Node.js](http://nodejs.org) and NPM. | ||
|
||
Clone the repo | ||
``` | ||
git clone git@github.com:ConciseCSS/concise-generator.git concise-generator | ||
cd concise-generator | ||
[sudo] npm link | ||
``` | ||
|
||
Now you can use this normaly. | ||
|
||
`concise [folder]` | ||
|
||
It's generate: | ||
|
||
``` | ||
myproject | ||
| | ||
|-js | ||
| |-concise.min.js | ||
|-css | ||
| |-concise.min.css | ||
|-image | ||
|-index.html | ||
| | ||
``` | ||
|
||
## Options | ||
``` | ||
-h, --help output usage information | ||
-V, --version output the version number | ||
-p, --prod use production version | ||
``` | ||
|
||
Any issue or pull request follow the Concise [contributing](https://github.com/ConciseCSS/concise.css/blob/master/CONTRIBUTING.md) guide. | ||
|
||
## License | ||
MIT |
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,58 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
var program = require('commander'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
|
||
var util = require('./lib/util'); | ||
var pkg = require('./package'); | ||
|
||
program | ||
.usage('[folder]') | ||
.version(pkg.version) | ||
.option('-p, --prod', 'use production version') | ||
.parse(process.argv); | ||
|
||
var destinationPath = program.args.shift() || '.'; | ||
|
||
var index = fs.readFileSync(__dirname + '/templates/index.html'); | ||
var css = fs.readFileSync(__dirname + '/templates/concise-css/concise.css') | ||
var cssMin = fs.readFileSync(__dirname + '/templates/concise-css/concise.min.css') | ||
var js = fs.readFileSync(__dirname + '/templates/js/concise.js'); | ||
var jsMin = fs.readFileSync(__dirname + '/templates/js/concise.min.js'); | ||
|
||
(function generateApp(path) { | ||
util.emptyDirectory(path, function(empty) { | ||
if (empty || program.force) { | ||
createApp(path); | ||
} else { | ||
program.confirm('destination path is not empty, are you sure to continue?', function(ok) { | ||
if (ok) { | ||
process.stdin.destroy(); | ||
createApp(path); | ||
} else { | ||
util.abort('Process canceled!') | ||
} | ||
}); | ||
} | ||
}); | ||
})(destinationPath); | ||
|
||
function createApp(path) { | ||
util.mkdir(path, function() { | ||
util.mkdir(path + '/css'); | ||
util.mkdir(path + '/images'); | ||
util.mkdir(path + '/js'); | ||
|
||
util.write(path + '/index.html', index); | ||
|
||
if (program.prod) { | ||
util.write(path + '/css/concise.css', css) | ||
util.write(path + '/js/concise.js', js); | ||
} else { | ||
util.write(path + '/css/concise.min.css', cssMin) | ||
util.write(path + '/js/concise.min.js', jsMin); | ||
} | ||
}); | ||
} |
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,30 @@ | ||
var fs = require('fs'); | ||
var mkdirp = require('mkdirp'); | ||
'use strict'; | ||
|
||
exports.emptyDirectory = function (path, fn) { | ||
fs.readdir(path, function(err, files) { | ||
if (err && 'ENOENT' != err.code) throw err; | ||
fn(!files || !files.length); | ||
}); | ||
} | ||
|
||
exports.write = function (path, str, mode) { | ||
fs.writeFile(path, str, { | ||
mode: mode || 0666 | ||
}); | ||
console.log(' [\x1b[32mcreate\x1b[0m] ' + path); | ||
} | ||
|
||
exports.mkdir = function (path, fn) { | ||
mkdirp(path, 0755, function(err) { | ||
if (err) throw err; | ||
console.log(' [\033[32mcreate\033[0m] ' + path); | ||
fn && fn(); | ||
}); | ||
} | ||
|
||
exports.abort = function (str) { | ||
console.error(str); | ||
process.exit(1); | ||
} |
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