From ef79eab44bfd000792c610b968b5ceefd41e76a0 Mon Sep 17 00:00:00 2001 From: Darius Jahandarie Date: Sat, 4 Nov 2023 18:45:57 +0900 Subject: Modernize codebase - Use ES modules - Remove vendored libs and build them from npm using esbuild - Switch from JSZip to zip.js --- .../scripts/check_for_upstream_updates.sh | 45 +++++++++++++++ dev/lib/handlebars/scripts/print_ast.js | 64 ++++++++++++++++++++++ .../handlebars/scripts/update_upstream_git_hash.sh | 24 ++++++++ 3 files changed, 133 insertions(+) create mode 100755 dev/lib/handlebars/scripts/check_for_upstream_updates.sh create mode 100755 dev/lib/handlebars/scripts/print_ast.js create mode 100755 dev/lib/handlebars/scripts/update_upstream_git_hash.sh (limited to 'dev/lib/handlebars/scripts') diff --git a/dev/lib/handlebars/scripts/check_for_upstream_updates.sh b/dev/lib/handlebars/scripts/check_for_upstream_updates.sh new file mode 100755 index 00000000..73f7376a --- /dev/null +++ b/dev/lib/handlebars/scripts/check_for_upstream_updates.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +set -e + +TMP=.tmp-handlebars +HASH_FILE=packages/kbn-handlebars/src/spec/.upstream_git_hash + +function cleanup { + rm -fr $TMP +} + +trap cleanup EXIT + +rm -fr $TMP +mkdir $TMP + +echo "Cloning handlebars repo..." +git clone -q --depth 1 https://github.com/handlebars-lang/handlebars.js.git -b 4.x $TMP + +echo "Looking for updates..." +hash=$(git -C $TMP rev-parse HEAD) +expected_hash=$(cat $HASH_FILE) + +if [ "$hash" = "$expected_hash" ]; then + echo "You're all up to date :)" +else + echo + echo "New changes has been committed to the '4.x' branch in the upstream git repository" + echo + echo "To resolve this issue, do the following:" + echo + echo " 1. Investigate the commits in the '4.x' branch of the upstream git repository." + echo " If files inside the 'spec' folder has been updated, sync those updates with" + echo " our local versions of these files (located in" + echo " 'packages/kbn-handlebars/src/spec')." + echo + echo " https://github.com/handlebars-lang/handlebars.js/compare/$hash...4.x" + echo + echo " 2. Execute the following script and commit the updated '$HASH_FILE'" + echo " file including any changes you made to our own spec files." + echo + echo " ./packages/kbn-handlebars/scripts/update_upstream_git_hash.sh" + echo + exit 1 +fi diff --git a/dev/lib/handlebars/scripts/print_ast.js b/dev/lib/handlebars/scripts/print_ast.js new file mode 100755 index 00000000..b97fb5a6 --- /dev/null +++ b/dev/lib/handlebars/scripts/print_ast.js @@ -0,0 +1,64 @@ +#!/usr/bin/env node +/* + * Elasticsearch B.V licenses this file to you under the MIT License. + * See `packages/kbn-handlebars/LICENSE` for more information. + */ +'use strict'; // eslint-disable-line strict + +const { relative } = require('path'); +const { inspect } = require('util'); + +const { parse } = require('handlebars'); +const argv = require('minimist')(process.argv.slice(2)); + +const DEFAULT_FILTER = 'loc,strip,openStrip,inverseStrip,closeStrip'; + +const filter = argv['show-all'] ? [''] : (argv.filter || DEFAULT_FILTER).split(','); +const hideEmpty = argv['hide-empty'] || false; +const template = argv._[0]; + +if (template === undefined) { + const script = relative(process.cwd(), process.argv[1]); + console.log(`Usage: ${script} [options]