@bakers-build/core 0.6.1-next.3 → 0.6.1-next.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.
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `host/path`, with scheme, userinfo, port, a trailing `.git` and trailing
3
+ * slashes dropped, lowercased. `undefined` when the input carries no host+path.
4
+ *
5
+ * | raw | normalised |
6
+ * |-----------------------------------------|---------------------|
7
+ * | `git@host:bakers-build/bakers-build.git` | `host/bakers-build/bakers-build` |
8
+ * | `ssh://git@host/bakers-build/bakers-build.git` | `host/bakers-build/bakers-build` |
9
+ * | `ssh://git@host:2222/bakers-build/bakers-build.git` | `host/bakers-build/bakers-build` |
10
+ * | `https://host/bakers-build/bakers-build.git` | `host/bakers-build/bakers-build` |
11
+ */
12
+ export declare function normalizeRepoUrl(raw: unknown): string | undefined;
@@ -0,0 +1,56 @@
1
+ // A git remote URL reduced to a comparable `host/path` identity, so the cwd's
2
+ // `origin` can be matched against `bb_project.repository.url`. `ui/src/route.ts`
3
+ // and `addons/bakers-ui/src/lib/repo-url.ts` keep their own mirrors.
4
+ /**
5
+ * `host/path`, with scheme, userinfo, port, a trailing `.git` and trailing
6
+ * slashes dropped, lowercased. `undefined` when the input carries no host+path.
7
+ *
8
+ * | raw | normalised |
9
+ * |-----------------------------------------|---------------------|
10
+ * | `git@host:bakers-build/bakers-build.git` | `host/bakers-build/bakers-build` |
11
+ * | `ssh://git@host/bakers-build/bakers-build.git` | `host/bakers-build/bakers-build` |
12
+ * | `ssh://git@host:2222/bakers-build/bakers-build.git` | `host/bakers-build/bakers-build` |
13
+ * | `https://host/bakers-build/bakers-build.git` | `host/bakers-build/bakers-build` |
14
+ */
15
+ export function normalizeRepoUrl(raw) {
16
+ if (typeof raw !== 'string')
17
+ return undefined;
18
+ const trimmed = raw.trim();
19
+ if (trimmed === '')
20
+ return undefined;
21
+ let host;
22
+ let path;
23
+ // `scheme://[user@]host[:port]/path` — checked FIRST, so an `ssh://…:2222/…`
24
+ // port is never mistaken for the scp form's `host:path` colon.
25
+ const withScheme = /^[A-Za-z][A-Za-z0-9+.-]*:\/\/(.+)$/.exec(trimmed);
26
+ if (withScheme?.[1] !== undefined) {
27
+ const rest = withScheme[1];
28
+ const slash = rest.indexOf('/');
29
+ if (slash < 0)
30
+ return undefined;
31
+ host = rest.slice(0, slash);
32
+ path = rest.slice(slash + 1);
33
+ }
34
+ else {
35
+ // The scp-like form `[user@]host:path` — what `git remote get-url` emits for
36
+ // an ssh clone. A bare local path has no colon and falls out here.
37
+ const scp = /^(?:[^/@]+@)?([^/:]+):(.+)$/.exec(trimmed);
38
+ if (scp?.[1] === undefined || scp[2] === undefined)
39
+ return undefined;
40
+ host = scp[1];
41
+ path = scp[2];
42
+ }
43
+ host = host
44
+ .replace(/^[^@]*@/, '')
45
+ .replace(/:\d+$/, '')
46
+ .toLowerCase();
47
+ path = path
48
+ .replace(/^\/+/, '')
49
+ .replace(/\/+$/, '')
50
+ .replace(/\.git$/i, '')
51
+ .replace(/\/+$/, '')
52
+ .toLowerCase();
53
+ if (host === '' || path === '')
54
+ return undefined;
55
+ return `${host}/${path}`;
56
+ }
@@ -20,6 +20,7 @@ export { type GitSandboxPaths, gitSandboxPaths, withoutGitDirs, } from './core/g
20
20
  export { type ConductorLiveness, type ConductorLivenessInput, deriveConductorLiveness, toUnixSeconds, } from './core/liveness.js';
21
21
  export { type ConductorLogger, createLogger } from './core/logger.js';
22
22
  export { defaultProcProbe, defaultRunProcessProbe, killRunProcesses, type ProcProbe, type RunProcessProbe, type SignalFailureReason, type SignalOutcome, type SignalVerifiedInput, signalVerifiedProcess, type VerifyOutcome, type VerifyProcessInput, verifyConductorProcess, } from './core/proc.js';
23
+ export { normalizeRepoUrl } from './core/repo-url.js';
23
24
  export { shellQuote } from './core/shell.js';
24
25
  export { DEFAULT_SLUG_MAX_LENGTH, slugify } from './core/slug.js';
25
26
  export { AddonUnresolvedError, discoverAddons, loadAddonPreset, type ResolvedConductorSlots, resolveConductorSlots, } from './plugins/discover-addons.js';
package/dist/src/index.js CHANGED
@@ -22,6 +22,7 @@ export { gitSandboxPaths, withoutGitDirs, } from './core/git-sandbox.js';
22
22
  export { deriveConductorLiveness, toUnixSeconds, } from './core/liveness.js';
23
23
  export { createLogger } from './core/logger.js';
24
24
  export { defaultProcProbe, defaultRunProcessProbe, killRunProcesses, signalVerifiedProcess, verifyConductorProcess, } from './core/proc.js';
25
+ export { normalizeRepoUrl } from './core/repo-url.js';
25
26
  export { shellQuote } from './core/shell.js';
26
27
  export { DEFAULT_SLUG_MAX_LENGTH, slugify } from './core/slug.js';
27
28
  // BB-215: the Storybook-style preset contract + the shared addon discovery.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/core",
3
- "version": "0.6.1-next.3",
3
+ "version": "0.6.1-next.5",
4
4
  "description": "bakers.build surface-agnostic kernel: host contract, split-config helpers, addon preset/discovery machinery, shared primitives.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  "yaml": "^2.7.0"
39
39
  },
40
40
  "bakersBuild": {
41
- "commit": "1531a0bb0d34ccf6b54a051fcb8b016902c31f0f",
41
+ "commit": "314f28982940df736bea55293a81435d37864b31",
42
42
  "channel": "next"
43
43
  }
44
44
  }