This commit is contained in:
2023-08-11 10:45:20 +08:00
commit 161ca982f3
31850 changed files with 2706500 additions and 0 deletions

12
node_modules/@vue/cli-shared-utils/lib/_silence.js generated vendored Normal file
View File

@ -0,0 +1,12 @@
module.exports = function silence (logName, exports) {
const logs = {}
Object.keys(exports).forEach(key => {
if (key !== 'error') {
exports[key] = (...args) => {
if (!logs[key]) logs[key] = []
logs[key].push(args)
}
}
})
exports[logName] = logs
}

218
node_modules/@vue/cli-shared-utils/lib/env.js generated vendored Normal file
View File

@ -0,0 +1,218 @@
const { execSync } = require('child_process')
const fs = require('fs')
const path = require('path')
const LRU = require('lru-cache')
const semver = require('semver')
let _hasYarn
const _yarnProjects = new LRU({
max: 10,
maxAge: 1000
})
let _hasGit
const _gitProjects = new LRU({
max: 10,
maxAge: 1000
})
// env detection
exports.hasYarn = () => {
if (process.env.VUE_CLI_TEST) {
return true
}
if (_hasYarn != null) {
return _hasYarn
}
try {
execSync('yarn --version', { stdio: 'ignore' })
return (_hasYarn = true)
} catch (e) {
return (_hasYarn = false)
}
}
exports.hasProjectYarn = (cwd) => {
if (_yarnProjects.has(cwd)) {
return checkYarn(_yarnProjects.get(cwd))
}
const lockFile = path.join(cwd, 'yarn.lock')
const result = fs.existsSync(lockFile)
_yarnProjects.set(cwd, result)
return checkYarn(result)
}
function checkYarn (result) {
if (result && !exports.hasYarn()) throw new Error(`The project seems to require yarn but it's not installed.`)
return result
}
exports.hasGit = () => {
if (process.env.VUE_CLI_TEST) {
return true
}
if (_hasGit != null) {
return _hasGit
}
try {
execSync('git --version', { stdio: 'ignore' })
return (_hasGit = true)
} catch (e) {
return (_hasGit = false)
}
}
exports.hasProjectGit = (cwd) => {
if (_gitProjects.has(cwd)) {
return _gitProjects.get(cwd)
}
let result
try {
execSync('git status', { stdio: 'ignore', cwd })
result = true
} catch (e) {
result = false
}
_gitProjects.set(cwd, result)
return result
}
let _hasPnpm
let _pnpmVersion
const _pnpmProjects = new LRU({
max: 10,
maxAge: 1000
})
function getPnpmVersion () {
if (_pnpmVersion != null) {
return _pnpmVersion
}
try {
_pnpmVersion = execSync('pnpm --version', {
stdio: ['pipe', 'pipe', 'ignore']
}).toString()
// there's a critical bug in pnpm 2
// https://github.com/pnpm/pnpm/issues/1678#issuecomment-469981972
// so we only support pnpm >= 3.0.0
_hasPnpm = true
} catch (e) {}
return _pnpmVersion || '0.0.0'
}
exports.hasPnpmVersionOrLater = (version) => {
if (process.env.VUE_CLI_TEST) {
return true
}
return semver.gte(getPnpmVersion(), version)
}
exports.hasPnpm3OrLater = () => {
return this.hasPnpmVersionOrLater('3.0.0')
}
exports.hasProjectPnpm = (cwd) => {
if (_pnpmProjects.has(cwd)) {
return checkPnpm(_pnpmProjects.get(cwd))
}
const lockFile = path.join(cwd, 'pnpm-lock.yaml')
const result = fs.existsSync(lockFile)
_pnpmProjects.set(cwd, result)
return checkPnpm(result)
}
function checkPnpm (result) {
if (result && !exports.hasPnpm3OrLater()) {
throw new Error(`The project seems to require pnpm${_hasPnpm ? ' >= 3' : ''} but it's not installed.`)
}
return result
}
const _npmProjects = new LRU({
max: 10,
maxAge: 1000
})
exports.hasProjectNpm = (cwd) => {
if (_npmProjects.has(cwd)) {
return _npmProjects.get(cwd)
}
const lockFile = path.join(cwd, 'package-lock.json')
const result = fs.existsSync(lockFile)
_npmProjects.set(cwd, result)
return result
}
// OS
exports.isWindows = process.platform === 'win32'
exports.isMacintosh = process.platform === 'darwin'
exports.isLinux = process.platform === 'linux'
const browsers = {}
let hasCheckedBrowsers = false
function tryRun (cmd) {
try {
return execSync(cmd, {
stdio: [0, 'pipe', 'ignore'],
timeout: 10000
}).toString().trim()
} catch (e) {
return ''
}
}
function getLinuxAppVersion (binary) {
return tryRun(`${binary} --version`).replace(/^.* ([^ ]*)/g, '$1')
}
function getMacAppVersion (bundleIdentifier) {
const bundlePath = tryRun(`mdfind "kMDItemCFBundleIdentifier=='${bundleIdentifier}'"`)
if (bundlePath) {
return tryRun(`/usr/libexec/PlistBuddy -c Print:CFBundleShortVersionString ${
bundlePath.replace(/(\s)/g, '\\ ')
}/Contents/Info.plist`)
}
}
exports.getInstalledBrowsers = () => {
if (hasCheckedBrowsers) {
return browsers
}
hasCheckedBrowsers = true
if (exports.isLinux) {
browsers.chrome = getLinuxAppVersion('google-chrome')
browsers.firefox = getLinuxAppVersion('firefox')
} else if (exports.isMacintosh) {
browsers.chrome = getMacAppVersion('com.google.Chrome')
browsers.firefox = getMacAppVersion('org.mozilla.firefox')
} else if (exports.isWindows) {
// get chrome stable version
// https://stackoverflow.com/a/51773107/2302258
const chromeQueryResult = tryRun(
'reg query "HKLM\\Software\\Google\\Update\\Clients\\{8A69D345-D564-463c-AFF1-A69D9E530F96}" /v pv /reg:32'
) || tryRun(
'reg query "HKCU\\Software\\Google\\Update\\Clients\\{8A69D345-D564-463c-AFF1-A69D9E530F96}" /v pv /reg:32'
)
if (chromeQueryResult) {
const matched = chromeQueryResult.match(/REG_SZ\s+(\S*)$/)
browsers.chrome = matched && matched[1]
}
// get firefox version
// https://community.spiceworks.com/topic/111518-how-to-determine-version-of-installed-firefox-in-windows-batchscript
const ffQueryResult = tryRun(
'reg query "HKLM\\Software\\Mozilla\\Mozilla Firefox" /v CurrentVersion'
)
if (ffQueryResult) {
const matched = ffQueryResult.match(/REG_SZ\s+(\S*)$/)
browsers.firefox = matched && matched[1]
}
}
return browsers
}

9
node_modules/@vue/cli-shared-utils/lib/exit.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
exports.exitProcess = !process.env.VUE_CLI_API_MODE && !process.env.VUE_CLI_TEST
exports.exit = function (code) {
if (exports.exitProcess) {
process.exit(code)
} else if (code > 0) {
throw new Error(`Process exited with code ${code}`)
}
}

142
node_modules/@vue/cli-shared-utils/lib/ipc.js generated vendored Normal file
View File

@ -0,0 +1,142 @@
const ipc = require('@achrinza/node-ipc')
const DEFAULT_ID = process.env.VUE_CLI_IPC || 'vue-cli'
const DEFAULT_IDLE_TIMEOUT = 3000
const DEFAULT_OPTIONS = {
networkId: DEFAULT_ID,
autoConnect: true,
disconnectOnIdle: false,
idleTimeout: DEFAULT_IDLE_TIMEOUT,
namespaceOnProject: true
}
const PROJECT_ID = process.env.VUE_CLI_PROJECT_ID
exports.IpcMessenger = class IpcMessenger {
constructor (options = {}) {
options = Object.assign({}, DEFAULT_OPTIONS, options)
ipc.config.id = this.id = options.networkId
ipc.config.retry = 1500
ipc.config.silent = true
this.connected = false
this.connecting = false
this.disconnecting = false
this.queue = null
this.options = options
this.listeners = []
this.disconnectTimeout = 15000
this.idleTimer = null
// Prevent forced process exit
// (or else ipc messages may not be sent before kill)
process.exit = code => {
process.exitCode = code
}
this._reset()
}
checkConnection () {
if (!ipc.of[this.id]) {
this.connected = false
}
}
send (data, type = 'message') {
this.checkConnection()
if (this.connected) {
if (this.options.namespaceOnProject && PROJECT_ID) {
data = {
_projectId: PROJECT_ID,
_data: data
}
}
ipc.of[this.id].emit(type, data)
clearTimeout(this.idleTimer)
if (this.options.disconnectOnIdle) {
this.idleTimer = setTimeout(() => {
this.disconnect()
}, this.options.idleTimeout)
}
} else {
this.queue.push(data)
if (this.options.autoConnect && !this.connecting) {
this.connect()
}
}
}
connect () {
this.checkConnection()
if (this.connected || this.connecting) return
this.connecting = true
this.disconnecting = false
ipc.connectTo(this.id, () => {
this.connected = true
this.connecting = false
this.queue && this.queue.forEach(data => this.send(data))
this.queue = null
ipc.of[this.id].on('message', this._onMessage)
})
}
disconnect () {
this.checkConnection()
if (!this.connected || this.disconnecting) return
this.disconnecting = true
this.connecting = false
const ipcTimer = setTimeout(() => {
this._disconnect()
}, this.disconnectTimeout)
this.send({ done: true }, 'ack')
ipc.of[this.id].on('ack', data => {
if (data.ok) {
clearTimeout(ipcTimer)
this._disconnect()
}
})
}
on (listener) {
this.listeners.push(listener)
}
off (listener) {
const index = this.listeners.indexOf(listener)
if (index !== -1) this.listeners.splice(index, 1)
}
_reset () {
this.queue = []
this.connected = false
}
_disconnect () {
this.connected = false
this.disconnecting = false
ipc.disconnect(this.id)
this._reset()
}
_onMessage (data) {
this.listeners.forEach(fn => {
if (this.options.namespaceOnProject && data._projectId) {
if (data._projectId === PROJECT_ID) {
data = data._data
} else {
return
}
}
fn(data)
})
}
}

16
node_modules/@vue/cli-shared-utils/lib/launch.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
const launch = require('launch-editor')
exports.launch = (...args) => {
const file = args[0]
console.log(`Opening ${file}...`)
let cb = args[args.length - 1]
if (typeof cb !== 'function') {
cb = null
}
launch(...args, (fileName, errorMessage) => {
console.error(`Unable to open '${fileName}'`, errorMessage)
console.log(`Try setting the EDITOR env variable. More info: https://github.com/yyx990803/launch-editor`)
if (cb) cb(fileName, errorMessage)
})
}

75
node_modules/@vue/cli-shared-utils/lib/logger.js generated vendored Normal file
View File

@ -0,0 +1,75 @@
const chalk = require('chalk')
const stripAnsi = require('strip-ansi')
const readline = require('readline')
const EventEmitter = require('events')
const { stopSpinner } = require('./spinner')
exports.events = new EventEmitter()
function _log (type, tag, message) {
if (process.env.VUE_CLI_API_MODE && message) {
exports.events.emit('log', {
message,
type,
tag
})
}
}
const format = (label, msg) => {
return msg.split('\n').map((line, i) => {
return i === 0
? `${label} ${line}`
: line.padStart(stripAnsi(label).length + line.length + 1)
}).join('\n')
}
const chalkTag = msg => chalk.bgBlackBright.white.dim(` ${msg} `)
exports.log = (msg = '', tag = null) => {
tag ? console.log(format(chalkTag(tag), msg)) : console.log(msg)
_log('log', tag, msg)
}
exports.info = (msg, tag = null) => {
console.log(format(chalk.bgBlue.black(' INFO ') + (tag ? chalkTag(tag) : ''), msg))
_log('info', tag, msg)
}
exports.done = (msg, tag = null) => {
console.log(format(chalk.bgGreen.black(' DONE ') + (tag ? chalkTag(tag) : ''), msg))
_log('done', tag, msg)
}
exports.warn = (msg, tag = null) => {
console.warn(format(chalk.bgYellow.black(' WARN ') + (tag ? chalkTag(tag) : ''), chalk.yellow(msg)))
_log('warn', tag, msg)
}
exports.error = (msg, tag = null) => {
stopSpinner()
console.error(format(chalk.bgRed(' ERROR ') + (tag ? chalkTag(tag) : ''), chalk.red(msg)))
_log('error', tag, msg)
if (msg instanceof Error) {
console.error(msg.stack)
_log('error', tag, msg.stack)
}
}
exports.clearConsole = title => {
if (process.stdout.isTTY) {
const blank = '\n'.repeat(process.stdout.rows)
console.log(blank)
readline.cursorTo(process.stdout, 0, 0)
readline.clearScreenDown(process.stdout)
if (title) {
console.log(title)
}
}
}
// silent all logs except errors during tests and keep record
if (process.env.VUE_CLI_TEST) {
require('./_silence')('logs', exports)
}

108
node_modules/@vue/cli-shared-utils/lib/module.js generated vendored Normal file
View File

@ -0,0 +1,108 @@
const Module = require('module')
const path = require('path')
const semver = require('semver')
// https://github.com/benmosher/eslint-plugin-import/pull/1591
// https://github.com/benmosher/eslint-plugin-import/pull/1602
// Polyfill Node's `Module.createRequireFromPath` if not present (added in Node v10.12.0)
// Use `Module.createRequire` if available (added in Node v12.2.0)
// eslint-disable-next-line node/no-deprecated-api
const createRequire = Module.createRequire || Module.createRequireFromPath || function (filename) {
const mod = new Module(filename, null)
mod.filename = filename
mod.paths = Module._nodeModulePaths(path.dirname(filename))
mod._compile(`module.exports = require;`, filename)
return mod.exports
}
function resolveFallback (request, options) {
const isMain = false
const fakeParent = new Module('', null)
const paths = []
for (let i = 0; i < options.paths.length; i++) {
const p = options.paths[i]
fakeParent.paths = Module._nodeModulePaths(p)
const lookupPaths = Module._resolveLookupPaths(request, fakeParent, true)
if (!paths.includes(p)) paths.push(p)
for (let j = 0; j < lookupPaths.length; j++) {
if (!paths.includes(lookupPaths[j])) paths.push(lookupPaths[j])
}
}
const filename = Module._findPath(request, paths, isMain)
if (!filename) {
const err = new Error(`Cannot find module '${request}'`)
err.code = 'MODULE_NOT_FOUND'
throw err
}
return filename
}
const resolve = semver.satisfies(process.version, '>=10.0.0')
? require.resolve
: resolveFallback
exports.resolveModule = function (request, context) {
// createRequire doesn't work with jest mock modules
// (which we used in migrator for inquirer, and in tests for cli-service)
// TODO: it's supported in Jest 25
if (process.env.VUE_CLI_TEST && (request.endsWith('migrator') || context === '/')) {
return request
}
let resolvedPath
try {
try {
resolvedPath = createRequire(path.resolve(context, 'package.json')).resolve(request)
} catch (e) {
resolvedPath = resolve(request, { paths: [context] })
}
} catch (e) {}
return resolvedPath
}
exports.loadModule = function (request, context, force = false) {
// createRequire doesn't work with jest mocked fs
// (which we used in tests for cli-service)
if (process.env.VUE_CLI_TEST && context === '/') {
return require(request)
}
try {
return createRequire(path.resolve(context, 'package.json'))(request)
} catch (e) {
const resolvedPath = exports.resolveModule(request, context)
if (resolvedPath) {
if (force) {
clearRequireCache(resolvedPath)
}
return require(resolvedPath)
}
}
}
exports.clearModule = function (request, context) {
const resolvedPath = exports.resolveModule(request, context)
if (resolvedPath) {
clearRequireCache(resolvedPath)
}
}
function clearRequireCache (id, map = new Map()) {
const module = require.cache[id]
if (module) {
map.set(id, true)
// Clear children modules
module.children.forEach(child => {
if (!map.get(child.id)) clearRequireCache(child.id, map)
})
delete require.cache[id]
}
}

49
node_modules/@vue/cli-shared-utils/lib/object.js generated vendored Normal file
View File

@ -0,0 +1,49 @@
exports.set = function (target, path, value) {
const fields = path.split('.')
let obj = target
const l = fields.length
for (let i = 0; i < l - 1; i++) {
const key = fields[i]
if (!obj[key]) {
obj[key] = {}
}
obj = obj[key]
}
obj[fields[l - 1]] = value
}
exports.get = function (target, path) {
const fields = path.split('.')
let obj = target
const l = fields.length
for (let i = 0; i < l - 1; i++) {
const key = fields[i]
if (!obj[key]) {
return undefined
}
obj = obj[key]
}
return obj[fields[l - 1]]
}
exports.unset = function (target, path) {
const fields = path.split('.')
let obj = target
const l = fields.length
const objs = []
for (let i = 0; i < l - 1; i++) {
const key = fields[i]
if (!obj[key]) {
return
}
objs.unshift({ parent: obj, key, value: obj[key] })
obj = obj[key]
}
delete obj[fields[l - 1]]
// Clear empty objects
for (const { parent, key, value } of objs) {
if (!Object.keys(value).length) {
delete parent[key]
}
}
}

122
node_modules/@vue/cli-shared-utils/lib/openBrowser.js generated vendored Normal file
View File

@ -0,0 +1,122 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file at
* https://github.com/facebook/create-react-app/blob/master/LICENSE
*/
const open = require('open')
const execa = require('execa')
const chalk = require('chalk')
const execSync = require('child_process').execSync
// https://github.com/sindresorhus/open#app
const OSX_CHROME = 'google chrome'
const Actions = Object.freeze({
NONE: 0,
BROWSER: 1,
SCRIPT: 2
})
function getBrowserEnv () {
// Attempt to honor this environment variable.
// It is specific to the operating system.
// See https://github.com/sindresorhus/open#app for documentation.
const value = process.env.BROWSER
let action
if (!value) {
// Default.
action = Actions.BROWSER
} else if (value.toLowerCase().endsWith('.js')) {
action = Actions.SCRIPT
} else if (value.toLowerCase() === 'none') {
action = Actions.NONE
} else {
action = Actions.BROWSER
}
return { action, value }
}
function executeNodeScript (scriptPath, url) {
const extraArgs = process.argv.slice(2)
const child = execa('node', [scriptPath, ...extraArgs, url], {
stdio: 'inherit'
})
child.on('close', code => {
if (code !== 0) {
console.log()
console.log(
chalk.red(
'The script specified as BROWSER environment variable failed.'
)
)
console.log(chalk.cyan(scriptPath) + ' exited with code ' + code + '.')
console.log()
}
})
return true
}
function startBrowserProcess (browser, url) {
// If we're on OS X, the user hasn't specifically
// requested a different browser, we can try opening
// Chrome with AppleScript. This lets us reuse an
// existing tab when possible instead of creating a new one.
const shouldTryOpenChromeWithAppleScript =
process.platform === 'darwin' &&
(typeof browser !== 'string' || browser === OSX_CHROME)
if (shouldTryOpenChromeWithAppleScript) {
try {
// Try our best to reuse existing tab
// on OS X Google Chrome with AppleScript
execSync('ps cax | grep "Google Chrome"')
execSync('osascript openChrome.applescript "' + encodeURI(url) + '"', {
cwd: __dirname,
stdio: 'ignore'
})
return true
} catch (err) {
// Ignore errors.
}
}
// Another special case: on OS X, check if BROWSER has been set to "open".
// In this case, instead of passing the string `open` to `open` function (which won't work),
// just ignore it (thus ensuring the intended behavior, i.e. opening the system browser):
// https://github.com/facebook/create-react-app/pull/1690#issuecomment-283518768
if (process.platform === 'darwin' && browser === 'open') {
browser = undefined
}
// Fallback to open
// (It will always open new tab)
try {
const options = { app: { name: browser }, url: true }
open(url, options).catch(() => {}) // Prevent `unhandledRejection` error.
return true
} catch (err) {
return false
}
}
/**
* Reads the BROWSER environment variable and decides what to do with it. Returns
* true if it opened a browser or ran a node.js script, otherwise false.
*/
exports.openBrowser = function (url) {
const { action, value } = getBrowserEnv()
switch (action) {
case Actions.NONE:
// Special case: BROWSER="none" will prevent opening completely.
return false
case Actions.SCRIPT:
return executeNodeScript(value, url)
case Actions.BROWSER:
return startBrowserProcess(value, url)
default:
throw new Error('Not implemented.')
}
}

View File

@ -0,0 +1,86 @@
(*
Copyright (c) 2015-present, Facebook, Inc.
This source code is licensed under the MIT license found in the
LICENSE file at
https://github.com/facebookincubator/create-react-app/blob/master/LICENSE
*)
property targetTab: null
property targetTabIndex: -1
property targetWindow: null
on run argv
set theURL to item 1 of argv
with timeout of 2 seconds
tell application "Chrome"
if (count every window) = 0 then
make new window
end if
-- 1: Looking for tab running debugger
-- then, Reload debugging tab if found
-- then return
set found to my lookupTabWithUrl(theURL)
if found then
set targetWindow's active tab index to targetTabIndex
tell targetTab to reload
tell targetWindow to activate
set index of targetWindow to 1
return
end if
-- 2: Looking for Empty tab
-- In case debugging tab was not found
-- We try to find an empty tab instead
set found to my lookupTabWithUrl("chrome://newtab/")
if found then
set targetWindow's active tab index to targetTabIndex
set URL of targetTab to theURL
tell targetWindow to activate
return
end if
-- 3: Create new tab
-- both debugging and empty tab were not found
-- make a new tab with url
tell window 1
activate
make new tab with properties {URL:theURL}
end tell
end tell
end timeout
end run
-- Function:
-- Lookup tab with given url
-- if found, store tab, index, and window in properties
-- (properties were declared on top of file)
on lookupTabWithUrl(lookupUrl)
tell application "Chrome"
-- Find a tab with the given url
set found to false
set theTabIndex to -1
repeat with theWindow in every window
set theTabIndex to 0
repeat with theTab in every tab of theWindow
set theTabIndex to theTabIndex + 1
if (theTab's URL as string) contains lookupUrl then
-- assign tab, tab index, and window to properties
set targetTab to theTab
set targetTabIndex to theTabIndex
set targetWindow to theWindow
set found to true
exit repeat
end if
end repeat
if found then
exit repeat
end if
end repeat
end tell
return found
end lookupTabWithUrl

10
node_modules/@vue/cli-shared-utils/lib/pkg.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
const fs = require('fs')
const path = require('path')
const readPkg = require('read-pkg')
exports.resolvePkg = function (context) {
if (fs.existsSync(path.join(context, 'package.json'))) {
return readPkg.sync({ cwd: context })
}
return {}
}

110
node_modules/@vue/cli-shared-utils/lib/pluginOrder.js generated vendored Normal file
View File

@ -0,0 +1,110 @@
// @ts-check
const { warn } = require('./logger')
/** @typedef {{after?: string|Array<string>}} Apply */
/** @typedef {{id: string, apply: Apply}} Plugin */
/** @typedef {{after: Set<string>}} OrderParams */
/** @type {Map<string, OrderParams>} */
const orderParamsCache = new Map()
/**
*
* @param {Plugin} plugin
* @returns {OrderParams}
*/
function getOrderParams (plugin) {
if (!process.env.VUE_CLI_TEST && orderParamsCache.has(plugin.id)) {
return orderParamsCache.get(plugin.id)
}
const apply = plugin.apply
let after = new Set()
if (typeof apply.after === 'string') {
after = new Set([apply.after])
} else if (Array.isArray(apply.after)) {
after = new Set(apply.after)
}
if (!process.env.VUE_CLI_TEST) {
orderParamsCache.set(plugin.id, { after })
}
return { after }
}
/**
* See leetcode 210
* @param {Array<Plugin>} plugins
* @returns {Array<Plugin>}
*/
function topologicalSorting (plugins) {
/** @type {Map<string, Plugin>} */
const pluginsMap = new Map(plugins.map(p => [p.id, p]))
/** @type {Map<Plugin, number>} */
const indegrees = new Map()
/** @type {Map<Plugin, Array<Plugin>>} */
const graph = new Map()
plugins.forEach(p => {
const after = getOrderParams(p).after
indegrees.set(p, after.size)
if (after.size === 0) return
for (const id of after) {
const prerequisite = pluginsMap.get(id)
// remove invalid data
if (!prerequisite) {
indegrees.set(p, indegrees.get(p) - 1)
continue
}
if (!graph.has(prerequisite)) {
graph.set(prerequisite, [])
}
graph.get(prerequisite).push(p)
}
})
const res = []
const queue = []
indegrees.forEach((d, p) => {
if (d === 0) queue.push(p)
})
while (queue.length) {
const cur = queue.shift()
res.push(cur)
const neighbors = graph.get(cur)
if (!neighbors) continue
neighbors.forEach(n => {
const degree = indegrees.get(n) - 1
indegrees.set(n, degree)
if (degree === 0) {
queue.push(n)
}
})
}
const valid = res.length === plugins.length
if (!valid) {
warn(`No proper plugin execution order found.`)
return plugins
}
return res
}
/**
* Arrange plugins by 'after' property.
* @param {Array<Plugin>} plugins
* @returns {Array<Plugin>}
*/
function sortPlugins (plugins) {
if (plugins.length < 2) return plugins
return topologicalSorting(plugins)
}
module.exports = {
topologicalSorting,
sortPlugins
}

View File

@ -0,0 +1,82 @@
const pluginRE = /^(@vue\/|vue-|@[\w-]+(\.)?[\w-]+\/vue-)cli-plugin-/
const scopeRE = /^@[\w-]+(\.)?[\w-]+\//
const officialRE = /^@vue\//
const officialPlugins = [
'babel',
'e2e-cypress',
'e2e-nightwatch',
'e2e-webdriverio',
'eslint',
'pwa',
'router',
'typescript',
'unit-jest',
'unit-mocha',
'vuex',
'webpack-4'
]
exports.isPlugin = id => pluginRE.test(id)
exports.isOfficialPlugin = id => exports.isPlugin(id) && officialRE.test(id)
exports.toShortPluginId = id => id.replace(pluginRE, '')
exports.resolvePluginId = id => {
// already full id
// e.g. vue-cli-plugin-foo, @vue/cli-plugin-foo, @bar/vue-cli-plugin-foo
if (pluginRE.test(id)) {
return id
}
if (id === '@vue/cli-service') {
return id
}
if (officialPlugins.includes(id)) {
return `@vue/cli-plugin-${id}`
}
// scoped short
// e.g. @vue/foo, @bar/foo
if (id.charAt(0) === '@') {
const scopeMatch = id.match(scopeRE)
if (scopeMatch) {
const scope = scopeMatch[0]
const shortId = id.replace(scopeRE, '')
return `${scope}${scope === '@vue/' ? `` : `vue-`}cli-plugin-${shortId}`
}
}
// default short
// e.g. foo
return `vue-cli-plugin-${id}`
}
exports.matchesPluginId = (input, full) => {
const short = full.replace(pluginRE, '')
return (
// input is full
full === input ||
// input is short without scope
short === input ||
// input is short with scope
short === input.replace(scopeRE, '')
)
}
exports.getPluginLink = id => {
if (officialRE.test(id)) {
return `https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-${
exports.toShortPluginId(id)
}`
}
let pkg = {}
try {
pkg = require(`${id}/package.json`)
} catch (e) {}
return (
pkg.homepage ||
(pkg.repository && pkg.repository.url) ||
`https://www.npmjs.com/package/${id.replace(`/`, `%2F`)}`
)
}

13
node_modules/@vue/cli-shared-utils/lib/request.js generated vendored Normal file
View File

@ -0,0 +1,13 @@
exports.request = {
get (url, opts) {
// lazy require
const fetch = require('node-fetch')
const reqOpts = {
method: 'GET',
timeout: 30000,
...opts
}
return fetch(url, reqOpts).then(result => result.json())
}
}

64
node_modules/@vue/cli-shared-utils/lib/spinner.js generated vendored Normal file
View File

@ -0,0 +1,64 @@
const ora = require('ora')
const chalk = require('chalk')
const spinner = ora()
let lastMsg = null
let isPaused = false
exports.logWithSpinner = (symbol, msg) => {
if (!msg) {
msg = symbol
symbol = chalk.green('✔')
}
if (lastMsg) {
spinner.stopAndPersist({
symbol: lastMsg.symbol,
text: lastMsg.text
})
}
spinner.text = ' ' + msg
lastMsg = {
symbol: symbol + ' ',
text: msg
}
spinner.start()
}
exports.stopSpinner = (persist) => {
if (!spinner.isSpinning) {
return
}
if (lastMsg && persist !== false) {
spinner.stopAndPersist({
symbol: lastMsg.symbol,
text: lastMsg.text
})
} else {
spinner.stop()
}
lastMsg = null
}
exports.pauseSpinner = () => {
if (spinner.isSpinning) {
spinner.stop()
isPaused = true
}
}
exports.resumeSpinner = () => {
if (isPaused) {
spinner.start()
isPaused = false
}
}
exports.failSpinner = (text) => {
spinner.fail(text)
}
// silent all logs except errors during tests and keep record
if (process.env.VUE_CLI_TEST) {
require('./_silence')('spinner', exports)
}

33
node_modules/@vue/cli-shared-utils/lib/validate.js generated vendored Normal file
View File

@ -0,0 +1,33 @@
const { exit } = require('./exit')
// proxy to joi for option validation
exports.createSchema = fn => {
const joi = require('joi')
let schema = fn(joi)
if (typeof schema === 'object' && typeof schema.validate !== 'function') {
schema = joi.object(schema)
}
return schema
}
exports.validate = (obj, schema, cb) => {
const { error } = schema.validate(obj)
if (error) {
cb(error.details[0].message)
if (process.env.VUE_CLI_TEST) {
throw error
} else {
exit(1)
}
}
}
exports.validateSync = (obj, schema) => {
const { error } = schema.validate(obj)
if (error) {
throw error
}
}