Documentation
¶
Index ¶
- Constants
- Variables
- func DetectNodeVersion(ctx *app.Context, pkg *PackageJSON) string
- func FindNestedPropertyValue(node *sitter.Node, source []byte, path ...string) string
- func FindPropertyValue(node *sitter.Node, source []byte, propertyName string) string
- func GetRequiredAptPackages(deps []NativeDependency) []string
- type ConfigParser
- type Engines
- type Framework
- type FrameworkInfo
- type NativeDependency
- type OutputType
- type PackageJSON
- func (p *PackageJSON) GetDependencyVersion(name string) string
- func (p *PackageJSON) GetPackageManagerInfo() (name, version string)
- func (p *PackageJSON) GetScript(name string) string
- func (p *PackageJSON) HasDependency(name string) bool
- func (p *PackageJSON) HasScript(name string) bool
- func (p *PackageJSON) IsMonorepo() bool
- type PackageManager
- type PackageManagerInfo
- type Provider
- type Workspaces
Constants ¶
const DefaultNodeVersion = "24"
Variables ¶
var NativeDependencies = []NativeDependency{ { Package: "sharp", AptPackages: []string{"libvips-dev"}, Description: "Image processing library", }, { Package: "@prisma/client", AptPackages: []string{"openssl"}, Description: "Database ORM", }, { Package: "prisma", AptPackages: []string{"openssl"}, Description: "Database ORM CLI", }, { Package: "puppeteer", AptPackages: []string{ "chromium", "libnss3", "libatk1.0-0", "libatk-bridge2.0-0", "libcups2", "libdrm2", "libxkbcommon0", "libxcomposite1", "libxdamage1", "libxfixes3", "libxrandr2", "libgbm1", "libasound2", "libpango-1.0-0", "libcairo2", }, Description: "Headless Chrome automation", }, { Package: "playwright", AptPackages: []string{ "libnss3", "libatk1.0-0", "libatk-bridge2.0-0", "libcups2", "libdrm2", "libxkbcommon0", "libxcomposite1", "libxdamage1", "libxfixes3", "libxrandr2", "libgbm1", "libasound2", "libpango-1.0-0", "libcairo2", }, Description: "Browser automation", }, { Package: "canvas", AptPackages: []string{"libcairo2-dev", "libjpeg-dev", "libpango1.0-dev", "libgif-dev", "librsvg2-dev"}, Description: "Canvas rendering", }, { Package: "bcrypt", AptPackages: []string{"build-essential", "python3"}, Description: "Password hashing", }, { Package: "argon2", AptPackages: []string{"build-essential"}, Description: "Password hashing", }, { Package: "sqlite3", AptPackages: []string{"build-essential", "python3"}, Description: "SQLite database", }, { Package: "better-sqlite3", AptPackages: []string{"build-essential", "python3"}, Description: "SQLite database", }, { Package: "node-gyp", AptPackages: []string{"build-essential", "python3"}, Description: "Native addon build tool", }, { Package: "cpu-features", AptPackages: []string{"build-essential"}, Description: "CPU feature detection", }, { Package: "ssh2", AptPackages: []string{"build-essential"}, Description: "SSH client", }, { Package: "libsql", AptPackages: []string{"build-essential"}, Description: "LibSQL database", }, { Package: "@libsql/client", AptPackages: []string{"build-essential"}, Description: "LibSQL client", }, }
NativeDependencies is a list of known packages requiring native dependencies
Functions ¶
func DetectNodeVersion ¶
func DetectNodeVersion(ctx *app.Context, pkg *PackageJSON) string
DetectNodeVersion detects the Node.js version to use Priority: 1. COOLPACK_NODE_VERSION environment variable 2. NODE_VERSION environment variable 3. engines.node in package.json 4. .nvmrc file 5. .node-version file 6. .tool-versions file (asdf) 7. mise.toml file 8. Default to 22
func FindNestedPropertyValue ¶
FindNestedPropertyValue searches for a nested property path (e.g., "server.preset") and returns its string value if found
func FindPropertyValue ¶
FindPropertyValue searches for a property with the given name in an object and returns its string value if found
func GetRequiredAptPackages ¶
func GetRequiredAptPackages(deps []NativeDependency) []string
GetRequiredAptPackages returns a deduplicated list of APT packages needed
Types ¶
type ConfigParser ¶
type ConfigParser struct {
// contains filtered or unexported fields
}
ConfigParser parses JavaScript/TypeScript config files using tree-sitter
func NewConfigParser ¶
func NewConfigParser() *ConfigParser
NewConfigParser creates a new config parser
type Engines ¶
type Engines struct {
Node string `json:"node"`
NPM string `json:"npm"`
Yarn string `json:"yarn"`
PNPM string `json:"pnpm"`
Bun string `json:"bun"`
}
Engines represents the engines field in package.json
type Framework ¶
type Framework string
Framework represents a detected Node.js framework
const ( FrameworkNone Framework = "" FrameworkNextJS Framework = "nextjs" FrameworkRemix Framework = "remix" FrameworkNuxt Framework = "nuxt" FrameworkAstro Framework = "astro" FrameworkVite Framework = "vite" FrameworkCRA Framework = "create-react-app" FrameworkAngular Framework = "angular" FrameworkSvelteKit Framework = "sveltekit" FrameworkSolidStart Framework = "solid-start" FrameworkExpress Framework = "express" FrameworkFastify Framework = "fastify" FrameworkNestJS Framework = "nestjs" FrameworkAdonisJS Framework = "adonisjs" FrameworkReactRouter Framework = "react-router" FrameworkTanStack Framework = "tanstack-start" FrameworkGatsby Framework = "gatsby" FrameworkEleventy Framework = "eleventy" )
type FrameworkInfo ¶
type FrameworkInfo struct {
Name Framework
Version string
OutputType OutputType
}
FrameworkInfo contains information about the detected framework
func DetectFramework ¶
func DetectFramework(ctx *app.Context, pkg *PackageJSON) FrameworkInfo
DetectFramework detects the framework used by the project
func (FrameworkInfo) GetDefaultBuildCommand ¶
func (f FrameworkInfo) GetDefaultBuildCommand(pm PackageManagerInfo) string
GetDefaultBuildCommand returns the default build command for a framework
func (FrameworkInfo) GetDefaultStartCommand ¶
func (f FrameworkInfo) GetDefaultStartCommand(pm PackageManagerInfo) string
GetDefaultStartCommand returns the default start command for a framework
type NativeDependency ¶
type NativeDependency struct {
// Package is the npm package name
Package string
// AptPackages are the Debian/Ubuntu packages needed for building
AptPackages []string
// Description explains why these packages are needed
Description string
}
NativeDependency represents a Node.js package that requires native system dependencies
func DetectNativeDependencies ¶
func DetectNativeDependencies(pkg *PackageJSON) []NativeDependency
DetectNativeDependencies checks which native dependencies are used by the project
type OutputType ¶
type OutputType string
OutputType represents the type of output the framework produces
const ( OutputTypeNone OutputType = "" // Unknown OutputTypeStatic OutputType = "static" // Static files (SPA, SSG) - can be served from any static file server OutputTypeServer OutputType = "server" // Needs Node.js server at runtime (SSR frameworks, backend APIs) )
type PackageJSON ¶
type PackageJSON struct {
Name string `json:"name"`
Version string `json:"version"`
Main string `json:"main"`
Type string `json:"type"`
Scripts map[string]string `json:"scripts"`
Dependencies map[string]string `json:"dependencies"`
DevDependencies map[string]string `json:"devDependencies"`
Engines Engines `json:"engines"`
PackageManager string `json:"packageManager"`
Workspaces Workspaces `json:"workspaces"`
CacheDirectories []string `json:"cacheDirectories"`
}
PackageJSON represents the structure of a package.json file
func ParsePackageJSON ¶
func ParsePackageJSON(data []byte) (*PackageJSON, error)
ParsePackageJSON parses a package.json file from bytes
func (*PackageJSON) GetDependencyVersion ¶
func (p *PackageJSON) GetDependencyVersion(name string) string
GetDependencyVersion returns the version of a dependency
func (*PackageJSON) GetPackageManagerInfo ¶
func (p *PackageJSON) GetPackageManagerInfo() (name, version string)
GetPackageManagerInfo parses the packageManager field (e.g., "pnpm@8.0.0") Returns the package manager name and version
func (*PackageJSON) GetScript ¶
func (p *PackageJSON) GetScript(name string) string
GetScript returns a script from package.json
func (*PackageJSON) HasDependency ¶
func (p *PackageJSON) HasDependency(name string) bool
HasDependency checks if a dependency exists (in either dependencies or devDependencies)
func (*PackageJSON) HasScript ¶
func (p *PackageJSON) HasScript(name string) bool
HasScript checks if a script exists in package.json
func (*PackageJSON) IsMonorepo ¶
func (p *PackageJSON) IsMonorepo() bool
IsMonorepo checks if this is a monorepo setup
type PackageManager ¶
type PackageManager string
PackageManager represents a Node.js package manager
const ( PackageManagerNPM PackageManager = "npm" PackageManagerYarn1 PackageManager = "yarn" PackageManagerYarnBerry PackageManager = "yarnberry" PackageManagerPNPM PackageManager = "pnpm" PackageManagerBun PackageManager = "bun" )
type PackageManagerInfo ¶
type PackageManagerInfo struct {
Name PackageManager
Version string
}
PackageManagerInfo contains information about the detected package manager
func DetectPackageManager ¶
func DetectPackageManager(ctx *app.Context, pkg *PackageJSON) PackageManagerInfo
DetectPackageManager detects the package manager used by the project Detection priority: 1. packageManager field in package.json 2. Lock files 3. engines field in package.json 4. Default to npm
func (PackageManagerInfo) GetInstallCommand ¶
func (pm PackageManagerInfo) GetInstallCommand() string
GetInstallCommand returns the install command for the package manager
func (PackageManagerInfo) GetLockFile ¶
func (pm PackageManagerInfo) GetLockFile() string
GetLockFile returns the lock file name for the package manager
func (PackageManagerInfo) GetRunCommand ¶
func (pm PackageManagerInfo) GetRunCommand() string
GetRunCommand returns the run command prefix for the package manager
type Provider ¶
type Provider struct{}
Provider is the Node.js provider implementation
type Workspaces ¶
type Workspaces struct {
Packages []string
}
Workspaces can be either an array of strings or an object with a packages field
func (*Workspaces) UnmarshalJSON ¶
func (w *Workspaces) UnmarshalJSON(data []byte) error
UnmarshalJSON handles both array and object formats for workspaces