@netlify/build 28.0.1-beta → 28.0.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.
Files changed (259) hide show
  1. package/bin.js +5 -0
  2. package/lib/core/bin.js +66 -0
  3. package/lib/core/build.js +355 -0
  4. package/lib/core/config.js +121 -0
  5. package/lib/core/constants.js +116 -0
  6. package/lib/core/dev.js +27 -0
  7. package/lib/core/dry.js +21 -0
  8. package/lib/core/feature_flags.js +19 -0
  9. package/lib/core/flags.js +201 -0
  10. package/lib/core/lingering.js +68 -0
  11. package/lib/core/main.js +105 -0
  12. package/lib/core/missing_side_file.js +17 -0
  13. package/lib/core/normalize_flags.js +59 -0
  14. package/lib/core/severity.js +21 -0
  15. package/lib/core/types.js +8 -0
  16. package/lib/core/user_node_version.js +32 -0
  17. package/lib/env/changes.js +43 -0
  18. package/lib/env/main.js +14 -0
  19. package/lib/env/metadata.js +68 -0
  20. package/lib/error/api.js +37 -0
  21. package/lib/error/build.js +36 -0
  22. package/{src → lib}/error/cancel.js +5 -6
  23. package/lib/error/colors.js +9 -0
  24. package/lib/error/handle.js +46 -0
  25. package/lib/error/info.js +37 -0
  26. package/lib/error/monitor/location.js +16 -0
  27. package/lib/error/monitor/normalize.js +86 -0
  28. package/lib/error/monitor/print.js +20 -0
  29. package/lib/error/monitor/report.js +120 -0
  30. package/lib/error/monitor/start.js +61 -0
  31. package/lib/error/parse/clean_stack.js +70 -0
  32. package/lib/error/parse/location.js +50 -0
  33. package/lib/error/parse/normalize.js +24 -0
  34. package/lib/error/parse/parse.js +67 -0
  35. package/lib/error/parse/plugin.js +55 -0
  36. package/lib/error/parse/properties.js +16 -0
  37. package/lib/error/parse/serialize_log.js +34 -0
  38. package/lib/error/parse/serialize_status.js +18 -0
  39. package/lib/error/parse/stack.js +34 -0
  40. package/lib/error/type.js +171 -0
  41. package/lib/install/functions.js +20 -0
  42. package/lib/install/local.js +45 -0
  43. package/lib/install/main.js +67 -0
  44. package/lib/install/missing.js +54 -0
  45. package/{src → lib}/log/colors.js +15 -22
  46. package/lib/log/description.js +21 -0
  47. package/lib/log/header.js +14 -0
  48. package/lib/log/header_func.js +13 -0
  49. package/lib/log/logger.js +140 -0
  50. package/lib/log/messages/compatibility.js +120 -0
  51. package/lib/log/messages/config.js +91 -0
  52. package/lib/log/messages/core.js +50 -0
  53. package/lib/log/messages/core_steps.js +75 -0
  54. package/lib/log/messages/dry.js +41 -0
  55. package/lib/log/messages/install.js +25 -0
  56. package/lib/log/messages/ipc.js +29 -0
  57. package/lib/log/messages/mutations.js +62 -0
  58. package/{src → lib}/log/messages/plugins.js +18 -32
  59. package/lib/log/messages/status.js +14 -0
  60. package/lib/log/messages/steps.js +18 -0
  61. package/lib/log/old_version.js +32 -0
  62. package/lib/log/serialize.js +10 -0
  63. package/lib/log/stream.js +68 -0
  64. package/lib/log/theme.js +25 -0
  65. package/lib/plugins/child/diff.js +46 -0
  66. package/lib/plugins/child/error.js +26 -0
  67. package/lib/plugins/child/lazy.js +15 -0
  68. package/lib/plugins/child/load.js +22 -0
  69. package/lib/plugins/child/logic.js +57 -0
  70. package/lib/plugins/child/main.js +37 -0
  71. package/lib/plugins/child/run.js +19 -0
  72. package/lib/plugins/child/status.js +63 -0
  73. package/lib/plugins/child/typescript.js +28 -0
  74. package/lib/plugins/child/utils.js +42 -0
  75. package/lib/plugins/child/validate.js +31 -0
  76. package/lib/plugins/compatibility.js +104 -0
  77. package/{src → lib}/plugins/error.js +31 -35
  78. package/{src → lib}/plugins/events.js +7 -12
  79. package/lib/plugins/expected_version.js +81 -0
  80. package/lib/plugins/ipc.js +120 -0
  81. package/lib/plugins/list.js +73 -0
  82. package/lib/plugins/load.js +50 -0
  83. package/lib/plugins/manifest/check.js +85 -0
  84. package/lib/plugins/manifest/load.js +38 -0
  85. package/lib/plugins/manifest/main.js +17 -0
  86. package/lib/plugins/manifest/path.js +24 -0
  87. package/lib/plugins/manifest/validate.js +91 -0
  88. package/lib/plugins/node_version.js +30 -0
  89. package/lib/plugins/options.js +55 -0
  90. package/lib/plugins/pinned_version.js +83 -0
  91. package/lib/plugins/resolve.js +110 -0
  92. package/lib/plugins/spawn.js +54 -0
  93. package/lib/plugins_core/add.js +35 -0
  94. package/lib/plugins_core/build_command.js +50 -0
  95. package/lib/plugins_core/deploy/buildbot_client.js +87 -0
  96. package/lib/plugins_core/deploy/index.js +49 -0
  97. package/{src → lib}/plugins_core/deploy/manifest.yml +0 -0
  98. package/lib/plugins_core/edge_functions/index.js +79 -0
  99. package/lib/plugins_core/edge_functions/lib/error.js +17 -0
  100. package/lib/plugins_core/edge_functions/lib/internal_manifest.js +50 -0
  101. package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +75 -0
  102. package/lib/plugins_core/functions/error.js +123 -0
  103. package/lib/plugins_core/functions/feature_flags.js +6 -0
  104. package/lib/plugins_core/functions/index.js +114 -0
  105. package/lib/plugins_core/functions/utils.js +45 -0
  106. package/lib/plugins_core/functions/zisi.js +39 -0
  107. package/{src → lib}/plugins_core/functions_install/index.js +8 -11
  108. package/{src → lib}/plugins_core/functions_install/manifest.yml +0 -0
  109. package/lib/plugins_core/list.js +20 -0
  110. package/lib/status/add.js +30 -0
  111. package/lib/status/colors.js +18 -0
  112. package/lib/status/load_error.js +10 -0
  113. package/lib/status/report.js +83 -0
  114. package/lib/status/success.js +14 -0
  115. package/lib/steps/core_step.js +57 -0
  116. package/lib/steps/error.js +65 -0
  117. package/lib/steps/get.js +43 -0
  118. package/lib/steps/plugin.js +55 -0
  119. package/lib/steps/return.js +25 -0
  120. package/lib/steps/run_core_steps.js +126 -0
  121. package/lib/steps/run_step.js +188 -0
  122. package/lib/steps/run_steps.js +96 -0
  123. package/lib/steps/update_config.js +66 -0
  124. package/lib/telemetry/main.js +97 -0
  125. package/lib/time/aggregate.js +120 -0
  126. package/lib/time/main.js +37 -0
  127. package/lib/time/measure.js +18 -0
  128. package/lib/time/report.js +47 -0
  129. package/lib/utils/errors.js +13 -0
  130. package/lib/utils/json.js +15 -0
  131. package/{src → lib}/utils/omit.js +3 -4
  132. package/lib/utils/package.js +22 -0
  133. package/lib/utils/remove_falsy.js +8 -0
  134. package/lib/utils/resolve.js +41 -0
  135. package/lib/utils/runtime.js +5 -0
  136. package/lib/utils/semver.js +28 -0
  137. package/package.json +40 -20
  138. package/types/config/netlify_config.d.ts +4 -4
  139. package/types/netlify_plugin_constants.d.ts +8 -8
  140. package/src/core/bin.js +0 -83
  141. package/src/core/config.js +0 -186
  142. package/src/core/constants.js +0 -156
  143. package/src/core/dry.js +0 -39
  144. package/src/core/feature_flags.js +0 -21
  145. package/src/core/flags.js +0 -194
  146. package/src/core/lingering.js +0 -85
  147. package/src/core/main.js +0 -692
  148. package/src/core/missing_side_file.js +0 -29
  149. package/src/core/normalize_flags.js +0 -69
  150. package/src/core/severity.js +0 -22
  151. package/src/core/user_node_version.js +0 -41
  152. package/src/env/changes.js +0 -52
  153. package/src/env/main.js +0 -19
  154. package/src/env/metadata.js +0 -81
  155. package/src/error/api.js +0 -46
  156. package/src/error/build.js +0 -50
  157. package/src/error/colors.js +0 -11
  158. package/src/error/handle.js +0 -57
  159. package/src/error/info.js +0 -46
  160. package/src/error/monitor/location.js +0 -21
  161. package/src/error/monitor/normalize.js +0 -77
  162. package/src/error/monitor/print.js +0 -42
  163. package/src/error/monitor/report.js +0 -133
  164. package/src/error/monitor/start.js +0 -69
  165. package/src/error/parse/clean_stack.js +0 -87
  166. package/src/error/parse/location.js +0 -58
  167. package/src/error/parse/normalize.js +0 -29
  168. package/src/error/parse/parse.js +0 -97
  169. package/src/error/parse/plugin.js +0 -70
  170. package/src/error/parse/properties.js +0 -23
  171. package/src/error/parse/serialize_log.js +0 -42
  172. package/src/error/parse/serialize_status.js +0 -23
  173. package/src/error/parse/stack.js +0 -43
  174. package/src/error/type.js +0 -182
  175. package/src/install/functions.js +0 -28
  176. package/src/install/local.js +0 -62
  177. package/src/install/main.js +0 -81
  178. package/src/install/missing.js +0 -67
  179. package/src/log/description.js +0 -26
  180. package/src/log/header.js +0 -16
  181. package/src/log/header_func.js +0 -17
  182. package/src/log/logger.js +0 -107
  183. package/src/log/messages/compatibility.js +0 -164
  184. package/src/log/messages/config.js +0 -105
  185. package/src/log/messages/core.js +0 -70
  186. package/src/log/messages/core_steps.js +0 -104
  187. package/src/log/messages/dry.js +0 -63
  188. package/src/log/messages/install.js +0 -20
  189. package/src/log/messages/ipc.js +0 -38
  190. package/src/log/messages/mutations.js +0 -82
  191. package/src/log/messages/status.js +0 -16
  192. package/src/log/messages/steps.js +0 -22
  193. package/src/log/old_version.js +0 -41
  194. package/src/log/serialize.js +0 -13
  195. package/src/log/stream.js +0 -85
  196. package/src/log/theme.js +0 -26
  197. package/src/plugins/child/diff.js +0 -55
  198. package/src/plugins/child/error.js +0 -32
  199. package/src/plugins/child/lazy.js +0 -18
  200. package/src/plugins/child/load.js +0 -29
  201. package/src/plugins/child/logic.js +0 -57
  202. package/src/plugins/child/main.js +0 -51
  203. package/src/plugins/child/run.js +0 -28
  204. package/src/plugins/child/status.js +0 -67
  205. package/src/plugins/child/typescript.js +0 -45
  206. package/src/plugins/child/utils.js +0 -56
  207. package/src/plugins/child/validate.js +0 -34
  208. package/src/plugins/compatibility.js +0 -128
  209. package/src/plugins/expected_version.js +0 -119
  210. package/src/plugins/ipc.js +0 -145
  211. package/src/plugins/list.js +0 -86
  212. package/src/plugins/load.js +0 -70
  213. package/src/plugins/manifest/check.js +0 -106
  214. package/src/plugins/manifest/load.js +0 -41
  215. package/src/plugins/manifest/main.js +0 -22
  216. package/src/plugins/manifest/path.js +0 -31
  217. package/src/plugins/manifest/validate.js +0 -108
  218. package/src/plugins/node_version.js +0 -50
  219. package/src/plugins/options.js +0 -88
  220. package/src/plugins/pinned_version.js +0 -131
  221. package/src/plugins/resolve.js +0 -152
  222. package/src/plugins/spawn.js +0 -66
  223. package/src/plugins_core/add.js +0 -49
  224. package/src/plugins_core/build_command.js +0 -75
  225. package/src/plugins_core/deploy/buildbot_client.js +0 -102
  226. package/src/plugins_core/deploy/index.js +0 -73
  227. package/src/plugins_core/edge_functions/index.js +0 -107
  228. package/src/plugins_core/edge_functions/lib/internal_manifest.js +0 -54
  229. package/src/plugins_core/functions/error.js +0 -163
  230. package/src/plugins_core/functions/feature_flags.js +0 -6
  231. package/src/plugins_core/functions/index.js +0 -160
  232. package/src/plugins_core/functions/utils.js +0 -66
  233. package/src/plugins_core/functions/zisi.js +0 -53
  234. package/src/plugins_core/list.js +0 -27
  235. package/src/status/add.js +0 -36
  236. package/src/status/colors.js +0 -23
  237. package/src/status/load_error.js +0 -11
  238. package/src/status/report.js +0 -128
  239. package/src/status/success.js +0 -18
  240. package/src/steps/core_step.js +0 -90
  241. package/src/steps/error.js +0 -102
  242. package/src/steps/get.js +0 -32
  243. package/src/steps/plugin.js +0 -85
  244. package/src/steps/return.js +0 -52
  245. package/src/steps/run_core_steps.js +0 -194
  246. package/src/steps/run_step.js +0 -300
  247. package/src/steps/run_steps.js +0 -179
  248. package/src/steps/update_config.js +0 -93
  249. package/src/telemetry/main.js +0 -136
  250. package/src/time/aggregate.js +0 -146
  251. package/src/time/main.js +0 -48
  252. package/src/time/measure.js +0 -22
  253. package/src/time/report.js +0 -59
  254. package/src/utils/errors.js +0 -12
  255. package/src/utils/json.js +0 -19
  256. package/src/utils/package.js +0 -23
  257. package/src/utils/remove_falsy.js +0 -10
  258. package/src/utils/resolve.js +0 -46
  259. package/src/utils/semver.js +0 -34
@@ -1,156 +0,0 @@
1
- import { relative, normalize } from 'path'
2
-
3
- import { getCacheDir } from '@netlify/cache-utils'
4
- import mapObj from 'map-obj'
5
- import { pathExists } from 'path-exists'
6
-
7
- import { ROOT_PACKAGE_JSON } from '../utils/json.js'
8
-
9
- // Retrieve constants passed to plugins
10
- export const getConstants = async function ({
11
- configPath,
12
- buildDir,
13
- functionsDistDir,
14
- edgeFunctionsDistDir,
15
- cacheDir,
16
- netlifyConfig,
17
- siteInfo: { id: siteId },
18
- apiHost,
19
- token,
20
- mode,
21
- }) {
22
- const isLocal = mode !== 'buildbot'
23
- const normalizedCacheDir = getCacheDir({ cacheDir, cwd: buildDir })
24
-
25
- const constants = {
26
- // Path to the Netlify configuration file
27
- CONFIG_PATH: configPath,
28
- // The directory where built serverless functions are placed before deployment
29
- FUNCTIONS_DIST: functionsDistDir,
30
- // The directory where built Edge Functions are placed before deployment
31
- EDGE_FUNCTIONS_DIST: edgeFunctionsDistDir,
32
- // Path to the Netlify build cache folder
33
- CACHE_DIR: normalizedCacheDir,
34
- // Boolean indicating whether the build was run locally (Netlify CLI) or in the production CI
35
- IS_LOCAL: isLocal,
36
- // The version of Netlify Build
37
- NETLIFY_BUILD_VERSION: ROOT_PACKAGE_JSON.version,
38
- // The Netlify Site ID
39
- SITE_ID: siteId,
40
- // The Netlify API access token
41
- NETLIFY_API_TOKEN: token,
42
- // The Netlify API host
43
- NETLIFY_API_HOST: apiHost,
44
- // The directory where internal functions (i.e. generated programmatically
45
- // via plugins or others) live
46
- INTERNAL_FUNCTIONS_SRC: `${buildDir}/${INTERNAL_FUNCTIONS_SRC}`,
47
- // The directory where internal Edge Functions (i.e. generated programmatically
48
- // via plugins or others) live
49
- INTERNAL_EDGE_FUNCTIONS_SRC: `${buildDir}/${INTERNAL_EDGE_FUNCTIONS_SRC}`,
50
- }
51
- const constantsA = await addMutableConstants({ constants, buildDir, netlifyConfig })
52
- return constantsA
53
- }
54
-
55
- const INTERNAL_EDGE_FUNCTIONS_SRC = '.netlify/edge-functions'
56
- const INTERNAL_FUNCTIONS_SRC = '.netlify/functions-internal'
57
-
58
- // Retrieve constants which might change during the build if a plugin modifies
59
- // `netlifyConfig` or creates some default directories.
60
- // Unlike readonly constants, this is called again before each build step.
61
- export const addMutableConstants = async function ({
62
- constants,
63
- buildDir,
64
- netlifyConfig: {
65
- build: { publish, edge_functions: edgeFunctions },
66
- functionsDirectory,
67
- },
68
- }) {
69
- const constantsA = {
70
- ...constants,
71
- // Directory that contains the deploy-ready HTML files and assets generated by the build
72
- PUBLISH_DIR: publish,
73
- // The directory where function source code lives
74
- FUNCTIONS_SRC: functionsDirectory,
75
- // The directory where Edge Functions source code lives
76
- EDGE_FUNCTIONS_SRC: edgeFunctions,
77
- }
78
- const constantsB = await addDefaultConstants(constantsA, buildDir)
79
- const constantsC = normalizeConstantsPaths(constantsB, buildDir)
80
- return constantsC
81
- }
82
-
83
- // Some `constants` have a default value when a specific file exists.
84
- // Those default values are assigned by `@netlify/config`. However, the build
85
- // command or plugins might create those specific files, in which case, the
86
- // related `constant` should be updated, unless the user has explicitly
87
- // configured it.
88
- const addDefaultConstants = async function (constants, buildDir) {
89
- const newConstants = await Promise.all(
90
- DEFAULT_PATHS.map(({ constantName, defaultPath }) =>
91
- addDefaultConstant({ constants, constantName, defaultPath, buildDir }),
92
- ),
93
- )
94
- return Object.assign({}, constants, ...newConstants)
95
- }
96
-
97
- // The current directory is the build directory, which is correct, so we don't
98
- // need to resolve paths
99
- const DEFAULT_PATHS = [
100
- // @todo Remove once we drop support for the legacy default functions directory.
101
- { constantName: 'FUNCTIONS_SRC', defaultPath: 'netlify-automatic-functions' },
102
- { constantName: 'FUNCTIONS_SRC', defaultPath: 'netlify/functions' },
103
- { constantName: 'EDGE_FUNCTIONS_SRC', defaultPath: 'netlify/edge-functions' },
104
- ]
105
-
106
- const addDefaultConstant = async function ({ constants, constantName, defaultPath, buildDir }) {
107
- // Configuration paths are relative to the build directory.
108
- if (!isEmptyValue(constants[constantName]) || !(await pathExists(`${buildDir}/${defaultPath}`))) {
109
- return {}
110
- }
111
-
112
- // However, the plugin child process' current directory is the build directory,
113
- // so we can pass the relative path instead of the resolved absolute path.
114
- return { [constantName]: defaultPath }
115
- }
116
-
117
- const normalizeConstantsPaths = function (constants, buildDir) {
118
- return mapObj(constants, (key, path) => [key, normalizePath(path, buildDir, key)])
119
- }
120
-
121
- // The current directory is `buildDir`. Most constants are inside this `buildDir`.
122
- // Instead of passing absolute paths, we pass paths relative to `buildDir`, so
123
- // that logs are less verbose.
124
- const normalizePath = function (path, buildDir, key) {
125
- if (isEmptyValue(path) || !CONSTANT_PATHS.has(key)) {
126
- return path
127
- }
128
-
129
- const pathA = normalize(path)
130
-
131
- if (pathA === buildDir) {
132
- return '.'
133
- }
134
-
135
- if (pathA.startsWith(buildDir)) {
136
- return relative(buildDir, pathA)
137
- }
138
-
139
- return pathA
140
- }
141
-
142
- const isEmptyValue = function (path) {
143
- return path === undefined || path === ''
144
- }
145
-
146
- const CONSTANT_PATHS = new Set([
147
- 'CONFIG_PATH',
148
- 'PUBLISH_DIR',
149
- 'FUNCTIONS_SRC',
150
- 'FUNCTIONS_DIST',
151
- 'INTERNAL_EDGE_FUNCTIONS_SRC',
152
- 'INTERNAL_FUNCTIONS_SRC',
153
- 'EDGE_FUNCTIONS_DIST',
154
- 'EDGE_FUNCTIONS_SRC',
155
- 'CACHE_DIR',
156
- ])
package/src/core/dry.js DELETED
@@ -1,39 +0,0 @@
1
- import pFilter from 'p-filter'
2
-
3
- import { logDryRunStart, logDryRunStep, logDryRunEnd } from '../log/messages/dry.js'
4
- import { runsOnlyOnBuildFailure } from '../plugins/events.js'
5
-
6
- // If the `dry` flag is specified, do a dry run
7
- export const doDryRun = async function ({ buildDir, steps, netlifyConfig, constants, buildbotServerSocket, logs }) {
8
- const successSteps = await pFilter(steps, ({ event, condition }) =>
9
- shouldIncludeStep({ buildDir, event, condition, netlifyConfig, constants, buildbotServerSocket }),
10
- )
11
- const eventWidth = Math.max(...successSteps.map(getEventLength))
12
- const stepsCount = successSteps.length
13
-
14
- logDryRunStart({ logs, eventWidth, stepsCount })
15
-
16
- successSteps.forEach((step, index) => {
17
- logDryRunStep({ logs, step, index, netlifyConfig, eventWidth, stepsCount })
18
- })
19
-
20
- logDryRunEnd(logs)
21
- }
22
-
23
- const shouldIncludeStep = async function ({
24
- buildDir,
25
- event,
26
- condition,
27
- netlifyConfig,
28
- constants,
29
- buildbotServerSocket,
30
- }) {
31
- return (
32
- !runsOnlyOnBuildFailure(event) &&
33
- (condition === undefined || (await condition({ buildDir, constants, netlifyConfig, buildbotServerSocket })))
34
- )
35
- }
36
-
37
- const getEventLength = function ({ event }) {
38
- return event.length
39
- }
@@ -1,21 +0,0 @@
1
- // From CLI `--featureFlags=a,b,c` to programmatic `{ a: true, b: true, c: true }`
2
- export const normalizeCliFeatureFlags = function (cliFeatureFlags) {
3
- return Object.assign({}, ...cliFeatureFlags.split(',').filter(isNotEmpty).map(getFeatureFlag))
4
- }
5
-
6
- const isNotEmpty = function (name) {
7
- return name.trim() !== ''
8
- }
9
-
10
- const getFeatureFlag = function (name) {
11
- return { [name]: true }
12
- }
13
-
14
- // Default values for feature flags
15
- export const DEFAULT_FEATURE_FLAGS = {
16
- buildbot_es_modules_esbuild: false,
17
- buildbot_zisi_trace_nft: false,
18
- buildbot_zisi_esbuild_parser: false,
19
- edge_functions_cache_cli: false,
20
- edge_functions_produce_eszip: false,
21
- }
package/src/core/flags.js DELETED
@@ -1,194 +0,0 @@
1
- /* eslint eslint-comments/no-use: off, max-lines: off */
2
-
3
- const jsonParse = function (value) {
4
- return value === undefined ? undefined : JSON.parse(value)
5
- }
6
-
7
- // All CLI flags
8
- export const FLAGS = {
9
- config: {
10
- string: true,
11
- describe: `Path to the configuration file.
12
- Defaults to any netlify.toml in the git repository root directory or the base directory`,
13
- },
14
- defaultConfig: {
15
- string: true,
16
- describe: `JSON configuration object containing default values.
17
- Each configuration default value is used unless overriden through the main configuration file.
18
- Default: none.`,
19
- coerce: jsonParse,
20
- hidden: true,
21
- },
22
- cachedConfig: {
23
- string: true,
24
- describe: `JSON configuration object returned by @netlify/config when --output=/ is used
25
- or when using @netlify/config programmatically.
26
- This is done as a performance optimization to cache the configuration loading logic.
27
- Default: none.`,
28
- coerce: jsonParse,
29
- hidden: true,
30
- },
31
- cachedConfigPath: {
32
- string: true,
33
- describe: `File path to the JSON configuration object returned by @netlify/config
34
- when --output=/path is used.
35
- This is done as a performance optimization to cache the configuration loading logic.
36
- Default: none.`,
37
- hidden: true,
38
- },
39
- cwd: {
40
- string: true,
41
- describe: `Current directory. Used to retrieve the configuration file.
42
- Default: current directory`,
43
- },
44
- repositoryRoot: {
45
- string: true,
46
- describe: `Git repository root directory. Used to retrieve the configuration file.
47
- Default: automatically guessed`,
48
- },
49
- apiHost: {
50
- string: true,
51
- describe: `Netlify API endpoint.
52
- Default: automatically guessed`,
53
- },
54
- token: {
55
- string: true,
56
- describe: `Netlify API token for authentication.
57
- The NETLIFY_AUTH_TOKEN environment variable can be used as well.`,
58
- },
59
- siteId: {
60
- string: true,
61
- describe: `Netlify Site ID.`,
62
- },
63
- deployId: {
64
- string: true,
65
- describe: `Netlify Deploy ID.
66
- Default: automatically guessed`,
67
- },
68
- buildId: {
69
- string: true,
70
- describe: `Netlify Build ID.
71
- Default: automatically guessed`,
72
- },
73
- context: {
74
- string: true,
75
- describe: `Build context.
76
- Default: 'production'`,
77
- },
78
- branch: {
79
- string: true,
80
- describe: `Repository branch.
81
- Default: automatically guessed`,
82
- },
83
- framework: {
84
- string: true,
85
- describe: 'Front-end framework.',
86
- hidden: true,
87
- },
88
- baseRelDir: {
89
- boolean: true,
90
- describe: `Feature flag meant for backward compatibility.
91
- When enabled, if the 'build.base' configuration property is defined, it is used
92
- to try to retrieve a second configuration file and discard the first one.
93
- Default: true`,
94
- hidden: true,
95
- },
96
- dry: {
97
- alias: 'dry-run',
98
- boolean: true,
99
- describe: `Run in dry mode, i.e. printing steps without executing them.
100
- Default: false`,
101
- },
102
- nodePath: {
103
- string: true,
104
- describe: `Path to the Node.js binary to use in the build command and plugins.
105
- Default: Current Node.js binary`,
106
- },
107
- functionsDistDir: {
108
- string: true,
109
- describe: `Path to the directory where packaged functions are kept.
110
- Default: automatically guessed`,
111
- hidden: true,
112
- },
113
- edgeFunctionsDistDir: {
114
- string: true,
115
- describe: `Path to the directory where packaged Edge Functions are kept.
116
- Default: automatically guessed`,
117
- hidden: true,
118
- },
119
- cacheDir: {
120
- string: true,
121
- describe: `Path to the cache directory.
122
- Default: .netlify/cache/`,
123
- hidden: true,
124
- },
125
- buildbotServerSocket: {
126
- string: true,
127
- describe: `Path to the buildbot server socket. This is used to connect to the buildbot to trigger deploys.`,
128
- hidden: true,
129
- },
130
- telemetry: {
131
- boolean: true,
132
- describe: `Enable telemetry.
133
- Default: false`,
134
- },
135
- mode: {
136
- string: true,
137
- describe: `Environment in which this is loaded. Can be:
138
- - 'buildbot': within Netlify Buildbot
139
- - 'cli': within Netlify CLI
140
- - 'require': through import('@netlify/build')`,
141
- hidden: true,
142
- },
143
- debug: {
144
- boolean: true,
145
- describe: 'Print user-facing debugging information',
146
- hidden: true,
147
- },
148
- verbose: {
149
- boolean: true,
150
- describe: 'Print internal debugging information',
151
- hidden: true,
152
- },
153
- sendStatus: {
154
- boolean: true,
155
- describe: 'Whether plugin statuses should be sent to the Netlify API',
156
- hidden: true,
157
- },
158
- saveConfig: {
159
- boolean: true,
160
- describe: 'Whether configuration changes should be saved to netlify.toml',
161
- hidden: true,
162
- },
163
- testOpts: {
164
- describe: 'Options for testing only',
165
- hidden: true,
166
- },
167
- featureFlags: {
168
- describe: 'Comma-separated list of feature flags to enable unreleased features',
169
- hidden: true,
170
- },
171
- statsd: {
172
- describe: 'Statsd-related options, for performance measuring',
173
- hidden: true,
174
- },
175
- 'statsd.host': {
176
- type: 'string',
177
- describe: 'Statsd host',
178
- hidden: true,
179
- },
180
- 'statsd.port': {
181
- type: 'number',
182
- describe: 'Statsd port',
183
- hidden: true,
184
- },
185
- offline: {
186
- boolean: true,
187
- describe: `Do not send requests to the Netlify API to retrieve site settings.
188
- Default: false`,
189
- },
190
- buffer: {
191
- boolean: true,
192
- describe: 'Buffer output instead of printing it',
193
- },
194
- }
@@ -1,85 +0,0 @@
1
- import psList from 'ps-list'
2
-
3
- import { logLingeringProcesses } from '../log/messages/core.js'
4
-
5
- // Print a warning when some build processes are still running.
6
- // We cannot rely on using the process tree:
7
- // - This is because it is impossible to know whether a process was a child of
8
- // of another once its parent process has exited. When that happens, the s
9
- // child becomes inherited by `init`, changing its `ppid`. The information
10
- // about the original parent is then lost.
11
- // - The only way to implement this would be to repeatedly list processes as
12
- // the build command is ongoing. However, this would fail to detect processes
13
- // spawned just before the build commands ends.
14
- // We cannot list processes before and after the build command and use the
15
- // difference.
16
- // - This is because other processes (unrelated to @netlify/build) might be
17
- // running at the same time. This includes OS background processes.
18
- // Therefore, we run this in a controlled environment only (the buildbot) and
19
- // exclude specific processes manually. This is a lesser evil, although still
20
- // quite hacky.
21
- export const warnOnLingeringProcesses = async function ({
22
- mode,
23
- logs,
24
- testOpts: { silentLingeringProcesses = false },
25
- }) {
26
- if (mode !== 'buildbot' || silentLingeringProcesses) {
27
- return
28
- }
29
-
30
- const processes = await psList()
31
-
32
- const commands = processes.map(getCommand).filter(isNotIgnoredCommand)
33
-
34
- if (commands.length === 0) {
35
- return
36
- }
37
-
38
- logLingeringProcesses(logs, commands)
39
- }
40
-
41
- // `cmd` is only available on Unix. Unlike `name`, it includes the arguments.
42
- const getCommand = function ({ name, cmd = name }) {
43
- return cmd
44
- }
45
-
46
- // We ignore any command known to be internal to the buildbot.
47
- // We also ignore commands known not to complete properly in builds if they are
48
- // widely used.
49
- const isNotIgnoredCommand = function (command) {
50
- return !IGNORED_COMMANDS.some((ignoredCommand) => matchesIgnoredCommand(command, ignoredCommand))
51
- }
52
-
53
- const matchesIgnoredCommand = function (command, ignoredCommand) {
54
- if (typeof ignoredCommand === 'string') {
55
- return command.includes(ignoredCommand)
56
- }
57
-
58
- return ignoredCommand.test(command)
59
- }
60
-
61
- const IGNORED_COMMANDS = [
62
- // TODO: Those can most likely be removed
63
- 'ps',
64
- 'grep',
65
- 'bash',
66
-
67
- // Internal buildbot commands
68
- '[build]',
69
- /buildbot.*\[node]/,
70
- // buildbot's main Bash script
71
- '/opt/build-bin/build',
72
- // `@netlify/build` binary itself
73
- 'netlify-build',
74
- // Plugin child processes spawned by @netlify/build
75
- '@netlify/build',
76
- // Shown for parent processes with currently running child processes.
77
- // Happens on `ps` itself.
78
- 'defunct',
79
-
80
- // Processes often left running. We should report those but don't because of
81
- // how common those are in production builds
82
- 'gatsby-telemetry',
83
- 'jest-worker',
84
- 'broccoli-babel-transpiler',
85
- ]