Documentation ¶
Overview ¶
Adapted from https://github.com/thought-machine/please Copyright Thought Machine, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- func AbsoluteSystemPathFromUpstream(s string) turbopath.AbsoluteSystemPath
- func CheckedToAbsoluteSystemPath(s string) (turbopath.AbsoluteSystemPath, error)
- func CopyFile(from *LstatCachedFile, to string) error
- func CreateDirFSAtRoot(absolutePath string) iofs.FS
- func DirContainsPath(dir string, target string) (bool, error)
- func EnsureDir(filename string) error
- func FileExists(filename string) bool
- func GetCwd(cwdRaw string) (turbopath.AbsoluteSystemPath, error)
- func GetDirFSRootPath(fsys iofs.FS) string
- func GetTurboDataDir() turbopath.AbsoluteSystemPath
- func GetUserConfigDir() turbopath.AbsoluteSystemPath
- func GetVolumeRoot(absolutePath string) string
- func GitLikeHashFile(filePath turbopath.AbsoluteSystemPath) (string, error)
- func HashFileHashes(hashes FileHashes) (string, error)
- func HashGlobal(global hash.GlobalHashable) (string, error)
- func HashLockfilePackages(packages LockfilePackages) (string, error)
- func HashTask(task *hash.TaskHashable) (string, error)
- func IofsRelativePath(fsysRoot string, absolutePath string) (string, error)
- func IsDirectory(path string) bool
- func MarshalPackageJSON(pkgJSON *PackageJSON) ([]byte, error)
- func PathExists(filename string) bool
- func ResolveUnknownPath(root turbopath.AbsoluteSystemPath, unknown string) turbopath.AbsoluteSystemPath
- func TempDir(subDir string) turbopath.AbsoluteSystemPath
- func UnsafeToAbsoluteSystemPath(s string) turbopath.AbsoluteSystemPath
- func UnsafeToAnchoredSystemPath(s string) turbopath.AnchoredSystemPath
- func Walk(rootPath string, callback func(name string, isDir bool) error) error
- func WalkMode(rootPath string, ...) error
- type BookkeepingTaskDefinition
- type FileHashes
- type LockfilePackages
- type LstatCachedFile
- type PackageJSON
- type Pipeline
- type PristinePipeline
- type RemoteCacheOptions
- type SpaceConfig
- type TaskDefinition
- type TurboJSON
- type TurboJSONValidation
- type Workspaces
- type WorkspacesAlt
Constants ¶
const DirPermissions = os.ModeDir | 0775
DirPermissions are the default permission bits we apply to directories.
Variables ¶
This section is empty.
Functions ¶
func AbsoluteSystemPathFromUpstream ¶
func AbsoluteSystemPathFromUpstream(s string) turbopath.AbsoluteSystemPath
AbsoluteSystemPathFromUpstream is used to mark return values from APIs that we expect to give us absolute paths. No checking is performed. Prefer to use this over a cast to maintain the search-ability of interfaces into and out of the turbopath.AbsoluteSystemPath type.
func CheckedToAbsoluteSystemPath ¶
func CheckedToAbsoluteSystemPath(s string) (turbopath.AbsoluteSystemPath, error)
CheckedToAbsoluteSystemPath inspects a string and determines if it is an absolute path.
func CopyFile ¶
func CopyFile(from *LstatCachedFile, to string) error
CopyFile copies a file from 'from' to 'to', with an attempt to perform a copy & rename to avoid chaos if anything goes wrong partway.
func CreateDirFSAtRoot ¶
CreateDirFSAtRoot creates an `os.dirFS` instance at the root of the volume containing the specified path.
func DirContainsPath ¶
DirContainsPath returns true if the path 'target' is contained within 'dir' Expects both paths to be absolute and does not verify that either path exists.
func FileExists ¶
FileExists returns true if the given path exists and is a file.
func GetCwd ¶
func GetCwd(cwdRaw string) (turbopath.AbsoluteSystemPath, error)
GetCwd returns the calculated working directory after traversing symlinks.
func GetDirFSRootPath ¶
GetDirFSRootPath returns the root path of a os.dirFS.
func GetTurboDataDir ¶
func GetTurboDataDir() turbopath.AbsoluteSystemPath
GetTurboDataDir returns a directory outside of the repo where turbo can store data files related to turbo.
func GetUserConfigDir ¶
func GetUserConfigDir() turbopath.AbsoluteSystemPath
GetUserConfigDir returns the platform-specific common location for configuration files that belong to a user.
func GetVolumeRoot ¶
GetVolumeRoot returns the root directory given an absolute path.
func GitLikeHashFile ¶
func GitLikeHashFile(filePath turbopath.AbsoluteSystemPath) (string, error)
GitLikeHashFile is a function that mimics how Git calculates the SHA1 for a file (or, in Git terms, a "blob") (without git)
func HashFileHashes ¶
func HashFileHashes(hashes FileHashes) (string, error)
HashFileHashes produces a single hash for a set of file hashes
func HashGlobal ¶
func HashGlobal(global hash.GlobalHashable) (string, error)
HashGlobal produces the global hash value to be incorporated in every task hash
func HashLockfilePackages ¶
func HashLockfilePackages(packages LockfilePackages) (string, error)
HashLockfilePackages hashes a list of packages
func HashTask ¶
func HashTask(task *hash.TaskHashable) (string, error)
HashTask produces the hash for a particular task
func IofsRelativePath ¶
IofsRelativePath calculates a `os.dirFS`-friendly path from an absolute system path.
func IsDirectory ¶
IsDirectory checks if a given path is a directory
func MarshalPackageJSON ¶
func MarshalPackageJSON(pkgJSON *PackageJSON) ([]byte, error)
MarshalPackageJSON Serialize PackageJSON to a slice of bytes
func PathExists ¶
PathExists returns true if the given path exists, as a file or a directory.
func ResolveUnknownPath ¶
func ResolveUnknownPath(root turbopath.AbsoluteSystemPath, unknown string) turbopath.AbsoluteSystemPath
ResolveUnknownPath returns unknown if it is an absolute path, otherwise, it assumes unknown is a path relative to the given root.
func TempDir ¶
func TempDir(subDir string) turbopath.AbsoluteSystemPath
TempDir returns the absolute path of a directory with the given name under the system's default temp directory location
func UnsafeToAbsoluteSystemPath ¶
func UnsafeToAbsoluteSystemPath(s string) turbopath.AbsoluteSystemPath
UnsafeToAbsoluteSystemPath directly converts a string to an AbsoluteSystemPath
func UnsafeToAnchoredSystemPath ¶
func UnsafeToAnchoredSystemPath(s string) turbopath.AnchoredSystemPath
UnsafeToAnchoredSystemPath directly converts a string to an AbsoluteSystemPath
func Walk ¶
Walk implements an equivalent to filepath.Walk. It's implemented over github.com/karrick/godirwalk but the provided interface doesn't use that to make it a little easier to handle.
func WalkMode ¶
func WalkMode(rootPath string, callback func(name string, isDir bool, mode os.FileMode) error) error
WalkMode is like Walk but the callback receives an additional type specifying the file mode type. N.B. This only includes the bits of the mode that determine the mode type, not the permissions.
Types ¶
type BookkeepingTaskDefinition ¶
type BookkeepingTaskDefinition struct { TaskDefinition taskDefinitionHashable // contains filtered or unexported fields }
BookkeepingTaskDefinition holds the underlying TaskDefinition and some bookkeeping data about the TaskDefinition. This wrapper struct allows us to leave TaskDefinition untouched.
func (BookkeepingTaskDefinition) GetTaskDefinition ¶
func (btd BookkeepingTaskDefinition) GetTaskDefinition() TaskDefinition
GetTaskDefinition gets a TaskDefinition by merging the experimental and non-experimental fields into a single representation to use downstream.
func (*BookkeepingTaskDefinition) UnmarshalJSON ¶
func (btd *BookkeepingTaskDefinition) UnmarshalJSON(data []byte) error
UnmarshalJSON deserializes a single task definition from turbo.json into a TaskDefinition struct
type FileHashes ¶
type FileHashes map[turbopath.AnchoredUnixPath]string
FileHashes is a hashable map of files to the hash of their contents
type LockfilePackages ¶
LockfilePackages is a hashable list of packages
type LstatCachedFile ¶
type LstatCachedFile struct { Path turbopath.AbsoluteSystemPath // contains filtered or unexported fields }
LstatCachedFile maintains a cache of file info, mode and type for the given Path
func (*LstatCachedFile) GetInfo ¶
func (file *LstatCachedFile) GetInfo() (fs.FileInfo, error)
GetInfo returns, and caches the file info for the LstatCachedFile.Path
type PackageJSON ¶
type PackageJSON struct { Name string `json:"name"` Version string `json:"version"` Scripts map[string]string `json:"scripts"` Dependencies map[string]string `json:"dependencies"` DevDependencies map[string]string `json:"devDependencies"` OptionalDependencies map[string]string `json:"optionalDependencies"` PeerDependencies map[string]string `json:"peerDependencies"` PackageManager string `json:"packageManager"` Os []string `json:"os"` Workspaces Workspaces `json:"workspaces"` Private bool `json:"private"` // Exact JSON object stored in package.json including unknown fields // During marshalling struct fields will take priority over raw fields RawJSON map[string]interface{} `json:"-"` // relative path from repo root to the package.json file PackageJSONPath turbopath.AnchoredSystemPath `json:"-"` // relative path from repo root to the package Dir turbopath.AnchoredSystemPath `json:"-"` InternalDeps []string `json:"-"` UnresolvedExternalDeps map[string]string `json:"-"` TransitiveDeps []lockfile.Package `json:"-"` LegacyTurboConfig *TurboJSON `json:"turbo"` Mu sync.Mutex `json:"-"` ExternalDepsHash string `json:"-"` }
PackageJSON represents NodeJS package.json
func ReadPackageJSON ¶
func ReadPackageJSON(path turbopath.AbsoluteSystemPath) (*PackageJSON, error)
ReadPackageJSON returns a struct of package.json
func UnmarshalPackageJSON ¶
func UnmarshalPackageJSON(data []byte) (*PackageJSON, error)
UnmarshalPackageJSON decodes a byte slice into a PackageJSON struct
func (*PackageJSON) SetExternalDeps ¶
func (p *PackageJSON) SetExternalDeps(externalDeps mapset.Set) error
SetExternalDeps sets TransitiveDeps and populates ExternalDepsHash
type Pipeline ¶
type Pipeline map[string]BookkeepingTaskDefinition
Pipeline is a struct for deserializing .pipeline in configFile
func (Pipeline) GetTask ¶
func (pc Pipeline) GetTask(taskID string, taskName string) (*BookkeepingTaskDefinition, error)
GetTask returns a TaskDefinition based on the ID (package#task format) or name (e.g. "build")
func (Pipeline) GetTaskDefinition ¶
func (pc Pipeline) GetTaskDefinition(taskID string) (TaskDefinition, bool)
GetTaskDefinition returns a TaskDefinition from a serialized definition in configFile
func (Pipeline) HasTask ¶
HasTask returns true if the given task is defined in the pipeline, either directly or via a package task (`pkg#task`)
func (Pipeline) Pristine ¶
func (pc Pipeline) Pristine() PristinePipeline
Pristine returns a PristinePipeline, this is used for printing to console and pruning
type PristinePipeline ¶
type PristinePipeline map[string]interface{}
PristinePipeline is a map of task names to TaskDefinition or taskDefinitionHashable. Depending on whether any experimental fields are defined, we will use either struct. The purpose is to omit experimental fields when making a pristine version, so that it doesn't show up in --dry/--summarize output or affect the global hash.
type RemoteCacheOptions ¶
type RemoteCacheOptions struct { TeamID string `json:"teamId,omitempty"` Signature bool `json:"signature,omitempty"` Enabled bool `json:"enabled,omitempty"` }
RemoteCacheOptions is a struct for deserializing .remoteCache of configFile
func (*RemoteCacheOptions) UnmarshalJSON ¶
func (rc *RemoteCacheOptions) UnmarshalJSON(data []byte) error
UnmarshalJSON deserializes the remoteCache key from turbo.json into an in-memory struct
type SpaceConfig ¶
type SpaceConfig struct {
ID string `json:"id"`
}
SpaceConfig is used to marshal and unmarshal the `experimentalSpaceId` field in a turbo.json
type TaskDefinition ¶
type TaskDefinition struct { Outputs hash.TaskOutputs Cache bool // TopologicalDependencies are tasks from package dependencies. // E.g. "build" is a topological dependency in: // dependsOn: ['^build']. // This field is custom-marshalled from rawTask.DependsOn TopologicalDependencies []string // TaskDependencies are anything that is not a topological dependency // E.g. both something and //whatever are TaskDependencies in: // dependsOn: ['something', '//whatever'] // This field is custom-marshalled from rawTask.DependsOn TaskDependencies []string // Inputs indicate the list of files this Task depends on. If any of those files change // we can conclude that any cached outputs or logs for this Task should be invalidated. Inputs []string // OutputMode determins how we should log the output. OutputMode util.TaskOutputMode // Persistent indicates whether the Task is expected to exit or not // Tasks marked Persistent do not exit (e.g. --watch mode or dev servers) Persistent bool // This field is custom-marshalled from rawTask.Env and rawTask.DependsOn Env []string // rawTask.PassThroughEnv PassThroughEnv []string // rawTask.DotEnv DotEnv turbopath.AnchoredUnixPathArray }
TaskDefinition is a representation of the configFile pipeline for further computation.
func MergeTaskDefinitions ¶
func MergeTaskDefinitions(taskDefinitions []BookkeepingTaskDefinition) (*TaskDefinition, error)
MergeTaskDefinitions accepts an array of BookkeepingTaskDefinitions and merges them into a single TaskDefinition. It uses the bookkeeping definedFields to determine which fields should be overwritten and when 0-values should be respected.
func (TaskDefinition) MarshalJSON ¶
func (c TaskDefinition) MarshalJSON() ([]byte, error)
MarshalJSON serializes TaskDefinition struct into json
type TurboJSON ¶
type TurboJSON struct { GlobalDeps []string GlobalEnv []string GlobalPassThroughEnv []string GlobalDotEnv turbopath.AnchoredUnixPathArray Pipeline Pipeline RemoteCacheOptions RemoteCacheOptions Extends []string // A list of Workspace names SpaceID string }
TurboJSON represents a turbo.json configuration file
func LoadTurboConfig ¶
func LoadTurboConfig(dir turbopath.AbsoluteSystemPath, rootPackageJSON *PackageJSON, includeSynthesizedFromRootPackageJSON bool) (*TurboJSON, error)
LoadTurboConfig loads, or optionally, synthesizes a TurboJSON instance
func (*TurboJSON) MarshalJSON ¶
MarshalJSON converts a TurboJSON into the equivalent json object in bytes note: we go via rawTurboJSON so that the output format is correct. This is used by `turbo prune` to generate a pruned turbo.json and also by --summarize & --dry=json to serialize the known config into something we can print to screen
func (*TurboJSON) UnmarshalJSON ¶
UnmarshalJSON deserializes the contents of turbo.json into a TurboJSON struct
func (*TurboJSON) Validate ¶
func (tj *TurboJSON) Validate(validations []TurboJSONValidation) []error
Validate calls an array of validation functions on the TurboJSON struct. The validations can be customized by the caller.
type TurboJSONValidation ¶
TurboJSONValidation is the signature for a validation function passed to Validate()
type Workspaces ¶
type Workspaces []string
func (*Workspaces) UnmarshalJSON ¶
func (r *Workspaces) UnmarshalJSON(data []byte) error
type WorkspacesAlt ¶
type WorkspacesAlt struct {
Packages []string `json:"packages,omitempty"`
}