@netlify/zip-it-and-ship-it 8.4.2 → 8.5.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/README.md +4 -0
- package/dist/main.d.ts +7 -3
- package/dist/main.js +16 -8
- package/dist/runtimes/index.d.ts +2 -1
- package/dist/runtimes/index.js +7 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -315,6 +315,10 @@ Each object has the following properties:
|
|
|
315
315
|
Function's name. This is the one used in the Function URL. For example, if a Function is a `myFunc.js` regular file,
|
|
316
316
|
the `name` is `myFunc` and the URL is `https://{hostname}/.netlify/functions/myFunc`.
|
|
317
317
|
|
|
318
|
+
- `displayName` `string`
|
|
319
|
+
|
|
320
|
+
If there was a user-defined configuration object applied to the function, and it had a `name` defined. This will be returned here.
|
|
321
|
+
|
|
318
322
|
- `mainFile`: `string`
|
|
319
323
|
|
|
320
324
|
Absolute path to the Function's main file. If the Function is a Node.js directory, this is its `index.js` or
|
package/dist/main.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface ListedFunction {
|
|
|
11
11
|
runtime: RuntimeType;
|
|
12
12
|
extension: string;
|
|
13
13
|
schedule?: string;
|
|
14
|
+
displayName?: string;
|
|
14
15
|
}
|
|
15
16
|
type ListedFunctionFile = ListedFunction & {
|
|
16
17
|
srcFile: string;
|
|
@@ -18,17 +19,20 @@ type ListedFunctionFile = ListedFunction & {
|
|
|
18
19
|
interface ListFunctionsOptions {
|
|
19
20
|
basePath?: string;
|
|
20
21
|
config?: Config;
|
|
22
|
+
configFileDirectories?: string[];
|
|
21
23
|
featureFlags?: FeatureFlags;
|
|
22
24
|
parseISC?: boolean;
|
|
23
25
|
}
|
|
24
|
-
export declare const listFunctions: (relativeSrcFolders: string | string[], { featureFlags: inputFeatureFlags, config, parseISC, }?: {
|
|
26
|
+
export declare const listFunctions: (relativeSrcFolders: string | string[], { featureFlags: inputFeatureFlags, config, configFileDirectories, parseISC, }?: {
|
|
25
27
|
featureFlags?: FeatureFlags | undefined;
|
|
26
28
|
config?: Config | undefined;
|
|
29
|
+
configFileDirectories?: string[] | undefined;
|
|
27
30
|
parseISC?: boolean | undefined;
|
|
28
31
|
}) => Promise<ListedFunction[]>;
|
|
29
|
-
export declare const listFunction: (path: string, { featureFlags: inputFeatureFlags, config, parseISC, }?: {
|
|
32
|
+
export declare const listFunction: (path: string, { featureFlags: inputFeatureFlags, config, configFileDirectories, parseISC, }?: {
|
|
30
33
|
featureFlags?: FeatureFlags | undefined;
|
|
31
34
|
config?: Config | undefined;
|
|
35
|
+
configFileDirectories?: string[] | undefined;
|
|
32
36
|
parseISC?: boolean | undefined;
|
|
33
37
|
}) => Promise<ListedFunction | undefined>;
|
|
34
|
-
export declare const listFunctionsFiles: (relativeSrcFolders: string | string[], { basePath, config, featureFlags: inputFeatureFlags, parseISC }?: ListFunctionsOptions) => Promise<ListedFunctionFile[]>;
|
|
38
|
+
export declare const listFunctionsFiles: (relativeSrcFolders: string | string[], { basePath, config, configFileDirectories, featureFlags: inputFeatureFlags, parseISC, }?: ListFunctionsOptions) => Promise<ListedFunctionFile[]>;
|
package/dist/main.js
CHANGED
|
@@ -6,7 +6,8 @@ import { RuntimeCache } from './utils/cache.js';
|
|
|
6
6
|
import { listFunctionsDirectories, resolveFunctionsDirectories } from './utils/fs.js';
|
|
7
7
|
export { zipFunction, zipFunctions } from './zip.js';
|
|
8
8
|
const augmentWithISC = async (func) => {
|
|
9
|
-
// ISC is currently only supported in JavaScript and TypeScript functions
|
|
9
|
+
// ISC is currently only supported in JavaScript and TypeScript functions
|
|
10
|
+
// and only supports scheduled functions.
|
|
10
11
|
if (func.runtime.name !== "js" /* RuntimeType.JAVASCRIPT */) {
|
|
11
12
|
return func;
|
|
12
13
|
}
|
|
@@ -14,21 +15,21 @@ const augmentWithISC = async (func) => {
|
|
|
14
15
|
return { ...func, inSourceConfig };
|
|
15
16
|
};
|
|
16
17
|
// List all Netlify Functions main entry files for a specific directory
|
|
17
|
-
export const listFunctions = async function (relativeSrcFolders, { featureFlags: inputFeatureFlags, config, parseISC = false, } = {}) {
|
|
18
|
+
export const listFunctions = async function (relativeSrcFolders, { featureFlags: inputFeatureFlags, config, configFileDirectories, parseISC = false, } = {}) {
|
|
18
19
|
const featureFlags = getFlags(inputFeatureFlags);
|
|
19
20
|
const srcFolders = resolveFunctionsDirectories(relativeSrcFolders);
|
|
20
21
|
const paths = await listFunctionsDirectories(srcFolders);
|
|
21
22
|
const cache = new RuntimeCache();
|
|
22
|
-
const functionsMap = await getFunctionsFromPaths(paths, { cache, config, featureFlags });
|
|
23
|
+
const functionsMap = await getFunctionsFromPaths(paths, { cache, config, configFileDirectories, featureFlags });
|
|
23
24
|
const functions = [...functionsMap.values()];
|
|
24
25
|
const augmentedFunctions = parseISC ? await Promise.all(functions.map(augmentWithISC)) : functions;
|
|
25
26
|
return augmentedFunctions.map(getListedFunction);
|
|
26
27
|
};
|
|
27
28
|
// Finds a function at a specific path.
|
|
28
|
-
export const listFunction = async function (path, { featureFlags: inputFeatureFlags, config, parseISC = false, } = {}) {
|
|
29
|
+
export const listFunction = async function (path, { featureFlags: inputFeatureFlags, config, configFileDirectories, parseISC = false, } = {}) {
|
|
29
30
|
const featureFlags = getFlags(inputFeatureFlags);
|
|
30
31
|
const cache = new RuntimeCache();
|
|
31
|
-
const func = await getFunctionFromPath(path, { cache, config, featureFlags });
|
|
32
|
+
const func = await getFunctionFromPath(path, { cache, config, configFileDirectories, featureFlags });
|
|
32
33
|
if (!func) {
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
@@ -36,19 +37,26 @@ export const listFunction = async function (path, { featureFlags: inputFeatureFl
|
|
|
36
37
|
return getListedFunction(augmentedFunction);
|
|
37
38
|
};
|
|
38
39
|
// List all Netlify Functions files for a specific directory
|
|
39
|
-
export const listFunctionsFiles = async function (relativeSrcFolders, { basePath, config, featureFlags: inputFeatureFlags, parseISC = false } = {}) {
|
|
40
|
+
export const listFunctionsFiles = async function (relativeSrcFolders, { basePath, config, configFileDirectories, featureFlags: inputFeatureFlags, parseISC = false, } = {}) {
|
|
40
41
|
const featureFlags = getFlags(inputFeatureFlags);
|
|
41
42
|
const srcFolders = resolveFunctionsDirectories(relativeSrcFolders);
|
|
42
43
|
const paths = await listFunctionsDirectories(srcFolders);
|
|
43
44
|
const cache = new RuntimeCache();
|
|
44
|
-
const functionsMap = await getFunctionsFromPaths(paths, { cache, config, featureFlags });
|
|
45
|
+
const functionsMap = await getFunctionsFromPaths(paths, { cache, config, configFileDirectories, featureFlags });
|
|
45
46
|
const functions = [...functionsMap.values()];
|
|
46
47
|
const augmentedFunctions = parseISC ? await Promise.all(functions.map(augmentWithISC)) : functions;
|
|
47
48
|
const listedFunctionsFiles = await Promise.all(augmentedFunctions.map((func) => getListedFunctionFiles(func, { basePath, featureFlags })));
|
|
48
49
|
return listedFunctionsFiles.flat();
|
|
49
50
|
};
|
|
50
51
|
const getListedFunction = function ({ runtime, name, mainFile, extension, config, inSourceConfig, }) {
|
|
51
|
-
return {
|
|
52
|
+
return {
|
|
53
|
+
name,
|
|
54
|
+
displayName: config.name,
|
|
55
|
+
mainFile,
|
|
56
|
+
runtime: runtime.name,
|
|
57
|
+
extension,
|
|
58
|
+
schedule: inSourceConfig?.schedule ?? config.schedule,
|
|
59
|
+
};
|
|
52
60
|
};
|
|
53
61
|
const getListedFunctionFiles = async function (func, options) {
|
|
54
62
|
const srcFiles = await getSrcFiles({ ...func, ...options });
|
package/dist/runtimes/index.d.ts
CHANGED
|
@@ -16,9 +16,10 @@ export declare const getFunctionsFromPaths: (paths: string[], { cache, config, c
|
|
|
16
16
|
/**
|
|
17
17
|
* Gets a list of functions found in a list of paths.
|
|
18
18
|
*/
|
|
19
|
-
export declare const getFunctionFromPath: (path: string, { cache, config, featureFlags }: {
|
|
19
|
+
export declare const getFunctionFromPath: (path: string, { cache, config, configFileDirectories, featureFlags, }: {
|
|
20
20
|
cache: RuntimeCache;
|
|
21
21
|
config?: Config | undefined;
|
|
22
|
+
configFileDirectories?: string[] | undefined;
|
|
22
23
|
featureFlags?: FeatureFlags | undefined;
|
|
23
24
|
}) => Promise<FunctionSource | undefined>;
|
|
24
25
|
export {};
|
package/dist/runtimes/index.js
CHANGED
|
@@ -66,11 +66,16 @@ export const getFunctionsFromPaths = async (paths, { cache, config, configFileDi
|
|
|
66
66
|
/**
|
|
67
67
|
* Gets a list of functions found in a list of paths.
|
|
68
68
|
*/
|
|
69
|
-
export const getFunctionFromPath = async (path, { cache, config, featureFlags = defaultFlags }) => {
|
|
69
|
+
export const getFunctionFromPath = async (path, { cache, config, configFileDirectories, featureFlags = defaultFlags, }) => {
|
|
70
70
|
for (const runtime of RUNTIMES) {
|
|
71
71
|
const func = await runtime.findFunctionInPath({ path, cache, featureFlags });
|
|
72
72
|
if (func) {
|
|
73
|
-
const functionConfig = await getConfigForFunction({
|
|
73
|
+
const functionConfig = await getConfigForFunction({
|
|
74
|
+
config,
|
|
75
|
+
configFileDirectories,
|
|
76
|
+
func: { ...func, runtime },
|
|
77
|
+
featureFlags,
|
|
78
|
+
});
|
|
74
79
|
return {
|
|
75
80
|
...func,
|
|
76
81
|
runtime,
|