File tree 5 files changed +66
-6
lines changed
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'
14
14
import { resolveAppSiteData } from './resolveAppSiteData.js'
15
15
import { resolveAppVersion } from './resolveAppVersion.js'
16
16
import { resolveAppWriteTemp } from './resolveAppWriteTemp.js'
17
- import { setupAppThemeAndPlugins } from './setupAppThemeAndPlugins.js'
18
17
19
18
/**
20
19
* Create base vuepress app.
@@ -49,10 +48,5 @@ export const createBaseApp = (config: AppConfig): App => {
49
48
prepare : async ( ) => appPrepare ( app ) ,
50
49
} satisfies AppPropertiesBase as App
51
50
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
-
57
51
return app
58
52
}
Original file line number Diff line number Diff line change 1
1
import type { AppConfig , BuildApp } from '../types/index.js'
2
2
import { createBaseApp } from './createBaseApp.js'
3
+ import { setupAppThemeAndPlugins } from './setupAppThemeAndPlugins.js'
3
4
4
5
/**
5
6
* Create vuepress build app.
@@ -11,5 +12,8 @@ export const createBuildApp = (config: AppConfig): BuildApp => {
11
12
app . env . isBuild = true
12
13
app . build = async ( ) => app . options . bundler . build ( app )
13
14
15
+ // setup theme and plugins
16
+ setupAppThemeAndPlugins ( app , config )
17
+
14
18
return app
15
19
}
Original file line number Diff line number Diff line change 1
1
import type { AppConfig , DevApp } from '../types/index.js'
2
2
import { createBaseApp } from './createBaseApp.js'
3
+ import { setupAppThemeAndPlugins } from './setupAppThemeAndPlugins.js'
3
4
4
5
/**
5
6
* Create vuepress dev app.
@@ -11,5 +12,8 @@ export const createDevApp = (config: AppConfig): DevApp => {
11
12
app . env . isDev = true
12
13
app . dev = async ( ) => app . options . bundler . dev ( app )
13
14
15
+ // setup theme and plugins
16
+ setupAppThemeAndPlugins ( app , config )
17
+
14
18
return app
15
19
}
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