api #

security-first JS runtime and toolchain on V8

88 modules ยท 460 declarations

Modules
#

afterNavigate
#

sveltekit_shim_app_navigation.ts view source

(callback: (navigation: (NavigationGoto & { type: "link" | "goto" | "enter" | "form" | "popstate"; willUnload: false; }) | (NavigationFormSubmit & { type: "link" | ... 3 more ... | "popstate"; willUnload: false; }) | (NavigationPopState & { ...; }) | (NavigationLink & { ...; }) | (NavigationEnter & { ...; })) => voi... import {afterNavigate} from '@fuzdev/gro/sveltekit_shim_app_navigation.js';

analyze_gen_result
#

gen.ts view source

(fs_paths: FsPaths, file: GenFile): Promise<AnalyzedGenResult> import {analyze_gen_result} from '@fuzdev/gro/gen.js';

Reads a gen output to say whether it's new or changed.

fs_paths

opens the output, which must resolve beneath its project

type FsPaths

file

type GenFile

returns

Promise<AnalyzedGenResult>

throws

  • `TaskError` - for an output outside the project or at the project directory itself

analyze_gen_results
#

gen.ts view source

(fs_paths: FsPaths, gen_results: GenResults): Promise<AnalyzedGenResult[]> import {analyze_gen_results} from '@fuzdev/gro/gen.js';

Reads each output of the successful genfiles to say whether it's new or changed.

fs_paths

opens the outputs, which must resolve beneath its project

type FsPaths

gen_results

returns

Promise<AnalyzedGenResult[]>

AnalyzedGenResult
#

gen.ts view source

AnalyzedGenResult

type { file: GenFile; existing_content: string; is_new: false; has_changed: boolean; } | { file: GenFile; existing_content: null; is_new: true; has_changed: true; }

import type {AnalyzedGenResult} from '@fuzdev/gro/gen.js';

applyAction
#

sveltekit_shim_app_forms.ts view source

<Success extends Record<string, unknown> | undefined, Failure extends Record<string, unknown> | undefined>(result: ActionResult<Success, Failure>) => Promise<void> import {applyAction} from '@fuzdev/gro/sveltekit_shim_app_forms.js';

asset
#

sveltekit_shim_app_paths.ts view source

(file: ".nojekyll" | "CNAME" | "favicon.png" | "logo.svg" | "robots.txt"): string import {asset} from '@fuzdev/gro/sveltekit_shim_app_paths.js';

file

type AssetPath

returns

string

beforeNavigate
#

browser
#

BUILD_CACHE_METADATA_FILENAME
#

BUILD_CACHE_METADATA_PATH
#

build_cache.ts view source

string import {BUILD_CACHE_METADATA_PATH} from '@fuzdev/gro/build_cache.js';

The build cache metadata's path, relative to the project.

BUILD_CACHE_VERSION
#

BuildCacheDependencies
#

build_cache_dependencies.ts view source

BuildCacheDependencies import type {BuildCacheDependencies} from '@fuzdev/gro/build_cache_dependencies.js';

The build inputs outside git that the build cache key folds in: the tools that run the build and the installed packages.

gro_version

Version of the running Gro, from its package.json. A Gro rebuilt without a version change keeps the same value.

type string

runtime_version

The running runtime's name and version, like process.runtime_version.

type string

package_lock_hash

BLAKE3 hash of node_modules/.package-lock.json, which npm rewrites when it changes what's installed. null when the file is missing, as with other package managers, an npm workspace member, or no install, and then installed-package drift doesn't invalidate the cache. Edits made directly inside node_modules don't change the file either.

type string | null

BuildCacheDeps
#

BuildCacheKey
#

build_cache.ts view source

BuildCacheKey import type {BuildCacheKey} from '@fuzdev/gro/build_cache.js';

The components of the build cache key. A cached build is reused only when all match.

inheritance

git_commit

type string | null

build_cache_config_hash

type string

BuildCacheKeyDeps
#

build_cache.ts view source

BuildCacheKeyDeps import type {BuildCacheKeyDeps} from '@fuzdev/gro/build_cache.js';

What the build cache key reads when its commit wasn't given: git and a log.

git

type SpawnProgram

log

type Logger

BuildCacheKeyOptions
#

build_cache.ts view source

BuildCacheKeyOptions import type {BuildCacheKeyOptions} from '@fuzdev/gro/build_cache.js';

The inputs to the build cache key beside the config.

dependencies

The Gro and Node versions and the installed-package hash, loaded once by the caller (load_build_cache_dependencies) so one build checks and saves the same values.

type BuildCacheDependencies

git_commit?

A pre-computed git commit hash, so a caller that has one needn't read it again; read from git when omitted.

type string | null

BuildCacheMetadata
#

build_cache.ts view source

value + type

{ version: string; git_commit: string | null; build_cache_config_hash: string; gro_version: string; runtime_version: string; package_lock_hash: string | null; timestamp: string; outputs: { ...; }[]; } import {BuildCacheMetadata} from '@fuzdev/gro/build_cache.js';

Metadata stored in .gro/ directory to track build cache validity. Schema validates structure at load time to catch corrupted cache files.

version

type string

git_commit

type string | null

build_cache_config_hash

type string

gro_version

type string

runtime_version

type string

package_lock_hash

type string | null

timestamp

type string

outputs

type BuildOutputEntry[]

BuildCacheMetadataOptions
#

build_cache.ts view source

BuildCacheMetadataOptions import type {BuildCacheMetadataOptions} from '@fuzdev/gro/build_cache.js';

inheritance

build_dirs?

Pre-discovered build directories, so a caller that has them avoids another scan; discovered when omitted.

type string[]

BuildCacheSaveDeps
#

build_cache.ts view source

BuildCacheSaveDeps import type {BuildCacheSaveDeps} from '@fuzdev/gro/build_cache.js';

What saving the build cache's metadata reaches: the project's paths and a log.

fs_paths

type FsPaths

log

type Logger

building
#

BuildOutputEntry
#

build_cache.ts view source

value + type

{ path: string; hash: string; size: number; mtime: number; mode: number; } import {BuildOutputEntry} from '@fuzdev/gro/build_cache.js';

Metadata about a single build output file. Includes cryptographic hash for validation plus filesystem stats for debugging and optimization.

path

type string

hash

type string

size

type number

mtime

type number

mode

type number

BuiltinTaskEntry
#

task_registry.ts view source

BuiltinTaskEntry import type {BuiltinTaskEntry} from '@fuzdev/gro/task_registry.js';

A builtin task with the summary gro lists it by.

inheritance

summary

type string

CHANGESET_CLI
#

CHANGESET_DIR
#

changeset_has_pending
#

changeset_helpers.ts view source

(project: FsDir): Promise<boolean> import {changeset_has_pending} from '@fuzdev/gro/changeset_helpers.js';

Whether project has a changeset to release, read the way Changesets does: a markdown file in .changeset other than its README.md.

project

the project root

type FsDir

returns

Promise<boolean>

CHANGESET_PUBLIC_ACCESS
#

CHANGESET_RESTRICTED_ACCESS
#

ChangesetAccess
#

changeset_helpers.ts view source

value + type

"restricted" | "public"

type "restricted" | "public"

import {ChangesetAccess} from '@fuzdev/gro/changeset_helpers.js';

ChangesetBump
#

changeset_helpers.ts view source

value + type

"patch" | "minor" | "major"

type "patch" | "minor" | "major"

import {ChangesetBump} from '@fuzdev/gro/changeset_helpers.js';

ChildOutputTargets
#

clean_fs
#

clean_fs.ts view source

({ fs_paths, log }: CleanFsDeps, { gro_dir, dist_dirs, sveltekit, nodemodules }: CleanFsOptions): Promise<void> import {clean_fs} from '@fuzdev/gro/clean_fs.js';

Deletes the selected temporary and build directories, each independently. A symlink at one of their paths is removed itself, never followed, except a .gro/ linked to a directory outside the project that holds Gro's marker (internal/gro_dir.ts) and isn't inside a git work tree, like one on a tmpfs, which keeps its link and has the directory it points at emptied.

__0

__1

returns

Promise<void>

CleanFsDeps
#

clean_fs.ts view source

CleanFsDeps import type {CleanFsDeps} from '@fuzdev/gro/clean_fs.js';

What clean_fs reaches: the project's paths, and a log for a linked .gro/.

fs_paths

Opens and removes each cleaned path, relative to the project.

type FsPaths

log?

Warned when a linked .gro/ is unlinked rather than emptied, saying why.

type Logger

CleanFsOptions
#

clean_fs.ts view source

CleanFsOptions import type {CleanFsOptions} from '@fuzdev/gro/clean_fs.js';

gro_dir?

Delete the .gro/ directory.

type boolean

dist_dirs?

Delete the dist_* plugin output directories at the project root.

type boolean

sveltekit?

Delete the SvelteKit directory, its build and dist outputs, and the Vite cache.

type boolean

nodemodules?

Delete node_modules/.

type boolean

CliTaskArgs
#

args.ts view source

CliTaskArgs import type {CliTaskArgs} from '@fuzdev/gro/args.js';

The task the CLI names and its args, parsed from the CLI args.

task_name

The first positional arg: a builtin name, TASK_VERB, or '' for none.

type string

task_path

The path after TASK_VERB, null when absent or for any other task_name.

type string | null

args

type Args

collect_build_outputs
#

build_cache.ts view source

(fs_paths: FsPaths, build_dirs: string[]): Promise<{ path: string; hash: string; size: number; mtime: number; mode: number; }[]> import {collect_build_outputs} from '@fuzdev/gro/build_cache.js';

Collects information about all files in build output directories. Returns an array of entries with path, hash, size, mtime, and mode. Each directory is opened once, its symlinks followed, and walked beneath its handle, where only regular files are collected, never a symlink.

Files are hashed in parallel for performance. For very large builds (10k+ files), this may take several seconds but ensures complete cache validation.

fs_paths

opens each directory, relative to the project

type FsPaths

build_dirs

array of output directories to scan (e.g., ['build', 'dist'] and any dist_*)

type string[]

returns

Promise<BuildOutputEntry[]>

compute_build_cache_key
#

build_cache.ts view source

({ git, log }: BuildCacheKeyDeps, config: GroConfig, { dependencies: deps, git_commit }: BuildCacheKeyOptions): Promise<BuildCacheKey> import {compute_build_cache_key} from '@fuzdev/gro/build_cache.js';

Computes the cache key components for a build. This determines whether a cached build can be reused.

__0

config

Gro config (build_cache_config_hash is already computed during config load)

__2

returns

Promise<BuildCacheKey>

configure_colored_output_with_path_replacement
#

child_process_logging.ts view source

(child: SpawnChild, replacement: string, cwd: string, targets: ChildOutputTargets): Promise<void> import {configure_colored_output_with_path_replacement} from '@fuzdev/gro/child_process_logging.js';

Configures process output handling with path replacements while preserving ANSI colors.

child

replacement

what cwd becomes in the output

type string

cwd

the absolute path to replace

type string

targets

where the output goes

returns

Promise<void>

a promise that resolves once the child's output has ended and been written

cook_gro_config
#

gro_config.ts view source

(raw_config: RawGroConfig): Promise<GroConfig> import {cook_gro_config} from '@fuzdev/gro/gro_config.js';

Transforms a RawGroConfig to the more strict GroConfig. This allows users to provide a more relaxed config. Hashes the build_cache_config and drops the raw value from the config.

raw_config

returns

Promise<GroConfig>

create_build_cache_metadata
#

build_cache.ts view source

({ fs_paths, log, git }: BuildCacheDeps, config: GroConfig, { build_dirs, ...key_options }: BuildCacheMetadataOptions): Promise<{ version: string; git_commit: string | null; ... 5 more ...; outputs: { ...; }[]; }> import {create_build_cache_metadata} from '@fuzdev/gro/build_cache.js';

Creates build cache metadata after a successful build. Automatically discovers all build output directories (build/, dist/, dist_*).

__0

config

Gro config

__2

returns

Promise<BuildCacheMetadata>

create_empty_gro_config
#

gro_config.ts view source

(): GroConfig import {create_empty_gro_config} from '@fuzdev/gro/gro_config.js';

returns

GroConfig

create_fs_paths
#

fs_paths.ts view source

(fs: Fs): FsPaths import {create_fs_paths} from '@fuzdev/gro/fs_paths.js';

Builds the boundary over the fs root, resolving relative paths against fs.project.

fs

the fs host module's root, fs from fs.ts or a mock of it

type Fs

returns

FsPaths

create_gen_context
#

gen.ts view source

(base: GenContextBase, origin_id: PathId): GenContext import {create_gen_context} from '@fuzdev/gro/gen.js';

Builds a GenContext for one genfile, with a lazy svelte_config that's a getter rather than a value so a genfile that ignores it never resolves it.

base

origin_id

type PathId

returns

GenContext

create_node_module_graph
#

module_graph_node.ts view source

(options: NodeModuleGraphOptions): ModuleGraph import {create_node_module_graph} from '@fuzdev/gro/module_graph_node.js';

Creates the Node ModuleGraph, which watches watch.dir with chokidar and reads each module's imports, following them outside watch.dir, except that a file reached by a bare specifier, like a package's even when linked, is an edge to a file never read, so its imports aren't edges. Its implementation (with chokidar and the import parser) is imported on first use, so a task that never queries the graph never loads them.

options

returns

ModuleGraph

create_paths
#

paths.ts view source

(root_dir: string): Paths import {create_paths} from '@fuzdev/gro/paths.js';

root_dir

type string

returns

Paths

CreateGroConfig
#

CSS_MATCHER
#

deserialize
#

sveltekit_shim_app_forms.ts view source

<Success extends Record<string, unknown> | undefined, Failure extends Record<string, unknown> | undefined>(result: string): ActionResult<Success, Failure> import {deserialize} from '@fuzdev/gro/sveltekit_shim_app_forms.js';

result

type string

returns

ActionResult

dev
#

DirEntry
#

fs.ts view source

DirEntry import type {DirEntry} from '@fuzdev/gro/fs.js';

One entry of a directory listing, its kind read without following a symlink.

name

type string

kind

type FileKind

disableScrollHandling
#

discover_build_output_dirs
#

build_cache.ts view source

(fs_paths: FsPaths): Promise<string[]> import {discover_build_output_dirs} from '@fuzdev/gro/build_cache.js';

Discovers all build output directories in the project. Returns an array of directory names that exist: build/, dist/, dist_*

fs_paths

type FsPaths

returns

Promise<string[]>

discover_dist_dirs
#

build_cache.ts view source

(fs_paths: FsPaths): Promise<string[]> import {discover_dist_dirs} from '@fuzdev/gro/build_cache.js';

Discovers the dist_* plugin output directories in the project.

fs_paths

type FsPaths

returns

Promise<string[]>

EMPTY_BUILD_CACHE_CONFIG_HASH
#

gro_config.ts view source

"af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262" import {EMPTY_BUILD_CACHE_CONFIG_HASH} from '@fuzdev/gro/gro_config.js';

BLAKE3 hash of empty string, used for configs without build_cache_config. This ensures consistent cache behavior when no custom config is provided.

enhance
#

sveltekit_shim_app_forms.ts view source

<Success extends Record<string, unknown> | undefined, Failure extends Record<string, unknown> | undefined>(form_element: HTMLFormElement, submit?: SubmitFunction<Success, Failure> | undefined): { ...; } import {enhance} from '@fuzdev/gro/sveltekit_shim_app_forms.js';

form_element

type HTMLFormElement

submit?

type SubmitFunction<Success, Failure>
optional

returns

{ destroy(): void; }

Env
#

process.ts view source

Env import type {Env} from '@fuzdev/gro/process.js';

The environment, read-only, a snapshot taken when the module loads.

get

A variable's value, undefined when it's unset. Own names only, so toString is unset.

type (name: string): string | undefined

name

type string
returns string | undefined

throws

  • `TypeError` - for a name that isn't a non-empty, well-formed string without NUL or `=`
  • `ProcessError` - `not_granted`, a name outside this handle's set

get_all

Every variable this handle allows that's set, a frozen null-prototype record. Pass it, or part of it, where a library takes a plain record.

type (): Readonly<Record<string, string>>

returns Readonly<Record<string, string>>

narrow

A handle limited to names, each an exact, case-sensitive name, never a glob, so a holder of the handle can't enumerate more than it's given. A name that's unset stays in the set, as undefined from get. It can only shrink.

type (names: readonly string[]): Env

names

type readonly string[]
returns Env

throws

  • `TypeError` - for a name `get` refuses, or one holding `*`
  • `ProcessError` - `not_granted`, a name outside this handle's set

env_var_has_visibility
#

env_declarations.ts view source

(config: EnvVarConfig<any>, visibility: EnvVisibility): boolean import {env_var_has_visibility} from '@fuzdev/gro/env_declarations.js';

Whether a declared env var belongs to visibility - SvelteKit's vars are private unless declared public: true.

config

type EnvVarConfig<any>

visibility

returns

boolean

EnvVarDeclarations
#

EnvVisibility
#

FileChange
#

FileChangeCallback
#

FileChangeType
#

FileInfo
#

fs.ts view source

FileInfo import type {FileInfo} from '@fuzdev/gro/fs.js';

What stat reports about an entry.

kind

type FileKind

size

Size in bytes.

type number

mtime_ms

Last modification time in milliseconds since the epoch.

type number

mode

The permission bits, like 0o644, without the file type bits.

type number

FileKind
#

fs.ts view source

FileKind

type "file" | "directory" | "symlink" | "other"

import type {FileKind} from '@fuzdev/gro/fs.js';

The kind of a filesystem entry. stat with follow (the default) never returns 'symlink'; stat without it and list do.

find_cli
#

cli.ts view source

(spawn: Spawn, name: string, options?: SpawnProgramOptions | undefined): SpawnProgram | null import {find_cli} from '@fuzdev/gro/cli.js';

Finds the CLI name, first in the project's node_modules/.bin and then on PATH. Only the first lookup reads a node_modules/.bin, as a name containing /: the PATH walk skips the node_modules/.bin entries npm run adds, so a dependency's .bin/git can't shadow a bare spawn.program('git'), and a tool installed only in an ancestor's node_modules isn't found.

spawn

resolves the program

type Spawn

name

the CLI's name

type string

options?

the program's environment, fixed when its handle is made

optional

returns

SpawnProgram | null

the program, or null if not found locally or on PATH

throws

  • `TaskError` - if the file isn't one the kernel will run or the name isn't allowed, like an absolute one, with the `SpawnError`'s message and the error as its `cause`

find_genfiles
#

gen.ts view source

(fs_paths: FsPaths, input_paths: InputPath[], root_dirs: PathId[], config: GroConfig, timings?: Timings | undefined, root?: PathId): Promise<...> import {find_genfiles} from '@fuzdev/gro/gen.js';

Finds modules from input paths. (see input_path.ts for more)

fs_paths

stats the input paths and searches the directories among them

type FsPaths

input_paths

type InputPath[]

root_dirs

type PathId[]

config

timings?

type Timings
optional

root?

the project root config.search_filters test paths relative to, defaults to the project of fs_paths

type PathId
optional default fs_paths.project.path

returns

Promise<FindGenfilesResult>

find_local_cli
#

cli.ts view source

(spawn: Spawn, name: string, options?: SpawnProgramOptions | undefined): SpawnProgram | null import {find_local_cli} from '@fuzdev/gro/cli.js';

Finds the project's own install of the CLI name in node_modules/.bin.

spawn

resolves the program

type Spawn

name

the CLI's name

type string

options?

the program's environment, fixed when its handle is made

optional

returns

SpawnProgram | null

the program, or null if the project doesn't have it

throws

  • `TaskError` - if the file isn't one the kernel will run or the name isn't allowed, with the `SpawnError`'s message and the error as its `cause`

find_test_files
#

vitest_helpers.ts view source

(fs_paths: FsPaths, dir: string): Promise<FsSearchResult[]> import {find_test_files} from '@fuzdev/gro/vitest_helpers.js';

Finds the files gro test would run in dir with its default pattern, by Vitest's own rules rather than Gro's search_filters, which Vitest never sees: a test beneath a build/ or .-prefixed directory runs, so it's found here too.

Symlinks are followed as Vitest follows them, through fs_paths, so a link out of the project reaches what it points at, and a dangling one is skipped. A path is matched as it's named through the links, and the pattern can match a directory's name, so each real directory is searched at most once with and once without a matching name above it. That finds every file Vitest would and ends on a loop, which Vitest follows one level in.

fs_paths

opens dir and each symlink beneath it

type FsPaths

dir

the test directory, absolute

type string

returns

Promise<FsSearchResult[]>

the test files sorted by path, named through the links, with kind the listed one; an empty array when nothing is at dir

throws

  • `FsError` - when `dir` isn't a directory, or a listing or a symlink's resolution fails

FindGenfilesFailure
#

gen.ts view source

FindGenfilesFailure

type { type: "unmapped_input_paths"; unmapped_input_paths: InputPath[]; resolved_input_paths: ResolvedInputPath[]; reasons: string[]; } | { type: "input_directories_with_no_files"; input_directories_with_no_files: InputPath[]; resolved_input_files: ResolvedInputFile[]; resolved_input_paths: ResolvedInputPath[]; reasons: string[]; }

import type {FindGenfilesFailure} from '@fuzdev/gro/gen.js';

FindGenfilesResult
#

gen.ts view source

FindGenfilesResult

type ({ ok: true; } & { value: FoundGenfiles; }) | (({ ok: false; } & { type: "unmapped_input_paths"; unmapped_input_paths: InputPath[]; resolved_input_paths: ResolvedInputPath[]; reasons: string[]; }) | ({ ok: false; } & { type: "input_directories_with_no_files"; input_directories_with_no_files: InputPath[]; resolved_input_files: ResolvedInputFile[]; resolved_input_paths: ResolvedInputPath[]; reasons: string[]; }))

import type {FindGenfilesResult} from '@fuzdev/gro/gen.js';

format_directory
#

format_directory.ts view source

(fs_paths: FsPaths, { log, dir, check, filter, patterns, root }: FormatDirectoryOptions): Promise<FormatDirectoryResult> import {format_directory} from '@fuzdev/gro/format_directory.js';

Formats files on the filesystem in-process via format_file. When patterns is provided, formats those specific files/globs. Otherwise formats dir (recursively, respecting filter) plus the root files when dir is the root's src/. A sweep acts on regular files only, skipping a symlink, as tsv's own walk does, root files included. In both modes, files matched by the project root's .formatignore, or with none, its .prettierignore, are skipped.

Files the formatter rejects (e.g. a syntax error), or that can't be read, are reported and fail the run in both modes rather than being silently skipped. A default root file the project lacks, or that's a symlink, is skipped.

This is separated from ./format_file so modules that only need directory traversal don't pull in the formatter (which loads the tsv native addon).

fs_paths

opens the swept directories, the patterns' files, and the ignore files, each directory once, its files read and written beneath its handle

type FsPaths

__1

returns

Promise<FormatDirectoryResult>

format_file
#

format_file.ts view source

(content: string, options?: FormatFileOptions): string import {format_file} from '@fuzdev/gro/format_file.js';

Formats a string of source code in-process. Passes the input through unchanged when the language is unsupported (an expected no-op), but throws when the formatter rejects the source โ€” e.g. a syntax error โ€” so callers can decide whether to log, skip, or fail rather than silently treating broken input as already-formatted.

content

the source to format

type string

options?

a filepath to infer the language, or an explicit lang

optional default {}

returns

string

FormatDirectoryOptions
#

format_directory.ts view source

FormatDirectoryOptions import type {FormatDirectoryOptions} from '@fuzdev/gro/format_directory.js';

log

type Logger

dir

The directory swept when patterns is empty.

type string

check?

When true, reports unformatted files instead of writing them.

type boolean

default false

filter?

Directory filters (e.g. config.search_filters) to skip, tested relative to the project root, or outside it to the searched directory or a glob's leading literal directory; also prunes patterns results, so a glob within the root can't reach node_modules, while a glob whose literal base is outside the root (../other/node_modules/x/*.js) is taken as given.

type (PathFilter) | (PathFilter)[]

patterns?

Files or globs to format instead of sweeping dir, relative to the cwd or absolute. A pattern naming an existing file is that file, followed through its symlinks, even when its name holds glob syntax (src/routes/[slug]/+page.ts). Any other is a glob, matched as path.matchesGlob does, searched from its leading literal directory, whose symlinks are followed; beneath it, a symlink is skipped.

type string[]

root?

The project root filter tests paths relative to, and where the ignore files are read.

type string

default `paths.root`

FormatDirectoryResult
#

format_directory.ts view source

FormatDirectoryResult import type {FormatDirectoryResult} from '@fuzdev/gro/format_directory.js';

ok

type boolean

formatted

The files that were formatted (or, in check mode, that need formatting).

type string[]

errored

Files the formatter rejected (e.g. a syntax error), left untouched.

type { id: string; error: unknown; }[]

FormatFileOptions
#

format_file.ts view source

FormatFileOptions import type {FormatFileOptions} from '@fuzdev/gro/format_file.js';

filepath?

The file path, used to infer the language from its extension.

type string

lang?

The language to format as, overriding any inference from filepath.

type FormatLang

FormatIgnore
#

format_directory.ts view source

FormatIgnore import type {FormatIgnore} from '@fuzdev/gro/format_directory.js';

Whether the format sweep skips a file, given its absolute id.

(call)

type (id: string): boolean

id

type string
returns boolean

FormatLang
#

format_file.ts view source

FormatLang

type "typescript" | "svelte" | "css" | "json"

import type {FormatLang} from '@fuzdev/gro/format_file.js';

The source languages Gro can format in-process, backed by @fuzdev/tsv (typescript/svelte/css) plus a builtin json formatter. Anything else passes through unchanged.

FoundGenfiles
#

fs
#

fs.ts view source

Fs import {fs} from '@fuzdev/gro/fs.js';

The fs host module's root handle. Import it where authority enters (a task, a script, an entry module) and hand narrower handles down.

Fs
#

fs.ts view source

Fs import type {Fs} from '@fuzdev/gro/fs.js';

The fs host module's root: the project directory and the ways to reach others.

project

The project directory.

type FsDir

readonly

open_dir

Opens a directory by absolute path.

type (path: string): Promise<FsDir>

path

type string
returns Promise<FsDir>

throws

  • `TypeError` - for a relative path, or one holding a NUL byte or a lone surrogate
  • `FsError` - `not_found`, `not_a_directory`

temp_dir

Creates a fresh directory under the OS temp directory, removed with everything in it when disposed (await using).

type (prefix?: string | undefined): Promise<FsDir & AsyncDisposable>

prefix?

the start of the directory's name, defaults to 'gro-'. It names no other directory: a non-string, a /, or a NUL byte throws TypeError, and .. is only the name's start (.. then six random characters).

type string
optional
returns Promise<FsDir & AsyncDisposable>

throws

  • `TypeError` - for a prefix that isn't a string or holds a `/` or a NUL byte

fs_search
#

FsCopyOptions
#

fs.ts view source

FsCopyOptions import type {FsCopyOptions} from '@fuzdev/gro/fs.js';

recursive?

Copy a directory and everything in it, symlinks copied as links.

type boolean

FsDir
#

fs.ts view source

FsDir import type {FsDir} from '@fuzdev/gro/fs.js';

A read-write handle on a directory. Every path is relative to it.

inheritance

extends: FsReadDir

dir

type (path: string): FsDir

path

type string
returns FsDir

readonly

A handle on the same directory without the write ops, at runtime as well as in types.

type (): FsReadDir

returns FsReadDir

write

Writes a file, replacing one that exists, or with create_new only creating one.

type (path: string, data: string | Uint8Array<ArrayBufferLike>, options: FsWriteOptions & { create_new: true; }): Promise<"created" | "exists">

path

type string

data

type Uint8Array<ArrayBufferLike> | string

options

type FsWriteOptions & { create_new: true; }
returns Promise<"created" | "exists">

with create_new, 'created', or 'exists' when an entry was already there

mkdir

type (path: string, options?: FsMkdirOptions | undefined): Promise<void>

path

type string

options?

optional
returns Promise<void>

remove

Removes an entry. A final symlink is removed, not its target, and with a trailing / refused as not_a_directory. The handle's own directory ('') is refused with io_error.

type (path: string, options?: FsRemoveOptions | undefined): Promise<void>

path

type string

options?

optional
returns Promise<void>

rename

Renames an entry, replacing what's at to as the OS does. Symlinks are moved, not followed. The handle's own directory at either end is refused with io_error.

type (from: string, to: string): Promise<void>

from

type string

to

type string
returns Promise<void>

copy

Copies a file, replacing what's at to, or with recursive a directory tree.

type (from: string, to: string, options?: FsCopyOptions | undefined): Promise<void>

from

type string

to

type string

options?

optional
returns Promise<void>

set_times

Sets an entry's modification and access times, atime_ms defaulting to mtime_ms. A final symlink is followed, its target confined as any path is, unless follow is false, which sets the link's own times. The runtime's run box, as designed, refuses follow: false with permission_denied, since no form of it can be bounded there. The current time is the caller's Date.now().

type (path: string, times: FsTimes, options?: FsStatOptions | undefined): Promise<void>

path

type string

times

type FsTimes

options?

optional
returns Promise<void>

throws

  • `TypeError` - for a time that isn't a finite number from `0` to `8.64e15`
  • `FsError` - `not_found`, `not_a_directory`, `permission_denied`, `outside_root`

set_mode

Sets an entry's permission bits, like 0o755, following a final symlink, whose target is confined as any path is (Linux has no mode of its own for a link). The mode is absolute, never symbolic, and holds no setuid, setgid, or sticky bit.

type (path: string, mode: number): Promise<void>

path

type string

mode

type number
returns Promise<void>

throws

  • `TypeError` - for a mode that isn't an integer from `0` to `0o777`
  • `FsError` - `not_found`, `not_a_directory`, `permission_denied`, `outside_root`

symlink

Creates a symlink at path pointing at target, path first like every handle op. The target is data, stored verbatim and never resolved, so it may be relative, absolute, or dangling: following a link is what's confined, by every handle that reaches it. The final component of path is never followed, and its parent is confined.

type (path: string, target: string): Promise<"created" | "exists">

path

type string

target

type string
returns Promise<"created" | "exists">

'created', or 'exists' when any entry was already at path, a dangling symlink included, which is left untouched

throws

  • `TypeError` - for a `path` ending in `/`, `/.`, or `/..`, which names a directory, unless it resolves to the handle's own directory (`''`, `'.'`, `'d/..'`), an existing entry and so `'exists'`; or a `target` that is empty, holds a NUL byte, or isn't well-formed Unicode
  • `FsError` - `not_found` for a missing parent, `not_a_directory`, `permission_denied`, `outside_root`

FsError
#

fs_error.ts view source

import {FsError} from '@fuzdev/gro/fs_error.js';

The error every fs op throws, typed by kind. Match it with is_fs_error, which also recognizes one from another copy of Gro. The class and its prototype are frozen.

inheritance

extends: Error

name

type string

kind

type FsErrorKind

readonly

path

The absolute path the op targeted, or for outside_root the path as requested.

type string

readonly

constructor

type new (kind: FsErrorKind, path: string, message?: string | undefined, options?: ErrorOptions | undefined): FsError

kind

path

type string

message?

type string
optional

options?

type ErrorOptions
optional

FsErrorKind
#

fs_error.ts view source

FsErrorKind

type "not_found" | "already_exists" | "permission_denied" | "not_a_directory" | "is_a_directory" | "not_empty" | "outside_root" | "io_error"

import type {FsErrorKind} from '@fuzdev/gro/fs_error.js';

Why an fs op failed. outside_root is a path that would leave its handle; io_error is every failure without a kind of its own.

FsMkdirOptions
#

fs.ts view source

FsMkdirOptions import type {FsMkdirOptions} from '@fuzdev/gro/fs.js';

recursive?

Create missing parents too; an existing directory is then not an error.

type boolean

exists_ok?

Return normally when the directory exists. An existing non-directory still throws.

type boolean

FsOpenedPath
#

fs_paths.ts view source

FsOpenedPath import type {FsOpenedPath} from '@fuzdev/gro/fs_paths.js';

A path resolved to a handle and the relative path beneath it.

dir

type FsDir

path

Relative to dir, '' for dir itself, keeping a requested trailing /.

type string

FsPaths
#

fs_paths.ts view source

FsPaths import type {FsPaths} from '@fuzdev/gro/fs_paths.js';

Opens paths from outside as handles. A relative path is relative to project, resolved lexically, its .. segments before any symlink is followed, as Node's path.resolve does. Then it's resolved to its real path, every symlink in it followed, a dangling final one to its missing target, and a missing part appended to its nearest existing ancestor's real path. A real path at or beneath the project is relative to project; any other opens its parent, or the parent's nearest existing ancestor, with fs.open_dir. So the op on the result follows no symlink but ones created since, and a symlink out of the project, at the end of the path or before it, reaches what it points at.

project

The project directory, the fs.project of the Fs this was built from, the dir of every path that resolves beneath it.

type FsDir

readonly

open_path

Converts a path into a handle and the relative path beneath it.

type (path: string): Promise<FsOpenedPath>

path

absolute, or relative to the project; a trailing / is kept

type string
returns Promise<FsOpenedPath>

throws

  • `FsError` - `not_a_directory` when, outside the project, an ancestor of the path is a file (beneath the project, the op on the result throws it instead); `io_error` for a symlink loop (ELOOP); `permission_denied` or `io_error` when reading a directory or symlink on the way fails otherwise

open_dir_path

Opens a directory, resolved as open_path resolves it: beneath the project, project and the directory's path beneath it, else the directory as its own handle, so what's found beneath it reaches nothing above.

type (path: string): Promise<FsOpenedPath | null>

path

absolute, or relative to the project

type string
returns Promise<FsOpenedPath | null>

the handle and the directory's path beneath it; null when nothing is at a path outside the project, while beneath it the result is project and the path, missing or not, and the op on it reports a missing directory

throws

  • `FsError` - `not_a_directory` when `path` is a file outside the project (beneath the project, the op on the result throws it instead), otherwise as `open_path` does

search_path

Searches a directory as fs_search does, with ids that start with the path as named, made absolute against the project. The directory is opened as open_dir_path opens it, so the search reaches nothing above it.

type (path: string, options?: Omit<FsSearchOptions, "path" | "id_dir"> | undefined): Promise<FsSearchResult[]>

path

absolute, or relative to the project

type string

options?

type Omit<FsSearchOptions, "path" | "id_dir">
optional
returns Promise<FsSearchResult[]>

the found paths, or an empty array when nothing is at path

throws

  • `FsError` - when `path` isn't a directory, or a listing fails

copy_path

Copies a file, or with recursive a directory tree, as FsDir.copy does, symlinks in a tree copied as links. Both paths are resolved as open_path resolves them, and the copy runs beneath project when both are in the project, else beneath their nearest common directory.

type (from: string, to: string, options?: FsCopyOptions | undefined): Promise<void>

from

absolute, or relative to the project

type string

to

absolute, or relative to the project

type string

options?

optional
returns Promise<void>

throws

  • `FsError` - as `open_path` and `FsDir.copy` do

empty_dir_path

Empties a directory, its symlinks followed, removing everything in it but never the directory itself, so a symlink to it is kept.

type (path: string): Promise<void>

path

absolute, or relative to the project

type string
returns Promise<void>

throws

  • `FsError` - `io_error` when the directory is the project, the process's working directory, `$HOME`, or an ancestor of one, `not_a_directory` when it's a file, otherwise as `open_dir_path` and `FsDir.remove` do

remove_path

Removes the entry at a path, never what a final symlink points at: the parent is resolved as open_path resolves it, symlinks followed, and the final entry is removed as FsDir.remove does, a symlink removed itself. A trailing / removes only a directory, as in FsDir.remove.

type (path: string, options?: FsRemoveOptions | undefined): Promise<void>

path

absolute, or relative to the project

type string

options?

optional
returns Promise<void>

throws

  • `FsError` - `io_error` for the project, the process's working directory, `$HOME`, or an ancestor of one, otherwise as `open_path` and `FsDir.remove` do

FsReadDir
#

fs.ts view source

FsReadDir import type {FsReadDir} from '@fuzdev/gro/fs.js';

A read-only handle on a directory. Every path is relative to it.

path

The directory's absolute real path, for display and as a spawned process's cwd. It carries no authority: ops take relative paths on the handle.

type string

readonly

dir

Narrows to a subdirectory, which must exist.

type (path: string): FsReadDir

path

type string
returns FsReadDir

throws

  • `FsError` - `not_found`, `not_a_directory`, `outside_root`

stat

type (path: string, options?: FsStatOptions | undefined): Promise<FileInfo | null>

path

type string

options?

optional
returns Promise<FileInfo | null>

the entry's info, or null when nothing is at path (a path through a file throws not_a_directory)

exists

Whether an entry is at path, following a final symlink.

type (path: string): Promise<boolean>

path

type string
returns Promise<boolean>

read

type (path: string): Promise<Uint8Array<ArrayBufferLike>>

path

type string
returns Promise<Uint8Array<ArrayBufferLike>>

read_text

Reads a file as UTF-8.

type (path: string): Promise<string>

path

type string
returns Promise<string>

read_if_exists

type (path: string): Promise<Uint8Array<ArrayBufferLike> | null>

path

type string
returns Promise<Uint8Array<ArrayBufferLike> | null>

the file's bytes, or null when nothing is at path

read_text_if_exists

type (path: string): Promise<string | null>

path

type string
returns Promise<string | null>

the file's UTF-8 text, or null when nothing is at path

list

Lists a directory's entries, in no particular order. An entry whose name isn't UTF-8 fails the listing with io_error, since no string names it.

type (path?: string | undefined): AsyncIterable<DirEntry>

path?

defaults to the handle's own directory

type string
optional
returns AsyncIterable<DirEntry, any, any>

read_link

Reads a symlink's target as stored, never following the link, so the target may be absolute or lead outside the handle: reading it reaches nothing. A target that isn't UTF-8 fails with io_error, since no string spells it.

type (path: string): Promise<string>

path

type string
returns Promise<string>

throws

  • `FsError` - `not_found`; `io_error` when the entry isn't a symlink

stat_sync

type (path: string, options?: FsStatOptions | undefined): FileInfo | null

path

type string

options?

optional
returns FileInfo | null

exists_sync

type (path: string): boolean

path

type string
returns boolean

read_text_sync

type (path: string): string

path

type string
returns string

FsRemoveOptions
#

fs.ts view source

FsRemoveOptions import type {FsRemoveOptions} from '@fuzdev/gro/fs.js';

recursive?

Remove a directory and everything in it. Without it, only a file, a symlink, or an empty directory is removed.

type boolean

missing_ok?

Return normally when nothing is at the path.

type boolean

FsSearchOptions
#

fs_search.ts view source

FsSearchOptions import type {FsSearchOptions} from '@fuzdev/gro/fs_search.js';

path?

The directory to search, relative to the handle. Defaults to the handle's own directory.

type string

id_dir?

The absolute directory each id starts with: an entry's id is id_dir, a /, and the entry's path relative to the searched directory. Defaults to the searched directory's real path, beneath the handle's. A caller that names the directory by another absolute path passes it, so the ids and the filters see the path the caller named.

type string

filter?

Filters each entry must pass, given its absolute id and whether it's a directory. A directory that fails isn't descended into.

type (PathFilter) | (PathFilter)[]

file_filter?

Filters each file must pass, given its absolute id.

type (FileFilter) | (FileFilter)[]

sort?

Whether the results are sorted by path, defaults to true. Without sorting the order is volatile.

type boolean

FsSearchResult
#

fs_search.ts view source

FsSearchResult import type {FsSearchResult} from '@fuzdev/gro/fs_search.js';

A file fs_search found: a non-directory entry, with its kind as the listing read it, so a caller that acts on regular files alone can skip a symlink.

inheritance

extends: ResolvedPath

kind

type "file" | "symlink" | "other"

FsStatOptions
#

fs.ts view source

FsStatOptions import type {FsStatOptions} from '@fuzdev/gro/fs.js';

follow?

Whether a final symlink is followed to its target. Defaults to true.

type boolean

FsTimes
#

fs.ts view source

FsTimes import type {FsTimes} from '@fuzdev/gro/fs.js';

The times set_times gives an entry, in milliseconds since the epoch, as FileInfo.mtime_ms. Each is a finite number from 0 to 8.64e15, the range of a Date, else a TypeError, and the filesystem may clamp a time beyond its own range. The Node implementation passes seconds as a double that libuv truncates, to a microsecond on libuv 1.51 (Node 24.14) and to a nanosecond on 1.52.1 (Node 26.13): on the microsecond step an integer is stored exactly through 2242, and on the nanosecond step within half the double's spacing (119ns from 2004 to 2038), so stat can show an integer one step of its own double off where that spacing is the coarser, as from 2038-01-19 to 2039-09-07.

mtime_ms

The last modification time.

type number

atime_ms?

The last access time. Defaults to mtime_ms.

type number

FsWriteOptions
#

fs.ts view source

FsWriteOptions import type {FsWriteOptions} from '@fuzdev/gro/fs.js';

create_new?

Fail with 'exists' rather than replace an existing entry.

type boolean

mode?

The permission bits of a newly created file, before the umask, masked to 0o777, so no setuid, setgid, or sticky bit. An integer from 0 to 0o7777, else a TypeError.

type number

Gen
#

GEN_FILE_PATTERN
#

GEN_FILE_PATTERN_TEXT
#

gen_inputs_match
#

gen_helpers.ts view source

(inputs: GenInputs, id: PathId, root?: PathId): boolean import {gen_inputs_match} from '@fuzdev/gro/gen_helpers.js';

Checks if a file is one of a genfile's inputs. 'all' matches every file, files match exactly after resolving against the root, and patterns match like a root .gitignore, only for files inside the root.

inputs

the genfile's inputs

id

the file to check

type PathId

root?

the project root that files resolve against and patterns anchor at

type PathId
optional default paths.root

returns

boolean

gen_task_registry
#

task_registry.ts view source

(fs_paths: FsPaths): GenConfig import {gen_task_registry} from '@fuzdev/gro/task_registry.js';

Creates the genfile config that types a project's tasks for invoke_task. Export it as gen from a genfile like src/gro_tasks.gen.ts, export const gen = gen_task_registry(create_fs_paths(fs));, which writes src/gro_tasks.ts augmenting ProjectTasks with every task file under src/, keyed by its path relative to the project root. In gro dev it regenerates when a task file is added or changed; gro dev ignores deletes, so run gro gen after removing a task.

fs_paths

searches the project's src/, its project the root the tasks are keyed relative to

type FsPaths

returns

GenConfig

GenConfig
#

gen.ts view source

GenConfig import type {GenConfig} from '@fuzdev/gro/gen.js';

generate

type (ctx: GenContext): RawGenResult | Promise<RawGenResult>

ctx

returns RawGenResult | Promise<RawGenResult>

inputs?

What the genfile reads besides its imports. Changes to its imports and to the genfile itself always rerun it.

type GenInputs

GenContext
#

gen.ts view source

GenContext import type {GenContext} from '@fuzdev/gro/gen.js';

config

type GroConfig

svelte_config

Resolved on first access, so genfiles that don't touch it never pay to read the SvelteKit config.

type Promise<ParsedSvelteConfig>

log

type Logger

timings

type Timings

invoke_task

type <TName extends string>(task_name: InvokeTaskName<TName>, ...rest: InvokeTaskRest<TName>): Promise<void>

task_name

type InvokeTaskName<TName>

rest

type InvokeTaskRest<TName>
returns Promise<void>

origin_id

Same as import.meta.url but in path form.

type PathId

origin_path

The origin_id relative to the root dir.

type string

GenContextBase
#

gen.ts view source

GenContextBase import type {GenContextBase} from '@fuzdev/gro/gen.js';

The GenContext values that are the same for every genfile in a run, as opposed to the per-genfile ones create_gen_context derives.

config

type GroConfig

log

type Logger

timings

type Timings

invoke_task

type <TName extends string>(task_name: InvokeTaskName<TName>, ...rest: InvokeTaskRest<TName>): Promise<void>

task_name

type InvokeTaskName<TName>

rest

type InvokeTaskRest<TName>
returns Promise<void>

GenFile
#

gen.ts view source

GenFile import type {GenFile} from '@fuzdev/gro/gen.js';

id

type PathId

content

type string

origin_id

type PathId

format

type boolean

GenfileModule
#

gen.ts view source

GenfileModule import type {GenfileModule} from '@fuzdev/gro/gen.js';

gen

type Gen

GenfileModuleMeta
#

GenfileModuleResult
#

GenfileModuleResultFailure
#

gen.ts view source

GenfileModuleResultFailure import type {GenfileModuleResultFailure} from '@fuzdev/gro/gen.js';

ok

type false

id

type PathId

reason

type string

error

type Error

elapsed

type number

GenfileModuleResultSuccess
#

gen.ts view source

GenfileModuleResultSuccess import type {GenfileModuleResultSuccess} from '@fuzdev/gro/gen.js';

ok

type true

id

type PathId

files

type GenFile[]

elapsed

type number

GenFunction
#

GenInputs
#

gen.ts view source

GenInputs

type "all" | { files?: string[] | undefined; patterns?: string[] | undefined; }

import type {GenInputs} from '@fuzdev/gro/gen.js';

What a genfile reads besides its imports, so gro dev reruns it when one changes: 'all' for every change the dev watch reports, or files and patterns that add to its imports. Plain data, read from the genfile's gen export. gro dev sees changes only under GroConfig.watch.dir (default src/), so an input outside it is declared but doesn't trigger a rerun.

GenResult
#

gen.ts view source

GenResult import type {GenResult} from '@fuzdev/gro/gen.js';

origin_id

type PathId

files

type GenFile[]

GenResults
#

get_possible_paths
#

input_path.ts view source

(fs_paths: FsPaths, input_path: InputPath, root_dirs: PathId[], extensions: string[]): Promise<PossiblePath[]> import {get_possible_paths} from '@fuzdev/gro/input_path.js';

Gets a list of possible source ids for each input path with extensions, duplicating each under root_dirs, checking the filesystem only for whether an absolute input path is a directory.

fs_paths

stats an absolute input path

type FsPaths

input_path

root_dirs

type PathId[]

extensions

type string[]

returns

Promise<PossiblePath[]>

git_check_clean_workspace
#

git.ts view source

(git: SpawnProgram, options?: SpawnCallOptions | undefined): Promise<string | null> import {git_check_clean_workspace} from '@fuzdev/gro/git.js';

git

options?

optional

returns

Promise<string | null>

an error message if the git workspace has any unstaged or uncommitted changes, or null if it's clean

git_check_fully_staged_workspace
#

git.ts view source

(git: SpawnProgram, options?: SpawnCallOptions | undefined): Promise<string | null> import {git_check_fully_staged_workspace} from '@fuzdev/gro/git.js';

git

options?

optional

returns

Promise<string | null>

an error message if the git workspace has any unstaged changes or untracked files, or null if fully staged

git_check_setting_pull_rebase
#

git.ts view source

(git: SpawnProgram, options?: SpawnCallOptions | undefined): Promise<boolean> import {git_check_setting_pull_rebase} from '@fuzdev/gro/git.js';

Returns the global git config setting for pull.rebase.

git

options?

optional

returns

Promise<boolean>

git_check_workspace
#

git.ts view source

(git: SpawnProgram, options?: SpawnCallOptions | undefined): Promise<GitWorkspaceStatus> import {git_check_workspace} from '@fuzdev/gro/git.js';

Checks the git workspace status using a single git status --porcelain -z call. A directory that isn't a repo reports no changes.

git

options?

optional

returns

Promise<GitWorkspaceStatus>

throws

  • `TaskError` - if it failed on a repo it couldn't read, which must not read as clean
  • Error - if `git` was stopped rather than exiting, or its output was truncated

git_checkout
#

git.ts view source

(git: SpawnProgram, branch: Flavored<string, "GitBranch">, options?: SpawnCallOptions | undefined): Promise<Flavored<string, "GitBranch"> | null> import {git_checkout} from '@fuzdev/gro/git.js';

Calls git checkout.

git

branch

type Flavored

options?

optional

returns

Promise<Flavored | null>

the previous branch name, if it changed

throws

  • `TaskError` - if `branch` isn't one plain ref name, or the current branch is unborn
  • Error - if the underlying git command fails

git_current_branch_first_commit_hash
#

git.ts view source

(git: SpawnProgram, options?: SpawnCallOptions | undefined): Promise<string> import {git_current_branch_first_commit_hash} from '@fuzdev/gro/git.js';

Returns the hash of the current branch's first commit.

git

options?

optional

returns

Promise<string>

throws

  • Error - if the underlying git command fails

git_current_branch_name
#

git.ts view source

(git: SpawnProgram, options?: SpawnCallOptions | undefined): Promise<Flavored<string, "GitBranch">> import {git_current_branch_name} from '@fuzdev/gro/git.js';

Returns the current git branch name, or the literal string HEAD on a detached HEAD, which callers comparing it to a branch name read as not that branch.

git

options?

optional

returns

Promise<Flavored>

throws

  • `TaskError` - on an unborn branch, one with no commits yet
  • Error - if `git` prints no name, as outside a repo, or was stopped or truncated

git_current_commit_hash
#

git.ts view source

(git: SpawnProgram, options?: SpawnCallOptions | undefined): Promise<string | null> import {git_current_commit_hash} from '@fuzdev/gro/git.js';

Returns the hash of the commit HEAD points at, or null when there is none: an unborn branch, or a directory that isn't a repo. A detached HEAD reads as its commit.

git

options?

optional

returns

Promise<string | null>

throws

  • Error - if `git` was stopped rather than exiting, or its output was truncated

git_delete_local_branch
#

git.ts view source

(git: SpawnProgram, branch: Flavored<string, "GitBranch">, options?: SpawnCallOptions | undefined): Promise<void> import {git_delete_local_branch} from '@fuzdev/gro/git.js';

Deletes a branch locally.

git

branch

type Flavored

options?

optional

returns

Promise<void>

throws

  • `TaskError` - if `branch` isn't one plain ref name
  • Error - if the underlying git command fails

GIT_DIRNAME
#

git_fetch
#

git.ts view source

(git: SpawnProgram, origin?: Flavored<string, "GitOrigin">, branch?: Flavored<string, "GitBranch"> | undefined, options?: SpawnCallOptions | undefined): Promise<...> import {git_fetch} from '@fuzdev/gro/git.js';

Calls git fetch. Contacts the remote, so it may prompt.

git

origin?

type Flavored
optional default 'origin'

branch?

type Flavored
optional

options?

optional

returns

Promise<void>

throws

  • `TaskError` - if `branch` isn't one plain ref name
  • Error - if the underlying git command fails

git_fetch_force
#

git.ts view source

(git: SpawnProgram, origin: Flavored<string, "GitOrigin">, branch: Flavored<string, "GitBranch">, options?: SpawnCallOptions | undefined): Promise<...> import {git_fetch_force} from '@fuzdev/gro/git.js';

Sets the local branch to the remote's, even when that drops commits only the local one has, as the refspec +branch:branch. Contacts the remote, so it may prompt.

git

origin

type Flavored

branch

type Flavored

options?

optional

returns

Promise<void>

throws

  • `TaskError` - if `branch` isn't one plain ref name
  • Error - if the underlying git command fails

git_head_subject
#

git.ts view source

(git: SpawnProgram, options?: SpawnCallOptions | undefined): Promise<string | null> import {git_head_subject} from '@fuzdev/gro/git.js';

git

options?

optional

returns

Promise<string | null>

the subject line of the commit HEAD points at, or null when there is none

throws

  • Error - if `git` was stopped rather than exiting, or its output was truncated

git_local_branch_exists
#

git.ts view source

(git: SpawnProgram, branch: Flavored<string, "GitBranch">, options?: SpawnCallOptions | undefined): Promise<boolean> import {git_local_branch_exists} from '@fuzdev/gro/git.js';

Checks if a local git branch exists.

git

branch

type Flavored

options?

optional

returns

Promise<boolean>

throws

  • `TaskError` - if `branch` isn't one plain ref name

GIT_LOCAL_PASS_ENV
#

git.ts view source

readonly string[] import {GIT_LOCAL_PASS_ENV} from '@fuzdev/gro/git.js';

The host variables a git that only reads the local repo needs beyond the base set. GIT_* carries what a repo reached through a hook or a worktree is (GIT_DIR, GIT_INDEX_FILE) and XDG_CONFIG_HOME where the user's config is. SUDO_UID is the owner git's safe.directory check accepts when the effective user is root, so under sudo the invoking user's repo isn't refused as dubiously owned. A git that commits or reaches a remote gets more, decided at its root.

git_parse_workspace_status
#

git.ts view source

(stdout: string | null): GitWorkspaceStatus import {git_parse_workspace_status} from '@fuzdev/gro/git.js';

Parses the output of git status --porcelain -z (v1 format) into a status object.

Format: XY path\0 where X is the staged status (index), Y the unstaged status (work tree), and path is unescaped, with renames and copies as XY new\0old\0. Submodule-specific status codes are interpreted as changes.

stdout

the raw output from git status --porcelain -z

type string | null

returns

GitWorkspaceStatus

git_pull
#

git.ts view source

(git: SpawnProgram, origin?: Flavored<string, "GitOrigin">, branch?: Flavored<string, "GitBranch"> | undefined, options?: SpawnCallOptions | undefined): Promise<...> import {git_pull} from '@fuzdev/gro/git.js';

Calls git pull. Contacts the remote, so it may prompt.

git

origin?

type Flavored
optional default 'origin'

branch?

type Flavored
optional

options?

optional

returns

Promise<void>

throws

  • `TaskError` - if `branch` isn't one plain ref name
  • Error - if the underlying git command fails, or `origin` begins with `-`

git_push
#

git.ts view source

(git: SpawnProgram, origin: Flavored<string, "GitOrigin">, branch?: Flavored<string, "GitBranch"> | undefined, options?: SpawnCallOptions | undefined, set_upstream?: boolean): Promise<...> import {git_push} from '@fuzdev/gro/git.js';

Calls git push. Contacts the remote, so it may prompt.

git

origin

type Flavored

branch?

type Flavored
optional

options?

optional

set_upstream?

type boolean
optional default false

returns

Promise<void>

throws

  • `TaskError` - if the branch isn't one plain ref name, as on a detached `HEAD`
  • Error - if the underlying git command fails

git_push_to_create
#

git.ts view source

(git: SpawnProgram, origin?: Flavored<string, "GitOrigin">, branch?: Flavored<string, "GitBranch"> | undefined, options?: SpawnCallOptions | undefined): Promise<...> import {git_push_to_create} from '@fuzdev/gro/git.js';

Calls git push, setting upstream if the remote branch does not yet exist.

git

origin?

type Flavored
optional default 'origin'

branch?

type Flavored
optional

options?

optional

returns

Promise<void>

throws

  • `TaskError` - if the branch isn't one plain ref name, as on a detached `HEAD`
  • Error - if the underlying git command fails

git_remote_branch_exists
#

git.ts view source

(git: SpawnProgram, origin?: Flavored<string, "GitOrigin">, branch?: Flavored<string, "GitBranch"> | undefined, options?: SpawnCallOptions | undefined): Promise<...> import {git_remote_branch_exists} from '@fuzdev/gro/git.js';

Checks if a remote git branch exists. Contacts the remote, so it may prompt.

git

origin?

type Flavored
optional default 'origin'

branch?

type Flavored
optional

options?

optional

returns

Promise<boolean>

throws

  • `TaskError` - if the branch isn't one plain ref name, as on a detached `HEAD`
  • Error - if `git ls-remote` fails for a reason other than the branch not existing

GIT_SHORT_HASH_LENGTH
#

build.task.ts view source

7 import {GIT_SHORT_HASH_LENGTH} from '@fuzdev/gro/build.task.js';

Length of git commit hash when displayed in logs (standard git convention).

git_tag_exists
#

git.ts view source

(git: SpawnProgram, tag: string, options?: SpawnCallOptions | undefined): Promise<boolean> import {git_tag_exists} from '@fuzdev/gro/git.js';

git

tag

type string

options?

optional

returns

Promise<boolean>

true if the local tag exists

throws

  • `TaskError` - if `tag` isn't one plain ref name
  • Error - if `git` was stopped rather than exiting

git_workspace_is_clean
#

git.ts view source

(status: GitWorkspaceStatus): boolean import {git_workspace_is_clean} from '@fuzdev/gro/git.js';

status

returns

boolean

true if the workspace has no changes at all

git_workspace_is_fully_staged
#

git.ts view source

(status: GitWorkspaceStatus): boolean import {git_workspace_is_fully_staged} from '@fuzdev/gro/git.js';

status

returns

boolean

true if the workspace has no unstaged changes and no untracked files (staged changes are OK)

git_workspace_status_message
#

git.ts view source

(status: GitWorkspaceStatus): string import {git_workspace_status_message} from '@fuzdev/gro/git.js';

Converts a workspace status to a human-readable message.

status

returns

string

GitBranch
#

git.ts view source

value + type

Flavored<string, "GitBranch">

type Flavored

import {GitBranch} from '@fuzdev/gro/git.js';

A git branch's name.

external types

s.Infer<typeof GitBranch>

github_fetch_commit_prs
#

github.ts view source

(owner: string, repo: string, commit_sha: string, fetch: { (input: RequestInfo | URL, init?: RequestInit | undefined): Promise<Response>; (input: string | ... 1 more ... | URL, init?: RequestInit | undefined): Promise<...>; }, token?: string | undefined, log?: Logger | undefined, cache?: FetchValueCache | undefined, api_version?: string | undefined): Promise<...> import {github_fetch_commit_prs} from '@fuzdev/gro/github.js';

Fetches the pull requests associated with a commit.

owner

type string

repo

type string

commit_sha

type string

fetch

the fetch the GitHub API request goes through, handed in by the caller

type { (input: RequestInfo | URL, init?: RequestInit | undefined): Promise<Response>; (input: string | Request | URL, init?: RequestInit | undefined): Promise<...>; }

token?

type string
optional

log?

type Logger
optional

cache?

type FetchValueCache
optional

api_version?

type string
optional

returns

Promise<GithubPullRequest[] | null>

see also

GITHUB_REPO_MATCHER
#

GithubPullRequest
#

github.ts view source

value + type

{ url: string; id: number; html_url: string; number: number; user: { login: string; } & Record<string, unknown>; } & Record<string, unknown>

type { url: string; id: number; html_url: string; number: number; user: { login: string; } & Record<string, unknown>; } & Record<string, unknown>

import {GithubPullRequest} from '@fuzdev/gro/github.js';

url

type string

id

type number

html_url

type string

number

type number

user

type { login: string; } & Record<string, unknown>

[key: string]

type unknown

GitOrigin
#

git.ts view source

value + type

Flavored<string, "GitOrigin">

type Flavored

import {GitOrigin} from '@fuzdev/gro/git.js';

A git remote's name, such as origin.

external types

s.Infer<typeof GitOrigin>

GitWorkspaceStatus
#

git.ts view source

GitWorkspaceStatus import type {GitWorkspaceStatus} from '@fuzdev/gro/git.js';

Git workspace status flags indicating which types of changes are present.

unstaged_changes

type boolean

staged_changes

type boolean

untracked_files

type boolean

goto
#

GRO_BUILTIN_TASK_SUMMARIES
#

gro_builtin_tasks.ts view source

Record<keyof GroBuiltinTasks, string>

type Record<"run" | "build" | "changeset" | "check" | "clean" | "commit" | "deploy" | "dev" | "format" | "gen" | "lint" | "publish" | "reinstall" | "release" | "sync" | "test" | "typecheck" | "upgrade", string>

import {GRO_BUILTIN_TASK_SUMMARIES} from '@fuzdev/gro/gro_builtin_tasks.js';

The summary of each of Gro's builtin tasks by name, so listing them imports no task module.

GRO_CONFIG_FILENAME
#

GRO_DIR
#

GRO_DIRNAME
#

GRO_DIST_PREFIX
#

constants.ts view source

"dist_" import {GRO_DIST_PREFIX} from '@fuzdev/gro/constants.js';

The prefix of plugin output directories at the project root, which gro build and gro clean delete and the build cache hashes.

gro_package_versions_diff
#

npm_install_helpers.ts view source

(before: GroPackageVersions, after: GroPackageVersions): string[] import {gro_package_versions_diff} from '@fuzdev/gro/npm_install_helpers.js';

Lists the packages whose installed version differs between two snapshots, formatted as name before โ†’ after and sorted by name.

before

the snapshot from before the install

after

the snapshot from after the install

returns

string[]

one line per changed package, empty when nothing changed

gro_package_versions_load
#

npm_install_helpers.ts view source

(fs_paths: FsPaths, gro_dir?: string, names?: Iterable<string>): Promise<GroPackageVersions> import {gro_package_versions_load} from '@fuzdev/gro/npm_install_helpers.js';

Reads the installed versions of the Gro package at gro_dir and its dependencies and peer dependencies, as they sit in node_modules. These are the packages a running Gro has loaded, so comparing snapshots from before and after an install tells whether the process is now stale. Read from disk, not through the module system, whose cache keeps what it first loaded.

fs_paths

opens the package.json files, beneath the project or not

type FsPaths

gro_dir?

the Gro package directory; defaults to the running Gro's

type string
optional default gro_paths.root

names?

more packages to read beside the ones Gro's package.json names, so an after-install snapshot covers the deps an upgraded Gro dropped

type Iterable<string, any, any>
optional default []

returns

Promise<GroPackageVersions>

the versions keyed by package name, @fuzdev/gro included

gro_paths
#

paths.ts view source

Paths import {gro_paths} from '@fuzdev/gro/paths.js';

Paths for the Gro package being used by the user repo.

gro_plugin_gen
#

gro_plugin_gen.ts view source

({ flush_debounce_delay }?: GroPluginGenOptions): Plugin<PluginContext<object>> import {gro_plugin_gen} from '@fuzdev/gro/gro_plugin_gen.js';

Runs gro gen in development: with no watch, once if there are genfiles under src/, and with watch, for each genfile in the module graph (watch.dir, default src/) that a change affects.

__0?

optional default EMPTY_OBJECT

returns

Plugin<PluginContext<object>>

gro_plugin_server
#

gro_plugin_server.ts view source

(options: GroPluginServerOptions): Plugin<PluginContext<object>> import {gro_plugin_server} from '@fuzdev/gro/gro_plugin_server.js';

Runs a server during development, beside the Vite dev server, restarting it when its entry or anything the entry imports changes, per the module graph. The entry runs with Gro's loader, as gro run runs a file, in its own process, with the host's whole environment, since a server reads a set Gro can't know. Only modules the graph tracks restart it: those under watch.dir, default src/, reached by path or # subpath imports, not a package's files reached by bare specifiers. Started at setup, only by gro dev in watch mode, and stopped at teardown.

options

returns

Plugin<PluginContext<object>>

gro_plugin_sveltekit_app
#

gro_plugin_sveltekit_library
#

GroBuiltinTasks
#

gro_builtin_tasks.ts view source

GroBuiltinTasks import type {GroBuiltinTasks} from '@fuzdev/gro/gro_builtin_tasks.js';

Gro's builtin tasks by name, mapped to their module types.

build

type typeof import("build.task.ts", { with: { "resolution-mode": "import" } })

changeset

type typeof import("changeset.task.ts", { with: { "resolution-mode": "import" } })

check

type typeof import("check.task.ts", { with: { "resolution-mode": "import" } })

clean

type typeof import("clean.task.ts", { with: { "resolution-mode": "import" } })

commit

type typeof import("commit.task.ts", { with: { "resolution-mode": "import" } })

deploy

type typeof import("deploy.task.ts", { with: { "resolution-mode": "import" } })

dev

type typeof import("dev.task.ts", { with: { "resolution-mode": "import" } })

format

type typeof import("format.task.ts", { with: { "resolution-mode": "import" } })

gen

type typeof import("gen.task.ts", { with: { "resolution-mode": "import" } })

lint

type typeof import("lint.task.ts", { with: { "resolution-mode": "import" } })

publish

type typeof import("publish.task.ts", { with: { "resolution-mode": "import" } })

reinstall

type typeof import("reinstall.task.ts", { with: { "resolution-mode": "import" } })

release

type typeof import("release.task.ts", { with: { "resolution-mode": "import" } })

run

type typeof import("run.task.ts", { with: { "resolution-mode": "import" } })

sync

type typeof import("sync.task.ts", { with: { "resolution-mode": "import" } })

test

type typeof import("test.task.ts", { with: { "resolution-mode": "import" } })

typecheck

type typeof import("typecheck.task.ts", { with: { "resolution-mode": "import" } })

upgrade

type typeof import("upgrade.task.ts", { with: { "resolution-mode": "import" } })

GroConfig
#

gro_config.ts view source

GroConfig import type {GroConfig} from '@fuzdev/gro/gro_config.js';

The config that users can extend via gro.config.ts. This is exposed to users in places like tasks and genfiles.

inheritance

extends: RawGroConfig

see also

plugins

type (ctx: PluginContext<object>): Plugin<PluginContext<object>>[] | Promise<Plugin<PluginContext<object>>[]>

ctx

type PluginContext<object>
returns Plugin<PluginContext<object>>[] | Promise<Plugin<PluginContext<object>>[]>

see also

map_package_json

Maps the project's package.json before writing it to the filesystem. The package_json argument may be mutated, but the return value is what's used by the caller. Returning null is a no-op for the caller.

type (PackageJsonMapper) | null

search_filters

When searching the filesystem for tasks, genfiles, and files to format, directories and files are included if they pass all of these filters. Each filter gets the path relative to the project root, like src/lib/foo.ts, whichever directory a search starts in, so the directories above the root never exclude anything; a path outside the root gets its absolute id.

type PathFilter[]

pm_cli

The CLI to use that's compatible with npm install. Defaults to 'npm'.

type string

build_cache_config_hash

BLAKE3 hash of the user's build_cache_config from gro.config.ts, as deterministic JSON. This is computed during config normalization, which then drops the raw value from the config. If no build_cache_config was provided, this is the hash of an empty string.

type string

see also

  • ``RawGroConfig.build_cache_config``

watch

What the task context's graph watches. Defaults to src/ with no filter.

type WatchOptions

GroConfigModule
#

GroPackageVersions
#

npm_install_helpers.ts view source

GroPackageVersions

type Map<string, string | null>

import type {GroPackageVersions} from '@fuzdev/gro/npm_install_helpers.js';

Installed versions of the running Gro and the packages it depends on, keyed by package name, with null for a package that isn't installed.

GroPluginGenOptions
#

gro_plugin_gen.ts view source

GroPluginGenOptions import type {GroPluginGenOptions} from '@fuzdev/gro/gro_plugin_gen.js';

Options for gro_plugin_gen.

flush_debounce_delay?

How long to wait after a change before running gro gen, batching the changes in between.

type number

GroPluginServerOptions
#

gro_plugin_server.ts view source

GroPluginServerOptions import type {GroPluginServerOptions} from '@fuzdev/gro/gro_plugin_server.js';

Options for gro_plugin_server.

entry

The server's entry module, relative to the project root, run as gro run runs a file.

type string

env_file?

The env file whose vars the server gets, absolute or relative to the project root, beneath the host's environment, so a var the host sets keeps the host's value. A missing file warns and loads nothing. null loads none.

type string | null

default '.env.development'

env?

Vars for the server over everything else, the host's environment and the env file included, like PORT and HOST. NODE_ENV is development unless this sets it.

type Record<string, string>

default {}

watch?

Whether a change to the entry or anything it imports restarts the server. gro dev --no-watch starts no server, since it tears down right after setup.

type boolean

default true

GroPluginSveltekitAppOptions
#

gro_plugin_sveltekit_app.ts view source

GroPluginSveltekitAppOptions import type {GroPluginSveltekitAppOptions} from '@fuzdev/gro/gro_plugin_sveltekit_app.js';

vite_cli?

The Vite CLI to use.

type string

GroPluginSveltekitLibraryOptions
#

has_forwarded_flag
#

args.ts view source

(forwarded_argv: string[], name: string, ignore_case?: boolean): boolean import {has_forwarded_flag} from '@fuzdev/gro/args.js';

Whether forwarded_argv names the flag name, by a scan of flag names, not a parse: --name, --name=โ€ฆ, --no-name, or --no-name=โ€ฆ, and a one-character name also as a short flag starting -name, like -o or -odist (not a later letter of a group like -wo). Tasks use it to drop a flag of their own that the user's forwarded text overrides.

forwarded_argv

the verbatim forwarded args, from to_forwarded_argv

type string[]

name

the flag name without dashes

type string

ignore_case?

match the long forms case-insensitively, for tools like tsc

type boolean
optional default false

returns

boolean

has_sveltekit_app
#

sveltekit_helpers.ts view source

(package_json: { name: string; description?: string | undefined; version?: string | undefined; type?: string | undefined; main?: string | undefined; private?: boolean | undefined; tagline?: string | undefined; ... 23 more ...; exports?: string | ... 2 more ... | undefined; } & Record<...>): Result<...> import {has_sveltekit_app} from '@fuzdev/gro/sveltekit_helpers.js';

Detected from package.json rather than the Svelte config, because reading the config costs a full Vite config resolution. Peer deps don't count - a package peered on SvelteKit is built to work with one, not to be one, and counting them would run vite build over a library that has no app.

package_json

type PackageJson

returns

Result

has_sveltekit_library
#

sveltekit_helpers.ts view source

(fs_paths: FsPaths, package_json: { name: string; description?: string | undefined; version?: string | undefined; type?: string | undefined; main?: string | undefined; private?: boolean | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; } & Record<...>): Promise<...> import {has_sveltekit_library} from '@fuzdev/gro/sveltekit_helpers.js';

Whether the project is a SvelteKit library: a SvelteKit app, as has_sveltekit_app detects one, with @sveltejs/package and the lib directory.

fs_paths

checks for the project's lib directory

type FsPaths

package_json

the project's package.json

type PackageJson

returns

Promise<Result>

infer_paths
#

paths.ts view source

(id: PathId): Paths import {infer_paths} from '@fuzdev/gro/paths.js';

id

type PathId

returns

Paths

InputPath
#

input_path.ts view source

value + type

InputPath

type string & Flavor<"InputPath">

import {InputPath} from '@fuzdev/gro/input_path.js';

external types

Flavored<s.Infer<typeof InputPath>, 'InputPath'>

install_with_cache_healing
#

npm_install_helpers.ts view source

(spawn: Spawn, pm_cli: string, options: InstallCacheHealingOptions): Promise<NpmCommandResult> import {install_with_cache_healing} from '@fuzdev/gro/npm_install_helpers.js';

Installs dependencies, self-healing the stale-cache (ETARGET) failure mode.

Strategy:

  1. First attempt: ${pm_cli} install [...install_args].
  2. On an npm ETARGET-class failure (stale cache): npm cache clean --force then retry the same install once.
  3. On any other failure โ€” or any failure under a non-npm pm_cli, or with heal_cache: false โ€” return immediately without healing.

Why ETARGET happens: right after a dependency is published and the registry has propagated, npm's local cache may still hold stale "404"/no-version metadata for it; clearing the cache forces a fresh metadata fetch. This makes installs safe to run immediately after publishing an upstream package โ€” e.g. picking up a just-released dep in a dependency-ordered publish chain, or gro upgrade-ing to a fresh @latest.

npm only: the heal uses npm-specific syntax (cache clean --force), so it's gated on pm_cli === 'npm'. A non-npm pm_cli surfaces the failure unchanged rather than running a command it can't understand.

The env is always to_install_program_options so the build's devDependencies survive, and the program is pinned once, for the install and its retry.

spawn

a root, which resolves pm_cli on PATH and takes the install's environment

type Spawn

pm_cli

the npm-compatible CLI to run (e.g. config.pm_cli)

type string

options

cwd, stderr, logger, extra install args, and an injectable runner

returns

Promise<NpmCommandResult>

the result of the (possibly retried) install

install_with_cache_healing_or_throw
#

npm_install_helpers.ts view source

(spawn: Spawn, pm_cli: string, options: InstallOrThrowOptions): Promise<void> import {install_with_cache_healing_or_throw} from '@fuzdev/gro/npm_install_helpers.js';

install_with_cache_healing that throws a TaskError on failure instead of returning the result โ€” the shape every task callsite wants. The thrown message names the exact command (including install_args), an optional context clause, and the failure detail.

spawn

a root, which resolves pm_cli on PATH

type Spawn

pm_cli

the npm-compatible CLI to run (e.g. config.pm_cli)

type string

options

same as install_with_cache_healing, plus the error's context clause and the throw_if_gro_packages_changed check

returns

Promise<void>

throws

  • TaskError - when the install fails, even after a cache-heal retry, or with `throw_if_gro_packages_changed`, when it changed Gro or its dependencies

InstallCacheHealingBaseOptions
#

npm_install_helpers.ts view source

InstallCacheHealingBaseOptions import type {InstallCacheHealingBaseOptions} from '@fuzdev/gro/npm_install_helpers.js';

cwd?

working directory for the install; defaults to the project root

type FsReadDir

log?

logger for cache-heal progress

type Logger

install_args?

Extra args appended after install, e.g. package specs and flags for gro upgrade (['foo@latest', '--force']) or a single dep for gro changeset (['-D', '@changesets/changelog-git']). The same args are reused on the post-cache-clean retry.

type readonly string[]

heal_cache?

Whether an ETARGET-class failure may clean npm's cache and retry. Defaults to true. A dry run passes false, since the clean acts on the machine whatever the install does.

type boolean

InstallCacheHealingOptions
#

InstallOrThrowOptions
#

npm_install_helpers.ts view source

InstallOrThrowOptions

type (InstallCacheHealingBaseOptions & { stderr: ProcessOutput; run?: undefined; } & { context?: string | undefined; } & { throw_if_gro_packages_changed?: false | undefined; fs_paths?: undefined; gro_dir?: undefined; }) | (InstallCacheHealingBaseOptions & { stderr: ProcessOutput; run?: undefined; } & { context?: string | undefined; } & { throw_if_gro_packages_changed: true; fs_paths: FsPaths; gro_dir?: string | undefined; }) | (InstallCacheHealingBaseOptions & { stderr?: undefined; run: NpmCommandRunner; } & { context?: string | undefined; } & { throw_if_gro_packages_changed?: false | undefined; fs_paths?: undefined; gro_dir?: undefined; }) | (InstallCacheHealingBaseOptions & { stderr?: undefined; run: NpmCommandRunner; } & { context?: string | undefined; } & { throw_if_gro_packages_changed: true; fs_paths: FsPaths; gro_dir?: string | undefined; })

import type {InstallOrThrowOptions} from '@fuzdev/gro/npm_install_helpers.js';

Options for install_with_cache_healing_or_throw, with fs_paths exactly when throw_if_gro_packages_changed is set.

invalidate
#

sveltekit_shim_app_navigation.ts view source

(resource: string | URL | ((url: URL) => boolean), keepState?: boolean | undefined) => Promise<void> import {invalidate} from '@fuzdev/gro/sveltekit_shim_app_navigation.js';

invalidateAll
#

invoke_cli
#

invoke_task.ts view source

(fs_paths: FsPaths, task_args: CliTaskArgs, config: GroConfig, raw_rest_args: readonly string[]): Promise<void> import {invoke_cli} from '@fuzdev/gro/invoke_task.js';

Invokes what the CLI's args name: gro lists the builtins and usage, importing no task module; gro <name> runs a builtin; gro task lists the project's tasks under src/, importing each; gro task <dir> lists the tasks under dir; gro task <path> runs the task file at path. A path without gro task is an error with a hint, as listing is never a fallthrough.

fs_paths

opens the paths the args name, passed to the task it invokes

type FsPaths

task_args

the parsed CLI args

config

the Gro configuration

raw_rest_args

the CLI args from the first -- on, from to_raw_rest_args

type readonly string[]

returns

Promise<void>

invoke_task
#

invoke_task.ts view source

(task_name: string, args: Args | undefined, options: InvokeTaskOptions): Promise<void> import {invoke_task} from '@fuzdev/gro/invoke_task.js';

Invokes a task by builtin name or by path.

A name always means one of Gro's builtins, so a project task never shadows one. A path, an input containing a / or ending in .task.ts or .task.js, always means a task file, relative to the cwd (the project root) or absolute, and must end in a task suffix. The task is displayed, and its forwarded args keyed, by its builtin name or its path relative to the project root, like gro check -- gro task src/x.task.ts --a. Nothing is searched for: a bare name that's not a builtin is an error.

task_name

a builtin name or a task path

type string

args

the CLI args to pass to the task

type Args | undefined

options

the config and what the invoking task shares

returns

Promise<void>

InvokeTask
#

task.ts view source

InvokeTask import type {InvokeTask} from '@fuzdev/gro/task.js';

Invokes a task: a name always means a builtin, and a path always means a task file, relative to the cwd and ending in .task.ts or .task.js.

Literal names and paths are checked against TaskRegistry and args against the task's Args schema input. A literal task path not in the registry, or a name widened to string, takes loose Args.

(call)

type <TName extends string>(task_name: InvokeTaskName<TName>, ...rest: InvokeTaskRest<TName>): Promise<void>

task_name

type InvokeTaskName<TName>

rest

type InvokeTaskRest<TName>
returns Promise<void>

InvokeTaskArgs
#

task.ts view source

InvokeTaskArgs<TName>

type TaskPathNormalized<TName> extends infer TKey extends TaskName ? TaskArgsInput<TKey> : Args

import type {InvokeTaskArgs} from '@fuzdev/gro/task.js';

The args InvokeTask accepts for TName: the input type of the registered task's Args schema, keyed by its name or normalized path, or loose Args for a task not in the registry.

generics

InvokeTaskArgs<TName extends string>
TName
constraint string

InvokeTaskContextOptions
#

task.ts view source

InvokeTaskContextOptions import type {InvokeTaskContextOptions} from '@fuzdev/gro/task.js';

The options a task's invoke_task takes, after the task name and args.

config?

The config the invoked task runs with, defaults to the invoking task's. The invoked task still shares the invoking task's graph, so this config's watch doesn't apply.

type GroConfig

InvokeTaskName
#

task.ts view source

InvokeTaskName<TName>

type string extends TName ? TName : TName extends "run" | `${string}.task.ts` | `${string}.task.js` | "build" | "changeset" | "check" | "clean" | "commit" | "deploy" | "dev" | "format" | "gen" | "lint" | "publish" | "reinstall" | "release" | "sync" | "test" | "typecheck" | "upgrade" ? TName : TaskName

import type {InvokeTaskName} from '@fuzdev/gro/task.js';

A literal must be in TaskRegistry or be a task file path, a widened string passes through.

generics

InvokeTaskName<TName extends string>
TName
constraint string

InvokeTaskOptions
#

invoke_task.ts view source

InvokeTaskOptions import type {InvokeTaskOptions} from '@fuzdev/gro/invoke_task.js';

What invoke_task runs a task with, after the task name and args.

config

The Gro configuration.

type GroConfig

fs_paths

Opens the task's path and the paths of the hints for a missing one, built by the composition root and passed to nested tasks.

type FsPaths

raw_rest_args

The CLI args from the first -- on, from to_raw_rest_args, passed to nested tasks. The gro sections in them forward args to Gro tasks; a task forwarding to an outside tool reads that tool's section from process.args itself.

type readonly string[]

graph?

The graph from the invoking task, created from config.watch and closed on finish when absent. A nested task gets its invoking task's even when invoked with its own config, so its config.watch is ignored.

type ModuleGraph

timings?

The invoking task's timings, shared by nested tasks; absent for the top-level task, which creates them and prints them on success. The CLI passes its own for gro run, which prints none, like node.

type Timings

parent_log?

The invoking task's logger, which labels this task's logger as its child.

type Logger

InvokeTaskRest
#

task.ts view source

InvokeTaskRest<TName>

type {} extends InvokeTaskArgs<TName> ? [args?: InvokeTaskArgs<TName> | undefined, options?: InvokeTaskContextOptions | undefined] : [args: InvokeTaskArgs<TName>, options?: InvokeTaskContextOptions | undefined]

import type {InvokeTaskRest} from '@fuzdev/gro/task.js';

Makes args required when the task's Args has required fields.

generics

InvokeTaskRest<TName extends string>
TName
constraint string

is_build_cache_valid
#

build_cache.ts view source

({ fs_paths, log, git }: BuildCacheDeps, config: GroConfig, options: BuildCacheKeyOptions): Promise<boolean> import {is_build_cache_valid} from '@fuzdev/gro/build_cache.js';

Main function to check if the build cache is valid. Returns true if the cached build can be used, false if a fresh build is needed.

__0

config

Gro config

options

returns

Promise<boolean>

is_builtin_task_name
#

task.ts view source

(name: string): name is keyof GroBuiltinTasks import {is_builtin_task_name} from '@fuzdev/gro/task.js';

Whether name is one of Gro's builtin tasks.

name

type string

returns

boolean

is_etarget_error
#

npm_install_helpers.ts view source

(message: string, stderr: string): boolean import {is_etarget_error} from '@fuzdev/gro/npm_install_helpers.js';

Checks if an npm install failure is caused by stale cache (ETARGET).

Detects the several shapes npm uses for "the requested version isn't there": code ETARGET, ETARGET, notarget, and No matching version found.

message

the short outcome string (e.g. code 1)

type string

stderr

the captured stderr of the failed command

type string

returns

boolean

true when the failure looks like an ETARGET-class staleness error

is_fs_error
#

fs_error.ts view source

(error: unknown, kind?: FsErrorKind | undefined): error is FsError import {is_fs_error} from '@fuzdev/gro/fs_error.js';

Whether error is an FsError from any copy of Gro, optionally of one kind.

error

any thrown value

type unknown

kind?

when given, the kind the error must have

optional

returns

boolean

is_gen_path
#

gen.ts view source

(path: string): boolean import {is_gen_path} from '@fuzdev/gro/gen.js';

Tests whether a path names a genfile by its file name, so a directory like my.gen.x/ doesn't make every file under it a genfile.

path

type string

returns

boolean

is_gro_id
#

paths.ts view source

(id: PathId): boolean import {is_gro_id} from '@fuzdev/gro/paths.js';

id

type PathId

returns

boolean

is_net_error
#

net_error.ts view source

(error: unknown, kind?: "not_granted" | undefined): error is NetError import {is_net_error} from '@fuzdev/gro/net_error.js';

Whether error is a NetError from any copy of Gro, optionally of one kind.

error

any thrown value

type unknown

kind?

when given, the kind the error must have

type "not_granted"
optional

returns

boolean

is_own_fs_error
#

fs_error.ts view source

internal

(value: unknown): value is FsError import {is_own_fs_error} from '@fuzdev/gro/fs_error.js';

Whether value is an FsError made by this copy of the module, by its private brand, so classifying an error mid-op runs no caller's code, as instanceof would through a Symbol.hasInstance or a proxy's getPrototypeOf. For the host module's own ops; other code matches errors with is_fs_error.

value

any value

type unknown

returns

boolean

is_path_specifier
#

resolve_specifier.ts view source

(specifier: string): boolean import {is_path_specifier} from '@fuzdev/gro/resolve_specifier.js';

Whether an import specifier is a path, relative or absolute, as Node reads one: ./, ../, or / starting it, or exactly . or ... Anything else, like '.hidden.ts', is bare and resolves as a package.

specifier

an import specifier

type string

returns

boolean

is_process_error
#

process_error.ts view source

(error: unknown, kind?: ProcessErrorKind | undefined): error is ProcessError import {is_process_error} from '@fuzdev/gro/process_error.js';

Whether error is a ProcessError from any copy of Gro, optionally of one kind.

error

any thrown value

type unknown

kind?

when given, the kind the error must have

optional

returns

boolean

is_silent_error
#

task.ts view source

(error: unknown): error is SilentError import {is_silent_error} from '@fuzdev/gro/task.js';

Whether error is a SilentError or a subclass of one, from any copy of Gro.

error

type unknown

returns

boolean

is_spawn_error
#

spawn_error.ts view source

(error: unknown, kind?: SpawnErrorKind | undefined): error is SpawnError import {is_spawn_error} from '@fuzdev/gro/spawn_error.js';

Whether error is a SpawnError from any copy of Gro, optionally of one kind.

error

any thrown value

type unknown

kind?

when given, the kind the error must have

optional

returns

boolean

is_task_error
#

task.ts view source

(error: unknown): error is TaskError import {is_task_error} from '@fuzdev/gro/task.js';

Whether error is a TaskError or a subclass of one, from any copy of Gro.

error

type unknown

returns

boolean

is_task_path
#

task.ts view source

(path: string): boolean import {is_task_path} from '@fuzdev/gro/task.js';

Whether path ends in a task file suffix, .task.ts or .task.js.

path

type string

returns

boolean

is_task_path_input
#

task.ts view source

(input: string): boolean import {is_task_path_input} from '@fuzdev/gro/task.js';

Whether a task input names a path rather than a builtin: it contains a / or ends in a task file suffix. Anything else is a builtin name, never looked up on the filesystem.

input

type string

returns

boolean

IS_THIS_GRO
#

JS_MATCHER
#

JSON_MATCHER
#

LIB_DIR
#

LIB_DIRNAME
#

constants.ts view source

"lib" import {LIB_DIRNAME} from '@fuzdev/gro/constants.js';

The library directory - SvelteKit has no files.lib option, so it's always here. Lives here rather than in ./paths.ts because it's a constant that reads no config.

LIB_PATH
#

library_cache_key
#

library_load.ts view source

({ fs_paths, git }: LibraryLoadDeps, repo_dir: string): Promise<string | null> import {library_cache_key} from '@fuzdev/gro/library_load.js';

Computes the cache key for a repo at repo_dir: the git HEAD commit hash.

Returns null (uncacheable โ€” analysis still runs, caching is skipped) when the dir is missing, or not a git repo, OR when the working tree is dirty. A dirty tree is deliberately uncacheable: the commit hash doesn't capture uncommitted edits, so a single -dirty key would serve a stale analysis across successive edits. Skipping the cache while dirty guarantees fresh metadata; clean commits cache.

A repo git can't read (a corrupt index, dubious ownership) or a stopped read is also null: the status isn't known, so its analysis runs fresh, and one unreadable sibling repo in a scan doesn't fail the scan.

__0

repo_dir

type string

returns

Promise<string | null>

library_cache_read
#

library_load.ts view source

(fs_paths: FsPaths, cache_path: string, key: string, log?: Logger | undefined): Promise<LibraryLoadResult | null> import {library_cache_read} from '@fuzdev/gro/library_load.js';

Reads and validates the .gro/library.json cache at cache_path.

Returns the cached {library_json, package_json} only when the file exists, its stored hash matches key, and its version and svelte_docinfo_version stamps match the current LIBRARY_CACHE_VERSION and SVELTE_DOCINFO_VERSION. Returns null on every miss - absent, stale (different hash or stamps), or unreadable/corrupt - signalling the caller to re-analyze.

fs_paths

opens the cache file, following its symlinks

type FsPaths

cache_path

absolute path to the cache file

type string

key

the expected cache key (a clean git commit hash)

type string

log?

type Logger
optional

returns

Promise<LibraryLoadResult | null>

the cached result, or null on any miss

LIBRARY_CACHE_VERSION
#

library_load.ts view source

2 import {LIBRARY_CACHE_VERSION} from '@fuzdev/gro/library_load.js';

Format version for the .gro/library.json cache. The cache key is the git commit hash, which does NOT change when the cached *shape* changes โ€” so bump this whenever LibraryCache's shape changes (e.g. the LibraryJson / PkgJson split, then slimming LibraryJson to the raw pkg_json/source_json pair) to self-invalidate stale caches across the ecosystem rather than serve old-shaped data at an unchanged commit. Upstream analyzer changes need no bump: each record also stamps SVELTE_DOCINFO_VERSION and self-invalidates when the installed svelte-docinfo moves.

library_cache_write
#

library_load.ts view source

(fs_paths: FsPaths, cache_path: string, key: string, result: LibraryLoadResult, log?: Logger | undefined): Promise<void> import {library_cache_write} from '@fuzdev/gro/library_load.js';

Writes result to the .gro/library.json cache at cache_path, keyed by key and stamped with the current LIBRARY_CACHE_VERSION and SVELTE_DOCINFO_VERSION, creating the parent directory as needed.

Best effort: caching is optional, so write failures are logged as a warning and swallowed rather than thrown.

fs_paths

makes the cache's directory and writes the file, following their symlinks

type FsPaths

cache_path

absolute path to the cache file

type string

key

the cache key to store (a clean git commit hash)

type string

result

the {library_json, package_json} to cache

log?

type Logger
optional

returns

Promise<void>

library_load_from_repo
#

library_load.ts view source

(deps: LibraryLoadDeps, repo_dir: string, options?: LibraryLoadOptions | undefined): Promise<LibraryLoadResult> import {library_load_from_repo} from '@fuzdev/gro/library_load.js';

Loads a repo's library metadata via svelte-docinfo, with a .gro cache keyed by git hash.

Analyzes repo_dir with analyzeFromFiles and combines the result with the repo's package.json into a LibraryJson, returned alongside the full package.json. Results are cached at <repo_dir>/.gro/library.json keyed by the current git HEAD, so repeated loads at the same commit skip the (potentially slow) analysis. A dirty working tree (or a non-git dir) is uncacheable, so analysis re-runs on every load until the changes are committed - see library_cache_key.

Refuses to analyze a repo whose tsconfig.json extends $app/tsconfig but that hasn't been synced (see sveltekit_tsconfig_is_unsynced): its analysis would read external types as any. The check runs only on a cache miss - a cache hit is served as written. svelte-docinfo logs to a child of log labelled with the repo dir's name: its diagnostics as warnings and errors, its progress at debug level.

The repo's files are read through fs_paths by path, not beneath a handle on the repo, so a package.json, tsconfig.json, or .gro symlinked from outside the repo is followed.

deps

fs_paths reads the repo's files and the cache, from the caller's root, and git reads the commit and status of the repo for the cache key

repo_dir

absolute path to the repo to analyze

type string

options?

optional

returns

Promise<LibraryLoadResult>

the repo's LibraryLoadResult (library_json + full package_json)

throws

  • Error - if the repo extends `$app/tsconfig` without `node_modules/$app/tsconfig.json` - install its dependencies if needed, then run `gro sync` in it

LibraryCache
#

LibraryLoadDeps
#

library_load.ts view source

LibraryLoadDeps import type {LibraryLoadDeps} from '@fuzdev/gro/library_load.js';

What loading a repo's library reaches: its files, and git to read its cache key.

fs_paths

type FsPaths

git

Reads only, so to_git_program(spawn, {pass_env: GIT_LOCAL_PASS_ENV}) is enough.

type SpawnProgram

LibraryLoadOptions
#

library_load.ts view source

LibraryLoadOptions import type {LibraryLoadOptions} from '@fuzdev/gro/library_load.js';

log?

type Logger

cache?

Set to false to bypass the .gro cache (always re-analyze, but still write the result).

type boolean

LibraryLoadResult
#

library_load.ts view source

LibraryLoadResult import type {LibraryLoadResult} from '@fuzdev/gro/library_load.js';

Result of loading a repo's library metadata: the curated LibraryJson (carrying the publish-safe pkg_json) plus the repo's full package.json.

The full package_json is kept alongside โ€” not folded into LibraryJson โ€” because tooling like fuz_gitops needs dependencies/devDependencies, which the curated LibraryJson.pkg_json deliberately omits.

library_json

type LibraryJson

package_json

type PackageJson

load_build_cache_dependencies
#

build_cache_dependencies.ts view source

(fs_paths: FsPaths, runtime_version: string): Promise<BuildCacheDependencies> import {load_build_cache_dependencies} from '@fuzdev/gro/build_cache_dependencies.js';

Reads the build inputs outside git that the build cache key folds in.

fs_paths

opens the project's node_modules/

type FsPaths

runtime_version

the running runtime's name and version, like process.runtime_version

type string

returns

Promise<BuildCacheDependencies>

load_build_cache_metadata
#

build_cache.ts view source

(fs_paths: FsPaths): Promise<{ version: string; git_commit: string | null; build_cache_config_hash: string; gro_version: string; runtime_version: string; package_lock_hash: string | null; timestamp: string; outputs: { ...; }[]; } | null> import {load_build_cache_metadata} from '@fuzdev/gro/build_cache.js';

Loads build cache metadata from .gro/ directory. A cache file that's read but invalid (corrupt, the wrong shape, or an old version) is deleted, the file entry itself, never what a symlink there points at; one that can't be read is left in place.

fs_paths

opens the project's .gro/

type FsPaths

returns

Promise<BuildCacheMetadata | null>

load_default_svelte_config
#

svelte_config.ts view source

(): Promise<ParsedSvelteConfig> import {load_default_svelte_config} from '@fuzdev/gro/svelte_config.js';

The parsed Svelte config for the project in the cwd, memoized.

Reading it costs a full Vite config resolution, which runs every Vite plugin's config hooks, so callers pull it in on demand instead of paying for it on every Gro invocation.

returns

Promise<ParsedSvelteConfig>

load_env
#

env.ts view source

(fs_paths: FsPaths, { dev, env_dir, env_files, ambient_env }: LoadEnvOptions): Promise<Record<string, string>> import {load_env} from '@fuzdev/gro/env.js';

Loads every env var from the env files plus the ambient env, later sources winning, so the ambient env overrides the files. A missing env file is skipped; one that can't be read throws.

fs_paths

reads the env files, a relative env_dir or file resolved against its project

type FsPaths

__1

returns

Promise<Record<string, string>>

all loaded vars, unfiltered - resolve_env_vars picks out the declared ones

throws

  • `FsError` - when reading an env file fails other than by its absence

load_env_file
#

env.ts view source

(fs_paths: FsPaths, path: string): Promise<Record<string, string> | null> import {load_env_file} from '@fuzdev/gro/env.js';

Loads one env file's vars, parsed as dotenv, without merging them into anything.

fs_paths

reads the file, a relative path resolved against its project

type FsPaths

path

absolute, or relative to the project

type string

returns

Promise<Record<string, string> | null>

the file's vars, or null when the file doesn't exist

throws

  • `FsError` - when reading the file fails other than by its absence

load_from_env
#

env.ts view source

(fs_paths: FsPaths, ambient_env: Readonly<Record<string, string | undefined>>, key: string, paths?: string[]): Promise<string | undefined> import {load_from_env} from '@fuzdev/gro/env.js';

Loads a single env value without merging it into the ambient env. Searches ambient_env, then each of paths that exists, by default only the project's .env - never a parent directory's, so one directory's .env isn't a secret channel to every repo under it. Empty strings are semantically the same as undefined for more ergonomic fallbacks.

fs_paths

reads the env files, a relative path resolved against its project

type FsPaths

ambient_env

a plain record a root builds, needing only key

type Readonly<Record<string, string | undefined>>

key

type string

paths?

absolute, or relative to the project

type string[]
optional default ['.env']

returns

Promise<string | undefined>

throws

  • `FsError` - when reading one of `paths` fails other than by its absence

load_genfiles
#

gen.ts view source

(found_genfiles: FoundGenfiles, timings?: Timings | undefined): Promise<LoadGenfilesResult> import {load_genfiles} from '@fuzdev/gro/gen.js';

found_genfiles

timings?

type Timings
optional

returns

Promise<LoadGenfilesResult>

load_gro_config
#

gro_config.ts view source

(fs_paths: FsPaths, dir?: string): Promise<GroConfig> import {load_gro_config} from '@fuzdev/gro/gro_config.js';

Loads the project's gro.config.ts, or the default config when there's none.

fs_paths

checks for the config file

type FsPaths

dir?

the directory holding gro.config.ts, defaults to the project of fs_paths

type string
optional default fs_paths.project.path

returns

Promise<GroConfig>

load_module
#

modules.ts view source

<TModule extends Record<string, any>>(id: PathId, validate?: ((mod: Record<string, any>) => mod is TModule) | undefined): Promise<LoadModuleResult<TModule>> import {load_module} from '@fuzdev/gro/modules.js';

id

type PathId

validate?

type (mod: Record<string, any>) => mod is TModule
optional

returns

Promise<LoadModuleResult>

generics

load_module<TModule extends Record<string, any>>
TModule
constraint Record<string, any>

load_modules
#

modules.ts view source

<TModule extends Record<string, any>, TModuleMeta extends ModuleMeta<TModule>>(resolved_input_files: ResolvedInputFile[], validate: (mod: any) => mod is TModule, map_module_meta: (resolved_input_file: ResolvedInputFile, mod: TModule) => TModuleMeta, timings?: Timings | undefined): Promise<...> import {load_modules} from '@fuzdev/gro/modules.js';

resolved_input_files

validate

type (mod: any) => mod is TModule

map_module_meta

type (resolved_input_file: ResolvedInputFile, mod: TModule) => TModuleMeta

timings?

type Timings
optional

returns

Promise<LoadModulesResult>

generics

load_modules<TModule extends Record<string, any>, TModuleMeta extends ModuleMeta<TModule>>
TModule
constraint Record<string, any>
TModuleMeta
constraint ModuleMeta<TModule>

load_svelte_config
#

svelte_config.ts view source

(): Promise<Config | null> import {load_svelte_config} from '@fuzdev/gro/svelte_config.js';

Loads the Svelte config of the project in the cwd by resolving its Vite config.

returns

Promise<Config | null>

null if the project has no Vite config, or one that configures no Svelte plugin

throws

  • if - the project has a Vite config but Vite isn't installed, or if it fails to resolve

load_sveltekit_env_declarations
#

sveltekit_shim_app_env_vars.ts view source

(entry_id: string): Promise<EnvVarDeclarations> import {load_sveltekit_env_declarations} from '@fuzdev/gro/sveltekit_shim_app_env_vars.js';

Imports the variables declared in a project's env entry module. The shims render static exports, so the declared names are needed before rendering - the values aren't, those resolve when the rendered module runs.

entry_id

the env declarations module, from resolve_sveltekit_env_entry

type string

returns

Promise<EnvVarDeclarations>

throws

  • if - the entry doesn't export a `variables` object, or declares an invalid name

load_task
#

task.ts view source

(id: PathId, name: string): Promise<LoadTaskResult> import {load_task} from '@fuzdev/gro/task.js';

Imports the task module at id, displayed as name.

id

type PathId

name

type string

returns

Promise<LoadTaskResult>

LoadedGenfiles
#

LoadEnvOptions
#

env_declarations.ts view source

LoadEnvOptions import type {LoadEnvOptions} from '@fuzdev/gro/env_declarations.js';

dev

Picks the development or production mode files for the default env_files.

type boolean

env_dir?

The directory the env files are resolved against, absolute or relative to the project of the FsPaths that reads them, defaults to the project.

type string

env_files?

The env files to load, in order, defaults to the same files as Vite.

type string[]

ambient_env

The env merged in last, a plain record a root builds, like process.env.get_all().

type Readonly<Record<string, string | undefined>>

LoadGenfilesFailure
#

LoadGenfilesResult
#

gen.ts view source

LoadGenfilesResult

type ({ ok: true; } & { value: LoadedGenfiles; }) | ({ ok: false; } & LoadGenfilesFailure)

import type {LoadGenfilesResult} from '@fuzdev/gro/gen.js';

LoadModuleFailure
#

modules.ts view source

LoadModuleFailure

type { ok: false; type: "failed_import"; id: PathId; error: Error; } | { ok: false; type: "failed_validation"; id: PathId; mod: Record<string, any>; validation: string; }

import type {LoadModuleFailure} from '@fuzdev/gro/modules.js';

LoadModuleResult
#

modules.ts view source

LoadModuleResult<TModule>

type ({ ok: true; } & { id: PathId; mod: TModule; }) | (({ ok: false; } & { ok: false; type: "failed_import"; id: PathId; error: Error; }) | ({ ok: false; } & { ok: false; type: "failed_validation"; id: PathId; mod: Record<string, any>; validation: string; }))

import type {LoadModuleResult} from '@fuzdev/gro/modules.js';

generics

LoadModuleResult<TModule>
TModule

LoadModulesFailure
#

modules.ts view source

LoadModulesFailure<TModuleMeta> import type {LoadModulesFailure} from '@fuzdev/gro/modules.js';

generics

LoadModulesFailure<TModuleMeta extends ModuleMeta>
TModuleMeta
constraint ModuleMeta

type

type "load_module_failures"

load_module_failures

type LoadModuleFailure[]

reasons

type string[]

modules

type TModuleMeta[]

LoadModulesResult
#

modules.ts view source

LoadModulesResult<TModuleMeta>

type ({ ok: true; } & { modules: TModuleMeta[]; }) | ({ ok: false; } & LoadModulesFailure<TModuleMeta>)

import type {LoadModulesResult} from '@fuzdev/gro/modules.js';

generics

LoadModulesResult<TModuleMeta extends ModuleMeta>
TModuleMeta
constraint ModuleMeta

LoadTaskResult
#

task.ts view source

LoadTaskResult

type ({ ok: true; } & { value: TaskModuleMeta; }) | ({ ok: false; } & { reason: string; })

import type {LoadTaskResult} from '@fuzdev/gro/task.js';

A loaded task module, or why it didn't load.

LOCKFILE_FILENAME
#

log_builtin_tasks
#

task_logging.ts view source

(log: Logger): void import {log_builtin_tasks} from '@fuzdev/gro/task_logging.js';

Logs Gro's builtin tasks with their summaries and the CLI's usage, from the generated summaries, so it imports no task module.

log

type Logger

returns

void

log_error_reasons
#

task_logging.ts view source

(log: Logger, reasons: string[]): void import {log_error_reasons} from '@fuzdev/gro/task_logging.js';

Logs each of reasons as an error, in red, the way failures are reported to the user.

log

the logger to report through

type Logger

reasons

the messages, one logged per call

type string[]

returns

void

log_task_help
#

task_logging.ts view source

(log: Logger, meta: TaskModuleMeta): void import {log_task_help} from '@fuzdev/gro/task_logging.js';

Logs a task's --help: its command, summary, and each arg of its Args schema with the arg's type, default, and description.

log

the logger to print to

type Logger

meta

the loaded task module

returns

void

log_tasks
#

task_logging.ts view source

(log: Logger, modules: TaskModuleMeta[], dir_label: string): void import {log_tasks} from '@fuzdev/gro/task_logging.js';

Logs the tasks found in a directory with their summaries, and how to run them.

log

the logger

type Logger

modules

the loaded tasks, named by their paths relative to the project root

dir_label

the directory searched, as displayed

type string

returns

void

map_child_process_output
#

child_process_logging.ts view source

(child: SpawnChild, transform: (data: string) => string, targets: ChildOutputTargets): Promise<void> import {map_child_process_output} from '@fuzdev/gro/child_process_logging.js';

Maps a child's piped output through a transform function to targets, chunk by chunk, decoding each stream as UTF-8 across chunk boundaries. Each write is awaited, so a slow reader paces the child.

child

transform

type (data: string) => string

targets

where the output goes, process.stdout and process.stderr at a root

returns

Promise<void>

a promise that resolves once both streams have ended and been written

match
#

sveltekit_shim_app_paths.ts view source

(url: string | URL): Promise<{ id: "/"; params: Record<string, never>; } | { id: "/about"; params: Record<string, never>; } | { id: "/docs"; params: Record<string, never>; } | ... 4 more ... | null> import {match} from '@fuzdev/gro/sveltekit_shim_app_paths.js';

url

type URL | string

returns

Promise<{ id: "/"; params: Record<string, never>; } | { id: "/about"; params: Record<string, never>; } | { id: "/docs"; params: Record<string, never>; } | { id: "/docs/api"; params: Record<string, never>; } | { id: "/docs/api/[...module_path]"; params: { module_path: string; }; } | { id: "/docs/introduction"; params: Record<string, never>; } | { id: "/history"; params: Record<string, never>; } | null>

merge_forwarded_args
#

args.ts view source

(args: Args | undefined, forwarded: Args): Args import {merge_forwarded_args} from '@fuzdev/gro/args.js';

Merges forwarded args over args, moving each forwarded key after every key of args. args_parse resolves a no-x pair given both ways to the later key, so a forwarded --color overrides a direct -C (an alias of no-color), where a spread keeps the overridden key at its original position. Keys match by spelling, not by schema alias, so a forwarded alias (-n) doesn't displace a direct canonical key (--name), which args_parse prefers.

args

the direct args, if any, not mutated

type Args | undefined

forwarded

the args forwarded to this command, which win over args

type Args

returns

Args

a new object with the keys of args not in forwarded, then the keys of forwarded

ModuleGraph
#

module_graph.ts view source

ModuleGraph import type {ModuleGraph} from '@fuzdev/gro/module_graph.js';

The project's module graph: which files exist under the watched directory and which import which. Tasks and plugins get one on their context. Queries load the graph on first use, and close tears it down for good. A load that fails stays failed: later queries reject with the same error.

modules

Gets the ids of the project modules that exist on disk.

type (filter?: ((id: PathId) => boolean) | undefined): Promise<PathId[]>

filter?

narrows the results

type (id: PathId) => boolean
optional
returns Promise<PathId[]>

dependents

Gets every module that imports id, directly or transitively. The filter narrows the results, not the traversal. A file reached by a bare specifier is never read, so its imports aren't edges.

type (id: PathId, filter?: ((id: PathId) => boolean) | undefined): Promise<Set<PathId>>

id

the module whose dependents to find

type PathId

filter?

narrows the results

type (id: PathId) => boolean
optional
returns Promise<Set<PathId>>

the dependents, including of an imported path that doesn't exist yet; empty when nothing imports id

watch

Subscribes to changes of project modules, first calling on_change with an add for each module already in the graph. Changes are content-based, so saving a file unchanged emits nothing.

type (on_change: FileChangeCallback): Promise<() => Promise<void>>

on_change

called for each change

returns Promise<() => Promise<void>>

a function that unsubscribes

close

Stops watching and drops the graph. A graph that never loaded closes without loading. Closing is permanent: later queries and watches reject, as do any pending when it's called. A watch pending when it's called may already have delivered its initial adds before rejecting. Every call returns the same teardown, so an awaited close means fully closed.

type (): Promise<void>

returns Promise<void>

ModuleMeta
#

modules.ts view source

ModuleMeta<TModule> import type {ModuleMeta} from '@fuzdev/gro/modules.js';

generics

ModuleMeta<TModule extends Record<string, any> = Record<string, any>>
TModule
constraint Record<string, any>
default Record<string, any>

id

type PathId

mod

type TModule

navigating
#

net
#

net.ts view source

Net import {net} from '@fuzdev/gro/net.js';

The net host module's root handle. Import it where authority enters (a task, a script, an entry module) and hand a narrower net.narrow({hosts}) down.

Net
#

net.ts view source

Net import type {Net} from '@fuzdev/gro/net.js';

The network, reached through a handle bound to its hosts.

fetch

fetch, bound to this handle's hosts: an own frozen closure, so it destructures and hands down as a bare function, and it's assignable to typeof globalThis.fetch. Redirects are followed by this handle, each Location checked before anything is sent to it. A caller's redirect: 'manual' or 'error' passes through unchanged, so a manual caller sees the response and decides.

type (input: string | Request | URL, init?: RequestInit | undefined): Promise<Response>

readonly

input

type string | URL | Request

init?

type RequestInit
optional
returns Promise<Response>

throws

  • `NetError` - `not_granted`, a host outside this handle's set, or a scheme other than `http:` and `https:`, on the first request or a redirect
  • `TypeError` - a network failure, an invalid `Location`, more than 20 redirects, or a redirect that can't replay a stream body

narrow

A handle limited to hosts, as env.narrow limits names. It can only shrink: a narrower one holds hostname:port beneath a hostname it's allowed, never the reverse.

type (options: NetNarrowOptions): Net

options

returns Net

throws

  • `TypeError` - for a host that isn't exact: `*`, a scheme, a path, or a value `URL` refuses
  • `NetError` - `not_granted`, a host this handle doesn't allow

NetError
#

net_error.ts view source

import {NetError} from '@fuzdev/gro/net_error.js';

The error net.ts throws when a request is refused before it's sent, typed by kind. Match it with is_net_error, which also recognizes one from another copy of Gro. The class and its prototype are frozen.

inheritance

extends: Error

name

type string

kind

type "not_granted"

readonly

target

What was refused: a host as hostname:port, or a scheme like data:. Never the whole URL, which can carry a token.

type string

readonly

constructor

type new (kind: "not_granted", target: string, message?: string | undefined, options?: ErrorOptions | undefined): NetError

kind

type "not_granted"

target

type string

message?

type string
optional

options?

type ErrorOptions
optional

NetErrorKind
#

net_error.ts view source

"not_granted" import type {NetErrorKind} from '@fuzdev/gro/net_error.js';

Why a request was refused. not_granted is a host outside what the handle allows, or a scheme other than http: and https:, on the first request or a redirect. A failure of the network itself is a TypeError, as from any fetch.

NetNarrowOptions
#

net.ts view source

NetNarrowOptions import type {NetNarrowOptions} from '@fuzdev/gro/net.js';

The options of narrow.

hosts

The hosts the new handle reaches, each hostname (any port) or hostname:port. An empty list reaches nothing.

type readonly string[]

NODE_MODULES_DIRNAME
#

NodeModuleGraphOptions
#

module_graph_node.ts view source

NodeModuleGraphOptions import type {NodeModuleGraphOptions} from '@fuzdev/gro/module_graph_node.js';

watch

What the graph watches, usually GroConfig.watch.

type WatchOptions

log?

The logger the graph reports through, like a file whose imports fail to parse, which also warns of a watch error, like EACCES reading a directory; absent, a watch error warns through console, and so does a failure processing a change, like an unexpected read error.

type Logger

normalize_gen_config
#

gen.ts view source

(gen: Gen, id: PathId, root?: PathId): GenConfig import {normalize_gen_config} from '@fuzdev/gro/gen.js';

Normalizes a genfile's gen export to a GenConfig, validating its inputs.

gen

the genfile's gen export

type Gen

id

the genfile, named in the error

type PathId

root?

the project root that inputs patterns anchor at

type PathId
optional default paths.root

returns

GenConfig

throws

  • `TaskError` - for `inputs` that can never match as written, saying what to write instead

NPM_HIDDEN_LOCKFILE_PATH
#

build_cache_dependencies.ts view source

string import {NPM_HIDDEN_LOCKFILE_PATH} from '@fuzdev/gro/build_cache_dependencies.js';

npm's hidden lockfile, which records the packages installed in node_modules.

NpmCommandResult
#

npm_install_helpers.ts view source

NpmCommandResult import type {NpmCommandResult} from '@fuzdev/gro/npm_install_helpers.js';

Result of one install or cache-clean attempt.

ok

type boolean

stderr

captured stderr; the default runner also tees this live to the terminal

type string

detail

short human-readable outcome, e.g. code 1 or the SpawnError message

type string

NpmCommandRunner
#

npm_install_helpers.ts view source

NpmCommandRunner import type {NpmCommandRunner} from '@fuzdev/gro/npm_install_helpers.js';

Runs an npm-compatible command and reports ok plus captured stderr. Injected by install_with_cache_healing for testing; the default implementation spawns a real subprocess.

(call)

type (program: SpawnProgram, args: readonly string[], options?: { cwd?: FsReadDir | undefined; } | undefined): Promise<NpmCommandResult>

program

args

type readonly string[]

options?

type { cwd?: FsReadDir | undefined; }
optional
returns Promise<NpmCommandResult>

onNavigate
#

sveltekit_shim_app_navigation.ts view source

(callback: (navigation: (NavigationGoto & { type: "link" | "goto" | "form" | "popstate"; willUnload: false; }) | (NavigationFormSubmit & { type: "link" | "goto" | "form" | "popstate"; willUnload: false; }) | (NavigationPopState & { ...; }) | (NavigationLink & { ...; })) => MaybePromise<...>) => void import {onNavigate} from '@fuzdev/gro/sveltekit_shim_app_navigation.js';

PACKAGE_JSON_EMPTY
#

package_json.ts view source

{ name: string; description?: string | undefined; version?: string | undefined; type?: string | undefined; main?: string | undefined; private?: boolean | undefined; tagline?: string | undefined; ... 23 more ...; exports?: string | ... 2 more ... | undefined; } & Record<...>

type PackageJson

import {PACKAGE_JSON_EMPTY} from '@fuzdev/gro/package_json.js';

package_json_extract_dependencies
#

package_json.ts view source

(package_json: { name: string; description?: string | undefined; version?: string | undefined; type?: string | undefined; main?: string | undefined; private?: boolean | undefined; tagline?: string | undefined; ... 23 more ...; exports?: string | ... 2 more ... | undefined; } & Record<...>): PackageJsonDep[] import {package_json_extract_dependencies} from '@fuzdev/gro/package_json.js';

package_json

type PackageJson

returns

PackageJsonDep[]

PACKAGE_JSON_FILENAME
#

package_json_has_dependency
#

package_json.ts view source

(dep_name: string, package_json: { name: string; description?: string | undefined; version?: string | undefined; type?: string | undefined; main?: string | undefined; private?: boolean | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; } & Record<...>): boolean import {package_json_has_dependency} from '@fuzdev/gro/package_json.js';

Whether dep_name is a direct dependency, in dependencies or devDependencies. A peerDependencies entry doesn't count, since a peer dep declares what a package works alongside - a plugin package peered on @sveltejs/kit isn't itself a SvelteKit app.

dep_name

type string

package_json

type PackageJson

returns

boolean

package_json_load
#

package_json.ts view source

(fs_paths: FsPaths, dir?: string, cache?: Record<string, { name: string; description?: string | undefined; version?: string | undefined; type?: string | undefined; main?: string | undefined; ... 25 more ...; exports?: string | ... 2 more ... | undefined; } & Record<...>> | undefined, parse?: boolean, log?: Logger | undefined): Promise<...> import {package_json_load} from '@fuzdev/gro/package_json.js';

Loads the package.json in dir, or PACKAGE_JSON_EMPTY when it can't be read or parsed as JSON, or, when not parse, holds no object.

fs_paths

opens dir's package.json

type FsPaths

dir?

absolute, or relative to the project; defaults to the project of fs_paths

type string
optional default fs_paths.project.path

cache?

keyed by dir as given

type Record<string, PackageJson>
optional

parse?

whether to validate it against the PackageJson schema

type boolean
optional default true

log?

logs a failure to load, other than a missing file

type Logger
optional

returns

Promise<PackageJson>

throws

  • when - `parse` and the loaded JSON fails the schema

package_json_load_for_gro
#

package_json.ts view source

(): { name: string; description?: string | undefined; version?: string | undefined; type?: string | undefined; main?: string | undefined; private?: boolean | undefined; tagline?: string | undefined; ... 23 more ...; exports?: string | ... 2 more ... | undefined; } & Record<...> import {package_json_load_for_gro} from '@fuzdev/gro/package_json.js';

Loads the running Gro's own package.json through the module system, which resolves it from this module, so it needs no fs capability.

returns

PackageJson

throws

  • when - it fails the `PackageJson` schema

package_json_parse_repo_url
#

package_json.ts view source

(package_json: { name: string; description?: string | undefined; version?: string | undefined; type?: string | undefined; main?: string | undefined; private?: boolean | undefined; tagline?: string | undefined; ... 23 more ...; exports?: string | ... 2 more ... | undefined; } & Record<...>): { ...; } | undefined import {package_json_parse_repo_url} from '@fuzdev/gro/package_json.js';

package_json

type PackageJson

returns

{ owner: string; repo: string; } | undefined

package_json_serialize
#

package_json.ts view source

(package_json: { name: string; description?: string | undefined; version?: string | undefined; type?: string | undefined; main?: string | undefined; private?: boolean | undefined; tagline?: string | undefined; ... 23 more ...; exports?: string | ... 2 more ... | undefined; } & Record<...>): string import {package_json_serialize} from '@fuzdev/gro/package_json.js';

package_json

type PackageJson

returns

string

package_json_sync
#

package_json.ts view source

(fs_paths: FsPaths, map_package_json: PackageJsonMapper, log: Logger, write?: boolean, dir?: string, exports_dir?: string | undefined): Promise<{ package_json: ({ ...; } & Record<...>) | null; changed: boolean; }> import {package_json_sync} from '@fuzdev/gro/package_json.js';

Updates the exports of a SvelteKit library's package.json from the files in its lib directory, then applies map_package_json, writing only when the contents change.

fs_paths

opens package.json, the lib directory, and the directories the paths name

type FsPaths

map_package_json

maps the updated package.json, or returns null to leave it unchanged

log

logs the outcome

type Logger

write?

when false, reports whether it would change without writing

type boolean
optional default true

dir?

the directory holding package.json, absolute or relative to the project; defaults to the project of fs_paths

type string
optional default fs_paths.project.path

exports_dir?

the directory whose files become the exports, relative to the project (not to dir), defaults to LIB_PATH; the library check also reads the project's lib directory

type string
optional

returns

Promise<{ package_json: ({ name: string; description?: string | undefined; version?: string | undefined; type?: string | undefined; main?: string | undefined; private?: boolean | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; } & Record<...>) | null; changed: boolean; }>

package_json_to_exports
#

package_json.ts view source

(paths: string[]): string | Record<string, ExportValue> | null import {package_json_to_exports} from '@fuzdev/gro/package_json.js';

paths

type string[]

returns

PackageJsonExports

package_json_update
#

package_json.ts view source

(fs_paths: FsPaths, update: (package_json: { name: string; description?: string | undefined; version?: string | undefined; type?: string | undefined; main?: string | undefined; private?: boolean | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; } & Record<...>) => ({ ...; } & Record<...>) | ... 1 more ... | null, dir?: string, write?: boolean): Promise<...> import {package_json_update} from '@fuzdev/gro/package_json.js';

Updates the package.json in dir. Writes to the filesystem only when contents change.

fs_paths

opens the file

type FsPaths

update

maps the loaded JSON, or returns null to leave it unchanged

type (package_json: { name: string; description?: string | undefined; version?: string | undefined; type?: string | undefined; main?: string | undefined; private?: boolean | undefined; tagline?: string | undefined; ... 23 more ...; exports?: string | ... 2 more ... | undefined; } & Record<...>) => ({ ...; } & Record<...>...

dir?

absolute, or relative to the project; defaults to the project of fs_paths

type string
optional default fs_paths.project.path

write?

when false, reports whether it would change without writing

type boolean
optional default true

returns

Promise<{ package_json: ({ name: string; description?: string | undefined; version?: string | undefined; type?: string | undefined; main?: string | undefined; private?: boolean | undefined; ... 24 more ...; exports?: string | ... 2 more ... | undefined; } & Record<...>) | null; changed: boolean; }>

package_json_write
#

package_json.ts view source

(fs_paths: FsPaths, serialized_package_json: string, dir?: string): Promise<void> import {package_json_write} from '@fuzdev/gro/package_json.js';

Writes the package.json in dir.

fs_paths

opens the file

type FsPaths

serialized_package_json

the file's contents, as package_json_serialize makes them

type string

dir?

absolute, or relative to the project; defaults to the project of fs_paths

type string
optional default fs_paths.project.path

returns

Promise<void>

PackageJsonDep
#

package_json.ts view source

PackageJsonDep import type {PackageJsonDep} from '@fuzdev/gro/package_json.js';

name

type string

version

type string

PackageJsonMapper
#

package_json.ts view source

PackageJsonMapper import type {PackageJsonMapper} from '@fuzdev/gro/package_json.js';

(call)

type (package_json: { name: string; description?: string | undefined; version?: string | undefined; type?: string | undefined; main?: string | undefined; private?: boolean | undefined; tagline?: string | undefined; ... 23 more ...; exports?: string | ... 2 more ... | undefined; } & Record<...>): ({ ...; } & Record<...>) | ... 1 more ... | null

package_json

type PackageJson
returns PackageJson | Promise<PackageJson | null> | null

page
#

sveltekit_shim_app_state.ts view source

Page<{ module_path?: string | undefined; }, "/" | "/about" | "/docs" | "/docs/api" | "/docs/api/[...module_path]" | "/docs/introduction" | "/history" | null>

type Page<{ module_path?: string | undefined; }, "/" | "/about" | "/docs" | "/docs/api" | "/docs/api/[...module_path]" | "/docs/introduction" | "/history" | null>

import {page} from '@fuzdev/gro/sveltekit_shim_app_state.js';

parse_svelte_config
#

ParsedSvelteConfig
#

svelte_config.ts view source

ParsedSvelteConfig import type {ParsedSvelteConfig} from '@fuzdev/gro/svelte_config.js';

A subset of SvelteKit's config in a form that Gro uses. Flattens things out to keep them simple and easy to pass around, and doesn't deal with most properties, but includes the full svelte_config. The base and assets in particular are renamed for clarity with Gro's internal systems, so these properties become first-class vocabulary inside Gro.

svelte_config

type Config | null

base_url

type "" | `/${string}` | undefined

assets_url

type "" | `http://${string}` | `https://${string}` | undefined

routes_path

Same as the SvelteKit files.routes, relative to the project directory.

type string

src_path

Same as the SvelteKit files.src, relative to the project directory. The env declarations entry env.ts lives here.

type string

env_dir

type string | undefined

version_name

Same as the SvelteKit version.name, exposed as version by the $app/env shim.

type string | undefined

svelte_compile_options

type CompileOptions

svelte_compile_module_options

type ModuleCompileOptions

svelte_preprocessors

type PreprocessorGroup | PreprocessorGroup[] | undefined

ParseSvelteConfigOptions
#

svelte_config.ts view source

ParseSvelteConfigOptions import type {ParseSvelteConfigOptions} from '@fuzdev/gro/svelte_config.js';

svelte_config?

An already-loaded config to parse instead of resolving the project's Vite config.

type Config

paths
#

Paths
#

paths.ts view source

Paths import type {Paths} from '@fuzdev/gro/paths.js';

root

type string

source

type string

lib

type string

build

type string

Plugin
#

plugin.ts view source

Plugin<TPluginContext> import type {Plugin} from '@fuzdev/gro/plugin.js';

Gro Plugins enable custom behavior during gro dev and gro build. In contrast, Adapters use the results of gro build to produce final artifacts.

generics

Plugin<TPluginContext extends PluginContext = PluginContext>
TPluginContext
constraint PluginContext

name

type string

setup?

type (ctx: TPluginContext): void | Promise<void>

ctx

type TPluginContext
returns void | Promise<void>

adapt?

type (ctx: TPluginContext): void | Promise<void>

ctx

type TPluginContext
returns void | Promise<void>

teardown?

type (ctx: TPluginContext): void | Promise<void>

ctx

type TPluginContext
returns void | Promise<void>

PluginContext
#

plugin.ts view source

PluginContext<TArgs> import type {PluginContext} from '@fuzdev/gro/plugin.js';

generics

PluginContext<TArgs = object>
TArgs
default object

inheritance

extends: TaskContext<TArgs>

dev

type boolean

watch

type boolean

Plugins
#

plugin.ts view source

import {Plugins} from '@fuzdev/gro/plugin.js';

See Plugins.create for a usage example.

generics

Plugins<TPluginContext extends PluginContext>
TPluginContext
constraint PluginContext

ctx

type TPluginContext

readonly

instances

type Plugin<TPluginContext>[]

readonly

constructor

type new <TPluginContext extends PluginContext>(ctx: TPluginContext, instances: Plugin<PluginContext<object>>[]): Plugins<TPluginContext>

ctx

type TPluginContext

instances

type Plugin<PluginContext<object>>[]

create

type <TPluginContext extends PluginContext>(ctx: TPluginContext): Promise<Plugins<TPluginContext>>

static

ctx

type TPluginContext
returns Promise<Plugins<TPluginContext>>

setup

type (): Promise<void>

returns Promise<void>

adapt

type (): Promise<void>

returns Promise<void>

teardown

type (): Promise<void>

returns Promise<void>

PluginsCreateConfig
#

plugin.ts view source

PluginsCreateConfig<TPluginContext> import type {PluginsCreateConfig} from '@fuzdev/gro/plugin.js';

generics

PluginsCreateConfig<TPluginContext extends PluginContext = PluginContext>
TPluginContext
constraint PluginContext

(call)

type (ctx: TPluginContext): Plugin<TPluginContext>[] | Promise<Plugin<TPluginContext>[]>

ctx

type TPluginContext
returns Plugin<TPluginContext>[] | Promise<Plugin<TPluginContext>[]>

PM_CLI_DEFAULT
#

PossiblePath
#

preloadCode
#

sveltekit_shim_app_navigation.ts view source

(id: "/" | "/about" | "/docs" | "/docs/api" | "/docs/api/[...module_path]" | "/docs/introduction" | "/history") => Promise<void> import {preloadCode} from '@fuzdev/gro/sveltekit_shim_app_navigation.js';

preloadData
#

sveltekit_shim_app_navigation.ts view source

(href: string) => Promise<({ type: "loaded"; data: Record<string, any>; } | { type: "redirect"; location: string; } | { type: "error"; error: Error; }) & { status: number; }> import {preloadData} from '@fuzdev/gro/sveltekit_shim_app_navigation.js';

print_command_args
#

print_path
#

process
#

process.ts view source

Process import {process} from '@fuzdev/gro/process.js';

The process host module's root handle. Import it where authority enters (a task, a script, an entry module) and hand a narrower process.env.narrow(...) or plain records down.

Process
#

process.ts view source

Process import type {Process} from '@fuzdev/gro/process.js';

The running process.

env

The environment, a frozen handle, narrowed with env.narrow.

type Env

readonly

args

The arguments after the script, frozen. In the CLI's own process these are the CLI's, the task name included; a task reads its parsed args from its context.

type readonly string[]

readonly

cwd

The working directory when the module loaded, checked as for fs.project.

type (): string

returns string

exit

Exits with code, or without one the code from set_exit_code, else 0. Spawned children are cleaned up on the way out, by the spawn module's exit hook. Writes not yet accepted are dropped, so await a write before exiting.

type (code?: number | undefined): never

code?

an integer from 0 to 255

type number
optional
returns never

throws

  • `TypeError` - for any other value, without calling a thenable or a `toPrimitive`

set_exit_code

Sets the code the process exits with when it next ends on its own.

type (code: number): void

code

an integer from 0 to 255

type number
returns void

throws

  • `TypeError` - for any other value

stdin

Stdin. Iterating is once only and reads bytes as plain Uint8Array copies, a second iteration throwing TypeError. Leaving a loop early stops reading.

type ProcessInput

readonly

stdout

Stdout.

type ProcessOutput

readonly

stderr

Stderr.

type ProcessOutput

readonly

pid

The process's id, for display only: nothing in this module takes a pid.

type number

readonly

runtime_version

The runtime's name and version, opaque, like node/v24.14.0 here and fgro/0.1.0 on the runtime, for display and for keying caches by the runtime that made them. Compare it for equality only; a program that branches on it is one this module can't serve.

type string

readonly

ProcessError
#

process_error.ts view source

import {ProcessError} from '@fuzdev/gro/process_error.js';

The error process.ts throws, typed by kind. Match it with is_process_error, which also recognizes one from another copy of Gro. The class and its prototype are frozen.

inheritance

extends: Error

name

type string

kind

type ProcessErrorKind

readonly

target

What the op targeted, an environment name or stdin, stdout, or stderr.

type string

readonly

constructor

type new (kind: ProcessErrorKind, target: string, message?: string | undefined, options?: ErrorOptions | undefined): ProcessError

kind

target

type string

message?

type string
optional

options?

type ErrorOptions
optional

ProcessErrorKind
#

process_error.ts view source

ProcessErrorKind

type "not_granted" | "io_error"

import type {ProcessErrorKind} from '@fuzdev/gro/process_error.js';

Why a process op failed. not_granted is an environment name outside what the handle allows; io_error is a stdio failure other than the reader going away, which is a false result.

ProcessInput
#

process.ts view source

ProcessInput import type {ProcessInput} from '@fuzdev/gro/process.js';

The process's stdin.

inheritance

extends: AsyncIterable<Uint8Array>

is_terminal

Whether stdin is a terminal.

type boolean

readonly

ProcessOutput
#

process.ts view source

ProcessOutput import type {ProcessOutput} from '@fuzdev/gro/process.js';

The process's stdout or stderr.

is_terminal

Whether this stream is a terminal.

type boolean

readonly

write

Writes data, a string as UTF-8, resolving once it's accepted, so awaiting each write paces a writer against the reader. Writes not awaited queue in memory, and exit drops any not yet accepted, so await a write before exiting.

type (data: string | Uint8Array<ArrayBufferLike>): Promise<boolean>

data

type string | Uint8Array<ArrayBufferLike>
returns Promise<boolean>

false when the reader has gone (EPIPE, a task piped to head), so the data went nowhere, and every later write resolves false too

throws

  • `TypeError` - for data that's neither a well-formed string nor a `Uint8Array`
  • `ProcessError` - `io_error`, any other write failure, like a full disk

project_has_sveltekit_app
#

sveltekit_helpers.ts view source

(fs_paths: FsPaths, log?: Logger | undefined): Promise<boolean> import {project_has_sveltekit_app} from '@fuzdev/gro/sveltekit_helpers.js';

Whether the project's package.json declares a SvelteKit app, as has_sveltekit_app detects one. Read without the schema, as only its dependencies matter, and one that can't be read is no app.

fs_paths

reads the project's package.json

type FsPaths

log?

reports a package.json that exists but can't be read or parsed; with none, stays silent

type Logger
optional

returns

Promise<boolean>

whether the project is a SvelteKit app

project_has_vitest
#

vitest_helpers.ts view source

(fs_paths: FsPaths, log?: Logger | undefined): Promise<boolean> import {project_has_vitest} from '@fuzdev/gro/vitest_helpers.js';

Whether the project's package.json declares Vitest as a direct dependency. Peer deps don't count - a package peered on Vitest is built to work with one, which says nothing about whether the package has tests of its own to run. Read without the schema, as only its dependencies matter, and one that can't be read declares nothing.

fs_paths

reads the project's package.json

type FsPaths

log?

reports a package.json that exists but can't be read or parsed; with none, stays silent

type Logger
optional

returns

Promise<boolean>

whether the project declares Vitest

ProjectTasks
#

task_registry.ts view source

ProjectTasks import type {ProjectTasks} from '@fuzdev/gro/task_registry.js';

The project's own tasks by normalized path, empty until augmented by a generated file. Create a genfile like src/gro_tasks.gen.ts exporting gen_task_registry(create_fs_paths(fs)) as gen to type the project's task paths and args for invoke_task.

pushState
#

RAW_QUERY
#

resolve_specifier.ts view source

"?raw" import {RAW_QUERY} from '@fuzdev/gro/resolve_specifier.js';

The query that imports a file's text as its default export, the only query Gro recognizes.

RawGenFile
#

gen.ts view source

RawGenFile import type {RawGenFile} from '@fuzdev/gro/gen.js';

content

type string

filename?

type string

format?

type boolean

RawGenResult
#

RawGroConfig
#

gro_config.ts view source

RawGroConfig import type {RawGroConfig} from '@fuzdev/gro/gro_config.js';

The relaxed variant of GroConfig that users can provide via gro.config.ts. Superset of GroConfig.

see also

plugins?

type (ctx: PluginContext<object>): Plugin<PluginContext<object>>[] | Promise<Plugin<PluginContext<object>>[]>

ctx

type PluginContext<object>
returns Plugin<PluginContext<object>>[] | Promise<Plugin<PluginContext<object>>[]>

map_package_json?

type (PackageJsonMapper) | null

search_filters?

type (PathFilter) | (PathFilter)[] | null

pm_cli?

type string

build_cache_config?

Optional object defining custom build inputs for cache invalidation. This value is hashed during config normalization and used to detect when builds need to be regenerated due to non-source changes.

Use cases:

  • Environment variables baked into build: {api_url: process.env.PUBLIC_API_URL}
  • External data files: {data: fs.readFileSync('data.json', 'utf-8')}
  • Build feature flags: {enable_analytics: true}

Can be a static object or an async function that returns an object.

Gro stores only an unkeyed hash of the value in .gro/build.json and never logs the raw value. The hash hides only high-entropy values: when every value in the object is short or guessable, such as flags and known URLs, hashing candidates recovers them. The process still holds the raw values it read, as in process.env.

type Record<string, unknown> | (() => Record<string, unknown> | Promise<Record<string, unknown>>)

watch?

What the task context's graph watches, each field defaulting separately.

type Partial<WatchOptions>

RawInputPath
#

input_path.ts view source

value + type

RawInputPath

type string & Flavor<"RawInputPath">

import {RawInputPath} from '@fuzdev/gro/input_path.js';

external types

Flavored<s.Infer<typeof RawInputPath>, 'RawInputPath'>

read_format_ignore
#

format_directory.ts view source

(fs_paths: FsPaths, root: string): Promise<FormatIgnore> import {read_format_ignore} from '@fuzdev/gro/format_directory.js';

Reads the root's ignore file into a matcher of gitignore-style patterns, with tsv's shadowing rule: .formatignore, or where the root has none, .prettierignore. Only the root's ignore files are read, in a git repo or out of one. The patterns are anchored at the root, as tsv's IgnoreStack matches them: a pattern with no / matches at any depth, a pattern with / is anchored to the root, a directory pattern skips everything beneath it, and ! re-includes. A file outside the root is never skipped, and no ignore file skips nothing.

fs_paths

opens the ignore files, their symlinks followed

type FsPaths

root

the project root, absolute or relative to the cwd

type string

returns

Promise<FormatIgnore>

throws

  • `FsError` - when reading an ignore file fails other than by its absence

refreshAll
#

render_sveltekit_shim_app_env
#

sveltekit_shim_app.ts view source

(dev: boolean, version_name?: string | undefined): string import {render_sveltekit_shim_app_env} from '@fuzdev/gro/sveltekit_shim_app.js';

dev

type boolean

version_name?

type string
optional default ''

returns

string

render_sveltekit_shim_app_env_vars
#

sveltekit_shim_app_env_vars.ts view source

({ visibility, entry, env_module_specifier, fs_module_specifier, fs_paths_module_specifier, process_module_specifier, dev, env_dir }: RenderSveltekitShimAppEnvVarsOptions): string import {render_sveltekit_shim_app_env_vars} from '@fuzdev/gro/sveltekit_shim_app_env_vars.js';

Generates a module shim for SvelteKit's $app/env/public and $app/env/private. Values resolve when the module runs, validated against the declarations, so unlike SvelteKit's build, static vars aren't inlined - the module reads them from the env files and ambient env, importing the declarations module and Gro's env module. The rendered module is the composition root of that read: it imports the fs host module and builds the FsPaths the env files are read through, and it imports the process host module for the ambient env, so $app/env/* shows its fs and env reach in its imports, while the shim's rendering, in the loader's hooks, never loads a host module.

__0

returns

string

render_sveltekit_shim_app_paths
#

sveltekit_shim_app.ts view source

(base_url?: "" | `/${string}` | undefined, assets_url?: "" | `http://${string}` | `https://${string}` | undefined): string import {render_sveltekit_shim_app_paths} from '@fuzdev/gro/sveltekit_shim_app.js';

base_url?

type "" | `/${string}`
optional default ''

assets_url?

type "" | `http://${string}` | `https://${string}`
optional default ''

returns

string

RenderSveltekitShimAppEnvVarsOptions
#

sveltekit_shim_app_env_vars.ts view source

RenderSveltekitShimAppEnvVarsOptions import type {RenderSveltekitShimAppEnvVarsOptions} from '@fuzdev/gro/sveltekit_shim_app_env_vars.js';

dev and env_dir are rendered into the module, which loads the env when it runs.

inheritance

extends: Pick< LoadEnvOptions, 'dev' | 'env_dir' >

visibility

type EnvVisibility

entry

The project's env declarations module, null if it has none.

type SveltekitEnvEntry | null

env_module_specifier

How the rendered module imports Gro's env module, a file URL.

type string

fs_module_specifier

How the rendered module imports Gro's fs host module, a file URL.

type string

fs_paths_module_specifier

How the rendered module imports Gro's fs_paths module, a file URL.

type string

process_module_specifier

How the rendered module imports Gro's process host module, a file URL.

type string

replace_extension
#

paths.ts view source

(path: string, new_extension: string): string import {replace_extension} from '@fuzdev/gro/paths.js';

path

type string

new_extension

type string

returns

string

replaceState
#

resolve
#

sveltekit_shim_app_paths.ts view source

<T extends RouteIdWithSearchOrHash | PathnameWithSearchOrHash>(...args: ResolveArgs<T>): "/" | "/about" | "/docs" | "/docs/api" | "/docs/introduction" | "/history" | ... 7 more ... | `/${string}/history` import {resolve} from '@fuzdev/gro/sveltekit_shim_app_paths.js';

args

type ResolveArgs<T>

returns

ResolvedPathname

resolve_env_vars
#

env.ts view source

(variables: EnvVarDeclarations, visibility: EnvVisibility, env: Record<string, string | undefined>): Record<string, unknown> import {resolve_env_vars} from '@fuzdev/gro/env.js';

Resolves the declared env vars of one visibility from env, validating each the way SvelteKit does: a var with no schema must be present, and one with a schema gets its Standard Schema result, so validators can transform values and make them optional.

variables

the declarations from the project's src/env.ts

visibility

which of the declared vars to resolve

env

the values to resolve them from, usually from load_env

type Record<string, string | undefined>

returns

Record<string, unknown>

the resolved values keyed by var name

throws

  • listing - every invalid var, so a misconfigured env fails all at once

resolve_gro_module_path
#

gro_helpers.ts view source

(path?: string): string import {resolve_gro_module_path} from '@fuzdev/gro/gro_helpers.js';

Resolves a path to an internal Gro file. Prefers any local installation of Gro and falls back to the current CLI context.

Uses heuristics to find path, so may fail in some rare corner cases. Currently looks for gro.ts as a sibling to the path arg for detection. If this fails for your usecases, rename gro.ts or open an issue/PR!

Used by the CLI and gro run.

case 1:

We're in a directory that has a local installation of Gro at node_modules/.bin/gro. Use this local version instead of the global.

case 2:

We're running Gro inside the Gro repo itself.

In this case, we use the build directory instead of dist. There's a paradox here for using Gro inside itself - ideally we use the dist directory because that's what's shipped, but the build directory has all of the tests, and loading two instances of its modules causes problems like instanceof checks failing. For now we'll just run from build and see if it causes any problems. There's probably a better design in here somewhere.

case 3:

Fall back to invoking Gro from wherever the CLI is being executed. When using the global CLI, this uses the global Gro installation.

path?

type string
optional default ''

returns

string

resolve_input_files
#

input_path.ts view source

(resolved_input_paths: ResolvedInputPath[], search: (dir: string) => Promise<ResolvedPath[]>): Promise<ResolvedInputFiles> import {resolve_input_files} from '@fuzdev/gro/input_path.js';

Finds all of the matching files for the given input paths. De-dupes source ids.

resolved_input_paths

search

finds the files under an input directory, like FsPaths.search_path

type (dir: string) => Promise<ResolvedPath[]>

returns

Promise<ResolvedInputFiles>

resolve_input_paths
#

input_path.ts view source

(fs_paths: FsPaths, input_paths: InputPath[], root_dirs: PathId[], extensions: string[]): Promise<ResolvedInputPaths> import {resolve_input_paths} from '@fuzdev/gro/input_path.js';

Gets the path data for each input path, checking the filesystem for the possibilities and stopping at the first existing file or falling back to the first existing directory. If none is found for an input path, it's added to unmapped_input_paths.

fs_paths

stats the possible paths

type FsPaths

input_paths

type InputPath[]

root_dirs

type PathId[]

extensions

type string[]

returns

Promise<ResolvedInputPaths>

resolve_specifier
#

resolve_specifier.ts view source

(specifier: string, importer: PathId): ResolvedSpecifier import {resolve_specifier} from '@fuzdev/gro/resolve_specifier.js';

Resolves a relative or absolute import specifier to exactly the file it names, the rule gro's runtime resolver follows: extensions are mandatory, nothing is probed, and .js never maps to .ts. The specifier is read as a filesystem path, never URL-decoded; ?raw is the only query recognized.

specifier

a relative or absolute path, optionally ending in ?raw

type string

importer

the path of the importing module

type PathId

returns

ResolvedSpecifier

throws

  • if - the specifier doesn't name an existing file, with the fix when there is one, `code` `'ERR_UNSUPPORTED_DIR_IMPORT'` for a directory or else `'ERR_MODULE_NOT_FOUND'`, and the path's `url` (with any `?raw`), as Node sets them; any other filesystem error (like `EACCES`) is rethrown naming the specifier and importer, the original as `cause`

resolve_sveltekit_env_entry
#

sveltekit_shim_app_env_vars.ts view source

(src_path: string): string | null import {resolve_sveltekit_env_entry} from '@fuzdev/gro/sveltekit_shim_app_env_vars.js';

The project's env var declarations module, like src/env.ts, if it has one. SvelteKit has no env vars without one, so neither does the shim.

src_path

the SvelteKit files.src, relative to the cwd

type string

returns

string | null

resolve_task
#

invoke_task.ts view source

(fs_paths: FsPaths, task_name: string, root?: string): Promise<ResolveTaskResult> import {resolve_task} from '@fuzdev/gro/invoke_task.js';

Resolves a builtin name or a task path to the task module's id and display name, with no search: a name is a builtin or an error, a path is a task file or an error.

fs_paths

stats the task file, and for a name that's no builtin, the file it hints

type FsPaths

task_name

a builtin name or a task path

type string

root?

the project root task paths are relative to, defaults to the project of fs_paths

type string
optional default fs_paths.project.path

returns

Promise<ResolveTaskResult>

ResolvedInputFile
#

ResolvedInputFiles
#

ResolvedInputPath
#

input_path.ts view source

ResolvedInputPath import type {ResolvedInputPath} from '@fuzdev/gro/input_path.js';

input_path

type InputPath

id

type PathId

is_directory

type boolean

root_dir

type PathId

ResolvedInputPaths
#

ResolvedSpecifier
#

resolve_specifier.ts view source

ResolvedSpecifier import type {ResolvedSpecifier} from '@fuzdev/gro/resolve_specifier.js';

A relative or absolute specifier resolved by resolve_specifier.

path_id

The resolved filesystem path for the specifier.

type PathId

raw

Whether the specifier ends in ?raw, importing the file's text.

type boolean

ResolveTaskResult
#

invoke_task.ts view source

ResolveTaskResult

type { ok: true; id: string; name: string; } | { ok: false; reasons: string[]; }

import type {ResolveTaskResult} from '@fuzdev/gro/invoke_task.js';

A resolved task's module id and display name, or why it didn't resolve.

rewrite_dist_file_imports
#

dist_rewrite_imports.ts view source

(path: string, content: string, log?: Logger | undefined): string import {rewrite_dist_file_imports} from '@fuzdev/gro/dist_rewrite_imports.js';

Rewrites the relative .ts import specifiers of one file of dist to .js. A .js or .svelte file changes only at its import requests, a .d.ts file by pattern.

path

the file's path, whose extension picks the rewrite and which names it in the warning

type string

content

the file's text

type string

log?

warned of a .js or .svelte file that doesn't parse and is rewritten by pattern

type Logger
optional

returns

string

the rewritten text

rewrite_dist_imports
#

dist_rewrite_imports.ts view source

(fs_paths: FsPaths, dist_dir?: string, log?: Logger | undefined): Promise<RewriteDistImportsResult> import {rewrite_dist_imports} from '@fuzdev/gro/dist_rewrite_imports.js';

Walks dist_dir and rewrites relative .ts import specifiers to .js in every .js runtime file, .d.ts declaration file, and .svelte file, as rewrite_dist_file_imports does. Source maps (*.map) and symlinks are skipped.

fs_paths

opens dist_dir, its symlinks followed, beneath which the files are rewritten

type FsPaths

dist_dir?

the packaged output directory, absolute or relative to the fs_paths project; defaults to dist

type string
optional default SVELTEKIT_DIST_DIRNAME

log?

logs the counts, and warns of a file that doesn't parse

type Logger
optional

returns

Promise<RewriteDistImportsResult>

counts of files scanned and rewritten

rewrite_relative_ts_imports
#

dist_rewrite_imports.ts view source

(content: string): string import {rewrite_relative_ts_imports} from '@fuzdev/gro/dist_rewrite_imports.js';

Rewrites relative .ts (and .svelte.ts) import specifiers to .js (and .svelte.js) by pattern across a chunk of TypeScript source, including any specifier-shaped text inside its strings and comments. For a dist file, use rewrite_dist_file_imports.

content

type string

returns

string

RewriteDistImportsResult
#

dist_rewrite_imports.ts view source

RewriteDistImportsResult import type {RewriteDistImportsResult} from '@fuzdev/gro/dist_rewrite_imports.js';

scanned

Number of files scanned (.js, .d.ts, and .svelte).

type number

rewritten

Number of scanned files whose contents changed.

type number

run_gen
#

run_gen.ts view source

(gen_modules: GenfileModuleMeta[], config: GroConfig, log: Logger, timings: Timings, invoke_task: InvokeTask, format_file?: ((content: string, options?: FormatFileOptions) => string) | undefined): Promise<...> import {run_gen} from '@fuzdev/gro/run_gen.js';

gen_modules

config

log

type Logger

timings

type Timings

invoke_task

format_file?

type (content: string, options?: FormatFileOptions) => string
optional

returns

Promise<GenResults>

run_svelte_package
#

sveltekit_helpers.ts view source

(fs_paths: FsPaths, spawn: Spawn, { package_json, svelte_package_options, svelte_package_cli: cli, forwarded_argv, log, pm_cli }: RunSveltePackageOptions): Promise<void> import {run_svelte_package} from '@fuzdev/gro/sveltekit_helpers.js';

Runs svelte-package for a SvelteKit library, with any forwarded -- svelte-package args.

fs_paths

checks for the project's lib directory

type FsPaths

spawn

finds and runs the CLI

type Spawn

__2

returns

Promise<void>

throws

  • `TaskError` if the project isn't a SvelteKit library, the CLI isn't installed locally, or `svelte-package` fails

run_task
#

run_task.ts view source

(task_meta: TaskModuleMeta, unparsed_args: Args, options: RunTaskOptions): Promise<RunTaskResult> import {run_task} from '@fuzdev/gro/run_task.js';

Validates unparsed_args against the task's Args and runs the task, or logs its help for --help. A failure, invalid args or a thrown error, is returned, not thrown, so the invoking invoke_task reports it once.

task_meta

the loaded task module

unparsed_args

the args before validation, forwarded args already merged

type Args

options

what the task's context is built from

returns

Promise<RunTaskResult>

RUN_TASK_NAME
#

args.ts view source

internal

"run" import {RUN_TASK_NAME} from '@fuzdev/gro/args.js';

The builtin whose script args the CLI leaves unparsed, gro run <path> ...rest, and which it runs like node, printing no timings.

RunSveltePackageOptions
#

sveltekit_helpers.ts view source

RunSveltePackageOptions import type {RunSveltePackageOptions} from '@fuzdev/gro/sveltekit_helpers.js';

package_json

type PackageJson

svelte_package_options?

The options serialized as svelte-package flags, each dropped when the forwarded args name it.

type SveltePackageOptions

svelte_package_cli

The svelte-package CLI's name, found only in the project's node_modules/.bin.

type string

forwarded_argv

The verbatim args forwarded to the CLI, from to_forwarded_argv.

type string[]

log

type Logger

pm_cli

The package manager named in the install hint when the CLI isn't found.

type string

RunTaskOptions
#

run_task.ts view source

RunTaskOptions import type {RunTaskOptions} from '@fuzdev/gro/run_task.js';

What run_task builds the task's context from: config, graph, log, and timings become its fields of the same name, and fs_paths and raw_rest_args pass to the tasks it invokes, never onto its context.

invoke_task

The invoke_task the task's own invoke_task calls, passing it this task's config, fs_paths, raw_rest_args, graph, timings, and log.

type (task_name: string, args: Args | undefined, options: InvokeTaskOptions): Promise<void>

task_name

type string

args

type Args | undefined

options

returns Promise<void>

config

type GroConfig

fs_paths

The invoking root's boundary, passed to the tasks this task invokes.

type FsPaths

raw_rest_args

The CLI args from the first -- on, passed to the tasks this task invokes.

type readonly string[]

graph

type ModuleGraph

log

type Logger

timings

type Timings

RunTaskResult
#

run_task.ts view source

RunTaskResult

type { ok: true; output: unknown; } | { ok: false; reason: string; error: Error; }

import type {RunTaskResult} from '@fuzdev/gro/run_task.js';

A task's run: its return value as output, or why it failed, with the error.

save_build_cache_metadata
#

build_cache.ts view source

({ fs_paths, log }: BuildCacheSaveDeps, metadata: { version: string; git_commit: string | null; build_cache_config_hash: string; gro_version: string; runtime_version: string; package_lock_hash: string | null; timestamp: string; outputs: { ...; }[]; }): Promise<...> import {save_build_cache_metadata} from '@fuzdev/gro/build_cache.js';

Saves build cache metadata to .gro/ directory. Errors are logged but don't fail the build (cache is optional).

__0

metadata

returns

Promise<void>

SEARCH_EXCLUDER_DEFAULT
#

gro_config.ts view source

RegExp import {SEARCH_EXCLUDER_DEFAULT} from '@fuzdev/gro/gro_config.js';

The regexp used by default to exclude directories and files when searching the filesystem for tasks and genfiles, tested against paths relative to the project root. Customize via search_filters in the GroConfig. See the test cases for the exact behavior.

should_trigger_gen
#

gen_helpers.ts view source

(gen_file_id: PathId, changed_file_id: PathId, dependents: ReadonlySet<PathId>, log: Logger, reported_invalid_inputs: Set<PathId>): Promise<...> import {should_trigger_gen} from '@fuzdev/gro/gen_helpers.js';

Checks if a file change should rerun a genfile: the genfile itself changed, it imports the changed file directly or transitively, or the changed file matches its inputs. The genfile is imported to read its inputs only when the graph doesn't decide. Node's module cache keeps the first read of a gen (and a failed evaluation), so an edit to inputs applies on restart.

gen_file_id

the genfile that may rerun

type PathId

changed_file_id

the file that changed

type PathId

dependents

the modules that import the changed file, directly or transitively, from one ModuleGraph.dependents query shared by the genfiles a change checks

type ReadonlySet<PathId>

log

logs a genfile that fails to import or has invalid inputs

type Logger

reported_invalid_inputs

the genfiles whose invalid inputs were already logged, so each is reported once, as its inputs are read once

type Set<PathId>

returns

Promise<boolean>

mutates

  • reported_invalid_inputs โ€” adds a genfile on logging its invalid `inputs`

SiblingHint
#

resolve_specifier.ts view source

internal

SiblingHint import type {SiblingHint} from '@fuzdev/gro/resolve_specifier.js';

The file a missing path likely meant, the specifier naming it, and the hint naming the fix.

sibling_id

The existing file.

type PathId

sibling_specifier

The specifier as written with the sibling's extension, keeping any ?raw.

type string

hint

The fix, like './x.ts' exists; write the real extension (.js never maps to .ts).

type string

SilentError
#

task.ts view source

import {SilentError} from '@fuzdev/gro/task.js';

This is used to tell Gro to exit silently, usually still with a non-zero exit code. Using it means error logging is handled by the code that threw it.

inheritance

extends: Error

snapshot
#

sveltekit_shim_app_navigation.ts view source

<T>(options: { id?: string | undefined; capture: () => T; restore: (value: T) => void; reset?: (() => void) | undefined; }) => void import {snapshot} from '@fuzdev/gro/sveltekit_shim_app_navigation.js';

SOURCE_DIR
#

SOURCE_DIRNAME
#

spawn
#

spawn.ts view source

Spawn import {spawn} from '@fuzdev/gro/spawn.js';

The spawn host module's root handle. Import it where authority enters (a task, a script, an entry module) and hand a narrower spawn.narrow(...) or a single SpawnProgram down.

Spawn
#

spawn.ts view source

Spawn import type {Spawn} from '@fuzdev/gro/spawn.js';

The spawn host module's root: makes program handles and narrower roots.

program

Resolves name and pins it for the handle's life. A bare name walks the host's PATH, skipping its node_modules/.bin entries, and a name containing / resolves against the project root. Options are read and checked before the name resolves.

type (name: string, options?: SpawnProgramOptions | undefined): SpawnProgram

name

type string

options?

optional
returns SpawnProgram

throws

  • `TypeError` - for a name that isn't a non-empty, well-formed string without NUL, or a malformed option
  • `SpawnError` - `not_found`, `not_executable`, `not_granted`, the last also for `env`, `pass_env: 'all'`, or a `pass_env` glob on a narrowed root

find

Like program, returning null when nothing is found.

type (name: string, options?: SpawnProgramOptions | undefined): SpawnProgram | null

name

type string

options?

optional
returns SpawnProgram | null

the handle, or null on not_found

throws

  • `TypeError` - as `program` does
  • `SpawnError` - `not_executable`, `not_granted`

program_in

Resolves name beneath the directory of dir, an fs handle, and pins it for the handle's life, for a program a run builds outside the project. name resolves as dir resolves any path: an absolute name, a .. above dir, an absolute symlink, or a relative one that climbs out of dir is refused, and a relative symlink that stays inside is followed. The pin, the script rules, and the environment are program's, and argv[0] is the path the program was found at, absolute. Options are read and checked before the name resolves.

type (dir: FsReadDir, name: string, options?: SpawnProgramOptions | undefined): SpawnProgram

dir

an fs handle from this copy of Gro, read-only or not

name

a relative path beneath dir

type string

options?

optional
returns SpawnProgram

throws

  • `TypeError` - for a `dir` that isn't such a handle, a name that isn't a non-empty, well-formed string without NUL, or a malformed option
  • `SpawnError` - `not_found`; `not_executable`, also when resolving the name fails another way, like a directory on the way this user can't search, the `FsError` as `cause`; `not_granted` for a name leading outside `dir`, the `FsError` as `cause`, and for any call on a narrowed root, as a set of names can't grant a directory

find_in

Like program_in, returning null when nothing is found. A permission error is never read as nothing found.

type (dir: FsReadDir, name: string, options?: SpawnProgramOptions | undefined): SpawnProgram | null

dir

an fs handle from this copy of Gro, read-only or not

name

a relative path beneath dir

type string

options?

optional
returns SpawnProgram | null

the handle, or null on not_found

throws

  • `TypeError` - as `program_in` does
  • `SpawnError` - `not_executable`, `not_granted`

narrow

A root that resolves only names, each spelled as it will be requested. It can only shrink: a name this root doesn't allow throws rather than widens. The root it returns refuses env, pass_env: 'all', and pass_env globs.

type (names: readonly string[]): Spawn

names

type readonly string[]
returns Spawn

throws

  • `TypeError` - for a name that isn't a non-empty, well-formed string without NUL
  • `SpawnError` - `not_granted`

spawn_cli
#

cli.ts view source

(program: SpawnProgram, args?: readonly string[], log?: Logger | undefined, options?: SpawnCallOptions | undefined): Promise<SpawnResult> import {spawn_cli} from '@fuzdev/gro/cli.js';

Runs a CLI with stdio inherited, resolving when it ends.

program

the CLI, usually from find_cli

args?

the arguments after argv[0]

type readonly string[]
optional default []

log?

logs the command when present

type Logger
optional

options?

the call's options

optional

returns

Promise<SpawnResult>

how it ended, a non-zero exit being a result

throws

  • `TaskError` - if it couldn't start, with the `SpawnError`'s message and the error as its `cause`

spawn_cli_process
#

cli.ts view source

(program: SpawnProgram, args?: readonly string[], log?: Logger | undefined, options?: SpawnStartOptions | undefined): Promise<SpawnChild> import {spawn_cli_process} from '@fuzdev/gro/cli.js';

Starts a long-lived CLI, stdio inherited unless options says otherwise.

program

the CLI, usually from find_cli

args?

the arguments after argv[0]

type readonly string[]
optional default []

log?

logs the command when present

type Logger
optional

options?

the call's options

optional

returns

Promise<SpawnChild>

the running child

throws

  • `TaskError` - if it couldn't start, with the `SpawnError`'s message and the error as its `cause`

spawn_restartable
#

spawn_restartable.ts view source

(program: SpawnProgram, args?: readonly string[], options?: SpawnStartOptions | undefined): Promise<SpawnRestartable> import {spawn_restartable} from '@fuzdev/gro/spawn_restartable.js';

Starts a child that can be restarted, resolving once the first child is running. Library code over a program, so the caller decides the program and its environment. args and options are copied once, here, so every start uses them as they were at this call, and a caller changing its array or options object afterward has no effect.

program

the executable, its pin and environment fixed for every restart

args?

the arguments after argv[0], copied now

type readonly string[]
optional default []

options?

the options of every start, stdio included, stdio inherited by default, copied now, with signal kept so an abort still stops a child

optional

returns

Promise<SpawnRestartable>

the restartable child

throws

  • `SpawnError` - `launch_failed`, as `SpawnProgram.start` does

spawn_result_is_ok
#

cli.ts view source

(result: SpawnResult): boolean import {spawn_result_is_ok} from '@fuzdev/gro/cli.js';

Whether a program finished by exiting 0.

result

returns

boolean

spawn_with_loader
#

gro_helpers.ts view source

(node: SpawnProgram, loader_path: string, invoke_path: string, argv: readonly string[], node_env: string | undefined): Promise<SpawnResult> import {spawn_with_loader} from '@fuzdev/gro/gro_helpers.js';

Runs a file using the Gro loader.

Uses conditional exports to correctly set up esm-env as development by default, so if you want production set NODE_ENV=production.

node

the node program, whose environment the root decides

loader_path

path to loader

type string

invoke_path

path to file to spawn with node

type string

argv

the args after invoke_path

type readonly string[]

node_env

the host's NODE_ENV, read by the root

type string | undefined

returns

Promise<SpawnResult>

see also

spawn_with_loader_args
#

gro_helpers.ts view source

(loader_path: string, invoke_path: string, argv: readonly string[], node_env: string | undefined): string[] import {spawn_with_loader_args} from '@fuzdev/gro/gro_helpers.js';

The Node args that run invoke_path with Gro's loader registered.

loader_path

type string

invoke_path

type string

argv

type readonly string[]

node_env

the host's NODE_ENV, read by the root

type string | undefined

returns

string[]

SpawnCallOptions
#

spawn.ts view source

SpawnCallOptions import type {SpawnCallOptions} from '@fuzdev/gro/spawn.js';

Options for a call that starts a program.

cwd?

The working directory, a handle rather than a path. Defaults to the project root.

type FsReadDir

timeout_ms?

Stops the child this many milliseconds after it starts, SIGTERM then SIGKILL after a grace period. The call's result is then of kind timed_out. A positive safe integer of at most 2147483647.

type number

signal?

Stops the child when it aborts, as timeout_ms does, its result of kind aborted. A signal that had aborted before the call starts nothing: the call throws SpawnError.

type AbortSignal

SpawnChild
#

spawn.ts view source

SpawnChild import type {SpawnChild} from '@fuzdev/gro/spawn.js';

A running child. pid is for display, and nothing takes a pid, so no surface here can signal another process. Awaiting it does nothing, as it has no then.

Disposing it with await using stops it, SIGTERM then SIGKILL after a grace period, and waits for closed.

inheritance

extends: AsyncDisposable

pid

The child's process id, for display only.

type number

readonly

closed

Resolves when the child has ended and its pipes closed, or the wait for them was bounded after it exited. Never rejects.

type Promise<SpawnResult>

readonly

stdout

The child's stdout, or null unless 'pipe'. Iterating is once only: a second iteration throws TypeError, and leaving the loop early discards the rest, the child still running. Chunks are plain Uint8Array copies. A stream nobody reads pauses once its buffer fills, so the child can block on a full pipe.

type AsyncIterable<Uint8Array<ArrayBufferLike>, any, any> | null

readonly

stderr

The child's stderr, as stdout.

type AsyncIterable<Uint8Array<ArrayBufferLike>, any, any> | null

readonly

stdin

The child's stdin, or null unless 'pipe'.

type SpawnStdin | null

readonly

kill

Sends signal, SIGTERM by default, to the child, or to its group when it leads one, once per call, so SIGTERM then SIGKILL works.

type (signal?: SpawnSignal | undefined): boolean

signal?

optional
returns boolean

false when the child has already ended and no signal was sent

throws

  • `TypeError` - for a `signal` that isn't an allowed name

SpawnError
#

spawn_error.ts view source

import {SpawnError} from '@fuzdev/gro/spawn_error.js';

The error spawn.ts throws when a program can't be reached or started, typed by kind. A program that started and exited non-zero is a result, not this error. Match it with is_spawn_error, which also recognizes one from another copy of Gro. The class and its prototype are frozen.

inheritance

extends: Error

name

type string

kind

type SpawnErrorKind

readonly

program

The program's name as it was requested.

type string

readonly

constructor

type new (kind: SpawnErrorKind, program: string, message?: string | undefined, options?: ErrorOptions | undefined): SpawnError

kind

program

type string

message?

type string
optional

options?

type ErrorOptions
optional

SpawnErrorKind
#

spawn_error.ts view source

SpawnErrorKind

type "not_found" | "not_executable" | "not_granted" | "launch_failed"

import type {SpawnErrorKind} from '@fuzdev/gro/spawn_error.js';

Why a program couldn't be reached or started. not_found is a name that resolves to no regular executable; not_executable is a regular file without execute permission, or one the module refuses (.bat, .cmd, a format that's neither #! nor ELF); not_granted is a name outside what the handle allows, or an environment a narrowed root can't give; launch_failed is a pinned program that couldn't start, what stopped it on cause, including one that wasn't started because the call's signal had already aborted (its reason) or a #! script's found path no longer resolves (the stat's error), and a #! script whose found path now leads to another file, which has no cause.

SpawnOutOptions
#

spawn.ts view source

SpawnOutOptions import type {SpawnOutOptions} from '@fuzdev/gro/spawn.js';

Options for a captured call.

inheritance

max_bytes?

The most bytes kept of each of stdout and stderr, a non-negative safe integer. Past it the child is killed and the result is truncated. Defaults to 64 MiB.

type number

stdin?

The child's stdin. 'ignore', the default, is /dev/null, and the child leads its own process group, in a new session with no terminal, so a stop and the cap reach what it left behind. 'inherit' shares the host's and keeps the child in the terminal's session, as for any child with an inherited stream, so a command that may prompt (ssh, a credential helper, a pinentry) still reaches /dev/tty. Such a child is stopped and capped by pid alone, so a process it started outlives the call.

A Uint8Array is the data sent to the child's stdin through a pipe, which then closes, empty data closing it at once. It's copied when the option is read, so changing the array afterward changes nothing sent, and written while the output is read, so a child can fill either pipe. Text goes through a TextEncoder, as a string here would collide with the mode names. The child leads its own process group, as for 'ignore'. A child that exits or closes its stdin before reading it all ends the write, which is no error, and the result stands, so a call's result never says whether the data was read.

type "inherit" | "ignore" | Uint8Array<ArrayBufferLike>

SpawnOutput
#

spawn.ts view source

SpawnOutput

type ({ readonly kind: "exited"; readonly code: number; } & { readonly stdout: string; readonly stderr: string; readonly truncated: boolean; }) | ({ readonly kind: "signaled"; readonly signal: string; } & { readonly stdout: string; readonly stderr: string; readonly truncated: boolean; }) | ({ readonly kind: "timed_out" | "aborted"; readonly code: number | null; readonly signal: string | null; } & { readonly stdout: string; readonly stderr: string; readonly truncated: boolean; })

import type {SpawnOutput} from '@fuzdev/gro/spawn.js';

A captured call's result. stdout and stderr decode as UTF-8, with U+FFFD for bytes that aren't, each at most max_bytes before decoding.

truncated is true when output passed max_bytes and the child was killed with SIGKILL, its kind then signaled unless it exited first, or when a process it left running still held a pipe when the wait for it ended, so output may be missing from the end.

SpawnOutputBytes
#

spawn.ts view source

SpawnOutputBytes

type ({ readonly kind: "exited"; readonly code: number; } & { readonly stdout: Uint8Array<ArrayBufferLike>; readonly stderr: Uint8Array<ArrayBufferLike>; readonly truncated: boolean; }) | ({ readonly kind: "signaled"; readonly signal: string; } & { readonly stdout: Uint8Array<ArrayBufferLike>; readonly stderr: Uint8Array<ArrayBufferLike>; readonly truncated: boolean; }) | ({ readonly kind: "timed_out" | "aborted"; readonly code: number | null; readonly signal: string | null; } & { readonly stdout: Uint8Array<ArrayBufferLike>; readonly stderr: Uint8Array<ArrayBufferLike>; readonly truncated: boolean; })

import type {SpawnOutputBytes} from '@fuzdev/gro/spawn.js';

A byte-captured call's result. stdout and stderr are exactly the bytes the child wrote, each at most max_bytes, plain Uint8Arrays holding their own memory. truncated is as for SpawnOutput.

SpawnProgram
#

spawn.ts view source

SpawnProgram import type {SpawnProgram} from '@fuzdev/gro/spawn.js';

One executable, pinned when the handle is made. name and path are for display: the pin is private, so changing what path says changes nothing that runs.

name

The name the program was granted. A bare name is also its argv[0], a name containing / passes its project-absolute path instead, and a name from program_in the absolute path it was found at beneath its handle. A #! script's interpreter gets the path the script was found at as $0 in its place.

type string

readonly

path

The pinned executable's real path, for display. A native binary runs at it, and a #! script runs at the path it was found at, which must still lead to the same file.

type string

readonly

run

Runs the program with stdio inherited, resolving when it ends. A non-zero exit is a result, not an error. An inheriting child is stopped by pid alone.

type (args: readonly string[], options?: SpawnCallOptions | undefined): Promise<SpawnResult>

args

the arguments after argv[0]

type readonly string[]

options?

optional
returns Promise<SpawnResult>

throws

  • `TypeError` - for an argument that isn't a well-formed string without NUL, or a malformed option
  • `SpawnError` - `launch_failed`, also for a `signal` already aborted or a script whose found path now leads to another file

out

Runs the program, capturing stdout and stderr as UTF-8 text, with stdin from /dev/null unless stdin gives data to send or says 'inherit'. Output past max_bytes (64 MiB by default) on either stream kills the child with SIGKILL, whose result is truncated, a multi-byte character cut at the end becoming U+FFFD. A child leading its own process group is killed as the group, and one with stdin inherited by pid alone. After it exits, a background process still holding a pipe gets a bounded wait, then the group, if there is one, is killed and reading stops, the result truncated because output may be missing. A stop, the cap, and the child's exit end a stdin write in progress.

type (args: readonly string[], options?: SpawnOutOptions | undefined): Promise<SpawnOutput>

args

the arguments after argv[0]

type readonly string[]

options?

optional
returns Promise<SpawnOutput>

throws

  • `TypeError` - for an argument that isn't a well-formed string without NUL, or a malformed option
  • `SpawnError` - `launch_failed`, also for a `signal` already aborted or a script whose found path now leads to another file
  • `RangeError` - when memory for a stream can't be allocated, the child killed first

out_bytes

Captures as out does, with the same options, stdin data included, keeping stdout and stderr as bytes, for output that isn't text, like a git blob.

type (args: readonly string[], options?: SpawnOutOptions | undefined): Promise<SpawnOutputBytes>

args

the arguments after argv[0]

type readonly string[]

options?

optional
returns Promise<SpawnOutputBytes>

throws

  • `TypeError` - for an argument that isn't a well-formed string without NUL, or a malformed option
  • `SpawnError` - `launch_failed`, also for a `signal` already aborted or a script whose found path now leads to another file
  • `RangeError` - when memory for a stream can't be allocated, the child killed first

start

Starts the program and returns once it's running, the child held by the SpawnChild. Stdio defaults to 'inherit'. A child with nothing inherited leads its own group.

type (args: readonly string[], options?: SpawnStartOptions | undefined): Promise<SpawnChild>

args

the arguments after argv[0]

type readonly string[]

options?

optional
returns Promise<SpawnChild>

throws

  • `TypeError` - for an argument that isn't a well-formed string without NUL, or a malformed option
  • `SpawnError` - `launch_failed`, also for a `signal` already aborted or a script whose found path now leads to another file

SpawnProgramOptions
#

spawn.ts view source

SpawnProgramOptions import type {SpawnProgramOptions} from '@fuzdev/gro/spawn.js';

How a program's environment is built, fixed when its handle is made.

pass_env?

Host variables to pass by name, beyond the base set: a name or a PREFIX_* glob. 'all' passes the host's whole environment, as strong as -A. A narrowed root takes names only.

type readonly string[] | "all"

omit_env?

Host variables pass_env: 'all' leaves out, each an exact, case-sensitive name, never a glob. Given with any other pass_env it's a TypeError. Only what's forwarded changes, so env can still set one of these names, and Node still adds what it copies itself, like NODE_V8_COVERAGE.

type readonly string[]

env?

Explicit values, the last word over the base set and pass_env. Given only when the handle is made: a call can't change a program's environment.

type Readonly<Record<string, string>>

SpawnRestartable
#

spawn_restartable.ts view source

SpawnRestartable import type {SpawnRestartable} from '@fuzdev/gro/spawn_restartable.js';

A long-lived child that can be restarted, its program and arguments kept.

restart

Stops the running child, if any, and starts a new one from the same program, so a restart reuses the pinned executable and its environment. restart and stop run in the order they're called, and a call shares the last one still pending when that's of its own kind, so the last call decides whether a child ends up running.

type (): Promise<void>

returns Promise<void>

throws

  • `SpawnError` - `launch_failed`, as `SpawnProgram.start` does

stop

Stops the running child and waits for it, SIGTERM and then SIGKILL after a grace period. A later restart starts a child again.

type (): Promise<void>

returns Promise<void>

active

Whether a child is being managed, following the last restart or stop requested, so it's false from the moment stop is called. A child that exited on its own stays managed until restart or stop, so a loop can read closed and decide. A failed restart doesn't change it, so it can be true with no child.

type boolean

readonly

child

The current child, possibly already exited, null after stop, during a restart, and after a failed restart.

type SpawnChild | null

readonly

closed

How the most recent child ended. Never rejects. During a restart, and after a failed one, it's the previous child's. Read it again after a restart to wait on the new child.

type Promise<SpawnResult>

readonly

SpawnResult
#

spawn.ts view source

SpawnResult

type { readonly kind: "exited"; readonly code: number; } | { readonly kind: "signaled"; readonly signal: string; } | { readonly kind: "timed_out" | "aborted"; readonly code: number | null; readonly signal: string | null; }

import type {SpawnResult} from '@fuzdev/gro/spawn.js';

How a program ended. code is its exit code, or signal the signal that ended it. timed_out and aborted are a child the module stopped for timeout_ms or signal, with the code or signal it then ended by, the other null, so one that exits 0 on SIGTERM is never mistaken for one that finished.

SpawnSignal
#

spawn.ts view source

SpawnSignal

type "SIGTERM" | "SIGKILL" | "SIGINT" | "SIGHUP" | "SIGQUIT" | "SIGUSR1" | "SIGUSR2"

import type {SpawnSignal} from '@fuzdev/gro/spawn.js';

A signal a child can be sent, by name. Numbers and other names are a TypeError.

SpawnStartOptions
#

spawn.ts view source

SpawnStartOptions import type {SpawnStartOptions} from '@fuzdev/gro/spawn.js';

Options for start.

inheritance

stdio?

Each of stdin, stdout, and stderr, one value for all or the three in order. Defaults to 'inherit'. A child with nothing inherited is the leader of its own process group.

type SpawnStdio | readonly [SpawnStdio, SpawnStdio, SpawnStdio]

SpawnStdin
#

spawn.ts view source

SpawnStdin import type {SpawnStdin} from '@fuzdev/gro/spawn.js';

A started child's stdin.

write

Writes data, a string as UTF-8, resolving once it's accepted.

type (data: string | Uint8Array<ArrayBufferLike>): Promise<boolean>

data

type string | Uint8Array<ArrayBufferLike>
returns Promise<boolean>

false when the child closed its stdin or ended, so the data went nowhere

throws

  • `TypeError` - for data that's neither a well-formed string nor a `Uint8Array`

close

Ends the stream, resolving once it's flushed. Closing twice is harmless.

type (): Promise<void>

returns Promise<void>

SpawnStdio
#

spawn.ts view source

SpawnStdio

type "inherit" | "pipe" | "ignore"

import type {SpawnStdio} from '@fuzdev/gro/spawn.js';

One stream of a started child: 'inherit' shares the host's, 'pipe' connects it to the SpawnChild, and 'ignore' is /dev/null.

SVELTE_CHECK_CLI
#

SVELTE_DOCINFO_VERSION
#

library_load.ts view source

string import {SVELTE_DOCINFO_VERSION} from '@fuzdev/gro/library_load.js';

The installed svelte-docinfo version โ€” read from the same copy that analyzeFromFiles resolves to. Stamped into each cache record and compared on read, so caches analyzed by a different svelte-docinfo self-invalidate: source_json.modules is cached verbatim, and the cache key (the analyzed repo's commit hash) doesn't move when the *analyzer's* dependency changes its output shape.

SVELTE_MATCHER
#

SVELTE_PACKAGE_CLI
#

SVELTE_PACKAGE_DEP_NAME
#

SVELTE_RUNES_MATCHER
#

constants.ts view source

RegExp import {SVELTE_RUNES_MATCHER} from '@fuzdev/gro/constants.js';

Svelte modules compiled for runes, vite-plugin-svelte's default rule: .svelte. in the file name, then any segments, then .js or .ts, like state.svelte.ts and state.svelte.test.ts.

SVELTE_SCRIPT_MATCHER
#

constants.ts view source

RegExp import {SVELTE_SCRIPT_MATCHER} from '@fuzdev/gro/constants.js';

Extracts the script content from Svelte files.

SVELTEKIT_APP_ENV_VARS_MATCHER
#

SVELTEKIT_BUILD_DIRNAME
#

SVELTEKIT_CLI
#

SVELTEKIT_DEP_NAME
#

SVELTEKIT_DEV_DIRNAME
#

SVELTEKIT_DIST_DIRNAME
#

SVELTEKIT_GLOBAL_SPECIFIER
#

SVELTEKIT_SHIM_APP_SPECIFIERS
#

sveltekit_sync
#

sveltekit_helpers.ts view source

(spawn: Spawn, { sveltekit_cli, pm_cli }?: SveltekitSyncOptions): Promise<void> import {sveltekit_sync} from '@fuzdev/gro/sveltekit_helpers.js';

Runs svelte-kit sync, with nothing checking that the project uses SvelteKit. Callers gate on project_has_sveltekit_app unless something else already establishes it.

spawn

finds and runs the CLI

type Spawn

__1?

optional default {}

returns

Promise<void>

throws

  • `TaskError` if the CLI isn't found or fails

sveltekit_sync_if_obviously_needed
#

sveltekit_helpers.ts view source

(fs_paths: FsPaths, spawn: Spawn, sveltekit_cli?: string): Promise<void> import {sveltekit_sync_if_obviously_needed} from '@fuzdev/gro/sveltekit_helpers.js';

What runs before every task: svelte-kit sync for a project has_sveltekit_app detects whose .svelte-kit directory or generated $app/tsconfig is missing, the tsconfig checked because it lives in node_modules, which reinstalls wipe. A project with both pays only their checks. A CLI that isn't found skips rather than throws, so gro sync --install runs on a fresh clone.

fs_paths

checks for the project's synced files and reads its package.json

type FsPaths

spawn

finds and runs the CLI

type Spawn

sveltekit_cli?

the SvelteKit CLI's name

type string
optional default SVELTEKIT_CLI

returns

Promise<void>

throws

  • `TaskError` if the CLI fails

sveltekit_tsconfig_is_unsynced
#

sveltekit_helpers.ts view source

(fs_paths: FsPaths, dir: string): Promise<boolean> import {sveltekit_tsconfig_is_unsynced} from '@fuzdev/gro/sveltekit_helpers.js';

Whether dir's tsconfig.json extends SvelteKit's $app/tsconfig while the generated node_modules/$app/tsconfig.json is missing - the project was never synced, or a reinstall wiped node_modules. TypeScript doesn't fail on an unresolved extends, so tools reading such a tsconfig silently run on default compiler options and read external types as any.

Reads the tsconfig as JSONC with TypeScript's own parser and accepts a string or array extends. Only dir's own tsconfig.json is checked, not configs it extends. A missing tsconfig, or one TypeScript's tolerant parser recovers no extends from, returns false, left to whatever reads it next.

fs_paths

opens dir's files

type FsPaths

dir

the project root, absolute or relative to the project of fs_paths

type string

returns

Promise<boolean>

true when the project needs svelte-kit sync

throws

  • `FsError` - when reading either file fails other than by its absence

SVELTEKIT_TSCONFIG_PATH
#

constants.ts view source

string import {SVELTEKIT_TSCONFIG_PATH} from '@fuzdev/gro/constants.js';

The tsconfig SvelteKit generates for projects to extend as $app/tsconfig.

SVELTEKIT_TSCONFIG_SPECIFIER
#

constants.ts view source

"$app/tsconfig" import {SVELTEKIT_TSCONFIG_SPECIFIER} from '@fuzdev/gro/constants.js';

The extends specifier SvelteKit projects use for the tsconfig that svelte-kit sync generates at SVELTEKIT_TSCONFIG_PATH.

SVELTEKIT_VITE_CACHE_PATH
#

SveltekitEnvEntry
#

SveltekitSyncOptions
#

sveltekit_helpers.ts view source

SveltekitSyncOptions import type {SveltekitSyncOptions} from '@fuzdev/gro/sveltekit_helpers.js';

sveltekit_cli?

The SvelteKit CLI's name.

type string

default `SVELTEKIT_CLI`

pm_cli?

The package manager named in the install hint when the CLI isn't found.

type string

default `PM_CLI_DEFAULT`

SveltePackageOptions
#

sveltekit_helpers.ts view source

SveltePackageOptions import type {SveltePackageOptions} from '@fuzdev/gro/sveltekit_helpers.js';

Options to the SvelteKit packaging CLI.

see also

watch?

Watch files in src/lib for changes and rebuild the package

type boolean

w?

Alias for watch.

type boolean

input?

The input directory which contains all the files of the package. Defaults to src/lib

type string

i?

Alias for input.

type string

output?

The output directory where the processed files are written to. Your package.json's exports should point to files inside there, and the files array should include that folder. Defaults to dist

type string

o?

Alias for output.

type string

types?

Whether or not to create type definitions (d.ts files). We strongly recommend doing this as it fosters ecosystem library quality. Defaults to true

type boolean

t?

Alias for types.

type boolean

tsconfig?

The path to a tsconfig or jsconfig. When not provided, searches for the next upper tsconfig/jsconfig in the workspace path.

type string

Task
#

task.ts view source

Task<TArgs, TArgsSchema, TReturn> import type {Task} from '@fuzdev/gro/task.js';

generics

Task<TArgs = Args, TArgsSchema extends Schema<Args, Args> = Schema<Args, Args>, TReturn = unknown>
TArgs
default Args
TArgsSchema
constraint Schema<Args, Args>
default Schema<Args, Args>
TReturn
default unknown

run

type (ctx: TaskContext<TArgs>): TReturn | Promise<TReturn>

ctx

type TaskContext<TArgs>
returns TReturn | Promise<TReturn>

summary?

type string

Args?

type TArgsSchema

TASK_FILE_SUFFIX_JS
#

TASK_FILE_SUFFIX_TS
#

TASK_FILE_SUFFIXES
#

task.ts view source

string[] import {TASK_FILE_SUFFIXES} from '@fuzdev/gro/task.js';

Every task file suffix, the only files gro task runs and lists.

task_registry_find
#

task_registry.ts view source

(fs_paths: FsPaths, dir: PathId, search_filters: PathFilter[], root?: PathId): Promise<TaskRegistryEntry[]> import {task_registry_find} from '@fuzdev/gro/task_registry.js';

Finds the task files under dir, named by their paths relative to root, the names invoke_task and gro task give them, sorted by name.

fs_paths

searches dir

type FsPaths

dir

the directory to search, absolute or relative to the project of fs_paths

type PathId

search_filters

the filters each file and directory must pass, given paths relative to root, or to dir for the paths outside root

type PathFilter[]

root?

the project root the names and filtered paths are relative to, defaults to the project of fs_paths

type PathId
optional default fs_paths.project.path

returns

Promise<TaskRegistryEntry[]>

task_registry_find_builtins
#

task_registry.ts view source

(src_lib: FsReadDir): Promise<BuiltinTaskEntry[]> import {task_registry_find_builtins} from '@fuzdev/gro/task_registry.js';

Finds Gro's builtin tasks, the *.task.ts files directly in src_lib, importing each to read its summary.

src_lib

Gro's src/lib/

returns

Promise<BuiltinTaskEntry[]>

task_registry_render_builtins
#

task_registry.ts view source

(entries: BuiltinTaskEntry[], output_dir: PathId, origin_path: string): string import {task_registry_render_builtins} from '@fuzdev/gro/task_registry.js';

Renders the GroBuiltinTasks interface for Gro's own tasks and their summaries, so listing them imports no task module.

entries

output_dir

type PathId

origin_path

type string

returns

string

task_registry_render_project
#

TASK_VERB
#

task.ts view source

"task" import {TASK_VERB} from '@fuzdev/gro/task.js';

The CLI verb that runs or lists project tasks by path, gro task [path].

TaskArgsInput
#

task_registry.ts view source

TaskArgsInput<TName>

type TaskRegistry[TName] extends { Args: infer TSchema extends AnySchema; } ? InferInput<TSchema> extends infer TInput ? TInput extends unknown ? [keyof TInput] extends [never] ? Record<string, never> : TInput : never : never : Args

import type {TaskArgsInput} from '@fuzdev/gro/task_registry.js';

The input type of the task's Args schema, so defaulted args are optional, or loose Args for a task module without an Args export. A member of the input with no keys becomes Record<string, never>, so an arg-less task refuses every arg, and a union keeps each option's keys.

generics

TaskArgsInput<TName extends TaskName>
TName
constraint TaskName

TaskContext
#

task.ts view source

TaskContext<TArgs> import type {TaskContext} from '@fuzdev/gro/task.js';

generics

TaskContext<TArgs = object>
TArgs
default object

args

type TArgs

config

type GroConfig

svelte_config

Resolved on first access, so tasks that don't touch it never pay to read the SvelteKit config.

type Promise<ParsedSvelteConfig>

graph

The project's module graph, loaded on first use.

type ModuleGraph

log

type Logger

timings

type Timings

invoke_task

type <TName extends string>(task_name: InvokeTaskName<TName>, ...rest: InvokeTaskRest<TName>): Promise<void>

task_name

type InvokeTaskName<TName>

rest

type InvokeTaskRest<TName>
returns Promise<void>

TaskError
#

task.ts view source

import {TaskError} from '@fuzdev/gro/task.js';

This is used by tasks to signal a known failure. It's useful for cleaning up logging because we usually don't need their stack trace.

inheritance

extends: Error

exit_code

The code the CLI exits with when this error fails the task it invoked, an integer 1โ€“255; absent or any other value means 1.

type number | undefined

readonly

constructor

type new (message?: string | undefined, options?: TaskErrorOptions | undefined): TaskError

message?

type string
optional

options?

optional

TaskErrorOptions
#

task.ts view source

TaskErrorOptions import type {TaskErrorOptions} from '@fuzdev/gro/task.js';

Options for a TaskError.

inheritance

extends: ErrorOptions

exit_code?

The code the CLI exits with when this error fails the task it invoked, like gro run's script's own, an integer 1โ€“255; absent or any other value means 1.

type number

TaskModule
#

task.ts view source

TaskModule import type {TaskModule} from '@fuzdev/gro/task.js';

A task file's module, which exports the task.

task

type Task<Args, Schema<Args, Args, string, unknown>, unknown>

TaskModuleMeta
#

task.ts view source

TaskModuleMeta import type {TaskModuleMeta} from '@fuzdev/gro/task.js';

A loaded task module with its id and display name.

inheritance

extends: ModuleMeta<TaskModule>

name

The builtin name or normalized root-relative path the task is displayed and keyed by.

type string

TaskName
#

task_registry.ts view source

TaskName

type "run" | "build" | "changeset" | "check" | "clean" | "commit" | "deploy" | "dev" | "format" | "gen" | "lint" | "publish" | "reinstall" | "release" | "sync" | "test" | "typecheck" | "upgrade" | "fixture/clean.task.ts" | "fixture/no_args.task.ts" | "fixture/required_args.task.ts" | "fixture/union_args.task.ts"

import type {TaskName} from '@fuzdev/gro/task_registry.js';

A builtin name or project task path in TaskRegistry, the literals invoke_task checks.

TaskPathLiteral
#

task.ts view source

TaskPathLiteral

type `${string}.task.ts` | `${string}.task.js`

import type {TaskPathLiteral} from '@fuzdev/gro/task.js';

A literal task file path, ending in .task.ts or .task.js.

TaskPathNormalized
#

task.ts view source

TaskPathNormalized<TName>

type TName extends `./${infer TRest}` ? TaskPathNormalized<TRest> : TName

import type {TaskPathNormalized} from '@fuzdev/gro/task.js';

Strips any leading ./ from a literal task path, so ./src/lib/x.task.ts keys the registry like src/lib/x.task.ts.

generics

TaskPathNormalized<TName extends string>
TName
constraint string

TaskRegistry
#

task_registry.ts view source

TaskRegistry

type GroBuiltinTasks & ProjectTasks

import type {TaskRegistry} from '@fuzdev/gro/task_registry.js';

Every task invoke_task types, mapped to its module's type: Gro's builtins by name and the project's tasks by path relative to the project root. Names never contain a / or end in a task suffix and paths always do, so nothing shadows.

build

type typeof import("build.task.ts", { with: { "resolution-mode": "import" } })

changeset

type typeof import("changeset.task.ts", { with: { "resolution-mode": "import" } })

check

type typeof import("check.task.ts", { with: { "resolution-mode": "import" } })

clean

type typeof import("clean.task.ts", { with: { "resolution-mode": "import" } })

commit

type typeof import("commit.task.ts", { with: { "resolution-mode": "import" } })

deploy

type typeof import("deploy.task.ts", { with: { "resolution-mode": "import" } })

dev

type typeof import("dev.task.ts", { with: { "resolution-mode": "import" } })

format

type typeof import("format.task.ts", { with: { "resolution-mode": "import" } })

gen

type typeof import("gen.task.ts", { with: { "resolution-mode": "import" } })

lint

type typeof import("lint.task.ts", { with: { "resolution-mode": "import" } })

publish

type typeof import("publish.task.ts", { with: { "resolution-mode": "import" } })

reinstall

type typeof import("reinstall.task.ts", { with: { "resolution-mode": "import" } })

release

type typeof import("release.task.ts", { with: { "resolution-mode": "import" } })

run

type typeof import("run.task.ts", { with: { "resolution-mode": "import" } })

sync

type typeof import("sync.task.ts", { with: { "resolution-mode": "import" } })

test

type typeof import("test.task.ts", { with: { "resolution-mode": "import" } })

typecheck

type typeof import("typecheck.task.ts", { with: { "resolution-mode": "import" } })

upgrade

type typeof import("upgrade.task.ts", { with: { "resolution-mode": "import" } })

fixture/clean.task.ts

type typeof import("src/test/fixtures/task_registry/clean_override.task_fixture.ts", { with: { "resolution-mode": "import" } })

fixture/no_args.task.ts

type typeof import("src/test/fixtures/task_registry/no_args.task_fixture.ts", { with: { "resolution-mode": "import" } })

fixture/required_args.task.ts

type typeof import("src/test/fixtures/task_registry/required_args.task_fixture.ts", { with: { "resolution-mode": "import" } })

fixture/union_args.task.ts

type typeof import("src/test/fixtures/task_registry/union_args.task_fixture.ts", { with: { "resolution-mode": "import" } })

TaskRegistryEntry
#

task_registry.ts view source

TaskRegistryEntry import type {TaskRegistryEntry} from '@fuzdev/gro/task_registry.js';

name

The builtin name, or the project task's path relative to the project root.

type string

id

type PathId

TEST_FILE_PATTERN
#

vitest_helpers.ts view source

".test." import {TEST_FILE_PATTERN} from '@fuzdev/gro/vitest_helpers.js';

The file pattern gro test passes to Vitest by default, which keeps the files whose path beneath the test directory contains it, ignoring case.

to_builtin_task_id
#

task.ts view source

(name: keyof GroBuiltinTasks): PathId import {to_builtin_task_id} from '@fuzdev/gro/task.js';

The module id of the builtin task name.

name

type "run" | "build" | "changeset" | "check" | "clean" | "commit" | "deploy" | "dev" | "format" | "gen" | "lint" | "publish" | "reinstall" | "release" | "sync" | "test" | "typecheck" | "upgrade"

returns

PathId

to_default_env_files
#

to_forwarded_args
#

args.ts view source

(command: string, raw_rest_args: readonly string[], root: string): Args import {to_forwarded_args} from '@fuzdev/gro/args.js';

Gets the parsed args forwarded to the Gro task command, like gro test given gro check -- gro test --coverage, or {} when none are. Outside tools get verbatim args with to_forwarded_argv instead.

command

gro and the task name, from to_task_command

type string

raw_rest_args

the CLI args from the first -- on, from to_raw_rest_args

type readonly string[]

root

the project root a section's task path is relative to

type string

returns

Args

throws

  • TaskError - when a `gro` section is malformed, see `to_forwarded_args_by_command`

to_forwarded_args_by_command
#

args.ts view source

(raw_rest_args: readonly string[], root: string): Record<string, Args | undefined> import {to_forwarded_args_by_command} from '@fuzdev/gro/args.js';

Parses each Gro task section of raw_rest_args, those after a -- whose first arg is gro, into args keyed by gro and the task name: -- gro test --a is keyed gro test, and -- gro task src/lib/x.task.ts --a is keyed by gro task and the normalized path. Other sections are left verbatim for outside tools, see to_forwarded_argv. When a task has several sections, the last one wins.

raw_rest_args

the CLI args from the first -- on, from to_raw_rest_args

type readonly string[]

root

the project root a section's task path is relative to

type string

returns

Record<string, Args | undefined>

the forwarded args of each Gro task command

throws

  • TaskError - when a `gro` section names no task, a `gro task` section no path, a section names a path without `gro task` or a task with the removed `gro/` prefix, or a flag replaces a section's positional args

to_forwarded_argv
#

args.ts view source

(command: string, raw_rest_args: readonly string[]): string[] import {to_forwarded_argv} from '@fuzdev/gro/args.js';

Gets the verbatim args forwarded to the outside tool command, unparsed, from the section after a -- whose first arg is command, the last one when several are. Given gro check -- eslint --max-warnings -1 -- tsc --noEmit, 'eslint' returns ['--max-warnings', '-1']. Gro tasks get parsed args with to_forwarded_args instead. A literal -- can't be forwarded, as it separates the sections.

command

the tool's CLI name, the section's first arg

type string

raw_rest_args

the CLI args from the first -- on, from to_raw_rest_args

type readonly string[]

returns

string[]

the args after command, empty when no section names it

to_forwarded_flag_value
#

args.ts view source

(forwarded_argv: string[], name: string, short?: string | undefined): string | null import {to_forwarded_flag_value} from '@fuzdev/gro/args.js';

Gets the value of the last flag name in forwarded_argv, by a scan, not a parse: --name value or --name=value, and for a one-character short, -short value or -shortvalue, not inside a group of short flags like -wo dir.

forwarded_argv

the verbatim forwarded args, from to_forwarded_argv

type string[]

name

the long flag name without dashes

type string

short?

the one-character short flag name, if any

type string
optional

returns

string | null

the value, or null when the flag is absent or has no value

to_gen_result
#

gen.ts view source

(origin_id: PathId, raw_result: RawGenResult): GenResult import {to_gen_result} from '@fuzdev/gro/gen.js';

Normalizes what a genfile returned into its output files.

origin_id

type PathId

raw_result

returns

GenResult

throws

  • `TaskError` - for a result that's not a `RawGenResult`, like a file whose `content` isn't a string, naming the genfile and what it returned
  • `Error` - for an invalid or duplicate output file name

to_git_program
#

git.ts view source

(spawn: Spawn, options?: SpawnProgramOptions | undefined): SpawnProgram import {to_git_program} from '@fuzdev/gro/git.js';

Finds git for a composition root, on PATH only, so a node_modules/.bin/git can't shadow it.

spawn

the root's spawn host module

type Spawn

options?

the program's environment, fixed when its handle is made

optional

returns

SpawnProgram

throws

  • `TaskError` - if `git` isn't on `PATH`

to_gro_package_dir
#

paths.ts view source

internal

(module_path: PathId): string import {to_gro_package_dir} from '@fuzdev/gro/paths.js';

Finds the Gro package directory from the path of Gro's own paths module, by its location in the package (src/lib/paths.ts from source, dist/paths.js built), so a checkout or worktree of any name works.

module_path

the absolute path of Gro's paths module

type PathId

returns

string

the package directory with a trailing slash

to_implicit_forwarded_argv
#

args.ts view source

(task_name: string, cli_args: readonly string[], root: string, command?: string | undefined): string[] import {to_implicit_forwarded_argv} from '@fuzdev/gro/args.js';

Gets the verbatim args of the first section after a -- for a tool run by task_name without naming it, like gro test -- --watch for vitest, only when task_name is the task the CLI invoked, so a nested task gets none. A first section starting with gro (a Gro task's) or with command (an explicit section, read by to_forwarded_argv) is none.

task_name

the asking task's name, a builtin name or a normalized task path

type string

cli_args

the args after the CLI's own path, as in process.args

type readonly string[]

root

the project root a task path in cli_args is relative to

type string

command?

the tool's CLI name, whose explicit section isn't implicit

type string
optional

returns

string[]

the first section's args, empty when absent or not for task_name

to_input_path
#

input_path.ts view source

(raw_input_path: RawInputPath, root_path: string): InputPath import {to_input_path} from '@fuzdev/gro/input_path.js';

Raw input paths are paths that users provide to Gro to reference files for gen.

A raw input path can be to a file or directory in the following forms:

  • an absolute path, preserved
  • an explicit relative path, e.g. ./src/foo, resolved to root_path
  • an implicit relative path, e.g. src/foo, preserved

Thus, input paths are either absolute or implicitly relative.

raw_input_path

root_path

type string

returns

InputPath

to_input_paths
#

input_path.ts view source

(raw_input_paths: RawInputPath[], root_path: string): InputPath[] import {to_input_paths} from '@fuzdev/gro/input_path.js';

raw_input_paths

root_path

type string

returns

InputPath[]

to_install_program_options
#

npm_install_helpers.ts view source

(): SpawnProgramOptions import {to_install_program_options} from '@fuzdev/gro/npm_install_helpers.js';

The options of the program that runs an install: every host variable but the pruning ones.

The pruning names are absent, not set to empty, as an empty NODE_ENV is a different value to a lifecycle script, and the host's LC_ALL stays exactly as it is, unset included, since an empty one changes the locale a Node lifecycle script gets.

returns

SpawnProgramOptions

the options for spawn.program, given on a root since a narrowed one refuses 'all'

to_output_file_name
#

gen.ts view source

(filename: string): string import {to_output_file_name} from '@fuzdev/gro/gen.js';

filename

type string

returns

string

to_plugin_context
#

plugin.ts view source

<TArgs>(ctx: TaskContext<TArgs>, dev: boolean, watch: boolean): PluginContext<TArgs> import {to_plugin_context} from '@fuzdev/gro/plugin.js';

Widens a TaskContext to a PluginContext by adding dev and watch. Copies property descriptors rather than spreading, because svelte_config is a lazy getter - spreading would call it, resolving the Svelte config even for a plugin set that never reads it, and pinning whichever promise it returned instead of the memoized one.

ctx

type TaskContext<TArgs>

dev

type boolean

watch

type boolean

returns

PluginContext<TArgs>

generics

to_plugin_context<TArgs>
TArgs

to_raw_rest_args
#

args.ts view source

(cli_args: readonly string[]): string[] import {to_raw_rest_args} from '@fuzdev/gro/args.js';

Gets the array of raw string args starting with the first --, if any. gro run <path> ...rest has none, as everything after the path is the script's.

cli_args

the args after the CLI's own path, as in process.args

type readonly string[]

returns

string[]

to_root_path
#

paths.ts view source

(id: PathId): string import {to_root_path} from '@fuzdev/gro/paths.js';

id

type PathId

returns

string

to_search_filters_relative
#

paths.ts view source

(search_filters: PathFilter | PathFilter[] | null | undefined, root: string, search_dir?: string | undefined): PathFilter[] import {to_search_filters_relative} from '@fuzdev/gro/paths.js';

Binds search_filters to the project root, so each filter tests the path relative to root rather than the absolute id, the same path whichever directory a search starts in, and a project under a .-prefixed directory like ~/.cache/ still finds its files. A path outside root but under search_dir is tested relative to search_dir, so a search of a directory outside the project, like ~/.cache/other/src, finds its files too, and any other path is tested as its absolute id.

search_filters

the filters each file and directory must pass, usually config.search_filters

type (PathFilter) | (PathFilter)[] | null | undefined

root

the project root the paths are relative to, usually paths.root

type string

search_dir?

the directory being searched, the base for the paths outside root

type string
optional

returns

PathFilter[]

filters for fs_search, which passes them absolute ids

to_sibling_hint
#

resolve_specifier.ts view source

internal

(path_id: PathId, specifier: string): SiblingHint | null import {to_sibling_hint} from '@fuzdev/gro/resolve_specifier.js';

Finds the file a missing path_id likely meant, when it exists: .ts in place of .js or .js in place of .ts, or for a path with no extension, .ts or .js appended. Shared by the resolver's refusal and the loader's subpath imports, so each names the fix the same way.

path_id

the missing path specifier names

type PathId

specifier

the specifier as written, optionally ending in ?raw, which the fix keeps

type string

returns

SiblingHint | null

the sibling and the hint, or null when no sibling exists

to_signal_exit_code
#

gro_helpers.ts view source

(signal: string): number import {to_signal_exit_code} from '@fuzdev/gro/gro_helpers.js';

The exit code for a child killed by signal, 128 plus its number, like a shell.

signal

a signal name from a SpawnResult, like SIGTERM

type string

returns

number

to_spawn_result_message
#

cli.ts view source

(result: SpawnResult): string import {to_spawn_result_message} from '@fuzdev/gro/cli.js';

Formats how a program ended, for an error message.

result

returns

string

to_specifier_path_id
#

resolve_specifier.ts view source

(specifier: string, importer: PathId): PathId import {to_specifier_path_id} from '@fuzdev/gro/resolve_specifier.js';

The path a relative or absolute specifier names, whether or not it exists.

specifier

a relative or absolute path, optionally ending in ?raw

type string

importer

the path of the importing module

type PathId

returns

PathId

to_task_args
#

args.ts view source

(cli_args: readonly string[]): CliTaskArgs import {to_task_args} from '@fuzdev/gro/args.js';

Parses the task and its args from the CLI args, ignoring anything after any --. gro task <path> consumes one more positional, the path, and refuses a flag before it. gro run [--help] <path> ...rest refuses any other flag before the path and appends the path and rest verbatim to the positionals, unparsed and including any --, so the script gets exactly what follows its path.

cli_args

the args after the CLI's own path, the task name first, as in process.args

type readonly string[]

returns

CliTaskArgs

throws

  • TaskError - when a flag replaces the positional args, like `--_` or `--no-_`, `gro run` has a flag other than `--help` before its path, or `gro task` has a flag before its path or one other than `--help` with none

to_task_command
#

task.ts view source

(name: string): string import {to_task_command} from '@fuzdev/gro/task.js';

The command that runs the task name, a builtin name or a normalized task path, which is also the key its forwarded args are given by, like gro check -- gro task src/x.task.ts --a.

name

type string

returns

string

to_task_path
#

task.ts view source

(path: string, root: string): string import {to_task_path} from '@fuzdev/gro/task.js';

Normalizes a task path to be relative to root, the form tasks are displayed, keyed, and forwarded args by. A relative path is relative to root, with or without a leading ./.

path

a relative or absolute task path

type string

root

the project root

type string

returns

string

TS_MATCHER
#

TSCONFIG_FILENAME
#

update_changelog
#

changelog.ts view source

(owner: string, repo: string, fetch: { (input: RequestInfo | URL, init?: RequestInit | undefined): Promise<Response>; (input: string | Request | URL, init?: RequestInit | undefined): Promise<...>; }, fs_paths: FsPaths, path?: string, token?: string | undefined, log?: Logger | undefined, cache?: FetchValueCache): Promise<...> import {update_changelog} from '@fuzdev/gro/changelog.js';

Updates a changelog produced by @changesets/changelog-git with better links and formatting. It's similar to @changesets/changelog-github but doesn't require a token for light usage. This may be better implemented as a standalone dependency as an alternative to @changesets/changelog-git.

owner

type string

repo

type string

fetch

the fetch the GitHub API requests go through, handed in by the caller

type { (input: RequestInfo | URL, init?: RequestInit | undefined): Promise<Response>; (input: string | Request | URL, init?: RequestInit | undefined): Promise<...>; }

fs_paths

reads and writes the changelog, handed in by the caller

type FsPaths

path?

absolute, or relative to the fs_paths project

type string
optional default 'CHANGELOG.md'

token?

type string
optional

log?

type Logger
optional

cache?

type FetchValueCache
optional default new Map()

returns

Promise<boolean>

boolean indicating if the changelog changed

updated
#

validate_build_cache
#

build_cache.ts view source

(fs_paths: FsPaths, metadata: { version: string; git_commit: string | null; build_cache_config_hash: string; gro_version: string; runtime_version: string; package_lock_hash: string | null; timestamp: string; outputs: { ...; }[]; }): Promise<...> import {validate_build_cache} from '@fuzdev/gro/build_cache.js';

Validates that a cached build is still valid by checking stats and hashing outputs. Uses size as a fast negative check before expensive hashing. This is comprehensive validation to catch manual tampering or corruption.

fs_paths

opens each output, relative to the project

type FsPaths

metadata

returns

Promise<boolean>

validate_gen_module
#

gen.ts view source

(mod: Record<string, any>): mod is GenfileModule import {validate_gen_module} from '@fuzdev/gro/gen.js';

mod

type Record<string, any>

returns

boolean

validate_gro_config_module
#

gro_config.ts view source

(config_module: any, config_path: string): asserts config_module is GroConfigModule import {validate_gro_config_module} from '@fuzdev/gro/gro_config.js';

config_module

type any

config_path

type string

returns

void

validate_task_module
#

task.ts view source

(mod: Record<string, any>): mod is TaskModule import {validate_task_module} from '@fuzdev/gro/task.js';

Whether a module is a task module, exporting a task with a run function.

mod

the imported module

type Record<string, any>

returns

boolean

version
#

VITE_CLI
#

VITE_CONFIG_FILENAMES
#

constants.ts view source

string[] import {VITE_CONFIG_FILENAMES} from '@fuzdev/gro/constants.js';

Every filename Vite picks up as its config, in Vite's own precedence order. Which one wins is Vite's call, so Gro treats them as a set rather than privileging one extension - it detects a Vite config with all of them, and formats all of them.

see also

VITEST_CLI
#

watch
#

watch.ts view source

Watch import {watch} from '@fuzdev/gro/watch.js';

The watch host module's root. Import it where authority enters (a task, a script, an entry module), with the fs handle it watches.

Watch
#

watch.ts view source

Watch import type {Watch} from '@fuzdev/gro/watch.js';

The watch host module's root.

dir

Watches the directory a handle is on, resolving once the watch is in place, with no event for what was already there.

type (dir: FsReadDir, options?: WatchDirOptions | undefined): Promise<Watcher>

dir

the handle to watch, read-only or not

options?

optional
returns Promise<Watcher>

throws

  • `FsError` - `not_found`, `not_a_directory`, `permission_denied`, `outside_root`, or `io_error`, as listing the handle's directory throws, and for a directory removed or replaced before the watch is in place
  • `TypeError` - for a handle without an absolute `path`, or an invalid option
  • the - `signal`'s reason, when it aborts before the watch is in place

WatchChange
#

watch.ts view source

WatchChange import type {WatchChange} from '@fuzdev/gro/watch.js';

A change to an entry beneath a watched directory.

kind

add for an entry that appeared, update for a non-directory whose contents or metadata changed, delete for one that's gone.

type "add" | "update" | "delete"

readonly

path

The entry's path relative to the watched handle, /-separated.

type string

readonly

is_directory

Whether the entry is a directory; a symlink is not, whatever it points at.

type boolean

readonly

WatchDirOptions
#

watch.ts view source

WatchDirOptions import type {WatchDirOptions} from '@fuzdev/gro/watch.js';

The options of watch.dir.

recursive?

Whether the directories beneath are watched too, defaults to false, which reports the directory's own entries, a subdirectory's add and delete included.

type boolean

signal?

Ends the watch when it aborts. Before watch.dir resolves, the call rejects with its reason; after, the iteration ends.

type AbortSignal

max_pending?

How many events not yet read are buffered before they're dropped for one rescan of '', a positive safe integer, defaults to 4096.

type number

Watcher
#

watch.ts view source

Watcher import type {Watcher} from '@fuzdev/gro/watch.js';

A running watch: an async iterable of its events, read once.

inheritance

extends: AsyncIterable<WatchEvent>,AsyncDisposable

close

Ends the watch, dropping the events not yet read. Resolves once nothing of it is left running.

type (): Promise<void>

returns Promise<void>

WatchEvent
#

WatchOptions
#

module_graph.ts view source

WatchOptions import type {WatchOptions} from '@fuzdev/gro/module_graph.js';

What a ModuleGraph watches, from GroConfig.watch.

dir

The directory to watch, which holds the project modules. Files outside it enter the graph only when a project module imports them.

type PathId

filter

Excludes the paths it rejects from the change events and from the project modules. It's called with absolute paths, unlike GroConfig.search_filters, which get paths relative to the project root. It filters events, not the directory walk: a rejected directory is still watched, so each path below it is filtered on its own.

type (PathFilter) | null

WatchRescan
#

watch.ts view source

WatchRescan import type {WatchRescan} from '@fuzdev/gro/watch.js';

Changes beneath path may have been missed, so its state is to be read again.

kind

type "rescan"

readonly

path

The directory to read again, relative to the watched handle, '' for all of it.

type string

readonly

write_gen_results
#

gen.ts view source

(fs_paths: FsPaths, gen_results: GenResults, analyzed_gen_results: AnalyzedGenResult[], log: Logger): Promise<void> import {write_gen_results} from '@fuzdev/gro/gen.js';

Writes the new and changed outputs of the successful genfiles.

fs_paths

opens the outputs, which must resolve beneath its project

type FsPaths

gen_results

analyzed_gen_results

log

type Logger

returns

Promise<void>

throws

  • `TaskError` - for an output outside the project or at the project directory itself