Files
awesome-cordova-plugins/scripts/build/transformers/methods.ts
Daniel Sogl 4f8f99fa44 feat!: upgrade to Angular 19.2.14 with modern testing infrastructure
BREAKING CHANGE: Minimum Angular version requirement updated to 19.2.14

- Angular Core: 19.0.5 → 19.2.14 (latest Angular 19 LTS)
- Zone.js: 0.15.0 → 0.15.1 (latest compatibility)
- TypeScript: 5.6.3 (latest supported by Angular 19)

Testing Infrastructure Modernization:
- Jest: 27.5.1 → 29.7.0 (major upgrade for better performance)
- ts-jest: 27.1.5 → 29.3.4 (TypeScript 5.6+ compatibility)
- @types/jest: 27.5.2 → 29.5.14 (latest type definitions)
- jest-environment-jsdom: Added 29.7.0 (required for Jest 29)
- RxJS: 7.8.1 → 7.8.2 (latest patch version)

Package Generator Improvements:
- Fixed package.json generator to use correct author from main package.json
- Updated RxJS peer dependency to ^7.8.0 (modern version range)
- Updated core version dependency to use current package version dynamically
- Ensured consistency across all generated plugin package.json files

This update brings the project to the latest Angular 19 LTS with enhanced testing capabilities, improved build performance, and modernized dependency management. All builds and tests passing successfully.
2025-06-07 15:47:18 +02:00

63 lines
1.9 KiB
TypeScript

import { Expression, factory, MethodDeclaration, SyntaxKind } from 'typescript';
import { Logger } from '../../logger';
import {
convertValueToLiteral,
getDecorator,
getDecoratorArgs,
getDecoratorName,
getMethodsForDecorator,
} from '../helpers';
export function transformMethod(method: MethodDeclaration) {
if (!method) return;
const decorator = getDecorator(method),
decoratorName = getDecoratorName(decorator),
decoratorArgs = getDecoratorArgs(decorator);
try {
return factory.createMethodDeclaration(
undefined,
undefined,
method.name,
undefined,
method.typeParameters,
method.parameters,
method.type,
factory.createBlock([factory.createReturnStatement(getMethodBlock(method, decoratorName, decoratorArgs))])
);
} catch (e) {
Logger.error('Error transforming method: ' + (method.name as any).text);
Logger.error(e.message);
}
}
function getMethodBlock(method: MethodDeclaration, decoratorName: string, decoratorArgs: any): Expression {
const decoratorMethod = getMethodsForDecorator(decoratorName)[0];
switch (decoratorName) {
case 'CordovaCheck':
case 'InstanceCheck':
// TODO remove function wrapper
return factory.createImmediatelyInvokedArrowFunction([
factory.createIfStatement(
factory.createBinaryExpression(
factory.createCallExpression(factory.createIdentifier(decoratorMethod), undefined, [factory.createThis()]),
SyntaxKind.EqualsEqualsEqualsToken,
factory.createTrue()
),
method.body
),
]);
default:
return factory.createCallExpression(factory.createIdentifier(decoratorMethod), undefined, [
factory.createThis(),
factory.createStringLiteral(decoratorArgs?.methodName || (method.name as any).text),
convertValueToLiteral(decoratorArgs),
factory.createIdentifier('arguments'),
]);
}
}