Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.git
.github
node_modules
npm-debug.log
yarn-error.log
.env
coverage
8 changes: 4 additions & 4 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '10'
node-version: '24'
cache: 'yarn'
- run: yarn install
- run: yarn test
Expand All @@ -20,7 +20,7 @@ jobs:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v10
v24
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
language: node_js
node_js:
- '10'
- '24'
notifications:
email: false
webhooks: https://huemul.devschile.cl/travis-ci/huemul-devs
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ En la medida que sea posible todo script _complejo_ que se quiera agregar deber

* Fork a tu cuenta de GitHub y clone este repo en tu local.
* `$ cd ruta/a/huemul`
* Usa Node.js 24 (`$ nvm use` lee automáticamente `.nvmrc`).
* `$ npm install` o `$ yarn` (probablemente sea mejor usar `sudo` a menos que uses nodenv o nvm).
* Si estás usando la carpeta de scripts deja tu código en `huemul/scripts`, sino:

Expand Down
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:24-bookworm-slim

WORKDIR /app

# Git is required for git-based npm dependencies.
RUN apt-get update && apt-get install -y --no-install-recommends git \
&& rm -rf /var/lib/apt/lists/*

COPY package.json yarn.lock ./

RUN corepack enable && yarn install --production

COPY . .

ENV NODE_ENV=production
ENV PORT=8080

EXPOSE 8080

CMD ["bin/hubot", "-a", "slack"]
6 changes: 6 additions & 0 deletions bin/hubot
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ set -e

export PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH"

COMPAT_SHIM="$(cd "$(dirname "$0")/.." && pwd)/scripts/node24-http-headers-compat.js"

if [ -f "$COMPAT_SHIM" ]; then
export NODE_OPTIONS="--require=$COMPAT_SHIM ${NODE_OPTIONS:-}"
fi

exec node_modules/.bin/hubot --name "huemul" "$@"
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"homepage": "https://github.com/devschile/huemul#readme",
"dependencies": {
"@sentry/node": "^10.18.0",
"@slack/web-api": "^5.10.0",
"atob": "^2.1.2",
"bip": "3.0.2",
Expand Down Expand Up @@ -97,24 +98,22 @@
"numbertoclpformater": "1.0.0",
"openai": "^3.2.1",
"password-generator": "2.2.0",
"phantom": "4.0.12",
"pug": "3.0.1",
"raven": "2.6.2",
"rutjs": "0.1.1",
"slack-block-kit": "^0.9.9",
"string": "3.3.3",
"superheroes": "1.0.0",
"tax-cl": "^0.0.1",
"twitter-rss-feed": "1.4.0",
"uuid": "3.2.1",
"uuid": "^9.0.1",
"whilst": "1.0.2",
"yelp": "1.0.2"
},
"devDependencies": {
"@sinonjs/fake-timers": "^9.1.2",
"@types/nock": "^11.1.0",
"ava": "0.25.0",
"coffee-script": "1.12.7",
"ava": "^4.3.3",
"coffeescript": "^2.7.0",
"eslint": "6.5.1",
"eslint-config-standard": "14.1.0",
"eslint-plugin-import": "2.18.2",
Expand All @@ -124,14 +123,14 @@
"hubot-test-helper": "1.9.0",
"husky": "0.14.3",
"lint-staged": "9.4.2",
"nock": "9.2.6",
"nock": "^13.5.6",
"prettier": "1.12.1",
"sinon": "^14.0.0"
},
"resolutions": {
"mongodb": "3.2.2"
},
"engines": {
"node": "~10.0.0"
"node": ">=24 <25"
}
}
2 changes: 1 addition & 1 deletion scripts/agencias.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

const express = require('express')
const path = require('path')
const uuidV4 = require('uuid/v4')
const { v4: uuidV4 } = require('uuid')
const querystring = require('querystring')

const images = [
Expand Down
49 changes: 28 additions & 21 deletions scripts/error-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Send errors to sentry.io
//
// Dependencies:
// raven
// @sentry/node
//
// Configuration:
// SENTRY_DSN, SENTRY_ENVIRONMENT, SENTRY_NAME, SENTRY_CHANNEL
Expand All @@ -13,40 +13,47 @@
// Author:
// @lgaticaq

const Raven = require('raven')
const Sentry = require('@sentry/node')

module.exports = robot => {
if (!process.env.SENTRY_DSN) {
const sentryDsn = process.env.SENTRY_DSN
if (!sentryDsn) {
robot.logger.warning('The SENTRY_DSN environment variable not set. Sentry not configured.')
} else {
Sentry.init({
dsn: sentryDsn,
environment: process.env.SENTRY_ENVIRONMENT,
serverName: process.env.SENTRY_NAME
})
}

Raven.config().install()

robot.error((err, res, scriptName = null) => {
const prefix = scriptName ? `<${scriptName}>: ` : ''
robot.logger.error(err)
if (typeof res !== 'undefined' && res !== null) {
if (['SlackBot', 'Room'].includes(robot.adapter.constructor.name) && res.message) {
const context = {
user: {
const room = process.env.SENTRY_CHANNEL || '#huemul-devs'
const fileName = err && err.stack ? err.stack.split(' at')[1] || 'unknown' : 'unknown'

robot.send({ room: room }, `
script name: ${fileName}
${prefix}An error has occurred: \`${err.message}\`
`)

if (!sentryDsn) return

Sentry.withScope(scope => {
if (typeof res !== 'undefined' && res !== null) {
if (['SlackBot', 'Room'].includes(robot.adapter.constructor.name) && res.message) {
scope.setUser({
id: res.message.user.id,
username: res.message.user.name,
email: res.message.user.email
},
script: null
})
}
if (scriptName) context.script = scriptName
Raven.setContext(context)
}
}
const room = process.env.SENTRY_CHANNEL || '#huemul-devs'

const fileName = err.stack.split(' at')[1]
if (scriptName) scope.setTag('script', scriptName)

robot.send({ room: room }, `
script name: ${fileName}
${prefix}An error has occurred: \`${err.message}\`
`)
Raven.captureException(err)
Sentry.captureException(err)
})
})
}
Loading