Skip to content

Commit 2e94bab

Browse files
committed
chore: initial commit, contains the whole skeleton of the library
1 parent 6e7d78e commit 2e94bab

20 files changed

+8166
-0
lines changed

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 4
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
.idea/
2+
.DS_Store
3+
node_modules/
4+
coverage/
5+
npm-debug.log
6+
dist/
7+
*.js
8+
*.js.map
9+
!/scripts/map-sources.js
10+
!/karma.conf.js
11+
!/rollup.config.js
12+
!/spec.bundle.js
13+
!/build.js
14+
15+
116
# Logs
217
logs
318
*.log

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-prefix=^

.travis.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
sudo: required
2+
3+
dist: trusty
4+
5+
addons:
6+
apt:
7+
sources:
8+
- google-chrome
9+
packages:
10+
- google-chrome-stable
11+
12+
language: node_js
13+
14+
node_js:
15+
- stable
16+
17+
before_install:
18+
- npm i npm@^4 -g
19+
20+
install:
21+
- npm install
22+
23+
script:
24+
- npm test
25+
- npm run build
26+
27+
before_script:
28+
- export DISPLAY=:99.0
29+
- sh -e /etc/init.d/xvfb start
30+
- sleep 3
31+
32+
notifications:
33+
email: false
34+
35+
after_success:
36+
- npm run codecov

build.js

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
"use strict";
2+
3+
const shell = require('shelljs');
4+
const chalk = require('chalk');
5+
6+
const PACKAGE = `xivapi-client`;
7+
const NPM_DIR = `dist`;
8+
const MODULES_DIR = `${NPM_DIR}/modules`;
9+
const BUNDLES_DIR = `${NPM_DIR}/bundles`;
10+
11+
shell.echo(`Start building...`);
12+
13+
shell.rm(`-Rf`, `${NPM_DIR}/*`);
14+
shell.mkdir(`-p`, `./${MODULES_DIR}`);
15+
shell.mkdir(`-p`, `./${BUNDLES_DIR}`);
16+
17+
/* TSLint with Codelyzer */
18+
// https://github.com/palantir/tslint/blob/master/src/configs/recommended.ts
19+
// https://github.com/mgechev/codelyzer
20+
shell.echo(`Start TSLint`);
21+
shell.exec(`tslint -c tslint.json -t stylish src/**/*.ts`);
22+
shell.echo(chalk.green(`TSLint completed`));
23+
24+
/* AoT compilation: ES2015 sources */
25+
shell.echo(`Start AoT compilation`);
26+
if (shell.exec(`ngc -p tsconfig-build.json`).code !== 0) {
27+
shell.echo(chalk.red(`Error: AoT compilation failed`));
28+
shell.exit(1);
29+
}
30+
shell.echo(chalk.green(`AoT compilation completed`));
31+
32+
/* Creates bundles: ESM/ES5 and UMD bundles */
33+
shell.echo(`Start bundling`);
34+
shell.echo(`Rollup package`);
35+
shell.exec(`rollup -i ${NPM_DIR}/${PACKAGE}.js -o ${MODULES_DIR}/${PACKAGE}.js --sourcemap`, { silent: true });
36+
shell.exec(`node scripts/map-sources -f ${MODULES_DIR}/${PACKAGE}.js`);
37+
38+
shell.echo(`Downleveling ES2015 to ESM/ES5`);
39+
shell.cp(`${MODULES_DIR}/${PACKAGE}.js`, `${MODULES_DIR}/${PACKAGE}.es5.ts`);
40+
shell.exec(`tsc ${MODULES_DIR}/${PACKAGE}.es5.ts --target es5 --module es2015 --noLib --sourceMap`, { silent: true });
41+
shell.exec(`node scripts/map-sources -f ${MODULES_DIR}/${PACKAGE}.es5.js`);
42+
shell.rm(`-f`, `${MODULES_DIR}/${PACKAGE}.es5.ts`);
43+
44+
shell.echo(`Run Rollup conversion on package`);
45+
if (shell.exec(`rollup -c rollup.config.js --sourcemap`).code !== 0) {
46+
shell.echo(chalk.red(`Error: Rollup conversion failed`));
47+
shell.exit(1);
48+
}
49+
shell.exec(`node scripts/map-sources -f ${BUNDLES_DIR}/${PACKAGE}.umd.js`);
50+
51+
shell.echo(`Minifying`);
52+
shell.cd(`${BUNDLES_DIR}`);
53+
shell.exec(`uglifyjs -c warnings=false --screw-ie8 --comments -o ${PACKAGE}.umd.min.js --source-map ${PACKAGE}.umd.min.js.map --source-map-include-sources ${PACKAGE}.umd.js`);
54+
shell.exec(`node ../../scripts/map-sources -f ${PACKAGE}.umd.min.js`);
55+
shell.cd(`..`);
56+
shell.cd(`..`);
57+
58+
shell.echo(chalk.green(`Bundling completed`));
59+
60+
shell.rm(`-Rf`, `${NPM_DIR}/*.js`);
61+
shell.rm(`-Rf`, `${NPM_DIR}/*.js.map`);
62+
shell.rm(`-Rf`, `${NPM_DIR}/src/**/*.js`);
63+
shell.rm(`-Rf`, `${NPM_DIR}/src/**/*.js.map`);
64+
65+
shell.cp(`-Rf`, [`package.json`, `LICENSE`, `README.md`], `${NPM_DIR}`);
66+
67+
shell.echo(chalk.green(`End building`));

index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './public_api';

karma.conf.js

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// Karma configuration for Unit testing
2+
3+
module.exports = function (config) {
4+
5+
const configuration = {
6+
7+
// base path that will be used to resolve all patterns (eg. files, exclude)
8+
basePath: '',
9+
10+
// frameworks to use
11+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
12+
frameworks: ['jasmine'],
13+
14+
plugins: [
15+
require('karma-jasmine'),
16+
require('karma-chrome-launcher'),
17+
require('karma-webpack'),
18+
require('karma-sourcemap-loader'),
19+
require('karma-spec-reporter'),
20+
require('karma-coverage-istanbul-reporter')
21+
],
22+
23+
// list of files / patterns to load in the browser
24+
files: [
25+
{ pattern: 'spec.bundle.js', watched: false }
26+
],
27+
28+
// list of files to exclude
29+
exclude: [
30+
],
31+
32+
// preprocess matching files before serving them to the browser
33+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
34+
preprocessors: {
35+
'spec.bundle.js': ['webpack', 'sourcemap']
36+
},
37+
38+
// webpack
39+
webpack: {
40+
resolve: {
41+
extensions: ['.ts', '.js']
42+
},
43+
module: {
44+
rules: [
45+
{
46+
test: /\.ts$/,
47+
loader: 'tslint-loader',
48+
exclude: /node_modules/,
49+
enforce: 'pre',
50+
options: {
51+
emitErrors: config.singleRun,
52+
failOnHint: config.singleRun
53+
}
54+
}, {
55+
test: /\.ts/,
56+
loaders: ['ts-loader', 'source-map-loader'],
57+
exclude: /node_modules/
58+
}, {
59+
test: /src[\\\/].+\.ts$/,
60+
exclude: /(node_modules|\.spec\.ts$)/,
61+
loader: 'istanbul-instrumenter-loader',
62+
enforce: 'post'
63+
}
64+
],
65+
exprContextCritical: false
66+
},
67+
devtool: 'inline-source-map',
68+
performance: { hints: false }
69+
},
70+
71+
webpackServer: {
72+
noInfo: true
73+
},
74+
75+
coverageIstanbulReporter: {
76+
reports: ['text-summary', 'html', 'lcovonly'],
77+
fixWebpackSourcePaths: true
78+
},
79+
80+
// test results reporter to use
81+
// possible values: 'dots', 'progress'
82+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
83+
reporters: ['spec', 'coverage-istanbul'],
84+
85+
86+
// web server port
87+
port: 9876,
88+
89+
90+
// enable / disable colors in the output (reporters and logs)
91+
colors: true,
92+
93+
94+
// level of logging
95+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
96+
logLevel: config.LOG_INFO,
97+
98+
99+
// enable / disable watching file and executing tests whenever any file changes
100+
autoWatch: true,
101+
102+
103+
// start these browsers
104+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
105+
browsers: ['Chrome'],
106+
107+
108+
// Continuous Integration mode
109+
// if true, Karma captures browsers, runs the tests and exits
110+
singleRun: true
111+
112+
};
113+
114+
config.set(configuration);
115+
116+
}

0 commit comments

Comments
 (0)