Skip to content

Commit 1978faf

Browse files
serhalpmrstork
andauthored
feat: link out to relevant Netlify docs in command help output (#7254)
* feat: link out to relevant Netlify platform from cmd help * fix: fix "check out" typo in some messages * feat: polish and improve main help text - always show the Netlify CLI header, not just the bare `netlify` case (there is also `netlify help` and `netlify --help`, which was otherwise identical) - use commander API instead of custom logging - use more consistent branding - change CLI getting started landing page - move the links to the bottom - add link to main Netlify docs * refactor: fix some suppressed no-unused-vars errors * test: fix e2e test help output assertion --------- Co-authored-by: Mateusz Bocian <mrstork@users.noreply.github.com>
1 parent e4bd247 commit 1978faf

File tree

26 files changed

+111
-67
lines changed

26 files changed

+111
-67
lines changed

docs/commands/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The `api` command will let you call any [Netlify open API methods](https://open-
1010

1111
<!-- AUTO-GENERATED-CONTENT:START (GENERATE_COMMANDS_DOCS) -->
1212
Run any Netlify API method
13-
For more information on available methods checkout https://open-api.netlify.com/ or run 'netlify api --list'
13+
For more information on available methods check out https://open-api.netlify.com/ or run 'netlify api --list'
1414

1515
**Usage**
1616

e2e/install.e2e.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ describe.each(tests)('%s → installs the cli and runs the help command without
176176
const binary = path.resolve(path.join(cwd, `./node_modules/.bin/netlify${platform() === 'win32' ? '.cmd' : ''}`))
177177
const { stdout } = await execa(binary, ['help'], { cwd })
178178

179-
expect(stdout.trim(), `Help command does not start with 'VERSION':\n\n${stdout}`).toMatch(/^VERSION/)
179+
expect(stdout.trim(), `Help command does not start with '⬥ Netlify CLI'\\n\\nVERSION: ${stdout}`).toMatch(
180+
/^ Netlify CLI\n\nVERSION/,
181+
)
180182
expect(stdout, `Help command does not include 'netlify-cli/${pkg.version}':\n\n${stdout}`).toContain(
181183
`netlify-cli/${pkg.version}`,
182184
)

eslint_temporary_suppressions.js

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,6 @@ export default [
105105
'@typescript-eslint/no-unsafe-assignment': 'off',
106106
},
107107
},
108-
{
109-
files: ['src/commands/completion/index.ts'],
110-
rules: {
111-
'@typescript-eslint/no-unused-vars': 'off',
112-
},
113-
},
114108
{
115109
files: ['src/commands/deploy/deploy.ts'],
116110
rules: {
@@ -196,7 +190,6 @@ export default [
196190
{
197191
files: ['src/commands/env/env-unset.ts'],
198192
rules: {
199-
'@typescript-eslint/no-unused-vars': 'off',
200193
'@typescript-eslint/no-unsafe-assignment': 'off',
201194
'@typescript-eslint/no-unsafe-member-access': 'off',
202195
'@typescript-eslint/no-unsafe-call': 'off',
@@ -224,7 +217,6 @@ export default [
224217
'@typescript-eslint/no-unnecessary-condition': 'off',
225218
'@typescript-eslint/restrict-template-expressions': 'off',
226219
'n/no-process-exit': 'off',
227-
'@typescript-eslint/no-unused-vars': 'off',
228220
'@typescript-eslint/prefer-optional-chain': 'off',
229221
'@typescript-eslint/await-thenable': 'off',
230222
'@typescript-eslint/no-confusing-void-expression': 'off',
@@ -250,24 +242,12 @@ export default [
250242
'@typescript-eslint/no-unnecessary-condition': 'off',
251243
},
252244
},
253-
{
254-
files: ['src/commands/init/index.ts'],
255-
rules: {
256-
'@typescript-eslint/no-unused-vars': 'off',
257-
},
258-
},
259245
{
260246
files: ['src/commands/init/init.ts'],
261247
rules: {
262248
'@typescript-eslint/no-unsafe-assignment': 'off',
263249
},
264250
},
265-
{
266-
files: ['src/commands/link/index.ts'],
267-
rules: {
268-
'@typescript-eslint/no-unused-vars': 'off',
269-
},
270-
},
271251
{
272252
files: ['src/commands/link/link.ts'],
273253
rules: {
@@ -280,12 +260,6 @@ export default [
280260
'@typescript-eslint/prefer-optional-chain': 'off',
281261
},
282262
},
283-
{
284-
files: ['src/commands/logout/logout.ts'],
285-
rules: {
286-
'@typescript-eslint/no-unused-vars': 'off',
287-
},
288-
},
289263
{
290264
files: ['src/commands/logs/build.ts'],
291265
rules: {
@@ -294,7 +268,6 @@ export default [
294268
'@typescript-eslint/no-unsafe-assignment': 'off',
295269
'@typescript-eslint/restrict-template-expressions': 'off',
296270
'@typescript-eslint/no-unsafe-call': 'off',
297-
'@typescript-eslint/no-unused-vars': 'off',
298271
'@typescript-eslint/prefer-nullish-coalescing': 'off',
299272
'@typescript-eslint/no-unsafe-argument': 'off',
300273
},
@@ -334,12 +307,6 @@ export default [
334307
'@typescript-eslint/no-unsafe-argument': 'off',
335308
},
336309
},
337-
{
338-
files: ['src/commands/open/open-site.ts'],
339-
rules: {
340-
'@typescript-eslint/no-unused-vars': 'off',
341-
},
342-
},
343310
{
344311
files: ['src/commands/recipes/common.ts'],
345312
rules: {
@@ -414,20 +381,17 @@ export default [
414381
rules: {
415382
'@typescript-eslint/restrict-template-expressions': 'off',
416383
'@typescript-eslint/no-unsafe-return': 'off',
417-
'@typescript-eslint/no-unused-vars': 'off',
418384
},
419385
},
420386
{
421387
files: ['src/commands/status/status-hooks.ts'],
422388
rules: {
423-
'@typescript-eslint/no-unused-vars': 'off',
424389
'@typescript-eslint/no-unsafe-member-access': 'off',
425390
},
426391
},
427392
{
428393
files: ['src/commands/switch/switch.ts'],
429394
rules: {
430-
'@typescript-eslint/no-unused-vars': 'off',
431395
'@typescript-eslint/no-unsafe-argument': 'off',
432396
'@typescript-eslint/no-unsafe-assignment': 'off',
433397
'@typescript-eslint/restrict-template-expressions': 'off',
@@ -442,7 +406,6 @@ export default [
442406
{
443407
files: ['src/commands/unlink/unlink.ts'],
444408
rules: {
445-
'@typescript-eslint/no-unused-vars': 'off',
446409
'@typescript-eslint/no-unnecessary-condition': 'off',
447410
'@typescript-eslint/prefer-optional-chain': 'off',
448411
},

src/commands/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const createApiCommand = (program: BaseCommand) =>
77
.argument('[apiMethod]', 'Open API method to run')
88
.description(
99
`Run any Netlify API method
10-
For more information on available methods checkout https://open-api.netlify.com/ or run '${chalk.grey(
10+
For more information on available methods check out https://open-api.netlify.com/ or run '${chalk.grey(
1111
'netlify api --list',
1212
)}'`,
1313
)

src/commands/blobs/blobs.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { OptionValues } from 'commander'
2+
import terminalLink from 'terminal-link'
23

34
import requiresSiteInfo from '../../utils/hooks/requires-site-info.js'
45
import BaseCommand from '../base-command.js'
@@ -84,6 +85,12 @@ export const createBlobsCommand = (program: BaseCommand) => {
8485
.command('blobs')
8586
.alias('blob')
8687
.description(`Manage objects in Netlify Blobs`)
88+
.addHelpText('after', () => {
89+
const docsUrl = 'https://docs.netlify.com/blobs/overview/'
90+
return `
91+
For more information about Netlify Blobs, see ${terminalLink(docsUrl, docsUrl)}
92+
`
93+
})
8794
.addExamples([
8895
'netlify blobs:get my-store my-key',
8996
'netlify blobs:set my-store my-key This will go in a blob',

src/commands/build/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import process from 'process'
22

3+
import terminalLink from 'terminal-link'
4+
35
import { normalizeContext } from '../../utils/env/index.js'
46
import BaseCommand from '../base-command.js'
57

@@ -20,6 +22,12 @@ export const createBuildCommand = (program: BaseCommand) =>
2022
'netlify build --context deploy-preview # Build with env var values from deploy-preview context',
2123
'netlify build --context branch:feat/make-it-pop # Build with env var values from the feat/make-it-pop branch context or branch-deploy context',
2224
])
25+
.addHelpText('after', () => {
26+
const docsUrl = 'https://docs.netlify.com/configure-builds/overview/'
27+
return `
28+
For more information about Netlify builds, see ${terminalLink(docsUrl, docsUrl)}
29+
`
30+
})
2331
.action(async (options, command) => {
2432
const { build } = await import('./build.js')
2533
await build(options, command)

src/commands/completion/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const createCompletionCommand = (program: BaseCommand) => {
2626
.command('completion')
2727
.description('Generate shell completion script\nRun this command to see instructions for your shell.')
2828
.addExamples(['netlify completion:install'])
29-
.action((options: OptionValues, command: BaseCommand) => {
29+
.action((_options: OptionValues, command: BaseCommand) => {
3030
command.help()
3131
})
3232
}

src/commands/deploy/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { env } from 'process'
22

33
import { Option } from 'commander'
4+
import terminalLink from 'terminal-link'
45

56
import BaseCommand from '../base-command.js'
67
import { chalk, logAndThrowError, warn } from '../../utils/command-helpers.js'
@@ -143,6 +144,12 @@ Support for package.json's main field, and intrinsic index.js entrypoints are co
143144
'netlify deploy --trigger',
144145
'netlify deploy --context deploy-preview',
145146
])
147+
.addHelpText('after', () => {
148+
const docsUrl = 'https://docs.netlify.com/site-deploys/overview/'
149+
return `
150+
For more information about Netlify deploys, see ${terminalLink(docsUrl, docsUrl)}
151+
`
152+
})
146153
.action(async (options: DeployOptionValues, command: BaseCommand) => {
147154
if (options.build && command.getOptionValueSource('build') === 'cli') {
148155
warn(

src/commands/dev/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Option, type OptionValues } from 'commander'
2+
import terminalLink from 'terminal-link'
23

34
import { BANG, chalk } from '../../utils/command-helpers.js'
45
import { normalizeContext } from '../../utils/env/index.js'
@@ -105,6 +106,12 @@ export const createDevCommand = (program: BaseCommand) => {
105106
'netlify dev --edge-inspect-brk=127.0.0.1:9229',
106107
'BROWSER=none netlify dev # disable browser auto opening',
107108
])
109+
.addHelpText('after', () => {
110+
const docsUrl = 'https://docs.netlify.com/cli/local-development/'
111+
return `
112+
For more information about Netlify local development, see ${terminalLink(docsUrl, docsUrl)}
113+
`
114+
})
108115
.action(async (options: OptionValues, command: BaseCommand) => {
109116
const { dev } = await import('./dev.js')
110117
await dev(options, command)

src/commands/env/env-unset.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { OptionValues } from 'commander'
22

3-
import { chalk, log, logJson, exit } from '../../utils/command-helpers.js'
3+
import { chalk, log, logJson } from '../../utils/command-helpers.js'
44
import { SUPPORTED_CONTEXTS, translateFromEnvelopeToMongo } from '../../utils/env/index.js'
55
import { promptOverwriteEnvVariable } from '../../utils/prompts/env-unset-prompts.js'
66
import BaseCommand from '../base-command.js'

0 commit comments

Comments
 (0)