@vercel/backends 0.6.0 → 0.7.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/index.d.mts +8 -2
- package/dist/index.mjs +39 -7
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import * as _vercel_build_utils0 from "@vercel/build-utils";
|
|
2
|
-
import { BuildOptions, BuildV2, Files, PrepareCache, Span } from "@vercel/build-utils";
|
|
2
|
+
import { BuildOptions, BuildV2, DetectEntrypointFn, Files, PrepareCache, Span } from "@vercel/build-utils";
|
|
3
3
|
import { ParseArgsConfig } from "node:util";
|
|
4
4
|
|
|
5
5
|
//#region src/find-entrypoint.d.ts
|
|
6
6
|
declare const findEntrypoint: (cwd: string) => Promise<string | undefined>;
|
|
7
7
|
declare const findEntrypointOrThrow: (cwd: string) => Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Normalized entrypoint detector for Node services. Wraps {@link findEntrypoint}
|
|
10
|
+
* and returns the result in the shared {@link DetectedEntrypoint} shape consumed
|
|
11
|
+
* by services auto-detection.
|
|
12
|
+
*/
|
|
13
|
+
declare const detectEntrypoint: DetectEntrypointFn;
|
|
8
14
|
//#endregion
|
|
9
15
|
//#region src/cervel/types.d.ts
|
|
10
16
|
/**
|
|
@@ -104,4 +110,4 @@ declare const version = 2;
|
|
|
104
110
|
declare const build: BuildV2;
|
|
105
111
|
declare const prepareCache: PrepareCache;
|
|
106
112
|
//#endregion
|
|
107
|
-
export { type CervelBuildOptions, type CervelServeOptions, type PathOptions, build, build$1 as cervelBuild, serve as cervelServe, diagnostics, findEntrypoint, findEntrypointOrThrow, getBuildSummary, introspectApp, nodeFileTrace, prepareCache, srvxOptions, version };
|
|
113
|
+
export { type CervelBuildOptions, type CervelServeOptions, type PathOptions, build, build$1 as cervelBuild, serve as cervelServe, detectEntrypoint, diagnostics, findEntrypoint, findEntrypointOrThrow, getBuildSummary, introspectApp, nodeFileTrace, prepareCache, srvxOptions, version };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { builtinModules, createRequire } from "node:module";
|
|
2
2
|
import { createWriteStream, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { basename, dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
4
|
-
import { delimiter, dirname as dirname$1, join as join$1 } from "path";
|
|
3
|
+
import { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { delimiter as delimiter$1, dirname as dirname$1, join as join$1 } from "path";
|
|
5
5
|
import { FileBlob, FileFsRef, NodejsLambda, Span, createDiagnostics, debug, defaultCachePathGlob, download, execCommand, generateProjectManifest, getEnvForPackageManager, getInternalServiceCronPath, getLambdaOptionsFromFunction, getNodeBinPaths, getNodeVersion, getReportedServiceType, glob, isBackendFramework, isBunVersion, isExperimentalBackendsWithoutIntrospectionEnabled, isScheduleTriggeredService, runNpmInstall, runPackageJsonScript, scanParentDirs } from "@vercel/build-utils";
|
|
6
6
|
import { lstat, readFile, rm, stat } from "node:fs/promises";
|
|
7
7
|
import { build as build$2 } from "rolldown";
|
|
@@ -53,11 +53,11 @@ async function maybeExecBuildCommand(args, { spawnEnv }) {
|
|
|
53
53
|
const nodeBinPath = getNodeBinPaths({
|
|
54
54
|
base: args.repoRootPath || args.workPath,
|
|
55
55
|
start: args.workPath
|
|
56
|
-
}).join(delimiter);
|
|
56
|
+
}).join(delimiter$1);
|
|
57
57
|
return execCommand(projectBuildCommand, {
|
|
58
58
|
env: {
|
|
59
59
|
...spawnEnv,
|
|
60
|
-
PATH: `${nodeBinPath}${delimiter}${spawnEnv?.PATH || process.env.PATH}`
|
|
60
|
+
PATH: `${nodeBinPath}${delimiter$1}${spawnEnv?.PATH || process.env.PATH}`
|
|
61
61
|
},
|
|
62
62
|
cwd: args.workPath
|
|
63
63
|
});
|
|
@@ -582,6 +582,19 @@ const findEntrypointOrThrow = async (cwd) => {
|
|
|
582
582
|
if (!entrypoint) throw new Error(`No entrypoint found in "${cwd}". Set package.json "main" to a server file, or add one of: ${entrypoints.join(", ")}`);
|
|
583
583
|
return entrypoint;
|
|
584
584
|
};
|
|
585
|
+
/**
|
|
586
|
+
* Normalized entrypoint detector for Node services. Wraps {@link findEntrypoint}
|
|
587
|
+
* and returns the result in the shared {@link DetectedEntrypoint} shape consumed
|
|
588
|
+
* by services auto-detection.
|
|
589
|
+
*/
|
|
590
|
+
const detectEntrypoint = async ({ workPath }) => {
|
|
591
|
+
const file = await findEntrypoint(workPath);
|
|
592
|
+
if (!file) return null;
|
|
593
|
+
return {
|
|
594
|
+
kind: "file",
|
|
595
|
+
entrypoint: file
|
|
596
|
+
};
|
|
597
|
+
};
|
|
585
598
|
|
|
586
599
|
//#endregion
|
|
587
600
|
//#region src/cervel/index.ts
|
|
@@ -936,7 +949,7 @@ function buildCronRouteTable(crons) {
|
|
|
936
949
|
* `undefined` when the service is not schedule-triggered. Throws on
|
|
937
950
|
* `<dynamic>` schedules — that path is reserved for a follow-up.
|
|
938
951
|
*/
|
|
939
|
-
function getServiceCrons(opts) {
|
|
952
|
+
async function getServiceCrons(opts) {
|
|
940
953
|
const { service, entrypoint } = opts;
|
|
941
954
|
if (!service || !isScheduleTriggeredService(service)) return;
|
|
942
955
|
if (!service.name || typeof service.schedule !== "string") return;
|
|
@@ -1660,12 +1673,31 @@ const build = async (args) => {
|
|
|
1660
1673
|
const entrypoint = explicit && existsSync(join(args.workPath, explicit)) ? explicit : await findEntrypointOrThrow(args.workPath);
|
|
1661
1674
|
debug("Entrypoint", entrypoint);
|
|
1662
1675
|
args.entrypoint = entrypoint;
|
|
1663
|
-
const cronEntries = getServiceCrons({
|
|
1676
|
+
const cronEntries = await getServiceCrons({
|
|
1664
1677
|
service: args.service,
|
|
1665
1678
|
entrypoint
|
|
1666
1679
|
});
|
|
1667
1680
|
const isCronService = cronEntries !== void 0;
|
|
1668
1681
|
const userBuildResult = await maybeDoBuildCommand(args, downloadResult);
|
|
1682
|
+
const preDeployCommand = args.config.preDeployCommand;
|
|
1683
|
+
if (args.registerPreDeploy && typeof preDeployCommand === "string") {
|
|
1684
|
+
const nodeBinPath = getNodeBinPaths({
|
|
1685
|
+
base: args.repoRootPath || args.workPath,
|
|
1686
|
+
start: args.workPath
|
|
1687
|
+
}).join(delimiter);
|
|
1688
|
+
const capturedEnv = {
|
|
1689
|
+
...downloadResult.spawnEnv,
|
|
1690
|
+
PATH: `${nodeBinPath}${delimiter}${downloadResult.spawnEnv?.PATH || process.env.PATH}`
|
|
1691
|
+
};
|
|
1692
|
+
const capturedCwd = args.workPath;
|
|
1693
|
+
args.registerPreDeploy(async () => {
|
|
1694
|
+
debug(`Running pre-deploy command: \`${preDeployCommand}\``);
|
|
1695
|
+
await execCommand(preDeployCommand, {
|
|
1696
|
+
env: capturedEnv,
|
|
1697
|
+
cwd: capturedCwd
|
|
1698
|
+
});
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1669
1701
|
const functionConfig = args.config.functions?.[entrypoint];
|
|
1670
1702
|
if (functionConfig) {
|
|
1671
1703
|
args.config.includeFiles = [...normalizeArray(args.config.includeFiles), ...normalizeArray(functionConfig.includeFiles)];
|
|
@@ -1837,4 +1869,4 @@ const escapeForRegex = (value) => value.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&");
|
|
|
1837
1869
|
const toRegexSource = (value) => escapeForRegex(value).replaceAll("/", "\\/");
|
|
1838
1870
|
|
|
1839
1871
|
//#endregion
|
|
1840
|
-
export { build, build$1 as cervelBuild, serve as cervelServe, diagnostics, findEntrypoint, findEntrypointOrThrow, getBuildSummary, introspectApp, nodeFileTrace, prepareCache, srvxOptions, version };
|
|
1872
|
+
export { build, build$1 as cervelBuild, serve as cervelServe, detectEntrypoint, diagnostics, findEntrypoint, findEntrypointOrThrow, getBuildSummary, introspectApp, nodeFileTrace, prepareCache, srvxOptions, version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/backends",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"homepage": "https://vercel.com/docs",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"srvx": "0.8.9",
|
|
36
36
|
"tsx": "4.21.0",
|
|
37
37
|
"zod": "3.22.4",
|
|
38
|
-
"@vercel/build-utils": "13.
|
|
38
|
+
"@vercel/build-utils": "13.26.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/express": "5.0.3",
|