mirror of
https://github.com/Alfresco/SearchServices.git
synced 2025-09-10 14:11:25 +00:00
Add command line passing parameters to allow this program be run without human interaction.
This commit is contained in:
@@ -96,6 +96,25 @@ When using Enterprise, some different options can be combined:
|
||||
? Would you like to use dynamic Sharding (2 SOLR nodes)? Yes
|
||||
```
|
||||
|
||||
## Passing parameters from command line
|
||||
|
||||
Default values for options can be specified in the command line, using a `--name=value` pattern. When an options is specified in the command line, the question is not prompted to the user, so you can generate a Docker Compose template with no user interaction.
|
||||
|
||||
```
|
||||
$ yo alfresco-docker-compose --acsVersion=6.1 --alfrescoVersion=community --httpMode=http --clustering=true
|
||||
```
|
||||
|
||||
**Parameter names reference**
|
||||
|
||||
`--acsVersion`: currently only accepting 6.1
|
||||
`--alfrescoVersion`: community or enterprise
|
||||
`--httpMode`: http or https
|
||||
`--clustering`: true or false
|
||||
`--insightEngine`: true or false
|
||||
`--zeppelin`: true or false
|
||||
`--sharding`: true or false
|
||||
|
||||
|
||||
## Using Docker Compose
|
||||
|
||||
Once the files have been generated, just start Docker Compose.
|
||||
|
@@ -43,7 +43,7 @@ module.exports = class extends Generator {
|
||||
},
|
||||
{
|
||||
when: function (response) {
|
||||
return response.httpMode == 'http';
|
||||
return response.httpMode == 'http' || commandProps['httpMode'] == 'http';
|
||||
},
|
||||
type: 'confirm',
|
||||
name: 'clustering',
|
||||
@@ -53,7 +53,7 @@ module.exports = class extends Generator {
|
||||
// Enterprise only options
|
||||
{
|
||||
when: function (response) {
|
||||
return response.alfrescoVersion == 'enterprise';
|
||||
return response.alfrescoVersion == 'enterprise' || commandProps['alfrescoVersion'] == 'enterprise';
|
||||
},
|
||||
type: 'confirm',
|
||||
name: 'insightEngine',
|
||||
@@ -62,8 +62,8 @@ module.exports = class extends Generator {
|
||||
},
|
||||
{
|
||||
when: function (response) {
|
||||
return response.alfrescoVersion == 'enterprise' &&
|
||||
response.insightEngine;
|
||||
return (response.alfrescoVersion == 'enterprise' || commandProps['alfrescoVersion'] == 'enterprise') &&
|
||||
(response.insightEngine || commandProps['insightEngine']);
|
||||
},
|
||||
type: 'confirm',
|
||||
name: 'zeppelin',
|
||||
@@ -72,8 +72,8 @@ module.exports = class extends Generator {
|
||||
},
|
||||
{
|
||||
when: function (response) {
|
||||
return response.alfrescoVersion == 'enterprise' &&
|
||||
!response.clustering;
|
||||
return (response.alfrescoVersion == 'enterprise' || commandProps['alfrescoVersion'] == 'enterprise') &&
|
||||
(!response.clustering || !commandProps['clustering']);
|
||||
},
|
||||
type: 'confirm',
|
||||
name: 'sharding',
|
||||
@@ -82,9 +82,24 @@ module.exports = class extends Generator {
|
||||
}
|
||||
];
|
||||
|
||||
return this.prompt(prompts).then(props => {
|
||||
// Read options from command line parameters
|
||||
const filteredPrompts = [];
|
||||
const commandProps = new Map();
|
||||
prompts.forEach(function prompts(prompt) {
|
||||
const option = this.options[prompt.name];
|
||||
if (option === undefined) {
|
||||
filteredPrompts.push(prompt);
|
||||
} else {
|
||||
commandProps[prompt.name] = normalize(option);
|
||||
}
|
||||
}, this);
|
||||
|
||||
// Prompt only for parameters not passed by command line
|
||||
return this.prompt(filteredPrompts).then(props => {
|
||||
this.props = props;
|
||||
Object.assign(props, commandProps);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Generate boilerplate from "templates" folder
|
||||
@@ -231,3 +246,24 @@ module.exports = class extends Generator {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Convert parameter string value to boolean value
|
||||
function normalize(option) {
|
||||
|
||||
if (typeof option === 'boolean') {
|
||||
return option;
|
||||
}
|
||||
|
||||
if (typeof option === 'string'){
|
||||
let lc = option.toLowerCase();
|
||||
if (lc === 'true' || lc === 'false') {
|
||||
return (lc === 'true');
|
||||
} else {
|
||||
return option;
|
||||
}
|
||||
}
|
||||
|
||||
return option;
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user