@netlify/build 0.5.0 → 1.0.0-dl-test
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/bin.js +5 -0
- package/lib/core/bin.js +66 -0
- package/lib/core/build.js +392 -0
- package/lib/core/config.js +124 -0
- package/lib/core/constants.js +116 -0
- package/lib/core/dev.js +27 -0
- package/lib/core/dry.js +21 -0
- package/lib/core/feature_flags.js +17 -0
- package/lib/core/flags.js +206 -0
- package/lib/core/lingering.js +68 -0
- package/lib/core/main.js +114 -0
- package/lib/core/missing_side_file.js +17 -0
- package/lib/core/normalize_flags.js +62 -0
- package/lib/core/report_metrics.js +17 -0
- package/lib/core/severity.js +21 -0
- package/lib/core/types.js +8 -0
- package/lib/core/user_node_version.js +32 -0
- package/lib/env/changes.js +43 -0
- package/lib/env/main.js +14 -0
- package/lib/env/metadata.js +68 -0
- package/lib/error/api.js +37 -0
- package/lib/error/build.js +36 -0
- package/lib/error/cancel.js +7 -0
- package/lib/error/colors.js +9 -0
- package/lib/error/handle.js +44 -0
- package/lib/error/info.js +37 -0
- package/lib/error/monitor/location.js +16 -0
- package/lib/error/monitor/normalize.js +86 -0
- package/lib/error/monitor/print.js +20 -0
- package/lib/error/monitor/report.js +120 -0
- package/lib/error/monitor/start.js +61 -0
- package/lib/error/parse/clean_stack.js +70 -0
- package/lib/error/parse/location.js +50 -0
- package/lib/error/parse/normalize.js +24 -0
- package/lib/error/parse/parse.js +67 -0
- package/lib/error/parse/plugin.js +55 -0
- package/lib/error/parse/properties.js +16 -0
- package/lib/error/parse/serialize_log.js +34 -0
- package/lib/error/parse/serialize_status.js +18 -0
- package/lib/error/parse/stack.js +34 -0
- package/lib/error/report.js +29 -0
- package/lib/error/type.js +177 -0
- package/lib/install/functions.js +20 -0
- package/lib/install/local.js +45 -0
- package/lib/install/main.js +67 -0
- package/lib/install/missing.js +54 -0
- package/lib/log/colors.js +28 -0
- package/lib/log/description.js +21 -0
- package/lib/log/header.js +12 -0
- package/lib/log/header_func.js +13 -0
- package/lib/log/logger.js +140 -0
- package/lib/log/messages/compatibility.js +120 -0
- package/lib/log/messages/config.js +91 -0
- package/lib/log/messages/core.js +49 -0
- package/lib/log/messages/core_steps.js +75 -0
- package/lib/log/messages/dry.js +41 -0
- package/lib/log/messages/install.js +25 -0
- package/lib/log/messages/ipc.js +29 -0
- package/lib/log/messages/mutations.js +62 -0
- package/lib/log/messages/plugins.js +25 -0
- package/lib/log/messages/status.js +14 -0
- package/lib/log/messages/steps.js +18 -0
- package/lib/log/serialize.js +10 -0
- package/lib/log/stream.js +68 -0
- package/lib/log/theme.js +27 -0
- package/lib/plugins/child/diff.js +46 -0
- package/lib/plugins/child/error.js +26 -0
- package/lib/plugins/child/lazy.js +15 -0
- package/lib/plugins/child/load.js +22 -0
- package/lib/plugins/child/logic.js +57 -0
- package/lib/plugins/child/main.js +37 -0
- package/lib/plugins/child/run.js +19 -0
- package/lib/plugins/child/status.js +63 -0
- package/lib/plugins/child/typescript.js +28 -0
- package/lib/plugins/child/utils.js +42 -0
- package/lib/plugins/child/validate.js +31 -0
- package/lib/plugins/compatibility.js +104 -0
- package/lib/plugins/error.js +46 -0
- package/lib/plugins/events.js +12 -0
- package/lib/plugins/expected_version.js +81 -0
- package/lib/plugins/internal.js +10 -0
- package/lib/plugins/ipc.js +120 -0
- package/lib/plugins/list.js +73 -0
- package/lib/plugins/load.js +50 -0
- package/lib/plugins/manifest/check.js +85 -0
- package/lib/plugins/manifest/load.js +38 -0
- package/lib/plugins/manifest/main.js +19 -0
- package/lib/plugins/manifest/path.js +24 -0
- package/lib/plugins/manifest/validate.js +91 -0
- package/lib/plugins/node_version.js +35 -0
- package/lib/plugins/options.js +70 -0
- package/lib/plugins/pinned_version.js +83 -0
- package/lib/plugins/resolve.js +110 -0
- package/lib/plugins/spawn.js +55 -0
- package/lib/plugins_core/add.js +35 -0
- package/lib/plugins_core/build_command.js +50 -0
- package/lib/plugins_core/deploy/buildbot_client.js +87 -0
- package/lib/plugins_core/deploy/index.js +49 -0
- package/lib/plugins_core/deploy/manifest.yml +1 -0
- package/lib/plugins_core/edge_functions/index.js +106 -0
- package/lib/plugins_core/edge_functions/lib/error.js +17 -0
- package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +14 -0
- package/lib/plugins_core/functions/error.js +123 -0
- package/lib/plugins_core/functions/feature_flags.js +5 -0
- package/lib/plugins_core/functions/index.js +137 -0
- package/lib/plugins_core/functions/utils.js +45 -0
- package/lib/plugins_core/functions/zisi.js +64 -0
- package/lib/plugins_core/functions_install/index.js +10 -0
- package/lib/plugins_core/list.js +20 -0
- package/lib/plugins_core/save_artifacts/index.js +33 -0
- package/lib/report/statsd.js +56 -0
- package/lib/status/add.js +30 -0
- package/lib/status/colors.js +18 -0
- package/lib/status/load_error.js +10 -0
- package/lib/status/report.js +83 -0
- package/lib/status/success.js +14 -0
- package/lib/steps/core_step.js +62 -0
- package/lib/steps/error.js +65 -0
- package/lib/steps/get.js +44 -0
- package/lib/steps/plugin.js +55 -0
- package/lib/steps/return.js +27 -0
- package/lib/steps/run_core_steps.js +117 -0
- package/lib/steps/run_step.js +200 -0
- package/lib/steps/run_steps.js +102 -0
- package/lib/steps/update_config.js +66 -0
- package/lib/telemetry/main.js +94 -0
- package/lib/time/aggregate.js +109 -0
- package/lib/time/main.js +31 -0
- package/lib/time/measure.js +16 -0
- package/lib/time/report.js +30 -0
- package/lib/utils/errors.js +13 -0
- package/lib/utils/json.js +10 -0
- package/lib/utils/omit.js +3 -0
- package/lib/utils/package.js +24 -0
- package/lib/utils/remove_falsy.js +8 -0
- package/lib/utils/resolve.js +41 -0
- package/lib/utils/runtime.js +5 -0
- package/lib/utils/semver.js +28 -0
- package/package.json +119 -56
- package/types/config/build.d.ts +52 -0
- package/types/config/functions.d.ts +36 -0
- package/types/config/inputs.d.ts +7 -0
- package/types/config/netlify_config.d.ts +58 -0
- package/types/index.d.ts +7 -0
- package/types/netlify_event_handler.d.ts +29 -0
- package/types/netlify_plugin.d.ts +29 -0
- package/types/netlify_plugin_constants.d.ts +51 -0
- package/types/netlify_plugin_options.d.ts +23 -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_functions_util.d.ts +32 -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 +15 -0
- package/types/utils/json_value.d.ts +1 -0
- package/types/utils/many.d.ts +6 -0
- package/README.md +0 -3
- package/src/core/bin.js +0 -139
- package/src/core/commands.js +0 -304
- package/src/core/config.js +0 -130
- package/src/core/constants.js +0 -86
- package/src/core/dry.js +0 -23
- package/src/core/main.js +0 -196
- package/src/env/changes.js +0 -49
- package/src/env/git.js +0 -27
- package/src/env/main.js +0 -97
- package/src/env/metadata.js +0 -81
- package/src/error/api.js +0 -32
- package/src/error/build.js +0 -32
- package/src/error/cancel.js +0 -22
- package/src/error/colors.js +0 -13
- package/src/error/info.js +0 -12
- package/src/error/monitor/normalize.js +0 -50
- package/src/error/monitor/print.js +0 -43
- package/src/error/monitor/report.js +0 -140
- package/src/error/monitor/start.js +0 -50
- package/src/error/parse/clean_stack.js +0 -86
- package/src/error/parse/location.js +0 -50
- package/src/error/parse/parse.js +0 -87
- package/src/error/parse/plugin.js +0 -68
- package/src/error/parse/properties.js +0 -20
- package/src/error/parse/serialize_log.js +0 -46
- package/src/error/parse/serialize_status.js +0 -28
- package/src/error/parse/stack.js +0 -45
- package/src/error/process.js +0 -13
- package/src/error/type.js +0 -143
- package/src/install/functions.js +0 -62
- package/src/install/local.js +0 -74
- package/src/install/main.js +0 -103
- package/src/install/missing.js +0 -86
- package/src/log/colors.js +0 -59
- package/src/log/description.js +0 -38
- package/src/log/header.js +0 -19
- package/src/log/logger.js +0 -55
- package/src/log/main.js +0 -290
- package/src/log/old_version.js +0 -45
- package/src/log/serialize.js +0 -15
- package/src/log/stream.js +0 -15
- package/src/log/theme.js +0 -32
- package/src/log/timer.js +0 -28
- package/src/plugins/child/api.js +0 -59
- package/src/plugins/child/error.js +0 -39
- package/src/plugins/child/load.js +0 -37
- package/src/plugins/child/logic.js +0 -31
- package/src/plugins/child/main.js +0 -48
- package/src/plugins/child/run.js +0 -30
- package/src/plugins/child/status.js +0 -53
- package/src/plugins/child/utils.js +0 -43
- package/src/plugins/child/validate.js +0 -71
- package/src/plugins/error.js +0 -73
- package/src/plugins/events.js +0 -77
- package/src/plugins/ipc.js +0 -136
- package/src/plugins/load.js +0 -66
- package/src/plugins/manifest/check.js +0 -80
- package/src/plugins/manifest/load.js +0 -54
- package/src/plugins/manifest/main.js +0 -24
- package/src/plugins/manifest/path.js +0 -12
- package/src/plugins/manifest/validate.js +0 -136
- package/src/plugins/node_version.js +0 -74
- package/src/plugins/options.js +0 -78
- package/src/plugins/package.js +0 -17
- package/src/plugins/resolve.js +0 -159
- package/src/plugins/spawn.js +0 -82
- package/src/plugins_core/cache/manifest.yml +0 -1
- package/src/plugins_core/cache/plugin.js +0 -75
- package/src/plugins_core/functions/manifest.yml +0 -1
- package/src/plugins_core/functions/plugin.js +0 -37
- package/src/plugins_core/functions_install/plugin.js +0 -14
- package/src/plugins_core/main.js +0 -38
- package/src/status/add.js +0 -56
- package/src/status/colors.js +0 -25
- package/src/status/report.js +0 -57
- package/src/telemetry/complete.js +0 -49
- package/src/telemetry/request.js +0 -28
- package/src/telemetry/track.js +0 -33
- package/src/utils/omit.js +0 -8
- package/src/utils/polyfills.js +0 -3
- package/src/utils/remove_falsy.js +0 -12
- package/src/utils/resolve.js +0 -39
- /package/{src → lib}/plugins_core/functions_install/manifest.yml +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PluginInputs } from './config/inputs'
|
|
2
|
+
import { OnBuild, OnEnd, OnError, OnPostBuild, OnPreBuild, OnSuccess } from './netlify_event_handler'
|
|
3
|
+
|
|
4
|
+
export interface NetlifyPlugin<TInputs extends PluginInputs = PluginInputs> {
|
|
5
|
+
/**
|
|
6
|
+
* Runs before the build command is executed.
|
|
7
|
+
*/
|
|
8
|
+
onPreBuild?: OnPreBuild<TInputs>
|
|
9
|
+
/**
|
|
10
|
+
* runs directly after the build command is executed and before Functions? bundling and Edge Handlers bundling.
|
|
11
|
+
*/
|
|
12
|
+
onBuild?: OnBuild<TInputs>
|
|
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?: OnPostBuild<TInputs>
|
|
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?: OnError<TInputs>
|
|
21
|
+
/**
|
|
22
|
+
* runs when the deploy succeeds. Can’t be used to prevent a build from being deployed.
|
|
23
|
+
*/
|
|
24
|
+
onSuccess?: OnSuccess<TInputs>
|
|
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?: OnEnd<TInputs>
|
|
29
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface NetlifyPluginConstants {
|
|
2
|
+
/**
|
|
3
|
+
* path to the Netlify configuration file.
|
|
4
|
+
* `undefined` if none was used.
|
|
5
|
+
*/
|
|
6
|
+
CONFIG_PATH?: string
|
|
7
|
+
/**
|
|
8
|
+
* 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.
|
|
9
|
+
*/
|
|
10
|
+
PUBLISH_DIR: string
|
|
11
|
+
/**
|
|
12
|
+
* the directory where function source code lives.
|
|
13
|
+
* `undefined` if no `netlify/functions` directory exists in the base directory and if not specified by the user.
|
|
14
|
+
*/
|
|
15
|
+
FUNCTIONS_SRC?: string
|
|
16
|
+
/**
|
|
17
|
+
* the directory where internal Edge Functions source code lives. This is where build plugins should place auto-generated functions.
|
|
18
|
+
* `undefined` if the version of @netlify/build does not support internal Edge Functions
|
|
19
|
+
*/
|
|
20
|
+
INTERNAL_EDGE_FUNCTIONS_SRC?: string
|
|
21
|
+
/**
|
|
22
|
+
* the directory where internal function source code lives. This is where build plugins should place auto-generated functions.
|
|
23
|
+
* `undefined` if the version of @netlify/build does not support internal functions
|
|
24
|
+
*/
|
|
25
|
+
INTERNAL_FUNCTIONS_SRC?: string
|
|
26
|
+
/**
|
|
27
|
+
* the directory where built serverless functions are placed before deployment. Its value is always defined, but the target might not have been created yet.
|
|
28
|
+
*/
|
|
29
|
+
FUNCTIONS_DIST: string
|
|
30
|
+
/**
|
|
31
|
+
* the directory where built Edge Functions are placed before deployment. Its value is always defined, but the target might not have been created yet.
|
|
32
|
+
*/
|
|
33
|
+
EDGE_FUNCTIONS_DIST: string
|
|
34
|
+
/**
|
|
35
|
+
* the directory where Edge Functions source code lives.
|
|
36
|
+
* `undefined` if no `netlify/edge-functions` directory exists.
|
|
37
|
+
*/
|
|
38
|
+
EDGE_FUNCTIONS_SRC?: string
|
|
39
|
+
/**
|
|
40
|
+
* boolean indicating whether the build was [run locally](https://docs.netlify.com/cli/get-started/#run-builds-locally) or on Netlify
|
|
41
|
+
*/
|
|
42
|
+
IS_LOCAL: boolean
|
|
43
|
+
/**
|
|
44
|
+
* version of Netlify Build as a `major.minor.patch` string
|
|
45
|
+
*/
|
|
46
|
+
NETLIFY_BUILD_VERSION: string
|
|
47
|
+
/**
|
|
48
|
+
* the Netlify site ID
|
|
49
|
+
*/
|
|
50
|
+
SITE_ID: string
|
|
51
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PluginInputs, StringKeys } from './config/inputs'
|
|
2
|
+
import { NetlifyConfig } from './config/netlify_config'
|
|
3
|
+
import { NetlifyPluginConstants } from './netlify_plugin_constants'
|
|
4
|
+
import { NetlifyPluginUtils } from './options/netlify_plugin_utils'
|
|
5
|
+
import { JSONValue } from './utils/json_value'
|
|
6
|
+
|
|
7
|
+
export interface NetlifyPluginOptions<TInputs extends PluginInputs<StringKeys<TInputs>> = PluginInputs> {
|
|
8
|
+
/**
|
|
9
|
+
* 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).
|
|
10
|
+
*/
|
|
11
|
+
inputs: TInputs
|
|
12
|
+
/**
|
|
13
|
+
* @see https://docs.netlify.com/configure-builds/build-plugins/create-plugins/#netlifyconfig
|
|
14
|
+
*/
|
|
15
|
+
netlifyConfig: NetlifyConfig
|
|
16
|
+
/**
|
|
17
|
+
* When an event handler executes, the contents of the `package.json` in a site's base directory get passed to a plugin.
|
|
18
|
+
* The data fields are normalized to prevent plugin errors. If the site has no `package.json`, the argument is an empty object.
|
|
19
|
+
*/
|
|
20
|
+
packageJson: Partial<Record<string, JSONValue>>
|
|
21
|
+
constants: NetlifyPluginConstants
|
|
22
|
+
utils: NetlifyPluginUtils
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NetlifyPluginUtils } 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,32 @@
|
|
|
1
|
+
import type { listFunctions, listFunctionsFiles } from '@netlify/zip-it-and-ship-it'
|
|
2
|
+
|
|
3
|
+
type Resolved<T> = T extends Promise<infer U> ? U : T
|
|
4
|
+
|
|
5
|
+
export type ListedFunction = Resolved<ReturnType<typeof listFunctions>>[0]
|
|
6
|
+
export type ListedFunctionFile = Resolved<ReturnType<typeof listFunctionsFiles>>[0]
|
|
7
|
+
|
|
8
|
+
export interface NetlifyPluginFunctionsUtil {
|
|
9
|
+
/**
|
|
10
|
+
* Returns the list of Netlify Functions main files as a Promise resolving to an array of objects with the following properties:
|
|
11
|
+
*
|
|
12
|
+
* - `name`: Function name, as used in the URL `https://{hostname}/.netlify/functions/{name}`
|
|
13
|
+
* - `mainFile`: absolute path to the Function's main file
|
|
14
|
+
* - `extension`: file extension of the Function's main file. For Go Functions, this might be an empty string. For Node.js Functions, this is either `.js` or `.zip`.
|
|
15
|
+
* - `runtime` `"js" | "go"`: Function's language runtime. TypeScript Functions use the "js" runtime
|
|
16
|
+
*/
|
|
17
|
+
list(): Promise<Array<ListedFunction>>
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Same as `list()` except it also returns the files required by the Functions' main files. This is much slower. The object have the following additional member:
|
|
21
|
+
*
|
|
22
|
+
* - `srcFile`: absolute path to the file
|
|
23
|
+
*/
|
|
24
|
+
listAll(): Promise<Array<ListedFunctionFile>>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Add a Functions file or directory to a build.
|
|
28
|
+
*
|
|
29
|
+
* @param path Path to the function file or directory.
|
|
30
|
+
*/
|
|
31
|
+
add(path: string): Promise<void>
|
|
32
|
+
}
|
|
@@ -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,15 @@
|
|
|
1
|
+
import { NetlifyPluginBuildUtil } from './netlify_plugin_build_util'
|
|
2
|
+
import { NetlifyPluginCacheUtil } from './netlify_plugin_cache_util'
|
|
3
|
+
import { NetlifyPluginFunctionsUtil } from './netlify_plugin_functions_util'
|
|
4
|
+
import { NetlifyPluginGitUtil } from './netlify_plugin_git_util'
|
|
5
|
+
import { NetlifyPluginRunUtil } from './netlify_plugin_run_util'
|
|
6
|
+
import { NetlifyPluginStatusUtil } from './netlify_plugin_status_util'
|
|
7
|
+
|
|
8
|
+
export interface NetlifyPluginUtils {
|
|
9
|
+
build: NetlifyPluginBuildUtil
|
|
10
|
+
status: NetlifyPluginStatusUtil
|
|
11
|
+
cache: NetlifyPluginCacheUtil
|
|
12
|
+
run: NetlifyPluginRunUtil
|
|
13
|
+
git: NetlifyPluginGitUtil
|
|
14
|
+
functions: NetlifyPluginFunctionsUtil
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type JSONValue = string | number | boolean | null | { [key: string]: JSONValue } | Array<JSONValue>
|
package/README.md
DELETED
package/src/core/bin.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const { exit } = require('process')
|
|
3
|
-
|
|
4
|
-
const filterObj = require('filter-obj')
|
|
5
|
-
const yargs = require('yargs')
|
|
6
|
-
|
|
7
|
-
require('../utils/polyfills')
|
|
8
|
-
|
|
9
|
-
const build = require('./main')
|
|
10
|
-
|
|
11
|
-
// CLI entry point
|
|
12
|
-
const runCli = async function() {
|
|
13
|
-
const flags = parseFlags()
|
|
14
|
-
const { features, ...flagsA } = filterObj(flags, isUserFlag)
|
|
15
|
-
|
|
16
|
-
if (features) {
|
|
17
|
-
return printFeatures()
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const success = await build(flagsA)
|
|
21
|
-
const exitCode = success ? 0 : 1
|
|
22
|
-
exit(exitCode)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const parseFlags = function() {
|
|
26
|
-
return yargs
|
|
27
|
-
.options(FLAGS)
|
|
28
|
-
.usage(USAGE)
|
|
29
|
-
.parse()
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const FLAGS = {
|
|
33
|
-
config: {
|
|
34
|
-
string: true,
|
|
35
|
-
describe: `Path to the configuration file.
|
|
36
|
-
Defaults to any netlify.toml in the git repository root directory or the base directory`,
|
|
37
|
-
},
|
|
38
|
-
defaultConfig: {
|
|
39
|
-
string: true,
|
|
40
|
-
describe: `JSON configuration object containing default values.
|
|
41
|
-
Each configuration default value is used unless overriden through the main configuration file.
|
|
42
|
-
Default: none.`,
|
|
43
|
-
hidden: true,
|
|
44
|
-
},
|
|
45
|
-
cachedConfig: {
|
|
46
|
-
string: true,
|
|
47
|
-
describe: `JSON configuration object returned by @netlify/config.
|
|
48
|
-
This is done as a performance optimization to cache the configuration loading logic.
|
|
49
|
-
Default: none.`,
|
|
50
|
-
hidden: true,
|
|
51
|
-
},
|
|
52
|
-
cwd: {
|
|
53
|
-
string: true,
|
|
54
|
-
describe: `Current directory. Used to retrieve the configuration file.
|
|
55
|
-
Default: current directory`,
|
|
56
|
-
},
|
|
57
|
-
repositoryRoot: {
|
|
58
|
-
string: true,
|
|
59
|
-
describe: `Git repository root directory. Used to retrieve the configuration file.
|
|
60
|
-
Default: automatically guessed`,
|
|
61
|
-
},
|
|
62
|
-
token: {
|
|
63
|
-
string: true,
|
|
64
|
-
describe: `Netlify API token for authentication.
|
|
65
|
-
The NETLIFY_AUTH_TOKEN environment variable can be used as well.`,
|
|
66
|
-
},
|
|
67
|
-
siteId: {
|
|
68
|
-
string: true,
|
|
69
|
-
describe: `Netlify Site ID.`,
|
|
70
|
-
},
|
|
71
|
-
context: {
|
|
72
|
-
string: true,
|
|
73
|
-
describe: `Build context.
|
|
74
|
-
Default: 'production'`,
|
|
75
|
-
},
|
|
76
|
-
branch: {
|
|
77
|
-
string: true,
|
|
78
|
-
describe: `Repository branch.
|
|
79
|
-
Default: automatically guessed`,
|
|
80
|
-
},
|
|
81
|
-
baseRelDir: {
|
|
82
|
-
boolean: true,
|
|
83
|
-
describe: `Feature flag meant for backward compatibility.
|
|
84
|
-
When enabled, if the 'build.base' configuration property is defined, it is used
|
|
85
|
-
to try to retrieve a second configuration file and discard the first one.
|
|
86
|
-
Default: true`,
|
|
87
|
-
hidden: true,
|
|
88
|
-
},
|
|
89
|
-
dry: {
|
|
90
|
-
alias: 'dry-run',
|
|
91
|
-
boolean: true,
|
|
92
|
-
describe: `Run in dry mode, i.e. printing commands without
|
|
93
|
-
executing them.
|
|
94
|
-
Default: false`,
|
|
95
|
-
},
|
|
96
|
-
nodePath: {
|
|
97
|
-
string: true,
|
|
98
|
-
describe: `Path to the Node.js binary to use in user commands and build plugins.
|
|
99
|
-
Default: Current Node.js binary`,
|
|
100
|
-
},
|
|
101
|
-
features: {
|
|
102
|
-
boolean: true,
|
|
103
|
-
describe: `Print currently enabled feature flags.
|
|
104
|
-
Default: false`,
|
|
105
|
-
},
|
|
106
|
-
mode: {
|
|
107
|
-
string: true,
|
|
108
|
-
describe: `Environment in which this is loaded. Can be:
|
|
109
|
-
- 'buildbot': within Netlify Buildbot
|
|
110
|
-
- 'cli': within Netlify CLI
|
|
111
|
-
- 'require': through require('@netlify/build')`,
|
|
112
|
-
hidden: true,
|
|
113
|
-
},
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const USAGE = `netlify-build [OPTIONS...]
|
|
117
|
-
|
|
118
|
-
Run Netlify Build system locally.
|
|
119
|
-
|
|
120
|
-
Options can also be specified as environment variables prefixed with
|
|
121
|
-
NETLIFY_BUILD_. For example the environment variable NETLIFY_BUILD_DRY=true can
|
|
122
|
-
be used instead of the CLI flag --dry.`
|
|
123
|
-
|
|
124
|
-
// Remove `yargs`-specific options, shortcuts, dash-cased and aliases
|
|
125
|
-
const isUserFlag = function(key, value) {
|
|
126
|
-
return value !== undefined && !INTERNAL_KEYS.includes(key) && key.length !== 1 && !key.includes('-')
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const INTERNAL_KEYS = ['help', 'version', '_', '$0', 'dryRun']
|
|
130
|
-
|
|
131
|
-
const printFeatures = function() {
|
|
132
|
-
console.log(['', ...FEATURES, ''].join(FEATURES_DELIMITER))
|
|
133
|
-
exit(0)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const FEATURES = ['cachesave']
|
|
137
|
-
const FEATURES_DELIMITER = '_'
|
|
138
|
-
|
|
139
|
-
runCli()
|