Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function () {
const localVue = createLocalVue()
localVue.use(Router)
// register global component
localVue.component('OutboundLink', mockComponent('outbound-link'))
localVue.component(siteData.pages[0].key, mockComponent('page-component'))
localVue.mixin(dataMixin(I18n, siteData))
return localVue
}
/* global VUEPRESS_VERSION, LAST_COMMIT_HASH*/
import { createApp } from '@vuepress/core/lib/app/app.js'
import { sync } from 'vuex-router-sync';
const { app, router } = createApp(false /* isServer */)
const store = app.$options.store
if (window.__INITIAL_STATE__) {
store.replaceState(window.__INITIAL_STATE__);
}
sync(store, router);
window.__VUEPRESS_VERSION__ = {
version: VUEPRESS_VERSION,
hash: LAST_COMMIT_HASH
}
router.onReady(() => {
if (!window.__INITIAL_STATE__) {
fetchMetadata(router.currentRoute);
}
/* global VUEPRESS_VERSION, LAST_COMMIT_HASH*/
import { createApp } from '@vuepress/core/lib/client/app.js'
import { sync } from 'vuex-router-sync'
const { app, router } = createApp(false /* isServer */)
const store = app.$options.store
if (window.__INITIAL_STATE__) {
store.replaceState(window.__INITIAL_STATE__)
}
sync(store, router)
window.__VUEPRESS_VERSION__ = {
version: VUEPRESS_VERSION,
hash: LAST_COMMIT_HASH
}
router.onReady(() => {
if (!window.__INITIAL_STATE__) {
fetchMetadata(router.currentRoute)
}
describe('dehydation', () => {
const app = createApp({
sourceDir: resolve(__dirname, 'docs'),
})
beforeAll(async () => {
await app.process()
await app.build()
}, 60000)
function testForFile (name, file = name) {
test(name, () => {
const html = readFileSync(resolve(app.outDir, file), 'utf8')
expect(html).toMatchSnapshot()
})
}
testForFile('404.html')
describe('plugin-public-files: source folder', () => {
const app = createApp({
sourceDir: resolve(__dirname, 'docs-1')
})
beforeAll(async () => {
await app.process()
await app.build()
}, 60000)
testForExistence(app, 'foo.txt')
testForExistence(app, 'baz.txt')
testForExistence(app, 'bar/foo.txt')
testForExistence(app, 'bar/baz.txt')
testForExistence(app, 'index.html')
testForExistence(app, 'readme.md', false)
testForExistence(app, '.dotfile', false)
testForExistence(app, '.dotfolder', false)
const { chalk } = require('@vuepress/shared-utils')
const semver = require('semver')
try {
require.resolve('@vuepress/core')
} catch (err) {
console.log(chalk.red(
`\n[vuepress] @vuepress/cli ` +
`requires @vuepress/core to be installed.\n`
))
process.exit(1)
}
const pkg = require('@vuepress/core/package.json')
const requiredVersion = pkg.engines.node
if (!semver.satisfies(process.version, requiredVersion)) {
console.log(chalk.red(
`\n[vuepress] minimum Node version not met:` +
`\nYou are using Node ${process.version}, but VuePress ` +
`requires Node ${requiredVersion}.\nPlease upgrade your Node version.\n`
))
process.exit(1)
}
const cli = require('cac')()
exports.cli = cli
exports.bootstrap = function ({
plugins,
theme
async beforeParse (subCli) {
const app = createApp({
sourceDir: sourceDir,
...options,
...commandoptions
})
await app.process()
app.pluginAPI.applySyncOption('extendCli', subCli, app)
console.log()
},
async afterParse (subCli) {
export default context => new Promise((resolve, reject) => {
originalServerEntry(context).then(app => {
const router = app.$options.router;
const store = app.$options.store;
sync(store, router);
router.onReady(() => {
const matchedComponents = router.getMatchedComponents();
if (!matchedComponents.length) {
return reject({ code: 404 })
}
const apiRoutePattern = /^\/api\//;
const currentRoutePath = router.currentRoute.path;
if (!apiRoutePattern.test(currentRoutePath)) {
return resolve(app);
}
export default context => new Promise((resolve, reject) => {
originalServerEntry(context).then(app => {
const router = app.$options.router
const store = app.$options.store
sync(store, router)
router.onReady(() => {
const matchedComponents = router.getMatchedComponents()
if (!matchedComponents.length) {
return reject({ code: 404 })
}
const apiRoutePattern = /^\/api\//
const currentRoutePath = router.currentRoute.path
if (!apiRoutePattern.test(currentRoutePath)) {
return resolve(app)
}
logger.developer('needPrepareBeforeLaunchCLI', needPrepareBeforeLaunchCLI)
if (needPrepareBeforeLaunchCLI) {
let app
let [, sourceDir] = argv
if (!sourceDir || sourceDir.startsWith('-')) {
sourceDir = inferredUserDocsDirectory
} else {
sourceDir = pwd
}
logger.setOptions({ logLevel: 1 })
if (sourceDir) {
app = createApp({ sourceDir, ...options })
await app.process()
app.pluginAPI.applySyncOption('extendCli', cli, app)
}
logger.setOptions({ logLevel: 3 })
}
}