Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: netlify/cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.13.12
Choose a base ref
...
head repository: netlify/cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.14.0
Choose a head ref
  • 3 commits
  • 15 files changed
  • 3 contributors

Commits on Apr 4, 2021

  1. feat: add functions directory creation when non-existent in netlify.t…

    …oml (#1996)
    Tiffany Le-Nguyen authored Apr 4, 2021
    Copy the full SHA
    4911e3d View commit details
  2. Copy the full SHA
    bdde7ff View commit details
  3. Copy the full SHA
    2572120 View commit details
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

## [3.14.0](https://www.github.com/netlify/cli/compare/v3.13.12...v3.14.0) (2021-04-04)


### Features

* add functions directory creation when non-existent in netlify.toml ([#1996](https://www.github.com/netlify/cli/issues/1996)) ([4911e3d](https://www.github.com/netlify/cli/commit/4911e3d584af04f572150132cf694ae2049f3dc1))
* add support for shell completion ([#2028](https://www.github.com/netlify/cli/issues/2028)) ([bdde7ff](https://www.github.com/netlify/cli/commit/bdde7ff289f1cf800ea2b4bb2e725be051c7ee7b))

### [3.13.12](https://www.github.com/netlify/cli/compare/v3.13.11...v3.13.12) (2021-04-04)


11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@ See the [CLI command line reference](https://cli.netlify.com/commands/) to get s
* [switch](#switch)
* [unlink](#unlink)
* [watch](#watch)
* [completion](#completion)
- [Contributing](#contributing)
- [Development](#development)
- [License](#license)
@@ -196,6 +197,16 @@ Unlink a local folder from a Netlify site

Watch for site deploy to finish

### [completion](/docs/commands/completion.md)

(Beta) Generate shell completion script

| Subcommand | description |
|:--------------------------- |:-----|
| [`completion:generate:alias`](/docs/commands/completion.md#completiongeneratealias) | Generates completion script for alias |
| [`completion:generate`](/docs/commands/completion.md#completiongenerate) | Generates completion script |



<!-- AUTO-GENERATED-CONTENT:END -->

10 changes: 10 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -159,5 +159,15 @@ Unlink a local folder from a Netlify site

Watch for site deploy to finish

### [completion](/docs/commands/completion.md)

(Beta) Generate shell completion script

| Subcommand | description |
|:--------------------------- |:-----|
| [`completion:generate:alias`](/docs/commands/completion.md#completiongeneratealias) | Generates completion script for alias |
| [`completion:generate`](/docs/commands/completion.md#completiongenerate) | Generates completion script |



<!-- AUTO-GENERATED-CONTENT:END -->
91 changes: 91 additions & 0 deletions docs/commands/completion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
title: Netlify CLI completion command
description: Shell completion script for netlify CLI
---

# `completion`

<!-- AUTO-GENERATED-CONTENT:START (GENERATE_COMMANDS_DOCS) -->
(Beta) Generate shell completion script

Run this command to see instructions for your shell.

**Usage**

```bash
netlify completion
```

**Arguments**



**Flags**

- `shell` (*bash | fish | zsh*) - Name of shell

| Subcommand | description |
|:--------------------------- |:-----|
| [`completion:generate:alias`](/docs/commands/completion.md#completiongeneratealias) | Generates completion script for alias |
| [`completion:generate`](/docs/commands/completion.md#completiongenerate) | Generates completion script |


**Examples**

```bash
$ netlify completion --shell zsh
```

---
## `completion:generate:alias`

Generates completion script for alias

This needs the completion script for the main command to be present.

Check the "completion:generate" command.

**Usage**

```bash
netlify completion:generate:alias
```

**Arguments**

- ALIAS - name of the alias

**Flags**

- `shell` (*bash | fish*) - Name of shell

---
## `completion:generate`

Generates completion script

Run the "completion" command to see instructions about how to use the script generated by this command.

**Usage**

```bash
netlify completion:generate
```

**Arguments**



**Flags**

- `shell` (*bash | fish | zsh*) - Name of shell

**Examples**

```bash
$ netlify completion:generate --shell zsh
```

---

<!-- AUTO-GENERATED-CONTENT:END -->
2 changes: 1 addition & 1 deletion docs/commands/functions.md
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ netlify functions:create

**Arguments**

- name - name of your new function file inside your functions folder
- name - name of your new function file inside your functions directory

**Flags**

10 changes: 10 additions & 0 deletions docs/commands/index.md
Original file line number Diff line number Diff line change
@@ -145,5 +145,15 @@ Unlink a local folder from a Netlify site

Watch for site deploy to finish

### [completion](/docs/commands/completion.md)

(Beta) Generate shell completion script

| Subcommand | description |
|:--------------------------- |:-----|
| [`completion:generate:alias`](/docs/commands/completion.md#completiongeneratealias) | Generates completion script for alias |
| [`completion:generate`](/docs/commands/completion.md#completiongenerate) | Generates completion script |



<!-- AUTO-GENERATED-CONTENT:END -->
30 changes: 29 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "netlify-cli",
"description": "Netlify command line tool",
"version": "3.13.12",
"version": "3.14.0",
"author": "Netlify Inc.",
"contributors": [
"Mathias Biilmann <matt@netlify.com> (https://twitter.com/biilmann)",
@@ -145,6 +145,7 @@
"netlify-redirector": "^0.2.1",
"node-fetch": "^2.6.0",
"node-version-alias": "^1.0.1",
"oclif-plugin-completion": "^0.6.0",
"open": "^7.0.0",
"ora": "^4.1.1",
"p-filter": "^2.1.0",
@@ -215,10 +216,12 @@
"oclif": {
"bin": "netlify",
"commands": "./src/commands",
"helpClass": "./src/lib/help",
"plugins": [
"@oclif/plugin-not-found",
"@oclif/plugin-plugins",
"@oclif/plugin-help"
"@oclif/plugin-help",
"oclif-plugin-completion"
],
"hooks": {
"init": [
40 changes: 29 additions & 11 deletions site/scripts/generate-command-data.js
Original file line number Diff line number Diff line change
@@ -4,15 +4,33 @@ const filterObj = require('filter-obj')
const mapObj = require('map-obj')
const { globby } = require('markdown-magic')

const getFlagType = (flagData) => {
if (flagData.type === 'option') {
return flagData.options ? flagData.options.join(' | ') : 'string'
}

return flagData.type
}

const formatExamples = (examples) =>
Array.isArray(examples) ? examples.map((example) => example.replace('<%= config.bin %>', 'netlify')) : examples

const isBetaPlugin = (description) => description.includes('Generate shell completion script')

const formatDescription = (description) => (isBetaPlugin(description) ? `(Beta) ${description}` : description)

module.exports = function generateCommandData() {
const commandsPath = path.join(__dirname, '..', '..', 'src/commands')
const netlifyDevPath = path.join(__dirname, '..', '..', 'node_modules/netlify-dev-plugin/src/commands')
const completionPluginPath = path.join(__dirname, '..', '..', 'node_modules/oclif-plugin-completion/lib/commands')
// console.log('commandsPath', commandsPath)
const commands = globby.sync([`${commandsPath}/**/**.js`, `${netlifyDevPath}/**/**.js`])
const commands = globby.sync([`${commandsPath}/**/**.js`, `${completionPluginPath}/**/**.js`])

const allCommands = commands.map((file) => {
// eslint-disable-next-line node/global-require, import/no-dynamic-require
const data = require(file)
let data = require(file)
if (!data.description && data.default && data.default.description) {
data = data.default
}
const command = commandFromPath(file)
const [parentCommand] = command.split(':')
const parent = command === parentCommand
@@ -21,7 +39,7 @@ module.exports = function generateCommandData() {
data.flags &&
mapObj(
filterObj(data.flags, (_, value) => value.hidden !== true),
(flag, flagData) => [flag, { ...flagData, type: flagData.type === 'option' ? 'string' : flagData.type }],
(flag, flagData) => [flag, { ...flagData, type: getFlagType(flagData) }],
)
return {
command,
@@ -39,10 +57,10 @@ module.exports = function generateCommandData() {
acc[curr.commandGroup] = {
name: curr.command,
usage: curr.data.usage,
description: curr.data.description,
description: formatDescription(curr.data.description),
flags: curr.data.flags,
args: curr.data.args,
examples: curr.data.examples,
examples: formatExamples(curr.data.examples),
strict: curr.data.strict,
commands: [],
}
@@ -57,10 +75,10 @@ module.exports = function generateCommandData() {
{
name: curr.command,
usage: curr.data.usage,
description: curr.data.description,
description: formatDescription(curr.data.description),
flags: curr.data.flags,
args: curr.data.args,
examples: curr.data.examples,
examples: formatExamples(curr.data.examples),
strict: curr.data.strict,
},
]
@@ -79,15 +97,15 @@ const commandFromPath = function (filePath) {
const rootDir = path.join(__dirname, '..', '..')
// Replace node_modules path for CLI plugins
if (normalized.includes('node_modules')) {
// in: /node_modules/netlify-dev-plugin/src/commands/dev/exec.js
// in: /node_modules/<package-name>/src/commands/dev/exec.js
// out: /src/commands/dev/exec.js
normalized = normalized.replace(/\/node_modules\/((?:[^/]+)*)?\//, '/')
}
return normalized
.replace(rootDir, '')
.replace(/\\/g, '/')
.replace('.js', '')
.replace('/src/commands/', '')
.replace(/\/(src|lib)\/commands\//, '')
.replace('/index', '')
.replace('/', ':')
.replace(/\//g, ':')
}
1 change: 1 addition & 0 deletions site/src/_app.js
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ const navOrder = [
'addons',
'api',
'build',
'completion',
'deploy',
'dev',
'env',
Loading