Skip to content

Commit 8978d82

Browse files
committed
refactor: clean up console logs and remove commented code in component creation functions
1 parent 37504b7 commit 8978d82

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

adminforth/commands/createCustomComponent/configUpdater.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ export async function injectLoginComponent(indexFilePath, componentPath) {
231231
);
232232

233233
if (!customizationProp) {
234-
// Добавляем customization: {}
235234
const customizationObj = b.objectExpression([]);
236235
customizationProp = b.objectProperty(b.identifier('customization'), customizationObj);
237236
configObject.properties.push(customizationProp);
@@ -294,6 +293,7 @@ export async function injectGlobalComponent(indexFilePath, injectionType, compon
294293
});
295294

296295
let updated = false;
296+
297297
console.log(JSON.stringify(injectionType));
298298
recast.visit(ast, {
299299
visitNewExpression(path) {
@@ -343,7 +343,6 @@ export async function injectGlobalComponent(indexFilePath, injectionType, compon
343343
currentValue.elements.push(b.stringLiteral(componentPath));
344344
console.log(chalk.dim(`Added '${componentPath}' to existing array in '${injectionType}'`));
345345
} else if (n.StringLiteral.check(currentValue)) {
346-
// Преобразовать строку в массив
347346
injectionProp.value = b.arrayExpression([
348347
b.stringLiteral(currentValue.value),
349348
b.stringLiteral(componentPath)

adminforth/commands/createCustomComponent/main.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function sanitizeLabel(input){
99
return input
1010
.replace(/[^a-zA-Z0-9\s]/g, '')
1111
.split(' ')
12-
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) // Переводим первую букву в верхний регистр
12+
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
1313
.join('');
1414
}
1515

@@ -113,7 +113,6 @@ async function handleFieldComponentCreation(config, resources) {
113113
console.log(chalk.dim(`Component generation successful: ${absoluteComponentPath}`));
114114

115115
await updateResourceConfig(selectedResource.resourceId, columnName, fieldType, componentPathForConfig);
116-
console.log(chalk.green(`\n✅ Successfully created component ${componentPathForConfig} and updated configuration.`));
117116
console.log(
118117
chalk.bold.greenBright('You can now open the component in your IDE:'),
119118
chalk.underline.cyanBright(absoluteComponentPath)
@@ -201,8 +200,6 @@ async function handleCrudPageInjectionCreation(config, resources) {
201200
componentPathForConfig,
202201
isThin
203202
);
204-
205-
console.log(chalk.green(`\n✅ Successfully created component ${componentPathForConfig} and updated configuration.`));
206203
console.log(
207204
chalk.bold.greenBright('You can now open the component in your IDE:'),
208205
chalk.underline.cyanBright(absoluteComponentPath)
@@ -253,8 +250,7 @@ async function handleLoginPageInjectionCreation(config) {
253250
const configFilePath = path.resolve(process.cwd(), 'index.ts');
254251
console.log(chalk.dim(`Injecting component: ${configFilePath}, ${componentFileName}`));
255252
await injectLoginComponent(configFilePath, `@@/${componentFileName}`);
256-
257-
console.log(chalk.green(`\n✅ Successfully created component ${componentFileName} and updated configuration.`));
253+
258254
console.log(
259255
chalk.bold.greenBright('You can now open the component in your IDE:'),
260256
chalk.underline.cyanBright(absoluteComponentPath)
@@ -299,7 +295,6 @@ async function handleGlobalInjectionCreation(config) {
299295

300296
const context = { reason };
301297

302-
// Генерация компонента
303298
const { alreadyExists, path: absoluteComponentPath } = await generateLoginOrGlobalComponentFile(
304299
componentFileName,
305300
injectionType,
@@ -308,13 +303,10 @@ async function handleGlobalInjectionCreation(config) {
308303
if (!alreadyExists) {
309304
console.log(chalk.dim(`Component generation successful: ${absoluteComponentPath}`));
310305

311-
// Путь к файлу конфигурации index.ts
312306
const configFilePath = path.resolve(process.cwd(), 'index.ts');
313307

314-
// Добавление компонента в соответствующую инъекцию
315308
await injectGlobalComponent(configFilePath, injectionType, `@@/${componentFileName}`);
316309

317-
console.log(chalk.green(`\n✅ Successfully created component ${componentFileName} and updated configuration.`));
318310
console.log(
319311
chalk.bold.greenBright('You can now open the component in your IDE:'),
320312
chalk.underline.cyanBright(absoluteComponentPath)

0 commit comments

Comments
 (0)