@vercel/build-utils 6.0.1 → 6.1.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.
@@ -1,4 +1,4 @@
1
- import type { Files } from './types';
1
+ import type { Cron, Files } from './types';
2
2
  /**
3
3
  * An Edge Functions output
4
4
  */
@@ -35,5 +35,7 @@ export declare class EdgeFunction {
35
35
  }[];
36
36
  /** The regions where the edge function will be executed on */
37
37
  regions?: string | string[];
38
+ /** Cronjob definition for the edge function */
39
+ cron?: Cron;
38
40
  constructor(params: Omit<EdgeFunction, 'type'>);
39
41
  }
@@ -14,6 +14,7 @@ class EdgeFunction {
14
14
  this.envVarsInUse = params.envVarsInUse;
15
15
  this.assets = params.assets;
16
16
  this.regions = params.regions;
17
+ this.cron = params.cron;
17
18
  }
18
19
  }
19
20
  exports.EdgeFunction = EdgeFunction;
@@ -63,7 +63,7 @@ export declare function getNodeBinPath({ cwd, }: {
63
63
  }): Promise<string>;
64
64
  export declare function runShellScript(fsPath: string, args?: string[], spawnOpts?: SpawnOptions): Promise<boolean>;
65
65
  export declare function getSpawnOptions(meta: Meta, nodeVersion: NodeVersion): SpawnOptions;
66
- export declare function getNodeVersion(destPath: string, _nodeVersion?: string, config?: Config, meta?: Meta): Promise<NodeVersion>;
66
+ export declare function getNodeVersion(destPath: string, nodeVersionFallback?: string | undefined, config?: Config, meta?: Meta): Promise<NodeVersion>;
67
67
  export declare function scanParentDirs(destPath: string, readPackageJson?: boolean): Promise<ScanParentDirsResult>;
68
68
  export declare function walkParentDirs({ base, start, filename, }: WalkParentDirsProps): Promise<string | null>;
69
69
  export declare function runNpmInstall(destPath: string, args?: string[], spawnOpts?: SpawnOptions, meta?: Meta, nodeVersion?: NodeVersion): Promise<boolean>;
@@ -113,14 +113,14 @@ function getSpawnOptions(meta, nodeVersion) {
113
113
  return opts;
114
114
  }
115
115
  exports.getSpawnOptions = getSpawnOptions;
116
- async function getNodeVersion(destPath, _nodeVersion, config = {}, meta = {}) {
116
+ async function getNodeVersion(destPath, nodeVersionFallback = process.env.VERCEL_PROJECT_SETTINGS_NODE_VERSION, config = {}, meta = {}) {
117
117
  const latest = node_version_1.getLatestNodeVersion();
118
118
  if (meta.isDev) {
119
119
  // Use the system-installed version of `node` in PATH for `vercel dev`
120
120
  return { ...latest, runtime: 'nodejs' };
121
121
  }
122
122
  const { packageJson } = await scanParentDirs(destPath, true);
123
- let { nodeVersion } = config;
123
+ let nodeVersion = config.nodeVersion || nodeVersionFallback;
124
124
  let isAuto = true;
125
125
  if (packageJson?.engines?.node) {
126
126
  const { node } = packageJson.engines;
package/dist/index.js CHANGED
@@ -30253,6 +30253,7 @@ class EdgeFunction {
30253
30253
  this.envVarsInUse = params.envVarsInUse;
30254
30254
  this.assets = params.assets;
30255
30255
  this.regions = params.regions;
30256
+ this.cron = params.cron;
30256
30257
  }
30257
30258
  }
30258
30259
  exports.EdgeFunction = EdgeFunction;
@@ -31093,14 +31094,14 @@ function getSpawnOptions(meta, nodeVersion) {
31093
31094
  return opts;
31094
31095
  }
31095
31096
  exports.getSpawnOptions = getSpawnOptions;
31096
- async function getNodeVersion(destPath, _nodeVersion, config = {}, meta = {}) {
31097
+ async function getNodeVersion(destPath, nodeVersionFallback = process.env.VERCEL_PROJECT_SETTINGS_NODE_VERSION, config = {}, meta = {}) {
31097
31098
  const latest = node_version_1.getLatestNodeVersion();
31098
31099
  if (meta.isDev) {
31099
31100
  // Use the system-installed version of `node` in PATH for `vercel dev`
31100
31101
  return { ...latest, runtime: 'nodejs' };
31101
31102
  }
31102
31103
  const { packageJson } = await scanParentDirs(destPath, true);
31103
- let { nodeVersion } = config;
31104
+ let nodeVersion = config.nodeVersion || nodeVersionFallback;
31104
31105
  let isAuto = true;
31105
31106
  if (packageJson?.engines?.node) {
31106
31107
  const { node } = packageJson.engines;
@@ -31730,7 +31731,7 @@ const download_1 = __webpack_require__(3166);
31730
31731
  const stream_to_buffer_1 = __importDefault(__webpack_require__(9688));
31731
31732
  class Lambda {
31732
31733
  constructor(opts) {
31733
- const { handler, runtime, maxDuration, memory, environment = {}, allowQuery, regions, supportsMultiPayloads, supportsWrapper, experimentalResponseStreaming, operationType, } = opts;
31734
+ const { handler, runtime, maxDuration, memory, environment = {}, allowQuery, regions, cron, supportsMultiPayloads, supportsWrapper, experimentalResponseStreaming, operationType, } = opts;
31734
31735
  if ('files' in opts) {
31735
31736
  assert_1.default(typeof opts.files === 'object', '"files" must be an object');
31736
31737
  }
@@ -31760,6 +31761,9 @@ class Lambda {
31760
31761
  assert_1.default(Array.isArray(regions), '"regions" is not an Array');
31761
31762
  assert_1.default(regions.every(r => typeof r === 'string'), '"regions" is not a string Array');
31762
31763
  }
31764
+ if (cron !== undefined) {
31765
+ assert_1.default(typeof cron === 'string', '"cron" is not a string');
31766
+ }
31763
31767
  this.type = 'Lambda';
31764
31768
  this.operationType = operationType;
31765
31769
  this.files = 'files' in opts ? opts.files : undefined;
@@ -31770,6 +31774,7 @@ class Lambda {
31770
31774
  this.environment = environment;
31771
31775
  this.allowQuery = allowQuery;
31772
31776
  this.regions = regions;
31777
+ this.cron = cron;
31773
31778
  this.zipBuffer = 'zipBuffer' in opts ? opts.zipBuffer : undefined;
31774
31779
  this.supportsMultiPayloads = supportsMultiPayloads;
31775
31780
  this.supportsWrapper = supportsWrapper;
package/dist/lambda.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import type { Files, Config } from './types';
2
+ import type { Files, Config, Cron } from './types';
3
3
  interface Environment {
4
4
  [key: string]: string;
5
5
  }
@@ -16,6 +16,7 @@ export interface LambdaOptionsBase {
16
16
  supportsWrapper?: boolean;
17
17
  experimentalResponseStreaming?: boolean;
18
18
  operationType?: string;
19
+ cron?: Cron;
19
20
  }
20
21
  export interface LambdaOptionsWithFiles extends LambdaOptionsBase {
21
22
  files: Files;
@@ -49,6 +50,7 @@ export declare class Lambda {
49
50
  environment: Environment;
50
51
  allowQuery?: string[];
51
52
  regions?: string[];
53
+ cron?: Cron;
52
54
  /**
53
55
  * @deprecated Use `await lambda.createZip()` instead.
54
56
  */
package/dist/lambda.js CHANGED
@@ -13,7 +13,7 @@ const download_1 = require("./fs/download");
13
13
  const stream_to_buffer_1 = __importDefault(require("./fs/stream-to-buffer"));
14
14
  class Lambda {
15
15
  constructor(opts) {
16
- const { handler, runtime, maxDuration, memory, environment = {}, allowQuery, regions, supportsMultiPayloads, supportsWrapper, experimentalResponseStreaming, operationType, } = opts;
16
+ const { handler, runtime, maxDuration, memory, environment = {}, allowQuery, regions, cron, supportsMultiPayloads, supportsWrapper, experimentalResponseStreaming, operationType, } = opts;
17
17
  if ('files' in opts) {
18
18
  assert_1.default(typeof opts.files === 'object', '"files" must be an object');
19
19
  }
@@ -43,6 +43,9 @@ class Lambda {
43
43
  assert_1.default(Array.isArray(regions), '"regions" is not an Array');
44
44
  assert_1.default(regions.every(r => typeof r === 'string'), '"regions" is not a string Array');
45
45
  }
46
+ if (cron !== undefined) {
47
+ assert_1.default(typeof cron === 'string', '"cron" is not a string');
48
+ }
46
49
  this.type = 'Lambda';
47
50
  this.operationType = operationType;
48
51
  this.files = 'files' in opts ? opts.files : undefined;
@@ -53,6 +56,7 @@ class Lambda {
53
56
  this.environment = environment;
54
57
  this.allowQuery = allowQuery;
55
58
  this.regions = regions;
59
+ this.cron = cron;
56
60
  this.zipBuffer = 'zipBuffer' in opts ? opts.zipBuffer : undefined;
57
61
  this.supportsMultiPayloads = supportsMultiPayloads;
58
62
  this.supportsWrapper = supportsWrapper;
package/dist/types.d.ts CHANGED
@@ -362,6 +362,7 @@ export interface BuildResultBuildOutput {
362
362
  */
363
363
  buildOutputPath: string;
364
364
  }
365
+ export declare type Cron = string;
365
366
  /**
366
367
  * When a Builder implements `version: 2`, the `build()` function is expected
367
368
  * to return this type.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "6.0.1",
3
+ "version": "6.1.0",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
@@ -51,5 +51,5 @@
51
51
  "typescript": "4.3.4",
52
52
  "yazl": "2.5.1"
53
53
  },
54
- "gitHead": "ada9a48d57be8f4375494a369aaa98cee1f5eae2"
54
+ "gitHead": "a4d16c681a7e85f64a2d78432d499c599b398bde"
55
55
  }