Skip to content
Myr

import-examples.ts

This file

Path

scripts/import-examples.ts

76 lines · 3.3 KiB · TypeScript

Last changed by

Merge build/imports-onto-demo into mainoscabrielbefore adoption873046e

History of this file

Take it

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 1–2why, one step back
1/**
2 * `bun run import-examples`: imports the open-source repos the code browser

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

line 3why, one step back
3 * is previewed on (the eight that test its shapes, anyhow first, then

Merge build/imports-onto-demo into mainoscabrielbefore adoption873046e

lines 4–7why, one step back
4 * thirty well-known projects), one at a time, as the operator, onto a
5 * stage or the Node world (`demo` included, since 2026-10-11, on the6 * user's approval: the recording shows them beside the fictional two, each7 * with its source). Each new import is warmed: its

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

lines 8–9why, one step back
8 * pages read once through the stage's web, so its first reader finds why
9 * and its history kept; `--warm` warms the ones listed already too.

Merge branch 'build/913-import-any-branch-and-examples'oscabrielbefore adoptiona4543f6

lines 10–12why, one step back
10 *
11 * bun scripts/import-examples.ts --world node [--only anyhow]12 * bunx varlock run --path apps/platform/ -- \

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

lines 13–14why, one step back
13 * bun scripts/import-examples.ts --stage dev-<user> --warm
14 * bunx varlock run --path apps/platform/ -- \

Merge branch 'build/913-import-any-branch-and-examples'oscabrielbefore adoptiona4543f6

lines 15–27why, one step back
15 * bun scripts/import-examples.ts --stage dev-<user> [--only <p>] [--dry-run]
16 * bunx varlock run --path apps/platform/ -- bunx varlock run --path infra/ -- \17 * bun scripts/import-examples.ts --stage dev-<user> --tags18 *19 * A project the platform lists already is skipped. After each import it20 * prints the repo's branch and tag counts (`git ls-remote`, anonymously).21 * Each new import on a stage is recorded in `infra/created.jsonl` with22 * `by: "import"` (its project and its repo): kept, never torn down.23 *24 * `--tags` backfills `refs/tags/*` for an import whose repo serves none:25 * the source's tags fetched into a temporary bare repo, then pushed to the26 * canonical repo with a write token minted over Artifacts' REST API for at27 * most ten minutes and revoked after, even on failure. It is the one write

Merge build/imported-from into mainoscabrielbefore adoptionf224a14

lines 28–34why, one step back
28 * that skips the gateway: tags only, by the operator, never `main`.
29 *30 * `--sources` keeps the source of each earlier import on its record: the31 * same `initProject` asked again by the operator, which the platform32 * answers as the import did and takes as the source to keep (ADR 0031).33 * A project the ledger records as this stage's import is never imported34 * again, even when the platform does not list it. The core is `lib/import/`.

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

line 35why, one step back
35 */

Merge branch 'build/913-import-any-branch-and-examples'oscabrielbefore adoptiona4543f6

line 36why, one step back
36import { BunRuntime, BunServices } from "@effect/platform-bun";

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

line 37why, one step back
37import { Effect, Layer, Option, Stdio } from "effect";

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

line 38why, one step back
38

Merge branch 'build/913-import-any-branch-and-examples'oscabrielbefore adoptiona4543f6

lines 39–61why, one step back
39import { worldTarget, restBackfill, stageTarget } from "./lib/import/live.ts";
40import {41 ImportWhere,42 importExamples,43 ImportExamplesFailed,44 TagBackfill,45} from "./lib/import/run.ts";46import type { ImportOptions } from "./lib/import/run.ts";4748/** No backfill: the run was not asked for `--tags`, so nothing calls it. */49const noBackfill = Layer.succeed(50 TagBackfill,51 TagBackfill.of({52 backfill: () =>53 Effect.fail(new ImportExamplesFailed({ reason: "--tags was not given" })),54 })55);5657/** The real target and backfill for what the flags ask. */58const layersOf = (options: ImportOptions) =>59 ImportWhere.match(options.where, {60 Stage: ({ stage, url }) =>61 Layer.mergeAll(

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

line 62why, one step back
62 stageTarget(stage, url, Option.getOrUndefined(options.web)),

Merge branch 'build/913-import-any-branch-and-examples'oscabrielbefore adoptiona4543f6

lines 63–67why, one step back
63 options.tags ? restBackfill(stage) : noBackfill
64 ),65 World: () => Layer.mergeAll(worldTarget, noBackfill),66 });67

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 68–69why, one step back
68if (import.meta.main) {
69 BunRuntime.runMain(

Merge branch 'build/913-import-any-branch-and-examples'oscabrielbefore adoptiona4543f6

lines 70–74why, one step back
70 Effect.gen(function* () {
71 const args = yield* (yield* Stdio.Stdio).args;7273 return yield* importExamples(args, layersOf);74 }).pipe(Effect.scoped, Effect.provide(BunServices.layer))

Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d

lines 75–76why, one step back
75 );
76}