import { Container } from "inversify";
import { Result } from "@codiac.io/codiac-common/contracts";
import { IdentitySet, TokenizedIdentity, ProjectUserConfig } from '@codiac.io/codiac-relay-contracts';
import { ProjectConfig, Submodule, ImageExport, PackageExport, RegistryTarget, PublishingMode } from '@codiac.io/codiac-relay-contracts';
import { Branch } from './entities/branch';
import { ImageBuildContext } from './entities/ImageBuildContext';
import { CliEnviro } from "./entities";
import { WorkspaceVersioner } from "./workspace-versioner";
export declare class LocalOps {
    private ioc;
    constructor(ioc: Container);
    get _projectRoot(): string;
    _cliEnviro: CliEnviro | undefined;
    get cliEnviro(): CliEnviro;
    private _projEnviro;
    private get projEnviro();
    private __projCfgRepo;
    private get _projCfgRepo();
    get _projCfg(): ProjectConfig;
    protected __projCfg: ProjectConfig | undefined;
    get _projUserCfg(): ProjectUserConfig;
    protected __projUserCfg: ProjectUserConfig | undefined;
    private __cliConfig;
    private get cliConfig();
    private _ux;
    private get ux();
    private _styler;
    private get styler();
    private __cliExec;
    private get _cliExec();
    private _logger;
    private get logger();
    get _workspaceVersioner(): WorkspaceVersioner;
    protected __workspaceVersioner: WorkspaceVersioner | undefined;
    /** Shows the ascii art product name and the version in the console */
    renderTitleBlock(): void;
    /**
     * ***OBSOLETE!!! Use CliPathWalker.getProjectRoot() instead!!***
     *
     * Gets the Toyhauler project root folder
     * that is in scope for the current working directory
     * or the given folder.
     * IMPORTANT: Throws by default when no Toyhauler config file exists up the parent folder chain.
     * @param folder (optional, defaults to current working directory) The folder containing the thaul config file, or any folder underneath that one.
     * @param errorWhenNotFound Setting to false will return an empty string if folder is not contained in a project root.
     *
     * @deprecated Use `CliPathWalker.getProjectRoot()` instead!
     */
    getConfigRoot(folder?: string, errorWhenNotFound?: boolean): string;
    /** Deserializes the Toyhauler config file in scope for the current working directory.
     * Throws if none is defined up the folder tree. */
    readCodiacProjectConfig(folder?: string): ProjectConfig;
    npmSyncIdentitiesWithNpmrc(...identities: TokenizedIdentity[]): Promise<void>;
    /** Deserializes the npm package.json file in the given directory.
     * Returns undefined if not found.
     * Throws if no toyhauler project is defined up the folder tree.
     * @param pkgRoot (Optional: defaults to the thaul project root) Fully qualified path to the folder containing the package.json file. */
    readNpmPackageJson(pkgRoot?: string, fileName?: string): any;
    /** Serializes the given object as the package.json for the project.
     * @param config the npm package.json as an object in memory.
     * @param projectRoot fully qualified target folder to write the package.json file (optional: defaults to the thaul project root)
    */
    writeNpmPackageJson(config: packageJson, projectRoot?: string): packageJson;
    /** Deletes the package.json file in the project root. */
    deleteNpmPackageJson(): void;
    /** Deletes the package.json file in the project root. */
    clearNpmNodeModulesFolder(): void;
    /** Retrieves a list of all production dependencies for the npm project with the given root folder.
     * @param projectRoot The fully qualified pathg to the folder containing the package.json file.
    */
    getNpmDependencies(projectRoot: string): Promise<string[]>;
    /** Instantiates the tsconfig.json object from its file in the project root.
     * NOTE: Returns undefined if no tsconfig.json is found.
     * @param typescriptRoot (optional: defaults to main project root) Fully qualified path to the folder containing the typescript config file to load.
    */
    readTsConfig(typescriptRoot?: string): tsconfigJson | undefined;
    /** Retrieves the fully qualified local path to the root folder
     * of the source control repository clone
     * (aka: the folder into which the repo was originally cloned).
     * Though it is best that this folder coincide with the toyhauler project root,
     * there are cases where it may not, such as with submodules,
     * or subfolders that contain their own typescript and npm configs.
     * @param projectRoot Fully qualified local path to the root of the thaul project (aka: nearest upstream folder containing a .codiac.json) */
    getRepoRoot(projectRoot: string): Promise<string>;
    APP_CONFIG_FILENAME: string;
    /** Array of built-in app config keys that are supported by the api framework. */
    AVAIL_CONFIG_KEYS_FILENAME: string;
    /** Deserializes the app config file if it exists
     * @param relFolder The folder relative to the root to read from:
     * eg: Either the project source folder "./src" or the build output folder "/bin".
     */
    loadConfig(relFolder?: string): any;
    /** Serializes the app config object to a file. */
    writeConfig(appConfig: any): void;
    deleteConfigFile(): void;
    /** Loads the list of names of the built in app-config settings
     * supported by the framework
     * (Reads from a json file in the cli executable folder). */
    loadConfigKeys(
    /** Path to the folder containing the CLI executable
     * (from an oclif Command class, use "this.config.root"). */
    execRoot: string): string[];
    /** Synchronously deletes the given file.  Throws any exceptions.
     * @param relPathName Path and filename of file relative to the project root
     *  (eg: "src/app-config.json").
    */
    deleteProjectFile(relPathName: string): void;
    /** Synchronously deletes all contents of the given folder without deleting the folder itself.
     * Throws any exceptions.
     * @param relPathName Path of target folder relative to the project root
     *  (eg: "src/my-outdated-stuff").
    */
    clearProjectFolder(relPathName: string): void;
    /** Reads the current version of the main project.
     * Uses npm's package.json as the system of record for the version. */
    npmGetCurrentVersion(pkgRoot?: string): string;
    getCodeVersion(pkgRoot?: string): Promise<string>;
    /** Loads the source code for the given repo as a git submodule of the project.
     * DOES NOT interface with npm or any other tool - just git.
     * @param packageName The official name of the project dependency whose repo is being submoduled (including any scope prefix, eg: "@codiac/").
     * @param cloneUrl The url of the git repo that will be used to pull the source code.
     * @param lastPkgVersion The version of its package that the project is currently depending on.
     * @param nameOverride (optional: defaults to the repo name) The unique identifier for this submodule within the current project.
     */
    addSubmodule(cloneUrl: string, packageName: string, lastPkgVersion?: string, nameOverride?: string, branch?: string): Promise<Submodule>;
    /** Replaces the installed package of the dependency with the local submodule folder as the source of the code references.
     * ie: allows the developer to debug the submoduled source code instead of the code that was installed from the package.
     * NOTE:  There is no guarantee that the submodule code being linked
     *        matches that of the installed dependency.
     * @param submodule A valid dependency sourced into the project.
     */
    symLinkSubmodule(submodule: Submodule): Promise<void>;
    /** Reverts a linked submodule reference back to the installed package dependency.
     * @param name Unique identifier in this project for the submodule (typically the package name).
     */
    unSymLinkSubmodule(name: string): Promise<void>;
    /**  Fully exorcises a git submodule from the project.
     * Returns the submodule object that was removed.
     * NOTE:  Does NOT remove the project package dependency that corresponds to the submodule.
     *
     * @param name Unique identifier in this project for the submodule (typically the package name without any scope prefix).
     * @param discardChanges Discards all uncommitted changes (staged and unstaged) before unsourcing, and goes back to the previously installed version of the dependency.  Again, uncomitted changes are LOST when this flag is set!
     */
    removeSubmodule(name: string, discardChanges?: boolean): Promise<Submodule>;
    /** Returns a valid submodule object from the given name or prompts for one.
     * Guarantees a valid submodule reference, an undefined, or throws an exception.
     * NOTE: The user can also cancel the operation entirely (CTRL-C), which will exit the whole process itself.
     * @param actionIntended The verb for the process for which the submodule is being selected.  (eg: 'remove' which will get used in user prompt as '...please select the dependency source to remove...')
     * @param name Unique identifier in this project for the submodule (typically the package name).
     * @param projectConfig The toyhauler settings for the current project.
     */
    protected chooseSubmodule(actionIntended: string, name?: string, projectConfig?: ProjectConfig): Promise<Submodule | undefined>;
    /** npm sends its warnings down the stderr pipe rather than stdout,
     * so we have to parse it to find out if it is indeed an error.
     * Fortunately they prefix them with "npm WARN" or "npm ERR!".
     */
    npmStdErrIsJustAWarning(stderr: string): boolean;
    protected buildVersionTag(mainVersionNumber: string, workingFolder: string): Promise<string>;
    /** Creates and publishes to the npm registry any configured npm packages
     * for the main project and its sourced dependencies.
     * NOTE:  Determines whether to publish based on the occurrence of commits since the last package date.
     * @param force Publishes regardless of whether package contents have changed or not.
     * */
    npmPublish(force?: boolean): Promise<void>;
    /** Determines whether the given npm module has changes
     *  that require the package to be rebuilt.
     *  Used to gate the publish of a package to avoid unnecessary processing. */
    protected npmIsPublishable(workingFolder: string, fullPackageName: string, version: string): Promise<boolean>;
    /** Installs any missing dependency packages. */
    dependencyInstallAll(): Promise<void>;
    dependencyInstall(name: string, version?: string): Promise<void>;
    /**
     * Sources a new dependency into the project
     * from an existing repo url,
     * initializes it with npm if it is not already,
     * publishes the npm package if it does not already exist,
     * and sources the dependency.
     * Uses the version currently specified in its package.json
     * for the dependency reference in this project.
     *
     * @param cloneUrl The official clone url for the repository.
     * @param branch The source code branch to switch the dependency to.
     * @param packageName (Optional: defaults to the repo name) The globally unique name to use for the npm package if initializing npm, including any scope prefix, eg: "@codiac/").
     * @param initVersion (Optional: defaults to the built in initial version number 0.0.0-1) The version number to use if initializing npm for the dependency.
     */
    dependencyAuthorNew(cloneUrl: string, packageName: string, branch?: string, initVersion?: string): Promise<void>;
    dependencyUpgrade(dep: string, version?: string): Promise<void>;
    /** Forces local source control to refresh its status
     * and returns true when uncommitted changes exist
     * on the local machine (staged AND unstaged)
     * for the git repo corresponding to the given working directory.
     * @param workingDirectory The fully qualified path in which to run the git status command.
     */
    private gitHasChanges;
    /** Returns a distinct list of branch names (without any prefixes such as "remotes/origin/").
     * @param remotes (optional: defaults to false) Flag to include remote branches.
     * @param locals (optional: defaults to true) Flag to include local branches.
     * @param repoRoot (optional: defaults to toyhauler project root) root folder of the repo being queried (used as the working folder for the git commands).
     */
    gitListBranches(remotes?: boolean, locals?: boolean, repoRoot?: string): Promise<string[]>;
    /** Returns a distinct list of branch names (without any prefixes such as "remotes/origin/").
     * @param branchName duh.
     * @param remotes (optional: defaults to false) Flag to include remote branches.
     * @param locals (optional: defaults to true) Flag to include local branches.
     * @param repoRoot (optional: defaults to toyhauler project root) root folder of the repo being queried (used as the working directory for the git commands).
     */
    gitBranchExists(branchName: string, remotes?: boolean, locals?: boolean, repoRoot?: string): Promise<boolean>;
    /** Switches the main project and any sourced dependencies to the given source code branch.
     * @param branchName duh.
     * @param autoCreate (optional: defaults to true) Turn this off to prevent creation of the branch in the sourced dependencies (if missing).  CAUTION: This will lead to sourced dependencies on different branches than the main project.
     * @param track (Optional: defaults to false) If autoCreate is set and branches are created, creates a matching upstream branch at origin.
    */
    gitSwitchToBranch(branchName: string, autoCreate?: boolean, track?: boolean): Promise<void>;
    /** Creates a new branch in repo rooted in the the given folder.  DOES NOT SWITCH TO IT.
     * @param branchName duh.
     * @param track (Optional: defaults to false) Creates a matching upstream branch at origin.
     * @param repoRoot (optional: defaults to toyhauler project root) root folder of the repo being queried (used as the working directory for the git commands).
    */
    gitCreateBranch(branchName: string, track?: boolean, repoRoot?: string): Promise<void>;
    /** Returns the current branch for the main proiject and any currently sourced dependencies. */
    gitEachCurrentBranch(): Promise<{
        [module: string]: Branch;
    }>;
    /** Retrieves just the abbreviated name of the current branch. */
    gitCurrentBranchNameFor(workingFolder: string): Promise<string | undefined>;
    /** Retrieves the current branch for the given folder.
     *  (Cuz git somehow makes that nontrivial).
     * @param workingFolder The folder from which to run the git command.  */
    protected gitCurrentBranchFor(workingFolder: string): Promise<Branch>;
    /** Merges the given branch with the current one
     * for the main project and all sourced dependencies.
     * @param branchName The branch to merge into the current one.
     * @param commit Commits if merge succeeds.  */
    gitMerge(branchName: string, commit?: boolean): Promise<void>;
    /** Syncs the current branch with the given branch by merging the given branch into it.  */
    gitSyncWith(branchToPullFrom: string, includeDependencies?: boolean, targetDependency?: string): Promise<void>;
    /** Lists uncommitted changed files (staged, unstaged, or both).
     * All paths are relative to the main project root.
     * (if both staged and unstaged are ignored, then both are returned)
     * @param unstaged Include unstaged files.
     * @param staged Include staged files.
     * @param repoRoot (optional: defaults to main project root) fully qualified path to the root folder of the cloned repo.
     */
    gitListChanges(status: "staged" | "unstaged" | "all", repoRoot?: string): Promise<string[]>;
    /** Stages the given files for a commit.
     * @param files (optional: defaults to "all") the space-delimited list of files to stage
     */
    gitStage(files?: string[]): Promise<void>;
    /** Removes the given files from the git commit index.
     * @param files (optional: defaults to "all") the space-delimited list of files to stage
     */
    gitUnstage(files?: string[]): Promise<void>;
    /** Stages or unstages the given files for/from a commit.
     * @param files (optional: defaults to "all") the space-delimited list of files to stage
     */
    protected gitPerformStaging(operation: "stage" | "unstage", files?: string[]): Promise<void>;
    /** Standard git clone call
    * @param url valid git url to clone from.
    * @param targetFolder relative path to the folder into which the repo is to be cloned.
    */
    gitClone(url: string, targetFolder?: string): Promise<void>;
    /** Debug-Logs any failure but doesn't throw errors.
    * @param directory Absolute folder path to open.
    */
    tryOpenVsCode(directory: string): Promise<void>;
    /** Commits the currently staged changes on the current branch
     * of the main project and on any sourced dependencies.
     * @param message The description for this particular commit.
     */
    gitCommit(message: string): Promise<void>;
    /** Returns the hash in the git log that identifies the most recent commit. */
    gitReadLatestCommitId(): Promise<string>;
    /** Pushes upstream any local commits on the current branch
     * of the main project and on any sourced dependencies.
     * @param only (optional, defaults to "all") The name of a specific sourced dependency to pull instead of everything in the project.  Pulls latest only for the sourced dependency specified by this parameter.
     */
    gitPushProject(only?: string): Promise<void>;
    private gitPush;
    /** Retrieves remote changesets on the current branch
     * of the main project and on any sourced dependencies.
     * @param only (optional, defaults to "all") The name of a specific sourced dependency to pull instead of everything in the project.  Pulls latest only for the sourced dependency specified by this parameter.
    */
    gitPull(only?: string): Promise<void>;
    /** Fails if the branch has pending changes or a pending merge status.
     * Set the discardChanges argument to ignore any pending status and force the delete.
     * @param branchName Must be a valid existing branch
     * @param discardChanges (optional: default = false) Ignores any pending changes or merge status and forces the delete of the branch.
     */
    gitDeleteBranch(branchName: string, discardChanges?: boolean): Promise<void>;
    private hasYetToBePublished;
    /** OBSOLETE!! Use build() instead. */
    typescriptBuild(newVersion?: VersionBump, buildDef?: string[], clear?: boolean): Promise<string>;
    /** Increments the version and builds each sourced dependency
     * and then the main project.
     * Returns the build number. */
    build(increment?: VersionBump, buildDef?: string[], clear?: boolean): Promise<string>;
    /** Bumps the version as specified.
     * NOTE!!!  Currently uses npm for this!
     *
     * ***TODO:  Move version persistence to image exports in codiac.json and get off of npm.***
     *
     * DEPRICATED! Codiac has no business modifiying npm
     */
    private npmIncrementVersion;
    /**
     * @param subm The sourced dependency project to build.
     * @param clear (Optional: defaults to false) Clears the output folder before build.
     */
    private buildSubmodule;
    /** Determines the build output folder as specified in the given tsconfig doc.
     * @param tsConfigFolder The root folder for the typescript project (contains the tsconfig.json file).
     * @param tsconfig The typescript configuration documetn for the project.
    */
    private getTsOutputFolder;
    private clearTsOutputFolder;
    private clearFolder;
    /** Builds the container image based on the given container definition file.
     * @param requestedFrameworkVersion (Optional: defaults to latest) Explicitly sets the version of the codiac base image to use.
     * @param noCache (Optional: defaults to false) Ignores the local Docker image cache, thereby forcing a fresh download of each image from its container registry layer in the build.
     * @param identitySet (Optional) The collection of the current user's auth tokens to inject into the build env (eg: for enabling private packages in npm).
     * @param targetStage (Optional) For images defined with multi-stage builds, the name of the only build stage to be built on this pass.
     * @param imagesToBuild (Optional) Limits the list of images to build.  Each value must match the name property of an image export defined in the codiac project file (codiac.json).  Ignored if empty.
     */
    buildProjectImages(buildNumber: string, versionBump?: VersionBump, requestedFrameworkVersion?: string, noCache?: boolean, identitySet?: IdentitySet, targetStage?: string, imagesToBuild?: string[]): Promise<void>;
    /** Currently conventional - check if the branch is main or master.
     *
     * TODO: This is too specific.  Make this configurable in the codiac.json, backed by the cli config, backed by this convention..
     */
    private isMainBranch;
    /**
     *
     * @param imageExport
     * @param thisVersion
     * @param noCache
     * @param cntx
     * @param targetStage (Optional) For an image defined with a multi-stage build, the name of the only build stage to be built on this pass.
     */
    buildSingleImage(imageExport: ImageExport, thisVersion: string, noCache: boolean, cntx: ImageBuildContext, targetStage?: string): Promise<void>;
    /**
     * Cherry Picking single property output from Docker inspection, and stored in the project > imgs > export cfg for:
     *    Os - needed to support multi-platform nodepooling
     *    Architecture - currently dont need it, but I have feeling it wont be long
     */
    private updateConfigWithImageMetaFromInspection;
    /** Housekeeping method that deletes any untagged images
     * that get leftover after multiple builds of the same image. */
    dockerPruneDanglingImages(): Promise<void>;
    /** Legacy logic to hydrate the build env and the npmrc file with token values. */
    private npmHydrateTokensInNpmrc;
    /** Retrieves the version of the api framework that is currently installed in the project
     * from the npm package.json dependencies list.
     * NOTE:  Removes any version-support prefixes (eg: ^).
     * NOTE: Returns "latest" when not installed. */
    private getInstalledFrameworkVersion;
    /** Constructs from scratch the contents of a dockerfile from which to build an image.
     * @param frameworkVersion The version of the api framework to use within the image.  That is, the api framework base image will need this version number applied to it.
     * @param distPath The path to the typescript output folder, relative to the project root (eg: "./dist").
     * @param prefixToProjRoot path prefix that, when applied to the image def file, resolves to the project root (ie: if using ".temp/jit.docker", this parameter would need to be "../") If this dockerfile exists within the project root itself, then any of "./" or "" or undefined are valid.
     * @param identities (Optional) The collection of tokenized identities registeed for the current user that are to be put into scope during the image build..
     */
    private generateDockerImageDef;
    declarePackageExport(config: ProjectConfig, target: RegistryTarget, sourceFile?: string): Promise<{
        package?: PackageExport;
        name?: string;
        operation: string;
    }>;
    /** Adds container image specifications to the project,
     * which will add the image spec into the build, publish, and deploy sequences.
     */
    declareImageExport(config: ProjectConfig, imageName: string, target: RegistryTarget, sourceFile?: string, port?: number, buildParams?: {
        [arg: string]: string | undefined;
    }): Promise<{
        image?: ImageExport;
        operation: string;
    }>;
    /** Returns the pedigree of the current branch
     *  starting with itself, through each parent, up to the root.  */
    gitBranchLine(startingBranch: string): Promise<string[]>;
    /** Returns the parent source code branch of the given one,
     * based on the commit history (because apparently git doesnt track branching history).
     * Returns undefined if the given branch has no parent (eg: master). */
    gitParent(branch: string): Promise<string | undefined>;
    /** Returns the parent source code branch of the given one,
     * based on the commit history (because apparently git doesnt track branching history).
     * Returns undefined if the given branch has no parent (eg: master). */
    gitParent_LinuxOnly(branch: string): Promise<string | undefined>;
    /** It is possible that a registry target has not been defined for the given params. */
    getTargetImageRegistry(imageConfig: ImageExport, remoteOrLocal: PublishingMode, branch: string): Promise<RegistryTarget | undefined>;
    /** Builds the container image based on the given container definition file.
     * @param targetRemote If set, publishes to the appropriate remote container registry
     *        mapped for the current branch, or to the local built-in container registry.  When not set, defaults to the previously set value, or to the system default of "local".
     * @param only (optional, defaults to "all") The name of a specific sourced dependency to pull instead of everything in the project.  Pulls latest only for the sourced dependency specified by this parameter.
     */
    projectPublishImages(targetRemote?: boolean, only?: string, imagesToPublish?: string[], username?: string, password?: string): Promise<void>;
    private publishImages;
    protected pushLegacy(): Promise<void>;
    /** This was lifted Copy-Paste from AzureContainerRegistryClient in the relay. */
    protected pushToAzure(fullImageId: string, registryDomain: string): Promise<Result>;
    /** Ensures that the current azure subscription matches the one that owns the registry for the given image. */
    setRelevantAzSubscription(): Promise<void>;
    /** Fires off the given commands
   * and commits the changes to source control.
   * @param commands The list of cli statements to execute
   * @param desc The comment applied to the commit; should be a description of the overall operation.
   * @param workingDirectory The fully qualified path from which to run the given commands and the source control commit statements...
   */
    protected execAndCommit(commands: string[], desc: string, workingDirectory: string): Promise<void>;
}
type packageJson = any;
type tsconfigJson = any;
export type VersionBump = {
    fullName?: string;
    major?: boolean;
    minor?: boolean;
    patch?: boolean;
    prerelease?: boolean;
    preId?: string;
};
export {};
