@netlify/build 0.4.48 → 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.
Files changed (243) hide show
  1. package/bin.js +5 -0
  2. package/lib/core/bin.js +66 -0
  3. package/lib/core/build.js +392 -0
  4. package/lib/core/config.js +124 -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 +17 -0
  9. package/lib/core/flags.js +206 -0
  10. package/lib/core/lingering.js +68 -0
  11. package/lib/core/main.js +114 -0
  12. package/lib/core/missing_side_file.js +17 -0
  13. package/lib/core/normalize_flags.js +62 -0
  14. package/lib/core/report_metrics.js +17 -0
  15. package/lib/core/severity.js +21 -0
  16. package/lib/core/types.js +8 -0
  17. package/lib/core/user_node_version.js +32 -0
  18. package/lib/env/changes.js +43 -0
  19. package/lib/env/main.js +14 -0
  20. package/lib/env/metadata.js +68 -0
  21. package/lib/error/api.js +37 -0
  22. package/lib/error/build.js +36 -0
  23. package/lib/error/cancel.js +7 -0
  24. package/lib/error/colors.js +9 -0
  25. package/lib/error/handle.js +44 -0
  26. package/lib/error/info.js +37 -0
  27. package/lib/error/monitor/location.js +16 -0
  28. package/lib/error/monitor/normalize.js +86 -0
  29. package/lib/error/monitor/print.js +20 -0
  30. package/lib/error/monitor/report.js +120 -0
  31. package/lib/error/monitor/start.js +61 -0
  32. package/lib/error/parse/clean_stack.js +70 -0
  33. package/lib/error/parse/location.js +50 -0
  34. package/lib/error/parse/normalize.js +24 -0
  35. package/lib/error/parse/parse.js +67 -0
  36. package/lib/error/parse/plugin.js +55 -0
  37. package/lib/error/parse/properties.js +16 -0
  38. package/lib/error/parse/serialize_log.js +34 -0
  39. package/lib/error/parse/serialize_status.js +18 -0
  40. package/lib/error/parse/stack.js +34 -0
  41. package/lib/error/report.js +29 -0
  42. package/lib/error/type.js +177 -0
  43. package/lib/install/functions.js +20 -0
  44. package/lib/install/local.js +45 -0
  45. package/lib/install/main.js +67 -0
  46. package/lib/install/missing.js +54 -0
  47. package/lib/log/colors.js +28 -0
  48. package/lib/log/description.js +21 -0
  49. package/lib/log/header.js +12 -0
  50. package/lib/log/header_func.js +13 -0
  51. package/lib/log/logger.js +140 -0
  52. package/lib/log/messages/compatibility.js +120 -0
  53. package/lib/log/messages/config.js +91 -0
  54. package/lib/log/messages/core.js +49 -0
  55. package/lib/log/messages/core_steps.js +75 -0
  56. package/lib/log/messages/dry.js +41 -0
  57. package/lib/log/messages/install.js +25 -0
  58. package/lib/log/messages/ipc.js +29 -0
  59. package/lib/log/messages/mutations.js +62 -0
  60. package/lib/log/messages/plugins.js +25 -0
  61. package/lib/log/messages/status.js +14 -0
  62. package/lib/log/messages/steps.js +18 -0
  63. package/lib/log/serialize.js +10 -0
  64. package/lib/log/stream.js +68 -0
  65. package/lib/log/theme.js +27 -0
  66. package/lib/plugins/child/diff.js +46 -0
  67. package/lib/plugins/child/error.js +26 -0
  68. package/lib/plugins/child/lazy.js +15 -0
  69. package/lib/plugins/child/load.js +22 -0
  70. package/lib/plugins/child/logic.js +57 -0
  71. package/lib/plugins/child/main.js +37 -0
  72. package/lib/plugins/child/run.js +19 -0
  73. package/lib/plugins/child/status.js +63 -0
  74. package/lib/plugins/child/typescript.js +28 -0
  75. package/lib/plugins/child/utils.js +42 -0
  76. package/lib/plugins/child/validate.js +31 -0
  77. package/lib/plugins/compatibility.js +104 -0
  78. package/lib/plugins/error.js +46 -0
  79. package/lib/plugins/events.js +12 -0
  80. package/lib/plugins/expected_version.js +81 -0
  81. package/lib/plugins/internal.js +10 -0
  82. package/lib/plugins/ipc.js +120 -0
  83. package/lib/plugins/list.js +73 -0
  84. package/lib/plugins/load.js +50 -0
  85. package/lib/plugins/manifest/check.js +85 -0
  86. package/lib/plugins/manifest/load.js +38 -0
  87. package/lib/plugins/manifest/main.js +19 -0
  88. package/lib/plugins/manifest/path.js +24 -0
  89. package/lib/plugins/manifest/validate.js +91 -0
  90. package/lib/plugins/node_version.js +35 -0
  91. package/lib/plugins/options.js +70 -0
  92. package/lib/plugins/pinned_version.js +83 -0
  93. package/lib/plugins/resolve.js +110 -0
  94. package/lib/plugins/spawn.js +55 -0
  95. package/lib/plugins_core/add.js +35 -0
  96. package/lib/plugins_core/build_command.js +50 -0
  97. package/lib/plugins_core/deploy/buildbot_client.js +87 -0
  98. package/lib/plugins_core/deploy/index.js +49 -0
  99. package/lib/plugins_core/deploy/manifest.yml +1 -0
  100. package/lib/plugins_core/edge_functions/index.js +106 -0
  101. package/lib/plugins_core/edge_functions/lib/error.js +17 -0
  102. package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +14 -0
  103. package/lib/plugins_core/functions/error.js +123 -0
  104. package/lib/plugins_core/functions/feature_flags.js +5 -0
  105. package/lib/plugins_core/functions/index.js +137 -0
  106. package/lib/plugins_core/functions/utils.js +45 -0
  107. package/lib/plugins_core/functions/zisi.js +64 -0
  108. package/lib/plugins_core/functions_install/index.js +10 -0
  109. package/lib/plugins_core/list.js +20 -0
  110. package/lib/plugins_core/save_artifacts/index.js +33 -0
  111. package/lib/report/statsd.js +56 -0
  112. package/lib/status/add.js +30 -0
  113. package/lib/status/colors.js +18 -0
  114. package/lib/status/load_error.js +10 -0
  115. package/lib/status/report.js +83 -0
  116. package/lib/status/success.js +14 -0
  117. package/lib/steps/core_step.js +62 -0
  118. package/lib/steps/error.js +65 -0
  119. package/lib/steps/get.js +44 -0
  120. package/lib/steps/plugin.js +55 -0
  121. package/lib/steps/return.js +27 -0
  122. package/lib/steps/run_core_steps.js +117 -0
  123. package/lib/steps/run_step.js +200 -0
  124. package/lib/steps/run_steps.js +102 -0
  125. package/lib/steps/update_config.js +66 -0
  126. package/lib/telemetry/main.js +94 -0
  127. package/lib/time/aggregate.js +109 -0
  128. package/lib/time/main.js +31 -0
  129. package/lib/time/measure.js +16 -0
  130. package/lib/time/report.js +30 -0
  131. package/lib/utils/errors.js +13 -0
  132. package/lib/utils/json.js +10 -0
  133. package/lib/utils/omit.js +3 -0
  134. package/lib/utils/package.js +24 -0
  135. package/lib/utils/remove_falsy.js +8 -0
  136. package/lib/utils/resolve.js +41 -0
  137. package/lib/utils/runtime.js +5 -0
  138. package/lib/utils/semver.js +28 -0
  139. package/package.json +119 -56
  140. package/types/config/build.d.ts +52 -0
  141. package/types/config/functions.d.ts +36 -0
  142. package/types/config/inputs.d.ts +7 -0
  143. package/types/config/netlify_config.d.ts +58 -0
  144. package/types/index.d.ts +7 -0
  145. package/types/netlify_event_handler.d.ts +29 -0
  146. package/types/netlify_plugin.d.ts +29 -0
  147. package/types/netlify_plugin_constants.d.ts +51 -0
  148. package/types/netlify_plugin_options.d.ts +23 -0
  149. package/types/options/index.d.ts +1 -0
  150. package/types/options/netlify_plugin_build_util.d.ts +7 -0
  151. package/types/options/netlify_plugin_cache_util.d.ts +39 -0
  152. package/types/options/netlify_plugin_functions_util.d.ts +32 -0
  153. package/types/options/netlify_plugin_git_util.d.ts +41 -0
  154. package/types/options/netlify_plugin_run_util.d.ts +24 -0
  155. package/types/options/netlify_plugin_status_util.d.ts +24 -0
  156. package/types/options/netlify_plugin_utils.d.ts +15 -0
  157. package/types/utils/json_value.d.ts +1 -0
  158. package/types/utils/many.d.ts +6 -0
  159. package/README.md +0 -3
  160. package/src/core/bin.js +0 -139
  161. package/src/core/commands.js +0 -304
  162. package/src/core/config.js +0 -130
  163. package/src/core/constants.js +0 -88
  164. package/src/core/dry.js +0 -23
  165. package/src/core/main.js +0 -196
  166. package/src/env/changes.js +0 -49
  167. package/src/env/git.js +0 -27
  168. package/src/env/main.js +0 -97
  169. package/src/env/metadata.js +0 -81
  170. package/src/error/api.js +0 -32
  171. package/src/error/build.js +0 -32
  172. package/src/error/cancel.js +0 -22
  173. package/src/error/colors.js +0 -13
  174. package/src/error/info.js +0 -12
  175. package/src/error/monitor/normalize.js +0 -50
  176. package/src/error/monitor/print.js +0 -43
  177. package/src/error/monitor/report.js +0 -140
  178. package/src/error/monitor/start.js +0 -50
  179. package/src/error/parse/clean_stack.js +0 -86
  180. package/src/error/parse/location.js +0 -50
  181. package/src/error/parse/parse.js +0 -87
  182. package/src/error/parse/plugin.js +0 -68
  183. package/src/error/parse/properties.js +0 -20
  184. package/src/error/parse/serialize_log.js +0 -46
  185. package/src/error/parse/serialize_status.js +0 -28
  186. package/src/error/parse/stack.js +0 -45
  187. package/src/error/process.js +0 -13
  188. package/src/error/type.js +0 -143
  189. package/src/install/functions.js +0 -52
  190. package/src/install/local.js +0 -65
  191. package/src/install/main.js +0 -103
  192. package/src/install/missing.js +0 -86
  193. package/src/log/colors.js +0 -59
  194. package/src/log/description.js +0 -38
  195. package/src/log/header.js +0 -19
  196. package/src/log/logger.js +0 -55
  197. package/src/log/main.js +0 -348
  198. package/src/log/old_version.js +0 -45
  199. package/src/log/serialize.js +0 -15
  200. package/src/log/stream.js +0 -15
  201. package/src/log/theme.js +0 -32
  202. package/src/log/timer.js +0 -28
  203. package/src/plugins/child/api.js +0 -59
  204. package/src/plugins/child/error.js +0 -39
  205. package/src/plugins/child/load.js +0 -40
  206. package/src/plugins/child/logic.js +0 -31
  207. package/src/plugins/child/main.js +0 -48
  208. package/src/plugins/child/normalize.js +0 -20
  209. package/src/plugins/child/run.js +0 -34
  210. package/src/plugins/child/status.js +0 -53
  211. package/src/plugins/child/utils.js +0 -43
  212. package/src/plugins/child/validate.js +0 -46
  213. package/src/plugins/error.js +0 -44
  214. package/src/plugins/events.js +0 -77
  215. package/src/plugins/ipc.js +0 -136
  216. package/src/plugins/load.js +0 -66
  217. package/src/plugins/manifest/check.js +0 -80
  218. package/src/plugins/manifest/load.js +0 -47
  219. package/src/plugins/manifest/main.js +0 -28
  220. package/src/plugins/manifest/path.js +0 -12
  221. package/src/plugins/manifest/validate.js +0 -136
  222. package/src/plugins/node_version.js +0 -74
  223. package/src/plugins/options.js +0 -78
  224. package/src/plugins/package.js +0 -17
  225. package/src/plugins/resolve.js +0 -159
  226. package/src/plugins/spawn.js +0 -82
  227. package/src/plugins_core/cache/manifest.yml +0 -1
  228. package/src/plugins_core/cache/plugin.js +0 -75
  229. package/src/plugins_core/functions/manifest.yml +0 -1
  230. package/src/plugins_core/functions/plugin.js +0 -37
  231. package/src/plugins_core/functions_install/plugin.js +0 -14
  232. package/src/plugins_core/main.js +0 -38
  233. package/src/status/add.js +0 -56
  234. package/src/status/colors.js +0 -25
  235. package/src/status/report.js +0 -57
  236. package/src/telemetry/complete.js +0 -49
  237. package/src/telemetry/request.js +0 -28
  238. package/src/telemetry/track.js +0 -33
  239. package/src/utils/omit.js +0 -8
  240. package/src/utils/polyfills.js +0 -3
  241. package/src/utils/remove_falsy.js +0 -12
  242. package/src/utils/resolve.js +0 -39
  243. /package/{src → lib}/plugins_core/functions_install/manifest.yml +0 -0
@@ -1,75 +0,0 @@
1
- const { homedir } = require('os')
2
- const {
3
- version,
4
- env: { TEST_CACHE_PATH },
5
- } = require('process')
6
-
7
- const { logCacheDir } = require('../../log/main')
8
-
9
- // Save/restore cache core plugin
10
- const cachePlugin = {
11
- async onPostBuild({ utils: { cache }, constants: { IS_LOCAL } }) {
12
- await Promise.all(ARTIFACTS.map(({ path, digests }) => saveCache({ path, digests, cache, IS_LOCAL })))
13
- },
14
- }
15
-
16
- // Cache a single directory
17
- const saveCache = async function({ path, digests, cache, IS_LOCAL }) {
18
- // In tests we don't run caching since it is slow and make source directory
19
- // much bigger
20
- if (TEST_CACHE_PATH !== undefined && TEST_CACHE_PATH !== path) {
21
- return
22
- }
23
-
24
- const success = await cache.save(path, { move: !IS_LOCAL, digests })
25
-
26
- if (success) {
27
- logCacheDir(path)
28
- }
29
- }
30
-
31
- // List of directories to cache
32
- const HOME = homedir()
33
- const ARTIFACTS = [
34
- // Node modules
35
- { path: 'node_modules', digests: ['package-lock.json', 'yarn.lock'] },
36
- // Bower components
37
- { path: 'bower_components' },
38
- // Ruby gems
39
- { path: '.bundle' },
40
- // Python virtualenv
41
- { path: '.venv' },
42
- // WAPM packages (WebAssembly)
43
- { path: 'wapm_packages' },
44
- // Yarn
45
- { path: `${HOME}/.yarn_cache` },
46
- // Pip
47
- { path: `${HOME}/.cache/pip` },
48
- // Emacs cask
49
- { path: `${HOME}/.cask` },
50
- // Emacs
51
- { path: `${HOME}/.emacs.d` },
52
- // Maven
53
- { path: `${HOME}/.m2` },
54
- // Boot
55
- { path: `${HOME}/.boot` },
56
- // Composer
57
- { path: `${HOME}/.composer` },
58
- // Wasmer
59
- { path: `${HOME}/.wasmer/cache` },
60
- // Go dependencies
61
- { path: `${HOME}/.gimme_cache` },
62
- // TODO: the buildbot currently uses different file paths. Once Netlify Build
63
- // handles both saving cache and restoring cache, this should not be an issue
64
- // anymore.
65
- // CACHE_DIR/node_version -> CACHE_DIR/.nvm/versions/node[/$NODE_VERSION]
66
- // CACHE_DIR/ruby_version -> CACHE_DIR/.rvm/rubies[/ruby-$RUBY_VERSION]
67
- // nvm
68
- { path: `${HOME}/.nvm/versions/node/${version}` },
69
- // TODO: only cache rvm when the version is not already in the Docker image,
70
- // i.e. it is a custom version
71
- // rvm
72
- { path: `${HOME}/.rvm/rubies` },
73
- ]
74
-
75
- module.exports = cachePlugin
@@ -1 +0,0 @@
1
- name: '@netlify/plugin-functions-core'
@@ -1,37 +0,0 @@
1
- const { zipFunctions } = require('@netlify/zip-it-and-ship-it')
2
- const pathExists = require('path-exists')
3
- const readdirp = require('readdirp')
4
-
5
- const { serializeArray } = require('../../log/serialize')
6
-
7
- // Plugin to package Netlify functions with @netlify/zip-it-and-ship-it
8
- const onPostBuild = async function({ constants: { FUNCTIONS_SRC, FUNCTIONS_DIST } }) {
9
- if (!(await pathExists(FUNCTIONS_SRC))) {
10
- return
11
- }
12
-
13
- console.log(`Packaging functions from ${FUNCTIONS_SRC}`)
14
- await zipFunctions(FUNCTIONS_SRC, FUNCTIONS_DIST)
15
-
16
- await logResults(FUNCTIONS_DIST)
17
- }
18
-
19
- // Print the list of paths to the packaged functions
20
- const logResults = async function(FUNCTIONS_DIST) {
21
- const files = await readdirp.promise(FUNCTIONS_DIST)
22
-
23
- if (files.length === 0) {
24
- console.log('No functions were packaged')
25
- return
26
- }
27
-
28
- const paths = files.map(getLoggedPath)
29
- console.log(`Functions packaged in ${FUNCTIONS_DIST}
30
- ${serializeArray(paths)}`)
31
- }
32
-
33
- const getLoggedPath = function({ path }) {
34
- return path
35
- }
36
-
37
- module.exports = { onPostBuild }
@@ -1,14 +0,0 @@
1
- const pathExists = require('path-exists')
2
-
3
- const { installFunctionDependencies } = require('../../install/functions')
4
-
5
- // Plugin to package Netlify functions with @netlify/zip-it-and-ship-it
6
- const onPreBuild = async function({ constants: { FUNCTIONS_SRC, IS_LOCAL } }) {
7
- if (!(await pathExists(FUNCTIONS_SRC))) {
8
- return
9
- }
10
-
11
- await installFunctionDependencies(FUNCTIONS_SRC, IS_LOCAL)
12
- }
13
-
14
- module.exports = { onPreBuild }
@@ -1,38 +0,0 @@
1
- const {
2
- env: { TEST_CACHE_PATH },
3
- } = require('process')
4
-
5
- const FUNCTIONS_INSTALL_PLUGIN = `${__dirname}/functions_install/plugin.js`
6
- const FUNCTIONS_PLUGIN = `${__dirname}/functions/plugin.js`
7
- const CACHE_PLUGIN = `${__dirname}/cache/plugin.js`
8
-
9
- const { LOCAL_INSTALL_NAME } = require('../install/local')
10
-
11
- // Plugins that are installed and enabled by default
12
- const getCorePlugins = FUNCTIONS_SRC => [
13
- // When no "Functions directory" is defined, it means users does not use
14
- // Netlify Functions.
15
- // However when it is defined but points to a non-existing directory, this
16
- // might mean the directory is created later one, so we cannot do that check
17
- // yet.
18
- ...(FUNCTIONS_SRC === undefined
19
- ? []
20
- : [{ package: '@netlify/plugin-functions-install-core', pluginPath: FUNCTIONS_INSTALL_PLUGIN }]),
21
- ...(FUNCTIONS_SRC === undefined ? [] : [{ package: '@netlify/plugin-functions-core', pluginPath: FUNCTIONS_PLUGIN }]),
22
- // TODO: run only inside tests until integrated in the buildbot
23
- ...(TEST_CACHE_PATH === undefined || TEST_CACHE_PATH === 'none'
24
- ? []
25
- : [{ package: '@netlify/plugin-cache-core', pluginPath: CACHE_PLUGIN }]),
26
- ]
27
-
28
- const CORE_PLUGINS = [
29
- '@netlify/plugin-functions-install-core',
30
- '@netlify/plugin-functions-core',
31
- '@netlify/plugin-cache-core',
32
- ]
33
-
34
- // Those core plugins cannot be handled like regular plugins because they must
35
- // be run before plugin child processes start
36
- const EARLY_CORE_PLUGINS = [LOCAL_INSTALL_NAME]
37
-
38
- module.exports = { getCorePlugins, CORE_PLUGINS, EARLY_CORE_PLUGINS }
package/src/status/add.js DELETED
@@ -1,56 +0,0 @@
1
- // The last event handler of a plugin (except for `onError` and `onEnd`)
2
- // defaults to `utils.status.show({ state: 'success' })` without any `summary`.
3
- const getSuccessStatus = function(newStatus, { commands, event, package }) {
4
- if (newStatus === undefined && isLastMainCommand({ commands, event, package })) {
5
- return IMPLICIT_STATUS
6
- }
7
-
8
- return newStatus
9
- }
10
-
11
- const isLastMainCommand = function({ commands, event, package }) {
12
- const mainCommands = commands.filter(command => command.package === package && isMainCommand(command))
13
- return mainCommands.length === 0 || mainCommands[mainCommands.length - 1].event === event
14
- }
15
-
16
- const isMainCommand = function({ event }) {
17
- return event !== 'onEnd' && event !== 'onError'
18
- }
19
-
20
- const IMPLICIT_STATUS = { state: 'success', implicit: true }
21
-
22
- // Merge plugin status to the list of plugin statuses.
23
- const addStatus = function({ newStatus, statuses, event, package, packageJson: { version } = {} }) {
24
- // Either:
25
- // - `build.command`
26
- // - no status was set
27
- if (newStatus === undefined) {
28
- return statuses
29
- }
30
-
31
- const formerStatus = statuses.find(status => status.package === package)
32
- if (!canOverrideStatus(formerStatus, newStatus)) {
33
- return statuses
34
- }
35
-
36
- // Overrides plugin's previous status and add more information
37
- const newStatuses = statuses.filter(status => status !== formerStatus)
38
- return [...newStatuses, { ...newStatus, event, package, version }]
39
- }
40
-
41
- const canOverrideStatus = function(formerStatus, newStatus) {
42
- // No previous status
43
- if (formerStatus === undefined) {
44
- return true
45
- }
46
-
47
- // Implicit statuses can never override
48
- if (newStatus.implicit) {
49
- return false
50
- }
51
-
52
- // Error statuses can only be overwritten by other error statuses
53
- return formerStatus.state === 'success' || newStatus.state !== 'success'
54
- }
55
-
56
- module.exports = { getSuccessStatus, addStatus }
@@ -1,25 +0,0 @@
1
- const stripAnsi = require('strip-ansi')
2
-
3
- // Remove colors from statuses
4
- const removeStatusesColors = function(statuses) {
5
- return statuses.map(removeStatusColors)
6
- }
7
-
8
- const removeStatusColors = function(status) {
9
- const attributes = COLOR_ATTRIBUTES.map(attribute => removeAttrColor(status, attribute))
10
- return Object.assign({}, status, ...attributes)
11
- }
12
-
13
- const COLOR_ATTRIBUTES = ['title', 'summary', 'text']
14
-
15
- const removeAttrColor = function(status, attribute) {
16
- const value = status[attribute]
17
- if (value === undefined) {
18
- return {}
19
- }
20
-
21
- const valueA = stripAnsi(value)
22
- return { [attribute]: valueA }
23
- }
24
-
25
- module.exports = { removeStatusesColors }
@@ -1,57 +0,0 @@
1
- const { env } = require('process')
2
-
3
- const { serializeErrorStatus } = require('../error/parse/serialize_status')
4
- const { logStatuses } = require('../log/main')
5
-
6
- const { removeStatusesColors } = require('./colors')
7
-
8
- // Errors that happen during plugin loads should be reported as error statuses
9
- const reportPluginLoadError = async function({ error, api, mode, event, package, version }) {
10
- const errorStatus = serializeErrorStatus(error)
11
- const statuses = [{ ...errorStatus, event, package, version }]
12
- await reportStatuses(statuses, api, mode)
13
- }
14
-
15
- const reportStatuses = async function(statuses, api, mode) {
16
- const statusesA = removeStatusesColors(statuses)
17
- printStatuses(statusesA, mode)
18
- await sendStatuses(statusesA, api, mode)
19
- }
20
-
21
- // When not in production, print statuses to console.
22
- // Only print successful ones, since errors are logged afterwards.
23
- const printStatuses = function(statuses, mode) {
24
- if (mode === 'buildbot') {
25
- return
26
- }
27
-
28
- const successStatuses = statuses.filter(shouldPrintStatus)
29
-
30
- if (successStatuses.length === 0) {
31
- return
32
- }
33
-
34
- logStatuses(successStatuses)
35
- }
36
-
37
- const shouldPrintStatus = function({ state, summary }) {
38
- return state === 'success' && summary !== undefined
39
- }
40
-
41
- // In production, send statuses to the API
42
- const sendStatuses = async function(statuses, api, mode) {
43
- if ((mode !== 'buildbot' && env.NETLIFY_BUILD_TEST_STATUS !== '1') || api === undefined || !env.DEPLOY_ID) {
44
- return
45
- }
46
-
47
- await Promise.all(statuses.map(status => sendStatus(api, status)))
48
- }
49
-
50
- const sendStatus = async function(api, { package, version, state, event, title, summary, text }) {
51
- await api.createPluginRun({
52
- deploy_id: env.DEPLOY_ID,
53
- body: { package, version, state, reporting_event: event, title, summary, text },
54
- })
55
- }
56
-
57
- module.exports = { reportPluginLoadError, reportStatuses }
@@ -1,49 +0,0 @@
1
- const { platform, version: nodeVersion } = require('process')
2
-
3
- const isCI = require('is-ci')
4
- const osName = require('os-name')
5
-
6
- const { version } = require('../../package.json')
7
-
8
- const { telemetry } = require('./track')
9
-
10
- // Send telemetry request when build completes
11
- const trackBuildComplete = async function({ commandsCount, netlifyConfig, duration, siteInfo, mode }) {
12
- const payload = getPayload({ commandsCount, netlifyConfig, duration, siteInfo, mode })
13
- await telemetry.track('netlifyCI:buildComplete', payload)
14
- }
15
-
16
- // Retrieve telemetry information
17
- const getPayload = function({ commandsCount, netlifyConfig, duration, siteInfo: { id: siteId }, mode }) {
18
- const plugins = Object.values(netlifyConfig.plugins).map(getPluginPackage)
19
- return {
20
- steps: commandsCount,
21
- duration,
22
- pluginCount: plugins.length,
23
- plugins,
24
- siteId,
25
- isCI,
26
- isNetlifyCI: mode === 'buildbot',
27
- buildVersion: version,
28
- nodeVersion: nodeVersion.replace('v', ''),
29
- osPlatform: OS_TYPES[platform],
30
- osName: osName(),
31
- }
32
- }
33
-
34
- const getPluginPackage = function({ package }) {
35
- return package
36
- }
37
-
38
- const OS_TYPES = {
39
- linux: 'Linux',
40
- darwin: 'MacOS',
41
- win32: 'Windows',
42
- android: 'Android',
43
- sunos: 'SunOS',
44
- aix: 'AIX',
45
- freebsd: 'FreeBSD',
46
- openbsd: 'OpenBSD',
47
- }
48
-
49
- module.exports = { trackBuildComplete }
@@ -1,28 +0,0 @@
1
- const {
2
- env: { TEST_SCHEME, TEST_HOST },
3
- argv,
4
- } = require('process')
5
-
6
- const got = require('got')
7
-
8
- const { version } = require('../../package.json')
9
-
10
- // Send HTTP request to telemetry.
11
- const sendRequest = async function() {
12
- const json = JSON.parse(argv[2])
13
- await got({ ...GOT_OPTS, json: true, body: json })
14
- }
15
-
16
- // TODO: find less intrusive way to mock HTTP requests
17
- const SCHEME = TEST_SCHEME || 'https'
18
- const HOST = TEST_HOST || 'telemetry-service.netlify.com'
19
- const GOT_OPTS = {
20
- url: `${SCHEME}://${HOST}/collect`,
21
- method: 'POST',
22
- headers: {
23
- 'X-Netlify-Client': 'NETLIFY_CI',
24
- 'X-Netlify-Client-Version': version,
25
- },
26
- }
27
-
28
- sendRequest()
@@ -1,33 +0,0 @@
1
- const {
2
- env: { BUILD_TELEMETRY_DISABLED, TEST_HOST },
3
- } = require('process')
4
-
5
- const Analytics = require('analytics').default
6
- const execa = require('execa')
7
-
8
- const { version } = require('../../package.json')
9
- const REQUEST_FILE = `${__dirname}/request.js`
10
-
11
- // Send HTTP request to telemetry.
12
- // Telemetry should not impact build speed, so we do not wait for the request
13
- // to complete, by using a child process.
14
- const track = async function({ payload }) {
15
- if (BUILD_TELEMETRY_DISABLED) {
16
- return
17
- }
18
-
19
- const childProcess = execa('node', [REQUEST_FILE, JSON.stringify(payload)], { detached: true, stdio: 'ignore' })
20
-
21
- // During tests, we wait for the HTTP request to complete
22
- if (TEST_HOST !== undefined) {
23
- await childProcess
24
- }
25
- }
26
-
27
- const telemetry = Analytics({
28
- app: 'netlifyCI',
29
- version,
30
- plugins: [{ NAMESPACE: 'netlify-telemetry', track }],
31
- })
32
-
33
- module.exports = { telemetry }
package/src/utils/omit.js DELETED
@@ -1,8 +0,0 @@
1
- const filterObj = require('filter-obj')
2
-
3
- // lodash.omit is 1400 lines of codes. filter-obj is much smaller and simpler.
4
- const omit = function(obj, keys) {
5
- return filterObj(obj, key => !keys.includes(key))
6
- }
7
-
8
- module.exports = { omit }
@@ -1,3 +0,0 @@
1
- // Patches `Array.flat()` and `Array.flatMap()`
2
- // TODO: remove after dropping Node <12 support
3
- require('array-flat-polyfill')
@@ -1,12 +0,0 @@
1
- const filterObj = require('filter-obj')
2
-
3
- // Remove falsy values from object
4
- const removeFalsy = function(obj) {
5
- return filterObj(obj, isDefined)
6
- }
7
-
8
- const isDefined = function(key, value) {
9
- return value !== undefined && value !== ''
10
- }
11
-
12
- module.exports = { removeFalsy }
@@ -1,39 +0,0 @@
1
- const { version: nodeVersion } = require('process')
2
-
3
- const resolve = require('resolve')
4
- const { gte: gteVersion } = require('semver')
5
-
6
- // This throws if the package cannot be found
7
- // We try not to use `resolve` because it gives unhelpful error messages.
8
- // https://github.com/browserify/resolve/issues/223
9
- // Ideally we would use async I/O but that is not an option with
10
- // `require.resolve()`
11
- const resolvePath = function(path, basedir) {
12
- if (gteVersion(nodeVersion, REQUEST_RESOLVE_MIN_VERSION)) {
13
- return require.resolve(path, { paths: [basedir] })
14
- }
15
-
16
- return resolvePathFallback(path, basedir)
17
- }
18
-
19
- // `require.resolve()` option `paths` was introduced in Node 8.9.0
20
- const REQUEST_RESOLVE_MIN_VERSION = '8.9.0'
21
-
22
- // Like `require.resolve()` but works with Node <8.9.0
23
- // TODO: remove after dropping support for Node <8.9.0
24
- // We need to use `new Promise()` due to a bug with `utils.promisify()` on
25
- // `resolve`:
26
- // https://github.com/browserify/resolve/issues/151#issuecomment-368210310
27
- const resolvePathFallback = function(path, basedir) {
28
- return new Promise((success, reject) => {
29
- resolve(path, { basedir }, (error, resolvedPath) => {
30
- if (error) {
31
- return reject(error)
32
- }
33
-
34
- success(resolvedPath)
35
- })
36
- })
37
- }
38
-
39
- module.exports = { resolvePath }