diff --git a/gulp-src/lint-md.js b/gulp-src/lint-md.js index 513c8d37bf49..2866588575a3 100644 --- a/gulp-src/lint-md.js +++ b/gulp-src/lint-md.js @@ -6,13 +6,15 @@ const markdownlint = require('markdownlint'); const { taskArgs, trimBlankLinesFromArray } = require('./_util'); const fs = require('fs'); -const defaultGlob = '**/*.md'; +const defaultGlobs = ['**/*.md']; const markdownFiles = [ '!.github/**', '!content-modules/**', + '!examples/**', '!layouts/**', '!node_modules/**', '!scripts/registry-scanner/node_modules/**', + '!tools/examples/**', '!themes/**', '!tmp/**', ]; @@ -121,13 +123,28 @@ function applyFixesToFileContent(content, issue) { return lines.join('\n'); } +function logFiles(debug) { + return through2.obj(function (file, enc, cb) { + if (debug) { + console.log('Processing file:', file.path); + } + cb(null, file); + }); +} + function lintMarkdown() { const argv = taskArgs().options({ glob: { alias: 'g', - type: 'string', - description: 'Glob of files to run through markdownlint.', - default: defaultGlob, + type: 'array', + description: + 'Globs of files to run through markdownlint. List flag more than once for multiple values.', + default: defaultGlobs, + }, + debug: { + type: 'boolean', + description: 'Output debugging information.', + default: false, }, fix: { type: 'boolean', @@ -142,8 +159,14 @@ function lintMarkdown() { } fix = argv.fix; + const globs = [...argv.glob, ...markdownFiles]; + if (argv.debug) { + console.log('Globs being used:', globs); + } + return gulp - .src([argv.glob, ...markdownFiles]) + .src(globs, { followSymlinks: false }) + .pipe(logFiles(argv.debug)) .pipe(through2.obj(markdownLintFile)) .on('end', () => { const fileOrFiles = 'file' + (numFilesProcessed == 1 ? '' : 's'); diff --git a/package.json b/package.json index 67bdf4829ce2..7aa48e43b552 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "_check:links--warn": "npm run _check:links || (echo; echo 'WARNING: see link-checker output for issues.'; echo)", "_check:links:internal": "npm run __check:links", "_check:links": "HTMLTEST_ARGS='--log-level 1' npm run __check:links", + "_check:markdown": "npx gulp lint-md", "_check:text": "npx textlint content data `ls *.md`", "_diff:check": "git diff --name-only --exit-code", "_diff:fail": "git diff --name-only --exit-code || exit 1", @@ -30,7 +31,7 @@ "_rename-to-kebab-case": "find assets content static -name '*_*' ! -name '_*' -exec sh -c 'mv \"$1\" \"${1//_/-}\"' _ {} \\;", "_serve:hugo": "hugo server --buildDrafts --minify", "_serve:netlify": "netlify dev -c \"npm run _serve:hugo -- --renderToMemory\"", - "_sync": "./scripts/sync-submodules.pl", + "_sync": "scripts/sync-submodules.pl", "all": "bash -c 'x=0; for c in \"$@\"; do npm run $c || x=$((x+1)); done; ((!x)) || (echo \"ERROR: some scripts failed!\" && exit 1)' -", "build:preview": "set -x && npm run _build -- --minify", "build:production": "npm run _hugo -- --minify", @@ -40,7 +41,7 @@ "check:format": "npm run _check:format || (echo '[help] Run: npm run fix:format'; exit 1)", "check:links:internal": "npm run _check:links:internal", "check:links": "npm run _check:links", - "check:markdown": "npx gulp lint-md", + "check:markdown": "scripts/check-markdown-wrapper.sh", "check:spelling": "npx cspell --no-progress -c .cspell.yml content data 'layouts/**/*.md'", "check:text": "npm run _check:text -- ", "check": "npm run seq -- $(npm run -s _list:check:*)", @@ -48,11 +49,11 @@ "code-excerpts": "rm -Rf tmp/excerpts/* && npm run seq -- code-excerpts:get code-excerpts:update-docs", "code-excerpts:get": "cd tools && dart run build_runner build --delete-conflicting-outputs --output ../tmp/excerpts", "code-excerpts:update-docs": "cd tools && dart run code_excerpt_updater --fragment-dir-path ../tmp/excerpts --src-dir-path examples --yaml --write-in-place content", - "cp:spec": "./scripts/content-modules/cp-pages.sh", + "cp:spec": "scripts/content-modules/cp-pages.sh", "diff:check": "npm run _diff:check || (echo; echo 'WARNING: the files above have not been committed'; echo)", "diff:fail": "npm run _diff:check || (echo; echo 'ERROR: the files above have changed. Locally rerun `npm run test-and-fix` and commit changes'; echo; exit 1)", "fix:all": "npm run seq -- $(npm -s run _list:fix:*)", - "fix:dict": "find content layouts -name \"*.md\" -print0 | xargs -0 ./scripts/normalize-cspell-front-matter.pl", + "fix:dict": "find content layouts -name \"*.md\" -print0 | xargs -0 scripts/normalize-cspell-front-matter.pl", "fix:filenames": "npm run _rename-to-kebab-case", "fix:format": "npm run format", "fix:i18n": "scripts/i18n-check.sh -u", @@ -83,7 +84,7 @@ "serve:hugo": "npm run _serve:hugo -- --renderToMemory", "serve:netlify": "npm run _serve:netlify", "serve": "npm run serve:hugo --", - "sync": "./scripts/sync-submodules.pl", + "sync": "scripts/sync-submodules.pl", "test-and-fix": "npm run seq -- check fix:dict fix:filenames", "test": "npm run check", "update:docsy-dep": "npm install --save-dev autoprefixer@latest postcss-cli@latest", @@ -98,12 +99,12 @@ "devDependencies": { "autoprefixer": "^10.4.19", "cspell": "^8.8.4", - "gulp": "^4.0.2", - "hugo-extended": "0.126.3", + "gulp": "^5.0.0", + "hugo-extended": "0.127.0", "markdown-link-check": "^3.12.2", "markdownlint": "^0.34.0", "postcss-cli": "^11.0.0", - "prettier": "^3.3.0", + "prettier": "^3.3.1", "require-dir": "^1.2.0", "textlint": "^14.0.4", "textlint-filter-rule-allowlist": "^4.0.0", @@ -113,20 +114,20 @@ "yargs": "^17.7.2" }, "dependencies": { - "@opentelemetry/api": "^1.8.0", - "@opentelemetry/auto-instrumentations-web": "^0.39.0", - "@opentelemetry/context-zone": "^1.24.1", - "@opentelemetry/core": "^1.24.1", - "@opentelemetry/exporter-trace-otlp-http": "^0.51.1", - "@opentelemetry/instrumentation": "^0.51.1", - "@opentelemetry/resources": "^1.24.1", - "@opentelemetry/sdk-trace-base": "^1.24.1", - "@opentelemetry/sdk-trace-web": "^1.24.1", - "@opentelemetry/semantic-conventions": "^1.24.1", + "@opentelemetry/api": "^1.9.0", + "@opentelemetry/auto-instrumentations-web": "^0.40.0", + "@opentelemetry/context-zone": "^1.25.0", + "@opentelemetry/core": "^1.25.0", + "@opentelemetry/exporter-trace-otlp-http": "^0.52.0", + "@opentelemetry/instrumentation": "^0.52.0", + "@opentelemetry/resources": "^1.25.0", + "@opentelemetry/sdk-trace-base": "^1.25.0", + "@opentelemetry/sdk-trace-web": "^1.25.0", + "@opentelemetry/semantic-conventions": "^1.25.0", "path": "^0.12.7" }, "optionalDependencies": { - "netlify-cli": "^17.25.0", + "netlify-cli": "^17.26.1", "npm-check-updates": "^16.14.20" }, "enginesComment": "Ensure that engines.node value stays consistent with the project's .nvmrc", diff --git a/scripts/check-markdown-wrapper.sh b/scripts/check-markdown-wrapper.sh new file mode 100755 index 000000000000..045eeed03949 --- /dev/null +++ b/scripts/check-markdown-wrapper.sh @@ -0,0 +1,14 @@ +#!/bin/bash -e +# +# @chalin can't get Gulp 5 to ignore symlinks, so this wrapper creates +# bogus symlink targets to make the check:markdown Gulp task happy. + +symlink_target="content-modules/opentelemetry-go/example" + +if [[ ! -e $symlink_target ]]; then + echo "WARNING: required symlink target does not exist, creating it: $symlink_target" + (set -x; mkdir -p $symlink_target) +fi + +set -x +exec npm run _check:markdown "$@"