refactor: ♻️ move function
This commit is contained in:
@@ -35,32 +35,6 @@ export default class Cli {
|
||||
this.debug = options.debug ?? this.debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./types').Package} pkg - The package to detect configs
|
||||
* @returns {import('./types').Package['config']} - Detected configs record
|
||||
*/
|
||||
detectConfig(pkg) {
|
||||
|
||||
const spinner = createSpinner(`Configuring ${c.bold(c.blue(pkg.name))}`);
|
||||
spinner.start();
|
||||
|
||||
/** @type {import('./types').Package['config']} */
|
||||
const pkgConfig = {};
|
||||
|
||||
for (const config of this.configs) {
|
||||
pkgConfig[config.name] = this.detectOptions(
|
||||
pkg,
|
||||
config.options,
|
||||
config.type === 'single',
|
||||
spinner,
|
||||
);
|
||||
spinner.update({ text: `Configuring ${c.bold(c.blue(pkg.name))}${c.dim(`: config ${config.name}`)}` });
|
||||
}
|
||||
|
||||
spinner.success({ text: `Configuring ${c.bold(c.blue(pkg.name))}` });
|
||||
return pkgConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./types').Package} pkg - Package to detect from
|
||||
* @param {import('./types').Config['options']} options - Options to be passed
|
||||
@@ -110,6 +84,32 @@ export default class Cli {
|
||||
return detectedOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./types').Package} pkg - The package to detect configs
|
||||
* @returns {import('./types').Package['config']} - Detected configs record
|
||||
*/
|
||||
detectConfig(pkg) {
|
||||
|
||||
const spinner = createSpinner(`Configuring ${c.bold(c.blue(pkg.name))}`);
|
||||
spinner.start();
|
||||
|
||||
/** @type {import('./types').Package['config']} */
|
||||
const pkgConfig = {};
|
||||
|
||||
for (const config of this.configs) {
|
||||
pkgConfig[config.name] = this.detectOptions(
|
||||
pkg,
|
||||
config.options,
|
||||
config.type === 'single',
|
||||
spinner,
|
||||
);
|
||||
spinner.update({ text: `Configuring ${c.bold(c.blue(pkg.name))}${c.dim(`: config ${config.name}`)}` });
|
||||
}
|
||||
|
||||
spinner.success({ text: `Configuring ${c.bold(c.blue(pkg.name))}` });
|
||||
return pkgConfig;
|
||||
}
|
||||
|
||||
async run() {
|
||||
const workspace = this.#workspace ?? await new Workspace(this.dir).get();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user