(flags?: InitializeFlags)
| 794 | |
| 795 | // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: "will fix later" |
| 796 | export const initialize = async (flags?: InitializeFlags) => { |
| 797 | const opts = flags ?? {}; |
| 798 | const quiet = opts.quiet ?? false; |
| 799 | |
| 800 | if (!quiet) { |
| 801 | intro(`Ultracite v${ultraciteVersion} Initialization`); |
| 802 | } |
| 803 | |
| 804 | try { |
| 805 | let pm: PackageManagerName; |
| 806 | let pmInfo: PackageManager; |
| 807 | |
| 808 | if (opts.pm) { |
| 809 | pm = assertSupportedPackageManagerName(opts.pm); |
| 810 | pmInfo = { command: pm, name: pm }; |
| 811 | } else { |
| 812 | const detected = await detectPackageManager(process.cwd()); |
| 813 | |
| 814 | if (!detected) { |
| 815 | throw new Error("No package manager specified or detected"); |
| 816 | } |
| 817 | |
| 818 | if (!quiet && detected.warnings) { |
| 819 | for (const warning of detected.warnings) { |
| 820 | log.warn(warning); |
| 821 | } |
| 822 | } |
| 823 | |
| 824 | if (!quiet) { |
| 825 | log.info(`Detected lockfile, using ${detected.name}`); |
| 826 | } |
| 827 | pmInfo = normalizePackageManager(detected); |
| 828 | pm = pmInfo.name; |
| 829 | } |
| 830 | |
| 831 | let { linter } = opts; |
| 832 | if (linter === undefined) { |
| 833 | // If quiet mode or other CLI options are provided, default to biome only |
| 834 | const hasOtherCliOptions = |
| 835 | quiet || |
| 836 | opts.pm || |
| 837 | opts.editors || |
| 838 | opts.agents || |
| 839 | opts.hooks || |
| 840 | opts.integrations !== undefined || |
| 841 | opts.frameworks !== undefined; |
| 842 | |
| 843 | if (hasOtherCliOptions) { |
| 844 | linter = "biome"; |
| 845 | } else { |
| 846 | const linterResult = await select({ |
| 847 | message: "Which linter do you want to use?", |
| 848 | options: [ |
| 849 | { |
| 850 | label: "Biome (Recommended)", |
| 851 | value: "biome", |
| 852 | }, |
| 853 | { |
no test coverage detected
searching dependent graphs…