Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the build process to build all targets at once #374

Merged
merged 1 commit into from
Jun 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,4 @@
npm-debug.log
testem.log

# dists

/dist_chrome/panes
/dist_chrome/ember_debug
/dist_chrome/in-page-script.js
/dist_chrome/ember-inspector.zip

/dist_firefox/data/panes
/dist_firefox/data/ember_debug
/dist_firefox/data/in-page-script.js

/dist_websocket

/dist_bookmarklet

/.mozilla-addon-sdk
4 changes: 2 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ tmp/
.DS_Store
*.swp

dist_chrome/ember-inspector.zip
dist/
dist/chrome/ember-inspector.zip
dist/testing

*.xpi

Expand Down
97 changes: 74 additions & 23 deletions Brocfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ var removeFile = require('broccoli-file-remover');
var path = require('path');
var jsStringEscape = require('js-string-escape');
var eslint = require('broccoli-lint-eslint');
var mv = require('broccoli-stew').mv;
var writeFile = require('broccoli-file-creator');
var replace = require('broccoli-replace');

/*global process */
var dist = process.env.EMBER_DIST;

var options = {
fingerprint: {
Expand Down Expand Up @@ -45,10 +47,10 @@ function eslintTestGenerator(relativePath, errors) {
"});\n";
}

if (dist === 'firefox') {
options.minifyJS = { enabled: false };
options.minifyCSS = { enabled: false };
}
// Firefox requires non-minified assets for review :(
options.minifyJS = { enabled: false };
options.minifyCSS = { enabled: false };

var app = new EmberApp(options);

var env = process.env.EMBER_ENV;
Expand Down Expand Up @@ -131,29 +133,78 @@ emberDebug = concatFiles(emberDebug, {
wrapInFunction: false
});

emberDebug = wrapFiles(emberDebug, {
wrapper: ["(function(adapter, env) {\n", "\n}('" + (dist || 'basic') + "', '" + env + "'));"]
var emberDebugs = [];
['basic', 'chrome', 'firefox', 'bookmarklet', 'websocket'].forEach(function(dist) {
emberDebugs[dist] = wrapFiles(emberDebug, {
wrapper: ["(function(adapter, env) {\n", "\n}('" + dist + "', '" + env + "'));"]
});
});

var tree = app.toTree();
tree = mergeTrees([tree, emberDebug]);

if (dist === 'bookmarklet') {
var extra = pickFiles('bookmarklet', {
srcDir: '/',
files: ['load_inspector.js'],
destDir: '/'
});
tree = mergeTrees([tree, extra]);
}
var bookmarklet = mergeTrees([tree, emberDebugs.bookmarklet, 'skeleton_bookmarklet']);

if (dist === 'firefox' || dist === 'chrome') {
var extra = pickFiles('shared', {
srcDir: '/',
files: ['in-page-script.js'],
destDir: '/'
var firefoxAndChromeExtra = pickFiles('shared', {
srcDir: '/',
files: ['in-page-script.js'],
destDir: '/'
});

var firefox = mergeTrees([
mv(mergeTrees([tree, firefoxAndChromeExtra, emberDebugs.firefox]), 'data/panes'),
'skeleton_firefox'
]);

var chrome = mergeTrees([
mv(mergeTrees([tree, firefoxAndChromeExtra, emberDebugs.chrome]), 'panes'),
'skeleton_chrome'
]);

var websocket = mergeTrees([tree, emberDebugs.websocket]);
var basic = mergeTrees([tree, emberDebugs.basic]);

// Pass the current dist to the Ember Inspector app.
chrome = mergeTrees([chrome, mv(writeFile('dist-config.js', "window.EMBER_DIST='chrome';"), 'panes/assets')]);
firefox = mergeTrees([firefox, mv(writeFile('dist-config.js', "window.EMBER_DIST='firefox';"), 'data/panes/assets')]);
bookmarklet = mergeTrees([bookmarklet, mv(writeFile('dist-config.js', "window.EMBER_DIST='bookmarklet';"), 'assets')]);
websocket = mergeTrees([websocket, mv(writeFile('dist-config.js', "window.EMBER_DIST='websocket';"), 'assets')]);
basic = mergeTrees([basic, mv(writeFile('dist-config.js', "window.EMBER_DIST='basic';"), 'assets')]);

// Add {{ remote-port }} to the head
// so that the websocket addon can replace it.
websocket = replace(websocket, {
files: ['index.html'],
patterns: [{
match: /<head>/,
replacement: '<head>\n{{ remote-port }}\n'
}]
});

var output;

if (env === 'test') {
// `ember test` expects the index.html file to be in the
// output directory.
output = basic;
} else {

// Change base tag for running tests in development env.
basic = replace(basic, {
files: ['tests/index.html'],
patterns: [{
match: /<base.*\/>/,
replacement: '<base href="../" />'
}]
});
tree = mergeTrees([tree, extra]);

output = mergeTrees([
mv(bookmarklet, 'bookmarklet'),
mv(firefox, 'firefox'),
mv(chrome, 'chrome'),
mv(websocket, 'websocket'),
mv(basic, 'testing')
]);
}

module.exports = tree;
module.exports = output;

12 changes: 6 additions & 6 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function(grunt) {
"stable": {
options: {
"mozilla-addon-sdk": "latest",
extension_dir: "dist_firefox",
extension_dir: "dist/firefox",
dist_dir: "tmp/xpi"
}
}
Expand All @@ -24,7 +24,7 @@ module.exports = function(grunt) {
"run": {
options: {
"mozilla-addon-sdk": "latest",
extension_dir: "dist_firefox",
extension_dir: "dist/firefox",
command: "run"
}
}
Expand All @@ -35,7 +35,7 @@ module.exports = function(grunt) {
},
dist: {
prefix: '^"?version"?:\s*[\'"]?',
src: ['dist_chrome/manifest.json', 'dist_firefox/package.json']
src: ['dist/chrome/manifest.json', 'dist/firefox/package.json']
}
},
"s3": {
Expand All @@ -49,7 +49,7 @@ module.exports = function(grunt) {
},
bookmarklet: {
sync: [{
src: 'dist_bookmarklet/**/*.*',
src: 'dist/bookmarklet/**/*.*',
dest: 'dist_bookmarklet/',
rel: 'dist_bookmarklet',
options: { verify: true }
Expand All @@ -59,11 +59,11 @@ module.exports = function(grunt) {
"compress": {
main: {
options: {
archive: 'dist_chrome/ember-inspector.zip'
archive: 'dist/chrome/ember-inspector.zip'
},
expand: true,
pretty: true,
src: 'dist_chrome/**/*'
src: 'dist/chrome/**/*'
}
}
};
Expand Down
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ OR:
- cd into the repo directory
- run `npm install && bower install`
- run `npm install -g ember-cli`
- run `npm run build:chrome` to build the `dist_chrome` directory
- run `npm build` to build the `dist` directory
- Visit chrome://extensions in chrome
- Make sure `Developer mode` is checked
- Click on 'Load unpacked extension...'
- Choose the `dist_chrome` folder in the cloned repo
- Choose the `dist/chrome` folder in the cloned repo
- Close and re-open developer tools if it's already open

### Firefox
Expand All @@ -34,7 +34,7 @@ OR:
- cd into the repo directory
- run `npm install && bower install`
- run `npm install -g ember-cli`
- run `npm run build:xpi` to build the `dist_firefox` directory, download Firefox Addon SDK and build Firefox Addon XPI to 'tmp/xpi/ember-inspector.xpi'
- run `npm run build:xpi` to build the `dist` directory, download Firefox Addon SDK and build Firefox Addon XPI to 'tmp/xpi/ember-inspector.xpi'
or `npm run run-xpi` to run the Firefox Addon in a temporary profile (or use `FIREFOX_BIN` and `FIREFOX_PROFILE` to customize Firefox profile directory and Firefox binary used to run the extension)

### Opera
Expand All @@ -43,11 +43,11 @@ OR:
- cd into the repo directory
- run `npm install`
- run `npm install -g ember-cli`
- run `npm run build:chrome` to build the `dist_chrome` directory
- run `npm build` to build the `dist` directory
- Visit chrome://extensions in chrome
- Make sure `Developer mode` is checked
- Click on 'Load unpacked extension...'
- Choose the `dist_chrome` folder in the cloned repo
- Choose the `dist/chrome` folder in the cloned repo
- Close and re-open developer tools if it's already open


Expand All @@ -66,7 +66,7 @@ For development:
- create a bookmark (make sure you unblock the popup when you run the bookmarklet):

```javascript
javascript: (function() { var s = document.createElement('script'); s.src = 'http://localhost:9191/load_inspector.js'; document.body.appendChild(s); }());
javascript: (function() { var s = document.createElement('script'); s.src = 'http://localhost:9191/bookmarklet/load_inspector.js'; document.body.appendChild(s); }());
```


Expand All @@ -75,21 +75,20 @@ Building and Testing:

Run `npm install && npm install -g ember-cli && && npm install -g bower && bower install && npm install -g grunt-cli` to install the required modules.

- `npm run build:chrome` to build the files in the `dist_chrome` directory
- `npm run watch:chrome` To watch the files and re-build in `dist_chrome` when anything changes (useful during development).
- `npm run build:all` to build all the different `dist` directories
- `npm build` to build the files in the `dist` directory
- `npm run watch` To watch the files and re-build in `dist` when anything changes (useful during development).
- `npm test` To run the tests in the terminal
- `npm run build:xpi` to download and build Firefox Addon XPI into `tmp/xpi/ember-inspector.xpi`
- `npm run run-xpi` to run the Firefox Addon XPI on a temporary new profile (or use `FIREFOX_BIN` and `FIREFOX_PROFILE` to customize Firefox profile directory and Firefox binary used to run the extension)
- `npm start` To start the test server at `localhost:4200/tests`
- `npm start` To start the test server at `localhost:4200/testing/tests`


Deploy new version:
-----------

- Update `package.json` to new version and run `grunt version`
- `npm run build:all:production`
- Publish `dist_chrome/ember-inspector.zip` to the Chrome web store
- `npm run build:production`
- Publish `dist/chrome/ember-inspector.zip` to the Chrome web store
- Publish `tmp/xpi/ember-inspector.xpi` to the Mozilla Addons
- 'git checkout stable && git merge master' and push the `stable` branch (to update the bookmarklet)
- `npm publish ./`
Expand Down
4 changes: 4 additions & 0 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ App.initializer({
name: "extension-init",

initialize(container, app) {
// `window.EMBER_DIST` is set by dist-config.js
// which is created by the build process.
app.adapter = window.EMBER_DIST;

// register and inject adapter
let Adapter;
if (Ember.typeOf(app.adapter) === 'string') {
Expand Down
4 changes: 3 additions & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>EmberInspector</title>
<title>Ember Inspector</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

Expand All @@ -18,6 +18,8 @@
{{content-for 'body'}}

<script src="assets/vendor.js"></script>
<!-- File created by the build process -->
<script src="assets/dist-config.js"></script>
<script src="assets/ember-inspector.js"></script>

{{content-for 'body-footer'}}
Expand Down
1 change: 0 additions & 1 deletion config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ module.exports = function(environment) {
},

APP: {
adapter: (process.env.EMBER_DIST || 'basic')
// Here you can pass flags/options to your application instance
// when it is created
}
Expand Down
9 changes: 0 additions & 9 deletions lib/websocket-dist/index.js

This file was deleted.

7 changes: 0 additions & 7 deletions lib/websocket-dist/package.json

This file was deleted.

33 changes: 10 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,13 @@
"start": "ember server",
"build": "ember build",
"test": "ember test",
"build:chrome": "EMBER_DIST=chrome ember build --output-path dist_chrome/panes",
"build:firefox": "EMBER_DIST=firefox ember build --output-path dist_firefox/data/panes",
"build:bookmarklet": "EMBER_DIST=bookmarklet ember build --output-path dist_bookmarklet",
"build:websocket": "EMBER_DIST=websocket ember build --output-path dist_websocket",
"build:chrome:production": "npm run build:chrome -- --environment production && grunt compress:main ",
"build:firefox:production": "npm run build:firefox -- --environment production",
"build:bookmarklet:production": "npm run build:bookmarklet -- --environment production",
"build:websocket:production": "npm run build:websocket -- --environment production",
"watch:chrome": "npm run build:chrome -- --watch",
"watch:firefox": "npm run build:firefox -- --watch",
"watch:websocket": "npm run build:websocket -- --watch",
"serve:bookmarklet": "EMBER_DIST=bookmarklet ember serve --output-path dist_bookmarklet --port 9191",
"build:all": "npm run build:chrome && npm run build:firefox && npm run build:bookmarklet && npm run build:websocket",
"build:all:production": "npm run build:chrome:production && npm run build:xpi:production && npm run build:bookmarklet:production && npm run build:websocket:production",
"upload": "npm run build:bookmarklet:production && grunt s3:bookmarklet",
"run-xpi": "npm run build:firefox && grunt run-xpi",
"build:xpi": "npm run build:firefox && grunt build-xpi",
"build:xpi:production": "npm run build:firefox:production && grunt clean-tmp build-xpi"
"watch": "ember build --watch",
"serve:bookmarklet": "ember serve --port 9191",
"build:production": "ember build --environment production",
"upload": "npm build:production && grunt s3:bookmarklet",
"run-xpi": "npm build && grunt run-xpi",
"build:xpi": "npm build && grunt build-xpi",
"build:xpi:production": "npm run build:production && grunt clean-tmp build-xpi"
},
"repository": "https://github.com/emberjs/ember-inspector",
"engines": {
Expand All @@ -40,11 +29,14 @@
"broccoli-asset-rev": "^2.0.0",
"broccoli-concat": "0.0.12",
"broccoli-es6modules": "^0.5.1",
"broccoli-file-creator": "^0.1.0",
"broccoli-file-remover": "^0.3.1",
"broccoli-lint-eslint": "1.0.0",
"broccoli-merge-trees": "^0.2.1",
"broccoli-replace": "^0.3.1",
"broccoli-sass": "^0.6.1",
"broccoli-static-compiler": "^0.2.1",
"broccoli-stew": "^0.3.1",
"broccoli-wrap": "0.0.2",
"ember-cli": "0.2.0",
"ember-cli-app-version": "0.3.2",
Expand All @@ -69,11 +61,6 @@
"js-string-escape": "^1.0.0",
"list-view": "emberjs/list-view#aefb20f"
},
"ember-addon": {
"paths": [
"lib/websocket-dist"
]
},
"dependencies": {
"ember-new-computed": "^1.0.0"
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading