@browserstack/accessibility-devtools-cli 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +19 -11
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4437,6 +4437,7 @@ var require_linterClient = __commonJS({
|
|
|
4437
4437
|
};
|
|
4438
4438
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
4439
4439
|
var events_1 = __importDefault(require("events"));
|
|
4440
|
+
var path_1 = __importDefault(require("path"));
|
|
4440
4441
|
var ws_1 = __importDefault(require_ws());
|
|
4441
4442
|
var LinterClient2 = class _LinterClient extends events_1.default {
|
|
4442
4443
|
constructor({ linterServerAddress, userLogger, internalLogger, retry, retryInterval }) {
|
|
@@ -4570,8 +4571,8 @@ var require_linterClient = __commonJS({
|
|
|
4570
4571
|
return this.supportedFileExtensions;
|
|
4571
4572
|
}
|
|
4572
4573
|
isFileExtensionSupported(filePath) {
|
|
4573
|
-
const extension =
|
|
4574
|
-
return this.supportedFileExtensions.includes(
|
|
4574
|
+
const extension = path_1.default.extname(filePath).toLowerCase();
|
|
4575
|
+
return this.supportedFileExtensions.includes(extension);
|
|
4575
4576
|
}
|
|
4576
4577
|
async createFile(filePath, code) {
|
|
4577
4578
|
const result = await this.sendRequest({
|
|
@@ -8528,8 +8529,8 @@ var v4_default = v4;
|
|
|
8528
8529
|
|
|
8529
8530
|
// src/buildConfig.ts
|
|
8530
8531
|
var DEBUG = "production"?.toLocaleLowerCase() !== "production";
|
|
8531
|
-
var LINTER_SERVER_ADDRESS = "wss://devtools-a11y-linter.browserstack.com
|
|
8532
|
-
var EDS_API_KEY = "";
|
|
8532
|
+
var LINTER_SERVER_ADDRESS = "wss://devtools-a11y-linter.browserstack.com/ws";
|
|
8533
|
+
var EDS_API_KEY = "5PJymLNdWrOwzQNC7J6SXBuUFQGWq4Vuw";
|
|
8533
8534
|
var EDS_BACKEND = "eds.browserstack.com";
|
|
8534
8535
|
|
|
8535
8536
|
// ../node_modules/commander/esm.mjs
|
|
@@ -8623,7 +8624,6 @@ var mockLogger = {
|
|
|
8623
8624
|
log: () => {
|
|
8624
8625
|
}
|
|
8625
8626
|
};
|
|
8626
|
-
var SUPPORTED_FILE_EXTENSIONS = [".jsx", ".tsx"];
|
|
8627
8627
|
function safeParseMessage(message) {
|
|
8628
8628
|
try {
|
|
8629
8629
|
const { description, help, failureSummary } = JSON.parse(message);
|
|
@@ -8647,7 +8647,10 @@ function formatLocation(filePath, line, column, endLine, endColumn) {
|
|
|
8647
8647
|
function formatMessage(msg, filePath) {
|
|
8648
8648
|
const { ruleId, message, severity, line, column, endLine, endColumn } = msg;
|
|
8649
8649
|
const parsed = safeParseMessage(message);
|
|
8650
|
-
|
|
8650
|
+
if (!parsed.success) {
|
|
8651
|
+
return "";
|
|
8652
|
+
}
|
|
8653
|
+
const { description, help, failureSummary } = parsed.data;
|
|
8651
8654
|
const lines = [
|
|
8652
8655
|
source_default.cyan(formatLocation(filePath, line, column, endLine, endColumn)),
|
|
8653
8656
|
source_default.yellow(`Rule: ${ruleId.split("/")[1]}`),
|
|
@@ -8658,7 +8661,7 @@ function formatMessage(msg, filePath) {
|
|
|
8658
8661
|
return lines.filter(Boolean).join("\n");
|
|
8659
8662
|
}
|
|
8660
8663
|
function formatResults(results) {
|
|
8661
|
-
return results.filter((result) => result.filePath && result.messages?.length > 0).flatMap((result) => result.messages.map((msg) => formatMessage(msg, result.filePath))).join("\n\n");
|
|
8664
|
+
return results.filter((result) => result.filePath && result.messages?.length > 0).flatMap((result) => result.messages.map((msg) => formatMessage(msg, result.filePath))).filter(Boolean).join("\n\n");
|
|
8662
8665
|
}
|
|
8663
8666
|
async function initializeAndAuthenticate(linterClient, args) {
|
|
8664
8667
|
const { browserstackUsername, browserstackAccessKey } = args;
|
|
@@ -8708,7 +8711,7 @@ async function main(args) {
|
|
|
8708
8711
|
const isInstrumentationAvailable = Boolean(EDS_API_KEY && EDS_BACKEND);
|
|
8709
8712
|
const authResult = await initializeAndAuthenticate(linterClient, args);
|
|
8710
8713
|
if (!authResult.success) {
|
|
8711
|
-
console.error(source_default.red(`Error:
|
|
8714
|
+
console.error(source_default.red(`Error: Authentication failed`));
|
|
8712
8715
|
process.exit(EXIT_CODES.ERROR);
|
|
8713
8716
|
}
|
|
8714
8717
|
const userProfile = authResult.data;
|
|
@@ -8720,10 +8723,10 @@ async function main(args) {
|
|
|
8720
8723
|
console.log(source_default.yellow("No files to lint. Please check your include/exclude patterns."));
|
|
8721
8724
|
process.exit(EXIT_CODES.SUCCESS);
|
|
8722
8725
|
}
|
|
8723
|
-
if (fileList.some((file) => !
|
|
8726
|
+
if (fileList.some((file) => !linterClient.isFileExtensionSupported(file))) {
|
|
8724
8727
|
console.error(
|
|
8725
8728
|
source_default.red(
|
|
8726
|
-
`Error: Unsupported file types. Supported extensions are: ${
|
|
8729
|
+
`Error: Unsupported file types. Supported extensions are: ${linterClient.getSupportedFileExtensions().join(", ")}`
|
|
8727
8730
|
)
|
|
8728
8731
|
);
|
|
8729
8732
|
process.exit(1);
|
|
@@ -8735,6 +8738,9 @@ async function main(args) {
|
|
|
8735
8738
|
fileList.map(async (file) => {
|
|
8736
8739
|
const fileStart = import_node_perf_hooks.performance.now();
|
|
8737
8740
|
const code = await fs.readFile(file, "utf-8");
|
|
8741
|
+
if (!code || !file) {
|
|
8742
|
+
return [];
|
|
8743
|
+
}
|
|
8738
8744
|
let result = [];
|
|
8739
8745
|
try {
|
|
8740
8746
|
result = await linterClient.lintText(file, code);
|
|
@@ -8774,7 +8780,9 @@ async function main(args) {
|
|
|
8774
8780
|
if (require.main === module) {
|
|
8775
8781
|
const parsedArgs = parseArgs();
|
|
8776
8782
|
if (!parsedArgs) process.exit(EXIT_CODES.ERROR);
|
|
8777
|
-
main(parsedArgs).catch(
|
|
8783
|
+
main(parsedArgs).catch(
|
|
8784
|
+
(err) => (console.error(`Unknown Error: ${String(err)}`), process.exit(EXIT_CODES.ERROR))
|
|
8785
|
+
);
|
|
8778
8786
|
}
|
|
8779
8787
|
// Annotate the CommonJS export names for ESM import in node:
|
|
8780
8788
|
0 && (module.exports = {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@browserstack/accessibility-devtools-cli",
|
|
3
3
|
"displayName": "BrowserStack Accessibility Linter CLI",
|
|
4
4
|
"description": "Command-line interface for BrowserStack Accessibility Linter",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.4",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Rishabh Jain",
|