@netlify/build 18.15.0 → 18.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/types/config/build.d.ts +61 -0
- package/types/config/functions.d.ts +38 -0
- package/types/config/netlify_config.d.ts +51 -0
- package/types/index.d.ts +3 -0
- package/types/netlify_event.d.ts +5 -0
- package/types/netlify_plugin.d.ts +29 -0
- package/types/netlify_plugin_options.d.ts +56 -0
- package/types/options/index.d.ts +1 -0
- package/types/options/netlify_plugin_build_util.d.ts +7 -0
- package/types/options/netlify_plugin_cache_util.d.ts +39 -0
- package/types/options/netlify_plugin_git_util.d.ts +41 -0
- package/types/options/netlify_plugin_run_util.d.ts +24 -0
- package/types/options/netlify_plugin_status_util.d.ts +24 -0
- package/types/options/netlify_plugin_utils.d.ts +13 -0
- package/types/utils/json_value.d.ts +1 -0
- package/types/utils/many.d.ts +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "18.15.
|
|
3
|
+
"version": "18.15.1",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
5
|
"main": "src/core/main.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"src/**/*.js",
|
|
12
|
-
"src/**/*.yml"
|
|
12
|
+
"src/**/*.yml",
|
|
13
|
+
"types/**/*.d.ts"
|
|
13
14
|
],
|
|
14
15
|
"author": "Netlify Inc.",
|
|
15
16
|
"contributors": [
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { JSONValue } from '../utils/json_value'
|
|
2
|
+
|
|
3
|
+
interface NetlifyPlugin {
|
|
4
|
+
package: string
|
|
5
|
+
inputs: JSONValue
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/* eslint-disable camelcase -- some properties are named in snake case in this API */
|
|
9
|
+
|
|
10
|
+
export interface Build {
|
|
11
|
+
/**
|
|
12
|
+
* Includes a site's [build command](https://docs.netlify.com/configure-builds/get-started/#definitions)
|
|
13
|
+
*/
|
|
14
|
+
command?: string
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* the path to your static content folder
|
|
18
|
+
*/
|
|
19
|
+
publish: string
|
|
20
|
+
base: string
|
|
21
|
+
services: Record<string, unknown>
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Allows specifying a Bash command that will be run from the base directory to determine whether the site needs rebuilding or not.
|
|
25
|
+
* Check out our [ignore builds](https://docs.netlify.com/configure-builds/common-configurations/ignore-builds/) doc for more information on the default ignore behavior and details about constructing a custom ignore command.
|
|
26
|
+
*/
|
|
27
|
+
ignore?: string
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Includes the path to a site's [Edge Handlers directory](https://docs.netlify.com/edge-handlers/configure-and-build/#choose-an-edge-handlers-directory)
|
|
31
|
+
*/
|
|
32
|
+
edge_handlers?: string
|
|
33
|
+
/**
|
|
34
|
+
* Contains a site's [environment variables](https://docs.netlify.com/configure-builds/environment-variables/#netlify-configuration-variables)
|
|
35
|
+
*/
|
|
36
|
+
environment: Partial<Record<string, string>>
|
|
37
|
+
/**
|
|
38
|
+
* Includes options for [post processing](https://docs.netlify.com/configure-builds/file-based-configuration/#post-processing) HTML, CSS, JavaScript, and images
|
|
39
|
+
*/
|
|
40
|
+
processing: {
|
|
41
|
+
skip_processing?: boolean
|
|
42
|
+
css: {
|
|
43
|
+
bundle?: boolean
|
|
44
|
+
minify?: boolean
|
|
45
|
+
}
|
|
46
|
+
js: {
|
|
47
|
+
bundle?: boolean
|
|
48
|
+
minify?: boolean
|
|
49
|
+
}
|
|
50
|
+
html: {
|
|
51
|
+
pretty_url?: boolean
|
|
52
|
+
}
|
|
53
|
+
images: {
|
|
54
|
+
compress?: boolean
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
plugins: readonly NetlifyPlugin[]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* eslint-enable camelcase */
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
type GlobPattern = string
|
|
2
|
+
|
|
3
|
+
/* eslint-disable camelcase -- some properties are named in snake case in this API */
|
|
4
|
+
type FunctionsObject = {
|
|
5
|
+
/**
|
|
6
|
+
* string that includes the path to a site's [functions directory](https://docs.netlify.com/functions/configure-and-deploy/#configure-the-functions-folder)
|
|
7
|
+
*/
|
|
8
|
+
directory: string
|
|
9
|
+
} & (
|
|
10
|
+
| {
|
|
11
|
+
/**
|
|
12
|
+
* the function bundling method used in [`@netlify/zip-it-and-ship-it`](https://github.com/netlify/zip-it-and-ship-it).
|
|
13
|
+
*/
|
|
14
|
+
node_bundler: 'zisi'
|
|
15
|
+
}
|
|
16
|
+
| {
|
|
17
|
+
/**
|
|
18
|
+
* the function bundling method used in [`@netlify/zip-it-and-ship-it`](https://github.com/netlify/zip-it-and-ship-it).
|
|
19
|
+
*/
|
|
20
|
+
node_bundler: 'esbuild'
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* a list of Node.js modules that are copied to the bundled artifact without adjusting their source or references during the bundling process.
|
|
24
|
+
* This property helps handle dependencies that can’t be inlined, such as modules with native add-ons.
|
|
25
|
+
*/
|
|
26
|
+
external_node_modules: string[]
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* a list of additional paths to include in the function bundle. Although our build system includes statically referenced files (like `require("./some-file.js")`) by default, `included_files` lets you specify additional files or directories and reference them dynamically in function code. You can use `*` to match any character or prefix an entry with `!` to exclude files. Paths are relative to the [base directory](https://docs.netlify.com/configure-builds/get-started/#definitions-1).
|
|
30
|
+
*/
|
|
31
|
+
included_files: string[]
|
|
32
|
+
|
|
33
|
+
ignored_node_modules: string[]
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
/* eslint-enable camelcase */
|
|
37
|
+
|
|
38
|
+
export type Functions = Record<GlobPattern, FunctionsObject>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Many } from '../utils/many'
|
|
2
|
+
|
|
3
|
+
import { Build } from './build'
|
|
4
|
+
import { Functions } from './functions'
|
|
5
|
+
|
|
6
|
+
type HttpStatusCode = number
|
|
7
|
+
|
|
8
|
+
interface Redirect {
|
|
9
|
+
from: string
|
|
10
|
+
to: string
|
|
11
|
+
status?: HttpStatusCode
|
|
12
|
+
force: boolean
|
|
13
|
+
signed?: string
|
|
14
|
+
query: Partial<Record<string, string>>
|
|
15
|
+
headers: Partial<Record<string, string>>
|
|
16
|
+
conditions: Record<'language' | 'role' | 'country', readonly string[]>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface Header {
|
|
20
|
+
for: string
|
|
21
|
+
values: Partial<Record<string, Many<string, 'mutable'>>>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface EdgeHandler {
|
|
25
|
+
path?: `/${string}`
|
|
26
|
+
handler: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* eslint-disable camelcase -- some properties are named in snake case in this API */
|
|
30
|
+
|
|
31
|
+
interface NetlifyConfig {
|
|
32
|
+
/**
|
|
33
|
+
* array of redirects with their modifiable options
|
|
34
|
+
*/
|
|
35
|
+
redirects: Redirect[]
|
|
36
|
+
/**
|
|
37
|
+
* array of headers with their modifiable options
|
|
38
|
+
*/
|
|
39
|
+
headers: Header[]
|
|
40
|
+
/**
|
|
41
|
+
* array of Edge Handlers with their modifiable options
|
|
42
|
+
*/
|
|
43
|
+
edge_handlers: EdgeHandler[]
|
|
44
|
+
/**
|
|
45
|
+
* object with options for modifying [functions](https://docs.netlify.com/configure-builds/file-based-configuration/#functions)
|
|
46
|
+
*/
|
|
47
|
+
functions: Functions
|
|
48
|
+
build: Build
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* eslint-enable camelcase */
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { NetlifyEvent } from './netlify_event'
|
|
2
|
+
import { NetlifyPluginOptions } from './netlify_plugin_options'
|
|
3
|
+
|
|
4
|
+
export interface NetlifyPlugin {
|
|
5
|
+
/**
|
|
6
|
+
* Runs before the build command is executed.
|
|
7
|
+
*/
|
|
8
|
+
onPreBuild?: NetlifyEvent
|
|
9
|
+
/**
|
|
10
|
+
* runs directly after the build command is executed and before Functions? bundling and Edge Handlers bundling.
|
|
11
|
+
*/
|
|
12
|
+
onBuild?: NetlifyEvent
|
|
13
|
+
/**
|
|
14
|
+
* runs after the build command completes; after onBuild? tasks, Functions? bundling, and Edge Handlers bundling are executed; and before the deploy stage. Can be used to prevent a build from being deployed.
|
|
15
|
+
*/
|
|
16
|
+
onPostBuild?: NetlifyEvent
|
|
17
|
+
/**
|
|
18
|
+
* runs when an error occurs in the build or deploy stage, failing the build. Can’t be used to prevent a build from being deployed.
|
|
19
|
+
*/
|
|
20
|
+
onError?: NetlifyEvent<NetlifyPluginOptions & { error: Error }>
|
|
21
|
+
/**
|
|
22
|
+
* runs when the deploy succeeds. Can’t be used to prevent a build from being deployed.
|
|
23
|
+
*/
|
|
24
|
+
onSuccess?: NetlifyEvent
|
|
25
|
+
/**
|
|
26
|
+
* runs after completion of the deploy stage, regardless of build error or success; is useful for resources cleanup. Can’t be used to prevent a build from being deployed.
|
|
27
|
+
*/
|
|
28
|
+
onEnd?: NetlifyEvent<NetlifyPluginOptions & { error?: Error }>
|
|
29
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { NetlifyConfig } from './config/netlify_config'
|
|
2
|
+
import { NetlifyPluginUtils } from './options/netlify_plugin_utils'
|
|
3
|
+
|
|
4
|
+
export interface NetlifyPluginOptions {
|
|
5
|
+
constants: {
|
|
6
|
+
/**
|
|
7
|
+
* path to the Netlify configuration file.
|
|
8
|
+
* `undefined` if none was used.
|
|
9
|
+
*/
|
|
10
|
+
CONFIG_PATH?: string
|
|
11
|
+
/**
|
|
12
|
+
* directory that contains the deploy-ready HTML files and assets generated by the build. Its value is always defined, but the target might not have been created yet.
|
|
13
|
+
*/
|
|
14
|
+
PUBLISH_DIR: string
|
|
15
|
+
/**
|
|
16
|
+
* the directory where function source code lives.
|
|
17
|
+
* `undefined` if no `netlify/functions` directory exists in the base directory and if not specified by the user.
|
|
18
|
+
*/
|
|
19
|
+
FUNCTIONS_SRC?: string
|
|
20
|
+
/**
|
|
21
|
+
* the directory where built serverless functions are placed before deployment. Its value is always defined, but the target might not have been created yet.
|
|
22
|
+
*/
|
|
23
|
+
FUNCTIONS_DIST: string
|
|
24
|
+
/**
|
|
25
|
+
* the directory where Edge Handlers source code lives.
|
|
26
|
+
* `undefined` if no `netlify/edge-handlers` directory exists in the base directory and if not specified in `netlify.toml`.
|
|
27
|
+
*/
|
|
28
|
+
EDGE_HANDLERS_SRC?: string
|
|
29
|
+
/**
|
|
30
|
+
* boolean indicating whether the build was [run locally](https://docs.netlify.com/cli/get-started/#run-builds-locally) or on Netlify
|
|
31
|
+
*/
|
|
32
|
+
IS_LOCAL: boolean
|
|
33
|
+
/**
|
|
34
|
+
* version of Netlify Build as a `major.minor.patch` string
|
|
35
|
+
*/
|
|
36
|
+
NETLIFY_BUILD_VERSION: string
|
|
37
|
+
/**
|
|
38
|
+
* the Netlify site ID
|
|
39
|
+
*/
|
|
40
|
+
SITE_ID: string
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* If your plugin requires additional values from the user, you can specify these requirements in an `inputs` array in the plugin’s [`manifest.yml` file](https://docs.netlify.com/configure-builds/build-plugins/create-plugins/#anatomy-of-a-plugin).
|
|
44
|
+
*/
|
|
45
|
+
inputs: Partial<Record<string, string>>
|
|
46
|
+
/**
|
|
47
|
+
* @see https://docs.netlify.com/configure-builds/build-plugins/create-plugins/#netlifyconfig
|
|
48
|
+
*/
|
|
49
|
+
netlifyConfig: NetlifyConfig
|
|
50
|
+
/**
|
|
51
|
+
* When an event handler executes, the contents of the `package.json` in a site's base directory get passed to a plugin.
|
|
52
|
+
* The data fields are normalized to prevent plugin errors. If the site has no `package.json`, the argument is an empty object.
|
|
53
|
+
*/
|
|
54
|
+
packageJson: Partial<Record<string, string>>
|
|
55
|
+
utils: NetlifyPluginUtils
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './netlify_plugin_utils'
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Many } from '../utils/many'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cache files between builds
|
|
5
|
+
*/
|
|
6
|
+
export type NetlifyPluginCacheUtil = {
|
|
7
|
+
save(
|
|
8
|
+
path: Many<string>,
|
|
9
|
+
options?: {
|
|
10
|
+
ttl?: number
|
|
11
|
+
digests?: string[]
|
|
12
|
+
/**
|
|
13
|
+
* @default `process.cwd()`
|
|
14
|
+
*/
|
|
15
|
+
cwd?: string
|
|
16
|
+
},
|
|
17
|
+
): Promise<boolean>
|
|
18
|
+
list(options: {
|
|
19
|
+
/**
|
|
20
|
+
* @default `process.cwd()`
|
|
21
|
+
*/
|
|
22
|
+
cwd?: string
|
|
23
|
+
/**
|
|
24
|
+
* @default 1
|
|
25
|
+
*/
|
|
26
|
+
depth?: number
|
|
27
|
+
}): Promise<string[]>
|
|
28
|
+
} & Record<
|
|
29
|
+
'restore' | 'remove' | 'has',
|
|
30
|
+
(
|
|
31
|
+
path: Many<string>,
|
|
32
|
+
options?: {
|
|
33
|
+
/**
|
|
34
|
+
* @default `process.cwd()`
|
|
35
|
+
*/
|
|
36
|
+
cwd?: string
|
|
37
|
+
},
|
|
38
|
+
) => Promise<boolean>
|
|
39
|
+
>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieve Git-related information such as the list of modified/created/deleted files
|
|
3
|
+
* @see https://github.com/netlify/build/blob/master/packages/git-utils/README.md
|
|
4
|
+
*/
|
|
5
|
+
export interface NetlifyPluginGitUtil {
|
|
6
|
+
fileMatch(globPattern: string): readonly string[]
|
|
7
|
+
/**
|
|
8
|
+
* Array of all modified files.
|
|
9
|
+
*/
|
|
10
|
+
modifiedFiles: readonly string[]
|
|
11
|
+
/**
|
|
12
|
+
* Array of all created files.
|
|
13
|
+
*/
|
|
14
|
+
createdFiles: readonly string[]
|
|
15
|
+
/**
|
|
16
|
+
* Array of all deleted files.
|
|
17
|
+
*/
|
|
18
|
+
deletedFiles: readonly string[]
|
|
19
|
+
/**
|
|
20
|
+
* Array of commits with details.
|
|
21
|
+
*/
|
|
22
|
+
commits: ReadonlyArray<{
|
|
23
|
+
sha: string
|
|
24
|
+
parents: string
|
|
25
|
+
author: {
|
|
26
|
+
name: string
|
|
27
|
+
email: string
|
|
28
|
+
date: string
|
|
29
|
+
}
|
|
30
|
+
committer: {
|
|
31
|
+
name: string
|
|
32
|
+
email: string
|
|
33
|
+
date: string
|
|
34
|
+
}
|
|
35
|
+
message: string
|
|
36
|
+
}>
|
|
37
|
+
/**
|
|
38
|
+
* How many lines of code have changed
|
|
39
|
+
*/
|
|
40
|
+
linesOfCode(): Promise<number>
|
|
41
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Options as ExecaOptions, ExecaChildProcess } from 'execa'
|
|
2
|
+
|
|
3
|
+
type NetlifyPluginRunUtilOptions = Omit<ExecaOptions, 'preferLocal'> & {
|
|
4
|
+
/**
|
|
5
|
+
* @default true
|
|
6
|
+
*/
|
|
7
|
+
preferLocal?: ExecaOptions['preferLocal']
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type NetlifyPluginRunUtilResult = ExecaChildProcess
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Run commands and processes
|
|
14
|
+
* @see https://github.com/netlify/build/blob/master/packages/run-utils/README.md
|
|
15
|
+
*/
|
|
16
|
+
export interface NetlifyPluginRunUtil {
|
|
17
|
+
(
|
|
18
|
+
file: string,
|
|
19
|
+
// eslint-disable-next-line fp/no-arguments -- params are named `arguments` in the docs. Unrelated to JS's `arguments`
|
|
20
|
+
arguments?: readonly string[],
|
|
21
|
+
options?: NetlifyPluginRunUtilOptions,
|
|
22
|
+
): Promise<NetlifyPluginRunUtilResult>
|
|
23
|
+
command(command: string, options?: NetlifyPluginRunUtilOptions): Promise<NetlifyPluginRunUtilResult>
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display information in the deploy summary
|
|
3
|
+
*/
|
|
4
|
+
export interface NetlifyPluginStatusUtil {
|
|
5
|
+
/**
|
|
6
|
+
* Only one status is shown per plugin.
|
|
7
|
+
* Calling `utils.status.show()` twice overrides the previous status.
|
|
8
|
+
*/
|
|
9
|
+
show(options: {
|
|
10
|
+
/**
|
|
11
|
+
* Default to the plugin's name followed by a generic title.
|
|
12
|
+
*/
|
|
13
|
+
title?: string
|
|
14
|
+
/**
|
|
15
|
+
* Message below the title
|
|
16
|
+
*/
|
|
17
|
+
summary: string
|
|
18
|
+
/**
|
|
19
|
+
* Detailed information shown in a collapsible section.
|
|
20
|
+
* @default ""
|
|
21
|
+
*/
|
|
22
|
+
text?: string
|
|
23
|
+
}): void
|
|
24
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NetlifyPluginBuildUtil } from './netlify_plugin_build_util'
|
|
2
|
+
import { NetlifyPluginCacheUtil } from './netlify_plugin_cache_util'
|
|
3
|
+
import { NetlifyPluginGitUtil } from './netlify_plugin_git_util'
|
|
4
|
+
import { NetlifyPluginRunUtil } from './netlify_plugin_run_util'
|
|
5
|
+
import { NetlifyPluginStatusUtil } from './netlify_plugin_status_util'
|
|
6
|
+
|
|
7
|
+
export interface NetlifyPluginUtils {
|
|
8
|
+
build: NetlifyPluginBuildUtil
|
|
9
|
+
status: NetlifyPluginStatusUtil
|
|
10
|
+
cache: NetlifyPluginCacheUtil
|
|
11
|
+
run: NetlifyPluginRunUtil
|
|
12
|
+
git: NetlifyPluginGitUtil
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type JSONValue = string | number | boolean | null | { [key: string]: JSONValue } | Array<JSONValue>
|