package.json: replace toml package

We need to be able to stringify objects into a toml format for on-prem.
This is needed to save the worker config, unfortunately the current toml
package only parses toml and can't stringify back to toml.
This commit is contained in:
Gianluca Zuccarelli 2025-04-29 16:36:54 +00:00 committed by Klara Simickova
parent cfa437a34b
commit 1715d395c2
4 changed files with 26 additions and 17 deletions

22
package-lock.json generated
View file

@ -9,6 +9,7 @@
"version": "1.1.0",
"hasInstallScript": true,
"dependencies": {
"@ltd/j-toml": "1.38.0",
"@patternfly/patternfly": "5.4.1",
"@patternfly/react-code-editor": "5.4.1",
"@patternfly/react-core": "5.4.12",
@ -28,8 +29,7 @@
"react-redux": "9.2.0",
"react-router-dom": "6.27.0",
"redux": "5.0.1",
"redux-promise-middleware": "6.2.0",
"toml": "3.0.0"
"redux-promise-middleware": "6.2.0"
},
"devDependencies": {
"@babel/core": "7.26.10",
@ -3355,6 +3355,12 @@
"dev": true,
"license": "MIT"
},
"node_modules/@ltd/j-toml": {
"version": "1.38.0",
"resolved": "https://registry.npmjs.org/@ltd/j-toml/-/j-toml-1.38.0.tgz",
"integrity": "sha512-lYtBcmvHustHQtg4X7TXUu1Xa/tbLC3p2wLvgQI+fWVySguVZJF60Snxijw5EiohumxZbR10kWYFFebh1zotiw==",
"license": "LGPL-3.0"
},
"node_modules/@monaco-editor/loader": {
"version": "1.4.0",
"license": "MIT",
@ -18007,10 +18013,6 @@
"node": ">=0.6"
}
},
"node_modules/toml": {
"version": "3.0.0",
"license": "MIT"
},
"node_modules/toposort": {
"version": "2.0.2",
"license": "MIT"
@ -21618,6 +21620,11 @@
"version": "2.0.5",
"dev": true
},
"@ltd/j-toml": {
"version": "1.38.0",
"resolved": "https://registry.npmjs.org/@ltd/j-toml/-/j-toml-1.38.0.tgz",
"integrity": "sha512-lYtBcmvHustHQtg4X7TXUu1Xa/tbLC3p2wLvgQI+fWVySguVZJF60Snxijw5EiohumxZbR10kWYFFebh1zotiw=="
},
"@monaco-editor/loader": {
"version": "1.4.0",
"requires": {
@ -30837,9 +30844,6 @@
"version": "1.0.1",
"dev": true
},
"toml": {
"version": "3.0.0"
},
"toposort": {
"version": "2.0.2"
},

View file

@ -7,6 +7,7 @@
"npm": ">=7.0.0"
},
"dependencies": {
"@ltd/j-toml": "1.38.0",
"@patternfly/patternfly": "5.4.1",
"@patternfly/react-code-editor": "5.4.1",
"@patternfly/react-core": "5.4.12",
@ -26,17 +27,16 @@
"react-redux": "9.2.0",
"react-router-dom": "6.27.0",
"redux": "5.0.1",
"redux-promise-middleware": "6.2.0",
"toml": "3.0.0"
"redux-promise-middleware": "6.2.0"
},
"devDependencies": {
"@babel/core": "7.26.10",
"@babel/preset-env": "7.27.1",
"@babel/preset-react": "7.26.3",
"@babel/preset-typescript": "7.27.0",
"@currents/playwright": "1.12.1",
"@patternfly/react-icons": "5.4.2",
"@playwright/test": "1.51.1",
"@currents/playwright": "1.12.1",
"@redhat-cloud-services/eslint-config-redhat-cloud-services": "2.0.12",
"@redhat-cloud-services/frontend-components-config": "6.3.8",
"@redhat-cloud-services/tsc-transform-imports": "1.0.23",

View file

@ -1,5 +1,6 @@
import React from 'react';
import { parse } from '@ltd/j-toml';
import {
ActionGroup,
Button,
@ -18,7 +19,6 @@ import { DropEvent } from '@patternfly/react-core/dist/esm/helpers';
import { HelpIcon } from '@patternfly/react-icons';
import { addNotification } from '@redhat-cloud-services/frontend-components-notifications/redux';
import { useNavigate } from 'react-router-dom';
import { parse } from 'toml';
import { mapOnPremToHosted } from './helpers/onPremToHostedBlueprintMapper';
@ -27,7 +27,10 @@ import {
useBulkImportRepositoriesMutation,
} from '../../store/contentSourcesApi';
import { useAppDispatch } from '../../store/hooks';
import { BlueprintExportResponse } from '../../store/imageBuilderApi';
import {
BlueprintExportResponse,
BlueprintItem,
} from '../../store/imageBuilderApi';
import { importCustomRepositories, wizardState } from '../../store/wizardSlice';
import { resolveRelPath } from '../../Utilities/path';
import { mapExportRequestToState } from '../CreateImageWizard/utilities/requestMapper';
@ -130,7 +133,9 @@ export const ImportBlueprintModal: React.FunctionComponent<
const isJson = filename.endsWith('.json');
if (isToml) {
const tomlBlueprint = parse(fileContent);
const blueprintFromFile = mapOnPremToHosted(tomlBlueprint);
const blueprintFromFile = mapOnPremToHosted(
tomlBlueprint as BlueprintItem
);
const importBlueprintState = mapExportRequestToState(
blueprintFromFile,
[]

View file

@ -6,9 +6,9 @@ import path from 'path';
// the `tsconfig` to stubs of the `cockpit` and `cockpit/fsinfo`
// modules. These stubs are in the `src/test/mocks/cockpit` directory.
// We also needed to create an alias in vitest to make this work.
import TOML from '@ltd/j-toml';
import cockpit from 'cockpit';
import { fsinfo } from 'cockpit/fsinfo';
import TOML from 'toml';
import { v4 as uuidv4 } from 'uuid';
// We have to work around RTK query here, since it doesn't like splitting
@ -382,7 +382,7 @@ export const cockpitApi = contentSourcesApi.injectEndpoints({
)) as string;
const parsed = TOML.parse(result);
const blueprint = mapOnPremToHosted(parsed);
const blueprint = mapOnPremToHosted(parsed as BlueprintItem);
result = (await cockpit.spawn(
[