Skip to content

Commit afdf219

Browse files
committed
refactor: remove more dead "addons" code
This is very old, unused code for something that no longer exists.
1 parent bc007d2 commit afdf219

13 files changed

Lines changed: 22 additions & 245 deletions

File tree

‎CLAUDE.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ Environment variables are loaded from multiple sources with specific precedence:
129129
1. Process environment
130130
2. `.env` files (multiple variants supported)
131131
3. Netlify site settings (shared, project-specific)
132-
4. Addon-provided variables
133-
5. Build-time configuration
132+
4. Build-time configuration
134133

135134
#### Function URL Routing
136135

‎eslint-suppressions.json‎

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,6 @@
266266
}
267267
},
268268
"src/commands/functions/functions-create.ts": {
269-
"@typescript-eslint/await-thenable": {
270-
"count": 1
271-
},
272-
"@typescript-eslint/no-confusing-void-expression": {
273-
"count": 1
274-
},
275269
"@typescript-eslint/no-floating-promises": {
276270
"count": 1
277271
},
@@ -285,13 +279,13 @@
285279
"count": 36
286280
},
287281
"@typescript-eslint/no-unsafe-assignment": {
288-
"count": 64
282+
"count": 38
289283
},
290284
"@typescript-eslint/no-unsafe-call": {
291-
"count": 11
285+
"count": 8
292286
},
293287
"@typescript-eslint/no-unsafe-member-access": {
294-
"count": 59
288+
"count": 47
295289
},
296290
"@typescript-eslint/no-unsafe-return": {
297291
"count": 11
@@ -303,7 +297,7 @@
303297
"count": 6
304298
},
305299
"@typescript-eslint/restrict-template-expressions": {
306-
"count": 29
300+
"count": 24
307301
},
308302
"n/no-process-exit": {
309303
"count": 2
@@ -809,20 +803,6 @@
809803
"count": 2
810804
}
811805
},
812-
"src/utils/addons/prepare.ts": {
813-
"@typescript-eslint/no-unsafe-assignment": {
814-
"count": 4
815-
},
816-
"@typescript-eslint/no-unsafe-call": {
817-
"count": 3
818-
},
819-
"@typescript-eslint/no-unsafe-member-access": {
820-
"count": 4
821-
},
822-
"@typescript-eslint/no-unsafe-return": {
823-
"count": 3
824-
}
825-
},
826806
"src/utils/agent-detection.ts": {
827807
"@typescript-eslint/prefer-nullish-coalescing": {
828808
"count": 1
@@ -1004,25 +984,25 @@
1004984
},
1005985
"src/utils/dev.ts": {
1006986
"@typescript-eslint/no-unsafe-argument": {
1007-
"count": 5
987+
"count": 3
1008988
},
1009989
"@typescript-eslint/no-unsafe-assignment": {
1010-
"count": 15
990+
"count": 9
1011991
},
1012992
"@typescript-eslint/no-unsafe-call": {
1013-
"count": 4
993+
"count": 1
1014994
},
1015995
"@typescript-eslint/no-unsafe-member-access": {
1016-
"count": 16
996+
"count": 7
1017997
},
1018998
"@typescript-eslint/no-unsafe-return": {
1019-
"count": 5
999+
"count": 2
10201000
},
10211001
"@typescript-eslint/prefer-nullish-coalescing": {
10221002
"count": 2
10231003
},
10241004
"@typescript-eslint/restrict-template-expressions": {
1025-
"count": 6
1005+
"count": 4
10261006
}
10271007
},
10281008
"src/utils/dot-env.ts": {
@@ -1193,16 +1173,16 @@
11931173
"count": 7
11941174
},
11951175
"@typescript-eslint/no-unsafe-argument": {
1196-
"count": 38
1176+
"count": 32
11971177
},
11981178
"@typescript-eslint/no-unsafe-assignment": {
1199-
"count": 69
1179+
"count": 61
12001180
},
12011181
"@typescript-eslint/no-unsafe-call": {
12021182
"count": 28
12031183
},
12041184
"@typescript-eslint/no-unsafe-member-access": {
1205-
"count": 98
1185+
"count": 96
12061186
},
12071187
"@typescript-eslint/no-unsafe-return": {
12081188
"count": 13

‎src/commands/dev/dev.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export const dev = async (options: OptionValues, command: BaseCommand) => {
148148

149149
env = await getDotEnvVariables({ devConfig, env, site })
150150

151-
const { accountId, addonsUrls, capabilities, siteUrl, timeouts } = await getSiteInformation({
151+
const { accountId, capabilities, siteUrl, timeouts } = await getSiteInformation({
152152
// inherited from base command --offline
153153

154154
offline: options.offline,
@@ -297,7 +297,6 @@ export const dev = async (options: OptionValues, command: BaseCommand) => {
297297
const inspectSettings = generateInspectSettings(options.edgeInspect, options.edgeInspectBrk)
298298

299299
await startProxyServer({
300-
addonsUrls,
301300
aiGatewayContext,
302301
api,
303302
blobsContext,

‎src/commands/functions/functions-create.ts‎

Lines changed: 3 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@ import path, { dirname, join, relative } from 'path'
66
import process from 'process'
77
import { fileURLToPath, pathToFileURL } from 'url'
88

9-
import { confirm, input, search, select, Separator } from '@inquirer/prompts'
9+
import { input, search, select, Separator } from '@inquirer/prompts'
1010
import { OptionValues } from 'commander'
1111
import { findUp } from 'find-up'
1212
import fuzzy from 'fuzzy'
1313
import fetch from 'node-fetch'
1414
import { createSpinner } from 'nanospinner'
1515

1616
import { fileExistsAsync } from '../../lib/fs.js'
17-
import { getAddons, getCurrentAddon, getSiteData } from '../../utils/addons/prepare.js'
1817
import {
19-
APIError,
2018
NETLIFYDEVERR,
2119
NETLIFYDEVLOG,
2220
NETLIFYDEVWARN,
@@ -406,10 +404,9 @@ const downloadFromURL = async function (command, options, argumentName, function
406404
const fnTemplateFile = path.join(fnFolder, '.netlify-function-template.mjs')
407405
if (await fileExistsAsync(fnTemplateFile)) {
408406
const {
409-
default: { addons = [], onComplete },
407+
default: { onComplete },
410408
} = await import(pathToFileURL(fnTemplateFile).href)
411409

412-
await installAddons(command, addons, path.resolve(fnFolder))
413410
await handleOnComplete({ command, onComplete })
414411
// delete
415412
await unlink(fnTemplateFile)
@@ -504,7 +501,7 @@ const scaffoldFromTemplate = async function (command, options, argumentName, fun
504501
} else if (chosenTemplate === 'report') {
505502
log(`${NETLIFYDEVLOG} Open in browser: https://github.com/netlify/cli/issues/new`)
506503
} else {
507-
const { addons = [], lang, name: templateName, onComplete } = chosenTemplate
504+
const { lang, name: templateName, onComplete } = chosenTemplate
508505
const pathToTemplate = path.join(templatesDir, lang, templateName)
509506
if (!fs.existsSync(pathToTemplate)) {
510507
throw new Error(
@@ -551,7 +548,6 @@ const scaffoldFromTemplate = async function (command, options, argumentName, fun
551548
await registerEFInToml(name, command.netlify)
552549
}
553550

554-
await installAddons(command, addons, path.resolve(functionPath))
555551
await handleOnComplete({ command, onComplete })
556552

557553
log()
@@ -561,26 +557,6 @@ const scaffoldFromTemplate = async function (command, options, argumentName, fun
561557

562558
const TEMPLATE_PERMISSIONS = 0o777
563559

564-
// @ts-expect-error TS(7031) FIXME: Binding element 'addonName' implicitly has an 'any... Remove this comment to see the full error message
565-
const createFunctionAddon = async function ({ addonName, addons, api, siteData, siteId }) {
566-
try {
567-
const addon = getCurrentAddon({ addons, addonName })
568-
if (addon?.id) {
569-
log(`The "${addonName} add-on" already exists for ${siteData.name}`)
570-
return false
571-
}
572-
await api.createServiceInstance({
573-
siteId,
574-
addon: addonName,
575-
body: { config: {} },
576-
})
577-
log(`Add-on "${addonName}" created for ${siteData.name}`)
578-
return true
579-
} catch (error_) {
580-
return logAndThrowError((error_ as APIError).message)
581-
}
582-
}
583-
584560
/**
585561
*
586562
* @param {object} config
@@ -601,81 +577,6 @@ const handleOnComplete = async ({ command, onComplete }) => {
601577
await onComplete.call(command)
602578
}
603579
}
604-
/**
605-
*
606-
* @param {object} config
607-
* @param {*} config.addonCreated
608-
* @param {*} config.addonDidInstall
609-
* @param {import('../base-command.js').default} config.command
610-
* @param {string} config.fnPath
611-
*/
612-
// @ts-expect-error TS(7031) FIXME: Binding element 'addonCreated' implicitly has an '... Remove this comment to see the full error message
613-
const handleAddonDidInstall = async ({ addonCreated, addonDidInstall, command, fnPath }) => {
614-
const { config } = command.netlify
615-
616-
if (!addonCreated || !addonDidInstall) {
617-
return
618-
}
619-
620-
const confirmPostInstall = await confirm({
621-
message: `This template has an optional setup script that runs after addon install. This can be helpful for first time users to try out templates. Run the script?`,
622-
default: false,
623-
})
624-
625-
if (!confirmPostInstall) {
626-
return
627-
}
628-
629-
await injectEnvVariables({
630-
devConfig: { ...config.dev },
631-
env: command.netlify.cachedConfig.env,
632-
site: command.netlify.site,
633-
})
634-
addonDidInstall(fnPath)
635-
}
636-
637-
/**
638-
*
639-
* @param {import('../base-command.js').default} command
640-
* @param {*} functionAddons
641-
* @param {*} fnPath
642-
* @returns
643-
*/
644-
// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type.
645-
const installAddons = async function (command, functionAddons, fnPath) {
646-
if (functionAddons.length === 0) {
647-
return
648-
}
649-
650-
const { api, site } = command.netlify
651-
const siteId = site.id
652-
if (!siteId) {
653-
log('No project id found, please run inside a project directory or `netlify link`')
654-
return false
655-
}
656-
log(`${NETLIFYDEVLOG} checking Netlify APIs...`)
657-
658-
const [siteData, siteAddons] = await Promise.all([getSiteData({ api, siteId }), getAddons({ api, siteId })])
659-
660-
// @ts-expect-error TS(7031) FIXME: Binding element 'addonDidInstall' implicitly has a... Remove this comment to see the full error message
661-
const arr = functionAddons.map(async ({ addonDidInstall, addonName }) => {
662-
log(`${NETLIFYDEVLOG} installing addon: ${chalk.yellow.inverse(addonName)}`)
663-
try {
664-
const addonCreated = await createFunctionAddon({
665-
api,
666-
addons: siteAddons,
667-
siteId,
668-
addonName,
669-
siteData,
670-
})
671-
672-
await handleAddonDidInstall({ addonCreated, addonDidInstall, command, fnPath })
673-
} catch (error_) {
674-
return logAndThrowError(`${NETLIFYDEVERR} Error installing addon: ${error_}`)
675-
}
676-
})
677-
return Promise.all(arr)
678-
}
679580

680581
/**
681582
*

‎src/commands/serve/serve.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const serve = async (options: OptionValues, command: BaseCommand) => {
5858

5959
env = await getDotEnvVariables({ devConfig, env, site })
6060

61-
const { accountId, addonsUrls, capabilities, siteUrl, timeouts } = await getSiteInformation({
61+
const { accountId, capabilities, siteUrl, timeouts } = await getSiteInformation({
6262
// inherited from base command --offline
6363
offline: options.offline,
6464
api,
@@ -190,7 +190,6 @@ export const serve = async (options: OptionValues, command: BaseCommand) => {
190190

191191
const inspectSettings = generateInspectSettings(options.edgeInspect, options.edgeInspectBrk)
192192
const url = await startProxyServer({
193-
addonsUrls,
194193
blobsContext: runtimeBlobsContext,
195194
command,
196195
config: mergedConfig,

‎src/lib/edge-functions/registry.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ export class EdgeFunctionsRegistryImpl implements EdgeFunctionsRegistry {
389389
if (
390390
variable.sources.includes('ui') ||
391391
variable.sources.includes('account') ||
392-
variable.sources.includes('addons') ||
393392
variable.sources.includes('internal') ||
394393
variable.sources.some((source) => source.startsWith('.env'))
395394
) {

‎src/utils/addons/prepare.ts‎

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)