tsworkspace

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NodeTypeRoots

func NodeTypeRoots(dirs ...string) []string

NodeTypeRoots returns existing @types roots visible from the provided dirs.

func NodeTypesPresent

func NodeTypesPresent(dirs ...string) bool

NodeTypesPresent reports whether @types/node is visible from any provided directory.

Types

type Owner

type Owner struct {
	// contains filtered or unexported fields
}

Owner owns TypeScript test workspace files, tool discovery, and execution.

func NewOwner

func NewOwner(workDir, toolDir string) *Owner

NewOwner creates a TypeScript workspace owner.

func (*Owner) EnsureNodeAmbientTypes

func (o *Owner) EnsureNodeAmbientTypes() Result

EnsureNodeAmbientTypes writes host runtime declarations needed by emitted tests.

func (*Owner) EnsurePackageJSON

func (o *Owner) EnsurePackageJSON() Result

EnsurePackageJSON writes the module package metadata used by Bun.

func (*Owner) FindTool

func (o *Owner) FindTool(name string) (string, error)

FindTool locates a TypeScript workspace tool.

func (*Owner) RunTool

func (o *Owner) RunTool(ctx context.Context, phase Phase, dir string, name string, args ...string) Result

RunTool finds and executes a TypeScript workspace tool.

func (*Owner) WorkDir

func (o *Owner) WorkDir() string

WorkDir returns the workspace directory.

func (*Owner) WriteFile

func (o *Owner) WriteFile(phase Phase, name string, data string) Result

WriteFile writes a workspace-relative file.

func (*Owner) WriteJSON

func (o *Owner) WriteJSON(phase Phase, name string, value any) Result

WriteJSON writes an indented JSON workspace file.

type Phase

type Phase string

Phase names a TypeScript workspace execution phase.

const (
	// PhaseWorkspace covers workspace file preparation and tool discovery.
	PhaseWorkspace Phase = "workspace"
	// PhaseTypeCheck covers TypeScript type checking.
	PhaseTypeCheck Phase = "typecheck"
	// PhaseRuntime covers TypeScript runtime execution.
	PhaseRuntime Phase = "runtime"

	// NodeAmbientTypesFile names the GoScript runtime ambient declarations.
	NodeAmbientTypesFile = "goscript-node.d.ts"
)

type Result

type Result struct {
	Phase   Phase
	Command []string
	Output  string
	Error   string
	Elapsed time.Duration
}

Result describes one workspace file or process operation.

func (Result) Failed

func (r Result) Failed() bool

Failed returns true when the operation failed.

Jump to

Keyboard shortcuts

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