nodejs

package
v0.0.0-...-d97b457 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2024 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package nodejs generates the Dockerfile for Node.js projects.

Index

Constants

View Source
const (
	// ConfigCacheDependencies is the key for the configuration of
	// whether to cache dependencies.
	// It is true by default.
	ConfigCacheDependencies = "cache_dependencies"
)

Variables

This section is empty.

Functions

func DetermineNeedPlaywright

func DetermineNeedPlaywright(ctx *nodePlanContext) bool

DetermineNeedPlaywright determines whether the project needs Playwright.

func DetermineNeedPuppeteer

func DetermineNeedPuppeteer(ctx *nodePlanContext) bool

DetermineNeedPuppeteer determines whether the project needs Puppeteer.

func DeterminePackageManager

func DeterminePackageManager(ctx *nodePlanContext) types.NodePackageManager

DeterminePackageManager determines the package manager of the Node.js project.

func DetermineProjectFramework

func DetermineProjectFramework(ctx *nodePlanContext) types.NodeProjectFramework

DetermineProjectFramework determines the framework of the Node.js project.

func GenerateDockerfile

func GenerateDockerfile(meta types.PlanMeta) (string, error)

GenerateDockerfile generates the Dockerfile for Node.js projects.

func GetBuildCmd

func GetBuildCmd(ctx *nodePlanContext) string

GetBuildCmd gets the build command of the Node.js project.

func GetBuildScript

func GetBuildScript(ctx *nodePlanContext) string

GetBuildScript gets the build command in package.json's `scripts` of the Node.js project.

func GetEntry

func GetEntry(ctx *nodePlanContext) string

GetEntry gets the entry file of the Node.js project.

func GetInstallCmd

func GetInstallCmd(ctx *nodePlanContext) string

GetInstallCmd gets the installation command of the Node.js project.

func GetMeta

func GetMeta(opt GetMetaOptions) types.PlanMeta

GetMeta gets the metadata of the Node.js project.

func GetNodeVersion

func GetNodeVersion(ctx *nodePlanContext) string

GetNodeVersion gets the Node.js version of the project.

func GetStartCmd

func GetStartCmd(ctx *nodePlanContext) string

GetStartCmd gets the start command of the Node.js project.

func GetStartScript

func GetStartScript(ctx *nodePlanContext) string

GetStartScript gets the start command in package.json's `scripts` of the Node.js project.

func GetStaticOutputDir

func GetStaticOutputDir(ctx *nodePlanContext) string

GetStaticOutputDir returns the output directory for static projects. If empty string is returned, the service is not deployed as static files.

func NewIdentifier

func NewIdentifier() plan.Identifier

NewIdentifier returns a new NodeJS identifier.

func NewPacker

func NewPacker() packer.Packer

NewPacker returns a new Node.js packer.

Types

type GetMetaOptions

type GetMetaOptions struct {
	Src    afero.Fs
	Config plan.ImmutableProjectConfiguration

	CustomBuildCmd *string
	CustomStartCmd *string
	OutputDir      *string

	Bun bool
}

GetMetaOptions is the options for GetMeta.

type PackageJSON

type PackageJSON struct {
	PackageManager  *string           `json:"packageManager,omitempty"`
	Dependencies    map[string]string `json:"dependencies,omitempty"`
	DevDependencies map[string]string `json:"devDependencies,omitempty"`
	Scripts         map[string]string `json:"scripts,omitempty"`
	Engines         PackageJSONEngine `json:"engines"`
	Main            string            `json:"main"`
	Module          string            `json:"module"`
}

PackageJSON is the structure of `package.json`.

func DeserializePackageJSON

func DeserializePackageJSON(source afero.Fs) (PackageJSON, error)

DeserializePackageJSON deserializes a package.json file from source. When the deserialization failed, it returns an empty PackageJson with the error.

func NewPackageJSON

func NewPackageJSON() PackageJSON

NewPackageJSON returns a new instance of PackageJson with some default values.

func (PackageJSON) FindDependency

func (p PackageJSON) FindDependency(name string) (string, bool)

FindDependency checks if the package.json contains the given dependency in "dependency" and "devDependencies", and returns the version of the dependency.

type PackageJSONEngine

type PackageJSONEngine struct {
	Node string `json:"node"`
}

PackageJSONEngine is the structure of `package.json`'s `engines` field.

type TemplateContext

type TemplateContext struct {
	NodeVersion string

	InstallCmd string
	BuildCmd   string
	StartCmd   string

	Framework  string
	Serverless bool
	OutputDir  string

	Bun bool
}

TemplateContext is the context for the Node.js Dockerfile template.

func (TemplateContext) Execute

func (c TemplateContext) Execute() (string, error)

Execute executes the template.

Directories

Path Synopsis
Package nextjs is used to transform build output of Next.js app to the serverless build output format of Zeabur
Package nextjs is used to transform build output of Next.js app to the serverless build output format of Zeabur
Package nuxtjs is used to transform build output of Nuxt.js app to the serverless build output format of Zeabur
Package nuxtjs is used to transform build output of Nuxt.js app to the serverless build output format of Zeabur
Package remix is used to transform build output of Remix app to the serverless build output format of Zeabur
Package remix is used to transform build output of Remix app to the serverless build output format of Zeabur
Package waku is used to transform build output of Waku app to the serverless build output format of Zeabur
Package waku is used to transform build output of Waku app to the serverless build output format of Zeabur

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL