mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Replace old docs with new docs repo (#24201)
This commit is contained in:
166
docs/snippets/cli/add.mdx
Normal file
166
docs/snippets/cli/add.mdx
Normal file
@@ -0,0 +1,166 @@
|
||||
## CLI Usage
|
||||
|
||||
```bash
|
||||
bun add <package> <@version>
|
||||
```
|
||||
|
||||
### Dependency Management
|
||||
|
||||
<ParamField path="--production" type="boolean">
|
||||
Don't install devDependencies. Alias: <code>-p</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--omit" type="string">
|
||||
Exclude <code>dev</code>, <code>optional</code>, or <code>peer</code> dependencies from install
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--global" type="boolean">
|
||||
Install globally. Alias: <code>-g</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--dev" type="boolean">
|
||||
Add dependency to <code>devDependencies</code>. Alias: <code>-d</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--optional" type="boolean">
|
||||
Add dependency to <code>optionalDependencies</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--peer" type="boolean">
|
||||
Add dependency to <code>peerDependencies</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--exact" type="boolean">
|
||||
Add the exact version instead of the <code>^</code> range. Alias: <code>-E</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--only-missing" type="boolean">
|
||||
Only add dependencies to <code>package.json</code> if they are not already present
|
||||
</ParamField>
|
||||
|
||||
### Project Files & Lockfiles
|
||||
|
||||
<ParamField path="--yarn" type="boolean">
|
||||
Write a <code>yarn.lock</code> file (yarn v1). Alias: <code>-y</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-save" type="boolean">
|
||||
Don't update <code>package.json</code> or save a lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--save" type="boolean" default="true">
|
||||
Save to <code>package.json</code> (true by default)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--frozen-lockfile" type="boolean">
|
||||
Disallow changes to lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--trust" type="boolean">
|
||||
Add to <code>trustedDependencies</code> in the project's <code>package.json</code> and install the package(s)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--save-text-lockfile" type="boolean">
|
||||
Save a text-based lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--lockfile-only" type="boolean">
|
||||
Generate a lockfile without installing dependencies
|
||||
</ParamField>
|
||||
|
||||
### Installation Control
|
||||
|
||||
<ParamField path="--dry-run" type="boolean">
|
||||
Don't install anything
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--force" type="boolean">
|
||||
Always request the latest versions from the registry & reinstall all dependencies. Alias: <code>-f</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-verify" type="boolean">
|
||||
Skip verifying integrity of newly downloaded packages
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--ignore-scripts" type="boolean">
|
||||
Skip lifecycle scripts in the project's <code>package.json</code> (dependency scripts are never run)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--analyze" type="boolean">
|
||||
Recursively analyze & install dependencies of files passed as arguments (using Bun's bundler). Alias:{" "}
|
||||
<code>-a</code>
|
||||
</ParamField>
|
||||
|
||||
### Network & Registry
|
||||
|
||||
<ParamField path="--ca" type="string">
|
||||
Provide a Certificate Authority signing certificate
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--cafile" type="string">
|
||||
Same as <code>--ca</code>, but as a file path to the certificate
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--registry" type="string">
|
||||
Use a specific registry by default, overriding <code>.npmrc</code>, <code>bunfig.toml</code>, and environment
|
||||
variables
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--network-concurrency" type="number" default="48">
|
||||
Maximum number of concurrent network requests (default 48)
|
||||
</ParamField>
|
||||
|
||||
### Performance & Resource
|
||||
|
||||
<ParamField path="--backend" type="string" default="clonefile">
|
||||
Platform-specific optimizations for installing dependencies. Possible values: <code>clonefile</code> (default),{" "}
|
||||
<code>hardlink</code>, <code>symlink</code>, <code>copyfile</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--concurrent-scripts" type="number" default="5">
|
||||
Maximum number of concurrent jobs for lifecycle scripts (default 5)
|
||||
</ParamField>
|
||||
|
||||
### Caching
|
||||
|
||||
<ParamField path="--cache-dir" type="string">
|
||||
Store & load cached data from a specific directory path
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-cache" type="boolean">
|
||||
Ignore manifest cache entirely
|
||||
</ParamField>
|
||||
|
||||
### Output & Logging
|
||||
|
||||
<ParamField path="--silent" type="boolean">
|
||||
Don't log anything
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--verbose" type="boolean">
|
||||
Excessively verbose logging
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-progress" type="boolean">
|
||||
Disable the progress bar
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-summary" type="boolean">
|
||||
Don't print a summary
|
||||
</ParamField>
|
||||
|
||||
### Global Configuration & Context
|
||||
|
||||
<ParamField path="--config" type="string">
|
||||
Specify path to config file (<code>bunfig.toml</code>). Alias: <code>-c</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--cwd" type="string">
|
||||
Set a specific current working directory
|
||||
</ParamField>
|
||||
|
||||
### Help
|
||||
|
||||
<ParamField path="--help" type="boolean">
|
||||
Print this help menu. Alias: <code>-h</code>
|
||||
</ParamField>
|
||||
196
docs/snippets/cli/build.mdx
Normal file
196
docs/snippets/cli/build.mdx
Normal file
@@ -0,0 +1,196 @@
|
||||
## CLI Usage
|
||||
|
||||
```bash
|
||||
bun build <entry points>
|
||||
```
|
||||
|
||||
### General Configuration
|
||||
|
||||
<ParamField path="--production" type="boolean">
|
||||
Set <code>NODE_ENV=production</code> and enable minification
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--bytecode" type="boolean">
|
||||
Use a bytecode cache when compiling
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--target" type="string" default="browser">
|
||||
Intended execution environment for the bundle. One of <code>browser</code>, <code>bun</code>, or <code>node</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--conditions" type="string">
|
||||
Pass custom resolution conditions
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--env" type="string" default="disable">
|
||||
Inline environment variables into the bundle as <code>process.env.${name}</code>. To inline variables matching a
|
||||
prefix, use a glob like <code>FOO_PUBLIC_*</code>
|
||||
</ParamField>
|
||||
|
||||
### Output & File Handling
|
||||
|
||||
<ParamField path="--outdir" type="string" default="dist">
|
||||
Output directory (used when building multiple entry points)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--outfile" type="string">
|
||||
Write output to a specific file
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--sourcemap" type="string" default="none">
|
||||
Generate source maps. One of <code>linked</code>, <code>inline</code>, <code>external</code>, or <code>none</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--banner" type="string">
|
||||
Add a banner to the output (e.g. <code>"use client"</code> for React Server Components)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--footer" type="string">
|
||||
Add a footer to the output (e.g. <code>// built with bun!</code>)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--format" type="string" default="esm">
|
||||
Module format of the output bundle. One of <code>esm</code>, <code>cjs</code>, or <code>iife</code>
|
||||
</ParamField>
|
||||
|
||||
### File Naming
|
||||
|
||||
<ParamField path="--entry-naming" type="string" default="[dir]/[name].[ext]">
|
||||
Customize entry point filenames
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--chunk-naming" type="string" default="[name]-[hash].[ext]">
|
||||
Customize chunk filenames
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--asset-naming" type="string" default="[name]-[hash].[ext]">
|
||||
Customize asset filenames
|
||||
</ParamField>
|
||||
|
||||
### Bundling Options
|
||||
|
||||
<ParamField path="--root" type="string">
|
||||
Root directory used when bundling multiple entry points
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--splitting" type="boolean">
|
||||
Enable code splitting for shared modules
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--public-path" type="string">
|
||||
Prefix to be added to import paths in bundled code
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--external" type="string">
|
||||
Exclude modules from the bundle (supports wildcards). Alias: <code>-e</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--packages" type="string" default="bundle">
|
||||
How to treat dependencies: <code>external</code> or <code>bundle</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-bundle" type="boolean">
|
||||
Transpile only — do not bundle
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--css-chunking" type="boolean">
|
||||
Chunk CSS files together to reduce duplication (only when multiple entry points import CSS)
|
||||
</ParamField>
|
||||
|
||||
### Minification & Optimization
|
||||
|
||||
<ParamField path="--emit-dce-annotations" type="boolean" default="true">
|
||||
Re-emit Dead Code Elimination annotations. Disabled when <code>--minify-whitespace</code> is used
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--minify" type="boolean">
|
||||
Enable all minification options
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--minify-syntax" type="boolean">
|
||||
Minify syntax and inline constants
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--minify-whitespace" type="boolean">
|
||||
Minify whitespace
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--minify-identifiers" type="boolean">
|
||||
Minify variable and function identifiers
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--keep-names" type="boolean">
|
||||
Preserve original function and class names when minifying
|
||||
</ParamField>
|
||||
|
||||
### Development Features
|
||||
|
||||
<ParamField path="--watch" type="boolean">
|
||||
Rebuild automatically when files change
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-clear-screen" type="boolean">
|
||||
Don’t clear the terminal when rebuilding with <code>--watch</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--react-fast-refresh" type="boolean">
|
||||
Enable React Fast Refresh transform (for development testing)
|
||||
</ParamField>
|
||||
|
||||
### Standalone Executables
|
||||
|
||||
<ParamField path="--compile" type="boolean">
|
||||
Generate a standalone Bun executable containing the bundle. Implies <code>--production</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--compile-exec-argv" type="string">
|
||||
Prepend arguments to the standalone executable’s <code>execArgv</code>
|
||||
</ParamField>
|
||||
|
||||
### Windows Executable Details
|
||||
|
||||
<ParamField path="--windows-hide-console" type="boolean">
|
||||
Prevent a console window from opening when running a compiled Windows executable
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--windows-icon" type="string">
|
||||
Set an icon for the Windows executable
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--windows-title" type="string">
|
||||
Set the Windows executable product name
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--windows-publisher" type="string">
|
||||
Set the Windows executable company name
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--windows-version" type="string">
|
||||
Set the Windows executable version (e.g. <code>1.2.3.4</code>)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--windows-description" type="string">
|
||||
Set the Windows executable description
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--windows-copyright" type="string">
|
||||
Set the Windows executable copyright notice
|
||||
</ParamField>
|
||||
|
||||
### Experimental & App Building
|
||||
|
||||
<ParamField path="--app" type="boolean">
|
||||
<b>(EXPERIMENTAL)</b> Build a web app for production using Bun Bake
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--server-components" type="boolean">
|
||||
<b>(EXPERIMENTAL)</b> Enable React Server Components
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--debug-dump-server-files" type="boolean">
|
||||
When <code>--app</code> is set, dump all server files to disk even for static builds
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--debug-no-minify" type="boolean">
|
||||
When <code>--app</code> is set, disable all minification
|
||||
</ParamField>
|
||||
17
docs/snippets/cli/feedback.mdx
Normal file
17
docs/snippets/cli/feedback.mdx
Normal file
@@ -0,0 +1,17 @@
|
||||
## CLI Usage
|
||||
|
||||
```bash
|
||||
bun feedback [options] [feedback text ... | files ...]
|
||||
```
|
||||
|
||||
### Contact Information
|
||||
|
||||
<ParamField path="--email" type="string">
|
||||
Set the email address used for this submission. Alias: <code>-e</code>
|
||||
</ParamField>
|
||||
|
||||
### Help
|
||||
|
||||
<ParamField path="--help" type="boolean">
|
||||
Show this help message and exit. Alias: <code>-h</code>
|
||||
</ParamField>
|
||||
84
docs/snippets/cli/init.mdx
Normal file
84
docs/snippets/cli/init.mdx
Normal file
@@ -0,0 +1,84 @@
|
||||
## CLI Usage
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
bun init <folder?>
|
||||
```
|
||||
|
||||
### Initialization Options
|
||||
|
||||
<ParamField path="--yes" type="boolean">
|
||||
{" "}
|
||||
Accept all default prompts without asking questions. Alias: <code>-y</code>{" "}
|
||||
</ParamField>
|
||||
<ParamField path="--minimal" type="boolean">
|
||||
{" "}
|
||||
Only initialize type definitions (skip app scaffolding). Alias: <code>-m</code>{" "}
|
||||
</ParamField>
|
||||
|
||||
### Project Templates
|
||||
|
||||
<ParamField path="--react" type="string|boolean">
|
||||
{" "}
|
||||
Scaffold a React project. When used without a value, creates a baseline React app.
|
||||
<br /> Accepts values for presets:{" "}
|
||||
<ul>
|
||||
{" "}
|
||||
<li>
|
||||
<code>tailwind</code> – React app preconfigured with Tailwind CSS
|
||||
</li>{" "}
|
||||
<li>
|
||||
<code>shadcn</code> – React app with <code>@shadcn/ui</code> and Tailwind CSS
|
||||
</li>{" "}
|
||||
</ul>{" "}
|
||||
Examples:{" "}
|
||||
<pre>
|
||||
<code>bun init --react bun init --react=tailwind bun init --react=shadcn</code>
|
||||
</pre>{" "}
|
||||
</ParamField>
|
||||
|
||||
### Output & Files
|
||||
|
||||
<ParamField path="(result)" type="info">
|
||||
{" "}
|
||||
Initializes project files and configuration for the chosen options (e.g., creating essential config files and a
|
||||
starter directory structure). Exact files vary by template.{" "}
|
||||
</ParamField>
|
||||
|
||||
### Global Configuration & Context
|
||||
|
||||
<ParamField path="--cwd" type="string">
|
||||
{" "}
|
||||
Run <code>bun init</code> as if started in a different working directory (useful in scripts).{" "}
|
||||
</ParamField>
|
||||
|
||||
### Help
|
||||
|
||||
<ParamField path="--help" type="boolean">
|
||||
{" "}
|
||||
Print this help menu. Alias: <code>-h</code>{" "}
|
||||
</ParamField>
|
||||
|
||||
### Examples
|
||||
|
||||
- Accept all defaults
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
bun init -y
|
||||
```
|
||||
|
||||
- React
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
bun init --react
|
||||
```
|
||||
|
||||
- React + Tailwind CSS
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
bun init --react=tailwind
|
||||
```
|
||||
|
||||
- React + @shadcn/ui
|
||||
```bash terminal icon="terminal"
|
||||
bun init --react=shadcn
|
||||
```
|
||||
173
docs/snippets/cli/install.mdx
Normal file
173
docs/snippets/cli/install.mdx
Normal file
@@ -0,0 +1,173 @@
|
||||
## CLI Usage
|
||||
|
||||
```sh terminal icon="terminal"
|
||||
bun install <name>@<version>
|
||||
```
|
||||
|
||||
### General Configuration
|
||||
|
||||
<ParamField path="--config" type="string">
|
||||
Specify path to config file (bunfig.toml)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--cwd" type="string">
|
||||
Set a specific cwd
|
||||
</ParamField>
|
||||
|
||||
### Dependency Scope & Management
|
||||
|
||||
<ParamField path="--production" type="boolean">
|
||||
Don't install devDependencies
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-save" type="boolean">
|
||||
Don't update package.json or save a lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--save" type="boolean" default="true">
|
||||
Save to package.json
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--omit" type="string">
|
||||
Exclude 'dev', 'optional', or 'peer' dependencies from install
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--only-missing" type="boolean">
|
||||
Only add dependencies to package.json if they are not already present
|
||||
</ParamField>
|
||||
|
||||
### Dependency Type & Versioning
|
||||
|
||||
<ParamField path="--dev" type="boolean">
|
||||
Add dependency to "devDependencies"
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--optional" type="boolean">
|
||||
Add dependency to "optionalDependencies"
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--peer" type="boolean">
|
||||
Add dependency to "peerDependencies"
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--exact" type="boolean">
|
||||
Add the exact version instead of the ^range
|
||||
</ParamField>
|
||||
|
||||
### Lockfile Control
|
||||
|
||||
<ParamField path="--yarn" type="boolean">
|
||||
Write a yarn.lock file (yarn v1)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--frozen-lockfile" type="boolean">
|
||||
Disallow changes to lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--save-text-lockfile" type="boolean">
|
||||
Save a text-based lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--lockfile-only" type="boolean">
|
||||
Generate a lockfile without installing dependencies
|
||||
</ParamField>
|
||||
|
||||
### Network & Registry Settings
|
||||
|
||||
<ParamField path="--ca" type="string">
|
||||
Provide a Certificate Authority signing certificate
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--cafile" type="string">
|
||||
File path to Certificate Authority signing certificate
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--registry" type="string">
|
||||
Use a specific registry by default, overriding .npmrc, bunfig.toml and environment variables
|
||||
</ParamField>
|
||||
|
||||
### Installation Process Control
|
||||
|
||||
<ParamField path="--dry-run" type="boolean">
|
||||
Don't install anything
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--force" type="boolean">
|
||||
Always request the latest versions from the registry & reinstall all dependencies
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--global" type="boolean">
|
||||
Install globally
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--backend" type="string" default="clonefile">
|
||||
Platform-specific optimizations: "clonefile", "hardlink", "symlink", "copyfile"
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--filter" type="string">
|
||||
Install packages for the matching workspaces
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--analyze" type="boolean">
|
||||
Analyze & install all dependencies of files passed as arguments recursively
|
||||
</ParamField>
|
||||
|
||||
### Caching Options
|
||||
|
||||
<ParamField path="--cache-dir" type="string">
|
||||
Store & load cached data from a specific directory path
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-cache" type="boolean">
|
||||
Ignore manifest cache entirely
|
||||
</ParamField>
|
||||
|
||||
### Output & Logging
|
||||
|
||||
<ParamField path="--silent" type="boolean">
|
||||
Don't log anything
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--verbose" type="boolean">
|
||||
Excessively verbose logging
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-progress" type="boolean">
|
||||
Disable the progress bar
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-summary" type="boolean">
|
||||
Don't print a summary
|
||||
</ParamField>
|
||||
|
||||
### Security & Integrity
|
||||
|
||||
<ParamField path="--no-verify" type="boolean">
|
||||
Skip verifying integrity of newly downloaded packages
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--trust" type="boolean">
|
||||
Add to trustedDependencies in the project's package.json and install the package(s)
|
||||
</ParamField>
|
||||
|
||||
### Concurrency & Performance
|
||||
|
||||
<ParamField path="--concurrent-scripts" type="number" default="5">
|
||||
Maximum number of concurrent jobs for lifecycle scripts
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--network-concurrency" type="number" default="48">
|
||||
Maximum number of concurrent network requests
|
||||
</ParamField>
|
||||
|
||||
### Lifecycle Script Management
|
||||
|
||||
<ParamField path="--ignore-scripts" type="boolean">
|
||||
Skip lifecycle scripts in the project's package.json (dependency scripts are never run)
|
||||
</ParamField>
|
||||
|
||||
### Help Information
|
||||
|
||||
<ParamField path="--help" type="boolean">
|
||||
Print this help menu
|
||||
</ParamField>
|
||||
163
docs/snippets/cli/link.mdx
Normal file
163
docs/snippets/cli/link.mdx
Normal file
@@ -0,0 +1,163 @@
|
||||
# CLI Usage
|
||||
|
||||
```bash
|
||||
bun link <packages>
|
||||
```
|
||||
|
||||
### Installation Scope
|
||||
|
||||
<ParamField path="--global" type="boolean">
|
||||
Install globally. Alias: <code>-g</code>
|
||||
</ParamField>
|
||||
|
||||
### Dependency Management
|
||||
|
||||
<ParamField path="--production" type="boolean">
|
||||
Don't install devDependencies. Alias: <code>-p</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--omit" type="string">
|
||||
Exclude <code>dev</code>, <code>optional</code>, or <code>peer</code> dependencies from install
|
||||
</ParamField>
|
||||
|
||||
### Project Files & Lockfiles
|
||||
|
||||
<ParamField path="--yarn" type="boolean">
|
||||
Write a <code>yarn.lock</code> file (yarn v1). Alias: <code>-y</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--frozen-lockfile" type="boolean">
|
||||
Disallow changes to lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--save-text-lockfile" type="boolean">
|
||||
Save a text-based lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--lockfile-only" type="boolean">
|
||||
Generate a lockfile without installing dependencies
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-save" type="boolean">
|
||||
Don't update <code>package.json</code> or save a lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--save" type="boolean" default="true">
|
||||
Save to <code>package.json</code> (true by default)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--trust" type="boolean">
|
||||
Add to <code>trustedDependencies</code> in the project's <code>package.json</code> and install the package(s)
|
||||
</ParamField>
|
||||
|
||||
### Installation Control
|
||||
|
||||
<ParamField path="--force" type="boolean">
|
||||
Always request the latest versions from the registry & reinstall all dependencies. Alias: <code>-f</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-verify" type="boolean">
|
||||
Skip verifying integrity of newly downloaded packages
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--backend" type="string" default="clonefile">
|
||||
Platform-specific optimizations for installing dependencies. Possible values: <code>clonefile</code> (default),{" "}
|
||||
<code>hardlink</code>, <code>symlink</code>, <code>copyfile</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--linker" type="string">
|
||||
Linker strategy (one of <code>isolated</code> or <code>hoisted</code>)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--dry-run" type="boolean">
|
||||
Don't install anything
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--ignore-scripts" type="boolean">
|
||||
Skip lifecycle scripts in the project's <code>package.json</code> (dependency scripts are never run)
|
||||
</ParamField>
|
||||
|
||||
### Network & Registry
|
||||
|
||||
<ParamField path="--ca" type="string">
|
||||
Provide a Certificate Authority signing certificate
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--cafile" type="string">
|
||||
Same as <code>--ca</code>, but as a file path to the certificate
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--registry" type="string">
|
||||
Use a specific registry by default, overriding <code>.npmrc</code>, <code>bunfig.toml</code>, and environment
|
||||
variables
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--network-concurrency" type="number" default="48">
|
||||
Maximum number of concurrent network requests (default 48)
|
||||
</ParamField>
|
||||
|
||||
### Performance & Resource
|
||||
|
||||
<ParamField path="--concurrent-scripts" type="number" default="5">
|
||||
Maximum number of concurrent jobs for lifecycle scripts (default 5)
|
||||
</ParamField>
|
||||
|
||||
### Caching
|
||||
|
||||
<ParamField path="--cache-dir" type="string">
|
||||
Store & load cached data from a specific directory path
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-cache" type="boolean">
|
||||
Ignore manifest cache entirely
|
||||
</ParamField>
|
||||
|
||||
### Output & Logging
|
||||
|
||||
<ParamField path="--silent" type="boolean">
|
||||
Don't log anything
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--quiet" type="boolean">
|
||||
Only show tarball name when packing
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--verbose" type="boolean">
|
||||
Excessively verbose logging
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-progress" type="boolean">
|
||||
Disable the progress bar
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-summary" type="boolean">
|
||||
Don't print a summary
|
||||
</ParamField>
|
||||
|
||||
### Platform Targeting
|
||||
|
||||
<ParamField path="--cpu" type="string">
|
||||
Override CPU architecture for optional dependencies (e.g., <code>x64</code>, <code>arm64</code>, <code>*</code> for
|
||||
all)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--os" type="string">
|
||||
Override operating system for optional dependencies (e.g., <code>linux</code>, <code>darwin</code>, <code>*</code> for
|
||||
all)
|
||||
</ParamField>
|
||||
|
||||
### Global Configuration & Context
|
||||
|
||||
<ParamField path="--config" type="string">
|
||||
Specify path to config file (<code>bunfig.toml</code>). Alias: <code>-c</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--cwd" type="string">
|
||||
Set a specific current working directory
|
||||
</ParamField>
|
||||
|
||||
### Help
|
||||
|
||||
<ParamField path="--help" type="boolean">
|
||||
Print this help menu. Alias: <code>-h</code>
|
||||
</ParamField>
|
||||
140
docs/snippets/cli/outdated.mdx
Normal file
140
docs/snippets/cli/outdated.mdx
Normal file
@@ -0,0 +1,140 @@
|
||||
## CLI Usage
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
bun outdated <filter>
|
||||
```
|
||||
|
||||
### General Options
|
||||
|
||||
<ParamField path="-c, --config" type="string">
|
||||
Specify path to config file (<code>bunfig.toml</code>)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--cwd" type="string">
|
||||
Set a specific cwd
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="-h, --help" type="boolean">
|
||||
Print this help menu
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="-F, --filter" type="string">
|
||||
Display outdated dependencies for each matching workspace
|
||||
</ParamField>
|
||||
|
||||
### Output & Logging
|
||||
|
||||
<ParamField path="--silent" type="boolean">
|
||||
Don't log anything
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--verbose" type="boolean">
|
||||
Excessively verbose logging
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-progress" type="boolean">
|
||||
Disable the progress bar
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-summary" type="boolean">
|
||||
Don't print a summary
|
||||
</ParamField>
|
||||
|
||||
### Dependency Scope & Target
|
||||
|
||||
<ParamField path="-p, --production" type="boolean">
|
||||
Don't install devDependencies
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--omit" type="string">
|
||||
Exclude <code>dev</code>, <code>optional</code>, or <code>peer</code> dependencies from install
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="-g, --global" type="boolean">
|
||||
Install globally
|
||||
</ParamField>
|
||||
|
||||
### Lockfile & Package.json
|
||||
|
||||
<ParamField path="-y, --yarn" type="boolean">
|
||||
Write a <code>yarn.lock</code> file (yarn v1)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-save" type="boolean">
|
||||
Don't update <code>package.json</code> or save a lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--save" type="boolean" default="true">
|
||||
Save to <code>package.json</code> (true by default)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--frozen-lockfile" type="boolean">
|
||||
Disallow changes to lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--save-text-lockfile" type="boolean">
|
||||
Save a text-based lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--lockfile-only" type="boolean">
|
||||
Generate a lockfile without installing dependencies
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--trust" type="boolean">
|
||||
Add to <code>trustedDependencies</code> in the project's <code>package.json</code> and install the package(s)
|
||||
</ParamField>
|
||||
|
||||
### Network & Registry
|
||||
|
||||
<ParamField path="--ca" type="string">
|
||||
Provide a Certificate Authority signing certificate
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--cafile" type="string">
|
||||
Same as <code>--ca</code>, but as a file path to the certificate
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--registry" type="string">
|
||||
Use a specific registry by default, overriding <code>.npmrc</code>, <code>bunfig.toml</code> and environment variables
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--network-concurrency" type="number" default="48">
|
||||
Maximum number of concurrent network requests (default 48)
|
||||
</ParamField>
|
||||
|
||||
### Caching
|
||||
|
||||
<ParamField path="--cache-dir" type="string">
|
||||
Store & load cached data from a specific directory path
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-cache" type="boolean">
|
||||
Ignore manifest cache entirely
|
||||
</ParamField>
|
||||
|
||||
### Execution Behavior
|
||||
|
||||
<ParamField path="--dry-run" type="boolean">
|
||||
Don't install anything
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="-f, --force" type="boolean">
|
||||
Always request the latest versions from the registry & reinstall all dependencies
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-verify" type="boolean">
|
||||
Skip verifying integrity of newly downloaded packages
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--ignore-scripts" type="boolean">
|
||||
Skip lifecycle scripts in the project's <code>package.json</code> (dependency scripts are never run)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--backend" type="string" default="clonefile">
|
||||
Platform-specific optimizations for installing dependencies. Possible values: <code>clonefile</code> (default),{" "}
|
||||
<code>hardlink</code>, <code>symlink</code>, <code>copyfile</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--concurrent-scripts" type="number" default="5">
|
||||
Maximum number of concurrent jobs for lifecycle scripts (default 5)
|
||||
</ParamField>
|
||||
171
docs/snippets/cli/patch.mdx
Normal file
171
docs/snippets/cli/patch.mdx
Normal file
@@ -0,0 +1,171 @@
|
||||
# CLI Usage
|
||||
|
||||
```bash
|
||||
bun patch <package>@<version>
|
||||
```
|
||||
|
||||
### Patch Generation
|
||||
|
||||
<ParamField path="--commit" type="boolean">
|
||||
Install a package containing modifications in <code>dir</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--patches-dir" type="string">
|
||||
The directory to put the patch file in (only if --commit is used)
|
||||
</ParamField>
|
||||
|
||||
### Dependency Management
|
||||
|
||||
<ParamField path="--production" type="boolean">
|
||||
Don't install devDependencies. Alias: <code>-p</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--ignore-scripts" type="boolean">
|
||||
Skip lifecycle scripts in the project's <code>package.json</code> (dependency scripts are never run)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--trust" type="boolean">
|
||||
Add to <code>trustedDependencies</code> in the project's <code>package.json</code> and install the package(s)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--global" type="boolean">
|
||||
Install globally. Alias: <code>-g</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--omit" type="string">
|
||||
Exclude <code>dev</code>, <code>optional</code>, or <code>peer</code> dependencies from install
|
||||
</ParamField>
|
||||
|
||||
### Project Files & Lockfiles
|
||||
|
||||
<ParamField path="--yarn" type="boolean">
|
||||
Write a <code>yarn.lock</code> file (yarn v1). Alias: <code>-y</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-save" type="boolean">
|
||||
Don't update <code>package.json</code> or save a lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--save" type="boolean" default="true">
|
||||
Save to <code>package.json</code> (true by default)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--frozen-lockfile" type="boolean">
|
||||
Disallow changes to lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--save-text-lockfile" type="boolean">
|
||||
Save a text-based lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--lockfile-only" type="boolean">
|
||||
Generate a lockfile without installing dependencies
|
||||
</ParamField>
|
||||
|
||||
### Installation Control
|
||||
|
||||
<ParamField path="--backend" type="string" default="clonefile">
|
||||
Platform-specific optimizations for installing dependencies. Possible values: <code>clonefile</code> (default),{" "}
|
||||
<code>hardlink</code>, <code>symlink</code>, <code>copyfile</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--linker" type="string">
|
||||
Linker strategy (one of <code>isolated</code> or <code>hoisted</code>)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--dry-run" type="boolean">
|
||||
Don't install anything
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--force" type="boolean">
|
||||
Always request the latest versions from the registry & reinstall all dependencies. Alias: <code>-f</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-verify" type="boolean">
|
||||
Skip verifying integrity of newly downloaded packages
|
||||
</ParamField>
|
||||
|
||||
### Network & Registry
|
||||
|
||||
<ParamField path="--ca" type="string">
|
||||
Provide a Certificate Authority signing certificate
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--cafile" type="string">
|
||||
Same as <code>--ca</code>, but as a file path to the certificate
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--registry" type="string">
|
||||
Use a specific registry by default, overriding <code>.npmrc</code>, <code>bunfig.toml</code>, and environment
|
||||
variables
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--network-concurrency" type="number" default="48">
|
||||
Maximum number of concurrent network requests (default 48)
|
||||
</ParamField>
|
||||
|
||||
### Performance & Resource
|
||||
|
||||
<ParamField path="--concurrent-scripts" type="number" default="5">
|
||||
Maximum number of concurrent jobs for lifecycle scripts (default 5)
|
||||
</ParamField>
|
||||
|
||||
### Caching
|
||||
|
||||
<ParamField path="--cache-dir" type="string">
|
||||
Store & load cached data from a specific directory path
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-cache" type="boolean">
|
||||
Ignore manifest cache entirely
|
||||
</ParamField>
|
||||
|
||||
### Output & Logging
|
||||
|
||||
<ParamField path="--silent" type="boolean">
|
||||
Don't log anything
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--quiet" type="boolean">
|
||||
Only show tarball name when packing
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--verbose" type="boolean">
|
||||
Excessively verbose logging
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-progress" type="boolean">
|
||||
Disable the progress bar
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-summary" type="boolean">
|
||||
Don't print a summary
|
||||
</ParamField>
|
||||
|
||||
### Platform Targeting
|
||||
|
||||
<ParamField path="--cpu" type="string">
|
||||
Override CPU architecture for optional dependencies (e.g., <code>x64</code>, <code>arm64</code>, <code>*</code> for
|
||||
all)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--os" type="string">
|
||||
Override operating system for optional dependencies (e.g., <code>linux</code>, <code>darwin</code>, <code>*</code> for
|
||||
all)
|
||||
</ParamField>
|
||||
|
||||
### Global Configuration & Context
|
||||
|
||||
<ParamField path="--config" type="string">
|
||||
Specify path to config file (<code>bunfig.toml</code>). Alias: <code>-c</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--cwd" type="string">
|
||||
Set a specific current working directory
|
||||
</ParamField>
|
||||
|
||||
### Help
|
||||
|
||||
<ParamField path="--help" type="boolean">
|
||||
Print this help menu. Alias: <code>-h</code>
|
||||
</ParamField>
|
||||
198
docs/snippets/cli/publish.mdx
Normal file
198
docs/snippets/cli/publish.mdx
Normal file
@@ -0,0 +1,198 @@
|
||||
## CLI Usage
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
bun publish dist
|
||||
```
|
||||
|
||||
### Publishing Options
|
||||
|
||||
<ParamField path="--access" type="string">
|
||||
The `--access` flag can be used to set the access level of the package being published. The access level can be one of `public` or `restricted`. Unscoped packages are always public, and attempting to publish an unscoped package with `--access restricted` will result in an error.
|
||||
|
||||
```sh terminal icon="terminal"
|
||||
bun publish --access public
|
||||
```
|
||||
|
||||
`--access` can also be set in the `publishConfig` field of your `package.json`.
|
||||
|
||||
```json package.json icon="file-json"
|
||||
{
|
||||
"publishConfig": {
|
||||
"access": "restricted" // [!code ++]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--tag" type="string" default="latest">
|
||||
Set the tag of the package version being published. By default, the tag is `latest`. The initial version of a package is always given the `latest` tag in addition to the specified tag.
|
||||
|
||||
```sh terminal icon="terminal"
|
||||
bun publish --tag alpha
|
||||
```
|
||||
|
||||
`--tag` can also be set in the `publishConfig` field of your `package.json`.
|
||||
|
||||
```json package.json file="file-json"
|
||||
{
|
||||
"publishConfig": {
|
||||
"tag": "next" // [!code ++]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--dry-run=<val>" type="string">
|
||||
The `--dry-run` flag can be used to simulate the publish process without actually publishing the package. This is useful for verifying the contents of the published package without actually publishing the package.
|
||||
|
||||
```sh
|
||||
bun publish --dry-run
|
||||
```
|
||||
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--gzip-level" type="string" default="9">
|
||||
Specify the level of gzip compression to use when packing the package. Only applies to `bun publish` without a tarball
|
||||
path argument. Values range from `0` to `9` (default is `9`).
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--auth-type" type="string" default="web">
|
||||
|
||||
If you have 2FA enabled for your npm account, `bun publish` will prompt you for a one-time password. This can be done through a browser or the CLI. The `--auth-type` flag can be used to tell the npm registry which method you prefer. The possible values are `web` and `legacy`, with `web` being the default.
|
||||
|
||||
```sh terminal icon="terminal"
|
||||
bun publish --auth-type legacy
|
||||
...
|
||||
This operation requires a one-time password.
|
||||
Enter OTP: 123456
|
||||
...
|
||||
```
|
||||
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--otp" type="string" default="web">
|
||||
|
||||
Provide a one-time password directly to the CLI. If the password is valid, this will skip the extra prompt for a one-time password before publishing. Example usage:
|
||||
|
||||
```sh terminal icon="terminal"
|
||||
bun publish --otp 123456
|
||||
```
|
||||
|
||||
<Note>
|
||||
`bun publish` respects the `NPM_CONFIG_TOKEN` environment variable which can be used when publishing in github actions
|
||||
or automated workflows.
|
||||
</Note>
|
||||
|
||||
</ParamField>
|
||||
|
||||
### Registry Configuration
|
||||
|
||||
#### Custom Registry
|
||||
|
||||
<ParamField path="--registry" type="string">
|
||||
Specify registry URL, overriding .npmrc and bunfig.toml
|
||||
</ParamField>
|
||||
|
||||
```bash
|
||||
bun publish --registry https://my-private-registry.com
|
||||
```
|
||||
|
||||
#### SSL Certificates
|
||||
|
||||
<ParamField path="--ca" type="string">
|
||||
Provide Certificate Authority signing certificate
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--cafile" type="string">
|
||||
Path to Certificate Authority certificate file
|
||||
</ParamField>
|
||||
|
||||
<CodeGroup>
|
||||
```bash Inline Certificate
|
||||
bun publish --ca "-----BEGIN CERTIFICATE-----..."
|
||||
```
|
||||
|
||||
```bash Certificate File
|
||||
bun publish --cafile ./ca-cert.pem
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
### Publishing Options
|
||||
|
||||
#### Dependency Management
|
||||
|
||||
<ParamField path="-p, --production" type="boolean">
|
||||
Don't install devDependencies
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--omit" type="string">
|
||||
Exclude dependency types: `dev`, `optional`, or `peer`
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="-f, --force" type="boolean">
|
||||
Always request the latest versions from the registry & reinstall all dependencies
|
||||
</ParamField>
|
||||
|
||||
#### Script Control
|
||||
|
||||
<ParamField path="--ignore-scripts" type="boolean">
|
||||
Skip lifecycle scripts during packing and publishing
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--trust" type="boolean">
|
||||
Add packages to trustedDependencies and run their scripts
|
||||
</ParamField>
|
||||
|
||||
<Note>
|
||||
**Lifecycle Scripts** — When providing a pre-built tarball, lifecycle scripts (prepublishOnly, prepack, etc.) are not
|
||||
executed. Scripts only run when Bun packs the package itself.
|
||||
</Note>
|
||||
|
||||
#### File Management
|
||||
|
||||
<ParamField path="--no-save" type="boolean">
|
||||
Don't update package.json or lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--frozen-lockfile" type="boolean">
|
||||
Disallow changes to lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--yarn" type="boolean">
|
||||
Generate yarn.lock file (yarn v1 compatible)
|
||||
</ParamField>
|
||||
|
||||
#### Performance
|
||||
|
||||
<ParamField path="--backend" type="string">
|
||||
Platform optimizations: `clonefile` (default), `hardlink`, `symlink`, or `copyfile`
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--network-concurrency" type="number" default="48">
|
||||
Maximum concurrent network requests
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--concurrent-scripts" type="number" default="5">
|
||||
Maximum concurrent lifecycle scripts
|
||||
</ParamField>
|
||||
|
||||
#### Output Control
|
||||
|
||||
<ParamField path="--silent" type="boolean">
|
||||
Suppress all output
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--verbose" type="boolean">
|
||||
Show detailed logging
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-progress" type="boolean">
|
||||
Hide progress bar
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-summary" type="boolean">
|
||||
Don't print publish summary
|
||||
</ParamField>
|
||||
146
docs/snippets/cli/remove.mdx
Normal file
146
docs/snippets/cli/remove.mdx
Normal file
@@ -0,0 +1,146 @@
|
||||
## CLI Usage
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
bun remove <package>
|
||||
```
|
||||
|
||||
### General Information
|
||||
|
||||
<ParamField path="--help" type="boolean">
|
||||
Print this help menu. Alias: <code>-h</code>
|
||||
</ParamField>
|
||||
|
||||
### Configuration
|
||||
|
||||
<ParamField path="--config" type="string">
|
||||
Specify path to config file (<code>bunfig.toml</code>). Alias: <code>-c</code>
|
||||
</ParamField>
|
||||
|
||||
### Package.json Interaction
|
||||
|
||||
<ParamField path="--no-save" type="boolean">
|
||||
Don't update <code>package.json</code> or save a lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--save" type="boolean" default="true">
|
||||
Save to <code>package.json</code> (true by default)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--trust" type="boolean">
|
||||
Add to <code>trustedDependencies</code> in the project's <code>package.json</code> and install the package(s)
|
||||
</ParamField>
|
||||
|
||||
### Lockfile Behavior
|
||||
|
||||
<ParamField path="--yarn" type="boolean">
|
||||
Write a <code>yarn.lock</code> file (yarn v1). Alias: <code>-y</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--frozen-lockfile" type="boolean">
|
||||
Disallow changes to lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--save-text-lockfile" type="boolean">
|
||||
Save a text-based lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--lockfile-only" type="boolean">
|
||||
Generate a lockfile without installing dependencies
|
||||
</ParamField>
|
||||
|
||||
### Dependency Filtering
|
||||
|
||||
<ParamField path="--production" type="boolean">
|
||||
Don't install devDependencies. Alias: <code>-p</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--omit" type="string">
|
||||
Exclude <code>dev</code>, <code>optional</code>, or <code>peer</code> dependencies from install
|
||||
</ParamField>
|
||||
|
||||
### Network & Registry
|
||||
|
||||
<ParamField path="--ca" type="string">
|
||||
Provide a Certificate Authority signing certificate
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--cafile" type="string">
|
||||
Same as <code>--ca</code>, but as a file path to the certificate
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--registry" type="string">
|
||||
Use a specific registry by default, overriding <code>.npmrc</code>, <code>bunfig.toml</code> and environment variables
|
||||
</ParamField>
|
||||
|
||||
### Execution Control & Validation
|
||||
|
||||
<ParamField path="--dry-run" type="boolean">
|
||||
Don't install anything
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--force" type="boolean">
|
||||
Always request the latest versions from the registry & reinstall all dependencies. Alias: <code>-f</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-verify" type="boolean">
|
||||
Skip verifying integrity of newly downloaded packages
|
||||
</ParamField>
|
||||
|
||||
### Output & Logging
|
||||
|
||||
<ParamField path="--silent" type="boolean">
|
||||
Don't log anything
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--verbose" type="boolean">
|
||||
Excessively verbose logging
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-progress" type="boolean">
|
||||
Disable the progress bar
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-summary" type="boolean">
|
||||
Don't print a summary
|
||||
</ParamField>
|
||||
|
||||
### Caching
|
||||
|
||||
<ParamField path="--cache-dir" type="string">
|
||||
Store & load cached data from a specific directory path
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-cache" type="boolean">
|
||||
Ignore manifest cache entirely
|
||||
</ParamField>
|
||||
|
||||
### Script Execution
|
||||
|
||||
<ParamField path="--ignore-scripts" type="boolean">
|
||||
Skip lifecycle scripts in the project's <code>package.json</code> (dependency scripts are never run)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--concurrent-scripts" type="number" default="5">
|
||||
Maximum number of concurrent jobs for lifecycle scripts (default 5)
|
||||
</ParamField>
|
||||
|
||||
### Scope & Path
|
||||
|
||||
<ParamField path="--global" type="boolean">
|
||||
Install globally. Alias: <code>-g</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--cwd" type="string">
|
||||
Set a specific cwd
|
||||
</ParamField>
|
||||
|
||||
### Advanced & Performance
|
||||
|
||||
<ParamField path="--backend" type="string" default="clonefile">
|
||||
Platform-specific optimizations for installing dependencies. Possible values: <code>clonefile</code> (default),{" "}
|
||||
<code>hardlink</code>, <code>symlink</code>, <code>copyfile</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--network-concurrency" type="number" default="48">
|
||||
Maximum number of concurrent network requests (default 48)
|
||||
</ParamField>
|
||||
293
docs/snippets/cli/run.mdx
Normal file
293
docs/snippets/cli/run.mdx
Normal file
@@ -0,0 +1,293 @@
|
||||
# CLI Usage
|
||||
|
||||
```bash
|
||||
bun run <file or script>
|
||||
```
|
||||
|
||||
### General Execution Options
|
||||
|
||||
<ParamField path="--silent" type="boolean">
|
||||
Don't print the script command
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--if-present" type="boolean">
|
||||
Exit without an error if the entrypoint does not exist
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--eval" type="string">
|
||||
Evaluate argument as a script. Alias: <code>-e</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--print" type="string">
|
||||
Evaluate argument as a script and print the result. Alias: <code>-p</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--help" type="boolean">
|
||||
Display this menu and exit. Alias: <code>-h</code>
|
||||
</ParamField>
|
||||
|
||||
### Workspace Management
|
||||
|
||||
<ParamField path="--elide-lines" type="number" default="10">
|
||||
Number of lines of script output shown when using --filter (default: 10). Set to 0 to show all lines
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--filter" type="string">
|
||||
Run a script in all workspace packages matching the pattern. Alias: <code>-F</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--workspaces" type="boolean">
|
||||
Run a script in all workspace packages (from the <code>workspaces</code> field in <code>package.json</code>)
|
||||
</ParamField>
|
||||
|
||||
### Runtime & Process Control
|
||||
|
||||
<ParamField path="--bun" type="boolean">
|
||||
Force a script or package to use Bun's runtime instead of Node.js (via symlinking node). Alias: <code>-b</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--shell" type="string">
|
||||
Control the shell used for <code>package.json</code> scripts. Supports either <code>bun</code> or <code>system</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--smol" type="boolean">
|
||||
Use less memory, but run garbage collection more often
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--expose-gc" type="boolean">
|
||||
Expose <code>gc()</code> on the global object. Has no effect on <code>Bun.gc()</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-deprecation" type="boolean">
|
||||
Suppress all reporting of the custom deprecation
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--throw-deprecation" type="boolean">
|
||||
Determine whether or not deprecation warnings result in errors
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--title" type="string">
|
||||
Set the process title
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--zero-fill-buffers" type="boolean">
|
||||
Boolean to force <code>Buffer.allocUnsafe(size)</code> to be zero-filled
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-addons" type="boolean">
|
||||
Throw an error if <code>process.dlopen</code> is called, and disable export condition <code>node-addons</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--unhandled-rejections" type="string">
|
||||
One of <code>strict</code>, <code>throw</code>, <code>warn</code>, <code>none</code>, or{" "}
|
||||
<code>warn-with-error-code</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--console-depth" type="number" default="2">
|
||||
Set the default depth for <code>console.log</code> object inspection (default: 2)
|
||||
</ParamField>
|
||||
|
||||
### Development Workflow
|
||||
|
||||
<ParamField path="--watch" type="boolean">
|
||||
Automatically restart the process on file change
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--hot" type="boolean">
|
||||
Enable auto reload in the Bun runtime, test runner, or bundler
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-clear-screen" type="boolean">
|
||||
Disable clearing the terminal screen on reload when --hot or --watch is enabled
|
||||
</ParamField>
|
||||
|
||||
### Debugging
|
||||
|
||||
<ParamField path="--inspect" type="string">
|
||||
Activate Bun's debugger
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--inspect-wait" type="string">
|
||||
Activate Bun's debugger, wait for a connection before executing
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--inspect-brk" type="string">
|
||||
Activate Bun's debugger, set breakpoint on first line of code and wait
|
||||
</ParamField>
|
||||
|
||||
### Dependency & Module Resolution
|
||||
|
||||
<ParamField path="--preload" type="string">
|
||||
Import a module before other modules are loaded. Alias: <code>-r</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--require" type="string">
|
||||
Alias of --preload, for Node.js compatibility
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--import" type="string">
|
||||
Alias of --preload, for Node.js compatibility
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-install" type="boolean">
|
||||
Disable auto install in the Bun runtime
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--install" type="string" default="auto">
|
||||
Configure auto-install behavior. One of <code>auto</code> (default, auto-installs when no node_modules),{" "}
|
||||
<code>fallback</code> (missing packages only), <code>force</code> (always)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="-i" type="boolean">
|
||||
Auto-install dependencies during execution. Equivalent to --install=fallback
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--prefer-offline" type="boolean">
|
||||
Skip staleness checks for packages in the Bun runtime and resolve from disk
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--prefer-latest" type="boolean">
|
||||
Use the latest matching versions of packages in the Bun runtime, always checking npm
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--conditions" type="string">
|
||||
Pass custom conditions to resolve
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--main-fields" type="string">
|
||||
Main fields to lookup in <code>package.json</code>. Defaults to --target dependent
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--preserve-symlinks" type="boolean">
|
||||
Preserve symlinks when resolving files
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--preserve-symlinks-main" type="boolean">
|
||||
Preserve symlinks when resolving the main entry point
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--extension-order" type="string" default=".tsx,.ts,.jsx,.js,.json">
|
||||
Defaults to: <code>.tsx,.ts,.jsx,.js,.json</code>
|
||||
</ParamField>
|
||||
|
||||
### Transpilation & Language Features
|
||||
|
||||
<ParamField path="--tsconfig-override" type="string">
|
||||
Specify custom <code>tsconfig.json</code>. Default <code>$cwd/tsconfig.json</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--define" type="string">
|
||||
Substitute K:V while parsing, e.g. <code>--define process.env.NODE_ENV:"development"</code>. Values are parsed as
|
||||
JSON. Alias: <code>-d</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--drop" type="string">
|
||||
Remove function calls, e.g. <code>--drop=console</code> removes all <code>console.*</code> calls
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--loader" type="string">
|
||||
Parse files with <code>.ext:loader</code>, e.g. <code>--loader .js:jsx</code>. Valid loaders: <code>js</code>,{" "}
|
||||
<code>jsx</code>, <code>ts</code>, <code>tsx</code>, <code>json</code>, <code>toml</code>, <code>text</code>,{" "}
|
||||
<code>file</code>, <code>wasm</code>, <code>napi</code>. Alias: <code>-l</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-macros" type="boolean">
|
||||
Disable macros from being executed in the bundler, transpiler and runtime
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--jsx-factory" type="string">
|
||||
Changes the function called when compiling JSX elements using the classic JSX runtime
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--jsx-fragment" type="string">
|
||||
Changes the function called when compiling JSX fragments
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--jsx-import-source" type="string" default="react">
|
||||
Declares the module specifier to be used for importing the jsx and jsxs factory functions. Default: <code>react</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--jsx-runtime" type="string" default="automatic">
|
||||
<code>automatic</code> (default) or <code>classic</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--jsx-side-effects" type="boolean">
|
||||
Treat JSX elements as having side effects (disable pure annotations)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--ignore-dce-annotations" type="boolean">
|
||||
Ignore tree-shaking annotations such as <code>@__PURE__</code>
|
||||
</ParamField>
|
||||
|
||||
### Networking & Security
|
||||
|
||||
<ParamField path="--port" type="number">
|
||||
Set the default port for <code>Bun.serve</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--fetch-preconnect" type="string">
|
||||
Preconnect to a URL while code is loading
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--max-http-header-size" type="number" default="16384">
|
||||
Set the maximum size of HTTP headers in bytes. Default is 16KiB
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--dns-result-order" type="string" default="verbatim">
|
||||
Set the default order of DNS lookup results. Valid orders: <code>verbatim</code> (default), <code>ipv4first</code>,{" "}
|
||||
<code>ipv6first</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--use-system-ca" type="boolean">
|
||||
Use the system's trusted certificate authorities
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--use-openssl-ca" type="boolean">
|
||||
Use OpenSSL's default CA store
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--use-bundled-ca" type="boolean">
|
||||
Use bundled CA store
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--redis-preconnect" type="boolean">
|
||||
Preconnect to <code>$REDIS_URL</code> at startup
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--sql-preconnect" type="boolean">
|
||||
Preconnect to PostgreSQL at startup
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--user-agent" type="string">
|
||||
Set the default User-Agent header for HTTP requests
|
||||
</ParamField>
|
||||
|
||||
### Global Configuration & Context
|
||||
|
||||
<ParamField path="--env-file" type="string">
|
||||
Load environment variables from the specified file(s)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--cwd" type="string">
|
||||
Absolute path to resolve files & entry points from. This just changes the process' cwd
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--config" type="string">
|
||||
Specify path to Bun config file. Default <code>$cwd/bunfig.toml</code>. Alias: <code>-c</code>
|
||||
</ParamField>
|
||||
|
||||
## Examples
|
||||
|
||||
Run a JavaScript or TypeScript file:
|
||||
|
||||
```bash
|
||||
bun run ./index.js
|
||||
bun run ./index.tsx
|
||||
```
|
||||
|
||||
Run a package.json script:
|
||||
|
||||
```bash
|
||||
bun run dev
|
||||
bun run lint
|
||||
```
|
||||
100
docs/snippets/cli/test.mdx
Normal file
100
docs/snippets/cli/test.mdx
Normal file
@@ -0,0 +1,100 @@
|
||||
# CLI Usage
|
||||
|
||||
```bash
|
||||
bun test <patterns>
|
||||
```
|
||||
|
||||
### Execution Control
|
||||
|
||||
<ParamField path="--timeout" type="number" default="5000">
|
||||
Set the per-test timeout in milliseconds (default 5000)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--rerun-each" type="number">
|
||||
Re-run each test file <code>NUMBER</code> times, helps catch certain bugs
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--concurrent" type="boolean">
|
||||
Treat all tests as <code>test.concurrent()</code> tests
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--randomize" type="boolean">
|
||||
Run tests in random order
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--seed" type="number">
|
||||
Set the random seed for test randomization
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--bail" type="number" default="1">
|
||||
Exit the test suite after <code>NUMBER</code> failures. If you do not specify a number, it defaults to 1.
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--max-concurrency" type="number" default="20">
|
||||
Maximum number of concurrent tests to execute at once (default 20)
|
||||
</ParamField>
|
||||
|
||||
### Test Filtering
|
||||
|
||||
<ParamField path="--todo" type="boolean">
|
||||
Include tests that are marked with <code>test.todo()</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--test-name-pattern" type="string">
|
||||
Run only tests with a name that matches the given regex. Alias: <code>-t</code>
|
||||
</ParamField>
|
||||
|
||||
### Reporting
|
||||
|
||||
<ParamField path="--reporter" type="string">
|
||||
Test output reporter format. Available: <code>junit</code> (requires --reporter-outfile), <code>dots</code>. Default:
|
||||
console output.
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--reporter-outfile" type="string">
|
||||
Output file path for the reporter format (required with --reporter)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--dots" type="boolean">
|
||||
Enable dots reporter. Shorthand for --reporter=dots
|
||||
</ParamField>
|
||||
|
||||
### Coverage
|
||||
|
||||
<ParamField path="--coverage" type="boolean">
|
||||
Generate a coverage profile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--coverage-reporter" type="string" default="text">
|
||||
Report coverage in <code>text</code> and/or <code>lcov</code>. Defaults to <code>text</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--coverage-dir" type="string" default="coverage">
|
||||
Directory for coverage files. Defaults to <code>coverage</code>
|
||||
</ParamField>
|
||||
|
||||
### Snapshots
|
||||
|
||||
<ParamField path="--update-snapshots" type="boolean">
|
||||
Update snapshot files. Alias: <code>-u</code>
|
||||
</ParamField>
|
||||
|
||||
## Examples
|
||||
|
||||
Run all test files:
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
bun test
|
||||
```
|
||||
|
||||
Run all test files with "foo" or "bar" in the file name:
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
bun test foo bar
|
||||
```
|
||||
|
||||
Run all test files, only including tests whose names includes "baz":
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
bun test --test-name-pattern baz
|
||||
```
|
||||
144
docs/snippets/cli/update.mdx
Normal file
144
docs/snippets/cli/update.mdx
Normal file
@@ -0,0 +1,144 @@
|
||||
## CLI Usage
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
bun update <package> <version>
|
||||
```
|
||||
|
||||
### Update Strategy
|
||||
|
||||
<ParamField path="--force" type="boolean">
|
||||
Always request the latest versions from the registry & reinstall all dependencies. Alias: <code>-f</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--latest" type="boolean">
|
||||
Update packages to their latest versions
|
||||
</ParamField>
|
||||
|
||||
### Dependency Scope
|
||||
|
||||
<ParamField path="--production" type="boolean">
|
||||
Don't install devDependencies. Alias: <code>-p</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--global" type="boolean">
|
||||
Install globally. Alias: <code>-g</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--omit" type="string">
|
||||
Exclude <code>dev</code>, <code>optional</code>, or <code>peer</code> dependencies from install
|
||||
</ParamField>
|
||||
|
||||
### Project File Management
|
||||
|
||||
<ParamField path="--yarn" type="boolean">
|
||||
Write a <code>yarn.lock</code> file (yarn v1). Alias: <code>-y</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-save" type="boolean">
|
||||
Don't update <code>package.json</code> or save a lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--save" type="boolean" default="true">
|
||||
Save to <code>package.json</code> (true by default)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--frozen-lockfile" type="boolean">
|
||||
Disallow changes to lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--save-text-lockfile" type="boolean">
|
||||
Save a text-based lockfile
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--lockfile-only" type="boolean">
|
||||
Generate a lockfile without installing dependencies
|
||||
</ParamField>
|
||||
|
||||
### Network & Registry
|
||||
|
||||
<ParamField path="--ca" type="string">
|
||||
Provide a Certificate Authority signing certificate
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--cafile" type="string">
|
||||
Same as <code>--ca</code>, but as a file path to the certificate
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--registry" type="string">
|
||||
Use a specific registry by default, overriding <code>.npmrc</code>, <code>bunfig.toml</code> and environment variables
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--network-concurrency" type="number" default="48">
|
||||
Maximum number of concurrent network requests (default 48)
|
||||
</ParamField>
|
||||
|
||||
### Caching
|
||||
|
||||
<ParamField path="--cache-dir" type="string">
|
||||
Store & load cached data from a specific directory path
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-cache" type="boolean">
|
||||
Ignore manifest cache entirely
|
||||
</ParamField>
|
||||
|
||||
### Output & Logging
|
||||
|
||||
<ParamField path="--silent" type="boolean">
|
||||
Don't log anything
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--verbose" type="boolean">
|
||||
Excessively verbose logging
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-progress" type="boolean">
|
||||
Disable the progress bar
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--no-summary" type="boolean">
|
||||
Don't print a summary
|
||||
</ParamField>
|
||||
|
||||
### Script Execution
|
||||
|
||||
<ParamField path="--ignore-scripts" type="boolean">
|
||||
Skip lifecycle scripts in the project's <code>package.json</code> (dependency scripts are never run)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--concurrent-scripts" type="number" default="5">
|
||||
Maximum number of concurrent jobs for lifecycle scripts (default 5)
|
||||
</ParamField>
|
||||
|
||||
### Installation Controls
|
||||
|
||||
<ParamField path="--no-verify" type="boolean">
|
||||
Skip verifying integrity of newly downloaded packages
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--trust" type="boolean">
|
||||
Add to <code>trustedDependencies</code> in the project's <code>package.json</code> and install the package(s)
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--backend" type="string" default="clonefile">
|
||||
Platform-specific optimizations for installing dependencies. Possible values: <code>clonefile</code> (default),{" "}
|
||||
<code>hardlink</code>, <code>symlink</code>, <code>copyfile</code>
|
||||
</ParamField>
|
||||
|
||||
### General & Environment
|
||||
|
||||
<ParamField path="--config" type="string">
|
||||
Specify path to config file (<code>bunfig.toml</code>). Alias: <code>-c</code>
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--dry-run" type="boolean">
|
||||
Don't install anything
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--cwd" type="string">
|
||||
Set a specific cwd
|
||||
</ParamField>
|
||||
|
||||
<ParamField path="--help" type="boolean">
|
||||
Print this help menu. Alias: <code>-h</code>
|
||||
</ParamField>
|
||||
548
docs/snippets/guides.jsx
Normal file
548
docs/snippets/guides.jsx
Normal file
@@ -0,0 +1,548 @@
|
||||
export const GuidesList = () => {
|
||||
const guidesData = {
|
||||
hero: {
|
||||
title: "Guides",
|
||||
blurb: "A collection of code samples and walkthroughs for performing common tasks with Bun.",
|
||||
},
|
||||
featured: [
|
||||
{
|
||||
category: "Ecosystem",
|
||||
title: "Build a frontend using Vite and Bun",
|
||||
href: "/guides/ecosystem/vite",
|
||||
cta: "View guide",
|
||||
},
|
||||
{
|
||||
category: "Runtime",
|
||||
title: "Install TypeScript declarations for Bun",
|
||||
href: "/guides/runtime/typescript",
|
||||
cta: "View guide",
|
||||
},
|
||||
{
|
||||
category: "Streams",
|
||||
title: "Convert a ReadableStream to a string",
|
||||
href: "/guides/streams/to-string",
|
||||
cta: "View guide",
|
||||
},
|
||||
{
|
||||
category: "HTTP",
|
||||
title: "Write a simple HTTP server",
|
||||
href: "/guides/http/simple",
|
||||
cta: "View guide",
|
||||
},
|
||||
{
|
||||
category: "WebSocket",
|
||||
title: "Build a simple WebSocket server",
|
||||
href: "/guides/websocket/simple",
|
||||
cta: "View guide",
|
||||
},
|
||||
{
|
||||
category: "Reading files",
|
||||
title: "Read a file as a string",
|
||||
href: "/guides/read-file/string",
|
||||
cta: "View guide",
|
||||
},
|
||||
],
|
||||
categories: [
|
||||
{
|
||||
key: "deployment",
|
||||
title: "Deployment",
|
||||
icon: "rocket",
|
||||
items: [
|
||||
{ title: "Deploy Bun on Vercel", href: "/guides/deployment/vercel" },
|
||||
{ title: "Deploy Bun on Railway", href: "/guides/deployment/railway" },
|
||||
{ title: "Deploy Bun on Render", href: "/guides/deployment/render" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "binary",
|
||||
title: "Binary data",
|
||||
icon: "binary",
|
||||
items: [
|
||||
{
|
||||
title: "Convert an ArrayBuffer to an array of numbers",
|
||||
href: "/guides/binary/arraybuffer-to-array",
|
||||
},
|
||||
{ title: "Convert an ArrayBuffer to a Blob", href: "/guides/binary/arraybuffer-to-blob" },
|
||||
{
|
||||
title: "Convert an ArrayBuffer to a Buffer",
|
||||
href: "/guides/binary/arraybuffer-to-buffer",
|
||||
},
|
||||
{
|
||||
title: "Convert an ArrayBuffer to a string",
|
||||
href: "/guides/binary/arraybuffer-to-string",
|
||||
},
|
||||
{
|
||||
title: "Convert an ArrayBuffer to a Uint8Array",
|
||||
href: "/guides/binary/arraybuffer-to-typedarray",
|
||||
},
|
||||
{ title: "Convert a Blob to an ArrayBuffer", href: "/guides/binary/blob-to-arraybuffer" },
|
||||
{ title: "Convert a Blob to a DataView", href: "/guides/binary/blob-to-dataview" },
|
||||
{ title: "Convert a Blob to a ReadableStream", href: "/guides/binary/blob-to-stream" },
|
||||
{ title: "Convert a Blob to a string", href: "/guides/binary/blob-to-string" },
|
||||
{ title: "Convert a Blob to a Uint8Array", href: "/guides/binary/blob-to-typedarray" },
|
||||
{
|
||||
title: "Convert a Buffer to an ArrayBuffer",
|
||||
href: "/guides/binary/buffer-to-arraybuffer",
|
||||
},
|
||||
{ title: "Convert a Buffer to a blob", href: "/guides/binary/buffer-to-blob" },
|
||||
{
|
||||
title: "Convert a Buffer to a ReadableStream",
|
||||
href: "/guides/binary/buffer-to-readablestream",
|
||||
},
|
||||
{ title: "Convert a Buffer to a string", href: "/guides/binary/buffer-to-string" },
|
||||
{
|
||||
title: "Convert a Buffer to a Uint8Array",
|
||||
href: "/guides/binary/buffer-to-typedarray",
|
||||
},
|
||||
{ title: "Convert a DataView to a string", href: "/guides/binary/dataview-to-string" },
|
||||
{
|
||||
title: "Convert a Uint8Array to an ArrayBuffer",
|
||||
href: "/guides/binary/typedarray-to-arraybuffer",
|
||||
},
|
||||
{ title: "Convert a Uint8Array to a Blob", href: "/guides/binary/typedarray-to-blob" },
|
||||
{
|
||||
title: "Convert a Uint8Array to a Buffer",
|
||||
href: "/guides/binary/typedarray-to-buffer",
|
||||
},
|
||||
{
|
||||
title: "Convert a Uint8Array to a DataView",
|
||||
href: "/guides/binary/typedarray-to-dataview",
|
||||
},
|
||||
{
|
||||
title: "Convert a Uint8Array to a ReadableStream",
|
||||
href: "/guides/binary/typedarray-to-readablestream",
|
||||
},
|
||||
{
|
||||
title: "Convert a Uint8Array to a string",
|
||||
href: "/guides/binary/typedarray-to-string",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "ecosystem",
|
||||
title: "Ecosystem",
|
||||
icon: "puzzle",
|
||||
items: [
|
||||
{ title: "Use EdgeDB with Bun", href: "/guides/ecosystem/edgedb" },
|
||||
{ title: "Use Prisma ORM with Bun", href: "/guides/ecosystem/prisma" },
|
||||
{ title: "Use Prisma Postgres with Bun", href: "/guides/ecosystem/prisma-postgres" },
|
||||
{ title: "Create a Discord bot", href: "/guides/ecosystem/discordjs" },
|
||||
{ title: "Add Sentry to a Bun app", href: "/guides/ecosystem/sentry" },
|
||||
{ title: "Use Drizzle ORM with Bun", href: "/guides/ecosystem/drizzle" },
|
||||
{ title: "Build a React app with Bun", href: "/guides/ecosystem/react" },
|
||||
{ title: "Run Bun as a daemon with PM2", href: "/guides/ecosystem/pm2" },
|
||||
{ title: "Build an app with Nuxt and Bun", href: "/guides/ecosystem/nuxt" },
|
||||
{ title: "Build an app with Qwik and Bun", href: "/guides/ecosystem/qwik" },
|
||||
{ title: "Build an app with Astro and Bun", href: "/guides/ecosystem/astro" },
|
||||
{ title: "Build an app with Remix and Bun", href: "/guides/ecosystem/remix" },
|
||||
{ title: "Run Bun as a daemon with systemd", href: "/guides/ecosystem/systemd" },
|
||||
{ title: "Build an app with Next.js and Bun", href: "/guides/ecosystem/nextjs" },
|
||||
{ title: "Build an app with SvelteKit and Bun", href: "/guides/ecosystem/sveltekit" },
|
||||
{ title: "Build a frontend using Vite and Bun", href: "/guides/ecosystem/vite" },
|
||||
{ title: "Build an app with SolidStart and Bun", href: "/guides/ecosystem/solidstart" },
|
||||
{
|
||||
title: "Use Neon Postgres through Drizzle ORM",
|
||||
href: "/guides/ecosystem/neon-drizzle",
|
||||
},
|
||||
{ title: "Build an HTTP server using Hono and Bun", href: "/guides/ecosystem/hono" },
|
||||
{
|
||||
title: "Use Neon\'s Serverless Postgres with Bun",
|
||||
href: "/guides/ecosystem/neon-serverless-postgres",
|
||||
},
|
||||
{ title: "Build an HTTP server using Elysia and Bun", href: "/guides/ecosystem/elysia" },
|
||||
{ title: "Containerize a Bun application with Docker", href: "/guides/ecosystem/docker" },
|
||||
{
|
||||
title: "Build an HTTP server using Express and Bun",
|
||||
href: "/guides/ecosystem/express",
|
||||
},
|
||||
{
|
||||
title: "Server-side render (SSR) a React component",
|
||||
href: "/guides/ecosystem/ssr-react",
|
||||
},
|
||||
{ title: "Build an HTTP server using StricJS and Bun", href: "/guides/ecosystem/stric" },
|
||||
{
|
||||
title: "Read and write data to MongoDB using Mongoose and Bun",
|
||||
href: "/guides/ecosystem/mongoose",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "htmlrewriter",
|
||||
title: "HTMLRewriter",
|
||||
icon: "file-code-2",
|
||||
items: [
|
||||
{
|
||||
title: "Extract links from a webpage using HTMLRewriter",
|
||||
href: "/guides/html-rewriter/extract-links",
|
||||
},
|
||||
{
|
||||
title: "Extract social share images and Open Graph tags",
|
||||
href: "/guides/html-rewriter/extract-social-meta",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "http",
|
||||
title: "HTTP",
|
||||
icon: "globe",
|
||||
items: [
|
||||
{ title: "Common HTTP server usage", href: "/guides/http/server" },
|
||||
{ title: "Hot reload an HTTP server", href: "/guides/http/hot" },
|
||||
{ title: "Write a simple HTTP server", href: "/guides/http/simple" },
|
||||
{ title: "Start a cluster of HTTP servers", href: "/guides/http/cluster" },
|
||||
{ title: "Configure TLS on an HTTP server", href: "/guides/http/tls" },
|
||||
{ title: "Send an HTTP request using fetch", href: "/guides/http/fetch" },
|
||||
{ title: "Proxy HTTP requests using fetch()", href: "/guides/http/proxy" },
|
||||
{ title: "Stream a file as an HTTP Response", href: "/guides/http/stream-file" },
|
||||
{ title: "Upload files via HTTP using FormData", href: "/guides/http/file-uploads" },
|
||||
{ title: "fetch with unix domain sockets in Bun", href: "/guides/http/fetch-unix" },
|
||||
{
|
||||
title: "Streaming HTTP Server with Async Iterators",
|
||||
href: "/guides/http/stream-iterator",
|
||||
},
|
||||
{
|
||||
title: "Streaming HTTP Server with Node.js Streams",
|
||||
href: "/guides/http/stream-node-streams-in-bun",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "install",
|
||||
title: "Package manager",
|
||||
icon: "package",
|
||||
items: [
|
||||
{ title: "Add a dependency", href: "/guides/install/add" },
|
||||
{ title: "Add a Git dependency", href: "/guides/install/add-git" },
|
||||
{ title: "Add a peer dependency", href: "/guides/install/add-peer" },
|
||||
{ title: "Add a tarball dependency", href: "/guides/install/add-tarball" },
|
||||
{ title: "Add a trusted dependency", href: "/guides/install/trusted" },
|
||||
{ title: "Add an optional dependency", href: "/guides/install/add-optional" },
|
||||
{ title: "Add a development dependency", href: "/guides/install/add-dev" },
|
||||
{
|
||||
title: "Using bun install with Artifactory",
|
||||
href: "/guides/install/jfrog-artifactory",
|
||||
},
|
||||
{ title: "Generate a yarn-compatible lockfile", href: "/guides/install/yarnlock" },
|
||||
{
|
||||
title: "Migrate from npm install to bun install",
|
||||
href: "/guides/install/from-npm-install-to-bun-install",
|
||||
},
|
||||
{ title: "Configuring a monorepo using workspaces", href: "/guides/install/workspaces" },
|
||||
{ title: "Install a package under a different name", href: "/guides/install/npm-alias" },
|
||||
{
|
||||
title: "Configure git to diff Bun\'s lockb lockfile",
|
||||
href: "/guides/install/git-diff-bun-lockfile",
|
||||
},
|
||||
{
|
||||
title: "Install dependencies with Bun in GitHub Actions",
|
||||
href: "/guides/install/cicd",
|
||||
},
|
||||
{
|
||||
title: "Override the default npm registry for bun install",
|
||||
href: "/guides/install/custom-registry",
|
||||
},
|
||||
{
|
||||
title: "Using bun install with an Azure Artifacts npm registry",
|
||||
href: "/guides/install/azure-artifacts",
|
||||
},
|
||||
{
|
||||
title: "Configure a private registry for an organization scope with bun install",
|
||||
href: "/guides/install/registry-scope",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "processes",
|
||||
title: "Processes",
|
||||
icon: "cpu",
|
||||
items: [
|
||||
{ title: "Read from stdin", href: "/guides/process/stdin" },
|
||||
{ title: "Listen for CTRL+C", href: "/guides/process/ctrl-c" },
|
||||
{ title: "Listen to OS signals", href: "/guides/process/os-signals" },
|
||||
{ title: "Spawn a child process", href: "/guides/process/spawn" },
|
||||
{ title: "Parse command-line arguments", href: "/guides/process/argv" },
|
||||
{ title: "Read stderr from a child process", href: "/guides/process/spawn-stderr" },
|
||||
{ title: "Read stdout from a child process", href: "/guides/process/spawn-stdout" },
|
||||
{ title: "Get the process uptime in nanoseconds", href: "/guides/process/nanoseconds" },
|
||||
{ title: "Spawn a child process and communicate using IPC", href: "/guides/process/ipc" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "read-file",
|
||||
title: "Reading files",
|
||||
icon: "file",
|
||||
items: [
|
||||
{ title: "Read a JSON file", href: "/guides/read-file/json" },
|
||||
{ title: "Check if a file exists", href: "/guides/read-file/exists" },
|
||||
{ title: "Read a file to a Buffer", href: "/guides/read-file/buffer" },
|
||||
{ title: "Read a file as a string", href: "/guides/read-file/string" },
|
||||
{ title: "Get the MIME type of a file", href: "/guides/read-file/mime" },
|
||||
{ title: "Read a file to a Uint8Array", href: "/guides/read-file/uint8array" },
|
||||
{ title: "Read a file to an ArrayBuffer", href: "/guides/read-file/arraybuffer" },
|
||||
{ title: "Watch a directory for changes", href: "/guides/read-file/watch" },
|
||||
{ title: "Read a file as a ReadableStream", href: "/guides/read-file/stream" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "runtime",
|
||||
title: "Runtime",
|
||||
icon: "bot",
|
||||
items: [
|
||||
{ title: "Delete files", href: "/guides/runtime/delete-file" },
|
||||
{ title: "Delete directories", href: "/guides/runtime/delete-directory" },
|
||||
{ title: "Import a JSON file", href: "/guides/runtime/import-json" },
|
||||
{ title: "Import a TOML file", href: "/guides/runtime/import-toml" },
|
||||
{ title: "Import a YAML file", href: "/guides/runtime/import-yaml" },
|
||||
{ title: "Run a Shell Command", href: "/guides/runtime/shell" },
|
||||
{ title: "Re-map import paths", href: "/guides/runtime/tsconfig-paths" },
|
||||
{ title: "Set a time zone in Bun", href: "/guides/runtime/timezone" },
|
||||
{ title: "Set environment variables", href: "/guides/runtime/set-env" },
|
||||
{ title: "Import a HTML file as text", href: "/guides/runtime/import-html" },
|
||||
{ title: "Read environment variables", href: "/guides/runtime/read-env" },
|
||||
{
|
||||
title: "Build-time constants with --define",
|
||||
href: "/guides/runtime/build-time-constants",
|
||||
},
|
||||
{ title: "Debugging Bun with the web debugger", href: "/guides/runtime/web-debugger" },
|
||||
{ title: "Install and run Bun in GitHub Actions", href: "/guides/runtime/cicd" },
|
||||
{ title: "Install TypeScript declarations for Bun", href: "/guides/runtime/typescript" },
|
||||
{
|
||||
title: "Debugging Bun with the VS Code extension",
|
||||
href: "/guides/runtime/vscode-debugger",
|
||||
},
|
||||
{
|
||||
title: "Inspect memory usage using V8 heap snapshots",
|
||||
href: "/guides/runtime/heap-snapshot",
|
||||
},
|
||||
{
|
||||
title: "Define and replace static globals & constants",
|
||||
href: "/guides/runtime/define-constant",
|
||||
},
|
||||
{
|
||||
title: "Codesign a single-file JavaScript executable on macOS",
|
||||
href: "/guides/runtime/codesign-macos-executable",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "streams",
|
||||
title: "Streams",
|
||||
icon: "waves",
|
||||
items: [
|
||||
{ title: "Convert a ReadableStream to JSON", href: "/guides/streams/to-json" },
|
||||
{
|
||||
title: "Convert a Node.js Readable to JSON",
|
||||
href: "/guides/streams/node-readable-to-json",
|
||||
},
|
||||
{ title: "Convert a ReadableStream to a Blob", href: "/guides/streams/to-blob" },
|
||||
{
|
||||
title: "Convert a Node.js Readable to a Blob",
|
||||
href: "/guides/streams/node-readable-to-blob",
|
||||
},
|
||||
{ title: "Convert a ReadableStream to a Buffer", href: "/guides/streams/to-buffer" },
|
||||
{ title: "Convert a ReadableStream to a string", href: "/guides/streams/to-string" },
|
||||
{
|
||||
title: "Convert a Node.js Readable to a string",
|
||||
href: "/guides/streams/node-readable-to-string",
|
||||
},
|
||||
{
|
||||
title: "Convert a ReadableStream to a Uint8Array",
|
||||
href: "/guides/streams/to-typedarray",
|
||||
},
|
||||
{
|
||||
title: "Convert a ReadableStream to an ArrayBuffer",
|
||||
href: "/guides/streams/to-arraybuffer",
|
||||
},
|
||||
{
|
||||
title: "Convert a Node.js Readable to an Uint8Array",
|
||||
href: "/guides/streams/node-readable-to-uint8array",
|
||||
},
|
||||
{
|
||||
title: "Convert a Node.js Readable to an ArrayBuffer",
|
||||
href: "/guides/streams/node-readable-to-arraybuffer",
|
||||
},
|
||||
{
|
||||
title: "Convert a ReadableStream to an array of chunks",
|
||||
href: "/guides/streams/to-array",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "test",
|
||||
title: "Test runner",
|
||||
icon: "test-tube",
|
||||
items: [
|
||||
{ title: "Mock functions in bun test", href: "/guides/test/mock-functions" },
|
||||
{ title: "Spy on methods in bun test", href: "/guides/test/spy-on" },
|
||||
{ title: "Using Testing Library with Bun", href: "/guides/test/testing-library" },
|
||||
{ title: "Update snapshots in bun test", href: "/guides/test/update-snapshots" },
|
||||
{ title: "Run tests in watch mode with Bun", href: "/guides/test/watch-mode" },
|
||||
{ title: "Use snapshot testing in bun test", href: "/guides/test/snapshot" },
|
||||
{ title: "Bail early with the Bun test runner", href: "/guides/test/bail" },
|
||||
{ title: "Skip tests with the Bun test runner", href: "/guides/test/skip-tests" },
|
||||
{
|
||||
title: "Migrate from Jest to Bun's test runner",
|
||||
href: "/guides/test/migrate-from-jest",
|
||||
},
|
||||
{ title: "Run your tests with the Bun test runner", href: "/guides/test/run-tests" },
|
||||
{ title: "Set the system time in Bun's test runner", href: "/guides/test/mock-clock" },
|
||||
{
|
||||
title: "Write browser DOM tests with Bun and happy-dom",
|
||||
href: "/guides/test/happy-dom",
|
||||
},
|
||||
{
|
||||
title: "Set a per-test timeout with the Bun test runner",
|
||||
href: "/guides/test/timeout",
|
||||
},
|
||||
{
|
||||
title: 'Mark a test as a "todo" with the Bun test runner',
|
||||
href: "/guides/test/todo-tests",
|
||||
},
|
||||
{
|
||||
title: "Re-run tests multiple times with the Bun test runner",
|
||||
href: "/guides/test/rerun-each",
|
||||
},
|
||||
{
|
||||
title: "Set a code coverage threshold with the Bun test runner",
|
||||
href: "/guides/test/coverage-threshold",
|
||||
},
|
||||
{
|
||||
title: "Generate code coverage reports with the Bun test runner",
|
||||
href: "/guides/test/coverage",
|
||||
},
|
||||
{
|
||||
title: "import, require, and test Svelte components with bun test",
|
||||
href: "/guides/test/svelte-test",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "utilities",
|
||||
title: "Utilities",
|
||||
icon: "wrench",
|
||||
items: [
|
||||
{ title: "Hash a password", href: "/guides/util/hash-a-password" },
|
||||
{ title: "Generate a UUID", href: "/guides/util/javascript-uuid" },
|
||||
{ title: "Escape an HTML string", href: "/guides/util/escape-html" },
|
||||
{ title: "Get the current Bun version", href: "/guides/util/version" },
|
||||
{ title: "Encode and decode base64 strings", href: "/guides/util/base64" },
|
||||
{ title: "Check if two objects are deeply equal", href: "/guides/util/deep-equals" },
|
||||
{ title: "Detect when code is executed with Bun", href: "/guides/util/detect-bun" },
|
||||
{ title: "Get the directory of the current file", href: "/guides/util/import-meta-dir" },
|
||||
{ title: "Get the file name of the current file", href: "/guides/util/import-meta-file" },
|
||||
{
|
||||
title: "Convert a file URL to an absolute path",
|
||||
href: "/guides/util/file-url-to-path",
|
||||
},
|
||||
{ title: "Compress and decompress data with gzip", href: "/guides/util/gzip" },
|
||||
{
|
||||
title: "Convert an absolute path to a file URL",
|
||||
href: "/guides/util/path-to-file-url",
|
||||
},
|
||||
{
|
||||
title: "Get the path to an executable bin file",
|
||||
href: "/guides/util/which-path-to-executable-bin",
|
||||
},
|
||||
{ title: "Sleep for a fixed number of milliseconds", href: "/guides/util/sleep" },
|
||||
{ title: "Compress and decompress data with DEFLATE", href: "/guides/util/deflate" },
|
||||
{
|
||||
title: "Get the absolute path of the current file",
|
||||
href: "/guides/util/import-meta-path",
|
||||
},
|
||||
{ title: "Check if the current file is the entrypoint", href: "/guides/util/entrypoint" },
|
||||
{ title: "Get the absolute path to the current entrypoint", href: "/guides/util/main" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "websocket",
|
||||
title: "WebSocket",
|
||||
icon: "radio",
|
||||
items: [
|
||||
{ title: "Build a simple WebSocket server", href: "/guides/websocket/simple" },
|
||||
{
|
||||
title: "Enable compression for WebSocket messages",
|
||||
href: "/guides/websocket/compression",
|
||||
},
|
||||
{ title: "Build a publish-subscribe WebSocket server", href: "/guides/websocket/pubsub" },
|
||||
{
|
||||
title: "Set per-socket contextual data on a WebSocket",
|
||||
href: "/guides/websocket/context",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "write-file",
|
||||
title: "Writing files",
|
||||
icon: "file-pen",
|
||||
items: [
|
||||
{ title: "Delete a file", href: "/guides/write-file/unlink" },
|
||||
{ title: "Write to stdout", href: "/guides/write-file/stdout" },
|
||||
{ title: "Write a Blob to a file", href: "/guides/write-file/blob" },
|
||||
{ title: "Write a file to stdout", href: "/guides/write-file/cat" },
|
||||
{ title: "Append content to a file", href: "/guides/write-file/append" },
|
||||
{ title: "Write a string to a file", href: "/guides/write-file/basic" },
|
||||
{ title: "Write a file incrementally", href: "/guides/write-file/filesink" },
|
||||
{ title: "Write a Response to a file", href: "/guides/write-file/response" },
|
||||
{ title: "Copy a file to another location", href: "/guides/write-file/file-cp" },
|
||||
{ title: "Write a ReadableStream to a file", href: "/guides/write-file/stream" },
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
return (
|
||||
<div id="guides-list">
|
||||
{/* Featured cards */}
|
||||
<div className="mb-12">
|
||||
<h2 className="text-2xl font-bold mb-6">Featured</h2>
|
||||
<Columns cols={3}>
|
||||
{guidesData.featured.map(g => (
|
||||
<Card key={g.href} title={g.title} href={g.href} cta={g.cta} />
|
||||
))}
|
||||
</Columns>
|
||||
</div>
|
||||
return (
|
||||
<div id="guides-list">
|
||||
{/* Featured cards */}
|
||||
<div className="mb-12">
|
||||
<h2 className="text-2xl font-bold mb-6">Featured</h2>
|
||||
<Columns cols={3}>
|
||||
{guidesData.featured.map(g => (
|
||||
<Card key={g.href} title={g.title} href={g.href} cta={g.cta} />
|
||||
))}
|
||||
</Columns>
|
||||
</div>
|
||||
|
||||
{/* All guides organized by category */}
|
||||
<div className="mb-8">
|
||||
<h2 className="text-2xl font-bold mb-6">All Guides</h2>
|
||||
{guidesData.categories.map(category => (
|
||||
<div key={category.key} className="mb-8">
|
||||
<h3 className="text-xl font-semibold mb-4 flex items-center gap-2">{category.title}</h3>
|
||||
<Columns cols={3}>
|
||||
{category.items.map(guide => (
|
||||
<Card key={guide.href} title={guide.title} description=" " href={guide.href} cta="" />
|
||||
))}
|
||||
</Columns>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
{/* All guides organized by category */}
|
||||
<div className="mb-8">
|
||||
<h2 className="text-2xl font-bold mb-6">All Guides</h2>
|
||||
{guidesData.categories.map(category => (
|
||||
<div key={category.key} className="mb-8">
|
||||
<h3 className="text-xl font-semibold mb-4 flex items-center gap-2">{category.title}</h3>
|
||||
<Columns cols={3}>
|
||||
{category.items.map(guide => (
|
||||
<Card key={guide.href} title={guide.title} description=" " href={guide.href} cta="" />
|
||||
))}
|
||||
</Columns>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
32
docs/snippets/product-card.mdx
Normal file
32
docs/snippets/product-card.mdx
Normal file
@@ -0,0 +1,32 @@
|
||||
export const ProductCard = ({ img, href, title, description, model, type }) => {
|
||||
return (
|
||||
<a href={href} target="_blank" rel="noopener noreferrer" className="group">
|
||||
<div className="flex flex-col gap-4 rounded-xl md:p-1">
|
||||
<div className="w-full h-32 overflow-hidden rounded-xl bg-gray-100 dark:bg-gray-800">
|
||||
<img
|
||||
src={img}
|
||||
className="w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"
|
||||
alt={title}
|
||||
loading="lazy"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-col gap-3 pb-2">
|
||||
<h2 className="text-md font-medium text-gray-900 dark:text-gray-200 group-hover:text-gray-600 dark:group-hover:text-gray-400 transition-colors mb-[-8px]">
|
||||
{title}
|
||||
</h2>
|
||||
<p className="text-gray-500 dark:text-gray-400 text-sm font-medium">{description}</p>
|
||||
<div className="flex gap-2 mt-2 mb-1">
|
||||
<span className="bg-gray-100 dark:bg-[#181817] text-gray-600 dark:text-white rounded-lg px-2 py-1 text-sm font-medium">
|
||||
{model}
|
||||
</span>
|
||||
<span className="bg-primary-light dark:bg-primary-dark text-white dark:text-white rounded-lg px-2 py-1 text-sm font-medium">
|
||||
{type}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
);
|
||||
};
|
||||
|
||||
;
|
||||
94
docs/snippets/product-tiles.mdx
Normal file
94
docs/snippets/product-tiles.mdx
Normal file
@@ -0,0 +1,94 @@
|
||||
export const ProductTiles = ({ categories, hideButtons = false }) => {
|
||||
const [activeCategory, setActiveCategory] = useState(categories[0].id)
|
||||
const [activeSubTab, setActiveSubTab] = useState(
|
||||
categories[0].items[0]?.id ?? null
|
||||
)
|
||||
|
||||
const currentCategory = categories.find((cat) => cat.id === activeCategory)
|
||||
const currentSub = currentCategory?.items.find(
|
||||
(item) => item.id === activeSubTab
|
||||
)
|
||||
|
||||
return (
|
||||
|
||||
<div className="not-prose space-y-6">
|
||||
{!hideButtons && (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{categories.map((cat) => (
|
||||
<button
|
||||
key={cat.id}
|
||||
onClick={() => {
|
||||
setActiveCategory(cat.id)
|
||||
setActiveSubTab(cat.items[0]?.id ?? null)
|
||||
}}
|
||||
className={`px-4 py-2 text-sm rounded-full font-medium transition-colors ${activeCategory === cat.id
|
||||
? 'bg-[#0A0B0D] text-white dark:bg-white dark:text-[#0A0B0D] border-black'
|
||||
: 'bg-gray-100 dark:bg-white/10 text-black dark:text-white'
|
||||
}`} >
|
||||
{cat.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div>
|
||||
{currentCategory?.items?.length ? (
|
||||
<div className="flex flex-col lg:flex-row gap-6 bg-gray-100 dark:bg-[#141414] rounded-2xl">
|
||||
<div className="flex flex-col w-full lg:w-1/2 space-y-2 p-4">
|
||||
{currentCategory.items.map((item) => (
|
||||
<a
|
||||
key={item.id}
|
||||
href={item.href}
|
||||
onMouseOver={() => setActiveSubTab(item.id)}
|
||||
className={`flex items-start gap-1.5 text-left px-5 py-3 rounded-2xl transition-all ${activeSubTab === item.id
|
||||
? 'bg-white dark:bg-white/5'
|
||||
: ''
|
||||
}`}
|
||||
>
|
||||
<div className="text-xl mr-3 mt-1"><img src={item.icon} alt={item.title} className="w-8 h-8" /></div>
|
||||
<div className="flex-1">
|
||||
<h3 className="font-medium text-base text-black dark:text-white">
|
||||
{item.title}
|
||||
</h3>
|
||||
<p className="text-sm text-gray-600 dark:text-gray-400">{item.desc}</p>
|
||||
</div>
|
||||
<div className={`flex items-center justify-center min-w-[24px] self-center ${activeSubTab === item.id ? 'opacity-100' : 'opacity-0'}`}>
|
||||
<div className="hidden dark:block">
|
||||
<Icon icon="chevron-right" size="14" color="#FFF" />
|
||||
</div>
|
||||
<div className="block dark:hidden">
|
||||
<Icon icon="chevron-right" size="14" color="#0A0B0D" />
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
<div className="group w-full h-fit lg:w-1/2 rounded-2xl flex items-center justify-center overflow-hidden min-h-[320px] p-4">
|
||||
{currentSub?.image ? (
|
||||
<>
|
||||
<img
|
||||
src={currentSub.image.light}
|
||||
alt={currentSub.title}
|
||||
className="block dark:hidden w-full h-full object-cover rounded-xl"
|
||||
/>
|
||||
<img
|
||||
src={currentSub.image.dark}
|
||||
alt={currentSub.title}
|
||||
className="hidden dark:block w-full h-full object-cover rounded-xl"
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<p className="text-gray-400 dark:text-gray-500 p-8">No preview available</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-sm text-gray-500 dark:text-gray-400">
|
||||
No features available for this category.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user