@netlify/zip-it-and-ship-it 9.12.2 → 9.13.1

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.js CHANGED
@@ -5,6 +5,7 @@ import { findISCDeclarationsInPath } from './runtimes/node/in_source_config/inde
5
5
  import { RUNTIME } from './runtimes/runtime.js';
6
6
  import { RuntimeCache } from './utils/cache.js';
7
7
  import { listFunctionsDirectories, resolveFunctionsDirectories } from './utils/fs.js';
8
+ import { getLogger } from './utils/logger.js';
8
9
  export { zipFunction, zipFunctions } from './zip.js';
9
10
  export { ARCHIVE_FORMAT } from './archive.js';
10
11
  export { NODE_BUNDLER } from './runtimes/node/bundlers/types.js';
@@ -16,7 +17,11 @@ const augmentWithISC = async (func, featureFlags) => {
16
17
  if (func.runtime.name !== RUNTIME.JAVASCRIPT) {
17
18
  return func;
18
19
  }
19
- const inSourceConfig = await findISCDeclarationsInPath(func.mainFile, func.name, featureFlags);
20
+ const inSourceConfig = await findISCDeclarationsInPath(func.mainFile, {
21
+ functionName: func.name,
22
+ featureFlags,
23
+ logger: getLogger(),
24
+ });
20
25
  return { ...func, inSourceConfig };
21
26
  };
22
27
  // List all Netlify Functions main entry files for a specific directory
@@ -1,16 +1,23 @@
1
1
  import type { ArgumentPlaceholder, Expression, SpreadElement, JSXNamespacedName } from '@babel/types';
2
2
  import type { FeatureFlags } from '../../../feature_flags.js';
3
3
  import { InvocationMode } from '../../../function.js';
4
+ import { Logger } from '../../../utils/logger.js';
4
5
  export declare const IN_SOURCE_CONFIG_MODULE = "@netlify/functions";
5
6
  export type ISCValues = {
6
7
  invocationMode?: InvocationMode;
7
8
  runtimeAPIVersion?: number;
8
9
  schedule?: string;
9
10
  };
10
- export declare const findISCDeclarationsInPath: (sourcePath: string, functionName: string, featureFlags: FeatureFlags) => Promise<ISCValues>;
11
- export declare const findISCDeclarations: (source: string, functionName: string, featureFlags: FeatureFlags) => ISCValues;
11
+ interface FindISCDeclarationsOptions {
12
+ functionName: string;
13
+ featureFlags: FeatureFlags;
14
+ logger: Logger;
15
+ }
16
+ export declare const findISCDeclarationsInPath: (sourcePath: string, { functionName, featureFlags, logger }: FindISCDeclarationsOptions) => Promise<ISCValues>;
17
+ export declare const findISCDeclarations: (source: string, { functionName, featureFlags, logger }: FindISCDeclarationsOptions) => ISCValues;
12
18
  export type ISCHandlerArg = ArgumentPlaceholder | Expression | SpreadElement | JSXNamespacedName;
13
19
  export interface ISCExport {
14
20
  local: string;
15
21
  args: ISCHandlerArg[];
16
22
  }
23
+ export {};
@@ -19,14 +19,14 @@ const validateScheduleFunction = (functionFound, scheduleFound, functionName) =>
19
19
  // Parses a JS/TS file and looks for in-source config declarations. It returns
20
20
  // an array of all declarations found, with `property` indicating the name of
21
21
  // the property and `data` its value.
22
- export const findISCDeclarationsInPath = async (sourcePath, functionName, featureFlags) => {
22
+ export const findISCDeclarationsInPath = async (sourcePath, { functionName, featureFlags, logger }) => {
23
23
  const source = await safelyReadSource(sourcePath);
24
24
  if (source === null) {
25
25
  return {};
26
26
  }
27
- return findISCDeclarations(source, functionName, featureFlags);
27
+ return findISCDeclarations(source, { functionName, featureFlags, logger });
28
28
  };
29
- export const findISCDeclarations = (source, functionName, featureFlags) => {
29
+ export const findISCDeclarations = (source, { functionName, featureFlags, logger }) => {
30
30
  const ast = safelyParseSource(source);
31
31
  if (ast === null) {
32
32
  return {};
@@ -42,6 +42,7 @@ export const findISCDeclarations = (source, functionName, featureFlags) => {
42
42
  const config = {
43
43
  runtimeAPIVersion: 2,
44
44
  };
45
+ logger.system('detected v2 function');
45
46
  if (typeof configExport.schedule === 'string') {
46
47
  config.schedule = configExport.schedule;
47
48
  }
@@ -25,7 +25,7 @@ const getSrcFilesWithBundler = async (parameters) => {
25
25
  const result = await bundler.getSrcFiles({ ...parameters, pluginsModulesPath });
26
26
  return result.srcFiles;
27
27
  };
28
- const zipFunction = async function ({ archiveFormat, basePath, cache, config = {}, destFolder, extension, featureFlags, filename, logger, mainFile, name, repositoryRoot, runtime, srcDir, srcPath, stat, isInternal, }) {
28
+ const zipFunction = async function ({ archiveFormat, basePath, cache, config = {}, destFolder, extension, featureFlags, filename, isInternal, logger, mainFile, name, repositoryRoot, runtime, srcDir, srcPath, stat, }) {
29
29
  // If the file is a zip, we assume the function is bundled and ready to go.
30
30
  // We simply copy it to the destination path with no further processing.
31
31
  if (extension === '.zip') {
@@ -33,7 +33,7 @@ const zipFunction = async function ({ archiveFormat, basePath, cache, config = {
33
33
  await copyFile(srcPath, destPath);
34
34
  return { config, path: destPath, entryFilename: '' };
35
35
  }
36
- const inSourceConfig = await findISCDeclarationsInPath(mainFile, name, featureFlags);
36
+ const inSourceConfig = await findISCDeclarationsInPath(mainFile, { functionName: name, featureFlags, logger });
37
37
  const runtimeAPIVersion = inSourceConfig.runtimeAPIVersion === 2 ? 2 : 1;
38
38
  const pluginsModulesPath = await getPluginsModulesPath(srcDir);
39
39
  const bundlerName = await getBundlerName({
@@ -54,10 +54,10 @@ export type ZipFunction = (args: {
54
54
  config: FunctionConfig;
55
55
  destFolder: string;
56
56
  featureFlags: FeatureFlags;
57
- logger: Logger;
58
- repositoryRoot?: string;
59
57
  generator?: string;
60
58
  isInternal: boolean;
59
+ logger: Logger;
60
+ repositoryRoot?: string;
61
61
  } & FunctionSource) => Promise<ZipFunctionResult>;
62
62
  export interface Runtime {
63
63
  findFunctionsInPaths: FindFunctionsInPathsFunction;
package/dist/zip.js CHANGED
@@ -52,6 +52,7 @@ export const zipFunctions = async function (relativeSrcFolders, destFolder, { ar
52
52
  extension: func.extension,
53
53
  featureFlags: functionFlags,
54
54
  filename: func.filename,
55
+ isInternal: Boolean(internalFunctionsPath && isPathInside(func.srcPath, internalFunctionsPath)),
55
56
  logger,
56
57
  mainFile: func.mainFile,
57
58
  name: func.name,
@@ -60,7 +61,6 @@ export const zipFunctions = async function (relativeSrcFolders, destFolder, { ar
60
61
  srcDir: func.srcDir,
61
62
  srcPath: func.srcPath,
62
63
  stat: func.stat,
63
- isInternal: Boolean(internalFunctionsPath && isPathInside(func.srcPath, internalFunctionsPath)),
64
64
  });
65
65
  return { ...zipResult, mainFile: func.mainFile, name: func.name, runtime: func.runtime };
66
66
  }, {
@@ -103,6 +103,7 @@ export const zipFunction = async function (relativeSrcPath, destFolder, { archiv
103
103
  extension,
104
104
  featureFlags: functionFlags,
105
105
  filename,
106
+ isInternal: Boolean(internalFunctionsPath && isPathInside(srcPath, internalFunctionsPath)),
106
107
  logger,
107
108
  mainFile,
108
109
  name,
@@ -111,7 +112,6 @@ export const zipFunction = async function (relativeSrcPath, destFolder, { archiv
111
112
  srcDir,
112
113
  srcPath,
113
114
  stat: stats,
114
- isInternal: Boolean(internalFunctionsPath && isPathInside(srcPath, internalFunctionsPath)),
115
115
  });
116
116
  return formatZipResult({ ...zipResult, mainFile, name, runtime });
117
117
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/zip-it-and-ship-it",
3
- "version": "9.12.2",
3
+ "version": "9.13.1",
4
4
  "description": "Zip it and ship it",
5
5
  "main": "./dist/main.js",
6
6
  "type": "module",
@@ -57,8 +57,8 @@
57
57
  "@babel/parser": "^7.22.5",
58
58
  "@netlify/binary-info": "^1.0.0",
59
59
  "@netlify/esbuild": "0.14.39",
60
- "@netlify/serverless-functions-api": "^1.5.1",
61
- "@vercel/nft": "^0.22.0",
60
+ "@netlify/serverless-functions-api": "^1.5.2",
61
+ "@vercel/nft": "^0.23.0",
62
62
  "archiver": "^5.3.0",
63
63
  "common-path-prefix": "^3.0.0",
64
64
  "cp-file": "^10.0.0",
@@ -99,7 +99,7 @@
99
99
  "@types/tmp": "0.2.3",
100
100
  "@types/unixify": "1.0.0",
101
101
  "@types/yargs": "17.0.24",
102
- "@vitest/coverage-v8": "0.32.2",
102
+ "@vitest/coverage-v8": "0.33.0",
103
103
  "cpy": "9.0.1",
104
104
  "deepmerge": "4.3.1",
105
105
  "get-stream": "6.0.1",
@@ -108,7 +108,7 @@
108
108
  "npm-run-all": "4.1.5",
109
109
  "source-map-support": "0.5.21",
110
110
  "typescript": "5.1.6",
111
- "vitest": "0.32.2"
111
+ "vitest": "0.33.0"
112
112
  },
113
113
  "engines": {
114
114
  "node": "^14.18.0 || >=16.0.0"