Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix linting errors

Christophe Bliard6f0cd781d107
diff --git a/frontend/ci-plugins-generator.js b/frontend/ci-plugins-generator.js
index 3d3cff09775..57278113460 100644
--- a/frontend/ci-plugins-generator.js
+++ b/frontend/ci-plugins-generator.js
@@ -1,27 +1,27 @@
const path = require('node:path');
const fs = require('node:fs');
-const _ = require("lodash");
+const _ = require('lodash');
const LINKED_PLUGINS_MODULE_TEMPLATE = (plugins) => {
const importableName = (name) => _.upperFirst(_.camelCase(name));
- const frontendPlugins = plugins.map(([name, _]) => [name, importableName(name)]);
+ const frontendPlugins = plugins.map(([name]) => [name, importableName(name)]);
return `
import {NgModule} from "@angular/core";
${
frontendPlugins
- .map(([actualName, moduleName]) =>
+ .map(([actualName, moduleName]) =>
`import {PluginModule as ${moduleName}} from './linked/${actualName}/main';`
)
- .join("\n")
+ .join('\n')
}
@NgModule({
imports: [
${
frontendPlugins
- .map(([_, moduleName]) => moduleName)
- .join(`,\n${" ".repeat(8)}`)
+ .map(([, moduleName]) => moduleName)
+ .join(`,\n${' '.repeat(8)}`)
}
],
})
@@ -29,18 +29,18 @@ export class LinkedPluginsModule { }
`;
};
-const railsRout = path.join(__dirname, "..");
+const railsRout = path.join(__dirname, '..');
const pluginDir = path.join(railsRout, 'modules');
const targetDir = path.join(railsRout, 'frontend/src/app/features/plugins/linked');
const plugins = new Map([
- ["budgets", path.join(pluginDir, "budgets")],
- ["costs", path.join(pluginDir, "costs")],
- ["openproject-avatars", path.join(pluginDir, "avatars")],
- ["openproject-documents", path.join(pluginDir, "documents")],
- ["openproject-github_integration", path.join(pluginDir, "github_integration")],
- ["openproject-gitlab_integration", path.join(pluginDir, "gitlab_integration")],
- ["openproject-meeting", path.join(pluginDir, "meeting")]
+ ['budgets', path.join(pluginDir, 'budgets')],
+ ['costs', path.join(pluginDir, 'costs')],
+ ['openproject-avatars', path.join(pluginDir, 'avatars')],
+ ['openproject-documents', path.join(pluginDir, 'documents')],
+ ['openproject-github_integration', path.join(pluginDir, 'github_integration')],
+ ['openproject-gitlab_integration', path.join(pluginDir, 'gitlab_integration')],
+ ['openproject-meeting', path.join(pluginDir, 'meeting')]
]);
console.log(`Cleaning linked target directory ${targetDir}`);
@@ -48,20 +48,20 @@ fs.rmSync(targetDir, { recursive: true, force: true });
fs.mkdirSync(targetDir);
plugins.forEach((pluginPath, name) => {
- const linkTarget = path.join(pluginPath, "frontend", "module");
+ const linkTarget = path.join(pluginPath, 'frontend', 'module');
const linkPath = path.join(targetDir, name);
- console.log(`Linking frontend of OpenProject plugin ${name} to ${linkPath}.`)
+ console.log(`Linking frontend of OpenProject plugin ${name} to ${linkPath}.`);
fs.symlinkSync(linkTarget, linkPath);
});
-const allFrontendPlugins = Array.from(plugins).filter(([_, pluginPath]) => {
- const frontendEntry = path.join(pluginPath, "frontend", "module", "main.ts");
+const allFrontendPlugins = Array.from(plugins).filter(([, pluginPath]) => {
+ const frontendEntry = path.join(pluginPath, 'frontend', 'module', 'main.ts');
return fs.existsSync(frontendEntry);
});
function generatePluginModule(plugins) {
- const fileRegister = path.join(railsRout, "frontend/src/app/features/plugins/linked-plugins.module.ts");
+ const fileRegister = path.join(railsRout, 'frontend/src/app/features/plugins/linked-plugins.module.ts');
console.log(`Regenerating frontend plugin registry ${fileRegister}.`);
const result = LINKED_PLUGINS_MODULE_TEMPLATE(plugins);
diff --git a/lib/open_project/plugins/frontend_linking/generator.rb b/lib/open_project/plugins/frontend_linking/generator.rb
index 1f1db93dca2..40c64e0dcac 100644
--- a/lib/open_project/plugins/frontend_linking/generator.rb
+++ b/lib/open_project/plugins/frontend_linking/generator.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -29,6 +31,7 @@
require "bundler"
require "fileutils"
+# rubocop:disable Rails/Output
module ::OpenProject::Plugins
module FrontendLinking
class Generator
@@ -58,25 +61,14 @@ module ::OpenProject::Plugins
# Register plugins with an Angular frontend to the CLI build.
# For that, search all gems with the group :opf_plugins
def regenerate_angular_links
- all_frontend_plugins.tap do |plugins|
- target_dir = Rails.root.join("frontend/src/app/features/plugins/linked")
- puts "Cleaning linked target directory #{target_dir}"
-
- # Removing the current linked directory and recreate
- FileUtils.remove_dir(target_dir, force: true)
- FileUtils.mkdir_p(target_dir)
-
- plugins.each do |name, path|
- source = File.join(path, "frontend", "module")
- target = File.join(target_dir, name)
-
- puts "Linking frontend of OpenProject plugin #{name} to #{target}."
- FileUtils.ln_sf(source, target)
- end
+ remove_all_frontend_plugins_links
+ create_frontend_plugins_links(all_frontend_plugins)
+ generate_plugin_module(all_angular_frontend_plugins)
+ generate_plugin_sass(all_plugins_with_global_styles)
+ end
- generate_plugin_module(all_angular_frontend_plugins)
- generate_plugin_sass(all_plugins_with_global_styles)
- end
+ def target_dir
+ Rails.root.join("frontend/src/app/features/plugins/linked")
end
def all_frontend_plugins
@@ -96,7 +88,25 @@ module ::OpenProject::Plugins
def all_plugins_with_global_styles
openproject_plugins.select do |_, path|
style_file = File.join(path, "frontend", "module", "global_styles.*")
- !Dir.glob(style_file).empty?
+ Dir.glob(style_file).any?
+ end
+ end
+
+ def remove_all_frontend_plugins_links
+ puts "Cleaning linked target directory #{target_dir}"
+
+ # Removing the current linked directory and recreate
+ FileUtils.remove_dir(target_dir, force: true)
+ FileUtils.mkdir_p(target_dir)
+ end
+
+ def create_frontend_plugins_links(plugins)
+ plugins.each do |name, path|
+ source = File.join(path, "frontend", "module")
+ target = File.join(target_dir, name)
+
+ puts "Linking frontend of OpenProject plugin #{name} to #{target}."
+ FileUtils.ln_sf(source, target)
end
end
@@ -137,10 +147,11 @@ module ::OpenProject::Plugins
gems.dependencies
.each_with_object({}) do |dep, l|
- l[dep.name] = dep if (bundler_groups & dep.groups).any?
+ l[dep.name] = dep if bundler_groups.intersect?(dep.groups)
end
.compact
end
end
end
end
+# rubocop:enable Rails/Output