Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ericapisani committed Nov 23, 2023
1 parent ab281ed commit ca1a9a6
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 106 deletions.
1 change: 0 additions & 1 deletion src/commands/blobs/blobs-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ interface Options extends OptionValues {
input?: string
}


export const blobsSet = async (
storeName: string,
key: string,
Expand Down
193 changes: 95 additions & 98 deletions src/commands/dev/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,110 +230,107 @@ export const dev = async (options: OptionValues, command: BaseCommand) => {
printBanner({ url })
}


export const createDevCommand = (program: BaseCommand) => {
createDevExecCommand(program)

return (
program
.command('dev')
.alias('develop')
.description(
`Local dev server\nThe dev command will run a local dev server with Netlify's proxy and redirect rules`,
)
.option('-c ,--command <command>', 'command to run')
.option(
'--context <context>',
'Specify a deploy context or branch for environment variables (contexts: "production", "deploy-preview", "branch-deploy", "dev")',
normalizeContext,
)
.option('-p ,--port <port>', 'port of netlify dev', (value) => Number.parseInt(value))
.addOption(
new Option('--targetPort <port>', 'Old, prefer --target-port. Port of target app server')
.argParser((value) => Number.parseInt(value))
.hideHelp(true),
)
.addOption(new Option('--no-open', 'disables the automatic opening of a browser window'))
.option('--target-port <port>', 'port of target app server', (value) => Number.parseInt(value))
.option('--framework <name>', 'framework to use. Defaults to #auto which automatically detects a framework')
.option('-d ,--dir <path>', 'dir with static files')
.option('-f ,--functions <folder>', 'specify a functions folder to serve')
.option('-o ,--offline', 'disables any features that require network access')
.option(
'-l, --live [subdomain]',
'start a public live session; optionally, supply a subdomain to generate a custom URL',
false,
)
.addOption(
new Option('--functionsPort <port>', 'Old, prefer --functions-port. Port of functions server')
.argParser((value) => Number.parseInt(value))
.hideHelp(true),
)
.option('--functions-port <port>', 'port of functions server', (value) => Number.parseInt(value))
.addOption(
new Option(
'--geo <mode>',
'force geolocation data to be updated, use cached data from the last 24h if found, or use a mock location',
)
.choices(['cache', 'mock', 'update'])
.default('cache'),
)
.addOption(
new Option(
'--country <geoCountry>',
'Two-letter country code (https://ntl.fyi/country-codes) to use as mock geolocation (enables --geo=mock automatically)',
).argParser(getGeoCountryArgParser('netlify dev --geo=mock --country=FR')),
)
.addOption(
new Option('--staticServerPort <port>', 'port of the static app server used when no framework is detected')
.argParser((value) => Number.parseInt(value))
.hideHelp(),
return program
.command('dev')
.alias('develop')
.description(
`Local dev server\nThe dev command will run a local dev server with Netlify's proxy and redirect rules`,
)
.option('-c ,--command <command>', 'command to run')
.option(
'--context <context>',
'Specify a deploy context or branch for environment variables (contexts: "production", "deploy-preview", "branch-deploy", "dev")',
normalizeContext,
)
.option('-p ,--port <port>', 'port of netlify dev', (value) => Number.parseInt(value))
.addOption(
new Option('--targetPort <port>', 'Old, prefer --target-port. Port of target app server')
.argParser((value) => Number.parseInt(value))
.hideHelp(true),
)
.addOption(new Option('--no-open', 'disables the automatic opening of a browser window'))
.option('--target-port <port>', 'port of target app server', (value) => Number.parseInt(value))
.option('--framework <name>', 'framework to use. Defaults to #auto which automatically detects a framework')
.option('-d ,--dir <path>', 'dir with static files')
.option('-f ,--functions <folder>', 'specify a functions folder to serve')
.option('-o ,--offline', 'disables any features that require network access')
.option(
'-l, --live [subdomain]',
'start a public live session; optionally, supply a subdomain to generate a custom URL',
false,
)
.addOption(
new Option('--functionsPort <port>', 'Old, prefer --functions-port. Port of functions server')
.argParser((value) => Number.parseInt(value))
.hideHelp(true),
)
.option('--functions-port <port>', 'port of functions server', (value) => Number.parseInt(value))
.addOption(
new Option(
'--geo <mode>',
'force geolocation data to be updated, use cached data from the last 24h if found, or use a mock location',
)
.addOption(
new Option(
'-e, --edgeInspect [address]',
'Old, prefer --edge-inspect. Enable the V8 Inspector Protocol for Edge Functions, with an optional address in the host:port format',
)
.conflicts('edgeInspectBrk')
.argParser(validateShortFlagArgs)
.hideHelp(true),
.choices(['cache', 'mock', 'update'])
.default('cache'),
)
.addOption(
new Option(
'--country <geoCountry>',
'Two-letter country code (https://ntl.fyi/country-codes) to use as mock geolocation (enables --geo=mock automatically)',
).argParser(getGeoCountryArgParser('netlify dev --geo=mock --country=FR')),
)
.addOption(
new Option('--staticServerPort <port>', 'port of the static app server used when no framework is detected')
.argParser((value) => Number.parseInt(value))
.hideHelp(),
)
.addOption(
new Option(
'-e, --edgeInspect [address]',
'Old, prefer --edge-inspect. Enable the V8 Inspector Protocol for Edge Functions, with an optional address in the host:port format',
)
.addOption(
new Option(
'-e, --edge-inspect [address]',
'enable the V8 Inspector Protocol for Edge Functions, with an optional address in the host:port format',
)
.conflicts('edgeInspectBrk')
.argParser(validateShortFlagArgs),
.conflicts('edgeInspectBrk')
.argParser(validateShortFlagArgs)
.hideHelp(true),
)
.addOption(
new Option(
'-e, --edge-inspect [address]',
'enable the V8 Inspector Protocol for Edge Functions, with an optional address in the host:port format',
)
.addOption(
new Option(
'-E, --edgeInspectBrk [address]',
'Old, prefer --edge-inspect-brk. Enable the V8 Inspector Protocol for Edge Functions and pause execution on the first line of code, with an optional address in the host:port format',
)
.conflicts('edgeInspect')
.hideHelp(true)
.argParser(validateShortFlagArgs),
.conflicts('edgeInspectBrk')
.argParser(validateShortFlagArgs),
)
.addOption(
new Option(
'-E, --edgeInspectBrk [address]',
'Old, prefer --edge-inspect-brk. Enable the V8 Inspector Protocol for Edge Functions and pause execution on the first line of code, with an optional address in the host:port format',
)
.addOption(
new Option(
'-E, --edge-inspect-brk [address]',
'enable the V8 Inspector Protocol for Edge Functions and pause execution on the first line of code, with an optional address in the host:port format',
)
.conflicts('edgeInspect')
.argParser(validateShortFlagArgs),
.conflicts('edgeInspect')
.hideHelp(true)
.argParser(validateShortFlagArgs),
)
.addOption(
new Option(
'-E, --edge-inspect-brk [address]',
'enable the V8 Inspector Protocol for Edge Functions and pause execution on the first line of code, with an optional address in the host:port format',
)
.addExamples([
'netlify dev',
'netlify dev -d public',
'netlify dev -c "hugo server -w" --target-port 1313',
'netlify dev --context production',
'netlify dev --edge-inspect',
'netlify dev --edge-inspect=127.0.0.1:9229',
'netlify dev --edge-inspect-brk',
'netlify dev --edge-inspect-brk=127.0.0.1:9229',
'BROWSER=none netlify dev # disable browser auto opening',
])
.action(dev)
)
.conflicts('edgeInspect')
.argParser(validateShortFlagArgs),
)
.addExamples([
'netlify dev',
'netlify dev -d public',
'netlify dev -c "hugo server -w" --target-port 1313',
'netlify dev --context production',
'netlify dev --edge-inspect',
'netlify dev --edge-inspect=127.0.0.1:9229',
'netlify dev --edge-inspect-brk',
'netlify dev --edge-inspect-brk=127.0.0.1:9229',
'BROWSER=none netlify dev # disable browser auto opening',
])
.action(dev)
}
1 change: 0 additions & 1 deletion src/commands/logs/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type BaseCommand from '../base-command.js'

import { CLI_LOG_LEVEL_CHOICES_STRING, LOG_LEVELS, LOG_LEVELS_LIST } from './log-levels.js'


function getLog(logData: { level: string; message: string }) {
let logString = ''
switch (logData.level) {
Expand Down
8 changes: 2 additions & 6 deletions tests/integration/commands/sites/sites.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import { render } from 'prettyjson'
import { afterAll, beforeEach, describe, expect, test, vi } from 'vitest'

import BaseCommand from '../../../../src/commands/base-command.js'
import {
fetchTemplates,
} from '../../../../src/commands/sites/sites-create-template.js'
import { createSitesCreateCommand ,
createSitesFromTemplateCommand
} from '../../../../src/commands/sites/sites.js'
import { fetchTemplates } from '../../../../src/commands/sites/sites-create-template.js'
import { createSitesCreateCommand, createSitesFromTemplateCommand } from '../../../../src/commands/sites/sites.js'
import { getGitHubToken } from '../../../../src/utils/init/config-github.js'
import { createRepo, getTemplatesFromGitHub } from '../../../../src/utils/sites/utils.js'
import { getEnvironmentVariables, withMockApi } from '../../utils/mock-api.js'
Expand Down

0 comments on commit ca1a9a6

Please sign in to comment.