//#region imports
import { LibTypeEnum } from 'tnp-core/lib';
import { path, } from 'tnp-core/lib';
import { Helpers, HelpersTaon } from 'tnp-helpers/lib';
import { packageJsonMainProject, taonJsonMainProject, } from '../../constants';
import { BaseCli } from './base-cli';
//#endregion
// @ts-ignore TODO weird inheritance problem
export class $Open extends BaseCli {
    _() {
        Helpers.info('Opening folder...');
        let pathToFolder = this.firstArg;
        if (!pathToFolder) {
            pathToFolder = this.cwd;
        }
        if (!path.isAbsolute(pathToFolder)) {
            pathToFolder = this.project.pathFor(pathToFolder);
        }
        Helpers.openFolderInFileExplorer(pathToFolder);
        this._exit();
    }
    async CORE_CONTAINER() {
        if (!this.project?.framework?.coreContainer) {
            Helpers.error(`This is not taon project`);
        }
        await this.project?.framework?.coreContainer?.openInEditor();
        this._exit();
    }
    async CORE_PROJECT() {
        if (!this.project?.framework?.coreProject) {
            Helpers.error(`This is not taon project`);
        }
        await this.project?.framework?.coreProject?.openInEditor();
        this._exit();
    }
    async TNP_PROJECT() {
        if (!this.project?.ins?.Tnp) {
            Helpers.error(`This is not taon project`);
        }
        await this.project.ins.Tnp?.openInEditor();
        this._exit();
    }
    async UNSTAGE() {
        const proj = this.project.ins.Current;
        const childrenThanAreLibs = proj.children.filter(c => {
            return c.typeIs(...[LibTypeEnum.ISOMORPHIC_LIB]);
        });
        const unstageProjects = childrenThanAreLibs.filter(f => f.git.thereAreSomeUncommitedChangeExcept([
            packageJsonMainProject,
            taonJsonMainProject,
        ]));
        for (const unstageProj of unstageProjects) {
            await unstageProj.openInEditor();
        }
        this._exit();
    }
}
export default {
    $Open: HelpersTaon.CLIWRAP($Open, '$Open'),
};
//# sourceMappingURL=cli-OPEN.js.map