Skip to content

Commit

Permalink
test: add file-based blob support to netlify dev (#6458)
Browse files Browse the repository at this point in the history
* refactor: add missing jsonwebtoken, node-fetch types
* refactor: convert dev command integration tests to TS
* test: add tests for `netlify dev` blob support
  • Loading branch information
ndhoule authored Apr 4, 2024
1 parent bb08e3f commit 5557ce1
Show file tree
Hide file tree
Showing 12 changed files with 248 additions and 57 deletions.
40 changes: 40 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@
"@sindresorhus/slugify": "2.2.1",
"@types/fs-extra": "11.0.4",
"@types/inquirer": "9.0.7",
"@types/jsonwebtoken": "^9.0.6",
"@types/node": "20.9.0",
"@types/node-fetch": "^2.6.11",
"@types/prettyjson": "0.0.33",
"@types/semver": "7.5.0",
"@types/uuid": "9.0.7",
Expand Down
1 change: 0 additions & 1 deletion src/commands/functions/functions-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import copyTemplateDirOriginal from 'copy-template-dir'
import { findUp } from 'find-up'
import fuzzy from 'fuzzy'
import inquirer from 'inquirer'
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message
import fetch from 'node-fetch'
import ora from 'ora'

Expand Down
1 change: 0 additions & 1 deletion src/commands/functions/functions-invoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import path from 'path'

import { OptionValues } from 'commander'
import inquirer from 'inquirer'
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message
import fetch from 'node-fetch'

import { NETLIFYDEVWARN, chalk, error, exit } from '../../utils/command-helpers.js'
Expand Down
6 changes: 0 additions & 6 deletions src/commands/integration/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { OptionValues } from 'commander'
import inquirer from 'inquirer'
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'js-y... Remove this comment to see the full error message
import yaml from 'js-yaml'
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message
import fetch from 'node-fetch'
import { z } from 'zod'

Expand Down Expand Up @@ -119,7 +118,6 @@ function verifyRequiredFieldsAreInConfig(name, description, scopes, integrationL
}

// @ts-expect-error TS(7006) FIXME: Parameter 'workingDir' implicitly has an 'any' typ... Remove this comment to see the full error message
// eslint-disable-next-line max-params
export async function registerIntegration(workingDir, siteId, accountId, localIntegrationConfig, token) {
const { description, integrationLevel, name, scopes, slug } = localIntegrationConfig
log(chalk.yellow(`An integration associated with the site ID ${siteId} is not registered.`))
Expand Down Expand Up @@ -165,7 +163,6 @@ export async function registerIntegration(workingDir, siteId, accountId, localIn
scopes: formatScopesForRemote(scopes),
integrationLevel,
}),
// @ts-expect-error TS(7006) FIXME: Parameter 'res' implicitly has an 'any' type.
}).then(async (res) => {
const response = await res.json()
return { body: response, statusCode: res.status }
Expand Down Expand Up @@ -194,7 +191,6 @@ export async function registerIntegration(workingDir, siteId, accountId, localIn
log(chalk.yellow('Your integration.yaml file has been updated. Please commit and push these changes.'))
}

// eslint-disable-next-line max-params
export async function updateIntegration(
// @ts-expect-error TS(7006) FIXME: Parameter 'workingDir' implicitly has an 'any' typ... Remove this comment to see the full error message
workingDir,
Expand Down Expand Up @@ -290,7 +286,6 @@ export async function updateIntegration(
integrationLevel,
}),
},
// @ts-expect-error TS(7006) FIXME: Parameter 'res' implicitly has an 'any' type.
).then(async (res) => {
const response = await res.json()
return { updateResponse: response, statusCode: res.status }
Expand Down Expand Up @@ -428,7 +423,6 @@ export const deploy = async (options: OptionValues, command: BaseCommand) => {
'netlify-token': token,
},
},
// @ts-expect-error TS(7006) FIXME: Parameter 'res' implicitly has an 'any' type.
).then(async (res) => {
const body = await res.json()
return { body, statusCode: res.status }
Expand Down
2 changes: 0 additions & 2 deletions src/lib/geo-location.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message
import fetch from 'node-fetch'

const API_URL = 'https://netlifind.netlify.app'
Expand All @@ -23,7 +22,6 @@ const REQUEST_TIMEOUT = 1e4
* @property {number} latitude
* @property {string} timezone
*/

export const mockLocation = {
city: 'San Francisco',
country: { code: 'US', name: 'United States' },
Expand Down
1 change: 0 additions & 1 deletion src/utils/live-tunnel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import process from 'process'

// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message
import fetch from 'node-fetch'
import pWaitFor from 'p-wait-for'
import { v4 as uuidv4 } from 'uuid'
Expand Down
1 change: 0 additions & 1 deletion src/utils/read-repo-url.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import url from 'url'

// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message
import fetch from 'node-fetch'

// supported repo host types
Expand Down
1 change: 0 additions & 1 deletion src/utils/sign-redirect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'json... Remove this comment to see the full error message
import jwt from 'jsonwebtoken'

// https://docs.netlify.com/routing/redirects/rewrites-proxies/#signed-proxy-redirects
Expand Down
1 change: 0 additions & 1 deletion src/utils/sites/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message
import fetch from 'node-fetch'

// @ts-expect-error TS(7006) FIXME: Parameter 'token' implicitly has an 'any' type.
Expand Down
1 change: 0 additions & 1 deletion src/utils/telemetry/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// to run a s a detached process
import process from 'process'

// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message
import fetch from 'node-fetch'

import getPackageJson from '../get-package-json.js'
Expand Down
Loading

1 comment on commit 5557ce1

@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,308
  • Package size: 294 MB
  • Number of ts-expect-error directives: 1,017

Please sign in to comment.