Skip to content

Commit 432de03

Browse files
author
Aaron Chambers
committed
Merge pull request #14 from strange-studios/update-readme-for-0.5.0
Update README for v0.5.0
2 parents 1a063a1 + 599a131 commit 432de03

File tree

1 file changed

+205
-13
lines changed

1 file changed

+205
-13
lines changed

README.md

Lines changed: 205 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,217 @@
11
# Ember-cli-deploy-redis
22

3-
This README outlines the details of collaborating on this Ember addon.
3+
> An ember-cli-deploy-plugin to upload index.html to a Redis store
4+
5+
<hr/>
6+
**WARNING: This plugin is only compatible with ember-cli-deploy versions >= 0.5.0**
7+
<hr/>
8+
9+
This plugin uploads a file, presumably index.html, to a specified Redis store.
10+
11+
More often than not this plugin will be used in conjunction with the [lightning method of deployment][1] where the ember application assets will be served from S3 and the index.html file will be served from Redis. However, it can be used to upload any file to a Redis store.
12+
13+
## What is an ember-cli-deploy plugin?
14+
15+
A plugin is an addon that can be executed as a part of the ember-cli-deploy pipeline. A plugin will implement one or more of the ember-cli-deploy's pipeline hooks.
16+
17+
For more information on what plugins are and how they work, please refer to the [Plugin Documentation][2].
18+
19+
## Quick Start
20+
To get up and running quickly, do the following:
21+
22+
- Ensure [ember-cli-deploy-build][4] is installed and configured.
23+
24+
- Install this plugin
25+
26+
```bash
27+
$ ember install ember-cli-deploy-redis
28+
```
29+
30+
- Place the following configuration into `config/deploy.js`
31+
32+
```javascript
33+
ENV.redis {
34+
host: '<your-redis-host>',
35+
port: <your-redis-port>,
36+
password: '<your-redis-password>'
37+
}
38+
```
39+
40+
- Run the pipeline
41+
42+
```bash
43+
$ ember deploy
44+
```
445

546
## Installation
47+
Run the following command in your terminal:
648

7-
* `git clone` this repository
8-
* `npm install`
9-
* `bower install`
49+
```bash
50+
ember install ember-cli-deploy-redis
51+
```
1052

11-
## Running
53+
## ember-cli-deploy Hooks Implemented
1254

13-
* `ember server`
14-
* Visit your app at http://localhost:4200.
55+
For detailed information on what plugin hooks are and how they work, please refer to the [Plugin Documentation][2].
1556

16-
## Running Tests
57+
- `configure`
58+
- `upload`
59+
- `activate`
60+
- `didDeploy`
61+
62+
## Configuration Options
63+
64+
For detailed information on how configuration of plugins works, please refer to the [Plugin Documentation][2].
65+
66+
### host
67+
68+
The Redis host. If [url](#url) is defined, then this option is not needed.
69+
70+
*Default:* `'localhost'`
71+
72+
### port
73+
74+
The Redis port. If [url](#url) is defined, then this option is not needed.
75+
76+
*Default:* `6379`
77+
78+
### password
79+
80+
The Redis password. If [url](#url) is defined, then this option is not needed.
81+
82+
*Default:* `null`
83+
84+
### url
85+
86+
A Redis connection url to the Redis store
87+
88+
*Example:* 'redis://some-user:some-password@some-host.com:1234'
89+
90+
### filePattern
91+
92+
A file matching this pattern will be uploaded to Redis.
93+
94+
*Default:* `'index.html'`
95+
96+
### distDir
97+
98+
The root directory where the file matching `filePattern` will be searched for. By default, this option will use the `distDir` property of the deployment context.
99+
100+
*Default:* `context.distDir`
101+
102+
### keyPrefix
103+
104+
The prefix to be used for the Redis key under which file will be uploaded to Redis. The Redis key will be a combination of the `keyPrefix` and the `revisionKey`. By default this option will use the `project.name()` property from the deployment context.
17105

18-
* `ember test`
19-
* `ember test --server`
106+
*Default:* `context.project.name() + ':index'`
20107

21-
## Building
108+
### revisionKey
109+
110+
The unique revision number for the version of the file being uploaded to Redis. The Redis key will be a combination of the `keyPrefix` and the `revisionKey`. By default this option will use either the `revisionKey` passed in from the command line or the `revisionKey` property from the deployment context.
111+
112+
*Default:* `context.commandLineArgs.revisionKey || context.revisionKey`
113+
114+
### redisDeployClient
115+
116+
The Redis client to be used to upload files to the Redis store. By default this option will use a new instance of the [Redis][3] client unless another client is provided in the `redisDeployClient` property of the deployment context. This allows for injection of a mock client for testing purposes.
117+
118+
*Default:* `context.redisDeployClient || new Redis(context.config.redis)`
119+
120+
### didDeployMessage
121+
122+
A message that will be displayed after the file has been successfully uploaded to Redis. By default this message will only display if the revision for `revisionKey` of the deployment context has been activated.
123+
124+
*Default:*
125+
126+
```javascript
127+
if (context.revisionKey && !context.activatedRevisionKey) {
128+
return "Deployed but did not activate revision " + context.revisionKey + ". "
129+
+ "To activate, run: "
130+
+ "ember deploy:activate " + context.revisionKey + " --environment=" + context.deployEnvironment + "\n";
131+
}
132+
```
133+
134+
## Activation
135+
136+
As well as uploading a file to Redis, *ember-cli-deploy-redis* has the ability to mark a revision of a deployed file as `current`. This is most commonly used in the [lightning method of deployment][1] whereby an index.html file is pushed to Redis and then served to the user by a web server. The web server could be configured to return any existing revision of the index.html file as requested by a query parameter. However, the revision marked as the currently `active` revision would be returned if no query paramter is present. For more detailed information on this method of deployment please refer to the [ember-cli-deploy-lightning-pack README][1].
137+
138+
### How do I activate a revision?
139+
140+
A user can activate a revision by either:
141+
142+
- Passing a command line argument to the `deploy` command:
143+
144+
```bash
145+
$ ember deploy --activate=true
146+
```
147+
148+
- Running the `deploy:activate` command:
149+
150+
```bash
151+
$ ember deploy:activate <revision-key>
152+
```
153+
154+
- Setting the `activateOnDeploy` flag in `deploy.js`
155+
156+
```javascript
157+
ENV.pipeline {
158+
activateOnDeploy: true
159+
}
160+
```
161+
162+
### What does activation do?
163+
164+
When *ember-cli-deploy-redis* uploads a file to Redis, it uploads it under the key defined by a combination of the two config properties `keyPrefix` and `revisionKey`.
165+
166+
So, if the `keyPrefix` was configured to be `my-app:index` and there had been 3 revisons deployed, then Redis might look something like this:
167+
168+
```bash
169+
$ redis-cli
170+
171+
127.0.0.1:6379> KEYS *
172+
1) my-app:index:9ab2021411f0cbc5ebd5ef8ddcd85cef
173+
2) my-app:index:499f5ac793551296aaf7f1ec74b2ca79
174+
3) my-app:index:f769d3afb67bd20ccdb083549048c86c
175+
```
176+
177+
Activating a revison would add a new entry to Redis pointing to the currently active revision:
178+
179+
```bash
180+
$ ember deploy:activate f769d3afb67bd20ccdb083549048c86c
181+
182+
$ redis-cli
183+
184+
127.0.0.1:6379> KEYS *
185+
1) my-app:index:9ab2021411f0cbc5ebd5ef8ddcd85cef
186+
2) my-app:index:499f5ac793551296aaf7f1ec74b2ca79
187+
3) my-app:index:f769d3afb67bd20ccdb083549048c86c
188+
4) my-app:index:current
189+
190+
127.0.0.1:6379> GET my-app:index:current
191+
"f769d3afb67bd20ccdb083549048c86c"
192+
```
193+
194+
### When does activation occur?
195+
196+
Activation occurs during the `activate` hook of the pipeline. By default, activation is turned off and must be explicitly enabled by one of the 3 methods above.
197+
198+
## Prerequisites
199+
200+
The following properties are expected to be present on the deployment `context` object:
201+
202+
- `distDir` (provided by [ember-cli-deploy-build][4])
203+
- `project.name()` (provided by [ember-cli-deploy][5])
204+
- `revisionKey` (provided by [ember-cli-deploy-revision-key][6])
205+
- `commandLineArgs.revisionKey` (provided by [ember-cli-deploy][5])
206+
- `deployEnvironment` (provided by [ember-cli-deploy][5])
207+
208+
## Running Tests
22209

23-
* `ember build`
210+
- `npm test`
24211

25-
For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).
212+
[1]: https://github.com/lukemelia/ember-cli-deploy-lightning-pack "ember-cli-deploy-lightning-pack"
213+
[2]: http://ember-cli.github.io/ember-cli-deploy/plugins "Plugin Documentation"
214+
[3]: https://www.npmjs.com/package/redis "Redis Client"
215+
[4]: https://github.com/zapnito/ember-cli-deploy-build "ember-cli-deploy-build"
216+
[5]: https://github.com/ember-cli/ember-cli-deploy "ember-cli-deploy"
217+
[6]: https://github.com/zapnito/ember-cli-deploy-revision-key "ember-cli-deploy-revision-key"

0 commit comments

Comments
 (0)