Skip to content

Commit

Permalink
If installed deps (#2918)
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox authored Jan 24, 2025
1 parent f03fbf8 commit d985c06
Show file tree
Hide file tree
Showing 13 changed files with 1,198 additions and 1,016 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,14 @@ The icons may not be reused in other projects without the proper flaticon licens
<!--
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
- (@GermanBluefox) Fixing Tabs in JSON Config

### 7.4.15 (2025-01-22)

- (@oweitman) Implemented better table view
- (@GermanBluefox) Extended DM with device type
- (@GermanBluefox) Showed the tabs in JSONConfig on narrow displays as menu
- (@GermanBluefox) Showed the tabs in JSONConfig on narrow displays as a menu

### 7.4.14 (2025-01-15)

Expand Down
1,813 changes: 955 additions & 858 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@alcalzone/release-script-plugin-license": "^3.7.0",
"@alcalzone/release-script-plugin-lerna": "^3.7.0",
"@iobroker/types": "^7.0.6",
"@iobroker/dm-utils": "^0.6.11",
"@iobroker/dm-utils": "^1.0.6",
"lerna": "^8.1.9"
},
"scripts": {
Expand All @@ -31,6 +31,6 @@
"release-major": "release-script major --yes --no-update-lockfile --publishAll",
"prettier": "cd packages/admin && npm run prettier && cd src-admin && npm run prettier && cd ../../dm-gui-components && npm run prettier && cd ../jsonConfig && npm run prettier",
"lint": "cd packages/admin && npm run lint-backend && cd src-admin && npm run lint && cd ../../dm-gui-components && npm run lint && cd ../jsonConfig && npm run lint",
"update-packages": "npx -y npm-check-updates --upgrade && cd packages/adapter-react-v5 && npx -y npm-check-updates --upgrade && cd packages/admin && npx -y npm-check-updates --upgrade && cd src-admin && npx -y npm-check-updates --upgrade && cd ../../dm-gui-components && npx -y npm-check-updates --upgrade && cd ../jsonConfig && npx -y npm-check-updates --upgrade"
"update-packages": "npx -y npm-check-updates --upgrade && cd packages/adapter-react-v5 && npx -y npm-check-updates --upgrade && cd ../admin && npx -y npm-check-updates --upgrade && cd src-admin && npx -y npm-check-updates --upgrade && cd ../../dm-gui-components && npx -y npm-check-updates --upgrade && cd ../jsonConfig && npx -y npm-check-updates --upgrade"
}
}
24 changes: 12 additions & 12 deletions packages/adapter-react-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,35 @@
"@rollup/rollup-linux-x64-gnu": "*"
},
"dependencies": {
"@emotion/react": "^11.13.5",
"@emotion/styled": "^11.13.5",
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.0",
"@iobroker/js-controller-common": "^7.0.6",
"@iobroker/js-controller-common-db": "^7.0.6",
"@iobroker/socket-client": "^4.0.0",
"@iobroker/types": "^7.0.6",
"@mui/icons-material": "^6.1.9",
"@mui/material": "^6.1.9",
"@sentry/browser": "^8.43.0",
"cronstrue": "^2.52.0",
"@mui/icons-material": "^6.4.1",
"@mui/material": "^6.4.1",
"@sentry/browser": "^8.51.0",
"cronstrue": "^2.53.0",
"react-color": "^2.19.3",
"react-colorful": "^5.6.1",
"react-cropper": "^2.3.3",
"react-dropzone": "^14.3.5",
"react-inlinesvg": "^4.1.5"
"react-inlinesvg": "^4.1.8"
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-transform-runtime": "^7.25.9",
"@babel/preset-env": "^7.26.0",
"@babel/preset-flow": "^7.25.9",
"@babel/preset-react": "^7.25.9",
"@babel/preset-react": "^7.26.3",
"@iobroker/eslint-config": "^1.0.0",
"@types/node": "^22.10.1",
"@types/react": "^18.3.12",
"@types/react-color": "^3.0.12",
"@types/node": "^22.10.10",
"@types/react": "^18.3.18",
"@types/react-color": "^3.0.13",
"ajv": "^8.17.1",
"ts-node": "^10.9.2",
"typescript": "^5.7.2"
"typescript": "^5.7.3"
}
}
12 changes: 6 additions & 6 deletions packages/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
"semver": "^7.6.3"
},
"devDependencies": {
"@iobroker/build-tools": "^2.0.12",
"@iobroker/build-tools": "^2.0.14",
"@iobroker/dm-gui-components": "file:../dm-gui-components",
"@iobroker/json-config": "file:../jsonConfig",
"@iobroker/legacy-testing": "^2.0.1",
"@iobroker/testing": "^5.0.0",
"@iobroker/legacy-testing": "^2.0.2",
"@iobroker/testing": "^5.0.3",
"@types/archiver": "^6.0.3",
"@types/body-parser": "^1.19.5",
"@types/compression": "^1.7.5",
Expand All @@ -60,10 +60,10 @@
"@types/passport-local": "^1.0.38",
"@types/validator": "^13.12.2",
"colorette": "^2.0.20",
"less": "^4.2.1",
"puppeteer": "^23.10.1",
"less": "^4.2.2",
"puppeteer": "^24.1.1",
"src-rx": "file:src-admin",
"typescript": "^5.7.2"
"typescript": "^5.7.3"
},
"bugs": {
"url": "https://github.com/ioBroker/ioBroker.admin/issues"
Expand Down
36 changes: 18 additions & 18 deletions packages/admin/src-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,50 +33,50 @@
"@dilesoft/vite-plugin-federation-dynamic": "^1.1.9",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@fnando/sparkline": "^0.3.10",
"@foxriver76/iob-component-lib": "^0.1.6",
"@foxriver76/iob-component-lib": "^0.2.0",
"@honkhonk/vite-plugin-svgr": "^1.1.0",
"@iobroker/admin-component-easy-access": "^1.0.11",
"@iobroker/dm-utils": "^0.6.11",
"@iobroker/socket-client": "^3.1.3",
"@iobroker/dm-utils": "^1.0.6",
"@iobroker/socket-client": "^4.0.0",
"@originjs/vite-plugin-commonjs": "^1.0.3",
"@react-leaflet/core": "^2.1.0",
"@tsconfig/node16": "^16.1.3",
"@types/ace": "^0.0.52",
"@types/crypto-js": "^4.2.2",
"@types/leaflet": "^1.9.14",
"@types/leaflet": "^1.9.16",
"@types/less": "^3.0.7",
"@types/lodash": "^4.17.13",
"@types/lodash": "^4.17.14",
"@types/mocha": "^10.0.10",
"@types/node": "^22.10.1",
"@types/react": "^18.3.12",
"@types/react-color": "^3.0.12",
"@types/react-dom": "^18.3.1",
"@types/node": "^22.10.10",
"@types/react": "^18.3.18",
"@types/react-color": "^3.0.13",
"@types/react-dom": "^18.3.5",
"buffer": "^6.0.3",
"craco-babel-loader": "^1.0.4",
"craco-module-federation": "^1.1.0",
"cron-parser": "^4.9.0",
"crypto-js": "^4.2.0",
"date-fns": "^4.1.0",
"echarts": "^5.5.1",
"echarts": "^5.6.0",
"echarts-for-react": "^3.0.2",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react": "^7.37.4",
"ipaddr.js": "^2.2.0",
"json5": "^2.2.3",
"leaflet": "^1.9.4",
"leaflet-geosearch": "^4.0.0",
"less": "^4.2.1",
"leaflet-geosearch": "^4.1.0",
"less": "^4.2.2",
"lodash": "^4.17.21",
"moment": "^2.30.1",
"react-ace": "^13.0.0",
"react-dnd": "^16.0.1",
"react-dnd-html5-backend": "^16.0.1",
"react-dnd-multi-backend": "^8.0.3",
"react-dnd-preview": "^8.0.3",
"react-dnd-multi-backend": "^8.1.2",
"react-dnd-preview": "^8.1.2",
"react-dnd-touch-backend": "^16.0.1",
"react-icons": "^5.3.0",
"react-icons": "^5.4.0",
"react-leaflet": "^4.2.1",
"react-markdown": "^9.0.1",
"react-markdown": "^9.0.3",
"react-monaco-editor": "^0.56.2",
"react-qr-code": "^2.0.15",
"react-scripts": "^5.0.1",
Expand All @@ -103,5 +103,5 @@
}
]
],
"version": "7.4.14"
"version": "7.4.15"
}
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export default abstract class AdapterInstallDialog<
entry.name = !checkVersion ? dependency : keys ? keys[0] : null;
entry.version = checkVersion ? dependency[entry.name] : null;

if (result && entry.name) {
if (entry.name) {
const installed = context.installed[entry.name];

entry.installed = !!installed;
Expand Down Expand Up @@ -309,7 +309,7 @@ export default abstract class AdapterInstallDialog<
entry.name = !checkVersion ? dependency : keys ? keys[0] : null;
entry.version = checkVersion ? dependency[entry.name] : null;

if (result && entry.name) {
if (entry.name) {
const installed = context.installedGlobal[entry.name];

entry.installed = !!installed;
Expand All @@ -329,6 +329,39 @@ export default abstract class AdapterInstallDialog<
}
}

const dependencies: Record<string, string> =
// @ts-expect-error Types implemented in js-controller
adapter.ifInstalledDependencies as Record<string, string>;

if (dependencies && typeof dependencies === 'object' && !Array.isArray(dependencies)) {
const adapters = Object.keys(dependencies);
for (const a of adapters) {
const entry: AdapterDependencies = {
name: a,
version: dependencies[a],
installed: false,
installedVersion: null,
rightVersion: false,
};

if (entry.name) {
const installed = context.installedGlobal[entry.name];

entry.installed = !!installed;
entry.installedVersion = installed ? installed.version : null;
try {
entry.rightVersion = installed
? semver.satisfies(installed.version, entry.version, { includePrerelease: true })
: true;
} catch {
entry.rightVersion = true;
}
}

result.push(entry);
}
}

if (nodeVersion) {
const entry: AdapterDependencies = {
name: 'node',
Expand Down
25 changes: 10 additions & 15 deletions packages/admin/src-admin/src/dialogs/AdapterUpdateDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import 'moment/locale/pt';
import 'moment/locale/ru';
import 'moment/locale/uk';
import 'moment/locale/zh-cn';
import type { AdapterDependencies } from '@/dialogs/AddInstanceDialog';

const styles: Record<string, any> = {
closeButton: (theme: IobTheme) => ({
Expand Down Expand Up @@ -344,7 +345,7 @@ export function checkCondition(
interface AdapterUpdateDialogProps {
adapter: string;
adapterObject: RepoAdapterObject;
dependencies?: Record<string, any>[];
dependencies?: AdapterDependencies[];
news: News[];
noTranslation: boolean;
toggleTranslation: () => void;
Expand Down Expand Up @@ -450,20 +451,14 @@ class AdapterUpdateDialog extends Component<AdapterUpdateDialogProps, AdapterUpd
}

getDependencies(): JSX.Element[] {
const result: JSX.Element[] = [];

this.props.dependencies?.forEach(dependency => {
result.push(
<State
key={dependency.name}
state={dependency.rightVersion}
>
{`${dependency.name}${dependency.version ? ` (${dependency.version})` : ''}: ${dependency.installed ? dependency.installedVersion : '-'}`}
</State>,
);
});

return result;
return (this.props.dependencies || []).map(dependency => (
<State
key={dependency.name}
state={dependency.rightVersion}
>
{`${dependency.name}${dependency.version ? ` (${dependency.version})` : ''}: ${dependency.installed ? dependency.installedVersion : '-'}`}
</State>
));
}

getNews(): JSX.Element[] {
Expand Down
25 changes: 24 additions & 1 deletion packages/admin/src-admin/src/tabs/Adapters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ class Adapters extends AdapterInstallDialog<AdaptersProps, AdaptersState> {
let result = true;

if (adapter) {
const dependencies = adapter.dependencies;
let dependencies = adapter.dependencies;
const nodeVersion = adapter.node;

if (dependencies) {
Expand Down Expand Up @@ -1111,6 +1111,29 @@ class Adapters extends AdapterInstallDialog<AdaptersProps, AdaptersState> {
}
}

// @ts-expect-error Types implemented in js-controller
const ifDependencies: Record<string, string> = adapter.ifInstalledDependencies as Record<string, string>;

if (ifDependencies && typeof ifDependencies === 'object' && !Array.isArray(ifDependencies)) {
const adapters = Object.keys(ifDependencies);

adapters.forEach(name => {
if (result && name) {
const installed = this.state.installed[name];

try {
result = installed
? semver.satisfies(installed.version, ifDependencies[name], {
includePrerelease: true,
})
: true;
} catch {
result = true;
}
}
});
}

if (result && nodeVersion) {
try {
result = semver.satisfies(this.state.nodeJsVersion, nodeVersion);
Expand Down
Loading

0 comments on commit d985c06

Please sign in to comment.