Skip to content

Commit

Permalink
fix!: upgrade to commander@12 and fix some conflicting short option n…
Browse files Browse the repository at this point in the history
…ames (#7008)

* fix: use a valid short flag for blobs:get output

`-o` is already used in the base command for `--offline`, so this was being quietly ignored

This can't be considered a breaking change as it has never worked. (I just tried it to be sure.)

See tj/commander.js#2055.

* fix: avoid redefining `--json` option in commands

See tj/commander.js#2055.

* fix: fix duplicate `-o` option for deploy command

It's already used in the BaseCommand for `--offline`.

This is not a breaking change, because this never worked as is.

Same issue as in 9280c55.

* fix: fix duplicate `-a` option in deploy command

It's already defined in the BaseCommand for `--offline`.

* fix: fix still more `--json` option overrides

* fix: fix env:import options

`-r` was already used globally so this was being ignored

* fix: don't mutate the commander singleton

It was redefining the options over and over and over. The latest commander throws.

* chore(deps): bump astro in docs site

* fix(deps): upgrade to commander@12

* types(site): fix jsdoc types in docs script

* fix: remove `--json`, `--offline` from BaseCommand

and centralize `--auth` only in `BaseCommand`

commander@12 doesn't allow redefining the same option, so this pattern was no longer viable

This was a pure refactor, but it uncovered some commands that weren't declaring options they were using, so I fixed
those too.

* fix: undo unnecessary short flag change
  • Loading branch information
serhalp authored Feb 21, 2025
1 parent 5435e79 commit 42b4a6c
Show file tree
Hide file tree
Showing 36 changed files with 271 additions and 141 deletions.
1 change: 1 addition & 0 deletions docs/commands/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ netlify api
- `data` (*string*) - Data to use
- `list` (*boolean*) - List out available API methods
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

**Examples**

Expand Down
5 changes: 5 additions & 0 deletions docs/commands/blobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ netlify blobs

- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

| Subcommand | description |
|:--------------------------- |:-----|
Expand Down Expand Up @@ -61,6 +62,7 @@ netlify blobs:delete
- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `force` (*boolean*) - Bypasses prompts & Force the command to run.
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

---
## `blobs:get`
Expand All @@ -83,6 +85,7 @@ netlify blobs:get
- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `output` (*string*) - Defines the filesystem path where the blob data should be persisted
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

---
## `blobs:list`
Expand All @@ -106,6 +109,7 @@ netlify blobs:list
- `json` (*boolean*) - Output list contents as JSON
- `prefix` (*string*) - A string for filtering down the entries; when specified, only the entries whose key starts with that prefix are returned
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

---
## `blobs:set`
Expand All @@ -130,6 +134,7 @@ netlify blobs:set
- `force` (*boolean*) - Bypasses prompts & Force the command to run.
- `input` (*string*) - Defines the filesystem path where the blob data should be read from
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

---

Expand Down
3 changes: 2 additions & 1 deletion docs/commands/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ netlify build
- `context` (*string*) - Specify a build context or branch (contexts: "production", "deploy-preview", "branch-deploy", "dev")
- `dry` (*boolean*) - Dry run: show instructions without running them
- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `offline` (*boolean*) - disables any features that require network access
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in
- `offline` (*boolean*) - Disables any features that require network access

**Examples**

Expand Down
2 changes: 2 additions & 0 deletions docs/commands/completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ netlify completion
**Flags**

- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

| Subcommand | description |
|:--------------------------- |:-----|
Expand Down Expand Up @@ -47,6 +48,7 @@ netlify completion:install

- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

---

Expand Down
6 changes: 3 additions & 3 deletions docs/commands/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ netlify deploy
**Flags**

- `alias` (*string*) - Specifies the alias for deployment, the string at the beginning of the deploy subdomain. Useful for creating predictable deployment URLs. Avoid setting an alias string to the same value as a deployed branch. `alias` doesn’t create a branch deploy and can’t be used in conjunction with the branch subdomain feature. Maximum 37 characters.
- `auth` (*string*) - Netlify auth token to deploy with
- `branch` (*string*) - Serves the same functionality as --alias. Deprecated and will be removed in future versions
- `build` (*boolean*) - Run build command before deploying
- `context` (*string*) - Context to use when resolving build configuration
Expand All @@ -94,14 +93,15 @@ netlify deploy
- `functions` (*string*) - Specify a functions folder to deploy
- `json` (*boolean*) - Output deployment data as JSON
- `message` (*string*) - A short message to include in the deploy log
- `prod-if-unlocked` (*boolean*) - Deploy to production if unlocked, create a draft otherwise
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in
- `open` (*boolean*) - Open site after deploy
- `prod` (*boolean*) - Deploy to production
- `prod-if-unlocked` (*boolean*) - Deploy to production if unlocked, create a draft otherwise
- `site` (*string*) - A site name or ID to deploy to
- `skip-functions-cache` (*boolean*) - Ignore any functions created as part of a previous `build` or `deploy` commands, forcing them to be bundled again as part of the deployment
- `timeout` (*string*) - Timeout to wait for deployment to finish
- `trigger` (*boolean*) - Trigger a new build of your site on Netlify without uploading local files
- `debug` (*boolean*) - Print debugging information

**Examples**

Expand Down
6 changes: 4 additions & 2 deletions docs/commands/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ netlify dev
- `geo` (*cache | mock | update*) - force geolocation data to be updated, use cached data from the last 24h if found, or use a mock location
- `live` (*string*) - start a public live session; optionally, supply a subdomain to generate a custom URL
- `no-open` (*boolean*) - disables the automatic opening of a browser window
- `offline` (*boolean*) - disables any features that require network access
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in
- `offline` (*boolean*) - Disables any features that require network access
- `port` (*string*) - port of netlify dev
- `target-port` (*string*) - port of target app server
- `debug` (*boolean*) - Print debugging information

| Subcommand | description |
|:--------------------------- |:-----|
Expand Down Expand Up @@ -76,6 +77,7 @@ netlify dev:exec
- `context` (*string*) - Specify a deploy context or branch for environment variables (contexts: "production", "deploy-preview", "branch-deploy", "dev")
- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

**Examples**

Expand Down
17 changes: 14 additions & 3 deletions docs/commands/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ netlify env

- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

| Subcommand | description |
|:--------------------------- |:-----|
Expand Down Expand Up @@ -60,6 +61,7 @@ netlify env:clone
- `from` (*string*) - Site ID (From)
- `to` (*string*) - Site ID (To)
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

**Examples**

Expand Down Expand Up @@ -87,8 +89,10 @@ netlify env:get

- `context` (*string*) - Specify a deploy context or branch (contexts: "production", "deploy-preview", "branch-deploy", "dev")
- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `scope` (*builds | functions | post-processing | runtime | any*) - Specify a scope
- `json` (*boolean*) - Output environment variables as JSON
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in
- `scope` (*builds | functions | post-processing | runtime | any*) - Specify a scope

**Examples**

Expand Down Expand Up @@ -117,8 +121,10 @@ netlify env:import
**Flags**

- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `json` (*boolean*) - Output environment variables as JSON
- `replace-existing` (*boolean*) - Replace all existing variables instead of merging them with the current ones
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

---
## `env:list`
Expand All @@ -136,9 +142,10 @@ netlify env:list
- `context` (*string*) - Specify a deploy context or branch (contexts: "production", "deploy-preview", "branch-deploy", "dev")
- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `json` (*boolean*) - Output environment variables as JSON
- `plain` (*boolean*) - Output environment variables as plaintext
- `scope` (*builds | functions | post-processing | runtime | any*) - Specify a scope
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in
- `plain` (*boolean*) - Output environment variables as plaintext

**Examples**

Expand Down Expand Up @@ -171,9 +178,11 @@ netlify env:set
- `context` (*string*) - Specify a deploy context or branch (contexts: "production", "deploy-preview", "branch-deploy", "dev") (default: all contexts)
- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `force` (*boolean*) - Bypasses prompts & Force the command to run.
- `scope` (*builds | functions | post-processing | runtime*) - Specify a scope (default: all scopes)
- `json` (*boolean*) - Output environment variables as JSON
- `secret` (*boolean*) - Indicate whether the environment variable value can be read again.
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in
- `scope` (*builds | functions | post-processing | runtime*) - Specify a scope (default: all scopes)

**Examples**

Expand Down Expand Up @@ -207,7 +216,9 @@ netlify env:unset
- `context` (*string*) - Specify a deploy context or branch (contexts: "production", "deploy-preview", "branch-deploy", "dev") (default: all contexts)
- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `force` (*boolean*) - Bypasses prompts & Force the command to run.
- `json` (*boolean*) - Output environment variables as JSON
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

**Examples**

Expand Down
12 changes: 10 additions & 2 deletions docs/commands/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ netlify functions

- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

| Subcommand | description |
|:--------------------------- |:-----|
Expand Down Expand Up @@ -55,6 +56,7 @@ netlify functions:build
- `functions` (*string*) - Specify a functions directory to build to
- `src` (*string*) - Specify the source directory for the functions
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

---
## `functions:create`
Expand All @@ -76,8 +78,10 @@ netlify functions:create
- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `language` (*string*) - function language
- `name` (*string*) - function name
- `offline` (*boolean*) - Disables any features that require network access
- `url` (*string*) - pull template from URL
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

**Examples**

Expand Down Expand Up @@ -109,10 +113,12 @@ netlify functions:invoke
- `identity` (*boolean*) - simulate Netlify Identity authentication JWT. pass --identity to affirm unauthenticated request
- `name` (*string*) - function name to invoke
- `no-identity` (*boolean*) - simulate Netlify Identity authentication JWT. pass --no-identity to affirm unauthenticated request
- `offline` (*boolean*) - Disables any features that require network access
- `payload` (*string*) - Supply POST payload in stringified json, or a path to a json file
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in
- `port` (*string*) - Port where netlify dev is accessible. e.g. 8888
- `querystring` (*string*) - Querystring to add to your function invocation
- `debug` (*boolean*) - Print debugging information

**Examples**

Expand Down Expand Up @@ -147,6 +153,7 @@ netlify functions:list
- `functions` (*string*) - Specify a functions directory to list
- `json` (*boolean*) - Output function data as JSON
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in
---
## `functions:serve`
Expand All @@ -163,9 +170,10 @@ netlify functions:serve
- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `functions` (*string*) - Specify a functions directory to serve
- `offline` (*boolean*) - disables any features that require network access
- `offline` (*boolean*) - Disables any features that require network access
- `port` (*string*) - Specify a port for the functions server
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in
---
Expand Down
1 change: 1 addition & 0 deletions docs/commands/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ netlify init
- `git-remote-name` (*string*) - Name of Git remote to use. e.g. "origin"
- `manual` (*boolean*) - Manually configure a git remote for CI
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in


<!-- AUTO-GENERATED-CONTENT:END -->
1 change: 1 addition & 0 deletions docs/commands/link.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ netlify link
- `id` (*string*) - ID of site to link to
- `name` (*string*) - Name of site to link to
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

**Examples**

Expand Down
1 change: 1 addition & 0 deletions docs/commands/login.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ netlify login

- `new` (*boolean*) - Login to new Netlify account
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in


<!-- AUTO-GENERATED-CONTENT:END -->
3 changes: 3 additions & 0 deletions docs/commands/logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ netlify logs

- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

| Subcommand | description |
|:--------------------------- |:-----|
Expand Down Expand Up @@ -49,6 +50,7 @@ netlify logs:deploy

- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

---
## `logs:function`
Expand All @@ -70,6 +72,7 @@ netlify logs:function
- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `level` (*string*) - Log levels to stream. Choices are: trace, debug, info, warn, error, fatal
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

**Examples**

Expand Down
3 changes: 3 additions & 0 deletions docs/commands/open.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ netlify open
- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `site` (*boolean*) - Open site
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

| Subcommand | description |
|:--------------------------- |:-----|
Expand Down Expand Up @@ -52,6 +53,7 @@ netlify open:admin

- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

**Examples**

Expand All @@ -74,6 +76,7 @@ netlify open:site

- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

**Examples**

Expand Down
2 changes: 2 additions & 0 deletions docs/commands/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ netlify recipes

- `name` (*string*) - recipe name to use
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

| Subcommand | description |
|:--------------------------- |:-----|
Expand Down Expand Up @@ -51,6 +52,7 @@ netlify recipes:list

- `filter` (*string*) - For monorepos, specify the name of the application to run the command in
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

**Examples**

Expand Down
3 changes: 2 additions & 1 deletion docs/commands/serve.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ netlify serve
- `functions` (*string*) - specify a functions folder to serve
- `functions-port` (*string*) - port of functions server
- `geo` (*cache | mock | update*) - force geolocation data to be updated, use cached data from the last 24h if found, or use a mock location
- `offline` (*boolean*) - disables any features that require network access
- `offline` (*boolean*) - Disables any features that require network access
- `port` (*string*) - port of netlify dev
- `debug` (*boolean*) - Print debugging information
- `auth` (*string*) - Netlify auth token - can be used to run this command without logging in

**Examples**

Expand Down
Loading

4 comments on commit 42b4a6c

@github-actions
Copy link

Choose a reason for hiding this comment

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

📊 Benchmark results

  • Dependency count: 1,217
  • Package size: 318 MB
  • Number of ts-expect-error directives: 729

@github-actions
Copy link

Choose a reason for hiding this comment

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

📊 Benchmark results

  • Dependency count: 1,217
  • Package size: 318 MB
  • Number of ts-expect-error directives: 729

@github-actions
Copy link

Choose a reason for hiding this comment

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

📊 Benchmark results

  • Dependency count: 1,217
  • Package size: 318 MB
  • Number of ts-expect-error directives: 729

@github-actions
Copy link

Choose a reason for hiding this comment

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

📊 Benchmark results

  • Dependency count: 1,217
  • Package size: 318 MB
  • Number of ts-expect-error directives: 729

Please sign in to comment.