@netlify/build 18.8.0 → 18.9.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/build",
3
- "version": "18.8.0",
3
+ "version": "18.9.0",
4
4
  "description": "Netlify build module",
5
5
  "main": "src/core/main.js",
6
6
  "bin": {
@@ -18,7 +18,7 @@ const getFeatureFlag = function (name) {
18
18
  // Default values for feature flags
19
19
  const DEFAULT_FEATURE_FLAGS = {
20
20
  zisiEsbuildDynamicImports: env.NETLIFY_EXPERIMENTAL_PROCESS_DYNAMIC_IMPORTS === 'true',
21
- buildbot_build_plugins_system_node_version: false,
21
+ netlify_build_warning_missing_headers: false,
22
22
  }
23
23
 
24
24
  module.exports = { normalizeCliFeatureFlags, DEFAULT_FEATURE_FLAGS }
package/src/core/main.js CHANGED
@@ -24,6 +24,7 @@ const { getConfigOpts, loadConfig } = require('./config')
24
24
  const { getConstants } = require('./constants')
25
25
  const { doDryRun } = require('./dry')
26
26
  const { warnOnLingeringProcesses } = require('./lingering')
27
+ const { warnOnMissingSideFiles } = require('./missing_side_file')
27
28
  const { normalizeFlags } = require('./normalize_flags')
28
29
  const { getSeverity } = require('./severity')
29
30
 
@@ -528,7 +529,10 @@ const initAndRunBuild = async function ({
528
529
  featureFlags,
529
530
  })
530
531
 
531
- await warnOnLingeringProcesses({ mode, logs, testOpts })
532
+ await Promise.all([
533
+ warnOnMissingSideFiles({ buildDir, netlifyConfig: netlifyConfigA, logs, featureFlags }),
534
+ warnOnLingeringProcesses({ mode, logs, testOpts }),
535
+ ])
532
536
 
533
537
  return {
534
538
  commandsCount,
@@ -0,0 +1,38 @@
1
+ 'use strict'
2
+
3
+ const { relative } = require('path')
4
+
5
+ const pathExists = require('path-exists')
6
+
7
+ const { logMissingSideFile } = require('../log/messages/core')
8
+
9
+ // Some files like `_headers` and `_redirects` must be copied to the publish
10
+ // directory to be used in production. When those are present in the repository
11
+ // but not in the publish directory, this most likely indicates that the build
12
+ // command accidentally forgot to copy those. We then print a warning message.
13
+ const warnOnMissingSideFiles = async function ({
14
+ buildDir,
15
+ netlifyConfig: {
16
+ build: { publish },
17
+ },
18
+ logs,
19
+ featureFlags,
20
+ }) {
21
+ if (!featureFlags.netlify_build_warning_missing_headers) {
22
+ return
23
+ }
24
+
25
+ await Promise.all(SIDE_FILES.map((sideFile) => warnOnMissingSideFile({ logs, sideFile, buildDir, publish })))
26
+ }
27
+
28
+ const SIDE_FILES = ['_headers', '_redirects']
29
+
30
+ const warnOnMissingSideFile = async function ({ logs, sideFile, buildDir, publish }) {
31
+ if (!(await pathExists(`${buildDir}/${sideFile}`)) || (await pathExists(`${publish}/${sideFile}`))) {
32
+ return
33
+ }
34
+
35
+ logMissingSideFile(logs, sideFile, relative(buildDir, publish))
36
+ }
37
+
38
+ module.exports = { warnOnMissingSideFiles }
@@ -42,6 +42,14 @@ const logTimer = function (logs, durationNs, timerName) {
42
42
  log(logs, THEME.dimWords(`(${timerName} completed in ${duration})`))
43
43
  }
44
44
 
45
+ const logMissingSideFile = function (logs, sideFile, publish) {
46
+ logWarning(
47
+ logs,
48
+ `
49
+ A "${sideFile}" file is present in the repository but is missing in the publish directory "${publish}".`,
50
+ )
51
+ }
52
+
45
53
  // @todo use `terminal-link` (https://github.com/sindresorhus/terminal-link)
46
54
  // instead of `ansi-escapes` once
47
55
  // https://github.com/jamestalmage/supports-hyperlinks/pull/12 is fixed
@@ -68,5 +76,6 @@ module.exports = {
68
76
  logBuildError,
69
77
  logBuildSuccess,
70
78
  logTimer,
79
+ logMissingSideFile,
71
80
  logLingeringProcesses,
72
81
  }