Updating createService File
This commit is contained in:
parent
2d48f2ee90
commit
09198a3b35
@ -46,7 +46,8 @@ rmdir node_modules /s /q
|
||||
|
||||
@REM update the Configuration:
|
||||
node .\dist\modules\wamo\cli\generateConfig.js
|
||||
node .\dist\lib\cli\createService.js
|
||||
@REM create the new services
|
||||
node .\dist\lib\cli\createService.js --noFuncs --runInstances --runEveryService --runExtra --layer io-client --log info
|
||||
node .\dist\lib\cli\ioServerService.js -m install
|
||||
|
||||
@REM now reinstall the services
|
||||
|
@ -60,6 +60,46 @@ export async function createService(
|
||||
dest: "outputDir"
|
||||
});
|
||||
|
||||
parser.addArgument(["--noFuncs"], {
|
||||
help: "Prevents using Functions",
|
||||
action: "storeTrue",
|
||||
dest: "noFuncs"
|
||||
});
|
||||
|
||||
parser.addArgument(["--runInstances"], {
|
||||
help: "Run instances provided in a packages.",
|
||||
action: "storeTrue",
|
||||
dest: "runInstances"
|
||||
});
|
||||
|
||||
parser.addArgument(["--runEveryService"], {
|
||||
help: "Run instances provided in a packages.",
|
||||
action: "storeTrue",
|
||||
dest: "runEveryService"
|
||||
});
|
||||
|
||||
parser.addArgument(["--runExtra"], {
|
||||
help: "Runs every instance in an extra Service",
|
||||
action: "storeTrue",
|
||||
dest: "runExtra"
|
||||
});
|
||||
|
||||
parser.addArgument(["--layer"], {
|
||||
help: "Defaultly selects layer to use.",
|
||||
defaultValue: "not-provided",
|
||||
type: "string",
|
||||
dest: "layer"
|
||||
});
|
||||
|
||||
parser.addArgument(["--log"], {
|
||||
help:
|
||||
"Specify the Logger Level of the Services. Defaults to \"info\". Valid values are: " +
|
||||
LoggerLevels.join(", "),
|
||||
defaultValue: "not-provided",
|
||||
type: "string",
|
||||
dest: "logLevel"
|
||||
});
|
||||
|
||||
const args = parser.parseArgs();
|
||||
|
||||
// Define a Logger
|
||||
@ -77,53 +117,83 @@ export async function createService(
|
||||
packages: []
|
||||
};
|
||||
|
||||
const modeSelection = [
|
||||
{
|
||||
const modeSelection = [];
|
||||
const argsToUse: any = {};
|
||||
|
||||
if (!args.noFuncs) {
|
||||
modeSelection.push({
|
||||
type: "confirm",
|
||||
name: "useFunction",
|
||||
message: "Do you want to share Functions",
|
||||
default: false
|
||||
},
|
||||
{
|
||||
});
|
||||
} else {
|
||||
argsToUse.useFunction = false;
|
||||
}
|
||||
|
||||
if (!args.runInstances) {
|
||||
modeSelection.push({
|
||||
type: "confirm",
|
||||
name: "usePackages",
|
||||
name: "detailPackages",
|
||||
message: "Do you want to run instances provided in a package?",
|
||||
default: true
|
||||
},
|
||||
{
|
||||
});
|
||||
} else {
|
||||
argsToUse.detailPackages = false;
|
||||
}
|
||||
|
||||
if (!args.runEveryService) {
|
||||
modeSelection.push({
|
||||
type: "confirm",
|
||||
name: "detailInstances",
|
||||
message:
|
||||
"Do you want to detail, which instance should be hosted as Service?",
|
||||
default: true
|
||||
},
|
||||
{
|
||||
});
|
||||
} else {
|
||||
argsToUse.detailInstances = false;
|
||||
}
|
||||
|
||||
if (!args.runExtra) {
|
||||
modeSelection.push({
|
||||
type: "confirm",
|
||||
name: "runExtra",
|
||||
message: "Do you want to run every selected option as single Service?",
|
||||
default: true
|
||||
},
|
||||
{
|
||||
type: "confirm",
|
||||
name: "runExtra",
|
||||
message: "Do you want to run every selected option as single Service?",
|
||||
default: true
|
||||
},
|
||||
{
|
||||
});
|
||||
} else {
|
||||
argsToUse.runExtra = true;
|
||||
}
|
||||
|
||||
if (args.layer === "not-provided") {
|
||||
modeSelection.push({
|
||||
type: "list",
|
||||
name: "layer",
|
||||
message: "Select the Communication Layer to use",
|
||||
choices: Object.getOwnPropertyNames(validLayers)
|
||||
},
|
||||
{
|
||||
});
|
||||
} else {
|
||||
argsToUse.runExtra = args.layer;
|
||||
}
|
||||
|
||||
if (args.logLevel === "not-provided") {
|
||||
modeSelection.push({
|
||||
type: "list",
|
||||
name: "logLevel",
|
||||
message: "Select the Level of the Logger, to use.",
|
||||
choices: LoggerLevels
|
||||
});
|
||||
} else {
|
||||
argsToUse.logLevel = args.logLevel;
|
||||
}
|
||||
];
|
||||
|
||||
const result = await inquirer.prompt(modeSelection);
|
||||
let result: any = {};
|
||||
|
||||
if (modeSelection.length > 0) {
|
||||
result = await inquirer.prompt(modeSelection);
|
||||
}
|
||||
|
||||
result = Object.assign({}, result, argsToUse);
|
||||
|
||||
if (result.useFunction) {
|
||||
config.functions = (
|
||||
@ -144,7 +214,10 @@ export async function createService(
|
||||
).functions;
|
||||
}
|
||||
|
||||
if (result.usePackages) {
|
||||
// Defaultly assign the default-Packages.
|
||||
config.packages = data.packages;
|
||||
|
||||
if (result.detailPackages) {
|
||||
// Determine the Packages which should be hosted.
|
||||
config.packages = (
|
||||
await inquirer.prompt([
|
||||
@ -162,7 +235,9 @@ export async function createService(
|
||||
}
|
||||
])
|
||||
).packages;
|
||||
}
|
||||
|
||||
// Now, that we know, which package we should use, let us "detail" the instances we should use.
|
||||
if (result.detailInstances) {
|
||||
// Iterate over the Pacakges
|
||||
for (const p of config.packages) {
|
||||
@ -185,7 +260,6 @@ export async function createService(
|
||||
).instances;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const serviceTemplates = runningInLinux
|
||||
? [
|
||||
@ -304,7 +378,7 @@ node {{{pathToFolder}}}\\index.js`)
|
||||
})
|
||||
);
|
||||
|
||||
logger.info("Create Service at ", path);
|
||||
logger.info("Create Service at ", join(path, template.name));
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user