-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: SB-842 Extract documents to separate package
- Loading branch information
Marcin Jadwiżyc
committed
Mar 24, 2023
1 parent
74fc8b1
commit 5ec8b80
Showing
42 changed files
with
622 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 15 additions & 15 deletions
30
packages/webapp-libs/webapp-api-client/src/graphql/__generated/gql/gql.ts
Large diffs are not rendered by default.
Oops, something went wrong.
62 changes: 31 additions & 31 deletions
62
packages/webapp-libs/webapp-api-client/src/graphql/__generated/gql/graphql.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"extends": ["plugin:@nrwl/nx/react", "../../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*", "node_modules/**/*"], | ||
"plugins": ["react-hooks", "formatjs", "testing-library"], | ||
"rules": { | ||
"import/order": ["error"], | ||
"formatjs/no-offset": "error", | ||
"react/jsx-curly-brace-presence": "error" | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": "*.stories.tsx", | ||
"rules": { | ||
"import/no-anonymous-default-export": "off" | ||
} | ||
}, | ||
{ | ||
"files": "*.{ts,tsx}", | ||
"rules": { | ||
"@typescript-eslint/no-var-requires": "off", | ||
"@typescript-eslint/ban-ts-comment": "off", | ||
"@typescript-eslint/explicit-module-boundary-types": "off", | ||
"import/no-anonymous-default-export": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"no-empty": "off", | ||
"react/jsx-no-useless-fragment": "off" | ||
} | ||
}, | ||
{ | ||
"files": ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"], | ||
"extends": ["plugin:testing-library/react"], | ||
"rules": { | ||
"testing-library/render-result-naming-convention": "off", | ||
"testing-library/no-node-access": "off" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"plugins": ["@trivago/prettier-plugin-sort-imports"], | ||
"printWidth": 120, | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"importOrder": [ | ||
"^(path|dns|fs)/?", | ||
"<THIRD_PARTY_MODULES>", | ||
"^(__generated__|__generated|@types|app|contexts|emails|fonts|images|mocks|modules|routes|shared|tests|theme|translations)/?", | ||
"^[./]" | ||
], | ||
"importOrderSeparation": true, | ||
"importOrderSortSpecifiers": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { CodegenConfig } from '@graphql-codegen/cli'; | ||
|
||
const config: Partial<CodegenConfig> = { | ||
generates: { | ||
'src/graphql/__generated/gql/': { | ||
documents: ['../webapp-documents/src/**/*.ts', '../webapp-documents/src/**/*.tsx'], | ||
|
||
plugins: [], | ||
}, | ||
}, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: 'webapp-documents', | ||
preset: '../../../jest.preset.js', | ||
transform: { | ||
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest', | ||
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nrwl/react/babel'] }], | ||
}, | ||
transformIgnorePatterns: ['/node_modules/(?!(@iconify-icons|react-markdown)/)'], | ||
globals: { | ||
'ts-jest': { | ||
tsconfig: '<rootDir>/tsconfig.spec.json', | ||
}, | ||
}, | ||
moduleNameMapper: { | ||
'react-markdown': '<rootDir>/node_modules/react-markdown/react-markdown.min.js', | ||
}, | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], | ||
coverageReporters: ['lcov'], | ||
coveragePathIgnorePatterns: ['/node_modules/', '.*.svg'], | ||
setupFilesAfterEnv: ['./src/tests/setupTests.ts'], | ||
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{ | ||
"name": "@sb/webapp-documents", | ||
"version": "0.0.1", | ||
"type": "commonjs", | ||
"scripts": { | ||
"test": "jest", | ||
"test:watch": "jest --watch", | ||
"lint": "eslint ." | ||
}, | ||
"dependencies": { | ||
"@sb/webapp-api-client": "*", | ||
"@sb/webapp-core": "*", | ||
"graphql": "^16.6.0", | ||
"react-loading-skeleton": "^3.1.0" | ||
}, | ||
"peerDependencies": { | ||
"@apollo/client": "^3.7.9", | ||
"@iconify-icons/ion": "^1.2.4", | ||
"@iconify/react": "^4.0.0", | ||
"@storybook/react": "^6.5.16", | ||
"@testing-library/dom": "^8.19.0", | ||
"@testing-library/jest-dom": "^5.16.5", | ||
"@testing-library/react": "^13.4.0", | ||
"@testing-library/react-hooks": "^8.0.1", | ||
"@testing-library/user-event": "^14.4.3", | ||
"babel-jest": "28.1.3", | ||
"jest": "28.1.3", | ||
"jest-environment-jsdom": "28.1.3", | ||
"msw": "^1.0.0", | ||
"ramda": "^0.28.0", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"react-intl": "^6.2.1", | ||
"react-markdown": "^8.0.3", | ||
"react-router": "^6.7.0", | ||
"react-router-dom": "^6.7.0", | ||
"styled-components": "5.3.6" | ||
}, | ||
"devDependencies": { | ||
"@apollo/client": "^3.7.9", | ||
"@apollo/rover": "^0.12.2", | ||
"@graphql-codegen/cli": "^2.13.11", | ||
"@iconify-icons/ion": "^1.2.4", | ||
"@iconify/react": "^4.0.0", | ||
"@nrwl/jest": "^15.8.6", | ||
"@nrwl/react": "^15.8.6", | ||
"@storybook/addon-actions": "^6.5.16", | ||
"@storybook/addon-backgrounds": "^6.5.16", | ||
"@storybook/addon-docs": "^6.5.16", | ||
"@storybook/addon-essentials": "^6.5.16", | ||
"@storybook/addon-measure": "^6.5.16", | ||
"@storybook/addon-outline": "^6.5.16", | ||
"@storybook/builder-vite": "^0.4.0", | ||
"@storybook/client-api": "^6.5.16", | ||
"@storybook/client-logger": "^6.5.16", | ||
"@storybook/react": "^6.5.16", | ||
"@testing-library/dom": "^8.19.0", | ||
"@testing-library/jest-dom": "^5.16.5", | ||
"@testing-library/react": "^13.4.0", | ||
"@testing-library/react-hooks": "^8.0.1", | ||
"@testing-library/user-event": "^14.4.3", | ||
"@types/jest": "28.1.3", | ||
"@types/ramda": "^0.28.23", | ||
"@types/react": "^18.0.24", | ||
"@types/styled-components": "^5.1.26", | ||
"@types/testing-library__jest-dom": "^5.14.5", | ||
"babel-jest": "28.1.3", | ||
"eslint-plugin-formatjs": "^4.3.4", | ||
"eslint-plugin-jsx-a11y": "^6.4.1", | ||
"eslint-plugin-react": "^7.21.5", | ||
"eslint-plugin-react-hooks": "^4.0.0", | ||
"eslint-plugin-testing-library": "^5.9.1", | ||
"jest": "28.1.3", | ||
"jest-environment-jsdom": "28.1.3", | ||
"jest-matcher-utils": "^29.4.2", | ||
"jest-watch-typeahead": "^2.2.2", | ||
"ramda": "^0.28.0", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"react-intl": "^6.2.1", | ||
"react-markdown": "^8.0.3", | ||
"react-router": "^6.7.0", | ||
"react-router-dom": "^6.7.0", | ||
"styled-components": "5.3.6", | ||
"ts-jest": "28.0.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "webapp-documents", | ||
"$schema": "../../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "packages/webapp-libs/webapp-documents/src", | ||
"projectType": "library", | ||
"targets": { | ||
"graphql": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"cwd": "packages/webapp-libs/webapp-documents", | ||
"color": true | ||
}, | ||
"configurations": { | ||
"download-schema": { | ||
"commands": ["/bin/sh ./scripts/download-graphql-schema.sh"] | ||
} | ||
} | ||
} | ||
}, | ||
"tags": [] | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/webapp-libs/webapp-documents/sonar-project.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
sonar.organization=apptension | ||
sonar.projectKey=saas_boilerplate_webapp_documents | ||
sonar.javascript.lcov.reportPaths=coverage/lcov.info | ||
|
||
# Define the same root directory for sources and tests | ||
sonar.sources = src/ | ||
sonar.tests = src/ | ||
|
||
# Include test subdirectories in test scope | ||
sonar.test.inclusions = src/**/*.spec.* | ||
|
||
# Exclude test and generated subdirectories from source scope | ||
sonar.exclusions = src/**/*.spec.* | ||
sonar.coverage.exclusions = src/**/*.stories.*, |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ts/document/skeleton/skeleton.stories.tsx → ...ts/document/skeleton/skeleton.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { asyncComponent } from '@sb/webapp-core/utils/asyncComponent'; | ||
|
||
export const Documents = asyncComponent(() => import('./documents')); |
File renamed without changes.
1 change: 1 addition & 0 deletions
1
packages/webapp-libs/webapp-documents/src/tests/factories/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './document'; |
2 changes: 2 additions & 0 deletions
2
packages/webapp-libs/webapp-documents/src/tests/setupTests.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import '@sb/webapp-api-client/tests/setupTests'; | ||
import '@sb/webapp-core/tests/setupTests'; |
56 changes: 56 additions & 0 deletions
56
packages/webapp-libs/webapp-documents/src/tests/utils/rendering.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import * as apiUtils from '@sb/webapp-api-client/tests/utils/rendering'; | ||
import * as corePath from '@sb/webapp-core/utils/path'; | ||
import { RenderOptions, render, renderHook } from '@testing-library/react'; | ||
import { ComponentClass, ComponentType, FC, ReactElement } from 'react'; | ||
import { MemoryRouterProps, generatePath } from 'react-router'; | ||
|
||
export type WrapperProps = apiUtils.WrapperProps; | ||
|
||
export function getWrapper( | ||
WrapperComponent: ComponentClass<apiUtils.ApiTestProvidersProps> | FC<apiUtils.ApiTestProvidersProps>, | ||
wrapperProps: WrapperProps | ||
): { | ||
wrapper: ComponentType<apiUtils.WrapperProps>; | ||
waitForApolloMocks: (mockIndex?: number) => Promise<void>; | ||
} { | ||
return apiUtils.getWrapper(apiUtils.ApiTestProviders, wrapperProps); | ||
} | ||
|
||
export type CustomRenderOptions = RenderOptions & WrapperProps; | ||
|
||
function customRender(ui: ReactElement, options: CustomRenderOptions = {}) { | ||
const { wrapper, waitForApolloMocks } = getWrapper(apiUtils.ApiTestProviders, options); | ||
|
||
return { | ||
...render(ui, { | ||
...options, | ||
wrapper, | ||
}), | ||
waitForApolloMocks, | ||
}; | ||
} | ||
|
||
function customRenderHook<Result, Props>(hook: (initialProps: Props) => Result, options: CustomRenderOptions = {}) { | ||
const { wrapper, waitForApolloMocks } = getWrapper(apiUtils.ApiTestProviders, options); | ||
|
||
return { | ||
...renderHook(hook, { | ||
...options, | ||
wrapper, | ||
}), | ||
waitForApolloMocks, | ||
}; | ||
} | ||
|
||
export { customRender as render, customRenderHook as renderHook }; | ||
|
||
export const createMockRouterProps = (pathName: string, params?: Record<string, any>): MemoryRouterProps => { | ||
return { | ||
initialEntries: [ | ||
generatePath(corePath.getLocalePath(pathName), { | ||
lang: 'en', | ||
...(params ?? {}), | ||
}), | ||
], | ||
}; | ||
}; |
16 changes: 16 additions & 0 deletions
16
packages/webapp-libs/webapp-documents/src/utils/storybook.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ApiTestProviders } from '@sb/webapp-api-client/tests/utils/rendering'; | ||
import { Story } from '@storybook/react'; | ||
|
||
import { WrapperProps, getWrapper } from '../tests/utils/rendering'; | ||
|
||
export function withProviders(wrapperProps: WrapperProps = {}) { | ||
return (StoryComponent: Story) => { | ||
const { wrapper: WrapperComponent } = getWrapper(ApiTestProviders, wrapperProps); | ||
|
||
return ( | ||
<WrapperComponent {...wrapperProps}> | ||
<StoryComponent /> | ||
</WrapperComponent> | ||
); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"extends": "../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
Oops, something went wrong.