Skip to content

Commit

Permalink
chore: use configuration and build process from `angular-library-star…
Browse files Browse the repository at this point in the history
…ter`
  • Loading branch information
DanielKucal committed Feb 17, 2018
1 parent b88b61f commit 8abd53c
Show file tree
Hide file tree
Showing 32 changed files with 7,119 additions and 1,275 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
### This project
dist/
/dist
/documentation
/coverage
*.tgz

### Third party
Expand Down Expand Up @@ -213,4 +215,4 @@ jspm_packages
.node_repl_history

### Typings
typings
typings
10 changes: 0 additions & 10 deletions .npmignore

This file was deleted.

30 changes: 18 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
sudo: false
dist: trusty
language: node_js

cache:
directories:
- node_modules

addons:
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
cache:
directories:
- node_modules

language: node_js

node_js:
- "7"
- "node"

matrix:
fast_finish: true
- "8"

before_install:
- npm install npm@5 -g
- npm i npm@^5 -g
- npm cache verify
- npm prune
- npm update

install:
- npm install

script:
- npm test
- npm run build

before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3

script:
- npm run build
matrix:
fast_finish: true

notifications:
email: false
6 changes: 6 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Copyright (c) 2017, Daniel Kucal, ZoomSphere

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

20 changes: 0 additions & 20 deletions Makefile

This file was deleted.

74 changes: 74 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"use strict";

const shell = require('shelljs');
const chalk = require('chalk');

const PACKAGE = `ngx-store`;
const NPM_DIR = `dist`;
const ESM2015_DIR = `${NPM_DIR}/esm2015`;
const ESM5_DIR = `${NPM_DIR}/esm5`;
const BUNDLES_DIR = `${NPM_DIR}/bundles`;
const OUT_DIR_ESM5 = `${NPM_DIR}/package/esm5`;

shell.echo(`Start building...`);

shell.rm(`-Rf`, `${NPM_DIR}/*`);
shell.mkdir(`-p`, `./${ESM2015_DIR}`);
shell.mkdir(`-p`, `./${ESM5_DIR}`);
shell.mkdir(`-p`, `./${BUNDLES_DIR}`);

/* TSLint with Codelyzer */
// https://github.com/palantir/tslint/blob/master/src/configs/recommended.ts
// https://github.com/mgechev/codelyzer
shell.echo(`Start TSLint`);
shell.exec(`tslint -p tslint.json -t stylish src/**/*.ts`);
shell.echo(chalk.green(`TSLint completed`));

/* AoT compilation */
shell.echo(`Start AoT compilation`);
if (shell.exec(`ngc -p tsconfig-build.json`).code !== 0) {
shell.echo(chalk.red(`Error: AoT compilation failed`));
shell.exit(1);
}
shell.echo(chalk.green(`AoT compilation completed`));

/* BUNDLING PACKAGE */
shell.echo(`Start bundling`);
shell.echo(`Rollup package`);
if (shell.exec(`rollup -c rollup.es.config.js -i ${NPM_DIR}/${PACKAGE}.js -o ${ESM2015_DIR}/${PACKAGE}.js`).code !== 0) {
shell.echo(chalk.red(`Error: Rollup package failed`));
shell.exit(1);
}

// Uncomment everything for Angular5
// shell.echo(`Produce ESM5 version`);
// shell.exec(`ngc -p tsconfig-build.json --target es5 -d false --outDir ${OUT_DIR_ESM5} --importHelpers true --sourceMap`);
// if (shell.exec(`rollup -c rollup.es.config.js -i ${OUT_DIR_ESM5}/${PACKAGE}.js -o ${ESM5_DIR}/${PACKAGE}.js`).code !== 0) {
// shell.echo(chalk.red(`Error: ESM5 version failed`));
// shell.exit(1);
// }

// shell.echo(`Run Rollup conversion on package`);
// if (shell.exec(`rollup -c rollup.config.js -i ${ESM5_DIR}/${PACKAGE}.js -o ${BUNDLES_DIR}/${PACKAGE}.umd.js`).code !== 0) {
// shell.echo(chalk.red(`Error: Rollup conversion failed`));
// shell.exit(1);
// }

// shell.echo(`Minifying`);
// shell.cd(`${BUNDLES_DIR}`);
// shell.exec(`uglifyjs ${PACKAGE}.umd.js -c --comments -o ${PACKAGE}.umd.min.js --source-map "filename='${PACKAGE}.umd.min.js.map', includeSources"`);
// shell.cd(`..`);
// shell.cd(`..`);

shell.echo(chalk.green(`Bundling completed`));

shell.rm(`-Rf`, `${NPM_DIR}/package`);
shell.rm(`-Rf`, `${NPM_DIR}/node_modules`);
// shell.rm(`-Rf`, `${NPM_DIR}/*.js`);
shell.rm(`-Rf`, `${NPM_DIR}/*.js.map`);
// shell.rm(`-Rf`, `${NPM_DIR}/src/**/*.js`);
shell.rm(`-Rf`, `${NPM_DIR}/src/**/*.js.map`);

shell.cp(`-Rf`, [`package.json`, `LICENSE`, `README.md`], `${NPM_DIR}`);

shell.echo(chalk.green(`End building`));
1 change: 0 additions & 1 deletion index.ts

This file was deleted.

124 changes: 124 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// Karma configuration for Unit testing

const path = require('path');

module.exports = function (config) {

const configuration = {

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],

plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-webpack'),
require('karma-sourcemap-loader'),
require('karma-spec-reporter'),
require('karma-coverage-istanbul-reporter'),
require("istanbul-instrumenter-loader")
],

// list of files / patterns to load in the browser
files: [
{ pattern: 'spec.bundle.js', watched: false }
],

// list of files to exclude
exclude: [
],

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

// webpack
webpack: {
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts/,
use: [
{ loader: 'ts-loader' },
{ loader: 'source-map-loader' }
],
exclude: /node_modules/
},
{
enforce: 'post',
test: /\.ts/,
use: [
{
loader: 'istanbul-instrumenter-loader',
options: { esModules: true }
}
],
exclude: [
/\.spec.ts/,
/node_modules/
]
}
],
exprContextCritical: false
},
devtool: 'inline-source-map',
performance: { hints: false }
},

webpackServer: {
noInfo: true
},


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

coverageIstanbulReporter: {
reports: ['html', 'lcovonly'],
dir: path.join(__dirname, 'coverage'),
fixWebpackSourcePaths: true
},


// 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,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,


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


// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true

};

config.set(configuration);

}
4 changes: 4 additions & 0 deletions license-banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* @license ngx-store
* ISC license
*/
6 changes: 6 additions & 0 deletions ngx-store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file is not used to build the module. It is only used during editing
// by the TypeScript language service and during build for verification. `ngc`
// replaces this file with production ngx-store.ts when it rewrites private symbol names.

export * from './public_api';
// export * from './src/ngx-store';
Loading

0 comments on commit 8abd53c

Please sign in to comment.