Unvendor toml package (#1263)

* Unvendor toml package

* Try @iarna/toml instead

* Fix import

* Use @ltd/j-toml

* Update test

* Use toml-j0.4

* Fix toml import
This commit is contained in:
Hood Chatham
2023-03-09 10:06:43 +01:00
committed by GitHub
parent 41a8d804e3
commit 84e4e361c5
5 changed files with 23 additions and 1795 deletions

View File

@@ -14,7 +14,8 @@
"@codemirror/state": "6.1.2",
"@codemirror/theme-one-dark": "6.1.0",
"@codemirror/view": "6.3.0",
"codemirror": "6.0.1"
"codemirror": "6.0.1",
"toml-j0.4": "^1.1.1"
},
"devDependencies": {
"@jest/globals": "29.1.2",
@@ -5308,6 +5309,11 @@
"node": ">=8.0"
}
},
"node_modules/toml-j0.4": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/toml-j0.4/-/toml-j0.4-1.1.1.tgz",
"integrity": "sha512-lYK5otg0+cto8YmsWcPEfeiTiC/VU6P6HA6ooaYI9K/KYT24Jg0BrYtRZK1K3cwakSMyh6nttfJL9RmQH0gyCg=="
},
"node_modules/tough-cookie": {
"version": "4.1.2",
"dev": true,
@@ -9142,6 +9148,11 @@
"is-number": "^7.0.0"
}
},
"toml-j0.4": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/toml-j0.4/-/toml-j0.4-1.1.1.tgz",
"integrity": "sha512-lYK5otg0+cto8YmsWcPEfeiTiC/VU6P6HA6ooaYI9K/KYT24Jg0BrYtRZK1K3cwakSMyh6nttfJL9RmQH0gyCg=="
},
"tough-cookie": {
"version": "4.1.2",
"dev": true,

View File

@@ -49,6 +49,7 @@
"@codemirror/state": "6.1.2",
"@codemirror/theme-one-dark": "6.1.0",
"@codemirror/view": "6.3.0",
"codemirror": "6.0.1"
"codemirror": "6.0.1",
"toml-j0.4": "^1.1.1"
}
}

View File

@@ -1,7 +1,6 @@
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import legacy from '@rollup/plugin-legacy';
import typescript from '@rollup/plugin-typescript';
import css from 'rollup-plugin-css-only';
import serve from 'rollup-plugin-serve';
@@ -46,7 +45,6 @@ export default {
string({
include: './src/**/*.py',
}),
legacy({ 'src/toml.js': 'toml' }),
resolve({
browser: true,
}),

View File

@@ -1,4 +1,4 @@
import toml from '../src/toml';
import toml from 'toml-j0.4';
import { getLogger } from './logger';
import { version } from './version';
import { getAttribute, readTextFromPath, htmlDecode, createDeprecationWarning } from './utils';
@@ -145,17 +145,18 @@ function mergeConfig(inlineConfig: AppConfig, externalConfig: AppConfig): AppCon
function parseConfig(configText: string, configType = 'toml') {
if (configType === 'toml') {
// TOML parser is soft and can parse even JSON strings, this additional check prevents it.
if (configText.trim()[0] === '{') {
throw new UserError(
ErrorCode.BAD_CONFIG,
`The config supplied: ${configText} is an invalid TOML and cannot be parsed`,
);
}
try {
// TOML parser is soft and can parse even JSON strings, this additional check prevents it.
if (configText.trim()[0] === '{') {
throw new UserError(
ErrorCode.BAD_CONFIG,
`The config supplied: ${configText} is an invalid TOML and cannot be parsed`,
);
}
return toml.parse(configText);
} catch (err) {
const errMessage: string = err.toString();
throw new UserError(
ErrorCode.BAD_CONFIG,
`The config supplied: ${configText} is an invalid TOML and cannot be parsed: ${errMessage}`,

File diff suppressed because it is too large Load Diff