mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
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:
13
pyscriptjs/package-lock.json
generated
13
pyscriptjs/package-lock.json
generated
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}),
|
||||
|
||||
@@ -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
Reference in New Issue
Block a user