feat!: 💥 export cli api and remove configs array

Removed the configs array from the cli package, as it now is handled by
the eslegant package.
Exported the Cli class so it can be run by other packages

BREAKING CHANGE
This commit is contained in:
Guz013
2023-08-29 15:08:29 -03:00
parent 26f29009d6
commit c061fdc8cd
10 changed files with 62 additions and 42 deletions

View File

@@ -1,6 +1,5 @@
import { Command } from 'commander';
import ConfigsProcessor from './configsProcessor.js';
import configs from './configs.js';
import Workspace from './workspace.js';
import c from 'picocolors';
import path from 'node:path';
@@ -22,6 +21,7 @@ export default class Cli {
/** @type {import('./types').CliArgs} */
args = {
dir: process.cwd(),
configs: [],
};
/**
@@ -45,13 +45,13 @@ export default class Cli {
this.args.dir = !this.args.dir.startsWith('/')
? path.join(process.cwd(), this.args.dir)
: this.args.dir;
}
async run() {
process.chdir(this.args.dir);
const configs = this.args.configs;
const spinner = createSpinner('Detecting workspace configuration');
const processor = new ConfigsProcessor({ configs });

View File

@@ -1,34 +0,0 @@
/** @type {import('./types').Config[]} */
const cliConfig = [
{
name: 'framework',
type: 'multiple',
description: 'The UI frameworks being used in the project',
options: [
{
name: 'svelte',
packages: { 'svelte': 'svelte' },
configs: ['svelte.recommended'],
detect: ['**/*.svelte', 'svelte.config.{js,ts,cjs,cts}'],
},
{
name: 'vue',
packages: { 'vue': ['vue', ['hello', 'world']], 'svelte': ['hello'] },
configs: ['vue.recommended'],
detect: ['nuxt.config.{js,ts,cjs,cts}', '**/*.vue'],
},
],
},
{
name: 'strict',
type: 'confirm',
manual: true,
options: [{
name: 'yes',
packages: { 'eslint': 'config', 'svelte': ['test1'] },
configs: ['config.strict'],
}],
},
];
export default cliConfig;

View File

@@ -1,4 +0,0 @@
import Cli from './cli.js';
const cli = new Cli();
await cli.run();

View File

@@ -7,6 +7,7 @@ type CliArgs = {
mergeToRoot?: boolean
installPkgs?: boolean | PackageManagerName
dir: string
configs: Config[]
} & OptionValues;
interface PackageManagerHandler {