Skip to content

Commit

Permalink
Merge pull request #176 from stephenyeargin/feature/small-refactorings
Browse files Browse the repository at this point in the history
Feature/small refactoring
  • Loading branch information
KeesCBakker committed Apr 23, 2024
2 parents 6d23db9 + 53b6f7e commit ad009c8
Show file tree
Hide file tree
Showing 12 changed files with 1,012 additions and 21 deletions.
8 changes: 8 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye

# Install the npm packages globally
RUN npm install -g npm \
&& npm install -g npm-check-updates

COPY ./startup.sh /
RUN chmod +x /startup.sh
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Node.js & TypeScript",
"dockerFile": "Dockerfile",
"postStartCommand": "/startup.sh",
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
"remoteUser": "node",
"mounts": [
"source=${localWorkspaceFolderBasename}-node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume"
],
"postCreateCommand": "sudo chown node node_modules"
}
11 changes: 11 additions & 0 deletions .devcontainer/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

# trust the repo
# fixes:
# - fatal: detected dubious ownership in repository at '/workspaces/bot-zero'.
git config --global --add safe.directory "$PWD"

# install NPM packages
echo ""
echo "Installing packages..."
npm install --no-audit --no-fund
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
7 changes: 4 additions & 3 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -24,13 +24,14 @@ jobs:

- name: npm install, build
run: |
npm ci
npm run bootstrap
npm run build --if-present
env:
CI: true

- name: npm test
run: |
npm test
npm run bootstrap
npm test -- --forbid-only --forbid-pending
env:
CI: true
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hubot-grafana",
"description": "Query Grafana dashboards",
"version": "5.1.1",
"version": "5.1.2",
"author": "Stephen Yeargin <[email protected]>",
"license": "MIT",
"keywords": [
Expand Down Expand Up @@ -39,8 +39,9 @@
},
"main": "index.js",
"scripts": {
"test": "script/test",
"test-with-coverage": "nyc --reporter=text ./script/test",
"test": "mocha \"test/**/*.js\" --reporter spec",
"test-with-coverage": "nyc --reporter=text mocha \"test/**/*.js\" --reporter spec",
"bootstrap": "script/bootstrap",
"prepare": "husky install",
"lint": "eslint src/ test/"
},
Expand Down
2 changes: 1 addition & 1 deletion script/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ if [ -f .env.${NODE_ENV} ]; then
source .env.${NODE_ENV}
fi

npm install
npm ci
6 changes: 0 additions & 6 deletions script/test

This file was deleted.

4 changes: 2 additions & 2 deletions src/grafana.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ module.exports = (robot) => {
let apiPanelId = false;
let pname = false;
const query = {
width: process.env.HUBOT_GRAFANA_DEFAULT_WIDTH || 1000,
height: process.env.HUBOT_GRAFANA_DEFAULT_HEIGHT || 500,
width: parseInt(process.env.HUBOT_GRAFANA_DEFAULT_WIDTH, 10) || 1000,
height: parseInt(process.env.HUBOT_GRAFANA_DEFAULT_HEIGHT, 10) || 500,
tz: process.env.HUBOT_GRAFANA_DEFAULT_TIME_ZONE || '',
orgId: process.env.HUBOT_GRAFANA_ORG_ID || '',
apiEndpoint: process.env.HUBOT_GRAFANA_API_ENDPOINT || 'd-solo',
Expand Down
Loading

0 comments on commit ad009c8

Please sign in to comment.