@docusaurus/utils
Advanced tools
Comparing version 2.0.0-alpha.66 to 2.0.0-alpha.68
@@ -7,2 +7,3 @@ /** | ||
*/ | ||
import { ReportingSeverity } from '@docusaurus/types'; | ||
export declare function generate(generatedFilesDir: string, file: string, content: any, skipCache?: boolean): Promise<void>; | ||
@@ -78,3 +79,5 @@ export declare function objectWithKeySorted(obj: { | ||
}; | ||
export declare function reportMessage(message: string, reportingSeverity: ReportingSeverity): void; | ||
export declare function getSwizzledComponent(componentPath: string): string | undefined; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -12,3 +12,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getElementsAround = exports.getFilePathForRoutePath = exports.removePrefix = exports.removeSuffix = exports.removeTrailingSlash = exports.addTrailingSlash = exports.addLeadingSlash = exports.resolvePathname = exports.isValidPathname = exports.getEditUrl = exports.aliasedSitePath = exports.normalizeUrl = exports.parseMarkdownFile = exports.parseMarkdownString = exports.createExcerpt = exports.getSubFolder = exports.idx = exports.genChunkName = exports.posixPath = exports.genComponentName = exports.upperFirst = exports.docuHash = exports.simpleHash = exports.encodePath = exports.fileToPath = exports.objectWithKeySorted = exports.generate = void 0; | ||
exports.getSwizzledComponent = exports.reportMessage = exports.getElementsAround = exports.getFilePathForRoutePath = exports.removePrefix = exports.removeSuffix = exports.removeTrailingSlash = exports.addTrailingSlash = exports.addLeadingSlash = exports.resolvePathname = exports.isValidPathname = exports.getEditUrl = exports.aliasedSitePath = exports.normalizeUrl = exports.parseMarkdownFile = exports.parseMarkdownString = exports.createExcerpt = exports.getSubFolder = exports.idx = exports.genChunkName = exports.posixPath = exports.genComponentName = exports.upperFirst = exports.docuHash = exports.simpleHash = exports.encodePath = exports.fileToPath = exports.objectWithKeySorted = exports.generate = void 0; | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const path_1 = __importDefault(require("path")); | ||
@@ -173,13 +174,14 @@ const gray_matter_1 = __importDefault(require("gray-matter")); | ||
exports.getSubFolder = getSubFolder; | ||
// Regex for an import statement. | ||
const importRegexString = '^(.*import){1}(.+){0,1}\\s[\'"](.+)[\'"];?'; | ||
function createExcerpt(fileString) { | ||
let fileContent = fileString.trimLeft(); | ||
if (RegExp(importRegexString).test(fileContent)) { | ||
fileContent = fileContent | ||
.replace(RegExp(importRegexString, 'gm'), '') | ||
.trimLeft(); | ||
} | ||
const fileLines = fileContent.split('\n'); | ||
const fileLines = fileString.trimLeft().split('\n'); | ||
/* eslint-disable no-continue */ | ||
for (const fileLine of fileLines) { | ||
// Skip empty line. | ||
if (!fileLine.trim()) { | ||
continue; | ||
} | ||
// Skip import/export declaration. | ||
if (/^.*import\s.*from.*;?|export\s.*{.*};?/.test(fileLine)) { | ||
continue; | ||
} | ||
const cleanedLine = fileLine | ||
@@ -379,1 +381,28 @@ // Remove HTML tags. | ||
exports.getElementsAround = getElementsAround; | ||
function reportMessage(message, reportingSeverity) { | ||
switch (reportingSeverity) { | ||
case 'ignore': | ||
break; | ||
case 'log': | ||
console.log(chalk_1.default.bold.blue('info ') + chalk_1.default.blue(message)); | ||
break; | ||
case 'warn': | ||
console.warn(chalk_1.default.bold.yellow('warn ') + chalk_1.default.yellow(message)); | ||
break; | ||
case 'error': | ||
console.error(chalk_1.default.bold.red('error ') + chalk_1.default.red(message)); | ||
break; | ||
case 'throw': | ||
throw new Error(message); | ||
default: | ||
throw new Error(`unexpected reportingSeverity value: ${reportingSeverity}`); | ||
} | ||
} | ||
exports.reportMessage = reportMessage; | ||
function getSwizzledComponent(componentPath) { | ||
const swizzledComponentPath = path_1.default.resolve(process.cwd(), 'src', componentPath); | ||
return fs_extra_1.default.existsSync(swizzledComponentPath) | ||
? swizzledComponentPath | ||
: undefined; | ||
} | ||
exports.getSwizzledComponent = getSwizzledComponent; |
{ | ||
"name": "@docusaurus/utils", | ||
"version": "2.0.0-alpha.66", | ||
"version": "2.0.0-alpha.68", | ||
"description": "Node utility functions for Docusaurus packages", | ||
@@ -14,4 +14,11 @@ "main": "./lib/index.js", | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/facebook/docusaurus.git", | ||
"directory": "packages/docusaurus-utils" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"@docusaurus/types": "2.0.0-alpha.68", | ||
"chalk": "^3.0.0", | ||
"escape-string-regexp": "^2.0.0", | ||
@@ -27,3 +34,3 @@ "fs-extra": "^8.1.0", | ||
}, | ||
"gitHead": "e3bce6207d652088ff79c39bffd78a10d2b1728b" | ||
"gitHead": "d2fd1436412662a8d69d7150e9e6bbfd68f949b6" | ||
} |
@@ -377,3 +377,3 @@ /** | ||
}, | ||
// Content with imports declarations and Markdown markup, as well as Emoji | ||
// Content with imports/exports declarations and Markdown markup, as well as Emoji | ||
{ | ||
@@ -384,2 +384,6 @@ input: ` | ||
export function ItemCol(props) { return <Item {...props} className={'col col--6 margin-bottom--lg'}/> } | ||
export function ItemCol(props) { return <Item {...props} className={'col col--6 margin-bottom--lg'}/> }; | ||
Lorem **ipsum** dolor sit \`amet\`[^1], consectetur _adipiscing_ elit. [**Vestibulum**](https://wiktionary.org/wiki/vestibulum) ex urna[^bignote], ~molestie~ et sagittis ut, varius ac justo :wink:. | ||
@@ -386,0 +390,0 @@ |
@@ -8,2 +8,3 @@ /** | ||
import chalk from 'chalk'; | ||
import path from 'path'; | ||
@@ -17,2 +18,3 @@ import matter from 'gray-matter'; | ||
import {URL} from 'url'; | ||
import {ReportingSeverity} from '@docusaurus/types'; | ||
@@ -191,17 +193,17 @@ // @ts-expect-error: no typedefs :s | ||
// Regex for an import statement. | ||
const importRegexString = '^(.*import){1}(.+){0,1}\\s[\'"](.+)[\'"];?'; | ||
export function createExcerpt(fileString: string): string | undefined { | ||
let fileContent = fileString.trimLeft(); | ||
const fileLines = fileString.trimLeft().split('\n'); | ||
if (RegExp(importRegexString).test(fileContent)) { | ||
fileContent = fileContent | ||
.replace(RegExp(importRegexString, 'gm'), '') | ||
.trimLeft(); | ||
} | ||
/* eslint-disable no-continue */ | ||
for (const fileLine of fileLines) { | ||
// Skip empty line. | ||
if (!fileLine.trim()) { | ||
continue; | ||
} | ||
const fileLines = fileContent.split('\n'); | ||
// Skip import/export declaration. | ||
if (/^.*import\s.*from.*;?|export\s.*{.*};?/.test(fileLine)) { | ||
continue; | ||
} | ||
for (const fileLine of fileLines) { | ||
const cleanedLine = fileLine | ||
@@ -442,1 +444,40 @@ // Remove HTML tags. | ||
} | ||
export function reportMessage( | ||
message: string, | ||
reportingSeverity: ReportingSeverity, | ||
): void { | ||
switch (reportingSeverity) { | ||
case 'ignore': | ||
break; | ||
case 'log': | ||
console.log(chalk.bold.blue('info ') + chalk.blue(message)); | ||
break; | ||
case 'warn': | ||
console.warn(chalk.bold.yellow('warn ') + chalk.yellow(message)); | ||
break; | ||
case 'error': | ||
console.error(chalk.bold.red('error ') + chalk.red(message)); | ||
break; | ||
case 'throw': | ||
throw new Error(message); | ||
default: | ||
throw new Error( | ||
`unexpected reportingSeverity value: ${reportingSeverity}`, | ||
); | ||
} | ||
} | ||
export function getSwizzledComponent( | ||
componentPath: string, | ||
): string | undefined { | ||
const swizzledComponentPath = path.resolve( | ||
process.cwd(), | ||
'src', | ||
componentPath, | ||
); | ||
return fs.existsSync(swizzledComponentPath) | ||
? swizzledComponentPath | ||
: undefined; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
1441
3
559493
8
+ Addedchalk@^3.0.0
+ Added@docusaurus/types@2.0.0-alpha.68(transitive)
+ Added@types/node@22.9.3(transitive)
+ Added@types/source-list-map@0.1.6(transitive)
+ Added@types/tapable@1.0.12(transitive)
+ Added@types/uglify-js@3.17.5(transitive)
+ Added@types/webpack@4.41.40(transitive)
+ Added@types/webpack-sources@3.2.3(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedanymatch@3.1.3(transitive)
+ Addedchalk@3.0.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcommander@4.1.1(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addednormalize-path@3.0.0(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedquerystring@0.2.0(transitive)
+ Addedsource-map@0.6.10.7.4(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addedwebpack-merge@4.2.2(transitive)