@xcelera/cli 2.4.0 → 3.0.0

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/dist/cli.js CHANGED
@@ -62,7 +62,7 @@ function isNetworkError(error) {
62
62
  return errorMessages.has(message);
63
63
  }
64
64
 
65
- async function requestAudit(url, token, context, auth) {
65
+ async function requestAudit(ref, token, context, auth) {
66
66
  const apiUrl = `${getApiBaseUrl()}/api/v1/audit`;
67
67
  try {
68
68
  const response = await fetch(apiUrl, {
@@ -72,7 +72,7 @@ async function requestAudit(url, token, context, auth) {
72
72
  Authorization: `Bearer ${token}`
73
73
  },
74
74
  body: JSON.stringify({
75
- url,
75
+ ref,
76
76
  context,
77
77
  ...(auth && { auth })
78
78
  })
@@ -9412,7 +9412,7 @@ function parseEpochSeconds(value, lineNumber, sourceLabel) {
9412
9412
  return num;
9413
9413
  }
9414
9414
 
9415
- async function runAuditCommand(url, token, authOptions) {
9415
+ async function runAuditCommand(ref, token, authOptions) {
9416
9416
  const output = [];
9417
9417
  const errors = [];
9418
9418
  try {
@@ -9424,13 +9424,13 @@ async function runAuditCommand(url, token, authOptions) {
9424
9424
  output.push('🔐 Authentication credentials detected');
9425
9425
  output.push('');
9426
9426
  }
9427
- const response = await requestAudit(url, token, buildContext, auth);
9427
+ const response = await requestAudit(ref, token, buildContext, auth);
9428
9428
  if (!response.success) {
9429
9429
  const { message, details } = response.error;
9430
9430
  errors.push('❌ Unable to schedule audit :(');
9431
9431
  errors.push(` ↳ ${message}`);
9432
9432
  if (details) {
9433
- errors.push(` ↳ ${details}`);
9433
+ errors.push(` ↳ ${JSON.stringify(details)}`);
9434
9434
  }
9435
9435
  return { exitCode: 1, output, errors };
9436
9436
  }
@@ -9563,7 +9563,7 @@ function parseCookie(cookie) {
9563
9563
 
9564
9564
  /* istanbul ignore file */
9565
9565
  const options = {
9566
- url: {
9566
+ ref: {
9567
9567
  type: 'string',
9568
9568
  required: true
9569
9569
  },
@@ -9604,17 +9604,17 @@ if (command !== 'audit') {
9604
9604
  printHelp();
9605
9605
  process.exit(1);
9606
9606
  }
9607
- const { url, token, cookie, header } = values;
9607
+ const { ref, token, cookie, header } = values;
9608
9608
  const cookieFile = values['cookie-file'];
9609
- if (!url) {
9610
- console.error('URL is required. Use --url <url> to specify the URL to audit.');
9609
+ if (!ref) {
9610
+ console.error('Page ref is required. Use --ref <ref> to specify the page reference to audit. This can be found on the page definition in the xcelera dashboard.');
9611
9611
  process.exit(1);
9612
9612
  }
9613
9613
  if (!token) {
9614
9614
  console.error('A token is required. Use --token or set XCELERA_TOKEN environment variable.');
9615
9615
  process.exit(1);
9616
9616
  }
9617
- const result = await runAuditCommand(url, token, {
9617
+ const result = await runAuditCommand(ref, token, {
9618
9618
  cookieFile,
9619
9619
  cookies: cookie,
9620
9620
  headers: header
@@ -9623,12 +9623,12 @@ result.output.forEach((line) => console.log(line));
9623
9623
  result.errors.forEach((line) => console.error(line));
9624
9624
  process.exit(result.exitCode);
9625
9625
  function printHelp() {
9626
- console.log('Usage: xcelera audit --url <url> [options]');
9626
+ console.log('Usage: xcelera audit --ref <ref> [options]');
9627
9627
  console.log('');
9628
9628
  console.log('Options:');
9629
9629
  console.log(' --token <token> The xcelera API token.');
9630
9630
  console.log(' Can also be set with XCELERA_TOKEN env var.');
9631
- console.log(' --url <url> The URL to audit.');
9631
+ console.log(' --ref <ref> The reference of the page to audit.');
9632
9632
  console.log('');
9633
9633
  console.log('Authentication (for pages behind login):');
9634
9634
  console.log(' --cookie <cookie> Cookie in "name=value" format.');
@@ -9640,21 +9640,21 @@ function printHelp() {
9640
9640
  console.log('');
9641
9641
  console.log('Examples:');
9642
9642
  console.log(' # Basic audit');
9643
- console.log(' xcelera audit --url https://example.com');
9643
+ console.log(' xcelera audit --ref example-page-xdfd');
9644
9644
  console.log('');
9645
9645
  console.log(' # With session cookie');
9646
- console.log(' xcelera audit --url https://myapp.com/dashboard --cookie "session=abc123"');
9646
+ console.log(' xcelera audit --ref example-page-xdfd --cookie "session=abc123"');
9647
9647
  console.log('');
9648
9648
  console.log(' # With bearer token');
9649
- console.log(' xcelera audit --url https://api.myapp.com/admin \\');
9649
+ console.log(' xcelera audit --ref example-page-xdfd \\');
9650
9650
  console.log(' --header "Authorization: Bearer eyJhbG..."');
9651
9651
  console.log('');
9652
9652
  console.log(' # Multiple cookies');
9653
- console.log(' xcelera audit --url https://myapp.com/dashboard \\');
9653
+ console.log(' xcelera audit --ref example-page-xdfd \\');
9654
9654
  console.log(' --cookie "session=abc123" --cookie "csrf=xyz"');
9655
9655
  console.log('');
9656
9656
  console.log(' # With cookie file (Netscape cookies.txt format)');
9657
- console.log(' xcelera audit --url https://myapp.com/dashboard --cookie-file ./cookies.txt');
9657
+ console.log(' xcelera audit --ref example-page-xdfd --cookie-file ./cookies.txt');
9658
9658
  console.log('');
9659
9659
  }
9660
9660
  //# sourceMappingURL=cli.js.map