mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-08 16:42:10 +01:00
Take static dependencies from ui-plugin dependencies
Instead of a separate manually tended list for static dependencies in ui-webapp we now take it from the package definitions in ui-plugins. Doing so we avoid inconsistencies between these lists.
This commit is contained in:
51
scm-ui/ui-plugins/generateStatic.js
Normal file
51
scm-ui/ui-plugins/generateStatic.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2020 - present Cloudogu GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
import fs from "node:fs";
|
||||
|
||||
const packageJson = JSON.parse(fs.readFileSync("./package.json", "utf8"));
|
||||
|
||||
const { lazyDependencies } = packageJson;
|
||||
|
||||
let importStatements = "";
|
||||
let calls = "";
|
||||
|
||||
Object.keys(packageJson.dependencies)
|
||||
.filter((dependency) => !lazyDependencies.includes(dependency))
|
||||
.forEach((dependency, index) => {
|
||||
importStatements += `import * as DEP${index} from '${dependency}';\n`;
|
||||
calls += ` defineStatic('${dependency}', DEP${index});\n`;
|
||||
});
|
||||
|
||||
fs.mkdirSync("./build", { recursive: true });
|
||||
fs.writeFileSync(
|
||||
"./build/provided-modules.d.ts",
|
||||
`
|
||||
type DefineStatic = (name: string, dependency: unknown) => void;
|
||||
|
||||
declare function definePluginDependencies(defineStatic: DefineStatic): void;
|
||||
export {definePluginDependencies};
|
||||
`
|
||||
);
|
||||
fs.writeFileSync(
|
||||
"./build/provided-modules.js",
|
||||
`
|
||||
${importStatements}
|
||||
|
||||
export function definePluginDependencies(defineStatic) {
|
||||
${calls}
|
||||
}`
|
||||
);
|
||||
@@ -3,6 +3,12 @@
|
||||
"description": "Defines the versions of SCM-Manager plugin dependencies provided by the core webapp. Exclusively used by the postinstall command of @scm-manager/plugin-scripts.",
|
||||
"version": "3.4.3-SNAPSHOT",
|
||||
"license": "AGPL-3.0-only",
|
||||
"type": "module",
|
||||
"main": "./build/provided-modules.js",
|
||||
"types": "./build/provided-modules.d.ts",
|
||||
"scripts": {
|
||||
"build": "node ./generateStatic.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "17",
|
||||
"react-dom": "17",
|
||||
@@ -11,12 +17,13 @@
|
||||
"react-i18next": "11",
|
||||
"styled-components": "^5.3.5",
|
||||
"@scm-manager/ui-api": "3.4.3-SNAPSHOT",
|
||||
"@scm-manager/ui-extensions": "3.4.3-SNAPSHOT",
|
||||
"@scm-manager/ui-components": "3.4.3-SNAPSHOT",
|
||||
"@scm-manager/ui-forms": "3.4.3-SNAPSHOT",
|
||||
"@scm-manager/ui-buttons": "3.4.3-SNAPSHOT",
|
||||
"@scm-manager/ui-overlays": "3.4.3-SNAPSHOT",
|
||||
"@scm-manager/ui-components": "3.4.3-SNAPSHOT",
|
||||
"@scm-manager/ui-core": "3.4.3-SNAPSHOT",
|
||||
"@scm-manager/ui-extensions": "3.4.3-SNAPSHOT",
|
||||
"@scm-manager/ui-forms": "3.4.3-SNAPSHOT",
|
||||
"@scm-manager/ui-layout": "3.4.3-SNAPSHOT",
|
||||
"@scm-manager/ui-overlays": "3.4.3-SNAPSHOT",
|
||||
"classnames": "^2.2.6",
|
||||
"query-string": "6.14.1",
|
||||
"redux": "^4.0.0",
|
||||
@@ -24,6 +31,7 @@
|
||||
"react-hook-form": "^7.5.1",
|
||||
"react-query": "^3.25.1"
|
||||
},
|
||||
"lazyDependencies": ["redux", "react-redux"],
|
||||
"devDependencies": {
|
||||
"@scm-manager/babel-preset": "^2.13.1",
|
||||
"@scm-manager/eslint-config": "^2.17.0",
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
"@scm-manager/eslint-config": "^2.17.0",
|
||||
"@scm-manager/jest-preset": "^2.13.0",
|
||||
"@scm-manager/ui-tests": "3.4.3-SNAPSHOT",
|
||||
"@scm-manager/ui-plugins": "3.4.3-SNAPSHOT",
|
||||
"@testing-library/react": "^12.1.5",
|
||||
"@types/classnames": "^2.2.9",
|
||||
"@types/enzyme": "^3.10.3",
|
||||
@@ -94,4 +95,4 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,44 +15,9 @@
|
||||
*/
|
||||
|
||||
import { defineLazy, defineStatic } from "./define";
|
||||
import { definePluginDependencies } from "@scm-manager/ui-plugins";
|
||||
|
||||
import * as React from "react";
|
||||
import * as ReactDOM from "react-dom";
|
||||
import * as ReactRouterDom from "react-router-dom";
|
||||
import * as ReactQuery from "react-query";
|
||||
import * as StyledComponents from "styled-components";
|
||||
import * as ReactHookForm from "react-hook-form";
|
||||
import * as ReactI18Next from "react-i18next";
|
||||
import * as ClassNames from "classnames";
|
||||
import * as QueryString from "query-string";
|
||||
import * as UIExtensions from "@scm-manager/ui-extensions";
|
||||
import * as UIComponents from "@scm-manager/ui-components";
|
||||
import * as UIButtons from "@scm-manager/ui-buttons";
|
||||
import * as UIForms from "@scm-manager/ui-forms";
|
||||
import * as UIOverlays from "@scm-manager/ui-overlays";
|
||||
import * as UILayout from "@scm-manager/ui-layout";
|
||||
import * as UIApi from "@scm-manager/ui-api";
|
||||
import * as UICore from "@scm-manager/ui-core";
|
||||
|
||||
// This module has side effects and is required to be imported unconditionally into the application at all times.
|
||||
|
||||
defineStatic("react", React);
|
||||
defineStatic("react-dom", ReactDOM);
|
||||
defineStatic("react-router-dom", ReactRouterDom);
|
||||
defineStatic("styled-components", StyledComponents);
|
||||
defineStatic("react-i18next", ReactI18Next);
|
||||
defineStatic("react-hook-form", ReactHookForm);
|
||||
defineStatic("react-query", ReactQuery);
|
||||
defineStatic("classnames", ClassNames);
|
||||
defineStatic("query-string", QueryString);
|
||||
defineStatic("@scm-manager/ui-extensions", UIExtensions);
|
||||
defineStatic("@scm-manager/ui-components", UIComponents);
|
||||
defineStatic("@scm-manager/ui-buttons", UIButtons);
|
||||
defineStatic("@scm-manager/ui-forms", UIForms);
|
||||
defineStatic("@scm-manager/ui-overlays", UIOverlays);
|
||||
defineStatic("@scm-manager/ui-layout", UILayout);
|
||||
defineStatic("@scm-manager/ui-api", UIApi);
|
||||
defineStatic("@scm-manager/ui-core", UICore);
|
||||
definePluginDependencies(defineStatic);
|
||||
|
||||
// redux is deprecated in favor of ui-api
|
||||
defineLazy("redux", () => import("@scm-manager/ui-legacy").then((legacy) => legacy.Redux));
|
||||
|
||||
Reference in New Issue
Block a user