commit
e092cb029c
252 files changed
+35037
No files matched your search
+47
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-FileCopyrightText: 2026 Scientific Computing Studio, LLC
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Rebuilds src/vendor/codemirror.js (one ES module) and src/vendor/cm-types/ (its
|
||||
# declarations) from the CodeMirror packages' own sources on GitHub.
|
||||
#
|
||||
# Programming+ ships no bundler and no runtime dependency; CodeMirror is
|
||||
# vendored the way the pseudo and asm86 engines are, as a built file checked
|
||||
# into the repository. Rerun this to move to newer CodeMirror releases:
|
||||
#
|
||||
# scripts/vendor/codemirror.sh # the packages' main branches
|
||||
# scripts/vendor/codemirror.sh @6.5.0 ... # (edit PINS below for exact tags)
|
||||
#
|
||||
# Needs: git, node >= 20, esbuild on the PATH or in ESBUILD, and tsc.
|
||||
set -euo pipefail
|
||||
here="$(cd "$(dirname "$0")" && pwd)"
|
||||
root="$(cd "$here/../.." && pwd)"
|
||||
work="${CM_WORK:-$(mktemp -d)}"
|
||||
ESBUILD="${ESBUILD:-$(command -v esbuild || true)}"
|
||||
[ -n "$ESBUILD" ] || { echo "esbuild not found: npm i -g esbuild, or ESBUILD=/path/to/esbuild"; exit 1; }
|
||||
|
||||
# repo -> directory name the build script expects
|
||||
PINS=(
|
||||
"codemirror/state state" "codemirror/view view" "codemirror/language language" "codemirror/commands commands" "codemirror/search search"
|
||||
"marijnh/style-mod style-mod" "marijnh/w3c-keyname w3c-keyname" "marijnh/crelt crelt" "marijnh/find-cluster-break find-cluster-break"
|
||||
"lezer-parser/common common" "lezer-parser/highlight highlight" "lezer-parser/lr lr"
|
||||
)
|
||||
cd "$work"
|
||||
for pin in "${PINS[@]}"; do
|
||||
set -- $pin
|
||||
[ -d "$2" ] || git clone -q --depth 1 "https://github.com/$1" "$2"
|
||||
done
|
||||
# two packages have no src/index.ts of their own
|
||||
printf 'export * from "./commands"\nexport * from "./history"\nexport * from "./comment"\n' > commands/src/index.ts
|
||||
printf 'export * from "./search"\nexport * from "./cursor"\nexport * from "./regexp"\nexport * from "./goto-line"\nexport * from "./selection-match"\n' > search/src/index.ts
|
||||
cp "$here/entry.ts" "$here/build.mjs" "$here/relink.mjs" "$here/tsconfig.cm.json" .
|
||||
mv tsconfig.cm.json tsconfig.json
|
||||
ESBUILD_LIB="$(node -e "console.log(require.resolve('esbuild', { paths: [process.cwd(), '$(dirname "$ESBUILD")/..', '$(npm root -g)'] }))")" node build.mjs
|
||||
rm -rf types && (tsc -p tsconfig.json || true) # the packages' own sources have a few strict-mode complaints; the declarations still emit
|
||||
node relink.mjs
|
||||
rm -rf "$root/src/vendor/cm-types"
|
||||
cp codemirror.js "$root/src/vendor/codemirror.js"
|
||||
cp -r types "$root/src/vendor/cm-types"
|
||||
rm "$root/src/vendor/cm-types/entry.d.ts"
|
||||
sed 's#"\./#"./cm-types/#g' types/entry.d.ts > "$root/src/vendor/codemirror.d.ts"
|
||||
cp state/LICENSE "$root/src/vendor/CODEMIRROR-LICENSE"
|
||||
echo "vendored into $root/src/vendor from $work"
|
||||
Reference in new issue
Block a user