feat(mod_standard): Add interactive main menu and help to standard CLI module; route commands via dynamic imports
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-12-14 - 2.5.0 - feat(mod_standard)
|
||||
Add interactive main menu and help to standard CLI module; route commands via dynamic imports
|
||||
|
||||
- Introduce interactive CLI menu using @push.rocks/smartinteract to prompt user for actions.
|
||||
- Add routing to commands (commit, format, config, template, services, open, help) using dynamic imports.
|
||||
- Add showHelp() helper to display usage and available commands.
|
||||
- Remove previous static template listing and logger.warn placeholder.
|
||||
|
||||
## 2025-12-14 - 2.4.0 - feat(cli)
|
||||
Add optional build step to release flow and auto-format npmextra config when registries change
|
||||
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@git.zone/cli',
|
||||
version: '2.4.0',
|
||||
version: '2.5.0',
|
||||
description: 'A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.'
|
||||
}
|
||||
|
||||
@@ -7,38 +7,85 @@ import * as paths from '../paths.js';
|
||||
import { logger } from '../gitzone.logging.js';
|
||||
|
||||
export let run = async () => {
|
||||
const done = plugins.smartpromise.defer();
|
||||
logger.log('warn', 'no action specified');
|
||||
console.log('');
|
||||
console.log('╭─────────────────────────────────────────────────────────────╮');
|
||||
console.log('│ gitzone - Development Workflow CLI │');
|
||||
console.log('╰─────────────────────────────────────────────────────────────╯');
|
||||
console.log('');
|
||||
|
||||
const dirEntries = await plugins.smartfs.directory(paths.templatesDir).list();
|
||||
const templates: string[] = [];
|
||||
for (const entry of dirEntries) {
|
||||
try {
|
||||
const stats = await plugins.smartfs
|
||||
.file(plugins.path.join(paths.templatesDir, entry.path))
|
||||
.stat();
|
||||
if (stats.isDirectory) {
|
||||
templates.push(entry.name);
|
||||
}
|
||||
} catch {
|
||||
// Skip entries that can't be accessed
|
||||
const interactInstance = new plugins.smartinteract.SmartInteract();
|
||||
const response = await interactInstance.askQuestion({
|
||||
type: 'list',
|
||||
name: 'action',
|
||||
message: 'What would you like to do?',
|
||||
default: 'commit',
|
||||
choices: [
|
||||
{ name: 'Commit changes (semantic versioning)', value: 'commit' },
|
||||
{ name: 'Format project files', value: 'format' },
|
||||
{ name: 'Configure release settings', value: 'config' },
|
||||
{ name: 'Create from template', value: 'template' },
|
||||
{ name: 'Manage dev services (MongoDB, S3)', value: 'services' },
|
||||
{ name: 'Open project assets', value: 'open' },
|
||||
{ name: 'Show help', value: 'help' },
|
||||
],
|
||||
});
|
||||
|
||||
const action = (response as any).value;
|
||||
|
||||
switch (action) {
|
||||
case 'commit': {
|
||||
const modCommit = await import('../mod_commit/index.js');
|
||||
await modCommit.run({ _: ['commit'] });
|
||||
break;
|
||||
}
|
||||
case 'format': {
|
||||
const modFormat = await import('../mod_format/index.js');
|
||||
await modFormat.run({ interactive: true });
|
||||
break;
|
||||
}
|
||||
case 'config': {
|
||||
const modConfig = await import('../mod_config/index.js');
|
||||
await modConfig.run({ _: ['config'] });
|
||||
break;
|
||||
}
|
||||
case 'template': {
|
||||
const modTemplate = await import('../mod_template/index.js');
|
||||
await modTemplate.run({ _: ['template'] });
|
||||
break;
|
||||
}
|
||||
case 'services': {
|
||||
const modServices = await import('../mod_services/index.js');
|
||||
await modServices.run({ _: ['services'] });
|
||||
break;
|
||||
}
|
||||
case 'open': {
|
||||
const modOpen = await import('../mod_open/index.js');
|
||||
await modOpen.run({ _: ['open'] });
|
||||
break;
|
||||
}
|
||||
case 'help':
|
||||
showHelp();
|
||||
break;
|
||||
}
|
||||
|
||||
let projects = `\n`;
|
||||
for (const template of templates) {
|
||||
projects += ` - ${template}\n`;
|
||||
}
|
||||
|
||||
logger.log(
|
||||
'info',
|
||||
`
|
||||
You can do one of the following things:
|
||||
* create a new project with 'gitzone template [template]'
|
||||
the following templates exist: ${projects}
|
||||
* format a project with 'gitzone format'
|
||||
`,
|
||||
);
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
function showHelp(): void {
|
||||
console.log('');
|
||||
console.log('Usage: gitzone <command> [options]');
|
||||
console.log('');
|
||||
console.log('Commands:');
|
||||
console.log(' commit Create a semantic commit with versioning');
|
||||
console.log(' format Format and standardize project files');
|
||||
console.log(' config Manage release registry configuration');
|
||||
console.log(' template Create a new project from template');
|
||||
console.log(' services Manage dev services (MongoDB, S3/MinIO)');
|
||||
console.log(' open Open project assets (GitLab, npm, etc.)');
|
||||
console.log(' docker Docker-related operations');
|
||||
console.log(' deprecate Deprecate a package on npm');
|
||||
console.log(' meta Run meta commands');
|
||||
console.log(' start Start working on a project');
|
||||
console.log(' helpers Run helper utilities');
|
||||
console.log('');
|
||||
console.log('Run gitzone <command> --help for more information on a command.');
|
||||
console.log('');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user