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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/.kodiak.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ versions = ["minor", "patch"]
usernames = ["renovate"]

[approve]
auto_approve_usernames = ["renovate"]
auto_approve_usernames = ["renovate"]
4 changes: 3 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Explain the **motivation** for making this change. What existing problem does th

For us to review and ship your PR efficiently, please perform the following steps:

- [ ] Open a [bug/issue](https://github.com/netlify/cli/issues/new/choose) before writing your code 🧑‍💻. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you\`re fixing a typo or something that\`s on fire 🔥 (e.g. incident related), you can skip this step.
- [ ] Open a [bug/issue](https://github.com/netlify/cli/issues/new/choose) before writing your code 🧑‍💻. This ensures we
can discuss the changes and get feedback from everyone that should be involved. If you\`re fixing a typo or
something that\`s on fire 🔥 (e.g. incident related), you can skip this step.
Comment thread
serhalp marked this conversation as resolved.
- [ ] Read the [contribution guidelines](../CONTRIBUTING.md) 📖. This ensures your code follows our style guide and
passes our tests.
- [ ] Update or add tests (if any source code was changed or added) 🧪
Expand Down
10 changes: 10 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"semi": false,
"singleQuote": true,
"printWidth": 120,
"proseWrap": "always",
"trailingComma": "all",
Comment on lines +3 to +7

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to just use defaults, but this matches our Netlify code style

"sortPackageJson": false,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could turn this one later 😁. I didn't wanna touch too many things here.

"ignorePatterns": ["node_modules", "CHANGELOG.md", "docs/**", "**/package-lock.json"]
}
3 changes: 0 additions & 3 deletions .prettierignore

This file was deleted.

7 changes: 0 additions & 7 deletions .prettierrc.json

This file was deleted.

29 changes: 27 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
## Development Commands

### Build and Development

- `npm run build` - Compiles TypeScript using `tsc --project tsconfig.build.json`
- `npm run dev` - Runs TypeScript compiler in watch mode
- `npm run clean` - Removes the `dist/` directory

### Testing

- `npm test` - Runs the full test suite (unit, integration, and e2e tests)
- `npm run test:unit` - Runs unit tests only with `vitest run tests/unit/`
- `npm run test:integration` - Runs integration tests with `vitest run --retry=3 tests/integration/`
Expand All @@ -20,26 +22,32 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
- `npm run test:init` - Sets up test dependencies for various fixtures (Hugo, Next.js, monorepo)

### Code Quality

- `npm run lint` - Runs ESLint with cache
- `npm run lint:fix` - Runs ESLint and automatically fixes issues
- `npm run format` - Formats code with Prettier
- `npm run format` - Formats code with oxfmt
- `npm run format:check` - Checks code formatting without modifying files
- `npm run typecheck` - Runs TypeScript type checking
- `npm run typecheck:watch` - Runs TypeScript type checking in watch mode

### Running the CLI Locally

- `./bin/run.js [command]` - Runs the CLI locally
- `DEBUG=true ./bin/run.js [command]` - Runs with stack traces enabled for debugging
- `npm run start -- [command]` - Alternative way to run CLI locally

## Architecture

### Core Structure
The Netlify CLI is built with **Commander.js** for CLI interface, **@netlify/js-client** for API interactions, and **TypeScript** with modular architecture. The system uses a registry pattern for managing Functions and Edge Functions, with sophisticated local development server capabilities.

The Netlify CLI is built with **Commander.js** for CLI interface, **@netlify/js-client** for API interactions, and
**TypeScript** with modular architecture. The system uses a registry pattern for managing Functions and Edge Functions,
with sophisticated local development server capabilities.

### Key Architectural Patterns

#### Command Architecture

- All commands extend `BaseCommand` class (`src/commands/base-command.ts`) which provides:
- Consistent config loading and API client setup
- Site information management and linking
Expand All @@ -49,6 +57,7 @@ The Netlify CLI is built with **Commander.js** for CLI interface, **@netlify/js-
- Each command supports both interactive prompts and non-interactive flag-based operation

#### Registry Pattern for Runtime Management

- **FunctionsRegistry** (`src/lib/functions/registry.ts`): Manages Netlify Functions lifecycle
- Supports multiple runtimes (JavaScript/TypeScript, Go, Rust)
- Handles hot reloading and file watching
Expand All @@ -58,14 +67,17 @@ The Netlify CLI is built with **Commander.js** for CLI interface, **@netlify/js-
- Handles Edge Function deployment and local serving

#### Development Server Architecture (`netlify dev`)

The dev server (`src/commands/dev/dev.ts`) orchestrates multiple subsystems:

- **Proxy Server**: Routes requests between static files, functions, and edge functions
- **Functions Server**: Executes Netlify Functions locally with runtime-specific handlers
- **Edge Functions Proxy**: Serves Edge Functions via Deno runtime
- **Framework Detection**: Auto-detects and integrates with various web frameworks
- **Live Tunneling**: Provides public URLs for local development via Netlify's tunnel service

#### Config System

- Uses `@netlify/config` for configuration resolution and normalization
- Supports `netlify.toml` files with environment-specific overrides
- Integrates with Netlify's build plugins system
Expand All @@ -74,30 +86,35 @@ The dev server (`src/commands/dev/dev.ts`) orchestrates multiple subsystems:
### Key Libraries and Their Roles

#### Core Infrastructure

- `src/lib/api.ts` - Netlify API client wrapper with authentication
- `src/lib/build.ts` - Build system integration and config caching
- `src/lib/settings.ts` - Project and global settings management
- `src/utils/command-helpers.ts` - Shared utilities for CLI commands (logging, error handling, prompts)

#### Function Runtime System

- `src/lib/functions/runtimes/` - Runtime-specific builders and executors
- `js/` - JavaScript/TypeScript function handling with `zip-it-and-ship-it`
- `go/` - Go function compilation and execution
- `rust/` - Rust function compilation via Cargo
- `src/lib/functions/server.ts` - Local function server with request/response handling

#### Development Tools

- `src/utils/dev.ts` - Development server utilities and environment setup
- `src/utils/proxy-server.ts` - HTTP proxy for routing dev server requests
- `src/utils/detect-server-settings.ts` - Framework detection and port management

#### Deployment System

- `src/utils/deploy/` - Site deployment orchestration
- File hashing, diffing, and upload optimization
- Build artifact management and caching
- Progress tracking and status reporting

### Testing Architecture

- **Unit Tests** (`tests/unit/`): Test individual modules and utilities
- **Integration Tests** (`tests/integration/`): Test full command workflows using fixtures
- **E2E Tests**: Test complete user scenarios with real Netlify API interactions
Expand All @@ -106,30 +123,38 @@ The dev server (`src/commands/dev/dev.ts`) orchestrates multiple subsystems:
### Important Implementation Details

#### Environment Variable Handling

Environment variables are loaded from multiple sources with specific precedence:

1. Process environment
2. `.env` files (multiple variants supported)
3. Netlify site settings (shared, project-specific)
4. Addon-provided variables
5. Build-time configuration

#### Function URL Routing

Functions are accessible via standardized URL patterns:

- `/.netlify/functions/[function-name]` - Standard functions
- `/.netlify/builders/[function-name]` - On-demand builders
- Custom paths supported via function configuration

#### Build Plugin Integration

The CLI integrates with Netlify's build plugin system, allowing plugins to:

- Modify build configuration
- Add custom build steps
- Integrate with the development server
- Provide additional CLI commands

### Development Setup Requirements

- Node.js 22.13.0+ required
- Git LFS must be installed for full test suite
- Some integration tests require Netlify Auth Token (`NETLIFY_AUTH_TOKEN`) or login via `./bin/run.js login`

### Coding Style:

- Never write comments on what the code does, make the code clean and self explanatory instead
64 changes: 25 additions & 39 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making
participation in our project and our community a harassment-free experience for everyone, regardless of age, body size,
disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race,
religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:
Examples of behavior that contributes to creating a positive environment include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
Expand All @@ -22,53 +19,42 @@

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
- Publishing others' private information, such as a physical or electronic address, without explicit permission

Check warning on line 25 in CODE_OF_CONDUCT.md

View workflow job for this annotation

GitHub Actions / lint-docs

[vale] reported by reviewdog 🐶 [smart-marks.smartApostrophes] Use a smart apostrophe (’) instead of a straight single quote mark in ' others' ' Raw Output: {"message": "[smart-marks.smartApostrophes] Use a smart apostrophe (’) instead of a straight single quote mark in ' others' '", "location": {"path": "CODE_OF_CONDUCT.md", "range": {"start": {"line": 25, "column": 13}}}, "severity": "WARNING"}
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take
appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits,
issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any
contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the
project or its community. Examples of representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed representative at an online or offline
event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at david@netlify.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at
david@netlify.com. All complaints will be reviewed and investigated and will result in a response that is deemed
necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to
the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent
repercussions as determined by other members of the project's leadership.

Check warning on line 52 in CODE_OF_CONDUCT.md

View workflow job for this annotation

GitHub Actions / lint-docs

[vale] reported by reviewdog 🐶 [smart-marks.smartApostrophes] Use a smart apostrophe (’) instead of a straight single quote mark in 'project's' Raw Output: {"message": "[smart-marks.smartApostrophes] Use a smart apostrophe (’) instead of a straight single quote mark in 'project's'", "location": {"path": "CODE_OF_CONDUCT.md", "range": {"start": {"line": 52, "column": 53}}}, "severity": "WARNING"}

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at
[http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@

Make sure everything is correctly set up by running those tests first.

We recommend you set up your IDE or text editor to run ESLint and Prettier automatically on file save. Otherwise, you
can run them manually using:
We recommend you set up your IDE or text editor to run ESLint and oxfmt automatically on file save. Otherwise, you can

Check warning on line 69 in CONTRIBUTING.md

View workflow job for this annotation

GitHub Actions / lint-docs

[vale] reported by reviewdog 🐶 [base.spelling] Spellcheck: did you really mean 'oxfmt'? Raw Output: {"message": "[base.spelling] Spellcheck: did you really mean 'oxfmt'?", "location": {"path": "CONTRIBUTING.md", "range": {"start": {"line": 69, "column": 67}}}, "severity": "WARNING"}

Check warning on line 69 in CONTRIBUTING.md

View workflow job for this annotation

GitHub Actions / lint-docs

[vale] reported by reviewdog 🐶 [base.spelling] Spellcheck: did you really mean 'ESLint'? Raw Output: {"message": "[base.spelling] Spellcheck: did you really mean 'ESLint'?", "location": {"path": "CONTRIBUTING.md", "range": {"start": {"line": 69, "column": 56}}}, "severity": "WARNING"}
run them manually using:

```bash
npm run format
Expand Down
2 changes: 1 addition & 1 deletion bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const UPDATE_BOXEN_OPTIONS = {
padding: 1,
margin: 1,
textAlignment: 'center',
borderStyle: 'round',
borderStyle: 'round',
borderColor: NETLIFY_CYAN_HEX,
float: 'center',
// This is an intentional half-width space to work around a unicode padding math bug in boxen
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Config } from "@netlify/functions"
import type { Config } from '@netlify/functions'

export default async (req: Request) => {
const { next_run } = await req.json()
const { next_run } = await req.json()

console.log("Received event! Next invocation at:", next_run)
console.log('Received event! Next invocation at:', next_run)
}

export const config: Config = {
schedule: "@hourly"
schedule: '@hourly',
}
2 changes: 1 addition & 1 deletion layout.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
Loading
Loading