# @moodia/ws-schematics-remotes

Provisional Node CLI for building federated admin remotes. Wraps an
already-built lib dist into a `<id>/{federation.json, remote/*}` layout
that drops directly into the admin federation controller's serving
directory or into a jar for jar-served deployment.

## Install (local, until published)

```
cd /Users/ph/projects/ws-admin/ws-schematics-remotes
npm install
npm link
```

`ws-pack-remote` is now available globally.

## Use

```
# from the workspace root (e.g. admin-modules)
npx ng build crm                                          # produce dist/crm
ws-pack-remote --project projects/crm --workspace .       # produce dist/admin-remotes/crm/
```

Output:

```
dist/admin-remotes/crm/
  federation.json
  remote/
    remoteEntry.js
    *.js
```

Deploy with a single rsync:

```
rsync -a --delete dist/admin-remotes/crm/ \
  /Users/ph/projects/wpm/ws-fiddle/scripts/ext-admin-remotes/crm/
```

## Identity defaults (no config required)

| field         | default                    |
| ------------- | -------------------------- |
| `id`          | `path.basename(--project)` |
| `hostId`      | `"admin"`                  |
| `remoteName`  | `camelCase(id) + "Module"` |
| `exposes`     | `"./Module"`               |
| `displayName` | `id`                       |

Override any of these via CLI flags. For rare cases where convention
isn't enough, drop a `pack.config.json` in the project root — see below.

## CLI

```
ws-pack-remote
  --project <path>      required: lib project root
  --workspace <path>    required: workspace root (resolves dist/<lib>)
  [--out <dir>]         default: <workspace>/dist/admin-remotes
  [--id <id>]
  [--host <hostId>]
  [--remote-name <s>]
  [--exposes <key>]
  [--display-name <s>]
  [--config <file>]     alt path to pack.config.json
```

## `pack.config.json` (optional escape hatch)

Used only when convention can't capture intent (id ≠ dir name, project-
specific shared overrides, non-default hostId). Every field optional:

```json
{
  "id": "crm",
  "hostId": "admin",
  "remoteName": "crmModule",
  "exposes": "./Module",
  "displayName": "crm",
  "sharedExtras": {
    "<package>": { "singleton": true, "requiredVersion": false }
  }
}
```

Identity precedence: CLI > pack.config.json > defaults.
