atmn 2.0.251 → 2.0.253
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/dist/bin.js +98 -34
- package/package.json +2 -2
- package/src/actions/push/safeMode.ts +11 -0
- package/src/actions/push.ts +14 -2
- package/src/actions/webhooks/previewWebhookEnvs.ts +16 -4
- package/src/cli.ts +6 -1
- package/src/generated/apiRoutes.ts +14 -0
- package/src/generated/client.ts +31 -1
- package/src/generated/skills.ts +11 -11
- package/src/render/renderPreview.ts +86 -38
- package/src/render/renderWebhooks.ts +24 -7
|
@@ -136,6 +136,8 @@ export type CatalogPreview = {
|
|
|
136
136
|
settings?: SettingsPreview;
|
|
137
137
|
/** One block per env the push syncs; absent when the config states no `webhooks`. */
|
|
138
138
|
webhooks?: WebhooksPreview[];
|
|
139
|
+
/** The server's echo of skip_updates: this preview is a safe-mode one. */
|
|
140
|
+
skipUpdates?: boolean;
|
|
139
141
|
/** Live webhook ids a plain push found out of date but leaves to `-p`. */
|
|
140
142
|
productionWebhooks?: string[];
|
|
141
143
|
/** The read-only live check failed: "No changes" would be a claim nobody checked. */
|
|
@@ -535,6 +537,21 @@ const planRowId = (row: { planId?: string; version?: number }): string =>
|
|
|
535
537
|
? (row.planId ?? "?")
|
|
536
538
|
: `${row.planId}@v${row.version}`;
|
|
537
539
|
|
|
540
|
+
/** A row safe mode held back: greyed, never a marker, never its diff. */
|
|
541
|
+
const skippedLine = ({
|
|
542
|
+
id,
|
|
543
|
+
label,
|
|
544
|
+
indent = " ",
|
|
545
|
+
}: {
|
|
546
|
+
id: string;
|
|
547
|
+
label?: string;
|
|
548
|
+
indent?: string;
|
|
549
|
+
}): string =>
|
|
550
|
+
`${indent}${chalk.dim(`· ${id}${label && label !== id ? ` ${label}` : ""} skipped`)}`;
|
|
551
|
+
|
|
552
|
+
const SAFE_MODE_HEADER =
|
|
553
|
+
"Safe mode: only ids that don't exist yet are created. Updates and deletions are skipped.";
|
|
554
|
+
|
|
538
555
|
/** A row printed only to place the work nested under it: no marker, no colour. */
|
|
539
556
|
const contextLine = ({
|
|
540
557
|
id,
|
|
@@ -666,6 +683,7 @@ const isFreshRow = (plan: PlanChange): boolean =>
|
|
|
666
683
|
* are the only work — then its identity moves, its diff, then those variants. */
|
|
667
684
|
const renderPlanRow = ({ plan }: { plan: PlanChange }): string[] => {
|
|
668
685
|
const id = planRowId(plan);
|
|
686
|
+
if (plan.action === "skip") return [skippedLine({ id, label: plan.name })];
|
|
669
687
|
const fresh = isFreshRow(plan);
|
|
670
688
|
return [
|
|
671
689
|
isChange(plan)
|
|
@@ -843,10 +861,13 @@ export const renderPreview = ({
|
|
|
843
861
|
/** Omitted in tests; the dashboard origin in real runs. */
|
|
844
862
|
migrationLinkBase?: string;
|
|
845
863
|
}): string => {
|
|
846
|
-
const
|
|
847
|
-
const
|
|
848
|
-
|
|
849
|
-
const
|
|
864
|
+
const safe = preview.skipUpdates === true;
|
|
865
|
+
const shown = (row: PreviewChange): boolean =>
|
|
866
|
+
rowHasWork(row) || (safe && row.action === "skip");
|
|
867
|
+
const features = (preview.features ?? []).filter(shown);
|
|
868
|
+
const plans = (preview.plans ?? []).filter(shown);
|
|
869
|
+
const rewards = (preview.rewards ?? []).filter(shown);
|
|
870
|
+
const referralPrograms = (preview.referralPrograms ?? []).filter(shown);
|
|
850
871
|
const migrations = preview.migrations ?? [];
|
|
851
872
|
const settings = settingChanges(preview.settings);
|
|
852
873
|
const webhooks = (preview.webhooks ?? [])
|
|
@@ -876,7 +897,7 @@ export const renderPreview = ({
|
|
|
876
897
|
return chalk.dim("No changes. Your catalog matches your config.");
|
|
877
898
|
}
|
|
878
899
|
|
|
879
|
-
const sections: string[] = [];
|
|
900
|
+
const sections: string[] = safe ? [chalk.bold(SAFE_MODE_HEADER)] : [];
|
|
880
901
|
|
|
881
902
|
if (settings.length > 0) {
|
|
882
903
|
sections.push(
|
|
@@ -891,17 +912,26 @@ export const renderPreview = ({
|
|
|
891
912
|
sections.push(
|
|
892
913
|
[
|
|
893
914
|
chalk.bold(`Features (${features.length})`),
|
|
894
|
-
...features.flatMap((feature) =>
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
915
|
+
...features.flatMap((feature) =>
|
|
916
|
+
feature.action === "skip"
|
|
917
|
+
? [
|
|
918
|
+
skippedLine({
|
|
919
|
+
id: feature.featureId ?? "?",
|
|
920
|
+
label: feature.name,
|
|
921
|
+
}),
|
|
922
|
+
]
|
|
923
|
+
: [
|
|
924
|
+
line({
|
|
925
|
+
action: feature.action,
|
|
926
|
+
id: feature.featureId ?? "?",
|
|
927
|
+
label: feature.name,
|
|
928
|
+
}),
|
|
929
|
+
...renderPreviousAttributes({
|
|
930
|
+
attributes: feature.previousAttributes,
|
|
931
|
+
indent: DETAIL_INDENT,
|
|
932
|
+
}),
|
|
933
|
+
],
|
|
934
|
+
),
|
|
905
935
|
].join("\n"),
|
|
906
936
|
);
|
|
907
937
|
}
|
|
@@ -919,17 +949,26 @@ export const renderPreview = ({
|
|
|
919
949
|
sections.push(
|
|
920
950
|
[
|
|
921
951
|
chalk.bold(`Rewards (${rewards.length})`),
|
|
922
|
-
...rewards.flatMap((reward) =>
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
952
|
+
...rewards.flatMap((reward) =>
|
|
953
|
+
reward.action === "skip"
|
|
954
|
+
? [
|
|
955
|
+
skippedLine({
|
|
956
|
+
id: reward.id ?? "?",
|
|
957
|
+
label: reward.name ?? reward.kind,
|
|
958
|
+
}),
|
|
959
|
+
]
|
|
960
|
+
: [
|
|
961
|
+
line({
|
|
962
|
+
action: reward.action,
|
|
963
|
+
id: reward.id ?? "?",
|
|
964
|
+
label: reward.name ?? reward.kind,
|
|
965
|
+
}),
|
|
966
|
+
...renderPreviousAttributes({
|
|
967
|
+
attributes: reward.previousAttributes,
|
|
968
|
+
indent: DETAIL_INDENT,
|
|
969
|
+
}),
|
|
970
|
+
],
|
|
971
|
+
),
|
|
933
972
|
].join("\n"),
|
|
934
973
|
);
|
|
935
974
|
}
|
|
@@ -938,17 +977,26 @@ export const renderPreview = ({
|
|
|
938
977
|
sections.push(
|
|
939
978
|
[
|
|
940
979
|
chalk.bold(`Referral programs (${referralPrograms.length})`),
|
|
941
|
-
...referralPrograms.flatMap((program) =>
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
980
|
+
...referralPrograms.flatMap((program) =>
|
|
981
|
+
program.action === "skip"
|
|
982
|
+
? [
|
|
983
|
+
skippedLine({
|
|
984
|
+
id: program.id ?? "?",
|
|
985
|
+
label: program.rewardId ?? undefined,
|
|
986
|
+
}),
|
|
987
|
+
]
|
|
988
|
+
: [
|
|
989
|
+
line({
|
|
990
|
+
action: program.action,
|
|
991
|
+
id: program.id ?? "?",
|
|
992
|
+
label: program.rewardId ?? undefined,
|
|
993
|
+
}),
|
|
994
|
+
...renderPreviousAttributes({
|
|
995
|
+
attributes: program.previousAttributes,
|
|
996
|
+
indent: DETAIL_INDENT,
|
|
997
|
+
}),
|
|
998
|
+
],
|
|
999
|
+
),
|
|
952
1000
|
].join("\n"),
|
|
953
1001
|
);
|
|
954
1002
|
}
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import type { PreviewSyncWebhooksResponse } from "../generated/client";
|
|
3
3
|
|
|
4
|
-
type
|
|
5
|
-
|
|
4
|
+
type WebhookState = Extract<
|
|
5
|
+
PreviewSyncWebhooksResponse["changes"][number],
|
|
6
|
+
{ action: "create" }
|
|
7
|
+
>["webhook"];
|
|
8
|
+
|
|
9
|
+
/** What skip_updates held back; spelled out until the generated client carries it. */
|
|
10
|
+
type SkippedWebhookChange = {
|
|
11
|
+
action: "skip";
|
|
12
|
+
id: string;
|
|
13
|
+
skipped: string;
|
|
14
|
+
webhook: WebhookState;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type WebhookChange =
|
|
18
|
+
| PreviewSyncWebhooksResponse["changes"][number]
|
|
19
|
+
| SkippedWebhookChange;
|
|
20
|
+
|
|
21
|
+
/** Neither an unmanaged nor a skipped webhook is written. */
|
|
22
|
+
const isWrite = (change: WebhookChange): boolean =>
|
|
23
|
+
change.action !== "unmanaged" && change.action !== "skip";
|
|
6
24
|
|
|
7
25
|
/** One env's webhook lane: the server's diff for that env. */
|
|
8
26
|
export type WebhooksPreview = {
|
|
@@ -15,8 +33,7 @@ export const webhooksHaveWork = ({
|
|
|
15
33
|
webhooks,
|
|
16
34
|
}: {
|
|
17
35
|
webhooks: WebhooksPreview | undefined;
|
|
18
|
-
}): boolean =>
|
|
19
|
-
(webhooks?.changes ?? []).some((change) => change.action !== "unmanaged");
|
|
36
|
+
}): boolean => (webhooks?.changes ?? []).some(isWrite);
|
|
20
37
|
|
|
21
38
|
const DETAIL_INDENT = " ";
|
|
22
39
|
|
|
@@ -76,6 +93,8 @@ const renderChange = ({ change }: { change: WebhookChange }): string[] => {
|
|
|
76
93
|
return [
|
|
77
94
|
` ${chalk.red(`- ${change.id}`)} ${chalk.bold("delete")}${chalk.dim(` ${change.webhook.url}`)}`,
|
|
78
95
|
];
|
|
96
|
+
if (change.action === "skip")
|
|
97
|
+
return [chalk.dim(` · ${change.id} skipped (would ${change.skipped})`)];
|
|
79
98
|
return [
|
|
80
99
|
chalk.dim(
|
|
81
100
|
` · ${change.id} unmanaged (not in your config; atmn leaves it alone)`,
|
|
@@ -91,9 +110,7 @@ export const renderWebhooks = ({
|
|
|
91
110
|
}): string | null => {
|
|
92
111
|
const rows = webhooks.changes.flatMap((change) => renderChange({ change }));
|
|
93
112
|
if (rows.length === 0) return null;
|
|
94
|
-
const count = webhooks.changes.filter(
|
|
95
|
-
(change) => change.action !== "unmanaged",
|
|
96
|
-
).length;
|
|
113
|
+
const count = webhooks.changes.filter(isWrite).length;
|
|
97
114
|
const heading =
|
|
98
115
|
webhooks.env === undefined
|
|
99
116
|
? `Webhooks (${count})`
|