22
33set -e
44
5- executeYeomanCommand () {
5+ executeOclifCommand () {
66 command_with_params=$1
77
8- # cleanup yeoman files after execution
9- # shellcheck disable=SC2064
10- trap " rm -rf \" $yeoman_target_dir /.cache\" \" $yeoman_target_dir /.config\" \" $yeoman_target_dir /.npm\" " EXIT
8+ ls -la /fablo/
9+ ls -la /fablo/bin/
1110
1211 if [ " $( id -u) " = 0 ]; then
13- # root user detected, running as yeoman user
14- sudo chown -R yeoman:yeoman " $yeoman_target_dir "
12+ # root user detected, running as yeoman user (keeping for compatibility)
13+ sudo chown -R yeoman:yeoman " $target_dir "
1514 # shellcheck disable=SC2086
16- (cd " $yeoman_target_dir " && sudo -E -u yeoman yo --no-insight $command_with_params )
17- sudo chown -R root:root " $yeoman_target_dir "
15+ (cd " $target_dir " && sudo -E -u yeoman node /fablo/bin/run.mjs $command_with_params )
16+ sudo chown -R root:root " $target_dir "
1817 else
1918 # shellcheck disable=SC2086
20- (cd " $yeoman_target_dir " && yo --no-insight $command_with_params )
19+ (cd " $target_dir " && node /fablo/bin/run.mjs $command_with_params )
2120 fi
2221}
2322
2423formatGeneratedFiles () {
2524 # Additional script and yaml formatting
2625 #
27- # Why? Yeoman output may contain some additional whitespaces or the formatting
26+ # Why? Generated output may contain some additional whitespaces or the formatting
2827 # might not be ideal. Keeping those whitespaces, however, might be useful
2928 # in templates to improve the brevity. That's why we need additional formatting.
3029 # Since the templates should obey good practices, we don't use linters here
3130 # (i.e. shellcheck and yamllint).
3231 echo " Formatting generated files"
33- shfmt -i=2 -l -w " $yeoman_target_dir " > /dev/null
32+ shfmt -i=2 -l -w " $target_dir " > /dev/null
3433
35- for yaml in " $yeoman_target_dir " /** /* .yaml; do
34+ for yaml in " $target_dir " /** /* .yaml; do
3635
3736 # the expansion failed, no yaml files found
38- if [ " $yaml " = " $yeoman_target_dir /**/*.yaml" ]; then
37+ if [ " $yaml " = " $target_dir /**/*.yaml" ]; then
3938 break
4039 fi
4140
@@ -48,16 +47,19 @@ formatGeneratedFiles() {
4847 done
4948}
5049
51- yeoman_target_dir =" /network/workspace"
52- yeoman_command =${1:- Fablo : setup-network}
50+ target_dir =" /network/workspace"
51+ oclif_command =${1:- setup-network}
5352
54- # This part of output will be replaces with empty line. It breaks parsing of yeoman generator output.
55- # See also: https://github.com/yeoman/generator/issues/1294
56- annoying_yeoman_info=" No change to package.json was detected. No package manager install will be executed."
53+ # Map old yeoman command format to oclif format
54+ case " $oclif_command " in
55+ " Fablo:setup-network" |" fablo:setup-network" )
56+ oclif_command=" setup-network"
57+ ;;
58+ esac
5759
5860# Execute the command
59- executeYeomanCommand " $yeoman_command " 2>&1 | sed " s/ $annoying_yeoman_info //g "
61+ executeOclifCommand " $oclif_command "
6062
61- if echo " $yeoman_command " | grep " setup-network" ; then
63+ if echo " $oclif_command " | grep -q " setup-network" ; then
6264 formatGeneratedFiles
6365fi
0 commit comments