@vuepress/shared-utils
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -52,5 +52,5 @@ "use strict"; | ||
if (!valid) { | ||
warnMsg = | ||
`expected a ${chalk_1.default.green(toNaturalMultiTypesLanguage(expectedTypes))} ` + | ||
`but got ${chalk_1.default.yellow(actualType)}.`; | ||
warnMsg | ||
= `expected a ${chalk_1.default.green(toNaturalMultiTypesLanguage(expectedTypes))} ` | ||
+ `but got ${chalk_1.default.yellow(actualType)}.`; | ||
} | ||
@@ -57,0 +57,0 @@ return { valid, warnMsg }; |
@@ -8,3 +8,3 @@ "use strict"; | ||
/** | ||
* Extract heeaders from markdown source content. | ||
* Extract headers from markdown source content. | ||
* | ||
@@ -26,7 +26,5 @@ * @param {string} content | ||
tokens.forEach((t, i) => { | ||
// @ts-ignore | ||
if (t.type === 'heading_open' && include.includes(t.tag)) { | ||
const title = tokens[i + 1].content; | ||
// @ts-ignore | ||
const slug = (t.attrs).find(([name]) => name === 'id')[1]; | ||
const slug = t.attrs.find(([name]) => name === 'id')[1]; | ||
res.push({ | ||
@@ -33,0 +31,0 @@ level: parseInt(t.tag.slice(1), 10), |
@@ -24,4 +24,4 @@ "use strict"; | ||
pattern = removeLeadingSlash(pattern); | ||
const link = localePath + | ||
pattern | ||
const link = localePath | ||
+ pattern | ||
.replace(/:year/, String(year)) | ||
@@ -28,0 +28,0 @@ .replace(/:month/, String(month)) |
@@ -74,3 +74,2 @@ 'use strict'; | ||
} | ||
// @ts-ignore | ||
console.log(chalk_1.default[color](label), ...args); | ||
@@ -77,0 +76,0 @@ } |
"use strict"; | ||
// Midified from https://github.com/vuejs/vue-cli/blob/dev/packages/@0vue/cli-shared-utils/lib/module.js | ||
// Modified from https://github.com/vuejs/vue-cli/blob/dev/packages/@0vue/cli-shared-utils/lib/module.js | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -10,2 +10,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
function resolveFallback(request, options) { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const Module = require('module'); | ||
@@ -29,3 +30,2 @@ const isMain = false; | ||
const err = new Error(`Cannot find module '${request}'`); | ||
// @ts-ignores | ||
err.code = 'MODULE_NOT_FOUND'; | ||
@@ -36,2 +36,14 @@ throw err; | ||
} | ||
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]; | ||
} | ||
} | ||
const resolve = semver_1.default.satisfies(process.version, '>=10.0.0') | ||
@@ -41,3 +53,2 @@ ? require.resolve | ||
function resolveModule(request, context) { | ||
let resolvedPath; | ||
if (env_1.default.isTest) { | ||
@@ -48,3 +59,3 @@ return require.resolve(request); | ||
const paths = [context || process.cwd(), ...module.paths]; | ||
resolvedPath = resolve(request, { paths }); | ||
const resolvedPath = resolve(request, { paths }); | ||
return resolvedPath; | ||
@@ -70,13 +81,1 @@ } | ||
exports.clearModule = clearModule; | ||
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]; | ||
} | ||
} |
@@ -16,3 +16,19 @@ 'use strict'; | ||
const datatypes_1 = require("./datatypes"); | ||
/** | ||
* Parse info of scope package. | ||
*/ | ||
const SCOPE_PACKAGE_RE = /^@(.*)\/(.*)/; | ||
function resolveScopePackage(name) { | ||
if (SCOPE_PACKAGE_RE.test(name)) { | ||
return { | ||
org: RegExp.$1, | ||
name: RegExp.$2 | ||
}; | ||
} | ||
return { | ||
org: '', | ||
name: '' | ||
}; | ||
} | ||
exports.resolveScopePackage = resolveScopePackage; | ||
/** | ||
@@ -150,16 +166,14 @@ * Common module constructor. | ||
const pkg = resolveScopePackage(req); | ||
if (pkg) { | ||
// speicial handling for default org. | ||
if (this.org && pkg.org === this.org) { | ||
shortcut = pkg.name.startsWith(`${this.type}-`) | ||
? pkg.name.slice(this.typePrefixLength) | ||
: pkg.name; | ||
name = `${this.scopePrefix}${shortcut}`; | ||
} | ||
else { | ||
shortcut = this.getShortcut(pkg.name); | ||
name = `@${pkg.org}/${this.nonScopePrefix}${shortcut}`; | ||
} | ||
shortcut = `@${pkg.org}/${shortcut}`; | ||
// special handling for default org. | ||
if (this.org && pkg.org === this.org) { | ||
shortcut = pkg.name.startsWith(`${this.type}-`) | ||
? pkg.name.slice(this.typePrefixLength) | ||
: pkg.name; | ||
name = `${this.scopePrefix}${shortcut}`; | ||
} | ||
else { | ||
shortcut = this.getShortcut(pkg.name); | ||
name = `@${pkg.org}/${this.nonScopePrefix}${shortcut}`; | ||
} | ||
shortcut = `@${pkg.org}/${shortcut}`; | ||
} | ||
@@ -195,17 +209,4 @@ else { | ||
} | ||
function resolveScopePackage(name) { | ||
if (SCOPE_PACKAGE_RE.test(name)) { | ||
return { | ||
org: RegExp.$1, | ||
name: RegExp.$2 | ||
}; | ||
} | ||
return { | ||
org: '', | ||
name: '' | ||
}; | ||
} | ||
exports.resolveScopePackage = resolveScopePackage; | ||
exports.getMarkdownItResolver = (cwd) => new ModuleResolver('markdown-it', '', [String, Function], true /* load module */, cwd); | ||
exports.getPluginResolver = (cwd) => new ModuleResolver('plugin', 'vuepress', [String, Function, Object], true /* load module */, cwd); | ||
exports.getThemeResolver = (cwd) => new ModuleResolver('theme', 'vuepress', [String], false /* load module */, cwd); |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const emojiData = require('markdown-it-emoji/lib/data/full.json'); | ||
const full_json_1 = __importDefault(require("markdown-it-emoji/lib/data/full.json")); | ||
exports.default = (str) => { | ||
return String(str).replace(/:(.+?):/g, (placeholder, key) => emojiData[key] || placeholder); | ||
return String(str).replace(/:(.+?):/g, (placeholder, key) => full_json_1.default[key] || placeholder); | ||
}; |
"use strict"; | ||
const matter = require('gray-matter'); | ||
const toml = require('toml'); | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
const gray_matter_1 = __importDefault(require("gray-matter")); | ||
const toml_1 = __importDefault(require("toml")); | ||
module.exports = function parseFrontmatter(content) { | ||
return matter(content, { | ||
return gray_matter_1.default(content, { | ||
// eslint-disable-next-line @typescript-eslint/camelcase | ||
excerpt_separator: '<!-- more -->', | ||
engines: { | ||
toml: toml.parse.bind(toml), | ||
excerpt: false | ||
toml: toml_1.default.parse.bind(toml_1.default) | ||
} | ||
}); | ||
}; |
@@ -14,4 +14,4 @@ "use strict"; | ||
// But header's parsing in the markdown content is done by the markdown | ||
// loader based on markdown-it. markdown-it parser will will always keep | ||
// HTML in headers, so in VuePress, after being parsed by the markdiwn | ||
// loader based on markdown-it. markdown-it parser will always keep | ||
// HTML in headers, so in VuePress, after being parsed by the markdown | ||
// loader, the raw HTML in headers will finally be parsed by Vue-loader. | ||
@@ -18,0 +18,0 @@ // so that we can write HTML/Vue in the header. One exception is the HTML |
@@ -6,3 +6,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// @ts-ignore | ||
const component_compiler_utils_1 = require("@vue/component-compiler-utils"); | ||
@@ -9,0 +8,0 @@ const parseFrontmatter_1 = __importDefault(require("./parseFrontmatter")); |
"use strict"; | ||
// string.js slugify drops non ascii chars so we have to | ||
// use a custom implementation here | ||
// @ts-ignore | ||
const diacritics_1 = require("diacritics"); | ||
// eslint-disable-next-line no-control-regex | ||
const rControl = /[\u0000-\u001f]/g; | ||
const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'<>,.?/]+/g; | ||
const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'“”‘’<>,.?/]+/g; | ||
module.exports = function slugify(str) { | ||
@@ -15,5 +14,5 @@ return diacritics_1.remove(str) | ||
.replace(rSpecial, '-') | ||
// Remove continous separators | ||
// Remove continuous separators | ||
.replace(/\-{2,}/g, '-') | ||
// Remove prefixing and trailing separtors | ||
// Remove prefixing and trailing separators | ||
.replace(/^\-+|\-+$/g, '') | ||
@@ -20,0 +19,0 @@ // ensure it doesn't start with a number (#121) |
{ | ||
"name": "@vuepress/shared-utils", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "shared-utils for vuepress", | ||
"main": "lib/index.js", | ||
"types": "types/index.d.ts", | ||
"keywords": [ | ||
"documentation", | ||
"generator", | ||
"vue", | ||
"vuepress" | ||
], | ||
"homepage": "https://github.com/vuejs/vuepress/packages/@vuepress/shared-utils#readme", | ||
"bugs": { | ||
"url": "https://github.com/vuejs/vuepress/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/vuejs/vuepress.git", | ||
"directory": "packages/@vuepress/shared-utils" | ||
}, | ||
"license": "MIT", | ||
"author": "ULIVZ <chl814@foxmail.com>", | ||
"files": [ | ||
@@ -11,2 +26,4 @@ "lib", | ||
], | ||
"main": "lib/index.js", | ||
"types": "types/index.d.ts", | ||
"scripts": { | ||
@@ -16,16 +33,2 @@ "tsc": "tsc", | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/vuejs/vuepress.git", | ||
"directory": "packages/@vuepress/shared-utils" | ||
}, | ||
"keywords": [ | ||
"documentation", | ||
"vue", | ||
"vuepress", | ||
"generator" | ||
], | ||
"dependencies": { | ||
@@ -42,9 +45,9 @@ "chalk": "^2.3.2", | ||
}, | ||
"author": "ULIVZ <chl814@foxmail.com>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/vuejs/vuepress/issues" | ||
"devDependencies": { | ||
"@types/diacritics": "^1.3.1" | ||
}, | ||
"homepage": "https://github.com/vuejs/vuepress/packages/@vuepress/shared-utils#readme", | ||
"gitHead": "f61e2d42b4b2d9a59630f95a37fab968dcbd8b39" | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"gitHead": "af092c46716405901f9a6cf933b4a6e8a7f9a396" | ||
} |
# @vuepress/shard-utils | ||
> shard-utils for vuepress | ||
> shard-utils for VuePress |
@@ -17,7 +17,7 @@ export declare const isObject: (obj: any) => boolean; | ||
*/ | ||
declare type Type = String | Number | Boolean | RegExp | Function | Record<string, any> | Array<any>; | ||
declare type Type = string | number | boolean | RegExp | Function | Record<string, any> | Array<any>; | ||
export declare function assertTypes(value: any, types: Type[]): { | ||
valid: boolean | undefined; | ||
warnMsg: string | undefined; | ||
valid: any; | ||
warnMsg: any; | ||
}; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
declare const _default: (content: string, include: never[] | undefined, md: any) => unknown; | ||
declare const _default: (content: string, include: any[] | undefined, md: any) => unknown; | ||
export = _default; |
@@ -35,2 +35,2 @@ import * as codegen from './codegen'; | ||
import semver from 'semver'; | ||
export { codegen, compose, datatypes, deeplyParseHeaders, ensureEndingSlash, ensureLeadingSlash, env, extractHeaders, fallback, fileToPath, getPermalink, inferTitle, isIndexFile, logger, moduleLoader, moduleResolver, normalizeConfig, parseEmojis, parseFrontmatter, parseHeaders, parseVueFrontmatter, performance, slugify, sort, toAbsolutePath, tryChain, unescapeHtml, chalk, fs, path, globby, hash, escapeHtml, semver, }; | ||
export { codegen, compose, datatypes, deeplyParseHeaders, ensureEndingSlash, ensureLeadingSlash, env, extractHeaders, fallback, fileToPath, getPermalink, inferTitle, isIndexFile, logger, moduleLoader, moduleResolver, normalizeConfig, parseEmojis, parseFrontmatter, parseHeaders, parseVueFrontmatter, performance, slugify, sort, toAbsolutePath, tryChain, unescapeHtml, chalk, fs, path, globby, hash, escapeHtml, semver }; |
@@ -0,1 +1,9 @@ | ||
export interface ScopePackage { | ||
org: string; | ||
name: string; | ||
} | ||
export declare function resolveScopePackage(name: string): { | ||
org: string; | ||
name: string; | ||
}; | ||
/** | ||
@@ -19,3 +27,3 @@ * Common module constructor. | ||
*/ | ||
declare type Type = String | Number | Boolean | RegExp | Function | Object | Record<string, any> | Array<any>; | ||
declare type Type = string | number | boolean | RegExp | Function | Record<string, any> | Record<string, any> | Array<any>; | ||
declare class ModuleResolver { | ||
@@ -65,13 +73,2 @@ private type; | ||
} | ||
/** | ||
* Parse info of scope package. | ||
*/ | ||
export interface ScopePackage { | ||
org: string; | ||
name: string; | ||
} | ||
export declare function resolveScopePackage(name: string): { | ||
org: string; | ||
name: string; | ||
}; | ||
export declare const getMarkdownItResolver: (cwd: string) => ModuleResolver; | ||
@@ -78,0 +75,0 @@ export declare const getPluginResolver: (cwd: string) => ModuleResolver; |
@@ -1,2 +0,3 @@ | ||
declare const _default: (content: string) => any; | ||
import matter from 'gray-matter'; | ||
declare const _default: (content: string) => matter.GrayMatterFile<string>; | ||
export = _default; |
@@ -1,2 +0,2 @@ | ||
export declare function parseStrippedFrontmatter(src: string): any; | ||
export declare function parse(src: string): any; | ||
export declare function parseStrippedFrontmatter(src: string): import("gray-matter").GrayMatterFile<string>; | ||
export declare function parse(src: string): {}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42978
4
1
1151
1