@intentius/sql-yodeler 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +110 -2
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +14 -0
- package/dist/bin.js.map +1 -0
- package/dist/chant/apply.d.ts +51 -0
- package/dist/chant/apply.js +104 -0
- package/dist/chant/apply.js.map +1 -0
- package/dist/chant/build.d.ts +34 -0
- package/dist/chant/build.js +48 -0
- package/dist/chant/build.js.map +1 -0
- package/dist/chant/drift.d.ts +44 -0
- package/dist/chant/drift.js +91 -0
- package/dist/chant/drift.js.map +1 -0
- package/dist/chant/plan.d.ts +45 -0
- package/dist/chant/plan.js +61 -0
- package/dist/chant/plan.js.map +1 -0
- package/dist/chant/process.d.ts +41 -0
- package/dist/chant/process.js +87 -0
- package/dist/chant/process.js.map +1 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +59 -0
- package/dist/cli.js.map +1 -0
- package/dist/command.d.ts +17 -0
- package/dist/command.js +13 -0
- package/dist/command.js.map +1 -0
- package/dist/commands/apply.d.ts +3 -0
- package/dist/commands/apply.js +306 -0
- package/dist/commands/apply.js.map +1 -0
- package/dist/commands/drift.d.ts +3 -0
- package/dist/commands/drift.js +38 -0
- package/dist/commands/drift.js.map +1 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.js +22 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.js +135 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/lint.d.ts +3 -0
- package/dist/commands/lint.js +193 -0
- package/dist/commands/lint.js.map +1 -0
- package/dist/commands/new.d.ts +3 -0
- package/dist/commands/new.js +168 -0
- package/dist/commands/new.js.map +1 -0
- package/dist/commands/plan.d.ts +3 -0
- package/dist/commands/plan.js +171 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/rebase.d.ts +3 -0
- package/dist/commands/rebase.js +167 -0
- package/dist/commands/rebase.js.map +1 -0
- package/dist/commands/repair.d.ts +3 -0
- package/dist/commands/repair.js +117 -0
- package/dist/commands/repair.js.map +1 -0
- package/dist/commands/status.d.ts +7 -0
- package/dist/commands/status.js +54 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/config/define.d.ts +50 -0
- package/dist/config/define.js +20 -0
- package/dist/config/define.js.map +1 -0
- package/dist/config/index.d.ts +11 -0
- package/dist/config/index.js +12 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/load.d.ts +17 -0
- package/dist/config/load.js +102 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/settings.d.ts +40 -0
- package/dist/config/settings.js +88 -0
- package/dist/config/settings.js.map +1 -0
- package/dist/env-args.d.ts +18 -0
- package/dist/env-args.js +62 -0
- package/dist/env-args.js.map +1 -0
- package/dist/history/client.d.ts +17 -0
- package/dist/history/client.js +19 -0
- package/dist/history/client.js.map +1 -0
- package/dist/history/ddl.d.ts +58 -0
- package/dist/history/ddl.js +100 -0
- package/dist/history/ddl.js.map +1 -0
- package/dist/history/index.d.ts +25 -0
- package/dist/history/index.js +26 -0
- package/dist/history/index.js.map +1 -0
- package/dist/history/lock.d.ts +100 -0
- package/dist/history/lock.js +224 -0
- package/dist/history/lock.js.map +1 -0
- package/dist/history/postgres/ddl.d.ts +22 -0
- package/dist/history/postgres/ddl.js +47 -0
- package/dist/history/postgres/ddl.js.map +1 -0
- package/dist/history/postgres/index.d.ts +12 -0
- package/dist/history/postgres/index.js +13 -0
- package/dist/history/postgres/index.js.map +1 -0
- package/dist/history/postgres/lock.d.ts +48 -0
- package/dist/history/postgres/lock.js +95 -0
- package/dist/history/postgres/lock.js.map +1 -0
- package/dist/history/postgres/store.d.ts +39 -0
- package/dist/history/postgres/store.js +68 -0
- package/dist/history/postgres/store.js.map +1 -0
- package/dist/history/rows.d.ts +96 -0
- package/dist/history/rows.js +73 -0
- package/dist/history/rows.js.map +1 -0
- package/dist/history/store.d.ts +72 -0
- package/dist/history/store.js +134 -0
- package/dist/history/store.js.map +1 -0
- package/dist/history/topology.d.ts +41 -0
- package/dist/history/topology.js +54 -0
- package/dist/history/topology.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/init/adopt.d.ts +70 -0
- package/dist/init/adopt.js +138 -0
- package/dist/init/adopt.js.map +1 -0
- package/dist/init/baseline.d.ts +61 -0
- package/dist/init/baseline.js +88 -0
- package/dist/init/baseline.js.map +1 -0
- package/dist/init/files.d.ts +23 -0
- package/dist/init/files.js +77 -0
- package/dist/init/files.js.map +1 -0
- package/dist/init/index.d.ts +16 -0
- package/dist/init/index.js +17 -0
- package/dist/init/index.js.map +1 -0
- package/dist/init/live.d.ts +28 -0
- package/dist/init/live.js +45 -0
- package/dist/init/live.js.map +1 -0
- package/dist/lint/check.d.ts +81 -0
- package/dist/lint/check.js +208 -0
- package/dist/lint/check.js.map +1 -0
- package/dist/lint/config.d.ts +21 -0
- package/dist/lint/config.js +43 -0
- package/dist/lint/config.js.map +1 -0
- package/dist/lint/index.d.ts +31 -0
- package/dist/lint/index.js +43 -0
- package/dist/lint/index.js.map +1 -0
- package/dist/lint/project-rules.d.ts +19 -0
- package/dist/lint/project-rules.js +32 -0
- package/dist/lint/project-rules.js.map +1 -0
- package/dist/lint/report.d.ts +7 -0
- package/dist/lint/report.js +48 -0
- package/dist/lint/report.js.map +1 -0
- package/dist/lint/rules.d.ts +53 -0
- package/dist/lint/rules.js +42 -0
- package/dist/lint/rules.js.map +1 -0
- package/dist/lint/silences.d.ts +49 -0
- package/dist/lint/silences.js +91 -0
- package/dist/lint/silences.js.map +1 -0
- package/dist/lint/statements.d.ts +38 -0
- package/dist/lint/statements.js +120 -0
- package/dist/lint/statements.js.map +1 -0
- package/dist/migrations/checksum.d.ts +56 -0
- package/dist/migrations/checksum.js +72 -0
- package/dist/migrations/checksum.js.map +1 -0
- package/dist/migrations/create.d.ts +73 -0
- package/dist/migrations/create.js +119 -0
- package/dist/migrations/create.js.map +1 -0
- package/dist/migrations/directory.d.ts +119 -0
- package/dist/migrations/directory.js +225 -0
- package/dist/migrations/directory.js.map +1 -0
- package/dist/migrations/document.d.ts +83 -0
- package/dist/migrations/document.js +82 -0
- package/dist/migrations/document.js.map +1 -0
- package/dist/migrations/index.d.ts +20 -0
- package/dist/migrations/index.js +21 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/pr/comment.d.ts +32 -0
- package/dist/pr/comment.js +99 -0
- package/dist/pr/comment.js.map +1 -0
- package/dist/pr/forge.d.ts +50 -0
- package/dist/pr/forge.js +105 -0
- package/dist/pr/forge.js.map +1 -0
- package/dist/pr/model.d.ts +91 -0
- package/dist/pr/model.js +113 -0
- package/dist/pr/model.js.map +1 -0
- package/dist/pr/render.d.ts +27 -0
- package/dist/pr/render.js +246 -0
- package/dist/pr/render.js.map +1 -0
- package/dist/project.d.ts +62 -0
- package/dist/project.js +92 -0
- package/dist/project.js.map +1 -0
- package/dist/rebase/index.d.ts +121 -0
- package/dist/rebase/index.js +390 -0
- package/dist/rebase/index.js.map +1 -0
- package/dist/rebase/repair.d.ts +41 -0
- package/dist/rebase/repair.js +68 -0
- package/dist/rebase/repair.js.map +1 -0
- package/dist/replay/clickhouse.d.ts +33 -0
- package/dist/replay/clickhouse.js +106 -0
- package/dist/replay/clickhouse.js.map +1 -0
- package/dist/replay/index.d.ts +36 -0
- package/dist/replay/index.js +54 -0
- package/dist/replay/index.js.map +1 -0
- package/dist/replay/postgres.d.ts +31 -0
- package/dist/replay/postgres.js +140 -0
- package/dist/replay/postgres.js.map +1 -0
- package/dist/replay/replay.d.ts +114 -0
- package/dist/replay/replay.js +98 -0
- package/dist/replay/replay.js.map +1 -0
- package/dist/replay/report.d.ts +18 -0
- package/dist/replay/report.js +72 -0
- package/dist/replay/report.js.map +1 -0
- package/dist/steps/backfill.d.ts +128 -0
- package/dist/steps/backfill.js +307 -0
- package/dist/steps/backfill.js.map +1 -0
- package/dist/steps/index.d.ts +52 -0
- package/dist/steps/index.js +52 -0
- package/dist/steps/index.js.map +1 -0
- package/dist/steps/kinds.d.ts +101 -0
- package/dist/steps/kinds.js +143 -0
- package/dist/steps/kinds.js.map +1 -0
- package/dist/steps/postgres-migration.d.ts +95 -0
- package/dist/steps/postgres-migration.js +149 -0
- package/dist/steps/postgres-migration.js.map +1 -0
- package/dist/steps/rebuild.d.ts +97 -0
- package/dist/steps/rebuild.js +162 -0
- package/dist/steps/rebuild.js.map +1 -0
- package/dist/steps/run.d.ts +45 -0
- package/dist/steps/run.js +72 -0
- package/dist/steps/run.js.map +1 -0
- package/dist/topology/render.d.ts +17 -0
- package/dist/topology/render.js +17 -0
- package/dist/topology/render.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +11 -0
- package/dist/version.js.map +1 -0
- package/dist/versioned/approval.d.ts +35 -0
- package/dist/versioned/approval.js +53 -0
- package/dist/versioned/approval.js.map +1 -0
- package/dist/versioned/clickhouse.d.ts +24 -0
- package/dist/versioned/clickhouse.js +34 -0
- package/dist/versioned/clickhouse.js.map +1 -0
- package/dist/versioned/digest.d.ts +77 -0
- package/dist/versioned/digest.js +69 -0
- package/dist/versioned/digest.js.map +1 -0
- package/dist/versioned/driver.d.ts +41 -0
- package/dist/versioned/driver.js +13 -0
- package/dist/versioned/driver.js.map +1 -0
- package/dist/versioned/engine.d.ts +152 -0
- package/dist/versioned/engine.js +277 -0
- package/dist/versioned/engine.js.map +1 -0
- package/dist/versioned/explain.d.ts +123 -0
- package/dist/versioned/explain.js +289 -0
- package/dist/versioned/explain.js.map +1 -0
- package/dist/versioned/index.d.ts +37 -0
- package/dist/versioned/index.js +54 -0
- package/dist/versioned/index.js.map +1 -0
- package/dist/versioned/op.d.ts +62 -0
- package/dist/versioned/op.js +153 -0
- package/dist/versioned/op.js.map +1 -0
- package/dist/versioned/postgres/catalog.d.ts +33 -0
- package/dist/versioned/postgres/catalog.js +34 -0
- package/dist/versioned/postgres/catalog.js.map +1 -0
- package/dist/versioned/postgres/driver.d.ts +69 -0
- package/dist/versioned/postgres/driver.js +113 -0
- package/dist/versioned/postgres/driver.js.map +1 -0
- package/dist/versioned/postgres/executor.d.ts +104 -0
- package/dist/versioned/postgres/executor.js +172 -0
- package/dist/versioned/postgres/executor.js.map +1 -0
- package/dist/versioned/postgres/index.d.ts +11 -0
- package/dist/versioned/postgres/index.js +12 -0
- package/dist/versioned/postgres/index.js.map +1 -0
- package/dist/versioned/report.d.ts +22 -0
- package/dist/versioned/report.js +81 -0
- package/dist/versioned/report.js.map +1 -0
- package/dist/versioned/state.d.ts +108 -0
- package/dist/versioned/state.js +153 -0
- package/dist/versioned/state.js.map +1 -0
- package/package.json +51 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/migrations/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAqD,MAAM,mDAAmD,CAAC;AACxJ,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAmE,MAAM,eAAe,CAAC;AACrI,OAAO,EAAE,cAAc,EAAkB,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAuCpD,8BAA8B;AAC9B,MAAM,UAAU,kBAAkB,CAAC,GAAS;IAC1C,MAAM,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,2BAA2B;IAC1D,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAA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C;QAC9F,GAAG,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,MAAM,EAAE,OAAO,CAAC,KAAK;KACtB,CAAC;IACF,MAAM,GAAG,GAAG,kBAAkB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,aAAa,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACjH,MAAM,QAAQ,GAAsB,EAAE,GAAG,QAAQ,EAAE,QAAQ,EAAE,eAAe,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAC/G,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,iBAAiB,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,UAAU,EAAE,CAAC;AACtH,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading and writing a project's `migrations/` directory.
|
|
3
|
+
*
|
|
4
|
+
* Order is the chain of parent ids, as in Alembic and pgroll: the first
|
|
5
|
+
* migration has `parent: null`, every other names the one it follows, and
|
|
6
|
+
* the list runs from the first to the newest. The ids' timestamps never
|
|
7
|
+
* decide the order. A directory is well formed when the parent links make
|
|
8
|
+
* one unbroken chain:
|
|
9
|
+
*
|
|
10
|
+
* - every directory under `migrations/` is named like an id and holds a
|
|
11
|
+
* readable `migration.sql` and `migration.json` whose `id` is that name
|
|
12
|
+
* (plain files directly under `migrations/`, such as a README, are
|
|
13
|
+
* ignored; files inside a migration's directory are its own and count in
|
|
14
|
+
* its checksum);
|
|
15
|
+
* - every parent names a migration in the directory;
|
|
16
|
+
* - no two migrations have the same parent, `null` included. Two branches
|
|
17
|
+
* that each added a migration give one parent two children: a fork. It is
|
|
18
|
+
* reported naming both, never ordered by timestamp or by name;
|
|
19
|
+
* - every migration is reachable from the first (no cycles).
|
|
20
|
+
*
|
|
21
|
+
* {@link scanMigrations} reports every problem and never throws on one, for
|
|
22
|
+
* `yodel lint`. {@link readMigrations} returns the ordered chain or throws a
|
|
23
|
+
* {@link MigrationDirectoryError} listing the problems, for the verbs that
|
|
24
|
+
* act on the chain (`new`, `apply`, `rebase`).
|
|
25
|
+
*/
|
|
26
|
+
import { YodelError } from "../project.js";
|
|
27
|
+
import { type ChecksumCheck } from "./checksum.js";
|
|
28
|
+
import { type MigrationDocument, type MigrationFiles } from "./document.js";
|
|
29
|
+
/** Where a project keeps its migrations, relative to the project directory. */
|
|
30
|
+
export declare const MIGRATIONS_DIR = "migrations";
|
|
31
|
+
/** `<YYYYMMDDTHHMM>-<name>`; a name is lowercase letters and digits, words joined by `-` or `_`. */
|
|
32
|
+
export declare const MIGRATION_ID: RegExp;
|
|
33
|
+
export declare const MIGRATION_NAME: RegExp;
|
|
34
|
+
/** One migration as read from disk. */
|
|
35
|
+
export interface Migration {
|
|
36
|
+
id: string;
|
|
37
|
+
/** Its directory, absolute. */
|
|
38
|
+
dir: string;
|
|
39
|
+
parent: string | null;
|
|
40
|
+
/** The checksum `migration.json` records (not recomputed; see {@link verifyChecksum}). */
|
|
41
|
+
checksum: string;
|
|
42
|
+
document: MigrationDocument;
|
|
43
|
+
/** The files' text exactly as read. */
|
|
44
|
+
files: MigrationFiles;
|
|
45
|
+
}
|
|
46
|
+
export type MigrationProblem = {
|
|
47
|
+
kind: "unreadable";
|
|
48
|
+
path: string;
|
|
49
|
+
message: string;
|
|
50
|
+
} | {
|
|
51
|
+
kind: "id-mismatch";
|
|
52
|
+
id: string;
|
|
53
|
+
recorded: string;
|
|
54
|
+
message: string;
|
|
55
|
+
} | {
|
|
56
|
+
kind: "missing-parent";
|
|
57
|
+
id: string;
|
|
58
|
+
parent: string;
|
|
59
|
+
message: string;
|
|
60
|
+
} | {
|
|
61
|
+
kind: "fork";
|
|
62
|
+
parent: string | null;
|
|
63
|
+
children: string[];
|
|
64
|
+
message: string;
|
|
65
|
+
} | {
|
|
66
|
+
kind: "unreachable";
|
|
67
|
+
ids: string[];
|
|
68
|
+
message: string;
|
|
69
|
+
} | {
|
|
70
|
+
kind: "checksum";
|
|
71
|
+
id: string;
|
|
72
|
+
check: ChecksumCheck;
|
|
73
|
+
message: string;
|
|
74
|
+
};
|
|
75
|
+
export interface MigrationScan {
|
|
76
|
+
/** The migrations directory, absolute. */
|
|
77
|
+
dir: string;
|
|
78
|
+
/** Every migration that could be read, sorted by id. */
|
|
79
|
+
migrations: Migration[];
|
|
80
|
+
/** From the first migration to the newest, when there is no structural problem; else `undefined`. */
|
|
81
|
+
ordered: Migration[] | undefined;
|
|
82
|
+
/** Every problem found. Checksum mismatches are listed here but never stop {@link MigrationScan.ordered} being computed. */
|
|
83
|
+
problems: MigrationProblem[];
|
|
84
|
+
}
|
|
85
|
+
/** A migrations directory that is not one unbroken chain, or (when asked) whose checksums do not match. */
|
|
86
|
+
export declare class MigrationDirectoryError extends YodelError {
|
|
87
|
+
readonly dir: string;
|
|
88
|
+
readonly problems: MigrationProblem[];
|
|
89
|
+
constructor(dir: string, problems: MigrationProblem[]);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A migration's files besides migration.sql and migration.json, by path
|
|
93
|
+
* relative to its directory (`/` separators): every regular file at any
|
|
94
|
+
* depth, except those two and anything whose name starts with `.`.
|
|
95
|
+
*/
|
|
96
|
+
export declare function readExtraFiles(at: string): Record<string, string>;
|
|
97
|
+
/** Every migration in `dir` and every problem with the directory. A missing `dir` is an empty directory. */
|
|
98
|
+
export declare function scanMigrations(dir: string): MigrationScan;
|
|
99
|
+
/**
|
|
100
|
+
* The migrations in `dir`, from the first to the newest. Throws a
|
|
101
|
+
* {@link MigrationDirectoryError} on any structural problem (unreadable,
|
|
102
|
+
* id mismatch, missing parent, fork, cycle), and, with `verify`, on a
|
|
103
|
+
* checksum mismatch too. A missing `dir` has no migrations.
|
|
104
|
+
*/
|
|
105
|
+
export declare function readMigrations(dir: string, options?: {
|
|
106
|
+
verify?: boolean;
|
|
107
|
+
}): Migration[];
|
|
108
|
+
/** The newest migration of an ordered list (the end of the chain), or `undefined` for none. */
|
|
109
|
+
export declare const newestMigration: (ordered: readonly Migration[]) => Migration | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Writes a migration's directory, `<dir>/<id>/`, creating `dir` as needed.
|
|
112
|
+
* The files go into a hidden directory first and are renamed into place, so
|
|
113
|
+
* a reader never sees half a migration. An existing `<id>` is an error.
|
|
114
|
+
* Returns the directory written.
|
|
115
|
+
*/
|
|
116
|
+
export declare function writeMigration(dir: string, migration: {
|
|
117
|
+
id: string;
|
|
118
|
+
files: MigrationFiles;
|
|
119
|
+
}): string;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading and writing a project's `migrations/` directory.
|
|
3
|
+
*
|
|
4
|
+
* Order is the chain of parent ids, as in Alembic and pgroll: the first
|
|
5
|
+
* migration has `parent: null`, every other names the one it follows, and
|
|
6
|
+
* the list runs from the first to the newest. The ids' timestamps never
|
|
7
|
+
* decide the order. A directory is well formed when the parent links make
|
|
8
|
+
* one unbroken chain:
|
|
9
|
+
*
|
|
10
|
+
* - every directory under `migrations/` is named like an id and holds a
|
|
11
|
+
* readable `migration.sql` and `migration.json` whose `id` is that name
|
|
12
|
+
* (plain files directly under `migrations/`, such as a README, are
|
|
13
|
+
* ignored; files inside a migration's directory are its own and count in
|
|
14
|
+
* its checksum);
|
|
15
|
+
* - every parent names a migration in the directory;
|
|
16
|
+
* - no two migrations have the same parent, `null` included. Two branches
|
|
17
|
+
* that each added a migration give one parent two children: a fork. It is
|
|
18
|
+
* reported naming both, never ordered by timestamp or by name;
|
|
19
|
+
* - every migration is reachable from the first (no cycles).
|
|
20
|
+
*
|
|
21
|
+
* {@link scanMigrations} reports every problem and never throws on one, for
|
|
22
|
+
* `yodel lint`. {@link readMigrations} returns the ordered chain or throws a
|
|
23
|
+
* {@link MigrationDirectoryError} listing the problems, for the verbs that
|
|
24
|
+
* act on the chain (`new`, `apply`, `rebase`).
|
|
25
|
+
*/
|
|
26
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
27
|
+
import { dirname, join } from "node:path";
|
|
28
|
+
import { YodelError } from "../project.js";
|
|
29
|
+
import { verifyChecksum } from "./checksum.js";
|
|
30
|
+
import { MIGRATION_JSON, MIGRATION_SQL } from "./document.js";
|
|
31
|
+
/** Where a project keeps its migrations, relative to the project directory. */
|
|
32
|
+
export const MIGRATIONS_DIR = "migrations";
|
|
33
|
+
/** `<YYYYMMDDTHHMM>-<name>`; a name is lowercase letters and digits, words joined by `-` or `_`. */
|
|
34
|
+
export const MIGRATION_ID = /^(\d{8}T\d{4})-([a-z0-9]+(?:[-_][a-z0-9]+)*)$/;
|
|
35
|
+
export const MIGRATION_NAME = /^[a-z0-9]+(?:[-_][a-z0-9]+)*$/;
|
|
36
|
+
/** A migrations directory that is not one unbroken chain, or (when asked) whose checksums do not match. */
|
|
37
|
+
export class MigrationDirectoryError extends YodelError {
|
|
38
|
+
dir;
|
|
39
|
+
problems;
|
|
40
|
+
constructor(dir, problems) {
|
|
41
|
+
super(`${dir}:\n${problems.map((p) => ` ${p.message}`).join("\n")}`);
|
|
42
|
+
this.dir = dir;
|
|
43
|
+
this.problems = problems;
|
|
44
|
+
this.name = "MigrationDirectoryError";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
48
|
+
/**
|
|
49
|
+
* A migration's files besides migration.sql and migration.json, by path
|
|
50
|
+
* relative to its directory (`/` separators): every regular file at any
|
|
51
|
+
* depth, except those two and anything whose name starts with `.`.
|
|
52
|
+
*/
|
|
53
|
+
export function readExtraFiles(at) {
|
|
54
|
+
const out = {};
|
|
55
|
+
const walk = (rel) => {
|
|
56
|
+
for (const entry of readdirSync(rel ? join(at, rel) : at).sort()) {
|
|
57
|
+
if (entry.startsWith("."))
|
|
58
|
+
continue;
|
|
59
|
+
const path = rel ? `${rel}/${entry}` : entry;
|
|
60
|
+
if (!rel && (entry === MIGRATION_SQL || entry === MIGRATION_JSON))
|
|
61
|
+
continue;
|
|
62
|
+
const st = statSync(join(at, path));
|
|
63
|
+
if (st.isDirectory())
|
|
64
|
+
walk(path);
|
|
65
|
+
else if (st.isFile())
|
|
66
|
+
out[path] = readFileSync(join(at, path), "utf8");
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
walk("");
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
function readOne(dir, id) {
|
|
73
|
+
const at = join(dir, id);
|
|
74
|
+
let sql;
|
|
75
|
+
let json;
|
|
76
|
+
let extra;
|
|
77
|
+
try {
|
|
78
|
+
sql = readFileSync(join(at, MIGRATION_SQL), "utf8");
|
|
79
|
+
json = readFileSync(join(at, MIGRATION_JSON), "utf8");
|
|
80
|
+
extra = readExtraFiles(at);
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
return { kind: "unreadable", path: at, message: `${id}: ${e instanceof Error ? e.message : String(e)}` };
|
|
84
|
+
}
|
|
85
|
+
let doc;
|
|
86
|
+
try {
|
|
87
|
+
doc = JSON.parse(json);
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
return { kind: "unreadable", path: join(at, MIGRATION_JSON), message: `${id}/${MIGRATION_JSON} is not JSON: ${e instanceof Error ? e.message : String(e)}` };
|
|
91
|
+
}
|
|
92
|
+
const bad = (what) => ({ kind: "unreadable", path: join(at, MIGRATION_JSON), message: `${id}/${MIGRATION_JSON}: ${what}` });
|
|
93
|
+
if (!isRecord(doc))
|
|
94
|
+
return bad("not an object");
|
|
95
|
+
if (typeof doc.id !== "string")
|
|
96
|
+
return bad("no id");
|
|
97
|
+
if (doc.parent !== null && typeof doc.parent !== "string")
|
|
98
|
+
return bad("parent is neither an id nor null");
|
|
99
|
+
if (typeof doc.checksum !== "string")
|
|
100
|
+
return bad("no checksum");
|
|
101
|
+
if (!Array.isArray(doc.steps))
|
|
102
|
+
return bad("no steps");
|
|
103
|
+
if (!isRecord(doc.schema))
|
|
104
|
+
return bad("no recorded schema");
|
|
105
|
+
if (doc.id !== id) {
|
|
106
|
+
return { kind: "id-mismatch", id, recorded: doc.id, message: `${id}/${MIGRATION_JSON} records id ${doc.id}; a migration's id is its directory's name` };
|
|
107
|
+
}
|
|
108
|
+
return { id, dir: at, parent: doc.parent, checksum: doc.checksum, document: doc, files: { sql, json, ...(Object.keys(extra).length > 0 ? { extra } : {}) } };
|
|
109
|
+
}
|
|
110
|
+
/** Every migration in `dir` and every problem with the directory. A missing `dir` is an empty directory. */
|
|
111
|
+
export function scanMigrations(dir) {
|
|
112
|
+
const problems = [];
|
|
113
|
+
const migrations = [];
|
|
114
|
+
if (!existsSync(dir))
|
|
115
|
+
return { dir, migrations, ordered: [], problems };
|
|
116
|
+
for (const entry of readdirSync(dir).sort()) {
|
|
117
|
+
if (entry.startsWith("."))
|
|
118
|
+
continue; // a write in progress, editor and OS files
|
|
119
|
+
if (!statSync(join(dir, entry)).isDirectory())
|
|
120
|
+
continue;
|
|
121
|
+
if (!MIGRATION_ID.test(entry)) {
|
|
122
|
+
problems.push({ kind: "unreadable", path: join(dir, entry), message: `${entry}: not a migration directory name (expected <YYYYMMDDTHHMM>-<name>)` });
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const read = readOne(dir, entry);
|
|
126
|
+
if ("kind" in read)
|
|
127
|
+
problems.push(read);
|
|
128
|
+
else
|
|
129
|
+
migrations.push(read);
|
|
130
|
+
}
|
|
131
|
+
const byId = new Map(migrations.map((m) => [m.id, m]));
|
|
132
|
+
const children = new Map();
|
|
133
|
+
for (const m of migrations) {
|
|
134
|
+
if (m.parent !== null && !byId.has(m.parent)) {
|
|
135
|
+
problems.push({ kind: "missing-parent", id: m.id, parent: m.parent, message: `${m.id} follows ${m.parent}, which is not in the directory` });
|
|
136
|
+
}
|
|
137
|
+
const list = children.get(m.parent) ?? [];
|
|
138
|
+
list.push(m);
|
|
139
|
+
children.set(m.parent, list);
|
|
140
|
+
}
|
|
141
|
+
for (const [parent, kids] of children) {
|
|
142
|
+
if (kids.length < 2)
|
|
143
|
+
continue;
|
|
144
|
+
const ids = kids.map((k) => k.id);
|
|
145
|
+
problems.push({
|
|
146
|
+
kind: "fork",
|
|
147
|
+
parent,
|
|
148
|
+
children: ids,
|
|
149
|
+
message: parent === null
|
|
150
|
+
? `fork: ${ids.join(" and ")} are each a first migration (parent null); rebase all but one onto the chain`
|
|
151
|
+
: `fork: ${ids.join(" and ")} both follow ${parent}; rebase one onto the other`,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
let ordered;
|
|
155
|
+
const structural = problems.length > 0;
|
|
156
|
+
if (!structural) {
|
|
157
|
+
ordered = [];
|
|
158
|
+
for (let next = children.get(null)?.[0]; next; next = children.get(next.id)?.[0])
|
|
159
|
+
ordered.push(next);
|
|
160
|
+
if (ordered.length !== migrations.length) {
|
|
161
|
+
const reached = new Set(ordered.map((m) => m.id));
|
|
162
|
+
const ids = migrations.filter((m) => !reached.has(m.id)).map((m) => m.id);
|
|
163
|
+
problems.push({ kind: "unreachable", ids, message: `${ids.join(", ")} cannot be reached from the first migration (their parents form a cycle)` });
|
|
164
|
+
ordered = undefined;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
for (const m of migrations) {
|
|
168
|
+
const check = verifyChecksum(m);
|
|
169
|
+
if (!check.ok) {
|
|
170
|
+
problems.push({ kind: "checksum", id: m.id, check, message: `${m.id}: its files hash to ${check.actual}, but ${MIGRATION_JSON} records ${check.recorded || "no checksum"}` });
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return { dir, migrations, ordered, problems };
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The migrations in `dir`, from the first to the newest. Throws a
|
|
177
|
+
* {@link MigrationDirectoryError} on any structural problem (unreadable,
|
|
178
|
+
* id mismatch, missing parent, fork, cycle), and, with `verify`, on a
|
|
179
|
+
* checksum mismatch too. A missing `dir` has no migrations.
|
|
180
|
+
*/
|
|
181
|
+
export function readMigrations(dir, options = {}) {
|
|
182
|
+
const scan = scanMigrations(dir);
|
|
183
|
+
const fatal = scan.problems.filter((p) => options.verify === true || p.kind !== "checksum");
|
|
184
|
+
if (fatal.length > 0 || !scan.ordered)
|
|
185
|
+
throw new MigrationDirectoryError(dir, fatal);
|
|
186
|
+
return scan.ordered;
|
|
187
|
+
}
|
|
188
|
+
/** The newest migration of an ordered list (the end of the chain), or `undefined` for none. */
|
|
189
|
+
export const newestMigration = (ordered) => ordered[ordered.length - 1];
|
|
190
|
+
/**
|
|
191
|
+
* Writes a migration's directory, `<dir>/<id>/`, creating `dir` as needed.
|
|
192
|
+
* The files go into a hidden directory first and are renamed into place, so
|
|
193
|
+
* a reader never sees half a migration. An existing `<id>` is an error.
|
|
194
|
+
* Returns the directory written.
|
|
195
|
+
*/
|
|
196
|
+
export function writeMigration(dir, migration) {
|
|
197
|
+
const target = join(dir, migration.id);
|
|
198
|
+
for (const path of Object.keys(migration.files.extra ?? {})) {
|
|
199
|
+
const parts = path.split("/");
|
|
200
|
+
if (parts.some((p) => p === "" || p.startsWith(".") || p.includes("\\")) || path === MIGRATION_SQL || path === MIGRATION_JSON) {
|
|
201
|
+
throw new YodelError(`${migration.id}: ${JSON.stringify(path)} is not a path a migration's own file can have (relative, "/"-separated, no part starting with ".")`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (existsSync(target))
|
|
205
|
+
throw new YodelError(`${target} already exists; a migration's directory is never overwritten`);
|
|
206
|
+
mkdirSync(dir, { recursive: true });
|
|
207
|
+
const staging = join(dir, `.${migration.id}.writing`);
|
|
208
|
+
rmSync(staging, { recursive: true, force: true });
|
|
209
|
+
mkdirSync(staging);
|
|
210
|
+
try {
|
|
211
|
+
writeFileSync(join(staging, MIGRATION_SQL), migration.files.sql);
|
|
212
|
+
writeFileSync(join(staging, MIGRATION_JSON), migration.files.json);
|
|
213
|
+
for (const [path, text] of Object.entries(migration.files.extra ?? {})) {
|
|
214
|
+
mkdirSync(dirname(join(staging, path)), { recursive: true });
|
|
215
|
+
writeFileSync(join(staging, path), text);
|
|
216
|
+
}
|
|
217
|
+
renameSync(staging, target);
|
|
218
|
+
}
|
|
219
|
+
catch (e) {
|
|
220
|
+
rmSync(staging, { recursive: true, force: true });
|
|
221
|
+
throw e;
|
|
222
|
+
}
|
|
223
|
+
return target;
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=directory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../../src/migrations/directory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAsB,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,cAAc,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C,OAAO,CAAC,CAAC;IACnB,IAAI,CAAC;QACH,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjE,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnE,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;YACvE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC7D,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;QAC3C,CAAC;QACD,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,MAAM,CAAC,CAAC;IACV,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What one migration directory holds, and how its `migration.json` is
|
|
3
|
+
* written so that the same migration always serializes to the same bytes.
|
|
4
|
+
*
|
|
5
|
+
* migrations/<id>/migration.sql the statements, each after a comment naming
|
|
6
|
+
* its object, rule and class (chant's
|
|
7
|
+
* `renderStatements`); an Op or manual step
|
|
8
|
+
* is a comment only
|
|
9
|
+
* migrations/<id>/migration.json a {@link MigrationDocument}
|
|
10
|
+
* migrations/<id>/<other files> only when a step names one, such as a
|
|
11
|
+
* backfill step's `backfill.ts`
|
|
12
|
+
*
|
|
13
|
+
* `<id>` is `<UTC timestamp YYYYMMDDTHHMM>-<name>`, e.g.
|
|
14
|
+
* `20261009T1412-add-country`. The timestamp is for people reading a
|
|
15
|
+
* directory listing; the order migrations run in is the chain of parent ids,
|
|
16
|
+
* never the ids' sort order (see `./directory.ts`).
|
|
17
|
+
*/
|
|
18
|
+
import type { MigrationStep, SchemaStatements } from "@intentius/chant-lexicon-sql/migration-statements";
|
|
19
|
+
import type { BuildOutput } from "../chant/build.js";
|
|
20
|
+
export type { MigrationStep, SchemaStatements };
|
|
21
|
+
export declare const MIGRATION_SQL = "migration.sql";
|
|
22
|
+
export declare const MIGRATION_JSON = "migration.json";
|
|
23
|
+
/** The version of the `migration.json` layout. Bumped only on a change older readers cannot read. */
|
|
24
|
+
export declare const MIGRATION_FORMAT = 1;
|
|
25
|
+
/**
|
|
26
|
+
* `migration.json`. Every value is plain JSON. Keys are written in the
|
|
27
|
+
* order listed here, and every nested object (a step, the schema) with its
|
|
28
|
+
* keys sorted, except that a step starts with `kind, object, type, name`.
|
|
29
|
+
*/
|
|
30
|
+
export interface MigrationDocument {
|
|
31
|
+
/** {@link MIGRATION_FORMAT}. */
|
|
32
|
+
format: number;
|
|
33
|
+
/** The directory's name: `<YYYYMMDDTHHMM>-<name>`. */
|
|
34
|
+
id: string;
|
|
35
|
+
/** The id of the migration this one follows, or `null` for the first. */
|
|
36
|
+
parent: string | null;
|
|
37
|
+
/** `sha256:<hex>` over this migration's own files; see `./checksum.ts`. */
|
|
38
|
+
checksum: string;
|
|
39
|
+
/** When `yodel new` wrote it, ISO 8601 in UTC, to the second. */
|
|
40
|
+
createdAt?: string;
|
|
41
|
+
dialect: SchemaStatements["dialect"];
|
|
42
|
+
/** ClickHouse: the database a bare name in the statements means. */
|
|
43
|
+
defaultDatabase?: string;
|
|
44
|
+
/** Postgres: the schema a bare name means; an applier sets `search_path` to it. */
|
|
45
|
+
defaultSchema?: string;
|
|
46
|
+
/** Postgres: the major the changes were classified for. */
|
|
47
|
+
major?: number;
|
|
48
|
+
/** ClickHouse: unset (or `single`): yodel writes migrations topology-neutral and renders them per environment at apply time. */
|
|
49
|
+
topology?: string;
|
|
50
|
+
/** True when a step is an Op or a manual step: the migration is more than its SQL. */
|
|
51
|
+
refused: boolean;
|
|
52
|
+
/** What the diff pointed out besides the changes, e.g. a likely rename written as a drop and an add. */
|
|
53
|
+
hints: string[];
|
|
54
|
+
/** In the order they run. An Op step carries the Op's declaration; it has no SQL. */
|
|
55
|
+
steps: MigrationStep[];
|
|
56
|
+
/** The recorded schema: the `chant build` output after this migration. The next `yodel new` diffs from it. */
|
|
57
|
+
schema: BuildOutput;
|
|
58
|
+
}
|
|
59
|
+
/** A migration's files as text, before or after they are on disk. */
|
|
60
|
+
export interface MigrationFiles {
|
|
61
|
+
/** `migration.sql`. */
|
|
62
|
+
sql: string;
|
|
63
|
+
/** `migration.json`. */
|
|
64
|
+
json: string;
|
|
65
|
+
/**
|
|
66
|
+
* The migration's other files, by path relative to its directory with `/`
|
|
67
|
+
* separators: a backfill step's module, for one. Absent or empty for a
|
|
68
|
+
* migration that has only the two. They count in the checksum.
|
|
69
|
+
*/
|
|
70
|
+
extra?: Record<string, string>;
|
|
71
|
+
}
|
|
72
|
+
/** `value` with every object's keys sorted, `head` first in that order; `undefined` members dropped. */
|
|
73
|
+
export declare function sortKeys(value: unknown, head?: readonly string[]): unknown;
|
|
74
|
+
/**
|
|
75
|
+
* The document in its written key order. Keys outside
|
|
76
|
+
* {@link MigrationDocument} (a newer yodel's) are kept, sorted, after `hints`
|
|
77
|
+
* and before `steps`, so a rewrite never drops them.
|
|
78
|
+
*/
|
|
79
|
+
export declare function orderDocument(doc: Record<string, unknown>): Record<string, unknown>;
|
|
80
|
+
/** `migration.json` as written: two-space indent, the key order above, `\n` line endings and a trailing newline. */
|
|
81
|
+
export declare function serializeDocument(doc: MigrationDocument | Record<string, unknown>): string;
|
|
82
|
+
/** Line endings as `\n`: CRLF and lone CR both become LF. */
|
|
83
|
+
export declare const normalizeLineEndings: (text: string) => string;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What one migration directory holds, and how its `migration.json` is
|
|
3
|
+
* written so that the same migration always serializes to the same bytes.
|
|
4
|
+
*
|
|
5
|
+
* migrations/<id>/migration.sql the statements, each after a comment naming
|
|
6
|
+
* its object, rule and class (chant's
|
|
7
|
+
* `renderStatements`); an Op or manual step
|
|
8
|
+
* is a comment only
|
|
9
|
+
* migrations/<id>/migration.json a {@link MigrationDocument}
|
|
10
|
+
* migrations/<id>/<other files> only when a step names one, such as a
|
|
11
|
+
* backfill step's `backfill.ts`
|
|
12
|
+
*
|
|
13
|
+
* `<id>` is `<UTC timestamp YYYYMMDDTHHMM>-<name>`, e.g.
|
|
14
|
+
* `20261009T1412-add-country`. The timestamp is for people reading a
|
|
15
|
+
* directory listing; the order migrations run in is the chain of parent ids,
|
|
16
|
+
* never the ids' sort order (see `./directory.ts`).
|
|
17
|
+
*/
|
|
18
|
+
export const MIGRATION_SQL = "migration.sql";
|
|
19
|
+
export const MIGRATION_JSON = "migration.json";
|
|
20
|
+
/** The version of the `migration.json` layout. Bumped only on a change older readers cannot read. */
|
|
21
|
+
export const MIGRATION_FORMAT = 1;
|
|
22
|
+
const STEP_HEAD = ["kind", "object", "type", "name"];
|
|
23
|
+
const DOCUMENT_ORDER = [
|
|
24
|
+
"format",
|
|
25
|
+
"id",
|
|
26
|
+
"parent",
|
|
27
|
+
"checksum",
|
|
28
|
+
"createdAt",
|
|
29
|
+
"dialect",
|
|
30
|
+
"defaultDatabase",
|
|
31
|
+
"defaultSchema",
|
|
32
|
+
"major",
|
|
33
|
+
"topology",
|
|
34
|
+
"refused",
|
|
35
|
+
"hints",
|
|
36
|
+
"steps",
|
|
37
|
+
"schema",
|
|
38
|
+
];
|
|
39
|
+
const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
40
|
+
/** `value` with every object's keys sorted, `head` first in that order; `undefined` members dropped. */
|
|
41
|
+
export function sortKeys(value, head = []) {
|
|
42
|
+
if (Array.isArray(value))
|
|
43
|
+
return value.map((v) => sortKeys(v));
|
|
44
|
+
if (!isRecord(value))
|
|
45
|
+
return value;
|
|
46
|
+
const keys = Object.keys(value).filter((k) => value[k] !== undefined);
|
|
47
|
+
const first = head.filter((k) => keys.includes(k));
|
|
48
|
+
const rest = keys.filter((k) => !head.includes(k)).sort();
|
|
49
|
+
return Object.fromEntries([...first, ...rest].map((k) => [k, sortKeys(value[k])]));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The document in its written key order. Keys outside
|
|
53
|
+
* {@link MigrationDocument} (a newer yodel's) are kept, sorted, after `hints`
|
|
54
|
+
* and before `steps`, so a rewrite never drops them.
|
|
55
|
+
*/
|
|
56
|
+
export function orderDocument(doc) {
|
|
57
|
+
const known = new Set(DOCUMENT_ORDER);
|
|
58
|
+
const out = {};
|
|
59
|
+
const put = (k) => {
|
|
60
|
+
const v = doc[k];
|
|
61
|
+
if (v === undefined)
|
|
62
|
+
return;
|
|
63
|
+
if (k === "steps" && Array.isArray(v))
|
|
64
|
+
out[k] = v.map((s) => sortKeys(s, STEP_HEAD));
|
|
65
|
+
else
|
|
66
|
+
out[k] = sortKeys(v);
|
|
67
|
+
};
|
|
68
|
+
for (const k of DOCUMENT_ORDER) {
|
|
69
|
+
if (k === "steps")
|
|
70
|
+
for (const extra of Object.keys(doc).filter((x) => !known.has(x)).sort())
|
|
71
|
+
put(extra);
|
|
72
|
+
put(k);
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
/** `migration.json` as written: two-space indent, the key order above, `\n` line endings and a trailing newline. */
|
|
77
|
+
export function serializeDocument(doc) {
|
|
78
|
+
return `${JSON.stringify(orderDocument(doc), null, 2)}\n`;
|
|
79
|
+
}
|
|
80
|
+
/** Line endings as `\n`: CRLF and lone CR both become LF. */
|
|
81
|
+
export const normalizeLineEndings = (text) => text.replace(/\r\n?/g,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,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;gBAAE,GAAG,CAAC,KAAK,CAAC,CAAC;QACxG,GAAG,CAAC,CAAC,CAAC,CAAC;IACT,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,oHAAoH;AACpH,MAAM,UAAU,iBAAiB,CAAC,GAAgD;IAChF,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,GAA8B,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AACvF,CAAC;AAED,6DAA6D;AAC7D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The migration directory (#7): what `yodel new` writes and what `apply`
|
|
3
|
+
* (#8), the replay check (#11), `lint` (#14) and `rebase` / `repair` (#15)
|
|
4
|
+
* read.
|
|
5
|
+
*
|
|
6
|
+
* readMigrations(dir, { verify? }) the chain, first to newest; throws on a fork, a missing parent, a cycle
|
|
7
|
+
* scanMigrations(dir) every migration and every problem, never throws on one (for lint)
|
|
8
|
+
* newestMigration(ordered) the end of the chain
|
|
9
|
+
* computeChecksum(files) the checksum of one migration's files
|
|
10
|
+
* verifyChecksum(m) recorded against recomputed
|
|
11
|
+
* createMigration(options) the next migration from a build, offline (pure)
|
|
12
|
+
* writeMigration(dir, migration) puts it on disk
|
|
13
|
+
*
|
|
14
|
+
* The file layout is in `./document.ts`, the checksum's exact definition in
|
|
15
|
+
* `./checksum.ts`, the ordering rules in `./directory.ts`.
|
|
16
|
+
*/
|
|
17
|
+
export * from "./checksum.js";
|
|
18
|
+
export * from "./create.js";
|
|
19
|
+
export * from "./directory.js";
|
|
20
|
+
export * from "./document.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The migration directory (#7): what `yodel new` writes and what `apply`
|
|
3
|
+
* (#8), the replay check (#11), `lint` (#14) and `rebase` / `repair` (#15)
|
|
4
|
+
* read.
|
|
5
|
+
*
|
|
6
|
+
* readMigrations(dir, { verify? }) the chain, first to newest; throws on a fork, a missing parent, a cycle
|
|
7
|
+
* scanMigrations(dir) every migration and every problem, never throws on one (for lint)
|
|
8
|
+
* newestMigration(ordered) the end of the chain
|
|
9
|
+
* computeChecksum(files) the checksum of one migration's files
|
|
10
|
+
* verifyChecksum(m) recorded against recomputed
|
|
11
|
+
* createMigration(options) the next migration from a build, offline (pure)
|
|
12
|
+
* writeMigration(dir, migration) puts it on disk
|
|
13
|
+
*
|
|
14
|
+
* The file layout is in `./document.ts`, the checksum's exact definition in
|
|
15
|
+
* `./checksum.ts`, the ordering rules in `./directory.ts`.
|
|
16
|
+
*/
|
|
17
|
+
export * from "./checksum.js";
|
|
18
|
+
export * from "./create.js";
|
|
19
|
+
export * from "./directory.js";
|
|
20
|
+
export * from "./document.js";
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One comment per environment on the pull request: found by its marker and
|
|
3
|
+
* updated, else created. The three forges' REST APIs:
|
|
4
|
+
*
|
|
5
|
+
* GitHub GET/POST {api}/repos/{owner}/{repo}/issues/{n}/comments
|
|
6
|
+
* PATCH {api}/repos/{owner}/{repo}/issues/comments/{id}
|
|
7
|
+
* GitLab GET/POST {api}/projects/{id}/merge_requests/{iid}/notes
|
|
8
|
+
* PUT {api}/projects/{id}/merge_requests/{iid}/notes/{note_id}
|
|
9
|
+
* Forgejo GET/POST {api}/repos/{owner}/{repo}/issues/{n}/comments (Gitea's API, /api/v1)
|
|
10
|
+
* PATCH {api}/repos/{owner}/{repo}/issues/comments/{id}
|
|
11
|
+
*/
|
|
12
|
+
import type { ForgeTarget } from "./forge.js";
|
|
13
|
+
export interface ForgeComment {
|
|
14
|
+
id: number;
|
|
15
|
+
body: string;
|
|
16
|
+
url?: string | undefined;
|
|
17
|
+
}
|
|
18
|
+
export interface CommentClient {
|
|
19
|
+
list(): Promise<ForgeComment[]>;
|
|
20
|
+
create(body: string): Promise<ForgeComment>;
|
|
21
|
+
update(id: number, body: string): Promise<ForgeComment>;
|
|
22
|
+
}
|
|
23
|
+
type Fetch = typeof fetch;
|
|
24
|
+
export declare function commentClient(t: ForgeTarget, f?: Fetch): CommentClient;
|
|
25
|
+
/** The comment carrying `marker`, the newest when several do. */
|
|
26
|
+
export declare function findComment(c: CommentClient, marker: string): Promise<ForgeComment | undefined>;
|
|
27
|
+
/** Updates the comment carrying `marker`, or creates one. */
|
|
28
|
+
export declare function upsertComment(c: CommentClient, marker: string, body: string, existing?: ForgeComment): Promise<{
|
|
29
|
+
action: "created" | "updated" | "unchanged";
|
|
30
|
+
comment: ForgeComment;
|
|
31
|
+
}>;
|
|
32
|
+
export {};
|