gg_lang library

Shared language catalog and project-type detection for the gg toolchain.

Classes

LanguageCatalog
The catalog of all language-specific commands, loaded from lib/src/assets/languages.json.
LanguageCommand
A single language-specific command, loaded from the language catalog.
LanguageSpec
All language-specific configuration for a single language.
Manifest
Reads and writes package metadata (name, version, publish marker) from a language manifest (pubspec.yaml / package.json), driven by a ManifestSpec so the field names and format never need to be hardcoded.
ManifestSpec
Describes where a language stores its package metadata (name, version, publish target).
MockManifest
A mocktail mock.
MockNpmRegistryResolver
A mocktail mock.
MockRegistry
A mocktail mock.
MockRegistryWaiter
A mocktail mock.
NpmRegistry
npm implementation (TypeScript) shelling out via the catalog command (npm view <name> versions --json).
NpmRegistryResolver
Resolves the npm registry a package actually publishes to, by asking the package manager for its merged .npmrc configuration.
PackageManagerSpec
Describes how a language's package manager wraps tool invocations.
PubDevRegistry
pub.dev implementation (Dart/Flutter) using the HTTP JSON API.
Registry
Looks up the latest version a package has published to its registry.
RegistryFactory
Builds the right Registry for a ProjectType / LanguageSpec, based on the language's RegistrySpec.kind.
RegistrySpec
Describes how to query the version a package has published to its registry.
RegistryWaiter
Polls a Registry until a published version becomes visible.

Enums

ProjectType
The kind of project gg is operating on.
PublishTarget
A public package registry gg can upload to.
TypeScriptPackageManager
The JavaScript/TypeScript package manager in use by a project.

Extensions

ProjectTypeX on ProjectType
Convenience predicates on ProjectType.
PublishTargetsX on Set<PublishTarget>
Convenience predicates on a set of PublishTargets.

Constants

languagesJsonSource → const String
The bundled languages.json catalog, embedded as a Dart constant.
npmjsStatusUrl → const String
The status page of the public npm registry, with a {name} placeholder.
pinnedNpmVersions → const Map<String, String>
npm packages gg holds at a fixed version instead of letting an upgrade carry them along.

Properties

allLockFileNames → Set<String>
All lock file names any supported language or package manager writes.
final

Functions

checkProjectType(Directory directory) → ProjectType
The ProjectType that gg's check pipeline (analyze / format / tests) should use for directory.
detectProjectType(Directory directory) → ProjectType
Detects the ProjectType of directory — which manifest the directory carries, not which pipeline gg should run on it. For the latter, use checkProjectType.
detectTypeScriptPackageManager(Directory directory) → TypeScriptPackageManager
Detects the TypeScriptPackageManager of directory by looking at the lockfiles present. Falls back to TypeScriptPackageManager.npm.
hasNpmManifest(Directory directory) → bool
Whether directory carries a package.json that is an npm manifest: a JSON object with a non-empty string name.
hasNpmScript(Directory directory, String name) → bool
Whether the package.json in directory declares an npm script named name.
hybridVersions(Directory directory, {LanguageCatalog? catalog}) → Future<({Version packageJson, Version pubspec})?>
The two manifest versions of the hybrid in directory, or null when directory is not a hybrid or either version cannot be parsed.
hybridVersionsDiffer(Directory directory, {LanguageCatalog? catalog}) → Future<bool>
Whether directory is a hybrid whose two manifests carry different versions.
isBridgeProject(Directory directory) → bool
Former name of isHybridProject, kept so callers keep compiling.
isHybridProject(Directory directory) → bool
Whether directory is a hybrid project — a repo that ships a Dart manifest (pubspec.yaml) and a TypeScript manifest (package.json) side by side.
isPrivateNpmPackage(Directory directory) → bool
Whether the package.json in directory sets "private": true.
lockFileFor(Directory directory) → String
Returns the dependency lock file name for the project in directory.
npmStatusUrlTemplate(String registryUrl) → String
Returns the human-facing page where the published versions of a package on registryUrl can be checked, as a template with a {name} placeholder.
publishTargetsOf(Directory directory, {LanguageCatalog? catalog}) → Future<Set<PublishTarget>>
The registries the package in directory publishes to.
readNpmDependencyNames(Directory directory) → Set<String>
The names of every dependency the package.json in directory declares — dependencies, devDependencies, peerDependencies and optionalDependencies.
readNpmScripts(Directory directory) → Map<String, String>
Reads the scripts section of the package.json in directory.

Exceptions / Errors

ManifestException
Thrown when a manifest field is missing or the manifest cannot be parsed.
RegistryException
Thrown on unexpected registry errors (non-404 HTTP status, npm non-zero exit that is not a "not found").