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
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@
"request": "launch",
"cwd": "${workspaceFolder}/vscode-extensions/rush-vscode-extension",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/vscode-extensions/rush-vscode-extension"
"--extensionDevelopmentPath=${workspaceFolder}/vscode-extensions/rush-vscode-extension/dist/vsix/unpacked"
],
"outFiles": [
"${workspaceFolder}/vscode-extensions/rush-vscode-extension/dist/**/*.js"
"${workspaceFolder}/vscode-extensions/rush-vscode-extension/**"
]
// "preLaunchTask": "npm: build:watch - vscode-extensions/rush-vscode-extension"
},
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/libraries/operation-graph](./libraries/operation-graph/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Foperation-graph.svg)](https://badge.fury.io/js/%40rushstack%2Foperation-graph) | [changelog](./libraries/operation-graph/CHANGELOG.md) | [@rushstack/operation-graph](https://www.npmjs.com/package/@rushstack/operation-graph) |
| [/libraries/package-deps-hash](./libraries/package-deps-hash/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fpackage-deps-hash.svg)](https://badge.fury.io/js/%40rushstack%2Fpackage-deps-hash) | [changelog](./libraries/package-deps-hash/CHANGELOG.md) | [@rushstack/package-deps-hash](https://www.npmjs.com/package/@rushstack/package-deps-hash) |
| [/libraries/package-extractor](./libraries/package-extractor/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fpackage-extractor.svg)](https://badge.fury.io/js/%40rushstack%2Fpackage-extractor) | [changelog](./libraries/package-extractor/CHANGELOG.md) | [@rushstack/package-extractor](https://www.npmjs.com/package/@rushstack/package-extractor) |
| [/libraries/problem-matcher](./libraries/problem-matcher/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fproblem-matcher.svg)](https://badge.fury.io/js/%40rushstack%2Fproblem-matcher) | [changelog](./libraries/problem-matcher/CHANGELOG.md) | [@rushstack/problem-matcher](https://www.npmjs.com/package/@rushstack/problem-matcher) |
| [/libraries/rig-package](./libraries/rig-package/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frig-package.svg)](https://badge.fury.io/js/%40rushstack%2Frig-package) | [changelog](./libraries/rig-package/CHANGELOG.md) | [@rushstack/rig-package](https://www.npmjs.com/package/@rushstack/rig-package) |
| [/libraries/rush-lib](./libraries/rush-lib/) | [![npm version](https://badge.fury.io/js/%40microsoft%2Frush-lib.svg)](https://badge.fury.io/js/%40microsoft%2Frush-lib) | | [@microsoft/rush-lib](https://www.npmjs.com/package/@microsoft/rush-lib) |
| [/libraries/rush-sdk](./libraries/rush-sdk/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-sdk.svg)](https://badge.fury.io/js/%40rushstack%2Frush-sdk) | | [@rushstack/rush-sdk](https://www.npmjs.com/package/@rushstack/rush-sdk) |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Add `IOperationExecutionResult.problemCollector` API which matches and collects VS Code style problem matchers",
"type": "patch"
}
],
"packageName": "@microsoft/rush"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/node-core-library",
"comment": "Add `FileError.getProblemMatcher()` which returns the problem matcher compatible with `IOperationExecutionResult.problemCollector` as well as VS Code, GitHub Actions",
"type": "patch"
}
],
"packageName": "@rushstack/node-core-library"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/problem-matcher",
"comment": "Add @rushstack/problem-matcher library to parse and use VS Code style problem matchers",
"type": "patch"
}
],
"packageName": "@rushstack/problem-matcher"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/terminal",
"comment": "Add `ProblemCollector extends TerminalWritable` API which matches and collects VS Code style problem matchers",
"type": "patch"
}
],
"packageName": "@rushstack/terminal"
}
4 changes: 4 additions & 0 deletions common/config/rush/browser-approved-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
"name": "@reduxjs/toolkit",
"allowedCategories": [ "libraries", "vscode-extensions" ]
},
{
"name": "@rushstack/problem-matcher",
"allowedCategories": [ "libraries" ]
},
{
"name": "@rushstack/rush-themed-ui",
"allowedCategories": [ "libraries" ]
Expand Down
14 changes: 14 additions & 0 deletions common/config/subspaces/build-tests-subspace/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
{
"pnpmShrinkwrapHash": "f89693a88037554bf0c35db4f2295ef771cd2a71",
"pnpmShrinkwrapHash": "a4362af2793dd557efe7e9f005f3e2f376eb2eda",
"preferredVersionsHash": "550b4cee0bef4e97db6c6aad726df5149d20e7d9",
"packageJsonInjectedDependenciesHash": "2fad9cbc4726f383da294e793c5b891d8775fca6"
"packageJsonInjectedDependenciesHash": "79ac135cb61506457e8d49c7ec1342d419bde3e2"
}
18 changes: 18 additions & 0 deletions common/config/subspaces/default/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions common/reviews/api/node-core-library.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export class FileError extends Error {
// @internal (undocumented)
static _environmentVariableIsAbsolutePath: boolean;
getFormattedErrorMessage(options?: IFileErrorFormattingOptions): string;
static getProblemMatcher(options?: Pick<IFileErrorFormattingOptions, 'format'>): IProblemPattern;
readonly line: number | undefined;
readonly projectFolder: string;
// @internal (undocumented)
Expand Down Expand Up @@ -587,6 +588,21 @@ export interface IPeerDependenciesMetaTable {
};
}

// @public
export interface IProblemPattern {
code?: number;
column?: number;
endColumn?: number;
endLine?: number;
file?: number;
line?: number;
location?: number;
loop?: boolean;
message: number;
regexp: string;
severity?: number;
}

// @public
export interface IProcessInfo {
childProcessInfos: IProcessInfo[];
Expand Down
55 changes: 55 additions & 0 deletions common/reviews/api/problem-matcher.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
## API Report File for "@rushstack/problem-matcher"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

// @public
export interface IProblem {
readonly code?: string;
readonly column?: number;
readonly endColumn?: number;
readonly endLine?: number;
readonly file?: string;
readonly line?: number;
readonly matcherName: string;
readonly message: string;
readonly severity?: ProblemSeverity;
}

// @public
export interface IProblemMatcher {
exec(line: string): IProblem | false;
flush?(): IProblem[];
readonly name: string;
}

// @public
export interface IProblemMatcherJson {
name: string;
pattern: IProblemPattern | IProblemPattern[];
severity?: ProblemSeverity;
}

// @public
export interface IProblemPattern {
code?: number;
column?: number;
endColumn?: number;
endLine?: number;
file?: number;
line?: number;
location?: number;
loop?: boolean;
message: number;
regexp: string;
severity?: number;
}

// @public
export function parseProblemMatchersJson(problemMatchers: IProblemMatcherJson[]): IProblemMatcher[];

// @public
export type ProblemSeverity = 'error' | 'warning' | 'info';

```
2 changes: 2 additions & 0 deletions common/reviews/api/rush-lib.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { HookMap } from 'tapable';
import { IFileDiffStatus } from '@rushstack/package-deps-hash';
import { IPackageJson } from '@rushstack/node-core-library';
import { IPrefixMatch } from '@rushstack/lookup-by-path';
import type { IProblemCollector } from '@rushstack/terminal';
import { ITerminal } from '@rushstack/terminal';
import { ITerminalProvider } from '@rushstack/terminal';
import { JsonNull } from '@rushstack/node-core-library';
Expand Down Expand Up @@ -621,6 +622,7 @@ export interface IOperationExecutionResult {
readonly metadataFolderPath: string | undefined;
readonly nonCachedDurationMs: number | undefined;
readonly operation: Operation;
readonly problemCollector: IProblemCollector;
readonly silent: boolean;
readonly status: OperationStatus;
readonly stdioSummarizer: StdioSummarizer;
Expand Down
22 changes: 22 additions & 0 deletions common/reviews/api/terminal.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
/// <reference types="node" />

import type { Brand } from '@rushstack/node-core-library';
import type { IProblem } from '@rushstack/problem-matcher';
import type { IProblemMatcher } from '@rushstack/problem-matcher';
import type { IProblemMatcherJson } from '@rushstack/problem-matcher';
import { NewlineKind } from '@rushstack/node-core-library';
import { Writable } from 'stream';
import { WritableOptions } from 'stream';
Expand Down Expand Up @@ -142,6 +145,17 @@ export interface IPrefixProxyTerminalProviderOptionsBase {
terminalProvider: ITerminalProvider;
}

// @public
export interface IProblemCollector {
getProblems(): ReadonlyArray<IProblem>;
}

// @public
export interface IProblemCollectorOptions extends ITerminalWritableOptions {
matcherJson?: IProblemMatcherJson[];
matchers?: IProblemMatcher[];
}

// @public
export interface ISplitterTransformOptions extends ITerminalWritableOptions {
destinations: TerminalWritable[];
Expand Down Expand Up @@ -287,6 +301,14 @@ export class PrintUtilities {
static wrapWordsToLines(text: string, maxLineLength?: number, indentOrLinePrefix?: number | string): string[];
}

// @public
export class ProblemCollector extends TerminalWritable implements IProblemCollector {
constructor(options: IProblemCollectorOptions);
getProblems(): ReadonlyArray<IProblem>;
protected onClose(): void;
protected onWriteChunk(chunk: ITerminalChunk): void;
}

// @public
export class RemoveColorsTextRewriter extends TextRewriter {
// (undocumented)
Expand Down
4 changes: 3 additions & 1 deletion libraries/node-core-library/config/api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@

"dtsRollup": {
"enabled": true
}
},

"bundledPackages": ["@rushstack/problem-matcher"]
}
1 change: 1 addition & 0 deletions libraries/node-core-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"devDependencies": {
"@rushstack/heft": "0.74.3",
"@rushstack/problem-matcher": "workspace:*",
"@types/fs-extra": "7.0.0",
"@types/jju": "1.4.1",
"@types/resolve": "1.20.2",
Expand Down
40 changes: 40 additions & 0 deletions libraries/node-core-library/src/FileError.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

import type { IProblemPattern } from '@rushstack/problem-matcher';
import { type FileLocationStyle, Path } from './Path';
import { TypeUuid } from './TypeUuid';

Expand Down Expand Up @@ -47,6 +48,27 @@ const uuidFileError: string = '37a4c772-2dc8-4c66-89ae-262f8cc1f0c1';

const baseFolderEnvVar: string = 'RUSHSTACK_FILE_ERROR_BASE_FOLDER';

const unixProblemMatcherPattern: IProblemPattern = {
regexp: '^\\[[^\\]]+\\]\\s+(Error|Warning):\\s+([^:]+):(\\d+):(\\d+)\\s+-\\s+(?:\\(([^)]+)\\)\\s+)?(.*)$',
severity: 1,
file: 2,
line: 3,
column: 4,
code: 5,
message: 6
};

const vsProblemMatcherPattern: IProblemPattern = {
regexp:
'^\\[[^\\]]+\\]\\s+(Error|Warning):\\s+([^\\(]+)\\((\\d+),(\\d+)\\)\\s+-\\s+(?:\\(([^)]+)\\)\\s+)?(.*)$',
severity: 1,
file: 2,
line: 3,
column: 4,
code: 5,
message: 6
};

/**
* An `Error` subclass that should be thrown to report an unexpected state that specifically references
* a location in a file.
Expand Down Expand Up @@ -127,6 +149,24 @@ export class FileError extends Error {
});
}

/**
* Get the problem matcher pattern for parsing error messages.
*
* @param options - Options for the error message format.
* @returns The problem matcher pattern.
*/
public static getProblemMatcher(options?: Pick<IFileErrorFormattingOptions, 'format'>): IProblemPattern {
const format: FileLocationStyle = options?.format || 'Unix';
switch (format) {
case 'Unix':
return unixProblemMatcherPattern;
case 'VisualStudio':
return vsProblemMatcherPattern;
default:
throw new Error(`The FileError format "${format}" is not supported for problem matchers.`);
}
}

private _evaluateBaseFolder(): string | undefined {
// Cache the sanitized environment variable. This means that we don't support changing
// the environment variable mid-execution. This is a reasonable tradeoff for the benefit
Expand Down
1 change: 1 addition & 0 deletions libraries/node-core-library/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export {
Executable
} from './Executable';
export { type IFileErrorOptions, type IFileErrorFormattingOptions, FileError } from './FileError';
export type { IProblemPattern } from '@rushstack/problem-matcher';
export type {
INodePackageJson,
IPackageJson,
Expand Down
Loading
Loading