diff --git a/.babelrc b/.babelrc deleted file mode 100644 index c13c5f62..00000000 --- a/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["es2015"] -} diff --git a/.bluemix/deploy.json b/.bluemix/deploy.json new file mode 100644 index 00000000..f69e1d9f --- /dev/null +++ b/.bluemix/deploy.json @@ -0,0 +1,171 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "messages": { + "$i18n": "locales.yml" + }, + "title": { + "$ref": "#/messages/deploy.title" + }, + "description": { + "$ref": "#/messages/deploy.description" + }, + "longDescription": { + "$ref": "#/messages/deploy.longDescription" + }, + "type": "object", + "properties": { + "prod-region": { + "description": "The bluemix region", + "type": "string" + }, + "prod-organization": { + "description": "The bluemix org", + "type": "string" + }, + "prod-space": { + "description": "The bluemix space", + "type": "string" + }, + "prod-app-name": { + "description": { + "$ref": "#/messages/deploy.appDescription" + }, + "type": "string", + "pattern": "\\S" + }, + "slack-teamid": { + "description": { + "$ref": "#/messages/deploy.slackTeamId" + }, + "type": "string" + }, + "slack-apitoken": { + "description": { + "$ref": "#/messages/deploy.slackApiToken" + }, + "type": "string" + }, + "captcha-secret": { + "description": { + "$ref": "#/messages/deploy.captchaSecret" + }, + "type": "string" + }, + "captcha-sitekey": { + "description": { + "$ref": "#/messages/deploy.captchaSiteKey" + }, + "type": "string" + } + + }, + "required": [ + "prod-region", + "prod-organization", + "prod-space", + "prod-app-name", + "slack-teamid", + "slack-apitoken", + "captcha-secret", + "captcha-sitekey" + ], + "form": [ + { + "type": "validator", + "url": "/devops/setup/bm-helper/helper.html" + }, + { + "type": "text", + "readonly": false, + "title": { + "$ref": "#/messages/deploy.appName" + }, + "key": "prod-app-name" + }, + { + "type": "table", + "columnCount": 4, + "widths": [ + "15%", + "28%", + "28%", + "28%" + ], + "items": [ + { + "type": "label", + "title": "" + }, + { + "type": "label", + "title": { + "$ref": "#/messages/region" + } + }, + { + "type": "label", + "title": { + "$ref": "#/messages/organization" + } + }, + { + "type": "label", + "title": { + "$ref": "#/messages/space" + } + }, + { + "type": "label", + "title": { + "$ref": "#/messages/prodStage" + } + }, + { + "type": "select", + "key": "prod-region" + }, + { + "type": "select", + "key": "prod-organization" + }, + { + "type": "select", + "key": "prod-space", + "readonly": false + } + ] + }, + { + "type": "text", + "readonly": false, + "title": { + "$ref": "#/messages/deploy.slackTeamId" + }, + "key": "slack-teamid" + }, + { + "type": "password", + "readonly": false, + "title": { + "$ref": "#/messages/deploy.slackApiToken" + }, + "key": "slack-apitoken" + }, + { + "type": "password", + "readonly": false, + "title": { + "$ref": "#/messages/deploy.captchaSecret" + }, + "key": "captcha-secret" + }, + { + "type": "password", + "readonly": false, + "title": { + "$ref": "#/messages/deploy.captchaSiteKey" + }, + "key": "captcha-sitekey" + } + ] +} diff --git a/.bluemix/icon.svg b/.bluemix/icon.svg new file mode 100644 index 00000000..6ddff828 --- /dev/null +++ b/.bluemix/icon.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + diff --git a/.bluemix/locales.yml b/.bluemix/locales.yml new file mode 100644 index 00000000..159d6992 --- /dev/null +++ b/.bluemix/locales.yml @@ -0,0 +1,29 @@ +--- +root: + $ref: ./nls/messages.yml +de: + $ref: ./nls/messages_de.yml +en-AA: + $ref: ./nls/messages_en_AA.yml +en-RR: + $ref: ./nls/messages_en_RR.yml +en-ZZ: + $ref: ./nls/messages_en_ZZ.yml +es: + $ref: ./nls/messages_es.yml +fr: + $ref: ./nls/messages_fr.yml +it: + $ref: ./nls/messages_it.yml +ja: + $ref: ./nls/messages_ja.yml +ko: + $ref: ./nls/messages_ko.yml +pt-BR: + $ref: ./nls/messages_pt_BR.yml +zh: + $ref: ./nls/messages_zh.yml +zh-HK: + $ref: ./nls/messages_zh_HK.yml +zh-TW: + $ref: ./nls/messages_zh_TW.yml diff --git a/.bluemix/nls/messages.yml b/.bluemix/nls/messages.yml new file mode 100644 index 00000000..b4623c83 --- /dev/null +++ b/.bluemix/nls/messages.yml @@ -0,0 +1,30 @@ +--- +template.name: "Deploy a Slackin server" +template.description: "With this toolchain, you can deploy a Slackin server.This toolchain is preconfigured for continuous delivery, source control, issue tracking, and online editing.\n\nThis toolchain uses tools that are part of the Continuous Delivery service. If an instance of that service isn't already in the selected organization, when you click **Create**, it is automatically added with the free [Lite](/catalog/services/continuous-delivery/) plan selected.\n\nTo get started, click **Create**.\n\nFor step-by-step instructions, follow the [tutorial](https://www.ibm.com/devops/method/tutorials/tutorial_toolchain_flow)." +template.gettingStarted: "**Your toolchain is ready!**" +deploy.title: "Sample Deploy Stage" +deploy.description: "sample toolchain" +deploy.longDescription: "The Delivery Pipeline automates continuous deployment." +deploy.appDescription: "The name of your Slackin server" +deploy.appName: "App name" +deploy.slackTeamId: "Slack Team Name" +deploy.slackApiToken: "Slack Legacy Token" +deploy.captchaSecret: "Google reCaptcha Secret" +deploy.captchaSiteKey: "Google reCaptcha Site Key" +region: "Region" +organization: "Organization" +space: "Space" +prodStage: "Production stage" +headerSVG.issueTracker: "ISSUE TRACKER" +headerSVG.gitHub1: "GitHub" +headerSVG.think: "THINK" +headerSVG.code: "CODE" +headerSVG.deliver: "DELIVER" +headerSVG.run: "RUN" +headerSVG.repository: "REPOSITORY" +headerSVG.gitHub2: "GitHub" +headerSVG.pipeline: "PIPELINE" +headerSVG.bluemix: "BLUEMIX" +headerSVG.ibmCloud: "IBM Cloud" +headerSVG.webIde: "WEB IDE" + diff --git a/.bluemix/pipeline.yml b/.bluemix/pipeline.yml new file mode 100644 index 00000000..b874453b --- /dev/null +++ b/.bluemix/pipeline.yml @@ -0,0 +1,84 @@ +--- +stages: +- name: BUILD + inputs: + - type: git + branch: master + service: ${SLACKIN_REPO} + triggers: + - type: commit + jobs: + - name: Build + type: builder +- name: DEPLOY + inputs: + - type: job + stage: BUILD + job: Build + triggers: + - type: stage + properties: + - name: CF_APP_NAME + value: undefined + type: text + - name: APP_URL + value: undefined + type: text + - name: SLACK_SUBDOMAIN + value: ${SLACK_SUBDOMAIN} + - name: SLACK_API_TOKEN + value: ${SLACK_API_TOKEN} + - name: GOOGLE_CAPTCHA_SECRET + value: ${GOOGLE_CAPTCHA_SECRET} + - name: GOOGLE_CAPTCHA_SITEKEY + value: ${GOOGLE_CAPTCHA_SITEKEY} + - name: SLACK_INTERVAL + value: '600000' + jobs: + - name: Blue-Green Deploy + type: deployer + target: + region_id: ${PROD_REGION_ID} + organization: ${PROD_ORG_NAME} + space: ${PROD_SPACE_NAME} + application: ${CF_APP_NAME} + script: | + #!/bin/bash + # Push app + push_app() { + if ! cf push "${CF_APP}" --no-start; then + echo "Error pushing ${CF_APP}." + exit 1 + fi + cf set-env ${CF_APP} "SLACK_SUBDOMAIN" ${SLACK_SUBDOMAIN} + cf set-env ${CF_APP} "SLACK_API_TOKEN" ${SLACK_API_TOKEN} > /dev/null + cf set-env ${CF_APP} "GOOGLE_CAPTCHA_SECRET" ${GOOGLE_CAPTCHA_SECRET} > /dev/null + cf set-env ${CF_APP} "GOOGLE_CAPTCHA_SITEKEY" ${GOOGLE_CAPTCHA_SITEKEY} > /dev/null + cf set-env ${CF_APP} "SLACK_INTERVAL" ${SLACK_INTERVAL} + cf start "${CF_APP}" + } + if ! cf app $CF_APP; then + push_app + else + OLD_CF_APP=${CF_APP}-OLD-$(date +"%s") + rollback() { + set +e + if cf app $OLD_CF_APP; then + cf logs $CF_APP --recent + cf delete $CF_APP -f + cf rename $OLD_CF_APP $CF_APP + fi + exit 1 + } + set -e + trap rollback ERR + cf rename $CF_APP $OLD_CF_APP + push_app + cf delete $OLD_CF_APP -f + fi + # Export app name and URL for use in later Pipeline jobs + export CF_APP_NAME="$CF_APP" + export APP_URL=http://$(cf app $CF_APP_NAME | grep -e urls: -e routes: | awk '{print $2}') + # View logs + #cf logs "${CF_APP}" --recent + diff --git a/.bluemix/toolchain.png b/.bluemix/toolchain.png new file mode 100644 index 00000000..04cf5489 Binary files /dev/null and b/.bluemix/toolchain.png differ diff --git a/.bluemix/toolchain.svg b/.bluemix/toolchain.svg new file mode 100644 index 00000000..d0517c07 --- /dev/null +++ b/.bluemix/toolchain.svg @@ -0,0 +1,423 @@ + + + + + + + background + + +Layer 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +THINK +CODE +DELIVER +RUN + + + + ISSUE TRACKER + + + GitHub + + + REPOSITORY + + + GitHub + + + PIPELINE + + + IBM Cloud + + + WEB IDE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.bluemix/toolchain.yml b/.bluemix/toolchain.yml new file mode 100644 index 00000000..b7ba3ebd --- /dev/null +++ b/.bluemix/toolchain.yml @@ -0,0 +1,62 @@ +version: '2' +messages: + $i18n: locales.yml +template: + name: + $ref: "#/messages/template.name" + description: + $ref: "#/messages/template.description" + header: '![](toolchain.svg?localize)' + icon: icon.svg + required: + - slackin-build + - slackin-repo + info: + git url: >- + [https://github.com/rauchg/slackin](https://github.com/rauchg/slackin) + git branch: >- + [master](https://github.com/rauchg/slackin/tree/master) +toolchain: + name: 'slackin-toolchain-{{timestamp}}' + template: + getting_started: + $ref: "#/messages/template.gettingStarted" +services: + slackin-repo: + service_id: githubpublic + parameters: + repo_name: '{{toolchain.name}}' + repo_url: 'https://github.com/rauchg/slackin' + type: clone + has_issues: true + enable_traceability: true + slackin-build: + service_id: pipeline + parameters: + services: + - slackin-repo + name: '{{services.slackin-repo.parameters.repo_name}}' + ui-pipeline: true + configuration: + content: + $text: pipeline.yml + env: + SLACKIN_REPO: slackin-repo + CF_APP_NAME: '{{form.pipeline.parameters.prod-app-name}}' + PROD_SPACE_NAME: '{{form.pipeline.parameters.prod-space}}' + PROD_ORG_NAME: '{{form.pipeline.parameters.prod-organization}}' + PROD_REGION_ID: '{{form.pipeline.parameters.prod-region}}' + SLACK_SUBDOMAIN: '{{form.pipeline.parameters.slack-teamid}}' + SLACK_API_TOKEN: '{{form.pipeline.parameters.slack-apitoken}}' + GOOGLE_CAPTCHA_SECRET: '{{form.pipeline.parameters.captcha-secret}}' + GOOGLE_CAPTCHA_SITEKEY: '{{form.pipeline.parameters.captcha-sitekey}}' + + execute: true + webide: + service_id: orion +form: + pipeline: + parameters: + prod-app-name: '{{services.slackin-repo.parameters.repo_name}}' + schema: + $ref: deploy.json diff --git a/.bluemix/toolchain_dark.png b/.bluemix/toolchain_dark.png new file mode 100644 index 00000000..4bd8590f Binary files /dev/null and b/.bluemix/toolchain_dark.png differ diff --git a/.gitignore b/.gitignore index 6b794026..22f7aa01 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ -node +# dependencies node_modules + +# logs +npm-debug.log diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 6c7b69a0..00000000 --- a/.npmignore +++ /dev/null @@ -1 +0,0 @@ -.gitignore diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..833d09d1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - stable diff --git a/Dockerfile b/Dockerfile index e40d2f4c..7e7a97e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM octohost/nodejs +FROM node:slim ENV PORT 3000 @@ -10,4 +10,4 @@ RUN npm install --unsafe-perm EXPOSE 3000 -CMD ./bin/slackin --channels "$SLACK_CHANNELS" --port $PORT $SLACK_SUBDOMAIN $SLACK_API_TOKEN +CMD ./bin/slackin --coc "$SLACK_COC" --channels "$SLACK_CHANNELS" --port $PORT $SLACK_SUBDOMAIN $SLACK_API_TOKEN $GOOGLE_CAPTCHA_SECRET $GOOGLE_CAPTCHA_SITEKEY diff --git a/History.md b/HISTORY.md similarity index 57% rename from History.md rename to HISTORY.md index 39acf724..ec576dfa 100644 --- a/History.md +++ b/HISTORY.md @@ -1,4 +1,87 @@ +0.13.0 / 2016-07-20 +=================== + + * index: add `/data` endpoint to get data through a JSON API + +0.12.0 / 2016-07-20 +=================== + + * add options cors support + * slack: improve error handling + +0.11.3 / 2016-07-19 +=================== + + * package: don't forget about assets + +0.11.2 / 2016-07-19 +=================== + + * package: fix broken `main` + +0.11.1 / 2016-07-19 +=================== + + * package: fix usecase of `require('slackin')` + +0.11.0 / 2016-07-19 +=================== + + * index: expose express app as `app` on the returned value of `slackin` + +0.10.3 / 2016-07-19 +=================== + + * package: only publish `bin` and `dist` + +0.10.2 / 2016-07-19 +=================== + + * package: remove postinstall + +0.10.1 / 2016-07-19 +=================== + + * moving babel and gulp into dev deps [@rauchg] + * package: remove `start` as it requires ENV stuff [@rauchg] + +0.10.0 / 2016-07-19 +=================== + + * package: bump `socket.io` for security fixes + +0.9.0 / 2016-07-19 +================== + + * Important bug fixes (#208) [@leo] + * Switch to args, lint code and clean up (#200) [@leo] + * Update docs with more clear token generation info + * Change heroku deploy to master + * Update Dockerfile to match Procfile + * issue #169, add turnary assignment for client sdk channels + * Change case on the "already invited" message + * Update Readme.md + * Fix TypeError when submitting w/o SLACK_CHANNELS config + +0.8.3 / 2016-03-08 +================== + + * fix postMessage({}, '*') causes slackin to throw [@laughinghan] + * add IBM Bluemix Deploy badge [@kevinSuttle] + * add `?large` to `/iframe` and `/iframe/dialog` [@laughinghan] + * convert dialog dimensions to em/rem for adjustability #prepwork [@laughinghan] + * fix redirecting already-registered users from iframe dialog [@laughinghan] + * add "or sign in" link to iframe too [@laughinghan] + * render a hidden form field for a single channel [@nickstenning] + * add .travis.yml [@jszwedko] + * fix test for successful invite [@jszwedko] + * update `babel-register` module name in mocha opts [@jszwedko] + * update readme for babel 6 change [@danreeves] + * shorten already-invited message [@MaxWofford] + * add success message for already signed up users [@MaxWofford] + * fix max listeners warnings [Hardeep Shoker] + 0.8.2 / 2016-01-13 ================== diff --git a/Procfile b/Procfile index 4ef841b6..618b7fb5 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: bin/slackin --coc "$SLACK_COC" --channels "$SLACK_CHANNELS" --port $PORT $SLACK_SUBDOMAIN $SLACK_API_TOKEN +web: bin/slackin --coc "$SLACK_COC" --channels "$SLACK_CHANNELS" --port $PORT $SLACK_SUBDOMAIN $SLACK_API_TOKEN $GOOGLE_CAPTCHA_SECRET $GOOGLE_CAPTCHA_SITEKEY diff --git a/Readme.md b/Readme.md deleted file mode 100644 index 768e1a10..00000000 --- a/Readme.md +++ /dev/null @@ -1,157 +0,0 @@ - -# slackin - -A little server that enables public access -to a Slack server. Like Freenode, but on Slack. - -It provides - -- A landing page you can point users to fill in their - emails and receive an invite (`https://slack.yourdomain.com`) -- An `