netlify-cli 17.22.0 → 17.22.1
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/dist/commands/dev/dev.js +2 -2
- package/dist/commands/functions/functions-serve.js +2 -2
- package/dist/commands/serve/serve.d.ts.map +1 -1
- package/dist/commands/serve/serve.js +13 -5
- package/dist/lib/blobs/blobs.d.ts +16 -5
- package/dist/lib/blobs/blobs.d.ts.map +1 -1
- package/dist/lib/blobs/blobs.js +25 -7
- package/dist/lib/edge-functions/proxy.d.ts +2 -2
- package/dist/lib/edge-functions/proxy.d.ts.map +1 -1
- package/dist/lib/functions/netlify-function.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/proxy-server.d.ts +2 -2
- package/dist/utils/proxy-server.d.ts.map +1 -1
- package/dist/utils/run-build.d.ts +4 -5
- package/dist/utils/run-build.d.ts.map +1 -1
- package/dist/utils/run-build.js +0 -4
- package/npm-shrinkwrap.json +36 -36
- package/package.json +3 -3
package/dist/commands/dev/dev.js
CHANGED
|
@@ -2,7 +2,7 @@ import process from 'process';
|
|
|
2
2
|
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module '@net... Remove this comment to see the full error message
|
|
3
3
|
import { applyMutations } from '@netlify/config';
|
|
4
4
|
import { Option } from 'commander';
|
|
5
|
-
import { BLOBS_CONTEXT_VARIABLE, encodeBlobsContext,
|
|
5
|
+
import { BLOBS_CONTEXT_VARIABLE, encodeBlobsContext, getBlobsContextWithEdgeAccess } from '../../lib/blobs/blobs.js';
|
|
6
6
|
import { promptEditorHelper } from '../../lib/edge-functions/editor-helper.js';
|
|
7
7
|
import { startFunctionsServer } from '../../lib/functions/server.js';
|
|
8
8
|
import { printBanner } from '../../utils/banner.js';
|
|
@@ -78,7 +78,7 @@ export const dev = async (options, command) => {
|
|
|
78
78
|
};
|
|
79
79
|
let { env } = cachedConfig;
|
|
80
80
|
env.NETLIFY_DEV = { sources: ['internal'], value: 'true' };
|
|
81
|
-
const blobsContext = await
|
|
81
|
+
const blobsContext = await getBlobsContextWithEdgeAccess({
|
|
82
82
|
debug: options.debug,
|
|
83
83
|
projectRoot: command.workingDir,
|
|
84
84
|
siteID: site.id ?? UNLINKED_SITE_MOCK_ID,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
|
-
import {
|
|
2
|
+
import { getBlobsContextWithEdgeAccess } from '../../lib/blobs/blobs.js';
|
|
3
3
|
import { startFunctionsServer } from '../../lib/functions/server.js';
|
|
4
4
|
import { printBanner } from '../../utils/banner.js';
|
|
5
5
|
import { UNLINKED_SITE_MOCK_ID, acquirePort, getDotEnvVariables, getSiteInformation, injectEnvVariables, } from '../../utils/dev.js';
|
|
@@ -24,7 +24,7 @@ export const functionsServe = async (options, command) => {
|
|
|
24
24
|
defaultPort: DEFAULT_PORT,
|
|
25
25
|
errorMessage: 'Could not acquire configured functions port',
|
|
26
26
|
});
|
|
27
|
-
const blobsContext = await
|
|
27
|
+
const blobsContext = await getBlobsContextWithEdgeAccess({
|
|
28
28
|
debug: options.debug,
|
|
29
29
|
projectRoot: command.workingDir,
|
|
30
30
|
siteID: site.id ?? UNLINKED_SITE_MOCK_ID,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../../src/commands/serve/serve.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../../src/commands/serve/serve.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AA6BxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAG5C,eAAO,MAAM,KAAK,YAAmB,YAAY,WAAW,WAAW,uBA0JtE,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import process from 'process';
|
|
2
|
-
import { BLOBS_CONTEXT_VARIABLE, encodeBlobsContext,
|
|
2
|
+
import { BLOBS_CONTEXT_VARIABLE, encodeBlobsContext, getBlobsContextWithAPIAccess, getBlobsContextWithEdgeAccess, } from '../../lib/blobs/blobs.js';
|
|
3
3
|
import { promptEditorHelper } from '../../lib/edge-functions/editor-helper.js';
|
|
4
4
|
import { startFunctionsServer } from '../../lib/functions/server.js';
|
|
5
5
|
import { printBanner } from '../../utils/banner.js';
|
|
@@ -64,19 +64,26 @@ export const serve = async (options, command) => {
|
|
|
64
64
|
command.setAnalyticsPayload({ live: options.live });
|
|
65
65
|
log(`${NETLIFYDEVLOG} Building site for production`);
|
|
66
66
|
log(`${NETLIFYDEVWARN} Changes will not be hot-reloaded, so if you need to rebuild your site you must exit and run 'netlify serve' again`);
|
|
67
|
-
const
|
|
67
|
+
const blobsOptions = {
|
|
68
68
|
debug: options.debug,
|
|
69
69
|
projectRoot: command.workingDir,
|
|
70
70
|
siteID: site.id ?? UNLINKED_SITE_MOCK_ID,
|
|
71
|
-
}
|
|
72
|
-
|
|
71
|
+
};
|
|
72
|
+
// We start by running a build, so we want a Blobs context with API access,
|
|
73
|
+
// which is what build plugins use.
|
|
74
|
+
process.env[BLOBS_CONTEXT_VARIABLE] = encodeBlobsContext(await getBlobsContextWithAPIAccess(blobsOptions));
|
|
73
75
|
const { configPath: configPathOverride } = await runBuildTimeline({
|
|
74
76
|
command,
|
|
75
77
|
settings,
|
|
76
78
|
options,
|
|
79
|
+
env: {},
|
|
77
80
|
});
|
|
81
|
+
// Now we generate a second Blobs context object, this time with edge access
|
|
82
|
+
// for runtime access (i.e. from functions and edge functions).
|
|
83
|
+
const runtimeBlobsContext = await getBlobsContextWithEdgeAccess(blobsOptions);
|
|
84
|
+
process.env[BLOBS_CONTEXT_VARIABLE] = encodeBlobsContext(runtimeBlobsContext);
|
|
78
85
|
const functionsRegistry = await startFunctionsServer({
|
|
79
|
-
blobsContext,
|
|
86
|
+
blobsContext: runtimeBlobsContext,
|
|
80
87
|
command,
|
|
81
88
|
config,
|
|
82
89
|
debug: options.debug,
|
|
@@ -109,6 +116,7 @@ export const serve = async (options, command) => {
|
|
|
109
116
|
const inspectSettings = generateInspectSettings(options.edgeInspect, options.edgeInspectBrk);
|
|
110
117
|
const url = await startProxyServer({
|
|
111
118
|
addonsUrls,
|
|
119
|
+
blobsContext: runtimeBlobsContext,
|
|
112
120
|
command,
|
|
113
121
|
config,
|
|
114
122
|
configPath: configPathOverride,
|
|
@@ -1,21 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
export interface BlobsContext {
|
|
1
|
+
interface BaseBlobsContext {
|
|
3
2
|
deployID: string;
|
|
4
|
-
edgeURL: string;
|
|
5
3
|
siteID: string;
|
|
6
4
|
token: string;
|
|
5
|
+
}
|
|
6
|
+
export interface BlobsContextWithAPIAccess extends BaseBlobsContext {
|
|
7
|
+
apiURL: string;
|
|
8
|
+
}
|
|
9
|
+
export interface BlobsContextWithEdgeAccess extends BaseBlobsContext {
|
|
10
|
+
edgeURL: string;
|
|
7
11
|
uncachedEdgeURL: string;
|
|
8
12
|
}
|
|
13
|
+
export type BlobsContext = BlobsContextWithAPIAccess | BlobsContextWithEdgeAccess;
|
|
14
|
+
export declare const BLOBS_CONTEXT_VARIABLE = "NETLIFY_BLOBS_CONTEXT";
|
|
9
15
|
interface GetBlobsContextOptions {
|
|
10
16
|
debug: boolean;
|
|
11
17
|
projectRoot: string;
|
|
12
18
|
siteID: string;
|
|
13
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Starts a local Blobs server and returns a context object that lets build
|
|
22
|
+
* plugins connect to it.
|
|
23
|
+
*/
|
|
24
|
+
export declare const getBlobsContextWithAPIAccess: ({ debug, projectRoot, siteID }: GetBlobsContextOptions) => Promise<BlobsContextWithAPIAccess>;
|
|
14
25
|
/**
|
|
15
26
|
* Starts a local Blobs server and returns a context object that lets functions
|
|
16
|
-
* connect to it.
|
|
27
|
+
* and edge functions connect to it.
|
|
17
28
|
*/
|
|
18
|
-
export declare const
|
|
29
|
+
export declare const getBlobsContextWithEdgeAccess: ({ debug, projectRoot, siteID }: GetBlobsContextOptions) => Promise<BlobsContextWithEdgeAccess>;
|
|
19
30
|
/**
|
|
20
31
|
* Returns a Base-64, JSON-encoded representation of the Blobs context. This is
|
|
21
32
|
* the format that the `@netlify/blobs` package expects to find the context in.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blobs.d.ts","sourceRoot":"","sources":["../../../src/lib/blobs/blobs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"blobs.d.ts","sourceRoot":"","sources":["../../../src/lib/blobs/blobs.ts"],"names":[],"mappings":"AASA,UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IACjE,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,0BAA2B,SAAQ,gBAAgB;IAClE,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,MAAM,YAAY,GAAG,yBAAyB,GAAG,0BAA0B,CAAA;AAIjF,eAAO,MAAM,sBAAsB,0BAA0B,CAAA;AAmC7D,UAAU,sBAAsB;IAC9B,KAAK,EAAE,OAAO,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;GAGG;AACH,eAAO,MAAM,4BAA4B,mCAA0C,sBAAsB,uCAUxG,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,6BAA6B,mCAA0C,sBAAsB,wCAWzG,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,YAAa,YAAY,WAA4D,CAAA"}
|
package/dist/lib/blobs/blobs.js
CHANGED
|
@@ -13,7 +13,12 @@ const printLocalBlobsNotice = () => {
|
|
|
13
13
|
hasPrintedLocalBlobsNotice = true;
|
|
14
14
|
log(`${NETLIFYDEVLOG} Netlify Blobs running in sandbox mode for local development. Refer to https://ntl.fyi/local-blobs for more information.`);
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Starts a local Blobs server on a random port and generates a random token
|
|
18
|
+
* for its authentication.
|
|
19
|
+
*/
|
|
20
|
+
const initializeBlobsServer = async (projectRoot, debug) => {
|
|
21
|
+
const token = uuidv4();
|
|
17
22
|
const directory = path.resolve(projectRoot, getPathInProject(['blobs-serve']));
|
|
18
23
|
const server = new BlobsServer({
|
|
19
24
|
debug,
|
|
@@ -24,16 +29,29 @@ const startBlobsServer = async (debug, projectRoot, token) => {
|
|
|
24
29
|
token,
|
|
25
30
|
});
|
|
26
31
|
const { port } = await server.start();
|
|
27
|
-
|
|
32
|
+
const url = `http://localhost:${port}`;
|
|
33
|
+
return { url, token };
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Starts a local Blobs server and returns a context object that lets build
|
|
37
|
+
* plugins connect to it.
|
|
38
|
+
*/
|
|
39
|
+
export const getBlobsContextWithAPIAccess = async ({ debug, projectRoot, siteID }) => {
|
|
40
|
+
const { token, url } = await initializeBlobsServer(projectRoot, debug);
|
|
41
|
+
const context = {
|
|
42
|
+
apiURL: url,
|
|
43
|
+
deployID: '0',
|
|
44
|
+
siteID,
|
|
45
|
+
token,
|
|
46
|
+
};
|
|
47
|
+
return context;
|
|
28
48
|
};
|
|
29
49
|
/**
|
|
30
50
|
* Starts a local Blobs server and returns a context object that lets functions
|
|
31
|
-
* connect to it.
|
|
51
|
+
* and edge functions connect to it.
|
|
32
52
|
*/
|
|
33
|
-
export const
|
|
34
|
-
const token =
|
|
35
|
-
const { port } = await startBlobsServer(debug, projectRoot, token);
|
|
36
|
-
const url = `http://localhost:${port}`;
|
|
53
|
+
export const getBlobsContextWithEdgeAccess = async ({ debug, projectRoot, siteID }) => {
|
|
54
|
+
const { token, url } = await initializeBlobsServer(projectRoot, debug);
|
|
37
55
|
const context = {
|
|
38
56
|
deployID: '0',
|
|
39
57
|
edgeURL: url,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IncomingMessage } from 'http';
|
|
2
2
|
import BaseCommand from '../../commands/base-command.js';
|
|
3
3
|
import { $TSFixMe } from '../../commands/types.js';
|
|
4
|
-
import {
|
|
4
|
+
import { BlobsContextWithEdgeAccess } from '../blobs/blobs.js';
|
|
5
5
|
declare const headersSymbol: unique symbol;
|
|
6
6
|
export declare const handleProxyRequest: (req: any, proxyReq: any) => void;
|
|
7
7
|
interface SiteInfo {
|
|
@@ -13,7 +13,7 @@ export declare const createSiteInfoHeader: (siteInfo: SiteInfo, localURL: string
|
|
|
13
13
|
export declare const createAccountInfoHeader: (accountInfo?: {}) => string;
|
|
14
14
|
export declare const initializeProxy: ({ accountId, blobsContext, command, config, configPath, debug, env: configEnv, geoCountry, geolocationMode, getUpdatedConfig, inspectSettings, mainPort, offline, passthroughPort, projectDir, repositoryRoot, settings, siteInfo, state, }: {
|
|
15
15
|
accountId: string;
|
|
16
|
-
blobsContext:
|
|
16
|
+
blobsContext: BlobsContextWithEdgeAccess;
|
|
17
17
|
command: BaseCommand;
|
|
18
18
|
config: $TSFixMe;
|
|
19
19
|
configPath: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../../src/lib/edge-functions/proxy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAA;AAM3C,OAAO,WAAW,MAAM,gCAAgC,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAGlD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../../src/lib/edge-functions/proxy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAA;AAM3C,OA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