@netlify/zip-it-and-ship-it 9.25.5 → 9.25.7

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.
@@ -7,7 +7,6 @@ export declare const defaultFlags: {
7
7
  readonly zisi_output_cjs_extension: false;
8
8
  readonly zisi_unique_entry_file: false;
9
9
  readonly zisi_esbuild_fail_double_glob: false;
10
- readonly zisi_golang_use_al2: false;
11
10
  };
12
11
  export type FeatureFlags = Partial<Record<keyof typeof defaultFlags, boolean>>;
13
12
  export declare const getFlags: (input?: Record<string, boolean>, flags?: {
@@ -19,5 +18,4 @@ export declare const getFlags: (input?: Record<string, boolean>, flags?: {
19
18
  readonly zisi_output_cjs_extension: false;
20
19
  readonly zisi_unique_entry_file: false;
21
20
  readonly zisi_esbuild_fail_double_glob: false;
22
- readonly zisi_golang_use_al2: false;
23
21
  }) => FeatureFlags;
@@ -18,8 +18,6 @@ export const defaultFlags = {
18
18
  zisi_unique_entry_file: false,
19
19
  // If multiple glob stars are in includedFiles, fail the build instead of warning.
20
20
  zisi_esbuild_fail_double_glob: false,
21
- // Bundle for the provided.AL2 runtime for Go functions.
22
- zisi_golang_use_al2: false,
23
21
  };
24
22
  // List of supported flags and their default value.
25
23
  export const getFlags = (input = {}, flags = defaultFlags) => Object.entries(flags).reduce((result, [key, defaultValue]) => ({
@@ -1,10 +1,8 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
- import type { FeatureFlags } from '../../feature_flags.js';
3
- export declare const build: ({ destPath, mainFile, srcDir, featureFlags, }: {
2
+ export declare const build: ({ destPath, mainFile, srcDir }: {
4
3
  destPath: string;
5
4
  mainFile: string;
6
5
  srcDir: string;
7
- featureFlags: FeatureFlags;
8
6
  }) => Promise<{
9
7
  mainFile: string;
10
8
  name: string;
@@ -3,13 +3,10 @@ import { basename } from 'path';
3
3
  import { FunctionBundlingUserError } from '../../utils/error.js';
4
4
  import { shellUtils } from '../../utils/shell.js';
5
5
  import { RUNTIME } from '../runtime.js';
6
- export const build = async ({ destPath, mainFile, srcDir, featureFlags, }) => {
6
+ export const build = async ({ destPath, mainFile, srcDir }) => {
7
7
  const functionName = basename(srcDir);
8
8
  try {
9
- const args = ['build', '-o', destPath, '-ldflags', '-s -w'];
10
- if (featureFlags.zisi_golang_use_al2) {
11
- args.push('-tags', 'lambda.norpc');
12
- }
9
+ const args = ['build', '-o', destPath, '-ldflags', '-s -w', '-tags', 'lambda.norpc'];
13
10
  await shellUtils.runCommand('go', args, {
14
11
  cwd: srcDir,
15
12
  env: {
@@ -68,7 +68,7 @@ const processSource = async ({ cache, mainFile, path, }) => {
68
68
  stat,
69
69
  };
70
70
  };
71
- const zipFunction = async function ({ config, destFolder, filename, mainFile, srcDir, srcPath, stat, isInternal, featureFlags, }) {
71
+ const zipFunction = async function ({ config, destFolder, filename, mainFile, srcDir, srcPath, stat, isInternal, }) {
72
72
  const destPath = join(destFolder, filename);
73
73
  const isSource = extname(mainFile) === '.go';
74
74
  let binary = {
@@ -78,7 +78,7 @@ const zipFunction = async function ({ config, destFolder, filename, mainFile, sr
78
78
  // If we're building a Go function from source, we call the build method and
79
79
  // update `binary` to point to the newly-created binary.
80
80
  if (isSource) {
81
- const { stat: binaryStat } = await build({ destPath, mainFile, srcDir, featureFlags });
81
+ const { stat: binaryStat } = await build({ destPath, mainFile, srcDir });
82
82
  binary = {
83
83
  path: destPath,
84
84
  stat: binaryStat,
@@ -88,7 +88,7 @@ const zipFunction = async function ({ config, destFolder, filename, mainFile, sr
88
88
  config,
89
89
  displayName: config?.name,
90
90
  generator: config?.generator || getInternalValue(isInternal),
91
- runtimeVersion: featureFlags.zisi_golang_use_al2 ? 'provided.al2' : undefined,
91
+ runtimeVersion: 'provided.al2',
92
92
  };
93
93
  // If `zipGo` is enabled, we create a zip archive with the Go binary and the
94
94
  // toolchain file.
@@ -96,7 +96,7 @@ const zipFunction = async function ({ config, destFolder, filename, mainFile, sr
96
96
  const zipPath = `${destPath}.zip`;
97
97
  const zipOptions = {
98
98
  destPath: zipPath,
99
- filename: featureFlags.zisi_golang_use_al2 ? 'bootstrap' : basename(destPath),
99
+ filename: 'bootstrap',
100
100
  runtime,
101
101
  };
102
102
  await zipBinary({ ...zipOptions, srcPath: binary.path, stat: binary.stat });
@@ -11,7 +11,7 @@ export declare const getFunctionsFromPaths: (paths: string[], { cache, config, c
11
11
  config?: Config | undefined;
12
12
  configFileDirectories?: string[] | undefined;
13
13
  dedupe?: boolean | undefined;
14
- featureFlags?: Partial<Record<"buildRustSource" | "parseWithEsbuild" | "traceWithNft" | "zisi_pure_esm" | "zisi_pure_esm_mjs" | "zisi_output_cjs_extension" | "zisi_unique_entry_file" | "zisi_esbuild_fail_double_glob" | "zisi_golang_use_al2", boolean>> | undefined;
14
+ featureFlags?: Partial<Record<"buildRustSource" | "parseWithEsbuild" | "traceWithNft" | "zisi_pure_esm" | "zisi_pure_esm_mjs" | "zisi_output_cjs_extension" | "zisi_unique_entry_file" | "zisi_esbuild_fail_double_glob", boolean>> | undefined;
15
15
  }) => Promise<FunctionMap>;
16
16
  /**
17
17
  * Gets a list of functions found in a list of paths.
@@ -20,6 +20,6 @@ export declare const getFunctionFromPath: (path: string, { cache, config, config
20
20
  cache: RuntimeCache;
21
21
  config?: Config | undefined;
22
22
  configFileDirectories?: string[] | undefined;
23
- featureFlags?: Partial<Record<"buildRustSource" | "parseWithEsbuild" | "traceWithNft" | "zisi_pure_esm" | "zisi_pure_esm_mjs" | "zisi_output_cjs_extension" | "zisi_unique_entry_file" | "zisi_esbuild_fail_double_glob" | "zisi_golang_use_al2", boolean>> | undefined;
23
+ featureFlags?: Partial<Record<"buildRustSource" | "parseWithEsbuild" | "traceWithNft" | "zisi_pure_esm" | "zisi_pure_esm_mjs" | "zisi_output_cjs_extension" | "zisi_unique_entry_file" | "zisi_esbuild_fail_double_glob", boolean>> | undefined;
24
24
  }) => Promise<FunctionSource | undefined>;
25
25
  export {};
@@ -1,5 +1,5 @@
1
1
  import { Buffer } from 'buffer';
2
- import { mkdir, rm, writeFile } from 'fs/promises';
2
+ import { mkdir, readlink as readLink, rm, symlink, writeFile } from 'fs/promises';
3
3
  import os from 'os';
4
4
  import { basename, extname, join } from 'path';
5
5
  import { getPath as getV2APIPath } from '@netlify/serverless-functions-api';
@@ -22,7 +22,7 @@ const addBootstrapFile = function (srcFiles, aliases) {
22
22
  srcFiles.push(v2APIPath);
23
23
  aliases.set(v2APIPath, BOOTSTRAP_FILE_NAME);
24
24
  };
25
- const createDirectory = async function ({ aliases = new Map(), basePath, destFolder, extension, featureFlags, filename, mainFile, moduleFormat, rewrites = new Map(), runtimeAPIVersion, srcFiles, }) {
25
+ const createDirectory = async function ({ aliases = new Map(), basePath, cache, destFolder, extension, featureFlags, filename, mainFile, moduleFormat, rewrites = new Map(), runtimeAPIVersion, srcFiles, }) {
26
26
  // There is a naming conflict with the entry file if one of the supporting
27
27
  // files (i.e. not the main file) has the path that the entry file needs to
28
28
  // take.
@@ -55,8 +55,9 @@ const createDirectory = async function ({ aliases = new Map(), basePath, destFol
55
55
  if (runtimeAPIVersion === 2) {
56
56
  addBootstrapFile(srcFiles, aliases);
57
57
  }
58
+ const symlinks = new Map();
58
59
  // Copying source files.
59
- await pMap(srcFiles, (srcFile) => {
60
+ await pMap(srcFiles, async (srcFile) => {
60
61
  const destPath = aliases.get(srcFile) || srcFile;
61
62
  const normalizedDestPath = normalizeFilePath({
62
63
  commonPrefix: basePath,
@@ -67,8 +68,21 @@ const createDirectory = async function ({ aliases = new Map(), basePath, destFol
67
68
  if (rewrites.has(srcFile)) {
68
69
  return mkdirAndWriteFile(absoluteDestPath, rewrites.get(srcFile));
69
70
  }
71
+ const stat = await cachedLstat(cache.lstatCache, srcFile);
72
+ // If the path is a symlink, find the link target and add the link to a
73
+ // `symlinks` map, which we'll later use to create the symlinks in the
74
+ // target directory. We can't do that right now because the target path
75
+ // may not have been copied over yet.
76
+ if (stat.isSymbolicLink()) {
77
+ const targetPath = await readLink(srcFile);
78
+ symlinks.set(targetPath, absoluteDestPath);
79
+ return;
80
+ }
70
81
  return copyFile(srcFile, absoluteDestPath);
71
82
  }, { concurrency: COPY_FILE_CONCURRENCY });
83
+ await pMap([...symlinks.entries()], ([target, path]) => symlink(target, path), {
84
+ concurrency: COPY_FILE_CONCURRENCY,
85
+ });
72
86
  return { path: functionFolder, entryFilename };
73
87
  };
74
88
  const createZipArchive = async function ({ aliases = new Map(), basePath, cache, destFolder, extension, featureFlags, filename, mainFile, moduleFormat, rewrites, runtimeAPIVersion, srcFiles, }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/zip-it-and-ship-it",
3
- "version": "9.25.5",
3
+ "version": "9.25.7",
4
4
  "description": "Zip it and ship it",
5
5
  "main": "./dist/main.js",
6
6
  "type": "module",
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@babel/parser": "^7.22.5",
58
- "@babel/types": "7.22.19",
58
+ "@babel/types": "7.23.0",
59
59
  "@netlify/binary-info": "^1.0.0",
60
60
  "@netlify/serverless-functions-api": "^1.10.1",
61
61
  "@vercel/nft": "^0.23.0",
@@ -63,7 +63,7 @@
63
63
  "common-path-prefix": "^3.0.0",
64
64
  "cp-file": "^10.0.0",
65
65
  "es-module-lexer": "^1.0.0",
66
- "esbuild": "0.19.4",
66
+ "esbuild": "0.19.5",
67
67
  "execa": "^6.0.0",
68
68
  "filter-obj": "^5.0.0",
69
69
  "find-up": "^6.0.0",
@@ -95,10 +95,10 @@
95
95
  "@types/node": "14.18.63",
96
96
  "@types/normalize-path": "3.0.1",
97
97
  "@types/resolve": "1.20.4",
98
- "@types/semver": "7.5.3",
99
- "@types/tmp": "0.2.4",
100
- "@types/unixify": "1.0.0",
101
- "@types/yargs": "17.0.28",
98
+ "@types/semver": "7.5.4",
99
+ "@types/tmp": "0.2.5",
100
+ "@types/unixify": "1.0.1",
101
+ "@types/yargs": "17.0.29",
102
102
  "@vitest/coverage-v8": "0.34.6",
103
103
  "adm-zip": "0.5.10",
104
104
  "browserslist": "4.22.1",