'use strict';
import { existsSync } from 'node:fs';
import { extname } from 'node:path';
import { execSyncCommand } from '../tools/exec.js';
import { getGitDiffFiles } from '../tools/git.js';
import { gitCommands } from '../constants/git-commands.js';
import { npmCommands } from '../constants/npm-commands.js';
import { environmentVariables } from '../constants/ci-constants.js';
import { files } from '../../../base-repo/app-constants/project-paths.js';
import { fileExtensions } from '../../../base-repo/app-constants/internal-system-constants.js';
import { cliLogInfo } from '../../../fd-toolbox/logging/cli-logger.js';
import { getBooleanEnvSetting } from '../../../fd-toolbox/infra/env-functions.js';
import { formatListWithPrefix } from '../../../fd-toolbox/logging/format-list.js';

var __defProp=Object['defineProperty'],__name=(_0x54e0f2,_0x418187)=>__defProp(_0x54e0f2,'name',{'value':_0x418187,'configurable':!![]});const eslintAllCommand=npmCommands['execEslint']+'\x20.',lintableFileExtensions=new Set([fileExtensions['cjs'],fileExtensions['cts'],fileExtensions['js'],fileExtensions['jsx'],fileExtensions['json'],fileExtensions['jsonc'],fileExtensions['mjs'],fileExtensions['mts'],fileExtensions['ts'],fileExtensions['tsx'],fileExtensions['yaml'],fileExtensions['yml']]);async function externalLint(){const _0x5f5b87=getBooleanEnvSetting(environmentVariables['fullLint'])===!![];_0x5f5b87?(cliLogInfo(environmentVariables['fullLint']+'\x20enabled.\x20Running\x20ESLint\x20on\x20the\x20entire\x20repo...'),execSyncCommand(eslintAllCommand)):runPartialLint();}__name(externalLint,'externalLint');function runPartialLint(){const _0x4e9fe3=getGitDiffFiles(gitCommands['diffNameOnlyOriginMainHeadWithoutDeleted']),_0xa683c0=_0x4e9fe3['some'](_0x4dc8b9=>_0x4dc8b9['endsWith'](files['eslintConfigJs']));if(_0x4e9fe3['length']===-0x228d+-0x1567+0x37f4)cliLogInfo('No\x20files\x20changed.\x20Skipping\x20ESLint.');else _0xa683c0?(cliLogInfo(files['eslintConfigJs']+'\x20changed.\x20Running\x20ESLint\x20on\x20the\x20entire\x20repo...'),execSyncCommand(eslintAllCommand)):runLintOnChangedFiles(_0x4e9fe3);}__name(runPartialLint,'runPartialLint');function runLintOnChangedFiles(_0x18c565){const _0x311acf=_0x18c565['filter'](isLintableChangedFile);if(_0x311acf['length']===-0x18b7+-0x4c2+0x1d79)cliLogInfo('No\x20existing\x20lintable\x20changed\x20files.\x20Skipping\x20ESLint.');else {cliLogInfo('Running\x20ESLint\x20on\x20changed\x20files:'),cliLogInfo(formatListWithPrefix(_0x311acf));const _0x1552ad=_0x311acf['map'](_0x386b19=>'\x22'+_0x386b19+'\x22')['join']('\x20');execSyncCommand(npmCommands['execEslint']+'\x20'+_0x1552ad);}}__name(runLintOnChangedFiles,'runLintOnChangedFiles');function isLintableChangedFile(_0x3e3686){const _0x19931d=existsSync(_0x3e3686),_0x3557b2=_0x19931d&&lintableFileExtensions['has'](extname(_0x3e3686)['toLowerCase']());if(!_0x19931d)cliLogInfo('Skipping\x20deleted\x20file:\x20'+_0x3e3686);else !_0x3557b2&&cliLogInfo('Skipping\x20non-lintable\x20file:\x20'+_0x3e3686);return _0x3557b2;}__name(isLintableChangedFile,'isLintableChangedFile');

export { externalLint };
