@now/build-utils
- Version 2.7.0
- Published
- 1.26 MB
- No dependencies
- MIT license
Install
npm i @now/build-utilsyarn add @now/build-utilspnpm add @now/build-utilsOverview
Overview not available.
Index
Variables
Functions
- createLambda()
- debug()
- detectApiDirectory()
- detectApiExtensions()
- detectBuilders()
- detectFramework()
- detectOutputDirectory()
- download()
- execAsync()
- execCommand()
- getDiscontinuedNodeVersions()
- getLambdaOptionsFromFunction()
- getLatestNodeVersion()
- getNodeBinPath()
- getNodeVersion()
- getPlatformEnv()
- getPrettyError()
- getScriptName()
- getSpawnOptions()
- getWriteableDirectory()
- glob()
- isOfficialRuntime()
- isStaticRuntime()
- isSymbolicLink()
- readConfigFile()
- rename()
- runBundleInstall()
- runNpmInstall()
- runPackageJsonScript()
- runPipInstall()
- runShellScript()
- shouldServe()
- spawnAsync()
- spawnCommand()
- streamToBuffer()
- walkParentDirs()
Classes
Interfaces
Type Aliases
Namespaces
Variables
variable buildsSchema
const buildsSchema: {    type: string;    minItems: number;    maxItems: number;    items: {        type: string;        additionalProperties: boolean;        required: string[];        properties: {            src: { type: string; minLength: number; maxLength: number };            use: { type: string; minLength: number; maxLength: number };            config: { type: string };        };    };};variable functionsSchema
const functionsSchema: {    type: string;    minProperties: number;    maxProperties: number;    additionalProperties: boolean;    patternProperties: {        '^.{1,256}$': {            type: string;            additionalProperties: boolean;            properties: {                runtime: { type: string; maxLength: number };                memory: { enum: number[] };                maxDuration: { type: string; minimum: number; maximum: number };                includeFiles: { type: string; maxLength: number };                excludeFiles: { type: string; maxLength: number };            };        };    };};variable installDependencies
const installDependencies: (    destPath: string,    args?: string[],    spawnOpts?: SpawnOptions,    meta?: Meta) => Promise<void>;- installDependencies() is deprecated. Please use runNpmInstall() instead. 
Functions
function createLambda
createLambda: ({    files,    handler,    runtime,    memory,    maxDuration,    environment,}: CreateLambdaOptions) => Promise<Lambda>;function debug
debug: (message: string, ...additional: any[]) => void;function detectApiDirectory
detectApiDirectory: (builders: Builder[]) => string | null;function detectApiExtensions
detectApiExtensions: (builders: Builder[]) => Set<string>;function detectBuilders
detectBuilders: (    files: string[],    pkg?: PackageJson | undefined | null,    options?: Options) => Promise<{    builders: Builder[] | null;    errors: ErrorResponse[] | null;    warnings: ErrorResponse[];    defaultRoutes: Route[] | null;    redirectRoutes: Route[] | null;    rewriteRoutes: Route[] | null;    errorRoutes: Route[] | null;}>;function detectFramework
detectFramework: ({    fs,    frameworkList,}: DetectFrameworkOptions) => Promise<string | null>;function detectOutputDirectory
detectOutputDirectory: (builders: Builder[]) => string | null;function download
download: (    files: Files,    basePath: string,    meta?: Meta) => Promise<DownloadedFiles>;function execAsync
execAsync: (    command: string,    args: string[],    opts?: SpawnOptionsExtended) => Promise<{ stdout: string; stderr: string; code: number }>;function execCommand
execCommand: (command: string, options?: SpawnOptions) => Promise<boolean>;function getDiscontinuedNodeVersions
getDiscontinuedNodeVersions: () => NodeVersion[];function getLambdaOptionsFromFunction
getLambdaOptionsFromFunction: ({    sourceFile,    config,}: GetLambdaOptionsFromFunctionOptions) => Promise<    Pick<LambdaOptions, 'memory' | 'maxDuration'>>;function getLatestNodeVersion
getLatestNodeVersion: () => NodeVersion;function getNodeBinPath
getNodeBinPath: ({ cwd }: { cwd: string }) => Promise<string>;function getNodeVersion
getNodeVersion: (    destPath: string,    _nodeVersion?: string,    _config?: Config,    meta?: Meta) => Promise<NodeVersion>;function getPlatformEnv
getPlatformEnv: (name: string) => string | undefined;- Helper function to support both - VERCEL_and legacy- NOW_env vars. Throws an error if *both* env vars are defined.
function getPrettyError
getPrettyError: (obj: {    dataPath?: string;    message?: string;    params: any;}) => NowBuildError;function getScriptName
getScriptName: (    pkg: Pick<PackageJson, 'scripts'> | null | undefined,    possibleNames: Iterable<string>) => string | null;function getSpawnOptions
getSpawnOptions: (meta: Meta, nodeVersion: NodeVersion) => SpawnOptions;function getWriteableDirectory
getWriteableDirectory: () => Promise<string>;function glob
glob: (    pattern: string,    opts: GlobOptions | string,    mountpoint?: string) => Promise<FsFiles>;function isOfficialRuntime
isOfficialRuntime: (desired: string, name?: string | undefined) => boolean;- Helper function to support both - @verceland legacy- @nowofficial Runtimes.
function isStaticRuntime
isStaticRuntime: (name?: string | undefined) => boolean;function isSymbolicLink
isSymbolicLink: (mode: number) => boolean;function readConfigFile
readConfigFile: <T>(files: string | string[]) => Promise<T | null>;function rename
rename: (files: Files, delegate: Delegate) => Files;function runBundleInstall
runBundleInstall: (    destPath: string,    args?: string[],    spawnOpts?: SpawnOptions,    meta?: Meta) => Promise<void>;function runNpmInstall
runNpmInstall: (    destPath: string,    args?: string[],    spawnOpts?: SpawnOptions,    meta?: Meta) => Promise<void>;function runPackageJsonScript
runPackageJsonScript: (    destPath: string,    scriptNames: string | Iterable<string>,    spawnOpts?: SpawnOptions) => Promise<boolean>;function runPipInstall
runPipInstall: (    destPath: string,    args?: string[],    spawnOpts?: SpawnOptions,    meta?: Meta) => Promise<void>;function runShellScript
runShellScript: (    fsPath: string,    args?: string[],    spawnOpts?: SpawnOptions) => Promise<boolean>;function shouldServe
shouldServe: ({ entrypoint, files, requestPath }: ShouldServeOptions) => boolean;function spawnAsync
spawnAsync: (    command: string,    args: string[],    opts?: SpawnOptionsExtended) => Promise<void>;function spawnCommand
spawnCommand: (command: string, options?: SpawnOptions) => any;function streamToBuffer
streamToBuffer: (stream: NodeJS.ReadableStream) => Promise<Buffer>;function walkParentDirs
walkParentDirs: ({    base,    start,    filename,}: WalkParentDirsProps) => Promise<string | null>;Classes
class DetectorFilesystem
abstract class DetectorFilesystem {}- DetectorFilesystemis an abstract class that represents a virtual filesystem to perform read-only operations on in order to detect which framework is being used.- Its abstract methods must be implemented by a subclass that perform the actual FS operations. Example subclasses could be implemented as: - - Local filesystem, which proxies the FS operations to the equivalent - fsmodule functions. - HTTP filesystem, which implements the FS operations over an HTTP server and does not require a local copy of the files. -- Filesfilesystem, which operates on a virtual- Filesobject (i.e. from the- glob()function) which could include- FileFsRef,- FileBlob, etc.- This base class implements various helper functions for common tasks (i.e. read and parse a JSON file). It also includes caching for all FS operations so that multiple detector functions de-dup read operations on the same file to reduce network/filesystem overhead. - **NOTE:** It's important that all instance methods in this base class are bound to - thisso that the- fsobject may be destructured in the detector functions. The easiest way to do this is to use the- =syntax when defining methods in this class definition.
constructor
constructor();property hasPath
hasPath: (path: string) => Promise<boolean>;property isFile
isFile: (name: string) => Promise<boolean>;property readFile
readFile: (name: string) => Promise<Buffer>;class FileBlob
class FileBlob implements File {}constructor
constructor({ mode, contentType, data }: FileBlobOptions);property contentType
contentType: string;property data
data: any;property mode
mode: number;property type
type: string;method fromStream
static fromStream: ({    mode,    contentType,    stream,}: FromStreamOptions) => Promise<FileBlob>;method toStream
toStream: () => NodeJS.ReadableStream;class FileRef
class FileRef implements File {}constructor
constructor({ mode, digest, contentType, mutable }: FileRefOptions);property contentType
contentType: string;property digest
digest: string;property mode
mode: number;property type
type: string;method toStream
toStream: () => NodeJS.ReadableStream;method toStreamAsync
toStreamAsync: () => Promise<NodeJS.ReadableStream>;class Lambda
class Lambda {}constructor
constructor({    zipBuffer,    handler,    runtime,    maxDuration,    memory,    environment,}: LambdaOptions);property environment
environment: Environment;property handler
handler: string;property maxDuration
maxDuration?: number;property memory
memory?: number;property runtime
runtime: string;property type
type: string;property zipBuffer
zipBuffer: Buffer;class NowBuildError
class NowBuildError extends Error {}- This error should be thrown from a Builder in order to stop the build and print a message. This is necessary to avoid printing a stack trace. 
constructor
constructor({ message, code, link, action }: Props);property action
action?: string;property code
code: string;property hideStackTrace
hideStackTrace: boolean;property link
link?: string;class Prerender
class Prerender {}constructor
constructor({    expiration,    lambda,    fallback,    group,    bypassToken,}: PrerenderOptions);property bypassToken
bypassToken: string;property expiration
expiration: number | false;property fallback
fallback: any;property group
group?: number;property lambda
lambda: Lambda;property type
type: string;Interfaces
interface AnalyzeOptions
interface AnalyzeOptions {}property config
config: Config;- An arbitrary object passed by the user in the build definition defined in - vercel.json.
property entrypoint
entrypoint: string;- Name of entrypoint file for this particular build job. Value - files[entrypoint]is guaranteed to exist and be a valid File reference.- entrypointis always a discrete file and never a glob, since globs are expanded into separate builds at deployment time.
property files
files: {    [filePath: string]: FileRef;};- All source files of the project 
property workPath
workPath: string;- A writable temporary directory where you are encouraged to perform your build process. This directory will be populated with the restored cache. 
interface Builder
interface Builder {}interface BuilderFunctions
interface BuilderFunctions {}index signature
[key: string]: {    memory?: number;    maxDuration?: number;    runtime?: string;    includeFiles?: string;    excludeFiles?: string;};interface BuildOptions
interface BuildOptions {}property config
config: Config;- An arbitrary object passed by the user in the build definition defined in - vercel.json.
property entrypoint
entrypoint: string;- Name of entrypoint file for this particular build job. Value - files[entrypoint]is guaranteed to exist and be a valid File reference.- entrypointis always a discrete file and never a glob, since globs are expanded into separate builds at deployment time.
property files
files: Files;- All source files of the project 
property meta
meta?: Meta;- Metadata related to the invoker of the builder, used by - vercel dev. Builders may use the properties on this object to change behavior based on the build environment.
property repoRootPath
repoRootPath?: string;- The "Root Directory" is assigned to the - workPathso the- repoRootPathis the Git Repository Root. This is only relevant for Monorepos. See https://vercel.com/blog/monorepos
property workPath
workPath: string;- A writable temporary directory where you are encouraged to perform your build process. This directory will be populated with the restored cache. 
interface Config
interface Config {}property buildCommand
buildCommand?: string;property bundle
bundle?: boolean;property debug
debug?: boolean;property devCommand
devCommand?: string;property excludeFiles
excludeFiles?: string | string[];property framework
framework?: string;property functions
functions?: BuilderFunctions;property helpers
helpers?: boolean;property import
import?: {    [key: string]: string;};property includeFiles
includeFiles?: string | string[];property installCommand
installCommand?: string;property ldsflags
ldsflags?: string;property maxLambdaSize
maxLambdaSize?: string;property nodeVersion
nodeVersion?: string;property outputDirectory
outputDirectory?: string;property rust
rust?: string;property zeroConfig
zeroConfig?: boolean;index signature
[key: string]:    | string    | string[]    | boolean    | number    | {          [key: string]: string;      }    | BuilderFunctions    | undefined;interface DownloadedFiles
interface DownloadedFiles {}index signature
[filePath: string]: FileFsRef;interface Env
interface Env {}index signature
[name: string]: string | undefined;interface File
interface File {}property contentType
contentType?: string;property fsPath
fsPath?: string;- The absolute path to the file in the filesystem 
property mode
mode: number;property toStream
toStream: () => NodeJS.ReadableStream;property type
type: string;interface Files
interface Files {}index signature
[filePath: string]: File;interface Meta
interface Meta {}property buildEnv
buildEnv?: Env;property devCacheDir
devCacheDir?: string;property env
env?: Env;property filesChanged
filesChanged?: string[];property filesRemoved
filesRemoved?: string[];property isDev
isDev?: boolean;property requestPath
requestPath?: string | null;property skipDownload
skipDownload?: boolean;interface NodeVersion
interface NodeVersion {}property discontinueDate
discontinueDate?: Date;property major
major: number;property range
range: string;property runtime
runtime: string;interface PackageJson
interface PackageJson {}property author
readonly author?: string | PackageJson.Author;property bin
readonly bin?: string | PackageJson.BinMap;property bugs
readonly bugs?: string | PackageJson.Bugs;property bundledDependencies
readonly bundledDependencies?: string[];property config
readonly config?: PackageJson.Config;property contributors
readonly contributors?: string[] | PackageJson.Author[];property cpu
readonly cpu?: string[];property dependencies
readonly dependencies?: PackageJson.DependencyMap;property description
readonly description?: string;property devDependencies
readonly devDependencies?: PackageJson.DependencyMap;property directories
readonly directories?: PackageJson.Directories;property engines
readonly engines?: PackageJson.Engines;property files
readonly files?: string[];property homepage
readonly homepage?: string;property keywords
readonly keywords?: string[];property license
readonly license?: string;property main
readonly main?: string;property man
readonly man?: string | string[];property name
readonly name?: string;property optionalDependencies
readonly optionalDependencies?: PackageJson.DependencyMap;property os
readonly os?: string[];property peerDependencies
readonly peerDependencies?: PackageJson.DependencyMap;property preferGlobal
readonly preferGlobal?: boolean;property private
readonly private?: boolean;property publishConfig
readonly publishConfig?: PackageJson.PublishConfig;property repository
readonly repository?: string | PackageJson.Repository;property scripts
readonly scripts?: PackageJson.ScriptsMap;property version
readonly version?: string;interface PrepareCacheOptions
interface PrepareCacheOptions {}property cachePath
cachePath: string;- A writable temporary directory where you can build a cache to use for the next run. 
property config
config: Config;- An arbitrary object passed by the user in the build definition defined in - vercel.json.
property entrypoint
entrypoint: string;- Name of entrypoint file for this particular build job. Value - files[entrypoint]is guaranteed to exist and be a valid File reference.- entrypointis always a discrete file and never a glob, since globs are expanded into separate builds at deployment time.
property files
files: Files;- All source files of the project 
property workPath
workPath: string;- A writable temporary directory where you are encouraged to perform your build process. 
interface ShouldServeOptions
interface ShouldServeOptions {}property config
config: Config;- An arbitrary object passed by the user in the build definition defined in - vercel.json.
property entrypoint
entrypoint: string;- Name of entrypoint file for this particular build job. Value - files[entrypoint]is guaranteed to exist and be a valid File reference.- entrypointis always a discrete file and never a glob, since globs are expanded into separate builds at deployment time.
property files
files: {    [path: string]: FileFsRef;};- All source files of the project 
property requestPath
requestPath: string;- A path string from a request. 
property workPath
workPath: string;- A writable temporary directory where you are encouraged to perform your build process. This directory will be populated with the restored cache. 
interface StartDevServerSuccess
interface StartDevServerSuccess {}Type Aliases
type GlobOptions
type GlobOptions = vanillaGlob_.IOptions;type StartDevServerOptions
type StartDevServerOptions = BuildOptions;- startDevServer()is given the same parameters as- build().
type StartDevServerResult
type StartDevServerResult = StartDevServerSuccess | null;- startDevServer()may return- nullto opt-out of spawning a dev server for a given- entrypoint.
Namespaces
namespace PackageJson
namespace PackageJson {}- Credit to Iain Reid, MIT license. Source: https://gist.github.com/iainreid820/5c1cc527fe6b5b7dba41fec7fe54bf6e 
interface Author
interface Author {}- An author or contributor 
interface BinMap
interface BinMap {}- A map of exposed bin commands 
index signature
[commandName: string]: string;interface DependencyMap
interface DependencyMap {}- A map of dependencies 
index signature
[dependencyName: string]: string;interface Directories
interface Directories {}- CommonJS package structure 
interface PublishConfig
interface PublishConfig {}property registry
registry?: string;interface Repository
interface Repository {}- A project repository 
interface ScriptsMap
interface ScriptsMap {}index signature
[scriptName: string]: string;Package Files (21)
- dist/debug.d.ts
- dist/detect-builders.d.ts
- dist/detect-framework.d.ts
- dist/detectors/filesystem.d.ts
- dist/errors.d.ts
- dist/file-blob.d.ts
- dist/file-ref.d.ts
- dist/fs/download.d.ts
- dist/fs/get-writable-directory.d.ts
- dist/fs/glob.d.ts
- dist/fs/node-version.d.ts
- dist/fs/read-config-file.d.ts
- dist/fs/rename.d.ts
- dist/fs/run-user-scripts.d.ts
- dist/fs/stream-to-buffer.d.ts
- dist/index.d.ts
- dist/lambda.d.ts
- dist/prerender.d.ts
- dist/schemas.d.ts
- dist/should-serve.d.ts
- dist/types.d.ts
Dependencies (0)
No dependencies.
Dev Dependencies (32)
- @iarna/toml
- @types/async-retry
- @types/cross-spawn
- @types/end-of-stream
- @types/fs-extra
- @types/glob
- @types/jest
- @types/js-yaml
- @types/multistream
- @types/node-fetch
- @types/semver
- @types/yazl
- @vercel/frameworks
- @vercel/ncc
- aggregate-error
- async-retry
- async-sema
- boxen
- cross-spawn
- end-of-stream
- fs-extra
- glob
- into-stream
- jest
- js-yaml
- minimatch
- multistream
- node-fetch
- semver
- ts-jest
- typescript
- yazl
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@now/build-utils.
- Markdown[](https://www.jsdocs.io/package/@now/build-utils)
- HTML<a href="https://www.jsdocs.io/package/@now/build-utils"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
 Package analyzed in 3237 ms.
- Missing or incorrect documentation? Open an issue for this package.
