@letterstory/cli 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli.mjs +15 -1
- package/lib/commands/connectors.mjs +77 -1
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
} from "./commands.mjs";
|
|
41
41
|
|
|
42
42
|
// Keep in sync with cli/package.json.
|
|
43
|
-
export const VERSION = "0.
|
|
43
|
+
export const VERSION = "0.13.0";
|
|
44
44
|
|
|
45
45
|
// Flags that never take a value. Listing them explicitly means `deploy get --json <id>`
|
|
46
46
|
// can't accidentally swallow the id as --json's value.
|
|
@@ -64,6 +64,10 @@ const BOOLEAN_FLAGS = new Set([
|
|
|
64
64
|
// both put a value-less flag next to a value: without these entries the parser
|
|
65
65
|
// hands the following token to the flag and the real argument disappears.
|
|
66
66
|
"regenerate",
|
|
67
|
+
// `connectors connect --provider framer --token … --auto-deploy` / `--no-auto-deploy`
|
|
68
|
+
// are value-less; without these the parser eats the following token.
|
|
69
|
+
"auto-deploy",
|
|
70
|
+
"no-auto-deploy",
|
|
67
71
|
"stock-only",
|
|
68
72
|
"gate",
|
|
69
73
|
"skip",
|
|
@@ -208,6 +212,16 @@ Connectors:
|
|
|
208
212
|
collection, reconciling (adopt/update/create/orphan).
|
|
209
213
|
--collection for a bound collection, --provider to
|
|
210
214
|
auto-resolve, or both to wire an unbound collection.
|
|
215
|
+
connectors connect --provider <p> --token <api-token>
|
|
216
|
+
Save + validate CMS credentials. framer also needs
|
|
217
|
+
--project-url (+ [--no-auto-deploy]); sanity needs
|
|
218
|
+
--project-id [--dataset]; contentful needs --space-id
|
|
219
|
+
[--environment].
|
|
220
|
+
connectors disconnect --provider <p> Forget a CMS connection (keeps imported posts)
|
|
221
|
+
connectors connections Show connection status for every provider
|
|
222
|
+
connectors mappings --provider <p> List the org's field mappings for a provider
|
|
223
|
+
connectors bind --collection <uuid> --provider <p> [--mapping <uuid>]
|
|
224
|
+
Wire a collection to a CMS + field mapping
|
|
211
225
|
|
|
212
226
|
Strategy & onboarding:
|
|
213
227
|
strategy company get | set [--name] [--domain] [--manifesto <text>|--manifesto-file <path>]
|
|
@@ -20,8 +20,20 @@ export async function cmdConnectors(ctx) {
|
|
|
20
20
|
case "pull":
|
|
21
21
|
case "import":
|
|
22
22
|
return connectorsPull(rest);
|
|
23
|
+
case "connect":
|
|
24
|
+
return connectorsConnect(rest);
|
|
25
|
+
case "disconnect":
|
|
26
|
+
return connectorsDisconnect(rest);
|
|
27
|
+
case "connections":
|
|
28
|
+
return connectorsConnections(rest);
|
|
29
|
+
case "mappings":
|
|
30
|
+
return connectorsMappings(rest);
|
|
31
|
+
case "bind":
|
|
32
|
+
return connectorsBind(rest);
|
|
23
33
|
default:
|
|
24
|
-
throw new CliError(
|
|
34
|
+
throw new CliError(
|
|
35
|
+
`Unknown connectors subcommand: ${sub ?? "(none)"}. Try: list, publish, status, pull, connect, disconnect, connections, mappings, bind`
|
|
36
|
+
);
|
|
25
37
|
}
|
|
26
38
|
}
|
|
27
39
|
|
|
@@ -81,3 +93,67 @@ async function connectorsPull(ctx) {
|
|
|
81
93
|
printResult(io, flags, result);
|
|
82
94
|
return 0;
|
|
83
95
|
}
|
|
96
|
+
|
|
97
|
+
async function connectorsConnect(ctx) {
|
|
98
|
+
const { client, flags, io } = ctx;
|
|
99
|
+
const provider = requireFlag(flags, "provider");
|
|
100
|
+
// api_token is required for every provider; the rest are provider-specific.
|
|
101
|
+
const args = compact({
|
|
102
|
+
provider,
|
|
103
|
+
api_token: requireFlag(flags, "token"),
|
|
104
|
+
project_url: flagStr(flags["project-url"]),
|
|
105
|
+
auto_deploy: flags["no-auto-deploy"] ? false : flagBool(flags["auto-deploy"]) || undefined,
|
|
106
|
+
project_id: flagStr(flags["project-id"]),
|
|
107
|
+
dataset: flagStr(flags.dataset),
|
|
108
|
+
project_name: flagStr(flags["project-name"]),
|
|
109
|
+
workspace_name: flagStr(flags.workspace),
|
|
110
|
+
space_id: flagStr(flags["space-id"]),
|
|
111
|
+
environment_id: flagStr(flags.environment),
|
|
112
|
+
space_name: flagStr(flags["space-name"]),
|
|
113
|
+
default_locale: flagStr(flags.locale),
|
|
114
|
+
});
|
|
115
|
+
const result = await client.callTool("connect_cms", args);
|
|
116
|
+
ok(ctx, `Connected ${provider}${result?.label ? ` (${result.label})` : ""}.`);
|
|
117
|
+
printResult(io, flags, result);
|
|
118
|
+
return 0;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function connectorsDisconnect(ctx) {
|
|
122
|
+
const { client, flags, io } = ctx;
|
|
123
|
+
const provider = requireFlag(flags, "provider");
|
|
124
|
+
const result = await client.callTool("disconnect_cms", { provider });
|
|
125
|
+
ok(ctx, `Disconnected ${provider}.`);
|
|
126
|
+
printResult(io, flags, result);
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function connectorsConnections(ctx) {
|
|
131
|
+
const { client, flags, io } = ctx;
|
|
132
|
+
const result = await client.callTool("list_cms_connections", {});
|
|
133
|
+
printResult(io, flags, result);
|
|
134
|
+
return 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function connectorsMappings(ctx) {
|
|
138
|
+
const { client, flags, io } = ctx;
|
|
139
|
+
const provider = requireFlag(flags, "provider");
|
|
140
|
+
const result = await client.callTool("list_cms_mappings", { provider });
|
|
141
|
+
printResult(io, flags, result);
|
|
142
|
+
return 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function connectorsBind(ctx) {
|
|
146
|
+
const { client, flags, io } = ctx;
|
|
147
|
+
const args = compact({
|
|
148
|
+
collection_id: requireFlag(flags, "collection"),
|
|
149
|
+
provider: requireFlag(flags, "provider"),
|
|
150
|
+
mapping_id: flagStr(flags.mapping),
|
|
151
|
+
});
|
|
152
|
+
const result = await client.callTool("bind_collection_cms", args);
|
|
153
|
+
ok(
|
|
154
|
+
ctx,
|
|
155
|
+
`Bound collection ${result?.collection_id ?? ""} to ${result?.provider ?? ""} (mapping ${result?.mapping_id ?? ""}).`
|
|
156
|
+
);
|
|
157
|
+
printResult(io, flags, result);
|
|
158
|
+
return 0;
|
|
159
|
+
}
|