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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Port simplified plugin:register_frontend to JS
Alexander Brandon Colesb1b5054d97d8
diff --git a/frontend/ci-plugins-generator.js b/frontend/ci-plugins-generator.jsnew file mode 100644index 00000000000..3d3cff09775--- /dev/null+++ b/frontend/ci-plugins-generator.js@@ -0,0 +1,71 @@+const path = require('node:path');+const fs = require('node:fs');+const _ = require("lodash");++const LINKED_PLUGINS_MODULE_TEMPLATE = (plugins) => {+ const importableName = (name) => _.upperFirst(_.camelCase(name));+ const frontendPlugins = plugins.map(([name, _]) => [name, importableName(name)]);++ return `+import {NgModule} from "@angular/core";+${+ frontendPlugins+ .map(([actualName, moduleName]) =>+ `import {PluginModule as ${moduleName}} from './linked/${actualName}/main';`+ )+ .join("\n")+}++@NgModule({+ imports: [+ ${+ frontendPlugins+ .map(([_, moduleName]) => moduleName)+ .join(`,\n${" ".repeat(8)}`)+ }+ ],+})+export class LinkedPluginsModule { }+ `;+};++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")]+]);++console.log(`Cleaning linked target directory ${targetDir}`);+fs.rmSync(targetDir, { recursive: true, force: true });+fs.mkdirSync(targetDir);++plugins.forEach((pluginPath, name) => {+ const linkTarget = path.join(pluginPath, "frontend", "module");+ const linkPath = path.join(targetDir, name);++ 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");+ return fs.existsSync(frontendEntry);+});++function generatePluginModule(plugins) {+ 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);+ fs.writeFileSync(fileRegister, result);+};++generatePluginModule(allFrontendPlugins);diff --git a/frontend/package.json b/frontend/package.jsonindex 3dc4122d4e4..3c7abe761e1 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -167,6 +167,7 @@"build:fast": "OPENPROJECT_ANGULAR_BUILD=fast node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --configuration production","build": "node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build --configuration production --named-chunks --source-map","build:watch": "node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build --watch --named-chunks",+ "ci:plugins:register_frontend": "node ci-plugins-generator.js","tokens:generate": "theo src/app/spot/styles/tokens/tokens.yml --transform web --format sass,json --dest src/app/spot/styles/tokens/dist","serve": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng serve --host ${FE_HOST:-localhost} --port ${FE_PORT:-4200} --public-host http://${PROXY_HOSTNAME:-localhost}:${FE_PORT:-4200}","serve:test": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng serve --host ${FE_HOST:-localhost} --port ${FE_PORT:-4200} --disable-host-check --public-host http://frontend-test:${FE_PORT:-4200}",