import { withStandardBuilder, withStandardUsage } from '@-xun/cli/extensions'; import { DefaultGlobalScope } from "./configure.js"; import type { AbsolutePath } from '@-xun/fs'; import type { GenericProjectMetadata, Package, ProjectMetadata, RawAlias, RawAliasMapping, RawPath } from '@-xun/project'; import type { DotenvConfigOptions, DotenvParseOutput } from 'dotenv'; import type { ExtendedDebugger, ExtendedLogger } from 'rejoinder'; import type { Jsonifiable, LiteralUnion, Merge } from 'type-fest'; import type { TransformerContext } from "./assets.js"; import type { GlobalCliArguments, GlobalExecutionContext } from "./configure.js"; /** * A function that receives the current {@link ProjectMetadata} and must return * an array of {@link RawAliasMapping}s. * * Note that import map files can export via default either * `RawAliasMapperFunction` or a {@link RawAliasMapperArray}. * * @see {@link ImportedAliasMap} */ export type RawAliasMapperFunction = (projectMetadata: ProjectMetadata, outputFunctions: { log: ExtendedLogger; debug: ExtendedDebugger; }) => RawAliasMapperArray; /** * An array of {@link RawAliasMapping}s. * * Note that import map files can export via default either * `RawAliasMapperArray` or a {@link RawAliasMapperFunction}. * * @see {@link ImportedAliasMap} */ export type RawAliasMapperArray = [Merge, Merge][]; /** * Represents the result of importing an import map file. * * Note that import map files can export via default either * {@link RawAliasMapperFunction} or a {@link RawAliasMapperArray}. */ export type ImportedAliasMap = RawAliasMapperArray | RawAliasMapperFunction; /** * Magic string used to denote the beginning of a replacer region in Markdown * files processed by symbiote. * * Note that this string describes a regular expression that can be used to * match region start comments containing an ID parameter. */ export declare const magicStringReplacerRegionStart: string; /** * Create a magic string that denotes the beginning of a replacer region in * Markdown files processed by symbiote. Note that `id` is NOT escaped. */ export declare function makeMagicStringReplacerRegionStartWithId(id: string): string; /** * Magic string used to denote the beginning of a replacer region in Markdown * files processed by symbiote. */ export declare const magicStringReplacerRegionEnd = ""; /** * A regular expression that will match a replacer region in a string. Contains * two unnamed matching groups: `id` and `contents`. */ export declare const replacerRegionMatcherRegExp: RegExp; /** * Create a regular expression that will match a specific replacer region in a * string. Contains one unnamed matching group by default: `contents`. * * Note that `id` is NOT escaped. */ export declare function makeReplacerRegionIdMatcherRegExp(id: string, { includeMagic }?: { /** * If `true`, the start and end comments that denote the beginning and the * end of the region will be included in the match (and therefore subject to * replacement). If `false`, they will not be included in the match; * however, their newlines will be, so take that into account when * generating replacement content. * @default true */ includeMagic?: boolean; }): RegExp; /** * Magic string used to denote the beginning of a chooser block in Markdown * files processed by symbiote. */ export declare const magicStringChooserBlockStart = ""; /** * Magic string used to denote the end of one choice and the start of another in * Markdown files processed by symbiote. */ export declare const magicStringChooserBlockSplit = "\u2704------------\u2704-----------\u23F6-\u23F7-----------\u2704------------\u2704"; /** * Magic string used to denote the end of a chooser block in Markdown * files processed by symbiote. */ export declare const magicStringChooserBlockEnd = ""; /** * A version of {@link withStandardBuilder} that expects `CustomCliArguments` to * extend {@link GlobalCliArguments} and implements any related global handler * functionality. * * {@link globalCliArguments} is included in `additionalCommonOptions` * automatically. See {@link withStandardBuilder} for more details on how this * function semi-deep merges various common option configurations. */ export declare function withGlobalBuilder>(...[customBuilder, settings]: Parameters>): ReturnType>; export { withStandardUsage as withGlobalUsage }; /** * This function runs common checks against the runtime to ensure the * environment is suitable for running symbiote. * * This function should be called at the top of just about every command * handler. * * This command also asserts that the `projectMetadata` property is defined by * returning it (or throwing a {@link CliError} if undefined). */ export declare function runGlobalPreChecks({ standardDebug: standardDebug, projectMetadata_, scope }: { standardDebug: GlobalExecutionContext['standardDebug']; projectMetadata_: GlobalExecutionContext['projectMetadata']; scope: LiteralUnion; }): Promise<{ projectMetadata: NonNullable; }>; /** * If `gitStatusOutput` is not empty or `gitStatusExitCode` is non-zero, then * the current working tree is dirty. This can be checked quickly via the * `isDirty` property. */ export declare function determineRepoWorkingTreeDirty(): Promise<{ gitStatusOutput: string; gitStatusExitCode: number | undefined; isDirty: boolean; }>; /** * Returns all dotenv file paths relevant to the current package in reverse * order of precedence; the most important dotenv file will be last in the * returned array. * * Use `scope` (default: `"both"`) to narrow which dotenv paths are returned. */ export declare function getRelevantDotEnvFilePaths(projectMetadata: GenericProjectMetadata | undefined, scope?: 'both' | 'package-only' | 'project-only'): AbsolutePath[]; /** * Performs regional replacement on a Markdown file's contents, including * overwriting existing non-numeric reference definitions that match those * generated by the template (and leaving the others). */ export declare function replaceRegionsRespectively({ templateContent, outputPath, context: { debug, log, forceOverwritePotentiallyDestructive } }: { /** * The compiled template contents (typically the result of calling * `compileTemplate`). */ templateContent: string; /** * The path to a potentially-existing file, potentially with replaceable * regions. */ outputPath: AbsolutePath; context: TransformerContext; }): Promise; /** * Return pathspecs for including only certain paths for consideration depending * on the project structure and the current working directory. * * This function takes into account {@link WorkspaceAttribute.Shared} packages * and is useful for narrowing the scope of tooling like xchangelog and * xrelease. */ export declare function deriveScopeNarrowingPathspecs({ projectMetadata: { cwdPackage, rootPackage, type } }: { projectMetadata: ProjectMetadata; }): string[]; /** * Returns a codecov flag consisting of the current branch name and package id. */ export declare function deriveCodecovPackageFlag(cwdPackage: Package): Promise<{ currentBranch: string; flag: string; }>; /** * @see {@link upstreamLogStartTime} */ export declare function logStartTime(options: { standardLog: ExtendedLogger; startTime: Date; isUsingLocalInstallation: boolean; }): void; export type LoadDotEnvSettings = { log: ExtendedLogger; /** * Variables from files earlier in this list will be overwritten by * variables from files later in the list. */ dotEnvFilePaths: AbsolutePath[]; /** * If `true`, do not throw on errors. */ force: boolean; /** * Further instructions for the user upon environment validation failure. */ failInstructions: string; /** * Action to take upon environment validation failure. */ onFail: () => void; /** * If `true`, loaded environment variables will be added to `process.env` * with respect to `override`, and this function will return `void`. If * `false`, the environment variables will be returned instead and * `override` is ignored. * * @default true */ updateProcessEnv?: boolean; } & Pick; /** * @see {@link loadDotEnv} */ export type LoadDotEnvSimplifiedSettings = Merge; /** * Loads environment variables from the given `dotEnvFilePaths` files, with * variables from files earlier in the list being overwritten by variables from * files later in the list. * * `process.env` will be updated, and then an object containing only the loaded * environment variables is returned. * * **Note that this function internally caches the result of loading the dotenv * files, meaning they'll only be read once.** */ export declare function loadDotEnv(settings: LoadDotEnvSimplifiedSettings & { updateProcessEnv?: true; }): DotenvParseOutput; /** * Loads environment variables from the given `dotEnvFilePaths` files, with * variables from files earlier in the list being overwritten by variables from * files later in the list. * * An object containing only the loaded environment variables is returned. * **`process.env` will NOT be updated!** * * **Note that this function internally caches the result of loading the dotenv * files, meaning they'll only be read once.** */ export declare function loadDotEnv(settings: LoadDotEnvSimplifiedSettings & { updateProcessEnv: false; }): DotenvParseOutput; /** * Loads environment variables from the given `dotEnvFilePaths` files, with * variables from files earlier in the list being overwritten by variables from * files later in the list. * * `process.env` will be updated, and the resulting environment object (after * `overrides` and `updateProcessEnv` are considered) will be checked for the * existence of the variables in `expectedEnvironmentVariables`. If the check is * successful, an object containing only the loaded environment variables is * returned. Otherwise, an error is thrown. * * **Note that this function internally caches the result of loading the dotenv * files, meaning they'll only be read once.** */ export declare function loadDotEnv(expectedEnvironmentVariables: string[], settings: LoadDotEnvSettings & { updateProcessEnv?: true; }): DotenvParseOutput; /** * Loads environment variables from the given `dotEnvFilePaths` files, with * variables from files earlier in the list being overwritten by variables from * files later in the list. * * The resulting environment object (after `overrides` and `updateProcessEnv` * are considered) will be checked for the existence of the variables in * `expectedEnvironmentVariables`, but **`process.env` will NOT be updated!**. * If the check is successful, an object containing only the loaded environment * variables is returned. Otherwise, an error is thrown. * * **Note that this function internally caches the result of loading the dotenv * files, meaning they'll only be read once.** */ export declare function loadDotEnv(expectedEnvironmentVariables: string[], settings: LoadDotEnvSettings & { updateProcessEnv: false; }): DotenvParseOutput; /** * Used by renovate and init project-level commands to load additional raw * aliases from import map files. */ export declare function importAdditionalRawAliasMappings(projectMetadata: ProjectMetadata, outputFunctions: { log: ExtendedLogger; debug: ExtendedDebugger; }): Promise; /** * Take a JavaScript object and return its stringified form with some semblance * of proper formatting. Also appends a newline. */ export declare function stringifyJson(o: Jsonifiable, spaceTabs?: number): string; export declare function readFile(path: string): Promise; export declare function writeFile(path: string, contents: string): Promise; export declare function copyFile(from: string, to: string): Promise; export declare function makeDirectory(path: string): Promise; export declare function __read_file_sync(path: string): string; export declare function __write_file_sync(path: string, contents: string): void; export declare function hasExitCode(error: unknown): error is object & { exitCode: number; }; /** * The value populating the SYMBIOTE_SPECIAL_INITIAL_COMMIT environment variable * when there was no special initialization commit reference found. */ export declare const noSpecialInitialCommitIndicator = "N/A"; /** * Return the commit-ish (SHA hash) of the most recent commit containing the * Xpipeline command suffix `[INIT]`, or being pointed to by a * `${tagPrefix}0.0.0-init` version tag. If no such commit could be found, * {@link noSpecialInitialCommitIndicator} is returned. * * @see {@link XchangelogConfig} */ export declare function getLatestCommitWithXpipelineInitCommandSuffixOrTagSuffix(tagPrefix: string): Promise; /** * Returns `true` if `ref` is "more recent than" `moreRecentThan`. * * In other words: `true` is returned iff `moreRecentThan` is or points to a * commit that is an ancestor of `ref`. Returns `false` otherwise, including * when `ref === moreRecentThan`. */ export declare function isGitReferenceMoreRecent(ref: string, moreRecentThan: string): Promise;