Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 59 additions & 1 deletion fern/products/cli-api-reference/pages/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ hideOnThisPage: true

<CodeBlock title="terminal">
```bash
fern generate [--group <group>] [--api <api>] [--version <version>] [--preview] [--fernignore <path>] [--local] [--force] [--no-replay]
fern generate [--group <group>] [--api <api>] [--version <version>] [--preview] [--fernignore <path>] [--local] [--force] [--no-replay] [--package] [--package-mode <mode>] [--package-only]
```
</CodeBlock>

Expand Down Expand Up @@ -294,6 +294,64 @@ hideOnThisPage: true
`--no-replay` works only for local generation (`--local`).
</Note>

### package

Use `--package` to build a distributable package artifact for every generator in the run whose [output location](/learn/sdks/reference/generators-yml#output) is `local-file-system`. Artifacts are written to a `fern-dist/` folder inside that generator's output directory, so a generated SDK can be handed to internal consumers without publishing it to a public registry. `--package` works with both cloud and local (`--local`) generation, and implies full project output so the artifact includes the project metadata files (`pyproject.toml`, `README.md`, and similar) it needs to build.

```bash
# Package every local-file-system output
fern generate --package

# Package one group generated locally
fern generate --group plantstore-python-sdk --local --package
```

| Language | Artifact |
|----------|----------|
| TypeScript | npm tarball (`.tgz`) |
| Python | wheel (`.whl`) |
| Java | JAR |
| C# | NuGet package (`.nupkg`) |
| Ruby | gem (`.gem`) |
| PHP | Composer archive (`.zip`) |
| Rust | crate (`.crate`) |
| Go | module source zip (`<output-dir>-source.zip`) |

Go modules have no binary package format, so the Go artifact is a zip of the generated module source, excluding `fern-dist/` and `.git/`. Fern builds it in-process: it produces the same artifact in either package mode and requires no Go toolchain. Consumers unzip it and point their `go.mod` at the unzipped directory:

```go title="go.mod"
require github.com/plantstore/plantstore-go v0.0.0

replace github.com/plantstore/plantstore-go => ../plantstore-go
```

Swift SDKs are distributed as Swift Package Manager source packages, so packaging logs a warning instead of producing an artifact: share the output directory or reference it as a local package dependency. If packaging fails for one or more generators, the CLI reports them together as `Packaging failed for: <generators>` and removes any empty `fern-dist/` directory it created.

`--package` can't be combined with `--preview` or with docs generation (`--docs`).

### package-mode

Use `--package-mode <mode>` to choose where `--package` runs the packaging toolchains. `host` (the default) uses the toolchains installed on the machine (`npm`, `pip`, `gradle`, `dotnet`, `gem`, `composer`, `cargo`). `docker` runs each toolchain inside its official image (`node`, `python`, `gradle`, `dotnet/sdk`, `ruby`, `composer`, `rust`) with the output directory mounted, so no language toolchains are required locally. Docker mode uses `docker` as the container runtime unless you pass `--runner podman`.

```bash
fern generate --group plantstore-python-sdk --package --package-mode docker
```

`--package-mode` requires `--package` or `--package-only`.

### package-only

Use `--package-only` to keep only the artifact: after packaging, everything in the output directory except `fern-dist/` is deleted, so the generated SDK source isn't left behind. `--package-only` implies `--package`. Deletion happens per generator, so a generator whose packaging failed keeps its source for debugging, as does a generator that produces no artifact at all (Swift). `.git`, `.fernignore`, and any top-level path a `.fernignore` entry covers are always preserved.

```bash
fern generate --group plantstore-node-sdk --version 0.0.1 --package-only --package-mode docker
# SDKs/plantstore-node-sdk/ contains only fern-dist/plantstore-0.0.1.tgz
```

<Warning>
The earlier `--pack` and `--pack-mode` flags were renamed to `--package` and `--package-mode` and no longer exist. Update any scripts that use them.
</Warning>

</Accordion>

<Accordion title="fern check">
Expand Down
2 changes: 2 additions & 0 deletions fern/products/sdks/deep-dives/self-hosted.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ fern generate --group python-sdk --local

To pull generator images from a private registry your organization controls instead of Docker Hub, see [Private registry setup](#private-registry-setup).

To share a locally generated SDK internally without publishing it to a registry, add [`--package`](/learn/cli-api-reference/cli-reference/commands#package), which builds a distributable artifact into a `fern-dist/` folder inside the output directory.

</Step>
</Steps>

Expand Down
2 changes: 2 additions & 0 deletions fern/products/sdks/reference/generators-yml-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,8 @@ Set to "local-file-system" for local output
<ParamField path="path" type="string" required={true}>
Local directory path where generated files will be saved
</ParamField>

To turn a local output into an installable artifact (npm tarball, wheel, JAR, and so on) without publishing it to a registry, run [`fern generate --package`](/learn/cli-api-reference/cli-reference/commands#package).
</Accordion>
</AccordionGroup>

Expand Down
Loading