@vercel/build-utils
Advanced tools
Comparing version 9.0.1 to 9.1.0
# @vercel/build-utils | ||
## 9.1.0 | ||
### Minor Changes | ||
- Add `useWebApi` property to `NodejsLambda` class ([#12873](https://github.com/vercel/vercel/pull/12873)) | ||
- [build-utils] convert NodeVersion to class and add state getter ([#12883](https://github.com/vercel/vercel/pull/12883)) | ||
[ruby] convert RubyVersion to class and add state getter | ||
## 9.0.1 | ||
@@ -4,0 +13,0 @@ |
@@ -40,9 +40,22 @@ "use strict"; | ||
var import_semver = require("semver"); | ||
var import_types = require("../types"); | ||
var import_errors = require("../errors"); | ||
var import_debug = __toESM(require("../debug")); | ||
const NODE_VERSIONS = [ | ||
{ major: 22, range: "22.x", runtime: "nodejs22.x" }, | ||
{ major: 20, range: "20.x", runtime: "nodejs20.x" }, | ||
{ major: 18, range: "18.x", runtime: "nodejs18.x" }, | ||
{ | ||
new import_types.NodeVersion({ | ||
major: 22, | ||
range: "22.x", | ||
runtime: "nodejs22.x" | ||
}), | ||
new import_types.NodeVersion({ | ||
major: 20, | ||
range: "20.x", | ||
runtime: "nodejs20.x" | ||
}), | ||
new import_types.NodeVersion({ | ||
major: 18, | ||
range: "18.x", | ||
runtime: "nodejs18.x" | ||
}), | ||
new import_types.NodeVersion({ | ||
major: 16, | ||
@@ -52,4 +65,4 @@ range: "16.x", | ||
discontinueDate: /* @__PURE__ */ new Date("2025-01-31") | ||
}, | ||
{ | ||
}), | ||
new import_types.NodeVersion({ | ||
major: 14, | ||
@@ -59,4 +72,4 @@ range: "14.x", | ||
discontinueDate: /* @__PURE__ */ new Date("2023-08-15") | ||
}, | ||
{ | ||
}), | ||
new import_types.NodeVersion({ | ||
major: 12, | ||
@@ -66,4 +79,4 @@ range: "12.x", | ||
discontinueDate: /* @__PURE__ */ new Date("2022-10-03") | ||
}, | ||
{ | ||
}), | ||
new import_types.NodeVersion({ | ||
major: 10, | ||
@@ -73,4 +86,4 @@ range: "10.x", | ||
discontinueDate: /* @__PURE__ */ new Date("2021-04-20") | ||
}, | ||
{ | ||
}), | ||
new import_types.NodeVersion({ | ||
major: 8, | ||
@@ -80,3 +93,3 @@ range: "8.10.x", | ||
discontinueDate: /* @__PURE__ */ new Date("2020-01-06") | ||
} | ||
}) | ||
]; | ||
@@ -114,3 +127,5 @@ function getOptions() { | ||
function getDiscontinuedNodeVersions() { | ||
return getOptions().filter(isDiscontinued); | ||
return getOptions().filter((version) => { | ||
return version.state === "discontinued"; | ||
}); | ||
} | ||
@@ -138,3 +153,3 @@ async function getSupportedNodeVersion(engineRange, isAuto = false, availableVersions) { | ||
} | ||
if (isDiscontinued(selection)) { | ||
if (selection.state === "discontinued") { | ||
const intro = `Node.js Version "${selection.range}" is discontinued and must be upgraded.`; | ||
@@ -148,16 +163,20 @@ throw new import_errors.NowBuildError({ | ||
(0, import_debug.default)(`Selected Node.js ${selection.range}`); | ||
if (selection.discontinueDate) { | ||
const d = selection.discontinueDate.toISOString().split("T")[0]; | ||
console.warn( | ||
`Error: Node.js version ${selection.range} has reached End-of-Life. Deployments created on or after ${d} will fail to build. ${getHint( | ||
isAuto | ||
)}` | ||
); | ||
if (selection.state === "deprecated") { | ||
const d = selection.formattedDate; | ||
if (d) { | ||
console.warn( | ||
`Error: Node.js version ${selection.range} is deprecated. Deployments created on or after ${d} will fail to build. ${getHint( | ||
isAuto | ||
)}` | ||
); | ||
} else { | ||
console.warn( | ||
`Error: Node.js version ${selection.range} is deprecated. ${getHint( | ||
isAuto | ||
)}` | ||
); | ||
} | ||
} | ||
return selection; | ||
} | ||
function isDiscontinued({ discontinueDate }) { | ||
const today = Date.now(); | ||
return discontinueDate !== void 0 && discontinueDate.getTime() <= today; | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -164,0 +183,0 @@ 0 && (module.exports = { |
@@ -204,3 +204,4 @@ "use strict"; | ||
if (meta.isDev) { | ||
return { ...latestVersion, runtime: "nodejs" }; | ||
latestVersion.runtime = "nodejs"; | ||
return latestVersion; | ||
} | ||
@@ -207,0 +208,0 @@ const { packageJson } = await scanParentDirs(destPath, true); |
@@ -6,2 +6,3 @@ import { Lambda, LambdaOptionsWithFiles } from './lambda'; | ||
awsLambdaHandler?: string; | ||
useWebApi?: boolean; | ||
} | ||
@@ -13,4 +14,5 @@ export declare class NodejsLambda extends Lambda { | ||
awsLambdaHandler?: string; | ||
constructor({ shouldAddHelpers, shouldAddSourcemapSupport, awsLambdaHandler, ...opts }: NodejsLambdaOptions); | ||
useWebApi?: boolean; | ||
constructor({ shouldAddHelpers, shouldAddSourcemapSupport, awsLambdaHandler, useWebApi, ...opts }: NodejsLambdaOptions); | ||
} | ||
export {}; |
@@ -30,2 +30,3 @@ "use strict"; | ||
awsLambdaHandler, | ||
useWebApi, | ||
...opts | ||
@@ -38,2 +39,3 @@ }) { | ||
this.awsLambdaHandler = awsLambdaHandler; | ||
this.useWebApi = useWebApi; | ||
} | ||
@@ -40,0 +42,0 @@ } |
@@ -286,5 +286,7 @@ /// <reference types="node" /> | ||
} | ||
export interface NodeVersion { | ||
export interface ConstructorVersion { | ||
/** major version number: 18 */ | ||
major: number; | ||
/** minor version number: 18 */ | ||
minor?: number; | ||
/** major version range: "18.x" */ | ||
@@ -294,5 +296,19 @@ range: string; | ||
runtime: string; | ||
/** date beyond which this version is discontinued: 2023-08-17T19:05:45.951Z */ | ||
discontinueDate?: Date; | ||
} | ||
interface BaseVersion extends ConstructorVersion { | ||
state: 'active' | 'deprecated' | 'discontinued'; | ||
} | ||
export declare class Version implements BaseVersion { | ||
major: number; | ||
minor?: number; | ||
range: string; | ||
runtime: string; | ||
discontinueDate?: Date; | ||
constructor(version: ConstructorVersion); | ||
get state(): "active" | "deprecated" | "discontinued"; | ||
get formattedDate(): string | undefined; | ||
} | ||
export declare class NodeVersion extends Version { | ||
} | ||
export interface Builder { | ||
@@ -299,0 +315,0 @@ use: string; |
@@ -6,2 +6,6 @@ "use strict"; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
@@ -17,2 +21,33 @@ if (from && typeof from === "object" || typeof from === "function") { | ||
var types_exports = {}; | ||
__export(types_exports, { | ||
NodeVersion: () => NodeVersion, | ||
Version: () => Version | ||
}); | ||
module.exports = __toCommonJS(types_exports); | ||
class Version { | ||
constructor(version) { | ||
this.major = version.major; | ||
this.minor = version.minor; | ||
this.range = version.range; | ||
this.runtime = version.runtime; | ||
this.discontinueDate = version.discontinueDate; | ||
} | ||
get state() { | ||
if (this.discontinueDate && this.discontinueDate.getTime() <= Date.now()) { | ||
return "discontinued"; | ||
} else if (this.discontinueDate) { | ||
return "deprecated"; | ||
} | ||
return "active"; | ||
} | ||
get formattedDate() { | ||
return this.discontinueDate && this.discontinueDate.toISOString().split("T")[0]; | ||
} | ||
} | ||
class NodeVersion extends Version { | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
NodeVersion, | ||
Version | ||
}); |
{ | ||
"name": "@vercel/build-utils", | ||
"version": "9.0.1", | ||
"version": "9.1.0", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is too big to display
1303337
29650