Skip to content

Commit

Permalink
feat(package): upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
zack9433 committed Jan 26, 2018
1 parent f6c9f9d commit a900d5e
Show file tree
Hide file tree
Showing 17 changed files with 3,792 additions and 2,073 deletions.
19 changes: 16 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
{
"presets": [
"es2015"
[
"env",
{
"modules": false,
"targets": {
"browsers": ["last 2 versions"]
}
}
]
],
"plugins": [
"lodash",
"transform-object-rest-spread"
"transform-object-rest-spread",
[
"angularjs-annotate",
{
"explicitOnly": true
}
]
],
"env": {
"test": {
Expand Down
49 changes: 21 additions & 28 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"parser": "babel-eslint",
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"extends": [
"kentcdodds/possible-errors",
"kentcdodds/es6/possible-errors",
"kentcdodds/es6/stylistic",
"kentcdodds/best-practices",
"prettier"
],
"plugins": ["prettier"],
"env": {
"es6": true,
"browser": true,
Expand All @@ -16,33 +18,24 @@
"angular": true,
"sinon": true,
"expect": true,
"Offline": true,
"__BASE_PATH__": true,
"__API_TOKEN__": true
"__API_TOKEN__": true,
"__VERSION__": true
},
"rules": {
"indent": [
"prettier/prettier": [
"error",
2,
{
"SwitchCase": 1
}
],
"quotes": [
2,
"single",
{
"avoidEscape": true,
"allowTemplateLiterals": true
"printWidth": 120,
"singleQuote": true,
"trailingComma": "none"
}
],
"linebreak-style": [
2,
"unix"
],
"semi": [
2,
"always"
],
"no-console": 0
"no-console": "off",
"complexity": "off",
"no-return-assign": "off",
"babel/object-curly-spacing": "off",
"babel/semi": "off"
}
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ npm-debug.log
demo
coverage/
.opt-in
dist/
41 changes: 28 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
sudo: false
sudo: required
language: node_js
node_js:
- "8"
addons:
chrome: stable
cache:
yarn: true
directories:
- ~/.yarn
- node_modules
notifications:
email: false
node_js:
- '6'
branches:
only:
- master
install:
- npm i
env:
global:
- YARN_VERSION=1.3.2

before_install:
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
- yarn global add greenkeeper-lockfile@1
- |
if [[ ! -e ~/.yarn/bin/yarn || $(yarn --version) != "${YARN_VERSION}" ]]; then
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version $YARN_VERSION
fi
before_script: greenkeeper-lockfile-update
after_script: greenkeeper-lockfile-upload
script:
- npm run build
after_success:
- npm run semantic-release
- yarn build
after_success:
- yarn travis-deploy-once "yarn semantic-release"
branches:
except:
- /^v\d+\.\d+\.\d+$/

30 changes: 8 additions & 22 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// Karma configuration
'use strict';

var webpackConfig = require('./webpack.test');
var test = process.env.NODE_ENV === 'test';
const webpackConfig = require('./webpack.test');
const test = process.env.NODE_ENV === 'test';

module.exports = function(config) {
config.set({
Expand Down Expand Up @@ -32,53 +29,42 @@ module.exports = function(config) {
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'chai', 'sinon-chai'],


// list of files / patterns to load in the browser
files: [
'src/app.test.js'
],

files: ['src/app.test.js'],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
// run the bundle through the webpack and sourcemap plugins
preprocessors: {
'src/app.test.js': [ 'webpack', 'sourcemap' ]
'src/app.test.js': ['webpack', 'sourcemap']
},


// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['spec', 'coverage'],


coverageReporter: {
reporters: [
{type: 'lcov', dir: 'coverage/', subdir: '.'},
{type: 'json', dir: 'coverage/', subdir: '.'},
{type: 'text-summary'}
{ type: 'lcov', dir: 'coverage/', subdir: '.' },
{ type: 'json', dir: 'coverage/', subdir: '.' },
{ type: 'text-summary' }
]
},


// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,


// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],

browsers: ['ChromeHeadless'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
Expand Down
20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sanji-cellular-ui",
"author": "Zack Yang <zack9433@gmail.com> (https://github.com/zack9433)",
"description": "Sanji cellualr UI",
"version": "3.6.4",
"version": "0.0.0-development",
"main": "index",
"config": {
"ghooks": {
Expand All @@ -13,11 +13,11 @@
}
},
"scripts": {
"validate": "npm run test:once && npm run check-coverage",
"start": "npm run mock:serve && npm run dev:serve",
"validate": "yarn test:once && yarn check-coverage",
"start": "yarn mock:serve && yarn dev:serve",
"dev:serve": "cross-env NODE_ENV=development node server/dev-server.js && kill $npm_package_config_mockserver",
"test": "cross-env NODE_ENV=test BABEL_ENV=test karma start",
"test:e2e": "npm run mock:serve && npm run protractor",
"test:e2e": "yarn mock:serve && yarn protractor",
"test:once": "cross-env BABEL_ENV=test karma start",
"protractor": "protractor protractor.conf.js && kill $npm_package_config_mockserver",
"mock:serve": "mockserver -I schema & npm config set sanji-cellular-ui:mockserver $!",
Expand All @@ -26,13 +26,15 @@
"commit": "git-cz",
"check-coverage": "istanbul check-coverage --statements 75 --branches 75 --functions 75 --lines 75",
"report-coverage": "cat ./coverage/lcov.info | codecov",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
"semantic-release": "semantic-release",
"travis-deploy-once": "travis-deploy-once"
},
"devDependencies": {
"angular-mocks": "~1.5.0",
"sanji-common-devs-ui": "~5.3.0",
"angular-mocks": "~1.6.8",
"sanji-common-devs-ui": "^7.0.0",
"sanji-openapi-mock": "github:sanji-io/sanji-openapi-mockserver",
"semantic-release": "^6.3.6"
"travis-deploy-once": "^4.3.3",
"semantic-release": "^12.2.5"
},
"repository": {
"type": "git",
Expand All @@ -47,6 +49,6 @@
"license": "MIT",
"homepage": "https://github.com/Sanji-IO/sanji-cellular-ui",
"dependencies": {
"sanji-core-ui": "^3.1.17"
"sanji-core-ui": "^4.0.0"
}
}
3 changes: 3 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
plugins: [require('autoprefixer')({ browsers: 'last 2 versions' })]
};
7 changes: 5 additions & 2 deletions src/component/component.i18n.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import EN from './lang/en.json';
import ZH_TW from './lang/zh-tw.json';

export default $translateProvider => {
'ngInject';
$translateProvider.translations('en', require('./lang/en.json'));
$translateProvider.translations('zh-tw', require('./lang/zh-tw.json'));
$translateProvider.translations('en', EN);
$translateProvider.translations('zh-tw', ZH_TW);
};
22 changes: 14 additions & 8 deletions src/component/component.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ class CellularService {

get() {
const toPath = this.pathToRegexp.compile(config.get.url);
return this.rest.get(toPath(), this.restConfig).then(res => this._transform(res.data)).catch(err => {
this.exception.catcher(this.$filter('translate')(this.message.read.error))(err);
return this.$q.reject();
});
return this.rest
.get(toPath(), this.restConfig)
.then(res => this._transform(res.data))
.catch(err => {
this.exception.catcher(this.$filter('translate')(this.message.read.error))(err);
return this.$q.reject();
});
}

update(data) {
Expand All @@ -59,10 +62,13 @@ class CellularService {
}

getCarrier(id) {
return this.rest.get(`/network/cellulars/${id}/firmware`, this.restConfig).then(res => res.data).catch(err => {
this.exception.catcher(this.$filter('translate')(this.message.read.error))(err);
return this.$q.reject();
});
return this.rest
.get(`/network/cellulars/${id}/firmware`, this.restConfig)
.then(res => res.data)
.catch(err => {
this.exception.catcher(this.$filter('translate')(this.message.read.error))(err);
return this.$q.reject();
});
}

setCarrier(id, data) {
Expand Down
19 changes: 10 additions & 9 deletions src/component/component.state.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,25 @@ export const CellularActions = ($q, cellularService) => {
//-------------------------------------------------------------------
// Reducers
//-------------------------------------------------------------------
export const cellulars = (state = [], { type, payload }) => {

const cellular = (state, { type, payload }) => {
switch (type) {
case GET_CELLULARS:
return payload || state;
case UPDATE_CELLULAR:
return state.map(data => cellular(data, { type, payload }));
if (state.content.id !== payload.content.id) {
return state;
}
return Object.assign({}, state, payload);
default:
return state;
}
};

const cellular = (state, { type, payload }) => {
export const cellulars = (state = [], { type, payload }) => {
switch (type) {
case GET_CELLULARS:
return payload || state;
case UPDATE_CELLULAR:
if (state.content.id !== payload.content.id) {
return state;
}
return Object.assign({}, state, payload);
return state.map(data => cellular(data, { type, payload }));
default:
return state;
}
Expand Down
2 changes: 1 addition & 1 deletion src/component/info/cellular-signal.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const $inject = [];
class CellularSignalController {
constructor(...injects) {
CellularSignalController.$inject.forEach((item, index) => this[item] = injects[index]);
CellularSignalController.$inject.forEach((item, index) => (this[item] = injects[index]));
}
}
CellularSignalController.$inject = $inject;
Expand Down
8 changes: 4 additions & 4 deletions src/component/info/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import './info.tpl.html';
import CellularInfoContainerComponent from './container.component';
import CellularInfoComponent from './info.component';

const sjCellularInfo = angular.module('sanji.cellular.info', [])
const sjCellularInfo = angular
.module('sanji.cellular.info', [])
.component('sanjiCellularInfoContainer', CellularInfoContainerComponent)
.component('sanjiCellularInfo', CellularInfoComponent)
.component('cellularSignal', CellularSignalComponent)
.name;
export {sjCellularInfo};
.component('cellularSignal', CellularSignalComponent).name;
export { sjCellularInfo };
Loading

0 comments on commit a900d5e

Please sign in to comment.