Skip to content

Commit

Permalink
Update to remove bower dependency (#91)
Browse files Browse the repository at this point in the history
* Update to remove bower dependency + Fastboot compatibility

* Update to remove bower dependency + Fastboot compatibility

* lock to 0.5.15 gmaps tag

* Rerun tests

* replace gmaps-for-apps github tag dependency with an npm module

* add travis wait to npm install to fix emberjs/data#5016

* move travis wait to build script and allow beta fail

* increase travis wait on build to 30 minutes for ember-lts-2.4
  • Loading branch information
devotox authored and Matt-Jensen committed Jul 8, 2017
1 parent ea5b525 commit 9212407
Show file tree
Hide file tree
Showing 34 changed files with 14,027 additions and 190 deletions.
4 changes: 0 additions & 4 deletions .bowerrc

This file was deleted.

18 changes: 18 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
},
extends: 'eslint:recommended',
env: {
browser: true
},
rules: {
'no-console': 0,
},
globals: {
google: false,
GMaps: false
}
};
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@
/coverage/*
/libpeerconnection.log
npm-debug.log*
yarn-error.log
testem.log

# ember-try
.node_modules.ember-try/
bower.json.ember-try
package.json.ember-try
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.editorconfig
.ember-cli
.gitignore
.jshintrc
.eslintrc.js
.watchmanconfig
.travis.yml
bower.json
Expand Down
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
---
language: node_js
node_js:
- "5"
- "6"

sudo: false

cache:
directories:
- $HOME/.npm
- $HOME/.cache # includes bowers cache

env:
# we recommend testing LTS's and latest stable release (bonus points to beta/canary)
Expand All @@ -17,24 +16,23 @@ env:
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default

matrix:
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-beta
- env: EMBER_TRY_SCENARIO=ember-canary

before_install:
- npm config set spin false
- npm install -g bower
- bower --version
- npm install phantomjs-prebuilt
- node_modules/phantomjs-prebuilt/bin/phantomjs --version
- npm install -g phantomjs-prebuilt
- phantomjs --version

install:
- npm install
- bower install

script:
# Usually, it's ok to finish the test scenario without reverting
# to the addon's original dependency state, skipping "cleanup".
- ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup
- travis_wait 30 node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup
2 changes: 1 addition & 1 deletion addon/utils/load-google-maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default (function () {
* Resolve available global google.maps
*/

if (typeof google === 'object' && typeof google.maps === 'object') {
if (typeof window.google === 'object' && typeof window.google.maps === 'object') {
return RSVP.Promise.resolve(window.google.maps); // Google maps is loaded
}

Expand Down
6 changes: 0 additions & 6 deletions blueprints/.jshintrc

This file was deleted.

16 changes: 0 additions & 16 deletions blueprints/ember-cli-g-maps/index.js

This file was deleted.

10 changes: 0 additions & 10 deletions bower.json

This file was deleted.

33 changes: 32 additions & 1 deletion config/ember-try.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*jshint node:true*/
/* eslint-env node */
module.exports = {
scenarios: [
{
Expand All @@ -10,6 +10,11 @@ module.exports = {
resolutions: {
'ember': 'lts-2-4'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
Expand All @@ -21,6 +26,11 @@ module.exports = {
resolutions: {
'ember': 'lts-2-8'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
Expand All @@ -32,6 +42,11 @@ module.exports = {
resolutions: {
'ember': 'release'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
Expand All @@ -43,6 +58,11 @@ module.exports = {
resolutions: {
'ember': 'beta'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
Expand All @@ -54,6 +74,17 @@ module.exports = {
resolutions: {
'ember': 'canary'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
name: 'ember-default',
npm: {
devDependencies: {}
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion config/environment.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*jshint node:true*/
/* eslint-env node */
'use strict';

module.exports = function(/* environment, appConfig */) {
Expand Down
14 changes: 9 additions & 5 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
/*jshint node:true*/
/* global require, module */
var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
/* eslint-env node */
const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function(defaults) {
var app = new EmberAddon(defaults, {
let app = new EmberAddon(defaults, {
autoprefixer: {
browsers: ['last 2 versions']
},

babel: {
optional: ['es6.spec.symbols'],
includePolyfill: true
},

'ember-cli-babel': {
compileModules: true,
includePolyfill: true,
disableDebugTooling: true
}
});

Expand Down
59 changes: 32 additions & 27 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
/* jshint node: true */
/* global process */
'use strict';

const path = require('path');
const Funnel = require('broccoli-funnel');
const assert = require('assert');
const MergeTrees = require('broccoli-merge-trees');
const map = require('broccoli-stew').map;
const debug = require('broccoli-stew').debug;
const fastbootTransform = require('fastboot-transform');

module.exports = {
name: 'ember-cli-g-maps',

included(app) {
this._super.included.apply(this, arguments);

// see: https://github.com/ember-cli/ember-cli/issues/3718
if (typeof app.import !== 'function' && app.app) {
app = app.app;
options: {
nodeAssets: {
'gmaps-for-apps': {
vendor: {
srcDir: '',
include: ['gmaps.js'],
processTree(input) {
return fastbootTransform(input);
}
}
}
}

app.import('vendor/gmaps.js');
},

treeForVendor(vendorNode) {
const deps = this.project.bowerDependencies();
assert(deps['gmaps-for-apps'], 'ember-cli-g-maps requires bower dependency `gmaps-for-apps`');

let trees = [];
let gmapsNode = new Funnel(path.join(this.app.project.root, this.app.bowerDirectory, 'gmaps-for-apps'), {
files: ['gmaps.js']
});
included() {
this._super.included.apply(this, arguments);
this._ensureThisImport();

if (vendorNode) {
trees.push(vendorNode);
this.import('vendor/gmaps-for-apps/gmaps.js');
},
_ensureThisImport() {
if (!this.import) {
this._findHost = function findHostShim() {
let current = this;
let app;

do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
return app;
};
this.import = function importShim(asset, options) {
let app = this._findHost();
app.import(asset, options);
};
}

trees.push(map(gmapsNode, (content) => `if (typeof FastBoot === 'undefined') { ${content} }`));
return new MergeTrees(trees);
},

// Request Google Maps script in consuming app
Expand Down
Loading

0 comments on commit 9212407

Please sign in to comment.