Browse Source

refactor

pull/22645/head
erdemcaygor 1 year ago
parent
commit
0388e60b8e
  1. 10
      npm/ng-packs/packages/schematics/src/commands/change-theme/index.ts
  2. 2
      npm/ng-packs/packages/schematics/src/commands/change-theme/style-map.ts

10
npm/ng-packs/packages/schematics/src/commands/change-theme/index.ts

@ -190,10 +190,8 @@ export function removeImportsFromStandaloneProviders(
let modules: readonly ts.Expression[] = []; let modules: readonly ts.Expression[] = [];
if (args.length === 1 && ts.isArrayLiteralExpression(args[0])) { if (args.length === 1 && ts.isArrayLiteralExpression(args[0])) {
// importProvidersFrom([Module1, Module2]) tarzı
modules = (args[0] as ts.ArrayLiteralExpression).elements; modules = (args[0] as ts.ArrayLiteralExpression).elements;
} else { } else {
// importProvidersFrom(Module1, Module2) tarzı
modules = args; modules = args;
} }
@ -219,7 +217,6 @@ export function removeImportsFromStandaloneProviders(
} }
} }
// Eğer tüm modüller silinirse, importProvidersFrom() fonksiyonunu da kaldır
const remaining = modules.filter(el => !elementsToRemove.includes(el)); const remaining = modules.filter(el => !elementsToRemove.includes(el));
if (remaining.length === 0) { if (remaining.length === 0) {
const start = expr.getFullStart(); const start = expr.getFullStart();
@ -236,7 +233,6 @@ export function removeImportsFromStandaloneProviders(
} }
} }
} else { } else {
// Diğer bağımsız provider fonksiyonları için
const match = impMap.find(({ importName, provider }) => { const match = impMap.find(({ importName, provider }) => {
const moduleSymbol = importName?.split('.')[0]; const moduleSymbol = importName?.split('.')[0];
return ( return (
@ -306,11 +302,11 @@ export function removeProviderFromNgModuleMetadata(
const prevChar = source.text.slice(start - 1, start); const prevChar = source.text.slice(start - 1, start);
if (nextChar === ',') { if (nextChar === ',') {
recorder.remove(start, end - start + 1); // sağ virgül ile recorder.remove(start, end - start + 1);
} else if (prevChar === ',') { } else if (prevChar === ',') {
recorder.remove(start - 1, end - start + 1); // sol virgül ile recorder.remove(start - 1, end - start + 1);
} else { } else {
recorder.remove(start, end - start); // direkt recorder.remove(start, end - start);
} }
} }
} }

2
npm/ng-packs/packages/schematics/src/commands/change-theme/style-map.ts

@ -261,7 +261,7 @@ styleMap.set(ThemeOptionsEnum.LeptonXLite, [
bundleName: 'bootstrap-icons', bundleName: 'bootstrap-icons',
}, },
]); ]);
// the code written by Github co-pilot. thank go-pilot. You are the best sidekick.
export const allStyles = Array.from(styleMap.values()).reduce((acc, val) => [...acc, ...val], []); export const allStyles = Array.from(styleMap.values()).reduce((acc, val) => [...acc, ...val], []);
export const importMap = new Map<ThemeOptionsEnum, ImportDefinition[]>(); export const importMap = new Map<ThemeOptionsEnum, ImportDefinition[]>();

Loading…
Cancel
Save