Skip to content

Commit

Permalink
build(package): merging core and enriched: copied all js files into src/
Browse files Browse the repository at this point in the history
  • Loading branch information
lzcabrera committed Jul 18, 2017
1 parent 141f1ab commit c4585b2
Show file tree
Hide file tree
Showing 65 changed files with 6,528 additions and 197 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
presets: ['es2015', 'stage-2', 'react']
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Node.js dependencies, files, & directories
.npm
.npmrc
node_modules
npm-debug.log*
*.log
Expand Down
92 changes: 92 additions & 0 deletions config/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"extends": [
"airbnb",
"plugin:import/errors"
],
"plugins": [
"react",
"import"
],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"experimentalObjectRestSpread": true
}
},
"env": {
"es6": true,
"browser": true,
"node": true,
"jquery": true,
"mocha": true
},
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx"]
}
}
},
"globals": {
"expect": true,
"jest": true
},
"rules": {
"quotes": 0,
"no-console": 1,
"no-debugger": 1,
"no-var": 1,
"semi": [1, "always"],
"no-trailing-spaces": 0,
"eol-last": 0,
"no-unused-vars": 0,
"no-underscore-dangle": 0,
"no-alert": 0,
"no-lone-blocks": 0,
"jsx-quotes": 1,
"global-require": 0,
"comma-dangle": ["error", "never"],
"no-confusing-arrow": ["error", {"allowParens": true}],
"arrow-body-style": 0,
"class-methods-use-this": 0,
"jsx-a11y/no-static-element-interactions": 0,
"jsx-a11y/no-noninteractive-element-to-interactive-role": 1,
"react/display-name": [ 1, {"ignoreTranspilerName": false }],
"react/forbid-prop-types": [1, {"forbid": ["any"]}],
"react/jsx-boolean-value": 1,
"react/jsx-closing-bracket-location": 0,
"react/jsx-curly-spacing": 1,
"react/jsx-indent-props": 0,
"react/jsx-key": 1,
"react/jsx-max-props-per-line": 0,
"react/jsx-no-bind": 1,
"react/jsx-no-duplicate-props": 1,
"react/jsx-no-literals": 0,
"react/jsx-no-undef": 1,
"react/jsx-pascal-case": 1,
"react/jsx-sort-prop-types": 0,
"react/jsx-sort-props": 0,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/no-array-index-key": 1,
"react/no-danger": 0,
"react/no-string-refs": 0,
"react/no-did-mount-set-state": 1,
"react/no-did-update-set-state": 1,
"react/no-direct-mutation-state": 1,
"react/no-multi-comp": 1,
"react/no-set-state": 0,
"react/no-unknown-property": 1,
"react/prefer-es6-class": 1,
"react/prefer-stateless-function": 0,
"react/prop-types": 1,
"react/react-in-jsx-scope": 1,
"react/require-default-props": 1,
"react/self-closing-comp": 1,
"react/sort-comp": 1,
"react/jsx-wrap-multilines": 1,
"import/no-extraneous-dependencies": 0
}
}
7 changes: 7 additions & 0 deletions config/.jestrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"rootDir": "../",
"moduleNameMapper": {
"^.+\\.(css|scss)$": "<rootDir>/src/__mocks__/styleMock.js"
},
"setupTestFrameworkScriptFile": "<rootDir>/node_modules/jest-enzyme/lib/index.js"
}
48 changes: 48 additions & 0 deletions config/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import path from 'path';

import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';

import babel from 'rollup-plugin-babel';

import sass from 'rollup-plugin-sass';
import postcss from 'postcss';
import autoprefixer from 'autoprefixer';

export default {
entry: path.resolve('./src/index.js'),
targets: [
{ format: 'cjs', dest: path.resolve('./dist/tds.cjs.js') },
{ format: 'es', dest: path.resolve('./dist/tds.es.js') }
],
sourceMap: true,

external: ['react', 'prop-types', '@telusdigital/redux-contentful'],

plugins: [
resolve({
extensions: ['.js', '.jsx']
}),
commonjs({
include: 'node_modules/**'
}),
sass({
output: path.resolve('./dist/tds.css'),
processor(css) {
return postcss([autoprefixer])
.process(css)
.then(result => result.css);
}
}),
babel({
babelrc: false,
presets: [
['es2015', { modules: false }],
'react',
'stage-2'
],
plugins: ['external-helpers'],
exclude: 'node_modules/**'
})
]
};
73 changes: 48 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
{
"name": "tds-build",
"name": "@telusdigital/tds",
"version": "0.18.1",
"description": "TELUS Design System",
"license": "UNLICENSED",
"main": "dist/tds.cjs.js",
"module": "dist/tds.es.js",
"scripts": {
"build": "npm run build:assets && npm run build:core && npm run build:enriched && npm run build:docs",
"build:assets": "cp -r core/fonts/* docs/src/html/assets/fonts/ && cp designs/TDS.sketch docs/src/html/assets/downloads/TDS.sketch && cp core/fonts/core-icons.ttf docs/src/html/assets/downloads/core-icons.ttf",
"build:core": "cd core && npm run build",
"build:docs": "cd docs && npm run build",
"build:enriched": "cd enriched && npm run build",
"prestart": "npm run build",
"start": "concurrently --kill-others \"cd docs && npm run start\" \"cd docs && npm run devServer\"",
"deploy:cdn": "npm run deploy:cdn:core && npm run deploy:cdn:enriched",
"deploy:cdn:core": "node scripts/s3deploy.js --bucket cdn.telus-thorium --module core --environment production --latest",
"deploy:cdn:enriched": "node scripts/s3deploy.js --bucket cdn.telus-thorium --module enriched --environment production --latest",
"precommit": "yarn lint && yarn test && yarn build",
"prerelease": "scripts/prerelease.sh",
"setup:links": "cd core && npm link && cd ../enriched && npm link && npm link telus-thorium-core && cd ../docs && npm link telus-thorium-core && npm link telus-thorium-enriched",
"lint": "cd core && npm run lint && cd ../docs && npm run lint && cd ../enriched && npm run lint",
"lint:scss": "stylelint 'src/**/*.scss' --config config/.stylelintrc.json",
"test": "cd enriched && npm run test",
"editjson": "underscore",
"precommit": "npm run lint && npm run build && npm run test"
"lint": "yarn lint:js && yarn lint:scss",
"lint:js": "eslint src --ext '.js,.jsx' --config config/.eslintrc.json",
"lint:scss": "stylelint 'src/scss/**/*.scss' --config config/.stylelintrc.json",
"test": "jest --config config/.jestrc.json",
"test:watch": "yarn test -- --watch",
"test:u": "yarn test -- -u",
"build": "yarn build:js && yarn build:scss",
"build:js": "rollup -c config/rollup.config.js && cp ./src/components/Headline/wave_header_default.png ./dist/",
"build:scss": "sh ./scripts/cp-scss.sh"
},
"repository": {
"type": "git",
Expand All @@ -30,21 +26,48 @@
"bugs": {
"url": "https://github.com/telusdigital/tds/issues"
},
"homepage": "http://tds.telus.com",
"devDependencies": {
"@telusdigital/redux-contentful": "^3.0.0",
"aws-sdk": "^2.7.3",
"concurrently": "^3.1.0",
"babel-cli": "^6.24.1",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"classnames": "^2.2.5",
"cz-conventional-changelog": "^2.0.0",
"log4js": "^1.0.1",
"mime-types": "^2.1.13",
"mkdirp": "^0.5.1",
"rimraf": "^2.5.4",
"enzyme": "^2.9.1",
"enzyme-to-json": "^1.5.1",
"eslint": "3.19.0",
"eslint-config-airbnb": "^15.0.2",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "5.1.1",
"eslint-plugin-react": "^7.1.0",
"jest": "^20.0.4",
"jest-enzyme": "^3.5.3",
"node-sass": "^4.5.3",
"postcss": "^6.0.7",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-test-renderer": "^15.6.1",
"rollup": "^0.45.2",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-sass": "^0.5.3",
"sinon": "^2.3.8",
"stylelint": "^8.0.0",
"stylelint-config-sass-guidelines": "^2.2.0",
"stylelint-scss": "^1.5.1",
"underscore-cli": "^0.2.19"
"stylelint-scss": "^1.5.1"
},
"peerDependencies": {
"@telusdigital/redux-contentful": ">=2.0.0",
"react": "^15.6.1",
"react-dom": "^15.6.1"
},
"dependencies": {
"commander": "^2.9.0"
"prop-types": "^15.5.10"
},
"config": {
"commitizen": {
Expand Down
6 changes: 6 additions & 0 deletions scripts/cp-scss.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

mkdir -p dist/scss

cp src/scss/settings/_variables.scss dist/scss/
cp src/scss/utility/{_helpers,_mixins}.scss dist/scss/
1 change: 1 addition & 0 deletions src/__mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
31 changes: 31 additions & 0 deletions src/components/Card/Card.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import PropTypes from 'prop-types';

import classNames from 'classnames';

import { warn } from '../../deprecate';

import './Card.scss';

const Card = ({ className, children, ...rest }) => {
if (className) {
warn('Card', 'Custom CSS classes are deprecated. This component does not support custom styling.');
}

if (rest.style) {
warn('Card', 'Inline styles are deprecated. This component does not support custom styling.');
}

return (
<div {...rest} className={classNames('card', className)}>
{children}
</div>
);
};

Card.propTypes = {
className: PropTypes.string,
children: PropTypes.node.isRequired
};

export default Card;
10 changes: 10 additions & 0 deletions src/components/Card/Card.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@import '../../scss/settings/variables';

.card {
border: 0;
box-sizing: border-box;
border-radius: 4px;
box-shadow: 0 0 16px 0 rgba(213, 213, 213, .5);
background-color: $color-white;
padding: 30px;
}
46 changes: 46 additions & 0 deletions src/components/Card/__tests__/Card.spec.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';

import sinon from 'sinon';

import * as deprecate from '../../../deprecate';
import Card from '../Card';

describe('<Card />', () => {
beforeEach(() => {
sinon.spy(deprecate, "warn");
});

afterEach(() => {
deprecate.warn.restore();
});

it('renders correctly', () => {
const card = shallow(<Card>Some content</Card>);

expect(toJson(card)).toMatchSnapshot();
});

it('passes attributes to DOM node', () => {
const card = shallow(<Card id="hello" title="my title">Some content</Card>);

expect(card).toHaveProp('id', 'hello');
expect(card).toHaveProp('title', 'my title');
});

it('accepts but deprecates custom classes', () => {
const card = shallow(<Card className="some-class">Some content</Card>);

expect(card).toHaveClassName('some-class');
expect(deprecate.warn.called).toBeTruthy();
});

it('accepts but deprecates inline styles', () => {
const styles = { color: 'blue' };
const card = shallow(<Card style={styles}>Some content</Card>);

expect(card).toHaveProp('style', styles);
expect(deprecate.warn.called).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Card /> renders correctly 1`] = `
<div
className="card"
>
Some content
</div>
`;
Loading

0 comments on commit c4585b2

Please sign in to comment.