Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular detection: Fetch patterns from GCOM #137

Closed
xnyo opened this issue Sep 13, 2023 · 0 comments · Fixed by #172
Closed

Angular detection: Fetch patterns from GCOM #137

xnyo opened this issue Sep 13, 2023 · 0 comments · Fixed by #172
Assignees
Labels
enhancement New feature or request

Comments

@xnyo
Copy link
Member

xnyo commented Sep 13, 2023

In the legacyplatform inspector (Angular), it would be good to fetch the patterns from GCOM rather than relying on hardcoded ones:

GCOM API: https://grafana.com/api/plugins/angular_patterns

var legacyDetectors = []detector{
&containsBytesDetector{pattern: []byte("PanelCtrl")},
&containsBytesDetector{pattern: []byte("QueryCtrl")},
&containsBytesDetector{pattern: []byte("app/plugins/sdk")},
&containsBytesDetector{pattern: []byte("angular.isNumber(")},
&containsBytesDetector{pattern: []byte("editor.html")},
&containsBytesDetector{pattern: []byte("ctrl.annotation")},
&containsBytesDetector{pattern: []byte("getLegacyAngularInjector")},
&containsBytesDetector{pattern: []byte("System.register(")},
// &regexDetector{regex: regexp.MustCompile(`['"](app/core/.*?)|(app/plugins/.*?)['"]`)},
&regexDetector{regex: regexp.MustCompile(`['"](app/core/utils/promiseToDigest)|(app/plugins/.*?)|(app/core/core_module)['"]`)},
&regexDetector{regex: regexp.MustCompile(`from\s+['"]grafana\/app\/`)},
}

Grafana core already has support for it:

https://github.com/grafana/grafana/blob/e9a12598db238b3923ca30a490d4abcaf0b00b65/pkg/services/pluginsintegration/angulardetectorsprovider/dynamic.go#L110

This would save us from having to open yet another PR when we have to chang the Angular detection patterns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants