@tempo-ai/visual-review 0.0.138 → 0.0.139

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.
@@ -1,10 +1,17 @@
1
1
  import { createRequire as __tempoCreateRequire } from 'node:module'; const require = __tempoCreateRequire(import.meta.url);
2
+ import {
3
+ buildBitbucketNoVisualChangeComment,
4
+ upsertBitbucketStickyComment
5
+ } from "./chunk-TEVWNWZ6.js";
2
6
  import {
3
7
  DEFAULT_VISUAL_REVIEW_INGEST_URL,
8
+ declareNoVisualChangeIfPresent,
9
+ detectCiContext,
4
10
  fetchWithRetry,
5
- githubPullRequestContext,
6
- resolveIngestCredential
7
- } from "./chunk-CKMUCU6E.js";
11
+ readCiState,
12
+ resolveIngestCredential,
13
+ writeCiState
14
+ } from "./chunk-H7MXR6QX.js";
8
15
  import {
9
16
  __commonJS,
10
17
  __require,
@@ -40238,7 +40245,7 @@ var MissingRootDepsError = class extends TempoDevServerError {
40238
40245
  // ../tempo-sdk/package.json
40239
40246
  var package_default = {
40240
40247
  name: "tempo-sdk",
40241
- version: "0.0.89",
40248
+ version: "0.0.92",
40242
40249
  publishConfig: {
40243
40250
  tag: "sdk-v2-latest"
40244
40251
  },
@@ -41428,6 +41435,28 @@ function matchMissingTempoSdkImport(line) {
41428
41435
  );
41429
41436
  return missingEntry ? `entry \`tempo-sdk/${missingEntry[1]}\`` : null;
41430
41437
  }
41438
+ function installedPackageRoot(file) {
41439
+ const normalized = file.replace(/\\/g, "/");
41440
+ const marker = "/node_modules/";
41441
+ const index = normalized.lastIndexOf(marker);
41442
+ if (index < 0) return null;
41443
+ const segments = normalized.slice(index + marker.length).split("/");
41444
+ const name = segments[0]?.startsWith("@") ? segments.slice(0, 2) : segments.slice(0, 1);
41445
+ if (name.length === 0 || name.some((segment) => !segment)) return null;
41446
+ return `${normalized.slice(0, index + marker.length)}${name.join("/")}`;
41447
+ }
41448
+ function isPackageMissingItsOwnFile(output) {
41449
+ const missing = output.match(
41450
+ /Cannot find (?:module|package) ['"]((?:\/|[A-Za-z]:[\\/])[^'"]+)['"]/
41451
+ );
41452
+ if (!missing) return false;
41453
+ const importer = output.match(
41454
+ /imported from ((?:\/|[A-Za-z]:[\\/])[^\s'"]+)/
41455
+ )?.[1] ?? output.match(/Require stack:\s*\n\s*-\s*(\S+)/)?.[1];
41456
+ if (!importer) return false;
41457
+ const root2 = installedPackageRoot(missing[1]);
41458
+ return root2 !== null && root2 === installedPackageRoot(importer);
41459
+ }
41431
41460
  function createDevServerOutputClassifier() {
41432
41461
  let pending = "";
41433
41462
  let cssFile = null;
@@ -41567,6 +41596,12 @@ function matchClass(line) {
41567
41596
  errorCode: "node_version_unsupported"
41568
41597
  };
41569
41598
  }
41599
+ if (isPackageMissingItsOwnFile(line)) {
41600
+ return {
41601
+ class: "installed-packages-changed",
41602
+ hint: "The canvas server's installed packages changed while it was running (a reinstall or cleanup removed files it had loaded), and it can't recover on its own. Retry restarts it."
41603
+ };
41604
+ }
41570
41605
  const packageSubpathExportMatch = line.match(
41571
41606
  /Missing\s+["'](\.\/[^"']+)["']\s+specifier\s+in\s+["']([^"']+)["']/i
41572
41607
  );
@@ -41578,7 +41613,13 @@ function matchClass(line) {
41578
41613
  hint: `Vite could not resolve package subpath ${importPath}. Fix the import path or the package export map; this is a package export issue, not a local install strategy issue.`
41579
41614
  };
41580
41615
  }
41581
- if (/ERESOLVE|unable to resolve dependency tree|could not resolve/i.test(line)) {
41616
+ if (
41617
+ // npm's install wording only; a bare "could not resolve" also appears in
41618
+ // bundler and runtime errors that have nothing to do with an install.
41619
+ /ERESOLVE|unable to resolve dependency tree|could not resolve dependency/i.test(
41620
+ line
41621
+ )
41622
+ ) {
41582
41623
  return {
41583
41624
  class: "dependency-conflict",
41584
41625
  hint: "Package installation hit a dependency resolution conflict. Tempo avoids strict CI installs locally; if this persists, package.json or the lockfile needs a targeted dependency fix."
@@ -45133,10 +45174,11 @@ function readStringAttribute(openingElement, name) {
45133
45174
  attributeSpan: toSpan(attribute) ?? { start: 0, end: 0 }
45134
45175
  };
45135
45176
  }
45136
- const expression = unwrapAttributeExpression(value);
45137
- if (expression?.type === "Literal" && typeof expression.value === "string") {
45177
+ const expression = unwrapTsExpression(unwrapAttributeExpression(value));
45178
+ const fixed = expression?.type === "Literal" && typeof expression.value === "string" ? expression.value : expression?.type === "TemplateLiteral" && (expression.expressions?.length ?? 0) === 0 && expression.quasis?.length === 1 && typeof expression.quasis[0]?.value?.cooked === "string" ? expression.quasis[0].value.cooked : null;
45179
+ if (fixed !== null) {
45138
45180
  return {
45139
- value: expression.value,
45181
+ value: fixed,
45140
45182
  valueSpan: toSpan(expression) ?? toSpan(attribute) ?? { start: 0, end: 0 },
45141
45183
  attributeSpan: toSpan(attribute) ?? { start: 0, end: 0 }
45142
45184
  };
@@ -62902,7 +62944,13 @@ var VisualReviewIngestClient = class {
62902
62944
  async authHeader() {
62903
62945
  const credential = await this.credential();
62904
62946
  this.lastCredentialKind = credential.kind;
62905
- return credential.kind === "oidc" ? { "x-visual-review-oidc": credential.value } : { "x-visual-review-secret": credential.value };
62947
+ if (credential.kind !== "oidc") {
62948
+ return { "x-visual-review-secret": credential.value };
62949
+ }
62950
+ return credential.repoKey ? {
62951
+ "x-visual-review-oidc": credential.value,
62952
+ "x-visual-review-repo-key": credential.repoKey
62953
+ } : { "x-visual-review-oidc": credential.value };
62906
62954
  }
62907
62955
  async request(path44, init) {
62908
62956
  const response = await fetchWithRetry(
@@ -63093,7 +63141,10 @@ var VisualReviewIngestClient = class {
63093
63141
  envFingerprint: manifest.envFingerprint,
63094
63142
  expected: manifest.expected,
63095
63143
  snapshots: manifest.snapshots,
63096
- baselineClaimToken: manifest.baselineClaimToken
63144
+ baselineClaimToken: manifest.baselineClaimToken,
63145
+ // Non-GitHub providers name their repository here (GitHub keeps
63146
+ // `githubRepo`); absent on GitHub runs, so their body is unchanged.
63147
+ scm: manifest.scm
63097
63148
  })
63098
63149
  });
63099
63150
  if (!response.ok) {
@@ -63120,25 +63171,26 @@ function inferRepoRoot() {
63120
63171
  }
63121
63172
  }
63122
63173
  function parseArgs(argv) {
63123
- const eventName = process.env.GITHUB_EVENT_NAME;
63124
- const pullRequest = githubPullRequestContext();
63125
- const inferredTrigger = eventName === "pull_request" ? "pr" : eventName === "push" ? "main" : "manual";
63174
+ const ci = detectCiContext();
63126
63175
  const args = {
63127
63176
  repoRoot: inferRepoRoot(),
63128
63177
  tempoDir: "",
63129
63178
  tempoDirExplicit: false,
63130
- // The published CLI is intentionally near-argumentless in Actions. Local
63179
+ // The published CLI is intentionally near-argumentless in CI. Local
63131
63180
  // capture remains Convex-free unless --upload is explicit.
63132
- upload: process.env.GITHUB_ACTIONS === "true" && inferredTrigger !== "manual",
63133
- trigger: inferredTrigger,
63181
+ upload: ci.isCi && ci.trigger !== "manual",
63182
+ trigger: ci.trigger,
63134
63183
  baseDepth: 50,
63135
- prNumber: pullRequest?.number,
63136
- headSha: pullRequest?.headSha ?? process.env.GITHUB_SHA,
63137
- branch: pullRequest?.headRef ?? process.env.GITHUB_HEAD_REF ?? process.env.GITHUB_REF_NAME,
63138
- githubRepo: process.env.GITHUB_REPOSITORY,
63184
+ prNumber: ci.prNumber,
63185
+ headSha: ci.headSha,
63186
+ branch: ci.branch,
63187
+ // GitHub keys its repo by `githubRepo`; Bitbucket supplies the repo key.
63188
+ githubRepo: ci.provider === "bitbucket" ? void 0 : ci.repoFullName,
63189
+ repoKey: ci.repoKey,
63139
63190
  // Reused pages make six workers faster than twelve: each worker pays one
63140
63191
  // cold React/module-graph boot, while later storyboard switches are warm.
63141
- parallel: 6
63192
+ parallel: 6,
63193
+ ci
63142
63194
  };
63143
63195
  for (let index = 0; index < argv.length; index += 1) {
63144
63196
  const flag = argv[index];
@@ -63219,8 +63271,19 @@ function parseArgs(argv) {
63219
63271
  }
63220
63272
  function inferPrBase(args) {
63221
63273
  if (args.trigger !== "pr" || args.baseSha) return;
63222
- const pullRequest = githubPullRequestContext();
63223
- const baseRef = pullRequest?.baseRef ?? process.env.GITHUB_BASE_REF;
63274
+ const baseRef = args.ci.baseRef;
63275
+ if (baseRef && args.ci.provider === "bitbucket") {
63276
+ try {
63277
+ git(
63278
+ args.repoRoot,
63279
+ "fetch",
63280
+ "--no-tags",
63281
+ "origin",
63282
+ `+refs/heads/${baseRef}:refs/remotes/origin/${baseRef}`
63283
+ );
63284
+ } catch {
63285
+ }
63286
+ }
63224
63287
  if (baseRef) {
63225
63288
  try {
63226
63289
  args.baseSha = git(
@@ -63232,7 +63295,7 @@ function inferPrBase(args) {
63232
63295
  } catch {
63233
63296
  }
63234
63297
  }
63235
- args.baseSha ??= pullRequest?.baseSha;
63298
+ args.baseSha ??= args.ci.baseSha;
63236
63299
  }
63237
63300
  function git(repoRoot, ...gitArgs) {
63238
63301
  return execFileSync("git", gitArgs, {
@@ -63474,6 +63537,23 @@ async function main(argv = process.argv.slice(2)) {
63474
63537
  const log = (line) => console.log(`[visual-review] ${line}`);
63475
63538
  const headSha = args.headSha ?? git(args.repoRoot, "rev-parse", "HEAD");
63476
63539
  const branch = args.branch || git(args.repoRoot, "branch", "--show-current") || "detached";
63540
+ if (args.upload && args.baselineClaimToken === void 0 && args.trigger === "pr" && args.ci.provider === "bitbucket" && args.prNumber !== void 0) {
63541
+ if (await declareNoVisualChangeIfPresent(headSha)) {
63542
+ log("no-visual-change declaration present \u2014 posted success and skipped capture");
63543
+ writeCiState({ declared: "no-visual-change" });
63544
+ await upsertBitbucketStickyComment({
63545
+ repoFullName: args.ci.repoFullName,
63546
+ prNumber: args.prNumber,
63547
+ body: buildBitbucketNoVisualChangeComment(),
63548
+ log
63549
+ }).catch(
63550
+ (error) => log(
63551
+ `sticky comment failed: ${error instanceof Error ? error.message : error}`
63552
+ )
63553
+ );
63554
+ return 0;
63555
+ }
63556
+ }
63477
63557
  const baseCandidates = args.baseSha ? git(
63478
63558
  args.repoRoot,
63479
63559
  "rev-list",
@@ -63523,7 +63603,8 @@ async function main(argv = process.argv.slice(2)) {
63523
63603
  let ownedClaimLeaseExpiresAt = 0;
63524
63604
  let heartbeat = null;
63525
63605
  let reusedCandidate = null;
63526
- const announcedOwnerToken = process.env.VISUAL_REVIEW_CAPTURE_OWNER_TOKEN;
63606
+ const announcedOwnerToken = process.env.VISUAL_REVIEW_CAPTURE_OWNER_TOKEN ?? (args.ci.provider === "bitbucket" ? readCiState().captureOwnerToken : void 0);
63607
+ const ownsStepOutputs = args.baselineClaimToken === void 0;
63527
63608
  let terminating = false;
63528
63609
  const releaseCurrentClaims = async (reason) => {
63529
63610
  if (!ingest) return;
@@ -63749,6 +63830,7 @@ async function main(argv = process.argv.slice(2)) {
63749
63830
  const manifest = {
63750
63831
  repoKey,
63751
63832
  githubRepo: args.githubRepo,
63833
+ ...args.ci.provider === "bitbucket" && args.ci.repoFullName ? { scm: { provider: "bitbucket", fullName: args.ci.repoFullName } } : {},
63752
63834
  headSha,
63753
63835
  branch,
63754
63836
  trigger: args.trigger,
@@ -63862,6 +63944,13 @@ async function main(argv = process.argv.slice(2)) {
63862
63944
  JSON.stringify(finalizeResult, null, 2)
63863
63945
  );
63864
63946
  }
63947
+ if (args.ci.provider === "bitbucket" && ownsStepOutputs) {
63948
+ writeCiState({
63949
+ reportKey: finalizeResult.reportKey,
63950
+ reportUrl: finalizeResult.reportUrl,
63951
+ statusUrl: finalizeResult.statusUrl
63952
+ });
63953
+ }
63865
63954
  if (process.env.GITHUB_OUTPUT) {
63866
63955
  await writeFile12(
63867
63956
  process.env.GITHUB_OUTPUT,
@@ -63925,4 +64014,4 @@ export {
63925
64014
  buildBaselineCaptureArgs,
63926
64015
  main
63927
64016
  };
63928
- //# sourceMappingURL=chunk-V4U3XAR5.js.map
64017
+ //# sourceMappingURL=chunk-VZDQYZCX.js.map