# Adding and removing microapps

Incremental scaffolding, project updates, and manual removal using the commands that actually exist.

<span id="añadir-una-aplicación"></span>

<span class="section-anchor" id="section-1"></span>

## Adding an application

```bash
wu add vue explorador --no-install
wu add react busqueda --no-install
wu install
```

Run `add` from the project root. The two positional arguments are **framework and name**, in that order. The only recognized option is `--no-install`, which lets you generate several apps and install their dependencies once at the end.

Without `--no-install`, `add` uses the same aggregator and writer as `wu install`, preserves root fields and propagates npm failures. If the root manifest has no `_wu`, it stops before generating; use `--no-install` to declare dependencies manually or adopt the manifest with `wu install --force`.

<span id="qué-escribe"></span>

<span class="section-anchor" id="section-2"></span>

## What it writes

1. Validates the framework and name, and checks that the directory does not exist.
2. Finds a free port after the highest one used by apps; if none remains, searches from 5001. Avoids shell and proxy ports.
3. Generates `mf-<name>/` with `package.json`, an entrypoint, a component, and framework configuration. It does not write a source `wu.json`.
4. If the configuration came from `wu.config.json`, adds the new app and rewrites the file.
5. Aggregates shell and app declarations into the managed root manifest.
6. Installs with npm unless `--no-install` was supplied.

Declare specific dependencies in the app or shell that consumes them. `add` preserves custom configuration and extends `shared` from the catalog. JSON errors include line and column; they do not replace broken configuration with a new file.

<span id="nombres-y-typescript"></span>

<span class="section-anchor" id="section-3"></span>

## Names and TypeScript

`wu add react mf-checkout` removes the supplied prefix and generates `mf-checkout/`; it does not duplicate `mf-`. The same applies to the `mf_` prefix. An empty name or one consisting only of that prefix is rejected. An existing directory also causes an error.

The command enables TypeScript when `supportsTs` supports it, matching the quick mode of `create`. HTMX, Alpine, and Stimulus remain JavaScript. There is no `add` option to select JavaScript for the other templates.

<span id="integrar-una-aplicación-existente"></span>

<span class="section-anchor" id="section-4"></span>

## Integrating an existing application

`add` generates a new application. To integrate an existing one, declare an entry in `apps` with its `name`, `dir`, `framework`, port, and commands; adapt its entrypoint to WU registration and check `wu.json`. Then run `wu install`, `wu info`, and `wu build`, and verify mounting in the browser.

The name identifies the app in the runtime catalog. The directory locates files and resolves dependency overrides. If you change one, review the consumers of that field instead of assuming they are interchangeable.

<span id="retirar-o-renombrar"></span>

<span class="section-anchor" id="section-5"></span>

## Removing or renaming

This version implements neither `wu remove` nor a rename command. Removal requires deleting the entry from `apps`, updating navigation and mounting references, and running `wu install` to recalculate dependencies and overrides. You can archive or remove the directory after reviewing these references.

Renaming requires keeping the directory, `wu.config.json`, the adapter's registered name, `wu.json`, and the identifiers used by the shell consistent. Run `wu doctor` to find stale directory references, and rebuild before publishing.

<span id="limitaciones-observadas"></span>

<span class="section-anchor" id="section-6"></span>

## Observed limitations

Without `wu.config.json`, `add` uses discovery to calculate dependencies and ports but does not write a new configuration. Prefer an explicitly created project for a stable topology. A failed scaffold write removes the new directory; a later installation failure is reported with exit code `1`.

<span id="referencia-de-implementación"></span>

<span class="section-anchor" id="section-7"></span>

## Implementation references

- `wu-cli/src/commands/add.zig`
- `wu-cli/src/commands/install.zig`
- `wu-cli/src/config/names.zig`
- `wu-cli/tests/scaffold-writers.test.cjs`
- `wu-cli/tests/scaffold-security.test.cjs`