Skip to content

Commit

Permalink
try to fix build (#25)
Browse files Browse the repository at this point in the history
* fix build

* use the official device manager again

* change utils import

* autofix lint issues

* fix lint issue

* remove checks because outside check already caught them

* try to fix build

* fix consistent return

* add ts-expect-error for unsure types now

* fix another build error

* perform lint steps separate and ignore linter during build

* get rid of the dependency conflicts and thus force flag on install
  • Loading branch information
foxriver76 authored Jul 5, 2024
1 parent 3b49a53 commit 1319128
Show file tree
Hide file tree
Showing 16 changed files with 156 additions and 164 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,15 @@ jobs:
- name: Install Dependencies
run: npm run npm

- name: Lint TypeScript backend code
run: npm run lint

- name: Lint TypeScript frontend code
run: npm run lint-frontend

- name: Build
run: npm run build

# - name: Perform a type check
# run: npm run check:ts
# env:
# CI: true
# - name: Lint TypeScript code
# run: npm run lint
# - name: Test package files
# run: npm run test:package

# Runs adapter tests on all supported node versions and OSes
adapter-tests:
if: contains(github.event.head_commit.message, '[skip ci]') == false
Expand All @@ -54,7 +51,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18.x, 20.x]
node-version: [18.x, 20.x, 22.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
Expand Down
3 changes: 2 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ function build() {
return new Promise((resolve, reject) => {
const options = {
stdio: 'pipe',
cwd: `${__dirname}/src-admin/`
cwd: `${__dirname}/src-admin/`,
env: { DISABLE_ESLINT_PLUGIN: true }
};

const version = JSON.parse(fs.readFileSync(`${__dirname}/package.json`).toString('utf8')).version;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"@typescript-eslint/eslint-plugin": "^7.14.1",
"chai": "^4.4.1",
"eslint": "^8.57.0",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^17.9.0",
"eslint-plugin-promise": "^6.2.0",
Expand All @@ -67,6 +66,7 @@
"test": "mocha --exit",
"prepublishOnly": "npm run build",
"lint": "eslint --ext .ts src/",
"lint-frontend": "eslint src-admin/",
"build": "npm run build:ts && npm run build:gui",
"build:gui": "gulp",
"build:ts": "tsc -p tsconfig.build.json",
Expand All @@ -75,7 +75,7 @@
"release-minor": "release-script minor --yes",
"release-major": "release-script major --yes",
"update-packages": "ncu --upgrade && cd src-admin && ncu --upgrade",
"npm": "npm i -f && cd src-admin && npm i -f",
"npm": "npm i && cd src-admin && npm i",
"dev-server": "dev-server"
},
"license": "Apache-2.0",
Expand Down
1 change: 1 addition & 0 deletions src-admin/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
globals: {
ioBroker: true,
},
ignorePatterns: ['build/*'],
env: {
browser: true,
es2021: true,
Expand Down
2 changes: 1 addition & 1 deletion src-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@
}
]
]
}
}
34 changes: 18 additions & 16 deletions src-admin/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react';
import { ThemeProvider, StyledEngineProvider } from '@mui/material/styles';

import { AppBar, Tabs, Tab, IconButton } from '@mui/material';
import {
AppBar, Tabs, Tab, IconButton,
} from '@mui/material';

import {
SignalWifiConnectedNoInternet4 as IconNoConnection,
Expand All @@ -24,12 +26,6 @@ import ControllerTab from './Tabs/Controller';
import BridgesTab from './Tabs/Bridges';
import DevicesTab from './Tabs/Devices';

declare global {
interface Window {
sentryDSN: string;
}
}

import type {
MatterAdapterConfig,
NodeStateResponse,
Expand All @@ -39,6 +35,12 @@ import type {
CommissioningInfo,
} from './types';

declare global {
interface Window {
sentryDSN: string;
}
}

const productIDs: string[] = [];
for (let i = 0x8000; i <= 0x801f; i++) {
productIDs.push(`0x${i.toString(16)}`);
Expand Down Expand Up @@ -75,7 +77,7 @@ interface AppState extends GenericAppState {
}

class App extends GenericApp<GenericAppProps, AppState> {
private isIFrame: boolean = false;
private isIFrame = false;

private configHandler: ConfigHandler | null = null;

Expand Down Expand Up @@ -172,11 +174,15 @@ class App extends GenericApp<GenericAppProps, AppState> {
const commissioning = this.configHandler.getCommissioning();
matter.controller = matter.controller || { enabled: false };
matter.devices = matter.devices || [];
// @ts-expect-error list should not exist as it should be an array.. fix types
if (matter.devices.list) {
// @ts-expect-error list should not exist as it should be an array.. fix types
matter.devices = matter.devices.list;
}
matter.bridges = matter.bridges || [];
// @ts-expect-error list should not exist as it should be an array.. fix types
if (matter.bridges.list) {
// @ts-expect-error list should not exist as it should be an array.. fix types
matter.bridges = matter.bridges.list;
}

Expand All @@ -188,8 +194,7 @@ class App extends GenericApp<GenericAppProps, AppState> {
.catch(e =>
this.showError(
`Cannot subscribe on system.adapter.matter.${this.instance}.alive: ${e}`,
),
);
));

const alive = await this.socket.getState(
`system.adapter.matter.${this.instance}.alive`,
Expand Down Expand Up @@ -342,8 +347,7 @@ class App extends GenericApp<GenericAppProps, AppState> {
theme={this.state.theme}
detectedDevices={this.state.detectedDevices || []}
setDetectedDevices={(detectedDevices: DetectedRoom[]) =>
this.setState({ detectedDevices })
}
this.setState({ detectedDevices })}
productIDs={productIDs}
matter={this.state.matter}
updateConfig={this.onChanged}
Expand Down Expand Up @@ -372,16 +376,14 @@ class App extends GenericApp<GenericAppProps, AppState> {
theme={this.state.theme}
detectedDevices={this.state.detectedDevices || []}
setDetectedDevices={(detectedDevices: DetectedRoom[]) =>
this.setState({ detectedDevices })
}
this.setState({ detectedDevices })}
productIDs={productIDs}
instance={this.instance}
matter={this.state.matter}
updateConfig={this.onChanged}
showToast={(text: string) => this.showToast(text)}
checkLicenseOnAdd={(matter: MatterConfig) =>
this.checkLicenseOnAdd('addDevice', matter)
}
this.checkLicenseOnAdd('addDevice', matter)}
/>;
}

Expand Down
4 changes: 3 additions & 1 deletion src-admin/src/Tabs/BridgesAndDevices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ class BridgesAndDevices<
fontStyle: 'italic',
}}
>
({info.label})
(
{info.label}
)
</span>
) : null}
</TableCell>
Expand Down
41 changes: 15 additions & 26 deletions src-admin/src/Tabs/Controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,20 @@ import {
} from '@mui/icons-material';

import {
AdminConnection,
I18n,
IconClosed,
IconOpen,
type ThemeName,
type ThemeType,
type IobTheme,
} from '@iobroker/adapter-react-v5';
// import DeviceManager from '@iobroker/dm-gui-components';
import type {
AdminConnection,
ThemeName,
ThemeType,
IobTheme,
} from '@iobroker/adapter-react-v5';
import DeviceManager from '@iobroker/dm-gui-components';

import type { CommissionableDevice, GUIMessage, MatterConfig } from '@/types';
import { getText } from '../Utils';
import DeviceManager from '../components/InstanceManager';

const styles: Record<string, React.CSSProperties> = {
panel: {
Expand Down Expand Up @@ -142,8 +143,6 @@ class Controller extends Component<ComponentProps, ComponentState> {

private qrScanner: QrScanner | null | true = null;

private aliveState: boolean;

constructor(props: ComponentProps) {
super(props);
const openedNodesStr = window.localStorage.getItem('openedNodes');
Expand Down Expand Up @@ -173,8 +172,6 @@ class Controller extends Component<ComponentProps, ComponentState> {
showQrCodeDialog: null,
};

this.aliveState = this.props.alive;

this.refQrScanner = React.createRef();
}

Expand Down Expand Up @@ -241,16 +238,14 @@ class Controller extends Component<ComponentProps, ComponentState> {
`matter.${this.props.instance}.controller.*`,
this.onObjectChange,
)
.catch(e => window.alert(`Cannot subscribe: ${e}`)),
)
.catch(e => window.alert(`Cannot subscribe: ${e}`)))
.then(() =>
this.props.socket
.subscribeState(
`matter.${this.props.instance}.controller.*`,
this.onStateChange,
)
.catch(e => window.alert(`Cannot subscribe 1: ${e}`)),
);
.catch(e => window.alert(`Cannot subscribe 1: ${e}`)));
}

onObjectChange = (id: string, obj: ioBroker.Object | null | undefined) => {
Expand Down Expand Up @@ -368,8 +363,7 @@ class Controller extends Component<ComponentProps, ComponentState> {
return <Dialog
open={!0}
onClose={() =>
this.setState({ showQrCodeDialog: null }, () => this.destroyQrCode())
}
this.setState({ showQrCodeDialog: null }, () => this.destroyQrCode())}
>
<DialogTitle>{I18n.t('QR Code')}</DialogTitle>
<DialogContent>
Expand Down Expand Up @@ -427,8 +421,7 @@ class Controller extends Component<ComponentProps, ComponentState> {
onClick={() => {
const device = this.state.showQrCodeDialog;
this.setState({ showQrCodeDialog: null }, () =>
this.destroyQrCode(),
);
this.destroyQrCode());
this.props.socket
.sendTo(
`matter.${this.props.instance}`,
Expand Down Expand Up @@ -458,9 +451,7 @@ class Controller extends Component<ComponentProps, ComponentState> {
color="grey"
onClick={() =>
this.setState({ showQrCodeDialog: null }, () =>
this.destroyQrCode(),
)
}
this.destroyQrCode())}
startIcon={<Close />}
>
{I18n.t('Close')}
Expand Down Expand Up @@ -496,7 +487,7 @@ class Controller extends Component<ComponentProps, ComponentState> {
manualCode: '',
qrCode: '',
});
setTimeout(async() => this.initQrCode(), 500);
setTimeout(async () => this.initQrCode(), 500);
}}
>
<LeakAdd />
Expand All @@ -518,8 +509,7 @@ class Controller extends Component<ComponentProps, ComponentState> {
'controllerDiscoveryStop',
{},
)
.then(() => this.setState({ discoveryDone: false }))
}
.then(() => this.setState({ discoveryDone: false }))}
startIcon={<SearchOff />}
>
{I18n.t('Stop')}
Expand Down Expand Up @@ -951,8 +941,7 @@ class Controller extends Component<ComponentProps, ComponentState> {
});
}
},
),
);
));
}}
>
{I18n.t('Discovery devices')}
Expand Down
Loading

0 comments on commit 1319128

Please sign in to comment.