@theholocron/cli 5.0.0-alpha.476 → 5.0.0-alpha.478
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 +2 -2
- package/dist/cli.mjs +453 -21
- package/dist/cli.mjs.map +1 -1
- package/dist/{index-sbZQbBuu.d.mts → index-BQwudYHb.d.mts} +15 -4
- package/dist/index.d.mts +1 -1
- package/dist/plugin/capabilities.d.mts +1 -1
- package/dist/presets.d.mts +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -740,8 +740,8 @@ See the [command pages](https://theholocron.dev/holocron/commands/setup-notifica
|
|
|
740
740
|
kebab-case, or `--name` as the whole name) with `status: draft`, `issue:`, `blocked-by: []`, no `id`, and the issue's text
|
|
741
741
|
under `## Problem` less the `Filed from idea:` line and the marker. It never overwrites a file, never edits the issue or
|
|
742
742
|
touches the vault, and asks first unless `--dry-run` or `--yes`.
|
|
743
|
-
- **`holocron new issue <title> [--body <text>] [--label <name>]... [--milestone <value>] [--dry-run] [--yes]`** — files an
|
|
744
|
-
issue through the `issues` provider (`Issues.create`: GitHub or Linear) and prints its key. It asks first unless
|
|
743
|
+
- **`holocron new issue <title> [--body <text> | --body-file <path|->] [--label <name>]... [--assignee <login>]... [--milestone <value>] [--dry-run] [--yes]`** — files an
|
|
744
|
+
issue through the `issues` provider (`Issues.create`: GitHub or Linear) and prints its key; what the tracker cannot hold (a second Linear assignee, an unknown user) is listed as not carried across. It asks first unless
|
|
745
745
|
`--dry-run` or `--yes` (without a terminal it refuses instead) and does not look for a duplicate.
|
|
746
746
|
|
|
747
747
|
## Syncing tooling
|
package/dist/cli.mjs
CHANGED
|
@@ -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",
|
|
@@ -585,17 +586,39 @@ const issueCreateEntry = {
|
|
|
585
586
|
message: "Title:",
|
|
586
587
|
type: "input"
|
|
587
588
|
}],
|
|
588
|
-
options: [
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
589
|
+
options: [
|
|
590
|
+
{
|
|
591
|
+
key: "body",
|
|
592
|
+
flag: "--body",
|
|
593
|
+
type: "input",
|
|
594
|
+
message: "Text:"
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
key: "bodyFile",
|
|
598
|
+
flag: "--body-file",
|
|
599
|
+
type: "input",
|
|
600
|
+
message: "File with the text (- for stdin):"
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
key: "label",
|
|
604
|
+
flag: "--label",
|
|
605
|
+
type: "input",
|
|
606
|
+
message: "Label:"
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
key: "assignee",
|
|
610
|
+
flag: "--assignee",
|
|
611
|
+
type: "input",
|
|
612
|
+
message: "Assignee (login, or me):"
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
key: "milestone",
|
|
616
|
+
flag: "--milestone",
|
|
617
|
+
type: "input",
|
|
618
|
+
message: "Milestone (number or title):"
|
|
619
|
+
}
|
|
598
620
|
],
|
|
621
|
+
skipOptions: ["yes"],
|
|
599
622
|
supportsDryRun: true
|
|
600
623
|
};
|
|
601
624
|
// src/commands/migrate/migrate-issue/migrate-issue.entry.ts
|
|
@@ -792,6 +815,43 @@ const newRepoEntry = {
|
|
|
792
815
|
],
|
|
793
816
|
supportsDryRun: true
|
|
794
817
|
};
|
|
818
|
+
// src/commands/new-domain/new-domain.entry.ts
|
|
819
|
+
const newDomainEntry = {
|
|
820
|
+
name: "new domain",
|
|
821
|
+
description: "Make a DNS record through the `dns` provider and keep it in .holocron/dns-records.json",
|
|
822
|
+
positionals: [],
|
|
823
|
+
options: [
|
|
824
|
+
{
|
|
825
|
+
key: "type",
|
|
826
|
+
flag: "--type",
|
|
827
|
+
type: "input",
|
|
828
|
+
message: "Type (CNAME, TXT, A or AAAA):",
|
|
829
|
+
required: true
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
key: "name",
|
|
833
|
+
flag: "--name",
|
|
834
|
+
type: "input",
|
|
835
|
+
message: "Hostname (e.g. status.example.dev):",
|
|
836
|
+
required: true
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
key: "value",
|
|
840
|
+
flag: "--value",
|
|
841
|
+
type: "input",
|
|
842
|
+
message: "Value, as the vendor shows it:",
|
|
843
|
+
required: true
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
key: "note",
|
|
847
|
+
flag: "--note",
|
|
848
|
+
type: "input",
|
|
849
|
+
message: "Note (which vendor serves it):"
|
|
850
|
+
}
|
|
851
|
+
],
|
|
852
|
+
skipOptions: ["proxied", "yes"],
|
|
853
|
+
supportsDryRun: true
|
|
854
|
+
};
|
|
795
855
|
// src/commands/notifications-channel-add/notifications-channel-add.entry.ts
|
|
796
856
|
const notificationsChannelAddEntry = {
|
|
797
857
|
name: "new channel",
|
|
@@ -1567,6 +1627,7 @@ const registry = createCommandRegistry([
|
|
|
1567
1627
|
],
|
|
1568
1628
|
supportsDryRun: true
|
|
1569
1629
|
},
|
|
1630
|
+
newDomainEntry,
|
|
1570
1631
|
projectListEntry,
|
|
1571
1632
|
projectCreateEntry,
|
|
1572
1633
|
projectCloseEntry,
|
|
@@ -6991,6 +7052,86 @@ const doctorCiCommand = {
|
|
|
6991
7052
|
})).status === "fail") process.exitCode = 1;
|
|
6992
7053
|
}
|
|
6993
7054
|
};
|
|
7055
|
+
// src/dns-records/disk-io/disk-io.ts
|
|
7056
|
+
/** The file system the list lives on. */
|
|
7057
|
+
const diskIo = {
|
|
7058
|
+
read: (path) => readFile(path, "utf8").catch((err) => {
|
|
7059
|
+
if (err.code === "ENOENT") return null;
|
|
7060
|
+
throw err;
|
|
7061
|
+
}),
|
|
7062
|
+
write: async (path, text) => {
|
|
7063
|
+
await mkdir(dirname(path), { recursive: true });
|
|
7064
|
+
await writeFile(path, text, "utf8");
|
|
7065
|
+
}
|
|
7066
|
+
};
|
|
7067
|
+
// src/dns-records/dns-records.type.ts
|
|
7068
|
+
/** The list's file, relative to the repository root. */
|
|
7069
|
+
const DNS_RECORDS_FILE = ".holocron/dns-records.json";
|
|
7070
|
+
/** The record types `holocron new domain` takes. MX and SRV need a priority the entry does not carry. */
|
|
7071
|
+
const DNS_ENTRY_TYPES = [
|
|
7072
|
+
"CNAME",
|
|
7073
|
+
"TXT",
|
|
7074
|
+
"A",
|
|
7075
|
+
"AAAA"
|
|
7076
|
+
];
|
|
7077
|
+
// src/dns-records/parse-dns-records/parse-dns-records.ts
|
|
7078
|
+
/** The list in `text`, or a `ConfigError` naming the entry that is wrong. An empty file is an empty list. */
|
|
7079
|
+
function parseDnsRecords(text, file) {
|
|
7080
|
+
if (text.trim() === "") return [];
|
|
7081
|
+
let raw;
|
|
7082
|
+
try {
|
|
7083
|
+
raw = JSON.parse(text);
|
|
7084
|
+
} catch (err) {
|
|
7085
|
+
throw new ConfigError$1(`${file} is not JSON: ${errorMessage(err)}`);
|
|
7086
|
+
}
|
|
7087
|
+
if (!Array.isArray(raw)) throw new ConfigError$1(`${file} must hold an array of records`);
|
|
7088
|
+
return raw.map((item, i) => {
|
|
7089
|
+
const at = `${file} entry ${i + 1}`;
|
|
7090
|
+
if (typeof item !== "object" || item === null) throw new ConfigError$1(`${at} must be an object`);
|
|
7091
|
+
const e = item;
|
|
7092
|
+
const type = DNS_ENTRY_TYPES.find((t) => t === e.type);
|
|
7093
|
+
if (!type) throw new ConfigError$1(`${at}: type must be one of ${DNS_ENTRY_TYPES.join(", ")}`);
|
|
7094
|
+
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`);
|
|
7095
|
+
if (e.note !== void 0 && typeof e.note !== "string") throw new ConfigError$1(`${at}: note must be a string`);
|
|
7096
|
+
if (e.proxied !== void 0 && typeof e.proxied !== "boolean") throw new ConfigError$1(`${at}: proxied must be true or false`);
|
|
7097
|
+
return {
|
|
7098
|
+
type,
|
|
7099
|
+
name: e.name,
|
|
7100
|
+
value: e.value,
|
|
7101
|
+
...e.note !== void 0 ? { note: e.note } : {},
|
|
7102
|
+
...e.proxied !== void 0 ? { proxied: e.proxied } : {}
|
|
7103
|
+
};
|
|
7104
|
+
});
|
|
7105
|
+
}
|
|
7106
|
+
// src/dns-records/read-dns-records/read-dns-records.ts
|
|
7107
|
+
/** The records `.holocron/dns-records.json` lists; none when the file is absent. */
|
|
7108
|
+
async function readDnsRecords(repoRoot, io = diskIo) {
|
|
7109
|
+
const text = await io.read(join(repoRoot, DNS_RECORDS_FILE));
|
|
7110
|
+
return text === null ? [] : parseDnsRecords(text, DNS_RECORDS_FILE);
|
|
7111
|
+
}
|
|
7112
|
+
// src/dns-records/upsert-dns-entry/upsert-dns-entry.ts
|
|
7113
|
+
/** An entry's identity: its type and its name, without case or a final dot. */
|
|
7114
|
+
const entryKey = (e) => `${e.type} ${e.name.toLowerCase().replace(/\.$/, "")}`;
|
|
7115
|
+
/**
|
|
7116
|
+
* The list with `entry` in it: a new entry goes last, one with the same type and name takes its place (order kept)
|
|
7117
|
+
* and is returned as `replaced`. The list given is not changed.
|
|
7118
|
+
*/
|
|
7119
|
+
function upsertDnsEntry(list, entry) {
|
|
7120
|
+
const at = list.findIndex((e) => entryKey(e) === entryKey(entry));
|
|
7121
|
+
if (at === -1) return {
|
|
7122
|
+
list: [...list, entry],
|
|
7123
|
+
replaced: void 0
|
|
7124
|
+
};
|
|
7125
|
+
return {
|
|
7126
|
+
list: list.map((e, i) => i === at ? entry : e),
|
|
7127
|
+
replaced: list[at]
|
|
7128
|
+
};
|
|
7129
|
+
}
|
|
7130
|
+
// src/dns-records/write-dns-records/write-dns-records.ts
|
|
7131
|
+
/** Write the list the way Prettier lays JSON out, so a rewrite leaves the file formatted. */
|
|
7132
|
+
async function writeDnsRecords(repoRoot, list, io = diskIo) {
|
|
7133
|
+
await io.write(join(repoRoot, DNS_RECORDS_FILE), formatJson(list));
|
|
7134
|
+
}
|
|
6994
7135
|
// src/commands/missing-token/missing-token.ts
|
|
6995
7136
|
/**
|
|
6996
7137
|
* Why a provider call could not be tried for want of a token, or undefined when the error is something else. A plugin
|
|
@@ -7231,10 +7372,35 @@ async function runDoctorDns(input) {
|
|
|
7231
7372
|
...loader.has("wiki") ? { wiki: loader.get("wiki") } : {},
|
|
7232
7373
|
layouts: (loader.has("notifications") ? loader.get("notifications") : []).flatMap((p) => p.layout ? [p.layout] : [])
|
|
7233
7374
|
});
|
|
7375
|
+
let listFailure;
|
|
7376
|
+
const listed = await readDnsRecords(input.context.repoRoot, input.io).catch((err) => {
|
|
7377
|
+
listFailure = errorMessage(err);
|
|
7378
|
+
return [];
|
|
7379
|
+
});
|
|
7380
|
+
const apex = input.loaded.resolved.domain;
|
|
7381
|
+
for (const e of listed) {
|
|
7382
|
+
const zone = apex && (e.name === apex || e.name.endsWith(`.${apex}`)) ? apex : e.name;
|
|
7383
|
+
expected.push({
|
|
7384
|
+
zone,
|
|
7385
|
+
record: {
|
|
7386
|
+
type: e.type,
|
|
7387
|
+
name: e.name,
|
|
7388
|
+
content: e.value,
|
|
7389
|
+
proxied: e.proxied ?? false
|
|
7390
|
+
}
|
|
7391
|
+
});
|
|
7392
|
+
}
|
|
7234
7393
|
const zones = [...new Set(expected.map((e) => e.zone))];
|
|
7235
7394
|
const deploy = loader.has("deployment") ? loader.get("deployment") : void 0;
|
|
7236
7395
|
const domains = deploy?.expectedDomainRecord ? deploymentDomains(input.loaded.resolved, deploy) : [];
|
|
7237
7396
|
const rows = [];
|
|
7397
|
+
if (listFailure !== void 0) rows.push({
|
|
7398
|
+
id: "dns-records-file",
|
|
7399
|
+
title: "dns-records.json reads",
|
|
7400
|
+
status: "fail",
|
|
7401
|
+
detail: listFailure,
|
|
7402
|
+
problems: []
|
|
7403
|
+
});
|
|
7238
7404
|
if (zones.length === 0 && domains.length === 0) rows.push({
|
|
7239
7405
|
id: "dns",
|
|
7240
7406
|
title: "dns",
|
|
@@ -7652,7 +7818,7 @@ function datasetTargets(config) {
|
|
|
7652
7818
|
* the token (accepted by the provider), one per dataset (the CLI's, Sentinel's and any other `dev.serve.logging` names),
|
|
7653
7819
|
* one for the organization, and an `info` row per existing dataset with its retention (ADR-0019: one setting for the whole
|
|
7654
7820
|
* dataset, shared by every environment in it). Only a dataset the provider says is missing, or a token it refuses, fails;
|
|
7655
|
-
* a name, a token or a response that cannot be read is a skip with the reason.
|
|
7821
|
+
* a dataset the token may not see (403), a name, a token or a response that cannot be read is a skip with the reason.
|
|
7656
7822
|
*/
|
|
7657
7823
|
const row$14 = (id, title, status, detail, problems = []) => ({
|
|
7658
7824
|
id,
|
|
@@ -7690,7 +7856,7 @@ async function runDoctorLogs(input) {
|
|
|
7690
7856
|
}
|
|
7691
7857
|
async function checkLogs(logs, targets) {
|
|
7692
7858
|
const rows = [];
|
|
7693
|
-
const token = await checkToken$1(logs);
|
|
7859
|
+
const token = await checkToken$1(logs, targets.find((t) => t.id === "cli")?.name);
|
|
7694
7860
|
rows.push(token.row);
|
|
7695
7861
|
for (const target of targets) {
|
|
7696
7862
|
const id = `logs:dataset:${target.id}`;
|
|
@@ -7705,14 +7871,14 @@ async function checkLogs(logs, targets) {
|
|
|
7705
7871
|
return rows;
|
|
7706
7872
|
}
|
|
7707
7873
|
/** Whether the provider accepts the token. `usable` is false when it was refused or could not be tried. */
|
|
7708
|
-
async function checkToken$1(logs) {
|
|
7874
|
+
async function checkToken$1(logs, dataset) {
|
|
7709
7875
|
const title = "token is accepted";
|
|
7710
7876
|
if (!logs.checkToken) return {
|
|
7711
7877
|
row: row$14("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
|
|
7712
7878
|
usable: true
|
|
7713
7879
|
};
|
|
7714
7880
|
try {
|
|
7715
|
-
const result = await logs.checkToken();
|
|
7881
|
+
const result = await logs.checkToken(dataset);
|
|
7716
7882
|
if (result.ok) return {
|
|
7717
7883
|
row: row$14("logs:token", title, "ok", `${logs.providerName} accepts the token`),
|
|
7718
7884
|
usable: true
|
|
@@ -7734,6 +7900,10 @@ async function checkToken$1(logs) {
|
|
|
7734
7900
|
async function checkDataset(logs, target, name, id, title) {
|
|
7735
7901
|
try {
|
|
7736
7902
|
const found = await logs.readDataset(name);
|
|
7903
|
+
if (found.forbidden) {
|
|
7904
|
+
const why = `${name}: not visible to this token (${logs.providerName} refused the read; it may also not exist)`;
|
|
7905
|
+
return [row$14(id, title, "skip", why)];
|
|
7906
|
+
}
|
|
7737
7907
|
if (!found.exists) {
|
|
7738
7908
|
const problem = `dataset ${name} does not exist (${target.variable}); ${target.fix}`;
|
|
7739
7909
|
return [row$14(id, title, "fail", `${name} does not exist`, [problem])];
|
|
@@ -17007,6 +17177,65 @@ function describeProviderError(err) {
|
|
|
17007
17177
|
if (said === void 0 || !(err instanceof Error)) return describeError(err);
|
|
17008
17178
|
return describeError(Object.assign(new Error(err.message), { details: said }));
|
|
17009
17179
|
}
|
|
17180
|
+
// src/commands/setup/dns-records-step/dns-records-step.ts
|
|
17181
|
+
/**
|
|
17182
|
+
* `holocron setup`'s step for the records `holocron new domain` keeps in `.holocron/dns-records.json` (spec
|
|
17183
|
+
* `tech-new-domain-command`). Each is made through the `dns` provider, DNS-only unless the entry says `proxied`; an
|
|
17184
|
+
* upsert leaves a record that is already right as it is. With no `dns` provider each is a failing `todo` row that says
|
|
17185
|
+
* what to make. `--dry-run` writes nothing. Never deletes. No list, no steps; a list that cannot be read is one
|
|
17186
|
+
* failing row.
|
|
17187
|
+
*/
|
|
17188
|
+
async function dnsRecordsStep(loader, repoRoot, dryRun, io) {
|
|
17189
|
+
let list;
|
|
17190
|
+
try {
|
|
17191
|
+
list = await readDnsRecords(repoRoot, io);
|
|
17192
|
+
} catch (err) {
|
|
17193
|
+
return [{
|
|
17194
|
+
capability: "dns",
|
|
17195
|
+
step: "read dns-records.json",
|
|
17196
|
+
status: "fail",
|
|
17197
|
+
message: errorMessage(err)
|
|
17198
|
+
}];
|
|
17199
|
+
}
|
|
17200
|
+
const steps = [];
|
|
17201
|
+
for (const e of list) {
|
|
17202
|
+
const step = `dns ${e.type} ${e.name}`;
|
|
17203
|
+
if (dryRun) steps.push({
|
|
17204
|
+
capability: "dns",
|
|
17205
|
+
step,
|
|
17206
|
+
status: "dry-run",
|
|
17207
|
+
message: "would make the record"
|
|
17208
|
+
});
|
|
17209
|
+
else if (!loader.has("dns")) steps.push({
|
|
17210
|
+
capability: "dns",
|
|
17211
|
+
step,
|
|
17212
|
+
status: "fail",
|
|
17213
|
+
message: `todo: no \`dns\` provider is configured; make ${e.type} ${e.name} -> ${e.value}`
|
|
17214
|
+
});
|
|
17215
|
+
else try {
|
|
17216
|
+
await loader.get("dns").upsertRecord(e.name, {
|
|
17217
|
+
type: e.type,
|
|
17218
|
+
name: e.name,
|
|
17219
|
+
content: e.value,
|
|
17220
|
+
proxied: e.proxied ?? false
|
|
17221
|
+
});
|
|
17222
|
+
steps.push({
|
|
17223
|
+
capability: "dns",
|
|
17224
|
+
step,
|
|
17225
|
+
status: "ok",
|
|
17226
|
+
message: `made${e.proxied ? "" : " (DNS only)"}${e.note ? `: ${e.note}` : ""}`
|
|
17227
|
+
});
|
|
17228
|
+
} catch (err) {
|
|
17229
|
+
steps.push({
|
|
17230
|
+
capability: "dns",
|
|
17231
|
+
step,
|
|
17232
|
+
status: "fail",
|
|
17233
|
+
message: describeProviderError(err)
|
|
17234
|
+
});
|
|
17235
|
+
}
|
|
17236
|
+
}
|
|
17237
|
+
return steps;
|
|
17238
|
+
}
|
|
17010
17239
|
// src/commands/setup/engineering.ts
|
|
17011
17240
|
async function writeIfAbsent(filePath, content) {
|
|
17012
17241
|
try {
|
|
@@ -17910,6 +18139,14 @@ async function runSetup(input) {
|
|
|
17910
18139
|
print(formatStep(steps[steps.length - 1]));
|
|
17911
18140
|
}
|
|
17912
18141
|
}
|
|
18142
|
+
const dnsSteps = await dnsRecordsStep(loader, input.context.repoRoot, dryRun);
|
|
18143
|
+
if (dnsSteps.length > 0) {
|
|
18144
|
+
print(style.step("dns"));
|
|
18145
|
+
for (const step of dnsSteps) {
|
|
18146
|
+
steps.push(step);
|
|
18147
|
+
print(formatStep(step));
|
|
18148
|
+
}
|
|
18149
|
+
}
|
|
17913
18150
|
if (loader.has("monitoring")) {
|
|
17914
18151
|
const monitoring = loader.get("monitoring");
|
|
17915
18152
|
print(style.step("monitoring"));
|
|
@@ -19694,6 +19931,14 @@ const ideasPromoteCommand = {
|
|
|
19694
19931
|
})).status === "fail") process.exitCode = 1;
|
|
19695
19932
|
}
|
|
19696
19933
|
};
|
|
19934
|
+
// src/commands/issue-create/read-issue-body/read-issue-body.ts
|
|
19935
|
+
/**
|
|
19936
|
+
* The text of an issue from `--body-file`: a path (relative to `cwd`), or `-` for standard input. `read` is injected
|
|
19937
|
+
* so a test needs no file or terminal.
|
|
19938
|
+
*/
|
|
19939
|
+
function readIssueBody(file, cwd, read = (p) => readFileSync(p, "utf8")) {
|
|
19940
|
+
return file === "-" ? read(0) : read(resolve(cwd, file));
|
|
19941
|
+
}
|
|
19697
19942
|
// src/commands/issue-create/run-issue-create/run-issue-create.ts
|
|
19698
19943
|
/**
|
|
19699
19944
|
* `holocron new issue` — files an issue through the repo's `issues` provider.
|
|
@@ -19750,7 +19995,12 @@ async function runIssueCreate(input) {
|
|
|
19750
19995
|
const labels = [...new Set((input.labels ?? []).map((l) => l.trim()).filter(Boolean))];
|
|
19751
19996
|
const body = input.body?.trim() ? input.body : void 0;
|
|
19752
19997
|
const milestone = input.milestone?.trim() ? input.milestone.trim() : void 0;
|
|
19753
|
-
const
|
|
19998
|
+
const assignees = [...new Set((input.assignees ?? []).map((a) => a.trim()).filter(Boolean))];
|
|
19999
|
+
const details = [
|
|
20000
|
+
labels.length > 0 ? `labels: ${labels.join(", ")}` : void 0,
|
|
20001
|
+
assignees.length > 0 ? `assignee: ${assignees.join(", ")}` : void 0,
|
|
20002
|
+
milestone ? `milestone: ${milestone}` : void 0
|
|
20003
|
+
].filter(Boolean);
|
|
19754
20004
|
const summary = details.length > 0 ? ` (${details.join("; ")})` : "";
|
|
19755
20005
|
if (dryRun) {
|
|
19756
20006
|
print(` ${title}`);
|
|
@@ -19772,13 +20022,14 @@ async function runIssueCreate(input) {
|
|
|
19772
20022
|
}
|
|
19773
20023
|
}
|
|
19774
20024
|
try {
|
|
19775
|
-
const { key } = await loader.get("issues").create({
|
|
20025
|
+
const { key, dropped } = await loader.get("issues").create({
|
|
19776
20026
|
summary: title,
|
|
19777
20027
|
...body ? { body } : {},
|
|
19778
20028
|
...labels.length > 0 ? { labels } : {},
|
|
19779
|
-
...milestone ? { milestone } : {}
|
|
20029
|
+
...milestone ? { milestone } : {},
|
|
20030
|
+
...assignees.length > 0 ? { assignees } : {}
|
|
19780
20031
|
});
|
|
19781
|
-
return finish([row$4(title, "ok", `filed ${key}`)], key);
|
|
20032
|
+
return finish([row$4(title, "ok", `filed ${key}`), ...(dropped ?? []).map((line) => row$4("not carried across", "skip", line))], key);
|
|
19782
20033
|
} catch (err) {
|
|
19783
20034
|
return finish([row$4(title, "fail", `could not file the issue: ${describeError(err)}`)]);
|
|
19784
20035
|
}
|
|
@@ -19794,10 +20045,18 @@ const issueCreateCommand = {
|
|
|
19794
20045
|
}).option("body", {
|
|
19795
20046
|
type: "string",
|
|
19796
20047
|
describe: "The issue's text"
|
|
20048
|
+
}).option("body-file", {
|
|
20049
|
+
type: "string",
|
|
20050
|
+
describe: "Read the issue's text from a file (`-` for standard input)",
|
|
20051
|
+
conflicts: "body"
|
|
19797
20052
|
}).option("label", {
|
|
19798
20053
|
type: "string",
|
|
19799
20054
|
array: true,
|
|
19800
20055
|
describe: "A label to put on it (repeatable)"
|
|
20056
|
+
}).option("assignee", {
|
|
20057
|
+
type: "string",
|
|
20058
|
+
array: true,
|
|
20059
|
+
describe: "A person to assign, by login; `me` is you (repeatable)"
|
|
19801
20060
|
}).option("milestone", {
|
|
19802
20061
|
type: "string",
|
|
19803
20062
|
describe: "The milestone: its number or its exact title"
|
|
@@ -19810,6 +20069,14 @@ const issueCreateCommand = {
|
|
|
19810
20069
|
if (!tokens) return;
|
|
19811
20070
|
const loaded = await loadConfig(argv.cwd);
|
|
19812
20071
|
applyResolvedConfig(argv, loaded.resolved);
|
|
20072
|
+
let body = argv.body;
|
|
20073
|
+
if (argv.bodyFile) try {
|
|
20074
|
+
body = readIssueBody(argv.bodyFile, argv.cwd);
|
|
20075
|
+
} catch (err) {
|
|
20076
|
+
console.error(`Could not read ${argv.bodyFile}: ${describeError(err)}`);
|
|
20077
|
+
process.exitCode = 1;
|
|
20078
|
+
return;
|
|
20079
|
+
}
|
|
19813
20080
|
if ((await runIssueCreate({
|
|
19814
20081
|
title: String(argv.title),
|
|
19815
20082
|
loaded,
|
|
@@ -19819,13 +20086,178 @@ const issueCreateCommand = {
|
|
|
19819
20086
|
...tokens,
|
|
19820
20087
|
org: resolveOrg(argv, loaded.resolved)
|
|
19821
20088
|
},
|
|
19822
|
-
...
|
|
20089
|
+
...body ? { body } : {},
|
|
20090
|
+
...argv.assignee ? { assignees: argv.assignee.map(String) } : {},
|
|
19823
20091
|
...argv.label ? { labels: argv.label.map(String) } : {},
|
|
19824
20092
|
...argv.milestone ? { milestone: String(argv.milestone) } : {},
|
|
19825
20093
|
...argv.yes ? { yes: true } : {}
|
|
19826
20094
|
})).status === "fail") process.exitCode = 1;
|
|
19827
20095
|
}
|
|
19828
20096
|
};
|
|
20097
|
+
// src/commands/new-domain/new-domain.ts
|
|
20098
|
+
/**
|
|
20099
|
+
* `holocron new domain` — take a DNS record, make it through the `dns` provider, keep it in the list
|
|
20100
|
+
* (`.holocron/dns-records.json`) that `setup` re-applies and `doctor dns` checks (spec `tech-new-domain-command`).
|
|
20101
|
+
*
|
|
20102
|
+
* Provider-neutral: it calls the `dns` capability's `upsertRecord`, so it names no vendor. A record is DNS-only unless
|
|
20103
|
+
* `--proxied`, because a vendor reads the record itself to verify the name. It shows what will change, asks first
|
|
20104
|
+
* (unless `--yes` or `--dry-run`) and never deletes.
|
|
20105
|
+
*/
|
|
20106
|
+
/** A value as comparable text: no case, no final dot, no quotes around a TXT value. */
|
|
20107
|
+
const normal = (v) => v.trim().replace(/^"(.*)"$/s, "$1").replace(/\.$/, "").toLowerCase();
|
|
20108
|
+
async function runNewDomain(input) {
|
|
20109
|
+
const { print, logger, loader } = input;
|
|
20110
|
+
await loader.load();
|
|
20111
|
+
assertPluginsResolvable(loader, "new domain");
|
|
20112
|
+
if (!loader.has("dns")) throw new Error("`dns` capability is not configured: add a `dns` provider to holocron.config");
|
|
20113
|
+
const need = async (field) => {
|
|
20114
|
+
const given = input[field];
|
|
20115
|
+
if (given !== void 0 && given !== "") return given;
|
|
20116
|
+
if (!input.ask) throw new NonInteractiveError(`--${field} is required without a terminal`);
|
|
20117
|
+
return (await input.ask(field)).trim();
|
|
20118
|
+
};
|
|
20119
|
+
const type = (await need("type")).toUpperCase();
|
|
20120
|
+
const kind = DNS_ENTRY_TYPES.find((t) => t === type);
|
|
20121
|
+
if (!kind) throw new Error(`--type must be one of ${DNS_ENTRY_TYPES.join(", ")} (got ${type})`);
|
|
20122
|
+
const name = (await need("name")).toLowerCase().replace(/\.$/, "");
|
|
20123
|
+
const zone = input.loaded.resolved.domain;
|
|
20124
|
+
if (zone && name !== zone && !name.endsWith(`.${zone}`)) throw new Error(`--name must be ${zone} or a name under it (got ${name})`);
|
|
20125
|
+
const value = await need("value");
|
|
20126
|
+
if (value === "") throw new Error("--value is required");
|
|
20127
|
+
const entry = {
|
|
20128
|
+
type: kind,
|
|
20129
|
+
name,
|
|
20130
|
+
value,
|
|
20131
|
+
...input.note ? { note: input.note } : {},
|
|
20132
|
+
...input.proxied ? { proxied: true } : {}
|
|
20133
|
+
};
|
|
20134
|
+
const dryRun = input.context.dryRun === true;
|
|
20135
|
+
const dns = loader.get("dns");
|
|
20136
|
+
const { list, replaced } = upsertDnsEntry(await readDnsRecords(input.context.repoRoot, input.io), entry);
|
|
20137
|
+
print(`Holocron new domain — ${entry.type} ${entry.name}${dryRun ? " (dry-run)" : ""}`);
|
|
20138
|
+
try {
|
|
20139
|
+
const held = (await dns.listRecords(entry.name)).filter((r) => r.type === entry.type && normal(r.name) === normal(entry.name));
|
|
20140
|
+
const same = held.some((r) => normal(r.content) === normal(entry.value) && r.proxied === true === (entry.proxied ?? false));
|
|
20141
|
+
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}`);
|
|
20142
|
+
if (replaced) print(` ~ the list already has this record (${replaced.value}); its entry is replaced`);
|
|
20143
|
+
if (dryRun) return {
|
|
20144
|
+
status: "dry-run",
|
|
20145
|
+
entry,
|
|
20146
|
+
message: "nothing written"
|
|
20147
|
+
};
|
|
20148
|
+
if (!input.yes) {
|
|
20149
|
+
if (!input.confirm) throw new NonInteractiveError("pass --yes to make the record without a terminal");
|
|
20150
|
+
if (!await input.confirm(`Make ${entry.type} ${entry.name} (DNS ${entry.proxied ? "proxied" : "only"})?`)) {
|
|
20151
|
+
print(" cancelled; nothing written");
|
|
20152
|
+
return {
|
|
20153
|
+
status: "cancelled",
|
|
20154
|
+
entry
|
|
20155
|
+
};
|
|
20156
|
+
}
|
|
20157
|
+
}
|
|
20158
|
+
const record = {
|
|
20159
|
+
type: entry.type,
|
|
20160
|
+
name: entry.name,
|
|
20161
|
+
content: entry.value,
|
|
20162
|
+
proxied: entry.proxied ?? false
|
|
20163
|
+
};
|
|
20164
|
+
await dns.upsertRecord(entry.name, record);
|
|
20165
|
+
await writeDnsRecords(input.context.repoRoot, list, input.io);
|
|
20166
|
+
print(` ✓ made ${entry.type} ${entry.name} via ${dns.providerName}; kept in .holocron/dns-records.json`);
|
|
20167
|
+
logger.info({
|
|
20168
|
+
type: entry.type,
|
|
20169
|
+
name: entry.name,
|
|
20170
|
+
provider: dns.providerName,
|
|
20171
|
+
status: "ok"
|
|
20172
|
+
}, "new domain");
|
|
20173
|
+
return {
|
|
20174
|
+
status: "ok",
|
|
20175
|
+
entry
|
|
20176
|
+
};
|
|
20177
|
+
} catch (err) {
|
|
20178
|
+
if (err instanceof NonInteractiveError) throw err;
|
|
20179
|
+
const message = errorMessage(err);
|
|
20180
|
+
print(` ✗ ${message}`);
|
|
20181
|
+
logger.warn({
|
|
20182
|
+
type: entry.type,
|
|
20183
|
+
name: entry.name,
|
|
20184
|
+
reason: message
|
|
20185
|
+
}, "new domain");
|
|
20186
|
+
return {
|
|
20187
|
+
status: "fail",
|
|
20188
|
+
entry,
|
|
20189
|
+
message
|
|
20190
|
+
};
|
|
20191
|
+
}
|
|
20192
|
+
}
|
|
20193
|
+
// src/commands/new-domain/new-domain.command.ts
|
|
20194
|
+
const newDomainArgs = (y) => y.option("type", {
|
|
20195
|
+
type: "string",
|
|
20196
|
+
describe: `Record type: ${DNS_ENTRY_TYPES.join(", ")} (asked for on a terminal)`
|
|
20197
|
+
}).option("name", {
|
|
20198
|
+
type: "string",
|
|
20199
|
+
describe: "The full hostname, under the org's domain (asked for on a terminal)"
|
|
20200
|
+
}).option("value", {
|
|
20201
|
+
type: "string",
|
|
20202
|
+
describe: "The record's content, as the vendor shows it (asked for on a terminal)"
|
|
20203
|
+
}).option("note", {
|
|
20204
|
+
type: "string",
|
|
20205
|
+
describe: "Why it exists, e.g. which vendor serves the name"
|
|
20206
|
+
}).option("proxied", {
|
|
20207
|
+
type: "boolean",
|
|
20208
|
+
default: false,
|
|
20209
|
+
describe: "Send traffic through the provider's proxy (default: DNS only, which a vendor's verification needs)"
|
|
20210
|
+
}).option("yes", {
|
|
20211
|
+
type: "boolean",
|
|
20212
|
+
default: false,
|
|
20213
|
+
describe: "Make the record without asking first (required without a terminal)"
|
|
20214
|
+
});
|
|
20215
|
+
/** Ask for one field on a terminal. */
|
|
20216
|
+
async function ask(field) {
|
|
20217
|
+
if (field === "type") return select({
|
|
20218
|
+
message: "Record type:",
|
|
20219
|
+
choices: DNS_ENTRY_TYPES.map((t) => ({ value: t }))
|
|
20220
|
+
});
|
|
20221
|
+
return input({ message: field === "name" ? "Hostname:" : "Value, as the vendor shows it:" });
|
|
20222
|
+
}
|
|
20223
|
+
const newDomainCommand = {
|
|
20224
|
+
command: "domain",
|
|
20225
|
+
describe: "Make a DNS record through the `dns` provider and keep it in .holocron/dns-records.json",
|
|
20226
|
+
builder: newDomainArgs,
|
|
20227
|
+
handler: async (argv) => {
|
|
20228
|
+
const tokens = tokenContext(argv.token);
|
|
20229
|
+
if (!tokens) return;
|
|
20230
|
+
const loaded = await loadConfig(argv.cwd);
|
|
20231
|
+
applyResolvedConfig(argv, loaded.resolved);
|
|
20232
|
+
const terminal = process.stdin.isTTY === true;
|
|
20233
|
+
const context = {
|
|
20234
|
+
repoRoot: argv.cwd,
|
|
20235
|
+
dryRun: argv.dryRun,
|
|
20236
|
+
...tokens,
|
|
20237
|
+
org: resolveOrg(argv, loaded.resolved)
|
|
20238
|
+
};
|
|
20239
|
+
if ((await runNewDomain({
|
|
20240
|
+
loaded,
|
|
20241
|
+
context,
|
|
20242
|
+
loader: new PluginLoader(loaded.resolved, context),
|
|
20243
|
+
print: (line) => console.log(line),
|
|
20244
|
+
logger: getLogger(),
|
|
20245
|
+
...argv.type ? { type: argv.type } : {},
|
|
20246
|
+
...argv.name ? { name: argv.name } : {},
|
|
20247
|
+
...argv.value ? { value: argv.value } : {},
|
|
20248
|
+
...argv.note ? { note: argv.note } : {},
|
|
20249
|
+
...argv.proxied ? { proxied: true } : {},
|
|
20250
|
+
...argv.yes ? { yes: true } : {},
|
|
20251
|
+
...terminal ? {
|
|
20252
|
+
ask,
|
|
20253
|
+
confirm: (message) => confirm({
|
|
20254
|
+
message,
|
|
20255
|
+
default: false
|
|
20256
|
+
})
|
|
20257
|
+
} : {}
|
|
20258
|
+
})).status === "fail") process.exitCode = 1;
|
|
20259
|
+
}
|
|
20260
|
+
};
|
|
19829
20261
|
// src/commands/notifications-channel-add/notifications-channel-add.args.ts
|
|
19830
20262
|
const notificationsChannelAddArgs = (y) => y.positional("name", {
|
|
19831
20263
|
type: "string",
|
|
@@ -22255,8 +22687,8 @@ const newRepoCommand = {
|
|
|
22255
22687
|
// src/commands/new/new.command.ts
|
|
22256
22688
|
const newCommand = {
|
|
22257
22689
|
command: "new",
|
|
22258
|
-
describe: "Create a repo, plugin, channel, server, secret, token, tunnel, GitHub App, project, spec or issue",
|
|
22259
|
-
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")),
|
|
22690
|
+
describe: "Create a repo, plugin, channel, server, secret, token, tunnel, domain record, GitHub App, project, spec or issue",
|
|
22691
|
+
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")),
|
|
22260
22692
|
handler: () => {}
|
|
22261
22693
|
};
|
|
22262
22694
|
// src/commands/probe/probe.args.ts
|