Skip to content
Myr

plan.ts

This file

Path

scripts/lib/import/plan.ts

383 lines · 7.4 KiB · TypeScript

Last changed by

Merge build/comments-ops into mainoscabrielbefore adoptione4c407e

History of this file

Take it

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 1why, one step back
1import { ProjectKey, ProjectName, sourceNamespaceOf } from "@repo/protocol/ids";

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

lines 2–4why, one step back
2import { Option, Redacted } from "effect";
34export interface ImportExample {

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

lines 5–6why, one step back
5 readonly name: ProjectName;
6 readonly key: ProjectKey;

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

lines 7–9why, one step back
7 readonly url: string;
8 readonly branch: string;9 readonly kind: string;

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

line 10why, one step back
10 readonly licence: string;

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

lines 11–13why, one step back
11}
1213const example = (

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 14why, one step back
14 key: string,

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

lines 15–16why, one step back
15 url: string,
16 branch: string,

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

lines 17–20why, one step back
17 kind: string,
18 licence: string19): ImportExample => ({20 branch,

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 21why, one step back
21 key: ProjectKey.make(key),

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

lines 22–23why, one step back
22 kind,
23 licence,

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 24why, one step back
24 name: ProjectName.make(`${Option.getOrThrow(sourceNamespaceOf(url))}/${key}`),

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

lines 25–26why, one step back
25 url,
26});

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

line 27why, one step back
27

Merge build/comments-ops into mainoscabrielbefore adoptione4c407e

line 28why, one step back
28// anyhow first: it probes a `master` default and tags.

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

lines 29–33why, one step back
29export const examples: readonly ImportExample[] = [
30 example(31 "anyhow",32 "https://github.com/dtolnay/anyhow",33 "master",

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

lines 34–35why, one step back
34 "Rust crate",
35 "MIT OR Apache-2.0"

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

lines 36–40why, one step back
36 ),
37 example(38 "ky",39 "https://github.com/sindresorhus/ky",40 "main",

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

lines 41–42why, one step back
41 "TypeScript library",
42 "MIT"

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

lines 43–44why, one step back
43 ),
44 example(

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

lines 45–51why, one step back
45 "gum",
46 "https://github.com/charmbracelet/gum",47 "main",48 "Go CLI",49 "MIT"50 ),51 example(

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

lines 52–54why, one step back
52 "click",
53 "https://github.com/pallets/click",54 "main",

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

lines 55–56why, one step back
55 "Python package",
56 "BSD-3-Clause"

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

lines 57–61why, one step back
57 ),
58 example(59 "awesome",60 "https://github.com/sindresorhus/awesome",61 "main",

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

lines 62–63why, one step back
62 "Markdown list",
63 "CC0-1.0"

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

lines 64–68why, one step back
64 ),
65 example(66 "changesets",67 "https://github.com/changesets/changesets",68 "main",

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

lines 69–70why, one step back
69 "TypeScript monorepo",
70 "MIT"

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

lines 71–75why, one step back
71 ),
72 example(73 "stb",74 "https://github.com/nothings/stb",75 "master",

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

lines 76–77why, one step back
76 "C single-file headers",
77 "MIT OR Unlicense"

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

lines 78–82why, one step back
78 ),
79 example(80 "fuzzel",81 "https://codeberg.org/dnkl/fuzzel",82 "master",

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

lines 83–84why, one step back
83 "C on Codeberg",
84 "MIT"

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

line 85why, one step back
85 ),

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

lines 86–295why, one step back
86 example(
87 "hono",88 "https://github.com/honojs/hono",89 "main",90 "TypeScript web framework",91 "MIT"92 ),93 example(94 "express",95 "https://github.com/expressjs/express",96 "master",97 "JavaScript web framework",98 "MIT"99 ),100 example(101 "fastify",102 "https://github.com/fastify/fastify",103 "main",104 "JavaScript web framework",105 "MIT"106 ),107 example(108 "zustand",109 "https://github.com/pmndrs/zustand",110 "main",111 "TypeScript state library",112 "MIT"113 ),114 example(115 "immer",116 "https://github.com/immerjs/immer",117 "main",118 "JavaScript immutable state",119 "MIT"120 ),121 example(122 "nanoid",123 "https://github.com/ai/nanoid",124 "main",125 "JavaScript ID generator",126 "MIT"127 ),128 example(129 "commander",130 "https://github.com/tj/commander.js",131 "master",132 "JavaScript CLI parser",133 "MIT"134 ),135 example(136 "execa",137 "https://github.com/sindresorhus/execa",138 "main",139 "JavaScript process runner",140 "MIT"141 ),142 example(143 "chalk",144 "https://github.com/chalk/chalk",145 "main",146 "JavaScript terminal colours",147 "MIT"148 ),149 example(150 "mitt",151 "https://github.com/developit/mitt",152 "main",153 "TypeScript event emitter",154 "MIT"155 ),156 example(157 "clsx",158 "https://github.com/lukeed/clsx",159 "master",160 "JavaScript class names",161 "MIT"162 ),163 example(164 "ripgrep",165 "https://github.com/BurntSushi/ripgrep",166 "master",167 "Rust CLI",168 "Unlicense OR MIT"169 ),170 example(171 "serde",172 "https://github.com/serde-rs/serde",173 "master",174 "Rust serialization",175 "MIT OR Apache-2.0"176 ),177 example(178 "axum",179 "https://github.com/tokio-rs/axum",180 "main",181 "Rust web framework",182 "MIT"183 ),184 example(185 "fd",186 "https://github.com/sharkdp/fd",187 "master",188 "Rust CLI",189 "MIT OR Apache-2.0"190 ),191 example(192 "hyperfine",193 "https://github.com/sharkdp/hyperfine",194 "master",195 "Rust benchmarking CLI",196 "MIT OR Apache-2.0"197 ),198 example(199 "bubbletea",200 "https://github.com/charmbracelet/bubbletea",201 "main",202 "Go TUI framework",203 "MIT"204 ),205 example(206 "fzf",207 "https://github.com/junegunn/fzf",208 "master",209 "Go fuzzy finder",210 "MIT"211 ),212 example(213 "cobra",214 "https://github.com/spf13/cobra",215 "main",216 "Go CLI library",217 "Apache-2.0"218 ),219 example(220 "gin",221 "https://github.com/gin-gonic/gin",222 "master",223 "Go web framework",224 "MIT"225 ),226 example(227 "requests",228 "https://github.com/psf/requests",229 "main",230 "Python HTTP library",231 "Apache-2.0"232 ),233 example(234 "flask",235 "https://github.com/pallets/flask",236 "main",237 "Python web framework",238 "BSD-3-Clause"239 ),240 example(241 "httpx",242 "https://github.com/encode/httpx",243 "master",244 "Python HTTP client",245 "BSD-3-Clause"246 ),247 example(248 "typer",249 "https://github.com/fastapi/typer",250 "master",251 "Python CLI library",252 "MIT"253 ),254 example(255 "jinja",256 "https://github.com/pallets/jinja",257 "main",258 "Python templates",259 "BSD-3-Clause"260 ),261 example(262 "lua",263 "https://github.com/lua/lua",264 "master",265 "C language interpreter",266 "MIT"267 ),268 example(269 "jq",270 "https://github.com/jqlang/jq",271 "master",272 "C JSON processor",273 "MIT"274 ),275 example(276 "kilo",277 "https://github.com/antirez/kilo",278 "master",279 "C text editor",280 "BSD-2-Clause"281 ),282 example(283 "sinatra",284 "https://github.com/sinatra/sinatra",285 "main",286 "Ruby web framework",287 "MIT"288 ),289 example(290 "nvm",291 "https://github.com/nvm-sh/nvm",292 "master",293 "Shell version manager",294 "MIT"295 ),

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

lines 296–297why, one step back
296];
297

Merge build/comments-ops into mainoscabrielbefore adoptione4c407e

line 298why, one step back
298// A name the platform lists is never imported again, whatever repo it came from.

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

lines 299–304why, one step back
299export const planImports = (
300 all: readonly ImportExample[],301 listed: ReadonlySet<ProjectName>,302 only: Option.Option<ProjectName>303): readonly ImportExample[] =>304 all.filter(

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 305why, one step back
305 ({ name }) =>

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

lines 306–307why, one step back
306 Option.match(only, {
307 onNone: () => true,

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

lines 308–309why, one step back
308 onSome: (named) => named === name,
309 }) && !listed.has(name)

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

line 310why, one step back
310 );

Merge build/1314-import-list into mainoscabrielbefore adoption33c4cac

lines 311–326why, one step back
311
312export const warmPaths = (313 project: ProjectName,314 readme: Option.Option<string>315): readonly string[] => [316 `/${project}`,317 `/${project}/tree/main`,318 `/${project}/commits/main`,319 ...Option.match(readme, {320 onNone: () => [],321 onSome: (path) => [322 `/${project}/blob/main/${path}`,323 `/${project}/why/main/${path}`,324 ],325 }),326];

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

line 327why, one step back
327

Merge build/comments-ops into mainoscabrielbefore adoptione4c407e

line 328why, one step back
328// Kept apart from the token so the URL can be shown.

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

lines 329–333why, one step back
329export interface RedactedUrl {
330 readonly url: string;331 readonly token: Redacted.Redacted;332}333

Merge build/comments-ops into mainoscabrielbefore adoptione4c407e

line 334why, one step back
334// Its argv may be printed; its env values never are.

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

lines 335–343why, one step back
335export interface Command {
336 readonly argv: readonly string[];337 readonly env?: Readonly<Record<string, Redacted.Redacted>>;338}339340export const shownCommand = ({ argv }: Command) => argv.join(" ");341342const TAGS = "refs/tags/*:refs/tags/*";343

Merge build/comments-ops into mainoscabrielbefore adoptione4c407e

lines 344–346why, one step back
344// The write token reaches git as an `Authorization` header through `GIT_CONFIG_*`,
345// so it is in no argument, URL or printed line. Only the tags are fetched: a346// `clone --mirror` would bring every `refs/pull/*` GitHub keeps.

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

lines 347–383why, one step back
347export const tagBackfillCommands = (input: {
348 readonly source: string;349 readonly mirror: string;350 readonly remote: RedactedUrl;351}): readonly Command[] => [352 { argv: ["git", "init", "--bare", "--quiet", input.mirror] },353 {354 argv: [355 "git",356 "--git-dir",357 input.mirror,358 "fetch",359 "--quiet",360 "--no-tags",361 input.source,362 TAGS,363 ],364 },365 {366 argv: [367 "git",368 "--git-dir",369 input.mirror,370 "push",371 "--quiet",372 input.remote.url,373 TAGS,374 ],375 env: {376 GIT_CONFIG_COUNT: Redacted.make("1"),377 GIT_CONFIG_KEY_0: Redacted.make("http.extraHeader"),378 GIT_CONFIG_VALUE_0: Redacted.make(379 `Authorization: Bearer ${Redacted.value(input.remote.token)}`380 ),381 },382 },383];