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
|
? 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
|
## Using Docker Compose
|
||||||
|
|
||||||
Once the files have been generated, just start Docker Compose.
|
Once the files have been generated, just start Docker Compose.
|
||||||
|
@@ -43,7 +43,7 @@ module.exports = class extends Generator {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
when: function (response) {
|
when: function (response) {
|
||||||
return response.httpMode == 'http';
|
return response.httpMode == 'http' || commandProps['httpMode'] == 'http';
|
||||||
},
|
},
|
||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
name: 'clustering',
|
name: 'clustering',
|
||||||
@@ -53,7 +53,7 @@ module.exports = class extends Generator {
|
|||||||
// Enterprise only options
|
// Enterprise only options
|
||||||
{
|
{
|
||||||
when: function (response) {
|
when: function (response) {
|
||||||
return response.alfrescoVersion == 'enterprise';
|
return response.alfrescoVersion == 'enterprise' || commandProps['alfrescoVersion'] == 'enterprise';
|
||||||
},
|
},
|
||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
name: 'insightEngine',
|
name: 'insightEngine',
|
||||||
@@ -62,8 +62,8 @@ module.exports = class extends Generator {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
when: function (response) {
|
when: function (response) {
|
||||||
return response.alfrescoVersion == 'enterprise' &&
|
return (response.alfrescoVersion == 'enterprise' || commandProps['alfrescoVersion'] == 'enterprise') &&
|
||||||
response.insightEngine;
|
(response.insightEngine || commandProps['insightEngine']);
|
||||||
},
|
},
|
||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
name: 'zeppelin',
|
name: 'zeppelin',
|
||||||
@@ -72,8 +72,8 @@ module.exports = class extends Generator {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
when: function (response) {
|
when: function (response) {
|
||||||
return response.alfrescoVersion == 'enterprise' &&
|
return (response.alfrescoVersion == 'enterprise' || commandProps['alfrescoVersion'] == 'enterprise') &&
|
||||||
!response.clustering;
|
(!response.clustering || !commandProps['clustering']);
|
||||||
},
|
},
|
||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
name: 'sharding',
|
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;
|
this.props = props;
|
||||||
|
Object.assign(props, commandProps);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate boilerplate from "templates" folder
|
// 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