From ca739d559feb93ae82cf76f2d3fd817f95a111a9 Mon Sep 17 00:00:00 2001 From: Sarah Etter Date: Fri, 17 Nov 2023 09:05:38 -0500 Subject: [PATCH] chore: prettier --- src/commands/addons/addons-auth.mts | 1 - src/commands/addons/addons-create.mts | 1 - src/commands/addons/addons-list.mts | 1 - src/commands/addons/addons.mts | 99 ++++++++++---------- src/commands/api/api.mts | 2 - src/commands/api/index.mts | 8 +- src/commands/blobs/blobs-set.mts | 8 +- src/commands/blobs/blobs.mts | 20 ++-- src/commands/build/build.mts | 4 +- src/commands/build/index.mts | 6 +- src/commands/completion/index.mts | 9 +- src/commands/deploy/deploy.mts | 1 - src/commands/dev/dev-exec.mts | 3 +- src/commands/dev/dev.mts | 2 - src/commands/dev/index.mts | 42 ++++----- src/commands/env/env-clone.mts | 3 - src/commands/env/env-get.mts | 1 - src/commands/env/env-import.mts | 2 - src/commands/env/env-set.mts | 9 +- src/commands/env/env-unset.mts | 3 - src/commands/env/env.mts | 74 +++++++-------- src/commands/functions/functions-build.mts | 1 - src/commands/functions/functions-create.mts | 1 - src/commands/functions/functions-serve.mts | 2 - src/commands/functions/functions.mts | 47 +++++----- src/commands/init/index.mts | 6 +- src/commands/integration/deploy.mts | 2 +- src/commands/integration/index.mts | 25 +++-- src/commands/link/index.mts | 5 +- src/commands/link/link.mts | 1 - src/commands/lm/lm-install.mts | 1 - src/commands/lm/lm-setup.mts | 1 - src/commands/lm/lm.mts | 38 ++++---- src/commands/login/login.mts | 1 - src/commands/logout/index.mts | 16 ++-- src/commands/logout/logout.mts | 1 - src/commands/logs/index.mts | 17 ++-- src/commands/open/index.mts | 21 ++--- src/commands/open/open-admin.mts | 1 - src/commands/open/open-site.mts | 1 - src/commands/open/open.mts | 1 - src/commands/recipes/index.mts | 4 +- src/commands/recipes/recipes.mts | 2 - src/commands/serve/index.mts | 6 +- src/commands/serve/serve.mts | 1 - src/commands/sites/sites-create-template.mts | 1 - src/commands/sites/sites-create.mts | 2 - src/commands/sites/sites-delete.mts | 1 - src/commands/sites/sites-list.mts | 1 - src/commands/sites/sites.mts | 50 +++++----- src/commands/status/index.mts | 4 +- src/commands/status/status-hooks.mts | 1 - src/commands/status/status.mts | 1 - src/commands/switch/index.mts | 16 ++-- src/commands/switch/switch.mts | 1 - src/commands/unlink/index.mts | 18 ++-- src/commands/unlink/unlink.mts | 1 - src/commands/watch/index.mts | 4 +- src/commands/watch/watch.mts | 1 - 59 files changed, 269 insertions(+), 334 deletions(-) diff --git a/src/commands/addons/addons-auth.mts b/src/commands/addons/addons-auth.mts index 307bdfb8bbd..39776122f3f 100644 --- a/src/commands/addons/addons-auth.mts +++ b/src/commands/addons/addons-auth.mts @@ -5,7 +5,6 @@ import { exit, log } from '../../utils/command-helpers.mjs' import openBrowser from '../../utils/open-browser.mjs' import BaseCommand from '../base-command.mjs' - export const addonsAuth = async (addonName: string, options: OptionValues, command: BaseCommand) => { const { addon } = await prepareAddonCommand({ command, diff --git a/src/commands/addons/addons-create.mts b/src/commands/addons/addons-create.mts index cd4b6d0a439..8bace53b587 100644 --- a/src/commands/addons/addons-create.mts +++ b/src/commands/addons/addons-create.mts @@ -29,7 +29,6 @@ const createAddon = async ({ addonName, api, config, siteData, siteId }) => { } } - export const addonsCreate = async (addonName: string, options: OptionValues, command: BaseCommand) => { const { manifest, siteData } = await prepareAddonCommand({ command, diff --git a/src/commands/addons/addons-list.mts b/src/commands/addons/addons-list.mts index ed83c900f1d..a2ddaea427f 100644 --- a/src/commands/addons/addons-list.mts +++ b/src/commands/addons/addons-list.mts @@ -5,7 +5,6 @@ import { prepareAddonCommand } from '../../utils/addons/prepare.mjs' import { log, logJson } from '../../utils/command-helpers.mjs' import BaseCommand from '../base-command.mjs' - export const addonsList = async (options: OptionValues, command: BaseCommand) => { // @ts-expect-error TS(2345) FIXME: Argument of type '{ command: any; }' is not assign... Remove this comment to see the full error message const { addons, siteData } = await prepareAddonCommand({ command }) diff --git a/src/commands/addons/addons.mts b/src/commands/addons/addons.mts index 326b65d6731..5329ef1b82b 100644 --- a/src/commands/addons/addons.mts +++ b/src/commands/addons/addons.mts @@ -8,65 +8,64 @@ const addons = (options: OptionValues, command: BaseCommand) => { export const createAddonsCommand = (program: BaseCommand) => { program - .command('addons:auth', { hidden: true }) - .alias('addon:auth') - .argument('', 'Add-on slug') - .description('Login to add-on provider') - .action(async (addonName: string, options: OptionValues, command: BaseCommand) => { - const { addonsAuth } = await import('./addons-auth.mjs') - await addonsAuth(addonName, options, command) - }) + .command('addons:auth', { hidden: true }) + .alias('addon:auth') + .argument('', 'Add-on slug') + .description('Login to add-on provider') + .action(async (addonName: string, options: OptionValues, command: BaseCommand) => { + const { addonsAuth } = await import('./addons-auth.mjs') + await addonsAuth(addonName, options, command) + }) program - .command('addons:config', { hidden: true }) - .alias('addon:config') - .argument('', 'Add-on namespace') - .description('Configure add-on settings') - // allow for any flags. Handy for variadic configuration options - .allowUnknownOption(true) - .action(async (addonName: string, options: OptionValues, command: BaseCommand) => { - const { addonsConfig } = await import('./addons-config.mjs') - await addonsConfig(addonName, options, command) - }) + .command('addons:config', { hidden: true }) + .alias('addon:config') + .argument('', 'Add-on namespace') + .description('Configure add-on settings') + // allow for any flags. Handy for variadic configuration options + .allowUnknownOption(true) + .action(async (addonName: string, options: OptionValues, command: BaseCommand) => { + const { addonsConfig } = await import('./addons-config.mjs') + await addonsConfig(addonName, options, command) + }) program - .command('addons:create', { hidden: true }) - .alias('addon:create') - .argument('', 'Add-on namespace') - .description( - `Add an add-on extension to your site + .command('addons:create', { hidden: true }) + .alias('addon:create') + .argument('', 'Add-on namespace') + .description( + `Add an add-on extension to your site Add-ons are a way to extend the functionality of your Netlify site`, - ) - // allow for any flags. Handy for variadic configuration options - .allowUnknownOption(true) - .action(async (addonName: string, options: OptionValues, command: BaseCommand) => { - const { addonsCreate } = await import('./addons-create.mjs') - await addonsCreate(addonName, options, command) - }) + ) + // allow for any flags. Handy for variadic configuration options + .allowUnknownOption(true) + .action(async (addonName: string, options: OptionValues, command: BaseCommand) => { + const { addonsCreate } = await import('./addons-create.mjs') + await addonsCreate(addonName, options, command) + }) program - .command('addons:delete', { hidden: true }) - .alias('addon:delete') - .argument('', 'Add-on namespace') - .description( - `Remove an add-on extension to your site\nAdd-ons are a way to extend the functionality of your Netlify site`, - ) - .option('-f, --force', 'delete without prompting (useful for CI)') - .action(async (addonName: string, options: OptionValues, command: BaseCommand) => { - const { addonsDelete } = await import('./addons-delete.mjs') - await addonsDelete(addonName, options, command) - }) - + .command('addons:delete', { hidden: true }) + .alias('addon:delete') + .argument('', 'Add-on namespace') + .description( + `Remove an add-on extension to your site\nAdd-ons are a way to extend the functionality of your Netlify site`, + ) + .option('-f, --force', 'delete without prompting (useful for CI)') + .action(async (addonName: string, options: OptionValues, command: BaseCommand) => { + const { addonsDelete } = await import('./addons-delete.mjs') + await addonsDelete(addonName, options, command) + }) program - .command('addons:list', { hidden: true }) - .alias('addon:list') - .description(`List currently installed add-ons for site`) - .option('--json', 'Output add-on data as JSON') - .action(async (options: OptionValues, command: BaseCommand) => { - const {addonsList} = await import('./addons-list.mjs') - await addonsList(options, command) - }) + .command('addons:list', { hidden: true }) + .alias('addon:list') + .description(`List currently installed add-ons for site`) + .option('--json', 'Output add-on data as JSON') + .action(async (options: OptionValues, command: BaseCommand) => { + const { addonsList } = await import('./addons-list.mjs') + await addonsList(options, command) + }) return program .command('addons', { hidden: true }) diff --git a/src/commands/api/api.mts b/src/commands/api/api.mts index a4195de4de2..c18db056120 100644 --- a/src/commands/api/api.mts +++ b/src/commands/api/api.mts @@ -5,7 +5,6 @@ import { methods } from 'netlify' import { chalk, error, exit, log, logJson } from '../../utils/command-helpers.mjs' import BaseCommand from '../base-command.mjs' - export const apiCommand = async (apiMethod: string, options: OptionValues, command: BaseCommand) => { const { api } = command.netlify @@ -45,4 +44,3 @@ export const apiCommand = async (apiMethod: string, options: OptionValues, comma error(error_) } } - diff --git a/src/commands/api/index.mts b/src/commands/api/index.mts index 390d6bc4e02..8f321c82018 100644 --- a/src/commands/api/index.mts +++ b/src/commands/api/index.mts @@ -1,5 +1,5 @@ -import { chalk } from '../../utils/command-helpers.mjs' -import BaseCommand from "../base-command.mjs"; +import { chalk } from '../../utils/command-helpers.mjs' +import BaseCommand from '../base-command.mjs' export const createApiCommand = (program: BaseCommand) => program @@ -16,5 +16,5 @@ For more information on available methods checkout https://open-api.netlify.com/ .addExamples(['netlify api --list', `netlify api getSite --data '{ "site_id": "123456" }'`]) .action(async (apiMethod, options, command) => { const { apiCommand } = await import('./api.mjs') - await apiCommand(apiMethod, options, command ) - } ) + await apiCommand(apiMethod, options, command) + }) diff --git a/src/commands/blobs/blobs-set.mts b/src/commands/blobs/blobs-set.mts index 72caaa4a99e..7667371d08e 100644 --- a/src/commands/blobs/blobs-set.mts +++ b/src/commands/blobs/blobs-set.mts @@ -12,7 +12,13 @@ interface Options extends OptionValues { } // eslint-disable-next-line max-params -export const blobsSet = async (storeName: string, key: string, valueParts: string[], options: Options, command: BaseCommand) => { +export const blobsSet = async ( + storeName: string, + key: string, + valueParts: string[], + options: Options, + command: BaseCommand, +) => { const { api, siteInfo } = command.netlify const { input } = options const store = getStore({ diff --git a/src/commands/blobs/blobs.mts b/src/commands/blobs/blobs.mts index d6e42f58744..14b77d483c7 100644 --- a/src/commands/blobs/blobs.mts +++ b/src/commands/blobs/blobs.mts @@ -26,7 +26,7 @@ export const createBlobsCommand = (program: BaseCommand) => { await blobsDelete(storeName, key, _options, command) }) - program + program .command('blobs:get') .description( `(Beta) Reads an object with a given key from a Netlify Blobs store and, if it exists, prints the content to the terminal or saves it to a file`, @@ -36,12 +36,12 @@ export const createBlobsCommand = (program: BaseCommand) => { .option('-o, --output ', 'Defines the filesystem path where the blob data should be persisted') .alias('blob:get') .hook('preAction', requiresSiteInfo) - .action(async(storeName: string, key: string, options: OptionValues, command: BaseCommand) => { + .action(async (storeName: string, key: string, options: OptionValues, command: BaseCommand) => { const { blobsGet } = await import('./blobs-get.mjs') await blobsGet(storeName, key, options, command) }) - program + program .command('blobs:list') .description(`(Beta) Lists objects in a Netlify Blobs store`) .argument('', 'Name of the store') @@ -56,12 +56,12 @@ export const createBlobsCommand = (program: BaseCommand) => { .option('--json', `Output list contents as JSON`) .alias('blob:list') .hook('preAction', requiresSiteInfo) - .action(async(storeName: string, options: OptionValues, command: BaseCommand) => { + .action(async (storeName: string, options: OptionValues, command: BaseCommand) => { const { blobsList } = await import('./blobs-list.mjs') await blobsList(storeName, options, command) }) - program + program .command('blobs:set') .description( `(Beta) Writes to a Netlify Blobs store an object with the data provided in the command or the contents of a file defined by the 'input' parameter`, @@ -73,10 +73,12 @@ export const createBlobsCommand = (program: BaseCommand) => { .alias('blob:set') .hook('preAction', requiresSiteInfo) // eslint-disable-next-line max-params - .action(async(storeName: string, key: string, valueParts: string[], options: OptionValues, command: BaseCommand) => { - const { blobsSet } = await import('./blobs-set.mjs') - await blobsSet(storeName, key, valueParts, options, command) - }) + .action( + async (storeName: string, key: string, valueParts: string[], options: OptionValues, command: BaseCommand) => { + const { blobsSet } = await import('./blobs-set.mjs') + await blobsSet(storeName, key, valueParts, options, command) + }, + ) return program .command('blobs') diff --git a/src/commands/build/build.mts b/src/commands/build/build.mts index a78324e0651..0102feda682 100644 --- a/src/commands/build/build.mts +++ b/src/commands/build/build.mts @@ -33,7 +33,6 @@ const injectEnv = async function (command, { api, buildOptions, context, siteInf } } - export const build = async (options: OptionValues, command: BaseCommand) => { const { cachedConfig, siteInfo } = command.netlify command.setAnalyticsPayload({ dry: options.dry }) @@ -53,7 +52,7 @@ export const build = async (options: OptionValues, command: BaseCommand) => { packagePath: command.workspacePackage, currentDir: command.workingDir, token, - // @ts-expect-error TS(2740) + // @ts-expect-error TS(2740) options, }) @@ -68,4 +67,3 @@ export const build = async (options: OptionValues, command: BaseCommand) => { const { exitCode } = await runBuild(buildOptions) exit(exitCode) } - diff --git a/src/commands/build/index.mts b/src/commands/build/index.mts index 90a0a7e33c6..7d4d29157c0 100644 --- a/src/commands/build/index.mts +++ b/src/commands/build/index.mts @@ -1,7 +1,7 @@ import process from 'process' import { normalizeContext } from '../../utils/env/index.mjs' -import BaseCommand from "../base-command.mjs"; +import BaseCommand from '../base-command.mjs' export const createBuildCommand = (program: BaseCommand) => program @@ -16,7 +16,7 @@ export const createBuildCommand = (program: BaseCommand) => .option('--dry', 'Dry run: show instructions without running them', false) .option('-o, --offline', 'disables any features that require network access', false) .addExamples(['netlify build']) - .action(async(options, command) => { + .action(async (options, command) => { const { build } = await import('./build.mjs') - await build(options, command ) + await build(options, command) }) diff --git a/src/commands/completion/index.mts b/src/commands/completion/index.mts index d3b967125ee..38884810821 100644 --- a/src/commands/completion/index.mts +++ b/src/commands/completion/index.mts @@ -1,14 +1,13 @@ -import { OptionValues } from "commander" - -import BaseCommand from "../base-command.mjs" +import { OptionValues } from 'commander' +import BaseCommand from '../base-command.mjs' export const createCompletionCommand = (program: BaseCommand) => { program .command('completion:install') .alias('completion:generate') .description('Generates completion script for your preferred shell') - .action(async(options: OptionValues, command: BaseCommand) => { + .action(async (options: OptionValues, command: BaseCommand) => { const { completionGenerate } = await import('./completion.mjs') await completionGenerate(options, command) }) @@ -18,7 +17,7 @@ export const createCompletionCommand = (program: BaseCommand) => { .alias('completion:remove') .description('Uninstalls the installed completions') .addExamples(['netlify completion:uninstall']) - .action(async(options: OptionValues, command: BaseCommand) => { + .action(async (options: OptionValues, command: BaseCommand) => { const { completionUninstall } = await import('./completion.mjs') await completionUninstall(options, command) }) diff --git a/src/commands/deploy/deploy.mts b/src/commands/deploy/deploy.mts index b05b782c87c..5a11852c848 100644 --- a/src/commands/deploy/deploy.mts +++ b/src/commands/deploy/deploy.mts @@ -819,4 +819,3 @@ export const deploy = async (options: OptionValues, command: BaseCommand) => { exit() } } - diff --git a/src/commands/dev/dev-exec.mts b/src/commands/dev/dev-exec.mts index 460895f952d..ec52ec0bd01 100644 --- a/src/commands/dev/dev-exec.mts +++ b/src/commands/dev/dev-exec.mts @@ -5,8 +5,7 @@ import { getDotEnvVariables, injectEnvVariables } from '../../utils/dev.mjs' import { getEnvelopeEnv } from '../../utils/env/index.mjs' import BaseCommand from '../base-command.mjs' - -export const devExec = async (cmd:string, options: OptionValues, command: BaseCommand) => { +export const devExec = async (cmd: string, options: OptionValues, command: BaseCommand) => { const { api, cachedConfig, config, site, siteInfo } = command.netlify let { env } = cachedConfig diff --git a/src/commands/dev/dev.mts b/src/commands/dev/dev.mts index 7c969b80057..6c9d94d8c8a 100644 --- a/src/commands/dev/dev.mts +++ b/src/commands/dev/dev.mts @@ -26,7 +26,6 @@ import { getProxyUrl } from '../../utils/proxy.mjs' import { runDevTimeline } from '../../utils/run-build.mjs' import BaseCommand from '../base-command.mjs' - /** * * @param {object} config @@ -66,7 +65,6 @@ const handleLiveTunnel = async ({ api, options, settings, site, state }) => { } } - export const dev = async (options: OptionValues, command: BaseCommand) => { log(`${NETLIFYDEV}`) const { api, cachedConfig, config, repositoryRoot, site, siteInfo, state } = command.netlify diff --git a/src/commands/dev/index.mts b/src/commands/dev/index.mts index 3f9a3f53d59..9a62614538d 100644 --- a/src/commands/dev/index.mts +++ b/src/commands/dev/index.mts @@ -1,10 +1,7 @@ import { Option, OptionValues } from 'commander' -import { - BANG, - chalk, -} from '../../utils/command-helpers.mjs' -import { normalizeContext } from '../../utils/env/index.mjs' +import { BANG, chalk } from '../../utils/command-helpers.mjs' +import { normalizeContext } from '../../utils/env/index.mjs' import { getGeoCountryArgParser } from '../../utils/validation.mjs' import BaseCommand from '../base-command.mjs' @@ -26,24 +23,23 @@ const validateShortFlagArgs = (args: string) => { export const createDevCommand = (program: BaseCommand) => { program - .command('dev:exec') - .argument('<...cmd>', `the command that should be executed`) - .option( - '--context ', - 'Specify a deploy context or branch for environment variables (contexts: "production", "deploy-preview", "branch-deploy", "dev")', - normalizeContext, - 'dev', - ) - .description( - 'Exec command\nRuns a command within the netlify dev environment, e.g. with env variables from any installed addons', - ) - .allowExcessArguments(true) - .addExamples(['netlify dev:exec npm run bootstrap']) - .action(async (cmd:string, options: OptionValues, command: BaseCommand) => { - const { devExec } = await import('./dev-exec.mjs') - await devExec(cmd, options, command) - }) - + .command('dev:exec') + .argument('<...cmd>', `the command that should be executed`) + .option( + '--context ', + 'Specify a deploy context or branch for environment variables (contexts: "production", "deploy-preview", "branch-deploy", "dev")', + normalizeContext, + 'dev', + ) + .description( + 'Exec command\nRuns a command within the netlify dev environment, e.g. with env variables from any installed addons', + ) + .allowExcessArguments(true) + .addExamples(['netlify dev:exec npm run bootstrap']) + .action(async (cmd: string, options: OptionValues, command: BaseCommand) => { + const { devExec } = await import('./dev-exec.mjs') + await devExec(cmd, options, command) + }) return program .command('dev') diff --git a/src/commands/env/env-clone.mts b/src/commands/env/env-clone.mts index 0fc041d05b7..fdd5bbc7108 100644 --- a/src/commands/env/env-clone.mts +++ b/src/commands/env/env-clone.mts @@ -1,4 +1,3 @@ - import { OptionValues } from 'commander' import { chalk, error as logError, log } from '../../utils/command-helpers.mjs' @@ -87,7 +86,6 @@ const envelopeToEnvelope = async ({ api, siteFrom, siteTo }) => { return true } - /** * Copies the env from a site not configured with Envelope to a different site not configured with Envelope * @returns {Promise} @@ -164,7 +162,6 @@ const mongoToEnvelope = async ({ api, siteFrom, siteTo }) => { return true } - export const envClone = async (options: OptionValues, command: BaseCommand) => { const { api, site } = command.netlify diff --git a/src/commands/env/env-get.mts b/src/commands/env/env-get.mts index 57bce0fbd3d..a16a05e78ef 100644 --- a/src/commands/env/env-get.mts +++ b/src/commands/env/env-get.mts @@ -4,7 +4,6 @@ import { chalk, error, log, logJson } from '../../utils/command-helpers.mjs' import { AVAILABLE_CONTEXTS, getEnvelopeEnv } from '../../utils/env/index.mjs' import BaseCommand from '../base-command.mjs' - export const envGet = async (name: string, options: OptionValues, command: BaseCommand) => { const { context, scope } = options const { api, cachedConfig, site } = command.netlify diff --git a/src/commands/env/env-import.mts b/src/commands/env/env-import.mts index 063eaf8948b..6c8bdf4250f 100644 --- a/src/commands/env/env-import.mts +++ b/src/commands/env/env-import.mts @@ -8,7 +8,6 @@ import { exit, log, logJson } from '../../utils/command-helpers.mjs' import { translateFromEnvelopeToMongo, translateFromMongoToEnvelope } from '../../utils/env/index.mjs' import BaseCommand from '../base-command.mjs' - /** * Updates the imported env in the site record * @returns {Promise} @@ -76,7 +75,6 @@ const importIntoEnvelope = async ({ api, importedEnv, options, siteInfo }) => { } } - export const envImport = async (fileName: string, options: OptionValues, command: BaseCommand) => { const { api, cachedConfig, site } = command.netlify const siteId = site.id diff --git a/src/commands/env/env-set.mts b/src/commands/env/env-set.mts index 8d1f407f7d4..92a25536341 100644 --- a/src/commands/env/env-set.mts +++ b/src/commands/env/env-set.mts @@ -1,15 +1,9 @@ - import { OptionValues } from 'commander' import { chalk, error, log, logJson } from '../../utils/command-helpers.mjs' -import { - AVAILABLE_CONTEXTS, - AVAILABLE_SCOPES, - translateFromEnvelopeToMongo, -} from '../../utils/env/index.mjs' +import { AVAILABLE_CONTEXTS, AVAILABLE_SCOPES, translateFromEnvelopeToMongo } from '../../utils/env/index.mjs' import BaseCommand from '../base-command.mjs' - /** * Updates the env for a site record with a new key/value pair * @returns {Promise} @@ -136,7 +130,6 @@ const setInEnvelope = async ({ api, context, key, scope, secret, siteInfo, value } } - export const envSet = async (key: string, value: string, options: OptionValues, command: BaseCommand) => { const { context, scope, secret } = options diff --git a/src/commands/env/env-unset.mts b/src/commands/env/env-unset.mts index a796deddc13..8615e2c7ed2 100644 --- a/src/commands/env/env-unset.mts +++ b/src/commands/env/env-unset.mts @@ -1,4 +1,3 @@ - import { OptionValues } from 'commander' import { chalk, error, log, logJson } from '../../utils/command-helpers.mjs' @@ -93,7 +92,6 @@ const unsetInEnvelope = async ({ api, context, key, siteInfo }) => { return env } - export const envUnset = async (key: string, options: OptionValues, command: BaseCommand) => { const { context } = options const { api, cachedConfig, site } = command.netlify @@ -129,4 +127,3 @@ export const envUnset = async (key: string, options: OptionValues, command: Base const contextType = AVAILABLE_CONTEXTS.includes(context || 'all') ? 'context' : 'branch' log(`Unset environment variable ${chalk.yellow(key)} in the ${chalk.magenta(context || 'all')} ${contextType}`) } - diff --git a/src/commands/env/env.mts b/src/commands/env/env.mts index 1adc131702e..cf58e55d1a3 100644 --- a/src/commands/env/env.mts +++ b/src/commands/env/env.mts @@ -1,40 +1,38 @@ - import { OptionValues, Option } from 'commander' -import { normalizeContext } from '../../utils/env/index.mjs' +import { normalizeContext } from '../../utils/env/index.mjs' import BaseCommand from '../base-command.mjs' - const env = (options: OptionValues, command: BaseCommand) => { command.help() } export const createEnvCommand = (program: BaseCommand) => { program - .command('env:get') - .argument('', 'Environment variable name') - .option( - '-c, --context ', - 'Specify a deploy context or branch (contexts: "production", "deploy-preview", "branch-deploy", "dev")', - normalizeContext, - 'dev', - ) - .addOption( - new Option('-s, --scope ', 'Specify a scope') - .choices(['builds', 'functions', 'post-processing', 'runtime', 'any']) - .default('any'), - ) - .addExamples([ - 'netlify env:get MY_VAR # get value for MY_VAR in dev context', - 'netlify env:get MY_VAR --context production', - 'netlify env:get MY_VAR --context branch:staging', - 'netlify env:get MY_VAR --scope functions', - ]) - .description('Get resolved value of specified environment variable (includes netlify.toml)') - .action(async (name: string, options: OptionValues, command: BaseCommand) => { - const { envGet } = await import('./env-get.mjs') - await envGet(name, options, command) - }) + .command('env:get') + .argument('', 'Environment variable name') + .option( + '-c, --context ', + 'Specify a deploy context or branch (contexts: "production", "deploy-preview", "branch-deploy", "dev")', + normalizeContext, + 'dev', + ) + .addOption( + new Option('-s, --scope ', 'Specify a scope') + .choices(['builds', 'functions', 'post-processing', 'runtime', 'any']) + .default('any'), + ) + .addExamples([ + 'netlify env:get MY_VAR # get value for MY_VAR in dev context', + 'netlify env:get MY_VAR --context production', + 'netlify env:get MY_VAR --context branch:staging', + 'netlify env:get MY_VAR --scope functions', + ]) + .description('Get resolved value of specified environment variable (includes netlify.toml)') + .action(async (name: string, options: OptionValues, command: BaseCommand) => { + const { envGet } = await import('./env-get.mjs') + await envGet(name, options, command) + }) program .command('env:import') @@ -54,11 +52,11 @@ export const createEnvCommand = (program: BaseCommand) => { ) .description('Import and set environment variables from .env file') .action(async (fileName: string, options: OptionValues, command: BaseCommand) => { - const {envImport} = await import('./env-import.mjs') + const { envImport } = await import('./env-import.mjs') await envImport(fileName, options, command) }) - program + program .command('env:list') .option( '-c, --context ', @@ -82,11 +80,11 @@ export const createEnvCommand = (program: BaseCommand) => { ]) .description('Lists resolved environment variables for site (includes netlify.toml)') .action(async (options: OptionValues, command: BaseCommand) => { - const {envList} = await import('./env-list.mjs') + const { envList } = await import('./env-list.mjs') await envList(options, command) }) - program + program .command('env:set') .argument('', 'Environment variable key') .argument('[value]', 'Value to set to', '') @@ -116,13 +114,12 @@ export const createEnvCommand = (program: BaseCommand) => { 'netlify env:set VAR_NAME value --scope builds functions', 'netlify env:set VAR_NAME --secret # convert existing variable to secret', ]) - .action(async (key: string, value:string, options: OptionValues, command: BaseCommand) => { - const {envSet} = await import('./env-set.mjs') + .action(async (key: string, value: string, options: OptionValues, command: BaseCommand) => { + const { envSet } = await import('./env-set.mjs') await envSet(key, value, options, command) }) - - program + program .command('env:unset') .aliases(['env:delete', 'env:remove']) .argument('', 'Environment variable key') @@ -140,11 +137,11 @@ export const createEnvCommand = (program: BaseCommand) => { ]) .description('Unset an environment variable which removes it from the UI') .action(async (key: string, options: OptionValues, command: BaseCommand) => { - const {envUnset} = await import('./env-unset.mjs') + const { envUnset } = await import('./env-unset.mjs') await envUnset(key, options, command) }) - program + program .command('env:clone') .alias('env:migrate') .option('-f, --from ', 'Site ID (From)') @@ -152,11 +149,10 @@ export const createEnvCommand = (program: BaseCommand) => { .description(`Clone environment variables from one site to another`) .addExamples(['netlify env:clone --to ', 'netlify env:clone --to --from ']) .action(async (options: OptionValues, command: BaseCommand) => { - const {envClone} = await import('./env-clone.mjs') + const { envClone } = await import('./env-clone.mjs') await envClone(options, command) }) - return program .command('env') .description('Control environment variables for the current site') diff --git a/src/commands/functions/functions-build.mts b/src/commands/functions/functions-build.mts index f293aa41918..800a4e8d841 100644 --- a/src/commands/functions/functions-build.mts +++ b/src/commands/functions/functions-build.mts @@ -7,7 +7,6 @@ import { NETLIFYDEVERR, NETLIFYDEVLOG, exit, log } from '../../utils/command-hel import { getFunctionsDir } from '../../utils/functions/index.mjs' import BaseCommand from '../base-command.mjs' - export const functionsBuild = async (options: OptionValues, command: BaseCommand) => { const { config } = command.netlify diff --git a/src/commands/functions/functions-create.mts b/src/commands/functions/functions-create.mts index b8308e295fd..e7a29377715 100644 --- a/src/commands/functions/functions-create.mts +++ b/src/commands/functions/functions-create.mts @@ -750,7 +750,6 @@ const ensureFunctionPathIsOk = function (functionsDir, name) { return functionPath } - export const functionsCreate = async (name: string, options: OptionValues, command: BaseCommand) => { const functionType = await selectTypeOfFunc() const functionsDir = diff --git a/src/commands/functions/functions-serve.mts b/src/commands/functions/functions-serve.mts index a9f1a81557e..3d4d9b282cb 100644 --- a/src/commands/functions/functions-serve.mts +++ b/src/commands/functions/functions-serve.mts @@ -11,7 +11,6 @@ import BaseCommand from '../base-command.mjs' const DEFAULT_PORT = 9999 - export const functionsServe = async (options: OptionValues, command: BaseCommand) => { const { api, config, site, siteInfo, state } = command.netlify @@ -59,4 +58,3 @@ export const functionsServe = async (options: OptionValues, command: BaseCommand const url = getProxyUrl({ port: functionsPort }) printBanner({ url }) } - diff --git a/src/commands/functions/functions.mts b/src/commands/functions/functions.mts index 44cfffb4d44..7db507c491a 100644 --- a/src/commands/functions/functions.mts +++ b/src/commands/functions/functions.mts @@ -1,4 +1,3 @@ - import { OptionValues } from 'commander' import { chalk } from '../../utils/command-helpers.mjs' @@ -16,29 +15,28 @@ export const createFunctionsCommand = (program: BaseCommand) => { .description('Build functions locally') .option('-f, --functions ', 'Specify a functions directory to build to') .option('-s, --src ', 'Specify the source directory for the functions') - .action(async(options: OptionValues, command: BaseCommand) => { + .action(async (options: OptionValues, command: BaseCommand) => { const { functionsBuild } = await import('./functions-build.mjs') await functionsBuild(options, command) }) program - .command('functions:create') - .alias('function:create') - .argument('[name]', 'name of your new function file inside your functions directory') - .description('Create a new function locally') - .option('-n, --name ', 'function name') - .option('-u, --url ', 'pull template from URL') - .option('-l, --language ', 'function language') - .addExamples([ - 'netlify functions:create', - 'netlify functions:create hello-world', - 'netlify functions:create --name hello-world', - ]) - .action(async(name: string, options: OptionValues, command: BaseCommand) => { - const { functionsCreate } = await import('./functions-create.mjs') - await functionsCreate(name, options, command) - }) - + .command('functions:create') + .alias('function:create') + .argument('[name]', 'name of your new function file inside your functions directory') + .description('Create a new function locally') + .option('-n, --name ', 'function name') + .option('-u, --url ', 'pull template from URL') + .option('-l, --language ', 'function language') + .addExamples([ + 'netlify functions:create', + 'netlify functions:create hello-world', + 'netlify functions:create --name hello-world', + ]) + .action(async (name: string, options: OptionValues, command: BaseCommand) => { + const { functionsCreate } = await import('./functions-create.mjs') + await functionsCreate(name, options, command) + }) program .command('functions:invoke') @@ -71,13 +69,12 @@ export const createFunctionsCommand = (program: BaseCommand) => { 'netlify functions:invoke myfunction --querystring "foo=1', 'netlify functions:invoke myfunction --payload "./pathTo.json"', ]) - .action(async(name: string, options: OptionValues, command: BaseCommand) => { + .action(async (name: string, options: OptionValues, command: BaseCommand) => { const { functionsInvoke } = await import('./functions-invoke.mjs') await functionsInvoke(name, options, command) }) - - program + program .command('functions:list') .alias('function:list') .description( @@ -89,12 +86,12 @@ NOT the same as listing the functions that have been deployed. For that info you .option('-f, --functions ', 'Specify a functions directory to list') .option('--json', 'Output function data as JSON') .hook('preAction', requiresSiteInfo) - .action(async(options: OptionValues, command: BaseCommand) => { + .action(async (options: OptionValues, command: BaseCommand) => { const { functionsList } = await import('./functions-list.mjs') await functionsList(options, command) }) - program + program .command('functions:serve') .alias('function:serve') .description('Serve functions locally') @@ -102,7 +99,7 @@ NOT the same as listing the functions that have been deployed. For that info you .option('-p, --port ', 'Specify a port for the functions server', (value) => Number.parseInt(value)) .option('-o, --offline', 'disables any features that require network access') .addHelpText('after', 'Helpful for debugging functions.') - .action(async(options: OptionValues, command: BaseCommand) => { + .action(async (options: OptionValues, command: BaseCommand) => { const { functionsServe } = await import('./functions-serve.mjs') await functionsServe(options, command) }) diff --git a/src/commands/init/index.mts b/src/commands/init/index.mts index 96f608a9cc7..49b4f18a0b5 100644 --- a/src/commands/init/index.mts +++ b/src/commands/init/index.mts @@ -1,6 +1,6 @@ -import { Option, OptionValues } from "commander"; +import { Option, OptionValues } from 'commander' -import BaseCommand from "../base-command.mjs"; +import BaseCommand from '../base-command.mjs' export const createInitCommand = (program: BaseCommand) => program @@ -17,7 +17,7 @@ export const createInitCommand = (program: BaseCommand) => ).hideHelp(true), ) .option('--git-remote-name ', 'Name of Git remote to use. e.g. "origin"') - .action(async(options: OptionValues, command: BaseCommand) => { + .action(async (options: OptionValues, command: BaseCommand) => { const { init } = await import('./init.mjs') await init(options, command) }) diff --git a/src/commands/integration/deploy.mts b/src/commands/integration/deploy.mts index e67aab077ab..103097e9674 100644 --- a/src/commands/integration/deploy.mts +++ b/src/commands/integration/deploy.mts @@ -404,7 +404,7 @@ export const deploy = async (options: OptionValues, command: BaseCommand) => { packagePath: command.workspacePackage, currentDir: command.workingDir, token, - // @ts-expect-error TS(2740) + // @ts-expect-error TS(2740) options, }) diff --git a/src/commands/integration/index.mts b/src/commands/integration/index.mts index aa9170d64c3..e77471d9077 100644 --- a/src/commands/integration/index.mts +++ b/src/commands/integration/index.mts @@ -2,7 +2,7 @@ import { env } from 'process' import { OptionValues } from 'commander' -import BaseCommand from "../base-command.mjs" +import BaseCommand from '../base-command.mjs' const integrations = (options: OptionValues, command: BaseCommand) => { command.help() @@ -10,18 +10,17 @@ const integrations = (options: OptionValues, command: BaseCommand) => { export const createIntegrationDeployCommand = (program: BaseCommand) => { program - .command('integration:deploy') - .alias('int:deploy') - .description('Register, build, and deploy a private integration on Netlify') - .option('-p, --prod', 'Deploy to production', false) - .option('-b, --build', 'Build the integration', false) - .option('-a, --auth ', 'Netlify auth token to deploy with', env.NETLIFY_AUTH_TOKEN) - .option('-s, --site ', 'A site name or ID to deploy to', env.NETLIFY_SITE_ID) - .action(async(options: OptionValues, command: BaseCommand) => { - const { deploy } = await import('./deploy.mjs') - await deploy(options, command) - }) - + .command('integration:deploy') + .alias('int:deploy') + .description('Register, build, and deploy a private integration on Netlify') + .option('-p, --prod', 'Deploy to production', false) + .option('-b, --build', 'Build the integration', false) + .option('-a, --auth ', 'Netlify auth token to deploy with', env.NETLIFY_AUTH_TOKEN) + .option('-s, --site ', 'A site name or ID to deploy to', env.NETLIFY_SITE_ID) + .action(async (options: OptionValues, command: BaseCommand) => { + const { deploy } = await import('./deploy.mjs') + await deploy(options, command) + }) } export const createIntegrationCommand = (program: BaseCommand) => { diff --git a/src/commands/link/index.mts b/src/commands/link/index.mts index cc15cd4913d..b2fe2d89120 100644 --- a/src/commands/link/index.mts +++ b/src/commands/link/index.mts @@ -1,7 +1,6 @@ -import { Option, OptionValues } from "commander"; - -import BaseCommand from "../base-command.mjs"; +import { Option, OptionValues } from 'commander' +import BaseCommand from '../base-command.mjs' export const createLinkCommand = (program: BaseCommand) => program diff --git a/src/commands/link/link.mts b/src/commands/link/link.mts index 29b1bfb6bb0..8f6a834eb14 100644 --- a/src/commands/link/link.mts +++ b/src/commands/link/link.mts @@ -250,7 +250,6 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`) return site } - export const link = async (options: OptionValues, command: BaseCommand) => { await command.authenticate() diff --git a/src/commands/lm/lm-install.mts b/src/commands/lm/lm-install.mts index 3f3b9cd050b..104d46dcda5 100644 --- a/src/commands/lm/lm-install.mts +++ b/src/commands/lm/lm-install.mts @@ -3,7 +3,6 @@ import { OptionValues } from 'commander' import { installPlatform } from '../../utils/lm/install.mjs' import { printBanner } from '../../utils/lm/ui.mjs' - export const lmInstall = async ({ force }: OptionValues) => { const installed = await installPlatform({ force }) if (installed) { diff --git a/src/commands/lm/lm-setup.mts b/src/commands/lm/lm-setup.mts index 7c56083ffe3..5215040adf6 100644 --- a/src/commands/lm/lm-setup.mts +++ b/src/commands/lm/lm-setup.mts @@ -57,7 +57,6 @@ const configureLFSURL = async function (siteId, api) { return execa('git', ['config', '-f', '.lfsconfig', 'lfs.url', url]) } - export const lmSetup = async (options: OptionValues, command: BaseCommand) => { await command.authenticate() diff --git a/src/commands/lm/lm.mts b/src/commands/lm/lm.mts index 11701be5e12..7e1e30773e8 100644 --- a/src/commands/lm/lm.mts +++ b/src/commands/lm/lm.mts @@ -2,33 +2,32 @@ import { OptionValues } from 'commander' import BaseCommand from '../base-command.mjs' - const lm = (options: OptionValues, command: BaseCommand) => { command.help() } export const createLmCommand = (program: BaseCommand) => { program - .command('lm:info', { hidden: true }) - .description('Show large media requirements information.') - .action(async () => { - const { lmInfo } = await import('./lm-info.mjs') - await lmInfo() - }) + .command('lm:info', { hidden: true }) + .description('Show large media requirements information.') + .action(async () => { + const { lmInfo } = await import('./lm-info.mjs') + await lmInfo() + }) program - .command('lm:install', { hidden: true }) - .alias('lm:init') - .description( - `Configures your computer to use Netlify Large Media + .command('lm:install', { hidden: true }) + .alias('lm:init') + .description( + `Configures your computer to use Netlify Large Media It installs the required credentials helper for Git, and configures your Git environment with the right credentials.`, - ) - .option('-f, --force', 'Force the credentials helper installation') - .action(async (options: OptionValues) => { - const { lmInstall } = await import('./lm-install.mjs') - await lmInstall(options) - }) + ) + .option('-f, --force', 'Force the credentials helper installation') + .action(async (options: OptionValues) => { + const { lmInstall } = await import('./lm-install.mjs') + await lmInstall(options) + }) program .command('lm:setup', { hidden: true }) @@ -41,14 +40,13 @@ and configures your Git environment with the right credentials.`, await lmSetup(options, command) }) - - program + program .command('lm:uninstall', { hidden: true }) .alias('lm:remove') .description( 'Uninstalls Netlify git credentials helper and cleans up any related configuration changes made by the install command.', ) - .action(async() => { + .action(async () => { const { lmUninstall } = await import('./lm-uninstall.mjs') await lmUninstall() }) diff --git a/src/commands/login/login.mts b/src/commands/login/login.mts index 85cbb80e410..d1fcd3c8938 100644 --- a/src/commands/login/login.mts +++ b/src/commands/login/login.mts @@ -17,7 +17,6 @@ const msg = function (location) { } } - export const login = async (options: OptionValues, command: BaseCommand) => { // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0. const [accessToken, location] = await getToken() diff --git a/src/commands/logout/index.mts b/src/commands/logout/index.mts index 0df6d3ffe21..469ca8212e4 100644 --- a/src/commands/logout/index.mts +++ b/src/commands/logout/index.mts @@ -1,12 +1,12 @@ -import { OptionValues } from "commander"; +import { OptionValues } from 'commander' -import BaseCommand from "../base-command.mjs"; +import BaseCommand from '../base-command.mjs' export const createLogoutCommand = (program: BaseCommand) => program - .command('logout', { hidden: true }) - .description('Logout of your Netlify account') - .action(async (options: OptionValues, command: BaseCommand) => { - const { logout } = await import('./logout.mjs') - await logout(options, command) - }) + .command('logout', { hidden: true }) + .description('Logout of your Netlify account') + .action(async (options: OptionValues, command: BaseCommand) => { + const { logout } = await import('./logout.mjs') + await logout(options, command) + }) diff --git a/src/commands/logout/logout.mts b/src/commands/logout/logout.mts index ef53522d75b..485b22cfea8 100644 --- a/src/commands/logout/logout.mts +++ b/src/commands/logout/logout.mts @@ -4,7 +4,6 @@ import { exit, getToken, log } from '../../utils/command-helpers.mjs' import { track } from '../../utils/telemetry/index.mjs' import BaseCommand from '../base-command.mjs' - export const logout = async (options: OptionValues, command: BaseCommand) => { // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0. const [accessToken, location] = await getToken() diff --git a/src/commands/logs/index.mts b/src/commands/logs/index.mts index 057d866dcc5..8e42c5cab9f 100644 --- a/src/commands/logs/index.mts +++ b/src/commands/logs/index.mts @@ -4,13 +4,13 @@ import BaseCommand from '../base-command.mjs' export const createLogsBuildCommand = (program: BaseCommand) => { program - .command('logs:deploy') - .alias('logs:build') - .description('(Beta) Stream the logs of deploys currently being built to the console') - .action(async (options: OptionValues, command: BaseCommand) => { - const { logsBuild } = await import('./build.mjs') - await logsBuild(options, command) - }) + .command('logs:deploy') + .alias('logs:build') + .description('(Beta) Stream the logs of deploys currently being built to the console') + .action(async (options: OptionValues, command: BaseCommand) => { + const { logsBuild } = await import('./build.mjs') + await logsBuild(options, command) + }) } export const createLogsFunctionCommand = (program: BaseCommand) => { @@ -24,10 +24,9 @@ export const createLogsFunctionCommand = (program: BaseCommand) => { const { logsFunction } = await import('./functions.mjs') await logsFunction(functionName, options, command) }) - } +} export const createLogsCommand = (program: BaseCommand) => { - createLogsBuildCommand(program) createLogsFunctionCommand(program) diff --git a/src/commands/open/index.mts b/src/commands/open/index.mts index 446d14228f5..ca62242171d 100644 --- a/src/commands/open/index.mts +++ b/src/commands/open/index.mts @@ -1,18 +1,18 @@ -import { OptionValues } from "commander" +import { OptionValues } from 'commander' import requiresSiteInfo from '../../utils/hooks/requires-site-info.mjs' -import BaseCommand from "../base-command.mjs" +import BaseCommand from '../base-command.mjs' export const createOpenCommand = (program: BaseCommand) => { program - .command('open:admin') - .description('Opens current site admin UI in Netlify') - .addExamples(['netlify open:admin']) - .hook('preAction', requiresSiteInfo) - .action(async (options: OptionValues, command: BaseCommand) => { - const { openAdmin } = await import('./open-admin.mjs') - await openAdmin(options, command) - }) + .command('open:admin') + .description('Opens current site admin UI in Netlify') + .addExamples(['netlify open:admin']) + .hook('preAction', requiresSiteInfo) + .action(async (options: OptionValues, command: BaseCommand) => { + const { openAdmin } = await import('./open-admin.mjs') + await openAdmin(options, command) + }) program .command('open:site') @@ -24,7 +24,6 @@ export const createOpenCommand = (program: BaseCommand) => { await openSite(options, command) }) - return program .command('open') .description(`Open settings for the site linked to the current folder`) diff --git a/src/commands/open/open-admin.mts b/src/commands/open/open-admin.mts index c66c9bdad2b..c2278ddfb9e 100644 --- a/src/commands/open/open-admin.mts +++ b/src/commands/open/open-admin.mts @@ -4,7 +4,6 @@ import { exit, log } from '../../utils/command-helpers.mjs' import openBrowser from '../../utils/open-browser.mjs' import BaseCommand from '../base-command.mjs' - export const openAdmin = async (options: OptionValues, command: BaseCommand) => { const { siteInfo } = command.netlify diff --git a/src/commands/open/open-site.mts b/src/commands/open/open-site.mts index 7b25268e3d7..4cdeda7083a 100644 --- a/src/commands/open/open-site.mts +++ b/src/commands/open/open-site.mts @@ -4,7 +4,6 @@ import { exit, log } from '../../utils/command-helpers.mjs' import openBrowser from '../../utils/open-browser.mjs' import BaseCommand from '../base-command.mjs' - export const openSite = async (options: OptionValues, command: BaseCommand) => { const { siteInfo } = command.netlify diff --git a/src/commands/open/open.mts b/src/commands/open/open.mts index 0fbd85ac219..f60ce9bebdc 100644 --- a/src/commands/open/open.mts +++ b/src/commands/open/open.mts @@ -6,7 +6,6 @@ import BaseCommand from '../base-command.mjs' import { openAdmin } from './open-admin.mjs' import { openSite } from './open-site.mjs' - export const open = async (options: OptionValues, command: BaseCommand) => { if (!options.site || !options.admin) { log(command.helpInformation()) diff --git a/src/commands/recipes/index.mts b/src/commands/recipes/index.mts index 8e6750c29ad..cc183282192 100644 --- a/src/commands/recipes/index.mts +++ b/src/commands/recipes/index.mts @@ -1,6 +1,6 @@ -import { OptionValues } from "commander" +import { OptionValues } from 'commander' -import BaseCommand from "../base-command.mjs" +import BaseCommand from '../base-command.mjs' export const createRecipesCommand = (program: BaseCommand) => { program diff --git a/src/commands/recipes/recipes.mts b/src/commands/recipes/recipes.mts index 99ffb29878d..e248c2df561 100644 --- a/src/commands/recipes/recipes.mts +++ b/src/commands/recipes/recipes.mts @@ -11,7 +11,6 @@ import { getRecipe, listRecipes } from './common.mjs' const SUGGESTION_TIMEOUT = 1e4 - // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message export const runRecipe = async ({ config, recipeName, repositoryRoot }) => { const recipe = await getRecipe(recipeName) @@ -19,7 +18,6 @@ export const runRecipe = async ({ config, recipeName, repositoryRoot }) => { return recipe.run({ config, repositoryRoot }) } - export const recipesCommand = async (recipeName: string, options: OptionValues, command: BaseCommand): Promise => { const { config, repositoryRoot } = command.netlify const sanitizedRecipeName = basename(recipeName || '').toLowerCase() diff --git a/src/commands/serve/index.mts b/src/commands/serve/index.mts index bd04792936b..4a002d32d0c 100644 --- a/src/commands/serve/index.mts +++ b/src/commands/serve/index.mts @@ -1,8 +1,8 @@ -import { Option } from "commander"; +import { Option } from 'commander' -import { normalizeContext } from '../../utils/env/index.mjs' +import { normalizeContext } from '../../utils/env/index.mjs' import { getGeoCountryArgParser } from '../../utils/validation.mjs' -import BaseCommand from "../base-command.mjs"; +import BaseCommand from '../base-command.mjs' export const createServeCommand = (program: BaseCommand) => program diff --git a/src/commands/serve/serve.mts b/src/commands/serve/serve.mts index 8744d806476..669ec07bd7e 100644 --- a/src/commands/serve/serve.mts +++ b/src/commands/serve/serve.mts @@ -24,7 +24,6 @@ import { generateInspectSettings, startProxyServer } from '../../utils/proxy-ser import { runBuildTimeline } from '../../utils/run-build.mjs' import BaseCommand from '../base-command.mjs' - export const serve = async (options: OptionValues, command: BaseCommand) => { const { api, cachedConfig, config, repositoryRoot, site, siteInfo, state } = command.netlify config.dev = { ...config.dev } diff --git a/src/commands/sites/sites-create-template.mts b/src/commands/sites/sites-create-template.mts index 37a6518a65b..3856595942f 100644 --- a/src/commands/sites/sites-create-template.mts +++ b/src/commands/sites/sites-create-template.mts @@ -69,7 +69,6 @@ const getTemplateName = async ({ ghToken, options, repository }) => { // @ts-expect-error TS(7031) FIXME: Binding element 'options' implicitly has an 'any' ... Remove this comment to see the full error message const getGitHubLink = ({ options, templateName }) => options.url || `https://github.com/${templateName}` - export const sitesCreateTemplate = async (repository: string, options: OptionValues, command: BaseCommand) => { const { api } = command.netlify diff --git a/src/commands/sites/sites-create.mts b/src/commands/sites/sites-create.mts index 8e41e6a287d..6e2e77d4141 100644 --- a/src/commands/sites/sites-create.mts +++ b/src/commands/sites/sites-create.mts @@ -28,7 +28,6 @@ export const getSiteNameInput = async (name) => { return { name } } - export const sitesCreate = async (options: OptionValues, command: BaseCommand) => { const { api } = command.netlify @@ -154,4 +153,3 @@ export const sitesCreate = async (options: OptionValues, command: BaseCommand) = return site } - diff --git a/src/commands/sites/sites-delete.mts b/src/commands/sites/sites-delete.mts index e982532ddd0..370175e3398 100644 --- a/src/commands/sites/sites-delete.mts +++ b/src/commands/sites/sites-delete.mts @@ -4,7 +4,6 @@ import inquirer from 'inquirer' import { chalk, error, exit, log } from '../../utils/command-helpers.mjs' import BaseCommand from '../base-command.mjs' - export const sitesDelete = async (siteId: string, options: OptionValues, command: BaseCommand) => { command.setAnalyticsPayload({ force: options.force }) diff --git a/src/commands/sites/sites-list.mts b/src/commands/sites/sites-list.mts index a3de86eeed2..399da20a73d 100644 --- a/src/commands/sites/sites-list.mts +++ b/src/commands/sites/sites-list.mts @@ -5,7 +5,6 @@ import { startSpinner, stopSpinner } from '../../lib/spinner.mjs' import { chalk, log, logJson } from '../../utils/command-helpers.mjs' import BaseCommand from '../base-command.mjs' - export const sitesList = async (options: OptionValues, command: BaseCommand) => { const { api } = command.netlify /** @type {import('ora').Ora} */ diff --git a/src/commands/sites/sites.mts b/src/commands/sites/sites.mts index 911db66010d..ac48feaed3d 100644 --- a/src/commands/sites/sites.mts +++ b/src/commands/sites/sites.mts @@ -1,4 +1,4 @@ -import { OptionValues , InvalidArgumentError } from 'commander' +import { OptionValues, InvalidArgumentError } from 'commander' import BaseCommand from '../base-command.mjs' @@ -44,42 +44,40 @@ Create a site from a starter template.`, export const createSitesCreateCommand = (program: BaseCommand) => { program - .command('sites:create') - .description( - `Create an empty site (advanced) + .command('sites:create') + .description( + `Create an empty site (advanced) Create a blank site that isn't associated with any git remote. Will link the site to the current working directory.`, - ) - .option('-n, --name ', 'name of site', validateName) - .option('-a, --account-slug ', 'account slug to create the site under') - .option('-c, --with-ci', 'initialize CI hooks during site creation') - .option('-m, --manual', 'force manual CI setup. Used --with-ci flag') - .option('--disable-linking', 'create the site without linking it to current directory') - .addHelpText( - 'after', - `Create a blank site that isn't associated with any git remote. Will link the site to the current working directory.`, - ) - .action(async (options: OptionValues, command: BaseCommand) => { - const { sitesCreate } = await import('./sites-create.mjs') - await sitesCreate(options, command) - }) - } - + ) + .option('-n, --name ', 'name of site', validateName) + .option('-a, --account-slug ', 'account slug to create the site under') + .option('-c, --with-ci', 'initialize CI hooks during site creation') + .option('-m, --manual', 'force manual CI setup. Used --with-ci flag') + .option('--disable-linking', 'create the site without linking it to current directory') + .addHelpText( + 'after', + `Create a blank site that isn't associated with any git remote. Will link the site to the current working directory.`, + ) + .action(async (options: OptionValues, command: BaseCommand) => { + const { sitesCreate } = await import('./sites-create.mjs') + await sitesCreate(options, command) + }) +} export const createSitesCommand = (program: BaseCommand) => { + createSitesCreateCommand(program) + createSitesFromTemplateCommand(program) - createSitesCreateCommand(program) - createSitesFromTemplateCommand(program) - - program + program .command('sites:list') .description('List all sites you have access to') .option('--json', 'Output site data as JSON') .action(async (options: OptionValues, command: BaseCommand) => { - const {sitesList} = await import('./sites-list.mjs') + const { sitesList } = await import('./sites-list.mjs') await sitesList(options, command) }) - program + program .command('sites:delete') .description('Delete a site\nThis command will permanently delete the site on Netlify. Use with caution.') .argument('', 'Site ID to delete.') diff --git a/src/commands/status/index.mts b/src/commands/status/index.mts index 6e1c1d4d4e3..4993d1fe780 100644 --- a/src/commands/status/index.mts +++ b/src/commands/status/index.mts @@ -1,7 +1,7 @@ -import { OptionValues } from "commander" +import { OptionValues } from 'commander' import requiresSiteInfo from '../../utils/hooks/requires-site-info.mjs' -import BaseCommand from "../base-command.mjs" +import BaseCommand from '../base-command.mjs' export const createStatusCommand = (program: BaseCommand) => { program diff --git a/src/commands/status/status-hooks.mts b/src/commands/status/status-hooks.mts index a74f3c63d35..9c6a2076e92 100644 --- a/src/commands/status/status-hooks.mts +++ b/src/commands/status/status-hooks.mts @@ -4,7 +4,6 @@ import prettyjson from 'prettyjson' import { log } from '../../utils/command-helpers.mjs' import BaseCommand from '../base-command.mjs' - export const statusHooks = async (options: OptionValues, command: BaseCommand) => { const { api, siteInfo } = command.netlify diff --git a/src/commands/status/status.mts b/src/commands/status/status.mts index 6a331ba05f9..01a78c94596 100644 --- a/src/commands/status/status.mts +++ b/src/commands/status/status.mts @@ -5,7 +5,6 @@ import prettyjson from 'prettyjson' import { chalk, error, exit, getToken, log, logJson, warn } from '../../utils/command-helpers.mjs' import BaseCommand from '../base-command.mjs' - export const status = async (options: OptionValues, command: BaseCommand) => { const { api, globalConfig, site, siteInfo } = command.netlify const current = globalConfig.get('userId') diff --git a/src/commands/switch/index.mts b/src/commands/switch/index.mts index 9d2b7b1b798..6a085c48447 100644 --- a/src/commands/switch/index.mts +++ b/src/commands/switch/index.mts @@ -1,12 +1,12 @@ -import { OptionValues } from "commander"; +import { OptionValues } from 'commander' -import BaseCommand from "../base-command.mjs"; +import BaseCommand from '../base-command.mjs' export const createSwitchCommand = (program: BaseCommand) => program - .command('switch') - .description('Switch your active Netlify account') - .action(async (options: OptionValues, command: BaseCommand) => { - const { switchCommand } = await import('./switch.mjs') - await switchCommand(options, command) - }) + .command('switch') + .description('Switch your active Netlify account') + .action(async (options: OptionValues, command: BaseCommand) => { + const { switchCommand } = await import('./switch.mjs') + await switchCommand(options, command) + }) diff --git a/src/commands/switch/switch.mts b/src/commands/switch/switch.mts index 74f225ad496..a77d77a1160 100644 --- a/src/commands/switch/switch.mts +++ b/src/commands/switch/switch.mts @@ -7,7 +7,6 @@ import { login } from '../login/login.mjs' const LOGIN_NEW = 'I would like to login to a new account' - export const switchCommand = async (options: OptionValues, command: BaseCommand) => { const availableUsersChoices = Object.values(command.netlify.globalConfig.get('users') || {}).reduce( (prev, current) => diff --git a/src/commands/unlink/index.mts b/src/commands/unlink/index.mts index 682aee96c69..b1c1250c235 100644 --- a/src/commands/unlink/index.mts +++ b/src/commands/unlink/index.mts @@ -1,12 +1,12 @@ -import { OptionValues } from "commander"; +import { OptionValues } from 'commander' -import BaseCommand from "../base-command.mjs"; +import BaseCommand from '../base-command.mjs' export const createUnlinkCommand = (program: BaseCommand) => - program. - command('unlink') - .description('Unlink a local folder from a Netlify site') - .action(async (options: OptionValues, command: BaseCommand) => { - const { unlink } = await import('./unlink.mjs') - await unlink(options, command) - }) + program + .command('unlink') + .description('Unlink a local folder from a Netlify site') + .action(async (options: OptionValues, command: BaseCommand) => { + const { unlink } = await import('./unlink.mjs') + await unlink(options, command) + }) diff --git a/src/commands/unlink/unlink.mts b/src/commands/unlink/unlink.mts index ef616b787c9..a5316e524dc 100644 --- a/src/commands/unlink/unlink.mts +++ b/src/commands/unlink/unlink.mts @@ -4,7 +4,6 @@ import { exit, log } from '../../utils/command-helpers.mjs' import { track } from '../../utils/telemetry/index.mjs' import BaseCommand from '../base-command.mjs' - export const unlink = async (options: OptionValues, command: BaseCommand) => { const { site, siteInfo, state } = command.netlify const siteId = site.id diff --git a/src/commands/watch/index.mts b/src/commands/watch/index.mts index 505cfb58fbe..8ceeb882e76 100644 --- a/src/commands/watch/index.mts +++ b/src/commands/watch/index.mts @@ -1,6 +1,6 @@ -import { OptionValues } from "commander"; +import { OptionValues } from 'commander' -import BaseCommand from "../base-command.mjs"; +import BaseCommand from '../base-command.mjs' export const createWatchCommand = (program: BaseCommand) => program diff --git a/src/commands/watch/watch.mts b/src/commands/watch/watch.mts index 57ef45c56af..ae8b146509c 100644 --- a/src/commands/watch/watch.mts +++ b/src/commands/watch/watch.mts @@ -56,7 +56,6 @@ const waitForBuildFinish = async function (api, siteId, spinner) { return firstPass } - export const watch = async (options: OptionValues, command: BaseCommand) => { await command.authenticate() const client = command.netlify.api