summaryrefslogtreecommitdiff
path: root/dev/lib/handlebars/scripts
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-02-05 06:11:08 -0500
committerGitHub <noreply@github.com>2024-02-05 11:11:08 +0000
commit71c3aff53173cc83a96d7d2715b7918bdbc2d8a5 (patch)
treed13cc4a90ef26bb6476daca1edc1999208f4fadc /dev/lib/handlebars/scripts
parent0e7531bc5b443461d7e76e20877464ccf48a3ef5 (diff)
kbn-handlebars dependency update (#613)
* Update kbn-handlebars dependency * Move handlebars dependency to dev * Update package * Update readme * Update readme * Ignore legal file
Diffstat (limited to 'dev/lib/handlebars/scripts')
-rwxr-xr-xdev/lib/handlebars/scripts/check_for_upstream_updates.sh45
-rwxr-xr-xdev/lib/handlebars/scripts/print_ast.js64
-rwxr-xr-xdev/lib/handlebars/scripts/update_upstream_git_hash.sh24
3 files changed, 0 insertions, 133 deletions
diff --git a/dev/lib/handlebars/scripts/check_for_upstream_updates.sh b/dev/lib/handlebars/scripts/check_for_upstream_updates.sh
deleted file mode 100755
index 73f7376a..00000000
--- a/dev/lib/handlebars/scripts/check_for_upstream_updates.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/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
deleted file mode 100755
index b97fb5a6..00000000
--- a/dev/lib/handlebars/scripts/print_ast.js
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/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] <template>`);
- console.log();
- console.log('Options:');
- console.log(' --filter=... A comma separated list of keys to filter from the output.');
- console.log(` Default: ${DEFAULT_FILTER}`);
- console.log(' --hide-empty Do not display empty properties.');
- console.log(' --show-all Do not filter out any properties. Equivalent to --filter="".');
- console.log();
- console.log('Example:');
- console.log(` ${script} --hide-empty -- 'hello {{name}}'`);
- console.log();
- process.exit(1);
-}
-
-console.log(inspect(reduce(parse(template, filter)), { colors: true, depth: null }));
-
-function reduce(ast) {
- if (Array.isArray(ast)) {
- for (let i = 0; i < ast.length; i++) {
- ast[i] = reduce(ast[i]);
- }
- } else {
- for (const k of filter) {
- delete ast[k];
- }
-
- if (hideEmpty) {
- for (const [k, v] of Object.entries(ast)) {
- if (v === undefined || v === null || (Array.isArray(v) && v.length === 0)) {
- delete ast[k];
- }
- }
- }
-
- for (const [k, v] of Object.entries(ast)) {
- if (typeof v === 'object' && v !== null) {
- ast[k] = reduce(v);
- }
- }
- }
-
- return ast;
-}
diff --git a/dev/lib/handlebars/scripts/update_upstream_git_hash.sh b/dev/lib/handlebars/scripts/update_upstream_git_hash.sh
deleted file mode 100755
index 52cc39e0..00000000
--- a/dev/lib/handlebars/scripts/update_upstream_git_hash.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/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 "Updating hash file..."
-git -C $TMP rev-parse HEAD | tr -d '\n' > $HASH_FILE
-git add $HASH_FILE
-
-echo "Done! - Don't forget to commit any changes to $HASH_FILE"