diff --git a/Assets/repo-banner.png b/Assets/repo-banner.png new file mode 100644 index 0000000..5abd47d Binary files /dev/null and b/Assets/repo-banner.png differ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..3b2f772 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,39 @@ +# Contributing to slackin-swift + +First off - thank you!!! + +## The Goal + +As of this writing, [slackin](https://github.com/rauchg/slackin) is the goal to aim for. By aiming for this, we hope to prove that Swift is as viable as Node.js for web applications. + +Once software parity has been reached, a manifesto can be designed to discuss future ideas, but this should always remain simple to use, just like the original :smile: + +## Branching + +Please fork slackin-swift and submit a pull request to make any contributions. Repeated contributors who would like to maintain any branches that exist should email me about becoming a full-time collaborator [here](mailto:david@okun.io) + +## Pull Requests + +Please submit any feature requests or bug fixes as a pull request. + +Please make sure that all pull requests have the following: + +- a descriptive title +- a meaningful body of text to explain what the PR does +- if it fixes a pre-existing issue, include the issue number in the body of text + +Pushing directly to master is disallowed. + +## Running locally + +To run Lumina locally, please follow these steps: + +- Clone the repository +- Run `swift build` +- Run `.build/debug/slackin-swift **insert token here**` --OR-- `./runDocker **insert token here**` + +To develop on slackin-swift: + +- Run `swift package generate-xcodeproj` + +**Thanks for contributing! :100:** \ No newline at end of file diff --git a/README.md b/README.md index 66dea69..692fa60 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,41 @@ -## slackin-swift +
+ +
+ + + +---------------- + +Create a landing page invited for a Slack instance you want people to join. + +Heavily inspired, obviously, by [slackin](https://github.com/rauchg/slackin). + +### Requirements + +- You must obtain a Slack legacy token. You can do this [here](https://api.slack.com/custom-integrations/legacy-tokens). +- Ability to deploy to Cloud Foundry with at least 128MB of application memory ### Building the project -1) Clone this repo -2) From the root directory, run `swift build` -3) From the root directory, run `swift package generate-xcodeproj` +1) Clone this repo. +2) From the root directory, run `swift build`. +3) From the root directory, run `swift package generate-xcodeproj`. ### Running in Xcode 1) Create a file in your `~/Documents` directory called `slackkey.txt`. 2) For the slack you want to run this with, make the only contents of that file the legacy slack token you are working with. -3) Save the file, +3) Save the file. When you run this in Xcode, if you don't provide a token as a command line argument, it will search for this file and read it, and use that. You can debug on `main.swift` to see what it's doing. @@ -20,113 +45,12 @@ If you run this from the command line, you'll want to run: .build/debug/slackin-swift **insert token here** ``` -Let me know if you have further questions. - -[![](https://img.shields.io/badge/bluemix-powered-blue.svg)](https://bluemix.net) -[![Platform](https://img.shields.io/badge/platform-swift-lightgrey.svg?style=flat)](https://developer.ibm.com/swift/) - -### Table of Contents -* [Summary](#summary) -* [Requirements](#requirements) -* [Project contents](#project-contents) -* [Configuration](#configuration) -* [Run](#run) -* [Deploy to IBM Cloud](#deploy-to-ibm-cloud) -* [License](#license) -* [Generator](#generator) - -### Summary -This scaffolded application provides a starting point for creating Swift applications running on [Kitura](http://www.kitura.io/). - -### Requirements -* [Swift 4](https://swift.org/download/) - -### Project contents -This application has been generated with the following capabilities and services: - -* [CloudEnvironment](#configuration) -* [Embedded metrics dashboard](#embedded-metrics-dashboard) -* [Docker files](#docker-files) -* [IBM Cloud deployment](#ibm-cloud-deployment) - -#### Embedded metrics dashboard -This application uses the [SwiftMetrics package](https://github.com/RuntimeTools/SwiftMetrics) to gather application and system metrics. - -These metrics can be viewed in an embedded dashboard on `/swiftmetrics-dash`. The dashboard displays various system and application metrics, including CPU, memory usage, HTTP response metrics and more. -#### Docker files -The application includes the following files for Docker support: -* `.dockerignore` -* `Dockerfile` -* `Dockerfile-tools` - -The `.dockerignore` file contains the files/directories that should not be included in the built docker image. By default this file contains the `Dockerfile` and `Dockerfile-tools`. It can be modified as required. - -The `Dockerfile` defines the specification of the default docker image for running the application. This image can be used to run the application. - -The `Dockerfile-tools` is a docker specification file similar to the `Dockerfile`, except it includes the tools required for compiling the application. This image can be used to compile the application. - -Details on how to build the docker images, compile and run the application within the docker image can be found in the [Run section](#run) below. -#### IBM Cloud deployment -Your application has a set of cloud deployment configuration files defined to support deploying your application to IBM Cloud: -* `manifest.yml` -* `.bluemix/toolchain.yml` -* `.bluemix/pipeline.yml` +### Running in Docker -The [`manifest.yml`](https://console.ng.bluemix.net/docs/manageapps/depapps.html#appmanifest) defines options which are passed to the Cloud Foundry `cf push` command during application deployment. +There is a run script provided with the repository titled `runDocker` that utilizes a local `Dockerfile` for running the app, and `Dockerfile-tools` for building the app. The script takes one parameter, so execute the script like so: -[IBM Cloud DevOps](https://console.ng.bluemix.net/docs/services/ContinuousDelivery/index.html) service provides toolchains as a set of tool integrations that support development, deployment, and operations tasks inside IBM Cloud, for both Cloud Foundry and Kubernetes applications. The ["Create Toolchain"](#deploy-to-ibm-cloud) button creates a DevOps toolchain and acts as a single-click deploy to IBM Cloud including provisioning all required services. - - -### Configuration -Your application configuration information is stored in the `config.json` in the project root directory. This file is in the `.gitignore` to prevent sensitive information from being stored in git. - -The connection information for any configured services, such as username, password and hostname, is stored in this file. - -The application uses the [CloudEnvironment package](https://github.com/IBM-Swift/CloudEnvironment) to read the connection and configuration information from the environment and this file. - -If the application is running locally, it can connect to IBM Cloud services using unbound credentials read from this file. If you need to create unbound credentials you can do so from the IBM Cloud web console ([example](https://console.ng.bluemix.net/docs/services/Cloudant/tutorials/create_service.html#creating-a-service-instance)), or using the CloudFoundry CLI [`cf create-service-key` command](http://cli.cloudfoundry.org/en-US/cf/create-service-key.html). - -When you push your application to IBM Cloud, these values are no longer used, instead the application automatically connects to bound services using environment variables. - -### Run -To build and run the application: -1. `swift build` -1. `.build/debug/slackin-swift` - -**NOTE**: On macOS you will need to add options to the `swift build` command: `swift build -Xlinker -lc++` - -#### Docker -To build the two docker images, run the following commands from the root directory of the project: -* `docker build -t myapp-run .` -* `docker build -t myapp-build -f Dockerfile-tools .` -You may customize the names of these images by specifying a different value after the `-t` option. - -To compile the application using the tools docker image, run: -* `docker run -v $PWD:/swift-project -w /swift-project myapp-build /swift-utils/tools-utils.sh build release` - -To run the application: -* `docker run -it -p 8080:8080 -v $PWD:/swift-project -w /swift-project myapp-run sh -c .build-ubuntu/release/slackin-swift` - -### Deploy to IBM Cloud -You can deploy your application to Bluemix using: -* the [CloudFoundry CLI](#cloudfoundry-cli) -* an [IBM Cloud toolchain](#ibm-cloud-toolchain) - -#### CloudFoundry CLI -You can deploy the application to IBM Cloud using the CloudFoundry command-line: -1. Install the Cloud Foundry command-line (https://docs.cloudfoundry.org/cf-cli/install-go-cli.html) -1. Ensure all configured services have been provisioned -1. Run `cf push` from the project root directory - -The Cloud Foundry CLI will not provision the configured services for you, so you will need to do this manually using the IBM Cloud web console ([example](https://console.ng.bluemix.net/docs/services/Cloudant/tutorials/create_service.html#creating-a-service-instance)) or the CloudFoundry CLI (`cf create-service` command)[http://cli.cloudfoundry.org/en-US/cf/create-service.html]. The service names and types will need to match your [configuration](#configuration). - -#### IBM Cloud toolchain -You can also set up a default IBM Cloud Toolchain to handle deploying your application to IBM Cloud. This is achieved by publishing your application to a publicly accessible github repository and using the "Create Toolchain" button below. In this case configured services will be automatically provisioned, once, during toolchain creation. - -[![Create Toolchain](https://console.ng.bluemix.net/devops/graphics/create_toolchain_button.png)](https://console.ng.bluemix.net/devops/setup/deploy/) - -### License -All generated content is available for use and modification under the permissive MIT License (see `LICENSE` file), with the exception of SwaggerUI which is licensed under an Apache-2.0 license (see `NOTICES.txt` file). +```bash +./runDocker **insert token here** +``` -### Generator -This project was generated with [generator-swiftserver](https://github.com/IBM-Swift/generator-swiftserver) v4.9.3. +Note that, in the script, the names of the images created can be modified, but everything is consistently named for the sake of simplicity. \ No newline at end of file diff --git a/Sources/slackin-swift/main.swift b/Sources/slackin-swift/main.swift index b741282..344f306 100644 --- a/Sources/slackin-swift/main.swift +++ b/Sources/slackin-swift/main.swift @@ -6,20 +6,23 @@ import Application var token: String? +HeliumLogger.use(LoggerMessageType.verbose) + if let argumentToken = SlackArguments.extractToken(from: CommandLine.arguments) { + Log.verbose("Token found and validated: \(argumentToken)") token = argumentToken } else { do { let debugToken = try SlackArguments.debug_extractTokenFromFile() + Log.verbose("Debug token found and validated: \(debugToken)") token = debugToken } catch let error { - Log.error(error.localizedDescription) + Log.error("Could not start application without token: \(error.localizedDescription)") exit(0) } } do { - HeliumLogger.use(LoggerMessageType.debug) let app = try App() guard let unwrappedToken = token else { throw SlackError.noToken diff --git a/chart/kiturainit/Chart.yaml b/chart/slackin-swift/Chart.yaml similarity index 100% rename from chart/kiturainit/Chart.yaml rename to chart/slackin-swift/Chart.yaml diff --git a/chart/kiturainit/templates/basedeployment.yaml b/chart/slackin-swift/templates/basedeployment.yaml similarity index 100% rename from chart/kiturainit/templates/basedeployment.yaml rename to chart/slackin-swift/templates/basedeployment.yaml diff --git a/chart/kiturainit/templates/deployment.yaml b/chart/slackin-swift/templates/deployment.yaml similarity index 100% rename from chart/kiturainit/templates/deployment.yaml rename to chart/slackin-swift/templates/deployment.yaml diff --git a/chart/kiturainit/templates/hpa.yaml b/chart/slackin-swift/templates/hpa.yaml similarity index 100% rename from chart/kiturainit/templates/hpa.yaml rename to chart/slackin-swift/templates/hpa.yaml diff --git a/chart/kiturainit/templates/istio.yaml b/chart/slackin-swift/templates/istio.yaml similarity index 100% rename from chart/kiturainit/templates/istio.yaml rename to chart/slackin-swift/templates/istio.yaml diff --git a/chart/kiturainit/templates/service.yaml b/chart/slackin-swift/templates/service.yaml similarity index 100% rename from chart/kiturainit/templates/service.yaml rename to chart/slackin-swift/templates/service.yaml diff --git a/chart/kiturainit/values.yaml b/chart/slackin-swift/values.yaml similarity index 100% rename from chart/kiturainit/values.yaml rename to chart/slackin-swift/values.yaml diff --git a/manifest.yml b/manifest.yml index a35c734..42ab93f 100644 --- a/manifest.yml +++ b/manifest.yml @@ -4,7 +4,4 @@ applications: timeout: 180 name: weirdswiftslack buildpack: swift_buildpack - command: "'slackin-swift $SLACK_TOKEN'" memory: 128M - env: - SLACK_TOKEN: production