Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@docusaurus/utils

Package Overview
Dependencies
Maintainers
5
Versions
1839
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@docusaurus/utils - npm Package Compare versions

Comparing version 2.0.0-alpha.66 to 2.0.0-alpha.68

3

lib/index.d.ts

@@ -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

49

lib/index.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc