From 1752b0a8c7e9ddf7a23cf9323a571d676e0abb9a Mon Sep 17 00:00:00 2001 From: GermanBluefox Date: Fri, 11 Oct 2024 06:48:42 +0300 Subject: [PATCH 1/6] * (bluefox) Replaced `@iobroker/adapter-react-v5` with `@iobroker/react-components` --- .github/workflows/test-and-release.yml | 26 +----- README.md | 3 + craco.config.js | 2 +- gulpfile.js | 112 ------------------------- modulefederation.config.js | 2 +- package.json | 26 +++--- src/ConfigCustomEasyAccess.jsx | 10 +-- src/package-lock.json | 4 +- src/public | 0 tasks.js | 39 +++++++++ 10 files changed, 69 insertions(+), 155 deletions(-) delete mode 100644 gulpfile.js delete mode 100644 src/public create mode 100644 tasks.js diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index 2653ad5..a51d925 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -28,7 +28,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 20 - run: npm i --force - run: NODE_OPTIONS=--max_old_space_size=4096 npm run build @@ -42,18 +42,15 @@ jobs: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest - strategy: - matrix: - node-version: [16.x] steps: - name: Checkout code uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} + - name: Use Node.js 20.x uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} + node-version: 20.x - name: Extract the version and commit body from the tag id: extract_release @@ -93,20 +90,3 @@ jobs: # Prerelease versions create pre-releases on GitHub prerelease: ${{ contains(steps.extract_release.outputs.VERSION, '-') }} body: ${{ steps.extract_release.outputs.BODY }} - - #- name: Notify Sentry.io about the release - # run: | - # npm i -g @sentry/cli - # export SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} - # export SENTRY_URL=https://sentry.iobroker.net - # export SENTRY_ORG=iobroker - # export SENTRY_PROJECT=iobroker-admin - # export SENTRY_VERSION=iobroker.admin@${{ steps.extract_release.outputs.VERSION }} - # sentry-cli releases new $SENTRY_VERSION - # sentry-cli releases finalize $SENTRY_VERSION - - # Add the following line BEFORE finalize if repositories are connected in Sentry - # sentry-cli releases set-commits $SENTRY_VERSION --auto - - # Add the following line BEFORE finalize if sourcemap uploads are needed - # sentry-cli releases files $SENTRY_VERSION upload-sourcemaps build/ diff --git a/README.md b/README.md index fb3f7ad..8d76e4e 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,9 @@ Explanation: ### **WORK IN PROGRESS** --> ## Changelog +### **WORK IN PROGRESS** +* (bluefox) Replaced `@iobroker/adapter-react-v5` with `@iobroker/react-components` + ### 1.0.1 (2024-07-14) * (bluefox) Updated for Admin 7 diff --git a/craco.config.js b/craco.config.js index 4a6503d..c3b12fa 100644 --- a/craco.config.js +++ b/craco.config.js @@ -1,6 +1,6 @@ const CracoEsbuildPlugin = require('craco-esbuild'); const { ProvidePlugin } = require('webpack'); -const cracoModuleFederation = require('@iobroker/adapter-react-v5/craco-module-federation'); +const cracoModuleFederation = require('@iobroker/react-components/craco-module-federation'); module.exports = { plugins: [ diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index b4bb73a..0000000 --- a/gulpfile.js +++ /dev/null @@ -1,112 +0,0 @@ -const gulp = require('gulp'); -const fs = require('node:fs'); -const cp = require('node:child_process'); -const src = `${__dirname}/src/`; - -function deleteFoldersRecursive(path, exceptions) { - if (fs.existsSync(path)) { - const files = fs.readdirSync(path); - for (const file of files) { - const curPath = `${path}/${file}`; - if (exceptions && exceptions.find(e => curPath.endsWith(e))) { - continue; - } - - const stat = fs.statSync(curPath); - if (stat.isDirectory()) { - deleteFoldersRecursive(curPath); - fs.rmdirSync(curPath); - } else { - fs.unlinkSync(curPath); - } - } - } -} - -function npmInstall() { - return new Promise((resolve, reject) => { - // Install node modules - const cwd = src.replace(/\\/g, '/'); - - const cmd = `npm install -f`; - console.log(`"${cmd} in ${cwd}`); - - // System call used for update of js-controller itself, - // because during the installation npm packet will be deleted too, but some files must be loaded even during the installation process. - const exec = cp.exec; - const child = exec(cmd, {cwd}); - - child.stderr.pipe(process.stderr); - child.stdout.pipe(process.stdout); - - child.on('exit', code => { - // code 1 is a strange error that cannot be explained. Everything is installed but error :( - if (code && code !== 1) { - reject(`Cannot install: ${code}`); - } else { - console.log(`"${cmd} in ${cwd} finished.`); - // command succeeded - resolve(); - } - }); - }); -} - -function build() { - const version = JSON.parse(fs.readFileSync(`${__dirname}/package.json`).toString('utf8')).version; - const data = JSON.parse(fs.readFileSync(`${src}package.json`).toString('utf8')); - - data.version = version; - - fs.writeFileSync(`${src}package.json`, JSON.stringify(data, null, 4)); - - return new Promise((resolve, reject) => { - const options = { - stdio: 'pipe', - cwd: __dirname - }; - - console.log(options.cwd); - - let script = `${src}node_modules/@craco/craco/dist/bin/craco.js`; - if (!fs.existsSync(script)) { - script = `${__dirname}/node_modules/@craco/craco/dist/bin/craco.js`; - } - if (!fs.existsSync(script)) { - console.error(`Cannot find execution file: ${script}`); - reject(`Cannot find execution file: ${script}`); - } else { - const child = cp.fork(script, ['build'], options); - child.stdout.on('data', data => console.log(data.toString())); - child.stderr.on('data', data => console.log(data.toString())); - child.on('close', code => { - console.log(`child process exited with code ${code}`); - code ? reject(`Exit code: ${code}`) : resolve(); - }); - } - }); -} - -gulp.task('0-clean', done => { - deleteFoldersRecursive(`${__dirname}/admin`, ['admin-component-template.png', 'jsonConfig.json']); - deleteFoldersRecursive(`${__dirname}/src/build`); - done(); -}); - -gulp.task('1-npm', async () => npmInstall()); -gulp.task('2-compile', async () => build()); - -gulp.task('3-copy', () => Promise.all([ - gulp.src(['build/static/js/*.js']).pipe(gulp.dest('dist/admin/custom/static/js')), - gulp.src(['build/customComponents.js']).pipe(gulp.dest('dist/admin/custom')), - gulp.src(['build/customComponents.js.map']).pipe(gulp.dest('dist/admin/custom')), - gulp.src(['build/static/js/*.map']).pipe(gulp.dest('dist/admin/custom/static/js')), - gulp.src(['src/i18n/*.json']).pipe(gulp.dest('dist/admin/custom/i18n')), - gulp.src(['img/*']).pipe(gulp.dest('dist/img')), - gulp.src(['README.md', 'LICENSE']).pipe(gulp.dest('dist')), - gulp.src(['src/package.json']).pipe(gulp.dest('dist')), -])); - -gulp.task('build', gulp.series(['0-clean', '1-npm', '2-compile', '3-copy'])); - -gulp.task('default', gulp.series(['build'])); diff --git a/modulefederation.config.js b/modulefederation.config.js index 705b865..cedf884 100644 --- a/modulefederation.config.js +++ b/modulefederation.config.js @@ -1,4 +1,4 @@ -const { shared } = require('@iobroker/adapter-react-v5/modulefederation.admin.config'); +const { shared } = require('@iobroker/react-components/modulefederation.admin.config'); module.exports = { name: 'AdminComponentEasyAccessSet', diff --git a/package.json b/package.json index 0c68647..363ae79 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,11 @@ "start": "set PORT=4173 && craco start", "lint": "eslint --fix --ext .js,.jsx src", "webpack-build": "craco build", - "build": "gulp", + "build": "node tasks", + "0-clean": "node tasks --0-clean", + "1-npm": "node tasks --1-npm", + "2-compile": "node tasks --2-compile", + "3-copy": "node tasks --3-copy", "prepublishOnly": "echo Run publish in dist && exit 1", "release": "release-script", "release-patch": "release-script patch --yes", @@ -15,22 +19,22 @@ }, "dependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.21.11", - "@alcalzone/release-script": "^3.7.3", + "@alcalzone/release-script": "^3.8.0", "@alcalzone/release-script-plugin-license": "^3.7.0", - "@iobroker/adapter-react-v5": "^6.0.19", - "@iobroker/json-config": "^7.0.13", - "@mui/material": "^5.16.1", + "@iobroker/build-tools": "^2.0.6", + "@iobroker/react-components": "^7.2.5", + "@iobroker/json-config": "^7.2.5", + "@mui/material": "^6.1.3", "prop-types": "^15.8.1", "react": "^18.3.1", "react-dom": "^18.3.1", "react-scripts": "^5.0.1", - "gulp": "^4.0.2", - "@originjs/vite-plugin-federation": "^1.3.5", + "@originjs/vite-plugin-federation": "^1.3.6", "@rollup/plugin-babel": "^6.0.4", - "@rollup/plugin-commonjs": "^26.0.1", - "@rollup/plugin-node-resolve": "^15.2.3", - "@rollup/plugin-replace": "^5.0.7", - "@types/react": "^18.3.3", + "@rollup/plugin-commonjs": "^28.0.0", + "@rollup/plugin-node-resolve": "^15.3.0", + "@rollup/plugin-replace": "^6.0.1", + "@types/react": "^18.3.11", "@types/react-dom": "^18.3.0" }, "devDependencies": { diff --git a/src/ConfigCustomEasyAccess.jsx b/src/ConfigCustomEasyAccess.jsx index a221ba9..c713904 100644 --- a/src/ConfigCustomEasyAccess.jsx +++ b/src/ConfigCustomEasyAccess.jsx @@ -13,10 +13,10 @@ import { // important to make from package and not from some children. // invalid -// import ConfigGeneric from '@iobroker/adapter-react-v5/ConfigGeneric'; +// import ConfigGeneric from '@iobroker/react-components/ConfigGeneric'; // valid import { ConfigGeneric } from '@iobroker/json-config'; -import { i18n } from '@iobroker/adapter-react-v5'; +import { I18n } from '@iobroker/react-components'; const styles = { table: { @@ -59,9 +59,9 @@ class ConfigCustomEasyAccess extends ConfigGeneric { - {i18n.t('custom_easy_Instance')} - {i18n.t('custom_easy_Config')} - {i18n.t('custom_easy_Tab')} + {I18n.t('custom_easy_Instance')} + {I18n.t('custom_easy_Config')} + {I18n.t('custom_easy_Tab')} diff --git a/src/package-lock.json b/src/package-lock.json index 1192251..63c856a 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -1,12 +1,12 @@ { "name": "@iobroker/admin-component-easy-access", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@iobroker/admin-component-easy-access", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "devDependencies": {} } diff --git a/src/public b/src/public deleted file mode 100644 index e69de29..0000000 diff --git a/tasks.js b/tasks.js new file mode 100644 index 0000000..ff3458e --- /dev/null +++ b/tasks.js @@ -0,0 +1,39 @@ +const { deleteFoldersRecursive, npmInstall, buildReact, copyFiles } = require('@iobroker/build-tools'); + +function copyAllFiles() { + copyFiles(['build/static/js/*.js'], 'dist/admin/custom/static/js'); + copyFiles(['build/customComponents.js'], 'dist/admin/custom'); + copyFiles(['build/customComponents.js.map'], 'dist/admin/custom'); + copyFiles(['build/static/js/*.map'], 'dist/admin/custom/static/js'); + copyFiles(['src/i18n/*.json'], 'dist/admin/custom/i18n'); + copyFiles(['img/*'], 'dist/img'); + copyFiles(['README.md', 'LICENSE'], 'dist'); + copyFiles(['src/package.json'], 'dist'); +} + +if (process.argv.includes('--0-clean')) { + deleteFoldersRecursive(`${__dirname}/admin`, ['admin-component-template.png', 'jsonConfig.json']); + deleteFoldersRecursive(`${__dirname}/src/build`); +} else if (process.argv.includes('--1-npm')) { + npmInstall(__dirname).catch(e => { + console.error(`Cannot install packages: ${e}`); + process.exit(1); + }); +} else if (process.argv.includes('--2-compile')) { + buildReact(__dirname, { rootDir: __dirname, craco: true, exec: true }).catch(e => { + console.error(`Cannot compile: ${e}`); + process.exit(1); + }); +} else if (process.argv.includes('--3-copy')) { + copyAllFiles(); +} else { + deleteFoldersRecursive(`${__dirname}/admin`, ['admin-component-template.png', 'jsonConfig.json']); + deleteFoldersRecursive(`${__dirname}/src/build`); + npmInstall(src) + .then(() => buildReact(src, { rootDir: __dirname, craco: true, exec: true })) + .then(() => copyAllFiles()) + .catch(e => { + console.error(`Cannot build: ${e}`); + process.exit(1); + }); +} From 8b697d768fc686a5090875d88d7fc84149251458 Mon Sep 17 00:00:00 2001 From: GermanBluefox Date: Fri, 11 Oct 2024 06:49:29 +0300 Subject: [PATCH 2/6] Fixed build --- tasks.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks.js b/tasks.js index ff3458e..b85eca6 100644 --- a/tasks.js +++ b/tasks.js @@ -29,8 +29,8 @@ if (process.argv.includes('--0-clean')) { } else { deleteFoldersRecursive(`${__dirname}/admin`, ['admin-component-template.png', 'jsonConfig.json']); deleteFoldersRecursive(`${__dirname}/src/build`); - npmInstall(src) - .then(() => buildReact(src, { rootDir: __dirname, craco: true, exec: true })) + npmInstall(__dirname) + .then(() => buildReact(__dirname, { rootDir: __dirname, craco: true, exec: true })) .then(() => copyAllFiles()) .catch(e => { console.error(`Cannot build: ${e}`); From f80de7859477b7fe50aec2ffe1bdc34c8167eeb1 Mon Sep 17 00:00:00 2001 From: GermanBluefox Date: Fri, 11 Oct 2024 06:50:10 +0300 Subject: [PATCH 3/6] chore: release v1.0.2 * (bluefox) Replaced `@iobroker/adapter-react-v5` with `@iobroker/react-components` --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8d76e4e..c77e04d 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Explanation: ### **WORK IN PROGRESS** --> ## Changelog -### **WORK IN PROGRESS** +### 1.0.2 (2024-10-11) * (bluefox) Replaced `@iobroker/adapter-react-v5` with `@iobroker/react-components` ### 1.0.1 (2024-07-14) diff --git a/package.json b/package.json index 363ae79..69d3232 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "iobroker-admin-component-easy-access", "private": true, - "version": "1.0.1", + "version": "1.0.2", "scripts": { "start": "set PORT=4173 && craco start", "lint": "eslint --fix --ext .js,.jsx src", From 200b09582f9f810098c2c751aab543f0953f5bba Mon Sep 17 00:00:00 2001 From: GermanBluefox Date: Fri, 11 Oct 2024 06:50:21 +0300 Subject: [PATCH 4/6] Fixed build --- tasks.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks.js b/tasks.js index b85eca6..fad5b23 100644 --- a/tasks.js +++ b/tasks.js @@ -27,8 +27,8 @@ if (process.argv.includes('--0-clean')) { } else if (process.argv.includes('--3-copy')) { copyAllFiles(); } else { - deleteFoldersRecursive(`${__dirname}/admin`, ['admin-component-template.png', 'jsonConfig.json']); - deleteFoldersRecursive(`${__dirname}/src/build`); + deleteFoldersRecursive(`${__dirname}/dist`); + deleteFoldersRecursive(`${__dirname}/build`); npmInstall(__dirname) .then(() => buildReact(__dirname, { rootDir: __dirname, craco: true, exec: true })) .then(() => copyAllFiles()) From 350c62f12416f40340ff4551aa84e62e45dddffd Mon Sep 17 00:00:00 2001 From: GermanBluefox Date: Fri, 11 Oct 2024 07:05:03 +0300 Subject: [PATCH 5/6] Fixed build --- README.md | 2 +- src/package-lock.json | 14 -------------- src/package.json | 2 +- tasks.js | 19 ++++++++++++++----- 4 files changed, 16 insertions(+), 21 deletions(-) delete mode 100644 src/package-lock.json diff --git a/README.md b/README.md index c77e04d..8d76e4e 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Explanation: ### **WORK IN PROGRESS** --> ## Changelog -### 1.0.2 (2024-10-11) +### **WORK IN PROGRESS** * (bluefox) Replaced `@iobroker/adapter-react-v5` with `@iobroker/react-components` ### 1.0.1 (2024-07-14) diff --git a/src/package-lock.json b/src/package-lock.json deleted file mode 100644 index 63c856a..0000000 --- a/src/package-lock.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "@iobroker/admin-component-easy-access", - "version": "1.0.1", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "@iobroker/admin-component-easy-access", - "version": "1.0.1", - "license": "MIT", - "devDependencies": {} - } - } -} diff --git a/src/package.json b/src/package.json index e67f64e..fa4458a 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "@iobroker/admin-component-easy-access", - "version": "1.0.1", + "version": "1.0.2", "description": "Admin JSON config component", "author": { "name": "bluefox", diff --git a/tasks.js b/tasks.js index fad5b23..f47fec8 100644 --- a/tasks.js +++ b/tasks.js @@ -11,6 +11,14 @@ function copyAllFiles() { copyFiles(['src/package.json'], 'dist'); } +function build() { + const pack = require(`${__dirname}/package.json`); + const packSrc = require(`${__dirname}/src/package.json`); + packSrc.version = pack.version; + require('fs').writeFileSync(`${__dirname}/src/package.json`, JSON.stringify(packSrc, null, 4)); + return buildReact(__dirname, { rootDir: __dirname, craco: true, exec: true }); +} + if (process.argv.includes('--0-clean')) { deleteFoldersRecursive(`${__dirname}/admin`, ['admin-component-template.png', 'jsonConfig.json']); deleteFoldersRecursive(`${__dirname}/src/build`); @@ -20,17 +28,18 @@ if (process.argv.includes('--0-clean')) { process.exit(1); }); } else if (process.argv.includes('--2-compile')) { - buildReact(__dirname, { rootDir: __dirname, craco: true, exec: true }).catch(e => { - console.error(`Cannot compile: ${e}`); - process.exit(1); - }); + build() + .catch(e => { + console.error(`Cannot compile: ${e}`); + process.exit(1); + }); } else if (process.argv.includes('--3-copy')) { copyAllFiles(); } else { deleteFoldersRecursive(`${__dirname}/dist`); deleteFoldersRecursive(`${__dirname}/build`); npmInstall(__dirname) - .then(() => buildReact(__dirname, { rootDir: __dirname, craco: true, exec: true })) + .then(() => build()) .then(() => copyAllFiles()) .catch(e => { console.error(`Cannot build: ${e}`); From c1d18491e7528fa6e524d27b47171c2ad30edac8 Mon Sep 17 00:00:00 2001 From: GermanBluefox Date: Fri, 11 Oct 2024 07:05:48 +0300 Subject: [PATCH 6/6] chore: release v1.0.3 * (bluefox) Replaced `@iobroker/adapter-react-v5` with `@iobroker/react-components` --- README.md | 2 +- package.json | 2 +- src/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8d76e4e..9f4ed15 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Explanation: ### **WORK IN PROGRESS** --> ## Changelog -### **WORK IN PROGRESS** +### 1.0.3 (2024-10-11) * (bluefox) Replaced `@iobroker/adapter-react-v5` with `@iobroker/react-components` ### 1.0.1 (2024-07-14) diff --git a/package.json b/package.json index 69d3232..b01a893 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "iobroker-admin-component-easy-access", "private": true, - "version": "1.0.2", + "version": "1.0.3", "scripts": { "start": "set PORT=4173 && craco start", "lint": "eslint --fix --ext .js,.jsx src", diff --git a/src/package.json b/src/package.json index fa4458a..255cf70 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "@iobroker/admin-component-easy-access", - "version": "1.0.2", + "version": "1.0.3", "description": "Admin JSON config component", "author": { "name": "bluefox",