Skip to content
Snippets Groups Projects
Verified Commit 83ef62f2 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

feat: Update dependencies and improve Updater class structure

Summary of changes
- Added `prettier` as a devDependency in both `package.json` and `package-lock.json` to maintain code formatting standards.
- Reorganized import statements in `updater.mjs` for better readability and consistency.
- Enhanced the Updater class methods by refining spaces and indentation for improved code clarity.
- Introduced a new helper function `parseIntArray` for parsing integer arrays, cleaning up `retrieveAndSetValue` function.

Changes
- Updated `package.json` and `package-lock.json` to include the latest version of `prettier`.
- Reformatted multiple sections in `updater.mjs` to adhere to a consistent style, making future edits easier and reducing visual clutter.
- Improved logic readability in `retrieveAndSetValue` by delegating array parsing to the new `parseIntArray` function.
parent 655e26fc
Branches
Tags
No related merge requests found
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
"postcss-responsive-type": "^1.0.0", "postcss-responsive-type": "^1.0.0",
"postcss-rtlcss": "^5.7.1", "postcss-rtlcss": "^5.7.1",
"postcss-strip-units": "^2.0.1", "postcss-strip-units": "^2.0.1",
"prettier": "^3.6.2",
"puppeteer": "^24.11.2", "puppeteer": "^24.11.2",
"sinon": "^21.0.0", "sinon": "^21.0.0",
"turbowatch": "^2.29.4", "turbowatch": "^2.29.4",
...@@ -6853,6 +6854,22 @@ ...@@ -6853,6 +6854,22 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/prettier": {
"version": "3.6.2",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz",
"integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==",
"dev": true,
"license": "MIT",
"bin": {
"prettier": "bin/prettier.cjs"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/pretty-ms": { "node_modules/pretty-ms": {
"version": "7.0.1", "version": "7.0.1",
"resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.1.tgz", "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.1.tgz",
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "2.0.6", "@biomejs/biome": "2.0.6",
"buffer": "^6.0.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2", "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@peculiar/webcrypto": "^1.5.0", "@peculiar/webcrypto": "^1.5.0",
"@playwright/test": "^1.53.2", "@playwright/test": "^1.53.2",
...@@ -53,6 +52,7 @@ ...@@ -53,6 +52,7 @@
"autoprefixer": "^10.4.21", "autoprefixer": "^10.4.21",
"browserslist": "^4.25.1", "browserslist": "^4.25.1",
"btoa": "^1.2.1", "btoa": "^1.2.1",
"buffer": "^6.0.3",
"c8": "^10.1.3", "c8": "^10.1.3",
"chai": "^5.2.0", "chai": "^5.2.0",
"chai-dom": "^1.12.1", "chai-dom": "^1.12.1",
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
"postcss-responsive-type": "^1.0.0", "postcss-responsive-type": "^1.0.0",
"postcss-rtlcss": "^5.7.1", "postcss-rtlcss": "^5.7.1",
"postcss-strip-units": "^2.0.1", "postcss-strip-units": "^2.0.1",
"prettier": "^3.6.2",
"puppeteer": "^24.11.2", "puppeteer": "^24.11.2",
"sinon": "^21.0.0", "sinon": "^21.0.0",
"turbowatch": "^2.29.4", "turbowatch": "^2.29.4",
......
...@@ -434,6 +434,7 @@ function retrieveAndSetValue(element) { ...@@ -434,6 +434,7 @@ function retrieveAndSetValue(element) {
break; break;
case "string[]": case "string[]":
case "[]string":
if (isString(value)) { if (isString(value)) {
if (value.trim() === "") { if (value.trim() === "") {
value = []; value = [];
...@@ -454,38 +455,11 @@ function retrieveAndSetValue(element) { ...@@ -454,38 +455,11 @@ function retrieveAndSetValue(element) {
case "int[]": case "int[]":
case "integer[]": case "integer[]":
if (isString(value)) { case "number[]":
if (value.trim() === "") { case "[]int":
value = []; case "[]integer":
} else { case "[]number":
value = value value=parseIntArray(value)
.split(",")
.map((v) => {
try {
return parseInt(v, 10);
} catch (e) {}
return -1;
})
.filter((v) => v !== -1);
}
} else if (isInteger(value)) {
value = [value];
} else if (value === undefined || value === null) {
value = [];
} else if (isArray(value)) {
value = value
.split(",")
.map((v) => {
try {
return parseInt(v, 10);
} catch (e) {}
return -1;
})
.filter((v) => v !== -1);
} else {
throw new Error("unsupported value");
}
break; break;
case "[]": case "[]":
case "array": case "array":
...@@ -531,6 +505,30 @@ function retrieveAndSetValue(element) { ...@@ -531,6 +505,30 @@ function retrieveAndSetValue(element) {
} }
} }
/**
* @private
*/
function parseIntArray(val) {
if (isString(val)) {
return val.trim() === ""
? []
: val
.split(",")
.map((v) => parseInt(v, 10))
.filter((v) => !isNaN(v));
} else if (isInteger(val)) {
return [val];
} else if (val === undefined || val === null) {
return [];
} else if (isArray(val)) {
return val
.map((v) => parseInt(v, 10))
.filter((v) => !isNaN(v));
}
throw new Error("unsupported value for int array");
}
/** /**
* @license AGPLv3 * @license AGPLv3
* @since 1.27.0 * @since 1.27.0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment