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/state": "6.1.2",
"@codemirror/theme-one-dark": "6.1.0", "@codemirror/theme-one-dark": "6.1.0",
"@codemirror/view": "6.3.0", "@codemirror/view": "6.3.0",
"codemirror": "6.0.1" "codemirror": "6.0.1",
"toml-j0.4": "^1.1.1"
}, },
"devDependencies": { "devDependencies": {
"@jest/globals": "29.1.2", "@jest/globals": "29.1.2",
@@ -5308,6 +5309,11 @@
"node": ">=8.0" "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": { "node_modules/tough-cookie": {
"version": "4.1.2", "version": "4.1.2",
"dev": true, "dev": true,
@@ -9142,6 +9148,11 @@
"is-number": "^7.0.0" "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": { "tough-cookie": {
"version": "4.1.2", "version": "4.1.2",
"dev": true, "dev": true,

View File

@@ -49,6 +49,7 @@
"@codemirror/state": "6.1.2", "@codemirror/state": "6.1.2",
"@codemirror/theme-one-dark": "6.1.0", "@codemirror/theme-one-dark": "6.1.0",
"@codemirror/view": "6.3.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 commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve'; import resolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser'; import { terser } from 'rollup-plugin-terser';
import legacy from '@rollup/plugin-legacy';
import typescript from '@rollup/plugin-typescript'; import typescript from '@rollup/plugin-typescript';
import css from 'rollup-plugin-css-only'; import css from 'rollup-plugin-css-only';
import serve from 'rollup-plugin-serve'; import serve from 'rollup-plugin-serve';
@@ -46,7 +45,6 @@ export default {
string({ string({
include: './src/**/*.py', include: './src/**/*.py',
}), }),
legacy({ 'src/toml.js': 'toml' }),
resolve({ resolve({
browser: true, browser: true,
}), }),

View File

@@ -1,4 +1,4 @@
import toml from '../src/toml'; import toml from 'toml-j0.4';
import { getLogger } from './logger'; import { getLogger } from './logger';
import { version } from './version'; import { version } from './version';
import { getAttribute, readTextFromPath, htmlDecode, createDeprecationWarning } from './utils'; import { getAttribute, readTextFromPath, htmlDecode, createDeprecationWarning } from './utils';
@@ -145,17 +145,18 @@ function mergeConfig(inlineConfig: AppConfig, externalConfig: AppConfig): AppCon
function parseConfig(configText: string, configType = 'toml') { function parseConfig(configText: string, configType = 'toml') {
if (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 { 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); return toml.parse(configText);
} catch (err) { } catch (err) {
const errMessage: string = err.toString(); const errMessage: string = err.toString();
throw new UserError( throw new UserError(
ErrorCode.BAD_CONFIG, ErrorCode.BAD_CONFIG,
`The config supplied: ${configText} is an invalid TOML and cannot be parsed: ${errMessage}`, `The config supplied: ${configText} is an invalid TOML and cannot be parsed: ${errMessage}`,

File diff suppressed because it is too large Load Diff