Skip to content
This repository was archived by the owner on Aug 5, 2020. It is now read-only.

Commit accb493

Browse files
committed
Merge pull request #51 from mobify/site-js
Add support for site.js
2 parents 0f46312 + f674f60 commit accb493

File tree

4 files changed

+69
-8
lines changed

4 files changed

+69
-8
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Reviewers: @ellenmobify @marlowpayne @mobify-derrick
77
- (change2)
88

99
## Todos:
10-
- [] Passed linting check (run `grunt lint`)
11-
- [] Updated README
12-
- [] Updated CHANGELOG
10+
- [ ] Passed linting check (run `grunt lint`)
11+
- [ ] Updated README
12+
- [ ] Updated CHANGELOG
1313

1414
### Feedback:
1515
_none so far_
@@ -19,4 +19,4 @@ _none so far_
1919
- `npm install`
2020
- `npm link`
2121
- `grunt lint`
22-
- (notes)
22+
- (notes)

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
1.6.0
2+
- Update `preview` command to accept an optional `site.js`.
13
1.5.0
24
- Follow company practices for tools and gitflow
35
- Have CircleCI lint our source code (TODO: tests to be fixed later)

README.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,59 @@ this.demoTest = function (browser) {
166166

167167
#### preview(url, callback)
168168

169-
The `preview` command uses http://preview.mobify.com to open a website to preview a given bundle. The bundle and the base URL need to be set in the `tests/system/site.json` file. Note that if the "production" flag is set in `site.json`, the bundle URL will be ignored. Pass in an optional URL as an argument to this command. Upon completion, `waitUntilMobified` is called to ensure that the mobile site adaptation is complete.
169+
The `preview` command uses http://preview.mobify.com to open a website to preview a given bundle. The bundle and the base URL need to be set in the `tests/system/site.json` or `tests/system/site.js` file. Note that if the "production" flag is set in the `activeProfile` in `site.json` or `site.js`, the bundle URL will be ignored. Pass in an optional URL as an argument to this command. Upon completion, `waitUntilMobified` is called to ensure that the mobile site adaptation is complete.
170+
171+
Example site.json
172+
```
173+
{
174+
"activeProfile": "production",
175+
"profiles": {
176+
"default": {
177+
"bundleUrl": "http://localhost:8080/adaptive.js",
178+
"siteUrl": "http://www.merlinspotions.com/"
179+
},
180+
"production": {
181+
"bundleUrl": "",
182+
"siteUrl": "http://www.merlinspotions.com/",
183+
"production": true
184+
}
185+
}
186+
}
187+
```
188+
189+
Example site.js
190+
```
191+
var Site = {
192+
/*
193+
activeProfile defines which environment to run tests against.
194+
By default, builds on master branch run against production, without preview.
195+
Builds on any other branch should use preview with local adaptive.js.
196+
197+
Change activeProfile whenever you need to override the default behaviour.
198+
*/
199+
activeProfile: process.env.ACTIVE_PROFILE || 'default',
200+
201+
/*
202+
Define new profiles as needed for different URLs, eg. staging, prod.
203+
*/
204+
profiles: {
205+
default: {
206+
bundleUrl: 'http://localhost:8080/adaptive.js',
207+
siteUrl: 'http://www.merlinspotions.com/'
208+
},
209+
production: {
210+
bundleUrl: '',
211+
siteUrl: 'http://www.merlinspotions.com',
212+
production: true
213+
}
214+
}
215+
};
216+
217+
module.exports = Site;
170218
171-
If the project does not have a `tests/system/site.json` file, this command is equivalent to the `url` protocol command.
219+
```
220+
221+
If the project does not have a `site.json` or `site.js` file, this command is equivalent to the `url` protocol command.
172222

173223
Parameter Name | Parameter Type | Description
174224
------------- | -------------- | -----------
@@ -318,4 +368,4 @@ callback | Function | _optional_ A function to call after the curren
318368
this.demoTest = function (browser) {
319369
browser.waitUntilMobified();
320370
};
321-
```
371+
```

commands/preview.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,18 @@ try {
3232
var siteConfig = require(path.join(path.resolve('./'), '/tests/system/site.json'));
3333
} catch (e) {
3434
if (e instanceof Error && e.code === 'MODULE_NOT_FOUND') {
35-
console.log('Not using optional site.json...');
35+
console.log('Not using optional site.json. Looking for site.js...');
3636
}
3737
}
38+
39+
try {
40+
var siteConfig = require(path.join(path.resolve('./'), '/tests/system/site.js'));
41+
} catch (e) {
42+
if (e instanceof Error && e.code === 'MODULE_NOT_FOUND') {
43+
console.log('Not using optional site.js.');
44+
}
45+
}
46+
3847
var qs = require('querystring');
3948

4049
exports.command = function(url, callback) {

0 commit comments

Comments
 (0)