Skip to content

Commit c1d0848

Browse files
authored
Merge pull request #149 from microservices-suite/repo-engineering/deletion_automation
Repo engineering/deletion automation
2 parents cd8bbec + 5d9f89b commit c1d0848

File tree

256 files changed

+35541
-27
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

256 files changed

+35541
-27
lines changed

.suite-cli/cli/cli.js

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,12 @@ program
123123
}
124124
])
125125
.then(answers => {
126-
const existing_services = getExistingComponent({ key: 'services', currentDir: cwd() })
126+
let existing_services = []
127+
try {
128+
existing_services = getExistingComponent({ key: 'services', currentDir: cwd() })
129+
} catch (error) {
130+
131+
}
127132
switch (answers.resource) {
128133
case 'monorepo':
129134
// Additional prompts specific to 'monorepo' resource
@@ -231,7 +236,7 @@ program
231236
]).then((answers) => actionHandlers.scaffoldNewLibrary({ answers: { ...answers, private: false } }))
232237
break
233238
case 'app':
234-
const existing_apps = getExistingComponent({ key: 'apps', currentDir: cwd() })
239+
const existing_apps = getExistingComponent({ key: 'apps', currentDir: cwd() })||[]
235240
const formatServiceName = (service) => `${service.name}: ${service.port}`;
236241
prompt([
237242
{
@@ -294,14 +299,20 @@ program
294299
})
295300
break;
296301
case 'gateway':
297-
const all_apps = getExistingApps({ currentDir: cwd() });
302+
const apps = getExistingApps({ currentDir: cwd() });
303+
if(!apps) {
304+
logInfo({ message: `No apps found in this project. You need to have atleast one app to generate a gateway` })
305+
ora().info(`Run 'suite generate' to create one...`)
306+
process.exit(0);
307+
308+
}
298309
const formatAppsName = (app) => app.name;
299310
prompt([
300311
{
301312
type: 'checkbox',
302313
name: 'apps',
303314
message: 'Select apps',
304-
choices: all_apps.map(app => ({
315+
choices: apps.map(app => ({
305316
name: formatAppsName(app),
306317
value: app,
307318
checked: true, // Default all services to be selected
@@ -344,7 +355,17 @@ program
344355
}
345356
});
346357
});
347-
348-
358+
program
359+
.command('remove')
360+
.description('Clean remove a monorepo resource plus all the associated files. No residual files remain behind')
361+
.option('service', 'remove service and associated files')
362+
.option('app', 'remove app and associated files')
363+
.option('library', 'remove library and associated files')
364+
.option('microservice', 'remove microservice and associated files')
365+
.option('gateway', 'remove gateway and associated files')
366+
.action(async (options) => {
367+
console.log({options})
368+
await actionHandlers.dockerPrune({ options })
369+
});
349370
program.parse(process.argv);
350371
module.exports = program

.suite-cli/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@microservices-suite/cli",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"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",
55
"main": "cli.js",
66
"repository": "https://github.com/microservices-suite/node-microservices-suite.git",

.suite-cli/cli/scripts/commands/scaffoldNewService.cmd.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ const { scaffoldNewService, logError } = require('../scripts.module')
33

44
module.exports = async ({ answers }) => {
55
try {
6-
console.log({answers})
7-
86
await scaffoldNewService({ answers });
97
} catch (error) {
108
logError({ error })

.suite-cli/cli/scripts/scripts.module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ const scaffoldGateways = async ({ answers }) => {
16431643
const { projectName } = readFileContent({ currentDir: cwd() });
16441644
let { apps } = answers;
16451645
const project_root = generatRootPath({ currentDir: cwd() });
1646-
const service_objects = getExistingComponent({ key, currentDir: cwd() });
1646+
const service_objects = getExistingComponent({ key:'services', currentDir: cwd() });
16471647
// add port to services in each app eg ['auth']=>[{name:'auth',port:9001}]
16481648
apps = apps.map((app) => {
16491649
app.services.map((name, i) => {

0 commit comments

Comments
 (0)