diff --git a/ci/build.sh b/ci/build.sh index ccfaebda1..32ce0d650 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -15,4 +15,6 @@ if [ -z $STACKS_LIST ]; then . $base_dir/ci/list.sh $base_dir fi . $base_dir/ci/package.sh $base_dir -. $base_dir/ci/test.sh $base_dir \ No newline at end of file +. $base_dir/ci/test.sh $base_dir + +python $base_dir/ci/create_codewind_index.py $base_dir \ No newline at end of file diff --git a/ci/create_codewind_index.py b/ci/create_codewind_index.py new file mode 100755 index 000000000..a04be1751 --- /dev/null +++ b/ci/create_codewind_index.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +import yaml +import json +import os +import fnmatch +import sys +from collections import OrderedDict + +base_dir = os.path.abspath(os.path.dirname(sys.argv[0])) + +# directory to store assets for test or release +assets_dir = base_dir + "/assets/" + +for file in os.listdir(assets_dir): + if fnmatch.fnmatch(file, '*index.yaml'): + with open(assets_dir + file, 'r') as yamlFile, open(assets_dir + os.path.splitext(file)[0] + ".json", 'w') as jsonFile: + try: + doc = yaml.safe_load(yamlFile) + list = [] + + if (doc['stacks'] != None): + for item in doc['stacks']: + + # get template name + for n in range(0, len(item['templates'])): + if len(item['templates'])==1: + template = "" + else: + template = " " + item['templates'][n]['id'] + + # populate stack details + res = (OrderedDict([ + ("displayName", "Appsody " + item['name'] + template + " template"), + ("description", item['description']), + ("language", ""), + ("projectType", "appsodyExtension"), + ("projectStyle", "Appsody"), + ("location", item['templates'][n]['url']), + ("links", OrderedDict([ + ("self", "/devfiles/" + + item['id'] + "/devfile.yaml") + ])) + ])) + list.append(res) + + jsonFile.write(json.dumps(list, indent=4, ensure_ascii=False).encode('utf8')) + print("Generated: " + os.path.splitext(file)[0] + ".json") + + except yaml.YAMLError as exc: + print(exc) \ No newline at end of file