Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
502 changes: 0 additions & 502 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions packages/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
"prebuild": "rm -rf lib",
"postbuild": "npx cpy \"src/**/*.yml\" \"lib/\"",
"build": "tsc",
"test:types": "tsd",
"test": "ava && tsd && vitest run",
"test:types": "vitest --typecheck",
"test": "ava && vitest --typecheck && vitest run",
"test:dev": "ava -w",
"test:ci": "run-p test:ci:*",
"test:ci:types": "tsd",
"test:ci:types": "vitest --typecheck",
"test:ci:ava": "c8 -r lcovonly -r text -r json ava",
"test:ci:vitest": "vitest run"
},
Expand Down Expand Up @@ -135,7 +135,6 @@
"process-exists": "^5.0.0",
"tinyspy": "^4.0.3",
"tmp-promise": "^3.0.2",
"tsd": "^0.32.0",
"vitest": "^3.0.0",
"yarn": "^1.22.22"
},
Expand Down
24 changes: 24 additions & 0 deletions packages/build/test-d/config/build.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { NetlifyConfig } from '@netlify/build'
import { expectTypeOf, test } from 'vitest'

test('netlify config build types', () => {
type Build = NetlifyConfig['build']
expectTypeOf<Build['command']>().toEqualTypeOf<string | undefined>()
expectTypeOf<Build['publish']>().toEqualTypeOf<string>()
expectTypeOf<Build['base']>().toEqualTypeOf<string>()
expectTypeOf<Build['services']['testVar']>().toEqualTypeOf<unknown>()
expectTypeOf<Build['ignore']>().toEqualTypeOf<string | undefined>()
expectTypeOf<Build['edge_handlers']>().toEqualTypeOf<string | undefined>()
expectTypeOf<Build['environment']['TEST_VAR']>().toEqualTypeOf<string | undefined>()
})

test('netlify config build processing types', () => {
type Processing = NetlifyConfig['build']['processing']
expectTypeOf<Processing['skip_processing']>().toEqualTypeOf<boolean | undefined>()
expectTypeOf<Processing['css']['bundle']>().toEqualTypeOf<boolean | undefined>()
expectTypeOf<Processing['css']['minify']>().toEqualTypeOf<boolean | undefined>()
expectTypeOf<Processing['js']['bundle']>().toEqualTypeOf<boolean | undefined>()
expectTypeOf<Processing['js']['minify']>().toEqualTypeOf<boolean | undefined>()
expectTypeOf<Processing['html']['pretty_url']>().toEqualTypeOf<boolean | undefined>()
expectTypeOf<Processing['images']['compress']>().toEqualTypeOf<boolean | undefined>()
})
26 changes: 0 additions & 26 deletions packages/build/test-d/config/build.ts

This file was deleted.

19 changes: 19 additions & 0 deletions packages/build/test-d/config/functions.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { NetlifyConfig } from '@netlify/build'
import { expectTypeOf, test } from 'vitest'

test('netlify config functions types', () => {
type Functions = NetlifyConfig['functions']['*']

expectTypeOf<Functions['node_bundler']>().toExtend<string | undefined>()
expectTypeOf<Functions['included_files']>().toEqualTypeOf<string[] | undefined>()

// available when node_bundler is 'esbuild'
type EsbuildFunctions = Functions & { node_bundler: 'esbuild' }
expectTypeOf<EsbuildFunctions['external_node_modules']>().toEqualTypeOf<string[] | undefined>()
expectTypeOf<EsbuildFunctions['ignored_node_modules']>().toEqualTypeOf<string[] | undefined>()

// NOT available when node_bundler is not 'esbuild'
type NonEsbuildFunctions = Functions & { node_bundler: 'webpack' }
expectTypeOf<NonEsbuildFunctions['external_node_modules']>().toBeNever()
expectTypeOf<NonEsbuildFunctions['ignored_node_modules']>().toBeNever()
})
19 changes: 0 additions & 19 deletions packages/build/test-d/config/functions.ts

This file was deleted.

28 changes: 28 additions & 0 deletions packages/build/test-d/config/inputs.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { OnPreBuild } from '@netlify/build'
import { expectTypeOf, test } from 'vitest'
import type { JSONValue } from '../../src/types/utils/json_value.js'

test('generic inputs types', () => {
type GenericInputs = Parameters<OnPreBuild>[0]['inputs']
expectTypeOf<GenericInputs['testVar']>().toExtend<JSONValue | undefined>()
})

test('specific inputs types', () => {
type SpecificInputs = Parameters<OnPreBuild<{ testVar: boolean }>>[0]['inputs']
expectTypeOf<SpecificInputs['testVar']>().toEqualTypeOf<boolean>()

// @ts-expect-error - non-existent property
expectTypeOf<SpecificInputs['otherTestVar']>().toBeNever()
})

test('specific inputs interface types', () => {
interface InputsInterface {
testVar: string
}

type InterfaceInputs = Parameters<OnPreBuild<InputsInterface>>[0]['inputs']
expectTypeOf<InterfaceInputs['testVar']>().toEqualTypeOf<string>()

// @ts-expect-error - non-existent property
expectTypeOf<InterfaceInputs['otherTestVar']>().toBeNever()
})
21 changes: 0 additions & 21 deletions packages/build/test-d/config/inputs.ts

This file was deleted.

42 changes: 42 additions & 0 deletions packages/build/test-d/config/netlify_config.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { NetlifyConfig } from '@netlify/build'
import { expectTypeOf, test } from 'vitest'
import type { JSONValue } from '../../src/types/utils/json_value.js'

test('netlify config plugins types', () => {
type Plugin = NetlifyConfig['plugins'][number]
expectTypeOf<Plugin['package']>().toEqualTypeOf<string>()
expectTypeOf<Plugin['inputs']['testVar']>().toEqualTypeOf<JSONValue | undefined>()
})

test('netlify config edge functions types', () => {
type EdgeFunction = NetlifyConfig['edge_functions'][number]
expectTypeOf<EdgeFunction['path']>().toExtend<string | undefined>()
expectTypeOf<EdgeFunction['function']>().toEqualTypeOf<string>()
})

test('netlify config headers types', () => {
type Header = NetlifyConfig['headers'][number]
expectTypeOf<Header['for']>().toEqualTypeOf<string>()
expectTypeOf<Header['values']['testVar']>().toEqualTypeOf<string | string[] | undefined>()
})

test('netlify config redirects types', () => {
type Redirect = NetlifyConfig['redirects'][number]
expectTypeOf<Redirect['from']>().toEqualTypeOf<string>()
expectTypeOf<Redirect['to']>().toEqualTypeOf<string | undefined>()
expectTypeOf<Redirect['status']>().toEqualTypeOf<number | undefined>()
expectTypeOf<Redirect['force']>().toEqualTypeOf<boolean | undefined>()
expectTypeOf<Redirect['signed']>().toEqualTypeOf<string | undefined>()

type QueryTestVar = NonNullable<Redirect['query']>['testVar']
expectTypeOf<QueryTestVar>().toEqualTypeOf<string | undefined>()

type HeadersTestVar = NonNullable<Redirect['headers']>['testVar']
expectTypeOf<HeadersTestVar>().toEqualTypeOf<string | undefined>()

type Conditions = NonNullable<Redirect['conditions']>
expectTypeOf<Conditions['Language']>().toEqualTypeOf<readonly string[] | undefined>()
expectTypeOf<Conditions['Cookie']>().toEqualTypeOf<readonly string[] | undefined>()
expectTypeOf<Conditions['Country']>().toEqualTypeOf<readonly string[] | undefined>()
expectTypeOf<Conditions['Role']>().toEqualTypeOf<readonly string[] | undefined>()
})
58 changes: 0 additions & 58 deletions packages/build/test-d/config/netlify_config.ts

This file was deleted.

24 changes: 24 additions & 0 deletions packages/build/test-d/netlify_plugin.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { NetlifyPlugin, OnPreBuild, OnBuild, OnPostBuild, OnError, OnSuccess, OnEnd } from '@netlify/build'
import { expectTypeOf, test } from 'vitest'

test('event types', () => {
const noop = function () {}

expectTypeOf(noop).toExtend<NetlifyPlugin['onPreBuild']>()
expectTypeOf(noop).toExtend<OnPreBuild>()
expectTypeOf(noop).toExtend<OnBuild>()
expectTypeOf(noop).toExtend<OnPostBuild>()
expectTypeOf(noop).toExtend<OnError>()
expectTypeOf(noop).toExtend<OnSuccess>()
expectTypeOf(noop).toExtend<OnEnd>()
})

test('onError event types', () => {
type ErrorParams = Parameters<OnError>[0]
expectTypeOf<ErrorParams['error']>().toEqualTypeOf<Error>()
})

test('onEnd event types', () => {
type EndParams = Parameters<OnEnd>[0]
expectTypeOf<EndParams['error']>().toEqualTypeOf<Error | undefined>()
})
22 changes: 0 additions & 22 deletions packages/build/test-d/netlify_plugin.ts

This file was deleted.

21 changes: 21 additions & 0 deletions packages/build/test-d/netlify_plugin_options.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { NetlifyPluginConstants, NetlifyPluginOptions } from '@netlify/build'
import { expectTypeOf, test } from 'vitest'
import type { JSONValue } from '../src/types/utils/json_value.js'

test('constants types', () => {
expectTypeOf<NetlifyPluginConstants['CONFIG_PATH']>().toEqualTypeOf<string | undefined>()
expectTypeOf<NetlifyPluginConstants['PUBLISH_DIR']>().toEqualTypeOf<string>()
expectTypeOf<NetlifyPluginConstants['FUNCTIONS_SRC']>().toEqualTypeOf<string | undefined>()
expectTypeOf<NetlifyPluginConstants['INTERNAL_EDGE_FUNCTIONS_SRC']>().toEqualTypeOf<string | undefined>()
expectTypeOf<NetlifyPluginConstants['INTERNAL_FUNCTIONS_SRC']>().toEqualTypeOf<string | undefined>()
expectTypeOf<NetlifyPluginConstants['FUNCTIONS_DIST']>().toEqualTypeOf<string>()
expectTypeOf<NetlifyPluginConstants['EDGE_FUNCTIONS_SRC']>().toEqualTypeOf<string | undefined>()
expectTypeOf<NetlifyPluginConstants['EDGE_FUNCTIONS_DIST']>().toEqualTypeOf<string>()
expectTypeOf<NetlifyPluginConstants['IS_LOCAL']>().toEqualTypeOf<boolean>()
expectTypeOf<NetlifyPluginConstants['NETLIFY_BUILD_VERSION']>().toEqualTypeOf<string>()
expectTypeOf<NetlifyPluginConstants['SITE_ID']>().toEqualTypeOf<string>()
})

test('package json types', () => {
expectTypeOf<NetlifyPluginOptions['packageJson']['version']>().toEqualTypeOf<JSONValue | undefined>()
})
21 changes: 0 additions & 21 deletions packages/build/test-d/netlify_plugin_options.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { NetlifyPluginUtils } from '@netlify/build'
import { expectTypeOf, test } from 'vitest'

test('utils build failBuild types', () => {
type BuildFailBuild = NetlifyPluginUtils['build']['failBuild']

expectTypeOf<BuildFailBuild>().toBeCallableWith('message')
expectTypeOf<BuildFailBuild>().toBeCallableWith('message', {})
expectTypeOf<BuildFailBuild>().toBeCallableWith('message', { error: new Error('message') })
})

test('utils build failPlugin types', () => {
type BuildFailPlugin = NetlifyPluginUtils['build']['failPlugin']

expectTypeOf<BuildFailPlugin>().toBeCallableWith('message')
expectTypeOf<BuildFailPlugin>().toBeCallableWith('message', {})
expectTypeOf<BuildFailPlugin>().toBeCallableWith('message', { error: new Error('message') })
})

test('utils build cancelBuild types', () => {
type BuildCancelBuild = NetlifyPluginUtils['build']['cancelBuild']

expectTypeOf<BuildCancelBuild>().toBeCallableWith('message')
expectTypeOf<BuildCancelBuild>().toBeCallableWith('message', {})
expectTypeOf<BuildCancelBuild>().toBeCallableWith('message', { error: new Error('message') })
})
Loading
Loading