Skip to content

Commit

Permalink
Merge pull request #14 from lightbasenl/next
Browse files Browse the repository at this point in the history
v2
  • Loading branch information
rodymolenaar authored Jun 5, 2020
2 parents 7611fe5 + ff850ad commit 2f9ded9
Show file tree
Hide file tree
Showing 53 changed files with 5,833 additions and 3,961 deletions.
19 changes: 19 additions & 0 deletions .checks/component_has_story.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const fs = require("fs");
const path = require("path");

module.exports = fail => {
const componentsPath = path.join(__dirname, "./../src/components");

const files = fs.readdirSync(componentsPath);

const components = files.filter(file => !file.match(/.story.(tsx|mdx)$/));
const stories = files.filter(file => file.match(/.story.(tsx|mdx)$/));

components.forEach(component => {
const name = component.split(".")[0];

if (!stories.find(file => file.startsWith(name))) {
fail(`There is a story missing for ${name} in src/components`);
}
});
};
17 changes: 17 additions & 0 deletions .checks/helper_has_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const fs = require("fs");
const path = require("path");

module.exports = fail => {
const helpersPath = path.join(__dirname, "./../src/helpers");

const files = fs.readdirSync(helpersPath);

const tests = files.filter(file => file.match(/\.test\.(ts|tsx)$/));
const helpers = files.filter(file => !file.match(/\.test\.(ts|tsx)$/));

helpers.forEach(helper => {
if (!tests.find(test => test.match(/\.test\.(ts|tsx)$/))) {
fail(`There is a test missing for ${helper} in src/helpers`);
}
});
};
14 changes: 14 additions & 0 deletions .checks/hook_starts_with_use.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const fs = require("fs");
const path = require("path");

module.exports = fail => {
const hooksPath = path.join(__dirname, "./../src/hooks");

const files = fs.readdirSync(hooksPath);

files.forEach(file => {
if (!file.match(/^use/) && file.charAt(0) !== ".") {
fail(`There is a file that doesn't start with "use" in src/hooks: ${file}`);
}
});
};
25 changes: 25 additions & 0 deletions .checks/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const checks = [
require("./component_has_story"),
require("./helper_has_test"),
require("./hook_starts_with_use"),
];

let fails = 0;

function fail(message) {
console.log(`\x1b[41m[ FAILED ]\x1b[0m - ${message}`);
fails++;
}

console.log("\nPerforming checks...\n");

checks.forEach(check => {
check(fail);
});

if (fails > 0) {
console.error(`\x1b[31m${fails} check(s) failed\x1b[0m`);
process.exitCode = 1;
} else {
console.log("\x1b[32mAll checks passed. 🎉");
}
27 changes: 27 additions & 0 deletions .github/workflows/cypress-test-storybook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Cypress storybook tests
on: [push]
jobs:
cypress-run:
strategy:
matrix:
os: [ubuntu-latest]
node: [14]
runs-on: ${{ matrix.os }}
name: Storybook on Chrome on Node v${{ matrix.node }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Cypress run
uses: cypress-io/github-action@v1
with:
browser: chrome
config: pageLoadTimeout=100000,watchForFileChanges=false
start: yarn storybook
wait-on: http://localhost:6006
wait-on-timeout: 120
spec: cypress/integration/storybook/**/*
29 changes: 29 additions & 0 deletions .github/workflows/cypress-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: End-to-end cypress app tests
on: [push]

jobs:
cypress-run:
strategy:
matrix:
os: [ubuntu-latest]
node: [14]
runs-on: ${{ matrix.os }}
name: E2E on Chrome on Node v${{ matrix.node }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Cypress run
uses: cypress-io/github-action@v1
with:
browser: chrome
config: pageLoadTimeout=100000,watchForFileChanges=false
build: yarn build
start: yarn start
wait-on: http://localhost:3000
wait-on-timeout: 120
spec: cypress/integration/app/**/*
35 changes: 35 additions & 0 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: lint-test
on: [push]

jobs:
lint-build-test:
strategy:
matrix:
os: [ubuntu-latest]
node: [14]
runs-on: ${{ matrix.os }}
env:
CI: true
steps:
- uses: actions/checkout@v2
- name: Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Cache node modules
uses: actions/cache@v1
with:
path: ~/.yarn
key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node }}-
${{ runner.os }}-
- name: Install, Format, Check
run: |
yarn
yarn format
yarn checks:run
- name: Test, Build
run: |
yarn test
yarn build
16 changes: 13 additions & 3 deletions .storybook/.babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{
"presets": ["next/babel"],
"presets": [
"next/babel"
],
"plugins": [
[
"module-resolver",
{
"root": ["./../src"],
"extensions": [".js", ".jsx", ".ts", ".tsx", ".json"]
"root": [
"./src"
],
"extensions": [
".js",
".jsx",
".ts",
".tsx",
".json"
]
}
]
]
Expand Down
10 changes: 0 additions & 10 deletions .storybook/config.js

This file was deleted.

22 changes: 22 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const path = require("path");

module.exports = {
addons: [
{
name: "@storybook/preset-typescript",
options: {
tsLoaderOptions: {
configFile: path.resolve(__dirname, "./tsconfig.json"),
},
forkTsCheckerWebpackPluginOptions: {
colors: false,
},
include: [path.resolve(__dirname, "../src")],
transpileManager: true,
},
},
"@storybook/addon-docs",
"@storybook/addon-knobs/register",
"@storybook/addon-a11y/register",
],
};
4 changes: 4 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import "../src/css/tailwind.css";
import { configure } from "@storybook/react";

configure(require.context("../src/components", true, /\.story\.(tsx|mdx)$/), module);
44 changes: 0 additions & 44 deletions .storybook/webpack.config.js

This file was deleted.

10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:14-alpine

WORKDIR /app

COPY package.json .
COPY node_modules node_modules
COPY .next .next
COPY public public

CMD ["yarn", "start"]
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Lightbase B.V.
Copyright (c) 2020 Lightbase B.V.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit 2f9ded9

Please sign in to comment.