Skip to content

Commit

Permalink
refactor($core): use upath
Browse files Browse the repository at this point in the history
  • Loading branch information
ulivz committed Sep 28, 2018
1 parent e2253c2 commit 19e73d7
Show file tree
Hide file tree
Showing 38 changed files with 39 additions and 52 deletions.
2 changes: 1 addition & 1 deletion packages/@vuepress/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exports.bootstrap = function ({
plugins,
theme
} = {}) {
const path = require('path')
const { path } = require('@vuepress/shared-utils')
const { dev, build, eject } = require('@vuepress/core')

program
Expand Down
3 changes: 1 addition & 2 deletions packages/@vuepress/core/__tests__/prepare/prepare.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { fs } = require('@vuepress/shared-utils')
const path = require('path')
const { fs, path } = require('@vuepress/shared-utils')
const prepare = require('../../lib/prepare')

const docsBaseDir = path.resolve(__dirname, 'fixtures')
Expand Down
3 changes: 1 addition & 2 deletions packages/@vuepress/core/__tests__/prepare/util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require('path')
const { fs } = require('@vuepress/shared-utils')
const { fs, path } = require('@vuepress/shared-utils')
const AppContext = require('../../lib/prepare/AppContext')
const createMarkdown = require('../../../markdown/lib/index')

Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/core/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module.exports = async function build (sourceDir, cliOptions = {}) {
process.env.NODE_ENV = 'production'

const path = require('path')
const { path } = require('@vuepress/shared-utils')
const webpack = require('webpack')
const readline = require('readline')
const escape = require('escape-html')
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/core/lib/dev.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

module.exports = async function dev (sourceDir, cliOptions = {}) {
const path = require('path')
const { path } = require('@vuepress/shared-utils')
const webpack = require('webpack')
const chokidar = require('chokidar')
const serve = require('webpack-serve')
Expand Down
3 changes: 1 addition & 2 deletions packages/@vuepress/core/lib/eject.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'

const path = require('path')
const { chalk, fs, logger } = require('@vuepress/shared-utils')
const { path, chalk, fs, logger } = require('@vuepress/shared-utils')

module.exports = async (dir) => {
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/core/lib/internal-plugins/enhanceApp.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const { path } = require('@vuepress/shared-utils')

module.exports = (options, context) => ({
name: '@vuepress/internal-enhance-app',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module.exports = (options, ctx) => ({

// user's palette can override theme's palette.
const paletteContent = themePaletteContent + userPaletteContent
console.log(paletteContent)
await writeTemp('palette.styl', paletteContent)
}
})
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/core/lib/internal-plugins/rootMixins.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const { path } = require('@vuepress/shared-utils')
const { codegen: { pathsToModuleCode }} = require('@vuepress/shared-utils')

module.exports = (options, context, api) => ({
Expand Down
5 changes: 2 additions & 3 deletions packages/@vuepress/core/lib/internal-plugins/style/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require('path')
const { fs, logger, chalk } = require('@vuepress/shared-utils')
const { fs, path, logger, chalk } = require('@vuepress/shared-utils')

module.exports = (options, context) => ({
name: '@vuepress/internal-style',
Expand All @@ -17,7 +16,7 @@ module.exports = (options, context) => ({
}

// style.styl API.
const stylePath = path.resolve(sourceDir, '.vuepress/style.styl').replace(/[\\]+/g, '/')
const stylePath = path.resolve(sourceDir, '.vuepress/style.styl')
const hasUserStyle = fs.existsSync(stylePath)
await writeTemp('style.styl', hasUserStyle ? `@import(${JSON.stringify(stylePath)})` : ``)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require('path')
const { fs } = require('@vuepress/shared-utils')
const { fs, path } = require('@vuepress/shared-utils')

const DIR = 'transform'

Expand Down
3 changes: 1 addition & 2 deletions packages/@vuepress/core/lib/prepare/AppContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
* Module dependencies.
*/

const path = require('path')
const createMarkdown = require('./createMarkdown')
const loadConfig = require('./loadConfig')
const loadTheme = require('./loadTheme')
const {
fs, logger, chalk, globby, sort,
fs, path, logger, chalk, globby, sort,
datatypes: { isFunction },
fallback: { fsExistsFallback }
} = require('@vuepress/shared-utils')
Expand Down
3 changes: 1 addition & 2 deletions packages/@vuepress/core/lib/prepare/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
* Module dependencies.
*/

const path = require('path')
const slugify = require('../../../markdown/lib/slugify')
const { inferDate, DATE_RE } = require('../util/index')
const { extractHeaders, fs, fileToPath, parseFrontmatter, getPermalink, inferTitle } = require('@vuepress/shared-utils')
const { extractHeaders, fs, path, fileToPath, parseFrontmatter, getPermalink, inferTitle } = require('@vuepress/shared-utils')

/**
* Expose Page class.
Expand Down
3 changes: 1 addition & 2 deletions packages/@vuepress/core/lib/prepare/loadConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* Module dependencies.
*/

const { fs } = require('@vuepress/shared-utils')
const path = require('path')
const { fs, path } = require('@vuepress/shared-utils')
const yamlParser = require('js-yaml')
const tomlParser = require('toml')

Expand Down
3 changes: 1 addition & 2 deletions packages/@vuepress/core/lib/prepare/loadTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
* Module dependencies.
*/

const path = require('path')
const fs = require('fs')
const {
fs, path,
shortcutPackageResolver: { resolveTheme },
datatypes: { isString },
logger, chalk
Expand Down
3 changes: 1 addition & 2 deletions packages/@vuepress/core/lib/webpack/createBaseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* Module dependencies.
*/

const path = require('path')
const { fs, logger, chalk } = require('@vuepress/shared-utils')
const { fs, path, logger, chalk } = require('@vuepress/shared-utils')

/**
* Expose createBaseConfig method.
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/core/lib/webpack/createClientConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

module.exports = function createClientConfig (ctx) {
const path = require('path')
const { path } = require('@vuepress/shared-utils')
const WebpackBar = require('webpackbar')
const createBaseConfig = require('./createBaseConfig')

Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/core/lib/webpack/createServerConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

module.exports = function createServerConfig (ctx) {
const fs = require('fs')
const path = require('path')
const { path } = require('@vuepress/shared-utils')
const WebpackBar = require('webpackbar')
const createBaseConfig = require('./createBaseConfig')
const VueSSRServerPlugin = require('vue-server-renderer/server-plugin')
Expand Down
3 changes: 1 addition & 2 deletions packages/@vuepress/markdown-loader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
* Module dependencies.
*/

const path = require('path')
const { EventEmitter } = require('events')
const { getOptions } = require('loader-utils')
const { fs, hash, parseFrontmatter, inferTitle, extractHeaders } = require('@vuepress/shared-utils')
const { fs, path, hash, parseFrontmatter, inferTitle, extractHeaders } = require('@vuepress/shared-utils')
const LRU = require('lru-cache')
const md = require('@vuepress/markdown')

Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/plugin-active-header-links/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const { path } = require('@vuepress/shared-utils')

module.exports = {
clientRootMixin: path.resolve(__dirname, 'mixin.js')
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/plugin-back-to-top/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const { path } = require('@vuepress/shared-utils')

module.exports = (options, context) => ({
enhanceAppFiles: [
Expand Down
3 changes: 1 addition & 2 deletions packages/@vuepress/plugin-blog/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require('path')
const { datatypes: { isString }} = require('@vuepress/shared-utils')
const { path, datatypes: { isString }} = require('@vuepress/shared-utils')

module.exports = (options, ctx) => {
const { layoutComponentMap } = ctx
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/plugin-google-analytics/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const { path } = require('@vuepress/shared-utils')

module.exports = (options = {}, context) => ({
define () {
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/plugin-i18n-ui/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const { path } = require('@vuepress/shared-utils')

module.exports = (pluginOptions = {}, context) => ({
name: 'i18n-ui',
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/plugin-medium-zoom/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const { path } = require('@vuepress/shared-utils')

module.exports = {
clientRootMixin: path.resolve(__dirname, 'mixin.js')
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/plugin-pagination/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const { path } = require('@vuepress/shared-utils')

function getIntervallers (max, interval) {
const count = Math.floor(max / interval)
Expand Down
3 changes: 1 addition & 2 deletions packages/@vuepress/plugin-pwa/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require('path')
const { logger, fs } = require('@vuepress/shared-utils')
const { logger, fs, path } = require('@vuepress/shared-utils')

module.exports = (options, context) => ({
ready () {
Expand Down
3 changes: 1 addition & 2 deletions packages/@vuepress/plugin-register-components/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { fs, globby } = require('@vuepress/shared-utils')
const path = require('path')
const { fs, path, globby } = require('@vuepress/shared-utils')

function fileToComponentName (file) {
return file
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/plugin-search/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const { path } = require('@vuepress/shared-utils')

module.exports = (options) => ({
alias: {
Expand Down
1 change: 1 addition & 0 deletions packages/@vuepress/shared-utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ exports.extractHeaders = require('./lib/extractHeaders')

exports.chalk = require('chalk')
exports.fs = require('fs-extra')
exports.path = require('upath')
exports.globby = require('globby')

exports.hash = require('hash-sum')
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/shared-utils/lib/module.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Midified from https://github.com/vuejs/vue-cli/blob/dev/packages/@0vue/cli-shared-utils/lib/module.js

const semver = require('semver')
const path = require('path')
const path = require('upath')
const fs = require('fs-extra')
const { isTest } = require('./env')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs')
const path = require('path')
const path = require('upath')
const chalk = require('chalk')
const { isDebug } = require('./env')
const { resolveModule, loadModule } = require('./module')
Expand Down
3 changes: 2 additions & 1 deletion packages/@vuepress/shared-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"escape-html": "^1.0.3",
"fs-extra": "^5.0.0",
"globby": "^8.0.1",
"hash-sum": "^1.0.2"
"hash-sum": "^1.0.2",
"upath": "^1.1.0"
},
"author": "ULIVZ <[email protected]>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/test-utils/jest/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// https://github.com/facebook/jest/tree/master/packages/babel-jest
// TODO remove 'babel-core@^7.0.0-0' when babel-jest can work with '@babel/core'

const path = require('path')
const { path } = require('@vuepress/shared-utils')

module.exports = {
rootDir: path.resolve(__dirname, '..'),
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/theme-default/plugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const { path } = require('@vuepress/shared-utils')

module.exports = (options, context) => ({
name: 'default-theme',
Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// create package.json and README for packages that don't have one yet

const fs = require('fs')
const path = require('path')
const { path } = require('@vuepress/shared-utils')
const baseVersion = require('../packages/@vuepress/core/package.json').version

const packagesDir = path.resolve(__dirname, '../packages/@vuepress')
Expand Down
2 changes: 1 addition & 1 deletion scripts/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const { path } = require('@vuepress/shared-utils')
const createJestConfig = require('@vuepress/test-utils/createJestConfig')

module.exports = createJestConfig({
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8891,7 +8891,7 @@ unzip-response@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97"

upath@^1.0.5:
upath@^1.0.5, upath@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/upath/-/upath-1.1.0.tgz#35256597e46a581db4793d0ce47fa9aebfc9fabd"

Expand Down

0 comments on commit 19e73d7

Please sign in to comment.