Permalink
Browse files

fix(build): Remove kcd-common-tools, update dependencies, make life g…

…ood again
  • Loading branch information...
1 parent d8906a6 commit 1df064a29684d8e35240632ab77063cf0496f773 @kentcdodds kentcdodds committed Oct 8, 2015
View
View
@@ -0,0 +1,25 @@
+# EditorConfig is awesome: http://EditorConfig.org
+
+# top-most EditorConfig file
+root = true
+
+# all files
+[*]
+end_of_line = lf
+insert_final_newline = true
+indent_style = space
+indent_size = 2
+charset = utf-8
+trim_trailing_whitespace = true
+max_line_length = 120
+
+[*.js]
+quote_type = single
+curly_bracket_next_line = false
+spaces_around_operators = true
+spaces_around_brackets = inside
+indent_brace_style = BSD KNF
+
+# HTML
+[*.html]
+quote_type = double
View
View
@@ -0,0 +1,5 @@
+node_modules
+coverage
+dist
+local-examples
+other
View
@@ -1,19 +1,5 @@
{
- "extends": "kentcdodds/test-angular",
- "rules": {
- "no-invalid-this": 0, // meh...
- "func-names": 0, // I wish, but doing this right now would be a royal pain
- "new-cap": [
- 2,
- {
- "newIsCap": true,
- "capIsNew": true
- }
- ],
- "max-params": [2, 10],
- "max-statements": [2, 30], // TODO bring this down
- },
- "globals": {
- "VERSION": false
- },
+ // The purpose of this .eslintrc is just for editors and IDEs to pick it up.
+ // Webpack tells eslint which files to use explicitly.
+ "extends": "./other/test.eslintrc"
}
View
View
@@ -0,0 +1,14 @@
+.idea
+*.log
+*.iml
+*.DS_Store
+
+node_modules
+coverage
+nohup.out
+
+*.ignored.*
+*.ignored/
+*.ignored
+dist
+
View
View
@@ -0,0 +1,12 @@
+.idea
+node_modules
+coverage
+local-examples
+demo
+.editorconfig
+.gitignore
+.travis.yml
+CONTRIBUTING.md
+karma.conf.js
+webpack.config.js
+other
View
@@ -18,7 +18,7 @@ before_script:
- npm prune
script:
- npm run code-checks
- - npm t
+ - npm run test:ci
- npm run check-coverage
after_success:
- npm run report-coverage
View
@@ -1 +1,3 @@
-module.exports = require('kcd-common-tools/shared/karma.conf');
+/* eslint-env node */
+require('babel/register');
+module.exports = require('./other/karma.conf.es6');
View
@@ -0,0 +1,18 @@
+{
+ "rules": {
+ "no-invalid-this": 0, // meh...
+ "func-names": 0, // I wish, but doing this right now would be a royal pain
+ "new-cap": [
+ 2,
+ {
+ "newIsCap": true,
+ "capIsNew": true
+ }
+ ],
+ "max-params": [2, 10],
+ "max-statements": [2, 30], // TODO bring this down
+ },
+ "globals": {
+ "VERSION": false
+ },
+}
@@ -0,0 +1,56 @@
+/* eslint-env node */
+const path = require('path');
+
+process.env.NODE_ENV = process.env.NODE_ENV || 'test';
+
+const coverage = process.env.COVERAGE === 'true';
+const ci = process.env.CI;
+if (coverage) {
+ console.log('-- recording coverage --'); // eslint-disable-line no-console
+}
+
+const webpackConfig = require('./webpack.config.es6');
+const entry = path.join(webpackConfig.context, webpackConfig.entry);
+const preprocessors = {};
+preprocessors[entry] = ['webpack'];
+
+module.exports = function(config) {
+ config.set({
+ basePath: './',
+ frameworks: ['sinon-chai', 'chai', 'mocha', 'sinon'],
+ files: [
+ 'node_modules/lodash/index.js',
+ 'node_modules/api-check/dist/api-check.js',
+ 'node_modules/angular/angular.js',
+ 'node_modules/angular-mocks/angular-mocks.js',
+ entry
+ ],
+ preprocessors,
+ reporters: getReporters(),
+ webpack: webpackConfig,
+ webpackMiddleware: {noInfo: true},
+ coverageReporter: {
+ reporters: [
+ {type: 'lcov', dir: 'coverage/', subdir: '.'},
+ {type: 'json', dir: 'coverage/', subdir: '.'},
+ {type: 'text-summary'}
+ ]
+ },
+ port: 9876,
+ colors: true,
+ logLevel: config.LOG_INFO,
+ autoWatch: !ci,
+ browsers: ['Firefox'],
+ singleRun: ci,
+ browserNoActivityTimeout: 180000
+ });
+};
+
+function getReporters() {
+ const reps = ['progress'];
+ if (coverage) {
+ reps.push('coverage');
+ }
+ return reps;
+}
+
View
@@ -0,0 +1,3 @@
+{
+ "extends": ["kentcdodds", "./common.eslintrc"]
+}
View
@@ -0,0 +1,3 @@
+{
+ "extends": ["kentcdodds/test-angular", "./common.eslintrc"]
+}
@@ -0,0 +1,178 @@
+/* eslint-env node */
+const packageJson = require('../package.json');
+
+const here = require('path-here');
+const _ = require('lodash');
+const webpack = require('webpack');
+const deindent = require('deindent');
+const WebpackNotifierPlugin = require('webpack-notifier');
+
+module.exports = getConfig();
+
+function getConfig() {
+ let config = getCommonConfig();
+
+ switch (process.env.NODE_ENV) {
+ case 'development':
+ config = _.merge(config, getDevConfig());
+ break;
+ case 'production':
+ config = _.merge(config, getProdConfig());
+ break;
+ case 'test':
+ config = _.merge(config, getTestConfig());
+ break;
+ default:
+ throw new Error(`NODE_ENV not equal to development, production, or test. It is equal to ${process.env.NODE_ENV}`);
+ }
+ return config;
+}
+
+
+function getCommonConfig() {
+ return {
+ context: here('src'),
+ entry: './index.js',
+ output: {
+ libraryTarget: 'umd',
+ library: 'ngFormly'
+ },
+ stats: {
+ colors: true,
+ reasons: true
+ },
+ resolve: {
+ extensions: ['', '.js'],
+ alias: {
+ 'angular-fix': here('src/angular-fix')
+ }
+ },
+ eslint: {
+ emitError: true,
+ failOnError: true,
+ failOnWarning: false,
+ quiet: true
+ },
+ externals: {
+ angular: 'angular',
+ 'api-check': {
+ root: 'apiCheck',
+ amd: 'api-check',
+ commonjs2: 'api-check',
+ commonjs: 'api-check'
+ }
+ }
+ };
+}
+
+function getDevConfig() {
+ return {
+ output: {
+ filename: 'dist/formly.js'
+ },
+ module: {
+ loaders: [
+ getJavaScriptLoader(),
+ getHtmlLoader()
+ ]
+ },
+ plugins: getCommonPlugins()
+ };
+}
+
+function getProdConfig() {
+ return {
+ output: {
+ filename: 'dist/formly.min.js'
+ },
+ devtool: 'source-map',
+ module: {
+ loaders: [
+ getJavaScriptLoader(),
+ getHtmlLoader()
+ ]
+ },
+ plugins: _.union(getCommonPlugins(), [
+ new webpack.optimize.DedupePlugin(),
+ new webpack.optimize.OccurenceOrderPlugin(),
+ new webpack.optimize.AggressiveMergingPlugin()
+ ])
+ };
+}
+
+function getTestConfig() {
+ const coverage = process.env.COVERAGE === 'true';
+ const ci = process.env.CI === 'true';
+ console.log(process.env.CI);
+ return {
+ entry: './index.test.js',
+ module: {
+ loaders: _.flatten([
+ coverage ? getCoverageLoaders() : getJavaScriptLoader(),
+ getHtmlLoader()
+ ])
+ },
+ plugins: getCommonPlugins(),
+ eslint: {
+ emitError: ci,
+ failOnError: ci
+ }
+ };
+
+ function getCoverageLoaders() {
+ return [
+ {
+ test: /\.test\.js$|\.mock\.js$/, // include only mock and test files
+ loaders: ['ng-annotate', 'babel', 'eslint?configFile=./other/test.eslintrc'],
+ exclude: /node_modules/
+ },
+ {
+ test: /\.js$/,
+ loaders: ['ng-annotate', 'isparta', 'eslint?configFile=./other/src.eslintrc'],
+ exclude: /node_modules|\.test.js$|\.mock\.js$/ // exclude node_modules and test files
+ }
+ ];
+ }
+}
+
+
+function getJavaScriptLoader() {
+ return {test: /\.js$/, loaders: ['ng-annotate', 'babel', 'eslint?configFile=./other/src.eslintrc'], exclude: /node_modules/};
+}
+
+function getHtmlLoader() {
+ return {test: /\.html$/, loaders: ['raw'], exclude: /node_modules/};
+}
+
+function getCommonPlugins() {
+ return _.filter([
+ new webpack.BannerPlugin(getBanner(process.env.NODE_ENV), {raw: true}),
+ new webpack.DefinePlugin({
+ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
+ VERSION: JSON.stringify(packageJson.version)
+ }),
+ process.env.CI ? undefined : new WebpackNotifierPlugin({
+ title: 'angular-formly',
+ contentImage: here('other/logo/angular-formly-logo-64px.png')
+ })
+ ]);
+}
+
+function getBanner(env) {
+ if (env === 'production') {
+ return deindent`
+ /*! ${packageJson.name} v${packageJson.version} | MIT | built with ♥ by ${packageJson.contributors.join(', ')} (ó ì_í)=óò=(ì_í ò) */
+ `.trim();
+ } else {
+ return deindent`
+ /*!
+ * ${packageJson.name} JavaScript Library v${packageJson.version}
+ *
+ * @license MIT (http://license.angular-formly.com)
+ *
+ * built with ♥ by ${packageJson.contributors.join(', ')}
+ * (ó ì_í)=óò=(ì_í ò)
+ */
+ `.trim();
+ }
+}

0 comments on commit 1df064a

Please sign in to comment.