@netlify/build 25.0.2 → 25.0.3
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 +1 -1
- package/src/core/constants.js +2 -2
- package/src/error/monitor/start.js +3 -3
- package/src/log/messages/core.js +2 -2
- package/src/log/old_version.js +3 -3
- package/src/plugins/compatibility.js +2 -2
- package/src/plugins/expected_version.js +2 -2
- package/src/plugins/node_version.js +2 -4
- package/src/plugins/options.js +3 -4
- package/src/telemetry/main.js +2 -2
- package/src/utils/json.js +22 -0
package/package.json
CHANGED
package/src/core/constants.js
CHANGED
|
@@ -5,7 +5,7 @@ const { relative, normalize } = require('path')
|
|
|
5
5
|
const mapObj = require('map-obj')
|
|
6
6
|
const pathExists = require('path-exists')
|
|
7
7
|
|
|
8
|
-
const {
|
|
8
|
+
const { ROOT_PACKAGE_JSON } = require('../utils/json')
|
|
9
9
|
|
|
10
10
|
const cacheUtilsPromise = import('@netlify/cache-utils')
|
|
11
11
|
|
|
@@ -35,7 +35,7 @@ const getConstants = async function ({
|
|
|
35
35
|
// Boolean indicating whether the build was run locally (Netlify CLI) or in the production CI
|
|
36
36
|
IS_LOCAL: isLocal,
|
|
37
37
|
// The version of Netlify Build
|
|
38
|
-
NETLIFY_BUILD_VERSION: version,
|
|
38
|
+
NETLIFY_BUILD_VERSION: ROOT_PACKAGE_JSON.version,
|
|
39
39
|
// The Netlify Site ID
|
|
40
40
|
SITE_ID: siteId,
|
|
41
41
|
// The Netlify API access token
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
const Bugsnag = require('@bugsnag/js')
|
|
4
4
|
const memoizeOne = require('memoize-one')
|
|
5
5
|
|
|
6
|
-
const { name, version } = require('../../../package.json')
|
|
7
6
|
const { log } = require('../../log/logger')
|
|
7
|
+
const { ROOT_PACKAGE_JSON } = require('../../utils/json')
|
|
8
8
|
|
|
9
9
|
const projectRoot = `${__dirname}/../../..`
|
|
10
10
|
|
|
@@ -20,8 +20,8 @@ const startErrorMonitor = function ({ flags: { mode }, logs, bugsnagKey }) {
|
|
|
20
20
|
try {
|
|
21
21
|
const errorMonitor = startBugsnag({
|
|
22
22
|
apiKey: bugsnagKey,
|
|
23
|
-
appVersion: `${name} ${version}`,
|
|
24
|
-
appType: name,
|
|
23
|
+
appVersion: `${ROOT_PACKAGE_JSON.name} ${ROOT_PACKAGE_JSON.version}`,
|
|
24
|
+
appType: ROOT_PACKAGE_JSON.name,
|
|
25
25
|
releaseStage,
|
|
26
26
|
logger,
|
|
27
27
|
projectRoot,
|
package/src/log/messages/core.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
const { link } = require('ansi-escapes')
|
|
4
4
|
const prettyMs = require('pretty-ms')
|
|
5
5
|
|
|
6
|
-
const { name, version } = require('../../../package.json')
|
|
7
6
|
const { getFullErrorInfo } = require('../../error/parse/parse')
|
|
8
7
|
const { serializeLogError } = require('../../error/parse/serialize_log')
|
|
9
8
|
const { roundTimerToMillisecs } = require('../../time/measure')
|
|
9
|
+
const { ROOT_PACKAGE_JSON } = require('../../utils/json')
|
|
10
10
|
const { getLogHeaderFunc } = require('../header_func')
|
|
11
11
|
const { log, logMessage, logWarning, logHeader, logSubHeader, logWarningArray } = require('../logger')
|
|
12
12
|
const { logOldCliVersionError } = require('../old_version')
|
|
@@ -17,7 +17,7 @@ const { logConfigOnError } = require('./config')
|
|
|
17
17
|
const logBuildStart = function (logs) {
|
|
18
18
|
logHeader(logs, 'Netlify Build')
|
|
19
19
|
logSubHeader(logs, 'Version')
|
|
20
|
-
logMessage(logs, `${name} ${version}`)
|
|
20
|
+
logMessage(logs, `${ROOT_PACKAGE_JSON.name} ${ROOT_PACKAGE_JSON.version}`)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const logBuildError = async function ({ error, netlifyConfig, mode, logs, debug, testOpts }) {
|
package/src/log/old_version.js
CHANGED
|
@@ -4,7 +4,7 @@ const { stdout } = require('process')
|
|
|
4
4
|
|
|
5
5
|
const UpdateNotifier = require('update-notifier')
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const { ROOT_PACKAGE_JSON } = require('../utils/json')
|
|
8
8
|
|
|
9
9
|
// Many build errors happen in local builds that do not use the latest version
|
|
10
10
|
// of `@netlify/build`. We print a warning message on those.
|
|
@@ -32,10 +32,10 @@ const getCorePackageJson = function (testOpts) {
|
|
|
32
32
|
// eslint-disable-next-line fp/no-mutation
|
|
33
33
|
stdout.isTTY = true
|
|
34
34
|
|
|
35
|
-
return { ...
|
|
35
|
+
return { ...ROOT_PACKAGE_JSON, version: '0.0.1' }
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
return
|
|
38
|
+
return ROOT_PACKAGE_JSON
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const OLD_VERSION_MESSAGE = `Please update netlify-cli to its latest version.
|
|
@@ -3,6 +3,7 @@ const pEvery = require('p-every')
|
|
|
3
3
|
const pLocate = require('p-locate')
|
|
4
4
|
const { satisfies, clean: cleanVersion } = require('semver')
|
|
5
5
|
|
|
6
|
+
const { importJsonFile } = require('../utils/json')
|
|
6
7
|
const { resolvePath } = require('../utils/resolve')
|
|
7
8
|
|
|
8
9
|
// Retrieve the `expectedVersion` of a plugin:
|
|
@@ -107,8 +108,7 @@ const siteDependencyTest = async function ({ dependencyName, allowedVersion, sit
|
|
|
107
108
|
try {
|
|
108
109
|
// if this is a range we need to get the exact version
|
|
109
110
|
const packageJsonPath = await resolvePath(`${dependencyName}/package.json`, buildDir)
|
|
110
|
-
|
|
111
|
-
const { version } = require(packageJsonPath)
|
|
111
|
+
const { version } = await importJsonFile(packageJsonPath)
|
|
112
112
|
return satisfies(version, allowedVersion)
|
|
113
113
|
} catch (error) {
|
|
114
114
|
return false
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const { satisfies } = require('semver')
|
|
4
4
|
|
|
5
5
|
const { addErrorInfo } = require('../error/info')
|
|
6
|
+
const { importJsonFile } = require('../utils/json')
|
|
6
7
|
const { resolvePath } = require('../utils/resolve')
|
|
7
8
|
|
|
8
9
|
const { getExpectedVersion } = require('./compatibility')
|
|
@@ -95,8 +96,7 @@ const isMissingVersion = async function ({ autoPluginsDir, packageName, pluginPa
|
|
|
95
96
|
|
|
96
97
|
const getAutoPluginVersion = async function (packageName, autoPluginsDir) {
|
|
97
98
|
const packageJsonPath = await resolvePath(`${packageName}/package.json`, autoPluginsDir)
|
|
98
|
-
|
|
99
|
-
const { version } = require(packageJsonPath)
|
|
99
|
+
const { version } = await importJsonFile(packageJsonPath)
|
|
100
100
|
return version
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -4,10 +4,8 @@ const { version: currentVersion, execPath } = require('process')
|
|
|
4
4
|
|
|
5
5
|
const { satisfies, clean: cleanVersion } = require('semver')
|
|
6
6
|
|
|
7
|
-
const {
|
|
8
|
-
engines: { node: nodeVersionSupportedRange },
|
|
9
|
-
} = require('../../package.json')
|
|
10
7
|
const { addErrorInfo } = require('../error/info')
|
|
8
|
+
const { ROOT_PACKAGE_JSON } = require('../utils/json')
|
|
11
9
|
|
|
12
10
|
// Local plugins and `package.json`-installed plugins use user's preferred Node.js version if higher than our minimum
|
|
13
11
|
// supported version. Else default to the system Node version.
|
|
@@ -29,7 +27,7 @@ const addPluginNodeVersion = function ({
|
|
|
29
27
|
nodePath,
|
|
30
28
|
}) {
|
|
31
29
|
return (loadedFrom === 'local' || loadedFrom === 'package.json') &&
|
|
32
|
-
satisfies(userNodeVersion,
|
|
30
|
+
satisfies(userNodeVersion, ROOT_PACKAGE_JSON.engines.node)
|
|
33
31
|
? { ...pluginOptions, nodePath, nodeVersion: userNodeVersion }
|
|
34
32
|
: { ...pluginOptions, nodePath: execPath, nodeVersion: currentNodeVersion }
|
|
35
33
|
}
|
package/src/plugins/options.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const { dirname } = require('path')
|
|
4
4
|
|
|
5
|
-
const corePackageJson = require('../../package.json')
|
|
6
5
|
const { installLocalPluginsDependencies } = require('../install/local')
|
|
7
6
|
const { measureDuration } = require('../time/main')
|
|
7
|
+
const { ROOT_PACKAGE_JSON } = require('../utils/json')
|
|
8
8
|
const { getPackageJson } = require('../utils/package')
|
|
9
9
|
|
|
10
10
|
const { useManifest } = require('./manifest/main')
|
|
@@ -83,10 +83,9 @@ const isNotRedundantCorePlugin = function (pluginOptionsA, index, pluginsOptions
|
|
|
83
83
|
// Retrieve information about @netlify/build when an error happens there and not
|
|
84
84
|
// in a plugin
|
|
85
85
|
const getSpawnInfo = function () {
|
|
86
|
-
const { name } = corePackageJson
|
|
87
86
|
return {
|
|
88
|
-
plugin: { packageName: name, pluginPackageJson:
|
|
89
|
-
location: { event: 'load', packageName: name, loadedFrom: 'core', origin: 'core' },
|
|
87
|
+
plugin: { packageName: ROOT_PACKAGE_JSON.name, pluginPackageJson: ROOT_PACKAGE_JSON },
|
|
88
|
+
location: { event: 'load', packageName: ROOT_PACKAGE_JSON.name, loadedFrom: 'core', origin: 'core' },
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
91
|
|
package/src/telemetry/main.js
CHANGED
|
@@ -5,9 +5,9 @@ const { platform } = require('process')
|
|
|
5
5
|
const got = require('got')
|
|
6
6
|
const osName = require('os-name')
|
|
7
7
|
|
|
8
|
-
const { version: buildVersion } = require('../../package.json')
|
|
9
8
|
const { addErrorInfo } = require('../error/info')
|
|
10
9
|
const { roundTimerToMillisecs } = require('../time/measure')
|
|
10
|
+
const { ROOT_PACKAGE_JSON } = require('../utils/json')
|
|
11
11
|
|
|
12
12
|
const DEFAULT_TELEMETRY_TIMEOUT = 1200
|
|
13
13
|
const DEFAULT_TELEMETRY_CONFIG = {
|
|
@@ -89,7 +89,7 @@ const getPayload = function ({
|
|
|
89
89
|
buildId,
|
|
90
90
|
status,
|
|
91
91
|
steps: stepsCount,
|
|
92
|
-
buildVersion,
|
|
92
|
+
buildVersion: ROOT_PACKAGE_JSON.version,
|
|
93
93
|
// We're passing the node version set by the buildbot/user which will run the `build.command` and
|
|
94
94
|
// the `package.json`/locally defined plugins
|
|
95
95
|
nodeVersion: userNodeVersion,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { promises: fs, readFileSync } = require('fs')
|
|
4
|
+
|
|
5
|
+
const ROOT_PACKAGE_JSON_PATH = `${__dirname}/../../package.json`
|
|
6
|
+
|
|
7
|
+
// TODO: Replace with dynamic `import()` once it is supported without
|
|
8
|
+
// experimental flags
|
|
9
|
+
const importJsonFile = async function (filePath) {
|
|
10
|
+
const fileContents = await fs.readFile(filePath, 'utf8')
|
|
11
|
+
return JSON.parse(fileContents)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const importJsonFileSync = function (filePath) {
|
|
15
|
+
// Use sync I/O so it is easier to migrate to `import()` later on
|
|
16
|
+
const fileContents = readFileSync(filePath, 'utf8')
|
|
17
|
+
return JSON.parse(fileContents)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const ROOT_PACKAGE_JSON = importJsonFileSync(ROOT_PACKAGE_JSON_PATH)
|
|
21
|
+
|
|
22
|
+
module.exports = { importJsonFile, ROOT_PACKAGE_JSON }
|