Skip to content

Commit

Permalink
refactor: simplified imports in definition functions
Browse files Browse the repository at this point in the history
  • Loading branch information
catalandres committed Dec 24, 2023
1 parent eb6c0ac commit 879e5fe
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as path from 'node:path';
import * as MetadataFile from '../index.js';
import { getExtension } from '../index.js';

export function getBasenameWithoutExtension(fullPath: string): string {
const extension = MetadataFile.getExtension(fullPath);
const extension = getExtension(fullPath);
return path.basename(fullPath).replace(extension, '');
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as MetadataFile from '../index.js';
import { getBasenameWithoutExtension, getNameOfSecondToLastFolderLevel } from '../index.js';

export function getFullNameForObjectComponent(fullPath: string): string {
const objectName = MetadataFile.getNameOfSecondToLastFolderLevel(fullPath);
const componentName = MetadataFile.getBasenameWithoutExtension(fullPath);
const objectName = getNameOfSecondToLastFolderLevel(fullPath);
const componentName = getBasenameWithoutExtension(fullPath);
return objectName + '.' + componentName;
}
10 changes: 5 additions & 5 deletions src/shared/metadata/file/functions/processWorkflowRules.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as Metadata from '../../types/metadata.js';
import * as MetadataFile from '../index.js';
import { Extended, getNameOfSecondToLastFolderLevel } from '../index.js';
import { array } from '../../../array.js';

export function processWorkflowRules(record: Metadata.Workflow): Array<MetadataFile.Extended<Metadata.WorkflowRule>> {
const workflowRules: Array<MetadataFile.Extended<Metadata.WorkflowRule>> = [];
for (const thisRule of array(record.rules) as Array<MetadataFile.Extended<Metadata.WorkflowRule>>) {
thisRule.objectName = MetadataFile.getNameOfSecondToLastFolderLevel(thisRule.fileName);
export function processWorkflowRules(record: Metadata.Workflow): Array<Extended<Metadata.WorkflowRule>> {
const workflowRules: Array<Extended<Metadata.WorkflowRule>> = [];
for (const thisRule of array(record.rules) as Array<Extended<Metadata.WorkflowRule>>) {
thisRule.objectName = getNameOfSecondToLastFolderLevel(thisRule.fileName);
workflowRules.push(thisRule);
}
return workflowRules;
Expand Down
10 changes: 5 additions & 5 deletions src/shared/metadata/file/functions/splitBasename.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import * as MetadataFile from '../index.js';
import { getBasenameWithoutExtension } from '../index.js';

export function getFirstHalfOfBasenameSplitByPeriod(fullPath: string): string {
const basename = MetadataFile.getBasenameWithoutExtension(fullPath);
const basename = getBasenameWithoutExtension(fullPath);
return basename.split('.')[0];
}

export function getSecondHalfOfBasenameSplitByPeriod(fullPath: string): string {
const basename = MetadataFile.getBasenameWithoutExtension(fullPath);
const basename = getBasenameWithoutExtension(fullPath);
return basename.split('.')[1];
}

export function getFirstHalfOfBasenameSplitByDash(fullPath: string): string {
const basename = MetadataFile.getBasenameWithoutExtension(fullPath);
const basename = getBasenameWithoutExtension(fullPath);
return basename.split('-')[0];
}

export function getSecondHalfOfBasenameSplitByDash(fullPath: string): string {
const basename = MetadataFile.getBasenameWithoutExtension(fullPath);
const basename = getBasenameWithoutExtension(fullPath);
return basename.split('-')[1];
}
6 changes: 3 additions & 3 deletions src/shared/metadata/file/functions/transformCustomTab.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Metadata from '../../types/metadata.js';
import * as MetadataFile from '../index.js';
import { CustomTab } from '../../types/metadata.js';
import { Extended } from '../index.js';

export function transformCustomTab(tab: MetadataFile.Extended<Metadata.CustomTab>): void {
export function transformCustomTab(tab: Extended<CustomTab>): void {
if (tab.customObject) {
tab.objectName = tab.name;
}
Expand Down

0 comments on commit 879e5fe

Please sign in to comment.