Skip to content

Commit 680d009

Browse files
author
Sassoun Derderian
committed
refactor: Replace Browserify to Webpack, code in Typescript
1 parent 9f0f60a commit 680d009

19 files changed

Lines changed: 398 additions & 172 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ coverage
1212

1313
# generated API docs
1414
docs
15+
16+
# dist
17+
dist

.travis.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
language: node_js
2-
32
sudo: false
4-
53
notifications:
64
email:
75
on_failure: always
86
on_success: change
9-
107
node_js:
11-
- "4.2"
12-
- "0.12"
13-
- "0.10"
8+
- '4'
9+
- '6'
10+
script: npm run ci-test
11+
addons:
12+
sauce_connect: true
13+
env:
14+
global:
15+
- secure: Zmndw3YPp7JUPHRWfzF6ieqwDqWs4GnKMqXNaPNCcY1D76rH2CGTe6YQHhvNEgIm5UItH39x306TMWjqZfCFUVpAks8AQEigADAMPbgqLg8JG4QVIb1sQiZPiVHJA5Ho6YNB4hqv3fp+D9DWRDIMiLYmWiRD8/hFaow/xkfMyiA=
16+
- secure: jdw+OA04vF8+t+iOkWRfDWexKGVxrjpt8iwkY/CBnmANFQckseLwVrDJyHrjcxQlY7SlkSudMNXizINKJDldPx4BBlt1I6n7441CYQ2KpRqzAQXgLPWy+Ea/lM2QcSfihG/xC8Q30CVfMUTZTZx/6nUlIoeB2eItzy9+KsE9UaU=

bower.json

Lines changed: 0 additions & 36 deletions
This file was deleted.

dist/workfront.js

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/login/exception.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"error":{"class":"com.attask.common.AuthenticationException","message":"That username\/password combination wasn't quite right. Make sure your caps lock isn't on and try again."}}

fixtures/login/successful.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"data":{"userID":"5461d7620000029e306908fbf1a469fe","sessionID":"f6533722f8a44a298065950f240d3deb","versionInformation":{"currentAPI":"v6.0","buildNumber":"","apiVersions":{"v1.0":"\/attask\/api\/v1.0\/","v2.0":"\/attask\/api\/v2.0\/","v3.0":"\/attask\/api\/v3.0\/","v4.0":"\/attask\/api\/v4.0\/","v5.0":"\/attask\/api\/v5.0\/","v6.0":"\/attask\/api\/v6.0\/"},"lastUpdated":"2017\/03\/07 17:53:19","release":"R16","version":"4.0"},"locale":"en_US","timeZone":"W-SU","timeZoneName":"Moscow Standard Time","iso3Country":"USA","iso3Language":"eng","currency":{"useNegativeSign":false,"fractionDigits":2,"symbol":"$","ID":"USD","groupingSeparator":",","decimalSeparator":"."}}}

karma-ci.conf.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
'use strict'
2+
3+
const karmaConfig = require('./karma.conf');
4+
5+
module.exports = function (config) {
6+
karmaConfig(config)
7+
8+
// Browsers to run on Sauce Labs
9+
const customLaunchers = {
10+
'SL_Chrome': {
11+
base: 'SauceLabs',
12+
browserName: 'chrome',
13+
version: '48.0',
14+
platform: 'Linux'
15+
},
16+
'SL_Firefox': {
17+
base: 'SauceLabs',
18+
browserName: 'firefox',
19+
version: '50.0',
20+
platform: 'Windows 10'
21+
},
22+
'SL_InternetExplorer': {
23+
base: 'SauceLabs',
24+
browserName: 'internet explorer',
25+
version: '11.0',
26+
platform: 'Windows 7'
27+
},
28+
'SL_Safari': {
29+
base: 'SauceLabs',
30+
browserName: 'safari',
31+
platform: 'OS X 10.11',
32+
version: '10.0'
33+
}
34+
};
35+
36+
// Override config for CI.
37+
config.set({
38+
reporters: ['spec', 'coverage', 'saucelabs'],
39+
sauceLabs: {
40+
testName: 'Karma and Sauce Labs demo'
41+
},
42+
captureTimeout: 120000,
43+
customLaunchers: customLaunchers,
44+
45+
// start these browsers
46+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
47+
browsers: Object.keys(customLaunchers),
48+
singleRun: true
49+
})
50+
51+
}

karma.conf.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
'use strict'
2+
3+
const webpackConfig = require('./webpack.config')
4+
webpackConfig.devtool = 'inline-source-map'
5+
6+
webpackConfig.resolve.alias = webpackConfig.resolve.alias || {}
7+
8+
// Conditional requires workaround (https://github.com/sinonjs/sinon/issues/830)
9+
webpackConfig.resolve.alias.sinon ='sinon/pkg/sinon'
10+
11+
webpackConfig.module.rules = webpackConfig.module.rules || []
12+
webpackConfig.module.rules.push({
13+
test: /\.[tj]s$/,
14+
enforce: 'post',
15+
exclude: /(test-bundle\.js|\.spec|node_modules|mock|\.mock|\.stub)/,
16+
use: {
17+
loader: 'istanbul-instrumenter-loader',
18+
options: {
19+
esModules: true,
20+
produceSourceMap: true
21+
}
22+
}
23+
})
24+
25+
// override compiler options for "ts-loader"
26+
webpackConfig.module.rules.forEach(function(rule) {
27+
if (Array.isArray(rule.use)) {
28+
rule.use.forEach(function(loaderInfo) {
29+
if (loaderInfo.loader === 'awesome-typescript-loader') {
30+
loaderInfo.options = loaderInfo.options || {}
31+
loaderInfo.options.compilerOptions = {
32+
sourceMap: false,
33+
inlineSourceMap: true
34+
}
35+
}
36+
})
37+
}
38+
})
39+
40+
webpackConfig.externals = [
41+
]
42+
43+
module.exports = function (config) {
44+
config.set({
45+
46+
// base path that will be used to resolve all patterns (eg. files, exclude)
47+
basePath: '',
48+
49+
// frameworks to use
50+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
51+
frameworks: ['mocha'],
52+
53+
// list of files / patterns to load in the browser
54+
files: [
55+
'test/test-bundle.js'
56+
],
57+
58+
proxies: {
59+
//TODO Make sure to list proxies for requests to server which you can't mock here
60+
//NOTE The path part '/base/' points to root folder of the package.
61+
//NOTE The common case is to sent clear.cache.gif instead of image.
62+
//'/user/avatar': '/base/mock/clear.cache.gif'
63+
},
64+
65+
preprocessors: {
66+
'test/test-bundle.js': ['webpack', 'sourcemap']
67+
},
68+
69+
webpack: webpackConfig,
70+
71+
// level of logging
72+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
73+
logLevel: config.LOG_INFO,
74+
75+
reporters: ['progress', 'coverage', 'remap-coverage'],
76+
77+
coverageReporter: {
78+
type: 'in-memory'
79+
},
80+
81+
remapOptions: {
82+
warn: function() {}
83+
},
84+
remapCoverageReporter: {
85+
'text-summary': null, // to show summary in console
86+
html: './coverage'
87+
},
88+
89+
port: 9876,
90+
colors: true,
91+
autoWatch: false,
92+
browsers: ['Chrome'],
93+
singleRun: false
94+
})
95+
}

package.json

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@
1010
"workfront-api-constants": "1.0.4"
1111
},
1212
"devDependencies": {
13+
"@types/mocha": "2.2.39",
14+
"@types/node": "7.0.8",
15+
"@types/should": "8.1.30",
16+
"@types/sinon": "1.16.35",
1317
"awesome-typescript-loader": "3.0.8",
14-
"browserify": "13.0.1",
15-
"chai": "3.5.0",
16-
"chai-as-promised": "5.3.0",
18+
"codecov": "1.0.1",
1719
"dateformat": "1.0.12",
1820
"del": "1.2.1",
21+
"fetch-mock": "5.9.4",
1922
"gulp": "3.9.1",
2023
"gulp-coveralls": "0.1.4",
2124
"gulp-help": "1.6.1",
@@ -25,22 +28,36 @@
2528
"gulp-rename": "1.2.2",
2629
"gulp-uglify": "1.5.3",
2730
"http-server": "0.9.0",
28-
"nock": "8.0.0",
31+
"istanbul-instrumenter-loader": "2.0.0",
32+
"karma": "1.5.0",
33+
"karma-chrome-launcher": "2.0.0",
34+
"karma-cli": "1.0.1",
35+
"karma-coverage": "1.1.1",
36+
"karma-mocha": "1.3.0",
37+
"karma-remap-coverage": "0.1.4",
38+
"karma-sauce-launcher": "1.1.0",
39+
"karma-sourcemap-loader": "0.3.7",
40+
"karma-spec-reporter": "0.0.30",
41+
"karma-webpack": "2.0.2",
42+
"mocha": "3.2.0",
2943
"semver": "5.1.0",
3044
"shelljs": "0.5.3",
45+
"should": "11.2.1",
46+
"should-http": "0.1.0",
47+
"should-spies": "1.1.0",
3148
"sinon": "^1.12.2",
32-
"sinon-as-promised": "4.0.0",
33-
"sinon-chai": "2.8.0",
3449
"source-map-loader": "0.1.6",
3550
"tslint": "4.5.1",
3651
"tslint-loader": "3.4.3",
52+
"typedoc": "0.5.7",
3753
"typescript": "2.2.1",
3854
"vinyl-buffer": "1.0.0",
3955
"vinyl-source-stream": "1.1.0",
4056
"webpack": "2.2.1"
4157
},
4258
"scripts": {
43-
"test": "gulp test-ci",
59+
"test": "karma start karma.conf.js",
60+
"ci-test": "karma start karma-ci.conf.js",
4461
"build": "gulp build",
4562
"update-online-docs": "gulp publish-docs",
4663
"prepublish": "npm run build",

0 commit comments

Comments
 (0)