netlify-cli 13.2.2 → 14.0.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/npm-shrinkwrap.json +14737 -30481
- package/package.json +12 -85
- package/src/commands/dev/dev-exec.mjs +3 -2
- package/src/commands/dev/dev.mjs +20 -10
- package/src/commands/functions/functions-create.mjs +3 -2
- package/src/commands/functions/functions-serve.mjs +4 -3
- package/src/commands/functions/functions.mjs +1 -1
- package/src/commands/serve/serve.mjs +3 -2
- package/src/commands/watch/watch.mjs +4 -2
- package/src/functions-templates/javascript/google-analytics/package.json +1 -1
- package/src/functions-templates/javascript/token-hider/package-lock.json +6 -6
- package/src/functions-templates/typescript/hello-world/package-lock.json +6 -6
- package/src/lib/edge-functions/bootstrap.mjs +1 -1
- package/src/lib/edge-functions/proxy.mjs +6 -3
- package/src/lib/edge-functions/registry.mjs +263 -170
- package/src/lib/functions/registry.mjs +4 -1
- package/src/lib/functions/server.mjs +2 -2
- package/src/utils/deploy/util.mjs +9 -4
- package/src/utils/dev.mjs +20 -10
- package/src/utils/init/node-version.mjs +2 -3
- package/src/utils/live-tunnel.mjs +1 -1
- package/src/utils/proxy.mjs +6 -2
- package/src/utils/run-build.mjs +2 -1
package/src/utils/dev.mjs
CHANGED
|
@@ -137,30 +137,40 @@ const getEnvSourceName = (source) => {
|
|
|
137
137
|
return printFn(name)
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
/**
|
|
141
|
+
* @param {{devConfig: any, env: Record<string, { sources: string[], value: string}>, site: any}} param0
|
|
142
|
+
* @returns {Promise<Record<string, { sources: string[], value: string}>>}
|
|
143
|
+
*/
|
|
144
|
+
export const getDotEnvVariables = async ({ devConfig, env, site }) => {
|
|
144
145
|
const dotEnvFiles = await loadDotEnvFiles({ envFiles: devConfig.envFiles, projectDir: site.root })
|
|
145
|
-
|
|
146
146
|
dotEnvFiles.forEach(({ env: fileEnv, file }) => {
|
|
147
|
+
const newSourceName = `${file} file`
|
|
148
|
+
|
|
147
149
|
Object.keys(fileEnv).forEach((key) => {
|
|
148
|
-
const
|
|
149
|
-
const sources = environment.has(key) ? [newSourceName, ...environment.get(key).sources] : [newSourceName]
|
|
150
|
+
const sources = key in env ? [newSourceName, ...env[key].sources] : [newSourceName]
|
|
150
151
|
|
|
151
152
|
if (sources.includes('internal')) {
|
|
152
153
|
return
|
|
153
154
|
}
|
|
154
155
|
|
|
155
|
-
|
|
156
|
+
env[key] = {
|
|
156
157
|
sources,
|
|
157
158
|
value: fileEnv[key],
|
|
158
|
-
}
|
|
159
|
+
}
|
|
159
160
|
})
|
|
160
161
|
})
|
|
161
162
|
|
|
163
|
+
return env
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Takes a set of environment variables in the format provided by @netlify/config and injects them into `process.env`
|
|
168
|
+
* @param {Record<string, { sources: string[], value: string}>} env
|
|
169
|
+
* @return {void}
|
|
170
|
+
*/
|
|
171
|
+
export const injectEnvVariables = (env) => {
|
|
162
172
|
// eslint-disable-next-line fp/no-loops
|
|
163
|
-
for (const [key, variable] of
|
|
173
|
+
for (const [key, variable] of Object.entries(env)) {
|
|
164
174
|
const existsInProcess = process.env[key] !== undefined
|
|
165
175
|
const [usedSource, ...overriddenSources] = existsInProcess ? ['process', ...variable.sources] : variable.sources
|
|
166
176
|
const usedSourceName = getEnvSourceName(usedSource)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import { readFile } from 'fs/promises'
|
|
3
3
|
|
|
4
|
-
import { get } from 'dot-prop'
|
|
5
4
|
import { locatePath } from 'locate-path'
|
|
6
5
|
import nodeVersionAlias from 'node-version-alias'
|
|
7
6
|
|
|
@@ -18,10 +17,10 @@ export const detectNodeVersion = async ({ baseDirectory, env }) => {
|
|
|
18
17
|
try {
|
|
19
18
|
const nodeVersionFile = await locatePath(['.nvmrc', '.node-version'], { cwd: baseDirectory })
|
|
20
19
|
const configuredVersion =
|
|
21
|
-
nodeVersionFile === undefined ?
|
|
20
|
+
nodeVersionFile === undefined ? env.NODE_VERSION?.value : await readFile(nodeVersionFile, 'utf8')
|
|
22
21
|
|
|
23
22
|
const version =
|
|
24
|
-
configuredVersion === undefined
|
|
23
|
+
configuredVersion === undefined || configuredVersion === null
|
|
25
24
|
? DEFAULT_NODE_VERSION
|
|
26
25
|
: await nodeVersionAlias(normalizeConfiguredVersion(configuredVersion))
|
|
27
26
|
|
|
@@ -111,7 +111,7 @@ export const startLiveTunnel = async ({ localPort, netlifyApiToken, siteId }) =>
|
|
|
111
111
|
return data.state === 'online'
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
connectTunnel({ session, netlifyApiToken, localPort })
|
|
115
115
|
|
|
116
116
|
// Waiting for the live session to have a state of `online`.
|
|
117
117
|
await pWaitFor(isLiveTunnelReady, {
|
package/src/utils/proxy.mjs
CHANGED
|
@@ -575,6 +575,11 @@ const onRequest = async (
|
|
|
575
575
|
proxy.web(req, res, options)
|
|
576
576
|
}
|
|
577
577
|
|
|
578
|
+
export const getProxyUrl = function (settings) {
|
|
579
|
+
const scheme = settings.https ? 'https' : 'http'
|
|
580
|
+
return `${scheme}://localhost:${settings.port}`
|
|
581
|
+
}
|
|
582
|
+
|
|
578
583
|
export const startProxy = async function ({
|
|
579
584
|
addonsUrls,
|
|
580
585
|
config,
|
|
@@ -665,8 +670,7 @@ export const startProxy = async function ({
|
|
|
665
670
|
|
|
666
671
|
await Promise.all(eventQueue)
|
|
667
672
|
|
|
668
|
-
|
|
669
|
-
return `${scheme}://localhost:${settings.port}`
|
|
673
|
+
return getProxyUrl(settings)
|
|
670
674
|
}
|
|
671
675
|
|
|
672
676
|
const BYTES_LIMIT = 30
|
package/src/utils/run-build.mjs
CHANGED
|
@@ -56,7 +56,7 @@ const getBuildOptions = ({
|
|
|
56
56
|
saveConfig,
|
|
57
57
|
})
|
|
58
58
|
|
|
59
|
-
const runNetlifyBuild = async ({ cachedConfig, options, settings, site, timeline = 'build' }) => {
|
|
59
|
+
const runNetlifyBuild = async ({ cachedConfig, env, options, settings, site, timeline = 'build' }) => {
|
|
60
60
|
const { default: buildSite, startDev } = await netlifyBuildPromise
|
|
61
61
|
const sharedOptions = getBuildOptions({
|
|
62
62
|
cachedConfig,
|
|
@@ -112,6 +112,7 @@ const runNetlifyBuild = async ({ cachedConfig, options, settings, site, timeline
|
|
|
112
112
|
// Set `quiet` to suppress non-essential output from Netlify Build unless
|
|
113
113
|
// the `debug` flag is set.
|
|
114
114
|
quiet: !options.debug,
|
|
115
|
+
env,
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
// Run Netlify Build using the `startDev` entry point.
|