@netlify/zip-it-and-ship-it 5.7.2 → 5.8.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 +19 -38
- package/dist/archive.d.ts +6 -8
- package/dist/bin.js +2 -2
- package/dist/config.d.ts +7 -8
- package/dist/feature_flags.d.ts +4 -6
- package/dist/feature_flags.js +3 -4
- package/dist/function.d.ts +5 -6
- package/dist/main.d.ts +7 -8
- package/dist/main.js +19 -19
- package/dist/manifest.d.ts +4 -5
- package/dist/runtimes/detect_runtime.d.ts +3 -4
- package/dist/runtimes/detect_runtime.js +2 -2
- package/dist/runtimes/go/builder.d.ts +1 -2
- package/dist/runtimes/go/builder.js +2 -2
- package/dist/runtimes/go/index.d.ts +1 -1
- package/dist/runtimes/go/index.js +13 -13
- package/dist/runtimes/index.d.ts +6 -6
- package/dist/runtimes/index.js +10 -10
- package/dist/runtimes/node/bundlers/esbuild/bundler.d.ts +6 -4
- package/dist/runtimes/node/bundlers/esbuild/bundler.js +23 -17
- package/dist/runtimes/node/bundlers/esbuild/bundler_target.d.ts +7 -1
- package/dist/runtimes/node/bundlers/esbuild/bundler_target.js +19 -3
- package/dist/runtimes/node/bundlers/esbuild/index.d.ts +2 -2
- package/dist/runtimes/node/bundlers/esbuild/index.js +15 -14
- package/dist/runtimes/node/bundlers/esbuild/plugin_dynamic_imports.d.ts +1 -2
- package/dist/runtimes/node/bundlers/esbuild/plugin_dynamic_imports.js +2 -2
- package/dist/runtimes/node/bundlers/esbuild/plugin_native_modules.d.ts +2 -3
- package/dist/runtimes/node/bundlers/esbuild/plugin_native_modules.js +2 -2
- package/dist/runtimes/node/bundlers/esbuild/plugin_node_builtin.d.ts +1 -2
- package/dist/runtimes/node/bundlers/esbuild/special_cases.d.ts +1 -2
- package/dist/runtimes/node/bundlers/esbuild/special_cases.js +2 -2
- package/dist/runtimes/node/bundlers/esbuild/src_files.d.ts +2 -3
- package/dist/runtimes/node/bundlers/esbuild/src_files.js +10 -10
- package/dist/runtimes/node/bundlers/index.d.ts +10 -11
- package/dist/runtimes/node/bundlers/index.js +12 -13
- package/dist/runtimes/node/bundlers/nft/es_modules.d.ts +5 -6
- package/dist/runtimes/node/bundlers/nft/es_modules.js +8 -8
- package/dist/runtimes/node/bundlers/nft/index.d.ts +2 -2
- package/dist/runtimes/node/bundlers/nft/index.js +14 -14
- package/dist/runtimes/node/bundlers/nft/transpile.d.ts +2 -3
- package/dist/runtimes/node/bundlers/nft/transpile.js +2 -2
- package/dist/runtimes/node/bundlers/zisi/index.d.ts +2 -2
- package/dist/runtimes/node/bundlers/zisi/index.js +5 -5
- package/dist/runtimes/node/bundlers/zisi/list_imports.d.ts +1 -2
- package/dist/runtimes/node/bundlers/zisi/list_imports.js +3 -3
- package/dist/runtimes/node/bundlers/zisi/nested.d.ts +3 -4
- package/dist/runtimes/node/bundlers/zisi/published.d.ts +1 -2
- package/dist/runtimes/node/bundlers/zisi/resolve.d.ts +2 -3
- package/dist/runtimes/node/bundlers/zisi/resolve.js +1 -1
- package/dist/runtimes/node/bundlers/zisi/side_files.d.ts +1 -2
- package/dist/runtimes/node/bundlers/zisi/side_files.js +2 -2
- package/dist/runtimes/node/bundlers/zisi/src_files.d.ts +2 -3
- package/dist/runtimes/node/bundlers/zisi/src_files.js +19 -19
- package/dist/runtimes/node/bundlers/zisi/traverse.d.ts +3 -4
- package/dist/runtimes/node/bundlers/zisi/traverse.js +15 -15
- package/dist/runtimes/node/bundlers/zisi/tree_files.d.ts +1 -2
- package/dist/runtimes/node/bundlers/zisi/tree_shake.d.ts +1 -2
- package/dist/runtimes/node/bundlers/zisi/tree_shake.js +2 -2
- package/dist/runtimes/node/finder.d.ts +3 -4
- package/dist/runtimes/node/finder.js +3 -3
- package/dist/runtimes/node/in_source_config/index.d.ts +6 -8
- package/dist/runtimes/node/in_source_config/index.js +13 -14
- package/dist/runtimes/node/in_source_config/properties/schedule.d.ts +1 -1
- package/dist/runtimes/node/index.d.ts +2 -2
- package/dist/runtimes/node/index.js +16 -16
- package/dist/runtimes/node/parser/exports.d.ts +2 -3
- package/dist/runtimes/node/parser/exports.js +2 -2
- package/dist/runtimes/node/parser/helpers.d.ts +3 -4
- package/dist/runtimes/node/parser/imports.d.ts +1 -2
- package/dist/runtimes/node/parser/imports.js +6 -6
- package/dist/runtimes/node/parser/index.d.ts +2 -3
- package/dist/runtimes/node/parser/index.js +2 -2
- package/dist/runtimes/node/utils/base_path.d.ts +1 -2
- package/dist/runtimes/node/utils/detect_es_module.d.ts +1 -2
- package/dist/runtimes/node/utils/detect_native_module.d.ts +2 -3
- package/dist/runtimes/node/utils/entry_file.d.ts +3 -4
- package/dist/runtimes/node/utils/entry_file.js +2 -2
- package/dist/runtimes/node/utils/included_files.d.ts +2 -3
- package/dist/runtimes/node/utils/module.d.ts +1 -2
- package/dist/runtimes/node/utils/node_version.d.ts +7 -7
- package/dist/runtimes/node/utils/node_version.js +4 -5
- package/dist/runtimes/node/utils/normalize_path.d.ts +1 -2
- package/dist/runtimes/node/utils/package_json.d.ts +9 -5
- package/dist/runtimes/node/utils/package_json.js +46 -21
- package/dist/runtimes/node/utils/plugin_modules_path.d.ts +2 -3
- package/dist/runtimes/node/utils/traversal_cache.d.ts +2 -3
- package/dist/runtimes/node/utils/zip.d.ts +4 -4
- package/dist/runtimes/node/utils/zip.js +14 -14
- package/dist/runtimes/runtime.d.ts +14 -15
- package/dist/runtimes/rust/builder.d.ts +2 -3
- package/dist/runtimes/rust/builder.js +8 -8
- package/dist/runtimes/rust/cargo_manifest.d.ts +1 -2
- package/dist/runtimes/rust/constants.d.ts +2 -3
- package/dist/runtimes/rust/constants.js +2 -4
- package/dist/runtimes/rust/index.d.ts +1 -1
- package/dist/runtimes/rust/index.js +17 -17
- package/dist/utils/archive_size.d.ts +2 -3
- package/dist/utils/format_result.d.ts +4 -6
- package/dist/utils/format_result.js +2 -2
- package/dist/utils/fs.d.ts +10 -12
- package/dist/utils/fs.js +7 -10
- package/dist/utils/non_nullable.d.ts +1 -2
- package/dist/utils/remove_undefined.d.ts +1 -2
- package/dist/zip.d.ts +7 -7
- package/dist/zip.js +19 -19
- package/dist/zip_binary.d.ts +2 -3
- package/dist/zip_binary.js +5 -5
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -32,15 +32,11 @@ npm install @netlify/zip-it-and-ship-it
|
|
|
32
32
|
- _Return value_: `Promise<object[]>`
|
|
33
33
|
|
|
34
34
|
```js
|
|
35
|
-
|
|
35
|
+
import { zipFunctions } from '@netlify/zip-it-and-ship-it'
|
|
36
36
|
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
return archives
|
|
43
|
-
}
|
|
37
|
+
const archives = await zipFunctions('functions', 'functions-dist', {
|
|
38
|
+
archiveFormat: 'zip',
|
|
39
|
+
})
|
|
44
40
|
```
|
|
45
41
|
|
|
46
42
|
Creates Zip `archives` from Node.js, Go, and Rust programs. Those `archives` are ready to be uploaded to AWS Lambda.
|
|
@@ -258,13 +254,9 @@ Additionally, the following properties also exist for Node.js functions:
|
|
|
258
254
|
- _Return value_: `object | undefined`
|
|
259
255
|
|
|
260
256
|
```js
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
const zipNetlifyFunctions = async function () {
|
|
264
|
-
const archive = await zipFunctions('functions/function.js', 'functions-dist')
|
|
257
|
+
import { zipFunction } from '@netlify/zip-it-and-ship-it'
|
|
265
258
|
|
|
266
|
-
|
|
267
|
-
}
|
|
259
|
+
const archive = await zipFunctions('functions/function.js', 'functions-dist')
|
|
268
260
|
```
|
|
269
261
|
|
|
270
262
|
This is like [`zipFunctions()`](#zipfunctionssrcfolder-destfolder-options) except it bundles a single Function.
|
|
@@ -276,13 +268,9 @@ The return value is `undefined` if the function is invalid.
|
|
|
276
268
|
Returns the list of functions to bundle.
|
|
277
269
|
|
|
278
270
|
```js
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const listNetlifyFunctions = async function () {
|
|
282
|
-
const functions = await listFunctions('functions/function.js')
|
|
271
|
+
import { listFunctions } from '@netlify/zip-it-and-ship-it'
|
|
283
272
|
|
|
284
|
-
|
|
285
|
-
}
|
|
273
|
+
const functions = await listFunctions('functions/function.js')
|
|
286
274
|
```
|
|
287
275
|
|
|
288
276
|
### `srcFolders`
|
|
@@ -326,12 +314,9 @@ Like [`listFunctions()`](#listfunctionssrcfolder), except it returns not only th
|
|
|
326
314
|
their required files. This is much slower.
|
|
327
315
|
|
|
328
316
|
```js
|
|
329
|
-
|
|
317
|
+
import { listFunctionsFiles } from '@netlify/zip-it-and-ship-it'
|
|
330
318
|
|
|
331
|
-
const
|
|
332
|
-
const functions = await listFunctionsFiles('functions/function.js')
|
|
333
|
-
return functions
|
|
334
|
-
}
|
|
319
|
+
const functions = await listFunctionsFiles('functions/function.js')
|
|
335
320
|
```
|
|
336
321
|
|
|
337
322
|
### `srcFolders`
|
|
@@ -400,20 +385,16 @@ included in the bundle.
|
|
|
400
385
|
You can enable esbuild by setting the [`config` option](#config) when calling `zipFunction` or `zipFunctions`:
|
|
401
386
|
|
|
402
387
|
```js
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
const zipNetlifyFunctions = async function () {
|
|
406
|
-
const archives = await zipFunctions('functions', 'functions-dist', {
|
|
407
|
-
config: {
|
|
408
|
-
// Applying these settings to all functions.
|
|
409
|
-
'*': {
|
|
410
|
-
nodeBundler: 'esbuild',
|
|
411
|
-
},
|
|
412
|
-
},
|
|
413
|
-
})
|
|
388
|
+
import { zipFunctions } from '@netlify/zip-it-and-ship-it'
|
|
414
389
|
|
|
415
|
-
|
|
416
|
-
|
|
390
|
+
const archives = await zipFunctions('functions', 'functions-dist', {
|
|
391
|
+
config: {
|
|
392
|
+
// Applying these settings to all functions.
|
|
393
|
+
'*': {
|
|
394
|
+
nodeBundler: 'esbuild',
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
})
|
|
417
398
|
```
|
|
418
399
|
|
|
419
400
|
# Feature flags
|
package/dist/archive.d.ts
CHANGED
|
@@ -2,14 +2,12 @@ import { Buffer } from 'buffer';
|
|
|
2
2
|
import { Stats } from 'fs';
|
|
3
3
|
import { Writable } from 'stream';
|
|
4
4
|
import { Archiver } from 'archiver';
|
|
5
|
-
|
|
6
|
-
declare
|
|
5
|
+
export { Archiver as ZipArchive } from 'archiver';
|
|
6
|
+
export declare type ArchiveFormat = 'none' | 'zip';
|
|
7
|
+
export declare const startZip: (destPath: string) => {
|
|
7
8
|
archive: Archiver;
|
|
8
9
|
output: Writable;
|
|
9
10
|
};
|
|
10
|
-
declare const addZipFile: (archive: Archiver, file: string, name: string, stat: Stats) => void;
|
|
11
|
-
declare const addZipContent: (archive: Archiver, content: Buffer | string, name: string) => void;
|
|
12
|
-
declare const endZip: (archive: Archiver, output: Writable) => Promise<void>;
|
|
13
|
-
export { startZip, addZipFile, addZipContent, endZip };
|
|
14
|
-
export type { ArchiveFormat };
|
|
15
|
-
export { Archiver as ZipArchive } from 'archiver';
|
|
11
|
+
export declare const addZipFile: (archive: Archiver, file: string, name: string, stat: Stats) => void;
|
|
12
|
+
export declare const addZipContent: (archive: Archiver, content: Buffer | string, name: string) => void;
|
|
13
|
+
export declare const endZip: (archive: Archiver, output: Writable) => Promise<void>;
|
package/dist/bin.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
const process_1 = require("process");
|
|
8
8
|
const yargs_1 = __importDefault(require("yargs"));
|
|
9
9
|
const helpers_1 = require("yargs/helpers");
|
|
10
|
-
const
|
|
10
|
+
const main_js_1 = require("./main.js");
|
|
11
11
|
// CLI entry point
|
|
12
12
|
const runCli = async function () {
|
|
13
13
|
// @ts-expect-error TODO: `destFolder` and `srcFolder` are not being passed
|
|
@@ -15,7 +15,7 @@ const runCli = async function () {
|
|
|
15
15
|
const { destFolder, srcFolder, ...options } = parseArgs();
|
|
16
16
|
try {
|
|
17
17
|
// @ts-expect-error TODO: `options` is not getting the right types.
|
|
18
|
-
const zipped = await (0,
|
|
18
|
+
const zipped = await (0, main_js_1.zipFunctions)(srcFolder, destFolder, options);
|
|
19
19
|
console.log(JSON.stringify(zipped, null, 2));
|
|
20
20
|
}
|
|
21
21
|
catch (error) {
|
package/dist/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FunctionSource } from './function';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
interface FunctionConfig {
|
|
1
|
+
import { FunctionSource } from './function.js';
|
|
2
|
+
import type { NodeBundlerName } from './runtimes/node/bundlers/index.js';
|
|
3
|
+
import type { NodeVersionString } from './runtimes/node/index.js';
|
|
4
|
+
export interface FunctionConfig {
|
|
5
5
|
externalNodeModules?: string[];
|
|
6
6
|
includedFiles?: string[];
|
|
7
7
|
includedFilesBasePath?: string;
|
|
@@ -15,10 +15,9 @@ interface FunctionConfig {
|
|
|
15
15
|
zipGo?: boolean;
|
|
16
16
|
}
|
|
17
17
|
declare type GlobPattern = string;
|
|
18
|
-
declare type Config = Record<GlobPattern, FunctionConfig>;
|
|
19
|
-
declare const getConfigForFunction: ({ config, func, }: {
|
|
18
|
+
export declare type Config = Record<GlobPattern, FunctionConfig>;
|
|
19
|
+
export declare const getConfigForFunction: ({ config, func, }: {
|
|
20
20
|
config?: Config | undefined;
|
|
21
21
|
func: Omit<FunctionSource, 'config'>;
|
|
22
22
|
}) => FunctionConfig;
|
|
23
|
-
export {
|
|
24
|
-
export type { Config, FunctionConfig };
|
|
23
|
+
export {};
|
package/dist/feature_flags.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
declare type FeatureFlag = keyof typeof
|
|
3
|
-
declare type FeatureFlags = Record<FeatureFlag, boolean>;
|
|
4
|
-
declare const getFlags: (input?: Record<string, boolean>, flags?: Record<string, boolean>) => {};
|
|
5
|
-
export { FLAGS as defaultFlags, getFlags };
|
|
6
|
-
export type { FeatureFlag, FeatureFlags };
|
|
1
|
+
export declare const defaultFlags: Record<string, boolean>;
|
|
2
|
+
export declare type FeatureFlag = keyof typeof defaultFlags;
|
|
3
|
+
export declare type FeatureFlags = Record<FeatureFlag, boolean>;
|
|
4
|
+
export declare const getFlags: (input?: Record<string, boolean>, flags?: Record<string, boolean>) => {};
|
package/dist/feature_flags.js
CHANGED
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFlags = exports.defaultFlags = void 0;
|
|
4
4
|
const process_1 = require("process");
|
|
5
|
-
|
|
5
|
+
exports.defaultFlags = {
|
|
6
6
|
buildGoSource: Boolean(process_1.env.NETLIFY_EXPERIMENTAL_BUILD_GO_SOURCE),
|
|
7
7
|
buildRustSource: Boolean(process_1.env.NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE),
|
|
8
|
-
defaultEsModulesToEsbuild: Boolean(process_1.env.NETLIFY_EXPERIMENTAL_DEFAULT_ES_MODULES_TO_ESBUILD),
|
|
9
8
|
parseWithEsbuild: false,
|
|
10
9
|
traceWithNft: false,
|
|
10
|
+
zisi_detect_esm: false,
|
|
11
11
|
zisi_pure_esm: false,
|
|
12
12
|
};
|
|
13
|
-
exports.defaultFlags = FLAGS;
|
|
14
13
|
// List of supported flags and their default value.
|
|
15
|
-
const getFlags = (input = {}, flags =
|
|
14
|
+
const getFlags = (input = {}, flags = exports.defaultFlags) => Object.entries(flags).reduce((result, [key, defaultValue]) => ({
|
|
16
15
|
...result,
|
|
17
16
|
[key]: input[key] === undefined ? defaultValue : input[key],
|
|
18
17
|
}), {});
|
package/dist/function.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Stats } from 'fs';
|
|
3
|
-
import type { FunctionConfig } from './config';
|
|
4
|
-
import type { Runtime, ZipFunctionResult } from './runtimes/runtime';
|
|
5
|
-
declare type FunctionArchive = ZipFunctionResult & {
|
|
3
|
+
import type { FunctionConfig } from './config.js';
|
|
4
|
+
import type { Runtime, ZipFunctionResult } from './runtimes/runtime.js';
|
|
5
|
+
export declare type FunctionArchive = ZipFunctionResult & {
|
|
6
6
|
mainFile: string;
|
|
7
7
|
name: string;
|
|
8
8
|
runtime: Runtime;
|
|
9
9
|
size?: number;
|
|
10
10
|
};
|
|
11
|
-
interface SourceFile {
|
|
11
|
+
export interface SourceFile {
|
|
12
12
|
extension: string;
|
|
13
13
|
filename: string;
|
|
14
14
|
mainFile: string;
|
|
@@ -17,8 +17,7 @@ interface SourceFile {
|
|
|
17
17
|
srcPath: string;
|
|
18
18
|
stat: Stats;
|
|
19
19
|
}
|
|
20
|
-
declare type FunctionSource = SourceFile & {
|
|
20
|
+
export declare type FunctionSource = SourceFile & {
|
|
21
21
|
config: FunctionConfig;
|
|
22
22
|
runtime: Runtime;
|
|
23
23
|
};
|
|
24
|
-
export { FunctionArchive, FunctionSource, SourceFile };
|
package/dist/main.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Config } from './config';
|
|
2
|
-
import { FeatureFlags } from './feature_flags';
|
|
3
|
-
import { RuntimeName } from './runtimes/runtime';
|
|
1
|
+
import { Config } from './config.js';
|
|
2
|
+
import { FeatureFlags } from './feature_flags.js';
|
|
3
|
+
import { RuntimeName } from './runtimes/runtime.js';
|
|
4
|
+
export { zipFunction, zipFunctions } from './zip.js';
|
|
4
5
|
interface ListedFunction {
|
|
5
6
|
name: string;
|
|
6
7
|
mainFile: string;
|
|
@@ -17,16 +18,14 @@ interface ListFunctionsOptions {
|
|
|
17
18
|
featureFlags?: FeatureFlags;
|
|
18
19
|
parseISC?: boolean;
|
|
19
20
|
}
|
|
20
|
-
declare const listFunctions: (relativeSrcFolders: string | string[], { featureFlags: inputFeatureFlags, config, parseISC, }?: {
|
|
21
|
+
export declare const listFunctions: (relativeSrcFolders: string | string[], { featureFlags: inputFeatureFlags, config, parseISC, }?: {
|
|
21
22
|
featureFlags?: FeatureFlags | undefined;
|
|
22
23
|
config?: Config | undefined;
|
|
23
24
|
parseISC?: boolean | undefined;
|
|
24
25
|
}) => Promise<ListedFunction[]>;
|
|
25
|
-
declare const listFunction: (path: string, { featureFlags: inputFeatureFlags, config, parseISC, }?: {
|
|
26
|
+
export declare const listFunction: (path: string, { featureFlags: inputFeatureFlags, config, parseISC, }?: {
|
|
26
27
|
featureFlags?: FeatureFlags | undefined;
|
|
27
28
|
config?: Config | undefined;
|
|
28
29
|
parseISC?: boolean | undefined;
|
|
29
30
|
}) => Promise<ListedFunction | undefined>;
|
|
30
|
-
declare const listFunctionsFiles: (relativeSrcFolders: string | string[], { basePath, config, featureFlags: inputFeatureFlags, parseISC }?: ListFunctionsOptions) => Promise<ListedFunctionFile[]>;
|
|
31
|
-
export { listFunctions, listFunction, listFunctionsFiles };
|
|
32
|
-
export { zipFunction, zipFunctions } from './zip';
|
|
31
|
+
export declare const listFunctionsFiles: (relativeSrcFolders: string | string[], { basePath, config, featureFlags: inputFeatureFlags, parseISC }?: ListFunctionsOptions) => Promise<ListedFunctionFile[]>;
|
package/dist/main.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.listFunctionsFiles = exports.listFunction = exports.listFunctions = exports.zipFunctions = exports.zipFunction = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
5
|
+
const feature_flags_js_1 = require("./feature_flags.js");
|
|
6
|
+
const index_js_1 = require("./runtimes/index.js");
|
|
7
|
+
const index_js_2 = require("./runtimes/node/in_source_config/index.js");
|
|
8
|
+
const fs_js_1 = require("./utils/fs.js");
|
|
9
|
+
var zip_js_1 = require("./zip.js");
|
|
10
|
+
Object.defineProperty(exports, "zipFunction", { enumerable: true, get: function () { return zip_js_1.zipFunction; } });
|
|
11
|
+
Object.defineProperty(exports, "zipFunctions", { enumerable: true, get: function () { return zip_js_1.zipFunctions; } });
|
|
9
12
|
const augmentWithISC = async (func) => {
|
|
10
13
|
// ISC is currently only supported in JavaScript and TypeScript functions.
|
|
11
14
|
if (func.runtime.name !== 'js') {
|
|
12
15
|
return func;
|
|
13
16
|
}
|
|
14
|
-
const inSourceConfig = await (0,
|
|
17
|
+
const inSourceConfig = await (0, index_js_2.findISCDeclarationsInPath)(func.mainFile);
|
|
15
18
|
return { ...func, inSourceConfig };
|
|
16
19
|
};
|
|
17
20
|
// List all Netlify Functions main entry files for a specific directory
|
|
18
21
|
const listFunctions = async function (relativeSrcFolders, { featureFlags: inputFeatureFlags, config, parseISC = false, } = {}) {
|
|
19
|
-
const featureFlags = (0,
|
|
20
|
-
const srcFolders = (0,
|
|
21
|
-
const paths = await (0,
|
|
22
|
-
const functionsMap = await (0,
|
|
22
|
+
const featureFlags = (0, feature_flags_js_1.getFlags)(inputFeatureFlags);
|
|
23
|
+
const srcFolders = (0, fs_js_1.resolveFunctionsDirectories)(relativeSrcFolders);
|
|
24
|
+
const paths = await (0, fs_js_1.listFunctionsDirectories)(srcFolders);
|
|
25
|
+
const functionsMap = await (0, index_js_1.getFunctionsFromPaths)(paths, { featureFlags, config });
|
|
23
26
|
const functions = [...functionsMap.values()];
|
|
24
27
|
const augmentedFunctions = parseISC ? await Promise.all(functions.map(augmentWithISC)) : functions;
|
|
25
28
|
return augmentedFunctions.map(getListedFunction);
|
|
@@ -27,8 +30,8 @@ const listFunctions = async function (relativeSrcFolders, { featureFlags: inputF
|
|
|
27
30
|
exports.listFunctions = listFunctions;
|
|
28
31
|
// Finds a function at a specific path.
|
|
29
32
|
const listFunction = async function (path, { featureFlags: inputFeatureFlags, config, parseISC = false, } = {}) {
|
|
30
|
-
const featureFlags = (0,
|
|
31
|
-
const func = await (0,
|
|
33
|
+
const featureFlags = (0, feature_flags_js_1.getFlags)(inputFeatureFlags);
|
|
34
|
+
const func = await (0, index_js_1.getFunctionFromPath)(path, { featureFlags, config });
|
|
32
35
|
if (!func) {
|
|
33
36
|
return;
|
|
34
37
|
}
|
|
@@ -38,10 +41,10 @@ const listFunction = async function (path, { featureFlags: inputFeatureFlags, co
|
|
|
38
41
|
exports.listFunction = listFunction;
|
|
39
42
|
// List all Netlify Functions files for a specific directory
|
|
40
43
|
const listFunctionsFiles = async function (relativeSrcFolders, { basePath, config, featureFlags: inputFeatureFlags, parseISC = false } = {}) {
|
|
41
|
-
const featureFlags = (0,
|
|
42
|
-
const srcFolders = (0,
|
|
43
|
-
const paths = await (0,
|
|
44
|
-
const functionsMap = await (0,
|
|
44
|
+
const featureFlags = (0, feature_flags_js_1.getFlags)(inputFeatureFlags);
|
|
45
|
+
const srcFolders = (0, fs_js_1.resolveFunctionsDirectories)(relativeSrcFolders);
|
|
46
|
+
const paths = await (0, fs_js_1.listFunctionsDirectories)(srcFolders);
|
|
47
|
+
const functionsMap = await (0, index_js_1.getFunctionsFromPaths)(paths, { config, featureFlags });
|
|
45
48
|
const functions = [...functionsMap.values()];
|
|
46
49
|
const augmentedFunctions = parseISC ? await Promise.all(functions.map(augmentWithISC)) : functions;
|
|
47
50
|
const listedFunctionsFiles = await Promise.all(augmentedFunctions.map((func) => getListedFunctionFiles(func, { basePath, featureFlags })));
|
|
@@ -68,7 +71,4 @@ const getSrcFiles = async function ({ extension, runtime, srcPath, ...args }) {
|
|
|
68
71
|
...args,
|
|
69
72
|
});
|
|
70
73
|
};
|
|
71
|
-
var zip_1 = require("./zip");
|
|
72
|
-
Object.defineProperty(exports, "zipFunction", { enumerable: true, get: function () { return zip_1.zipFunction; } });
|
|
73
|
-
Object.defineProperty(exports, "zipFunctions", { enumerable: true, get: function () { return zip_1.zipFunctions; } });
|
|
74
74
|
//# sourceMappingURL=main.js.map
|
package/dist/manifest.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FunctionResult } from './utils/format_result';
|
|
1
|
+
import { FunctionResult } from './utils/format_result.js';
|
|
2
2
|
interface ManifestFunction {
|
|
3
3
|
mainFile: string;
|
|
4
4
|
name: string;
|
|
@@ -6,7 +6,7 @@ interface ManifestFunction {
|
|
|
6
6
|
runtime: string;
|
|
7
7
|
schedule?: string;
|
|
8
8
|
}
|
|
9
|
-
interface Manifest {
|
|
9
|
+
export interface Manifest {
|
|
10
10
|
functions: ManifestFunction[];
|
|
11
11
|
system: {
|
|
12
12
|
arch: string;
|
|
@@ -15,9 +15,8 @@ interface Manifest {
|
|
|
15
15
|
timestamp: number;
|
|
16
16
|
version: number;
|
|
17
17
|
}
|
|
18
|
-
declare const createManifest: ({ functions, path }: {
|
|
18
|
+
export declare const createManifest: ({ functions, path }: {
|
|
19
19
|
functions: FunctionResult[];
|
|
20
20
|
path: string;
|
|
21
21
|
}) => Promise<void>;
|
|
22
|
-
export {
|
|
23
|
-
export type { Manifest };
|
|
22
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { FsCache } from '../utils/fs';
|
|
2
|
-
import type { RuntimeName } from './runtime';
|
|
3
|
-
declare const detectBinaryRuntime: ({ fsCache, path, }: {
|
|
1
|
+
import { FsCache } from '../utils/fs.js';
|
|
2
|
+
import type { RuntimeName } from './runtime.js';
|
|
3
|
+
export declare const detectBinaryRuntime: ({ fsCache, path, }: {
|
|
4
4
|
fsCache: FsCache;
|
|
5
5
|
path: string;
|
|
6
6
|
}) => Promise<RuntimeName | undefined>;
|
|
7
|
-
export { detectBinaryRuntime };
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.detectBinaryRuntime = void 0;
|
|
4
4
|
const elf_cam_1 = require("elf-cam");
|
|
5
|
-
const
|
|
5
|
+
const fs_js_1 = require("../utils/fs.js");
|
|
6
6
|
// Try to guess the runtime by inspecting the binary file.
|
|
7
7
|
const detectBinaryRuntime = async function ({ fsCache, path, }) {
|
|
8
8
|
try {
|
|
9
|
-
const buffer = await (0,
|
|
9
|
+
const buffer = await (0, fs_js_1.cachedReadFile)(fsCache, path);
|
|
10
10
|
// We're using the Type Assertion because the `cachedReadFile` abstraction
|
|
11
11
|
// loses part of the return type information. We can safely say it's a
|
|
12
12
|
// Buffer in this case because we're not specifying an encoding.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
declare const build: ({ destPath, mainFile, srcDir }: {
|
|
2
|
+
export declare const build: ({ destPath, mainFile, srcDir }: {
|
|
3
3
|
destPath: string;
|
|
4
4
|
mainFile: string;
|
|
5
5
|
srcDir: string;
|
|
@@ -10,4 +10,3 @@ declare const build: ({ destPath, mainFile, srcDir }: {
|
|
|
10
10
|
srcPath: string;
|
|
11
11
|
stat: import("fs").Stats;
|
|
12
12
|
}>;
|
|
13
|
-
export { build };
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.build = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
-
const
|
|
6
|
+
const shell_js_1 = require("../../utils/shell.js");
|
|
7
7
|
const build = async ({ destPath, mainFile, srcDir }) => {
|
|
8
8
|
const functionName = (0, path_1.basename)(srcDir);
|
|
9
9
|
try {
|
|
10
|
-
await
|
|
10
|
+
await shell_js_1.shellUtils.runCommand('go', ['build', '-o', destPath, '-ldflags', '-s -w'], {
|
|
11
11
|
cwd: srcDir,
|
|
12
12
|
env: {
|
|
13
13
|
CGO_ENABLED: '0',
|
|
@@ -5,20 +5,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const cp_file_1 = __importDefault(require("cp-file"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
8
|
+
const fs_js_1 = require("../../utils/fs.js");
|
|
9
|
+
const non_nullable_js_1 = require("../../utils/non_nullable.js");
|
|
10
|
+
const zip_binary_js_1 = require("../../zip_binary.js");
|
|
11
|
+
const detect_runtime_js_1 = require("../detect_runtime.js");
|
|
12
|
+
const builder_js_1 = require("./builder.js");
|
|
13
13
|
const detectGoFunction = async ({ fsCache, path }) => {
|
|
14
|
-
const stat = await (0,
|
|
14
|
+
const stat = await (0, fs_js_1.cachedLstat)(fsCache, path);
|
|
15
15
|
if (!stat.isDirectory()) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
const directoryName = (0, path_1.basename)(path);
|
|
19
19
|
// @ts-expect-error TODO: The `makeCachedFunction` abstraction is causing the
|
|
20
20
|
// return value of `readdir` to be incorrectly typed.
|
|
21
|
-
const files = (await (0,
|
|
21
|
+
const files = (await (0, fs_js_1.cachedReaddir)(fsCache, path));
|
|
22
22
|
const mainFileName = [`${directoryName}.go`, 'main.go'].find((name) => files.includes(name));
|
|
23
23
|
if (mainFileName === undefined) {
|
|
24
24
|
return;
|
|
@@ -27,10 +27,10 @@ const detectGoFunction = async ({ fsCache, path }) => {
|
|
|
27
27
|
};
|
|
28
28
|
const findFunctionsInPaths = async function ({ featureFlags, fsCache, paths }) {
|
|
29
29
|
const functions = await Promise.all(paths.map((path) => findFunctionInPath({ featureFlags, fsCache, path })));
|
|
30
|
-
return functions.filter(
|
|
30
|
+
return functions.filter(non_nullable_js_1.nonNullable);
|
|
31
31
|
};
|
|
32
32
|
const findFunctionInPath = async function ({ featureFlags, fsCache, path }) {
|
|
33
|
-
const runtime = await (0,
|
|
33
|
+
const runtime = await (0, detect_runtime_js_1.detectBinaryRuntime)({ fsCache, path });
|
|
34
34
|
if (runtime === 'go') {
|
|
35
35
|
return processBinary({ fsCache, path });
|
|
36
36
|
}
|
|
@@ -43,7 +43,7 @@ const findFunctionInPath = async function ({ featureFlags, fsCache, path }) {
|
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
const processBinary = async ({ fsCache, path }) => {
|
|
46
|
-
const stat = (await (0,
|
|
46
|
+
const stat = (await (0, fs_js_1.cachedLstat)(fsCache, path));
|
|
47
47
|
const extension = (0, path_1.extname)(path);
|
|
48
48
|
const filename = (0, path_1.basename)(path);
|
|
49
49
|
const name = (0, path_1.basename)(path, (0, path_1.extname)(path));
|
|
@@ -62,7 +62,7 @@ const processSource = async ({ fsCache, mainFile, path, }) => {
|
|
|
62
62
|
// the `FunctionSource` interface. We should revisit whether `stat` should be
|
|
63
63
|
// part of that interface in the first place, or whether we could compute it
|
|
64
64
|
// downstream when needed (maybe using the FS cache as an optimisation).
|
|
65
|
-
const stat = (await (0,
|
|
65
|
+
const stat = (await (0, fs_js_1.cachedLstat)(fsCache, path));
|
|
66
66
|
const filename = (0, path_1.basename)(path);
|
|
67
67
|
const extension = (0, path_1.extname)(mainFile);
|
|
68
68
|
const name = (0, path_1.basename)(path, (0, path_1.extname)(path));
|
|
@@ -86,7 +86,7 @@ const zipFunction = async function ({ config, destFolder, filename, mainFile, sr
|
|
|
86
86
|
// If we're building a Go function from source, we call the build method and
|
|
87
87
|
// update `binary` to point to the newly-created binary.
|
|
88
88
|
if (isSource) {
|
|
89
|
-
const { stat: binaryStat } = await (0,
|
|
89
|
+
const { stat: binaryStat } = await (0, builder_js_1.build)({ destPath, mainFile, srcDir });
|
|
90
90
|
binary = {
|
|
91
91
|
path: destPath,
|
|
92
92
|
stat: binaryStat,
|
|
@@ -101,7 +101,7 @@ const zipFunction = async function ({ config, destFolder, filename, mainFile, sr
|
|
|
101
101
|
filename: (0, path_1.basename)(destPath),
|
|
102
102
|
runtime,
|
|
103
103
|
};
|
|
104
|
-
await (0,
|
|
104
|
+
await (0, zip_binary_js_1.zipBinary)({ ...zipOptions, srcPath: binary.path, stat: binary.stat });
|
|
105
105
|
return { config, path: zipPath };
|
|
106
106
|
}
|
|
107
107
|
// We don't need to zip the binary, so we can just copy it to the right path.
|
package/dist/runtimes/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Config } from '../config';
|
|
2
|
-
import { FeatureFlags } from '../feature_flags';
|
|
3
|
-
import { FunctionSource } from '../function';
|
|
1
|
+
import { Config } from '../config.js';
|
|
2
|
+
import { FeatureFlags } from '../feature_flags.js';
|
|
3
|
+
import { FunctionSource } from '../function.js';
|
|
4
4
|
declare type FunctionMap = Map<string, FunctionSource>;
|
|
5
5
|
/**
|
|
6
6
|
* Gets a list of functions found in a list of paths.
|
|
7
7
|
*/
|
|
8
|
-
declare const getFunctionsFromPaths: (paths: string[], { config, dedupe, featureFlags, }?: {
|
|
8
|
+
export declare const getFunctionsFromPaths: (paths: string[], { config, dedupe, featureFlags, }?: {
|
|
9
9
|
config?: Config | undefined;
|
|
10
10
|
dedupe?: boolean | undefined;
|
|
11
11
|
featureFlags?: FeatureFlags | undefined;
|
|
@@ -13,8 +13,8 @@ declare const getFunctionsFromPaths: (paths: string[], { config, dedupe, feature
|
|
|
13
13
|
/**
|
|
14
14
|
* Gets a list of functions found in a list of paths.
|
|
15
15
|
*/
|
|
16
|
-
declare const getFunctionFromPath: (path: string, { config, featureFlags }?: {
|
|
16
|
+
export declare const getFunctionFromPath: (path: string, { config, featureFlags }?: {
|
|
17
17
|
config?: Config | undefined;
|
|
18
18
|
featureFlags?: FeatureFlags | undefined;
|
|
19
19
|
}) => Promise<FunctionSource | undefined>;
|
|
20
|
-
export {
|
|
20
|
+
export {};
|
package/dist/runtimes/index.js
CHANGED
|
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getFunctionFromPath = exports.getFunctionsFromPaths = void 0;
|
|
7
7
|
const path_1 = require("path");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
8
|
+
const config_js_1 = require("../config.js");
|
|
9
|
+
const feature_flags_js_1 = require("../feature_flags.js");
|
|
10
|
+
const index_js_1 = __importDefault(require("./go/index.js"));
|
|
11
|
+
const index_js_2 = __importDefault(require("./node/index.js"));
|
|
12
|
+
const index_js_3 = __importDefault(require("./rust/index.js"));
|
|
13
13
|
/**
|
|
14
14
|
* Finds functions for a list of paths using a specific runtime. The return
|
|
15
15
|
* value is an object containing an array of the functions found (`functions`)
|
|
@@ -43,11 +43,11 @@ const makeFsCache = () => ({});
|
|
|
43
43
|
// The order of this array determines the priority of the runtimes. If a path
|
|
44
44
|
// is used by the first time, it won't be made available to the subsequent
|
|
45
45
|
// runtimes.
|
|
46
|
-
const RUNTIMES = [
|
|
46
|
+
const RUNTIMES = [index_js_2.default, index_js_1.default, index_js_3.default];
|
|
47
47
|
/**
|
|
48
48
|
* Gets a list of functions found in a list of paths.
|
|
49
49
|
*/
|
|
50
|
-
const getFunctionsFromPaths = async (paths, { config, dedupe = false, featureFlags =
|
|
50
|
+
const getFunctionsFromPaths = async (paths, { config, dedupe = false, featureFlags = feature_flags_js_1.defaultFlags, } = {}) => {
|
|
51
51
|
const fsCache = makeFsCache();
|
|
52
52
|
// We cycle through the ordered array of runtimes, passing each one of them
|
|
53
53
|
// through `findFunctionsInRuntime`. For each iteration, we collect all the
|
|
@@ -69,7 +69,7 @@ const getFunctionsFromPaths = async (paths, { config, dedupe = false, featureFla
|
|
|
69
69
|
}, Promise.resolve({ functions: [], remainingPaths: paths }));
|
|
70
70
|
const functionsWithConfig = functions.map(([name, func]) => [
|
|
71
71
|
name,
|
|
72
|
-
{ ...func, config: (0,
|
|
72
|
+
{ ...func, config: (0, config_js_1.getConfigForFunction)({ config, func }) },
|
|
73
73
|
]);
|
|
74
74
|
return new Map(functionsWithConfig);
|
|
75
75
|
};
|
|
@@ -77,7 +77,7 @@ exports.getFunctionsFromPaths = getFunctionsFromPaths;
|
|
|
77
77
|
/**
|
|
78
78
|
* Gets a list of functions found in a list of paths.
|
|
79
79
|
*/
|
|
80
|
-
const getFunctionFromPath = async (path, { config, featureFlags =
|
|
80
|
+
const getFunctionFromPath = async (path, { config, featureFlags = feature_flags_js_1.defaultFlags } = {}) => {
|
|
81
81
|
const fsCache = makeFsCache();
|
|
82
82
|
for (const runtime of RUNTIMES) {
|
|
83
83
|
const func = await runtime.findFunctionInPath({ path, fsCache, featureFlags });
|
|
@@ -85,7 +85,7 @@ const getFunctionFromPath = async (path, { config, featureFlags = feature_flags_
|
|
|
85
85
|
return {
|
|
86
86
|
...func,
|
|
87
87
|
runtime,
|
|
88
|
-
config: (0,
|
|
88
|
+
config: (0, config_js_1.getConfigForFunction)({ config, func: { ...func, runtime } }),
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { FunctionConfig } from '../../../../config';
|
|
2
|
-
|
|
3
|
-
declare const
|
|
1
|
+
import type { FunctionConfig } from '../../../../config.js';
|
|
2
|
+
import { FeatureFlags } from '../../../../feature_flags.js';
|
|
3
|
+
export declare const ESBUILD_LOG_LIMIT = 10;
|
|
4
|
+
export declare const bundleJsFile: ({ additionalModulePaths, basePath, config, externalModules, featureFlags, ignoredModules, name, srcDir, srcFile, }: {
|
|
4
5
|
additionalModulePaths?: string[] | undefined;
|
|
5
6
|
basePath?: string | undefined;
|
|
6
7
|
config: FunctionConfig;
|
|
7
8
|
externalModules: string[];
|
|
9
|
+
featureFlags: FeatureFlags;
|
|
8
10
|
ignoredModules: string[];
|
|
9
11
|
name: string;
|
|
10
12
|
srcDir: string;
|
|
@@ -14,8 +16,8 @@ declare const bundleJsFile: ({ additionalModulePaths, basePath, config, external
|
|
|
14
16
|
bundlePaths: Map<string, string>;
|
|
15
17
|
cleanTempFiles: () => Promise<void>;
|
|
16
18
|
inputs: string[];
|
|
19
|
+
moduleFormat: import("../../utils/module_format.js").ModuleFormat;
|
|
17
20
|
nativeNodeModules: {};
|
|
18
21
|
nodeModulesWithDynamicImports: string[];
|
|
19
22
|
warnings: import("@netlify/esbuild").Message[];
|
|
20
23
|
}>;
|
|
21
|
-
export { bundleJsFile, ESBUILD_LOG_LIMIT };
|