netlify-cli 17.29.0 → 17.31.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/dist/commands/base-command.d.ts +1 -0
- package/dist/commands/base-command.d.ts.map +1 -1
- package/dist/commands/base-command.js +4 -0
- package/dist/commands/deploy/deploy.d.ts.map +1 -1
- package/dist/commands/deploy/deploy.js +6 -1
- package/dist/commands/serve/serve.d.ts.map +1 -1
- package/dist/commands/serve/serve.js +6 -3
- package/dist/lib/edge-functions/registry.d.ts +1 -0
- package/dist/lib/edge-functions/registry.d.ts.map +1 -1
- package/dist/lib/edge-functions/registry.js +16 -2
- package/dist/lib/functions/registry.d.ts +4 -1
- package/dist/lib/functions/registry.d.ts.map +1 -1
- package/dist/lib/functions/registry.js +15 -7
- package/dist/lib/functions/server.d.ts.map +1 -1
- package/dist/lib/functions/server.js +6 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/feature-flags.d.ts.map +1 -1
- package/dist/utils/feature-flags.js +1 -0
- package/dist/utils/frameworks-api.d.ts +20 -0
- package/dist/utils/frameworks-api.d.ts.map +1 -0
- package/dist/utils/frameworks-api.js +53 -0
- package/dist/utils/run-build.js +3 -4
- package/npm-shrinkwrap.json +9473 -11759
- package/package.json +8 -8
|
@@ -29,6 +29,7 @@ export default class BaseCommand extends Command {
|
|
|
29
29
|
workspacePackage?: string;
|
|
30
30
|
featureFlags: FeatureFlags;
|
|
31
31
|
siteId?: string;
|
|
32
|
+
accountId?: string;
|
|
32
33
|
/**
|
|
33
34
|
* IMPORTANT this function will be called for each command!
|
|
34
35
|
* Don't do anything expensive in there.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-command.d.ts","sourceRoot":"","sources":["../../src/commands/base-command.ts"],"names":[],"mappings":"AAOA,OAAO,EAAiB,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA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EAAiE;IACjE,UAAU,IAAI,IAAI;IAgIlB,kEAAkE;IAC5D,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO;IAwBtB,YAAY,CAAC,aAAa,CAAC,EAAE,MAAM;IAQnC,uBAAuB;IA4D7B,8CAA8C;IAC9C,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAOpD;;OAEG;YACW,IAAI;IA2LlB,iDAAiD;IAC3C,SAAS,CAAC,MAAM,EAAE;QACtB,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;QACrB,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,2EAA2E;QAC3E,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC;IAiDpC;;OAEG;IACH,gBAAgB,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;IAI5C;;;;OAIG;IACH,iBAAiB,IAAI,YAAY,GAAG,KAAK;IAIzC;;OAEG;IACH,cAAc,CAAC,CAAC,GAAG,IAAI,GAAG,OAAO,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;CAGjE"}
|
|
@@ -29,6 +29,7 @@ import merge from 'lodash/merge.js';
|
|
|
29
29
|
import { NetlifyAPI } from 'netlify';
|
|
30
30
|
import { getAgent } from '../lib/http-agent.js';
|
|
31
31
|
import { NETLIFY_CYAN, USER_AGENT, chalk, error, exit, getToken, log, version, normalizeConfig, padLeft, pollForToken, sortOptions, warn, } from '../utils/command-helpers.js';
|
|
32
|
+
import { getFrameworksAPIPaths } from '../utils/frameworks-api.js';
|
|
32
33
|
import getGlobalConfig from '../utils/get-global-config.js';
|
|
33
34
|
import { getSiteByName } from '../utils/get-site.js';
|
|
34
35
|
import openBrowser from '../utils/open-browser.js';
|
|
@@ -449,6 +450,7 @@ class BaseCommand extends Command {
|
|
|
449
450
|
try {
|
|
450
451
|
const site = await api.getSite({ siteId: actionCommand.siteId, feature_flags: 'cli' });
|
|
451
452
|
actionCommand.featureFlags = site.feature_flags;
|
|
453
|
+
actionCommand.accountId = site.account_id;
|
|
452
454
|
}
|
|
453
455
|
catch {
|
|
454
456
|
// if the site is not found, that could mean that the user passed a site name, not an ID
|
|
@@ -531,6 +533,7 @@ class BaseCommand extends Command {
|
|
|
531
533
|
globalConfig,
|
|
532
534
|
// state of current site dir
|
|
533
535
|
state,
|
|
536
|
+
frameworksAPIPaths: getFrameworksAPIPaths(buildDir, this.workspacePackage),
|
|
534
537
|
};
|
|
535
538
|
debug(`${this.name()}:init`)('end');
|
|
536
539
|
}
|
|
@@ -540,6 +543,7 @@ class BaseCommand extends Command {
|
|
|
540
543
|
const flags = this.opts();
|
|
541
544
|
try {
|
|
542
545
|
return await resolveConfig({
|
|
546
|
+
accountId: this.accountId,
|
|
543
547
|
config: config.configFilePath,
|
|
544
548
|
packagePath: config.packagePath,
|
|
545
549
|
repositoryRoot: config.repositoryRoot,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/deploy.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/deploy.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAiCxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAwuB5C,eAAO,MAAM,MAAM,YAAmB,YAAY,WAAW,WAAW,kBAmHvE,CAAA"}
|
|
@@ -356,10 +356,15 @@ title, }) => {
|
|
|
356
356
|
results = await api.createSiteDeploy({ siteId, title, body: { draft, branch: alias } });
|
|
357
357
|
deployId = results.id;
|
|
358
358
|
const internalFunctionsFolder = await getInternalFunctionsDir({ base: site.root, packagePath, ensureExists: true });
|
|
359
|
+
await command.netlify.frameworksAPIPaths.functions.ensureExists();
|
|
359
360
|
// The order of the directories matter: zip-it-and-ship-it will prioritize
|
|
360
361
|
// functions from the rightmost directories. In this case, we want user
|
|
361
362
|
// functions to take precedence over internal functions.
|
|
362
|
-
const functionDirectories = [
|
|
363
|
+
const functionDirectories = [
|
|
364
|
+
internalFunctionsFolder,
|
|
365
|
+
command.netlify.frameworksAPIPaths.functions.path,
|
|
366
|
+
functionsFolder,
|
|
367
|
+
].filter((folder) => Boolean(folder));
|
|
363
368
|
const manifestPath = skipFunctionsCache ? null : await getFunctionsManifestPath({ base: site.root, packagePath });
|
|
364
369
|
const redirectsPath = `${deployFolder}/_redirects`;
|
|
365
370
|
const headersPath = `${deployFolder}/_headers`;
|
|
@@ -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;AA8BxC,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAG5C,eAAO,MAAM,KAAK,YAAmB,YAAY,WAAW,WAAW,uBA8JtE,CAAA"}
|
|
@@ -7,13 +7,14 @@ import { NETLIFYDEVERR, NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, exit, log, normali
|
|
|
7
7
|
import detectServerSettings, { getConfigWithPlugins } from '../../utils/detect-server-settings.js';
|
|
8
8
|
import { UNLINKED_SITE_MOCK_ID, getDotEnvVariables, getSiteInformation, injectEnvVariables } from '../../utils/dev.js';
|
|
9
9
|
import { getEnvelopeEnv } from '../../utils/env/index.js';
|
|
10
|
+
import { getFrameworksAPIConfig } from '../../utils/frameworks-api.js';
|
|
10
11
|
import { getInternalFunctionsDir } from '../../utils/functions/functions.js';
|
|
11
12
|
import { ensureNetlifyIgnore } from '../../utils/gitignore.js';
|
|
12
13
|
import openBrowser from '../../utils/open-browser.js';
|
|
13
14
|
import { generateInspectSettings, startProxyServer } from '../../utils/proxy-server.js';
|
|
14
15
|
import { runBuildTimeline } from '../../utils/run-build.js';
|
|
15
16
|
export const serve = async (options, command) => {
|
|
16
|
-
const { api, cachedConfig, config, repositoryRoot, site, siteInfo, state } = command.netlify;
|
|
17
|
+
const { api, cachedConfig, config, frameworksAPIPaths, repositoryRoot, site, siteInfo, state } = command.netlify;
|
|
17
18
|
config.dev = { ...config.dev };
|
|
18
19
|
config.build = { ...config.build };
|
|
19
20
|
const devConfig = {
|
|
@@ -51,6 +52,7 @@ export const serve = async (options, command) => {
|
|
|
51
52
|
ensureExists: true,
|
|
52
53
|
packagePath: command.workspacePackage,
|
|
53
54
|
});
|
|
55
|
+
await frameworksAPIPaths.functions.ensureExists();
|
|
54
56
|
let settings;
|
|
55
57
|
try {
|
|
56
58
|
settings = await detectServerSettings(devConfig, options, command);
|
|
@@ -78,6 +80,7 @@ export const serve = async (options, command) => {
|
|
|
78
80
|
options,
|
|
79
81
|
env: {},
|
|
80
82
|
});
|
|
83
|
+
const mergedConfig = await getFrameworksAPIConfig(config, frameworksAPIPaths.config.path);
|
|
81
84
|
// Now we generate a second Blobs context object, this time with edge access
|
|
82
85
|
// for runtime access (i.e. from functions and edge functions).
|
|
83
86
|
const runtimeBlobsContext = await getBlobsContextWithEdgeAccess(blobsOptions);
|
|
@@ -85,7 +88,7 @@ export const serve = async (options, command) => {
|
|
|
85
88
|
const functionsRegistry = await startFunctionsServer({
|
|
86
89
|
blobsContext: runtimeBlobsContext,
|
|
87
90
|
command,
|
|
88
|
-
config,
|
|
91
|
+
config: mergedConfig,
|
|
89
92
|
debug: options.debug,
|
|
90
93
|
loadDistFunctions: true,
|
|
91
94
|
settings,
|
|
@@ -118,7 +121,7 @@ export const serve = async (options, command) => {
|
|
|
118
121
|
addonsUrls,
|
|
119
122
|
blobsContext: runtimeBlobsContext,
|
|
120
123
|
command,
|
|
121
|
-
config,
|
|
124
|
+
config: mergedConfig,
|
|
122
125
|
configPath: configPathOverride,
|
|
123
126
|
debug: options.debug,
|
|
124
127
|
disableEdgeFunctions: options.internalDisableEdgeFunctions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/lib/edge-functions/registry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAuD,MAAM,uBAAuB,CAAA;AAE7G,OAAO,WAAW,MAAM,gCAAgC,CAAA;AAYxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAOhE,MAAM,WAAW,MAAM;IACrB,cAAc,CAAC,EAAE,WAAW,EAAE,CAAA;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAKD,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,cAAc,uBAAuB,EAAE,KAAK,CAAC,CAAC,CAAA;AAInF,UAAU,4BAA4B;IACpC,OAAO,EAAE,WAAW,CAAA;IACpB,OAAO,EAAE,cAAc,uBAAuB,CAAC,CAAA;IAC/C,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,OAAO,CAAA;IACd,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACzD,YAAY,EAAE,YAAY,CAAA;IAC1B,gBAAgB,EAAE,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IAMtC,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,MAAM,CAAC,uBAAuB;YAoBxB,gBAAgB;IAoCxB,UAAU;IAIhB;;OAEG;IACH,OAAO,CAAC,QAAQ;IA2ChB;;;OAGG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;;;;;;;;;IA2C5C;;;OAGG;IACH,OAAO,CAAC,YAAY;IA4CpB;;;OAGG;YACW,QAAQ;IA+BtB,OAAO,KAAK,iBAAiB,GAE5B;YAEa,gBAAgB;YAShB,mBAAmB;YAgBnB,gBAAgB;YAiChB,aAAa;YAwBb,wBAAwB;IActC,OAAO,KAAK,iBAAiB,GAE5B;CACF"}
|
|
@@ -338,9 +338,16 @@ export class EdgeFunctionsRegistry {
|
|
|
338
338
|
success: true,
|
|
339
339
|
};
|
|
340
340
|
}
|
|
341
|
+
const importMapPaths = [this.importMapFromTOML, this.importMapFromDeployConfig];
|
|
342
|
+
if (this.usesFrameworksAPI) {
|
|
343
|
+
const { edgeFunctionsImportMap } = this.command.netlify.frameworksAPIPaths;
|
|
344
|
+
if (await edgeFunctionsImportMap.exists()) {
|
|
345
|
+
importMapPaths.push(edgeFunctionsImportMap.path);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
341
348
|
const { functionsConfig, graph, npmSpecifiersWithExtraneousFiles, success } = await this.runIsolate(this.functions, this.env, {
|
|
342
349
|
getFunctionsConfig: true,
|
|
343
|
-
importMapPaths:
|
|
350
|
+
importMapPaths: importMapPaths.filter(nonNullable),
|
|
344
351
|
});
|
|
345
352
|
return { functionsConfig, graph, npmSpecifiersWithExtraneousFiles, success };
|
|
346
353
|
}
|
|
@@ -370,11 +377,13 @@ export class EdgeFunctionsRegistry {
|
|
|
370
377
|
: undefined;
|
|
371
378
|
}
|
|
372
379
|
async scanForFunctions() {
|
|
373
|
-
const [
|
|
380
|
+
const [frameworkFunctions, integrationFunctions, userFunctions] = await Promise.all([
|
|
381
|
+
this.usesFrameworksAPI ? this.bundler.find([this.command.netlify.frameworksAPIPaths.edgeFunctions.path]) : [],
|
|
374
382
|
this.bundler.find([this.internalDirectory]),
|
|
375
383
|
this.bundler.find(this.directories),
|
|
376
384
|
this.scanForDeployConfig(),
|
|
377
385
|
]);
|
|
386
|
+
const internalFunctions = [...frameworkFunctions, ...integrationFunctions];
|
|
378
387
|
const functions = [...internalFunctions, ...userFunctions];
|
|
379
388
|
const newFunctions = functions.filter((func) => {
|
|
380
389
|
const functionExists = this.functions.some((existingFunc) => func.name === existingFunc.name && func.path === existingFunc.path);
|
|
@@ -419,4 +428,9 @@ export class EdgeFunctionsRegistry {
|
|
|
419
428
|
});
|
|
420
429
|
this.directoryWatchers.set(this.projectDir, watcher);
|
|
421
430
|
}
|
|
431
|
+
// We only take into account edge functions from the Frameworks API in
|
|
432
|
+
// the `serve` command, since we don't run the build command in `dev`.
|
|
433
|
+
get usesFrameworksAPI() {
|
|
434
|
+
return this.command.name() === 'serve';
|
|
435
|
+
}
|
|
422
436
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ListedFunction, listFunctions } from '@netlify/zip-it-and-ship-it';
|
|
2
|
+
import { getFrameworksAPIPaths } from '../../utils/frameworks-api.js';
|
|
2
3
|
import type { BlobsContext } from '../blobs/blobs.js';
|
|
3
4
|
import NetlifyFunction from './netlify-function.js';
|
|
4
5
|
export declare const DEFAULT_FUNCTION_URL_EXPRESSION: RegExp;
|
|
@@ -27,9 +28,11 @@ export declare class FunctionsRegistry {
|
|
|
27
28
|
private projectRoot;
|
|
28
29
|
private isConnected;
|
|
29
30
|
private debug;
|
|
30
|
-
|
|
31
|
+
private frameworksAPIPaths;
|
|
32
|
+
constructor({ blobsContext, capabilities, config, debug, frameworksAPIPaths, isConnected, logLambdaCompat, manifest, projectRoot, settings, timeouts, }: {
|
|
31
33
|
projectRoot: string;
|
|
32
34
|
debug?: boolean;
|
|
35
|
+
frameworksAPIPaths: ReturnType<typeof getFrameworksAPIPaths>;
|
|
33
36
|
isConnected?: boolean;
|
|
34
37
|
blobsContext: BlobsContext;
|
|
35
38
|
} & object);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/registry.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/registry.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAa3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAErE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAIrD,OAAO,eAAe,MAAM,uBAAuB,CAAA;AAGnD,eAAO,MAAM,+BAA+B,QAAiD,CAAA;AAQ7F;;GAEG;AAEH,qBAAa,iBAAiB;IAC5B;;OAEG;IACH,OAAO,CAAC,SAAS,CAAqC;IAEtD;;;OAGG;IACH,OAAO,CAAC,gBAAgB,CAAgE;IAExF;;;OAGG;IACH,OAAO,CAAC,sBAAsB,CAAQ;IAEtC;;OAEG;IACH,OAAO,CAAC,YAAY,CAAc;IAElC,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,kBAAkB,CAA0C;gBAExD,EACV,YAAY,EAEZ,YAAY,EAEZ,MAAM,EACN,KAAa,EACb,kBAAkB,EAClB,WAAmB,EAEnB,eAAe,EAEf,QAAQ,EACR,WAAW,EAEX,QAAQ,EAER,QAAQ,GACT,EAAE;QACD,WAAW,EAAE,MAAM,CAAA;QACnB,KAAK,CAAC,EAAE,OAAO,CAAA;QACf,kBAAkB,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAA;QAC5D,WAAW,CAAC,EAAE,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GE = '@netlify/functions';
|
|
15
15
|
const ZIP_EXTENSION = '.zip';
|
|
16
|
-
const isInternalFunction = (func) => func.mainFile.includes(getPathInProject([INTERNAL_FUNCTIONS_FOLDER]))
|
|
16
|
+
const isInternalFunction = (func, frameworksAPIFunctionsPath) => func.mainFile.includes(getPathInProject([INTERNAL_FUNCTIONS_FOLDER])) ||
|
|
17
|
+
func.mainFile.includes(frameworksAPIFunctionsPath);
|
|
17
18
|
/**
|
|
18
19
|
* @typedef {"buildError" | "extracted" | "loaded" | "missing-types-package" | "reloaded" | "reloading" | "removed"} FunctionEvent
|
|
19
20
|
*/
|
|
@@ -22,7 +23,7 @@ export class FunctionsRegistry {
|
|
|
22
23
|
// @ts-expect-error TS(7031) FIXME: Binding element 'capabilities' implicitly has an '... Remove this comment to see the full error message
|
|
23
24
|
capabilities,
|
|
24
25
|
// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message
|
|
25
|
-
config, debug = false, isConnected = false,
|
|
26
|
+
config, debug = false, frameworksAPIPaths, isConnected = false,
|
|
26
27
|
// @ts-expect-error TS(7031) FIXME: Binding element 'logLambdaCompat' implicitly has a... Remove this comment to see the full error message
|
|
27
28
|
logLambdaCompat,
|
|
28
29
|
// @ts-expect-error TS(7031) FIXME: Binding element 'manifest' implicitly has an 'any'... Remove this comment to see the full error message
|
|
@@ -50,6 +51,7 @@ export class FunctionsRegistry {
|
|
|
50
51
|
// @ts-expect-error TS(2339) FIXME: Property 'config' does not exist on type 'Function... Remove this comment to see the full error message
|
|
51
52
|
this.config = config;
|
|
52
53
|
this.debug = debug;
|
|
54
|
+
this.frameworksAPIPaths = frameworksAPIPaths;
|
|
53
55
|
this.isConnected = isConnected;
|
|
54
56
|
this.projectRoot = projectRoot;
|
|
55
57
|
// @ts-expect-error TS(2339) FIXME: Property 'timeouts' does not exist on type 'Functi... Remove this comment to see the full error message
|
|
@@ -295,13 +297,19 @@ export class FunctionsRegistry {
|
|
|
295
297
|
// the new location.
|
|
296
298
|
if (extname(func.mainFile) === ZIP_EXTENSION) {
|
|
297
299
|
const unzippedDirectory = await this.unzipFunction(func);
|
|
298
|
-
if (this.debug) {
|
|
299
|
-
FunctionsRegistry.logEvent('extracted', { func });
|
|
300
|
-
}
|
|
301
300
|
// If there's a manifest file, look up the function in order to extract
|
|
302
301
|
// the build data.
|
|
303
302
|
// @ts-expect-error TS(2339) FIXME: Property 'manifest' does not exist on type 'Functi... Remove this comment to see the full error message
|
|
304
303
|
const manifestEntry = (this.manifest?.functions || []).find((manifestFunc) => manifestFunc.name === func.name);
|
|
304
|
+
// We found a zipped function that does not have a corresponding entry in
|
|
305
|
+
// the manifest. This shouldn't happen, but we ignore the function in
|
|
306
|
+
// this case.
|
|
307
|
+
if (!manifestEntry) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
if (this.debug) {
|
|
311
|
+
FunctionsRegistry.logEvent('extracted', { func });
|
|
312
|
+
}
|
|
305
313
|
func.buildData = {
|
|
306
314
|
...manifestEntry?.buildData,
|
|
307
315
|
routes: manifestEntry?.routes,
|
|
@@ -357,9 +365,9 @@ export class FunctionsRegistry {
|
|
|
357
365
|
// user-defined functions take precedence over internal functions,
|
|
358
366
|
// so we want to ignore any internal functions where there's a user-defined one with the same name
|
|
359
367
|
const ignoredFunctions = new Set(functions
|
|
360
|
-
.filter((func) => isInternalFunction(func) &&
|
|
368
|
+
.filter((func) => isInternalFunction(func, this.frameworksAPIPaths.functions.path) &&
|
|
361
369
|
this.functions.has(func.name) &&
|
|
362
|
-
!isInternalFunction(this.functions.get(func.name)))
|
|
370
|
+
!isInternalFunction(this.functions.get(func.name), this.frameworksAPIPaths.functions.path))
|
|
363
371
|
.map((func) => func.name));
|
|
364
372
|
// Before registering any functions, we look for any functions that were on
|
|
365
373
|
// the previous list but are missing from the new one. We unregister them.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/lib/functions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AAc,EAAE,MAAM,SAAS,CAAA;AAKtD,OAAO,KAAK,WAAW,MAAM,gCAAgC,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAWvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAMrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAuDjD,eAAO,MAAM,aAAa,YAAsB,yBAAyB,KAAG,cA6K3E,CAAA;AAED,UAAU,yBAAyB;IACjC,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,QAAQ,CAAA;IAChB,eAAe,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;CAC7C;AA4BD,eAAO,MAAM,oBAAoB,YACtB;IACP,YAAY,EAAE,YAAY,CAAA;IAC1B,OAAO,EAAE,WAAW,CAAA;IACpB,MAAM,EAAE,QAAQ,CAAA;IAChB,YAAY,EAAE,QAAQ,CAAA;IACtB,KAAK,EAAE,OAAO,CAAA;IACd,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,EAAE,QAAQ,CAAA;IAClB,IAAI,EAAE,QAAQ,CAAA;IACd,QAAQ,EAAE,QAAQ,CAAA;IAClB,QAAQ,EAAE,QAAQ,CAAA;CACnB,GAAG,KAAK,yBAAyB,EAAE,mBAAmB,CAAC,KACvD,QAAQ,iBAAiB,GAAG,SAAS,CAsFvC,CAAA"}
|
|
@@ -249,7 +249,11 @@ export const startFunctionsServer = async (options) => {
|
|
|
249
249
|
else {
|
|
250
250
|
// The order of the function directories matters. Rightmost directories take
|
|
251
251
|
// precedence.
|
|
252
|
-
const sourceDirectories = [
|
|
252
|
+
const sourceDirectories = [
|
|
253
|
+
internalFunctionsDir,
|
|
254
|
+
command.netlify.frameworksAPIPaths.functions.path,
|
|
255
|
+
settings.functions,
|
|
256
|
+
].filter(Boolean);
|
|
253
257
|
functionsDirectories.push(...sourceDirectories);
|
|
254
258
|
}
|
|
255
259
|
try {
|
|
@@ -268,6 +272,7 @@ export const startFunctionsServer = async (options) => {
|
|
|
268
272
|
capabilities,
|
|
269
273
|
config,
|
|
270
274
|
debug,
|
|
275
|
+
frameworksAPIPaths: command.netlify.frameworksAPIPaths,
|
|
271
276
|
isConnected: Boolean(siteUrl),
|
|
272
277
|
logLambdaCompat: isFeatureFlagEnabled('cli_log_lambda_compat', siteInfo),
|
|
273
278
|
manifest,
|