Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions .suite-cli/cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ program
}
])
.then(answers => {
const existing_services = getExistingComponent({ key: 'services', currentDir: cwd() })
let existing_services = []
try {
existing_services = getExistingComponent({ key: 'services', currentDir: cwd() })
} catch (error) {

}
switch (answers.resource) {
case 'monorepo':
// Additional prompts specific to 'monorepo' resource
Expand Down Expand Up @@ -231,7 +236,7 @@ program
]).then((answers) => actionHandlers.scaffoldNewLibrary({ answers: { ...answers, private: false } }))
break
case 'app':
const existing_apps = getExistingComponent({ key: 'apps', currentDir: cwd() })
const existing_apps = getExistingComponent({ key: 'apps', currentDir: cwd() })||[]
const formatServiceName = (service) => `${service.name}: ${service.port}`;
prompt([
{
Expand Down Expand Up @@ -294,14 +299,20 @@ program
})
break;
case 'gateway':
const all_apps = getExistingApps({ currentDir: cwd() });
const apps = getExistingApps({ currentDir: cwd() });
if(!apps) {
logInfo({ message: `No apps found in this project. You need to have atleast one app to generate a gateway` })
ora().info(`Run 'suite generate' to create one...`)
process.exit(0);

}
const formatAppsName = (app) => app.name;
prompt([
{
type: 'checkbox',
name: 'apps',
message: 'Select apps',
choices: all_apps.map(app => ({
choices: apps.map(app => ({
name: formatAppsName(app),
value: app,
checked: true, // Default all services to be selected
Expand Down Expand Up @@ -344,7 +355,17 @@ program
}
});
});


program
.command('remove')
.description('Clean remove a monorepo resource plus all the associated files. No residual files remain behind')
.option('service', 'remove service and associated files')
.option('app', 'remove app and associated files')
.option('library', 'remove library and associated files')
.option('microservice', 'remove microservice and associated files')
.option('gateway', 'remove gateway and associated files')
.action(async (options) => {
console.log({options})
await actionHandlers.dockerPrune({ options })
});
program.parse(process.argv);
module.exports = program
2 changes: 1 addition & 1 deletion .suite-cli/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microservices-suite/cli",
"version": "3.0.0",
"version": "3.0.1",
"description": "This is the CLI tool for running the microservices-suite monorepo. It contains functionalities and tools required for automation and managing the repo across supported platforms. Works on Windows,MacOS and Linux as well as support to some extend other variants like SunOS, IBM AIX, FreeBSD, OpenBSD and more",
"main": "cli.js",
"repository": "https://github.com/microservices-suite/node-microservices-suite.git",
Expand Down
2 changes: 0 additions & 2 deletions .suite-cli/cli/scripts/commands/scaffoldNewService.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ const { scaffoldNewService, logError } = require('../scripts.module')

module.exports = async ({ answers }) => {
try {
console.log({answers})

await scaffoldNewService({ answers });
} catch (error) {
logError({ error })
Expand Down
2 changes: 1 addition & 1 deletion .suite-cli/cli/scripts/scripts.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,7 @@ const scaffoldGateways = async ({ answers }) => {
const { projectName } = readFileContent({ currentDir: cwd() });
let { apps } = answers;
const project_root = generatRootPath({ currentDir: cwd() });
const service_objects = getExistingComponent({ key, currentDir: cwd() });
const service_objects = getExistingComponent({ key:'services', currentDir: cwd() });
// add port to services in each app eg ['auth']=>[{name:'auth',port:9001}]
apps = apps.map((app) => {
app.services.map((name, i) => {
Expand Down
Loading