@netlify/zip-it-and-ship-it 8.1.0 → 8.2.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 CHANGED
@@ -137,6 +137,7 @@ The following properties are accepted:
137
137
  - `12.x` (or `nodejs12.x`)
138
138
  - `14.x` (or `nodejs14.x`)
139
139
  - `16.x` (or `nodejs16.x`)
140
+ - `18.x` (or `nodejs18.x`)
140
141
 
141
142
  - `rustTargetDirectory`
142
143
 
package/dist/archive.d.ts CHANGED
@@ -3,7 +3,7 @@ import { Stats } from 'fs';
3
3
  import { Writable } from 'stream';
4
4
  import { Archiver } from 'archiver';
5
5
  export { Archiver as ZipArchive } from 'archiver';
6
- export declare type ArchiveFormat = 'none' | 'zip';
6
+ export type ArchiveFormat = 'none' | 'zip';
7
7
  export declare const startZip: (destPath: string) => {
8
8
  archive: Archiver;
9
9
  output: Writable;
package/dist/config.d.ts CHANGED
@@ -17,9 +17,9 @@ interface FunctionConfig {
17
17
  zipGo?: boolean;
18
18
  nodeModuleFormat?: ModuleFormat;
19
19
  }
20
- declare type GlobPattern = string;
21
- declare type Config = Record<GlobPattern, FunctionConfig>;
22
- declare type FunctionWithoutConfig = Omit<FunctionSource, 'config'>;
20
+ type GlobPattern = string;
21
+ type Config = Record<GlobPattern, FunctionConfig>;
22
+ type FunctionWithoutConfig = Omit<FunctionSource, 'config'>;
23
23
  declare const getConfigForFunction: ({ config, configFileDirectories, func, featureFlags, }: {
24
24
  config?: Config | undefined;
25
25
  configFileDirectories?: string[] | undefined;
@@ -1,4 +1,4 @@
1
1
  export declare const defaultFlags: Record<string, boolean>;
2
- export declare type FeatureFlag = keyof typeof defaultFlags;
3
- export declare type FeatureFlags = Record<FeatureFlag, boolean>;
2
+ export type FeatureFlag = keyof typeof defaultFlags;
3
+ export type FeatureFlags = Record<FeatureFlag, boolean>;
4
4
  export declare const getFlags: (input?: Record<string, boolean>, flags?: Record<string, boolean>) => FeatureFlags;
@@ -2,7 +2,7 @@
2
2
  import { Stats } from 'fs';
3
3
  import type { FunctionConfig } from './config.js';
4
4
  import type { Runtime, ZipFunctionResult } from './runtimes/runtime.js';
5
- export declare type FunctionArchive = ZipFunctionResult & {
5
+ export type FunctionArchive = ZipFunctionResult & {
6
6
  mainFile: string;
7
7
  name: string;
8
8
  runtime: Runtime;
@@ -17,7 +17,7 @@ export interface SourceFile {
17
17
  srcPath: string;
18
18
  stat: Stats;
19
19
  }
20
- export declare type FunctionSource = SourceFile & {
20
+ export type FunctionSource = SourceFile & {
21
21
  config: FunctionConfig;
22
22
  runtime: Runtime;
23
23
  };
package/dist/main.d.ts CHANGED
@@ -12,7 +12,7 @@ export interface ListedFunction {
12
12
  extension: string;
13
13
  schedule?: string;
14
14
  }
15
- declare type ListedFunctionFile = ListedFunction & {
15
+ type ListedFunctionFile = ListedFunction & {
16
16
  srcFile: string;
17
17
  };
18
18
  interface ListFunctionsOptions {
@@ -2,7 +2,7 @@ import { Config } from '../config.js';
2
2
  import { FeatureFlags } from '../feature_flags.js';
3
3
  import { FunctionSource } from '../function.js';
4
4
  import type { RuntimeCache } from '../utils/cache.js';
5
- declare type FunctionMap = Map<string, FunctionSource>;
5
+ type FunctionMap = Map<string, FunctionSource>;
6
6
  /**
7
7
  * Gets a list of functions found in a list of paths.
8
8
  */
@@ -7,8 +7,9 @@ declare const versionMap: {
7
7
  readonly '12.x': "node12";
8
8
  readonly '14.x': "node14";
9
9
  readonly '16.x': "node16";
10
+ readonly '18.x': "node18";
10
11
  };
11
- declare type VersionValues = typeof versionMap[keyof typeof versionMap];
12
+ type VersionValues = typeof versionMap[keyof typeof versionMap];
12
13
  declare const getBundlerTarget: (suppliedVersion?: NodeVersionString) => VersionValues;
13
14
  declare const getModuleFormat: (srcDir: string, featureFlags: FeatureFlags, extension: string, configVersion?: string) => Promise<{
14
15
  includedFiles: string[];
@@ -6,6 +6,7 @@ const versionMap = {
6
6
  '12.x': 'node12',
7
7
  '14.x': 'node14',
8
8
  '16.x': 'node16',
9
+ '18.x': 'node18',
9
10
  };
10
11
  const getBundlerTarget = (suppliedVersion) => {
11
12
  const version = normalizeVersion(suppliedVersion);
@@ -1,15 +1,11 @@
1
1
  import { basename, dirname, join, normalize, resolve } from 'path';
2
2
  import { nodeFileTrace } from '@vercel/nft';
3
- import nftResolveDependency from '@vercel/nft/out/resolve-dependency.js';
3
+ import resolveDependency from '@vercel/nft/out/resolve-dependency.js';
4
4
  import { cachedReadFile } from '../../../../utils/fs.js';
5
5
  import { minimatch } from '../../../../utils/matching.js';
6
6
  import { getBasePath } from '../../utils/base_path.js';
7
7
  import { filterExcludedPaths, getPathsOfIncludedFiles } from '../../utils/included_files.js';
8
8
  import { processESM } from './es_modules.js';
9
- // @ts-expect-error vitest with esbuild already resolves the default export, whereas Node.js does not
10
- const resolveDependency = nftResolveDependency.default
11
- ? nftResolveDependency.default
12
- : nftResolveDependency;
13
9
  // Paths that will be excluded from the tracing process.
14
10
  const ignore = ['node_modules/aws-sdk/**'];
15
11
  const appearsToBeModuleName = (name) => !name.startsWith('.');
@@ -65,7 +61,7 @@ const traceFilesAndTranspile = async function ({ basePath, cache, config, featur
65
61
  },
66
62
  resolve: async (specifier, parent, ...args) => {
67
63
  try {
68
- return await resolveDependency(specifier, parent, ...args);
64
+ return await resolveDependency.default(specifier, parent, ...args);
69
65
  }
70
66
  catch (error) {
71
67
  // If we get a `MODULE_NOT_FOUND` error for what appears to be a module
@@ -73,7 +69,7 @@ const traceFilesAndTranspile = async function ({ basePath, cache, config, featur
73
69
  // as the base directory.
74
70
  if (error.code === 'MODULE_NOT_FOUND' && pluginsModulesPath && appearsToBeModuleName(specifier)) {
75
71
  const newParent = join(pluginsModulesPath, basename(parent));
76
- return await resolveDependency(specifier, newParent, ...args);
72
+ return await resolveDependency.default(specifier, newParent, ...args);
77
73
  }
78
74
  throw error;
79
75
  }
@@ -11,10 +11,10 @@ export declare const enum NodeBundlerType {
11
11
  ZISI = "zisi",
12
12
  NONE = "none"
13
13
  }
14
- declare type BundlerWarning = Message;
15
- declare type CleanupFunction = () => Promise<void>;
16
- export declare type NativeNodeModules = Record<string, Record<string, string | undefined>>;
17
- export declare type BundleFunction = (args: {
14
+ type BundlerWarning = Message;
15
+ type CleanupFunction = () => Promise<void>;
16
+ export type NativeNodeModules = Record<string, Record<string, string | undefined>>;
17
+ export type BundleFunction = (args: {
18
18
  basePath?: string;
19
19
  cache: RuntimeCache;
20
20
  config: FunctionConfig;
@@ -35,7 +35,7 @@ export declare type BundleFunction = (args: {
35
35
  nodeModulesWithDynamicImports?: string[];
36
36
  srcFiles: string[];
37
37
  }>;
38
- export declare type GetSrcFilesFunction = (args: {
38
+ export type GetSrcFilesFunction = (args: {
39
39
  basePath?: string;
40
40
  config: FunctionConfig;
41
41
  featureFlags: FeatureFlags;
@@ -1,4 +1,6 @@
1
- export declare const listImports: ({ functionName, path, }: {
1
+ import { FeatureFlags } from '../../../../feature_flags.js';
2
+ export declare const listImports: ({ featureFlags, ...args }: {
3
+ featureFlags: FeatureFlags;
2
4
  functionName: string;
3
5
  path: string;
4
6
  }) => Promise<string[]>;
@@ -1,5 +1,6 @@
1
1
  import * as esbuild from '@netlify/esbuild';
2
2
  import isBuiltinModule from 'is-builtin-module';
3
+ import precinct from 'precinct';
3
4
  import { tmpName } from 'tmp-promise';
4
5
  import { FunctionBundlingUserError } from '../../../../utils/error.js';
5
6
  import { safeUnlink } from '../../../../utils/fs.js';
@@ -23,7 +24,7 @@ const getListImportsPlugin = ({ imports, path }) => ({
23
24
  });
24
25
  },
25
26
  });
26
- export const listImports = async ({ functionName, path, }) => {
27
+ const listImportsWithESBuild = async ({ functionName, path, }) => {
27
28
  // We're not interested in the output that esbuild generates, we're just
28
29
  // using it for its parsing capabilities in order to find import/require
29
30
  // statements. However, if we don't give esbuild a path in `outfile`, it
@@ -56,4 +57,21 @@ export const listImports = async ({ functionName, path, }) => {
56
57
  }
57
58
  return [...imports];
58
59
  };
60
+ const listImportsWithPrecinct = async ({ functionName, path }) => {
61
+ try {
62
+ return await precinct.paperwork(path, { includeCore: false });
63
+ }
64
+ catch (error) {
65
+ // Syntax errors from babel are user errors
66
+ if (error.code === 'BABEL_PARSER_SYNTAX_ERROR') {
67
+ throw FunctionBundlingUserError.addCustomErrorInfo(error, {
68
+ functionName,
69
+ runtime: "js" /* RuntimeType.JAVASCRIPT */,
70
+ bundler: "zisi" /* NodeBundlerType.ZISI */,
71
+ });
72
+ }
73
+ throw error;
74
+ }
75
+ };
76
+ export const listImports = async ({ featureFlags, ...args }) => (featureFlags.parseWithEsbuild ? await listImportsWithESBuild(args) : await listImportsWithPrecinct(args));
59
77
  //# sourceMappingURL=list_imports.js.map
@@ -1,6 +1,5 @@
1
1
  import { dirname, basename, normalize } from 'path';
2
- import { not as notJunk } from 'junk';
3
- import precinct from 'precinct';
2
+ import { isNotJunk as notJunk } from 'junk';
4
3
  import { nonNullable } from '../../../../utils/non_nullable.js';
5
4
  import { filterExcludedPaths, getPathsOfIncludedFiles } from '../../utils/included_files.js';
6
5
  import { getPackageJson } from '../../utils/package_json.js';
@@ -58,9 +57,7 @@ const getFileDependencies = async function ({ featureFlags, functionName, path,
58
57
  }
59
58
  state.localFiles.add(path);
60
59
  const basedir = dirname(path);
61
- const dependencies = featureFlags.parseWithEsbuild
62
- ? await listImports({ functionName, path })
63
- : await precinct.paperwork(path, { includeCore: false });
60
+ const dependencies = await listImports({ featureFlags, functionName, path });
64
61
  const depsPaths = await Promise.all(dependencies.filter(nonNullable).map((dependency) => getImportDependencies({
65
62
  dependency,
66
63
  basedir,
@@ -1,9 +1,9 @@
1
1
  import type { ArgumentPlaceholder, Expression, SpreadElement, JSXNamespacedName } from '@babel/types';
2
2
  import { parse as parseSchedule } from './properties/schedule.js';
3
3
  export declare const IN_SOURCE_CONFIG_MODULE = "@netlify/functions";
4
- export declare type ISCValues = Partial<ReturnType<typeof parseSchedule>>;
4
+ export type ISCValues = Partial<ReturnType<typeof parseSchedule>>;
5
5
  export declare const findISCDeclarationsInPath: (sourcePath: string, functionName: string) => Promise<ISCValues>;
6
- export declare type ISCHandlerArg = ArgumentPlaceholder | Expression | SpreadElement | JSXNamespacedName;
6
+ export type ISCHandlerArg = ArgumentPlaceholder | Expression | SpreadElement | JSXNamespacedName;
7
7
  export interface ISCExport {
8
8
  local: string;
9
9
  args: ISCHandlerArg[];
@@ -1,5 +1,5 @@
1
1
  import type { Expression, Statement } from '@babel/types';
2
- declare type Bindings = Map<string, Expression>;
3
- export declare type BindingMethod = () => Bindings;
2
+ type Bindings = Map<string, Expression>;
3
+ export type BindingMethod = () => Bindings;
4
4
  export declare const createBindingsMethod: (nodes: Statement[]) => BindingMethod;
5
5
  export {};
@@ -1,6 +1,6 @@
1
- declare type SupportedVersionNumbers = 8 | 10 | 12 | 14 | 16;
2
- export declare type ShortNodeVersionString = `${SupportedVersionNumbers}.x`;
3
- export declare type NodeVersionString = ShortNodeVersionString | `nodejs${SupportedVersionNumbers}.x`;
1
+ type SupportedVersionNumbers = 8 | 10 | 12 | 14 | 16 | 18;
2
+ export type ShortNodeVersionString = `${SupportedVersionNumbers}.x`;
3
+ export type NodeVersionString = ShortNodeVersionString | `nodejs${SupportedVersionNumbers}.x`;
4
4
  export interface NodeVersionSupport {
5
5
  esm: boolean;
6
6
  }
@@ -1,7 +1,7 @@
1
1
  import type { FeatureFlags } from '../../../feature_flags.js';
2
2
  import type { RuntimeCache } from '../../../utils/cache.js';
3
3
  import { ModuleFormat } from './module_format.js';
4
- export declare type ArchiveFormat = 'none' | 'zip';
4
+ export type ArchiveFormat = 'none' | 'zip';
5
5
  interface ZipNodeParameters {
6
6
  aliases?: Map<string, string>;
7
7
  basePath: string;
@@ -10,17 +10,17 @@ export declare const enum RuntimeType {
10
10
  JAVASCRIPT = "js",
11
11
  RUST = "rs"
12
12
  }
13
- export declare type FindFunctionsInPathsFunction = (args: {
13
+ export type FindFunctionsInPathsFunction = (args: {
14
14
  cache: RuntimeCache;
15
15
  featureFlags: FeatureFlags;
16
16
  paths: string[];
17
17
  }) => Promise<SourceFile[]>;
18
- export declare type FindFunctionInPathFunction = (args: {
18
+ export type FindFunctionInPathFunction = (args: {
19
19
  cache: RuntimeCache;
20
20
  featureFlags: FeatureFlags;
21
21
  path: string;
22
22
  }) => Promise<SourceFile | undefined>;
23
- export declare type GetSrcFilesFunction = (args: {
23
+ export type GetSrcFilesFunction = (args: {
24
24
  basePath?: string;
25
25
  config: FunctionConfig;
26
26
  featureFlags: FeatureFlags;
@@ -38,7 +38,7 @@ export interface ZipFunctionResult {
38
38
  nodeModulesWithDynamicImports?: string[];
39
39
  path: string;
40
40
  }
41
- export declare type ZipFunction = (args: {
41
+ export type ZipFunction = (args: {
42
42
  archiveFormat: ArchiveFormat;
43
43
  basePath?: string;
44
44
  cache: RuntimeCache;
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  import type { Stats } from 'fs';
3
- export declare type FileCache = Map<string, Promise<string>>;
4
- export declare type LstatCache = Map<string, Promise<Stats>>;
5
- export declare type ReaddirCache = Map<string, Promise<string[]>>;
3
+ export type FileCache = Map<string, Promise<string>>;
4
+ export type LstatCache = Map<string, Promise<Stats>>;
5
+ export type ReaddirCache = Map<string, Promise<string[]>>;
6
6
  interface NFTCache {
7
7
  fileCache: FileCache;
8
8
  }
@@ -9,7 +9,7 @@ interface CustomErrorInfo {
9
9
  type: 'functionsBundling';
10
10
  location: CustomErrorLocation;
11
11
  }
12
- declare type UserError = Error & {
12
+ type UserError = Error & {
13
13
  customErrorInfo: CustomErrorInfo;
14
14
  };
15
15
  export declare class FunctionBundlingUserError extends Error {
@@ -1,6 +1,6 @@
1
1
  import { FunctionArchive } from '../function.js';
2
2
  import { RuntimeType } from '../runtimes/runtime.js';
3
- export declare type FunctionResult = Omit<FunctionArchive, 'runtime'> & {
3
+ export type FunctionResult = Omit<FunctionArchive, 'runtime'> & {
4
4
  runtime: RuntimeType;
5
5
  schedule?: string;
6
6
  };
@@ -1,4 +1,4 @@
1
- declare type LogFunction = (...args: unknown[]) => void;
1
+ type LogFunction = (...args: unknown[]) => void;
2
2
  interface Logger {
3
3
  system: LogFunction;
4
4
  user: LogFunction;
@@ -1,22 +1,4 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import execa from 'execa';
1
+ import { execa } from 'execa';
3
2
  export declare const shellUtils: {
4
- runCommand: {
5
- (file: string, arguments?: readonly string[] | undefined, options?: execa.Options<string> | undefined): execa.ExecaChildProcess<string>;
6
- (file: string, arguments?: readonly string[] | undefined, options?: execa.Options<null> | undefined): execa.ExecaChildProcess<Buffer>;
7
- (file: string, options?: execa.Options<string> | undefined): execa.ExecaChildProcess<string>;
8
- (file: string, options?: execa.Options<null> | undefined): execa.ExecaChildProcess<Buffer>;
9
- sync(file: string, arguments?: readonly string[] | undefined, options?: execa.SyncOptions<string> | undefined): execa.ExecaSyncReturnValue<string>;
10
- sync(file: string, arguments?: readonly string[] | undefined, options?: execa.SyncOptions<null> | undefined): execa.ExecaSyncReturnValue<Buffer>;
11
- sync(file: string, options?: execa.SyncOptions<string> | undefined): execa.ExecaSyncReturnValue<string>;
12
- sync(file: string, options?: execa.SyncOptions<null> | undefined): execa.ExecaSyncReturnValue<Buffer>;
13
- command(command: string, options?: execa.Options<string> | undefined): execa.ExecaChildProcess<string>;
14
- command(command: string, options?: execa.Options<null> | undefined): execa.ExecaChildProcess<Buffer>;
15
- commandSync(command: string, options?: execa.SyncOptions<string> | undefined): execa.ExecaSyncReturnValue<string>;
16
- commandSync(command: string, options?: execa.SyncOptions<null> | undefined): execa.ExecaSyncReturnValue<Buffer>;
17
- node(scriptPath: string, arguments?: readonly string[] | undefined, options?: execa.NodeOptions<string> | undefined): execa.ExecaChildProcess<string>;
18
- node(scriptPath: string, arguments?: readonly string[] | undefined, options?: execa.Options<null> | undefined): execa.ExecaChildProcess<Buffer>;
19
- node(scriptPath: string, options?: execa.Options<string> | undefined): execa.ExecaChildProcess<string>;
20
- node(scriptPath: string, options?: execa.Options<null> | undefined): execa.ExecaChildProcess<Buffer>;
21
- };
3
+ runCommand: typeof execa;
22
4
  };
@@ -1,3 +1,3 @@
1
- import execa from 'execa';
1
+ import { execa } from 'execa';
2
2
  export const shellUtils = { runCommand: execa };
3
3
  //# sourceMappingURL=shell.js.map
package/dist/zip.d.ts CHANGED
@@ -12,7 +12,7 @@ interface ZipFunctionOptions {
12
12
  systemLog?: LogFunction;
13
13
  debug?: boolean;
14
14
  }
15
- export declare type ZipFunctionsOptions = ZipFunctionOptions & {
15
+ export type ZipFunctionsOptions = ZipFunctionOptions & {
16
16
  configFileDirectories?: string[];
17
17
  manifest?: string;
18
18
  parallelLimit?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/zip-it-and-ship-it",
3
- "version": "8.1.0",
3
+ "version": "8.2.0",
4
4
  "description": "Zip it and ship it",
5
5
  "main": "./dist/main.js",
6
6
  "type": "module",
@@ -63,18 +63,18 @@
63
63
  "del": "^7.0.0",
64
64
  "end-of-stream": "^1.4.4",
65
65
  "es-module-lexer": "^1.0.0",
66
- "execa": "^5.0.0",
66
+ "execa": "^6.0.0",
67
67
  "filter-obj": "^5.0.0",
68
68
  "find-up": "^6.0.0",
69
69
  "glob": "^8.0.3",
70
70
  "is-builtin-module": "^3.1.0",
71
- "is-path-inside": "^3.0.3",
72
- "junk": "^3.1.0",
71
+ "is-path-inside": "^4.0.0",
72
+ "junk": "^4.0.0",
73
73
  "locate-path": "^7.0.0",
74
74
  "merge-options": "^3.0.4",
75
75
  "minimatch": "^5.0.0",
76
76
  "normalize-path": "^3.0.0",
77
- "p-map": "^4.0.0",
77
+ "p-map": "^5.0.0",
78
78
  "path-exists": "^5.0.0",
79
79
  "precinct": "^9.0.1",
80
80
  "require-package-name": "^2.0.1",
@@ -87,16 +87,17 @@
87
87
  },
88
88
  "devDependencies": {
89
89
  "@babel/types": "^7.15.6",
90
- "@netlify/eslint-config-node": "^7.0.0",
90
+ "@netlify/eslint-config-node": "^7.0.1",
91
91
  "@types/archiver": "^5.1.1",
92
92
  "@types/end-of-stream": "^1.4.1",
93
93
  "@types/node": "^14.18.32",
94
94
  "@types/normalize-path": "^3.0.0",
95
95
  "@types/resolve": "^1.20.2",
96
96
  "@types/semver": "^7.3.8",
97
+ "@types/tmp": "^0.2.3",
97
98
  "@types/unixify": "^1.0.0",
98
99
  "@types/yargs": "^17.0.4",
99
- "@vitest/coverage-c8": "^0.24.3",
100
+ "@vitest/coverage-c8": "^0.25.0",
100
101
  "cpy": "^9.0.0",
101
102
  "deepmerge": "^4.2.2",
102
103
  "get-stream": "^6.0.0",
@@ -106,8 +107,8 @@
106
107
  "source-map-support": "^0.5.21",
107
108
  "throat": "^6.0.1",
108
109
  "typescript": "^4.8.4",
109
- "vite": "^3.1.8",
110
- "vitest": "^0.24.3"
110
+ "vite": "^4.0.0",
111
+ "vitest": "^0.25.0"
111
112
  },
112
113
  "engines": {
113
114
  "node": "^14.16.0 || >=16.0.0"