@vercel/build-utils 6.0.0 → 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.
- package/dist/edge-function.d.ts +3 -1
- package/dist/edge-function.js +1 -0
- package/dist/fs/rename.d.ts +7 -0
- package/dist/fs/rename.js +12 -4
- package/dist/fs/run-user-scripts.d.ts +1 -1
- package/dist/fs/run-user-scripts.js +2 -2
- package/dist/index.js +20 -7
- package/dist/lambda.d.ts +3 -1
- package/dist/lambda.js +5 -1
- package/dist/types.d.ts +1 -0
- package/package.json +2 -2
package/dist/edge-function.d.ts
CHANGED
@@ -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
|
}
|
package/dist/edge-function.js
CHANGED
package/dist/fs/rename.d.ts
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
import { Files } from '../types';
|
2
2
|
declare type Delegate = (name: string) => string;
|
3
|
+
/**
|
4
|
+
* Renames the keys of a `Files` map.
|
5
|
+
*
|
6
|
+
* @param files A map of filenames to `File` instances
|
7
|
+
* @param delegate A function that returns the new filename
|
8
|
+
* @returns A new file map with the renamed filenames
|
9
|
+
*/
|
3
10
|
export default function rename(files: Files, delegate: Delegate): Files;
|
4
11
|
export {};
|
package/dist/fs/rename.js
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
/**
|
4
|
+
* Renames the keys of a `Files` map.
|
5
|
+
*
|
6
|
+
* @param files A map of filenames to `File` instances
|
7
|
+
* @param delegate A function that returns the new filename
|
8
|
+
* @returns A new file map with the renamed filenames
|
9
|
+
*/
|
3
10
|
function rename(files, delegate) {
|
4
|
-
|
5
|
-
|
6
|
-
[delegate(name)]
|
7
|
-
}
|
11
|
+
const result = {};
|
12
|
+
for (const [name, file] of Object.entries(files)) {
|
13
|
+
result[delegate(name)] = file;
|
14
|
+
}
|
15
|
+
return result;
|
8
16
|
}
|
9
17
|
exports.default = rename;
|
@@ -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,
|
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,
|
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
|
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;
|
@@ -30955,11 +30956,19 @@ exports.readConfigFile = readConfigFile;
|
|
30955
30956
|
"use strict";
|
30956
30957
|
|
30957
30958
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
30959
|
+
/**
|
30960
|
+
* Renames the keys of a `Files` map.
|
30961
|
+
*
|
30962
|
+
* @param files A map of filenames to `File` instances
|
30963
|
+
* @param delegate A function that returns the new filename
|
30964
|
+
* @returns A new file map with the renamed filenames
|
30965
|
+
*/
|
30958
30966
|
function rename(files, delegate) {
|
30959
|
-
|
30960
|
-
|
30961
|
-
[delegate(name)]
|
30962
|
-
}
|
30967
|
+
const result = {};
|
30968
|
+
for (const [name, file] of Object.entries(files)) {
|
30969
|
+
result[delegate(name)] = file;
|
30970
|
+
}
|
30971
|
+
return result;
|
30963
30972
|
}
|
30964
30973
|
exports.default = rename;
|
30965
30974
|
|
@@ -31085,14 +31094,14 @@ function getSpawnOptions(meta, nodeVersion) {
|
|
31085
31094
|
return opts;
|
31086
31095
|
}
|
31087
31096
|
exports.getSpawnOptions = getSpawnOptions;
|
31088
|
-
async function getNodeVersion(destPath,
|
31097
|
+
async function getNodeVersion(destPath, nodeVersionFallback = process.env.VERCEL_PROJECT_SETTINGS_NODE_VERSION, config = {}, meta = {}) {
|
31089
31098
|
const latest = node_version_1.getLatestNodeVersion();
|
31090
31099
|
if (meta.isDev) {
|
31091
31100
|
// Use the system-installed version of `node` in PATH for `vercel dev`
|
31092
31101
|
return { ...latest, runtime: 'nodejs' };
|
31093
31102
|
}
|
31094
31103
|
const { packageJson } = await scanParentDirs(destPath, true);
|
31095
|
-
let
|
31104
|
+
let nodeVersion = config.nodeVersion || nodeVersionFallback;
|
31096
31105
|
let isAuto = true;
|
31097
31106
|
if (packageJson?.engines?.node) {
|
31098
31107
|
const { node } = packageJson.engines;
|
@@ -31722,7 +31731,7 @@ const download_1 = __webpack_require__(3166);
|
|
31722
31731
|
const stream_to_buffer_1 = __importDefault(__webpack_require__(9688));
|
31723
31732
|
class Lambda {
|
31724
31733
|
constructor(opts) {
|
31725
|
-
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;
|
31726
31735
|
if ('files' in opts) {
|
31727
31736
|
assert_1.default(typeof opts.files === 'object', '"files" must be an object');
|
31728
31737
|
}
|
@@ -31752,6 +31761,9 @@ class Lambda {
|
|
31752
31761
|
assert_1.default(Array.isArray(regions), '"regions" is not an Array');
|
31753
31762
|
assert_1.default(regions.every(r => typeof r === 'string'), '"regions" is not a string Array');
|
31754
31763
|
}
|
31764
|
+
if (cron !== undefined) {
|
31765
|
+
assert_1.default(typeof cron === 'string', '"cron" is not a string');
|
31766
|
+
}
|
31755
31767
|
this.type = 'Lambda';
|
31756
31768
|
this.operationType = operationType;
|
31757
31769
|
this.files = 'files' in opts ? opts.files : undefined;
|
@@ -31762,6 +31774,7 @@ class Lambda {
|
|
31762
31774
|
this.environment = environment;
|
31763
31775
|
this.allowQuery = allowQuery;
|
31764
31776
|
this.regions = regions;
|
31777
|
+
this.cron = cron;
|
31765
31778
|
this.zipBuffer = 'zipBuffer' in opts ? opts.zipBuffer : undefined;
|
31766
31779
|
this.supportsMultiPayloads = supportsMultiPayloads;
|
31767
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
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/build-utils",
|
3
|
-
"version": "6.
|
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": "
|
54
|
+
"gitHead": "a4d16c681a7e85f64a2d78432d499c599b398bde"
|
55
55
|
}
|