@netlify/config 17.0.17 → 17.0.18
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/env/main.js +21 -7
- package/src/options/main.js +6 -1
package/package.json
CHANGED
package/src/env/main.js
CHANGED
|
@@ -68,7 +68,8 @@ export const getEnv = async function ({
|
|
|
68
68
|
// Environment variables not set by users, but meant to mimic the production
|
|
69
69
|
// environment.
|
|
70
70
|
const getGeneralEnv = async function ({
|
|
71
|
-
siteInfo
|
|
71
|
+
siteInfo,
|
|
72
|
+
siteInfo: { id, name },
|
|
72
73
|
buildDir,
|
|
73
74
|
branch,
|
|
74
75
|
deployId,
|
|
@@ -76,13 +77,13 @@ const getGeneralEnv = async function ({
|
|
|
76
77
|
context,
|
|
77
78
|
}) {
|
|
78
79
|
const gitEnv = await getGitEnv(buildDir, branch)
|
|
80
|
+
const deployUrls = getDeployUrls({ siteInfo, branch, deployId })
|
|
79
81
|
return removeFalsy({
|
|
80
82
|
SITE_ID: id,
|
|
81
83
|
SITE_NAME: name,
|
|
82
84
|
DEPLOY_ID: deployId,
|
|
83
85
|
BUILD_ID: buildId,
|
|
84
|
-
|
|
85
|
-
REPOSITORY_URL,
|
|
86
|
+
...deployUrls,
|
|
86
87
|
CONTEXT: context,
|
|
87
88
|
NETLIFY_LOCAL: 'true',
|
|
88
89
|
...gitEnv,
|
|
@@ -96,6 +97,23 @@ const getGeneralEnv = async function ({
|
|
|
96
97
|
})
|
|
97
98
|
}
|
|
98
99
|
|
|
100
|
+
const getDeployUrls = function ({
|
|
101
|
+
siteInfo: { name = DEFAULT_SITE_NAME, ssl_url: sslUrl, build_settings: { repo_url: REPOSITORY_URL } = {} },
|
|
102
|
+
branch,
|
|
103
|
+
deployId,
|
|
104
|
+
}) {
|
|
105
|
+
return {
|
|
106
|
+
URL: sslUrl,
|
|
107
|
+
REPOSITORY_URL,
|
|
108
|
+
DEPLOY_PRIME_URL: `https://${branch}--${name}${NETLIFY_DEFAULT_DOMAIN}`,
|
|
109
|
+
DEPLOY_URL: `https://${deployId}--${name}${NETLIFY_DEFAULT_DOMAIN}`,
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const NETLIFY_DEFAULT_DOMAIN = '.netlify.app'
|
|
114
|
+
// `site.name` is `undefined` when there is no token or siteId
|
|
115
|
+
const DEFAULT_SITE_NAME = 'site-name'
|
|
116
|
+
|
|
99
117
|
// Environment variables specified by the user
|
|
100
118
|
const getUserEnv = function ({ config, siteInfo, accounts, addons }) {
|
|
101
119
|
const accountEnv = getAccountEnv({ siteInfo, accounts })
|
|
@@ -155,10 +173,6 @@ const READONLY_ENV = [
|
|
|
155
173
|
'NETLIFY_LOCAL',
|
|
156
174
|
|
|
157
175
|
// Not set in local builds because there is no CI build/deploy, incoming hooks nor PR
|
|
158
|
-
'BUILD_ID',
|
|
159
|
-
'DEPLOY_ID',
|
|
160
|
-
'DEPLOY_PRIME_URL',
|
|
161
|
-
'DEPLOY_URL',
|
|
162
176
|
'INCOMING_HOOK_BODY',
|
|
163
177
|
'INCOMING_HOOK_TITLE',
|
|
164
178
|
'INCOMING_HOOK_URL',
|
package/src/options/main.js
CHANGED
|
@@ -44,7 +44,8 @@ const getDefaultOpts = function ({ env: envOpt = {}, cwd: cwdOpt, defaultConfig
|
|
|
44
44
|
host: combinedEnv.NETLIFY_API_HOST,
|
|
45
45
|
token: combinedEnv.NETLIFY_AUTH_TOKEN,
|
|
46
46
|
siteId: combinedEnv.NETLIFY_SITE_ID,
|
|
47
|
-
deployId: combinedEnv.DEPLOY_ID,
|
|
47
|
+
deployId: combinedEnv.DEPLOY_ID || DEFAULT_DEPLOY_ID,
|
|
48
|
+
buildId: combinedEnv.BUILD_ID || DEFAULT_BUILD_ID,
|
|
48
49
|
mode: 'require',
|
|
49
50
|
offline: false,
|
|
50
51
|
debug: getDefaultDebug(combinedEnv, defaultConfig),
|
|
@@ -55,6 +56,10 @@ const getDefaultOpts = function ({ env: envOpt = {}, cwd: cwdOpt, defaultConfig
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
// Local builds do not have any deploys, so some dummy ids are used instead
|
|
60
|
+
const DEFAULT_DEPLOY_ID = '0'
|
|
61
|
+
const DEFAULT_BUILD_ID = '0'
|
|
62
|
+
|
|
58
63
|
// --debug can be set using an environment variable `NETLIFY_BUILD_DEBUG` either
|
|
59
64
|
// locally or in the UI build settings
|
|
60
65
|
const getDefaultDebug = function (combinedEnv, { build: { environment = {} } = {} }) {
|