sanoma 0.7.1 → 0.8.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/serve.d.ts CHANGED
@@ -48,18 +48,20 @@ export type ReadSecrets = (names: string[]) => Promise<Map<string, string>>;
48
48
  export declare function parseDomains(value: string | undefined): Record<string, string> | undefined;
49
49
  /**
50
50
  * The app's host (`SANOMA_APP_HOST`, default 127.0.0.1), the public sites' domains
51
- * (`SANOMA_DOMAINS`, `parseDomains`) and, when the `SANOMA_GITHUB_*` variables are set, GitHub
51
+ * (`SANOMA_DOMAINS`, `parseDomains`) and, with `SANOMA_DEMO=1`, a demo (`AppOptions.demo`), on any
52
+ * host and with no GitHub sign-in; else, when the `SANOMA_GITHUB_*` variables are set, GitHub
52
53
  * sign-in; both or neither, and any host but this machine needs it. An empty value is the same
53
54
  * as unset. On a host beyond this machine, or with one of them set, one the environment leaves
54
55
  * unset is read from the stored secrets (`readSecrets`), where creating the GitHub App on the
55
56
  * app's connect page put them. A mistake in them is a UsageError.
56
57
  */
57
- export declare function appOptions(readSecrets?: ReadSecrets): Promise<Pick<AppOptions, "host" | "login" | "domains">>;
58
+ export declare function appOptions(readSecrets?: ReadSecrets): Promise<Pick<AppOptions, "host" | "login" | "domains" | "demo">>;
58
59
  /**
59
60
  * The sites' build, the worker under a supervisor (`superviseWorker`), the wakeup service when
60
61
  * the config runs it (`wakeup: true`), then the app, serving `/wake` and the service's routes, in
61
62
  * this process. A worker that stopped itself starts again on a wake, or on a write from the app
62
- * (`AppOptions.onWrite`: a run's start, an approval's decision), never on a page read. `stop`
63
+ * (`AppOptions.onWrite`: a run's start, an approval's decision), never on a page read. A demo's
64
+ * (`SANOMA_DEMO=1`) worker and app share the instance's fakes (`fakes: "instance"`). `stop`
63
65
  * stops the app, the service, then the worker.
64
66
  */
65
67
  export declare function serve(config: SanomaConfig, serveOptions: ServeOptions): Promise<Served>;
package/dist/serve.js CHANGED
@@ -20,13 +20,24 @@ const workerOptions = (config) => ({ promote: true, source: sourceOf(config) });
20
20
  * would start it again (no app hears a write or a wake). `serve` supervises its own.
21
21
  */
22
22
  export async function runWorker(config) {
23
+ if (demoAsked())
24
+ throw notAlone("worker");
23
25
  const worker = await startWorker(config, workerOptions(config));
24
26
  return { stop: () => worker.stop() };
25
27
  }
26
28
  /** Starts the app on `port`, with the host and login `appOptions` reads, and the sites built; `url` says where. */
27
29
  export async function runApp(config, options) {
30
+ if (demoAsked())
31
+ throw notAlone("app");
28
32
  return served(config, await appStart(config, options), []);
29
33
  }
34
+ /** `SANOMA_DEMO=1`: the repo runs as a demo (`AppOptions.demo`). */
35
+ const demoAsked = () => process.env.SANOMA_DEMO === "1";
36
+ /**
37
+ * Why `sanoma worker` or `sanoma app` does not run a demo alone: its vendors' fakes live in the
38
+ * process, which the worker and the app must share.
39
+ */
40
+ const notAlone = (command) => new UsageError(`SANOMA_DEMO=1 runs the worker and the app in one process, which holds the demo's fakes: run \`sanoma serve\` (or \`sanoma demo\`), not \`sanoma ${command}\``);
30
41
  /**
31
42
  * The wakeup's `GET /wake`, a machine route with no login: handed to `onWake` and answered 204,
32
43
  * always (a wake is "resume if stopped": one late, twice or for a replaced registration starts a
@@ -84,8 +95,8 @@ async function appSites(root, log, dev) {
84
95
  return { distDir };
85
96
  }
86
97
  // buildApp says the same of each when there is a build to run.
87
- for (const name of refused) {
88
- log(`sites/${name} is not mounted: a site's folder name is a URL segment (lowercase letters, digits and dashes)`);
98
+ for (const dir of refused) {
99
+ log(`${dir} is not mounted: a site's folder name is a URL segment (lowercase letters, digits and dashes)`);
89
100
  }
90
101
  if (!sites.length)
91
102
  return {};
@@ -163,7 +174,8 @@ export function parseDomains(value) {
163
174
  }
164
175
  /**
165
176
  * The app's host (`SANOMA_APP_HOST`, default 127.0.0.1), the public sites' domains
166
- * (`SANOMA_DOMAINS`, `parseDomains`) and, when the `SANOMA_GITHUB_*` variables are set, GitHub
177
+ * (`SANOMA_DOMAINS`, `parseDomains`) and, with `SANOMA_DEMO=1`, a demo (`AppOptions.demo`), on any
178
+ * host and with no GitHub sign-in; else, when the `SANOMA_GITHUB_*` variables are set, GitHub
167
179
  * sign-in; both or neither, and any host but this machine needs it. An empty value is the same
168
180
  * as unset. On a host beyond this machine, or with one of them set, one the environment leaves
169
181
  * unset is read from the stored secrets (`readSecrets`), where creating the GitHub App on the
@@ -174,6 +186,9 @@ export async function appOptions(readSecrets) {
174
186
  const domains = parseDomains(env.SANOMA_DOMAINS);
175
187
  const host = env.SANOMA_APP_HOST || undefined;
176
188
  const options = { host, ...(domains && { domains }) };
189
+ // The demo login signs everyone in as the company's people, on any host: no GitHub sign-in.
190
+ if (demoAsked())
191
+ return { ...options, demo: true };
177
192
  const beyond = host !== undefined && !isLoopback(host);
178
193
  const found = new Map(GITHUB.flatMap((name) => (env[name] ? [[name, env[name]]] : [])));
179
194
  if ((beyond || found.size) && readSecrets && found.size < GITHUB.length) {
@@ -205,7 +220,8 @@ export async function appOptions(readSecrets) {
205
220
  * The sites' build, the worker under a supervisor (`superviseWorker`), the wakeup service when
206
221
  * the config runs it (`wakeup: true`), then the app, serving `/wake` and the service's routes, in
207
222
  * this process. A worker that stopped itself starts again on a wake, or on a write from the app
208
- * (`AppOptions.onWrite`: a run's start, an approval's decision), never on a page read. `stop`
223
+ * (`AppOptions.onWrite`: a run's start, an approval's decision), never on a page read. A demo's
224
+ * (`SANOMA_DEMO=1`) worker and app share the instance's fakes (`fakes: "instance"`). `stop`
209
225
  * stops the app, the service, then the worker.
210
226
  */
211
227
  export async function serve(config, serveOptions) {
@@ -215,7 +231,13 @@ export async function serve(config, serveOptions) {
215
231
  // An app on this machine alone is not the instance the host runs: its worker never stops
216
232
  // itself (its wakeup would wake that instance).
217
233
  const here = isLoopback(options.host ?? "127.0.0.1");
218
- const supervised = await superviseWorker(config, { ...workerOptions(config), selfStop: !here });
234
+ // A demo's worker and app share one resolution: the instance's fakes, which only this process holds.
235
+ const shared = options.demo ? resolveConfig(config, { fakes: "instance" }) : undefined;
236
+ const supervised = await superviseWorker(config, {
237
+ ...workerOptions(config),
238
+ selfStop: !here,
239
+ ...(shared && { resolved: shared }),
240
+ });
219
241
  let wakeup;
220
242
  let app;
221
243
  try {
@@ -224,14 +246,12 @@ export async function serve(config, serveOptions) {
224
246
  const { startWakeupService } = await import("@sanoma-ai/workflows/wakeup-service");
225
247
  wakeup = await startWakeupService({ databaseUrl, log: { info: log, warn: log } });
226
248
  }
227
- app = await served(config, { ...options, onWrite: () => void supervised.resume() }, [
228
- wakeRoute({ log, onWake: () => supervised.wake() }),
229
- ...(wakeup?.routes ?? []),
230
- ]);
249
+ app = await served(config, { ...options, onWrite: () => void supervised.resume(), ...(shared && { resolved: shared }) }, [wakeRoute({ log, onWake: () => supervised.wake() }), ...(wakeup?.routes ?? [])]);
231
250
  }
232
251
  catch (err) {
233
252
  await wakeup?.stop().catch(() => { });
234
253
  await supervised.stop().catch(() => { });
254
+ await shared?.dataStore?.close().catch(() => { });
235
255
  throw err;
236
256
  }
237
257
  return {
@@ -246,7 +266,12 @@ export async function serve(config, serveOptions) {
246
266
  await wakeup?.stop();
247
267
  }
248
268
  finally {
249
- await supervised.stop();
269
+ try {
270
+ await supervised.stop();
271
+ }
272
+ finally {
273
+ await shared?.dataStore?.close();
274
+ }
250
275
  }
251
276
  }
252
277
  },
package/dist/serve.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"serve.js","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAmB,WAAW,EAAqB,QAAQ,EAAE,MAAM,gBAA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AC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACrC,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACxC,MAAM,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACjD,MAAM,GAAG,CAAC;IACZ,CAAC;IACD,OAAO;QACL,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,KAAK,CAAC,IAAI;YACR,IAAI,CAAC;gBACH,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YACnB,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC;oBACH,MAAM,MAAM,EAAE,IAAI,EAAE,CAAC;gBACvB,CAAC;wBAAS,CAAC;oBACT,IAAI,CAAC;wBACH,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC;oBAC1B,CAAC;4BAAS,CAAC;wBACT,MAAM,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;oBACnC,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
package/dist/site-lint.js CHANGED
@@ -10,6 +10,13 @@ const inside = (dir, path) => {
10
10
  const to = relative(dir, path);
11
11
  return to !== ".." && !to.startsWith(`..${sep}`);
12
12
  };
13
+ /** The `sites/` `file` is in, under the repo at `cwd`: the root's, or an app's `apps/<app>/sites/`. */
14
+ function sitesOf(cwd, file) {
15
+ const [top, app, under] = relative(cwd, file).split(sep);
16
+ if (top === "sites")
17
+ return join(cwd, "sites");
18
+ return top === "apps" && app !== undefined && under === "sites" ? join(cwd, "apps", app, "sites") : undefined;
19
+ }
13
20
  export const siteFile = {
14
21
  meta: {
15
22
  type: "problem",
@@ -18,12 +25,12 @@ export const siteFile = {
18
25
  },
19
26
  },
20
27
  create(context) {
21
- // oxlint runs in the repo's root, where the override's `sites/**` matches.
22
- const sites = join(context.cwd, "sites");
23
- /** A relative import, not of types alone, that resolves outside `sites/`. */
28
+ // oxlint runs in the repo's root, where the override's `sites/**` and `apps/*/sites/**` match.
29
+ const sites = sitesOf(context.cwd, context.filename);
30
+ /** A relative import, not of types alone, that resolves outside the file's `sites/`. */
24
31
  const leaves = (node) => {
25
32
  const source = node.source?.value;
26
- if (typeof source !== "string" || !source.startsWith(".") || !inside(sites, context.filename))
33
+ if (typeof source !== "string" || !source.startsWith(".") || sites === undefined)
27
34
  return false;
28
35
  if (node.importKind === "type" || node.exportKind === "type")
29
36
  return false;
@@ -32,7 +39,7 @@ export const siteFile = {
32
39
  const imported = (node) => {
33
40
  if (leaves(node)) {
34
41
  context.report({
35
- message: `A site imports only from inside sites/, \`sanoma/site\`, \`sanoma/ui\` and its packages: ${String(node.source.value)} leaves sites/.`,
42
+ message: `A site imports only from inside sites/, \`sanoma/site\`, \`sanoma/ui\`, \`sanoma/claims\` and its packages: ${String(node.source.value)} leaves sites/.`,
36
43
  node: node.source,
37
44
  });
38
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"site-lint.js","sourceRoot":"","sources":["../src/site-lint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAmB5E,8FAA8F;AAC9F,MAAM,CAAC,MAAM,MAAM,GAAG,yEAAyE,CAAC;AAEhG,kFAAkF;AAClF,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAE3F,kGAAkG;AAClG,MAAM,UAAU,GAAG,CAAC,MAAe,EAAsB,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAErH,4CAA4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CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,QAAQ,CACxF,CAAC;gBACF,IAAI,MAAM,EAAE,CAAC;oBACX,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,8CAA8C,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;gBACpG,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
package/dist/sites.d.ts CHANGED
@@ -3,5 +3,8 @@
3
3
  * as it resolves from here, the launcher's own copy, so the worker and the app share one.
4
4
  */
5
5
  export declare const runtimeFrom: () => string;
6
- /** `@sanoma-ai/app/build` when the repo has a `sites/` directory: a repo without one never loads the app's build. */
7
- export declare const siteBuild: (root: string) => Promise<typeof import("@sanoma-ai/app/build") | undefined>;
6
+ /**
7
+ * `@sanoma-ai/app/build` when the repo has a `sites/` directory, or an app has one
8
+ * (`apps/<app>/sites/`): a repo without one never loads the app's build.
9
+ */
10
+ export declare function siteBuild(root: string): Promise<typeof import("@sanoma-ai/app/build") | undefined>;
package/dist/sites.js CHANGED
@@ -1,11 +1,16 @@
1
1
  import { existsSync, realpathSync } from "node:fs";
2
- import { join } from "node:path";
3
2
  import { fileURLToPath } from "node:url";
4
3
  /**
5
4
  * This package's `package.json`, by real path: a sites build's server bundle imports the runtime
6
5
  * as it resolves from here, the launcher's own copy, so the worker and the app share one.
7
6
  */
8
7
  export const runtimeFrom = () => realpathSync(fileURLToPath(new URL("../package.json", import.meta.url)));
9
- /** `@sanoma-ai/app/build` when the repo has a `sites/` directory: a repo without one never loads the app's build. */
10
- export const siteBuild = async (root) => existsSync(join(root, "sites")) ? await import("@sanoma-ai/app/build") : undefined;
8
+ /**
9
+ * `@sanoma-ai/app/build` when the repo has a `sites/` directory, or an app has one
10
+ * (`apps/<app>/sites/`): a repo without one never loads the app's build.
11
+ */
12
+ export async function siteBuild(root) {
13
+ const { kindDirs } = await import("@sanoma-ai/workflows");
14
+ return kindDirs(root, "sites").some((dir) => existsSync(dir)) ? await import("@sanoma-ai/app/build") : undefined;
15
+ }
11
16
  //# sourceMappingURL=sites.js.map
package/dist/sites.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sites.js","sourceRoot":"","sources":["../src/sites.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAE1G,qHAAqH;AACrH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE,CAC9C,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC"}
1
+ {"version":3,"file":"sites.js","sourceRoot":"","sources":["../src/sites.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAE1G;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAY;IAC1C,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;IAC1D,OAAO,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACnH,CAAC"}
package/dist/source.d.ts CHANGED
@@ -6,6 +6,8 @@ import { type Source } from "@sanoma-ai/workflows";
6
6
  * worktree at `<root>/.sanoma/drafts/<id>` on the branch `draft/<id>`, with the root's
7
7
  * `node_modules` linked into it; `git worktree list` is the one record of which are open. A
8
8
  * draft's `sanoma check` runs on `<databaseUrl>_check` (the launcher's database when it is not given).
9
+ * A draft takes an app (`git merge --allow-unrelated-histories` of its source) and updates one
10
+ * (a merge of its source's default branch); `behind` fetches an app's source into the checkout.
9
11
  */
10
12
  export declare function localGitSource(root: string, { databaseUrl }?: {
11
13
  databaseUrl?: string;
package/dist/source.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import { execFile } from "node:child_process";
2
+ import { randomUUID } from "node:crypto";
2
3
  import { appendFileSync, existsSync, lstatSync, mkdirSync, realpathSync, symlinkSync } from "node:fs";
3
4
  import { readFile } from "node:fs/promises";
4
5
  import { dirname, join, relative, resolve } from "node:path";
5
6
  import { promisify } from "node:util";
6
- import { errorMessage } from "@sanoma-ai/workflows";
7
+ import { draftBranch, draftOf, errorMessage, readApps, } from "@sanoma-ai/workflows";
8
+ import { APP_NAME } from "@sanoma-ai/workflows/shared";
7
9
  const run = promisify(execFile);
8
10
  /** Git in `cwd`: its output, trimmed. */
9
11
  const gitIn = async (cwd, args, env) => (await run("git", args, { cwd, env: { ...process.env, ...env } })).stdout.trim();
@@ -24,7 +26,7 @@ function draftId(id) {
24
26
  return id;
25
27
  }
26
28
  /** The branch of the draft `id`. */
27
- const branchOf = (id) => `draft/${draftId(id)}`;
29
+ const branchOf = (id) => draftBranch(draftId(id));
28
30
  // One git write at a time in this process, whichever source makes it: two tool calls of one turn
29
31
  // may open, or commit to, one draft at once, and the worker and the app each hold a source.
30
32
  let writing = Promise.resolve();
@@ -63,6 +65,131 @@ const commitIn = (cwd) => ({ paths, message, author }) => serial(async () => {
63
65
  });
64
66
  return { revision: await gitIn(cwd, ["rev-parse", "HEAD"]) };
65
67
  });
68
+ // Taking and updating an app: a source repository's history merged into a draft. A source is a
69
+ // public repository: fetched by https alone (`GIT_ALLOW_PROTOCOL`, unless the environment sets its
70
+ // own list), with no credential helper and no prompt, into a ref of its own, so two fetches run
71
+ // at once and outside the one git write.
72
+ /** A ref a source is taken at: a branch, a tag or a commit id, never an option or a refspec. */
73
+ const SOURCE_REF = /^(?!-)(?!.*\.\.)[\w./-]{1,200}$/;
74
+ /** How long a source's fetch may take. */
75
+ const FETCH_TIMEOUT_MS = 2 * 60_000;
76
+ /** The commit `ref` (the default branch when absent) names in the repository at `url`, fetched into the checkout at `cwd`. */
77
+ async function fetchSource(cwd, url, ref) {
78
+ if (ref !== undefined && !SOURCE_REF.test(ref))
79
+ throw new Error(`Not a branch, tag or commit: ${JSON.stringify(ref)}`);
80
+ const into = `refs/sanoma/fetched/${randomUUID()}`;
81
+ const args = ["-c", "credential.helper=", "fetch", "--quiet", "--no-tags", "--no-write-fetch-head"];
82
+ await run("git", [...args, "--", url, `+${ref ?? "HEAD"}:${into}`], {
83
+ cwd,
84
+ env: { ...process.env, GIT_TERMINAL_PROMPT: "0", GIT_ALLOW_PROTOCOL: process.env.GIT_ALLOW_PROTOCOL ?? "https" },
85
+ timeout: FETCH_TIMEOUT_MS,
86
+ }).catch((err) => {
87
+ throw new Error(`git fetch from ${url} failed: ${err.stderr?.trim() || err.message}`);
88
+ });
89
+ try {
90
+ return await gitIn(cwd, ["rev-parse", "--verify", `${into}^{commit}`]);
91
+ }
92
+ finally {
93
+ // Its commit is pinned by its id.
94
+ await gitIn(cwd, ["update-ref", "-d", into]);
95
+ }
96
+ }
97
+ /** The source URL of the app `folder` in the checkout at `cwd`, as its `app.ts` names it; an error when it names none. */
98
+ function sourceOf(cwd, folder) {
99
+ const app = readApps(cwd).find((a) => a.name === folder);
100
+ if (!app)
101
+ throw new Error(`There is no app apps/${folder}/`);
102
+ if (app.source === undefined)
103
+ throw new Error(`apps/${folder}/app.ts names no source: the app is the company's own`);
104
+ return app.source;
105
+ }
106
+ /**
107
+ * How many commits `from` has that `HEAD` lacks, in the checkout at `cwd`, of those that change
108
+ * what a merge of the app `folder` takes: its folder and `package.json`.
109
+ */
110
+ const behindIn = async (cwd, from, folder) => Number(await gitIn(cwd, ["rev-list", "--count", `HEAD..${from}`, "--", `apps/${folder}`, "package.json"]));
111
+ /** Paths git printed with `-z`. */
112
+ const pathsOf = (z) => z.split("\0").filter(Boolean);
113
+ /**
114
+ * Merges the commit `from` into the draft at `cwd` as one commit by `author`, titled `message`,
115
+ * with its history (`take`: the first time the two meet, or another app of a source merged here
116
+ * already). What it merges is the app's folder (a take's, the source's as it is) and `package.json`
117
+ * (its connectors): every other file stays the company's, as does a file one side deleted, since
118
+ * the source's root is the starter's and the rest of it the source's own. A file git could not
119
+ * merge is committed with its markers (ours, the base, theirs) and named in `conflicts`. Refused
120
+ * when the draft has uncommitted changes; a failure once the merge has begun puts the draft back.
121
+ */
122
+ async function mergeIn(cwd, from, { folder, message, author, take }) {
123
+ if (await gitIn(cwd, ["status", "--porcelain"]))
124
+ throw new Error("The draft has uncommitted changes: commit them first");
125
+ const merged = await behindIn(cwd, from, folder);
126
+ if (!merged && !take)
127
+ return { folder, revision: await gitIn(cwd, ["rev-parse", "HEAD"]), merged, conflicts: [] };
128
+ const as = { GIT_AUTHOR_NAME: `${author} via Sanoma` };
129
+ if (merged) {
130
+ const merge = ["-c", "merge.conflictStyle=diff3", "merge", "--quiet", "--no-ff", "--no-commit"];
131
+ const failed = await gitIn(cwd, [...merge, ...(take ? ["--allow-unrelated-histories"] : []), from], as).then(() => undefined, (err) => err);
132
+ if (!(await holds(cwd, ["rev-parse", "--quiet", "--verify", "MERGE_HEAD"]))) {
133
+ throw new Error(`git merge of ${from} failed: ${failed?.stderr?.trim() || failed?.stdout?.trim() || failed?.message}`);
134
+ }
135
+ }
136
+ try {
137
+ // The draft has no such folder: a take's is the source's whole, whatever the history here says.
138
+ if (take)
139
+ await gitIn(cwd, ["checkout", from, "--", `apps/${folder}`]);
140
+ const outside = pathsOf(await gitIn(cwd, [
141
+ "diff",
142
+ "--name-only",
143
+ "-z",
144
+ "HEAD",
145
+ "--",
146
+ ".",
147
+ `:(exclude)apps/${folder}`,
148
+ ":(exclude)package.json",
149
+ ]));
150
+ // Each unmerged file's stages: without ours (2) or theirs (3), one side deleted it.
151
+ const stages = new Map();
152
+ for (const entry of pathsOf(await gitIn(cwd, ["ls-files", "--unmerged", "-z"]))) {
153
+ const tab = entry.indexOf("\t");
154
+ const path = entry.slice(tab + 1);
155
+ stages.set(path, [...(stages.get(path) ?? []), entry.slice(0, tab).split(" ")[2]]);
156
+ }
157
+ const bothSides = (path) => ["2", "3"].every((stage) => stages.get(path).includes(stage));
158
+ const kept = new Set(outside);
159
+ const conflicts = [...stages.keys()].filter((path) => !kept.has(path) && bothSides(path)).toSorted();
160
+ await keepOurs(cwd, [...new Set([...outside, ...[...stages.keys()].filter((path) => !bothSides(path))])]);
161
+ if (conflicts.length)
162
+ await gitIn(cwd, ["add", "--", ...conflicts], { GIT_LITERAL_PATHSPECS: "1" });
163
+ const left = conflicts.length ? `\n\nConflicts left to resolve:\n${conflicts.map((f) => `- ${f}`).join("\n")}` : "";
164
+ await gitIn(cwd, ["commit", "--quiet", "-m", `${message}${left}`], as);
165
+ return { folder, revision: await gitIn(cwd, ["rev-parse", "HEAD"]), merged, conflicts };
166
+ }
167
+ catch (err) {
168
+ // The draft was clean: back to its commit, the merge (if any) with it.
169
+ await gitIn(cwd, ["reset", "--quiet", "--hard", "HEAD"]).catch(() => undefined);
170
+ throw err;
171
+ }
172
+ }
173
+ /** Refuses `from` unless the checkout at `cwd` shares history with it: a take squashed or rebased away leaves no base. */
174
+ async function mustShareHistory(cwd, from, folder, url) {
175
+ if (!(await holds(cwd, ["merge-base", "HEAD", from]))) {
176
+ throw new Error(`apps/${folder}/ shares no history with ${url}: was it taken by a squashed or rebased merge?`);
177
+ }
178
+ }
179
+ /** The files at `paths` in the checkout at `cwd` as `HEAD` has them, merged or not: those it lacks removed. */
180
+ async function keepOurs(cwd, paths) {
181
+ if (!paths.length)
182
+ return;
183
+ // Paths, not patterns: a file's name may hold a `*`.
184
+ const literal = { GIT_LITERAL_PATHSPECS: "1" };
185
+ const listed = await gitIn(cwd, ["ls-tree", "-r", "--name-only", "-z", "HEAD", "--", ...paths], literal);
186
+ const ours = new Set(pathsOf(listed));
187
+ const gone = paths.filter((path) => !ours.has(path));
188
+ if (ours.size)
189
+ await gitIn(cwd, ["checkout", "HEAD", "--", ...ours], literal);
190
+ if (gone.length)
191
+ await gitIn(cwd, ["rm", "--quiet", "--force", "--", ...gone], literal);
192
+ }
66
193
  /**
67
194
  * The local git checkout at `root` as a `Source`: commits on the current branch, as the
68
195
  * machine's git identity with the author named `<author> via Sanoma`, pushes a branch to a
@@ -70,10 +197,13 @@ const commitIn = (cwd) => ({ paths, message, author }) => serial(async () => {
70
197
  * worktree at `<root>/.sanoma/drafts/<id>` on the branch `draft/<id>`, with the root's
71
198
  * `node_modules` linked into it; `git worktree list` is the one record of which are open. A
72
199
  * draft's `sanoma check` runs on `<databaseUrl>_check` (the launcher's database when it is not given).
200
+ * A draft takes an app (`git merge --allow-unrelated-histories` of its source) and updates one
201
+ * (a merge of its source's default branch); `behind` fetches an app's source into the checkout.
73
202
  */
74
203
  export function localGitSource(root, { databaseUrl } = {}) {
75
204
  const git = (args, env) => gitIn(root, args, env);
76
- const head = (ref = "HEAD") => git(["rev-parse", "--verify", `${ref}^{commit}`]);
205
+ /** The commit `ref` names, in the checkout at `cwd` (the root's by default). */
206
+ const head = (ref = "HEAD", cwd = root) => gitIn(cwd, ["rev-parse", "--verify", `${ref}^{commit}`]);
77
207
  /** Where the draft `id`'s checkout is. */
78
208
  const draftAt = (id) => join(root, ".sanoma", "drafts", draftId(id));
79
209
  /** Whether the local branch `branch` exists. */
@@ -85,16 +215,15 @@ export function localGitSource(root, { databaseUrl } = {}) {
85
215
  return new Map(entries.flatMap((entry) => {
86
216
  const fields = entry.split("\0");
87
217
  const path = fields.find((f) => f.startsWith("worktree "))?.slice("worktree ".length);
88
- const id = fields
89
- .find((f) => f.startsWith("branch refs/heads/draft/"))
90
- ?.slice("branch refs/heads/draft/".length);
218
+ const branch = fields.find((f) => f.startsWith("branch refs/heads/"))?.slice("branch refs/heads/".length);
219
+ const id = branch === undefined ? undefined : draftOf(branch);
91
220
  return id && path === join(at, id) ? [[id, !fields.some((f) => f.startsWith("prunable"))]] : [];
92
221
  }));
93
222
  };
94
223
  return {
95
224
  root,
96
225
  commit: commitIn(root),
97
- head,
226
+ head: (ref) => head(ref),
98
227
  async push({ url, token, ref }) {
99
228
  await git(["push", "--quiet", "--", url, `refs/heads/${ref}:refs/heads/${ref}`], signedIn(token)).catch(withoutToken(`git push to ${url}`, token));
100
229
  },
@@ -104,21 +233,28 @@ export function localGitSource(root, { databaseUrl } = {}) {
104
233
  return undefined;
105
234
  throw err;
106
235
  }),
107
- follow: ({ url, token, ref }) => serial(async () => {
108
- const on = await git(["branch", "--show-current"]);
109
- if (on !== ref)
110
- return { skipped: on ? `${on} is checked out, not ${ref}` : `no branch is checked out, not ${ref}` };
111
- if (await git(["status", "--porcelain"]))
112
- return { skipped: "the checkout has uncommitted changes" };
113
- await git(["fetch", "--quiet", "--no-tags", "--", url, `refs/heads/${ref}`], signedIn(token)).catch(withoutToken(`git fetch from ${url}`, token));
114
- // The commit fetched, pinned: anything else may rewrite FETCH_HEAD before the merge.
115
- const fetched = await head("FETCH_HEAD");
116
- if (!(await holds(root, ["merge-base", "--is-ancestor", "HEAD", fetched]))) {
117
- return { skipped: `${ref} has commits ${url} does not` };
118
- }
119
- await git(["merge", "--quiet", "--ff-only", fetched]);
120
- return { revision: fetched };
121
- }),
236
+ follow: async ({ url, token, ref }) => {
237
+ // A draft's branch is checked out in the draft's own checkout, and moves under no check running in it.
238
+ const id = draftOf(ref);
239
+ const cwd = id !== undefined && DRAFT_ID.test(id) && (await listed()).get(id) ? draftAt(id) : root;
240
+ await checkingAt.get(cwd);
241
+ return serial(async () => {
242
+ const gitHere = (args, env) => gitIn(cwd, args, env);
243
+ const on = await gitHere(["branch", "--show-current"]);
244
+ if (on !== ref)
245
+ return { skipped: on ? `${on} is checked out, not ${ref}` : `no branch is checked out, not ${ref}` };
246
+ if (await gitHere(["status", "--porcelain"]))
247
+ return { skipped: "the checkout has uncommitted changes" };
248
+ await gitHere(["fetch", "--quiet", "--no-tags", "--", url, `refs/heads/${ref}`], signedIn(token)).catch(withoutToken(`git fetch from ${url}`, token));
249
+ // The commit fetched, pinned: anything else may rewrite FETCH_HEAD before the merge.
250
+ const fetched = await head("FETCH_HEAD", cwd);
251
+ if (!(await holds(cwd, ["merge-base", "--is-ancestor", "HEAD", fetched]))) {
252
+ return { skipped: `${ref} has commits ${url} does not` };
253
+ }
254
+ await gitHere(["merge", "--quiet", "--ff-only", fetched]);
255
+ return { revision: fetched };
256
+ });
257
+ },
122
258
  async draft(id) {
123
259
  const [branch, at] = [branchOf(id), draftAt(id)];
124
260
  await serial(async () => {
@@ -145,7 +281,37 @@ export function localGitSource(root, { databaseUrl } = {}) {
145
281
  }
146
282
  }
147
283
  });
148
- return { branch, root: at, commit: commitIn(at) };
284
+ return {
285
+ branch,
286
+ root: at,
287
+ commit: commitIn(at),
288
+ take: async ({ url, ref, folder, author }) => {
289
+ const from = await fetchSource(at, url, ref);
290
+ return serial(async () => {
291
+ const apps = pathsOf(await gitIn(at, ["ls-tree", "-d", "--name-only", "-z", from, "--", "apps/"]))
292
+ .map((path) => path.slice("apps/".length))
293
+ .filter((name) => APP_NAME.test(name));
294
+ const name = folder ?? (apps.length === 1 ? apps[0] : undefined);
295
+ if (name === undefined || !apps.includes(name)) {
296
+ const held = apps.map((a) => `apps/${a}/`).join(", ");
297
+ if (!held)
298
+ throw new Error(`${url} holds no app: a source holds one apps/<name>/`);
299
+ throw new Error(`${url} ${folder ? `has no apps/${folder}/` : "holds more than one app"}: it holds ${held}`);
300
+ }
301
+ if (existsSync(join(at, "apps", name)))
302
+ throw new Error(`apps/${name}/ is here already: update it instead`);
303
+ return mergeIn(at, from, { folder: name, message: `Take ${name} from ${url}`, author, take: true });
304
+ });
305
+ },
306
+ update: async ({ folder, author }) => {
307
+ const url = sourceOf(at, folder);
308
+ const from = await fetchSource(at, url);
309
+ return serial(async () => {
310
+ await mustShareHistory(at, from, folder, url);
311
+ return mergeIn(at, from, { folder, message: `Update ${folder} from ${url}`, author });
312
+ });
313
+ },
314
+ };
149
315
  },
150
316
  closeDraft: async (id) => {
151
317
  const [branch, at] = [branchOf(id), draftAt(id)];
@@ -160,6 +326,12 @@ export function localGitSource(root, { databaseUrl } = {}) {
160
326
  });
161
327
  },
162
328
  check: async (id) => checks(draftAt(id), databaseUrl, async () => (await listed()).get(id) === true),
329
+ async behind(folder) {
330
+ const url = sourceOf(root, folder);
331
+ const from = await fetchSource(root, url);
332
+ await mustShareHistory(root, from, folder, url);
333
+ return behindIn(root, from, folder);
334
+ },
163
335
  drafts: async () => [...(await listed())].flatMap(([id, here]) => (here ? [id] : [])).toSorted(),
164
336
  async diff(id) {
165
337
  // Three dots: from where the branch left the checked-out one, so what was merged since is not shown.
@@ -169,7 +341,7 @@ export function localGitSource(root, { databaseUrl } = {}) {
169
341
  git(["diff", "--no-renames", "--name-only", "-z", range, "--"]),
170
342
  git(["diff", "--no-renames", "--no-color", "--stat", range, "--"]),
171
343
  ]);
172
- return { files: names.split("\0").filter(Boolean), summary };
344
+ return { files: pathsOf(names), summary };
173
345
  },
174
346
  };
175
347
  }