Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev: Add Keystone embed with Bookmark and Collection #213

Merged
merged 8 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Dependency directories
node_modules/

.awcache
.DS_Store

# Build output
.next
out/

# Keystone output
.keystone

# Storybook build output
storybook-static

# Copied by yarn postinstall
public/vendor/fonts
public/vendor/img

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Coverage directory used by tools like istanbul
coverage

# Cypress artifacts
cypress/screenshots
cypress/videos
cypress/reports
# Optional eslint cache
.eslintcache

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.envrc.local

# Public assets
public/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ node_modules/
.next
out/

# Keystone output
.keystone

# Storybook build output
storybook-static

Expand Down
21 changes: 20 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ node_modules/

# Build output
.next
out/

# Keystone output
.keystone

# Storybook build output
storybook-static

# Copied by yarn postinstall
public/vendor/fonts
public/vendor/img

# Logs
logs
Expand All @@ -17,6 +28,10 @@ yarn-error.log*
# Coverage directory used by tools like istanbul
coverage

# Cypress artifacts
cypress/screenshots
cypress/videos
cypress/reports
# Optional eslint cache
.eslintcache

Expand All @@ -25,6 +40,10 @@ coverage

# dotenv environment variables file
.env
.envrc.local

# Public assets
public/
public/

# Generated files
CHANGELOG.md
Binary file added cms.db
Binary file not shown.
7 changes: 6 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module.exports = {
testPathIgnorePatterns: ['/node_modules/', '.next/', 'cypress/'],
moduleDirectories: ['node_modules/', '.'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing babel transform errors when trying to test Keystone 😕

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this change (if anything) moving forward?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we add directories under src/ that we want to be able to import from using absolute paths, they'll need to be added to this file so Jest can resolve the imports correctly

moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
transform: {
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
Expand All @@ -9,6 +8,12 @@ module.exports = {
'\\.(scss|sass|css)$': 'identity-obj-proxy',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/__mocks__/fileMock.js',
'__mocks__/(.*)': '<rootDir>/src/__mocks__/$1',
'components/(.*)': '<rootDir>/src/components/$1',
'hooks/(.*)': '<rootDir>/src/hooks/$1',
'layout/(.*)': '<rootDir>/src/layout/$1',
'pages/(.*)': '<rootDir>/src/pages/$1',
'stores/(.*)': '<rootDir>/src/stores/$1',
},
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
coverageThreshold: {
Expand Down
12 changes: 12 additions & 0 deletions keystone.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { config } from '@keystone-next/keystone'

import schema from './src/cms/schema'

export default config({
db: { provider: 'sqlite', url: 'file:./cms.db' },
experimental: {
generateNextGraphqlAPI: true,
generateNodeAPI: true,
},
lists: schema,
})
110 changes: 57 additions & 53 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,61 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
/* eslint-disable @typescript-eslint/no-var-requires */
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})

module.exports = withBundleAnalyzer({
async rewrites() {
return {
beforeFiles: [
{
source: '/:path',
has: [
{
type: 'cookie',
key: 'betaOptIn',
value: 'true',
},
],
destination: '/beta/:path',
},
{
source: '/training-and-education/:path*',
has: [
{
type: 'cookie',
key: 'betaOptIn',
value: 'true',
},
],
destination: '/beta/training-and-education/:path*',
},
{
source: '/about-us/:path*',
has: [
{
type: 'cookie',
key: 'betaOptIn',
value: 'true',
},
],
destination: '/beta/about-us/:path*',
},
{
source: '/',
has: [
{
type: 'cookie',
key: 'betaOptIn',
value: 'true',
},
],
destination: '/beta',
},
],
}
},
})
const { withKeystone } = require('@keystone-next/keystone/next')

module.exports = withKeystone(
withBundleAnalyzer({
async rewrites() {
return {
beforeFiles: [
{
source: '/:path',
has: [
{
type: 'cookie',
key: 'betaOptIn',
value: 'true',
},
],
destination: '/beta/:path',
},
{
source: '/training-and-education/:path*',
has: [
{
type: 'cookie',
key: 'betaOptIn',
value: 'true',
},
],
destination: '/beta/training-and-education/:path*',
},
{
source: '/about-us/:path*',
has: [
{
type: 'cookie',
key: 'betaOptIn',
value: 'true',
},
],
destination: '/beta/about-us/:path*',
},
{
source: '/',
has: [
{
type: 'cookie',
key: 'betaOptIn',
value: 'true',
},
],
destination: '/beta',
},
],
}
},
})
)
33 changes: 19 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
"lint": "tsc --noEmit && eslint .",
"prepare": "husky install",
"pre-commit": "lint-staged",
"test": "jest",
"test:watch": "jest --watch",
"test": "jest --runInBand --testTimeout=60000",
"test:watch": "jest --watch --runInBand --testTimeout=60000",
"cypress:dev": "cypress open",
"postinstall": "sh ./scripts/copy_uswds_assets.sh",
"postinstall": "sh ./scripts/copy_uswds_assets.sh && keystone-next postinstall",
"release": "standard-version -t ''"
},
"dependencies": {
"@keystone-next/fields": "15.0.0",
"@keystone-next/keystone": "25.0.1",
"@next/bundle-analyzer": "11.1.2",
"@trussworks/react-uswds": "2.0.0",
"classnames": "2.3.1",
Expand All @@ -40,23 +42,23 @@
"uswds": "2.10.3"
},
"devDependencies": {
"@babel/core": "7.15.0",
"@babel/core": "7.15.5",
"@fortawesome/fontawesome-svg-core": "1.2.36",
"@fortawesome/free-solid-svg-icons": "5.15.4",
"@fortawesome/react-fontawesome": "0.1.15",
"@storybook/addon-a11y": "6.3.7",
"@storybook/addon-actions": "6.3.7",
"@storybook/addon-essentials": "6.3.7",
"@storybook/addon-links": "6.3.7",
"@storybook/react": "6.3.7",
"@storybook/addon-a11y": "6.3.8",
"@storybook/addon-actions": "6.3.8",
"@storybook/addon-essentials": "6.3.8",
"@storybook/addon-links": "6.3.8",
"@storybook/react": "6.3.8",
"@testing-library/jest-dom": "5.14.1",
"@testing-library/react": "12.0.0",
"@testing-library/user-event": "13.2.1",
"@types/jest-axe": "3.5.2",
"@types/react": "17.0.19",
"@types/react": "17.0.20",
"@types/react-fontawesome": "1.6.5",
"@typescript-eslint/eslint-plugin": "4.30.0",
"@typescript-eslint/parser": "4.30.0",
"@typescript-eslint/eslint-plugin": "4.31.0",
"@typescript-eslint/parser": "4.31.0",
"axe-core": "4.3.3",
"babel-loader": "8.2.2",
"css-loader": "5.2.7",
Expand All @@ -73,7 +75,7 @@
"eslint-plugin-security": "1.4.0",
"husky": "7.0.2",
"identity-obj-proxy": "3.0.0",
"jest": "27.1.0",
"jest": "27.1.1",
"jest-axe": "5.0.1",
"lint-staged": "11.1.2",
"mkdirp": "1.0.4",
Expand All @@ -82,11 +84,14 @@
"sass-loader": "10.2.0",
"serve": "12.0.0",
"standard-version": "9.3.1",
"storybook-addon-next-router": "3.0.7",
"storybook-addon-next-router": "3.0.8",
"storybook-css-modules-preset": "1.1.1",
"style-loader": "2.0.0",
"typescript": "4.4.2"
},
"resolutions": {
"@babel/runtime": "7.15.4"
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up updating a bunch of packages because there were some incompatibilities causing Storybook to not run.

"lint-staged": {
"*.{js,jsx,ts,tsx,json}": [
"prettier --write",
Expand Down
Loading