@meltemi/diagrams-cli 0.0.0-stage → 1.9.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.
Files changed (163) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +58 -2
  3. package/dist/assets-command.d.ts +16 -0
  4. package/dist/assets-command.d.ts.map +1 -0
  5. package/dist/assets-command.js +145 -0
  6. package/dist/assets-command.js.map +1 -0
  7. package/dist/assist-command.d.ts +19 -0
  8. package/dist/assist-command.d.ts.map +1 -0
  9. package/dist/assist-command.js +268 -0
  10. package/dist/assist-command.js.map +1 -0
  11. package/dist/auth-command.d.ts +14 -0
  12. package/dist/auth-command.d.ts.map +1 -0
  13. package/dist/auth-command.js +233 -0
  14. package/dist/auth-command.js.map +1 -0
  15. package/dist/bin.d.ts +3 -0
  16. package/dist/bin.d.ts.map +1 -0
  17. package/dist/bin.js +60 -0
  18. package/dist/bin.js.map +1 -0
  19. package/dist/build-command.d.ts +23 -0
  20. package/dist/build-command.d.ts.map +1 -0
  21. package/dist/build-command.js +123 -0
  22. package/dist/build-command.js.map +1 -0
  23. package/dist/cli.d.ts +46 -0
  24. package/dist/cli.d.ts.map +1 -0
  25. package/dist/cli.js +823 -0
  26. package/dist/cli.js.map +1 -0
  27. package/dist/cloud-client.d.ts +246 -0
  28. package/dist/cloud-client.d.ts.map +1 -0
  29. package/dist/cloud-client.js +591 -0
  30. package/dist/cloud-client.js.map +1 -0
  31. package/dist/cloud-command.d.ts +56 -0
  32. package/dist/cloud-command.d.ts.map +1 -0
  33. package/dist/cloud-command.js +81 -0
  34. package/dist/cloud-command.js.map +1 -0
  35. package/dist/cloud-context.d.ts +106 -0
  36. package/dist/cloud-context.d.ts.map +1 -0
  37. package/dist/cloud-context.js +185 -0
  38. package/dist/cloud-context.js.map +1 -0
  39. package/dist/cloud-errors.d.ts +37 -0
  40. package/dist/cloud-errors.d.ts.map +1 -0
  41. package/dist/cloud-errors.js +46 -0
  42. package/dist/cloud-errors.js.map +1 -0
  43. package/dist/cloud-host.d.ts +72 -0
  44. package/dist/cloud-host.d.ts.map +1 -0
  45. package/dist/cloud-host.js +129 -0
  46. package/dist/cloud-host.js.map +1 -0
  47. package/dist/cloud-manifest.d.ts +12 -0
  48. package/dist/cloud-manifest.d.ts.map +1 -0
  49. package/dist/cloud-manifest.js +21 -0
  50. package/dist/cloud-manifest.js.map +1 -0
  51. package/dist/cloud-paths.d.ts +48 -0
  52. package/dist/cloud-paths.d.ts.map +1 -0
  53. package/dist/cloud-paths.js +104 -0
  54. package/dist/cloud-paths.js.map +1 -0
  55. package/dist/credentials.d.ts +107 -0
  56. package/dist/credentials.d.ts.map +1 -0
  57. package/dist/credentials.js +243 -0
  58. package/dist/credentials.js.map +1 -0
  59. package/dist/export-command.d.ts +35 -0
  60. package/dist/export-command.d.ts.map +1 -0
  61. package/dist/export-command.js +524 -0
  62. package/dist/export-command.js.map +1 -0
  63. package/dist/import-command.d.ts +20 -0
  64. package/dist/import-command.d.ts.map +1 -0
  65. package/dist/import-command.js +254 -0
  66. package/dist/import-command.js.map +1 -0
  67. package/dist/index.d.ts +4 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +4 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/init-command.d.ts +28 -0
  72. package/dist/init-command.d.ts.map +1 -0
  73. package/dist/init-command.js +199 -0
  74. package/dist/init-command.js.map +1 -0
  75. package/dist/login-listener.d.ts +58 -0
  76. package/dist/login-listener.d.ts.map +1 -0
  77. package/dist/login-listener.js +173 -0
  78. package/dist/login-listener.js.map +1 -0
  79. package/dist/messages/en.d.ts +533 -0
  80. package/dist/messages/en.d.ts.map +1 -0
  81. package/dist/messages/en.js +803 -0
  82. package/dist/messages/en.js.map +1 -0
  83. package/dist/messages/es.d.ts +3 -0
  84. package/dist/messages/es.d.ts.map +1 -0
  85. package/dist/messages/es.js +764 -0
  86. package/dist/messages/es.js.map +1 -0
  87. package/dist/messages/index.d.ts +442 -0
  88. package/dist/messages/index.d.ts.map +1 -0
  89. package/dist/messages/index.js +42 -0
  90. package/dist/messages/index.js.map +1 -0
  91. package/dist/messages/push-pull-en.d.ts +84 -0
  92. package/dist/messages/push-pull-en.d.ts.map +1 -0
  93. package/dist/messages/push-pull-en.js +146 -0
  94. package/dist/messages/push-pull-en.js.map +1 -0
  95. package/dist/messages/push-pull-es.d.ts +7 -0
  96. package/dist/messages/push-pull-es.d.ts.map +1 -0
  97. package/dist/messages/push-pull-es.js +144 -0
  98. package/dist/messages/push-pull-es.js.map +1 -0
  99. package/dist/open-url.d.ts +11 -0
  100. package/dist/open-url.d.ts.map +1 -0
  101. package/dist/open-url.js +36 -0
  102. package/dist/open-url.js.map +1 -0
  103. package/dist/plugins-command.d.ts +15 -0
  104. package/dist/plugins-command.d.ts.map +1 -0
  105. package/dist/plugins-command.js +106 -0
  106. package/dist/plugins-command.js.map +1 -0
  107. package/dist/preview.d.ts +54 -0
  108. package/dist/preview.d.ts.map +1 -0
  109. package/dist/preview.js +249 -0
  110. package/dist/preview.js.map +1 -0
  111. package/dist/project-errors.d.ts +17 -0
  112. package/dist/project-errors.d.ts.map +1 -0
  113. package/dist/project-errors.js +85 -0
  114. package/dist/project-errors.js.map +1 -0
  115. package/dist/projects-command.d.ts +13 -0
  116. package/dist/projects-command.d.ts.map +1 -0
  117. package/dist/projects-command.js +85 -0
  118. package/dist/projects-command.js.map +1 -0
  119. package/dist/publish-command.d.ts +41 -0
  120. package/dist/publish-command.d.ts.map +1 -0
  121. package/dist/publish-command.js +311 -0
  122. package/dist/publish-command.js.map +1 -0
  123. package/dist/pull-command.d.ts +21 -0
  124. package/dist/pull-command.d.ts.map +1 -0
  125. package/dist/pull-command.js +300 -0
  126. package/dist/pull-command.js.map +1 -0
  127. package/dist/push-command.d.ts +31 -0
  128. package/dist/push-command.d.ts.map +1 -0
  129. package/dist/push-command.js +391 -0
  130. package/dist/push-command.js.map +1 -0
  131. package/dist/push-review.d.ts +16 -0
  132. package/dist/push-review.d.ts.map +1 -0
  133. package/dist/push-review.js +72 -0
  134. package/dist/push-review.js.map +1 -0
  135. package/dist/push-set.d.ts +126 -0
  136. package/dist/push-set.d.ts.map +1 -0
  137. package/dist/push-set.js +289 -0
  138. package/dist/push-set.js.map +1 -0
  139. package/dist/push-validation.d.ts +20 -0
  140. package/dist/push-validation.d.ts.map +1 -0
  141. package/dist/push-validation.js +70 -0
  142. package/dist/push-validation.js.map +1 -0
  143. package/dist/redact.d.ts +9 -0
  144. package/dist/redact.d.ts.map +1 -0
  145. package/dist/redact.js +22 -0
  146. package/dist/redact.js.map +1 -0
  147. package/dist/review-command.d.ts +44 -0
  148. package/dist/review-command.d.ts.map +1 -0
  149. package/dist/review-command.js +348 -0
  150. package/dist/review-command.js.map +1 -0
  151. package/package.json +56 -3
  152. package/templates/c4/diagrams/views.meltemi +16 -0
  153. package/templates/c4/models/system.meltemi +23 -0
  154. package/templates/ci/github.yml +96 -0
  155. package/templates/ci/gitlab.yml +53 -0
  156. package/templates/flow/diagrams/overview.meltemi +15 -0
  157. package/templates/free/diagrams/slide.meltemi +39 -0
  158. package/templates/purchase/diagrams/architecture.meltemi +36 -0
  159. package/templates/purchase/diagrams/executive.meltemi +52 -0
  160. package/templates/purchase/diagrams/payment.meltemi +42 -0
  161. package/templates/purchase/models/commerce.meltemi +30 -0
  162. package/templates/purchase/stories/purchase.meltemi +38 -0
  163. package/templates/sequence/diagrams/sign-in.meltemi +36 -0
@@ -0,0 +1,249 @@
1
+ import { statSync, watch } from "node:fs";
2
+ import { createServer } from "node:http";
3
+ import { relative, resolve, sep } from "node:path";
4
+ import { parseArgs } from "node:util";
5
+ import { href } from "@meltemi/diagrams-catalog";
6
+ import { buildCatalog, } from "@meltemi/diagrams-editor/node";
7
+ import { getLocale } from "@meltemi/diagrams-i18n";
8
+ import { joinPath, toProjectPath } from "@meltemi/diagrams-project";
9
+ import { argumentsError, messages } from "./messages/index.js";
10
+ import { openUrl } from "./open-url.js";
11
+ const EVENTS = "/events";
12
+ const LOCAL_HOSTS = new Set(["127.0.0.1", "localhost", "[::1]"]);
13
+ /** Whether a change under the project root can change the catalog. */
14
+ function relevant(root, file) {
15
+ const path = relative(root, file).split(sep).join("/");
16
+ if (path.split("/").some((part) => part.startsWith(".") || part === "node_modules")) {
17
+ return false;
18
+ }
19
+ return (path.endsWith(".meltemi") ||
20
+ path === "project.json" ||
21
+ path === "assets.lock.json" ||
22
+ path.startsWith("assets/") ||
23
+ /\.(svg|png|jpe?g|gif|webp)$/i.test(path));
24
+ }
25
+ /**
26
+ * Serves the catalog of a project on the loopback interface and builds it again when its files
27
+ * change; open pages reload where they were (decision 0028). Only requests addressed to this
28
+ * machine's names are answered.
29
+ */
30
+ export function startPreview(options) {
31
+ let projects = options.projects();
32
+ const workspaceOf = () => options.isFolder ? projects.forFolder(options.target) : projects.forFile(options.target);
33
+ let workspace = workspaceOf();
34
+ const root = workspace.root;
35
+ let html = "";
36
+ let builds = 0;
37
+ const clients = new Set();
38
+ const build = () => {
39
+ const result = buildCatalog(workspace, projects, {
40
+ generator: options.generator,
41
+ script: options.script,
42
+ liveReload: EVENTS,
43
+ });
44
+ html = result.html;
45
+ builds++;
46
+ options.report(result, workspace);
47
+ return result;
48
+ };
49
+ const first = build();
50
+ const rebuild = (changed = []) => {
51
+ // Settings and assets reach fonts and icons: start again from the files.
52
+ if (changed.some((p) => p === joinPath(root, "project.json") || p.includes("/assets"))) {
53
+ projects = options.projects();
54
+ workspace = workspaceOf();
55
+ }
56
+ else {
57
+ for (const path of changed)
58
+ workspace.invalidate(path);
59
+ }
60
+ build();
61
+ for (const client of clients)
62
+ client.write(`event: reload\ndata: ${builds}\n\n`);
63
+ };
64
+ const serve = (request, response) => {
65
+ const host = (request.headers.host ?? "").replace(/:\d+$/, "");
66
+ if (!LOCAL_HOSTS.has(host)) {
67
+ response.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
68
+ response.end(`${messages().preview.onlyHere}\n`);
69
+ return;
70
+ }
71
+ const path = (request.url ?? "/").split("?")[0];
72
+ if (request.method !== "GET") {
73
+ response.writeHead(405, { Allow: "GET" });
74
+ response.end();
75
+ }
76
+ else if (path === EVENTS) {
77
+ response.writeHead(200, {
78
+ "Content-Type": "text/event-stream",
79
+ "Cache-Control": "no-store",
80
+ Connection: "keep-alive",
81
+ });
82
+ response.write("retry: 1000\n\n");
83
+ clients.add(response);
84
+ request.on("close", () => clients.delete(response));
85
+ }
86
+ else if (path === "/" || path === "/index.html") {
87
+ response.writeHead(200, {
88
+ "Content-Type": "text/html; charset=utf-8",
89
+ "Cache-Control": "no-store",
90
+ "X-Content-Type-Options": "nosniff",
91
+ });
92
+ response.end(html);
93
+ }
94
+ else {
95
+ response.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" });
96
+ response.end(`${messages().preview.notFound}\n`);
97
+ }
98
+ };
99
+ return new Promise((resolvePromise, reject) => {
100
+ const server = createServer(serve);
101
+ let watcher;
102
+ let timer;
103
+ const pending = new Set();
104
+ server.once("error", reject);
105
+ server.listen(options.port, "127.0.0.1", () => {
106
+ server.off("error", reject);
107
+ try {
108
+ watcher = watch(root, { recursive: true }, (_event, name) => {
109
+ if (!name)
110
+ return;
111
+ const file = toProjectPath(joinPath(root, String(name).split(sep).join("/")));
112
+ if (!relevant(root, file))
113
+ return;
114
+ pending.add(file);
115
+ clearTimeout(timer);
116
+ timer = setTimeout(() => {
117
+ const changed = [...pending];
118
+ pending.clear();
119
+ rebuild(changed);
120
+ }, 150);
121
+ });
122
+ }
123
+ catch {
124
+ // Without file watching, the page still serves; rebuild() still works.
125
+ }
126
+ const address = server.address();
127
+ const port = typeof address === "object" && address ? address.port : options.port;
128
+ const firstDiagram = options.isFolder
129
+ ? undefined
130
+ : first.data.entries.find((e) => e.file === relative(root, options.target).split(sep).join("/"));
131
+ const route = firstDiagram
132
+ ? href(firstDiagram.kind === "story"
133
+ ? { page: "story", key: firstDiagram.key }
134
+ : { page: "diagram", key: firstDiagram.key, scenario: null, element: null })
135
+ : "";
136
+ resolvePromise({
137
+ url: `http://127.0.0.1:${port}/${route}`,
138
+ get builds() {
139
+ return builds;
140
+ },
141
+ rebuild,
142
+ close: () => new Promise((done) => {
143
+ clearTimeout(timer);
144
+ watcher?.close();
145
+ for (const client of clients)
146
+ client.end();
147
+ clients.clear();
148
+ server.close(() => done());
149
+ }),
150
+ });
151
+ });
152
+ });
153
+ }
154
+ /**
155
+ * Opens a URL in the default browser, the way `login` does (`open-url.ts`): the address is one
156
+ * argument of the opener and no shell reads it, so a `&` or a quote in it means nothing (`cmd /c
157
+ * start` ended the command at the first `&`). The preview prints its address first, so an opener
158
+ * that cannot start is not an error here. `open` is replaceable for tests.
159
+ */
160
+ export function openInBrowser(url, open = openUrl) {
161
+ try {
162
+ void open(url).catch(() => undefined);
163
+ }
164
+ catch {
165
+ // An address that is not a web address: nothing to open.
166
+ }
167
+ }
168
+ /** Prints the diagnostics of a build as the other commands do. */
169
+ export function previewReport(print, stdout, display) {
170
+ return (build) => {
171
+ const t = messages().preview;
172
+ for (const [path, diagnostics] of build.diagnostics)
173
+ print(display(path), diagnostics);
174
+ for (const entry of build.skipped) {
175
+ stdout(`${t.skipped(`${display(entry.path)}#${entry.id}`, entry.reason)}\n`);
176
+ }
177
+ const diagrams = build.data.entries.filter((e) => e.kind === "diagram").length;
178
+ const stories = build.data.entries.length - diagrams;
179
+ // The machine's clock in English, as before; Spanish writes its own.
180
+ const locale = getLocale();
181
+ const time = new Date().toLocaleTimeString(locale === "en" ? undefined : locale);
182
+ stdout(`${t.built(diagrams, stories, time)}\n`);
183
+ };
184
+ }
185
+ /** `meltemi-diagrams preview`: runs until stopped; usage errors return 2 at once. */
186
+ export function previewCommand(args, context) {
187
+ const fail = (message) => {
188
+ context.stderr(`${context.name} preview: ${message}\n`);
189
+ return 2;
190
+ };
191
+ let values;
192
+ let positionals;
193
+ try {
194
+ const parsed = parseArgs({
195
+ args: [...args],
196
+ options: {
197
+ port: { type: "string" },
198
+ open: { type: "boolean", default: false },
199
+ help: { type: "boolean", short: "h", default: false },
200
+ },
201
+ allowPositionals: true,
202
+ strict: true,
203
+ });
204
+ values = parsed.values;
205
+ positionals = parsed.positionals;
206
+ }
207
+ catch (error) {
208
+ return fail(argumentsError(error));
209
+ }
210
+ const t = messages().preview;
211
+ if (values.help) {
212
+ context.stdout(messages().help.preview);
213
+ return 0;
214
+ }
215
+ if (positionals.length > 1)
216
+ return fail(messages().common.oneProject);
217
+ const port = values.port === undefined ? 4317 : Number(values.port);
218
+ if (!Number.isInteger(port) || port < 0 || port > 65535)
219
+ return fail(t.port(values.port));
220
+ const target = toProjectPath(resolve(context.cwd, positionals[0] ?? "."));
221
+ let isFolder;
222
+ try {
223
+ isFolder = statSync(target).isDirectory();
224
+ }
225
+ catch {
226
+ return fail(messages().common.pathNotFound(positionals[0] ?? "."));
227
+ }
228
+ startPreview({
229
+ target,
230
+ isFolder,
231
+ port,
232
+ projects: context.projects,
233
+ generator: context.generator,
234
+ script: context.script,
235
+ report: previewReport(context.printDiagnostics, context.stdout, context.display),
236
+ }).then((server) => {
237
+ context.stdout(`${t.serving(server.url)}\n`);
238
+ if (values.open)
239
+ openInBrowser(server.url);
240
+ process.once("SIGINT", () => {
241
+ void server.close().then(() => process.exit(0));
242
+ });
243
+ }, (error) => {
244
+ context.stderr(`${context.name} preview: ${error.code === "EADDRINUSE" ? t.portInUse(port) : error.message}\n`);
245
+ process.exitCode = 2;
246
+ });
247
+ return 0;
248
+ }
249
+ //# sourceMappingURL=preview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.js","sourceRoot":"","sources":["../src/preview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAkB,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,SAAS,EAA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AY,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAC1D,IAAI,CACL,CAAC;QACF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC,CACF,CAAC;IACF,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * How the failures of `push` and `pull` read in the interface language (`cli-cloud`): by stable
3
+ * code, with the facts the failure carries in its `details` (a path, a count, a project id).
4
+ * `describeCloudError` (`cloud-context.ts`) asks here for every code it has no sentence of its own
5
+ * for and falls back to the failure's English message when this does not know the code either.
6
+ *
7
+ * Besides the commands' own codes (`push.*`, `pull.*`) these are the service's codes as a push or a
8
+ * pull meets them (`revision.mismatch`, `quota.files`, `quota.binary`, `doc.too-large`, ...). The
9
+ * codes that `cloud-context.ts` has sentences for (`cloud.no-project`, `pull.unsafe-path`,
10
+ * `project.not-found`, `version.not-found`, `access.denied`) are not repeated here.
11
+ */
12
+ import { CloudError } from "./cloud-errors.js";
13
+ /** The sentence of a failure of `push`, `pull` or the service as they meet it; undefined for any other code. */
14
+ export declare function describeProjectError(error: CloudError): string | undefined;
15
+ /** The same failure with more facts in its `details` (the project or version it was about). */
16
+ export declare function withDetails(error: unknown, details: Readonly<Record<string, unknown>>): unknown;
17
+ //# sourceMappingURL=project-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-errors.d.ts","sourceRoot":"","sources":["../src/project-errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAc/C,gHAAgH;AAChH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAoD1E;AAED,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAQ/F"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * How the failures of `push` and `pull` read in the interface language (`cli-cloud`): by stable
3
+ * code, with the facts the failure carries in its `details` (a path, a count, a project id).
4
+ * `describeCloudError` (`cloud-context.ts`) asks here for every code it has no sentence of its own
5
+ * for and falls back to the failure's English message when this does not know the code either.
6
+ *
7
+ * Besides the commands' own codes (`push.*`, `pull.*`) these are the service's codes as a push or a
8
+ * pull meets them (`revision.mismatch`, `quota.files`, `quota.binary`, `doc.too-large`, ...). The
9
+ * codes that `cloud-context.ts` has sentences for (`cloud.no-project`, `pull.unsafe-path`,
10
+ * `project.not-found`, `version.not-found`, `access.denied`) are not repeated here.
11
+ */
12
+ import { CloudError } from "./cloud-errors.js";
13
+ import { messages } from "./messages/index.js";
14
+ /** A detail as text: a string or a number, else `fallback`. */
15
+ function text(value, fallback = "") {
16
+ if (typeof value === "string")
17
+ return value;
18
+ return typeof value === "number" ? String(value) : fallback;
19
+ }
20
+ /** A detail as a count. */
21
+ function whole(value) {
22
+ return typeof value === "number" ? value : 0;
23
+ }
24
+ /** The sentence of a failure of `push`, `pull` or the service as they meet it; undefined for any other code. */
25
+ export function describeProjectError(error) {
26
+ const t = messages().cloud.projectErrors;
27
+ const d = error.details;
28
+ const path = text(d["path"]);
29
+ switch (error.code) {
30
+ case "revision.mismatch":
31
+ return t.revisionMismatch;
32
+ case "quota.files":
33
+ return t.quotaFiles;
34
+ case "quota.binary":
35
+ return t.quotaBinary(path);
36
+ case "quota.storage":
37
+ return t.quotaStorage;
38
+ case "quota.projects":
39
+ return t.quotaProjects;
40
+ case "doc.too-large":
41
+ return t.docTooLarge(path);
42
+ case "path.invalid":
43
+ return t.pathInvalid(path);
44
+ case "binary.invalid":
45
+ return t.binaryInvalid(path);
46
+ case "push.differs":
47
+ return t.pushDiffers(whole(d["count"]));
48
+ case "push.declined":
49
+ return t.pushDeclined;
50
+ case "push.already-linked":
51
+ return t.pushLinked(text(d["project"], "?"));
52
+ case "push.strict":
53
+ return t.pushStrict(whole(d["errors"]), whole(d["unsent"]));
54
+ case "push.manifest-invalid":
55
+ return t.pushManifestInvalid(text(d["reason"], error.message));
56
+ case "push.manifest-not-written":
57
+ return t.pushManifestNotWritten(text(d["project"], "?"), text(d["host"], "?"), text(d["reason"], error.message));
58
+ case "push.file-changed":
59
+ return t.pushFileChanged(path);
60
+ case "pull.no-project":
61
+ return t.pullNoProject;
62
+ case "pull.other-project":
63
+ return t.pullOtherProject(text(d["project"], "?"), text(d["linked"], "?"));
64
+ case "pull.not-a-folder":
65
+ return t.pullNotAFolder(path);
66
+ case "pull.manifest-not-updated":
67
+ return t.pullManifestNotUpdated(text(d["reason"], error.message));
68
+ case "pull.write":
69
+ return t.pullWrite(path, text(d["reason"], error.message));
70
+ default:
71
+ return undefined;
72
+ }
73
+ }
74
+ /** The same failure with more facts in its `details` (the project or version it was about). */
75
+ export function withDetails(error, details) {
76
+ if (!(error instanceof CloudError))
77
+ return error;
78
+ return new CloudError(error.code, error.message, {
79
+ status: error.status,
80
+ details: { ...error.details, ...details },
81
+ exitCode: error.exitCode,
82
+ ...(error.retryAfter === undefined ? {} : { retryAfter: error.retryAfter }),
83
+ });
84
+ }
85
+ //# sourceMappingURL=project-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-errors.js","sourceRoot":"","sources":["../src/project-errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,+DAA+D;AAC/D,SAAS,IAAI,CAAC,KAAc,EAAE,QAAQ,GAAG,EAAE;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC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C,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7D;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,WAAW,CAAC,KAAc,EAAE,OAA0C;IACpF,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC;QAAE,OAAO,KAAK,CAAC;IACjD,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE;QAC/C,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE;QACzC,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,GAAG,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC;KAC5E,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * `projects` (`cli-cloud`, "Projects and review against the cloud"): the person's cloud projects
3
+ * with id, name, role and last change, most recent first, as a table or as JSON.
4
+ *
5
+ * The JSON is one object whose field names are the service's own and are stable:
6
+ * `{ "host": "<origin>", "projects": [{ "id", "name", "description", "role", "updated_at" }] }`,
7
+ * `role` being `owner`, `editor` or `viewer` and `updated_at` an ISO 8601 time in UTC. The table is
8
+ * for people: its words follow the interface language, and a name that holds a control character
9
+ * (an escape sequence in a project somebody shared) is printed with spaces instead.
10
+ */
11
+ import { type CloudCommand } from "./cloud-context.js";
12
+ export declare const projectsCommand: CloudCommand;
13
+ //# sourceMappingURL=projects-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projects-command.d.ts","sourceRoot":"","sources":["../src/projects-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAgC,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAiCrF,eAAO,MAAM,eAAe,EAAE,YAmD7B,CAAC"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * `projects` (`cli-cloud`, "Projects and review against the cloud"): the person's cloud projects
3
+ * with id, name, role and last change, most recent first, as a table or as JSON.
4
+ *
5
+ * The JSON is one object whose field names are the service's own and are stable:
6
+ * `{ "host": "<origin>", "projects": [{ "id", "name", "description", "role", "updated_at" }] }`,
7
+ * `role` being `owner`, `editor` or `viewer` and `updated_at` an ISO 8601 time in UTC. The table is
8
+ * for people: its words follow the interface language, and a name that holds a control character
9
+ * (an escape sequence in a project somebody shared) is printed with spaces instead.
10
+ */
11
+ import { parseArgs } from "node:util";
12
+ import { openCloud, usage, usageError } from "./cloud-context.js";
13
+ import { EXIT_OK } from "./cloud-errors.js";
14
+ import { messages } from "./messages/index.js";
15
+ /** Text safe for a terminal: control characters (C0, DEL and C1) become spaces. */
16
+ function plain(text) {
17
+ return Array.from(text, (character) => {
18
+ const code = character.codePointAt(0);
19
+ return code < 0x20 || (code >= 0x7f && code <= 0x9f) ? " " : character;
20
+ }).join("");
21
+ }
22
+ /** A time as the table shows it: ISO 8601 in UTC to the second, `2026-10-15T09:41:02Z`. */
23
+ function shown(time) {
24
+ return plain(time.replace(/\.\d+Z$/, "Z"));
25
+ }
26
+ /** The table, columns padded to the width of their widest cell. */
27
+ function table(projects) {
28
+ const t = messages().cloud.projects;
29
+ const rows = [
30
+ [t.header.id, t.header.name, t.header.role, t.header.changed],
31
+ ...projects.map((p) => [plain(p.id), plain(p.name), t.roles[p.role], shown(p.updated_at)]),
32
+ ];
33
+ const widths = [0, 1, 2].map((column) => Math.max(...rows.map((row) => row[column].length)));
34
+ return rows
35
+ .map((row) => [...row.slice(0, 3).map((cell, i) => cell.padEnd(widths[i])), row[3]].join(" ").trimEnd())
36
+ .join("\n");
37
+ }
38
+ export const projectsCommand = async (args, context) => {
39
+ const help = messages().help.projects;
40
+ let parsed;
41
+ try {
42
+ parsed = parseArgs({
43
+ args: [...args],
44
+ options: {
45
+ json: { type: "boolean", default: false },
46
+ host: { type: "string" },
47
+ help: { type: "boolean", short: "h", default: false },
48
+ },
49
+ allowPositionals: true,
50
+ strict: true,
51
+ });
52
+ }
53
+ catch (error) {
54
+ return usageError(context, error, help);
55
+ }
56
+ if (parsed.values.help) {
57
+ context.stdout(help);
58
+ return EXIT_OK;
59
+ }
60
+ if (parsed.positionals.length > 0) {
61
+ return usage(context, messages().cloud.noArguments(context.command), help);
62
+ }
63
+ const { host, client } = openCloud(context, { host: parsed.values.host });
64
+ const projects = await client.projects();
65
+ if (parsed.values.json) {
66
+ context.stdout(`${JSON.stringify({
67
+ host,
68
+ projects: projects.map((p) => ({
69
+ id: p.id,
70
+ name: p.name,
71
+ description: p.description,
72
+ role: p.role,
73
+ updated_at: p.updated_at,
74
+ })),
75
+ }, null, 2)}\n`);
76
+ return EXIT_OK;
77
+ }
78
+ if (projects.length === 0) {
79
+ context.stdout(`${messages().cloud.projects.none(context.name)}\n`);
80
+ return EXIT_OK;
81
+ }
82
+ context.stdout(`${table(projects)}\n`);
83
+ return EXIT_OK;
84
+ };
85
+ //# sourceMappingURL=projects-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projects-command.js","sourceRoot":"","sources":["../src/projects-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAqB,MAAM,oBAAoB,CAAC;AAErF,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,mFAAmF;AACnF,SAAS,KAAK,CAAC,IAAY;IACzB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,EAAE;QACpC,MAAM,IAAI,GAAG,SAAS,CAAC,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
+ * `publish` (`cli-cloud`, "Publish"): the catalog of the folder's project as a web page of the cloud
3
+ * service.
4
+ *
5
+ * The order, and why:
6
+ *
7
+ * 1. The project and the session: the folder's manifest names the cloud project (`cloud.project`,
8
+ * or `--project`), the host is `--host`, `MELTEMI_HOST` or the default, and `cloud.host-mismatch`
9
+ * and "not signed in" fail before any request.
10
+ * 2. `--unpublish` ends here: one `DELETE`, nothing is built or pushed.
11
+ * 3. `GET …/publish` first: it is the owner's, so a project the person may not publish (`access.denied`,
12
+ * `project.not-found`) fails before the catalog is built, and it says whether a handle is chosen.
13
+ * 4. The catalog is built in memory, exactly as `build catalog` builds it (same generator, same
14
+ * defaults, the `--lang` language), before anything is sent: a catalog with nothing in it, with
15
+ * errors under `--strict`, or too large for a page, fails with nothing pushed and nothing
16
+ * published.
17
+ * 5. The handle: the first publication needs one (`--handle`, or asked on a terminal). With
18
+ * `--handle` the handle is set first (`PATCH /api/account`); the service lets a token do that; a
19
+ * service that answers `403 request.forbidden` instead makes it `publish.handle-in-page`.
20
+ * 6. The folder is pushed when it differs from the cloud project: the command of `push`, with its
21
+ * comparison and its question (`--force` answers it, as in CI), so what is published is what the
22
+ * cloud holds.
23
+ * 7. `PUT …/publish`, and the public address printed on a line of its own.
24
+ */
25
+ import { type CloudCommand } from "./cloud-context.js";
26
+ /**
27
+ * The size that makes a page too large for the service, or undefined when it fits: the HTML over
28
+ * 16 MiB of UTF-8, or the request that carries it over 24 MiB (JSON escapes quotes and the like, so
29
+ * a page below the first limit can still be above the second). Checked here so that nothing is sent.
30
+ */
31
+ export declare function oversize(slug: string, html: string): number | undefined;
32
+ /** A page name made of a project's name: lower-case ASCII letters and digits with single hyphens. */
33
+ export declare function slugOf(text: string): string;
34
+ /**
35
+ * The `publish` command, with the step that pushes the folder given: `push`'s own command, which
36
+ * compares the folder with the cloud project and asks (or is forced), and answers its exit code.
37
+ */
38
+ export declare function createPublishCommand(push: CloudCommand): CloudCommand;
39
+ /** `publish`, pushing the folder with `push`'s own command. */
40
+ export declare const publishCommand: CloudCommand;
41
+ //# sourceMappingURL=publish-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish-command.d.ts","sourceRoot":"","sources":["../src/publish-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAYH,OAAO,EAIL,KAAK,YAAY,EAElB,MAAM,oBAAoB,CAAC;AAa5B;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOvE;AAKD,qGAAqG;AACrG,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU3C;AAoKD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,CAiHrE;AAED,+DAA+D;AAC/D,eAAO,MAAM,cAAc,EAAE,YAAgD,CAAC"}