|
@@ -53,7 +53,7 @@ def download_buffered(url: str) -> Path:
|
|
|
return filepath
|
|
|
|
|
|
|
|
|
-DEPENDENCIES = (root_path / 'DEPENDENCIES.md').open('w')
|
|
|
+DEPENDENCIES = (root_path / 'DEPENDENCIES.md').open('w', encoding='utf-8')
|
|
|
DEPENDENCIES.write('# Included Web Dependencies\n\n')
|
|
|
KNOWN_LICENSES = {
|
|
|
'UNKNOWN': 'UNKNOWN',
|
|
@@ -67,7 +67,7 @@ KNOWN_LICENSES = {
|
|
|
# Create a hidden folder to work in.
|
|
|
tmp = cleanup(root_path / '.npm')
|
|
|
|
|
|
-dependencies: Dict[str, dict] = json.loads((root_path / 'npm.json').read_text())
|
|
|
+dependencies: Dict[str, dict] = json.loads((root_path / 'npm.json').read_text(encoding='utf-8'))
|
|
|
for key, dependency in dependencies.items():
|
|
|
if names is not None and key not in names:
|
|
|
continue
|
|
@@ -77,7 +77,7 @@ for key, dependency in dependencies.items():
|
|
|
|
|
|
# Get package info from NPM.
|
|
|
package_name = dependency.get('package', key)
|
|
|
- npm_data = json.loads(download_buffered(f'https://registry.npmjs.org/{package_name}').read_text())
|
|
|
+ npm_data = json.loads(download_buffered(f'https://registry.npmjs.org/{package_name}').read_text(encoding='utf-8'))
|
|
|
npm_version = dependency.get('version') or dependency.get('version', npm_data['dist-tags']['latest'])
|
|
|
npm_tarball = npm_data['versions'][npm_version]['dist']['tarball']
|
|
|
license_ = 'UNKNOWN'
|
|
@@ -91,7 +91,7 @@ for key, dependency in dependencies.items():
|
|
|
# Handle the special case of tailwind. Hopefully remove this soon.
|
|
|
if 'download' in dependency:
|
|
|
download_path = download_buffered(dependency['download'])
|
|
|
- content = download_path.read_text()
|
|
|
+ content = download_path.read_text(encoding='utf-8')
|
|
|
MSG = (
|
|
|
'console.warn("cdn.tailwindcss.com should not be used in production. '
|
|
|
'To use Tailwind CSS in production, install it as a PostCSS plugin or use the Tailwind CLI: '
|
|
@@ -100,7 +100,7 @@ for key, dependency in dependencies.items():
|
|
|
if MSG not in content:
|
|
|
raise ValueError(f'Expected to find "{MSG}" in {download_path}')
|
|
|
content = content.replace(MSG, '')
|
|
|
- prepare(destination / dependency['rename']).write_text(content)
|
|
|
+ prepare(destination / dependency['rename']).write_text(content, encoding='utf-8')
|
|
|
|
|
|
# Download and extract.
|
|
|
tgz_file = prepare(Path(tmp, key, f'{key}.tgz'))
|
|
@@ -124,25 +124,25 @@ for key, dependency in dependencies.items():
|
|
|
Path(tmp, key, extracted.name).rename(newfile)
|
|
|
|
|
|
if 'GLTFLoader' in filename:
|
|
|
- content = newfile.read_text()
|
|
|
+ content = newfile.read_text(encoding='utf-8')
|
|
|
MSG = '../utils/BufferGeometryUtils.js'
|
|
|
if MSG not in content:
|
|
|
raise ValueError(f'Expected to find "{MSG}" in {filename}')
|
|
|
content = content.replace(MSG, 'BufferGeometryUtils')
|
|
|
- newfile.write_text(content)
|
|
|
+ newfile.write_text(content, encoding='utf-8')
|
|
|
|
|
|
if 'DragControls.js' in filename:
|
|
|
- content = newfile.read_text()
|
|
|
+ content = newfile.read_text(encoding='utf-8')
|
|
|
MSG = '_selected = findGroup( _intersections[ 0 ].object )'
|
|
|
if MSG not in content:
|
|
|
raise ValueError(f'Expected to find "{MSG}" in {filename}')
|
|
|
content = content.replace(MSG, MSG + ' || _intersections[ 0 ].object')
|
|
|
- newfile.write_text(content)
|
|
|
+ newfile.write_text(content, encoding='utf-8')
|
|
|
|
|
|
if 'mermaid.esm.min.mjs' in filename:
|
|
|
- content = newfile.read_text()
|
|
|
+ content = newfile.read_text(encoding='utf-8')
|
|
|
content = re.sub(r'"\./chunks/mermaid.esm.min/(.*?)\.mjs"', r'"\1"', content)
|
|
|
- newfile.write_text(content)
|
|
|
+ newfile.write_text(content, encoding='utf-8')
|
|
|
|
|
|
# Delete destination folder if empty.
|
|
|
if not any(destination.iterdir()):
|