diff --git a/package.json b/package.json index c85f1609..2ded0e8f 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "compile-monaco-languages": "NODE_OPTIONS=--max_old_space_size=16384 rollup --config rollup/rollup.monaco.ts --configPlugin 'typescript={tsconfig: `tsconfig.rollup-config-monaco.json`}'", "clean": "rm -rf dist/", "compile-rollup-plugins": "rollup --config rollup/rollup.rollup-plugins.config.ts --configPlugin 'typescript={tsconfig: `tsconfig.rollup-config-plugins.json`, include: [`./rollup/rollup.rollup-plugins.config.ts`, `./rollup/rollup-metadata-plugin.ts`]}'", - "preprepare": "patch-package && ./scripts/install-vscode", + "preprepare": "patch-package && ./scripts/install-vscode && ./scripts/install-monaco-editor", "lint": "eslint '{src/**/*.ts,rollup/*.ts,*.ts}'", "generate-types": "./scripts/generate-types", "update-vscode-dependencies": "node --loader ts-node/esm scripts/update-vscode-dependencies.ts", @@ -36,8 +36,8 @@ "commit": "fee1edb8d6d72a0ddff41e5f71a671c23ed924b9" }, "monaco": { - "ref": "v0.50.0", - "version": "0.50.0" + "ref": "v0.51.0", + "version": "0.51.0" } }, "devDependencies": { diff --git a/scripts/install-monaco-editor b/scripts/install-monaco-editor new file mode 100755 index 00000000..7cee5a35 --- /dev/null +++ b/scripts/install-monaco-editor @@ -0,0 +1,35 @@ +#!/bin/bash +set -e + +monacoRef=$(cat package.json | jq -r '.config.monaco.ref') + +package_json="`pwd`/package.json" +output_directory="`pwd`/monaco-editor" +version_info=$output_directory/version.info + +if [[ -e $version_info && $(cat $version_info) == $monacoRef ]]; then + echo "monaco-editor version $monacoRef is already installed. Aborting..." + exit 0 +else + echo "monaco-editor version $monacoRef is not available. Installing..." +fi + +monaco_build_directory=`mktemp -d` +echo "Downloading monaco-editor languages $monacoRef in $monaco_build_directory..." +rm -rf $output_directory +mkdir -p $output_directory +curl -L --max-redirs 5 https://github.com/Microsoft/monaco-editor/tarball/$monacoRef | tar -xz -C $monaco_build_directory --strip-components=1 +monacoVersion=$(cat "$monaco_build_directory/package.json" | jq -r '.["version"]') +cat <<< "$(jq ".config.monaco.version = \"$monacoVersion\"" $package_json)" > $package_json + +cd $monaco_build_directory +npm ci + +# Copy editor types +npm run build-monaco-editor +cp out/monaco-editor/esm/vs/editor/editor.api.d.ts $output_directory/editor.api.d.ts +cp -R out/monaco-editor/esm/vs/basic-languages $output_directory/basic-languages +cp -R out/monaco-editor/esm/vs/language $output_directory/language + +# Cleaning +rm -rf $monaco_build_directory diff --git a/scripts/install-vscode b/scripts/install-vscode index 515d183a..c2dabad4 100755 --- a/scripts/install-vscode +++ b/scripts/install-vscode @@ -105,23 +105,4 @@ rm -rf $loc_output_directory mkdir -p $loc_output_directory curl -L --max-redirs 5 https://github.com/microsoft/vscode-loc/archive/refs/heads/main.tar.gz | tar -xz -C $loc_output_directory --strip-components=2 vscode-loc-main/i18n -monaco_build_directory=`mktemp -d` -echo "Downloading monaco-editor languages $monacoRef in $monaco_build_directory..." -rm -rf $monaco_editor_output_directory -mkdir -p $monaco_editor_output_directory -curl -L --max-redirs 5 https://github.com/Microsoft/monaco-editor/tarball/$monacoRef | tar -xz -C $monaco_build_directory --strip-components=1 -monacoVersion=$(cat "$monaco_build_directory/package.json" | jq -r '.["version"]') -cat <<< "$(jq ".config.monaco.version = \"$monacoVersion\"" $package_json)" > $package_json - -cd $monaco_build_directory -npm ci - -# Copy editor types -npm run build-monaco-editor -cp out/monaco-editor/esm/vs/editor/editor.api.d.ts $monaco_editor_output_directory/editor.api.d.ts -cp -R out/monaco-editor/esm/vs/basic-languages $monaco_editor_output_directory/basic-languages -cp -R out/monaco-editor/esm/vs/language $monaco_editor_output_directory/language - -# Cleaning -rm -rf $monaco_build_directory rm -rf $build_directory