Permalink
Browse files

🚨+✨ `@phenomic/*`: we can now configure every plugins from phenomic c…

…onfig

✨ `@phenomic/api-client`: `import fetchRestApi from "@phenomic/api-client/lib/fetch";` to fetch phenomic api directly.
🀫 `@phenomic/plugin-urls-resolver-react-router-3` has been removed and included as the default resolver for react, since plugins api has changed a bit.
✨ `@phenomic/core`: we added a new plugin api so any plugin can add static or dynamic url on runtime (`resolveURLs`)
✨ `@phenomic/core`: `renderStatic` is now not limited to a single plugin. Multiples plugins (those that have a `resolveURLs` can now render static files).
🚨 `@phenomic/core`: `collect` method for plugin should now be `collectFile`.
🚨 `@phenomic/core`: many plugin methods have their signature that have been updated. Please check flow definitions until docs is online (major change is that config is not send since plugin receive it when it's created).
  • Loading branch information...
MoOx committed Mar 29, 2018
1 parent b52fa5b commit 2d2f806cfee35aa6fa21d88ba5465bb37dad8119
Showing with 1,113 additions and 731 deletions.
  1. +7 βˆ’13 flow-typed/handmade/jsx-test-helpers-v1.x.x.js
  2. +109 βˆ’86 flow-typed/phenomic.js
  3. +1 βˆ’3 package.json
  4. +3 βˆ’1 packages/api-client/package.json
  5. +18 βˆ’0 packages/api-client/src/fetch.js
  6. +0 βˆ’2 packages/core/package.json
  7. +12 βˆ’9 packages/core/src/api/__tests__/index.js
  8. +2 βˆ’0 packages/core/src/api/helpers.js
  9. +25 βˆ’18 packages/core/src/api/index.js
  10. +79 βˆ’92 packages/core/src/commands/build.js
  11. +25 βˆ’22 packages/core/src/commands/start.js
  12. +184 βˆ’0 packages/core/src/configuration/__tests__/__snapshots__/flattenConfiguration.js.snap
  13. +108 βˆ’9 packages/core/src/configuration/__tests__/flattenConfiguration.js
  14. +150 βˆ’54 packages/core/src/configuration/flattenConfiguration.js
  15. +8 βˆ’5 packages/core/src/db/__tests__/index-test.js
  16. +68 βˆ’86 packages/core/src/db/index.js
  17. +1 βˆ’1 packages/core/src/index.js
  18. +6 βˆ’9 packages/core/src/injection/processFile.js
  19. +2 βˆ’2 packages/core/src/utils/readFile.js
  20. +1 βˆ’3 packages/core/src/watch/index.js
  21. +6 βˆ’4 packages/plugin-api-related-content/src/index.js
  22. +7 βˆ’5 packages/plugin-bundler-webpack/src/index.js
  23. +5 βˆ’3 packages/plugin-collector-files/src/__tests__/collect.js
  24. +24 βˆ’26 packages/plugin-collector-files/src/index.js
  25. +18 βˆ’14 packages/plugin-public-assets/src/index.js
  26. +0 βˆ’2 packages/plugin-renderer-react/package.json
  27. +8 βˆ’0 packages/plugin-renderer-react/src/__tests__/__snapshots__/resolveURLs-list.js.snap
  28. +0 βˆ’7 ...napshots__/index.js.snap β†’ plugin-renderer-react/src/__tests__/__snapshots__/resolveURLs.js.snap}
  29. +35 βˆ’0 packages/plugin-renderer-react/src/__tests__/resolveURLs-list.js
  30. +42 βˆ’0 packages/plugin-renderer-react/src/__tests__/resolveURLs.js
  31. +6 βˆ’6 packages/plugin-renderer-react/src/components/Provider.js
  32. +1 βˆ’16 packages/plugin-renderer-react/src/createApp.js
  33. +8 βˆ’4 packages/plugin-renderer-react/src/index.js
  34. +12 βˆ’1 packages/plugin-renderer-react/src/renderHTML.js
  35. +11 βˆ’12 packages/{plugin-urls-resolver-react-router-3 β†’ plugin-renderer-react}/src/resolveURLs.js
  36. +16 βˆ’9 packages/plugin-renderer-react/src/server/dev-server.js
  37. +25 βˆ’15 packages/plugin-renderer-react/src/server/static.js
  38. +5 βˆ’9 packages/plugin-renderer-react/src/shared/performQuery.js
  39. +3 βˆ’1 packages/plugin-transform-asciidoc/src/__tests__/index.js
  40. +16 βˆ’16 packages/plugin-transform-asciidoc/src/index.js
  41. +4 βˆ’2 packages/plugin-transform-json/src/__tests__/index.js
  42. +20 βˆ’20 packages/plugin-transform-json/src/index.js
  43. +3 βˆ’1 packages/plugin-transform-markdown/src/__tests__/index.js
  44. +15 βˆ’5 packages/plugin-transform-markdown/src/index.js
  45. +0 βˆ’6 packages/plugin-urls-resolver-react-router-3/README.md
  46. +0 βˆ’36 packages/plugin-urls-resolver-react-router-3/package.json
  47. +0 βˆ’73 packages/plugin-urls-resolver-react-router-3/src/__tests__/index.js
  48. +0 βˆ’8 packages/plugin-urls-resolver-react-router-3/src/index.js
  49. +1 βˆ’2 packages/preset-react-app/package.json
  50. +13 βˆ’13 packages/preset-react-app/src/index.js
@@ -1,16 +1,10 @@
/* eslint-disable */
declare module "jsx-test-helpers" {
declare export function concatPath(dirA: string, dirB: string): string;
declare export function noop(): void;
declare export function JSX(jsx: React$Element<any>): string;
declare export function renderJSX(
jsx: React$Element<any>,
cb?: any,
context?: any
): string;
declare export function render(
jsx: React$Element<any>,
cb?: any,
context?: any
): Object;
declare module.exports: {
concatPath: (dirA: string, dirB: string) => string,
noop: () => void,
JSX: (jsx: React$Node) => string,
renderJSX: (jsx: React$Node, cb?: any, context?: any) => string,
render: (jsx: React$Node, cb?: any, context?: any) => Object
};
}
View
@@ -1,4 +1,6 @@
export type Url = {
// @flow
declare type Url = {
href: string,
protocol: string,
slashes?: boolean,
@@ -13,60 +15,99 @@ export type Url = {
hash?: string
};
export type PhenomicDBEntryInput = {|
declare type PhenomicDBEntryInput = {|
data: Object,
partial: Object
|};
export type PhenomicDBEntry = {|
declare type PhenomicDBEntry = {|
data: Object,
partial: Object,
id: string
|};
export type PhenomicDBEntryPartial = {
declare type PhenomicDBEntryPartial = {
id: string
};
export type PhenomicDBEntryDetailed = {
declare type PhenomicDBEntryDetailed = {|
id: string,
body?: any
};
value: {
body?: any
}
|};
export type PhenomicDBSubRegistry = Array<PhenomicDBEntry>;
export type PhenomicDBRegistry = { [key: string]: PhenomicDBSubRegistry };
declare type PhenomicDBSubRegistry = Array<PhenomicDBEntry>;
declare type PhenomicDBRegistry = { [key: string]: PhenomicDBSubRegistry };
export type PhenomicDB = {|
declare type PhenomicDB = {|
_getDatabase: () => PhenomicDBRegistry,
_setDatabase: PhenomicDBRegistry => void,
destroy: () => Promise<void>,
destroy: () => void,
put: (
sub: null | string | Array<string>,
id: string,
value?: PhenomicDBEntryInput
) => Promise<void>,
) => void,
update: (
sub: null | string | Array<string>,
id: string,
value?: PhenomicDBEntryInput
) => Promise<void>,
) => void,
get: (
sub: null | string | Array<string>,
id: string
) => Promise<PhenomicDBEntry>,
getPartial: (sub: string | Array<string>, id: string) => Promise<mixed>,
) => PhenomicDBEntryDetailed,
getPartial: (
sub: string | Array<string>,
id: string
) => mixed | PhenomicDBEntryPartial,
getList: (
sub: null | string | Array<string>,
config?: LevelStreamConfig,
config?: {
gt?: string,
gte?: string,
lt?: string,
lte?: string,
limit?: number,
reverse?: boolean
},
filter?: string,
filterValue?: string
) => Promise<Array<PhenomicDBEntryPartial>>
) => Array<PhenomicDBEntryPartial>
|};
export type PhenomicInputPlugins = {|
plugins?: Array<(arg: PhenomicInputConfig) => PhenomicPlugin>,
presets?: Array<(arg: PhenomicInputConfig) => PhenomicInputPlugins>
declare type PhenomicInputPluginOption = { [optionName: string]: mixed };
declare type PhenomicInputPlugin =
| string
// | {| default: PhenomicPluginModule<PhenomicInputPluginOption> |}
| PhenomicPluginModule<PhenomicInputPluginOption>;
declare type PhenomicInputPluginWithOptionalOptions =
| PhenomicInputPlugin
| Array<PhenomicInputPlugin | PhenomicInputPluginOption>;
declare type PhenomicInputPreset = (any) => PhenomicInputPlugins;
declare type PhenomicInputMaybePreset = string | PhenomicInputMaybePreset;
declare type PhenomicInputPlugins = {|
plugins?:
| Array<PhenomicInputPluginWithOptionalOptions>
| {
[name: string]: PhenomicInputPluginWithOptionalOptions
},
presets?: Array<
| PhenomicInputMaybePreset
| Array<
| PhenomicInputMaybePreset
| Array<Array<string | PhenomicInputPluginOption>>
| {
[name: string]: PhenomicInputPluginOption
}
>
>
|};
export type PhenomicInputConfig = {|
declare type PhenomicInputConfig = {|
baseUrl?: string,
path?: string,
content?: string,
@@ -76,7 +117,7 @@ export type PhenomicInputConfig = {|
...PhenomicInputPlugins
|};
export type PhenomicContentFile = {|
declare type PhenomicContentFile = {|
name: string,
fullpath: string
// exists: boolean,
@@ -90,25 +131,14 @@ type PhenomicTransformResult = {|
type ReactCompo = Function;
export type PhenomicAppType = {|
routes: React$Element<any>
|};
type PhenomicIntermediateHtmlPropsType = {|
WrappedApp: ReactCompo,
renderAsObject: (
app: React$Element<any>
) => {
main: string,
state?: Object | null,
assets: PhenomicAssets
}
declare type PhenomicAppType = {|
routes: React$Node
|};
export type PhenomicHtmlPropsType = {|
declare type PhenomicHtmlPropsType = {|
App: ReactCompo,
render: (
app: React$Element<any>
app: React$Node
) => {|
assets: PhenomicAssets,
html: string,
@@ -119,64 +149,61 @@ export type PhenomicHtmlPropsType = {|
|}
|};
export type PhenomicHtmlType = (
props: PhenomicHtmlPropsType
) => React$Element<any>;
declare type PhenomicHtmlType = (props: PhenomicHtmlPropsType) => React$Node;
export type PhenomicPluginRenderStaticType = ({|
declare type PhenomicPluginModule<Opt> = (
config: PhenomicConfig,
app: AppType,
assets: PhenomicAssets,
phenomicFetch: PhenomicFetch,
location: string
|}) => Promise<Array<{| path: string, contents: string |}>>;
options: Opt
) => PhenomicPlugin;
export type PhenomicPluginRenderDevServerType = ({|
config: PhenomicConfig,
assets: PhenomicAssets,
location: string
|}) => string;
export type PhenomicPluginRenderHTMLType = ({|
config: PhenomicConfig,
props: PhenomicIntermediateHtmlPropsType
|}) => string;
export type PhenomicPlugin = {|
declare type PhenomicPlugin = {|
name: string,
// transformer
supportedFileTypes?: Array<string>,
transform?: ({|
config?: PhenomicConfig,
file: PhenomicContentFile,
contents: Buffer
|}) => Promise<PhenomicTransformResult> | PhenomicTransformResult,
|}) => PhenomicTransformResult | Promise<PhenomicTransformResult>,
// api
define?: (api: express$Application, db: PhenomicDB) => mixed,
extendAPI?: ({|
apiServer: express$Application,
db: PhenomicDB
|}) => mixed,
// collector
collect?: (db: PhenomicDB, fileName: string, parsed: Object) => Array<mixed>,
collectFile?: ({|
db: PhenomicDB,
fileName: string,
parsed: Object
|}) => Array<mixed> | Promise<Array<mixed>>,
// bunder
buildForPrerendering?: PhenomicConfig => PhenomicAppType,
build?: PhenomicConfig => PhenomicAssets,
buildForPrerendering?: () => Promise<PhenomicAppType>,
build?: () => PhenomicAssets,
// renderer
getRoutes?: PhenomicAppType => void,
resolveURLs?: (routes: any, fetch: PhenomicFetch) => Array<string>,
renderStatic?: PhenomicPluginRenderStaticType,
renderDevServer?: PhenomicPluginRenderDevServerType,
// urls-resolver
resolveURLs?: ({|
routes: any
|}) => Promise<Array<string>>,
renderStatic?: ({|
app: PhenomicAppType,
assets: PhenomicAssets,
location: string
|}) => Promise<Array<{| path: string, contents: string |}>>,
renderDevServer?: ({|
assets: PhenomicAssets,
location: string
|}) => string,
// common
addDevServerMiddlewares?: PhenomicConfig => Array<
express$Middleware | Promise<express$Middleware>
>,
beforeBuild?: PhenomicConfig => void
addDevServerMiddlewares?: () =>
| Array<express$Middleware>
| Promise<Array<express$Middleware>>,
beforeBuild?: () => void | Promise<void>,
afterBuild?: () => void | Promise<void>
|};
export type PhenomicPlugins = Array<PhenomicPlugin>;
export type PhenomicPresets = Array<PhenomicPreset>;
export type PhenomicExtensions = PhenomicPreset;
declare type PhenomicPlugins = Array<PhenomicPlugin>;
export type PhenomicConfig = {|
declare type PhenomicConfig = {|
baseUrl: Url,
path: string,
content: string,
@@ -186,7 +213,7 @@ export type PhenomicConfig = {|
plugins: Array<PhenomicPlugin>
|};
export type PhenomicQueryConfig = {|
declare type PhenomicQueryConfig = {|
path?: string,
id?: string,
after?: string,
@@ -196,7 +223,7 @@ export type PhenomicQueryConfig = {|
limit?: number
|};
export type PhenomicRoute = {|
declare type PhenomicRoute = {|
path: string,
params?: { [key: string]: any },
component: {
@@ -206,11 +233,7 @@ export type PhenomicRoute = {|
}
|};
export type PhenomicAssets = { [key: string]: string };
declare type PhenomicAssets = { [key: string]: string };
// @todo why this inconsistency?
export type PhenomicFetch =
| IsomorphicFetch
| ((config: PhenomicQueryConfig) => Promise<any>);
export type phenomic$Query = string;
export type phenomic$Queries = Array<phenomic$Query>;
declare type phenomic$Query = string;
declare type phenomic$Queries = Array<phenomic$Query>;
View
@@ -26,7 +26,7 @@
"git-exec-and-restage": "^1.0.1",
"globby": "^6.1.0",
"husky": "^0.13.3",
"jest": "^21.0.0",
"jest": "^22.4.3",
"lerna": "^2.5.1",
"lint-staged": "^3.4.0",
"npm-run-all": "^3.0.0",
@@ -69,7 +69,6 @@
"test-without-lint": "yarn tests",
"posttest": "yarn examples && yarn website:test"
},
"lint-staged": {
"*.{js,json,css,md}": ["git-exec-and-restage prettier --write"],
"*.re": ["git-exec-and-restage refmt --in-place"]
@@ -123,7 +122,6 @@
"lines": 80
}
},
"transformIgnorePatterns": ["node_modules"],
"testPathIgnorePatterns": ["/_output/", "/__fixtures__"]
},
"workspaces": ["website", "examples/*", "packages/*"]
@@ -24,7 +24,9 @@
"main": "lib/index.js",
"files": ["lib", "src", "!**/__tests__", "bsconfig.json"],
"dependencies": {
"debug": "^2.6.0"
"debug": "^2.6.0",
"isomorphic-fetch": "^2.2.1",
"simple-json-fetch": "^1.0.1"
},
"devDependencies": {
"bs-platform": "^2.2.0"
@@ -0,0 +1,18 @@
import "isomorphic-fetch";
import jsonFetch from "simple-json-fetch";
import createURL from "./url";
export default (config: PhenomicQueryConfig) => {
return jsonFetch(
createURL({
...config,
// @todo find a way to avoid bundling the line with localhost in production
root:
typeof window === "undefined"
? // $FlowFixMe yeah yeah
`http://localhost:${process.env.PHENOMIC_RESTAPI_PORT}`
: `${process.env.PHENOMIC_APP_BASENAME || "/"}phenomic`
})
).then(res => res.json);
};
@@ -23,15 +23,13 @@
"express": "^4.14.0",
"get-port": "^2.1.0",
"globby": "^6.1.0",
"isomorphic-fetch": "^2.2.1",
"log-symbols": "^1.0.2",
"mkdirp": "^0.5.1",
"p-map": "^1.2.0",
"path-to-regexp": "^1.7.0",
"react-dev-utils": "^4.2.1",
"rimraf": "^2.5.4",
"sane": "^1.7.0",
"simple-json-fetch": "^1.0.1",
"socket.io": "^1.7.2",
"socket.io-client": "^1.7.2",
"url": "^0.11.0"
Oops, something went wrong.

0 comments on commit 2d2f806

Please sign in to comment.