@bridge-ds/core 0.12.0 → 0.15.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.
@@ -0,0 +1,5 @@
1
+ import { type RepoSource, type RepoSourceRef } from '../repo-source';
2
+ /** owner, repo and sha of a checkout: the github.com origin remote and HEAD, when git knows them. */
3
+ export declare function localRepoRef(root: string): RepoSourceRef;
4
+ /** A RepoSource over the files of `root` as they are on disk (uncommitted changes included). */
5
+ export declare function fsSource(root: string, ref?: Partial<RepoSourceRef>): RepoSource;
@@ -5,3 +5,4 @@ export * from './component-specs';
5
5
  export * from './spec-css';
6
6
  export * from './spec-motion';
7
7
  export * from './suggestion-apply-node';
8
+ export * from './fs-source';
@@ -1,11 +1,11 @@
1
- import { execFile } from "node:child_process";
1
+ import { execFile, execFileSync } from "node:child_process";
2
2
  import { mkdtemp, rm, mkdir, writeFile, lstat, readFile } from "node:fs/promises";
3
3
  import { tmpdir } from "node:os";
4
4
  import { join, resolve, relative, dirname, sep, posix } from "node:path";
5
- import { aU as assertSafeBranch, c as collectHistory, p as packageDirCandidates, a as parseChangelog, m as mergeReleases, r as releasesFromTags, b as buildReport, cr as prNumberFromSubject, cO as specHash, da as validateComponentSpec, bN as hashSpec, bO as iconComponentName, C as variantKeyOf, d6 as tokenCssVar, aj as COMPONENT_SPECS_VERSION, ai as COLOR_FIELDS, cR as suggestionAppliedComment, X as gitBlobSha, cp as planSuggestionApply } from "../suggestion-apply-DxXRGQrO.js";
6
- import { K as selectTokenFiles, bl as globToRegExp, N as loadConfig, L as LayeredTokenSet, V as CONFIG_FILE, $ as layoutOptions, a0 as buildTokenSet, b3 as defaultContext, B as resolve$1, ae as slugify, bX as protectedBranchesOf, aM as baseBranchOf } from "../prod-branch-BdMPKffE.js";
5
+ import { aZ as assertSafeBranch, c as collectHistory, p as packageDirCandidates, a as parseChangelog, m as mergeReleases, r as releasesFromTags, b as buildReport, cA as prNumberFromSubject, cX as specHash, dk as validateComponentSpec, bT as hashSpec, bU as iconComponentName, C as variantKeyOf, df as tokenCssVar, ao as COMPONENT_SPECS_VERSION, an as COLOR_FIELDS, c_ as suggestionAppliedComment, X as gitBlobSha, cy as planSuggestionApply, ak as normalizeRepoPath } from "../repo-source-CNZLq_xK.js";
6
+ import { K as selectTokenFiles, bl as globToRegExp, N as loadConfig, L as LayeredTokenSet, V as CONFIG_FILE, $ as layoutOptions, a0 as buildTokenSet, b4 as defaultContext, B as resolve$1, ae as slugify, bY as protectedBranchesOf, aN as baseBranchOf } from "../prod-branch-BjXFIz74.js";
7
7
  import { statSync, readFileSync, existsSync, writeFileSync, readdirSync } from "node:fs";
8
- import { i as isAuditable, Q as planCssFixes, O as parseAllowlist, d as DesignSystemIndex, l as buildAuditReport, o as compareWithBaseline, b as AUDIT_IGNORE_DIRS } from "../report-DOnKUw8G.js";
8
+ import { i as isAuditable, Q as planCssFixes, O as parseAllowlist, d as DesignSystemIndex, l as buildAuditReport, o as compareWithBaseline, b as AUDIT_IGNORE_DIRS } from "../report-DCPfvvoq.js";
9
9
  import ts from "typescript";
10
10
  function git(root, args, opts = {}) {
11
11
  return new Promise((resolve2, reject) => {
@@ -3797,6 +3797,53 @@ async function applySuggestionLocally(input) {
3797
3797
  appliedComment: suggestionAppliedComment(plan, { by: input.by, branch, commit: res.sha, at })
3798
3798
  });
3799
3799
  }
3800
+ const SKIP = /* @__PURE__ */ new Set([".git", "node_modules"]);
3801
+ function gitOut(root, args) {
3802
+ try {
3803
+ return execFileSync("git", args, { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
3804
+ } catch {
3805
+ return "";
3806
+ }
3807
+ }
3808
+ function localRepoRef(root) {
3809
+ const origin = /github\.com[:/]([\w.-]+)\/([\w.-]+?)(\.git)?$/.exec(gitOut(root, ["remote", "get-url", "origin"]));
3810
+ return { owner: origin?.[1] ?? "", repo: origin?.[2] ?? "", sha: gitOut(root, ["rev-parse", "HEAD"]) || "working-tree" };
3811
+ }
3812
+ function fsSource(root, ref = {}) {
3813
+ let resolved;
3814
+ const walk2 = (rel, out) => {
3815
+ for (const entry of readdirSync(join(root, rel), { withFileTypes: true })) {
3816
+ if (SKIP.has(entry.name)) continue;
3817
+ const path = rel ? `${rel}/${entry.name}` : entry.name;
3818
+ if (entry.isDirectory()) walk2(path, out);
3819
+ else if (entry.isFile()) out.push(path);
3820
+ else if (entry.isSymbolicLink() && statSync(join(root, path), { throwIfNoEntry: false })?.isFile()) out.push(path);
3821
+ }
3822
+ };
3823
+ return {
3824
+ get ref() {
3825
+ resolved ??= { ...localRepoRef(root), ...Object.fromEntries(Object.entries(ref).filter(([, v]) => v !== void 0)) };
3826
+ return resolved;
3827
+ },
3828
+ async list(prefix = "") {
3829
+ const rel = normalizeRepoPath(prefix);
3830
+ const abs = join(root, rel);
3831
+ if (!existsSync(abs)) return [];
3832
+ if (!statSync(abs).isDirectory()) return [rel];
3833
+ const out = [];
3834
+ walk2(rel, out);
3835
+ return out.sort();
3836
+ },
3837
+ async text(path) {
3838
+ const abs = join(root, normalizeRepoPath(path));
3839
+ try {
3840
+ return statSync(abs).isFile() ? readFileSync(abs, "utf8") : null;
3841
+ } catch {
3842
+ return null;
3843
+ }
3844
+ }
3845
+ };
3846
+ }
3800
3847
  export {
3801
3848
  COMMON_ICONS,
3802
3849
  DEFAULT_STATE,
@@ -3820,6 +3867,7 @@ export {
3820
3867
  fileDiff,
3821
3868
  findDesignSystemRoot,
3822
3869
  fixCss,
3870
+ fsSource,
3823
3871
  generateAllComponentSpecs,
3824
3872
  generateComponentSpec,
3825
3873
  generateComponentSpecs,
@@ -3835,6 +3883,7 @@ export {
3835
3883
  loadDesignSystem,
3836
3884
  loadLocalHistory,
3837
3885
  localGitHistoryBackend,
3886
+ localRepoRef,
3838
3887
  localTags,
3839
3888
  matchComplex,
3840
3889
  mediaApplies,