|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 3 | +# or more contributor license agreements. See the NOTICE file |
| 4 | +# distributed with this work for additional information |
| 5 | +# regarding copyright ownership. The ASF licenses this file |
| 6 | +# to you under the Apache License, Version 2.0 (the |
| 7 | +# "License"); you may not use this file except in compliance |
| 8 | +# with the License. You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, |
| 13 | +# software distributed under the License is distributed on an |
| 14 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | +# KIND, either express or implied. See the License for the |
| 16 | +# specific language governing permissions and limitations |
| 17 | +# under the License. |
| 18 | + |
| 19 | +DIR=$(dirname $0) |
| 20 | +configFile="$DIR/public/config.json" |
| 21 | +tmpFile="$DIR/public/config.json.tmp" |
| 22 | +echo "Pre-build: list all docHelp suffixes in ${configFile}" |
| 23 | +for m in $(grep "docHelp: '" -R ./src | sed "s/^.*: '//g" | sed "s/',//g" | sort | uniq); do |
| 24 | + docHelpMappings+="${m}," |
| 25 | +done; |
| 26 | + |
| 27 | +node > ${tmpFile} <<EOF |
| 28 | +// Read config |
| 29 | +var data = require('${configFile}'); |
| 30 | +
|
| 31 | +// Add docHelpMappings |
| 32 | +var suffixes = '${docHelpMappings}'; |
| 33 | +suffixes = suffixes.split(','); |
| 34 | +var mappings = {} |
| 35 | +for (const suffix of suffixes) { |
| 36 | + if (suffix) { |
| 37 | + mappings[suffix] = suffix; |
| 38 | + } |
| 39 | +} |
| 40 | +data.docHelpMappings = mappings; |
| 41 | +
|
| 42 | +// Output config |
| 43 | +console.log(JSON.stringify(data, null, 2)); |
| 44 | +
|
| 45 | +EOF |
| 46 | + |
| 47 | +mv ${tmpFile} ${configFile} |
0 commit comments