Skip to content

Upgrade cachefactory #243

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
28 changes: 22 additions & 6 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,49 @@ module.exports = function (config) {
frameworks: ['mocha', 'chai', 'sinon'],
browsers: ['PhantomJS'],
files: [
'node_modules/es6-promise/dist/es6-promise.auto.js',
'node_modules/angular/angular.js',
'node_modules/angular-resource/angular-resource.js',
'node_modules/angular-mocks/angular-mocks.js',
'dist/angular-cache.js',
'./karma.start.js',
'node_modules/cachefactory/dist/cachefactory.es2015.js',
'src/index.js',
'test/_setup.js',
'test/**/*.js'
],
captureTimeout: 60000,
captureTimeout: 60 * 1000,
colors: true,
logLevel: config.LOG_INFO,
port: 9876,
plugins: [
'karma-sourcemap-loader',
'karma-babel-preprocessor',
'karma-chrome-launcher',
'karma-phantomjs-launcher',
'karma-mocha',
'karma-chai',
'karma-sinon',
'karma-coverage'
],
runnerPort: 9100,
singleRun: true,
autoWatch: false,
singleRun: false,
autoWatch: true,
coverageReporter: {
type: 'lcov',
dir: 'coverage/'
},
preprocessors: {
'dist/angular-cache.js': ['coverage']
'node_modules/cachefactory/dist/cachefactory.es2015.js': ['babel'],
'src/index.js': ['babel', /*'coverage',*/ 'sourcemap'],
'test/**/*.js': ['babel', 'sourcemap']
},
babelPreprocessor: {
options: {
presets: ['es2015'],
plugins: [
'transform-es2015-modules-umd'
],
sourceMap: 'inline'
}
},
reporters: ['progress', 'coverage']
})
Expand Down
98 changes: 0 additions & 98 deletions karma.start.js

This file was deleted.

48 changes: 23 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@
"angular"
]
},
"babel": {
"presets": [
"es2015"
]
},
"scripts": {
"lint": "standard src/*.js *.js",
"lint": "standard 'src/**/*.js'",
"bundle": "rollup src/index.js -c -o dist/angular-cache.js -m dist/angular-cache.js.map -f umd && node scripts/postbuild",
"min": "uglifyjs dist/angular-cache.js -o dist/angular-cache.min.js --source-map dist/angular-cache.min.map --source-map-url angular-cache.min.map -v -m -c",
"build": "npm run lint && npm run bundle && npm run min",
Expand All @@ -43,30 +38,33 @@
"ci": "npm test && cat ./coverage/PhantomJS*/lcov.info | codecov"
},
"devDependencies": {
"angular": "1.5.8",
"angular-mocks": "1.5.8",
"angular-resource": "1.5.8",
"babel-core": "6.14.0",
"babel-eslint": "6.1.2",
"babel-preset-es2015": "6.14.0",
"babel-preset-es2015-rollup": "1.2.0",
"cachefactory": "1.5.1",
"angular": "1.6.2",
"angular-mocks": "1.6.2",
"angular-resource": "1.6.2",
"babel-core": "6.23.1",
"babel-eslint": "7.1.1",
"babel-plugin-transform-es2015-modules-umd": "6.23.0",
"babel-preset-es2015": "6.22.0",
"cachefactory": "3.0.0",
"chai": "3.5.0",
"codecov": "1.0.1",
"es6-promise": "3.2.1",
"karma": "1.2.0",
"es6-promise": "4.0.5",
"karma": "1.5.0",
"karma-babel-preprocessor": "6.0.1",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "1.1.1",
"karma-mocha": "1.1.1",
"karma-phantomjs-launcher": "1.0.1",
"karma-mocha": "1.3.0",
"karma-phantomjs-launcher": "1.0.2",
"karma-sinon": "1.0.5",
"mocha": "3.0.2",
"phantomjs-prebuilt": "2.1.12",
"rollup": "0.34.10",
"rollup-plugin-babel": "2.6.1",
"sinon": "1.17.5",
"standard": "8.0.0",
"uglify-js": "2.7.3"
"karma-sourcemap-loader": "0.3.7",
"mocha": "3.2.0",
"phantomjs-prebuilt": "2.1.14",
"rollup": "0.41.4",
"rollup-plugin-babel": "2.7.1",
"sinon": "1.17.7",
"standard": "8.6.0",
"uglify-js": "2.7.5"
},
"peerDependencies": {
"angular": ">=1.x <2"
Expand Down
18 changes: 15 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,31 @@ var pkg = require('./package.json')
module.exports = {
moduleName: 'angularCacheModuleName',
moduleId: 'angular-cache',
external: [
'angular'
],
globals: {
angular: 'angular'
},
banner: '/**\n' +
' * angular-cache\n' +
' * @version ' + pkg.version + ' - Homepage <https://github.com/jmdobry/angular-cache>\n' +
' * @copyright (c) 2013-2016 angular-cache project authors\n' +
' * @copyright (c) 2013-2017 angular-cache project authors\n' +
' * @license MIT <https://github.com/jmdobry/angular-cache/blob/master/LICENSE>\n' +
' * @overview angular-cache is a very useful replacement for Angular\'s $cacheFactory.\n' +
' */',
plugins: [
babel({
babelrc: false,
presets: [
'es2015-rollup'
]
[
'es2015',
{
modules: false
}
]
],
exclude: 'node_modules/**'
})
]
}
20 changes: 10 additions & 10 deletions scripts/postbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ file = file.replace(
'module.exports = factory(require(\'angular\'))',
'module.exports = factory(typeof angular === \'undefined\' ? require(\'angular\') : angular)'
)
var index = file.indexOf('babelHelpers;')
var str = 'var babelHelpers = {};\n' +
' babelHelpers.typeof = typeof Symbol === "function" && babelHelpers.typeof(Symbol.iterator) === "symbol" ? function (obj) {\n' +
' return typeof obj === "undefined" ? "undefined" : babelHelpers.typeof(obj);\n' +
' } : function (obj) {\n' +
' return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj === "undefined" ? "undefined" : babelHelpers.typeof(obj);\n' +
' };'
// var index = file.indexOf('babelHelpers;')
// var str = 'var babelHelpers = {};\n' +
// ' babelHelpers.typeof = typeof Symbol === "function" && babelHelpers.typeof(Symbol.iterator) === "symbol" ? function (obj) {\n' +
// ' return typeof obj === "undefined" ? "undefined" : babelHelpers.typeof(obj);\n' +
// ' } : function (obj) {\n' +
// ' return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj === "undefined" ? "undefined" : babelHelpers.typeof(obj);\n' +
// ' };'

var index2 = file.indexOf(str)
// var index2 = file.indexOf(str)

var file2 = file.substring(index2 + str.length)
file = file.substring(0, index) + file2
// var file2 = file.substring(index2 + str.length)
// file = file.substring(0, index) + file2

fs.writeFileSync(path, file)
25 changes: 17 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
import angular from 'angular'
import CacheFactory from '../node_modules/cachefactory/dist/cachefactory.es2015'
import {
BinaryHeap,
CacheFactory,
defaults,
utils
} from '../node_modules/cachefactory/dist/cachefactory.es2015.js'

CacheFactory.utils.equals = angular.equals
CacheFactory.utils.isObject = angular.isObject
CacheFactory.utils.fromJson = angular.fromJson
utils.equals = angular.equals
utils.isObject = angular.isObject
utils.fromJson = angular.fromJson

function BinaryHeapProvider () {
this.$get = function () { return CacheFactory.BinaryHeap }
this.$get = function () { return BinaryHeap }
}

function CacheFactoryProvider () {
this.defaults = CacheFactory.defaults
this.defaults = defaults
this.defaults.storagePrefix = 'angular-cache.caches.'

this.$get = ['$q', function ($q) {
CacheFactory.utils.Promise = $q
return CacheFactory
utils.Promise = $q
var cacheFactory = new CacheFactory()
Object.defineProperty(cacheFactory, 'defaults', {
value: defaults
})
return cacheFactory
}]
}

Expand Down
Loading