Skip to content

Commit

Permalink
feat(renderContext): test
Browse files Browse the repository at this point in the history
  • Loading branch information
lzxb committed May 11, 2020
1 parent 2b2d8d8 commit a87bd5c
Show file tree
Hide file tree
Showing 8 changed files with 2,662 additions and 89 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ src/**
dist/**
examples/**/dist/**
coverage/**
**.log
1 change: 0 additions & 1 deletion .yarnrc

This file was deleted.

1 change: 1 addition & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ yarn
yarn build:ts
yarn build
yarn test
npm run semantic-release
lerna publish --registry=https://registry.npmjs.org --force-publish
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"type-check": "tsc --noEmit",
"test": "jest --coverage",
"coveralls": "coveralls < coverage/lcov.info",
"semantic-release": "semantic-release pre && semantic-release post",
"lerna": "yarn test && lerna publish --registry=https://registry.npmjs.org --force-publish"
},
"sideEffects": [
Expand All @@ -39,6 +40,7 @@
"@types/jest": "^25.1.4",
"coveralls": "^3.0.11",
"jest": "^25.2.4",
"semantic-release": "^17.0.7",
"vue": "^2.6.11",
"vue-property-decorator": "^8.4.0"
},
Expand Down
12 changes: 6 additions & 6 deletions packages/genesis-app/dist/create-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ exports.createServerApp = async (options) => {
if (!options.App) {
throw new Error('options.App component cannot be empty');
}
if (!options.context) {
throw new Error('options.context parameter cannot be empty');
if (!options.renderContext) {
throw new Error('options.renderContext parameter cannot be empty');
}
const { App, context, vueOptions } = options;
const { App, renderContext, vueOptions } = options;
const { router } = vueOptions || {};
if (router) {
await router.replace(context.data.url).catch((err) => {
await router.replace(renderContext.data.url).catch((err) => {
throw err ||
new Error(`router.replace('${context.data.url}') error`);
new Error(`router.replace('${renderContext.data.url}') error`);
});
await new Promise((resolve, reject) => {
router.onReady(resolve, (err) => {
Expand All @@ -59,7 +59,7 @@ exports.createServerApp = async (options) => {
}
const app = new vue_1.default({
...vueOptions,
renderContext: context,
renderContext,
render(h) {
return h(App);
}
Expand Down
16 changes: 8 additions & 8 deletions packages/genesis-app/src/create-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export interface CreateServerAppOptions {
*/
App: typeof Vue;
/**
* Client side rendering context
* Server side rendering context
*/
context: RenderContext;
renderContext: RenderContext;
/**
* Parameters of Vue
*/
Expand Down Expand Up @@ -68,15 +68,15 @@ export const createServerApp = async (options: CreateServerAppOptions) => {
if (!options.App) {
throw new Error('options.App component cannot be empty');
}
if (!options.context) {
throw new Error('options.context parameter cannot be empty');
if (!options.renderContext) {
throw new Error('options.renderContext parameter cannot be empty');
}
const { App, context, vueOptions } = options;
const { App, renderContext, vueOptions } = options;
const { router } = (vueOptions as any) || {};
if (router) {
await router.replace(context.data.url).catch((err: Error) => {
await router.replace(renderContext.data.url).catch((err: Error) => {
throw err ||
new Error(`router.replace('${context.data.url}') error`);
new Error(`router.replace('${renderContext.data.url}') error`);
});
await new Promise((resolve, reject) => {
router.onReady(resolve, (err: Error) => {
Expand All @@ -86,7 +86,7 @@ export const createServerApp = async (options: CreateServerAppOptions) => {
}
const app = new Vue({
...vueOptions,
renderContext: context,
renderContext,
render(h) {
return h(App);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/genesis-app/types/create-app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export interface CreateServerAppOptions {
*/
App: typeof Vue;
/**
* Client side rendering context
* Server side rendering context
*/
context: RenderContext;
renderContext: RenderContext;
/**
* Parameters of Vue
*/
Expand Down
Loading

0 comments on commit a87bd5c

Please sign in to comment.