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) titanpath.AbsoluteSystemPath
- func CheckedToAbsoluteSystemPath(s string) (titanpath.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() (titanpath.AbsoluteSystemPath, error)
- func GetDirFSRootPath(fsys iofs.FS) string
- func GetTurboDataDir() titanpath.AbsoluteSystemPath
- func GetUserConfigDir() titanpath.AbsoluteSystemPath
- func GetVolumeRoot(absolutePath string) string
- func GitLikeHashFile(filePath string) (string, error)
- func HashFile(filePath string) (string, error)
- func HashObject(i interface{}) (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 RecursiveCopy(from string, to string) error
- func ResolveUnknownPath(root titanpath.AbsoluteSystemPath, unknown string) titanpath.AbsoluteSystemPath
- func TempDir(subDir string) titanpath.AbsoluteSystemPath
- func UnsafeToAbsoluteSystemPath(s string) titanpath.AbsoluteSystemPath
- func UnsafeToAnchoredSystemPath(s string) titanpath.AnchoredSystemPath
- func Walk(rootPath string, callback func(name string, isDir bool) error) error
- func WalkMode(rootPath string, ...) error
- type LstatCachedFile
- type PackageJSON
- type Pipeline
- type RemoteCacheOptions
- type TaskDefinition
- type TaskOutputs
- type TurboJSON
- 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) titanpath.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 titanpath.AbsoluteSystemPath type.
func CheckedToAbsoluteSystemPath ¶
func CheckedToAbsoluteSystemPath(s string) (titanpath.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() (titanpath.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() titanpath.AbsoluteSystemPath
GetTurboDataDir returns a directory outside of the repo where titan can store data files related to titan.
func GetUserConfigDir ¶
func GetUserConfigDir() titanpath.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 ¶
GitLikeHashFile is a function that mimics how Git calculates the SHA1 for a file (or, in Git terms, a "blob") (without git)
func HashObject ¶
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 RecursiveCopy ¶
RecursiveCopy copies either a single file or a directory. 'mode' is the mode of the destination file.
func ResolveUnknownPath ¶
func ResolveUnknownPath(root titanpath.AbsoluteSystemPath, unknown string) titanpath.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) titanpath.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) titanpath.AbsoluteSystemPath
UnsafeToAbsoluteSystemPath directly converts a string to an AbsoluteSystemPath
func UnsafeToAnchoredSystemPath ¶
func UnsafeToAnchoredSystemPath(s string) titanpath.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 LstatCachedFile ¶
type LstatCachedFile struct { Path titanpath.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 titanpath.AnchoredSystemPath `json:"-"` // relative path from repo root to the package Dir titanpath.AnchoredSystemPath `json:"-"` InternalDeps []string `json:"-"` UnresolvedExternalDeps map[string]string `json:"-"` ExternalDeps []string `json:"-"` TransitiveDeps []string `json:"-"` LegacyTurboConfig *TurboJSON `json:"titan"` Mu sync.Mutex `json:"-"` ExternalDepsHash string `json:"-"` }
PackageJSON represents NodeJS package.json
func ReadPackageJSON ¶
func ReadPackageJSON(path titanpath.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
type Pipeline ¶
type Pipeline map[string]TaskDefinition
Pipeline is a struct for deserializing .pipeline in configFile
func (Pipeline) GetTaskDefinition ¶
func (pc Pipeline) GetTaskDefinition(taskID string) (TaskDefinition, bool)
GetTaskDefinition returns a TaskDefinition from a serialized definition in configFile
type RemoteCacheOptions ¶
type RemoteCacheOptions struct { TeamID string `json:"teamId,omitempty"` Signature bool `json:"signature,omitempty"` }
RemoteCacheOptions is a struct for deserializing .remoteCache of configFile
type TaskDefinition ¶
type TaskDefinition struct { Outputs TaskOutputs ShouldCache bool EnvVarDependencies []string TopologicalDependencies []string TaskDependencies []string Inputs []string OutputMode util.TaskOutputMode }
TaskDefinition is a representation of the configFile pipeline for further computation.
func (*TaskDefinition) UnmarshalJSON ¶
func (c *TaskDefinition) UnmarshalJSON(data []byte) error
UnmarshalJSON deserializes JSON into a TaskDefinition
type TaskOutputs ¶
TaskOutputs represents the patterns for including and excluding files from outputs
type TurboJSON ¶
type TurboJSON struct { GlobalDeps []string GlobalEnv []string Pipeline Pipeline RemoteCacheOptions RemoteCacheOptions }
TurboJSON is the root titanrepo configuration
func LoadTurboConfig ¶
func LoadTurboConfig(rootPath titanpath.AbsoluteSystemPath, rootPackageJSON *PackageJSON, includeSynthesizedFromRootPackageJSON bool) (*TurboJSON, error)
LoadTurboConfig loads, or optionally, synthesizes a TurboJSON instance
func ReadTurboConfig ¶
func ReadTurboConfig(rootPath titanpath.AbsoluteSystemPath, rootPackageJSON *PackageJSON) (*TurboJSON, error)
ReadTurboConfig toggles between reading from package.json or the configFile to support early adopters.
func (*TurboJSON) UnmarshalJSON ¶
UnmarshalJSON deserializes TurboJSON objects into struct
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"`
}