@bridge-ds/mcp 0.4.1 → 0.6.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/branches.d.ts +9 -1
- package/dist/{chunk-QTO4EP6V.js → chunk-E4D5KPIQ.js} +25 -6
- package/dist/{chunk-MXMMPO7F.js → chunk-M7DUTFIQ.js} +2074 -124
- package/dist/explorations.d.ts +6 -1
- package/dist/figma.d.ts +83 -0
- package/dist/index.js +2 -2
- package/dist/lib.d.ts +2 -0
- package/dist/lib.js +6 -2
- package/dist/ops.d.ts +3 -0
- package/dist/pieces.d.ts +122 -0
- package/dist/{src-DHJOM5PQ.js → src-F2PTXW5B.js} +1 -1
- package/package.json +3 -3
package/dist/branches.d.ts
CHANGED
|
@@ -9,8 +9,16 @@ export declare const RIGHTS: {
|
|
|
9
9
|
readonly draft: "Pull requests: read and write (you must be the author, as in Studio)";
|
|
10
10
|
readonly docs: "Contents and Pull requests: read and write";
|
|
11
11
|
};
|
|
12
|
+
export declare function reader(ctx: BridgeContext): Promise<GitHubClient>;
|
|
13
|
+
/**
|
|
14
|
+
* A client for writes on a branch someone already opened (any name, never a protected branch): the token is required,
|
|
15
|
+
* with the rights `need` names, so the error says exactly what to add.
|
|
16
|
+
*/
|
|
17
|
+
export declare function writer(ctx: BridgeContext, what: string, need: string): Promise<GitHubClient>;
|
|
12
18
|
/** 12, "#12" or a pull request link: the branch number. Throws how to fix it otherwise. */
|
|
13
19
|
export declare function branchNumber(input: number | string): number;
|
|
20
|
+
/** The viewer of the token, or null without one (or when GitHub does not say). */
|
|
21
|
+
export declare function viewerOf(ctx: BridgeContext, gh: GitHubClient): Promise<string | null>;
|
|
14
22
|
/** Everything Studio reads about one branch to paint its header and decide its actions. */
|
|
15
23
|
export declare function branchFacts(ctx: BridgeContext, gh: GitHubClient, n: number, viewer: string | null): Promise<{
|
|
16
24
|
config: BridgeConfig;
|
|
@@ -180,7 +188,7 @@ export declare function tryBranch(ctx: BridgeContext, a: {
|
|
|
180
188
|
}[];
|
|
181
189
|
share: {
|
|
182
190
|
message?: import("@bridge-ds/core").ShareMessage | undefined;
|
|
183
|
-
state: "ready" | "building" | "failed" | "closed" | "
|
|
191
|
+
state: "ready" | "building" | "failed" | "closed" | "shipped" | "no-packages";
|
|
184
192
|
install: string | null;
|
|
185
193
|
sentence: string;
|
|
186
194
|
};
|
|
@@ -558,6 +558,8 @@ function sameProducts(a, b) {
|
|
|
558
558
|
|
|
559
559
|
// ../core/src/config.ts
|
|
560
560
|
var CONFIG_FILE = "bridge.config.json";
|
|
561
|
+
var CHANGES_MODES = ["suggest", "direct"];
|
|
562
|
+
var DEFAULT_CHANGES_MODE = "suggest";
|
|
561
563
|
var DEFAULT_OVERRIDE = { allowed: [], requireReason: true, minReasonLength: 20 };
|
|
562
564
|
var DEFAULT_TOKEN_PATHS = {
|
|
563
565
|
root: "tokens",
|
|
@@ -697,6 +699,8 @@ function defineConfig(input) {
|
|
|
697
699
|
...g.rights ? { rights: normalizeRights(g.rights) } : {}
|
|
698
700
|
},
|
|
699
701
|
products: input.products?.length ? input.products.map((p) => ({ ...p })) : DEFAULT_PRODUCTS.map((p) => ({ ...p })),
|
|
702
|
+
changes: input.changes === "direct" ? "direct" : DEFAULT_CHANGES_MODE,
|
|
703
|
+
...input.storybook?.url ? { storybook: { url: input.storybook.url.trim().replace(/\/+$/, "") } } : {},
|
|
700
704
|
...input.audit ? { audit: { ...input.audit } } : {},
|
|
701
705
|
...input.visualImpact ? { visualImpact: { mode: input.visualImpact.mode === "on-demand" ? "on-demand" : "auto" } } : {},
|
|
702
706
|
...input.integrations ? { integrations: { ...input.integrations } } : {},
|
|
@@ -819,6 +823,13 @@ function loadConfig(source) {
|
|
|
819
823
|
}
|
|
820
824
|
}
|
|
821
825
|
problems.push(...visualImpactProblems(d.visualImpact));
|
|
826
|
+
if (d.changes !== void 0 && !CHANGES_MODES.includes(d.changes)) problems.push(`"changes" must be "suggest" or "direct" (got ${JSON.stringify(d.changes)})`);
|
|
827
|
+
const sb = d.storybook;
|
|
828
|
+
if (sb !== void 0) {
|
|
829
|
+
if (!isObj(sb) || !isStr(sb.url)) problems.push('"storybook" must be { "url" } with the deployed Storybook address');
|
|
830
|
+
else if (!/^https:\/\/[^\s/]+/.test(sb.url.trim())) problems.push('"storybook.url" must start with https://, for example https://storybook.example.com');
|
|
831
|
+
else for (const k of Object.keys(sb)) if (k !== "url") problems.push(`"storybook.${k}" is not a known key`);
|
|
832
|
+
}
|
|
822
833
|
problems.push(...productProblems(d.products));
|
|
823
834
|
const audit = d.audit;
|
|
824
835
|
if (audit !== void 0) {
|
|
@@ -851,6 +862,7 @@ function loadConfig(source) {
|
|
|
851
862
|
var tokensPath = (config, rel = "") => [config.tokens.root === "." ? "" : config.tokens.root, rel].filter(Boolean).join("/");
|
|
852
863
|
var protectedBranchesOf = (config) => [.../* @__PURE__ */ new Set([...config.governance.protectedBranches, ...config.repo ? [config.repo.defaultBranch] : []])];
|
|
853
864
|
var baseBranchOf = (config) => config.repo?.defaultBranch ?? "main";
|
|
865
|
+
var changesMode = (config) => config?.changes === "direct" ? "direct" : DEFAULT_CHANGES_MODE;
|
|
854
866
|
function toConfigJson(config, schema = "./packages/core/bridge.config.schema.json") {
|
|
855
867
|
return {
|
|
856
868
|
$schema: schema,
|
|
@@ -867,6 +879,8 @@ function toConfigJson(config, schema = "./packages/core/bridge.config.schema.jso
|
|
|
867
879
|
...config.audit ? { audit: config.audit } : {},
|
|
868
880
|
...config.previews ? { previews: config.previews } : {},
|
|
869
881
|
...config.visualImpact ? { visualImpact: config.visualImpact } : {},
|
|
882
|
+
changes: changesMode(config),
|
|
883
|
+
...config.storybook ? { storybook: config.storybook } : {},
|
|
870
884
|
...config.products && !sameProducts(config.products, DEFAULT_PRODUCTS) ? { products: config.products } : {}
|
|
871
885
|
};
|
|
872
886
|
}
|
|
@@ -1943,11 +1957,17 @@ async function commitToNewLocalBranch(root, args) {
|
|
|
1943
1957
|
throw new Error(`Refusing to write branch "${args.branch}": ${err.message}`);
|
|
1944
1958
|
}
|
|
1945
1959
|
if (await branchExists(root, args.branch)) throw new Error(`Branch "${args.branch}" already exists. Pick another title or delete it first.`);
|
|
1946
|
-
const
|
|
1960
|
+
const { sha, parent } = await commitTree(root, args);
|
|
1961
|
+
await git(root, ["update-ref", `refs/heads/${args.branch}`, sha, ""]);
|
|
1962
|
+
const diff = await git(root, ["diff", parent, sha]);
|
|
1963
|
+
return { sha, diff };
|
|
1964
|
+
}
|
|
1965
|
+
async function commitTree(root, args) {
|
|
1966
|
+
const parent = (await git(root, ["rev-parse", "--verify", `${args.base}^{commit}`])).trim();
|
|
1947
1967
|
const dir = await mkdtemp(join(tmpdir(), "bridge-index-"));
|
|
1948
1968
|
const env = { GIT_INDEX_FILE: join(dir, "index") };
|
|
1949
1969
|
try {
|
|
1950
|
-
await git(root, ["read-tree",
|
|
1970
|
+
await git(root, ["read-tree", parent], { env });
|
|
1951
1971
|
for (const f of args.files) {
|
|
1952
1972
|
if (f.content === null) {
|
|
1953
1973
|
await git(root, ["update-index", "--force-remove", f.path], { env });
|
|
@@ -1958,10 +1978,8 @@ async function commitToNewLocalBranch(root, args) {
|
|
|
1958
1978
|
}
|
|
1959
1979
|
const tree = (await git(root, ["write-tree"], { env })).trim();
|
|
1960
1980
|
const ident = await identityEnv(root);
|
|
1961
|
-
const sha = (await git(root, ["commit-tree", tree, "-p",
|
|
1962
|
-
|
|
1963
|
-
const diff = await git(root, ["diff", baseSha, sha]);
|
|
1964
|
-
return { sha, diff };
|
|
1981
|
+
const sha = (await git(root, ["commit-tree", tree, "-p", parent, "-F", "-"], { input: args.message, env: ident })).trim();
|
|
1982
|
+
return { sha, parent };
|
|
1965
1983
|
} finally {
|
|
1966
1984
|
await rm(dir, { recursive: true, force: true });
|
|
1967
1985
|
}
|
|
@@ -2035,6 +2053,7 @@ export {
|
|
|
2035
2053
|
assertSafeBranch,
|
|
2036
2054
|
DEFAULT_COMPONENT_SPECS_FILE,
|
|
2037
2055
|
coverageSummary,
|
|
2056
|
+
variantKeyOf,
|
|
2038
2057
|
parseComponentSpecs,
|
|
2039
2058
|
figmaCell,
|
|
2040
2059
|
FIGMA_REFERENCES_BRANCH,
|