Skip to content
This repository has been archived by the owner on May 2, 2020. It is now read-only.

Commit

Permalink
Merge pull request #68 from edm00se/feat/cli-power-use
Browse files Browse the repository at this point in the history
WIP: CLI Power Use Capabilities
  • Loading branch information
edm00se authored Jan 29, 2017
2 parents 2e99931 + 90b8e44 commit 3428d36
Show file tree
Hide file tree
Showing 18 changed files with 551 additions and 77 deletions.
24 changes: 24 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"projectName": "generator-xsp",
"projectOwner": "edm00se",
"files": [
"README.md"
],
"imageSize": 100,
"commit": true,
"contributors": [
{
"login": "edm00se",
"name": "Eric McCormick",
"avatar_url": "https://avatars.githubusercontent.com/u/622118?v=3",
"profile": "https://ericmccormick.io",
"contributions": [
"code",
"doc",
"test",
"infra",
"example"
]
}
]
}
2 changes: 2 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
comment:
layout: header, changes, diff
coverage:
precision: 2
round: down
status:
patch: false
codecov:
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# generator-xsp
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors)

> a [yeoman](http://yeoman.io/) generator to scaffold an XPages runtime (xsp) compliant On Disk Project (ODP)
Expand Down Expand Up @@ -52,6 +53,17 @@ Available are:

Feel free to report bugs [in Issues](https://github.com/edm00se/generator-xsp/issues), and should you have an addition to the road map, [create a Pull Request to this repo, of just this ReadMe.md](README.md), with what you would like added. If you would like to contribute code, read the [CONTRIBUTING guide](CONTRIBUTING.md), then [create a Pull Request](https://github.com/edm00se/generator-xsp/compare).

## Contributors

Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
| [<img src="https://avatars.githubusercontent.com/u/622118?v=3" width="100px;"/><br /><sub>Eric McCormick</sub>](https://ericmccormick.io)<br />[💻](https://github.com/edm00se/generator-xsp/commits?author=edm00se) [📖](https://github.com/edm00se/generator-xsp/commits?author=edm00se) [⚠️](https://github.com/edm00se/generator-xsp/commits?author=edm00se) 🚇 💡 |
| :---: |
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!

## License

The code in this project governs my unique contributions and is open, free to use and redistribute or modify, for public or private use, without warranty or liability.
Expand Down
2 changes: 1 addition & 1 deletion generators/app/USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Description:
Example:
yo xsp

This will compose a new On Disk Project, default to the ODP in the current
This will compose a new On Disk Project, defaults to the ODP in the current
working directory, to scaffold an application for import into IBM Domino
Designer to generate an actual NSF.

Expand Down
152 changes: 137 additions & 15 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,115 @@ module.exports = class extends Generator {
type: String,
alias: 'n'
});

if (this.options.name) {
this.myAppName = this.options.name;
this.config.set('name', this.myAppName);
}

this.option('basetheme', {
desc: 'the base theme for the app.theme to extend (ex: webstandard, Bootstrap3, etc.)',
type: String,
alias: 't'
});
if (this.options.basetheme) {
this.basetheme = this.options.basetheme;
this.config.set('name', this.basetheme);
}

this.option('starter-resources', {
desc: 'includes starter CSS, JS, SSJS files',
type: Boolean,
alias: 'r'
});
this.option('skip-starter-resources', {
desc: 'skips inclusion of starter CSS, JS, SSJS files (use instead of --starter-resources)',
type: Boolean,
alias: 'no-res'
});
if (this.options['starter-resources']) {
this.starterResources = true;
this.config.set('starterResources', true);
}
if (this.options['skip-starter-resources']) {
this.starterResources = false;
this.config.set('starterResources', false);
}

this.option('dde-plugins', {
desc: 'plugins to enable for the app (ExtLib, ODA, JUnit)',
type: String,
alias: 'd'
});
/* istanbul ignore next */
if (this.option['dde-plugins']) {
let ar = [];
let tmpAr = [];
if (this.option['dde-plugins'].indexOf(',') > -1) {
tmpAr = this.option['dde-plugins'].split(',');
} else {
tmpAr.push(this.option['dde-plugins']);
}
tmpAr.forEach(function (val) {
switch (val) {
case 'ExtLib':
ar.push('com.ibm.xsp.extlib.library');
break;
case 'ODA':
ar.push('org.openntf.domino.xsp.XspLibrary');
break;
case 'JUnit':
ar.push('org.openntf.junit4xpages.Library');
break;
default:
break;
}
});
if (this.options.basetheme) {
if (this.options.basetheme === 'Bootstrap3' || this.options.basetheme === 'Bootstrap3_flat') {
if (ar.indexOf('com.ibm.xsp.extlib.library') < 0) {
ar.push('com.ibm.xsp.extlib.library');
}
}
}
this.ddeplugins = ar;
}

this.option('use-bower', {
desc: 'opts-in to using Bower for client-side dependency management',
type: Boolean,
alias: 'b'
});
this.option('skip-bower', {
desc: 'opts-out of using Bower, use instead of --use-bower',
type: Boolean
});
if (this.options['use-bower']) {
this.useBower = true;
this.config.set('installBower', true);
}
if (this.options['skip-bower']) {
this.useBower = false;
this.config.set('installBower', false);
}

this.option('use-npm', {
desc: 'opts-in to using npm for dependency management and adds a DORA-like xslt cleaning script',
type: Boolean,
alias: 'npm'
});
this.option('skip-npm', {
desc: 'opts-out of using npm, use instead of --use-npm',
type: Boolean
});
if (this.options['use-npm'] && this.options['use-npm'] === true) {
this.useNpm = true;
this.config.set('useNpm', true);
}
if (this.options['skip-npm']) {
this.useNpm = false;
this.config.set('useNpm', false);
}

// This method adds support for a `--set-odp-path` flag
this.option('set-odp-path', {
desc: 'sets On Disk Project path',
Expand All @@ -31,7 +134,7 @@ module.exports = class extends Generator {
default: 'ODP'
});

// This method adds support for a `--set-odp-path` flag
// This method adds support for a `--skip-app-init` flag
this.option('skip-app-init', {
desc: 'skips other setup for a new app, use wth set-odp-path',
type: String,
Expand All @@ -45,7 +148,11 @@ module.exports = class extends Generator {
}

// And you can then access it later; e.g.
this.odpPath = (this.options['set-odp-path'] ? this.options['set-odp-path'] : 'ODP');
this.odpPath = 'ODP';
/* istanbul ignore next */
if (this.options['set-odp-path']) {
this.odpPath = this.options['set-odp-path'];
}
this.config.set('odpPath', this.odpPath);
}

Expand Down Expand Up @@ -87,21 +194,27 @@ module.exports = class extends Generator {
'oneuiv3.0.2'
],
default: 'webstandard',
store: true
store: true,
when: function () {
return undefined === ctx.basetheme;
}
},
{
type: 'confirm',
name: 'starterResources',
message: 'Would you like to include some starter resources in your theme (app file for CSS, JS, SSJS)?',
default: true,
store: true
store: true,
when: function () {
return undefined === ctx.starterResources;
}
},
{
type: 'checkbox',
name: 'ddeplugins',
message: function (answerOb) {
var str = 'What plugins should be included?';
var condition = (answerOb.basetheme === 'Bootstrap3' || answerOb.basetheme === 'Bootstrap3_flat');
let str = 'What plugins should be included?';
const condition = (answerOb.basetheme === 'Bootstrap3' || answerOb.basetheme === 'Bootstrap3_flat');
if (condition) {
str += '\n 🍰 ExtLib pre-selected in order to extend ' + answerOb.basetheme;
}
Expand Down Expand Up @@ -131,27 +244,36 @@ module.exports = class extends Generator {
],
default: /* istanbul ignore next */
function (answerOb) {
var altAr = [];
const altAr = [];
if (answerOb.basetheme === 'Bootstrap3' || answerOb.baseTheme === 'Bootstrap3_flat') {
altAr.push('com.ibm.xsp.extlib.library');
}
return altAr;
},
store: true
store: true,
when: function () {
return undefined === ctx.ddeplugins;
}
},
{
type: 'confirm',
name: 'installBower',
message: 'Would you like to use Bower for dependency management?',
default: false,
store: true
store: true,
when: function () {
return undefined === ctx.useBower;
}
},
{
type: 'confirm',
name: 'useNpm',
message: 'Include npm scripts (clean to perform a la DORA), etc.?',
default: true,
store: true
store: true,
when: function () {
return undefined === ctx.useNpm;
}
}
];

Expand All @@ -172,7 +294,7 @@ module.exports = class extends Generator {
this.config.set('useExtLib', false);
}
/* istanbul ignore else */
if (this.props.useNpm) {
if (this.props.useNpm || this.useNpm) {
this.fs.copyTpl(
this.templatePath('_package.json'),
this.destinationPath('package.json'), {
Expand All @@ -185,7 +307,7 @@ module.exports = class extends Generator {
);
}
// Only load Bower files if requested
if (this.props.installBower) {
if (this.props.installBower || this.useBower) {
this.fs.copyTpl(
this.templatePath('_bower.json'),
this.destinationPath('bower.json'), {
Expand Down Expand Up @@ -244,7 +366,7 @@ module.exports = class extends Generator {
this.templatePath('_app.theme'),
this.destinationPath(this.odpPath + '/Resources/Themes/app.theme'), {
basetheme: this.props.basetheme,
starterResources: this.props.starterResources
starterResources: this.props.starterResources || this.starterResources
}
);
this.fs.copyTpl(
Expand All @@ -253,7 +375,7 @@ module.exports = class extends Generator {
ddeplugins: this.props.ddeplugins
}
);
if (this.props.starterResources === true) {
if (this.props.starterResources === true || this.starterResources) {
this.fs.copyTpl(
this.templatePath('_app.css'),
this.destinationPath(this.odpPath + '/Resources/StyleSheets/app.css')
Expand Down
53 changes: 43 additions & 10 deletions generators/bean/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,52 @@ const updateNotifier = require('update-notifier');
const pkg = require('../../package.json');

module.exports = class extends Generator {
constructor(args, opts) {
// Calling the super constructor is important so our generator is correctly set up
super(args, opts);

this.option('name', {
desc: 'the name, in Pascal case (aka- UpperCamelCase), to give the newly created managed bean',
type: String,
alias: 'n'
});
if (this.options.name) {
this.name = this.options.name;
}

this.option('scope', {
desc: 'the scope to give the newly created managed bean',
type: String,
alias: 's'
});
if (this.options.scope) {
this.scope = this.options.scope;
}
}

prompting() {
updateNotifier({pkg}).notify();
var prompts = [
const ctx = this;
const prompts = [
{
name: 'name',
message: 'Name of the class in Pascal case (aka- UpperCamelCase)',
required: true,
type: String
type: String,
when: function () {
return undefined === ctx.name;
}
},
{
name: 'scope',
message: 'Scope to put managed bean into',
required: true,
required: function () {/* istanbul ignore next */
return undefined === ctx.scope;
},
type: 'list',
when: function () {
return undefined === ctx.scope;
},
choices: [
{
name: 'request',
Expand Down Expand Up @@ -56,20 +88,21 @@ module.exports = class extends Generator {
// Writing Logic
writing() {
// Copy the configuration files
var scope = this.props.scope;
var parts = this.props.name.split('.');
var name = parts.pop();
var log = this.log;
const scope = this.scope || this.props.scope;
const rawName = this.name || this.props.name;
const parts = rawName.split('.');
const name = parts.pop();
const log = this.log;
const odpPath = this.config.get('odpPath') || 'ODP';

this.props = this.config.getAll();
this.props.package = parts.join('.');
var pkg = this.props.package;
const pkg = this.props.package;
this.props.dir = parts.join('/');
this.props.name = name;
var lCaseName = changeCase.lowerCase(this.props.name);
const lCaseName = changeCase.lowerCase(this.props.name);

var namespace = (this.props.namespace || '').replace(/\./g, '/');
const namespace = (this.props.namespace || '').replace(/\./g, '/');

const exlib = this.config.get('useExtLib') || false;

Expand Down
Loading

0 comments on commit 3428d36

Please sign in to comment.