Skip to content

Commit

Permalink
chore: improve logging when generating a Hubot
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyguerra committed Nov 12, 2023
1 parent f902983 commit 3ffd13f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
14 changes: 6 additions & 8 deletions bin/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,20 @@ trap "{ CODE=$?; popd; rm -rf $TEMP_ROOT; exit $CODE; }" EXIT
## https://github.com/hubotio/hubot/blob/main/docs/index.md

## use this hubot version
echo "$ create hubot in $TEMP_ROOT"
echo "$ install Hubot from $HUBOT_FOLDER"
echo "Creating hubot in $TEMP_ROOT"
echo " and installing Hubot from $HUBOT_FOLDER"
npm init -y
npm i $HUBOT_FOLDER

./node_modules/.bin/hubot --create myhubot
cd myhubot
export HUBOT_INSTALLATION_PATH=$HUBOT_FOLDER
./node_modules/.bin/hubot --create .

# npm install /path/to/hubot will create a symlink in npm 5+ (http://blog.npmjs.org/post/161081169345/v500).
# As the require calls for app-specific scripts happen inside hubot, we have to
# set NODE_PATH to the app’s node_modules path so they can be found
echo "$ Update NODE_PATH=$TEMP_ROOT/node_modules so everything can be found correctly."
export NODE_PATH=$TEMP_ROOT/node_modules:$TEMP_ROOT/myhubot/node_modules
export PATH=$PATH:$TEMP_ROOT/node_modules/.bin:$TEMP_ROOT/myhubot/node_modules/.bin
export HUBOT_INSTALLATION_PATH=$HUBOT_FOLDER
echo $HUBOT_INSTALLATION_PATH
export NODE_PATH=$TEMP_ROOT/node_modules
export PATH=$PATH:$TEMP_ROOT/node_modules/.bin

## start, but have to sleep 1 second to wait for hubot to start and the scripts to load
expect <<EOL
Expand Down
7 changes: 5 additions & 2 deletions src/GenHubot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ function runCommands (hubotDirectory, options) {
const envFilePath = path.resolve(process.cwd(), '.env')
process.chdir(hubotDirectory)

spawnSync('npm', ['init', '-y'])
spawnSync('npm', ['i', options.hubotInstallationPath].concat(options.adapter, 'hubot-help', 'hubot-rules', 'hubot-diagnostics'))
let output = spawnSync('npm', ['init', '-y'])
console.log('npm init', output.stderr.toString(), output.stdout.toString())
output = spawnSync('npm', ['i', 'hubot-help@latest', 'hubot-rules@latest', 'hubot-diagnostics@latest'].concat([options.hubotInstallationPath, options.adapter]).filter(Boolean))
console.log('npm i', output.stderr.toString(), output.stdout.toString())
spawnSync('mkdir', ['scripts'])
spawnSync('touch', ['external-scripts.json'])

Expand Down Expand Up @@ -50,6 +52,7 @@ export default (robot) => {
packageJson.scripts = {
start: 'hubot'
}
packageJson.description = 'A simple helpful robot for your Company'
if (options.adapter) {
packageJson.scripts.start += ` --adapter ${options.adapter}`
}
Expand Down

0 comments on commit 3ffd13f

Please sign in to comment.