Skip to content

Commit

Permalink
Started work on adding "luke:grits"; it's a work in progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Chavers committed Dec 22, 2016
1 parent cdbb486 commit 0de692f
Show file tree
Hide file tree
Showing 15 changed files with 411 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/partials/bower.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This [partial](../partials.md) does not depend on any others.

This partial is included in the following [project scaffolds](../project-scaffolds.md):

* `luke:grits` (todo)
* [luke:grits](../project-scaffolds/grits.md)

_Note: Additional, unlisted, [project scaffolds](../project-scaffolds.md) may
automatically include this [partial](../partials.md) by way of
Expand Down
1 change: 1 addition & 0 deletions docs/partials/mocha.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ $ yo luke:mocha

## Files Created

* `/scripts/test.sh` (static, [source](../../templates/core/scripts/_mocha-exec-tests.sh))
* `/test/index.js` (static, [source](../../templates/core/test/_mocha-index.js))
* `/test/lib/util.js` (static, [source](../../templates/core/test/lib/_util.js))

Expand Down
49 changes: 49 additions & 0 deletions docs/partials/travis-grits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Partial: "luke:travis-grits" ([source](../../generators/travis-grits/index.js))

A [partial](../partials.md) that generates a `.travis.yml` file with common
options for Grits.js deployment..

## Usage Example

```
$ yo luke:travis-grits
```

## Files Created

* `/.travis.yml` (static, [source](../../templates/grits/_travis.yml))
* `/scripts/grits/_vars.sh` (static, [source](../../templates/grits/scripts/grits/_vars.sh))
* `/scripts/grits/render/ci.sh` (static, [source](../../templates/grits/scripts/grits/render/_ci.sh))


## Other Operations

* Adds a NPM run script: `scripts/grits/render/ci.sh` (as `grits-render-ci`)

## Dependencies

This [partial](../partials.md) depends on, and automatically includes:

* [luke:grits-config](../partials/grits-config.md)
* [luke:grits-scripts](../partials/grits-scripts.md)
* [luke:package](../partials/package.md)
* [luke:scripts](../partials/scripts.md)

## Included In

* [luke:app](../project-scaffolds/app.md)
* [luke:grits](../project-scaffolds/grits.md)
* [luke:module](../project-scaffolds/module.md)

_Note: Additional, unlisted, [project scaffolds](../project-scaffolds.md) may
automatically include this [partial](../partials.md) by way of
[partial dependency](../partials.md#partial-dependency)._

# Further Reading

* [Source](../../generators/travis-grits/index.js) - The source code for this [partial](../partials.md)
* [Partial Listing](./) - Individual docs for each [partial](../partials.md)
* [About Partials](../partials.md) - Information about partials
* [About Project Scaffolds](../project-scaffolds.md) - Basic information about project scaffolds
* [About Sub-Generators](../generators.md) - General information about generators and sub-generators
* [Project README](../README.md) - Basic project information
48 changes: 48 additions & 0 deletions docs/project-scaffolds/grits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Project Scaffold: "luke:grits" ([source](../../generators/grits/index.js))

A [project scaffold](../project-scaffolds.md) that can be used to create or
recreate a basic [Grits.js](https://github.com/Dasix/grits) project.

This scaffold includes everything that the [module scaffold](module.md) includes
as well as many additional [partials](../partials.md) for
[Grits.js](https://github.com/Dasix/grits) development.

## Usage Example

```
$ yo luke:grits
```

## Included Partials

The following [partials](../partials.md) are included when this
[project scaffold](../project-scaffolds.md) is used/specified:

* [luke:editor](../partials/editor.md)
* [luke:git](../partials/git.md)
* [luke:js](../partials/js.md)
* [luke:mit-license](../partials/mit-license.md)
* [luke:mocha](../partials/mocha.md)
* [luke:npm](../partials/npm.md)
* [luke:package](../partials/package.md)
* [luke:readme](../partials/readme.md)
* [luke:scripts](../partials/scripts.md)
* [luke:vagrant](../partials/vagrant.md)
* [luke:bower](../partials/scripts.md)
* [luke:grits-core](../partials/grits-core.md)
* [luke:grits-config](../partials/grits-config.md)
* [luke:grits-scripts](../partials/grits-scripts.md)
* [luke:grits-source](../partials/grits-source.md)
* [luke:travis-grits](../partials/travis-grits.md)

_Note: Additional, unlisted, [partials](../partials.md) may be automatically
included as [partial dependencies](../partials.md#partial-dependency)._

# Further Reading

* [Source](../../generators/grits/index.js) - The source code for this [project scaffold](../project-scaffolds.md)
* [Project Scaffold Listing](./) - Individual docs for each [project scaffold](../project-scaffolds.md)
* [About Project Scaffolds](../project-scaffolds.md) - Basic information about project scaffolds
* [About Partials](../partials.md) - Information about partials
* [About Sub-Generators](../generators.md) - General information about generators and sub-generators
* [Project README](../README.md) - Basic project information
18 changes: 18 additions & 0 deletions generators/_BaseGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,24 @@ module.exports = yeoman.Base.extend(
return existing[ objectType ];
}

},

/**
* This helper method is specific to projects that include 'luke:vagrant',
* it allows a provisioning step using a slightly abbreviated syntax.
*
* @param scriptName The name of the script to add as a provisioning step.
* @private
*/
_addVagrantStep: function( scriptName ) {

var me = this;
me._createSharedObject(
"vagrant-provision-step", scriptName, {
script : scriptName
}
);

}

}
Expand Down
64 changes: 64 additions & 0 deletions generators/grits-scripts/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* This is a "partial" sub-generator that sets up the basic npm run scripts
* for Grits.js projects.
*
* @example
* shell> yo luke:grits-scripts
*
* @author Luke Chavers <[email protected]>
* @created 2016-12-22
*/

var yeoman = require( "yeoman-generator" );
var baseGenerator = require("../_BaseGenerator");

module.exports = baseGenerator.extend(
{
prompting : function() {

// Locals
var me = this;

// Initialize the base generator
me._initBase();

me.composeWith("luke:pm2");
me.composeWith("luke:scripts");

},

default : {

createSharedMetaObjects: function() {

var me = this;

// Add an npm script for running grits on travis
me._createSharedObject(
"script", "grits/xx/xx.sh", {
name : "grits-xx",
src : "grits/scripts/grits/render/_ci.sh",
dest : "scripts/grits/render/ci.sh"
}
);

}

},

writing : {

createPartialFiles : function() {

var me = this;

// _vars.sh
me.fs.copy(
me.templatePath( "grits/scripts/grits/_vars.sh" ), me.destinationPath( "scripts/grits/_vars.sh" )
);

}
}

}
);
41 changes: 41 additions & 0 deletions generators/grits/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* This is a "project scaffold" sub-generator that generates a project scaffold
* for a Grits.js website.
*
* @example
* shell> yo luke:grits
*
* @author Luke Chavers <[email protected]>
* @created 2016-12-22
*/

var yeoman = require( "yeoman-generator" );

module.exports = yeoman.generators.Base.extend({

initializing : function() {

// Locals
var me = this;

// Compose
me.composeWith("luke:package");
me.composeWith("luke:mit-license");
me.composeWith("luke:readme");
me.composeWith("luke:js");
me.composeWith("luke:editor");
me.composeWith("luke:npm");
me.composeWith("luke:git");
me.composeWith("luke:vagrant");
me.composeWith("luke:mocha");
me.composeWith("luke:scripts");
me.composeWith("luke:bower");
me.composeWith("luke:travis-grits");

},

configuring: function() {
this.log(" ");
}

});
57 changes: 57 additions & 0 deletions generators/pm2/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* This is a "partial" sub-generator that adds PM2 to the project.
*
* @example
* shell> yo luke:pm2
*
* @author Luke Chavers <[email protected]>
* @created 2016-12-22
*/

var yeoman = require( "yeoman-generator" );
var baseGenerator = require("../_BaseGenerator");

module.exports = baseGenerator.extend(
{
prompting : function() {

// Locals
var me = this;

// Initialize the base generator
me._initBase();

me.composeWith("luke:scripts");

},

configuring: {

addProvisioningSteps: function() {

var me = this;

// Add provisioning steps to install PM2 & PM2 Web
me._addVagrantStep("npm-install-pm2");
me._addVagrantStep("npm-install-pm2-web");

}

},

writing : {

createPartialFiles : function() {

var me = this;

// example-app.json
me.fs.copy(
me.templatePath( "core/env/pm2/_example-app.json" ), me.destinationPath( "env/pm2/example-app.json" )
);

}
}

}
);
7 changes: 7 additions & 0 deletions generators/scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,16 @@ module.exports = baseGenerator.extend(
_.each( me._getSharedObjects("script"), function( obj ) {

var cfg = obj.config;

/*
me.fs.copy(
me.templatePath( cfg.src ), me.destinationPath( cfg.dest )
);
*/

me.fs.copyTpl(
me.templatePath( cfg.src ), me.destinationPath( cfg.dest ), cfg
);

});

Expand Down
71 changes: 71 additions & 0 deletions generators/travis-grits/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* This is a "partial" sub-generator that generates a `.travis.yml` file
* with common options for Grits.js deployment.
*
* @example
* shell> yo luke:travis-grits
*
* @author Luke Chavers <[email protected]>
* @created 2016-12-22
*/

var yeoman = require( "yeoman-generator" );
var baseGenerator = require("../_BaseGenerator");

module.exports = baseGenerator.extend(
{
prompting : function() {

// Locals
var me = this;

// Initialize the base generator
me._initBase();

me.composeWith("luke:package");
me.composeWith("luke:grits-scripts");
//me.composeWith("luke:grits-config");

},

default : {

createSharedMetaObjects: function() {

var me = this;

// Add an npm script for running grits on travis
me._createSharedObject(
"script", "grits/render/ci.sh", {
name : "grits-render-ci",
src : "grits/scripts/grits/render/_ci.sh",
dest : "scripts/grits/render/ci.sh"
}
);

}

},

writing : {

createPartialFiles : function() {

var me = this;

// _vars.sh
// todo: move this to its own partial
me.fs.copy(
me.templatePath( "grits/scripts/grits/_vars.sh" ), me.destinationPath( "scripts/grits/_vars.sh" )
);

// .travis.yml
me.fs.copy(
me.templatePath( "grits/_travis.yml" ), me.destinationPath( ".travis.yml" )
);

}
}

}
);
Loading

0 comments on commit 0de692f

Please sign in to comment.