From 9c7a2706696d0c85cff23b4f0529922c5fab32cd Mon Sep 17 00:00:00 2001 From: zehfernandes Date: Mon, 3 Oct 2016 16:22:15 -0300 Subject: [PATCH 1/6] help --- cli.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cli.js b/cli.js index 3f9c78c..fddec8e 100755 --- a/cli.js +++ b/cli.js @@ -26,8 +26,10 @@ const cli = meow(` -n, --new Generate a new Tachyons project --generate-docs Generate documentation for a given module --package The path to the module package to be documented + --customMedia Generate media queries single files or directorys Example + $ tachyons src/ > dist/ --customMedia --variables:src/variables.css --overwrite:false $ tachyons src/tachyons.css > dist/c.css $ tachyons src/tachyons.css > dist/c.css --minify $ tachyons src/tachyons.css > dist/c.repeated.css --repeat From a6dbd10e2fa7eaf3c81fb28272da443b71558e76 Mon Sep 17 00:00:00 2001 From: zehfernandes Date: Mon, 3 Oct 2016 17:48:46 -0300 Subject: [PATCH 2/6] add rule to call external plugin --- cli.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cli.js b/cli.js index fddec8e..b60eb43 100755 --- a/cli.js +++ b/cli.js @@ -12,6 +12,7 @@ const fileExists = require('file-exists') const cssstats = require('cssstats') const trailingLines = require('single-trailing-newline') const authorsToMd = require('authors-to-markdown') +const generate = require('../updatemediaquerie') const tachyonsBuildCss = require('tachyons-build-css') @@ -26,10 +27,10 @@ const cli = meow(` -n, --new Generate a new Tachyons project --generate-docs Generate documentation for a given module --package The path to the module package to be documented - --customMedia Generate media queries single files or directorys + --customMedia Generate media queries single files or directory Example - $ tachyons src/ > dist/ --customMedia --variables:src/variables.css --overwrite:false + $ tachyons src/ --customMedia --variables=src/variables.css --overwrite=false $ tachyons src/tachyons.css > dist/c.css $ tachyons src/tachyons.css > dist/c.css --minify $ tachyons src/tachyons.css > dist/c.repeated.css --repeat @@ -69,6 +70,18 @@ if (cli.flags.new) { process.exit(0) } +if (cli.flags.customMedia) { + console.log(outputFile); + + generate(outputFile, { + variables: cli.flags.variables, + overwrite: cli.flags.overwrite + }) + + //process.exit(0) + +} +/* if (isBlank(inputFile)) { console.error(chalk.red('Please provide an input stylesheet')) console.log(cli.help) @@ -114,3 +127,4 @@ tachyonsBuildCss(input, { process.exit(0) } }) +*/ \ No newline at end of file From 54dff9b89731712b7f13dbefc7c4b0beefc0f434 Mon Sep 17 00:00:00 2001 From: zehfernandes Date: Mon, 3 Oct 2016 19:04:00 -0300 Subject: [PATCH 3/6] update path check --- cli.js | 91 ++++++++++++++++++++++++++-------------------------- package.json | 1 + 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/cli.js b/cli.js index b60eb43..3df9a45 100755 --- a/cli.js +++ b/cli.js @@ -12,6 +12,7 @@ const fileExists = require('file-exists') const cssstats = require('cssstats') const trailingLines = require('single-trailing-newline') const authorsToMd = require('authors-to-markdown') +const pathExists = require('path-exists'); const generate = require('../updatemediaquerie') const tachyonsBuildCss = require('tachyons-build-css') @@ -70,61 +71,59 @@ if (cli.flags.new) { process.exit(0) } -if (cli.flags.customMedia) { - console.log(outputFile); - - generate(outputFile, { - variables: cli.flags.variables, - overwrite: cli.flags.overwrite - }) - - //process.exit(0) - -} -/* if (isBlank(inputFile)) { console.error(chalk.red('Please provide an input stylesheet')) console.log(cli.help) process.exit(1) -} else if (!fileExists(inputFile)) { +} else if (!pathExists.sync(inputFile)) { console.error(chalk.red('File does not exist ' + inputFile)) console.log(cli.help) process.exit(1) } -const input = fs.readFileSync(inputFile, 'utf8') -tachyonsBuildCss(input, { - from: inputFile, - to: outputFile, - minify: cli.flags.minify, - repeat: cli.flags.repeat -}).then(function (result) { - if (cli.flags.generateDocs) { - const stats = cssstats(result.css) - const pkg = require(cli.flags.package) - const template = fs.readFileSync(__dirname + '/templates/readme.md', 'utf8') - const tpl = _.template(template) - - let authors = `* [mrmrs](http://mrmrs.io) -* [johno](http://johnotander.com) -` - - if (cli.flags.authors) { - authors = authorsToMd(pkg) +if (!cli.flags.customMedia) { + + const input = fs.readFileSync(inputFile, 'utf8') + tachyonsBuildCss(input, { + from: inputFile, + to: outputFile, + minify: cli.flags.minify, + repeat: cli.flags.repeat + }).then(function (result) { + if (cli.flags.generateDocs) { + const stats = cssstats(result.css) + const pkg = require(cli.flags.package) + const template = fs.readFileSync(__dirname + '/templates/readme.md', 'utf8') + const tpl = _.template(template) + + let authors = `* [mrmrs](http://mrmrs.io) + * [johno](http://johnotander.com) + ` + + if (cli.flags.authors) { + authors = authorsToMd(pkg) + } + + const md = tpl({ + module: pkg, + stats: stats, + authors: authors, + srcCss: trailingLines(result.css) + }) + + console.log(trailingLines(md)) + process.exit(0) + } else { + console.log(trailingLines(result.css)) + process.exit(0) } + }) - const md = tpl({ - module: pkg, - stats: stats, - authors: authors, - srcCss: trailingLines(result.css) - }) +} - console.log(trailingLines(md)) - process.exit(0) - } else { - console.log(trailingLines(result.css)) - process.exit(0) - } -}) -*/ \ No newline at end of file +if (cli.flags.customMedia) { + generate(inputFile, { + variables: cli.flags.variables, + overwrite: cli.flags.overwrite + }) +} \ No newline at end of file diff --git a/package.json b/package.json index 5908fb9..d6627d5 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "lodash": "^4.16.0", "meow": "^3.7.0", "mkdirp": "^0.5.1", + "path-exists": "^3.0.0", "single-trailing-newline": "^1.0.0", "tachyons-build-css": "^1.1.2" }, From b67803ffc96ecddc00e1c54399dc3494d12ad559 Mon Sep 17 00:00:00 2001 From: zehfernandes Date: Tue, 4 Oct 2016 00:02:46 -0300 Subject: [PATCH 4/6] update packpage --- cli.js | 4 ++-- package.json | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cli.js b/cli.js index 3df9a45..0a802a5 100755 --- a/cli.js +++ b/cli.js @@ -13,7 +13,7 @@ const cssstats = require('cssstats') const trailingLines = require('single-trailing-newline') const authorsToMd = require('authors-to-markdown') const pathExists = require('path-exists'); -const generate = require('../updatemediaquerie') +const generate = require('tachyons-build-mediaquerie') const tachyonsBuildCss = require('tachyons-build-css') @@ -126,4 +126,4 @@ if (cli.flags.customMedia) { variables: cli.flags.variables, overwrite: cli.flags.overwrite }) -} \ No newline at end of file +} diff --git a/package.json b/package.json index d6627d5..b0dbaa3 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,8 @@ "mkdirp": "^0.5.1", "path-exists": "^3.0.0", "single-trailing-newline": "^1.0.0", - "tachyons-build-css": "^1.1.2" + "tachyons-build-css": "^1.1.2", + "tachyons-build-mediaquerie" : "git://github.com/zehfernandes/tachyons-build-mediaquerie.git" }, "devDependencies": { "ava": "*", From f05fe91fcc42f9dfb0e6a777215e16868d37037a Mon Sep 17 00:00:00 2001 From: zehfernandes Date: Tue, 4 Oct 2016 01:16:50 -0300 Subject: [PATCH 5/6] update help and readme.md --- cli.js | 2 +- readme.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cli.js b/cli.js index 0a802a5..229dcd5 100755 --- a/cli.js +++ b/cli.js @@ -28,7 +28,7 @@ const cli = meow(` -n, --new Generate a new Tachyons project --generate-docs Generate documentation for a given module --package The path to the module package to be documented - --customMedia Generate media queries single files or directory + --customMedia Generate media queries for single files or a directory Example $ tachyons src/ --customMedia --variables=src/variables.css --overwrite=false diff --git a/readme.md b/readme.md index c36d2eb..f1bc23b 100644 --- a/readme.md +++ b/readme.md @@ -30,8 +30,10 @@ $ tachyons --help -n, --new Generate a new Tachyons project --generate-docs Generate documentation for a given module --package The path to the module package to be documented + --customMedia Generate media queries for single files or a directory Example + $ tachyons src/ --customMedia --variables=src/variables.css --overwrite=false $ tachyons src/tachyons.css > dist/c.css $ tachyons src/tachyons.css > dist/c.css --minify $ tachyons src/tachyons.css > dist/c.repeated.css --repeat From a13f4eb62f874daf49e4cd88cdf05bced4fbf992 Mon Sep 17 00:00:00 2001 From: zehfernandes Date: Tue, 4 Oct 2016 02:41:56 -0300 Subject: [PATCH 6/6] resolve tests --- cli.js | 127 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 64 insertions(+), 63 deletions(-) diff --git a/cli.js b/cli.js index 229dcd5..8c46bd1 100755 --- a/cli.js +++ b/cli.js @@ -49,81 +49,82 @@ const cli = meow(` const inputFile = cli.input[0] const outputFile = cli.input[1] + +if (cli.flags.customMedia) { + + generate(inputFile, { + variables: cli.flags.variables, + overwrite: cli.flags.overwrite + }) + +} else { + if (cli.flags.new) { - console.log('Generating a new Tachyons project') - const projDir = cli.flags.new == true ? 'tachyons-project' : cli.flags.new +console.log('Generating a new Tachyons project') +const projDir = cli.flags.new == true ? 'tachyons-project' : cli.flags.new - mkdirp.sync(projDir) - mkdirp.sync(projDir + '/src') - mkdirp.sync(projDir + '/css') +mkdirp.sync(projDir) +mkdirp.sync(projDir + '/src') +mkdirp.sync(projDir + '/css') - const index = fs.readFileSync(__dirname + '/templates/new/index.html','utf8') - const pkg = fs.readFileSync(__dirname + '/templates/new/package.json', 'utf8') - const readme = fs.readFileSync(__dirname + '/templates/new/readme.md', 'utf8') - const style = fs.readFileSync(__dirname + '/templates/new/src/styles.css', 'utf8') +const index = fs.readFileSync(__dirname + '/templates/new/index.html','utf8') +const pkg = fs.readFileSync(__dirname + '/templates/new/package.json', 'utf8') +const readme = fs.readFileSync(__dirname + '/templates/new/readme.md', 'utf8') +const style = fs.readFileSync(__dirname + '/templates/new/src/styles.css', 'utf8') - fs.writeFileSync(projDir + '/index.html', index) - fs.writeFileSync(projDir + '/package.json', pkg) - fs.writeFileSync(projDir + '/readme.md', readme) - fs.writeFileSync(projDir + '/src/styles.css', style) +fs.writeFileSync(projDir + '/index.html', index) +fs.writeFileSync(projDir + '/package.json', pkg) +fs.writeFileSync(projDir + '/readme.md', readme) +fs.writeFileSync(projDir + '/src/styles.css', style) - console.log('New project located in ' + projDir) - process.exit(0) +console.log('New project located in ' + projDir) +process.exit(0) } if (isBlank(inputFile)) { - console.error(chalk.red('Please provide an input stylesheet')) - console.log(cli.help) - process.exit(1) +console.error(chalk.red('Please provide an input stylesheet')) +console.log(cli.help) +process.exit(1) } else if (!pathExists.sync(inputFile)) { - console.error(chalk.red('File does not exist ' + inputFile)) - console.log(cli.help) - process.exit(1) +console.error(chalk.red('File does not exist ' + inputFile)) +console.log(cli.help) +process.exit(1) } -if (!cli.flags.customMedia) { - - const input = fs.readFileSync(inputFile, 'utf8') - tachyonsBuildCss(input, { - from: inputFile, - to: outputFile, - minify: cli.flags.minify, - repeat: cli.flags.repeat - }).then(function (result) { - if (cli.flags.generateDocs) { - const stats = cssstats(result.css) - const pkg = require(cli.flags.package) - const template = fs.readFileSync(__dirname + '/templates/readme.md', 'utf8') - const tpl = _.template(template) - - let authors = `* [mrmrs](http://mrmrs.io) - * [johno](http://johnotander.com) - ` - - if (cli.flags.authors) { - authors = authorsToMd(pkg) - } - - const md = tpl({ - module: pkg, - stats: stats, - authors: authors, - srcCss: trailingLines(result.css) - }) - - console.log(trailingLines(md)) - process.exit(0) - } else { - console.log(trailingLines(result.css)) - process.exit(0) +const input = fs.readFileSync(inputFile, 'utf8') +tachyonsBuildCss(input, { + from: inputFile, + to: outputFile, + minify: cli.flags.minify, + repeat: cli.flags.repeat +}).then(function (result) { + if (cli.flags.generateDocs) { + const stats = cssstats(result.css) + const pkg = require(cli.flags.package) + const template = fs.readFileSync(__dirname + '/templates/readme.md', 'utf8') + const tpl = _.template(template) + + let authors = `* [mrmrs](http://mrmrs.io) +* [johno](http://johnotander.com) +` + + if (cli.flags.authors) { + authors = authorsToMd(pkg) } - }) -} - -if (cli.flags.customMedia) { - generate(inputFile, { - variables: cli.flags.variables, - overwrite: cli.flags.overwrite + const md = tpl({ + module: pkg, + stats: stats, + authors: authors, + srcCss: trailingLines(result.css) }) + + console.log(trailingLines(md)) + process.exit(0) + } else { + console.log(trailingLines(result.css)) + process.exit(0) + } +}) + }