@orthograph/cli 0.0.0-stage → 0.1.0-next.1
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 +28 -2
- package/dist/main.d.ts +2 -0
- package/dist/main.js +318 -0
- package/dist/modules/add/internal/journeys.d.ts +3 -0
- package/dist/modules/add/internal/journeys.js +13 -0
- package/dist/modules/add/internal/names.d.ts +8 -0
- package/dist/modules/add/internal/names.js +9 -0
- package/dist/modules/add/internal/templates.d.ts +16 -0
- package/dist/modules/add/internal/templates.js +104 -0
- package/dist/modules/add/service.d.ts +2 -0
- package/dist/modules/add/service.js +27 -0
- package/dist/modules/add/types.d.ts +30 -0
- package/dist/modules/add/types.js +6 -0
- package/dist/modules/brief/service.d.ts +2 -0
- package/dist/modules/brief/service.js +48 -0
- package/dist/modules/brief/types.d.ts +16 -0
- package/dist/modules/brief/types.js +1 -0
- package/dist/modules/check/internal/blanks.d.ts +3 -0
- package/dist/modules/check/internal/blanks.js +11 -0
- package/dist/modules/check/internal/changes.d.ts +8 -0
- package/dist/modules/check/internal/changes.js +16 -0
- package/dist/modules/check/internal/drift.d.ts +4 -0
- package/dist/modules/check/internal/drift.js +25 -0
- package/dist/modules/check/internal/files.d.ts +8 -0
- package/dist/modules/check/internal/files.js +18 -0
- package/dist/modules/check/internal/ratchets.d.ts +7 -0
- package/dist/modules/check/internal/ratchets.js +17 -0
- package/dist/modules/check/internal/tools.d.ts +12 -0
- package/dist/modules/check/internal/tools.js +66 -0
- package/dist/modules/check/service.d.ts +2 -0
- package/dist/modules/check/service.js +37 -0
- package/dist/modules/check/types.d.ts +32 -0
- package/dist/modules/check/types.js +1 -0
- package/dist/modules/generate/service.d.ts +2 -0
- package/dist/modules/generate/service.js +18 -0
- package/dist/modules/generate/types.d.ts +13 -0
- package/dist/modules/generate/types.js +1 -0
- package/dist/modules/handoff/internal/find.d.ts +6 -0
- package/dist/modules/handoff/internal/find.js +29 -0
- package/dist/modules/handoff/service.d.ts +2 -0
- package/dist/modules/handoff/service.js +16 -0
- package/dist/modules/handoff/types.d.ts +17 -0
- package/dist/modules/handoff/types.js +2 -0
- package/dist/modules/model/internal/summary.d.ts +3 -0
- package/dist/modules/model/internal/summary.js +6 -0
- package/dist/modules/model/service.d.ts +2 -0
- package/dist/modules/model/service.js +9 -0
- package/dist/modules/model/types.d.ts +14 -0
- package/dist/modules/model/types.js +1 -0
- package/dist/modules/mounting/internal/age.d.ts +9 -0
- package/dist/modules/mounting/internal/age.js +47 -0
- package/dist/modules/mounting/internal/needs.d.ts +2 -0
- package/dist/modules/mounting/internal/needs.js +26 -0
- package/dist/modules/mounting/internal/scaffold.d.ts +3 -0
- package/dist/modules/mounting/internal/scaffold.js +27 -0
- package/dist/modules/mounting/service.d.ts +7 -0
- package/dist/modules/mounting/service.js +71 -0
- package/dist/modules/mounting/types.d.ts +28 -0
- package/dist/modules/mounting/types.js +6 -0
- package/dist/modules/new/internal/read.d.ts +6 -0
- package/dist/modules/new/internal/read.js +15 -0
- package/dist/modules/new/service.d.ts +2 -0
- package/dist/modules/new/service.js +28 -0
- package/dist/modules/new/types.d.ts +22 -0
- package/dist/modules/new/types.js +5 -0
- package/dist/modules/secrets/internal/argv.d.ts +3 -0
- package/dist/modules/secrets/internal/argv.js +27 -0
- package/dist/modules/secrets/service.d.ts +2 -0
- package/dist/modules/secrets/service.js +26 -0
- package/dist/modules/secrets/types.d.ts +23 -0
- package/dist/modules/secrets/types.js +1 -0
- package/dist/modules/ship/service.d.ts +2 -0
- package/dist/modules/ship/service.js +36 -0
- package/dist/modules/ship/types.d.ts +35 -0
- package/dist/modules/ship/types.js +1 -0
- package/dist/modules/staging/internal/address.d.ts +21 -0
- package/dist/modules/staging/internal/address.js +28 -0
- package/dist/modules/staging/internal/alchemy-bin.d.ts +3 -0
- package/dist/modules/staging/internal/alchemy-bin.js +12 -0
- package/dist/modules/staging/internal/app.d.ts +3 -0
- package/dist/modules/staging/internal/app.js +23 -0
- package/dist/modules/staging/internal/cloudflare.d.ts +2 -0
- package/dist/modules/staging/internal/cloudflare.js +47 -0
- package/dist/modules/staging/internal/config.d.ts +26 -0
- package/dist/modules/staging/internal/config.js +39 -0
- package/dist/modules/staging/internal/deploy.d.ts +3 -0
- package/dist/modules/staging/internal/deploy.js +50 -0
- package/dist/modules/staging/internal/destroy.d.ts +10 -0
- package/dist/modules/staging/internal/destroy.js +29 -0
- package/dist/modules/staging/internal/live.d.ts +2 -0
- package/dist/modules/staging/internal/live.js +33 -0
- package/dist/modules/staging/internal/plan.d.ts +28 -0
- package/dist/modules/staging/internal/plan.js +56 -0
- package/dist/modules/staging/internal/stack.d.ts +15 -0
- package/dist/modules/staging/internal/stack.js +24 -0
- package/dist/modules/staging/service.d.ts +7 -0
- package/dist/modules/staging/service.js +52 -0
- package/dist/modules/staging/types.d.ts +110 -0
- package/dist/modules/staging/types.js +9 -0
- package/dist/modules/telemetry/service.d.ts +2 -0
- package/dist/modules/telemetry/service.js +27 -0
- package/dist/modules/telemetry/types.d.ts +19 -0
- package/dist/modules/telemetry/types.js +1 -0
- package/dist/modules/watch/service.d.ts +2 -0
- package/dist/modules/watch/service.js +17 -0
- package/dist/modules/watch/types.d.ts +23 -0
- package/dist/modules/watch/types.js +1 -0
- package/package.json +36 -3
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { binOf, installedCli, same } from "./internal/find.js";
|
|
3
|
+
export const Handoff = {
|
|
4
|
+
from: (args, cwd) => {
|
|
5
|
+
const at = args.findIndex((a) => a === "--root" || a.startsWith("--root="));
|
|
6
|
+
const given = at < 0 ? undefined : args[at].startsWith("--root=") ? args[at].slice("--root=".length) : args[at + 1];
|
|
7
|
+
return given === undefined || given === "" ? cwd : resolve(cwd, given);
|
|
8
|
+
},
|
|
9
|
+
target: ({ from, own }) => {
|
|
10
|
+
const dir = installedCli(from);
|
|
11
|
+
if (dir === undefined || same(dir, own))
|
|
12
|
+
return undefined;
|
|
13
|
+
const run = binOf(dir);
|
|
14
|
+
return run === undefined ? { broken: dir } : { run };
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface HandoffApi {
|
|
2
|
+
/** The folder whose app is meant: the `--root` in `args` (everything after `ortho`), else `cwd`. */
|
|
3
|
+
readonly from: (args: ReadonlyArray<string>, cwd: string) => string;
|
|
4
|
+
/**
|
|
5
|
+
* The app's own `ortho` entry to run instead (`run`), when one is installed from `from` up and it is not the CLI at `own` (its
|
|
6
|
+
* package folder); `broken` (the package's folder) when one is installed but its entry can't be read; nothing otherwise.
|
|
7
|
+
*/
|
|
8
|
+
readonly target: (options: {
|
|
9
|
+
readonly from: string;
|
|
10
|
+
readonly own: string;
|
|
11
|
+
}) => Target | undefined;
|
|
12
|
+
}
|
|
13
|
+
export type Target = {
|
|
14
|
+
readonly run: string;
|
|
15
|
+
} | {
|
|
16
|
+
readonly broken: string;
|
|
17
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** The human form: one line per thing and operation, so a glance shows what the blueprint declares. */
|
|
2
|
+
export const summary = (model) => [
|
|
3
|
+
...Object.values(model.things).map((t) => `thing ${t.name}${t.machine ? ` (${t.machine.states.join(", ")})` : ""} ${t.hash}`),
|
|
4
|
+
...Object.values(model.operations).map((o) => `operation ${o.name} refuses ${o.refusals.join(", ") || "nothing"} ${o.hash}`),
|
|
5
|
+
...Object.entries(model.blanks ?? {}).map(([owner, parts]) => `unfinished ${owner} ${parts.length} blank${parts.length === 1 ? "" : "s"}`),
|
|
6
|
+
].join("\n") + "\n";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { Compiler, nodeSource } from "@orthograph/compiler";
|
|
3
|
+
import { summary } from "./internal/summary.js";
|
|
4
|
+
export const ModelCommand = {
|
|
5
|
+
run: ({ root, json }) => Compiler.model.pipe(Effect.provide(nodeSource(root)), Effect.map((model) => ({ out: json ? JSON.stringify(model, null, 2) + "\n" : summary(model), err: "", exit: 0 })), Effect.catchTags({
|
|
6
|
+
BlueprintInvalid: (e) => Effect.succeed({ out: "", err: `The blueprint is invalid:\n${e.problems.map((p) => ` - ${p}`).join("\n")}\n`, exit: 2 }),
|
|
7
|
+
SourceError: (e) => Effect.succeed({ out: "", err: `${e.message}\n`, exit: 2 }),
|
|
8
|
+
})),
|
|
9
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Effect } from "effect";
|
|
2
|
+
/** What the command has to say. `main.ts` prints it and exits with `exit`; the module never prints. */
|
|
3
|
+
export interface Said {
|
|
4
|
+
readonly out: string;
|
|
5
|
+
readonly err: string;
|
|
6
|
+
readonly exit: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ModelCommandApi {
|
|
9
|
+
/** Reads `<root>/blueprint` and describes it. An invalid blueprint is an answer too: its problems, exit 2. */
|
|
10
|
+
readonly run: (options: {
|
|
11
|
+
readonly root: string;
|
|
12
|
+
readonly json: boolean;
|
|
13
|
+
}) => Effect.Effect<Said>;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
export declare const THREE_DAYS_MS: number;
|
|
3
|
+
/** Whether the project's lockfile says the package came from a registry (an integrity, no tarball or directory). */
|
|
4
|
+
export declare const fromRegistry: (root: string, pkg: string, version: string) => boolean;
|
|
5
|
+
/** The packages the project lets under three days, from `minimumReleaseAgeExclude` in its pnpm-workspace.yaml. */
|
|
6
|
+
export declare const excluded: (root: string) => ReadonlyArray<string>;
|
|
7
|
+
export type Fetch = (url: string) => Effect.Effect<unknown, string>;
|
|
8
|
+
/** How old the release is, read from the registry, or why it can't be. */
|
|
9
|
+
export declare const ageOf: (fetchJson: Fetch, registry: string, pkg: string, version: string) => Effect.Effect<number, string, never>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// R1: a registry release younger than three days is refused unless the project names it in pnpm's own override.
|
|
2
|
+
// A package from no registry (a local tarball, a link) has no release to age, and says so.
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { Clock, Effect } from "effect";
|
|
6
|
+
export const THREE_DAYS_MS = 3 * 24 * 60 * 60 * 1000;
|
|
7
|
+
const upward = (from, file) => {
|
|
8
|
+
for (let dir = from;; dir = dirname(dir)) {
|
|
9
|
+
if (existsSync(join(dir, file)))
|
|
10
|
+
return join(dir, file);
|
|
11
|
+
if (dirname(dir) === dir)
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
/** Whether the project's lockfile says the package came from a registry (an integrity, no tarball or directory). */
|
|
16
|
+
export const fromRegistry = (root, pkg, version) => {
|
|
17
|
+
const lock = upward(root, "pnpm-lock.yaml");
|
|
18
|
+
if (!lock)
|
|
19
|
+
return false;
|
|
20
|
+
const lines = readFileSync(lock, "utf8").split("\n");
|
|
21
|
+
const at = lines.findIndex((l) => l === ` ${pkg}@${version}:` || l === ` '${pkg}@${version}':`);
|
|
22
|
+
if (at < 0)
|
|
23
|
+
return false;
|
|
24
|
+
const entry = lines.slice(at + 1, lines.findIndex((l, i) => i > at && !l.startsWith(" "))).join("\n");
|
|
25
|
+
return /integrity:/.test(entry) && !/tarball:|directory:/.test(entry);
|
|
26
|
+
};
|
|
27
|
+
/** The packages the project lets under three days, from `minimumReleaseAgeExclude` in its pnpm-workspace.yaml. */
|
|
28
|
+
export const excluded = (root) => {
|
|
29
|
+
const file = upward(root, "pnpm-workspace.yaml");
|
|
30
|
+
if (!file)
|
|
31
|
+
return [];
|
|
32
|
+
const text = readFileSync(file, "utf8");
|
|
33
|
+
const inline = /^minimumReleaseAgeExclude:\s*\[(.*)\]\s*$/m.exec(text);
|
|
34
|
+
if (inline)
|
|
35
|
+
return inline[1].split(",").map((s) => s.trim().replace(/^['"]|['"]$/g, "")).filter(Boolean);
|
|
36
|
+
const block = /^minimumReleaseAgeExclude:\s*\n((?:\s+-.*\n?)*)/m.exec(text);
|
|
37
|
+
return block ? block[1].split("\n").map((l) => l.replace(/^\s+-\s*/, "").replace(/\s+#.*$/, "").trim().replace(/^['"]|['"]$/g, "")).filter(Boolean) : [];
|
|
38
|
+
};
|
|
39
|
+
/** How old the release is, read from the registry, or why it can't be. */
|
|
40
|
+
export const ageOf = (fetchJson, registry, pkg, version) => Effect.gen(function* () {
|
|
41
|
+
const meta = yield* fetchJson(`${registry.replace(/\/$/, "")}/${pkg.replace("/", "%2f")}`);
|
|
42
|
+
const published = meta.time?.[version];
|
|
43
|
+
if (!published)
|
|
44
|
+
return yield* Effect.fail(`${registry} has no publish time for ${pkg} ${version}`);
|
|
45
|
+
const now = yield* Clock.currentTimeMillis;
|
|
46
|
+
return now - Date.parse(published);
|
|
47
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// What the plugin needs at its first picks, and whether the project already mounts each (identity, as the compiler does).
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { Mounts as Picks } from "orthograph/server";
|
|
4
|
+
import { BlueprintSource, nodeSource } from "@orthograph/compiler";
|
|
5
|
+
const kindOf = (x) => (typeof x === "object" && x !== null ? x.kind : undefined);
|
|
6
|
+
const MOUNTS = /^(features|adapters|projections)\/[^/]+\.ts$/;
|
|
7
|
+
export const needLines = (root, descriptor) => Effect.gen(function* () {
|
|
8
|
+
const source = yield* BlueprintSource;
|
|
9
|
+
const nothing = { verbs: [] };
|
|
10
|
+
const needs = (descriptor.needs ?? []).flatMap((need) => {
|
|
11
|
+
const when = kindOf(need) === "need" ? need.when : undefined;
|
|
12
|
+
const wanted = kindOf(need) === "need" ? need.plugin : need;
|
|
13
|
+
return when && !Picks.picked(nothing, when) ? [] : [wanted];
|
|
14
|
+
});
|
|
15
|
+
if (needs.length === 0)
|
|
16
|
+
return ["needs none"];
|
|
17
|
+
const installed = yield* source.plugins;
|
|
18
|
+
const mounts = yield* Effect.forEach((yield* source.list).filter((p) => MOUNTS.test(p)), source.load);
|
|
19
|
+
return needs.map((wanted) => {
|
|
20
|
+
const pkg = installed.find((p) => p.descriptor === wanted);
|
|
21
|
+
const kind = String(kindOf(wanted) ?? "feature");
|
|
22
|
+
const by = mounts.find((m) => m.exports["default"]?.plugin === wanted);
|
|
23
|
+
const name = pkg?.name ?? `a ${kind} that isn't installed`;
|
|
24
|
+
return by ? `needs ${name}: met by blueprint/${by.path}` : `needs ${name}: not mounted: ortho add ${kind} ${pkg?.name ?? "<package>"}`;
|
|
25
|
+
});
|
|
26
|
+
}).pipe(Effect.provide(nodeSource(root)), Effect.orElseSucceed(() => ["needs (unread: the blueprint couldn't be loaded; ortho model says why)"]));
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Each choice's first option, as the mount writes it: `p.choices.style.plain`. */
|
|
2
|
+
export declare const firstPicks: (choices: unknown, path?: ReadonlyArray<string>) => ReadonlyArray<string>;
|
|
3
|
+
export declare const mountFile: (pkg: string, version: string, picks: ReadonlyArray<string>) => string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const kindOf = (x) => (typeof x === "object" && x !== null ? x.kind : undefined);
|
|
2
|
+
const IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
3
|
+
const access = (path) => path.map((k) => (IDENTIFIER.test(k) ? `.${k}` : `[${JSON.stringify(k)}]`)).join("");
|
|
4
|
+
/** Each choice's first option, as the mount writes it: `p.choices.style.plain`. */
|
|
5
|
+
export const firstPicks = (choices, path = []) => typeof choices !== "object" || choices === null ? [] : Object.entries(choices).sort(([a], [b]) => a.localeCompare(b)).flatMap(([key, value]) => {
|
|
6
|
+
if (kindOf(value) !== "choice")
|
|
7
|
+
return typeof value === "object" && value !== null ? firstPicks(value, [...path, key]) : [];
|
|
8
|
+
const first = Object.keys(value.options)[0];
|
|
9
|
+
return first === undefined ? [] : [`p.choices${access([...path, key, first])}`];
|
|
10
|
+
});
|
|
11
|
+
/** `@fixture/echo` is imported as `echo`; a name that isn't an identifier is `plugin`. */
|
|
12
|
+
const variable = (pkg) => {
|
|
13
|
+
const own = pkg.slice(pkg.lastIndexOf("/") + 1).replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
|
|
14
|
+
return IDENTIFIER.test(own) ? own : "plugin";
|
|
15
|
+
};
|
|
16
|
+
export const mountFile = (pkg, version, picks) => {
|
|
17
|
+
const name = variable(pkg);
|
|
18
|
+
const verbs = picks.length === 0 ? "" : `, (p) => [${picks.map((pick) => `p.choose(${pick})`).join(", ")}]`;
|
|
19
|
+
return [
|
|
20
|
+
`// Scaffolded from ${pkg} ${version}. Yours from now on.`,
|
|
21
|
+
`import { Blueprint } from "orthograph";`,
|
|
22
|
+
`import ${name} from "${pkg}";`,
|
|
23
|
+
"",
|
|
24
|
+
`export default Blueprint.use(${name}${verbs});`,
|
|
25
|
+
"",
|
|
26
|
+
].join("\n");
|
|
27
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type MountingApi } from "./types.ts";
|
|
2
|
+
import { type Fetch } from "./internal/age.ts";
|
|
3
|
+
/** A registry's JSON over HTTP, for R1's publish time. */
|
|
4
|
+
export declare const httpJson: Fetch;
|
|
5
|
+
/** `add`, reading registry release times through `fetchJson`. */
|
|
6
|
+
export declare const mountingWith: (fetchJson: Fetch) => MountingApi;
|
|
7
|
+
export declare const Mounting: MountingApi;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { dirname, join } from "node:path";
|
|
11
|
+
import { Effect } from "effect";
|
|
12
|
+
import { packageDir, resolveFrom } from "@orthograph/compiler";
|
|
13
|
+
import { MountRefused } from "./types.js";
|
|
14
|
+
import { firstPicks, mountFile } from "./internal/scaffold.js";
|
|
15
|
+
import { THREE_DAYS_MS, ageOf, excluded, fromRegistry } from "./internal/age.js";
|
|
16
|
+
import { needLines } from "./internal/needs.js";
|
|
17
|
+
const NAME = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
|
18
|
+
const FOLDERS = { feature: "features", adapter: "adapters", projection: "projections" };
|
|
19
|
+
const refuse = (message) => Effect.fail(new MountRefused({ message }));
|
|
20
|
+
const an = (kind) => (/^[aeiou]/.test(kind) ? `an ${kind}` : `a ${kind}`);
|
|
21
|
+
const readJson = (file) => JSON.parse(readFileSync(file, "utf8"));
|
|
22
|
+
/** A registry's JSON over HTTP, for R1's publish time. */
|
|
23
|
+
export const httpJson = (url) => Effect.tryPromise({ try: () => fetch(url).then((r) => (r.ok ? r.json() : Promise.reject(new Error(`${r.status}`)))), catch: (e) => `${url}: ${String(e)}` });
|
|
24
|
+
/** `add`, reading registry release times through `fetchJson`. */
|
|
25
|
+
export const mountingWith = (fetchJson) => ({
|
|
26
|
+
add: ({ root, kind, pkg, as, dryRun, registry }) => Effect.gen(function* () {
|
|
27
|
+
const name = as ?? pkg.slice(pkg.lastIndexOf("/") + 1);
|
|
28
|
+
if (!NAME.test(name))
|
|
29
|
+
return yield* refuse(`"${name}" isn't a mount name: lowercase words joined by dashes, like ${pkg.slice(pkg.lastIndexOf("/") + 1)}; nothing was written`);
|
|
30
|
+
const dir = packageDir(root, pkg);
|
|
31
|
+
if (!dir)
|
|
32
|
+
return yield* refuse(`${pkg} isn't installed: pnpm add --save-exact ${pkg}, then run this again; nothing was written`);
|
|
33
|
+
const installed = readJson(join(dir, "package.json"));
|
|
34
|
+
const version = installed.version ?? "0.0.0";
|
|
35
|
+
const actual = installed.orthograph?.kind;
|
|
36
|
+
if (!installed.orthograph)
|
|
37
|
+
return yield* refuse(`${pkg} is not a plugin: its package.json has no "orthograph" key; nothing was written`);
|
|
38
|
+
if (actual !== kind)
|
|
39
|
+
return yield* refuse(`${pkg} is ${an(actual ?? "unknown kind")}, not ${an(kind)}: ortho add ${actual} ${pkg}; nothing was written`);
|
|
40
|
+
const file = `blueprint/${FOLDERS[kind]}/${name}.ts`;
|
|
41
|
+
if (existsSync(join(root, file)))
|
|
42
|
+
return yield* refuse(`${file} already exists, so nothing was written: it is yours, edit it, or mount with --as <another name>`);
|
|
43
|
+
const descriptor = (yield* Effect.tryPromise({ try: () => import(__rewriteRelativeImportExtension(resolveFrom(root, pkg))), catch: (e) => new MountRefused({ message: `${pkg}: its root export can't be loaded: ${String(e)}` }) }))["default"];
|
|
44
|
+
const registered = fromRegistry(root, pkg, version);
|
|
45
|
+
let aged = "local: no registry release to age";
|
|
46
|
+
if (registered) {
|
|
47
|
+
const age = yield* ageOf(fetchJson, registry, pkg, version).pipe(Effect.mapError((why) => new MountRefused({ message: `${pkg} ${version}: R1 needs its publish time, and ${why}` })));
|
|
48
|
+
if (age < THREE_DAYS_MS && !excluded(root).includes(pkg)) {
|
|
49
|
+
return yield* refuse(`${pkg} ${version} was published ${Math.floor(age / 3_600_000)} hours ago, under R1's three days: wait, or name it in minimumReleaseAgeExclude with its reason`);
|
|
50
|
+
}
|
|
51
|
+
aged = `published ${Math.floor(age / 86_400_000)} days ago`;
|
|
52
|
+
}
|
|
53
|
+
const needs = yield* needLines(root, descriptor);
|
|
54
|
+
const content = mountFile(pkg, version, firstPicks(descriptor?.choices));
|
|
55
|
+
if (dryRun)
|
|
56
|
+
return { lines: [`would write ${file}`, `would pin ${pkg} ${version} (${aged})`, ...needs, "(dry run: nothing written)"] };
|
|
57
|
+
yield* Effect.sync(() => {
|
|
58
|
+
mkdirSync(dirname(join(root, file)), { recursive: true });
|
|
59
|
+
writeFileSync(join(root, file), content);
|
|
60
|
+
// Pinned exactly where the project lists it, or as a dependency when it doesn't.
|
|
61
|
+
const manifest = readJson(join(root, "package.json"));
|
|
62
|
+
if (manifest.devDependencies && pkg in manifest.devDependencies)
|
|
63
|
+
manifest.devDependencies[pkg] = version;
|
|
64
|
+
else
|
|
65
|
+
manifest.dependencies = { ...manifest.dependencies, [pkg]: version };
|
|
66
|
+
writeFileSync(join(root, "package.json"), JSON.stringify(manifest, null, 2) + "\n");
|
|
67
|
+
});
|
|
68
|
+
return { lines: [`wrote ${file}`, `pinned ${pkg} ${version} (${aged})`, ...needs, "next ortho generate, then ortho check"] };
|
|
69
|
+
}),
|
|
70
|
+
});
|
|
71
|
+
export const Mounting = mountingWith(httpJson);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Effect } from "effect";
|
|
2
|
+
export type Kind = "feature" | "adapter" | "projection";
|
|
3
|
+
export interface AddPlugin {
|
|
4
|
+
readonly root: string;
|
|
5
|
+
readonly kind: Kind;
|
|
6
|
+
readonly pkg: string;
|
|
7
|
+
/** The mount's name, when it isn't the plugin's own. */
|
|
8
|
+
readonly as?: string;
|
|
9
|
+
readonly dryRun: boolean;
|
|
10
|
+
/** Where registry releases are read: `npm_config_registry`, or npm's. */
|
|
11
|
+
readonly registry: string;
|
|
12
|
+
}
|
|
13
|
+
/** What was written, or would be: its lines, in order. */
|
|
14
|
+
export interface Added {
|
|
15
|
+
readonly lines: ReadonlyArray<string>;
|
|
16
|
+
}
|
|
17
|
+
declare const MountRefused_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
18
|
+
readonly _tag: "MountRefused";
|
|
19
|
+
} & Readonly<A>;
|
|
20
|
+
/** Refused before anything is written, saying why and what to run instead. */
|
|
21
|
+
export declare class MountRefused extends MountRefused_base<{
|
|
22
|
+
readonly message: string;
|
|
23
|
+
}> {
|
|
24
|
+
}
|
|
25
|
+
export interface MountingApi {
|
|
26
|
+
readonly add: (request: AddPlugin) => Effect.Effect<Added, MountRefused>;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Mounting a plugin: `ortho add feature|adapter|projection <package>` writes one mount file, pins the installed version
|
|
2
|
+
// exactly (R1's three days for a registry release), and says what the plugin needs (M1-plugins section 11).
|
|
3
|
+
import { Data } from "effect";
|
|
4
|
+
/** Refused before anything is written, saying why and what to run instead. */
|
|
5
|
+
export class MountRefused extends Data.TaggedError("MountRefused") {
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { NewRefused } from "../types.ts";
|
|
3
|
+
/** The description's text: from a URL (asking for JSON or YAML) or from a file. */
|
|
4
|
+
export declare const read: (from: string) => Effect.Effect<string, NewRefused, never>;
|
|
5
|
+
/** JSON first (exact and quick for the big ones), then YAML. */
|
|
6
|
+
export declare const parsed: (from: string, text: string) => Effect.Effect<unknown, NewRefused, never>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Where a description comes from, and how it is read: a file or an http(s) URL, JSON or YAML.
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import { parse } from "yaml";
|
|
5
|
+
import { NewRefused } from "../types.js";
|
|
6
|
+
const isUrl = (from) => /^https?:\/\//.test(from);
|
|
7
|
+
/** The description's text: from a URL (asking for JSON or YAML) or from a file. */
|
|
8
|
+
export const read = (from) => isUrl(from)
|
|
9
|
+
? Effect.tryPromise({
|
|
10
|
+
try: () => fetch(from, { headers: { accept: "application/json, application/yaml, text/yaml, */*" } }).then((r) => (r.ok ? r.text() : Promise.reject(new Error(`status ${r.status}`)))),
|
|
11
|
+
catch: (e) => new NewRefused({ message: `could not read ${from}: ${String(e)}` }),
|
|
12
|
+
})
|
|
13
|
+
: Effect.try({ try: () => readFileSync(from, "utf8"), catch: (e) => new NewRefused({ message: `could not read ${from}: ${e instanceof Error ? e.message : String(e)}` }) });
|
|
14
|
+
/** JSON first (exact and quick for the big ones), then YAML. */
|
|
15
|
+
export const parsed = (from, text) => Effect.try({ try: () => JSON.parse(text), catch: (e) => e }).pipe(Effect.catch(() => Effect.try({ try: () => parse(text, { maxAliasCount: -1 }), catch: (e) => e })), Effect.mapError((e) => new NewRefused({ message: `could not parse ${from} as JSON or YAML: ${e instanceof Error ? e.message.split("\n")[0] : String(e)}` })));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import { Adapter } from "@orthograph/generators/adapter";
|
|
5
|
+
import { NewRefused } from "./types.js";
|
|
6
|
+
import { parsed, read } from "./internal/read.js";
|
|
7
|
+
const adapter = ({ root, name, from }) => Effect.gen(function* () {
|
|
8
|
+
if (!Adapter.isName(name))
|
|
9
|
+
return yield* new NewRefused({ message: `${JSON.stringify(name)} isn't a name for an adapter: use lower case words joined by dashes, like github or error-tracking` });
|
|
10
|
+
const spec = yield* parsed(from, yield* read(from));
|
|
11
|
+
const made = yield* Adapter.generate({ name, spec }).pipe(Effect.mapError((e) => new NewRefused({ message: `${from}: ${e.message}` })));
|
|
12
|
+
const dir = join(root, "plugins", name);
|
|
13
|
+
yield* Effect.try({
|
|
14
|
+
try: () => {
|
|
15
|
+
for (const f of made.files) {
|
|
16
|
+
const file = join(dir, f.path);
|
|
17
|
+
if (f.how === "scaffold" && existsSync(file))
|
|
18
|
+
continue;
|
|
19
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
20
|
+
writeFileSync(file, f.content);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
catch: (e) => new NewRefused({ message: `could not write ${dir}: ${String(e)}` }),
|
|
24
|
+
});
|
|
25
|
+
return [`wrote plugins/${name}/ (${made.files.length} files; generated ones are put back by running this again, scaffolds are yours)`,
|
|
26
|
+
`generated adapter ${name}: ${made.calls} calls, ${made.events} events from ${made.title} ${made.version}`];
|
|
27
|
+
});
|
|
28
|
+
export const New = { adapter };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Effect } from "effect";
|
|
2
|
+
declare const NewRefused_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
3
|
+
readonly _tag: "NewRefused";
|
|
4
|
+
} & Readonly<A>;
|
|
5
|
+
/** Nothing was written: the message says what is wrong with the name, the description or where it was to be read from. */
|
|
6
|
+
export declare class NewRefused extends NewRefused_base<{
|
|
7
|
+
readonly message: string;
|
|
8
|
+
}> {
|
|
9
|
+
}
|
|
10
|
+
export interface NewApi {
|
|
11
|
+
/**
|
|
12
|
+
* Reads the description (a file, or an http(s) URL; JSON or YAML), makes the adapter and writes it to
|
|
13
|
+
* `<root>/plugins/<name>/`: every generated file put back, a scaffold only where there is none. Nothing is written
|
|
14
|
+
* unless the whole plugin could be made. The last line says what was made.
|
|
15
|
+
*/
|
|
16
|
+
readonly adapter: (input: {
|
|
17
|
+
readonly root: string;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly from: string;
|
|
20
|
+
}) => Effect.Effect<ReadonlyArray<string>, NewRefused>;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// `ortho new adapter <name> --from-openapi <file or URL>`: a plugin generated from a service's own published description.
|
|
2
|
+
import { Data } from "effect";
|
|
3
|
+
/** Nothing was written: the message says what is wrong with the name, the description or where it was to be read from. */
|
|
4
|
+
export class NewRefused extends Data.TaggedError("NewRefused") {
|
|
5
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Whether `args` (everything after `ortho`) is a `secrets set` with something on its command line besides NAME, --env and --root. */
|
|
2
|
+
export declare const carriesValue: (args: ReadonlyArray<string>) => boolean;
|
|
3
|
+
export declare const VALUE_REFUSED = "a secret's value is read from stdin, never given on the command line: printf %s \"$VALUE\" | ortho secrets set <NAME> [--env <name>]\n";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// A secret's value on the command line is seen by `ps` and kept in shell history, so `secrets set` takes none: the arguments
|
|
2
|
+
// of `ortho secrets set` are the name, `--env` and `--root`, and anything else is refused here, before the parser can
|
|
3
|
+
// quote it back in an error message. `--help` and `-h` take no value and print the usage, so they pass.
|
|
4
|
+
const OWN = new Set(["--env", "--root"]);
|
|
5
|
+
const HELP = new Set(["--help", "-h"]);
|
|
6
|
+
/** Whether `args` (everything after `ortho`) is a `secrets set` with something on its command line besides NAME, --env and --root. */
|
|
7
|
+
export const carriesValue = (args) => {
|
|
8
|
+
const at = args.findIndex((a, i) => a === "secrets" && args[i + 1] === "set");
|
|
9
|
+
if (at < 0)
|
|
10
|
+
return false;
|
|
11
|
+
let positionals = 0;
|
|
12
|
+
const rest = args.slice(at + 2);
|
|
13
|
+
for (let i = 0; i < rest.length; i++) {
|
|
14
|
+
const arg = rest[i];
|
|
15
|
+
if (OWN.has(arg)) {
|
|
16
|
+
i++;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (HELP.has(arg) || arg.startsWith("--env=") || arg.startsWith("--root="))
|
|
20
|
+
continue;
|
|
21
|
+
if (arg.startsWith("-"))
|
|
22
|
+
return true;
|
|
23
|
+
positionals++;
|
|
24
|
+
}
|
|
25
|
+
return positionals > 1;
|
|
26
|
+
};
|
|
27
|
+
export const VALUE_REFUSED = "a secret's value is read from stdin, never given on the command line: printf %s \"$VALUE\" | ortho secrets set <NAME> [--env <name>]\n";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { Compiler, nodeSource } from "@orthograph/compiler";
|
|
3
|
+
import { Secrets } from "@orthograph/prove";
|
|
4
|
+
import { VALUE_REFUSED, carriesValue } from "./internal/argv.js";
|
|
5
|
+
const refused = (message) => ({ out: "", err: `${message}\n`, exit: 2 });
|
|
6
|
+
/** The model, or the answer that says why there is none. */
|
|
7
|
+
const modelOf = (root) => Compiler.model.pipe(Effect.provide(nodeSource(root)), Effect.mapError((e) => refused(e._tag === "BlueprintInvalid" ? `The blueprint is invalid:\n${e.problems.map((p) => ` - ${p}`).join("\n")}` : e.message)));
|
|
8
|
+
const table = (rows) => {
|
|
9
|
+
const cells = [["NAME", "HOW", "KIND", "STATUS"], ...rows.map((r) => [r.name, r.how, r.kind, r.status])];
|
|
10
|
+
const wide = [0, 1, 2].map((i) => Math.max(...cells.map((c) => c[i].length)));
|
|
11
|
+
return cells.map((c) => [...c.slice(0, 3).map((x, i) => x.padEnd(wide[i] + 2)), c[3]].join("")).join("\n") + "\n";
|
|
12
|
+
};
|
|
13
|
+
export const SecretsCommand = {
|
|
14
|
+
refusesValue: (args) => (carriesValue(args) ? VALUE_REFUSED : undefined),
|
|
15
|
+
list: ({ root, env }) => Effect.gen(function* () {
|
|
16
|
+
const model = yield* modelOf(root);
|
|
17
|
+
const rows = yield* Secrets.rows({ root, env, model }).pipe(Effect.mapError((e) => refused(e.message)));
|
|
18
|
+
return { out: rows.length === 0 ? "no secrets declared\n" : table(rows), err: "", exit: 0 };
|
|
19
|
+
}).pipe(Effect.catch((said) => Effect.succeed(said))),
|
|
20
|
+
set: ({ root, env, name, stdin }) => Effect.gen(function* () {
|
|
21
|
+
const model = yield* modelOf(root);
|
|
22
|
+
const value = stdin.endsWith("\n") ? stdin.slice(0, -1) : stdin;
|
|
23
|
+
yield* Secrets.set({ root, env, name, value, model }).pipe(Effect.mapError((e) => refused(e.message)));
|
|
24
|
+
return { out: `set ${name} in ${env}\n`, err: "", exit: 0 };
|
|
25
|
+
}).pipe(Effect.catch((said) => Effect.succeed(said))),
|
|
26
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Effect } from "effect";
|
|
2
|
+
/** What the command has to say. `main.ts` prints it and exits with `exit`; the module never prints. */
|
|
3
|
+
export interface Said {
|
|
4
|
+
readonly out: string;
|
|
5
|
+
readonly err: string;
|
|
6
|
+
readonly exit: number;
|
|
7
|
+
}
|
|
8
|
+
export interface SecretsCommandApi {
|
|
9
|
+
/** What to say when `args` (everything after `ortho`) put a secret's value on the command line, else nothing. Checked before parsing, so no parser error quotes it. */
|
|
10
|
+
readonly refusesValue: (args: ReadonlyArray<string>) => string | undefined;
|
|
11
|
+
/** One row per declared secret: `NAME how kind status`, after a header. An unknown environment or an invalid blueprint is an answer: exit 2. */
|
|
12
|
+
readonly list: (options: {
|
|
13
|
+
readonly root: string;
|
|
14
|
+
readonly env: string;
|
|
15
|
+
}) => Effect.Effect<Said>;
|
|
16
|
+
/** Keeps `value` (the whole of stdin, less its one final newline) for `name` in `env`. Says `set NAME in <env>` and nothing of the value. */
|
|
17
|
+
readonly set: (options: {
|
|
18
|
+
readonly root: string;
|
|
19
|
+
readonly env: string;
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly stdin: string;
|
|
22
|
+
}) => Effect.Effect<Said>;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { Compiler, nodeSource } from "@orthograph/compiler";
|
|
3
|
+
import { Impact, Publish, Releases } from "@orthograph/prove";
|
|
4
|
+
const NO_LOGBOOK = "no logbook: start one with `ortho env up logbook`, or set ORTHO_LOGBOOK_URL";
|
|
5
|
+
const modelOf = (root) => Compiler.model.pipe(Effect.provide(nodeSource(root)));
|
|
6
|
+
const refused = (err) => ({ out: "", err: `${err.trimEnd()}\n`, exit: 2 });
|
|
7
|
+
/** The logbook's word on the working model; undefined when there is no logbook to ask. */
|
|
8
|
+
const shipping = ({ root, env }, model) => Releases.locate({ root, env }).pipe(Effect.flatMap((logbook) => (logbook === undefined ? Effect.succeed(undefined) : Releases.shipping(logbook, model, root))));
|
|
9
|
+
const next = (options) => modelOf(options.root).pipe(Effect.flatMap((model) => shipping(options, model)), Effect.map((s) => (s === undefined ? refused(NO_LOGBOOK) : { out: `${s.version}\n`, err: "", exit: 0 })), Effect.catchTags({
|
|
10
|
+
ReleaseFailed: (e) => Effect.succeed(refused(e.message)),
|
|
11
|
+
BlueprintInvalid: (e) => Effect.succeed(refused(e.problems.join("\n"))),
|
|
12
|
+
SourceError: (e) => Effect.succeed(refused(e.message)),
|
|
13
|
+
}));
|
|
14
|
+
const impact = (options) => modelOf(options.root).pipe(Effect.flatMap((model) => Impact.of(options.root, model).pipe(Effect.flatMap((local) => shipping(options, model).pipe(Effect.flatMap((s) => (s === undefined ? Effect.succeed(undefined) : Releases.writeChanges(options.root, s).pipe(Effect.as(s)))), Effect.map((s) => ({ out: Impact.lines(local, s).join("\n") + "\n", err: "", exit: 0 })),
|
|
15
|
+
// A logbook that doesn't answer is a warning, never a wrong `stale none`: the local lines are printed as they are.
|
|
16
|
+
Effect.catchTag("ReleaseFailed", (e) => Effect.succeed({ out: Impact.lines(local).join("\n") + "\n", err: `warning: the logbook was not consulted: ${e.message}\n`, exit: 0 })))))), Effect.catchTags({ BlueprintInvalid: (e) => Effect.succeed(refused(e.problems.join("\n"))), SourceError: (e) => Effect.succeed(refused(e.message)) }));
|
|
17
|
+
const changes = (options) => modelOf(options.root).pipe(Effect.flatMap((model) => shipping(options, model)), Effect.flatMap((s) => (s === undefined ? Effect.void : Releases.writeChanges(options.root, s))),
|
|
18
|
+
// `generate` has done its work: a logbook that is down or a blueprint that doesn't compile is not its failure.
|
|
19
|
+
Effect.catch(() => Effect.void));
|
|
20
|
+
const publish = ({ root, env, mode, say }) => Effect.gen(function* () {
|
|
21
|
+
const model = yield* modelOf(root);
|
|
22
|
+
const logbook = yield* Releases.locate({ root, env });
|
|
23
|
+
if (logbook === undefined)
|
|
24
|
+
return refused(NO_LOGBOOK);
|
|
25
|
+
if (mode === "local" && Publish.registry(env) === undefined)
|
|
26
|
+
return refused("no registry: set ORTHO_REGISTRY to the registry to publish to (Verdaccio, on this machine)");
|
|
27
|
+
const version = yield* Releases.next(logbook, model);
|
|
28
|
+
yield* Publish.run({ root, env, environment: "production", version, mode: mode === "local" ? "publish" : "dry-run", localTap: true, say });
|
|
29
|
+
return { out: "", err: "", exit: 0 };
|
|
30
|
+
}).pipe(Effect.catchTags({
|
|
31
|
+
ReleaseFailed: (e) => Effect.succeed(refused(e.message)),
|
|
32
|
+
PublishFailed: (e) => Effect.succeed(refused(`publish couldn't run: ${e.message}`)),
|
|
33
|
+
BlueprintInvalid: (e) => Effect.succeed(refused(e.problems.join("\n"))),
|
|
34
|
+
SourceError: (e) => Effect.succeed(refused(e.message)),
|
|
35
|
+
}));
|
|
36
|
+
export const Ship = { next, impact, changes, publish };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Effect } from "effect";
|
|
2
|
+
import type { ReleaseEnv } from "@orthograph/prove";
|
|
3
|
+
/** What a command prints and how it exits; only `main.ts` writes it out. */
|
|
4
|
+
export interface Said {
|
|
5
|
+
readonly out: string;
|
|
6
|
+
readonly err: string;
|
|
7
|
+
readonly exit: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ShipOptions {
|
|
10
|
+
readonly root: string;
|
|
11
|
+
/** The process environment, passed in because only `main.ts` reads it. */
|
|
12
|
+
readonly env: ReleaseEnv;
|
|
13
|
+
}
|
|
14
|
+
export interface ShipApi {
|
|
15
|
+
/** `ortho version --next`: the version alone on a line. Needs a logbook: exit 2 with the way to start one when there is none. */
|
|
16
|
+
readonly next: (options: ShipOptions) => Effect.Effect<Said>;
|
|
17
|
+
/**
|
|
18
|
+
* `ortho impact`: what changed, what is stale and what is proven. With a logbook: `next <version>` and
|
|
19
|
+
* `stale <ops> in <envs>` (or `stale none`) from its `main` verdicts, and `generated/model/changes.json` written. Without
|
|
20
|
+
* one, or when it doesn't answer, only the local ledger's lines (the second case with a warning on stderr).
|
|
21
|
+
*/
|
|
22
|
+
readonly impact: (options: ShipOptions) => Effect.Effect<Said>;
|
|
23
|
+
/**
|
|
24
|
+
* `ortho publish --dry-run | --local`: the generated SDK and CLI at the version `ortho version --next` says, as
|
|
25
|
+
* production's `publish` list names them. `dry-run` lists exactly what would go out and sends nothing; `local` sends the
|
|
26
|
+
* packages to the registry in `ORTHO_REGISTRY`, builds the CLI binary for this machine, and commits the formula to the
|
|
27
|
+
* tap (`ORTHO_TAP_REPO`, else `.ortho/tap/`). Each line is said as it happens; the result is the exit and any error.
|
|
28
|
+
*/
|
|
29
|
+
readonly publish: (options: ShipOptions & {
|
|
30
|
+
readonly mode: "dry-run" | "local";
|
|
31
|
+
readonly say: (line: string) => Effect.Effect<void>;
|
|
32
|
+
}) => Effect.Effect<Said>;
|
|
33
|
+
/** After `ortho generate`: write `generated/model/changes.json` when a logbook answers; silent when there is none. */
|
|
34
|
+
readonly changes: (options: ShipOptions) => Effect.Effect<void>;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { StagingRefused } from "../types.ts";
|
|
3
|
+
export interface Address {
|
|
4
|
+
readonly url: string;
|
|
5
|
+
/** What a refusal calls it: `run r4417`. */
|
|
6
|
+
readonly label: string;
|
|
7
|
+
/** `ortho-<app>-stg-<run>`: the name every resource of the run starts with. */
|
|
8
|
+
readonly prefix: string;
|
|
9
|
+
/** Whether a name (a database's) belongs to the run. */
|
|
10
|
+
readonly owns: (name: string) => boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The address to judge, or why there is none. `origin` (`ORTHO_STAGING_ORIGIN`) is used as it is, when it is on this machine, and then
|
|
14
|
+
* the subdomain (`ORTHO_STAGING_SUBDOMAIN`) is not needed. Nothing is contacted here.
|
|
15
|
+
*/
|
|
16
|
+
export declare const proveAddress: (options: {
|
|
17
|
+
readonly root: string;
|
|
18
|
+
readonly run: string | undefined;
|
|
19
|
+
readonly subdomain: string | undefined;
|
|
20
|
+
readonly origin: string | undefined;
|
|
21
|
+
}) => Effect.Effect<Address, StagingRefused>;
|