1
0
mirror of synced 2025-12-19 18:10:59 -05:00

Replace gray-matter with @gr2m/gray-matter to control quotes in frontmatter (#57049)

This commit is contained in:
Kevin Heis
2025-08-11 06:41:17 -07:00
committed by GitHub
parent 6b15cafa2d
commit c1577ff1e8
13 changed files with 30 additions and 60 deletions

View File

@@ -1,7 +1,7 @@
import fs from 'fs'
import path from 'path'
import frontmatter from 'gray-matter'
import frontmatter from '@gr2m/gray-matter'
import { getLogLevelNumber } from '#src/observability/logger/lib/log-levels.js'
// Replace imports with hardcoded values

63
package-lock.json generated
View File

@@ -10,6 +10,7 @@
"dependencies": {
"@elastic/elasticsearch": "8.13.1",
"@github/failbot": "0.8.3",
"@gr2m/gray-matter": "4.0.3-with-pr-137",
"@horizon-rs/language-guesser": "0.1.1",
"@octokit/plugin-retry": "8.0.1",
"@octokit/request-error": "7.0.0",
@@ -43,7 +44,6 @@
"github-slugger": "^2.0.0",
"glob": "11.0.2",
"got": "^14.4.7",
"gray-matter": "^4.0.3",
"hast-util-from-parse5": "^8.0.3",
"hast-util-to-string": "^3.0.1",
"hastscript": "^9.0.1",
@@ -1614,6 +1614,21 @@
"integrity": "sha512-Yx70pO8A0p7Stnm9knKkUNX8i4bjuwDYZarRkM8JH0Z+ffhpe++oNAPbzGI9GEcGugRHvKuSC6p4YOdoHtTniQ==",
"license": "MIT"
},
"node_modules/@gr2m/gray-matter": {
"version": "4.0.3-with-pr-137",
"resolved": "https://registry.npmjs.org/@gr2m/gray-matter/-/gray-matter-4.0.3-with-pr-137.tgz",
"integrity": "sha512-6prHnKL+WQzCFe64DtUKki7MacXZARwNH3jlocGrOMgGw8AJASl405f/ULz6vjIU9uTDnxwP2N7ZlHEqOX1T6w==",
"license": "MIT",
"dependencies": {
"js-yaml": "^4.1.0",
"kind-of": "^6.0.2",
"section-matter": "^1.0.0",
"strip-bom-string": "^1.0.0"
},
"engines": {
"node": ">=6.0"
}
},
"node_modules/@graphql-inspector/core": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/@graphql-inspector/core/-/core-6.1.0.tgz",
@@ -8445,17 +8460,6 @@
"url": "https://opencollective.com/eslint"
}
},
"node_modules/esprima": {
"version": "4.0.1",
"license": "BSD-2-Clause",
"bin": {
"esparse": "bin/esparse.js",
"esvalidate": "bin/esvalidate.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/esquery": {
"version": "1.5.0",
"dev": true,
@@ -9388,37 +9392,6 @@
"node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0"
}
},
"node_modules/gray-matter": {
"version": "4.0.3",
"license": "MIT",
"dependencies": {
"js-yaml": "^3.13.1",
"kind-of": "^6.0.2",
"section-matter": "^1.0.0",
"strip-bom-string": "^1.0.0"
},
"engines": {
"node": ">=6.0"
}
},
"node_modules/gray-matter/node_modules/argparse": {
"version": "1.0.10",
"license": "MIT",
"dependencies": {
"sprintf-js": "~1.0.2"
}
},
"node_modules/gray-matter/node_modules/js-yaml": {
"version": "3.14.1",
"license": "MIT",
"dependencies": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
},
"node_modules/has-bigints": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz",
@@ -15013,10 +14986,6 @@
"node": "*"
}
},
"node_modules/sprintf-js": {
"version": "1.0.3",
"license": "BSD-3-Clause"
},
"node_modules/srcset": {
"version": "5.0.0",
"dev": true,

View File

@@ -282,7 +282,7 @@
"github-slugger": "^2.0.0",
"glob": "11.0.2",
"got": "^14.4.7",
"gray-matter": "^4.0.3",
"@gr2m/gray-matter": "4.0.3-with-pr-137",
"hast-util-from-parse5": "^8.0.3",
"hast-util-to-string": "^3.0.1",
"hastscript": "^9.0.1",

View File

@@ -2,7 +2,7 @@ import walk from 'walk-sync'
import { existsSync, lstatSync, unlinkSync } from 'fs'
import path from 'path'
import { readFile, writeFile, readdir } from 'fs/promises'
import matter from 'gray-matter'
import matter from '@gr2m/gray-matter'
import { rimraf } from 'rimraf'
import { mkdirp } from 'mkdirp'
import { difference, isEqual } from 'lodash-es'

View File

@@ -5,7 +5,7 @@ import path from 'path'
import { afterAll, beforeAll, describe, expect, test } from 'vitest'
import { mkdirp } from 'mkdirp'
import matter from 'gray-matter'
import matter from '@gr2m/gray-matter'
import type { FrontmatterVersions } from '@/types'
import { updateContentDirectory } from '../lib/update-markdown'

View File

@@ -4,7 +4,7 @@ import walk from 'walk-sync'
import { mkdirp } from 'mkdirp'
import { execFileSync, execSync } from 'child_process'
import path from 'path'
import matter from 'gray-matter'
import matter from '@gr2m/gray-matter'
import { rimraf } from 'rimraf'
import { updateContentDirectory } from '../../automated-pipelines/lib/update-markdown'

View File

@@ -1,5 +1,5 @@
import { addError, filterTokens } from 'markdownlint-rule-helpers'
import matter from 'gray-matter'
import matter from '@gr2m/gray-matter'
// Adds an error object with details conditionally via the onError callback
export function addFixErrorDetail(onError, lineNumber, expected, actual, range, fixInfo) {

View File

@@ -5,7 +5,7 @@ import walk from 'walk-sync'
import yaml from 'js-yaml'
import { isRegExp, setWith } from 'lodash-es'
import filenameToKey from './filename-to-key'
import matter from 'gray-matter'
import matter from '@gr2m/gray-matter'
interface DataDirectoryOptions {
preprocess?: (content: string) => string

View File

@@ -2,7 +2,7 @@ import fs from 'fs'
import path from 'path'
import yaml from 'js-yaml'
import matter from 'gray-matter'
import matter from '@gr2m/gray-matter'
import { merge, get } from 'lodash-es'
import languages from '@/languages/lib/languages'

View File

@@ -1,4 +1,4 @@
import matter from 'gray-matter'
import matter from '@gr2m/gray-matter'
import { validateJson } from '@/tests/lib/validate-json-schema'
@@ -15,7 +15,8 @@ function readFrontmatter(markdown, opts = {}) {
const reason = e.reason
? // make this common error message a little easier to understand
e.reason.startsWith('can not read a block mapping entry;')
e.reason.startsWith('can not read a block mapping entry;') ||
e.reason === 'bad indentation of a mapping entry'
? defaultReason
: e.reason
: defaultReason

View File

@@ -65,7 +65,7 @@ I am content.
const expectedError = {
filepath: 'path/to/file.md',
message: 'YML parsing error!',
reason: 'bad indentation of a mapping entry',
reason: 'invalid frontmatter entry',
}
expect(errors[0]).toEqual(expectedError)
})

View File

@@ -2,7 +2,7 @@ import { readFileSync } from 'fs'
import { basename } from 'path'
import { Liquid } from 'liquidjs'
import walk from 'walk-sync'
import matter from 'gray-matter'
import matter from '@gr2m/gray-matter'
import { latest, oldestSupported } from '@/versions/lib/enterprise-server-releases'
import { getContents } from '@/workflows/git-utils'

View File

@@ -1,5 +1,5 @@
import { readFileSync } from 'fs'
import matter from 'gray-matter'
import matter from '@gr2m/gray-matter'
// Filters out files from a list of filePaths
// that have a type property in their frontmatter