Skip to content

Commit

Permalink
chore: add mts files to prettier (#6187)
Browse files Browse the repository at this point in the history
* chore: add mts files to prettier

* chore: dont include d.mts

* chore: come on dont include .d.mts

* chore: try this
  • Loading branch information
sarahetter authored Nov 17, 2023
1 parent 3ad0c9b commit 1b3229a
Show file tree
Hide file tree
Showing 105 changed files with 170 additions and 265 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
src/**/*.mjs
src/**/*.d.mts
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
},
"config": {
"eslint": "--cache --format=codeframe --max-warnings=0 \"{src,scripts,tests,.github}/**/*.{mjs,cjs,js,md,html}\" \"*.{mjs,cjs,js,md,html}\" \".*.{mjs,cjs,js,md,html}\"",
"prettier": "--ignore-path .eslintignore --loglevel=warn \"{src,tools,scripts,tests,.github}/**/*.{mjs,cjs,js,md,yml,json,html}\" \"*.{mjs,cjs,js,yml,json,html}\" \".*.{mjs,cjs,js,yml,json,html}\" \"!CHANGELOG.md\" \"!**/*/package-lock.json\" \"!.github/**/*.md\""
"prettier": "--ignore-path .eslintignore --loglevel=warn \"{src,tools,scripts,tests,.github}/**/*.{mjs,cjs,js,mts,md,yml,json,html}\" \"*.{mjs,cjs,js,mts,yml,json,html}\" \".*.{mjs,cjs,js,yml,json,html}\" \"!CHANGELOG.md\" \"!**/*/package-lock.json\" \"!.github/**/*.md\""
},
"dependencies": {
"@bugsnag/js": "7.20.2",
Expand Down
1 change: 0 additions & 1 deletion src/commands/addons/addons-auth.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { ADDON_VALIDATION, prepareAddonCommand } from '../../utils/addons/prepare.mjs'
import { exit, log } from '../../utils/command-helpers.mjs'
import openBrowser from '../../utils/open-browser.mjs'
Expand Down
1 change: 0 additions & 1 deletion src/commands/addons/addons-config.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import inquirer from 'inquirer'
import isEmpty from 'lodash/isEmpty.js'

Expand Down
1 change: 0 additions & 1 deletion src/commands/addons/addons-create.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import inquirer from 'inquirer'
import isEmpty from 'lodash/isEmpty.js'

Expand Down
1 change: 0 additions & 1 deletion src/commands/addons/addons-delete.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import inquirer from 'inquirer'

import { ADDON_VALIDATION, prepareAddonCommand } from '../../utils/addons/prepare.mjs'
Expand Down
2 changes: 0 additions & 2 deletions src/commands/addons/addons-list.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


import AsciiTable from 'ascii-table'

import { prepareAddonCommand } from '../../utils/addons/prepare.mjs'
Expand Down
1 change: 0 additions & 1 deletion src/commands/addons/addons.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { createAddonsAuthCommand } from './addons-auth.mjs'
import { createAddonsConfigCommand } from './addons-config.mjs'
import { createAddonsCreateCommand } from './addons-create.mjs'
Expand Down
2 changes: 0 additions & 2 deletions src/commands/api/api.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


import AsciiTable from 'ascii-table'
import { methods } from 'netlify'

Expand Down
1 change: 0 additions & 1 deletion src/commands/build/build.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import process from 'process'

import { getBuildOptions, runBuild } from '../../lib/build.mjs'
Expand Down
18 changes: 10 additions & 8 deletions src/commands/completion/completion.mts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ export const createCompletionCommand = (program) => {
})
})

return program
.command('completion')
.description('Generate shell completion script\nRun this command to see instructions for your shell.')
.addExamples(['netlify completion:install'])
// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
.action((options, command) => {
command.help()
})
return (
program
.command('completion')
.description('Generate shell completion script\nRun this command to see instructions for your shell.')
.addExamples(['netlify completion:install'])
// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
.action((options, command) => {
command.help()
})
)
}
199 changes: 100 additions & 99 deletions src/commands/dev/dev.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import process from 'process'

import { Option } from 'commander'
Expand Down Expand Up @@ -249,107 +248,109 @@ const dev = async (options, command) => {
export const createDevCommand = (program) => {
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,
)
// @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type.
.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'))
// @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type.
.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),
)
// @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type.
.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',
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`,
)
.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',
.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,
)
.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',
// @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type.
.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),
)
.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('--no-open', 'disables the automatic opening of a browser window'))
// @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type.
.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,
)
.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',
.addOption(
new Option('--functionsPort <port>', 'Old, prefer --functions-port. Port of functions server')
.argParser((value) => Number.parseInt(value))
.hideHelp(true),
)
.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)
// @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type.
.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(),
)
.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),
)
.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),
)
.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),
)
.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),
)
.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/env/env-clone.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { chalk, error as logError, log } from '../../utils/command-helpers.mjs'
import { translateFromEnvelopeToMongo, translateFromMongoToEnvelope } from '../../utils/env/index.mjs'

Expand Down
2 changes: 0 additions & 2 deletions src/commands/env/env-import.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

import { readFile } from 'fs/promises'


import AsciiTable from 'ascii-table'
import { Option } from 'commander'
import dotenv from 'dotenv'
Expand Down
1 change: 0 additions & 1 deletion src/commands/env/env-set.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { Option } from 'commander'

import { chalk, error, log, logJson } from '../../utils/command-helpers.mjs'
Expand Down
1 change: 0 additions & 1 deletion src/commands/env/env-unset.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { chalk, error, log, logJson } from '../../utils/command-helpers.mjs'
import { AVAILABLE_CONTEXTS, normalizeContext, translateFromEnvelopeToMongo } from '../../utils/env/index.mjs'

Expand Down
1 change: 0 additions & 1 deletion src/commands/env/env.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { createEnvCloneCommand } from './env-clone.mjs'
import { createEnvGetCommand } from './env-get.mjs'
import { createEnvImportCommand } from './env-import.mjs'
Expand Down
1 change: 0 additions & 1 deletion src/commands/functions/functions-build.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { mkdir } from 'fs/promises'

import { zipFunctions } from '@netlify/zip-it-and-ship-it'
Expand Down
31 changes: 17 additions & 14 deletions src/commands/functions/functions-create.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import cp from 'child_process'
import fs from 'fs'
import { mkdir, readdir, unlink } from 'fs/promises'
Expand Down Expand Up @@ -88,17 +87,21 @@ const filterRegistry = function (registry, input) {
const filteredTemplateNames = new Set(
filteredTemplates.map((filteredTemplate) => (input ? filteredTemplate.string : filteredTemplate)),
)
return registry
// @ts-expect-error TS(7006) FIXME: Parameter 't' implicitly has an 'any' type.
.filter((t) => filteredTemplateNames.has(t.name + t.description))
// @ts-expect-error TS(7006) FIXME: Parameter 't' implicitly has an 'any' type.
.map((t) => {
// add the score
// @ts-expect-error TS(2339) FIXME: Property 'score' does not exist on type 'FilterRes... Remove this comment to see the full error message
const { score } = filteredTemplates.find((filteredTemplate) => filteredTemplate.string === t.name + t.description)
t.score = score
return t
})
return (
registry
// @ts-expect-error TS(7006) FIXME: Parameter 't' implicitly has an 'any' type.
.filter((t) => filteredTemplateNames.has(t.name + t.description))
// @ts-expect-error TS(7006) FIXME: Parameter 't' implicitly has an 'any' type.
.map((t) => {
// add the score
// @ts-expect-error TS(2339) FIXME: Property 'score' does not exist on type 'FilterRes... Remove this comment to see the full error message
const { score } = filteredTemplates.find(
(filteredTemplate) => filteredTemplate.string === t.name + t.description,
)
t.score = score
return t
})
)
}

/**
Expand Down Expand Up @@ -177,8 +180,8 @@ const pickTemplate = async function ({ language: languageFromFlag }, funcType) {
if (language === undefined) {
const langs =
funcType === 'edge'
// @ts-expect-error TS(2339) FIXME: Property 'value' does not exist on type 'false | {... Remove this comment to see the full error message
? languages.filter((lang) => lang.value === 'javascript' || lang.value === 'typescript')
? // @ts-expect-error TS(2339) FIXME: Property 'value' does not exist on type 'false | {... Remove this comment to see the full error message
languages.filter((lang) => lang.value === 'javascript' || lang.value === 'typescript')
: languages.filter(Boolean)

const { language: languageFromPrompt } = await inquirer.prompt({
Expand Down
1 change: 0 additions & 1 deletion src/commands/functions/functions-invoke.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import fs from 'fs'
import { createRequire } from 'module'
import path from 'path'
Expand Down
1 change: 0 additions & 1 deletion src/commands/functions/functions-serve.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { join } from 'path'

import { startFunctionsServer } from '../../lib/functions/server.mjs'
Expand Down
1 change: 0 additions & 1 deletion src/commands/functions/functions.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { chalk } from '../../utils/command-helpers.mjs'

import { createFunctionsBuildCommand } from './functions-build.mjs'
Expand Down
1 change: 0 additions & 1 deletion src/commands/init/init.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { Option } from 'commander'
import inquirer from 'inquirer'
import isEmpty from 'lodash/isEmpty.js'
Expand Down
Loading

1 comment on commit 1b3229a

@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,396
  • Package size: 404 MB

Please sign in to comment.