@netlify/zip-it-and-ship-it 16.4.1 → 16.5.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.
@@ -94,6 +94,7 @@ export declare const inSourceConfig: z.ZodObject<{
94
94
  export type InSourceConfig = z.infer<typeof inSourceConfig>;
95
95
  export declare const serverConfig: z.ZodObject<{
96
96
  excludedPath: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>, z.ZodTransform<string[], string | string[]>>>;
97
+ includedFiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
97
98
  path: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>, z.ZodTransform<string[], string | string[]>>>;
98
99
  region: z.ZodOptional<z.ZodPreprocess<z.ZodEnum<{
99
100
  cmh: "cmh";
@@ -106,21 +107,6 @@ export declare const serverConfig: z.ZodObject<{
106
107
  }>>>;
107
108
  }, z.core.$strict>;
108
109
  export type ServerConfig = z.infer<typeof serverConfig>;
109
- export declare const serverInSourceConfig: z.ZodObject<{
110
- excludedPath: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>, z.ZodTransform<string[], string | string[]>>>;
111
- path: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>, z.ZodTransform<string[], string | string[]>>>;
112
- region: z.ZodOptional<z.ZodPreprocess<z.ZodEnum<{
113
- cmh: "cmh";
114
- fra: "fra";
115
- }>>>;
116
- size: z.ZodOptional<z.ZodPreprocess<z.ZodEnum<{
117
- small: "small";
118
- medium: "medium";
119
- large: "large";
120
- }>>>;
121
- includedFiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
122
- }, z.core.$strict>;
123
- export type ServerInSourceConfig = z.infer<typeof serverInSourceConfig>;
124
110
  /**
125
111
  * Loads a file at a given path, parses it into an AST, and returns a series of
126
112
  * data points, such as in-source configuration properties and other metadata.
@@ -59,16 +59,12 @@ export const inSourceConfig = functionConfigShape
59
59
  export const serverConfig = z
60
60
  .object({
61
61
  excludedPath: paths,
62
+ includedFiles: z.array(z.string()).optional(),
62
63
  path: paths,
63
64
  region: serverRegion.optional(),
64
65
  size: serverSize.optional(),
65
66
  })
66
67
  .strict();
67
- export const serverInSourceConfig = serverConfig
68
- .extend({
69
- includedFiles: z.array(z.string()).optional(),
70
- })
71
- .strict();
72
68
  /**
73
69
  * Resolves the default export expression to an ObjectExpression if possible,
74
70
  * following identifier bindings when needed.
@@ -184,7 +180,7 @@ const getWrappedConfigExport = (nodes, getAllBindings) => {
184
180
  }
185
181
  };
186
182
  const parseServerConfig = (config, functionName) => {
187
- const { data, error, success } = serverInSourceConfig.safeParse(config);
183
+ const { data, error, success } = serverConfig.safeParse(config);
188
184
  if (success) {
189
185
  return data;
190
186
  }
package/dist/server.d.ts CHANGED
@@ -14,6 +14,7 @@ export declare const findServerEntry: (directory: string) => Promise<string | un
14
14
  */
15
15
  export interface NetlifyServerConfig {
16
16
  excludedPath?: string | string[];
17
+ includedFiles?: string[];
17
18
  path?: string | string[];
18
19
  region?: string;
19
20
  size?: string;
package/dist/server.js CHANGED
@@ -2,7 +2,7 @@ import { promises as fs } from 'fs';
2
2
  import { extname, join, resolve } from 'path';
3
3
  import { ARCHIVE_FORMAT } from './archive.js';
4
4
  import { getFunctionFromPath } from './runtimes/index.js';
5
- import { parseFile, serverConfig, } from './runtimes/node/in_source_config/index.js';
5
+ import { parseFile, serverConfig } from './runtimes/node/in_source_config/index.js';
6
6
  import { RUNTIME } from './runtimes/runtime.js';
7
7
  import { FunctionBundlingUserError } from './utils/error.js';
8
8
  import { formatZipResult } from './utils/format_result.js';
@@ -88,11 +88,19 @@ export const bundleServer = async (server, destFolder, { basePath, cache, featur
88
88
  const fromNetlifyConfig = parseNetlifyServerConfig(server.config);
89
89
  const srcPath = resolve(server.path);
90
90
  const source = await readServerSource(srcPath, { cache, featureFlags });
91
+ if (fromNetlifyConfig.includedFiles !== undefined && basePath === undefined) {
92
+ throw new Error('Netlify Server includedFiles from the [server] block need a basePath to resolve from');
93
+ }
94
+ // Included files from the [server] block resolve from the base path.
95
+ // In-source ones resolve from the entry file and replace them.
96
+ const functionConfig = fromNetlifyConfig.includedFiles === undefined
97
+ ? source.config
98
+ : { ...source.config, includedFiles: fromNetlifyConfig.includedFiles, includedFilesBasePath: basePath };
91
99
  const zipResult = await source.runtime.zipFunction({
92
100
  archiveFormat: ARCHIVE_FORMAT.ZIP,
93
101
  basePath,
94
102
  cache,
95
- config: source.config,
103
+ config: functionConfig,
96
104
  destFolder,
97
105
  extension: source.extension,
98
106
  featureFlags,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/zip-it-and-ship-it",
3
- "version": "16.4.1",
3
+ "version": "16.5.0",
4
4
  "description": "Zip it and ship it",
5
5
  "main": "./dist/main.js",
6
6
  "type": "module",
@@ -99,5 +99,5 @@
99
99
  "engines": {
100
100
  "node": ">=22.12.0"
101
101
  },
102
- "gitHead": "9402ebe1d2303587983ef76772ef8714439d32d3"
102
+ "gitHead": "d21ff03cab97f189702f9900e48eb988cdd104cc"
103
103
  }