Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/cdn/setup.py
Views: 687
#!/usr/bin/env python312import os3from os.path import join, abspath, dirname, islink, exists4import json5from shutil import copytree67curdir = dirname(abspath(__file__))8os.chdir(join(curdir, 'dist'))910extra_path = {11'katex': 'dist/',12}1314deps = json.load(open(join('..', 'package-lock.json')))["dependencies"]15targets = list(16json.load(open(join('..', 'package.json')))["devDependencies"].keys())17BLACKLIST = ["typescript"]1819versions = {}20for path, data in deps.items():21if any(path.startswith(b) for b in BLACKLIST):22continue23if '/' in path:24name = path.split('/')[-1]25else:26name = path27if name not in targets:28continue29extra = extra_path.get(name, '')30# links must be relative to the current directory (we want to be able to move the directory around)31src = join("..", "node_modules", path, extra)32if not exists(src):33raise Exception(34f"target '{src}' does not exist -- did you forget to run 'npm ci' in '{curdir}'?"35)36version = data['version']37copytree(src, name)38dst = f"{name}-{version}"39print(f"symlink with version '{dst}' -> '{src}'")40os.symlink(name, dst)41versions[name] = version4243# finally, write the version info such that it can be loaded44with open('index.js', 'w') as out:45out.write(f"""46"use strict";47exports.__esModule = true;48exports.path = exports.versions = void 0;49exports.versions = {json.dumps(versions)};50exports.path = __dirname;51""")525354