From e4576da6e793eb91d678d1c40d6dc3ef9bd8e14e Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 28 Apr 2016 10:35:39 +0300 Subject: [PATCH 1/8] Fixed #67, update readme --- README.md | 140 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 101 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index cbaab97..3c9d433 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![NPM version][npm-image]][npm-url][![Trasiv Build Status][travis-image]][travis-url][![AppVeyor Build Status][appveyor-img]][appveyor][![Coveralls Status][coveralls-image]][coveralls-url][![Dependency Status][depstat-image]][depstat-url][![DevDependency Status][depstat-dev-image]][depstat-dev-url][![XO code style][codestyle-image]][codestyle-url] -> CLI for [PostHTML][posthtml-url] +> Simple CLI for [PostHTML][posthtml-url] ## Install @@ -15,52 +15,114 @@ npm install --global posthtml-cli ```console $ posthtml --help - Usage - posthtml --output|-o output.html --input|-i input.html [--config|-c path/to/json/config] - - Options - --config, -c Path to JSON file [string] - --output, -o Output html file/folder result [required] - --input, -i Input html file/folder [required] - --replace, -r Replace input file(s) [boolean] - --help, -h Show help [boolean] - --version, -v Show version number [boolean] - - Example sample - posthtml -o output.html -i input.html - - Example options config - posthtml -o output.html -i input.html -c posthtml.json - or - posthtml -o output.html -i input.html -c posthtml.js - - Example read dir - posthtml -o outputFolder/ -i inputFolder/*.html - or - posthtml -o outputFolder/ -i inputFolder/**/*.html + Usage + posthtml --output|-o output.html --input|-i input.html [--config|-c path/to/json/config] + + Options + --config, -c Path to JSON file [string] + --output, -o Output html file/folder result [required] + --input, -i Input html file/folder [required] + --replace, -r Replace input file(s) [boolean] + --help, -h Show help [boolean] + --version, -v Show version number [boolean] ``` -For reading config used [posthtml-load-plugins](https://github.com/michael-ciniawsky/posthtml-load-plugins) +## Config +*Default read options for plugins from package.json usin [posthtml-load-plugins](https://github.com/michael-ciniawsky/posthtml-load-plugins)* + +### ```package.json``` -*Default read options for plugins from package.json* ```json { - "name": "my project", - "devDependencies": { - "posthtml-custom-elements": "^1.0.3", - "posthtml-style-to-file": "^0.1.1" - }, - "posthtml": { - "customElements": { - "defaultTag": "span" - }, - "styleToFile": { - "path": "./dist/style.css" - } - } + "name": "my project", + "dependencies": { + "posthtml-bem": "^0.2.2", + "posthtml-each": "^1.0.1", + "posthtml-include": "^1.0.2" + }, + "devDependencies": { + "posthtml-style-to-file": "^0.1.1" + }, + "posthtml": { + "bem": { + "elemPrefix": "__", + "modPrefix": "-", + "modDlmtr": "--" + }, + "include": { + "root": "./", + "encoding": "utf-8" + }, + "styleToFile": { + "path": "./dist/style.css" + } + } } ``` +### ```[name].[ext]``` + +#### JS +```js +module.exports = { + bem: { + elemPrefix: '__', + modPrefix: '-', + modDlmtr: '--' + }, + include: { + root: './', + encoding: 'utf-8' + }, + styleToFile: { + path: './dist/style.css' + } +} +``` +#### ```JSON``` + +```json +{ + "bem": { + "elemPrefix": "__", + "modPrefix": "-", + "modDlmtr": "--" + }, + "include": { + "root": "./", + "encoding": "utf-8" + }, + "styleToFile": { + "path": "./dist/style.css" + } +} +``` + +## Examples + +### Example sample +```console +$ posthtml -o output.html -i input.html +``` + +### Example options config +```console +$ posthtml -o output.html -i input.html -c posthtml.json +``` + +```console +$ posthtml -o output.html -i input.html -c posthtml.js +``` + +### Example read dir +```console +$ posthtml -o outputFolder/ -i inputFolder/*.html +``` + +```console +$ posthtml -o outputFolder/ -i inputFolder/**/*.html +``` + ## License MIT From ffee98b8ac7690c198cac0cdbcbc61bc93460ae0 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 28 Apr 2016 10:37:24 +0300 Subject: [PATCH 2/8] Fixed #68, add node 6 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 1e3d229..ea10612 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: node_js node_js: + - v6 - v5 - v4 after_success: From f47861ac1748e5f7070251f77b63889249d27dc8 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 28 Apr 2016 13:47:09 +0300 Subject: [PATCH 3/8] Fixed bug witch replace options, see changelog --- cli.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cli.js b/cli.js index 68a20c4..6c66342 100755 --- a/cli.js +++ b/cli.js @@ -46,6 +46,9 @@ function processing(file, output) { } function isFile(outputPath) { + if (outputPath === undefined) { + return false; + } return Boolean(path.extname(outputPath)); } @@ -70,7 +73,6 @@ globby(argv.input).then(function (files) { if (argv.output !== undefined) { createFolder(argv.output); } - files.forEach(function (file) { var output = isFile(argv.output) ? argv.output : getOutput(file); processing(file, output); From 0da1c06fd6be8841aedcf71c584dfa332d5b3927 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 28 Apr 2016 13:54:05 +0300 Subject: [PATCH 4/8] Update, add await when create tmp folder --- test/test-cli.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-cli.js b/test/test-cli.js index 56e906c..0b0abfb 100644 --- a/test/test-cli.js +++ b/test/test-cli.js @@ -67,7 +67,7 @@ test('Transform html witch config in file', async t => { test('Transform html from folder', async t => { t.plan(2); - const folder = tempfile(); + const folder = await tempfile(); await execa('../cli.js', ['-i', 'fixtures/*.html', '-o', `${folder}/`]); t.is((await read('expected/output-config-pkg.html')), (await read(`${folder}/input.html`))); t.is((await read('expected/output-indent.html')), (await read(`${folder}/input-indent.html`))); @@ -75,7 +75,7 @@ test('Transform html from folder', async t => { test('Transform html witch options replace', async t => { t.plan(2); - const folder = tempfile(); + const folder = await tempfile(); await copy(['fixtures/*.html'], `${folder}/`); await execa('../cli.js', ['-i', `${folder}/*.html`, '-r']); t.is((await read('expected/output-config-pkg.html')), (await read(`${folder}/input.html`))); From 04cafb8bcc6f01f8febdc5a159279ca87685f5f3 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 28 Apr 2016 14:17:41 +0300 Subject: [PATCH 5/8] Fixed #65, update devDep --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 25f394d..874867f 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "scripts": { "test": "xo && nyc ava", "prepush": "xo", - "update": "updtr && ava-codemods" + "update": "updtr && ava-codemods --force" }, "repository": { "type": "git", @@ -30,17 +30,17 @@ "homepage": "https://github.com/GitScrum/posthtml-cli#readme", "dependencies": { "globby": "^4.0.0", - "posthtml": "^0.8.3", + "posthtml": "^0.8.6", "posthtml-load-plugins": "^0.9.5", "yargs": "^4.6.0" }, "devDependencies": { "ava": "^0.14.0", "ava-codemods": "^0.2.1", - "coveralls": "^2.11.8", + "coveralls": "^2.11.9", "cpy": "^4.0.0", - "execa": "^0.2.2", - "nyc": "^6.4.0", + "execa": "^0.4.0", + "nyc": "^6.4.1", "path-exists": "^2.1.0", "posthtml-custom-elements": "^1.0.3", "read-pkg": "^1.1.0", From 5e5c56cd3dc7369902aa61bdb0d4ebd8283aac06 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 28 Apr 2016 14:19:43 +0300 Subject: [PATCH 6/8] v0.1.1 ... v0.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 874867f..c70ded6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "posthtml-cli", - "version": "0.1.1", + "version": "0.1.2", "description": "CLI for posthtml", "bin": { "posthtml": "./cli.js" From 67ba3d3942ca3ac5b48a0bde6511fc68cd869802 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 28 Apr 2016 14:20:02 +0300 Subject: [PATCH 7/8] bump --- CHANGELOG.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08a4914..75092fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ +## [0.1.2] - 28-04-2016 +### Added +- Added #68, node 6 to config travis + +### Change +- Update #67, readme +- Update test, add await when create tmpFolder +- Update #65, update devDep + +### Fixed +- Fixed bug witch replace options. !path.extname(undefined) === true O_o + ## [0.1.1] - 22-04-2016 -## Added +### Added - Added #64, updtr - Added #62, ava-codemods - Added #59, tempfile for test @@ -14,19 +26,19 @@ - Remove #59, del not need ## [0.1.0] - 23-03-2016 -## Added +### Added - Added #16, replace file(s) - Added #9, read filed in folder and transform to folder ## [0.0.22] - 23-03-2016 -## Added +### Added - Added test with indent - Added node support in package.json -## Fixed +### Fixed - Fixed #53, coverage for windows -## Removed +### Removed - Remove #56, support node 0.12 ## [0.0.21] - 21-03-2016 From a06f9e77ab25c2932c0e27fd40f7cbacd4dd722a Mon Sep 17 00:00:00 2001 From: Scrum Date: Thu, 28 Apr 2016 14:22:26 +0300 Subject: [PATCH 8/8] Update appveyor.yml --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 0850b9f..e051b3d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,6 @@ environment: matrix: + - nodejs_version: "6" - nodejs_version: "5" - nodejs_version: "4"