@browserstack/accessibility-devtools-cli 0.0.3 → 0.0.5

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.
Files changed (2) hide show
  1. package/index.js +23 -11
  2. package/package.json +3 -3
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 = filePath.split(".").pop()?.toLowerCase() || "";
4574
- return this.supportedFileExtensions.includes(`.${extension}`);
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:443/ws";
8532
- var EDS_API_KEY = "";
8532
+ var LINTER_SERVER_ADDRESS = "wss://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,14 @@ 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
- const { description, help, failureSummary } = parsed.success ? parsed.data : { description: message, help: "", failureSummary: "" };
8650
+ if (!parsed.success) {
8651
+ return [
8652
+ source_default.cyan(formatLocation(filePath, line, column, endLine, endColumn)),
8653
+ source_default.yellow(`Rule: ${ruleId}`),
8654
+ source_default.white(`Description: ${message}`)
8655
+ ].join("\n");
8656
+ }
8657
+ const { description, help, failureSummary } = parsed.data;
8651
8658
  const lines = [
8652
8659
  source_default.cyan(formatLocation(filePath, line, column, endLine, endColumn)),
8653
8660
  source_default.yellow(`Rule: ${ruleId.split("/")[1]}`),
@@ -8658,7 +8665,7 @@ function formatMessage(msg, filePath) {
8658
8665
  return lines.filter(Boolean).join("\n");
8659
8666
  }
8660
8667
  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");
8668
+ 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
8669
  }
8663
8670
  async function initializeAndAuthenticate(linterClient, args) {
8664
8671
  const { browserstackUsername, browserstackAccessKey } = args;
@@ -8708,7 +8715,7 @@ async function main(args) {
8708
8715
  const isInstrumentationAvailable = Boolean(EDS_API_KEY && EDS_BACKEND);
8709
8716
  const authResult = await initializeAndAuthenticate(linterClient, args);
8710
8717
  if (!authResult.success) {
8711
- console.error(source_default.red(`Error: ${authResult.error}`));
8718
+ console.error(source_default.red(`Error: Authentication failed`));
8712
8719
  process.exit(EXIT_CODES.ERROR);
8713
8720
  }
8714
8721
  const userProfile = authResult.data;
@@ -8720,10 +8727,10 @@ async function main(args) {
8720
8727
  console.log(source_default.yellow("No files to lint. Please check your include/exclude patterns."));
8721
8728
  process.exit(EXIT_CODES.SUCCESS);
8722
8729
  }
8723
- if (fileList.some((file) => !SUPPORTED_FILE_EXTENSIONS.includes(path.extname(file)))) {
8730
+ if (fileList.some((file) => !linterClient.isFileExtensionSupported(file))) {
8724
8731
  console.error(
8725
8732
  source_default.red(
8726
- `Error: Unsupported file types. Supported extensions are: ${SUPPORTED_FILE_EXTENSIONS.join(", ")}`
8733
+ `Error: Unsupported file types. Supported extensions are: ${linterClient.getSupportedFileExtensions().join(", ")}`
8727
8734
  )
8728
8735
  );
8729
8736
  process.exit(1);
@@ -8735,6 +8742,9 @@ async function main(args) {
8735
8742
  fileList.map(async (file) => {
8736
8743
  const fileStart = import_node_perf_hooks.performance.now();
8737
8744
  const code = await fs.readFile(file, "utf-8");
8745
+ if (!code || !file) {
8746
+ return [];
8747
+ }
8738
8748
  let result = [];
8739
8749
  try {
8740
8750
  result = await linterClient.lintText(file, code);
@@ -8774,7 +8784,9 @@ async function main(args) {
8774
8784
  if (require.main === module) {
8775
8785
  const parsedArgs = parseArgs();
8776
8786
  if (!parsedArgs) process.exit(EXIT_CODES.ERROR);
8777
- main(parsedArgs).catch((err) => (console.error({ err }), process.exit(EXIT_CODES.ERROR)));
8787
+ main(parsedArgs).catch(
8788
+ (err) => (console.error(`Unknown Error: ${String(err)}`), process.exit(EXIT_CODES.ERROR))
8789
+ );
8778
8790
  }
8779
8791
  // Annotate the CommonJS export names for ESM import in node:
8780
8792
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@browserstack/accessibility-devtools-cli",
3
- "displayName": "BrowserStack Accessibility Linter CLI",
3
+ "displayName": "BrowserStack Accessibility Linter CLI (Beta)",
4
4
  "description": "Command-line interface for BrowserStack Accessibility Linter",
5
- "version": "0.0.3",
5
+ "version": "0.0.5",
6
6
  "main": "./index.js",
7
7
  "author": {
8
8
  "name": "Rishabh Jain",
@@ -17,4 +17,4 @@
17
17
  "scripts": {},
18
18
  "devDependencies": {},
19
19
  "dependencies": {}
20
- }
20
+ }