-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-examples-library
executable file
·63 lines (52 loc) · 1.67 KB
/
create-examples-library
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/zsh
#
# Script to make a library of models to be served.
#
# The script will:
#
# 1. Search for `*.poieticframe` source files in `FRAMES_PATH` (default: `../PoieticExamples`)
# 2. Creates a design file for each frame.
# 3. Creates a library `poietic-library.json` in current directory.
#
# Requires: poietic tool from PoieticFlows to be available in PATH.
#
# Usage:
#
# ./create-examples-library
#
# With explicit path:
#
# ./create-examples-library [FRAMES_PATH]
#
set -e
# -----------------------------------------------------------------------------------
# Some internal config, you might skip this to the next section ...
# Path to the poietic tool.
#
POIETIC="${POIETIC:-poietic}"
# Path to the output directory, default ./out
OUTPUT_DIR="${OUTPUT:-./ModelLibrary}"
FRAMES_PATH="${1:-../PoieticExamples}"
if ! command -v ${POIETIC} &> /dev/null
then
echo "ERROR: Command 'poietic' not found." 1>&2
echo "HINT: Follow the installation instructions in the PoieticTool package" 1>&2
echo "HINT: Get the tool at https://github.com/OpenPoiesis/poietic-tool" 1>&2
echo "HINT: Make sure you have '~/.swiftpm/bin' in your PATH." 1>&2
exit 1
fi
echo "Creating ${OUTPUT_DIR}"
mkdir -p "${OUTPUT_DIR}"
all_frames=($(find $FRAMES_PATH -name '*.poieticframe' ))
for frame_path in ${all_frames[*]}; do
frame_name=$(basename -- $frame_path)
frame_name=${frame_name%.*}
export POIETIC_DESIGN="$OUTPUT_DIR/${frame_name}.poietic"
echo "Processing frame ${frame_name}"
$POIETIC new --import $frame_path $POIETIC_DESIGN
$POIETIC edit auto-parameters
done
# FINALLY: Create the library!
#
echo "Creating library..."
poietic create-library $OUTPUT_DIR/*.poietic