Skip to content

Commit 2f9ded9

Browse files
authored
Merge pull request #14 from lightbasenl/next
v2
2 parents 7611fe5 + ff850ad commit 2f9ded9

Some content is hidden

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

53 files changed

+5833
-3961
lines changed

.checks/component_has_story.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
module.exports = fail => {
5+
const componentsPath = path.join(__dirname, "./../src/components");
6+
7+
const files = fs.readdirSync(componentsPath);
8+
9+
const components = files.filter(file => !file.match(/.story.(tsx|mdx)$/));
10+
const stories = files.filter(file => file.match(/.story.(tsx|mdx)$/));
11+
12+
components.forEach(component => {
13+
const name = component.split(".")[0];
14+
15+
if (!stories.find(file => file.startsWith(name))) {
16+
fail(`There is a story missing for ${name} in src/components`);
17+
}
18+
});
19+
};

.checks/helper_has_test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
module.exports = fail => {
5+
const helpersPath = path.join(__dirname, "./../src/helpers");
6+
7+
const files = fs.readdirSync(helpersPath);
8+
9+
const tests = files.filter(file => file.match(/\.test\.(ts|tsx)$/));
10+
const helpers = files.filter(file => !file.match(/\.test\.(ts|tsx)$/));
11+
12+
helpers.forEach(helper => {
13+
if (!tests.find(test => test.match(/\.test\.(ts|tsx)$/))) {
14+
fail(`There is a test missing for ${helper} in src/helpers`);
15+
}
16+
});
17+
};

.checks/hook_starts_with_use.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
module.exports = fail => {
5+
const hooksPath = path.join(__dirname, "./../src/hooks");
6+
7+
const files = fs.readdirSync(hooksPath);
8+
9+
files.forEach(file => {
10+
if (!file.match(/^use/) && file.charAt(0) !== ".") {
11+
fail(`There is a file that doesn't start with "use" in src/hooks: ${file}`);
12+
}
13+
});
14+
};

.checks/run.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const checks = [
2+
require("./component_has_story"),
3+
require("./helper_has_test"),
4+
require("./hook_starts_with_use"),
5+
];
6+
7+
let fails = 0;
8+
9+
function fail(message) {
10+
console.log(`\x1b[41m[ FAILED ]\x1b[0m - ${message}`);
11+
fails++;
12+
}
13+
14+
console.log("\nPerforming checks...\n");
15+
16+
checks.forEach(check => {
17+
check(fail);
18+
});
19+
20+
if (fails > 0) {
21+
console.error(`\x1b[31m${fails} check(s) failed\x1b[0m`);
22+
process.exitCode = 1;
23+
} else {
24+
console.log("\x1b[32mAll checks passed. 🎉");
25+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Cypress storybook tests
2+
on: [push]
3+
jobs:
4+
cypress-run:
5+
strategy:
6+
matrix:
7+
os: [ubuntu-latest]
8+
node: [14]
9+
runs-on: ${{ matrix.os }}
10+
name: Storybook on Chrome on Node v${{ matrix.node }}
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
- name: Node.js ${{ matrix.node }}
15+
uses: actions/setup-node@v1
16+
with:
17+
node-version: ${{ matrix.node }}
18+
19+
- name: Cypress run
20+
uses: cypress-io/github-action@v1
21+
with:
22+
browser: chrome
23+
config: pageLoadTimeout=100000,watchForFileChanges=false
24+
start: yarn storybook
25+
wait-on: http://localhost:6006
26+
wait-on-timeout: 120
27+
spec: cypress/integration/storybook/**/*

.github/workflows/cypress-test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: End-to-end cypress app tests
2+
on: [push]
3+
4+
jobs:
5+
cypress-run:
6+
strategy:
7+
matrix:
8+
os: [ubuntu-latest]
9+
node: [14]
10+
runs-on: ${{ matrix.os }}
11+
name: E2E on Chrome on Node v${{ matrix.node }}
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
- name: Node.js ${{ matrix.node }}
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: ${{ matrix.node }}
19+
20+
- name: Cypress run
21+
uses: cypress-io/github-action@v1
22+
with:
23+
browser: chrome
24+
config: pageLoadTimeout=100000,watchForFileChanges=false
25+
build: yarn build
26+
start: yarn start
27+
wait-on: http://localhost:3000
28+
wait-on-timeout: 120
29+
spec: cypress/integration/app/**/*

.github/workflows/lint-test.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: lint-test
2+
on: [push]
3+
4+
jobs:
5+
lint-build-test:
6+
strategy:
7+
matrix:
8+
os: [ubuntu-latest]
9+
node: [14]
10+
runs-on: ${{ matrix.os }}
11+
env:
12+
CI: true
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Node.js ${{ matrix.node }}
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: ${{ matrix.node }}
19+
- name: Cache node modules
20+
uses: actions/cache@v1
21+
with:
22+
path: ~/.yarn
23+
key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
24+
restore-keys: |
25+
${{ runner.os }}-${{ matrix.node }}-
26+
${{ runner.os }}-
27+
- name: Install, Format, Check
28+
run: |
29+
yarn
30+
yarn format
31+
yarn checks:run
32+
- name: Test, Build
33+
run: |
34+
yarn test
35+
yarn build

.storybook/.babelrc

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
{
2-
"presets": ["next/babel"],
2+
"presets": [
3+
"next/babel"
4+
],
35
"plugins": [
46
[
57
"module-resolver",
68
{
7-
"root": ["./../src"],
8-
"extensions": [".js", ".jsx", ".ts", ".tsx", ".json"]
9+
"root": [
10+
"./src"
11+
],
12+
"extensions": [
13+
".js",
14+
".jsx",
15+
".ts",
16+
".tsx",
17+
".json"
18+
]
919
}
1020
]
1121
]

.storybook/config.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

.storybook/main.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const path = require("path");
2+
3+
module.exports = {
4+
addons: [
5+
{
6+
name: "@storybook/preset-typescript",
7+
options: {
8+
tsLoaderOptions: {
9+
configFile: path.resolve(__dirname, "./tsconfig.json"),
10+
},
11+
forkTsCheckerWebpackPluginOptions: {
12+
colors: false,
13+
},
14+
include: [path.resolve(__dirname, "../src")],
15+
transpileManager: true,
16+
},
17+
},
18+
"@storybook/addon-docs",
19+
"@storybook/addon-knobs/register",
20+
"@storybook/addon-a11y/register",
21+
],
22+
};

0 commit comments

Comments
 (0)