Skip to content

Commit f262866

Browse files
feat(cli): Add unified Angular/React support with MCP integration and bug fixes
This commit introduces comprehensive Angular and React CLI support into the unified @sourceloop/cli package, along with critical bug fixes to the MCP server implementation. ## New Features ### Angular Commands (4) - `angular:scaffold` - Scaffold Angular projects from ARC boilerplate - `angular:generate` - Generate components, services, modules, directives, pipes, guards - `angular:config` - Update Angular environment configuration files - `angular:info` - Display Angular project information and statistics ### React Commands (4) - `react:scaffold` - Scaffold React projects from ARC boilerplate - `react:generate` - Generate components, hooks, contexts, pages, services, utils, Redux slices - `react:config` - Update React .env and config.json files - `react:info` - Display React project information and statistics ### Utility Classes - `FileGenerator` - Shared file generation and project manipulation utilities - `McpConfigInjector` - Automatic MCP configuration injection into scaffolded projects - `TemplateFetcher` - Smart template fetching with GitHub and local path support ### Architecture - **Unified CLI**: Single package (~8MB) vs separate packages (~208MB total) - **Dynamic Templates**: Fetch templates from GitHub on-demand, no vendored templates - **MCP Integration**: All 13 commands (5 backend + 4 Angular + 4 React) exposed via single MCP server - **Auto MCP Injection**: Scaffolded projects automatically get .claude/mcp.json configuration ## Bug Fixes (MCP Server) 1. **Fix hookProcessMethods called in loop** (mcp.ts:95) - Moved hookProcessMethods() call outside forEach loop - Previously hooked process methods multiple times (once per command) - Now hooks once before registering tools 2. **Fix console.error log level** (mcp.ts:156) - Changed from 'debug' to 'error' level for console.error messages - Ensures errors are properly categorized in MCP client logs 3. **Fix console.log not actually logging** (mcp.ts:178) - Added missing originalLog(...args) call - Previously intercepted but didn't execute original console.log - Now properly logs to both MCP client and console 4. **Fix argToZod optional handling** (mcp.ts:183) - Now correctly marks non-required args as optional - Returns arg.required ? option : option.optional() - Fixes validation errors for optional command arguments ## Technical Details ### Package Size Comparison - Option 1 (Separate packages): ~208MB total across 3 packages - Option 2 (Vendored templates): ~208MB single package - **Option 3 (Dynamic fetching)**: **~8MB** single package (96% reduction) ### Command Organization - Backend: `sl <command>` (scaffold, microservice, extension, cdk, update) - Angular: `sl angular:<command>` (scaffold, generate, config, info) - React: `sl react:<command>` (scaffold, generate, config, info) ### MCP Server - Single server exposes all 13 commands as tools - AI assistants can invoke any command via MCP protocol - Unified configuration: `npx @sourceloop/cli mcp` ## Testing - All existing tests passing - MCP integration tests passing (2/2) - Build successful with zero TypeScript errors ## Documentation - Added comprehensive TDD.md explaining architecture decisions - Detailed comparison of 3 architectural approaches - Implementation details and future enhancements 📦 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 3b42d44 commit f262866

File tree

14 files changed

+3890
-19
lines changed

14 files changed

+3890
-19
lines changed

packages/cli/README.md

Lines changed: 192 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ $ npm install -g @sourceloop/cli
2020
$ sl COMMAND
2121
running command...
2222
$ sl (-v|--version|version)
23-
@sourceloop/cli/12.0.0 linux-x64 node-v20.19.5
23+
@sourceloop/cli/12.0.0 darwin-arm64 node-v20.18.2
2424
$ sl --help [COMMAND]
2525
USAGE
2626
$ sl COMMAND
@@ -31,15 +31,118 @@ USAGE
3131
## Commands
3232

3333
<!-- commands -->
34+
* [`sl angular:config`](#sl-angularconfig)
35+
* [`sl angular:generate [NAME]`](#sl-angulargenerate-name)
36+
* [`sl angular:info`](#sl-angularinfo)
37+
* [`sl angular:scaffold [NAME]`](#sl-angularscaffold-name)
3438
* [`sl autocomplete [SHELL]`](#sl-autocomplete-shell)
3539
* [`sl cdk`](#sl-cdk)
3640
* [`sl extension [NAME]`](#sl-extension-name)
3741
* [`sl help [COMMAND]`](#sl-help-command)
3842
* [`sl mcp`](#sl-mcp)
3943
* [`sl microservice [NAME]`](#sl-microservice-name)
44+
* [`sl react:config`](#sl-reactconfig)
45+
* [`sl react:generate [NAME]`](#sl-reactgenerate-name)
46+
* [`sl react:info`](#sl-reactinfo)
47+
* [`sl react:scaffold [NAME]`](#sl-reactscaffold-name)
4048
* [`sl scaffold [NAME]`](#sl-scaffold-name)
4149
* [`sl update`](#sl-update)
4250

51+
## `sl angular:config`
52+
53+
Update Angular environment configuration files
54+
55+
```
56+
USAGE
57+
$ sl angular:config
58+
59+
OPTIONS
60+
--apiUrl=apiUrl Base API URL
61+
--authServiceUrl=authServiceUrl Authentication service URL
62+
--clientId=clientId OAuth client ID
63+
--environment=(development|production|staging) [default: development] Environment to update
64+
--help Show manual pages
65+
--publicKey=publicKey Public key for authentication
66+
```
67+
68+
_See code: [src/commands/angular/config.ts](https://github.com/sourcefuse/loopback4-microservice-catalog/blob/v12.0.0/src/commands/angular/config.ts)_
69+
70+
## `sl angular:generate [NAME]`
71+
72+
Generate Angular components, services, modules, and other artifacts
73+
74+
```
75+
USAGE
76+
$ sl angular:generate [NAME]
77+
78+
ARGUMENTS
79+
NAME Name of the artifact to generate
80+
81+
OPTIONS
82+
--help Show manual pages
83+
84+
--path=path Path where the artifact should be generated (relative to
85+
project src/app)
86+
87+
--project=project [default: arc] Angular project name (arc, arc-lib, arc-docs,
88+
saas-ui)
89+
90+
--skipTests Skip generating test files
91+
92+
--standalone Generate as a standalone component (Angular 14+)
93+
94+
--type=(component|service|module|directive|pipe|guard) Type of artifact to generate
95+
```
96+
97+
_See code: [src/commands/angular/generate.ts](https://github.com/sourcefuse/loopback4-microservice-catalog/blob/v12.0.0/src/commands/angular/generate.ts)_
98+
99+
## `sl angular:info`
100+
101+
Display Angular project information and statistics
102+
103+
```
104+
USAGE
105+
$ sl angular:info
106+
107+
OPTIONS
108+
--detailed Show detailed statistics
109+
--help Show manual pages
110+
```
111+
112+
_See code: [src/commands/angular/info.ts](https://github.com/sourcefuse/loopback4-microservice-catalog/blob/v12.0.0/src/commands/angular/info.ts)_
113+
114+
## `sl angular:scaffold [NAME]`
115+
116+
Scaffold a new Angular project from ARC boilerplate
117+
118+
```
119+
USAGE
120+
$ sl angular:scaffold [NAME]
121+
122+
ARGUMENTS
123+
NAME Name of the project
124+
125+
OPTIONS
126+
--help Show manual pages
127+
--installDeps Install dependencies after scaffolding
128+
--localPath=localPath Local path to template (for development)
129+
130+
--templateRepo=templateRepo [default: sourcefuse/angular-boilerplate] Custom template repository (e.g.,
131+
sourcefuse/angular-boilerplate)
132+
133+
--templateVersion=templateVersion Template version/branch to use
134+
135+
--withAuth Include authentication module
136+
137+
--withBreadcrumbs Include breadcrumb navigation
138+
139+
--withI18n Include internationalization
140+
141+
--withThemes Include theme system
142+
```
143+
144+
_See code: [src/commands/angular/scaffold.ts](https://github.com/sourcefuse/loopback4-microservice-catalog/blob/v12.0.0/src/commands/angular/scaffold.ts)_
145+
43146
## `sl autocomplete [SHELL]`
44147

45148
display autocomplete installation instructions
@@ -193,6 +296,94 @@ OPTIONS
193296

194297
_See code: [src/commands/microservice.ts](https://github.com/sourcefuse/loopback4-microservice-catalog/blob/v12.0.0/src/commands/microservice.ts)_
195298

299+
## `sl react:config`
300+
301+
Update React environment configuration
302+
303+
```
304+
USAGE
305+
$ sl react:config
306+
307+
OPTIONS
308+
--appApiBaseUrl=appApiBaseUrl Application API base URL
309+
--authApiBaseUrl=authApiBaseUrl Authentication API base URL
310+
--clientId=clientId OAuth client ID
311+
--enableSessionTimeout Enable session timeout
312+
--expiryTimeInMinute=expiryTimeInMinute Session timeout in minutes
313+
--help Show manual pages
314+
--promptTimeBeforeIdleInMinute=promptTimeBeforeIdleInMinute Prompt time before idle in minutes
315+
--regenerate Regenerate config.json after updating .env
316+
```
317+
318+
_See code: [src/commands/react/config.ts](https://github.com/sourcefuse/loopback4-microservice-catalog/blob/v12.0.0/src/commands/react/config.ts)_
319+
320+
## `sl react:generate [NAME]`
321+
322+
Generate React components, hooks, contexts, pages, and other artifacts
323+
324+
```
325+
USAGE
326+
$ sl react:generate [NAME]
327+
328+
ARGUMENTS
329+
NAME Name of the artifact to generate
330+
331+
OPTIONS
332+
--help Show manual pages
333+
--path=path Path where the artifact should be generated
334+
--skipTests Skip generating test files
335+
--type=(component|hook|context|page|service|util|slice) Type of artifact to generate
336+
```
337+
338+
_See code: [src/commands/react/generate.ts](https://github.com/sourcefuse/loopback4-microservice-catalog/blob/v12.0.0/src/commands/react/generate.ts)_
339+
340+
## `sl react:info`
341+
342+
Display React project information and statistics
343+
344+
```
345+
USAGE
346+
$ sl react:info
347+
348+
OPTIONS
349+
--detailed Show detailed statistics
350+
--help Show manual pages
351+
```
352+
353+
_See code: [src/commands/react/info.ts](https://github.com/sourcefuse/loopback4-microservice-catalog/blob/v12.0.0/src/commands/react/info.ts)_
354+
355+
## `sl react:scaffold [NAME]`
356+
357+
Scaffold a new React project from ARC boilerplate
358+
359+
```
360+
USAGE
361+
$ sl react:scaffold [NAME]
362+
363+
ARGUMENTS
364+
NAME Name of the project
365+
366+
OPTIONS
367+
--help Show manual pages
368+
--installDeps Install dependencies after scaffolding
369+
--localPath=localPath Local path to template (for development)
370+
371+
--templateRepo=templateRepo [default: sourcefuse/react-boilerplate-ts-ui] Custom template repository (e.g.,
372+
sourcefuse/react-boilerplate-ts-ui)
373+
374+
--templateVersion=templateVersion Template version/branch to use
375+
376+
--withAuth Include authentication module
377+
378+
--withRedux Include Redux Toolkit state management
379+
380+
--withRouting Include React Router
381+
382+
--withThemes Include Material-UI theme system
383+
```
384+
385+
_See code: [src/commands/react/scaffold.ts](https://github.com/sourcefuse/loopback4-microservice-catalog/blob/v12.0.0/src/commands/react/scaffold.ts)_
386+
196387
## `sl scaffold [NAME]`
197388

198389
Setup a ARC based monorepo using npm workspaces with an empty services, facades and packages folder

0 commit comments

Comments
 (0)