Skip to content

Commit

Permalink
Update packages and remove dependency from broccoli-webfont
Browse files Browse the repository at this point in the history
https://github.com/sunflowerdeath/broccoli-webfont is no longer active
Use new broccoli-caching-writer to resolve deprecation warnings



Revert repository name
  • Loading branch information
lsg-braymon committed Aug 7, 2018
1 parent ffb2378 commit d1604ad
Show file tree
Hide file tree
Showing 4 changed files with 767 additions and 189 deletions.
24 changes: 12 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

var Funnel = require('broccoli-funnel');
var merge = require('merge');
var mergeTrees = require('broccoli-merge-trees');
var webfont = require('broccoli-webfont');
var MergeTrees = require('broccoli-merge-trees');
var Webfont = require('./utils/webfont');

module.exports = {
name: 'ember-cli-webfont',
Expand All @@ -15,7 +15,7 @@ module.exports = {
dest: 'assets/webfonts/',
fontName: 'iconfont',
cssFontsUrl: 'webfonts/',
cssTemplate: webfont.templates.css,
cssTemplate: Webfont.templates.css,
templateOptions: {
classPrefix: 'iconfont-',
baseSelector: 'iconfont'
Expand All @@ -32,14 +32,13 @@ module.exports = {
},

treeForStyles: function() {
var path = this.webfontPath();
const path = new Funnel(this.webfontPath(), { include: this.options().files });
var options = merge(true, {
css: true,
cssDest: 'temp/ember-cli-webfont.css'
}, this.options());
var cssTree = webfont(path, options);

cssTree = new Funnel(cssTree, {
const webfont = new Webfont([path], options);
const cssTree = new Funnel(webfont, {
include: [new RegExp(/\.css$/)]
});

Expand All @@ -51,14 +50,15 @@ module.exports = {
if (!this.isDevelopingAddon()) {
dummyWatchDir = 'node_modules/ember-cli-webfont/' + dummyWatchDir;
}
return mergeTrees([dummyWatchDir, cssTree], { overwrite: true });
return new MergeTrees([dummyWatchDir, cssTree], { overwrite: true });
},

treeForPublic: function() {
var path = this.webfontPath();
var options = merge(true, { css:false }, this.options());
var fontTree = webfont(path, options);
return fontTree;
const path = new Funnel(this.webfontPath(), { include: this.options().files });
const options = merge(true, { css: false }, this.options());
const webfont = new Webfont([path], options);

return webfont;
},

included: function(app) {
Expand Down
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"doc": "doc",
"test": "tests"
},
"repository": "https://github.com/lightspeedgraphics/ember-cli-webfont.git",
"repository": "https://github.com/vitch/ember-cli-webfont.git",
"scripts": {
"build": "ember build",
"lint:js": "eslint ./*.js addon addon-test-support app config lib server test-support tests",
Expand All @@ -24,16 +24,20 @@
"test:all": "ember try:each"
},
"dependencies": {
"broccoli-funnel": "^1.0.0",
"broccoli-merge-trees": "^1.0.0",
"broccoli-webfont": "https://github.com/lightspeedgraphics/broccoli-webfont.git",
"broccoli": "1.1.4",
"broccoli-caching-writer": "^3.0.3",
"broccoli-funnel": "^2.0.1",
"broccoli-merge-trees": "^3.0.0",
"dirmatch": "^0.1.2",
"ember-cli-babel": "^6.6.0",
"merge": "^1.2.0"
"merge": "^1.2.0",
"underscore": "^1.9.1",
"webfonts-generator": "^0.4.0"
},
"devDependencies": {
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "^3.0.0",
"ember-cli": "~3.1.2",
"ember-cli": "~3.3.0",
"ember-cli-dependency-checker": "^2.0.0",
"ember-cli-eslint": "^4.2.1",
"ember-cli-htmlbars": "^2.0.1",
Expand Down
48 changes: 48 additions & 0 deletions utils/webfont/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict';

const Plugin = require('broccoli-caching-writer')
const webfontsGenerator = require('webfonts-generator');
const path = require('path');
const dirmatch = require('dirmatch');
const _ = require('underscore');

Webfont.prototype = Object.create(Plugin.prototype);
Webfont.prototype.constructor = Webfont;
function Webfont(inputNodes, options) {
options = options || {};
Plugin.call(this, inputNodes, {
annotation: options.annotation
});
this.options = options;
}

Webfont.prototype.build = function() {
const inputPath = this.inputPaths[0];

const files = dirmatch(inputPath, this.options.files);
const absFiles = _.map(files, function(file) {
return path.join(inputPath, file);
})

const webfontsOptions = _.extend({}, this.options);
webfontsOptions.files = absFiles;

_.each(['dest', 'cssDest', 'htmlDest'], function(option) {
let value = this.options[option];
if (value !== undefined) webfontsOptions[option] = path.join(this.outputPath, value);
}, this)

return new Promise(function(resolve, reject) {
webfontsGenerator(webfontsOptions, function(error, result) {
if (error) {
reject(error);
} else {
resolve(result);
}
});
});
}

Webfont.templates = webfontsGenerator.templates;

module.exports = Webfont;
Loading

0 comments on commit d1604ad

Please sign in to comment.