diff --git a/.all-contributorsrc b/.all-contributorsrc
new file mode 100644
index 0000000..54e3256
--- /dev/null
+++ b/.all-contributorsrc
@@ -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"
+ ]
+ }
+ ]
+}
diff --git a/.codecov.yml b/.codecov.yml
index 6aa19e4..ad54ba9 100644
--- a/.codecov.yml
+++ b/.codecov.yml
@@ -1,6 +1,8 @@
comment:
layout: header, changes, diff
coverage:
+ precision: 2
+ round: down
status:
patch: false
codecov:
diff --git a/README.md b/README.md
index 430d9de..22c0bc8 100644
--- a/README.md
+++ b/README.md
@@ -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)
@@ -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)):
+
+
+| [
Eric McCormick](https://ericmccormick.io)
[💻](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) 🚇 💡 |
+| :---: |
+
+
+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.
diff --git a/generators/app/USAGE b/generators/app/USAGE
index fd38604..64c1008 100644
--- a/generators/app/USAGE
+++ b/generators/app/USAGE
@@ -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.
diff --git a/generators/app/index.js b/generators/app/index.js
index 570bc2f..d9d6b60 100644
--- a/generators/app/index.js
+++ b/generators/app/index.js
@@ -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',
@@ -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,
@@ -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);
}
@@ -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;
}
@@ -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;
+ }
}
];
@@ -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'), {
@@ -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'), {
@@ -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(
@@ -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')
diff --git a/generators/bean/index.js b/generators/bean/index.js
index fa2f432..b142f65 100644
--- a/generators/bean/index.js
+++ b/generators/bean/index.js
@@ -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',
@@ -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;
diff --git a/generators/cc/index.js b/generators/cc/index.js
index c420948..cbc5122 100644
--- a/generators/cc/index.js
+++ b/generators/cc/index.js
@@ -7,12 +7,32 @@ 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 to give the newly created Custom Control',
+ type: String,
+ alias: 'n'
+ });
+
+ if (this.options.name) {
+ this.ccname = this.options.name;
+ }
+ }
+
prompting() {
+ updateNotifier({pkg}).notify();
+ const ctx = this;
updateNotifier({pkg}).notify();
var prompts = [{
type: 'input',
name: 'ccname',
- message: 'What shall we call your new Custom Control?'
+ message: 'What shall we call your new Custom Control?',
+ when: function () {
+ return undefined === ctx.ccname;
+ }
}];
return this.prompt(prompts).then(function (props) {
@@ -33,10 +53,6 @@ module.exports = class extends Generator {
}
);
- this.log(yosay(chalk.red('Done') + ` creating the ${this.props.ccname} Custom Control.`));
- }
-
- install() {
- // this.installDependencies();
+ this.log(yosay(chalk.red('Done') + ` creating the ${this.ccname || this.props.ccname} Custom Control.`));
}
};
diff --git a/generators/class/index.js b/generators/class/index.js
index 59f7c83..af5937d 100644
--- a/generators/class/index.js
+++ b/generators/class/index.js
@@ -8,9 +8,51 @@ 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 Class',
+ type: String,
+ alias: 'n'
+ });
+ if (this.options.name) {
+ this.name = this.options.name;
+ }
+
+ this.option('visibility', {
+ desc: 'the name to give the newly created XPage',
+ type: String,
+ alias: 'v'
+ });
+ if (this.options.visibility) {
+ this.visibility = this.options.visibility;
+ }
+
+ this.option('serializable', {
+ desc: 'makes the class implement Serializable',
+ type: Boolean,
+ alias: 's'
+ });
+ if (this.options.serializable) {
+ this.serializable = this.options.serializable;
+ }
+ }
+
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,
+ when: function () {
+ return undefined === ctx.name;
+ }
+ },
{
name: 'visibility',
message: `Specify the class visibility
@@ -34,20 +76,20 @@ module.exports = class extends Generator {
value: 'private'
}
],
- default: 'public'
- },
- {
- name: 'name',
- message: 'Name of the class in Pascal case (aka- UpperCamelCase)',
- required: true,
- type: String
+ default: 'public',
+ when: function () {
+ return undefined === ctx.visibility;
+ }
},
{
name: 'serializable',
message: 'Whether this class implements java.io.Serializable',
required: true,
type: 'confirm',
- default: false
+ default: false,
+ when: function () {
+ return undefined === ctx.serializable;
+ }
}
];
@@ -61,10 +103,11 @@ module.exports = class extends Generator {
writing() {
const odpPath = this.config.get('odpPath') || 'ODP';
// Copy the configuration files
- var vis = this.props.visibility;
- var serialize = this.props.serializable;
- var parts = this.props.name.split('.');
- var name = parts.pop();
+ const vis = this.visibility || this.props.visibility;
+ const serialize = this.serializable || this.props.serializable;
+ const rawName = this.name || this.props.name;
+ const parts = rawName.split('.');
+ const name = parts.pop();
this.props = this.config.getAll();
this.props.package = parts.join('.');
@@ -72,23 +115,19 @@ module.exports = class extends Generator {
this.props.name = name;
this.props.vis = vis;
- var namespace = (this.props.namespace || '').replace(/\./g, '/');
+ const namespace = (this.props.namespace || '').replace(/\./g, '/');
this.fs.copyTpl(
this.templatePath('Class.java'),
- this.destinationPath(path.join(odpPath + '/Code/Java', namespace, this.props.dir, this.props.name + '.java')), {
+ this.destinationPath(path.join(odpPath + '/Code/Java', namespace, this.props.dir, name + '.java')), {
package: this.props.package,
namespace: namespace,
visibility: vis,
- name: this.props.name,
+ name: rawName,
serializable: serialize
}
);
- this.log(yosay(chalk.red('Done') + ` creating the ${this.props.name} Class.`));
- }
-
- install() {
- // this.installDependencies();
+ this.log(yosay(chalk.red('Done') + ` creating the ${rawName} Class.`));
}
};
diff --git a/generators/rest/USAGE b/generators/rest/USAGE
index 7a3b75f..0a643f8 100644
--- a/generators/rest/USAGE
+++ b/generators/rest/USAGE
@@ -1,5 +1,5 @@
Description:
- Creates a new Java class, configured as `implements CustomServiceBean`,
+ Creates a new Java class, configured to implement `CustomServiceBean`,
within the On Disk Project, and creates an `xe:restService` control in an
XPage, `api.xsp`, binding them together, based on the selected options
diff --git a/generators/rest/index.js b/generators/rest/index.js
index 173fe69..cdcad92 100644
--- a/generators/rest/index.js
+++ b/generators/rest/index.js
@@ -10,13 +10,41 @@ const changeCase = require('change-case');
const cheerio = require('cheerio');
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('endpoint', {
+ desc: 'the name to give the newly created RESTful endpoint (ex: "todos" will yield `api.xsp/todos`)',
+ type: String,
+ alias: 'e'
+ });
+ if (this.options.endpoint) {
+ this.endpoint = this.options.endpoint;
+ }
+
+ this.option('contenttype', {
+ desc: 'the content-type to use, such as "application/json", "text/plain", etc.',
+ type: String,
+ alias: 't'
+ });
+ if (this.options.contenttype) {
+ this.contenttype = this.options.contenttype;
+ this.config.set('contenttype', this.contenttype);
+ }
+ }
+
prompting() {
updateNotifier({pkg}).notify();
- var prompts = [
+ const ctx = this;
+ const prompts = [
{
type: 'input',
name: 'endpoint',
- message: 'What endpoint would you like to use?'
+ message: 'What endpoint would you like to use?',
+ when: function () {
+ return undefined === ctx.endpoint;
+ }
},
{
type: 'list',
@@ -28,7 +56,13 @@ module.exports = class extends Generator {
'text/xml'
],
default: 'application/json',
- store: true
+ required: function () {/* istanbul ignore next */
+ return undefined === ctx.contenttype;
+ },
+ store: true,
+ when: function () {
+ return undefined === ctx.contenttype;
+ }
}
];
@@ -43,7 +77,7 @@ module.exports = class extends Generator {
const odpPath = this.config.get('odpPath') || 'ODP';
const vm = this;
const log = vm.log;
- let endpoint = changeCase.camelCase(vm.endpoint) || vm.props.endpoint;
+ const endpoint = changeCase.camelCase(vm.endpoint) || vm.props.endpoint;
// define templating vars
const opt = {
svcName: endpoint,
@@ -52,7 +86,7 @@ module.exports = class extends Generator {
serviceBeanPkg: 'app.rest',
serviceBeanPkgClass: 'app.rest.' + changeCase.pascalCase(endpoint),
serviceBeanPathClass: 'app/rest/' + changeCase.pascalCase(endpoint) + 'ServiceBean.java',
- type: vm.props.contenttype
+ type: vm.contenttype || vm.props.contenttype
};
/* istanbul ignore next */ // ignoring as the tests run async and no guarantee of existing api.xsp
if (fileExists(vm.destinationPath(odpPath + '/XPages/api.xsp'))) {
@@ -64,8 +98,8 @@ module.exports = class extends Generator {
xmlMode: true
});
const add = `
if (er) {
throw er;
}
- log(yosay(
- 'The ' + chalk.red('api.xsp') + ' has been updated!'
- ));
+ log('The ' + chalk.red('api.xsp') + ' has been updated!');
});
});
} else {
@@ -96,7 +128,7 @@ state="false">
vm.templatePath('./_serviceBean.java'),
vm.destinationPath(odpPath + '/Code/Java/' + opt.serviceBeanPathClass), opt
);
- vm.log(yosay(chalk.red('Done') + ` creating the ${vm.props.endpoint} as a Custom Rest Service via Service Bean.`));
+ vm.log(yosay(chalk.red('Done') + ` creating the ${vm.endpoint || vm.props.endpoint} as a Custom Rest Service via Service Bean.`));
}
install() {
diff --git a/generators/xpage/index.js b/generators/xpage/index.js
index 4541f23..3218b6e 100644
--- a/generators/xpage/index.js
+++ b/generators/xpage/index.js
@@ -7,12 +7,32 @@ 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 to give the newly created XPage',
+ type: String,
+ alias: 'n'
+ });
+
+ if (this.options.name) {
+ this.xpagename = this.options.name;
+ }
+ }
+
prompting() {
updateNotifier({pkg}).notify();
+ const ctx = this;
var prompts = [{
type: 'input',
name: 'xpagename',
- message: 'What shall we call your new XPage?'
+ message: 'What shall we call your new XPage?',
+ when: function () {
+ return undefined === ctx.xpagename;
+ }
}];
return this.prompt(prompts).then(function (props) {
@@ -33,10 +53,6 @@ module.exports = class extends Generator {
}
);
- this.log(yosay(chalk.red('Done') + ` creating the ${this.props.ccname} XPage.`));
- }
-
- install() {
- // this.installDependencies();
+ this.log(yosay(chalk.red('Done') + ` creating the ${this.xpagename || this.props.xpagename} XPage.`));
}
};
diff --git a/package.json b/package.json
index 8079302..6771f0b 100644
--- a/package.json
+++ b/package.json
@@ -38,6 +38,7 @@
"yosay": "1.2.1"
},
"devDependencies": {
+ "all-contributors-cli": "3.1.0",
"commitizen": "2.9.5",
"coveralls": "2.11.15",
"cz-conventional-changelog": "1.2.0",
@@ -68,6 +69,8 @@
"url": "https://github.com/edm00se/generator-xsp.git"
},
"scripts": {
+ "add": "all-contributors add",
+ "generate": "all-contributors generate",
"prepublish": "gulp prepublish",
"test": "gulp",
"watch": "gulp watch",
diff --git a/test/app.js b/test/app.js
index 2d448da..56761cd 100644
--- a/test/app.js
+++ b/test/app.js
@@ -8,10 +8,8 @@ describe('generator-xsp:app', function () {
describe('app without bower or npm deps', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/app'))
- .withOptions({
- name: testProjName
- })
.withPrompts({
+ name: testProjName,
basetheme: 'Bootstrap3',
ddeplugins: ['com.ibm.xsp.extlib.library'],
starterResources: false,
@@ -105,7 +103,7 @@ describe('generator-xsp:app', function () {
});
});
- describe('reconfigure existing app to use given ODP path', function () {
+ describe('reconfigure existing app to use given ODP path, via CLI options', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/app'))
.withOptions({
@@ -129,4 +127,69 @@ describe('generator-xsp:app', function () {
]);
});
});
+
+ describe('CLI options power invocation', function () {
+ describe(' basic setup with bower no npm scripts', function () {
+ before(function () {
+ return helpers.run(path.join(__dirname, '../generators/app'))
+ .withOptions({
+ n: testProjName,
+ t: 'webstandard',
+ r: true,
+ 'dde-plugins': 'ExtLib',
+ b: true,
+ 'skip-npm': true,
+ p: 'ODP'
+ })
+ .toPromise();
+ });
+
+ it('creates proper file structure from specified options', function () {
+ assert.file([
+ 'ODP/.project',
+ 'ODP/AppProperties/database.properties',
+ 'ODP/plugin.xml',
+ 'ODP/Resources/IconNote',
+ 'bower.json',
+ 'ODP/Resources/StyleSheets/app.css',
+ 'ODP/Code/ScriptLibraries/app.js',
+ 'ODP/Code/ScriptLibraries/app.jss'
+ ]);
+ assert.noFile([
+ 'package.json'
+ ]);
+ });
+ });
+ describe(' basic setup with npm scripts, no bower, starter resources', function () {
+ before(function () {
+ return helpers.run(path.join(__dirname, '../generators/app'))
+ .withOptions({
+ n: testProjName,
+ t: 'Bootstrap3',
+ 'no-res': true,
+ d: 'ODA',
+ 'skip-bower': true,
+ npm: true,
+ p: 'ODP'
+ })
+ .toPromise();
+ });
+
+ it('creates proper file structure from specified options', function () {
+ assert.file([
+ 'ODP/.project',
+ 'ODP/AppProperties/database.properties',
+ 'ODP/plugin.xml',
+ 'ODP/Resources/IconNote',
+ 'package.json'
+ ]);
+ assert.noFile([
+ 'bower.json',
+ 'ODP/Resources/StyleSheets/app.css',
+ 'ODP/Code/ScriptLibraries/app.js',
+ 'ODP/Code/ScriptLibraries/app.jss'
+ ]);
+ });
+ });
+ });
});
diff --git a/test/bean.js b/test/bean.js
index 7d8fbb1..49fc59d 100644
--- a/test/bean.js
+++ b/test/bean.js
@@ -23,4 +23,24 @@ describe('generator-xsp:bean', function () {
]);
});
});
+
+ describe('CLI options power invocation', function () {
+ const modifier = '6';
+
+ before(function () {
+ return helpers.run(path.join(__dirname, '../generators/bean'))
+ .withOptions({
+ name: testName + modifier,
+ scope: 'session'
+ })
+ .toPromise();
+ });
+
+ it('creates proper file structure from specified options', function () {
+ const fPath = 'ODP/Code/Java/' + testName.replace(/\./g, '/') + modifier + '.java';
+ assert.file([
+ fPath
+ ]);
+ });
+ });
});
diff --git a/test/cc.js b/test/cc.js
index 4f27685..5015f58 100644
--- a/test/cc.js
+++ b/test/cc.js
@@ -16,4 +16,20 @@ describe('generator-xsp:cc', function () {
'ODP/CustomControls/' + testFileName + '.xsp'
]);
});
+
+ describe('CLI options power invocation', function () {
+ before(function () {
+ return helpers.run(path.join(__dirname, '../generators/cc'))
+ .withOptions({
+ name: 'baz'
+ })
+ .toPromise();
+ });
+
+ it('creates proper file structure from specified options', function () {
+ assert.file([
+ 'ODP/CustomControls/baz.xsp'
+ ]);
+ });
+ });
});
diff --git a/test/class.js b/test/class.js
index f7f6add..19f6370 100644
--- a/test/class.js
+++ b/test/class.js
@@ -81,4 +81,28 @@ describe('generator-xsp:class', function () {
]);
});
});
+
+ describe('CLI options power invocation', function () {
+ const modifier = '6';
+
+ before(function () {
+ return helpers.run(path.join(__dirname, '../generators/class'))
+ .withOptions({
+ name: testName + modifier,
+ visibility: 'public',
+ serializable: true
+ })
+ .toPromise();
+ });
+
+ it('creates proper file structure from specified options', function () {
+ const fPath = 'ODP/Code/Java/' + testName.replace(/\./g, '/') + modifier + '.java';
+ assert.file([
+ fPath
+ ]);
+
+ const tmpBuf = fs.readFileSync(fPath);
+ assert(tmpBuf.toString().includes('implements Serializable'));
+ });
+ });
});
diff --git a/test/rest.js b/test/rest.js
index c1a9d20..0f4874c 100644
--- a/test/rest.js
+++ b/test/rest.js
@@ -3,13 +3,13 @@ const path = require('path');
const assert = require('yeoman-assert');
const helpers = require('yeoman-test');
const changeCase = require('change-case');
+const apiXpg = 'ODP/XPages/api.xsp';
describe('generator-xsp:rest', function () {
describe('first CustomRestService bean and endpoint', function () {
const myName = 'stuff';
const myProperName = changeCase.pascalCase(myName);
const fName = 'ODP/Code/Java/app/rest/' + myProperName + 'ServiceBean.java';
- const apiXpg = 'ODP/XPages/api.xsp';
before(() => {
return helpers.run(path.join(__dirname, '../generators/rest'))
@@ -47,7 +47,6 @@ describe('generator-xsp:rest', function () {
const myName = 'things';
const myProperName = changeCase.pascalCase(myName);
const fName = 'ODP/Code/Java/app/rest/' + myProperName + 'ServiceBean.java';
- const apiXpg = 'ODP/XPages/api.xsp';
before(() => {
return helpers.run(path.join(__dirname, '../generators/rest'))
@@ -80,4 +79,41 @@ describe('generator-xsp:rest', function () {
assert.fileContent(apiXpg, `serviceBean="app.rest.${myProperName}ServiceBean"`);
});
});
+
+ describe('CLI options power invocation', function () {
+ const myName = 'gadget';
+ const myProperName = changeCase.pascalCase(myName);
+ const fName = 'ODP/Code/Java/app/rest/' + myProperName + 'ServiceBean.java';
+
+ before(function () {
+ return helpers.run(path.join(__dirname, '../generators/rest'))
+ .withOptions({
+ endpoint: myName,
+ contenttype: 'text/plain'
+ })
+ .toPromise();
+ });
+
+ it('creates specified CustomServiceBean Java class file', () => {
+ assert.file([
+ fName
+ ]);
+
+ assert.fileContent(fName, 'extends CustomServiceBean');
+ });
+
+ it('ensures api.xsp exists', () => {
+ assert.file(apiXpg);
+ });
+
+ it('defines api endpont in api.xsp', () => {
+ assert.fileContent(apiXpg, ' {
+ assert.fileContent(apiXpg, '