• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vuepress / vuepress-next / 7163313360

11 Dec 2023 05:25AM CUT coverage: 67.837% (-1.3%) from 69.176%
7163313360

Pull #1449

github

web-flow
Merge 4941993a9 into b82d48e1e
Pull Request #1449: feat: remove vuepress-vite and vuepress-webpack package and support --bundler option, close #1446

325 of 462 branches covered (0.0%)

Branch coverage included in aggregate %.

2 of 26 new or added lines in 4 files covered. (7.69%)

1 existing line in 1 file now uncovered.

641 of 962 relevant lines covered (66.63%)

47.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

4.88
/packages/cli/src/commands/build/createBuild.ts
1
import process from 'node:process'
2
import { createBuildApp } from '@vuepress/core'
3
import type { AppConfig } from '@vuepress/core'
4
import { debug, formatMs, fs, logger, withSpinner } from '@vuepress/utils'
5
import {
6
  loadUserConfig,
7
  resolveAppConfig,
8
  resolveCliAppConfig,
9
  resolveUserConfigConventionalPath,
10
  resolveUserConfigPath,
11
  transformUserConfigToPlugin,
12
} from '../../config/index.js'
13
import type { BuildCommand } from './types.js'
14

15
const log = debug('vuepress:cli/build')
3✔
16

17
export const createBuild =
18
  (defaultAppConfig: Partial<AppConfig>): BuildCommand =>
3✔
19
  async (sourceDir = '.', commandOptions = {}): Promise<void> => {
×
20
    const start = Date.now()
×
21

22
    log(`commandOptions:`, commandOptions)
×
23

24
    if (process.env.NODE_ENV === undefined) {
×
25
      process.env.NODE_ENV = 'production'
×
26
    }
27

28
    // resolve app config from cli options
NEW
29
    const cliAppConfig = await resolveCliAppConfig(sourceDir, commandOptions)
×
30

31
    // resolve user config file
32
    const userConfigPath = commandOptions.config
×
33
      ? resolveUserConfigPath(commandOptions.config)
34
      : resolveUserConfigConventionalPath(cliAppConfig.source)
35
    log(`userConfigPath:`, userConfigPath)
×
36
    const { userConfig } = await loadUserConfig(userConfigPath)
×
37

38
    // resolve the final app config to use
39
    const appConfig = resolveAppConfig({
×
40
      defaultAppConfig,
41
      cliAppConfig,
42
      userConfig,
43
    })
44
    if (appConfig === null) {
×
45
      return
×
46
    }
47

48
    // create vuepress app
49
    const app = createBuildApp(appConfig)
×
50

51
    // use user-config plugin
52
    app.use(transformUserConfigToPlugin(userConfig, cliAppConfig.source))
×
53

54
    // clean temp and cache
55
    if (commandOptions.cleanTemp === true) {
×
56
      await withSpinner('Cleaning temp')(() => {
×
57
        return fs.remove(app.dir.temp())
×
58
      })
59
    }
60
    if (commandOptions.cleanCache === true) {
×
61
      await withSpinner('Cleaning cache')(() => {
×
62
        return fs.remove(app.dir.cache())
×
63
      })
64
    }
65

66
    // empty dest directory
67
    await fs.emptyDir(app.dir.dest())
×
68

69
    // initialize and prepare
70
    await withSpinner('Initializing and preparing data')(async () => {
×
71
      await app.init()
×
72
      await app.prepare()
×
73
    })
74

75
    // build
76
    await app.build()
×
77

78
    // plugin hook: onGenerated
79
    await app.pluginApi.hooks.onGenerated.process(app)
×
80

81
    logger.success(
×
82
      `VuePress build completed in ${formatMs(Date.now() - start)}!`,
83
    )
84
  }
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc