@netlify/zip-it-and-ship-it 13.0.1 → 13.1.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/main.d.ts +4 -2
- package/dist/main.js +10 -3
- package/dist/paths.d.ts +35 -0
- package/dist/paths.js +39 -0
- package/dist/utils/fs.js +1 -0
- package/dist/zip.d.ts +2 -36
- package/dist/zip.js +1 -39
- package/package.json +2 -2
package/dist/main.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Config } from './config.js';
|
|
2
2
|
import { FeatureFlags } from './feature_flags.js';
|
|
3
|
+
import { type MixedPaths } from './paths.js';
|
|
3
4
|
import { ModuleFormat } from './runtimes/node/utils/module_format.js';
|
|
4
5
|
import { RuntimeName } from './runtimes/runtime.js';
|
|
5
6
|
import type { ExtendedRoute, Route } from './utils/routes.js';
|
|
6
7
|
export { Config, FunctionConfig } from './config.js';
|
|
7
|
-
export {
|
|
8
|
+
export { zipFunction, zipFunctions, ZipFunctionOptions, ZipFunctionsOptions } from './zip.js';
|
|
9
|
+
export type { FunctionsBag } from './paths.js';
|
|
8
10
|
export { ArchiveFormat, ARCHIVE_FORMAT } from './archive.js';
|
|
9
11
|
export type { TrafficRules } from './rate_limit.js';
|
|
10
12
|
export type { ExtendedRoute, Route } from './utils/routes.js';
|
|
@@ -37,7 +39,7 @@ interface ListFunctionsOptions {
|
|
|
37
39
|
featureFlags?: FeatureFlags;
|
|
38
40
|
parseISC?: boolean;
|
|
39
41
|
}
|
|
40
|
-
export declare const listFunctions: (
|
|
42
|
+
export declare const listFunctions: (input: MixedPaths, { featureFlags: inputFeatureFlags, config, configFileDirectories, parseISC }?: ListFunctionsOptions) => Promise<ListedFunction[]>;
|
|
41
43
|
interface ListFunctionOptions {
|
|
42
44
|
basePath?: string;
|
|
43
45
|
config?: Config;
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { extname } from 'path';
|
|
2
2
|
import { getFlags } from './feature_flags.js';
|
|
3
|
+
import { getFunctionsBag } from './paths.js';
|
|
3
4
|
import { getFunctionFromPath, getFunctionsFromPaths } from './runtimes/index.js';
|
|
4
5
|
import { parseFile } from './runtimes/node/in_source_config/index.js';
|
|
5
6
|
import { RUNTIME } from './runtimes/runtime.js';
|
|
@@ -20,12 +21,18 @@ const augmentWithStaticAnalysis = async (func) => {
|
|
|
20
21
|
return { ...func, staticAnalysisResult };
|
|
21
22
|
};
|
|
22
23
|
// List all Netlify Functions main entry files for a specific directory.
|
|
23
|
-
export const listFunctions = async function (
|
|
24
|
+
export const listFunctions = async function (input, { featureFlags: inputFeatureFlags, config, configFileDirectories, parseISC = false } = {}) {
|
|
24
25
|
const featureFlags = getFlags(inputFeatureFlags);
|
|
25
|
-
const
|
|
26
|
+
const bag = getFunctionsBag(input);
|
|
27
|
+
const srcFolders = resolveFunctionsDirectories([...bag.generated.directories, ...bag.user.directories]);
|
|
26
28
|
const paths = await listFunctionsDirectories(srcFolders);
|
|
27
29
|
const cache = new RuntimeCache();
|
|
28
|
-
const functionsMap = await getFunctionsFromPaths(paths,
|
|
30
|
+
const functionsMap = await getFunctionsFromPaths([...paths, ...bag.generated.functions, ...bag.user.functions], {
|
|
31
|
+
cache,
|
|
32
|
+
config,
|
|
33
|
+
configFileDirectories,
|
|
34
|
+
featureFlags,
|
|
35
|
+
});
|
|
29
36
|
const functions = [...functionsMap.values()];
|
|
30
37
|
const augmentedFunctions = parseISC
|
|
31
38
|
? await Promise.all(functions.map((func) => augmentWithStaticAnalysis(func)))
|
package/dist/paths.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface FunctionsBag {
|
|
2
|
+
generated: FunctionsCategory;
|
|
3
|
+
user: FunctionsCategory;
|
|
4
|
+
}
|
|
5
|
+
export interface FunctionsCategory {
|
|
6
|
+
/**
|
|
7
|
+
* List of paths for directories containing one or more functions. Entries in
|
|
8
|
+
* these directories are considered functions when they are files that match
|
|
9
|
+
* one of the supported extensions or when they are sub-directories that
|
|
10
|
+
* contain a function following the sub-directory naming patterns.
|
|
11
|
+
* Paths can be relative.
|
|
12
|
+
*/
|
|
13
|
+
directories: string[];
|
|
14
|
+
/**
|
|
15
|
+
* List of paths for specific functions. Paths can be files that match one
|
|
16
|
+
* of the supported extensions or sub-directories that contain a function
|
|
17
|
+
* following the sub-directory naming patterns. Paths can be relative.
|
|
18
|
+
*/
|
|
19
|
+
functions: string[];
|
|
20
|
+
}
|
|
21
|
+
export type MixedPaths = string | string[] | {
|
|
22
|
+
/**
|
|
23
|
+
* Functions generated on behalf of the user by a build plugin, extension
|
|
24
|
+
* or a framework.
|
|
25
|
+
*/
|
|
26
|
+
generated?: Partial<FunctionsCategory>;
|
|
27
|
+
/**
|
|
28
|
+
* Functions authored by the user.
|
|
29
|
+
*/
|
|
30
|
+
user?: Partial<FunctionsCategory>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Normalizes the `zipFunctions` input into a `FunctionsBag` object.
|
|
34
|
+
*/
|
|
35
|
+
export declare const getFunctionsBag: (input: MixedPaths) => FunctionsBag;
|
package/dist/paths.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes the `zipFunctions` input into a `FunctionsBag` object.
|
|
3
|
+
*/
|
|
4
|
+
export const getFunctionsBag = (input) => {
|
|
5
|
+
if (typeof input === 'string') {
|
|
6
|
+
return {
|
|
7
|
+
generated: {
|
|
8
|
+
directories: [],
|
|
9
|
+
functions: [],
|
|
10
|
+
},
|
|
11
|
+
user: {
|
|
12
|
+
directories: [input],
|
|
13
|
+
functions: [],
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
if (Array.isArray(input)) {
|
|
18
|
+
return {
|
|
19
|
+
generated: {
|
|
20
|
+
directories: [],
|
|
21
|
+
functions: [],
|
|
22
|
+
},
|
|
23
|
+
user: {
|
|
24
|
+
directories: input,
|
|
25
|
+
functions: [],
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
generated: {
|
|
31
|
+
directories: input.generated?.directories ?? [],
|
|
32
|
+
functions: input.generated?.functions ?? [],
|
|
33
|
+
},
|
|
34
|
+
user: {
|
|
35
|
+
directories: input.user?.directories ?? [],
|
|
36
|
+
functions: input.user?.functions ?? [],
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
};
|
package/dist/utils/fs.js
CHANGED
|
@@ -78,5 +78,6 @@ export const mkdirAndWriteFile = async (path, ...params) => {
|
|
|
78
78
|
const directory = dirname(path);
|
|
79
79
|
await fs.mkdir(directory, { recursive: true });
|
|
80
80
|
}
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
81
82
|
return fs.writeFile(path, ...params);
|
|
82
83
|
};
|
package/dist/zip.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ArchiveFormat } from './archive.js';
|
|
2
2
|
import { Config } from './config.js';
|
|
3
3
|
import { FeatureFlags } from './feature_flags.js';
|
|
4
|
+
import { type MixedPaths } from './paths.js';
|
|
4
5
|
import { FunctionResult } from './utils/format_result.js';
|
|
5
6
|
import { LogFunction } from './utils/logger.js';
|
|
6
7
|
export interface ZipFunctionOptions {
|
|
@@ -20,40 +21,5 @@ export type ZipFunctionsOptions = ZipFunctionOptions & {
|
|
|
20
21
|
manifest?: string;
|
|
21
22
|
parallelLimit?: number;
|
|
22
23
|
};
|
|
23
|
-
export
|
|
24
|
-
generated: FunctionsCategory;
|
|
25
|
-
user: FunctionsCategory;
|
|
26
|
-
}
|
|
27
|
-
export interface FunctionsCategory {
|
|
28
|
-
/**
|
|
29
|
-
* List of paths for directories containing one or more functions. Entries in
|
|
30
|
-
* these directories are considered functions when they are files that match
|
|
31
|
-
* one of the supported extensions or when they are sub-directories that
|
|
32
|
-
* contain a function following the sub-directory naming patterns.
|
|
33
|
-
* Paths can be relative.
|
|
34
|
-
*/
|
|
35
|
-
directories: string[];
|
|
36
|
-
/**
|
|
37
|
-
* List of paths for specific functions. Paths can be files that match one
|
|
38
|
-
* of the supported extensions or sub-directories that contain a function
|
|
39
|
-
* following the sub-directory naming patterns. Paths can be relative.
|
|
40
|
-
*/
|
|
41
|
-
functions: string[];
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Normalizes the `zipFunctions` input into a `FunctionsBag` object.
|
|
45
|
-
*/
|
|
46
|
-
export declare const getFunctionsBag: (input: ZipFunctionsPaths) => FunctionsBag;
|
|
47
|
-
export type ZipFunctionsPaths = string | string[] | {
|
|
48
|
-
/**
|
|
49
|
-
* Functions generated on behalf of the user by a build plugin, extension
|
|
50
|
-
* or a framework.
|
|
51
|
-
*/
|
|
52
|
-
generated?: Partial<FunctionsCategory>;
|
|
53
|
-
/**
|
|
54
|
-
* Functions authored by the user.
|
|
55
|
-
*/
|
|
56
|
-
user?: Partial<FunctionsCategory>;
|
|
57
|
-
};
|
|
58
|
-
export declare const zipFunctions: (input: ZipFunctionsPaths, destFolder: string, { archiveFormat, basePath, branch, config, configFileDirectories, featureFlags: inputFeatureFlags, manifest, parallelLimit, repositoryRoot, systemLog, debug, }?: ZipFunctionsOptions) => Promise<FunctionResult[]>;
|
|
24
|
+
export declare const zipFunctions: (input: MixedPaths, destFolder: string, { archiveFormat, basePath, branch, config, configFileDirectories, featureFlags: inputFeatureFlags, manifest, parallelLimit, repositoryRoot, systemLog, debug, }?: ZipFunctionsOptions) => Promise<FunctionResult[]>;
|
|
59
25
|
export declare const zipFunction: (relativeSrcPath: string, destFolder: string, { archiveFormat, basePath, config: inputConfig, featureFlags: inputFeatureFlags, repositoryRoot, systemLog, debug, internalSrcFolder, }?: ZipFunctionOptions) => Promise<FunctionResult | undefined>;
|
package/dist/zip.js
CHANGED
|
@@ -7,6 +7,7 @@ import { getFlags } from './feature_flags.js';
|
|
|
7
7
|
import { createManifest } from './manifest.js';
|
|
8
8
|
import { getFunctionsFromPaths } from './runtimes/index.js';
|
|
9
9
|
import { MODULE_FORMAT } from './runtimes/node/utils/module_format.js';
|
|
10
|
+
import { getFunctionsBag } from './paths.js';
|
|
10
11
|
import { addArchiveSize } from './utils/archive_size.js';
|
|
11
12
|
import { RuntimeCache } from './utils/cache.js';
|
|
12
13
|
import { formatZipResult } from './utils/format_result.js';
|
|
@@ -19,45 +20,6 @@ const validateArchiveFormat = (archiveFormat) => {
|
|
|
19
20
|
throw new Error(`Invalid archive format: ${archiveFormat}`);
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
|
-
/**
|
|
23
|
-
* Normalizes the `zipFunctions` input into a `FunctionsBag` object.
|
|
24
|
-
*/
|
|
25
|
-
export const getFunctionsBag = (input) => {
|
|
26
|
-
if (typeof input === 'string') {
|
|
27
|
-
return {
|
|
28
|
-
generated: {
|
|
29
|
-
directories: [],
|
|
30
|
-
functions: [],
|
|
31
|
-
},
|
|
32
|
-
user: {
|
|
33
|
-
directories: [input],
|
|
34
|
-
functions: [],
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
if (Array.isArray(input)) {
|
|
39
|
-
return {
|
|
40
|
-
generated: {
|
|
41
|
-
directories: [],
|
|
42
|
-
functions: [],
|
|
43
|
-
},
|
|
44
|
-
user: {
|
|
45
|
-
directories: input,
|
|
46
|
-
functions: [],
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
generated: {
|
|
52
|
-
directories: input.generated?.directories ?? [],
|
|
53
|
-
functions: input.generated?.functions ?? [],
|
|
54
|
-
},
|
|
55
|
-
user: {
|
|
56
|
-
directories: input.user?.directories ?? [],
|
|
57
|
-
functions: input.user?.functions ?? [],
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
23
|
// Zip `srcFolder/*` (Node.js or Go files) to `destFolder/*.zip` so it can be
|
|
62
24
|
// used by AWS Lambda
|
|
63
25
|
export const zipFunctions = async function (input, destFolder, { archiveFormat = ARCHIVE_FORMAT.ZIP, basePath, branch, config = {}, configFileDirectories, featureFlags: inputFeatureFlags, manifest, parallelLimit = DEFAULT_PARALLEL_LIMIT, repositoryRoot = basePath, systemLog, debug, } = {}) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/zip-it-and-ship-it",
|
|
3
|
-
"version": "13.0
|
|
3
|
+
"version": "13.1.0",
|
|
4
4
|
"description": "Zip it and ship it",
|
|
5
5
|
"main": "./dist/main.js",
|
|
6
6
|
"type": "module",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"engines": {
|
|
101
101
|
"node": ">=18.14.0"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "8b4d1bc0bf7986ac48b4cb46e92f04f8cd8be987"
|
|
104
104
|
}
|