Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions build/tasks/format/format-dockerfile.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @module {type ES6Module} build/tasks/format/format-dockerfile
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

const dockerfileFiles = await glob([
'.devcontainer/**/Dockerfile',
Expand All @@ -14,7 +14,9 @@ const dockerfileFiles = await glob([
]);

let exitCode = 0;
const scripts = [`dprint fmt ${quote(dockerfileFiles)}`];
const scripts = matched(dockerfileFiles, '.devcontainer/**/Dockerfile')
? [`dprint fmt ${quote(dockerfileFiles)}`]
: [];

for (const element of scripts) {
exitCode = await exec(element);
Expand Down
6 changes: 4 additions & 2 deletions build/tasks/format/format-js.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @module {type ES6Module} build/tasks/format/format-js
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

const jsFiles = await glob([
'**/*.js',
Expand All @@ -16,7 +16,9 @@ const jsFiles = await glob([
]);

let exitCode = 0;
const scripts = [`biome check --write ${quote(jsFiles)}`];
const scripts = matched(jsFiles, '**/*.js, **/*.mjs')
? [`biome check --write ${quote(jsFiles)}`]
: [];

for (const element of scripts) {
exitCode = await exec(element);
Expand Down
12 changes: 9 additions & 3 deletions build/tasks/format/format-json.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @module {type ES6Module} build/tasks/format/format-json
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

const EXCLUDED = ['!_site/', '!node_modules/'];

Expand All @@ -17,9 +17,15 @@ const jsonFiles = await glob(['**/*.json', '**/*.jsonc', ...EXCLUDED]);
const json5Files = await glob(['**/*.json5', ...EXCLUDED]);

let exitCode = 0;
// Two lists, two tools, and a guard each: JSON5 going unformatted because no
// plain JSON matched would be the silence this guard exists to prevent.
const scripts = [
`biome check --write ${quote(jsonFiles)}`,
...(json5Files.length > 0 ? [`prettier --write ${quote(json5Files)}`] : []),
...(matched(jsonFiles, '**/*.json, **/*.jsonc')
? [`biome check --write ${quote(jsonFiles)}`]
: []),
...(matched(json5Files, '**/*.json5')
? [`prettier --write ${quote(json5Files)}`]
: []),
];

for (const element of scripts) {
Expand Down
6 changes: 4 additions & 2 deletions build/tasks/format/format-liquid.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @module {type ES6Module} build/tasks/format/format-liquid
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

const LiquidFiles = await glob([
'**/*.html',
Expand All @@ -15,7 +15,9 @@ const LiquidFiles = await glob([
]);

let exitCode = 0;
const scripts = [`prettier --write ${quote(LiquidFiles)}`];
const scripts = matched(LiquidFiles, '**/*.html, **/*.liquid')
? [`prettier --write ${quote(LiquidFiles)}`]
: [];

for (const element of scripts) {
exitCode = await exec(element);
Expand Down
12 changes: 7 additions & 5 deletions build/tasks/format/format-md.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @module {type ES6Module} build/tasks/format/format-md
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

const markdownFiles = await glob([
'**/*.md',
Expand All @@ -23,10 +23,12 @@ const markdownFiles = await glob([
]);

let exitCode = 0;
const scripts = [
`prettier --write ${quote(markdownFiles)}`,
`markdownlint-cli2 --fix ${quote(markdownFiles)}`,
];
const scripts = matched(markdownFiles, '**/*.md')
? [
`prettier --write ${quote(markdownFiles)}`,
`markdownlint-cli2 --fix ${quote(markdownFiles)}`,
]
: [];

for (const element of scripts) {
exitCode = await exec(element);
Expand Down
12 changes: 7 additions & 5 deletions build/tasks/format/format-scss.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
* @module {type ES6Module} build/tasks/format/format-scss
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

const scssFiles = await glob(['**/*.scss', '!_site/', '!node_modules/']);

let exitCode = 0;
const scripts = [
`prettier --write ${quote(scssFiles)}`,
`stylelint --fix ${quote(scssFiles)}`,
];
const scripts = matched(scssFiles, '**/*.scss')
? [
`prettier --write ${quote(scssFiles)}`,
`stylelint --fix ${quote(scssFiles)}`,
]
: [];

for (const element of scripts) {
exitCode = await exec(element);
Expand Down
6 changes: 4 additions & 2 deletions build/tasks/format/format-svg.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
* @module {type ES6Module} build/tasks/format/format-svg
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

const svgFiles = await glob(['**/*.svg', '!_site/', '!node_modules/']);

let exitCode = 0;
const scripts = [`prettier --write ${quote(svgFiles)}`];
const scripts = matched(svgFiles, '**/*.svg')
? [`prettier --write ${quote(svgFiles)}`]
: [];

for (const element of scripts) {
exitCode = await exec(element);
Expand Down
6 changes: 4 additions & 2 deletions build/tasks/format/format-toml.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
* @module {type ES6Module} build/tasks/format/format-toml
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

const tomlFiles = await glob(['**/*.toml', '!_site/', '!node_modules/']);

let exitCode = 0;
const scripts = [`dprint fmt ${quote(tomlFiles)}`];
const scripts = matched(tomlFiles, '**/*.toml')
? [`dprint fmt ${quote(tomlFiles)}`]
: [];

for (const element of scripts) {
exitCode = await exec(element);
Expand Down
6 changes: 4 additions & 2 deletions build/tasks/format/format-ts.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @module {type ES6Module} build/tasks/format/format-ts
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

const tsFiles = await glob([
'**/*.ts',
Expand All @@ -15,7 +15,9 @@ const tsFiles = await glob([
]);

let exitCode = 0;
const scripts = [`biome check --write ${quote(tsFiles)}`];
const scripts = matched(tsFiles, '**/*.ts, **/*.mts')
? [`biome check --write ${quote(tsFiles)}`]
: [];

for (const element of scripts) {
exitCode = await exec(element);
Expand Down
6 changes: 4 additions & 2 deletions build/tasks/format/format-yaml.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @module {type ES6Module} build/tasks/format/format-yaml
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

const yamlFiles = await glob([
'**/*.yml',
Expand All @@ -15,7 +15,9 @@ const yamlFiles = await glob([
]);

let exitCode = 0;
const scripts = [`prettier --write ${quote(yamlFiles)}`];
const scripts = matched(yamlFiles, '**/*.yml, **/*.yaml')
? [`prettier --write ${quote(yamlFiles)}`]
: [];

for (const element of scripts) {
exitCode = await exec(element);
Expand Down
6 changes: 4 additions & 2 deletions build/tasks/verify/verify-dockerfile.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @module {type ES6Module} build/tasks/verify/verify-dockerfile
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

const dockerfileFiles = await glob([
'.devcontainer/**/Dockerfile',
Expand All @@ -14,7 +14,9 @@ const dockerfileFiles = await glob([
]);

let exitCode = 0;
const scripts = [`dprint check ${quote(dockerfileFiles)}`];
const scripts = matched(dockerfileFiles, '.devcontainer/**/Dockerfile')
? [`dprint check ${quote(dockerfileFiles)}`]
: [];

for (const element of scripts) {
exitCode = await exec(element);
Expand Down
6 changes: 5 additions & 1 deletion build/tasks/verify/verify-filenames.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @module {type ES6Module} build/tasks/verify/verify-filenames
*/

import { glob } from '@openinf/portal/build/utils';
import { glob, matched } from '@openinf/portal/build/utils';

/**
* Lowercase words joined by hyphens. A leading underscore is Eleventy's and
Expand Down Expand Up @@ -33,6 +33,10 @@ const EXEMPT = new Set([

const files = await glob(['**/*', '!_site/', '!node_modules/']);

// This one hands nothing to a tool, but `glob` finding nothing would still
// leave it looping zero times and reporting success.
if (!matched(files, '**/*')) process.exit(1);

// A directory is only ever seen here as part of some file's path, and the
// same directory is part of many, so each is judged once.
const checked = new Set<string>();
Expand Down
6 changes: 4 additions & 2 deletions build/tasks/verify/verify-js.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @module {type ES6Module} build/tasks/verify/verify-js
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

const jsFiles = await glob([
'**/*.js',
Expand All @@ -16,7 +16,9 @@ const jsFiles = await glob([
]);

let exitCode = 0;
const scripts = [`biome check ${quote(jsFiles)}`];
const scripts = matched(jsFiles, '**/*.js, **/*.mjs')
? [`biome check ${quote(jsFiles)}`]
: [];

for (const element of scripts) {
exitCode = await exec(element);
Expand Down
12 changes: 9 additions & 3 deletions build/tasks/verify/verify-json.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @module {type ES6Module} build/tasks/verify/verify-json
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

const EXCLUDED = ['!_site/', '!node_modules/'];

Expand All @@ -17,9 +17,15 @@ const jsonFiles = await glob(['**/*.json', '**/*.jsonc', ...EXCLUDED]);
const json5Files = await glob(['**/*.json5', ...EXCLUDED]);

let exitCode = 0;
// Two lists, two tools, and a guard each: JSON5 going unchecked because no
// plain JSON matched would be the silence this guard exists to prevent.
const scripts = [
`biome check ${quote(jsonFiles)}`,
...(json5Files.length > 0 ? [`prettier --check ${quote(json5Files)}`] : []),
...(matched(jsonFiles, '**/*.json, **/*.jsonc')
? [`biome check ${quote(jsonFiles)}`]
: []),
...(matched(json5Files, '**/*.json5')
? [`prettier --check ${quote(json5Files)}`]
: []),
];

for (const element of scripts) {
Expand Down
6 changes: 4 additions & 2 deletions build/tasks/verify/verify-liquid.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @module {type ES6Module} build/tasks/verify/verify-liquid
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

const liquidFiles = await glob([
'**/*.html',
Expand All @@ -15,7 +15,9 @@ const liquidFiles = await glob([
]);

let exitCode = 0;
const scripts = [`prettier --check ${quote(liquidFiles)}`];
const scripts = matched(liquidFiles, '**/*.html, **/*.liquid')
? [`prettier --check ${quote(liquidFiles)}`]
: [];

for (const element of scripts) {
exitCode = await exec(element);
Expand Down
14 changes: 8 additions & 6 deletions build/tasks/verify/verify-md.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @module {type ES6Module} build/tasks/verify/verify-md
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

const markdownFiles = await glob([
'**/*.md',
Expand All @@ -23,11 +23,13 @@ const markdownFiles = await glob([
]);

let exitCode = 0;
const scripts = [
`prettier --check ${quote(markdownFiles)}`,
`markdownlint-cli2 ${quote(markdownFiles)}`,
`remark -f --silently-ignore ${quote(markdownFiles)}`,
];
const scripts = matched(markdownFiles, '**/*.md')
? [
`prettier --check ${quote(markdownFiles)}`,
`markdownlint-cli2 ${quote(markdownFiles)}`,
`remark -f --silently-ignore ${quote(markdownFiles)}`,
]
: [];

for (const element of scripts) {
exitCode = await exec(element);
Expand Down
9 changes: 4 additions & 5 deletions build/tasks/verify/verify-scss.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
* @module {type ES6Module} build/tasks/verify/verify-scss
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

const scssFiles = await glob(['**/*.scss', '!_site/', '!node_modules/']);

let exitCode = 0;
const scripts = [
`prettier --check ${quote(scssFiles)}`,
`stylelint ${quote(scssFiles)}`,
];
const scripts = matched(scssFiles, '**/*.scss')
? [`prettier --check ${quote(scssFiles)}`, `stylelint ${quote(scssFiles)}`]
: [];

for (const element of scripts) {
exitCode = await exec(element);
Expand Down
9 changes: 7 additions & 2 deletions build/tasks/verify/verify-spelling.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @module {type ES6Module} build/tasks/verify/verify-spelling
*/

import { exec, glob, quote } from '@openinf/portal/build/utils';
import { exec, glob, matched, quote } from '@openinf/portal/build/utils';

// Comments and template prose are read as often as the documentation is, and
// cspell's `en` dictionary is the American one, so this is also what holds the
Expand All @@ -30,4 +30,9 @@ const files = await glob([
'!collections/_pages/vision.md',
]);

process.exitCode = await exec(`cspell lint ${quote(files)}`);
process.exitCode = matched(
files,
'**/*.{md,html,liquid,scss,mts,mjs,json,yml,yaml,sh}'
)
? await exec(`cspell lint ${quote(files)}`)
: 1;
Loading
Loading