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

Commit

Permalink
Merge pull request #51 from mobify/site-js
Browse files Browse the repository at this point in the history
Add support for site.js
  • Loading branch information
ellenmobify committed Feb 19, 2016
2 parents 0f46312 + f674f60 commit accb493
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Reviewers: @ellenmobify @marlowpayne @mobify-derrick
- (change2)

## Todos:
- [] Passed linting check (run `grunt lint`)
- [] Updated README
- [] Updated CHANGELOG
- [ ] Passed linting check (run `grunt lint`)
- [ ] Updated README
- [ ] Updated CHANGELOG

### Feedback:
_none so far_
Expand All @@ -19,4 +19,4 @@ _none so far_
- `npm install`
- `npm link`
- `grunt lint`
- (notes)
- (notes)
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
1.6.0
- Update `preview` command to accept an optional `site.js`.
1.5.0
- Follow company practices for tools and gitflow
- Have CircleCI lint our source code (TODO: tests to be fixed later)
Expand Down
56 changes: 53 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,59 @@ this.demoTest = function (browser) {

#### preview(url, callback)

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.
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.

Example site.json
```
{
"activeProfile": "production",
"profiles": {
"default": {
"bundleUrl": "http://localhost:8080/adaptive.js",
"siteUrl": "http://www.merlinspotions.com/"
},
"production": {
"bundleUrl": "",
"siteUrl": "http://www.merlinspotions.com/",
"production": true
}
}
}
```

Example site.js
```
var Site = {
/*
activeProfile defines which environment to run tests against.
By default, builds on master branch run against production, without preview.
Builds on any other branch should use preview with local adaptive.js.
Change activeProfile whenever you need to override the default behaviour.
*/
activeProfile: process.env.ACTIVE_PROFILE || 'default',
/*
Define new profiles as needed for different URLs, eg. staging, prod.
*/
profiles: {
default: {
bundleUrl: 'http://localhost:8080/adaptive.js',
siteUrl: 'http://www.merlinspotions.com/'
},
production: {
bundleUrl: '',
siteUrl: 'http://www.merlinspotions.com',
production: true
}
}
};
module.exports = Site;
If the project does not have a `tests/system/site.json` file, this command is equivalent to the `url` protocol command.
```

If the project does not have a `site.json` or `site.js` file, this command is equivalent to the `url` protocol command.

Parameter Name | Parameter Type | Description
------------- | -------------- | -----------
Expand Down Expand Up @@ -318,4 +368,4 @@ callback | Function | _optional_ A function to call after the curren
this.demoTest = function (browser) {
browser.waitUntilMobified();
};
```
```
11 changes: 10 additions & 1 deletion commands/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,18 @@ try {
var siteConfig = require(path.join(path.resolve('./'), '/tests/system/site.json'));
} catch (e) {
if (e instanceof Error && e.code === 'MODULE_NOT_FOUND') {
console.log('Not using optional site.json...');
console.log('Not using optional site.json. Looking for site.js...');
}
}

try {
var siteConfig = require(path.join(path.resolve('./'), '/tests/system/site.js'));
} catch (e) {
if (e instanceof Error && e.code === 'MODULE_NOT_FOUND') {
console.log('Not using optional site.js.');
}
}

var qs = require('querystring');

exports.command = function(url, callback) {
Expand Down

0 comments on commit accb493

Please sign in to comment.