From 85da39a7ba4c8284b6f6e91d309f72f6294d6d8e Mon Sep 17 00:00:00 2001 From: Dan Stineback Date: Thu, 9 Jun 2016 10:00:14 -0700 Subject: [PATCH 01/18] added log to install --- lib/install.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/install.js b/lib/install.js index 5b616da..fd17028 100644 --- a/lib/install.js +++ b/lib/install.js @@ -7,8 +7,12 @@ const install = function(args, callback){ let default_name = template.split('/').pop().slice(0, -4); let rename = args.rename || default_name; GIT.Clone(template, process.env.HOME + '/.config/plop/' + rename) + .then((repo) => { + if (repo) this.log(`Files have been plopped into ~/.config/plop/${rename}.`); + }) .catch((err)=>{ - console.error('Failed to install template'); + err = `Failed to install template because ~/.config/plop/${rename} already exists.\nPlease try again with different name.`; + console.error(err); return err; }); callback(); From fd4029e7a270d9d0567bd8f6d57cdb89566964a9 Mon Sep 17 00:00:00 2001 From: Chris Perez Date: Thu, 9 Jun 2016 10:00:50 -0700 Subject: [PATCH 02/18] variadic deletion enabled --- lib/delete.js | 11 ++++++----- plop.js | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/delete.js b/lib/delete.js index ffb7fc3..2968c84 100644 --- a/lib/delete.js +++ b/lib/delete.js @@ -3,12 +3,13 @@ const fs = require('fs-extra'); const del = function(args, callback){ - let template_path = process.env.HOME + '/.config/plop/' + args.template_name; - fs.remove(template_path, (err)=>{ - if (err) return new Error('Deletion Failure'); - }); + for (var i = 0; i < args.template_name.length; i++){ + let template_path = process.env.HOME + '/.config/plop/' + args.template_name[i]; + fs.remove(template_path, (err)=>{ + if (err) this.log(new Error('Deletion failure')); + }); + } callback(); }; -//rimraf or dell module.exports = exports = del; diff --git a/plop.js b/plop.js index 36e8502..c5bbd9e 100755 --- a/plop.js +++ b/plop.js @@ -20,7 +20,7 @@ vorpal.command('install [template_repo_url] [rename]', 'clones a plop template f vorpal.command('use [template_name] [destination_path]', 'copies a plop template (by filename) you have saved into your working directory.') .action(use); -vorpal.command('delete [template_name]', 'removes a locally saved plop template.') +vorpal.command('delete [template_name...]', 'removes a locally saved plop template.') .action(del); vorpal.command('list', 'displays a list of templates saved locally. Can also use `ls`.') From 0d22a2f20bb4cd266fb399f5f0d3330ce0a6c2e0 Mon Sep 17 00:00:00 2001 From: Chris Perez Date: Thu, 9 Jun 2016 10:07:54 -0700 Subject: [PATCH 03/18] merged dan's install change and moved variable declaration out of loop in delete --- lib/delete.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/delete.js b/lib/delete.js index 2968c84..8571bc4 100644 --- a/lib/delete.js +++ b/lib/delete.js @@ -3,8 +3,9 @@ const fs = require('fs-extra'); const del = function(args, callback){ + let template_path; for (var i = 0; i < args.template_name.length; i++){ - let template_path = process.env.HOME + '/.config/plop/' + args.template_name[i]; + template_path = process.env.HOME + '/.config/plop/' + args.template_name[i]; fs.remove(template_path, (err)=>{ if (err) this.log(new Error('Deletion failure')); }); From 407e1855b15336cdf2ad9bc8f6f0777554aedcbe Mon Sep 17 00:00:00 2001 From: Chris Perez Date: Thu, 9 Jun 2016 10:19:47 -0700 Subject: [PATCH 04/18] added log for delete --- lib/delete.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/delete.js b/lib/delete.js index 8571bc4..5c7d9eb 100644 --- a/lib/delete.js +++ b/lib/delete.js @@ -10,6 +10,7 @@ const del = function(args, callback){ if (err) this.log(new Error('Deletion failure')); }); } + this.log(args.template_name.length > 1 ? 'Plops deleted' : 'Plop deleted'); callback(); }; From 225590c0dff76f11d6569c5f73640ee00e447c71 Mon Sep 17 00:00:00 2001 From: Dan Stineback Date: Thu, 9 Jun 2016 11:04:39 -0700 Subject: [PATCH 05/18] added logs to use --- lib/use.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/use.js b/lib/use.js index 5243b9a..801ddbf 100644 --- a/lib/use.js +++ b/lib/use.js @@ -6,8 +6,13 @@ const use = function(args, callback){ let template_name = args.template_name; let template_path = process.env.HOME + '/.config/plop/' + template_name + '/template'; let destination_path = args.destination_path || './'; + let existingPlops = fs.readdirSync(process.env.HOME + '/.config/plop/'); + if (existingPlops.indexOf(template_name) === -1) { + this.log(`${template_name} does not exist.\nUse 'list' to see existing plop templates.`); + } fs.copy(template_path, destination_path, (err)=>{ - if (err) return new Error('Failed to copy template to your project.'); + if (err) return new Error('Failed to copy plop template to your project.'); + this.log('You now have a new plop template in your project.'); }); callback(); }; From 2fd74bbcb6006abc7e91fb4fd2227033fbadb379 Mon Sep 17 00:00:00 2001 From: Chris Perez Date: Thu, 9 Jun 2016 11:08:52 -0700 Subject: [PATCH 06/18] all commands have success logs --- lib/delete.js | 4 ++-- lib/init.js | 2 +- lib/install.js | 2 +- lib/list.js | 4 ++-- lib/save.js | 1 + 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/delete.js b/lib/delete.js index 5c7d9eb..5cacd59 100644 --- a/lib/delete.js +++ b/lib/delete.js @@ -7,10 +7,10 @@ const del = function(args, callback){ for (var i = 0; i < args.template_name.length; i++){ template_path = process.env.HOME + '/.config/plop/' + args.template_name[i]; fs.remove(template_path, (err)=>{ - if (err) this.log(new Error('Deletion failure')); + if (err) this.log(new Error('Deletion failure.')); }); } - this.log(args.template_name.length > 1 ? 'Plops deleted' : 'Plop deleted'); + this.log(args.template_name.length > 1 ? 'Plop templates deleted.' : 'Plop template deleted.'); callback(); }; diff --git a/lib/init.js b/lib/init.js index c5781d4..fda7d87 100644 --- a/lib/init.js +++ b/lib/init.js @@ -19,7 +19,7 @@ const init = function(args, callback){ for (var i = 0; i < newPlop.length; i++){ this.log(newPlop[i]); } - this.log('\nChange directories into your template and start building your plop!'); + this.log('\nChange directories into your template and start building your plop template!'); }); }); }); diff --git a/lib/install.js b/lib/install.js index fd17028..ce8a68d 100644 --- a/lib/install.js +++ b/lib/install.js @@ -11,7 +11,7 @@ const install = function(args, callback){ if (repo) this.log(`Files have been plopped into ~/.config/plop/${rename}.`); }) .catch((err)=>{ - err = `Failed to install template because ~/.config/plop/${rename} already exists.\nPlease try again with different name.`; + err = `Failed to install plop template because ~/.config/plop/${rename} already exists.\nPlease try again with different name.`; console.error(err); return err; }); diff --git a/lib/list.js b/lib/list.js index ae679cf..e9da063 100644 --- a/lib/list.js +++ b/lib/list.js @@ -4,8 +4,8 @@ const fs = require('fs-extra'); const list = function(args, callback){ fs.readdir(process.env.HOME + '/.config/plop/', (err, files)=>{ - if (err) return new Error('Failed to find templates'); - if (files.length < 1) console.error('You have no templates saved locally'); + if (err) return new Error('Failed to find templates.'); + if (files.length < 1) console.error('You have no templates saved locally.'); for (var i = 0; i < files.length; i++){ this.log(files[i]); } diff --git a/lib/save.js b/lib/save.js index 43728fd..c56cf58 100644 --- a/lib/save.js +++ b/lib/save.js @@ -16,6 +16,7 @@ const save = function(args, callback){ this.log('You are not saving a valid plop template. Verify your working directory.'); } else if (contents.indexOf('plop.json') != -1) { fs.copy('./', process.env.HOME + '/.config/plop/' + plop_name + '/'); + this.log('New plop template successfully saved.'); } callback(); }; From 201c5591109e27ee2a96ef055cc289aa7c90774e Mon Sep 17 00:00:00 2001 From: Dan Stineback Date: Thu, 9 Jun 2016 12:14:34 -0700 Subject: [PATCH 07/18] added info to docs --- README.md | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 06b958f..0a664f3 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,7 @@ and this will show you the directory that node is located in on your computer if ```shell /Users/example/.node/bin/node -``` - -//TODO add info about NPM i for all dependencies +``` ## How to install @@ -52,8 +50,8 @@ from ```plop$``` you can then run any of efficient plop$ commands. ##plop$ install ```shell plop$ install [options] -```` -####Example +``` +####Example of install ```shell plop$ install https://github.com/PLOPdotJS/plop-test.git test @@ -62,10 +60,19 @@ plop$ install https://github.com/PLOPdotJS/plop-test.git test [options] is the name that you choose to give your template. +plop$ *install* will create a new plopjs template that will be stored locally in your plopjs cache directory. Once the plopjs template is installed it will be able to be accessed by any of the plop$ commands. + ####Please note that if you do not name your plopjs repo on install it will default to the name of the repo. ##VERY IMPORTANT ALL GITHUB REPOS MUST BE NON SSH. IT WILL ONLY WORK HTTPS. +####Example of the alias + +```shell +plop$ i +``` + + ##plop$ use ```shell plop$ use