@theholocron/cli 5.0.0-alpha.475 → 5.0.0-alpha.477

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/README.md CHANGED
@@ -499,7 +499,7 @@ job execute the same thing — at a turbo root both are
499
499
  ### `holocron deploy on-release`
500
500
 
501
501
  ```bash
502
- holocron deploy on-release [--channel <alpha|main>] [--from <commit>] [--to <commit>] [--dry-run]
502
+ holocron deploy on-release [--channel <alpha|main>] [--from <commit>] [--to <commit>] [--record-file <file>] [--record] [--dry-run]
503
503
  ```
504
504
 
505
505
  Deploys every workspace package whose own `holocron.config` declares
@@ -514,14 +514,19 @@ doesn't succeed exits non-zero. The shared `release` workflow runs it as its own
514
514
  `deploy` job after the release job (opt in with `deploy-on-release: true`).
515
515
 
516
516
  Each package is compared from the commit it was last deployed at, not only from
517
- `--from`: a successful deploy moves a `deployed/<package>` tag
518
- (`@theholocron/sentinel` is `deployed/theholocron-sentinel`) to the release
519
- commit and pushes it, so a release whose deploy job failed is made up by the next
520
- release, even one that touches nothing in the app. A package with no tag yet (or
521
- one whose tag is not an ancestor of `--to`) falls back to `--from`, and the skip
522
- line then says `No deploy is recorded for it yet.` A tag that cannot be pushed is
523
- a warning, not a failed deploy. `--dry-run` writes no tag; the deploy job needs
524
- `contents: write`.
517
+ `--from`: a successful deploy is recorded as a `deployed/<package>` tag
518
+ (`@theholocron/sentinel` is `deployed/theholocron-sentinel`) at the release
519
+ commit, so a release whose deploy job failed is made up by the next release,
520
+ even one that touches nothing in the app. A package with no tag yet (or one
521
+ whose tag is not an ancestor of `--to`) falls back to `--from`, and the skip line
522
+ then says `No deploy is recorded for it yet.`
523
+
524
+ The tag is written by a second step, so the deploy script never holds a write
525
+ token. `--record-file <file>` makes the deploy list the packages that deployed
526
+ (failed ones are left out) and write no tag; `--record --record-file <file>` then
527
+ tags and pushes them, reading the token from `GITHUB_TOKEN` and handing it to
528
+ `git push` in that command's environment only. A tag that cannot be pushed fails
529
+ that step, naming the package. `--dry-run` writes nothing.
525
530
 
526
531
  ### `holocron run ci`
527
532
 
package/dist/cli.mjs CHANGED
@@ -14,7 +14,7 @@ import { appendFileSync, copyFileSync, existsSync, fstatSync, mkdirSync, mkdtemp
14
14
  import { DRY_RUN_NOOP_EXIT_CODE, createCommandRegistry, createMenu, numeric } from "@theholocron/kyber/menu";
15
15
  import { Entry, findCredentials } from "@napi-rs/keyring";
16
16
  import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver as createFeatureResolver$1, createKeyring, dotenvLine, findCredential, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, resolveValue as resolveValue$1, resolveValue as resolveValue$2, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
17
- import { DEFAULT_ORG, DOCUMENTATION_FLAG, DOT_GITHUB_REPO, HOLOCRON_REPO, KNOWN_TASKS, KNOWN_WORKFLOWS, LEGACY_NAMES, PNPM_BUILTIN_COMMANDS, PRERELEASE_CHANNEL, RELEASE_BRANCHES, RESERVED_SCRIPT_NAMES, SUITES, TASKS, aggregateChecks, checkPackageScripts, checkReleaseLines, codecovFlagNames, createAstromech, createCommitMsg, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, describeTasks, extractPreviewConfig, formatJson, frozenReusablePaths, generateThinCallerContent, hostedReusableWorkflows, isDeprecated, isTask, legacyCaller, legacyCallerFile, legacyGate, legacyWorkflowKey, localize, localizeActions, mergeScripts, packageLocation, readWorkspacePackages, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, wedgeFix, workflowFile, workflowKey, workflowKeys, workspacePackages as workspacePackages$1 } from "@theholocron/astromech";
17
+ import { DEFAULT_ORG, DOCUMENTATION_FLAG, DOT_GITHUB_REPO, HOLOCRON_REPO, KNOWN_TASKS, KNOWN_WORKFLOWS, LEGACY_NAMES, PNPM_BUILTIN_COMMANDS, PRERELEASE_CHANNEL, RELEASE_BRANCHES, RESERVED_SCRIPT_NAMES, SUITES, TASKS, aggregateChecks, checkPackageScripts, checkReleaseLines, codecovFlagNames, createAstromech, createCommitMsg, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, describeTasks, extractPreviewConfig, formatJson, frozenReusablePaths, generateThinCallerContent, hostedReusableWorkflows, isDeprecated, isTask, legacyCaller, legacyCallerFile, legacyGate, legacyWorkflowKey, localize, localizeActions, mergeScripts, packageLocation, readWorkspacePackages, recordDeploys, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, wedgeFix, workflowFile, workflowKey, workflowKeys, workspacePackages as workspacePackages$1 } from "@theholocron/astromech";
18
18
  import { loadTasksConfig, releaseGroups } from "@theholocron/astromech/config";
19
19
  import { createCliLogger, createCliTelemetry } from "@theholocron/kyber/observability";
20
20
  import { resolveAxiomFromEnv } from "@theholocron/observability/logger";
@@ -86,6 +86,7 @@ const COMMAND_CONTEXTS = {
86
86
  "new secret": "workspace",
87
87
  "sync secrets": "workspace",
88
88
  "new tunnel": "workspace",
89
+ "new domain": "workspace",
89
90
  "list projects": "workspace",
90
91
  "new project": "workspace",
91
92
  "close project": "workspace",
@@ -333,7 +334,9 @@ const deployOnReleaseEntry = {
333
334
  "files",
334
335
  "channel",
335
336
  "from",
336
- "to"
337
+ "to",
338
+ "record-file",
339
+ "record"
337
340
  ],
338
341
  supportsDryRun: true
339
342
  };
@@ -790,6 +793,43 @@ const newRepoEntry = {
790
793
  ],
791
794
  supportsDryRun: true
792
795
  };
796
+ // src/commands/new-domain/new-domain.entry.ts
797
+ const newDomainEntry = {
798
+ name: "new domain",
799
+ description: "Make a DNS record through the `dns` provider and keep it in .holocron/dns-records.json",
800
+ positionals: [],
801
+ options: [
802
+ {
803
+ key: "type",
804
+ flag: "--type",
805
+ type: "input",
806
+ message: "Type (CNAME, TXT, A or AAAA):",
807
+ required: true
808
+ },
809
+ {
810
+ key: "name",
811
+ flag: "--name",
812
+ type: "input",
813
+ message: "Hostname (e.g. status.example.dev):",
814
+ required: true
815
+ },
816
+ {
817
+ key: "value",
818
+ flag: "--value",
819
+ type: "input",
820
+ message: "Value, as the vendor shows it:",
821
+ required: true
822
+ },
823
+ {
824
+ key: "note",
825
+ flag: "--note",
826
+ type: "input",
827
+ message: "Note (which vendor serves it):"
828
+ }
829
+ ],
830
+ skipOptions: ["proxied", "yes"],
831
+ supportsDryRun: true
832
+ };
793
833
  // src/commands/notifications-channel-add/notifications-channel-add.entry.ts
794
834
  const notificationsChannelAddEntry = {
795
835
  name: "new channel",
@@ -1565,6 +1605,7 @@ const registry = createCommandRegistry([
1565
1605
  ],
1566
1606
  supportsDryRun: true
1567
1607
  },
1608
+ newDomainEntry,
1568
1609
  projectListEntry,
1569
1610
  projectCreateEntry,
1570
1611
  projectCloseEntry,
@@ -5930,6 +5971,13 @@ const deployOnReleaseArgs = (y) => y.option("channel", {
5930
5971
  }).option("to", {
5931
5972
  type: "string",
5932
5973
  describe: "The release commit. Default HEAD."
5974
+ }).option("record-file", {
5975
+ type: "string",
5976
+ describe: "A file the deploy lists the packages it deployed in (and `--record` reads), so a later step tags them."
5977
+ }).option("record", {
5978
+ type: "boolean",
5979
+ default: false,
5980
+ describe: "Tag and push the `deployed/<package>` marker of each package in --record-file, using GITHUB_TOKEN. Deploys nothing."
5933
5981
  });
5934
5982
  // src/commands/deploy/deploy-on-release.command.ts
5935
5983
  const deployOnReleaseCommand = {
@@ -5937,13 +5985,25 @@ const deployOnReleaseCommand = {
5937
5985
  describe: "Deploy every workspace package whose delivery.deploy task is `on: release` — run by the delivery.publish workflow's deploy job",
5938
5986
  builder: deployOnReleaseArgs,
5939
5987
  handler: async (argv) => {
5988
+ const print = (line) => console.log(line);
5989
+ if (argv.record) {
5990
+ if (recordDeploys({
5991
+ cwd: argv.cwd,
5992
+ file: argv.recordFile ?? "",
5993
+ token: createEnvLookup().get("GITHUB_TOKEN"),
5994
+ dryRun: argv.dryRun,
5995
+ print
5996
+ }).status === "fail") process.exitCode = 1;
5997
+ return;
5998
+ }
5940
5999
  if ((await deployOnRelease({
5941
6000
  cwd: argv.cwd,
5942
6001
  channel: argv.channel,
5943
6002
  ...argv.from ? { from: argv.from } : {},
5944
6003
  ...argv.to ? { to: argv.to } : {},
6004
+ ...argv.recordFile ? { recordFile: argv.recordFile } : {},
5945
6005
  dryRun: argv.dryRun,
5946
- print: (line) => console.log(line)
6006
+ print
5947
6007
  })).status === "fail") process.exitCode = 1;
5948
6008
  }
5949
6009
  };
@@ -6970,6 +7030,86 @@ const doctorCiCommand = {
6970
7030
  })).status === "fail") process.exitCode = 1;
6971
7031
  }
6972
7032
  };
7033
+ // src/dns-records/disk-io/disk-io.ts
7034
+ /** The file system the list lives on. */
7035
+ const diskIo = {
7036
+ read: (path) => readFile(path, "utf8").catch((err) => {
7037
+ if (err.code === "ENOENT") return null;
7038
+ throw err;
7039
+ }),
7040
+ write: async (path, text) => {
7041
+ await mkdir(dirname(path), { recursive: true });
7042
+ await writeFile(path, text, "utf8");
7043
+ }
7044
+ };
7045
+ // src/dns-records/dns-records.type.ts
7046
+ /** The list's file, relative to the repository root. */
7047
+ const DNS_RECORDS_FILE = ".holocron/dns-records.json";
7048
+ /** The record types `holocron new domain` takes. MX and SRV need a priority the entry does not carry. */
7049
+ const DNS_ENTRY_TYPES = [
7050
+ "CNAME",
7051
+ "TXT",
7052
+ "A",
7053
+ "AAAA"
7054
+ ];
7055
+ // src/dns-records/parse-dns-records/parse-dns-records.ts
7056
+ /** The list in `text`, or a `ConfigError` naming the entry that is wrong. An empty file is an empty list. */
7057
+ function parseDnsRecords(text, file) {
7058
+ if (text.trim() === "") return [];
7059
+ let raw;
7060
+ try {
7061
+ raw = JSON.parse(text);
7062
+ } catch (err) {
7063
+ throw new ConfigError$1(`${file} is not JSON: ${errorMessage(err)}`);
7064
+ }
7065
+ if (!Array.isArray(raw)) throw new ConfigError$1(`${file} must hold an array of records`);
7066
+ return raw.map((item, i) => {
7067
+ const at = `${file} entry ${i + 1}`;
7068
+ if (typeof item !== "object" || item === null) throw new ConfigError$1(`${at} must be an object`);
7069
+ const e = item;
7070
+ const type = DNS_ENTRY_TYPES.find((t) => t === e.type);
7071
+ if (!type) throw new ConfigError$1(`${at}: type must be one of ${DNS_ENTRY_TYPES.join(", ")}`);
7072
+ for (const key of ["name", "value"]) if (typeof e[key] !== "string" || e[key] === "") throw new ConfigError$1(`${at}: ${key} must be a non-empty string`);
7073
+ if (e.note !== void 0 && typeof e.note !== "string") throw new ConfigError$1(`${at}: note must be a string`);
7074
+ if (e.proxied !== void 0 && typeof e.proxied !== "boolean") throw new ConfigError$1(`${at}: proxied must be true or false`);
7075
+ return {
7076
+ type,
7077
+ name: e.name,
7078
+ value: e.value,
7079
+ ...e.note !== void 0 ? { note: e.note } : {},
7080
+ ...e.proxied !== void 0 ? { proxied: e.proxied } : {}
7081
+ };
7082
+ });
7083
+ }
7084
+ // src/dns-records/read-dns-records/read-dns-records.ts
7085
+ /** The records `.holocron/dns-records.json` lists; none when the file is absent. */
7086
+ async function readDnsRecords(repoRoot, io = diskIo) {
7087
+ const text = await io.read(join(repoRoot, DNS_RECORDS_FILE));
7088
+ return text === null ? [] : parseDnsRecords(text, DNS_RECORDS_FILE);
7089
+ }
7090
+ // src/dns-records/upsert-dns-entry/upsert-dns-entry.ts
7091
+ /** An entry's identity: its type and its name, without case or a final dot. */
7092
+ const entryKey = (e) => `${e.type} ${e.name.toLowerCase().replace(/\.$/, "")}`;
7093
+ /**
7094
+ * The list with `entry` in it: a new entry goes last, one with the same type and name takes its place (order kept)
7095
+ * and is returned as `replaced`. The list given is not changed.
7096
+ */
7097
+ function upsertDnsEntry(list, entry) {
7098
+ const at = list.findIndex((e) => entryKey(e) === entryKey(entry));
7099
+ if (at === -1) return {
7100
+ list: [...list, entry],
7101
+ replaced: void 0
7102
+ };
7103
+ return {
7104
+ list: list.map((e, i) => i === at ? entry : e),
7105
+ replaced: list[at]
7106
+ };
7107
+ }
7108
+ // src/dns-records/write-dns-records/write-dns-records.ts
7109
+ /** Write the list the way Prettier lays JSON out, so a rewrite leaves the file formatted. */
7110
+ async function writeDnsRecords(repoRoot, list, io = diskIo) {
7111
+ await io.write(join(repoRoot, DNS_RECORDS_FILE), formatJson(list));
7112
+ }
6973
7113
  // src/commands/missing-token/missing-token.ts
6974
7114
  /**
6975
7115
  * Why a provider call could not be tried for want of a token, or undefined when the error is something else. A plugin
@@ -7210,10 +7350,35 @@ async function runDoctorDns(input) {
7210
7350
  ...loader.has("wiki") ? { wiki: loader.get("wiki") } : {},
7211
7351
  layouts: (loader.has("notifications") ? loader.get("notifications") : []).flatMap((p) => p.layout ? [p.layout] : [])
7212
7352
  });
7353
+ let listFailure;
7354
+ const listed = await readDnsRecords(input.context.repoRoot, input.io).catch((err) => {
7355
+ listFailure = errorMessage(err);
7356
+ return [];
7357
+ });
7358
+ const apex = input.loaded.resolved.domain;
7359
+ for (const e of listed) {
7360
+ const zone = apex && (e.name === apex || e.name.endsWith(`.${apex}`)) ? apex : e.name;
7361
+ expected.push({
7362
+ zone,
7363
+ record: {
7364
+ type: e.type,
7365
+ name: e.name,
7366
+ content: e.value,
7367
+ proxied: e.proxied ?? false
7368
+ }
7369
+ });
7370
+ }
7213
7371
  const zones = [...new Set(expected.map((e) => e.zone))];
7214
7372
  const deploy = loader.has("deployment") ? loader.get("deployment") : void 0;
7215
7373
  const domains = deploy?.expectedDomainRecord ? deploymentDomains(input.loaded.resolved, deploy) : [];
7216
7374
  const rows = [];
7375
+ if (listFailure !== void 0) rows.push({
7376
+ id: "dns-records-file",
7377
+ title: "dns-records.json reads",
7378
+ status: "fail",
7379
+ detail: listFailure,
7380
+ problems: []
7381
+ });
7217
7382
  if (zones.length === 0 && domains.length === 0) rows.push({
7218
7383
  id: "dns",
7219
7384
  title: "dns",
@@ -16986,6 +17151,65 @@ function describeProviderError(err) {
16986
17151
  if (said === void 0 || !(err instanceof Error)) return describeError(err);
16987
17152
  return describeError(Object.assign(new Error(err.message), { details: said }));
16988
17153
  }
17154
+ // src/commands/setup/dns-records-step/dns-records-step.ts
17155
+ /**
17156
+ * `holocron setup`'s step for the records `holocron new domain` keeps in `.holocron/dns-records.json` (spec
17157
+ * `tech-new-domain-command`). Each is made through the `dns` provider, DNS-only unless the entry says `proxied`; an
17158
+ * upsert leaves a record that is already right as it is. With no `dns` provider each is a failing `todo` row that says
17159
+ * what to make. `--dry-run` writes nothing. Never deletes. No list, no steps; a list that cannot be read is one
17160
+ * failing row.
17161
+ */
17162
+ async function dnsRecordsStep(loader, repoRoot, dryRun, io) {
17163
+ let list;
17164
+ try {
17165
+ list = await readDnsRecords(repoRoot, io);
17166
+ } catch (err) {
17167
+ return [{
17168
+ capability: "dns",
17169
+ step: "read dns-records.json",
17170
+ status: "fail",
17171
+ message: errorMessage(err)
17172
+ }];
17173
+ }
17174
+ const steps = [];
17175
+ for (const e of list) {
17176
+ const step = `dns ${e.type} ${e.name}`;
17177
+ if (dryRun) steps.push({
17178
+ capability: "dns",
17179
+ step,
17180
+ status: "dry-run",
17181
+ message: "would make the record"
17182
+ });
17183
+ else if (!loader.has("dns")) steps.push({
17184
+ capability: "dns",
17185
+ step,
17186
+ status: "fail",
17187
+ message: `todo: no \`dns\` provider is configured; make ${e.type} ${e.name} -> ${e.value}`
17188
+ });
17189
+ else try {
17190
+ await loader.get("dns").upsertRecord(e.name, {
17191
+ type: e.type,
17192
+ name: e.name,
17193
+ content: e.value,
17194
+ proxied: e.proxied ?? false
17195
+ });
17196
+ steps.push({
17197
+ capability: "dns",
17198
+ step,
17199
+ status: "ok",
17200
+ message: `made${e.proxied ? "" : " (DNS only)"}${e.note ? `: ${e.note}` : ""}`
17201
+ });
17202
+ } catch (err) {
17203
+ steps.push({
17204
+ capability: "dns",
17205
+ step,
17206
+ status: "fail",
17207
+ message: describeProviderError(err)
17208
+ });
17209
+ }
17210
+ }
17211
+ return steps;
17212
+ }
16989
17213
  // src/commands/setup/engineering.ts
16990
17214
  async function writeIfAbsent(filePath, content) {
16991
17215
  try {
@@ -17889,6 +18113,14 @@ async function runSetup(input) {
17889
18113
  print(formatStep(steps[steps.length - 1]));
17890
18114
  }
17891
18115
  }
18116
+ const dnsSteps = await dnsRecordsStep(loader, input.context.repoRoot, dryRun);
18117
+ if (dnsSteps.length > 0) {
18118
+ print(style.step("dns"));
18119
+ for (const step of dnsSteps) {
18120
+ steps.push(step);
18121
+ print(formatStep(step));
18122
+ }
18123
+ }
17892
18124
  if (loader.has("monitoring")) {
17893
18125
  const monitoring = loader.get("monitoring");
17894
18126
  print(style.step("monitoring"));
@@ -19805,6 +20037,170 @@ const issueCreateCommand = {
19805
20037
  })).status === "fail") process.exitCode = 1;
19806
20038
  }
19807
20039
  };
20040
+ // src/commands/new-domain/new-domain.ts
20041
+ /**
20042
+ * `holocron new domain` — take a DNS record, make it through the `dns` provider, keep it in the list
20043
+ * (`.holocron/dns-records.json`) that `setup` re-applies and `doctor dns` checks (spec `tech-new-domain-command`).
20044
+ *
20045
+ * Provider-neutral: it calls the `dns` capability's `upsertRecord`, so it names no vendor. A record is DNS-only unless
20046
+ * `--proxied`, because a vendor reads the record itself to verify the name. It shows what will change, asks first
20047
+ * (unless `--yes` or `--dry-run`) and never deletes.
20048
+ */
20049
+ /** A value as comparable text: no case, no final dot, no quotes around a TXT value. */
20050
+ const normal = (v) => v.trim().replace(/^"(.*)"$/s, "$1").replace(/\.$/, "").toLowerCase();
20051
+ async function runNewDomain(input) {
20052
+ const { print, logger, loader } = input;
20053
+ await loader.load();
20054
+ assertPluginsResolvable(loader, "new domain");
20055
+ if (!loader.has("dns")) throw new Error("`dns` capability is not configured: add a `dns` provider to holocron.config");
20056
+ const need = async (field) => {
20057
+ const given = input[field];
20058
+ if (given !== void 0 && given !== "") return given;
20059
+ if (!input.ask) throw new NonInteractiveError(`--${field} is required without a terminal`);
20060
+ return (await input.ask(field)).trim();
20061
+ };
20062
+ const type = (await need("type")).toUpperCase();
20063
+ const kind = DNS_ENTRY_TYPES.find((t) => t === type);
20064
+ if (!kind) throw new Error(`--type must be one of ${DNS_ENTRY_TYPES.join(", ")} (got ${type})`);
20065
+ const name = (await need("name")).toLowerCase().replace(/\.$/, "");
20066
+ const zone = input.loaded.resolved.domain;
20067
+ if (zone && name !== zone && !name.endsWith(`.${zone}`)) throw new Error(`--name must be ${zone} or a name under it (got ${name})`);
20068
+ const value = await need("value");
20069
+ if (value === "") throw new Error("--value is required");
20070
+ const entry = {
20071
+ type: kind,
20072
+ name,
20073
+ value,
20074
+ ...input.note ? { note: input.note } : {},
20075
+ ...input.proxied ? { proxied: true } : {}
20076
+ };
20077
+ const dryRun = input.context.dryRun === true;
20078
+ const dns = loader.get("dns");
20079
+ const { list, replaced } = upsertDnsEntry(await readDnsRecords(input.context.repoRoot, input.io), entry);
20080
+ print(`Holocron new domain — ${entry.type} ${entry.name}${dryRun ? " (dry-run)" : ""}`);
20081
+ try {
20082
+ const held = (await dns.listRecords(entry.name)).filter((r) => r.type === entry.type && normal(r.name) === normal(entry.name));
20083
+ const same = held.some((r) => normal(r.content) === normal(entry.value) && r.proxied === true === (entry.proxied ?? false));
20084
+ print(held.length === 0 ? ` + ${entry.type} ${entry.name} -> ${entry.value} is new` : same ? ` = ${entry.type} ${entry.name} already holds that value` : ` ~ ${entry.type} ${entry.name} holds ${held[0].content}; it would become ${entry.value}`);
20085
+ if (replaced) print(` ~ the list already has this record (${replaced.value}); its entry is replaced`);
20086
+ if (dryRun) return {
20087
+ status: "dry-run",
20088
+ entry,
20089
+ message: "nothing written"
20090
+ };
20091
+ if (!input.yes) {
20092
+ if (!input.confirm) throw new NonInteractiveError("pass --yes to make the record without a terminal");
20093
+ if (!await input.confirm(`Make ${entry.type} ${entry.name} (DNS ${entry.proxied ? "proxied" : "only"})?`)) {
20094
+ print(" cancelled; nothing written");
20095
+ return {
20096
+ status: "cancelled",
20097
+ entry
20098
+ };
20099
+ }
20100
+ }
20101
+ const record = {
20102
+ type: entry.type,
20103
+ name: entry.name,
20104
+ content: entry.value,
20105
+ proxied: entry.proxied ?? false
20106
+ };
20107
+ await dns.upsertRecord(entry.name, record);
20108
+ await writeDnsRecords(input.context.repoRoot, list, input.io);
20109
+ print(` ✓ made ${entry.type} ${entry.name} via ${dns.providerName}; kept in .holocron/dns-records.json`);
20110
+ logger.info({
20111
+ type: entry.type,
20112
+ name: entry.name,
20113
+ provider: dns.providerName,
20114
+ status: "ok"
20115
+ }, "new domain");
20116
+ return {
20117
+ status: "ok",
20118
+ entry
20119
+ };
20120
+ } catch (err) {
20121
+ if (err instanceof NonInteractiveError) throw err;
20122
+ const message = errorMessage(err);
20123
+ print(` ✗ ${message}`);
20124
+ logger.warn({
20125
+ type: entry.type,
20126
+ name: entry.name,
20127
+ reason: message
20128
+ }, "new domain");
20129
+ return {
20130
+ status: "fail",
20131
+ entry,
20132
+ message
20133
+ };
20134
+ }
20135
+ }
20136
+ // src/commands/new-domain/new-domain.command.ts
20137
+ const newDomainArgs = (y) => y.option("type", {
20138
+ type: "string",
20139
+ describe: `Record type: ${DNS_ENTRY_TYPES.join(", ")} (asked for on a terminal)`
20140
+ }).option("name", {
20141
+ type: "string",
20142
+ describe: "The full hostname, under the org's domain (asked for on a terminal)"
20143
+ }).option("value", {
20144
+ type: "string",
20145
+ describe: "The record's content, as the vendor shows it (asked for on a terminal)"
20146
+ }).option("note", {
20147
+ type: "string",
20148
+ describe: "Why it exists, e.g. which vendor serves the name"
20149
+ }).option("proxied", {
20150
+ type: "boolean",
20151
+ default: false,
20152
+ describe: "Send traffic through the provider's proxy (default: DNS only, which a vendor's verification needs)"
20153
+ }).option("yes", {
20154
+ type: "boolean",
20155
+ default: false,
20156
+ describe: "Make the record without asking first (required without a terminal)"
20157
+ });
20158
+ /** Ask for one field on a terminal. */
20159
+ async function ask(field) {
20160
+ if (field === "type") return select({
20161
+ message: "Record type:",
20162
+ choices: DNS_ENTRY_TYPES.map((t) => ({ value: t }))
20163
+ });
20164
+ return input({ message: field === "name" ? "Hostname:" : "Value, as the vendor shows it:" });
20165
+ }
20166
+ const newDomainCommand = {
20167
+ command: "domain",
20168
+ describe: "Make a DNS record through the `dns` provider and keep it in .holocron/dns-records.json",
20169
+ builder: newDomainArgs,
20170
+ handler: async (argv) => {
20171
+ const tokens = tokenContext(argv.token);
20172
+ if (!tokens) return;
20173
+ const loaded = await loadConfig(argv.cwd);
20174
+ applyResolvedConfig(argv, loaded.resolved);
20175
+ const terminal = process.stdin.isTTY === true;
20176
+ const context = {
20177
+ repoRoot: argv.cwd,
20178
+ dryRun: argv.dryRun,
20179
+ ...tokens,
20180
+ org: resolveOrg(argv, loaded.resolved)
20181
+ };
20182
+ if ((await runNewDomain({
20183
+ loaded,
20184
+ context,
20185
+ loader: new PluginLoader(loaded.resolved, context),
20186
+ print: (line) => console.log(line),
20187
+ logger: getLogger(),
20188
+ ...argv.type ? { type: argv.type } : {},
20189
+ ...argv.name ? { name: argv.name } : {},
20190
+ ...argv.value ? { value: argv.value } : {},
20191
+ ...argv.note ? { note: argv.note } : {},
20192
+ ...argv.proxied ? { proxied: true } : {},
20193
+ ...argv.yes ? { yes: true } : {},
20194
+ ...terminal ? {
20195
+ ask,
20196
+ confirm: (message) => confirm({
20197
+ message,
20198
+ default: false
20199
+ })
20200
+ } : {}
20201
+ })).status === "fail") process.exitCode = 1;
20202
+ }
20203
+ };
19808
20204
  // src/commands/notifications-channel-add/notifications-channel-add.args.ts
19809
20205
  const notificationsChannelAddArgs = (y) => y.positional("name", {
19810
20206
  type: "string",
@@ -22234,8 +22630,8 @@ const newRepoCommand = {
22234
22630
  // src/commands/new/new.command.ts
22235
22631
  const newCommand = {
22236
22632
  command: "new",
22237
- describe: "Create a repo, plugin, channel, server, secret, token, tunnel, GitHub App, project, spec or issue",
22238
- builder: (y) => y.command(newRepoCommand).command(pluginCreateCommand).command(notificationsChannelAddCommand).command(githubAppCreateCommand).command(projectCreateCommand).command(secretSetCommand).command(notificationsCreateServerCommand).command(ideasPromoteCommand).command(issueCreateCommand).command(authSetCommand).command(tunnelUpCommand).command(groupMenu("new")),
22633
+ describe: "Create a repo, plugin, channel, server, secret, token, tunnel, domain record, GitHub App, project, spec or issue",
22634
+ builder: (y) => y.command(newRepoCommand).command(pluginCreateCommand).command(notificationsChannelAddCommand).command(githubAppCreateCommand).command(projectCreateCommand).command(secretSetCommand).command(notificationsCreateServerCommand).command(ideasPromoteCommand).command(issueCreateCommand).command(authSetCommand).command(tunnelUpCommand).command(newDomainCommand).command(groupMenu("new")),
22239
22635
  handler: () => {}
22240
22636
  };
22241
22637
  // src/commands/probe/probe.args.ts