Plugins: Always load decoupled frontend assets from builds (#81873)

* Wip

* Wip

* Adapt to load external module

* build: remove cloudmonitoring from built_in_plugins, clean up webpack output

* chore(plugins): remove decoupled plugins from package.json deps

* chore(codeowners): update file for nx.json

* revert(webpack): put back path in config

* build(frontend): use nx to run prod builds of decoupled plugins with yarn build

* style(prometheus): run prettier-write to fix tsconfig.json

* style(backend): remove unused subFile.isDistDir

* revert(locales): remove formatting changes adding new line at end of files

* chore(webpack): clean up dev output

* build(nx): make grafana an nx project, bump lerna and nx

* build(plugin-configs): move cache directory to node_modules

* style(datasource-plugins): add eslint ignore for .gen.ts files

* chore(codeowners): add frontend-ops as owner of project.json

* build(webpack): add getDecoupledPlugins to automatically ignore when watching

* ci(drone): skip nx cache when building frontend packages

* style(ci): fix missing trailing comma

* Revert "style(ci): fix missing trailing comma"

This reverts commit 7520d41576.

* Revert "ci(drone): skip nx cache when building frontend packages"

This reverts commit 46938883ac.

* feat(zipkin): remove from grafana core bundle

* chore(npm): bump nx package to latest 18.0.8

* docs(dev-guide): add a note about what yarn start now builds

---------

Co-authored-by: Andres Martinez <andres.martinez@grafana.com>
This commit is contained in:
Jack Westbrook
2024-03-13 12:40:09 +01:00
committed by GitHub
co-authored by Andres Martinez
parent 75ea33e0cd
commit 6599fa805d
17 changed files with 896 additions and 337 deletions
+6 -14
View File
@@ -30,7 +30,7 @@ func newWalker(rootDir string) *walker {
// can detect infinite loops while following symlinks.
// It solves the issue where your WalkFunc needs a path relative to the symbolic link
// (resolving links within walkfunc loses the path to the symbolic link for each traversal).
func Walk(path string, followSymlinks bool, detectSymlinkInfiniteLoop bool, followDistFolder bool, walkFn WalkFunc) error {
func Walk(path string, followSymlinks bool, detectSymlinkInfiniteLoop bool, walkFn WalkFunc) error {
info, err := os.Lstat(path)
if err != nil {
return err
@@ -44,7 +44,7 @@ func Walk(path string, followSymlinks bool, detectSymlinkInfiniteLoop bool, foll
}
}
return newWalker(path).walk(path, info, resolvedPath, symlinkPathsFollowed, followDistFolder, walkFn)
return newWalker(path).walk(path, info, resolvedPath, symlinkPathsFollowed, walkFn)
}
// walk walks the path. It is a helper/sibling function to Walk.
@@ -53,7 +53,7 @@ func Walk(path string, followSymlinks bool, detectSymlinkInfiniteLoop bool, foll
//
// If resolvedPath is "", then we are not following symbolic links.
// If symlinkPathsFollowed is not nil, then we need to detect infinite loop.
func (w *walker) walk(path string, info os.FileInfo, resolvedPath string, symlinkPathsFollowed map[string]bool, followDistFolder bool, walkFn WalkFunc) error {
func (w *walker) walk(path string, info os.FileInfo, resolvedPath string, symlinkPathsFollowed map[string]bool, walkFn WalkFunc) error {
if info == nil {
return errors.New("walk: Nil FileInfo passed")
}
@@ -91,7 +91,7 @@ func (w *walker) walk(path string, info os.FileInfo, resolvedPath string, symlin
if err != nil {
return err
}
return w.walk(path, info2, path2, symlinkPathsFollowed, followDistFolder, walkFn)
return w.walk(path, info2, path2, symlinkPathsFollowed, walkFn)
} else if info.IsDir() {
list, err := os.ReadDir(path)
if err != nil {
@@ -112,23 +112,19 @@ func (w *walker) walk(path string, info os.FileInfo, resolvedPath string, symlin
subFiles = append(subFiles, subFile{path: path2, resolvedPath: resolvedPath2, fileInfo: fileInfo})
}
if followDistFolder && w.containsDistFolder(subFiles) {
if w.containsDistFolder(subFiles) {
err := w.walk(
filepath.Join(path, "dist"),
info,
filepath.Join(resolvedPath, "dist"),
symlinkPathsFollowed,
followDistFolder,
walkFn)
if err != nil {
return err
}
} else {
for _, p := range subFiles {
if p.isDistDir() && !followDistFolder {
continue
}
err = w.walk(p.path, p.fileInfo, p.resolvedPath, symlinkPathsFollowed, followDistFolder, walkFn)
err = w.walk(p.path, p.fileInfo, p.resolvedPath, symlinkPathsFollowed, walkFn)
if err != nil {
return err
}
@@ -154,10 +150,6 @@ type subFile struct {
fileInfo os.FileInfo
}
func (s subFile) isDistDir() bool {
return s.fileInfo.IsDir() && s.fileInfo.Name() == "dist"
}
// CleanRelativePath returns the shortest path name equivalent to path
// by purely lexical processing. It makes sure the provided path is rooted
// and then uses filepath.Clean and filepath.Rel to make sure the path