Skip to content

Commit

Permalink
Core refactor (#601)
Browse files Browse the repository at this point in the history
* #590 exporting auth, moving all exports into export folder

* #590 exporting utils

* #590 exporting config

* #590 exporting client

* #590 removing most of schema.generated, exporting only getClient, config, and related types

* #590 Headless -> Faust.js

* #590 HeadlessConfig -> Config

* #590 HeadlessConfig -> ClientConfig

* chore: changeset

* fix: core test imports

* chore: updating packages

* fix: only one failing test based on no exports support from jest 27

* fix: fixing tests, updating dependencies
  • Loading branch information
wjohnsto authored Oct 21, 2021
1 parent 90ad8b7 commit 81d6162
Show file tree
Hide file tree
Showing 38 changed files with 2,748 additions and 17,370 deletions.
7 changes: 7 additions & 0 deletions .changeset/fifty-bears-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@faustjs/core': patch
'@faustjs/next': patch
'@faustjs/react': patch
---

Refactored core exports and naming to make root namespace cleaner
4,543 changes: 2,301 additions & 2,242 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"devDependencies": {
"@types/jest": "^27.0.2",
"gqty": "^2.0.2",
"gqty": "^2.0.3",
"rimraf": "^3.0.2"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/api.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './dist/cjs/api';
export * from './dist/cjs/export/api';
1 change: 1 addition & 0 deletions packages/core/auth.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dist/cjs/export/auth';
1 change: 1 addition & 0 deletions packages/core/client.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dist/cjs/export/client';
1 change: 1 addition & 0 deletions packages/core/config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dist/cjs/export/config';
49 changes: 33 additions & 16 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,33 @@
"name": "@faustjs/core",
"version": "0.12.3",
"description": "This module helps you use WordPress as a Headless CMS",
"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js",
"types": "dist/cjs/index.d.ts",
"main": "dist/cjs/export/index.js",
"module": "dist/mjs/export/index.js",
"types": "dist/cjs/export/index.d.ts",
"exports": {
".": {
"import": "./dist/mjs/index.js",
"require": "./dist/cjs/index.js"
"import": "./dist/mjs/export/index.js",
"require": "./dist/cjs/export/index.js"
},
"./api": {
"import": "./dist/mjs/api.js",
"require": "./dist/cjs/api.js"
"import": "./dist/mjs/export/api.js",
"require": "./dist/cjs/export/api.js"
},
"./auth": {
"import": "./dist/mjs/export/auth.js",
"require": "./dist/cjs/export/auth.js"
},
"./client": {
"import": "./dist/mjs/export/client.js",
"require": "./dist/cjs/export/client.js"
},
"./config": {
"import": "./dist/mjs/export/config.js",
"require": "./dist/cjs/export/config.js"
},
"./utils": {
"import": "./dist/mjs/export/utils.js",
"require": "./dist/cjs/export/utils.js"
}
},
"scripts": {
Expand Down Expand Up @@ -48,35 +64,36 @@
"license": "MIT",
"dependencies": {
"deepmerge": "^4.2.2",
"gqty": "^2.0.2",
"gqty": "^2.0.3",
"isomorphic-fetch": "^3.0.0",
"lodash": "^4.17.21",
"cookie": "^0.4.1"
},
"devDependencies": {
"@gqty/cli": "^2.1.0",
"@gqty/cli": "^2.1.1",
"@testing-library/jest-dom": "^5.14.1",
"@types/cookie": "^0.4.1",
"@types/is-number": "^7.0.1",
"@types/isomorphic-fetch": "^0.0.35",
"@types/jest": "^27.0.2",
"@types/lodash": "^4.14.175",
"@types/node": "^16.10.3",
"@types/webpack-env": "^1.16.2",
"@types/lodash": "^4.14.176",
"@types/node": "^16.11.1",
"@types/webpack-env": "^1.16.3",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"clean-webpack-plugin": "^4.0.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"jest": "^27.2.4",
"jest": "^27.3.1",
"prettier": "^2.4.1",
"prettier-linter-helpers": "^1.0.0",
"rimraf": "^3.0.2",
"ts-jest": "^27.0.5",
"ts-jest": "^27.0.7",
"ts-loader": "^9.2.6",
"typescript": "^4.4.3",
"typescript": "^4.4.4",
"fetch-mock": "9.11.0"
}
}
1 change: 0 additions & 1 deletion packages/core/src/api.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/core/src/auth/client/accessToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export async function fetchAccessToken(code?: string): Promise<string | null> {

if (isNil(apiBasePath)) {
throw new Error(
'You must provide an apiBasePath value in your Headless config in order to use the fetchToken middleware',
'You must provide an apiBasePath value in your Faust.js config in order to use the fetchToken middleware',
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface Config extends Record<string, unknown> {
*
* @default /api/faust
* @type {string}
* @memberof HeadlessConfig
* @memberof Config
*/
apiBasePath?: string;

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/export/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../server';
1 change: 1 addition & 0 deletions packages/core/src/export/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../auth';
1 change: 1 addition & 0 deletions packages/core/src/export/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../gqty';
1 change: 1 addition & 0 deletions packages/core/src/export/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../config';
8 changes: 8 additions & 0 deletions packages/core/src/export/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export {
getClient,
ClientConfig,
ApiClient,
WithClient,
GqlClientSchema,
} from '../gqty';
export { Config, config } from '../config';
1 change: 1 addition & 0 deletions packages/core/src/export/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../utils';
2 changes: 1 addition & 1 deletion packages/core/src/gqty/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export interface ClientConfig<
* @param {string} url
* @param {RequestInit} init
* @returns {RequestContext}
* @memberof HeadlessConfig
* @memberof ClientConfig
*/
applyRequestContext?(
url: string,
Expand Down
Loading

0 comments on commit 81d6162

Please sign in to comment.