Skip to content

Commit

Permalink
chore: fix ts types using that are using the Netlify API (#7000)
Browse files Browse the repository at this point in the history
* fix(deps): update netlify packages

* chore: update ts types imported from Netlify API

* chore: run lint

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
YujohnNattrass and renovate[bot] authored Jan 21, 2025
1 parent 14bd4b6 commit 529bfbb
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/commands/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ export default class BaseCommand extends Command {
const needsFeatureFlagsToResolveConfig = COMMANDS_WITH_FEATURE_FLAGS.has(actionCommand.name())
if (api.accessToken && !flags.offline && needsFeatureFlagsToResolveConfig && actionCommand.siteId) {
try {
const site = await api.getSite({ siteId: actionCommand.siteId, feature_flags: 'cli' })
const site = await (api as any).getSite({ siteId: actionCommand.siteId, feature_flags: 'cli' })
actionCommand.featureFlags = site.feature_flags
actionCommand.accountId = site.account_id
} catch {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/logs/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const logsBuild = async (options: OptionValues, command: BaseCommand) =>
})),
})

deploy = deploys.find((dep: any) => dep.id === result)
deploy = deploys.find((dep: any) => dep.id === result) || deploy
}

const { id } = deploy
Expand Down
3 changes: 2 additions & 1 deletion src/commands/logs/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export const logsFunction = async (functionName: string | undefined, options: Op

const levelsToPrint = options.level || LOG_LEVELS_LIST

const { functions = [] } = await client.searchSiteFunctions({ siteId })
// TODO: Update type once the open api spec is updated https://open-api.netlify.com/#tag/function/operation/searchSiteFunctions
const { functions = [] } = (await client.searchSiteFunctions({ siteId: siteId as string })) as any

if (functions.length === 0) {
log(`No functions found for the site`)
Expand Down
5 changes: 3 additions & 2 deletions src/commands/sites/sites-create-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const sitesCreateTemplate = async (repository: string, options: OptionVal
}

try {
const sites: SiteInfo[] = await api.listSites({ name: siteName, filter: 'all' })
const sites = await api.listSites({ name: siteName, filter: 'all' })
const siteFoundByName = sites.find((filteredSite) => filteredSite.name === siteName)
if (siteFoundByName) {
log('A site with that name already exists on your account')
Expand Down Expand Up @@ -133,7 +133,8 @@ export const sitesCreateTemplate = async (repository: string, options: OptionVal
}

try {
site = await api.createSiteInTeam({
// TODO: Update type once the open api spec is updated https://open-api.netlify.com/#tag/site/operation/createSiteInTeam
site = await (api as any).createSiteInTeam({
accountSlug,
body: {
repo: {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/sites/sites-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const sitesCreate = async (options: OptionValues, command: BaseCommand) =
}
try {
site = await api.createSiteInTeam({
accountSlug,
accountSlug: accountSlug as string,
body,
})
} catch (error_) {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/sites/sites-delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const sitesDelete = async (siteId: string, options: OptionValues, command

/* Verify the user wants to delete the site */
if (noForce) {
log(`${chalk.redBright('Warning')}: You are about to permanently delete "${chalk.bold(siteData.name)}"`)
log(`${chalk.redBright('Warning')}: You are about to permanently delete "${chalk.bold(siteData?.name)}"`)
log(` Verify this siteID "${siteId}" supplied is correct and proceed.`)
log(' To skip this prompt, pass a --force flag to the delete command')
log()
Expand All @@ -41,7 +41,7 @@ export const sitesDelete = async (siteId: string, options: OptionValues, command
const { wantsToDelete } = await inquirer.prompt({
type: 'confirm',
name: 'wantsToDelete',
message: `WARNING: Are you sure you want to delete the "${siteData.name}" site?`,
message: `WARNING: Are you sure you want to delete the "${siteData?.name}" site?`,
default: false,
})
log()
Expand Down
2 changes: 1 addition & 1 deletion src/commands/status/status-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const statusHooks = async (options: OptionValues, command: BaseCommand) =
site: siteInfo.name,
hooks: {},
}
// @ts-expect-error TS(7006) FIXME: Parameter 'hook' implicitly has an 'any' type.

ntlHooks.forEach((hook) => {
// @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
data.hooks[hook.id] = {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/status/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export const status = async (options: OptionValues, command: BaseCommand) => {

const ghuser = command.netlify.globalConfig.get(`users.${current}.auth.github.user`)
const accountData = {
Name: user.full_name,
Email: user.email,
Name: user?.full_name,
Email: user?.email,
GitHub: ghuser,
}
const teamsData = {}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/watch/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const watch = async (options: OptionValues, command: BaseCommand) => {

const noActiveBuilds = await waitForBuildFinish(client, siteId, spinner)

const siteData = await client.getSite({ siteId })
const siteData = await client.getSite({ siteId: siteId as string })

const message = chalk.cyanBright.bold.underline(noActiveBuilds ? 'Last build' : 'Deploy complete')
log()
Expand Down
2 changes: 1 addition & 1 deletion src/utils/command-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const pollForToken = async ({
ticket,
}: {
api: NetlifyAPI
ticket: { id: string; client_id: string; authorized: boolean; created_at: string }
ticket: { id?: string; client_id?: string; authorized?: boolean; created_at?: string }
}) => {
const spinner = startSpinner({ text: 'Waiting for authorization...' })
try {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/telemetry/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export async function track(
return send('track', defaultData)
}

export async function identify(payload: { name: string; email: string; userId: string }) {
export async function identify(payload: { name?: string; email?: string; userId?: string }) {
if (isCI) {
return
}
Expand Down

0 comments on commit 529bfbb

Please sign in to comment.