Skip to content

Commit a47cdff

Browse files
committed
initial
1 parent 64d7479 commit a47cdff

File tree

114 files changed

+25562
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+25562
-0
lines changed

.babelrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"env": {
3+
"development": {
4+
"presets": ["next/babel"]
5+
},
6+
"production": {
7+
"presets": ["next/babel"]
8+
},
9+
"test": {
10+
"presets": [["next/babel", { "preset-env": { "modules": "commonjs" } }]]
11+
}
12+
}
13+
}

.eslintrc.js

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
module.exports = {
2+
'parser': 'babel-eslint',
3+
'env': {
4+
'browser': true,
5+
'node': true,
6+
'mocha': true
7+
},
8+
'extends': [
9+
'prettier',
10+
'prettier/react',
11+
'airbnb',
12+
'plugin:react/recommended',
13+
],
14+
'plugins': [
15+
'import',
16+
'prettier',
17+
'react',
18+
],
19+
'rules': {
20+
'linebreak-style': 0,
21+
'react/sort-comp': 0,
22+
'max-classes-per-file': 0,
23+
'import/prefer-default-export': 0,
24+
'consistent-return': 0,
25+
'no-unused-expressions': 0,
26+
'jsx-props-no-spreading': 0,
27+
'class-methods-use-this': 0,
28+
'eol-last': 0,
29+
'react/prefer-stateless-function': 0,
30+
'react/static-property-placement': 0,
31+
'react/jsx-props-no-spreading': 0,
32+
'no-use-before-define': 0,
33+
'global-require': 0,
34+
'arrow-body-style': 0,
35+
'jsx-a11y/click-events-have-key-events': 0, // there are valid cases for this e.g. forms
36+
'jsx-a11y/interactive-supports-focus': 0, // there are valid cases for this e.g. forms
37+
'jsx-a11y/label-has-associated-control': 0, // rule seems buggy, doesn't understand some htmlFor cases
38+
'jsx-a11y/label-has-for': 0,
39+
'jsx-a11y/mouse-events-have-key-events': 0,
40+
'jsx-a11y/no-noninteractive-element-interactions': 0, // rule seems buggy, doesn't understand some htmlFor cases
41+
'max-len': 0,
42+
'no-multi-assign': 0,
43+
'no-nested-ternary': 0,
44+
'no-param-reassign': 0, //Disabled to it not looking for global components
45+
'no-plusplus': 0,
46+
'no-restricted-globals': 'off',
47+
'no-return-assign': 0,
48+
'camelcase': 0,
49+
'no-underscore-dangle': 0,
50+
'object-curly-newline': 0,
51+
'prefer-destructuring': 0,
52+
'quote-props': 0,
53+
'radix': 0,
54+
'indent': [
55+
"error", 4,
56+
{
57+
SwitchCase: 1,
58+
ignoredNodes: ['JSXElement', 'JSXElement > *', 'JSXAttribute', 'JSXIdentifier', 'JSXNamespacedName', 'JSXMemberExpression', 'JSXSpreadAttribute', 'JSXExpressionContainer', 'JSXOpeningElement', 'JSXClosingElement', 'JSXText', 'JSXEmptyExpression', 'JSXSpreadChild'],
59+
},
60+
],
61+
'react/jsx-indent': ["error", 4],
62+
'react/jsx-indent-props': ["error", 2],
63+
'react/jsx-max-props-per-line': [1,
64+
{
65+
'maximum': 3
66+
}
67+
],
68+
'jsx-a11y/anchor-is-valid': 0,
69+
'react/destructuring-assignment': 0,
70+
'react/forbid-prop-types': 0,
71+
'react/jsx-filename-extension': 0,
72+
'react/jsx-one-expression-per-line': 0,
73+
'react/jsx-no-undef': 0,
74+
'react/jsx-pascal-case': 0,
75+
'react/jsx-tag-spacing': 0, //Disabled to it not looking for global components
76+
'react/no-access-state-in-setstate': 0,
77+
'react/no-array-index-key': 0, // there are valid cases for this where a key can not be determined
78+
'react/no-direct-mutation-state': 0,
79+
'react/no-find-dom-node': 0,
80+
'react/no-multi-comp': 0,
81+
'react/no-string-refs': 0, // todo: Disable for now, need to update probably for react 17
82+
'react/no-unescaped-entities': 0, // there are valid cases for this where a key can not be determined
83+
'react/require-default-props': 0,
84+
},
85+
'globals': {
86+
'_': true,
87+
'__DEV__': true,
88+
'API': true,
89+
'E2E': true,
90+
'Utils': true,
91+
'Constants': true,
92+
'Strings': true,
93+
'describe': true,
94+
'Format': true,
95+
'FormGroup': true,
96+
'ga': true,
97+
'Link': true,
98+
'openAlert': true,
99+
'openConfirm': true,
100+
'mixpanel': true,
101+
'Loader': true,
102+
'Project': true,
103+
'propTypes': true,
104+
'Radio': true,
105+
'React': true,
106+
'ReactDOM': true,
107+
'Row': true,
108+
'pact': true,
109+
}
110+
};

.gitignore

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.DS_Store
2+
.idea
3+
*.iml
4+
node_modules/
5+
build/
6+
*.log*
7+
npm-debug.log
8+
mobile/common-mobile/
9+
e2e_screenshots
10+
reports/
11+
reports/*
12+
reports/*
13+
tests/tokens.json
14+
.vscode
15+
mobile/fastlane/report.xml
16+
mobile/*.app.dSYM.zip
17+
pacts/*
18+
coverage/*
19+
.nyc_output/*
20+
.next
21+
out
22+
dist

.prettierrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"singleQuote": true,
3+
"requirePragma": true,
4+
"printWidth": 120,
5+
"trailingComma": "all"
6+
}

.storybook/addons.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import '@storybook/addon-knobs/register';
2+
import '@storybook/addon-actions/register';

.storybook/config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
import { configure } from '@storybook/react'
3+
import {configure as configureEnzyme} from 'enzyme';
4+
import Adapter from 'enzyme-adapter-react-16';
5+
6+
configureEnzyme({ adapter: new Adapter() });
7+
8+
function loadStories () {
9+
require('../stories/index')
10+
}
11+
12+
configure(loadStories, module)

.storybook/storybook.test.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import initStoryshots, { renderWithOptions } from '@storybook/addon-storyshots';
2+
import { mount } from 'enzyme';
3+
4+
initStoryshots({
5+
framework: 'react',
6+
test: renderWithOptions({
7+
renderer: mount,
8+
}),
9+
// Ignore integrityOptions for async.storyshot because only run when asyncJest is true
10+
integrityOptions: { cwd: __dirname, ignore: ['**/**.async.storyshot'] },
11+
configPath: __dirname,
12+
});

.storybook/webpack.config.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const path = require('path');
2+
3+
// Export a function. Accept the base config as the only param.
4+
module.exports = async ({ config, mode }) => {
5+
// `mode` has a value of 'DEVELOPMENT' or 'PRODUCTION'
6+
// You can change the configuration based on that.
7+
// 'PRODUCTION' is used when building the static version of storybook.
8+
9+
// Make whatever fine-grained changes you need
10+
config.module.rules.push(
11+
{
12+
test: /\.scss$/,
13+
use: ['style-loader', 'css-loader', 'sass-loader'],
14+
include: path.resolve(__dirname, '../'),
15+
}
16+
);
17+
18+
config.module.rules = config.module.rules.concat(require('../webpack/loaders.js'));
19+
20+
// Return the altered config
21+
return config;
22+
};

bin/blog.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
const join = require('path').join;
2+
const sortBy = require('lodash/sortBy');
3+
const uniq = require('lodash/uniq');
4+
5+
const testFolder = join(__dirname, '../static/pages-blog-markdown');
6+
const jsFolder = join(__dirname, '../pages/blog');
7+
const blogOutput = join(__dirname, '../static/blog.json');
8+
const fs = require('fs');
9+
const path = require('path');
10+
const parseMarkdown = require('../common/parse-markdown');
11+
12+
const files = fs.readdirSync(testFolder);
13+
const existingJSFiles = fs.readdirSync(jsFolder);
14+
let res = [];
15+
let allTags = [];
16+
17+
const writeJSTemplate = md => `
18+
import propTypes from 'prop-types';
19+
import md from '../../static/pages-blog-markdown/${md}';
20+
import BlogPost from '../../components/BlogPost';
21+
22+
23+
const BlogPostPage = props => (
24+
<BlogPost
25+
route={props.router.route}
26+
source={md}
27+
/>
28+
);
29+
30+
BlogPostPage.displayName = 'BlogPostPage';
31+
BlogPostPage.propTypes = {
32+
router: propTypes.object,
33+
};
34+
35+
export default BlogPostPage;
36+
`;
37+
38+
files.forEach((file) => {
39+
const md = fs.readFileSync(`${testFolder}/${file}`, 'utf8');
40+
const data = parseMarkdown(md);
41+
const targetJSFile = file.replace('.md', '.js');
42+
allTags = allTags.concat(data.tags);
43+
// eslint-disable-next-line no-console
44+
console.log('Processing', file);
45+
if (existingJSFiles.indexOf(targetJSFile) === -1) {
46+
// eslint-disable-next-line no-console
47+
console.log('File exists', targetJSFile);
48+
fs.writeFileSync(path.join(jsFolder, targetJSFile), writeJSTemplate(file));
49+
}
50+
res.push({
51+
...data,
52+
url: file.replace('.md', ''),
53+
content: null,
54+
});
55+
});
56+
res = sortBy(res, 'sort');
57+
res[0].allTags = uniq(allTags);
58+
fs.writeFileSync(blogOutput, JSON.stringify(res));
59+
// eslint-disable-next-line no-console
60+
console.log(`Wrote blog to ${blogOutput}`);
61+

bin/env.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Created by kylejohnson on 02/08/2016.
3+
*/
4+
require('colors');
5+
const fs = require('fs-extra');
6+
const path = require('path');
7+
8+
const env = process.env.ENV || 'dev';
9+
const src = path.resolve(__dirname, `../env/project_${env}.js`);
10+
const target = path.resolve(__dirname, '../common/project.js');
11+
12+
13+
// eslint-disable-next-line no-console
14+
console.log(`Using project_${env}.js`.green);
15+
16+
fs.copySync(src, target);

common/parse-markdown.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const each = require('lodash/each');
2+
const map = require('lodash/map');
3+
const moment = require('moment');
4+
5+
const splitAt = index => x => [x.slice(0, index), x.slice(index)];
6+
7+
module.exports = (source) => {
8+
const match = source.match(/---.*?---\n*/sg);
9+
const metaLength = match && match[0].length;
10+
const split = splitAt(metaLength)(source);
11+
const meta = split[0].split('\n');
12+
const content = split[1];
13+
const res = {
14+
content,
15+
};
16+
each(meta, (item) => {
17+
if (item.includes('title: ')) {
18+
res.title = item.replace('title: ', '');
19+
}
20+
if (item.includes('description: ')) {
21+
res.description = item.replace('description: ', '');
22+
}
23+
if (item.includes('author: ')) {
24+
res.author = item.replace('author: ', '');
25+
}
26+
if (item.includes('avatar: ')) {
27+
res.avatar = item.replace('avatar: ', '');
28+
}
29+
if (item.includes('date: ')) {
30+
const m = moment(item.replace('date: ', ''), 'DD-MMM-YYYY');
31+
res.dateFormatted = m.format('MMM DD YYYY');
32+
res.date = m.toISOString();
33+
res.sort = -m.valueOf();
34+
}
35+
if (item.includes('tags: ')) {
36+
res.tags = map(item.replace('tags: ', '').split(','), i => i.trim().toLowerCase()).sort();
37+
}
38+
});
39+
return res;
40+
};

common/project.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = global.Project = {
2+
siteName: 'Solid State Group',
3+
cookieDomain: '.solidstategroup.com',
4+
canonicalUrl: 'https://www.solidstategroup.com',
5+
ga: '',
6+
isso: 'https://isso.solidstategroup.com/',
7+
};

0 commit comments

Comments
 (0)