ipydrawio/scripts/project.py

130 wiersze
3.5 KiB
Python
Czysty Zwykły widok Historia

Split up packages (#1) * add drawio * more tweaking of editor load * more work on packaging * linting, remove trace of mxgraph submodule * clean up empty file rendering * add some missing images * don't reinitialize url after every show * some css sugar * belt and suspenders ui theme * some more params * add export * working on logo * more logo work * full in-place round-tripping of svg, png, html * use icons on documents * clean up some untitled files * first pass at schema * start settings integration * more work on settings * fix ref * work on url params * some more tweaks to load behavior * move submodule * clean up some packaging stuff * jlpm * resolve yarn * fix iframe url * bump to newest drawio release * brinf back the stencils * html doesn't really work * add more images * move more things from code into config defaults * rework settings some more * fix new view, still working on click-to-activate * fix capitalization on compressXml * give up on formatting xml * more work on round-trip, styling * linting * more missing images * more config reloading * drawio v13.1.8 * bump drawio files * update notebook * upgrade typescript * more submodule shenanigans, binder env * regenerate again, was missing stencils * try adding server proxy * update path * fix schema * pin node * hoist jupyter_notebook_config.json * some more work on export * more x * add some more demo tools * use apt, some status * apt deps, get back icons * some more apt work * more apt work * better programmatic example * more status work * more docs * add some more text * some more notes * some more status work, notes * add jinja example * more work on notebook * move notebook * add some deps * more deps for pandas, pdf * use local drawio assets * stop servers harder * Create Data-Driven Decks.ipynb * Update drawio_export_demo.py * Create template deck.dio * fix up some chores * some notebook tweaks * more work on demo * try another labextension spot * notebooks * store composite drawio in pdf * use file:// for drawio static * drawio v13.3.5 * remove even more unused code * bump drawio, remove more tornado junk * clean up xml pattern * add notebook, because why not * add ipynb example to decks * add png, svg to composite * add video chat for giggles * drawio v13.3.8 * add plugins * more work on plugin stuff * drawio v13.3.9 * drawio v13.4.7 * resolve yarn.lock * add sourcemaps * drawio v13.4.9 * start patching towards rtc * add plugin path to patches * add a mess of plugins * turn down the plugins * drawio v13.5.3 * re-solve static * get rid of all the high unicode in schema * use utf-8 encoding explicitly * Update package.json * Update _static.ts * drawio v13.5.4 * resolve static * drawio v13.5.8 * move notebooks * start moving things around * add dodo.py * more moving * more moving * more moving and naming * moving * move static * fix up static path * update more ids, locations * skeleton docs * start doing it * start linting in anger * passing eslint * add prebuild * yet more linting * back to ts building * packing * hoist tarball * clean up static generation * apply lint in anger * more work on static * remove videochat for now, more ignoring * tune up ci, binder * use smaller env for now * underspecify python in ci, don't url-encode [p]lugins * gah windows * some win debugging * do some roadmap work * work on roadmap while debugging * do per-platform shell commands * linting, url param * look harder for npm * start thinking about versions * version bumping, more windows work * remove patterns from schema * add all task * more encoding, linting * rebuild static with iife * try another import template * versions in changelog * more work on alernate asset loading * revert menu investigations * paths for windows
2020-08-08 13:45:27 +00:00
""" important project paths
this should not import anything not in py36+ stdlib, or any local paths
"""
import json
import os
import platform
import shutil
import sys
from pathlib import Path
# platform
PLATFORM = os.environ.get("FAKE_PLATFORM", platform.system())
WIN = PLATFORM == "Windows"
OSX = PLATFORM == "Darwin"
UNIX = not WIN
PREFIX = Path(sys.prefix)
# find root
SCRIPTS = Path(__file__).parent.resolve()
ROOT = SCRIPTS.parent
BINDER = ROOT / "binder"
# top-level stuff
NODE_MODULES = ROOT / "node_modules"
PACKAGE = ROOT / "package.json"
PACKAGES = ROOT / "packages"
YARN_INTEGRITY = NODE_MODULES / ".yarn-integrity"
YARN_LOCK = ROOT / "yarn.lock"
EXTENSIONS_FILE = BINDER / "labextensions.txt"
EXTENSIONS = sorted(
[
line.strip()
for line in EXTENSIONS_FILE.read_text().strip().splitlines()
if line and not line.startswith("#")
]
)
CI = ROOT / ".github"
DODO = ROOT / "dodo.py"
BUILD = ROOT / "build"
DIST = ROOT / "dist"
# tools
PY = ["python"]
PYM = [*PY, "-m"]
PIP = [*PYM, "pip"]
NPM = (
shutil.which("npm")
or shutil.which("npm.cmd")
or shutil.which("npm.exe")
or shutil.which("npm.bat")
)
JLPM = ["jlpm"]
JLPM_INSTALL = [*JLPM, "--ignore-optional", "--prefer-offline"]
LAB_EXT = ["jupyter", "labextension"]
LAB = ["jupyter", "lab"]
PRETTIER = [str(NODE_MODULES / ".bin" / "prettier")]
# lab stuff
LAB_APP_DIR = PREFIX / "share/jupyter/lab"
LAB_STAGING = LAB_APP_DIR / "staging"
LAB_LOCK = LAB_STAGING / "yarn.lock"
LAB_STATIC = LAB_APP_DIR / "static"
LAB_INDEX = LAB_STATIC / "index.html"
# tests
EXAMPLES = ROOT / "notebooks"
EXAMPLE_IPYNB = [
p for p in EXAMPLES.rglob("*.ipynb") if ".ipynb_checkpoints" not in str(p)
]
DIST_NBHTML = DIST / "nbsmoke"
# js packages
JS_NS = "@deathbeds"
JDIO = PACKAGES / "jupyterlab-drawio"
JDIO_SRC = JDIO / "src"
JDIO_PKG = JDIO / "package.json"
JDIO_PKG_DATA = json.loads(JDIO_PKG.read_text(encoding="utf-8"))
JDIO_STYLE = JDIO / "style"
JDIO_TSBUILD = JDIO / "lib" / ".tsbuildinfo"
JDIO_TARBALL = JDIO / f"""deathbeds-jupyterlab-drawio-{JDIO_PKG_DATA["version"]}.tgz"""
JDW = PACKAGES / "jupyterlab-drawio-webpack"
JDW_APP = JDW / "drawio/src/main/webapp/js/app.min.js"
JDW_PKG = JDW / "package.json"
JDW_PKG_DATA = json.loads(JDW_PKG.read_text(encoding="utf-8"))
JDW_PY = (JDW / "scripts").rglob("*.py")
DRAWIO = JDW / "drawio"
JDW_LIB = JDW / "lib"
JDW_IGNORE = JDW / ".npmignore"
ALL_JDW_JS = JDW_LIB.glob("*.js")
JDW_TARBALL = (
JDW / f"""deathbeds-jupyterlab-drawio-webpack-{JDW_PKG_DATA["version"]}.tgz"""
)
# mostly linting
ALL_PY = [DODO, *SCRIPTS.glob("*.py"), *JDW_PY]
ALL_YML = [*ROOT.glob("*.yml"), *CI.rglob("*.yml")]
ALL_JSON = [
*ROOT.glob("*.json"),
*PACKAGES.glob("*/*.json"),
*PACKAGES.glob("*/schema/*.json"),
]
ALL_MD = [*ROOT.glob("*.md"), *PACKAGES.glob("*/*.md")]
ALL_TS = [*JDIO_SRC.rglob("*.ts")]
ALL_CSS = [*JDIO_STYLE.rglob("*.css")]
ALL_PRETTIER = [*ALL_YML, *ALL_JSON, *ALL_MD, *ALL_TS, *ALL_CSS]
PKG_PACK = {
JDIO: [[JDIO / "package.json", JDIO_TSBUILD], JDIO_TARBALL],
JDW: [[JDW / "package.json", JDW_IGNORE, JDW_APP, *ALL_JDW_JS], JDW_TARBALL],
}
# built files
OK_SUBMODULES = BUILD / "submodules.ok"
OK_BLACK = BUILD / "black.ok"
OK_FLAKE8 = BUILD / "flake8.ok"
OK_ISORT = BUILD / "isort.ok"
OK_LINT = BUILD / "lint.ok"
OK_PYFLAKES = BUILD / "pyflakes.ok"
OK_PRETTIER = BUILD / "prettier.ok"
OK_ESLINT = BUILD / "eslint.ok"
OK_JS_BUILD_PRE = BUILD / "js.build.pre.ok"
OK_JS_BUILD = BUILD / "js.build.ok"
# built artifacts
EXAMPLE_HTML = [DIST_NBHTML / p.name.replace(".ipynb", ".html") for p in EXAMPLE_IPYNB]