Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2ebfe89
Merge pull request #25 from PLOPdotJS/development
dstineback Jun 8, 2016
7a13c80
Merge pull request #28 from PLOPdotJS/development
dstineback Jun 8, 2016
07a313d
Merge pull request #34 from PLOPdotJS/development
dstineback Jun 8, 2016
69d5a95
Merge pull request #36 from PLOPdotJS/development
ckperez Jun 8, 2016
6ac51da
Merge pull request #38 from PLOPdotJS/development
ckperez Jun 8, 2016
f72a2bc
Merge pull request #40 from PLOPdotJS/development
ckperez Jun 8, 2016
85da39a
added log to install
dstineback Jun 9, 2016
fd4029e
variadic deletion enabled
ckperez Jun 9, 2016
638d76f
Merge pull request #53 from dstineback/12-dan-doc
ckperez Jun 9, 2016
00fa834
Merge branch 'development' of https://github.com/PLOPdotJS/plopjs int…
ckperez Jun 9, 2016
0d22a2f
merged dan's install change and moved variable declaration out of loo…
ckperez Jun 9, 2016
407e185
added log for delete
ckperez Jun 9, 2016
fad665c
Merge pull request #54 from ckperez/15-chris-delete_more
dstineback Jun 9, 2016
307efcf
Merge pull request #55 from schrode50/7_stephen_moooore_tests
ckperez Jun 9, 2016
225590c
added logs to use
dstineback Jun 9, 2016
a89f97f
Merge pull request #56 from dstineback/13-dan-use
ckperez Jun 9, 2016
2fd74bb
all commands have success logs
ckperez Jun 9, 2016
ef6dd12
Merge pull request #57 from ckperez/16-chris-logs
schrode50 Jun 9, 2016
201c559
added info to docs
dstineback Jun 9, 2016
bf60160
fixed template example
dstineback Jun 9, 2016
80c3631
fixed error on install
ckperez Jun 9, 2016
0629ad9
1 more test
schrode50 Jun 9, 2016
b6ef1fe
Merge pull request #58 from schrode50/8_stephen_testatest
dstineback Jun 9, 2016
d3383db
Merge pull request #59 from ckperez/17-chris-errors
schrode50 Jun 9, 2016
60b8e73
added merge
dstineback Jun 9, 2016
2516b9f
added more readme
dstineback Jun 9, 2016
e396f82
Merge pull request #60 from dstineback/14-dan-doc
schrode50 Jun 9, 2016
5e00e60
fixed minor readme
dstineback Jun 9, 2016
9b13369
removing bad delete test
schrode50 Jun 9, 2016
950d511
added autocomplete
dstineback Jun 9, 2016
47165b2
fixed lint issue on delete-test
dstineback Jun 9, 2016
b53669d
install and delete tests working
ckperez Jun 9, 2016
6f59219
Merge pull request #61 from dstineback/15-dan-test
ckperez Jun 9, 2016
1dc847f
Merge branch 'master' of https://github.com/PLOPdotJS/plopjs into 18-…
ckperez Jun 9, 2016
e2b82a5
merged with dan's last edit. good tests and whatnot
ckperez Jun 9, 2016
8d2fd40
fixed author names
ckperez Jun 9, 2016
f043041
Merge pull request #62 from ckperez/18-chris-testing
schrode50 Jun 9, 2016
80ba424
resolving conflicts
schrode50 Jun 9, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 47 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -52,41 +50,55 @@ from ```plop$``` you can then run any of efficient plop$ commands.
##plop$ install
```shell
plop$ install <template_url> [options]
````
####Example
```
####Example of install

```shell
plop$ install https://github.com/PLOPdotJS/plop-test.git test
```
*<template_url>* is the github repo url for the template that you are choosing.

*template_url* is the github repo url for the template that you are choosing.

[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.
###VERY IMPORTANT ALL GITHUB REPOS MUST BE NON SSH. IT WILL ONLY WORK HTTPS.

plop$ install also has an alias

####Example of the alias

```shell
plop$ i <template_url> [options]
```


##plop$ use
```shell
plop$ use <template> [options]
```
*<template>* name of installed plopjs template.
```
sample
*template* is the name of installed plopjs template.
```shell
plop$ use sample
```

[options] path you would like the template loaded to.
```
/project
plop$ use sample /project
```
plop$ *use* will load what ever template you choose into specified directory or if no directory is named then it will default to your working directory.

For *node* projects run ```npm i``` to install all the required dependencies that are used in the plopjs template. Not installing the dependencies will throw err and not run the plopjs template correctly.

##plop$ init
```shell
plop$ init
plop$ init
```

using plopjs init allows a starting point to create a plop.json and start making your own plopjs template. This is your chance to be creative and customize your plopjs.
plopjs *init* allows a starting point to create a plop.json and start making your own plopjs template. This is your chance to be creative and customize your plopjs.

plop$ *init* prompts will walk you through making a new plop.json file. It will also make an empty README.md that you will need to populate and also an empty template directory. Make sure to make your template *INSIDE* the template directory. Any files other then the plop.json and README.md that are outside the template directory will not be included in your plopjs.

Expand Down Expand Up @@ -119,9 +131,11 @@ Change directories into your template and start building your plopjs!

Once you have your template built out you may either:

- create a new github repository on git hub and push your template
- create a new <https://github.com/> repository on git hub and push your template.
or
- git init and initialize a github repository from your working directory.
or
- use ```plop$ save``` command.

##plop$ list
```shell
Expand All @@ -131,16 +145,32 @@ plop$ *list* prints a list of plopjs templates that are saved and available on y

plop$ *list* also has a shorthand alias *ls*.

Example of ls alias.
####Example of alias

```shell
plop$ ls
```

##plop$ save

```shell
plop$ save [name]
```
plop$ *save* will take the existing plopjs template that you created from scratch and save locally to your plopjs cache directory. You can then use ```plop$ lsit``` to verify that your template has been saved. Now that new plopjs template will be available for any future projects.

[name] is the name you choose to name the new plopjs template you created.

*save* also has an alias *s*.

####Example of the alias

```shell
plop$ s [name]
```

##plop$ delete
```shell
plop$ delete
plop$ delete [name]
```
plop$ *delete* will delete any plopjs that is saved on your local client.

Expand Down Expand Up @@ -180,6 +210,7 @@ plop$ *help* will bring up a list of plop$ commands and options.
- gulp-mocha
- mocha


## Development Team

*Chris Perez* <https://github.com/ckperez>
Expand Down
13 changes: 8 additions & 5 deletions lib/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
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');
});
let template_path;
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.'));
});
}
this.log(args.template_name.length > 1 ? 'Plop templates deleted.' : 'Plop template deleted.');
callback();
};
//rimraf or dell

module.exports = exports = del;
2 changes: 1 addition & 1 deletion lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!');
});
});
});
Expand Down
14 changes: 12 additions & 2 deletions lib/install.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
'use strict';

const GIT = require('nodegit');
const fs = require('fs-extra');

const install = function(args, callback){
let template = args.template_repo_url;
let default_name = template.split('/').pop().slice(0, -4);
let rename = args.rename || default_name;
GIT.Clone(template, process.env.HOME + '/.config/plop/' + rename)
fs.mkdirsSync(process.env.HOME + '/.config/plop/');
let existingPlops = fs.readdirSync(process.env.HOME + '/.config/plop/');
if (existingPlops.indexOf(rename) == -1) {
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');
this.log(new Error(err));
return err;
});
} else {
this.log(new Error(`Failed to install plop template because ~/.config/plop/${rename} already exists.\nPlease try again with different name.`));
}
callback();
};

Expand Down
4 changes: 2 additions & 2 deletions lib/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) this.log(new Error('Failed to find templates.'));
if (files.length < 1) this.log(new Error('You have no templates saved locally.'));
for (var i = 0; i < files.length; i++){
this.log(files[i]);
}
Expand Down
5 changes: 3 additions & 2 deletions lib/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ const save = function(args, callback){
let full_WD = process.env.PWD;
let short_WD = full_WD.split('/').pop();
if (short_WD === 'template'){
this.log('Exit the plop CLI and `cd ..` out of template.\nYou will want to save your whole template directory, your README.md, and your plop.json.\nCan\'t do that from here!');
this.log(new Error('Exit the plop CLI and `cd ..` out of template.\nYou will want to save your whole template directory, your README.md, and your plop.json.\nCan\'t do that from here!'));
template_warning = true;
}
let plop_name = args.name || short_WD;
let contents = fs.readdirSync('./');
if (contents.indexOf('plop.json') == -1 && !template_warning){
this.log('You are not saving a valid plop template. Verify your working directory.');
this.log(new Error('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();
};
Expand Down
7 changes: 6 additions & 1 deletion lib/use.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(new Error(`${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();
};
Expand Down
87 changes: 44 additions & 43 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
{
"name": "plopjs",
"version": "0.2.0",
"description": "Cloud-based storage for organization-level boilerplate code",
"preferGlobal": true,
"main": "plop.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "./node_modules/mocha/bin/mocha",
"start": "node plop.js",
"lint": "./node_modules/eslint/bin/eslint.js *"
},
"bin": {
"plop": "./plop.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/PLOPdotJS/plopjs.git"
},
"author": {
"name": "Chris Perez <chris.k.perez@gmail.com>",
"name": "Dan Stineback <dstineback@gmail.com",
"name": "Stephen Schroder <schrode50@gmail.com>"
},
"license": "ISC",
"bugs": {
"url": "https://github.com/PLOPdotJS/plopjs/issues"
},
"homepage": "https://github.com/PLOPdotJS/plopjs#readme",
"dependencies": {
"fs-extra": "^0.30.0",
"nodegit": "^0.13.1",
"vorpal": "^1.11.1"
},
"devDependencies": {
"chai": "^3.5.0",
"eslint": "^2.11.1",
"gulp": "^3.9.1",
"gulp-eslint": "^2.0.0",
"gulp-mocha": "^2.2.0",
"mocha": "^2.5.3"
}
"name": "plopjs",
"version": "0.2.0",
"description": "Cloud-based storage for organization-level boilerplate code",
"preferGlobal": true,
"main": "plop.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "./node_modules/mocha/bin/mocha",
"start": "node plop.js",
"lint": "./node_modules/eslint/bin/eslint.js *"
},
"bin": {
"plop": "./plop.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/PLOPdotJS/plopjs.git"
},
"author": {
"name": "Stephen Schroder <schrode50@gmail.com>",
"name": "Chris Perez <chris.k.perez@gmail.com>",
"name": "Dan Stineback <dstineback@gmail.com>"
},
"license": "ISC",
"bugs": {
"url": "https://github.com/PLOPdotJS/plopjs/issues"
},
"homepage": "https://github.com/PLOPdotJS/plopjs#readme",
"dependencies": {
"fs-extra": "^0.30.0",
"nodegit": "^0.13.1",
"vorpal": "^1.11.1",
"vorpal-autocomplete-fs": "0.0.3"
},
"devDependencies": {
"chai": "^3.5.0",
"eslint": "^2.11.1",
"gulp": "^3.9.1",
"gulp-eslint": "^2.0.0",
"gulp-mocha": "^2.2.0",
"mocha": "^2.5.3"
}
}
28 changes: 15 additions & 13 deletions plop.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env node
'use strict';

const vorpal = require('vorpal')();
const Plop = require('vorpal')();

vorpal.delimiter('plop$').show();
const fsAutocomplete = require('vorpal-autocomplete-fs');

Plop.delimiter('plop$').show();

const use = require(__dirname + '/lib/use');
const install = require(__dirname + '/lib/install');
Expand All @@ -13,25 +14,26 @@ const list = require(__dirname + '/lib/list');
const init = require(__dirname + '/lib/init');
const save = require(__dirname + '/lib/save');


vorpal.command('install [template_repo_url] [rename]', 'clones a plop template from github into your ~/.config/plop/ directory. Can also use `i`.')
Plop.command('install [template_repo_url] [rename]', 'clones a plop template from github into your ~/.config/plop/ directory. Can also use `i`.')
.action(install).alias('i');

vorpal.command('use [template_name] [destination_path]', 'copies a plop template (by filename) you have saved into your working directory.')
.action(use);
Plop.command('use [template_name] [destination_path]', 'copies a plop template (by filename) you have saved into your working directory.')
.action(use).autocomplete(fsAutocomplete());

vorpal.command('delete [template_name]', 'removes a locally saved plop template.')
.action(del);
Plop.command('delete [template_name...]', 'removes a locally saved plop template.')
.action(del).autocomplete(fsAutocomplete());

vorpal.command('list', 'displays a list of templates saved locally. Can also use `ls`.')
.action(list).alias('ls');
Plop.command('list', 'displays a list of templates saved locally. Can also use `ls`.')
.action(list).alias('ls');

vorpal.command('init [template_name]', 'walks you through building a plop template.')
Plop.command('init', 'walks you through building a plop template.')
.action(init);

vorpal.command('save [name]', 'saves a locally created plop template to your ~/.config/plop/ directory. Can also use `s`.')
Plop.command('save [name]', 'saves a locally created plop template to your ~/.config/plop/ directory. Can also use `s`.')
.action(save).alias('s');

const exit = vorpal.find('exit');
const exit = Plop.find('exit');
exit.alias('k').alias('q');
exit.description('exits the plop CLI. Can also use `k` or `q`.');

module.exports = exports = Plop;
Loading