File tree Expand file tree Collapse file tree 5 files changed +66
-6
lines changed Expand file tree Collapse file tree 5 files changed +66
-6
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ import { resolveAppOptions } from './resolveAppOptions.js'
1414import { resolveAppSiteData } from './resolveAppSiteData.js'
1515import { resolveAppVersion } from './resolveAppVersion.js'
1616import { resolveAppWriteTemp } from './resolveAppWriteTemp.js'
17- import { setupAppThemeAndPlugins } from './setupAppThemeAndPlugins.js'
1817
1918/**
2019 * Create base vuepress app.
@@ -49,10 +48,5 @@ export const createBaseApp = (config: AppConfig): App => {
4948 prepare : async ( ) => appPrepare ( app ) ,
5049 } satisfies AppPropertiesBase as App
5150
52- // setup theme and plugins
53- // notice that we setup theme before plugins,
54- // so user plugins could override theme plugins
55- setupAppThemeAndPlugins ( app , config )
56-
5751 return app
5852}
Original file line number Diff line number Diff line change 11import type { AppConfig , BuildApp } from '../types/index.js'
22import { createBaseApp } from './createBaseApp.js'
3+ import { setupAppThemeAndPlugins } from './setupAppThemeAndPlugins.js'
34
45/**
56 * Create vuepress build app.
@@ -11,5 +12,8 @@ export const createBuildApp = (config: AppConfig): BuildApp => {
1112 app . env . isBuild = true
1213 app . build = async ( ) => app . options . bundler . build ( app )
1314
15+ // setup theme and plugins
16+ setupAppThemeAndPlugins ( app , config )
17+
1418 return app
1519}
Original file line number Diff line number Diff line change 11import type { AppConfig , DevApp } from '../types/index.js'
22import { createBaseApp } from './createBaseApp.js'
3+ import { setupAppThemeAndPlugins } from './setupAppThemeAndPlugins.js'
34
45/**
56 * Create vuepress dev app.
@@ -11,5 +12,8 @@ export const createDevApp = (config: AppConfig): DevApp => {
1112 app . env . isDev = true
1213 app . dev = async ( ) => app . options . bundler . dev ( app )
1314
15+ // setup theme and plugins
16+ setupAppThemeAndPlugins ( app , config )
17+
1418 return app
1519}
Original file line number Diff line number Diff line change 1+ import { expect , it } from 'vitest'
2+ import type { App , BuildApp , Bundler } from '../../src/index.js'
3+ import { createBuildApp } from '../../src/index.js'
4+
5+ it ( 'should create build app correctly' , ( ) => {
6+ const checkApp = ( app : App ) : void => {
7+ expect ( app . env . isDev ) . toBe ( false )
8+ expect ( ( app as unknown as { dev : never } ) . dev ) . toBeUndefined ( )
9+
10+ expect ( app . env . isBuild ) . toBe ( true )
11+ expect ( typeof ( app as BuildApp ) . build ) . toBe ( 'function' )
12+ }
13+
14+ const buildApp = createBuildApp ( {
15+ source : '/foo' ,
16+ theme : ( appInTheme ) => {
17+ checkApp ( appInTheme )
18+ return { name : 'test-theme' }
19+ } ,
20+ bundler : { } as Bundler ,
21+ plugins : [
22+ ( appInPlugin ) => {
23+ checkApp ( appInPlugin )
24+ return { name : 'test-plugin' }
25+ } ,
26+ ] ,
27+ } )
28+ checkApp ( buildApp )
29+ } )
Original file line number Diff line number Diff line change 1+ import { expect , it } from 'vitest'
2+ import type { App , Bundler , DevApp } from '../../src/index.js'
3+ import { createDevApp } from '../../src/index.js'
4+
5+ it ( 'should create dev app correctly' , ( ) => {
6+ const checkApp = ( app : App ) : void => {
7+ expect ( app . env . isDev ) . toBe ( true )
8+ expect ( typeof ( app as DevApp ) . dev ) . toBe ( 'function' )
9+
10+ expect ( app . env . isBuild ) . toBe ( false )
11+ expect ( ( app as unknown as { build : never } ) . build ) . toBeUndefined ( )
12+ }
13+
14+ const devApp = createDevApp ( {
15+ source : '/foo' ,
16+ theme : ( appInTheme ) => {
17+ checkApp ( appInTheme )
18+ return { name : 'test-theme' }
19+ } ,
20+ bundler : { } as Bundler ,
21+ plugins : [
22+ ( appInPlugin ) => {
23+ checkApp ( appInPlugin )
24+ return { name : 'test-plugin' }
25+ } ,
26+ ] ,
27+ } )
28+ checkApp ( devApp )
29+ } )
You can’t perform that action at this time.
0 commit comments