From d7a959f45f45ac0337e164328a8031be2c006358 Mon Sep 17 00:00:00 2001 From: Edward Medvedev Date: Mon, 23 Oct 2017 19:05:18 +0300 Subject: [PATCH] Change the env vars and deployment paths --- .eslintrc.js | 2 +- Dockerfile | 7 +------ Procfile | 2 +- app.json | 38 +++++++++++++++++++++++++++++--------- app.yaml | 2 +- azuredeploy.json | 4 ++-- lib/index.js | 5 +++-- package.json | 4 +--- readme.md | 12 ++++++------ scripts/azuredeploy.sh | 14 +++++++------- 10 files changed, 52 insertions(+), 38 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 923c92be..117c995f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,3 +1,3 @@ module.exports = { "extends": "airbnb-base" -}; \ No newline at end of file +} diff --git a/Dockerfile b/Dockerfile index 1430b73b..a09fdf2e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,6 @@ FROM node:alpine - ADD . /srv/www - WORKDIR /srv/www - RUN npm install --unsafe-perm -EXPOSE 8080 - -CMD ./bin/slackin --coc "$SLACK_COC" --channels "$SLACK_CHANNELS" --port $APP_PORT $SLACK_SUBDOMAIN $SLACK_API_TOKEN $GOOGLE_CAPTCHA_SECRET $GOOGLE_CAPTCHA_SITEKEY +CMD ./bin/slackin --coc "$SLACKIN_COC" --channels "$SLACKIN_CHANNELS" $SLACK_SUBDOMAIN $SLACK_API_TOKEN diff --git a/Procfile b/Procfile index 618b7fb5..466875ab 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: bin/slackin --coc "$SLACK_COC" --channels "$SLACK_CHANNELS" --port $PORT $SLACK_SUBDOMAIN $SLACK_API_TOKEN $GOOGLE_CAPTCHA_SECRET $GOOGLE_CAPTCHA_SITEKEY +web: bin/slackin --coc "$SLACKIN_COC" --channels "$SLACKIN_CHANNELS" $SLACK_SUBDOMAIN $SLACK_API_TOKEN diff --git a/app.json b/app.json index 4059674d..7ab3b2c7 100644 --- a/app.json +++ b/app.json @@ -1,8 +1,8 @@ { - "name": "Slackin", + "name": "slackin-extended", "description": "Let people invite themselves to your Slack", "logo": "https://i.imgur.com/odDO1Fx.png", - "repository": "https://github.com/rauchg/slackin", + "repository": "https://github.com/emedvedev/slackin-extended", "keywords": ["node", "slack"], "env": { "SLACK_SUBDOMAIN": { @@ -13,21 +13,41 @@ "description": "A Slack API token (find it on https://api.slack.com/web)", "required": true }, - "GOOGLE_CAPTCHA_SECRET": { + "RECAPTCHA_SECRET": { "description": "Google captcha secret key", - "required": true + "required": false }, - "GOOGLE_CAPTCHA_SITEKEY": { + "RECAPTCHA_SITEKEY": { "description": "Google captcha site key", - "required": true + "required": false }, - "SLACK_COC": { + "RECAPTCHA_INVISIBLE": { + "description": "Use invisible reCAPTCHA instead of reCAPTCHA v2", + "required": false + }, + "SLACKIN_COC": { "description": "A URL to a Code of Conduct people must agree on before joining.", "required": false }, - "SLACK_CHANNELS": { + "SLACKIN_CHANNELS": { "description": "Comma-separated list of single guest channels to invite them to (leave blank for a normal, all-channel invite). In order to make this work, you have to have a paid account. You'll only be able to invite as many people as your number of paying members times 5.", "required": false - } + }, + "SLACKIN_INTERVAL": { + "description": "How frequently (ms) to poll Slack", + "required": false + }, + "SLACKIN_ANALYTICS": { + "description": "Google Analytics ID", + "required": false + }, + "SLACKIN_THEME": { + "description": "Color scheme to use, \"light\" (default) or \"dark\"", + "required": false + }, + "SLACKIN_ACCENT": { + "description": "Accent color to use instead of a theme default", + "required": false + }, } } diff --git a/app.yaml b/app.yaml index 1982d0ce..fb3e011a 100644 --- a/app.yaml +++ b/app.yaml @@ -2,7 +2,7 @@ env: flex runtime: custom env_variables: FQDN: "your.slackin.subdomain.com" - APP_PORT: "8080" + SLACKIN_PORT: "8080" SLACK_INTERVAL: "25000" SLACK_SUBDOMAIN: "your-slack-workspace" SLACK_API_TOKEN: "your-slack-api-token" diff --git a/azuredeploy.json b/azuredeploy.json index 8e955658..e4dadf8f 100644 --- a/azuredeploy.json +++ b/azuredeploy.json @@ -99,8 +99,8 @@ "SLACK_SUBDOMAIN": "[parameters('slackTeamId')]", "SLACK_API_TOKEN": "[parameters('slackApiToken')]", "SLACKIN_RELEASE": "[parameters('slackinRelease')]", - "WEBSITE_NPM_DEFAULT_VERSION": "3.3.12", - "WEBSITE_NODE_DEFAULT_VERSION": "5.1.1", + "WEBSITE_NPM_DEFAULT_VERSION": "5.4.2", + "WEBSITE_NODE_DEFAULT_VERSION": "8.7.0", "command": "bash scripts/azuredeploy.sh" } }, diff --git a/lib/index.js b/lib/index.js index 465da170..402879ba 100644 --- a/lib/index.js +++ b/lib/index.js @@ -29,6 +29,7 @@ export default function slackin({ path = '/', recaptcha, silent, + analytics, ...params }) { // must haves @@ -122,7 +123,7 @@ export default function slackin({ return res .type('html') .render('main', { - coc, path, name, org, logo, channels, active, total, recaptcha, css, theme, + coc, path, name, org, logo, channels, active, total, recaptcha, css, theme, analytics, }); }); @@ -208,7 +209,7 @@ export default function slackin({ } res.type('html'); res.render('main', { - coc, path, name, org, channels, active, total, large, recaptcha, theme, iframe: true, + coc, path, name, org, channels, active, total, large, recaptcha, theme, analytics, iframe: true, }); }); diff --git a/package.json b/package.json index f30f6776..9f21cb98 100644 --- a/package.json +++ b/package.json @@ -79,9 +79,7 @@ ], "env": [ "SLACK_API_TOKEN", - "SLACK_SUBDOMAIN", - "GOOGLE_CAPTCHA_SECRET", - "GOOGLE_CAPTCHA_SITEKEY" + "SLACK_SUBDOMAIN" ] } } diff --git a/readme.md b/readme.md index 8e0b0753..aef8db03 100644 --- a/readme.md +++ b/readme.md @@ -14,15 +14,15 @@ Check out the [Demo](https://slackin.now.sh/) or read more about the [motivation Set up [Now](https://zeit.co/now) on your device and run this command. [Now](https://zeit.co/now) will automatically ask you for the required information and then spin up a deployment instantly. That easy! ```bash -now rauchg/slackin +now emedvedev/slackin-extended ``` Other platforms: -- [Heroku](https://heroku.com/deploy?template=https://github.com/rauchg/slackin/tree/master) +- [Heroku](https://heroku.com/deploy?template=https://github.com/emedvedev/slackin-extended/tree/master) - [Azure](https://azuredeploy.net/) - [OpenShift](https://github.com/rauchg/slackin/wiki/OpenShift) -- [IBM Bluemix](https://bluemix.net/deploy?repository=https://github.com/rauchg/slackin) +- [IBM Bluemix](https://bluemix.net/deploy?repository=https://github.com/emedvedev/slackin-extended) ### Tips @@ -59,7 +59,7 @@ sitekey](https://www.google.com/recaptcha/admin) for Google reCAPTCHA. Loading `slackin` will return a `Function` that creates a `HTTP.Server` instance: ```js -const slackin = require('slackin') +const slackin = require('slackin-extended') slackin.default({ token: 'yourtoken', // required @@ -78,8 +78,8 @@ All the metadata for your organization can be fetched via a JSON HTTP request to ## Caught a Bug? 1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device -2. Uninstall slackin if it's already installed: `npm uninstall -g slack` +2. Uninstall slackin if it's already installed: `npm uninstall -g slackin-extended` 3. Link it to the global module directory: `npm link` 4. Transpile the source code and watch for changes: `npm start` -Yey! Now can use the `slack` command everywhere. +Yey! Now can use the `slackin` command everywhere. diff --git a/scripts/azuredeploy.sh b/scripts/azuredeploy.sh index bd20cddc..c07760ad 100644 --- a/scripts/azuredeploy.sh +++ b/scripts/azuredeploy.sh @@ -81,7 +81,7 @@ selectNodeVersion () { NODE_EXE=`cat "$DEPLOYMENT_TEMP/__nodeVersion.tmp"` exitWithMessageOnError "getting node version failed" fi - + if [[ -e "$DEPLOYMENT_TEMP/.tmp" ]]; then NPM_JS_PATH=`cat "$DEPLOYMENT_TEMP/__npmVersion.tmp"` exitWithMessageOnError "getting npm version failed" @@ -114,12 +114,12 @@ echo Deploying Slackin: $SLACKIN_RELEASE if [[ "$SLACKIN_RELEASE" == "stable" ]]; then # Stable - echo Installing from npm - + echo Installing from npm + cd "$DEPLOYMENT_TARGET" - + # 1. Install latest release of slackin from npm - eval $NPM_CMD install slackin + eval $NPM_CMD install slackin-extended # 2. Copy to root folder cp -rv node_modules/slackin/* . @@ -130,12 +130,12 @@ else # Latest (from git repo) echo Installing from git repo - # 1. KuduSync + # 1. KuduSync if [[ "$IN_PLACE_DEPLOYMENT" -ne "1" ]]; then "$KUDU_SYNC_CMD" -v 50 -f "$DEPLOYMENT_SOURCE" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.hg;.deployment;deploy.sh" exitWithMessageOnError "Kudu Sync failed" fi - + # 2. Install npm packages if [ -e "$DEPLOYMENT_TARGET/package.json" ]; then echo npm install